Closed kanocence closed 5 months ago
Event's can be added via the template like shown in the docs.
I'm not quite sure what issue you are experiencing. Can you provide a reproduction?
Two boxes were added in MyComp.vue
. Although both have onClick
events in the console, only the box added through tres
can be triggered.
Hi @kanocence the way to add event handlers is through the template by passing the event handlers like you would do in vue. We don't provide an interface to add event handlers programmatically to objects because is not the normal flow of a TresJS app.
You could add your object to the scene graph by using primitives
and add the event handler there https://docs.tresjs.org/advanced/primitive
Description
I created a mesh using
Three.js
and added it to the scene withcontext.scene.add()
. How can I add a click event to it? Initially, I could directly writemesh.onClick = clickMesh
, but the #714 submission restricted this behavior.Suggested solution
Maybe you could extend the
context.scene
.Alternative
No response
Additional context
@tresjs/core@4.0.2
Validations