-
I am rendering few models using instancedMesh but I wanna pass some unique data to every different mesh, is there way for doing it? I know about instance attribute but I want to pass through userdata |
Beta Was this translation helpful? Give feedback.
Answered by
drcmda
Jul 23, 2021
Replies: 1 comment 2 replies
-
instancedmesh is a single object/mesh - the instances are virtual, they are not real meshes. but if you look at these https://codesandbox.io/s/instances-h873k and https://codesandbox.io/s/instanced-vertex-colors-8fo01 you'll see that you always have data to describe each instance. you can put anything in there, positions, color, sizes, ... const data = [...Array(count)].map((_, i) => ({
position: ...,
color: ...,
text: ....,
data: ....,
})
useFrame(() => {
for (let i = 0; i < data.length; i++) {
const item = data[i]
...
ref.current.setInstanceAt(i, ...) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
bhushan6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
instancedmesh is a single object/mesh - the instances are virtual, they are not real meshes. but if you look at these https://codesandbox.io/s/instances-h873k and https://codesandbox.io/s/instanced-vertex-colors-8fo01 you'll see that you always have data to describe each instance. you can put anything in there, positions, color, sizes, ...