878 tris0.96 × 0.41 × 0.93 m
Use it in code
Remix in the editorlandmine.js · 196 lines
Self-contained ES module — only depends on three. Call the factory and add the group to your scene.
/**
* Landmine — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 878 · Size (W × H × D): 0.96 × 0.41 × 0.93 m
*
* Usage:
* import { createLandmine } from './landmine.js';
*
* const model = createLandmine();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
// Deterministic vertex displacement (organic low-poly look).
function jitter(geometry, amount, seed) {
const pos = geometry.attributes.position;
const h = (a, b, c, s) => {
let x = Math.imul(a, 73856093) ^ Math.imul(b, 19349663) ^ Math.imul(c, 83492791) ^ Math.imul(s, 2654435761);
x = Math.imul(x ^ (x >>> 16), 2246822507);
x = Math.imul(x ^ (x >>> 13), 3266489909);
return ((x ^ (x >>> 16)) >>> 0) / 4294967295 - 0.5;
};
for (let i = 0; i < pos.count; i++) {
const x = pos.getX(i), y = pos.getY(i), z = pos.getZ(i);
const qx = Math.round(x * 1000), qy = Math.round(y * 1000), qz = Math.round(z * 1000);
pos.setXYZ(i, x + h(qx, qy, qz, seed) * 2 * amount, y + h(qx, qy, qz, seed + 1) * 2 * amount, z + h(qx, qy, qz, seed + 2) * 2 * amount);
}
pos.needsUpdate = true;
geometry.computeVertexNormals();
return geometry;
}
export function createLandmine() {
const root = new THREE.Group();
root.name = 'Landmine';
// Materials
const casingMat = new THREE.MeshStandardMaterial({ name: 'casing', color: 0x6b7a3a, roughness: 0.6, metalness: 0.25, flatShading: true });
const casingDarkMat = new THREE.MeshStandardMaterial({ name: 'casingDark', color: 0x464f26, roughness: 0.65, metalness: 0.3, flatShading: true });
const steelMat = new THREE.MeshStandardMaterial({ name: 'steel', color: 0x9aa2ad, roughness: 0.35, metalness: 0.75, flatShading: true });
const hazardMat = new THREE.MeshStandardMaterial({ name: 'hazard', color: 0xf5c02a, roughness: 0.55, flatShading: true });
const stripeMat = new THREE.MeshStandardMaterial({ name: 'stripe', color: 0x1d1f25, roughness: 0.7, flatShading: true });
const lightMat = new THREE.MeshStandardMaterial({ name: 'light', color: 0xff5a4a, roughness: 0.3, emissive: 0xff2a1a, emissiveIntensity: 1.4, flatShading: true });
const dirtMat = new THREE.MeshStandardMaterial({ name: 'dirt', color: 0x6a4a2c, roughness: 1, flatShading: true });
const dirtDarkMat = new THREE.MeshStandardMaterial({ name: 'dirtDark', color: 0x4e3520, roughness: 1, flatShading: true });
// Shared geometries
const boxGeo = new THREE.BoxGeometry(0.26, 0.012, 0.025);
const cylinderGeo = new THREE.CylinderGeometry(0.014, 0.014, 0.012, 6);
// Parts
const mound = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.48, 10, 3, 0, Math.PI * 2, 0, Math.PI / 2), 0.012, 4), dirtMat);
mound.name = 'mound';
mound.scale.set(1, 0.26, 1);
root.add(mound);
const dodecahedron2 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.0364, 0), 0.0073, 2), dirtMat);
dodecahedron2.position.set(0.3622, 0.0371, 0.0481);
root.add(dodecahedron2);
const dodecahedron3 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.037, 0), 0.0074, 3), dirtDarkMat);
dodecahedron3.position.set(0.3737, 0.033, 0.2797);
root.add(dodecahedron3);
const dodecahedron4 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.0316, 0), 0.0063, 4), dirtMat);
dodecahedron4.position.set(-0.0822, 0.0331, 0.3737);
root.add(dodecahedron4);
const dodecahedron5 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.0271, 0), 0.0054, 5), dirtDarkMat);
dodecahedron5.position.set(-0.3541, 0.0301, 0.1569);
root.add(dodecahedron5);
const dodecahedron6 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.0448, 0), 0.009, 6), dirtMat);
dodecahedron6.position.set(-0.3576, 0.0456, -0.2328);
root.add(dodecahedron6);
const dodecahedron7 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.0423, 0), 0.0085, 7), dirtDarkMat);
dodecahedron7.position.set(0.0014, 0.0446, -0.4053);
root.add(dodecahedron7);
const dodecahedron8 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.0382, 0), 0.0076, 8), dirtMat);
dodecahedron8.position.set(0.2355, 0.0336, -0.3883);
root.add(dodecahedron8);
const casing = new THREE.Mesh(new THREE.CylinderGeometry(0.24, 0.255, 0.15, 12), casingMat);
casing.name = 'casing';
casing.position.set(0, 0.105, 0);
root.add(casing);
const rim = new THREE.Mesh(new THREE.CylinderGeometry(0.26, 0.26, 0.03, 12), casingDarkMat);
rim.name = 'rim';
rim.position.set(0, 0.171, 0);
root.add(rim);
const cylinder11 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, 0, Math.PI / 6), hazardMat);
cylinder11.position.set(0, 0.115, 0);
root.add(cylinder11);
const cylinder12 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI / 6, Math.PI / 6), stripeMat);
cylinder12.position.set(0, 0.115, 0);
root.add(cylinder12);
const cylinder13 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI / 3, Math.PI / 6), hazardMat);
cylinder13.position.set(0, 0.115, 0);
root.add(cylinder13);
const cylinder14 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI / 2, Math.PI / 6), stripeMat);
cylinder14.position.set(0, 0.115, 0);
root.add(cylinder14);
const cylinder15 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI * 0.6667, Math.PI / 6), hazardMat);
cylinder15.position.set(0, 0.115, 0);
root.add(cylinder15);
const cylinder16 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI * 0.8333, Math.PI / 6), stripeMat);
cylinder16.position.set(0, 0.115, 0);
root.add(cylinder16);
const cylinder17 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI, Math.PI / 6), hazardMat);
cylinder17.position.set(0, 0.115, 0);
root.add(cylinder17);
const cylinder18 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI * 1.1667, Math.PI / 6), stripeMat);
cylinder18.position.set(0, 0.115, 0);
root.add(cylinder18);
const cylinder19 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI * 1.3333, Math.PI / 6), hazardMat);
cylinder19.position.set(0, 0.115, 0);
root.add(cylinder19);
const cylinder20 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI * 1.5, Math.PI / 6), stripeMat);
cylinder20.position.set(0, 0.115, 0);
root.add(cylinder20);
const cylinder21 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI * 1.6667, Math.PI / 6), hazardMat);
cylinder21.position.set(0, 0.115, 0);
root.add(cylinder21);
const cylinder22 = new THREE.Mesh(new THREE.CylinderGeometry(0.262, 0.262, 0.045, 2, 1, true, Math.PI * 1.8333, Math.PI / 6), stripeMat);
cylinder22.position.set(0, 0.115, 0);
root.add(cylinder22);
const pressurePlate = new THREE.Mesh(new THREE.CylinderGeometry(0.15, 0.16, 0.035, 12), casingDarkMat);
pressurePlate.name = 'pressurePlate';
pressurePlate.position.set(0, 0.1975, 0);
root.add(pressurePlate);
const box24 = new THREE.Mesh(boxGeo, casingMat);
box24.position.set(0, 0.221, 0);
root.add(box24);
const box25 = new THREE.Mesh(boxGeo, casingMat);
box25.position.set(0, 0.221, 0);
box25.rotation.set(0, deg(30), 0);
root.add(box25);
const box26 = new THREE.Mesh(boxGeo, casingMat);
box26.position.set(0, 0.221, 0);
box26.rotation.set(0, deg(60), 0);
root.add(box26);
const box27 = new THREE.Mesh(boxGeo, casingMat);
box27.position.set(0, 0.221, 0);
box27.rotation.set(0, deg(90), 0);
root.add(box27);
const box28 = new THREE.Mesh(boxGeo, casingMat);
box28.position.set(0, 0.221, 0);
box28.rotation.set(0, deg(120), 0);
root.add(box28);
const box29 = new THREE.Mesh(boxGeo, casingMat);
box29.position.set(0, 0.221, 0);
box29.rotation.set(0, deg(150), 0);
root.add(box29);
const cylinder30 = new THREE.Mesh(cylinderGeo, steelMat);
cylinder30.position.set(0.1775, 0.192, 0.1025);
root.add(cylinder30);
const cylinder31 = new THREE.Mesh(cylinderGeo, steelMat);
cylinder31.position.set(0, 0.192, 0.205);
root.add(cylinder31);
const cylinder32 = new THREE.Mesh(cylinderGeo, steelMat);
cylinder32.position.set(-0.1775, 0.192, 0.1025);
root.add(cylinder32);
const cylinder33 = new THREE.Mesh(cylinderGeo, steelMat);
cylinder33.position.set(-0.1775, 0.192, -0.1025);
root.add(cylinder33);
const cylinder34 = new THREE.Mesh(cylinderGeo, steelMat);
cylinder34.position.set(0, 0.192, -0.205);
root.add(cylinder34);
const cylinder35 = new THREE.Mesh(cylinderGeo, steelMat);
cylinder35.position.set(0.1775, 0.192, -0.1025);
root.add(cylinder35);
const fuseCap = new THREE.Mesh(new THREE.CylinderGeometry(0.035, 0.045, 0.035, 8), steelMat);
fuseCap.name = 'fuseCap';
fuseCap.position.set(0, 0.2445, 0);
root.add(fuseCap);
const stalk = new THREE.Mesh(new THREE.CylinderGeometry(0.014, 0.014, 0.06, 6), steelMat);
stalk.name = 'stalk';
stalk.position.set(0, 0.292, 0);
root.add(stalk);
const bulbSocket = new THREE.Mesh(new THREE.CylinderGeometry(0.042, 0.03, 0.02, 8), casingDarkMat);
bulbSocket.name = 'bulbSocket';
bulbSocket.position.set(0, 0.327, 0);
root.add(bulbSocket);
const light = new THREE.Mesh(new THREE.SphereGeometry(0.042, 8, 6), lightMat);
light.name = 'light';
light.position.set(0, 0.367, 0);
root.add(light);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createLandmine;
Ratings & comments
0 comments
No comments yet. Share how you used this model or what could be better.
Related models
Same category or similar tags









