Replies: 5 comments
-
matrix is set automatically by threejs, see https://threejs.org/docs/#manual/en/introduction/Matrix-transformations |
Beta Was this translation helpful? Give feedback.
-
Hi @drcmda, thanks for your answer. So according with what you sent I need to set position, scale ... so matrix gets updated. The things is I'm updating only vertices, something like mesh.geometry.vertices[0].copy(newVertex1) .. |
Beta Was this translation helpful? Give feedback.
-
see https://threejs.org/docs/#manual/en/introduction/How-to-update-things they do have these little rules. r3f doesnt change any of it thats why you experience it here. you can mutate vertices, but not reset them (in buffergeom) and there are some flags you need to set to see changes. |
Beta Was this translation helpful? Give feedback.
-
"All objects by default automatically update their matrices if they have been added to the scene with ... scene.add( object ); " |
Beta Was this translation helpful? Give feedback.
-
canvas has a default scene. your content is always part of a scene. you can switch off auto matrix, its in these docs as well. <mesh matrixAutoUpdate={false} matrix={...} /> you should never imperatively add/remove stuff in react. addChild/removeChild is probably the worst thing you could do. always "render" your objects conditionally. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm rendering a triangle mesh which position is set on mesh's geometry vertices. Mesh is correctly rendered at the position specified on vertices but the mesh.matrixWorld always returns [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]. I tried adding a new mesh to scene on every render (useFrame), declaring <mesh geometry={newGeometry}>, also <mesh><geometry vertices={newVertices}>. I found on similar errors description on internet that matrixWorld gets updated when mesh is added to scene with scene.add(mesh), I tried that too like: const { scene} = useThree() and scene.add(getNewMesh(vertices)) with no success.
Beta Was this translation helpful? Give feedback.
All reactions