Adding mesh objects dynamically with Vue's reactive objects. #950
Unanswered
EricTheRay
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was looking into incorporating Three.js into my Vue (or possibly Nuxt) project, and then found TresJS. I like the idea of making canvas, scenes and meshes declarative, without having to initialize them with extra lines of code. However, I want to add objects (meshes) to the scene dynamically; that is to say, spawn objects and add them to the scene anytime needed. I tried maintaining a Vue reactive object, containing all objects I want to render in the canvas, and then have the TresMesh component iterate through it (v-for), but it didn't seem to work as I expected.
The code is as below:
To be specific, when I delete an object from the said reactive object, the related mesh does not leave the canvas. Also, if I alter object.position, the mesh does not move accordingly.
I really like the simplicity brought by TresJS, and would like to use it in my project. Please let me know if what I want to achieve can be done by the above method, or if it can only be done the regular Three.js way. Thank you all.
Beta Was this translation helpful? Give feedback.
All reactions