I would like to put buttons inside my model, so that they seem like part of the device, but when I open it in Quicklook, something is obstructing the button click.
When I move the button outside of the bounds of the object, then it works. I don’t have coliders on the base model, so not sure what is obstructing the button from receiving an event.
Hi Tomislav, thanks for your detailed explanation. It sounds like your base model’s mesh is intercepting raycasts, so when your buttons are placed inside the model, the pointer events hit the base model instead of reaching the buttons. Although you don’t have explicit colliders on your base model, its mesh still participates in raycasting (see how raycasting is used in Needle Engine at RaycastUtils.d.ts.md).
A common solution in these cases is to disable pointer interactions on the base model’s mesh. You can do this by traversing the base model’s children and overriding the mesh’s raycast method so it doesn’t respond to clicks. For example, you can attach a component like this:
import { Behaviour } from "@needle-tools/engine";
import { Mesh } from "three";
export class DisableBaseMeshRaycast extends Behaviour {
awake() {
// Traverse all descendants
this.gameObject.traverse(child => {
if(child instanceof Mesh) {
// Disable raycasting on the base mesh
child.raycast = () => {};
}
});
}
}
Attach this component to your base model. This ensures that your base mesh won’t block pointer events, letting your button components receive clicks even when they remain inside the model.
If you still need the base model for visual purposes but want it to ignore pointer events, you could also consider using layers or marking the object so your raycaster ignores it. This approach should help resolve the issue you’re experiencing in Quicklook.
Give this a try and let me know if you have further questions!
4 replies left
thread_Fz9wNhJT9DsuXJwQiXsSsIKa
Reply to this post directly if you need further help (bottom right button)
I have set all objects that don’t need raycasting to the IgnoreRaycast Layer in Unity, but in Quicklook, the buttons are still blocked.
Use case is that I have model of the car, and would like to click on the doors, hood and some other parts, but when I put Everywhere action on body part it is not clickable like something is blocking raycast.
Is there any solution for this?