Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
188
rated 0 times [  193] [ 5]  / answers: 1 / hits: 102675  / 12 Years ago, tue, january 8, 2013, 12:00:00

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


I've tried:


// mesh is an instance of THREE.Mesh
// scene is an instance of THREE.Scene
scene.add(mesh)
scene.updateMatrixWorld(true)
mesh.matrixWorld.setPosition(new THREE.Vector3(100, 100, 100))
scene.updateMatrix()

BUT it didn't affect anything.


What should I do ?


More From » three.js

 Answers
5

I would recommend you to check the documentation 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 the property ".position". Click on ".position" to see what data-type it is. Paha..its Vector3.


So try to do the following:


// scene is an instance of THREE.Scene
scene.add(mesh);
mesh.position.set(100, 100, 100);

[#81001] Monday, January 7, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maureen

Total Points: 151
Total Questions: 110
Total Answers: 110

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
maureen questions
Mon, Oct 11, 21, 00:00, 3 Years ago
Wed, Jun 30, 21, 00:00, 3 Years ago
Thu, Apr 15, 21, 00:00, 3 Years ago
Tue, Mar 16, 21, 00:00, 3 Years ago
Mon, Dec 7, 20, 00:00, 4 Years ago
;