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

前端 未结 3 2047
无人共我
无人共我 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:38

    i would recommend you to check the documenation over here: http://threejs.org/docs/#Reference/Objects/Mesh As you can see on the top of the docu-page, Mesh inherits from "Object3D". That means that you can use all methods or properties that are provided by Object3D. So click on the "Object3D" link on the docu-page and check the properties list. You will find propertie ".position". Click on ".position" to see what data-type it is. Paha..its Vector3.

    So try to do the following:

    //scene is a THREE.Scene
    scene.add(mesh);
    mesh.position.set(100, 100, 100);
    

提交回复
热议问题