Skip to content

Commit

Permalink
Addons: Refactored InteractiveGroup.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Feb 16, 2024
1 parent a15b926 commit 791ed5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
18 changes: 10 additions & 8 deletions examples/jsm/interactive/InteractiveGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ const _event = { type: '', data: _pointer };

class InteractiveGroup extends Group {

constructor( renderer, camera ) {

super();
listenToPointerEvents( renderer, camera ) {

const scope = this;

const raycaster = new Raycaster();
const tempMatrix = new Matrix4();

// Pointer Events

const element = renderer.domElement;

Expand Down Expand Up @@ -60,7 +54,15 @@ class InteractiveGroup extends Group {
element.addEventListener( 'mousemove', onPointerEvent );
element.addEventListener( 'click', onPointerEvent );

// WebXR Controller Events
}

listenToXRControllerEvents( renderer ) {

const scope = this;

const raycaster = new Raycaster();
const tempMatrix = new Matrix4();

// TODO: Dispatch pointerevents too

const events = {
Expand Down
3 changes: 2 additions & 1 deletion examples/webxr_vr_layers.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@

}

const group = new InteractiveGroup( renderer, camera );
const group = new InteractiveGroup();
group.listenToXRControllerEvents( renderer );
scene.add( group );

guiMesh = new HTMLMesh( gui.domElement );
Expand Down
4 changes: 3 additions & 1 deletion examples/webxr_vr_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@
gui.add( parameters, 'thickness', 0, 1 ).onChange( onThicknessChange );
gui.domElement.style.visibility = 'hidden';

const group = new InteractiveGroup( renderer, camera );
const group = new InteractiveGroup();
group.listenToPointerEvents( renderer, camera );
group.listenToXRControllerEvents( renderer );
scene.add( group );

const mesh = new HTMLMesh( gui.domElement );
Expand Down

0 comments on commit 791ed5a

Please sign in to comment.