Factory function to create Codex Cookie Blaster in your world.
export function createAsset(THREE, options = {}) {
const group = new THREE.Group();
group.name = "Codex Cookie Blaster";
const body = new THREE.Mesh(
new THREE.BoxGeometry(1.8, 0.42, 1.8),
new THREE.MeshStandardMaterial({ color: 0xb8753b, roughness: 0.72 })
);
body.name = "cookie chassis";
body.position.y = 0.36;
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const frosting = new THREE.Mesh(
new THREE.BoxGeometry(1.48, 0.14, 1.48),
new THREE.MeshStandardMaterial({ color: 0xfff2d8, roughness: 0.38 })
);
frosting.name = "vanilla frosting plate";
frosting.position.y = 0.66;
frosting.castShadow = true;
group.add(frosting);
const barrel = new THREE.Mesh(
new THREE.BoxGeometry(0.42, 0.42, 2.15),
new THREE.MeshStandardMaterial({ color: 0x3d6f86, metalness: 0.12, roughness: 0.5 })
);
barrel.name = "sugar crystal barrel";
barrel.position.set(0, 0.92, -1.1);
barrel.castShadow = true;
group.add(barrel);
const muzzle = new THREE.Mesh(
new THREE.BoxGeometry(0.62, 0.62, 0.22),
new THREE.MeshStandardMaterial({ color: 0x94d2e5, emissive: 0x183f52, emissiveIntensity: 0.28, roughness: 0.34 })
);
muzzle.name = "glowing sugar muzzle";
muzzle.position.set(0, 0.92, -2.22);
muzzle.castShadow = true;
group.add(muzzle);
const chipMaterial = new THREE.MeshStandardMaterial({ color: 0x3b2112, roughness: 0.6 });
const chipPositions = [[-0.58, 0.76, -0.42], [0.52, 0.76, -0.22], [-0.18, 0.76, 0.34], [0.42, 0.76, 0.54], [-0.68, 0.76, 0.62]];
for (let index = 0; index < chipPositions.length; index += 1) {
const chip = new THREE.Mesh(new THREE.BoxGeometry(0.22, 0.08, 0.22), chipMaterial);
chip.name = "chocolate chip " + (index + 1);
chip.position.set(chipPositions[index][0], chipPositions[index][1], chipPositions[index][2]);
chip.rotation.y = index * 0.7;
chip.castShadow = true;
group.add(chip);
}
const coilMaterial = new THREE.MeshStandardMaterial({ color: 0xf7c948, emissive: 0x5a3c00, emissiveIntensity: 0.24, roughness: 0.42 });
for (let index = 0; index < 4; index += 1) {
const coil = new THREE.Mesh(new THREE.BoxGeometry(0.82 - index * 0.12, 0.1, 0.1), coilMaterial);
coil.name = "sugar charge stripe " + (index + 1);
coil.position.set(0, 1.18 + index * 0.13, -0.78 - index * 0.25);
coil.castShadow = true;
group.add(coil);
}
group.userData.gameplay = {
role: "weapon-pickup",
verb: "fire-sugar-burst",
readableName: "Cookie Blaster",
effect: "stuns frosting monsters with bright sugar rounds"
};
return group;
}