-
-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raycaster does not detect click on GltfModel #67
Comments
Did nobody encounter this before...? |
Hi, thanks, did you try with raycaster component ? |
Jup, here is a minimal reproducible example: https://glitch.com/edit/#!/apricot-neighborly-century After glancing over the raycaster code I assume that gltf models are not added to the list of intersect objects upon load. Is there a way to do it manually? |
I attempted to fix this. @klevron can you verify that this is correct? I don't have a local trois instance yet and purely did this by comparing the process on |
Thanks for your PR, I will handle this asap because there's another problem : raycaster component don't work with gltf because it's a group (not a mesh) and |
Hey @klevron, this issue is currently blocking a project of mine - is there any way I can support you to get this working faster? |
Hi, sorry, will handle this tomorrow |
This should work with 0.3.2, you can use : <Renderer :pointer="{ intersectRecursive: true }">
<Camera :position="{ z: 1 }" />
<Scene>
<GltfModel @click="onClick" src="..." />
</Scene>
</Renderer> Or : <Renderer>
<Camera :position="{ z: 1 }" />
<Scene>
<Raycaster intersect-recursive @click="onClick" />
<GltfModel src="..." />
</Scene>
</Renderer> |
@klevron I updated the glitch from above. Running into another issue now. In the glitch the click function for box fires twice, when I click once, while the gltf model behaves normal (see screenshot). In my other project it behaves exactly the other way around. GLTF fires twice. |
You should use : <renderer ref="renderer" antialias orbit-ctrl resize="window" :pointer="{ intersectRecursive: true }">
<camera :position="{ z: 10 }"></camera>
<scene>
<point-light :position="{ y: 50, z: 50 }"></point-light>
<box
ref="box"
:rotation="{ y: Math.PI / 4, z: Math.PI / 4 }"
@click="gotClicked('Box')"
:position="{x: 1}"
>
<lambert-material></lambert-material>
</box>
<gltf-model
ref="mars"
src="https://cdn.glitch.com/7196f70c-5654-466a-aa15-c2d49cf73ffc%2Fmars.glb?v=1622584963291"
:position="{x: -1}"
@click="gotClicked('Snickers')"
/>
</scene>
</renderer> You don't need to use Raycaster component |
@klevron thanks! |
You can use Raycaster if you need to raycast all objects (scene.children), the events props has to be set on Raycaster component : |
Great library!
When I use Raycaster it does not detect clicks on loaded Gltf-Models.
When I activate the option
intersectRecursive
and then console log the click event, theintersectObjects
list only contains meshes with a direct parent ofscene
and no loaded models.Is there a hidden attribute that has to be set in the
Gltf-Model
loading process?The text was updated successfully, but these errors were encountered: