80 tris1,28 × 3,20 × 1,25 m
Use no código
Fazer remix no editorpine-tree.js · 60 linhas
Módulo ES autocontido — depende apenas do three. Chame a factory e adicione o grupo à sua cena.
/**
* Pine Tree — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 80 · Size (W × H × D): 1.28 × 3.20 × 1.25 m
*
* Usage:
* import { createPineTree } from './pine-tree.js';
*
* const model = createPineTree();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
export function createPineTree() {
const root = new THREE.Group();
root.name = 'PineTree';
// Materials
const barkMat = new THREE.MeshStandardMaterial({ name: 'bark', color: 0x6b4a2f, roughness: 0.95, flatShading: true });
const leafMat = new THREE.MeshStandardMaterial({ name: 'leaf', color: 0x2f7d4a, roughness: 0.85, flatShading: true });
// Parts
const trunk = new THREE.Mesh(new THREE.CylinderGeometry(0.112, 0.176, 0.896, 6), barkMat);
trunk.name = 'trunk';
trunk.position.set(0, 0.448, 0);
root.add(trunk);
const tier1 = new THREE.Mesh(new THREE.ConeGeometry(0.6547, 1.0317, 7), leafMat);
tier1.name = 'tier1';
tier1.position.set(0, 1.0535, 0);
root.add(tier1);
const tier2 = new THREE.Mesh(new THREE.ConeGeometry(0.528, 1.0317, 7), leafMat);
tier2.name = 'tier2';
tier2.position.set(0, 1.597, 0);
tier2.rotation.set(0, deg(23), 0);
root.add(tier2);
const tier3 = new THREE.Mesh(new THREE.ConeGeometry(0.4013, 1.0317, 7), leafMat);
tier3.name = 'tier3';
tier3.position.set(0, 2.1406, 0);
tier3.rotation.set(0, deg(46), 0);
root.add(tier3);
const tier4 = new THREE.Mesh(new THREE.ConeGeometry(0.2746, 1.0317, 7), leafMat);
tier4.name = 'tier4';
tier4.position.set(0, 2.6842, 0);
tier4.rotation.set(0, deg(69), 0);
root.add(tier4);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createPineTree;
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









