1,5 mil tris3,25 × 0,42 × 3,20 m
Use no código
Fazer remix no editorlava-pool.js · 273 linhas
Módulo ES autocontido — depende apenas do three. Chame a factory e adicione o grupo à sua cena.
/**
* Lava Pool — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 1,486 · Size (W × H × D): 3.25 × 0.42 × 3.20 m
*
* Usage:
* import { createLavaPool } from './lava-pool.js';
*
* const model = createLavaPool();
* 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 createLavaPool() {
const root = new THREE.Group();
root.name = 'LavaPool';
// Materials
const rockMat = new THREE.MeshStandardMaterial({ name: 'rock', color: 0x3d3533, roughness: 0.95, flatShading: true });
const rockLightMat = new THREE.MeshStandardMaterial({ name: 'rockLight', color: 0x5a4f4a, roughness: 0.95, flatShading: true });
const basinMat = new THREE.MeshStandardMaterial({ name: 'basin', color: 0x2a2322, roughness: 1, flatShading: true });
const lavaMat = new THREE.MeshStandardMaterial({ name: 'lava', color: 0xff5a14, roughness: 0.5, emissive: 0xff5a14, emissiveIntensity: 0.55, flatShading: true });
const hotMat = new THREE.MeshStandardMaterial({ name: 'hot', color: 0xffa634, roughness: 0.4, emissive: 0xffa634, emissiveIntensity: 0.9, flatShading: true });
const edgeMat = new THREE.MeshStandardMaterial({ name: 'edge', color: 0xe43d0b, roughness: 0.5, emissive: 0xe43d0b, emissiveIntensity: 0.8, flatShading: true });
const bubbleMat = new THREE.MeshStandardMaterial({ name: 'bubble', color: 0xff6e30, roughness: 0.3, emissive: 0xff5a14, emissiveIntensity: 0.35, flatShading: true });
const crustMat = new THREE.MeshStandardMaterial({ name: 'crust', color: 0x2b1d1a, roughness: 0.9, flatShading: true });
// Parts
const basin = new THREE.Mesh(new THREE.CylinderGeometry(1.45, 1.5, 0.12, 14), basinMat);
basin.name = 'basin';
basin.position.set(0, 0.06, 0);
root.add(basin);
const lava = new THREE.Mesh(new THREE.CylinderGeometry(1.32, 1.32, 0.05, 14), lavaMat);
lava.name = 'lava';
lava.position.set(0, 0.135, 0);
root.add(lava);
const moltenEdge = new THREE.Mesh(new THREE.TorusGeometry(1.3, 0.035, 3, 20), edgeMat);
moltenEdge.name = 'moltenEdge';
moltenEdge.position.set(0, 0.16, 0);
moltenEdge.rotation.set(deg(90), 0, 0);
root.add(moltenEdge);
const swirls = new THREE.Group();
swirls.name = 'swirls';
root.add(swirls);
const cylinder5 = new THREE.Mesh(new THREE.CylinderGeometry(0.2748, 0.2258, 0.012, 7), hotMat);
cylinder5.position.set(0.0452, 0.166, 0.0298);
cylinder5.rotation.set(0, deg(38.5689), 0);
cylinder5.scale.set(1, 1, 0.4972);
swirls.add(cylinder5);
const cylinder6 = new THREE.Mesh(new THREE.CylinderGeometry(0.3039, 0.1813, 0.012, 7), hotMat);
cylinder6.position.set(-0.753, 0.166, -0.0572);
cylinder6.rotation.set(0, deg(37.5719), 0);
cylinder6.scale.set(1, 1, 0.6126);
swirls.add(cylinder6);
const cylinder7 = new THREE.Mesh(new THREE.CylinderGeometry(0.3059, 0.2508, 0.012, 7), hotMat);
cylinder7.position.set(0.6687, 0.166, 0.4025);
cylinder7.rotation.set(0, deg(9.9581), 0);
cylinder7.scale.set(1, 1, 0.6224);
swirls.add(cylinder7);
const cylinder8 = new THREE.Mesh(new THREE.CylinderGeometry(0.3278, 0.2119, 0.012, 7), hotMat);
cylinder8.position.set(-0.4959, 0.166, 0.153);
cylinder8.rotation.set(0, deg(41.4329), 0);
cylinder8.scale.set(1, 1, 0.6538);
swirls.add(cylinder8);
const crust = new THREE.Group();
crust.name = 'crust';
root.add(crust);
const cylinder10 = new THREE.Mesh(jitter(new THREE.CylinderGeometry(0.0957, 0.1126, 0.035, 6), 0.0113, 3), crustMat);
cylinder10.position.set(0.8989, 0.1675, -0.227);
cylinder10.rotation.set(0, deg(128.7512), 0);
cylinder10.scale.set(1, 1, 0.75);
crust.add(cylinder10);
const cylinder11 = new THREE.Mesh(jitter(new THREE.CylinderGeometry(0.1493, 0.1757, 0.035, 6), 0.0176, 4), crustMat);
cylinder11.position.set(0.0785, 0.1675, 0.7601);
cylinder11.rotation.set(0, deg(137.7167), 0);
cylinder11.scale.set(1, 1, 0.75);
crust.add(cylinder11);
const cylinder12 = new THREE.Mesh(jitter(new THREE.CylinderGeometry(0.1289, 0.1517, 0.035, 6), 0.0152, 5), crustMat);
cylinder12.position.set(-0.9547, 0.1675, -0.312);
cylinder12.rotation.set(0, deg(146.0869), 0);
cylinder12.scale.set(1, 1, 0.75);
crust.add(cylinder12);
const cylinder13 = new THREE.Mesh(jitter(new THREE.CylinderGeometry(0.1061, 0.1249, 0.035, 6), 0.0125, 6), crustMat);
cylinder13.position.set(0.0982, 0.1675, -0.5828);
cylinder13.rotation.set(0, deg(93.1076), 0);
cylinder13.scale.set(1, 1, 0.75);
crust.add(cylinder13);
const rim = new THREE.Group();
rim.name = 'rim';
root.add(rim);
const dodecahedron15 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.259, 0), 0.0259, 1), rockLightMat);
dodecahedron15.position.set(1.3548, 0.2049, 0.0859);
dodecahedron15.rotation.set(deg(6.5157), deg(-15.4784), deg(-1.6909));
dodecahedron15.scale.set(1.2024, 0.7613, 0.9136);
rim.add(dodecahedron15);
const dodecahedron16 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.1896, 0), 0.019, 2), rockMat);
dodecahedron16.position.set(1.305, 0.1644, 0.495);
dodecahedron16.rotation.set(deg(-7.9201), deg(-17.4871), deg(0.4823));
dodecahedron16.scale.set(1.17, 0.8241, 1.0051);
rim.add(dodecahedron16);
const dodecahedron17 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2073, 0), 0.0207, 3), rockMat);
dodecahedron17.position.set(1.0877, 0.1308, 0.8591);
dodecahedron17.rotation.set(deg(-4.7681), deg(-32.392), deg(-6.6365));
dodecahedron17.scale.set(1.0732, 0.6132, 0.8522);
rim.add(dodecahedron17);
const dodecahedron18 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2578, 0), 0.0258, 4), rockLightMat);
dodecahedron18.position.set(0.7851, 0.1691, 1.1084);
dodecahedron18.rotation.set(deg(3.7096), deg(-52.6319), deg(-3.0854));
dodecahedron18.scale.set(1.1737, 0.6458, 0.8846);
rim.add(dodecahedron18);
const dodecahedron19 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2484, 0), 0.0248, 5), rockMat);
dodecahedron19.position.set(0.5095, 0.1926, 1.2646);
dodecahedron19.rotation.set(deg(-7.6277), deg(-81.3988), deg(2.6022));
dodecahedron19.scale.set(1.1831, 0.8098, 0.9913);
rim.add(dodecahedron19);
const dodecahedron20 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.1947, 0), 0.0195, 6), rockMat);
dodecahedron20.position.set(-0.0291, 0.1209, 1.3926);
dodecahedron20.rotation.set(deg(0.8923), deg(-71.4064), deg(-7.6357));
dodecahedron20.scale.set(1.1037, 0.66, 0.8973);
rim.add(dodecahedron20);
const dodecahedron21 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2186, 0), 0.0219, 7), rockLightMat);
dodecahedron21.position.set(-0.4693, 0.1668, 1.2975);
dodecahedron21.rotation.set(deg(2.8792), deg(-90.7692), deg(4.6883));
dodecahedron21.scale.set(1.0279, 0.8413, 0.966);
rim.add(dodecahedron21);
const dodecahedron22 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.1921, 0), 0.0192, 8), rockMat);
dodecahedron22.position.set(-0.8804, 0.1565, 1.0813);
dodecahedron22.rotation.set(deg(1.404), deg(-121.0686), deg(3.291));
dodecahedron22.scale.set(1.0156, 0.796, 0.9742);
rim.add(dodecahedron22);
const dodecahedron23 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2276, 0), 0.0228, 9), rockMat);
dodecahedron23.position.set(-1.1247, 0.1669, 0.7906);
dodecahedron23.rotation.set(deg(7.5531), deg(-136.1484), deg(-6.5773));
dodecahedron23.scale.set(1.0559, 0.7851, 0.8912);
rim.add(dodecahedron23);
const dodecahedron24 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2565, 0), 0.0257, 10), rockLightMat);
dodecahedron24.position.set(-1.2665, 0.1664, 0.4926);
dodecahedron24.rotation.set(deg(-3.6955), deg(-178.2803), deg(5.3039));
dodecahedron24.scale.set(1.0394, 0.7102, 0.8626);
rim.add(dodecahedron24);
const dodecahedron25 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.1979, 0), 0.0198, 11), rockMat);
dodecahedron25.position.set(-1.3911, 0.1672, -0.0114);
dodecahedron25.rotation.set(deg(-4.207), deg(-179.1045), deg(-6.6871));
dodecahedron25.scale.set(1.1463, 0.828, 0.8794);
rim.add(dodecahedron25);
const dodecahedron26 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2188, 0), 0.0219, 12), rockMat);
dodecahedron26.position.set(-1.3127, 0.1586, -0.4247);
dodecahedron26.rotation.set(deg(-6.1829), deg(-192.7743), deg(-1.4056));
dodecahedron26.scale.set(1.1505, 0.7129, 0.8535);
rim.add(dodecahedron26);
const dodecahedron27 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2183, 0), 0.0218, 13), rockLightMat);
dodecahedron27.position.set(-1.1169, 0.1479, -0.8105);
dodecahedron27.rotation.set(deg(-4.0648), deg(-204.4168), deg(0.6366));
dodecahedron27.scale.set(1.0294, 0.8047, 1.0327);
rim.add(dodecahedron27);
const dodecahedron28 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.1977, 0), 0.0198, 14), rockMat);
dodecahedron28.position.set(-0.8423, 0.1451, -1.1073);
dodecahedron28.rotation.set(deg(-5.026), deg(-247.8456), deg(-5.5837));
dodecahedron28.scale.set(1.1153, 0.7156, 0.9572);
rim.add(dodecahedron28);
const dodecahedron29 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2015, 0), 0.0201, 15), rockMat);
dodecahedron29.position.set(-0.3601, 0.1438, -1.3417);
dodecahedron29.rotation.set(deg(-5.9917), deg(-249.7253), deg(5.4046));
dodecahedron29.scale.set(1.1807, 0.7955, 1.0035);
rim.add(dodecahedron29);
const dodecahedron30 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2622, 0), 0.0262, 16), rockLightMat);
dodecahedron30.position.set(0.0351, 0.2129, -1.3553);
dodecahedron30.rotation.set(deg(4.5755), deg(-259.2087), deg(-3.0426));
dodecahedron30.scale.set(1.0286, 0.7803, 0.8833);
rim.add(dodecahedron30);
const dodecahedron31 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2295, 0), 0.0229, 17), rockMat);
dodecahedron31.position.set(0.4309, 0.1761, -1.3044);
dodecahedron31.rotation.set(deg(-7.8243), deg(-304.2614), deg(5.5136));
dodecahedron31.scale.set(1.1667, 0.8233, 0.9075);
rim.add(dodecahedron31);
const dodecahedron32 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2592, 0), 0.0259, 18), rockMat);
dodecahedron32.position.set(0.831, 0.1588, -1.0733);
dodecahedron32.rotation.set(deg(-3.7282), deg(-322.6396), deg(-4.8828));
dodecahedron32.scale.set(1.0474, 0.6411, 1.0219);
rim.add(dodecahedron32);
const dodecahedron33 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.1773, 0), 0.0177, 19), rockLightMat);
dodecahedron33.position.set(1.147, 0.1118, -0.8071);
dodecahedron33.rotation.set(deg(-1.75), deg(-342.032), deg(-4.2707));
dodecahedron33.scale.set(1.226, 0.6699, 1.0372);
rim.add(dodecahedron33);
const dodecahedron34 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.2295, 0), 0.023, 20), rockMat);
dodecahedron34.position.set(1.3295, 0.1538, -0.3459);
dodecahedron34.rotation.set(deg(-2.7741), deg(-349.4411), deg(5.0177));
dodecahedron34.scale.set(1.0362, 0.7096, 0.9397);
rim.add(dodecahedron34);
const icosahedron35 = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.0914, 0), 0.0137, 40), rockLightMat);
icosahedron35.position.set(1.3695, 0.0914, 0.6595);
rim.add(icosahedron35);
const icosahedron36 = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.0966, 0), 0.0145, 41), rockLightMat);
icosahedron36.position.set(0.3382, 0.0846, 1.4819);
rim.add(icosahedron36);
const icosahedron37 = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.093, 0), 0.014, 42), rockLightMat);
icosahedron37.position.set(-0.9477, 0.0791, 1.1884);
rim.add(icosahedron37);
const icosahedron38 = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.1102, 0), 0.0165, 43), rockLightMat);
icosahedron38.position.set(-1.52, 0.1003, 0);
rim.add(icosahedron38);
const icosahedron39 = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.0959, 0), 0.0144, 44), rockLightMat);
icosahedron39.position.set(-0.9477, 0.0931, -1.1884);
rim.add(icosahedron39);
const icosahedron40 = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.0909, 0), 0.0136, 45), rockLightMat);
icosahedron40.position.set(0.3382, 0.0812, -1.4819);
rim.add(icosahedron40);
const icosahedron41 = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.1115, 0), 0.0167, 46), rockLightMat);
icosahedron41.position.set(1.3695, 0.1072, -0.6595);
rim.add(icosahedron41);
const bubbles = new THREE.Group();
bubbles.name = 'bubbles';
root.add(bubbles);
const bubble1 = new THREE.Mesh(new THREE.SphereGeometry(0.0802, 6, 2, 0, Math.PI * 2, 0, Math.PI / 2), bubbleMat);
bubble1.name = 'bubble1';
bubble1.position.set(0.0764, 0.156, 0.6075);
bubbles.add(bubble1);
const bubble2 = new THREE.Mesh(new THREE.SphereGeometry(0.1463, 6, 2, 0, Math.PI * 2, 0, Math.PI / 2), bubbleMat);
bubble2.name = 'bubble2';
bubble2.position.set(0.166, 0.156, -0.3257);
bubbles.add(bubble2);
const bubble3 = new THREE.Mesh(new THREE.SphereGeometry(0.0708, 6, 2, 0, Math.PI * 2, 0, Math.PI / 2), hotMat);
bubble3.name = 'bubble3';
bubble3.position.set(0.175, 0.156, 0.3899);
bubbles.add(bubble3);
const bubble4 = new THREE.Mesh(new THREE.SphereGeometry(0.1221, 6, 2, 0, Math.PI * 2, 0, Math.PI / 2), bubbleMat);
bubble4.name = 'bubble4';
bubble4.position.set(0.4173, 0.156, -0.1176);
bubbles.add(bubble4);
const bubble5 = new THREE.Mesh(new THREE.SphereGeometry(0.0867, 6, 2, 0, Math.PI * 2, 0, Math.PI / 2), bubbleMat);
bubble5.name = 'bubble5';
bubble5.position.set(-0.6832, 0.156, -0.6452);
bubbles.add(bubble5);
const popRing = new THREE.Mesh(new THREE.TorusGeometry(0.1, 0.018, 4, 12), hotMat);
popRing.name = 'popRing';
popRing.position.set(0.396, 0.17, -0.462);
popRing.rotation.set(deg(90), 0, 0);
bubbles.add(popRing);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createLavaPool;
Avaliações e comentários
0 comentário
Nenhum comentário ainda. Conte como você usou este modelo ou o que poderia melhorar.
Modelos relacionados
Mesma categoria ou tags parecidas









