Skip to content

Commit 4efcf2e

Browse files
remove indicator box for controllers (#5031)
1 parent 172446f commit 4efcf2e

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

packages/model-viewer/src/three-components/ARRenderer.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {Box3, BoxGeometry, BufferGeometry, Event as ThreeEvent, EventDispatcher, Line, Matrix4, Mesh, PerspectiveCamera, Quaternion, Vector3, WebGLRenderer, XRControllerEventType, XRTargetRaySpace, Object3D} from 'three';
16+
import {Box3, BufferGeometry, Event as ThreeEvent, EventDispatcher, Line, Matrix4, PerspectiveCamera, Quaternion, Vector3, WebGLRenderer, XRControllerEventType, XRTargetRaySpace, Object3D} from 'three';
1717
import {XREstimatedLight} from 'three/examples/jsm/webxr/XREstimatedLight.js';
1818

1919
import {CameraChangeDetails, ControlsInterface} from '../features/controls.js';
@@ -49,8 +49,6 @@ const MAX_DISTANCE = 10;
4949
const DECAY = 150;
5050
// Longer controller/hand indicator line (meters).
5151
const MAX_LINE_LENGTH = 5;
52-
// Maximum dimension of rotation indicator box on controller (meters).
53-
const BOX_SIZE = 0.1;
5452
// Axis Y in webxr.
5553
const AXIS_Y = new Vector3(0, 1, 0);
5654
// Webxr rotation sensitivity
@@ -83,7 +81,6 @@ export interface ARTrackingEvent extends ThreeEvent {
8381

8482
interface UserData {
8583
turning: boolean
86-
box: Mesh
8784
line: Line
8885
isSelected: boolean
8986
initialX: number
@@ -104,7 +101,6 @@ const hitPosition = new Vector3();
104101
const camera = new PerspectiveCamera(45, 1, 0.1, 100);
105102
const lineGeometry = new BufferGeometry().setFromPoints(
106103
[new Vector3(0, 0, 0), new Vector3(0, 0, -1)]);
107-
const boxGeometry = new BoxGeometry();
108104

109105
export class ARRenderer extends EventDispatcher<
110106
{status: {status: ARStatus}, tracking: {status: ARTracking}}> {
@@ -337,19 +333,6 @@ export class ARRenderer extends EventDispatcher<
337333
this.scaleLine.name = 'scale line';
338334
this.scaleLine.visible = false;
339335
this.controller1.add(this.scaleLine);
340-
341-
const {size} = scene;
342-
const scale = BOX_SIZE / Math.max(size.x, size.y, size.z);
343-
const box = new Mesh(boxGeometry);
344-
box.name = 'box';
345-
box.scale.copy(size).multiplyScalar(scale);
346-
box.visible = false;
347-
348-
this.controller1.userData.box = box;
349-
scene.add(box);
350-
const box2 = box.clone();
351-
this.controller2.userData.box = box2;
352-
scene.add(box2);
353336
}
354337
}
355338

@@ -362,10 +345,7 @@ export class ARRenderer extends EventDispatcher<
362345

363346
const scene = this.presentedScene!;
364347
const intersection =
365-
this.placementBox!.controllerIntersection(scene, controller)
366-
controller.userData.box.visible =
367-
(intersection == null || controller.userData.turning) &&
368-
!this.isTwoFingering;
348+
this.placementBox!.controllerIntersection(scene, controller);
369349
controller.userData.line.scale.z =
370350
intersection == null ? MAX_LINE_LENGTH : intersection.distance;
371351
return intersection != null;
@@ -592,7 +572,6 @@ export class ARRenderer extends EventDispatcher<
592572
if (this.xrMode !== 'screen-space') {
593573
if (this.controller1 != null) {
594574
this.controller1.userData.turning = false;
595-
this.controller1.userData.box.visible = false;
596575
this.controller1.userData.line.visible = true;
597576
this.controller1.removeEventListener(
598577
'selectstart', this.onControllerSelectStart);
@@ -603,7 +582,6 @@ export class ARRenderer extends EventDispatcher<
603582
}
604583
if (this.controller2 != null) {
605584
this.controller2.userData.turning = false;
606-
this.controller2.userData.box.visible = false;
607585
this.controller2.userData.line.visible = true;
608586
this.controller2.removeEventListener(
609587
'selectstart', this.onControllerSelectStart);

0 commit comments

Comments
 (0)