-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
ArcballControls: Expose raycaster. #22719
Conversation
@danielefornari Looking good? |
Yeah, sounds good! |
We should probably follow #22070 and add a |
I am okay doing that change because I can achieve what I want with that as well by extending the class ExtendedArcballControls extends ArcballControls {
constructor(...args) {
super(...args);
this.raycaster = new Raycaster();
}
getRaycaster() {
return this.raycaster;
}
} Another possible solution would be to do something like this in my code: const controls = new ArcballControls();
const raycaster = controls.getRaycaster();
raycaster.layers.enable(4); // For example However, I have multiple canvases on one page and if I would use multiple Let me know what you think. It's more a question, I am happy to make the change because I can achieve what I want with the first example that I gave. |
It's just a matter of consistency. Instead of exposing Sharing the same raycaster across multiple control instances is a different matter though. I would not adding support for this since I'm afraid there are unexpected side effects. Hence, the raycaster reference of the control class should not be writable by the application. |
But isn't this not the case when we would use the const first = new TransformControls(
new OrthographicCamera(),
document.createElement("canvas")
);
const second = new TransformControls(
new OrthographicCamera(),
document.createElement("canvas")
);
first.getRaycaster() === second.getRaycaster() // equals true https://codesandbox.io/s/interesting-rubin-owq9j?file=/src/index.js Should I not follow that example and make a |
Oh right, that's true. If forgot that I guess it would be good to do the same for |
That's done now 😃 |
Thanks! |
Description
This allows users to use their own raycaster (that has for example certain layers enabled/disabled). Since
unprojectOnObj
is used for the double click to focus functionality, passing in your own raycaster is useful if you want the double click to focus functionality also to work on objects that are in different layers.