Spaces:
Sleeping

File size: 1,268 Bytes
d091b2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import {Mesh,MeshLambertMaterial,CylinderGeometry,TorusGeometry,Group,BoxGeometry} from 'three';
export const viewSize=1.38,initialRotation=-.18;
function mesh(parent,shape,color,x,y,z){
  const item=new Mesh(shape,new MeshLambertMaterial({color,flatShading:true}));
  item.position.set(x,y,z);parent.add(item);return item;
}
export function makeObject(root){
  function spool(x,z,scale,color){
    const group=new Group();group.position.set(x,-.12,z);group.scale.setScalar(scale);root.add(group);
    mesh(group,new CylinderGeometry(.56,.55,1.24,28),color,0,0,0);
    for(const y of [-.68,.68]){
      mesh(group,new CylinderGeometry(.68,.68,.14,28),'#bc7e49',0,y,0);
      mesh(group,new CylinderGeometry(.65,.65,.035,28),'#e4b981',0,y+.077,0);
    }
    mesh(group,new CylinderGeometry(.118,.118,.025,18),'#493622',0,.79,0);
    for(let j=0;j<13;j++){
      const ring=mesh(group,new TorusGeometry(.554,.018,3,28),j%4===0?'#e8c285':color,0,(j-6)*.084,0);
      ring.rotation.x=Math.PI/2+.035*Math.sin(j);
    }
    return group;
  }
  const rear=spool(.5,-.43,.91,'#28405c');rear.rotation.z=-.08;
  const front=spool(-.48,.23,.79,'#b14f37');front.rotation.z=.12;
  const chalk=mesh(root,new BoxGeometry(.82,.12,.42),'#dfb85c',.74,-.64,.62);chalk.rotation.y=-.34;
}