How can I set the position of a mesh before I add it to the scene in three.js

前端 未结 3 2046
无人共我
无人共我 2020-12-25 12:19

In three.js, I want to add a mesh to a position in the scene

I\'ve tried:

// mesh is a THREE.Mesh
scene is a THREE.Scene
scene.add(mesh)
scene.update         


        
3条回答
  •  天涯浪人
    2020-12-25 12:30

    I prefer to use Vector3 to set position.

       let group = new THREE.Group();
    
       // position of box
       let vector = new THREE.Vector3(10, 10, 10);
       
         // add wooden Box
       let woodenBox = new THREE.Mesh(boxGeometry, woodMaterial);
    
        //update postion
        woodenBox.position.copy(vector);
    
      // add to scene
       group.add(woodenBox)
       this.scene.add(group);
    

提交回复
热议问题