1- import * as THREE from 'three' ;
1+ import { BufferGeometry , Float32BufferAttribute , Matrix4 , Mesh , MeshBasicMaterial , Object3D , Raycaster , SphereGeometry , Vector3 } from 'three' ;
22
33const PINCH_MAX = 0.05 ;
44const PINCH_THRESHOLD = 0.02 ;
@@ -13,13 +13,13 @@ const POINTER_LENGTH = 0.035;
1313const POINTER_SEGMENTS = 16 ;
1414const POINTER_RINGS = 12 ;
1515const POINTER_HEMISPHERE_ANGLE = 110 ;
16- const YAXIS = /* @__PURE__ */ new THREE . Vector3 ( 0 , 1 , 0 ) ;
17- const ZAXIS = /* @__PURE__ */ new THREE . Vector3 ( 0 , 0 , 1 ) ;
16+ const YAXIS = /* @__PURE__ */ new Vector3 ( 0 , 1 , 0 ) ;
17+ const ZAXIS = /* @__PURE__ */ new Vector3 ( 0 , 0 , 1 ) ;
1818
1919const CURSOR_RADIUS = 0.02 ;
2020const CURSOR_MAX_DISTANCE = 1.5 ;
2121
22- class OculusHandPointerModel extends THREE . Object3D {
22+ class OculusHandPointerModel extends Object3D {
2323
2424 constructor ( hand , controller ) {
2525
@@ -96,15 +96,15 @@ class OculusHandPointerModel extends THREE.Object3D {
9696
9797 const vertices = this . pointerGeometry . attributes . position . array ;
9898 // first ring for front face
99- const frontFaceBase = new THREE . Vector3 (
99+ const frontFaceBase = new Vector3 (
100100 POINTER_FRONT_RADIUS ,
101101 0 ,
102102 - 1 * ( POINTER_LENGTH - rearRadius )
103103 ) ;
104104 this . _drawVerticesRing ( vertices , frontFaceBase , 0 ) ;
105105
106106 // rings for rear hemisphere
107- const rearBase = new THREE . Vector3 (
107+ const rearBase = new Vector3 (
108108 Math . sin ( ( Math . PI * POINTER_HEMISPHERE_ANGLE ) / 180 ) * rearRadius ,
109109 Math . cos ( ( Math . PI * POINTER_HEMISPHERE_ANGLE ) / 180 ) * rearRadius ,
110110 0
@@ -122,22 +122,22 @@ class OculusHandPointerModel extends THREE.Object3D {
122122 // front and rear face center vertices
123123 const frontCenterIndex = POINTER_SEGMENTS * ( 1 + POINTER_RINGS ) ;
124124 const rearCenterIndex = POINTER_SEGMENTS * ( 1 + POINTER_RINGS ) + 1 ;
125- const frontCenter = new THREE . Vector3 (
125+ const frontCenter = new Vector3 (
126126 0 ,
127127 0 ,
128128 - 1 * ( POINTER_LENGTH - rearRadius )
129129 ) ;
130130 vertices [ frontCenterIndex * 3 ] = frontCenter . x ;
131131 vertices [ frontCenterIndex * 3 + 1 ] = frontCenter . y ;
132132 vertices [ frontCenterIndex * 3 + 2 ] = frontCenter . z ;
133- const rearCenter = new THREE . Vector3 ( 0 , 0 , rearRadius ) ;
133+ const rearCenter = new Vector3 ( 0 , 0 , rearRadius ) ;
134134 vertices [ rearCenterIndex * 3 ] = rearCenter . x ;
135135 vertices [ rearCenterIndex * 3 + 1 ] = rearCenter . y ;
136136 vertices [ rearCenterIndex * 3 + 2 ] = rearCenter . z ;
137137
138138 this . pointerGeometry . setAttribute (
139139 'position' ,
140- new THREE . Float32BufferAttribute ( vertices , 3 )
140+ new Float32BufferAttribute ( vertices , 3 )
141141 ) ;
142142 // verticesNeedUpdate = true;
143143
@@ -151,11 +151,11 @@ class OculusHandPointerModel extends THREE.Object3D {
151151 ) . fill ( 0 ) ;
152152 // const vertices = [];
153153 const indices = [ ] ;
154- this . pointerGeometry = new THREE . BufferGeometry ( ) ;
154+ this . pointerGeometry = new BufferGeometry ( ) ;
155155
156156 this . pointerGeometry . setAttribute (
157157 'position' ,
158- new THREE . Float32BufferAttribute ( vertices , 3 )
158+ new Float32BufferAttribute ( vertices , 3 )
159159 ) ;
160160
161161 this . _updatePointerVertices ( POINTER_REAR_RADIUS ) ;
@@ -213,27 +213,27 @@ class OculusHandPointerModel extends THREE.Object3D {
213213 POINTER_SEGMENTS * POINTER_RINGS
214214 ) ;
215215
216- const material = new THREE . MeshBasicMaterial ( ) ;
216+ const material = new MeshBasicMaterial ( ) ;
217217 material . transparent = true ;
218218 material . opacity = POINTER_OPACITY_MIN ;
219219
220220 this . pointerGeometry . setIndex ( indices ) ;
221221
222- this . pointerMesh = new THREE . Mesh ( this . pointerGeometry , material ) ;
222+ this . pointerMesh = new Mesh ( this . pointerGeometry , material ) ;
223223
224224 this . pointerMesh . position . set ( 0 , 0 , - 1 * POINTER_REAR_RADIUS ) ;
225- this . pointerObject = new THREE . Object3D ( ) ;
225+ this . pointerObject = new Object3D ( ) ;
226226 this . pointerObject . add ( this . pointerMesh ) ;
227227
228- this . raycaster = new THREE . Raycaster ( ) ;
228+ this . raycaster = new Raycaster ( ) ;
229229
230230 // create cursor
231- const cursorGeometry = new THREE . SphereGeometry ( CURSOR_RADIUS , 10 , 10 ) ;
232- const cursorMaterial = new THREE . MeshBasicMaterial ( ) ;
231+ const cursorGeometry = new SphereGeometry ( CURSOR_RADIUS , 10 , 10 ) ;
232+ const cursorMaterial = new MeshBasicMaterial ( ) ;
233233 cursorMaterial . transparent = true ;
234234 cursorMaterial . opacity = POINTER_OPACITY_MIN ;
235235
236- this . cursorObject = new THREE . Mesh ( cursorGeometry , cursorMaterial ) ;
236+ this . cursorObject = new Mesh ( cursorGeometry , cursorMaterial ) ;
237237 this . pointerObject . add ( this . cursorObject ) ;
238238
239239 this . add ( this . pointerObject ) ;
@@ -245,7 +245,7 @@ class OculusHandPointerModel extends THREE.Object3D {
245245 if ( this . raycaster ) {
246246
247247 const pointerMatrix = this . pointerObject . matrixWorld ;
248- const tempMatrix = new THREE . Matrix4 ( ) ;
248+ const tempMatrix = new Matrix4 ( ) ;
249249 tempMatrix . identity ( ) . extractRotation ( pointerMatrix ) ;
250250 this . raycaster . ray . origin . setFromMatrixPosition ( pointerMatrix ) ;
251251 this . raycaster . ray . direction . set ( 0 , 0 , - 1 ) . applyMatrix4 ( tempMatrix ) ;
@@ -372,7 +372,7 @@ class OculusHandPointerModel extends THREE.Object3D {
372372 if ( this . raycaster && ! this . attached ) {
373373
374374 const intersections = this . raycaster . intersectObjects ( objects , recursive ) ;
375- const direction = new THREE . Vector3 ( 0 , 0 , - 1 ) ;
375+ const direction = new Vector3 ( 0 , 0 , - 1 ) ;
376376 if ( intersections . length > 0 ) {
377377
378378 const intersection = intersections [ 0 ] ;
@@ -391,7 +391,7 @@ class OculusHandPointerModel extends THREE.Object3D {
391391
392392 setCursor ( distance ) {
393393
394- const direction = new THREE . Vector3 ( 0 , 0 , - 1 ) ;
394+ const direction = new Vector3 ( 0 , 0 , - 1 ) ;
395395 if ( this . raycaster && ! this . attached ) {
396396
397397 this . cursorObject . position . copy ( direction . multiplyScalar ( distance ) ) ;
0 commit comments