Skip to content
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

Merged
merged 4 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/js/controls/ArcballControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2323,11 +2323,10 @@

this.unprojectOnObj = ( cursor, camera ) => {

const raycaster = new THREE.Raycaster();
raycaster.near = camera.near;
raycaster.far = camera.far;
raycaster.setFromCamera( cursor, camera );
const intersect = raycaster.intersectObjects( this.scene.children, true );
this.raycaster.near = camera.near;
this.raycaster.far = camera.far;
this.raycaster.setFromCamera( cursor, camera );
const intersect = this.raycaster.intersectObjects( this.scene.children, true );

for ( let i = 0; i < intersect.length; i ++ ) {

Expand Down Expand Up @@ -2681,6 +2680,7 @@
this.domElement = domElement;
this.scene = scene;
this.target = new THREE.Vector3( 0, 0, 0 );
this.raycaster = new Raycaster();
this.mouseActions = [];
this._mouseOp = null; //global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)

Expand Down
10 changes: 5 additions & 5 deletions examples/jsm/controls/ArcballControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ArcballControls extends Object3D {
this.domElement = domElement;
this.scene = scene;
this.target = new Vector3( 0, 0, 0 );
this.raycaster = new Raycaster();

this.mouseActions = [];
this._mouseOp = null;
Expand Down Expand Up @@ -2817,12 +2818,11 @@ class ArcballControls extends Object3D {
*/
unprojectOnObj = ( cursor, camera ) => {

const raycaster = new Raycaster();
raycaster.near = camera.near;
raycaster.far = camera.far;
raycaster.setFromCamera( cursor, camera );
this.raycaster.near = camera.near;
this.raycaster.far = camera.far;
this.raycaster.setFromCamera( cursor, camera );

const intersect = raycaster.intersectObjects( this.scene.children, true );
const intersect = this.raycaster.intersectObjects( this.scene.children, true );

for ( let i = 0; i < intersect.length; i ++ ) {

Expand Down