text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("../loaders/GLTFLoader.cjs.js"),o=require("@webxr-input-profiles/motion-controllers");function n(){e.Object3D.call(this),this.motionController=null,this.envMap=null}function r(t,n){!function(t,n){Object.values(t.components).forEach((t=>{const{type:r,touchPointNodeName:s,visualResponses:a}=t;if(r===o.Constants.ComponentType.TOUCHPAD)if(t.touchPointNode=n.getObjectByName(s),t.touchPointNode){const o=new e.SphereGeometry(.001),n=new e.MeshBasicMaterial({color:255}),r=new e.Mesh(o,n);t.touchPointNode.add(r)}else console.warn(`Could not find touch dot, ${t.touchPointNodeName}, in touchpad component ${t.id}`);Object.values(a).forEach((e=>{const{valueNodeName:t,minNodeName:r,maxNodeName:s,valueNodeProperty:a}=e;if(a===o.Constants.VisualResponseProperty.TRANSFORM){if(e.minNode=n.getObjectByName(r),e.maxNode=n.getObjectByName(s),!e.minNode)return void console.warn(`Could not find ${r} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${s} in the model`)}e.valueNode=n.getObjectByName(t),e.valueNode||console.warn(`Could not find ${t} in the model`)}))}))}(t.motionController,n),t.envMap&&n.traverse((e=>{e.isMesh&&(e.material.envMap=t.envMap,e.material.needsUpdate=!0)})),t.add(n)}n.prototype=Object.assign(Object.create(e.Object3D.prototype),{constructor:n,setEnvironmentMap:function(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this},updateMatrixWorld:function(t){e.Object3D.prototype.updateMatrixWorld.call(this,t),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((t=>{Object.values(t.visualResponses).forEach((t=>{const{valueNode:n,minNode:r,maxNode:s,value:a,valueNodeProperty:i}=t;n&&(i===o.Constants.VisualResponseProperty.VISIBILITY?n.visible=a:i===o.Constants.VisualResponseProperty.TRANSFORM&&(e.Quaternion.slerp(r.quaternion,s.quaternion,n.quaternion,a),n.position.lerpVectors(r.position,s.position,a)))}))})))}});var s=function(){function e(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new t.GLTFLoader)}return e.prototype={constructor:e,createControllerModel:function(e){const t=new n;let s=null;return e.addEventListener("connected",(e=>{const n=e.data;"tracked-pointer"===n.targetRayMode&&n.gamepad&&o.fetchProfile(n,this.path,"generic-trigger").then((({profile:e,assetPath:a})=>{t.motionController=new o.MotionController(n,e,a);const i=this._assetCache[t.motionController.assetUrl];if(i)s=i.scene.clone(),r(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),r(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}},e}();exports.XRControllerModelFactory=s;
  