summit/frontend/node_modules/three-stdlib/webxr/OculusHandPointerModel.cjs.map

1 line
16 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"file":"OculusHandPointerModel.cjs","sources":["../../src/webxr/OculusHandPointerModel.js"],"sourcesContent":["import * as THREE from 'three'\n\nconst PINCH_MAX = 0.05\nconst PINCH_THRESHOLD = 0.02\nconst PINCH_MIN = 0.01\nconst POINTER_ADVANCE_MAX = 0.02\nconst POINTER_OPACITY_MAX = 1\nconst POINTER_OPACITY_MIN = 0.4\nconst POINTER_FRONT_RADIUS = 0.002\nconst POINTER_REAR_RADIUS = 0.01\nconst POINTER_REAR_RADIUS_MIN = 0.003\nconst POINTER_LENGTH = 0.035\nconst POINTER_SEGMENTS = 16\nconst POINTER_RINGS = 12\nconst POINTER_HEMISPHERE_ANGLE = 110\nconst YAXIS = /* @__PURE__ */ new THREE.Vector3(0, 1, 0)\nconst ZAXIS = /* @__PURE__ */ new THREE.Vector3(0, 0, 1)\n\nconst CURSOR_RADIUS = 0.02\nconst CURSOR_MAX_DISTANCE = 1.5\n\nclass OculusHandPointerModel extends THREE.Object3D {\n constructor(hand, controller) {\n super()\n\n this.hand = hand\n this.controller = controller\n\n // Unused\n this.motionController = null\n this.envMap = null\n this.mesh = null\n\n this.pointerGeometry = null\n this.pointerMesh = null\n this.pointerObject = null\n\n this.pinched = false\n this.attached = false\n\n this.cursorObject = null\n\n this.raycaster = null\n\n this._onConnected = this._onConnected.bind(this)\n this._onDisconnected = this._onDisconnected.bind(this)\n this.hand.addEventListener('connected', this._onConnected)\n this.hand.addEventListener('disconnected', this._onDisconnected)\n }\n\n _onConnected(event) {\n const xrInputSource = event.data\n if (xrInputSource.hand) {\n this.visible = true\n this.xrInputSource = xrInputSource\n\n this.createPointer()\n }\n }\n\n _onDisconnected() {\n this.visible = false\n this.xrInputSource = null\n\n this.pointerGeometry?.dispose()\n this.pointerMesh?.material.dispose()\n\n this.clear()\n }\n\n _drawVerticesRing(vertices, baseVector, ringIndex) {\n const segmentVector = baseVector.clone()\n for (var i = 0; i < POINTER_SEGMENTS; i++) {\n segmentVector.applyAxisAngle(ZAXIS, (Math.PI * 2) / POINTER_SEGMENTS)\n const vid = ringIndex * POINTER_SEGMENTS + i\n vertices[3 * vid] = segmentVector.x\n vertices[3 * vid + 1] = segmentVector.y\n vertices[3 * vid + 2] = segmentVector.z\n }\n }\n\n _updatePointerVertices(rearRadius) {\n const vertices = this.pointerGeometry.attributes.position.array\n // first ring for front face\n const frontFaceBase = new THREE.Vector3(POINTER_FRONT_RADIUS, 0, -1 * (POINTER_LENGTH - rearRadius))\n this._drawVerticesRing(vertices, frontFaceBase, 0)\n\n // rings for rear hemisphere\n const rearBase = new THREE.Vector3(\n Math.sin((Math.PI * POINTER_HEMISPHERE_ANGLE) / 180) * rearRadius,\n Math.cos((Math.PI * POINTER_HEMISPHERE_ANGLE) / 180) * rearRadius,\n 0,\n )\n for (var i = 0; i < POINTER_RINGS; i++) {\n this._drawVerticesRing(vertices, rearBase, i + 1)\n rearBase.applyAxisAngle(YAXIS, (Math.PI * POINTER_HEMISPHERE_ANGLE) / 180 / (POINTER_RINGS * -2))\n }\n\n // front and rear face center vertices\n const frontCenterIndex = POINTER_SEGMENTS * (1 + POINTER_RINGS)\n const rearCenterIndex = POINTER_SEGMENTS * (1 + POINTER_RINGS) + 1\n const frontCenter = new THREE.Vector3(0, 0, -1 * (POINTER_LENGTH - rearRadius))\n vertices[frontCenterIndex * 3] = frontCenter.x\n vertices[frontCenterIndex * 3 + 1] = frontCenter.y\n vertices[frontCenterIndex * 3 + 2] = frontCenter.z\n const rearCenter = new THREE.Vector3(0, 0, rearRadius)\n vertices[rearCenterIndex * 3] = rearCenter.x\n vertices[rearCenterIndex * 3 + 1] = rearCenter.y\n vertices[rearCenterIndex * 3 + 2] = rearCenter.z\n\n this.pointerGeometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3))\n // verticesNeedUpdate = true;\n }\n\n createPointer() {\n var i, j\n const vertices = new Array(((POINTER_RINGS + 1) * POINTER_SEGMENTS + 2) * 3).fill(0)\n // const vertices = [];\n const indices = []\n this.pointerGeometry = new THREE.BufferGeometry()\n\n