diff --git a/examples/rag-doll/assets/index-TtudX2O0.js b/examples/rag-doll/assets/index-1-zgYH--.js similarity index 99% rename from examples/rag-doll/assets/index-TtudX2O0.js rename to examples/rag-doll/assets/index-1-zgYH--.js index 3009212..9b5682c 100644 --- a/examples/rag-doll/assets/index-TtudX2O0.js +++ b/examples/rag-doll/assets/index-1-zgYH--.js @@ -4080,7 +4080,7 @@ No matching component was found for: #include #include <${kE>=154?"colorspace_fragment":"encodings_fragment"}> } - `})}}function ik({opacity:i=1,radiusTop:e,radiusBottom:t,depthBuffer:n,color:s="white",distance:o=5,angle:r=.15,attenuation:g=5,anglePower:a=5}){const l=k.useRef(null),I=Qn(f=>f.size),u=Qn(f=>f.camera),d=Qn(f=>f.viewport.dpr),[A]=k.useState(()=>new nk),[p]=k.useState(()=>new H);e=e===void 0?.1:e,t=t===void 0?r*7:t,Yn(()=>{A.uniforms.spotPosition.value.copy(l.current.getWorldPosition(p)),l.current.lookAt(l.current.parent.target.getWorldPosition(p))});const b=k.useMemo(()=>{const f=new Ka(e,t,o,128,64,!0);return f.applyMatrix4(new Ee().makeTranslation(0,-o/2,0)),f.applyMatrix4(new Ee().makeRotationX(-Math.PI/2)),f},[o,e,t]);return k.createElement(k.Fragment,null,k.createElement("mesh",{ref:l,geometry:b,raycast:()=>null},k.createElement("primitive",{object:A,attach:"material","uniforms-opacity-value":i,"uniforms-lightColor-value":s,"uniforms-attenuation-value":g,"uniforms-anglePower-value":a,"uniforms-depth-value":n,"uniforms-cameraNear-value":u.near,"uniforms-cameraFar-value":u.far,"uniforms-resolution-value":n?[I.width*d,I.height*d]:[0,0]})))}const sk=k.forwardRef(({opacity:i=1,radiusTop:e,radiusBottom:t,depthBuffer:n,color:s="white",distance:o=5,angle:r=.15,attenuation:g=5,anglePower:a=5,volumetric:l=!0,debug:I=!1,children:u,...d},A)=>{const p=k.useRef(null);return k.useImperativeHandle(A,()=>p.current,[]),k.createElement("group",null,I&&p.current&&k.createElement("spotLightHelper",{args:[p.current]}),k.createElement("spotLight",WC({ref:p,angle:r,color:s,distance:o,castShadow:!0},d),l&&k.createElement(ik,{debug:I,opacity:i,radiusTop:e,radiusBottom:t,depthBuffer:n,color:s,distance:o,angle:r,attenuation:g,anglePower:a})),u&&k.cloneElement(u,{spotlightRef:p,debug:I}))});var ok={BASE_URL:"/xr/examples/rad-doll/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const qw=i=>{let e;const t=new Set,n=(I,u)=>{const d=typeof I=="function"?I(e):I;if(!Object.is(d,e)){const A=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(p=>p(e,A))}},s=()=>e,a={setState:n,getState:s,getInitialState:()=>l,subscribe:I=>(t.add(I),()=>t.delete(I)),destroy:()=>{(ok?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}},l=e=i(n,s,a);return a},rk=i=>i?qw(i):qw;var PM={exports:{}},OM={},QM={exports:{}},jM={};/** + `})}}function ik({opacity:i=1,radiusTop:e,radiusBottom:t,depthBuffer:n,color:s="white",distance:o=5,angle:r=.15,attenuation:g=5,anglePower:a=5}){const l=k.useRef(null),I=Qn(f=>f.size),u=Qn(f=>f.camera),d=Qn(f=>f.viewport.dpr),[A]=k.useState(()=>new nk),[p]=k.useState(()=>new H);e=e===void 0?.1:e,t=t===void 0?r*7:t,Yn(()=>{A.uniforms.spotPosition.value.copy(l.current.getWorldPosition(p)),l.current.lookAt(l.current.parent.target.getWorldPosition(p))});const b=k.useMemo(()=>{const f=new Ka(e,t,o,128,64,!0);return f.applyMatrix4(new Ee().makeTranslation(0,-o/2,0)),f.applyMatrix4(new Ee().makeRotationX(-Math.PI/2)),f},[o,e,t]);return k.createElement(k.Fragment,null,k.createElement("mesh",{ref:l,geometry:b,raycast:()=>null},k.createElement("primitive",{object:A,attach:"material","uniforms-opacity-value":i,"uniforms-lightColor-value":s,"uniforms-attenuation-value":g,"uniforms-anglePower-value":a,"uniforms-depth-value":n,"uniforms-cameraNear-value":u.near,"uniforms-cameraFar-value":u.far,"uniforms-resolution-value":n?[I.width*d,I.height*d]:[0,0]})))}const sk=k.forwardRef(({opacity:i=1,radiusTop:e,radiusBottom:t,depthBuffer:n,color:s="white",distance:o=5,angle:r=.15,attenuation:g=5,anglePower:a=5,volumetric:l=!0,debug:I=!1,children:u,...d},A)=>{const p=k.useRef(null);return k.useImperativeHandle(A,()=>p.current,[]),k.createElement("group",null,I&&p.current&&k.createElement("spotLightHelper",{args:[p.current]}),k.createElement("spotLight",WC({ref:p,angle:r,color:s,distance:o,castShadow:!0},d),l&&k.createElement(ik,{debug:I,opacity:i,radiusTop:e,radiusBottom:t,depthBuffer:n,color:s,distance:o,angle:r,attenuation:g,anglePower:a})),u&&k.cloneElement(u,{spotlightRef:p,debug:I}))});var ok={BASE_URL:"/xr/examples/rag-doll/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const qw=i=>{let e;const t=new Set,n=(I,u)=>{const d=typeof I=="function"?I(e):I;if(!Object.is(d,e)){const A=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(p=>p(e,A))}},s=()=>e,a={setState:n,getState:s,getInitialState:()=>l,subscribe:I=>(t.add(I),()=>t.delete(I)),destroy:()=>{(ok?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}},l=e=i(n,s,a);return a},rk=i=>i?qw(i):qw;var PM={exports:{}},OM={},QM={exports:{}},jM={};/** * @license React * use-sync-external-store-shim.production.min.js * @@ -4096,7 +4096,7 @@ No matching component was found for: * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var mp=k,pk=hk;function mk(i,e){return i===e&&(i!==0||1/i===1/e)||i!==i&&e!==e}var fk=typeof Object.is=="function"?Object.is:mk,bk=pk.useSyncExternalStore,Gk=mp.useRef,yk=mp.useEffect,Bk=mp.useMemo,vk=mp.useDebugValue;OM.useSyncExternalStoreWithSelector=function(i,e,t,n,s){var o=Gk(null);if(o.current===null){var r={hasValue:!1,value:null};o.current=r}else r=o.current;o=Bk(function(){function a(A){if(!l){if(l=!0,I=A,A=n(A),s!==void 0&&r.hasValue){var p=r.value;if(s(p,A))return u=p}return u=A}if(p=u,fk(I,A))return p;var b=n(A);return s!==void 0&&s(p,b)?p:(I=A,u=b)}var l=!1,I,u,d=t===void 0?null:t;return[function(){return a(e())},d===null?void 0:function(){return a(d())}]},[e,t,n,s]);var g=bk(i,o[0],o[1]);return yk(function(){r.hasValue=!0,r.value=g},[g]),vk(g),g};PM.exports=OM;var Zk=PM.exports;const wk=yh(Zk);var Rk={BASE_URL:"/xr/examples/rad-doll/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:Sk}=lF,{useSyncExternalStoreWithSelector:Wk}=wk;let $w=!1;const xk=i=>i;function qM(i,e=xk,t){(Rk?"production":void 0)!=="production"&&t&&!$w&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),$w=!0);const n=Wk(i.subscribe,i.getState,i.getServerState||i.getInitialState,e,t);return Sk(n),n}var qy={exports:{}},rc=typeof Reflect=="object"?Reflect:null,eR=rc&&typeof rc.apply=="function"?rc.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},TA;rc&&typeof rc.ownKeys=="function"?TA=rc.ownKeys:Object.getOwnPropertySymbols?TA=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:TA=function(e){return Object.getOwnPropertyNames(e)};function Vk(i){console&&console.warn&&console.warn(i)}var $M=Number.isNaN||function(e){return e!==e};function Ot(){Ot.init.call(this)}qy.exports=Ot;qy.exports.once=Fk;Ot.EventEmitter=Ot;Ot.prototype._events=void 0;Ot.prototype._eventsCount=0;Ot.prototype._maxListeners=void 0;var tR=10;function fp(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(Ot,"defaultMaxListeners",{enumerable:!0,get:function(){return tR},set:function(i){if(typeof i!="number"||i<0||$M(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");tR=i}});Ot.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ot.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||$M(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function eX(i){return i._maxListeners===void 0?Ot.defaultMaxListeners:i._maxListeners}Ot.prototype.getMaxListeners=function(){return eX(this)};Ot.prototype.emit=function(e){for(var t=[],n=1;n0&&(r=t[0]),r instanceof Error)throw r;var g=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw g.context=r,g}var a=o[e];if(a===void 0)return!1;if(typeof a=="function")eR(a,this,t);else for(var l=a.length,I=oX(a,l),n=0;n0&&r.length>s&&!r.warned){r.warned=!0;var g=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");g.name="MaxListenersExceededWarning",g.emitter=i,g.type=e,g.count=r.length,Vk(g)}return i}Ot.prototype.addListener=function(e,t){return tX(this,e,t,!1)};Ot.prototype.on=Ot.prototype.addListener;Ot.prototype.prependListener=function(e,t){return tX(this,e,t,!0)};function Mk(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function nX(i,e,t){var n={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},s=Mk.bind(n);return s.listener=t,n.wrapFn=s,s}Ot.prototype.once=function(e,t){return fp(t),this.on(e,nX(this,e,t)),this};Ot.prototype.prependOnceListener=function(e,t){return fp(t),this.prependListener(e,nX(this,e,t)),this};Ot.prototype.removeListener=function(e,t){var n,s,o,r,g;if(fp(t),s=this._events,s===void 0)return this;if(n=s[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(o=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){g=n[r].listener,o=r;break}if(o<0)return this;o===0?n.shift():Xk(n,o),n.length===1&&(s[e]=n[0]),s.removeListener!==void 0&&this.emit("removeListener",e,g||t)}return this};Ot.prototype.off=Ot.prototype.removeListener;Ot.prototype.removeAllListeners=function(e){var t,n,s;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),r;for(s=0;s=0;s--)this.removeListener(e,t[s]);return this};function iX(i,e,t){var n=i._events;if(n===void 0)return[];var s=n[e];return s===void 0?[]:typeof s=="function"?t?[s.listener||s]:[s]:t?Hk(s):oX(s,s.length)}Ot.prototype.listeners=function(e){return iX(this,e,!0)};Ot.prototype.rawListeners=function(e){return iX(this,e,!1)};Ot.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):sX.call(i,e)};Ot.prototype.listenerCount=sX;function sX(i){var e=this._events;if(e!==void 0){var t=e[i];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ot.prototype.eventNames=function(){return this._eventsCount>0?TA(this._events):[]};function oX(i,e){for(var t=new Array(e),n=0;ni;function qM(i,e=xk,t){(Rk?"production":void 0)!=="production"&&t&&!$w&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),$w=!0);const n=Wk(i.subscribe,i.getState,i.getServerState||i.getInitialState,e,t);return Sk(n),n}var qy={exports:{}},rc=typeof Reflect=="object"?Reflect:null,eR=rc&&typeof rc.apply=="function"?rc.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},TA;rc&&typeof rc.ownKeys=="function"?TA=rc.ownKeys:Object.getOwnPropertySymbols?TA=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:TA=function(e){return Object.getOwnPropertyNames(e)};function Vk(i){console&&console.warn&&console.warn(i)}var $M=Number.isNaN||function(e){return e!==e};function Ot(){Ot.init.call(this)}qy.exports=Ot;qy.exports.once=Fk;Ot.EventEmitter=Ot;Ot.prototype._events=void 0;Ot.prototype._eventsCount=0;Ot.prototype._maxListeners=void 0;var tR=10;function fp(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(Ot,"defaultMaxListeners",{enumerable:!0,get:function(){return tR},set:function(i){if(typeof i!="number"||i<0||$M(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");tR=i}});Ot.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ot.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||$M(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function eX(i){return i._maxListeners===void 0?Ot.defaultMaxListeners:i._maxListeners}Ot.prototype.getMaxListeners=function(){return eX(this)};Ot.prototype.emit=function(e){for(var t=[],n=1;n0&&(r=t[0]),r instanceof Error)throw r;var g=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw g.context=r,g}var a=o[e];if(a===void 0)return!1;if(typeof a=="function")eR(a,this,t);else for(var l=a.length,I=oX(a,l),n=0;n0&&r.length>s&&!r.warned){r.warned=!0;var g=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");g.name="MaxListenersExceededWarning",g.emitter=i,g.type=e,g.count=r.length,Vk(g)}return i}Ot.prototype.addListener=function(e,t){return tX(this,e,t,!1)};Ot.prototype.on=Ot.prototype.addListener;Ot.prototype.prependListener=function(e,t){return tX(this,e,t,!0)};function Mk(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function nX(i,e,t){var n={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},s=Mk.bind(n);return s.listener=t,n.wrapFn=s,s}Ot.prototype.once=function(e,t){return fp(t),this.on(e,nX(this,e,t)),this};Ot.prototype.prependOnceListener=function(e,t){return fp(t),this.prependListener(e,nX(this,e,t)),this};Ot.prototype.removeListener=function(e,t){var n,s,o,r,g;if(fp(t),s=this._events,s===void 0)return this;if(n=s[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(o=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){g=n[r].listener,o=r;break}if(o<0)return this;o===0?n.shift():Xk(n,o),n.length===1&&(s[e]=n[0]),s.removeListener!==void 0&&this.emit("removeListener",e,g||t)}return this};Ot.prototype.off=Ot.prototype.removeListener;Ot.prototype.removeAllListeners=function(e){var t,n,s;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),r;for(s=0;s=0;s--)this.removeListener(e,t[s]);return this};function iX(i,e,t){var n=i._events;if(n===void 0)return[];var s=n[e];return s===void 0?[]:typeof s=="function"?t?[s.listener||s]:[s]:t?Hk(s):oX(s,s.length)}Ot.prototype.listeners=function(e){return iX(this,e,!0)};Ot.prototype.rawListeners=function(e){return iX(this,e,!1)};Ot.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):sX.call(i,e)};Ot.prototype.listenerCount=sX;function sX(i){var e=this._events;if(e!==void 0){var t=e[i];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ot.prototype.eventNames=function(){return this._eventsCount>0?TA(this._events):[]};function oX(i,e){for(var t=new Array(e),n=0;n{if(t.data.op==="frame"){this.buffers.positions=t.data.positions,this.buffers.quaternions=t.data.quaternions,this.emit(t.data.op,t.data);return}this.emit(t.data.type,t.data)};for(const t of this.messageQueue)this.worker.postMessage(t);this.messageQueue.length=0}disableConstraint(t){let{uuid:n}=t;this.postMessage({op:"disableConstraint",uuid:n})}disableConstraintMotor(t){let{uuid:n}=t;this.postMessage({op:"disableConstraintMotor",uuid:n})}disconnect(){this.worker&&(this.worker.onmessage=null)}enableConstraint(t){let{uuid:n}=t;this.postMessage({op:"enableConstraint",uuid:n})}enableConstraintMotor(t){let{uuid:n}=t;this.postMessage({op:"enableConstraintMotor",uuid:n})}init(){const{allowSleep:t,axisIndex:n,broadphase:s,defaultContactMaterial:o,frictionGravity:r,gravity:g,iterations:a,quatNormalizeFast:l,quatNormalizeSkip:I,solver:u,tolerance:d}=this.config;this.postMessage({op:"init",props:{allowSleep:t,axisIndex:n,broadphase:s,defaultContactMaterial:o,frictionGravity:r,gravity:g,iterations:a,quatNormalizeFast:l,quatNormalizeSkip:I,solver:u,tolerance:d}})}removeBodies(t){let{uuid:n}=t;this.postMessage({op:"removeBodies",uuid:n})}removeConstraint(t){let{uuid:n}=t;this.postMessage({op:"removeConstraint",uuid:n})}removeContactMaterial(t){let{uuid:n}=t;this.postMessage({op:"removeContactMaterial",uuid:n})}removeRay(t){let{uuid:n}=t;this.postMessage({op:"removeRay",uuid:n})}removeRaycastVehicle(t){let{uuid:n}=t;this.postMessage({op:"removeRaycastVehicle",uuid:n})}removeSpring(t){let{uuid:n}=t;this.postMessage({op:"removeSpring",uuid:n})}setAllowSleep(t){let{props:n,uuid:s}=t;this.postMessage({op:"setAllowSleep",props:n,uuid:s})}setAngularDamping(t){let{props:n,uuid:s}=t;this.postMessage({op:"setAngularDamping",props:n,uuid:s})}setAngularFactor(t){let{props:n,uuid:s}=t;this.postMessage({op:"setAngularFactor",props:n,uuid:s})}setAngularVelocity(t){let{props:n,uuid:s}=t;this.postMessage({op:"setAngularVelocity",props:n,uuid:s})}setCollisionFilterGroup(t){let{props:n,uuid:s}=t;this.postMessage({op:"setCollisionFilterGroup",props:n,uuid:s})}setCollisionFilterMask(t){let{props:n,uuid:s}=t;this.postMessage({op:"setCollisionFilterMask",props:n,uuid:s})}setCollisionResponse(t){let{props:n,uuid:s}=t;this.postMessage({op:"setCollisionResponse",props:n,uuid:s})}setConstraintMotorMaxForce(t){let{props:n,uuid:s}=t;this.postMessage({op:"setConstraintMotorMaxForce",props:n,uuid:s})}setConstraintMotorSpeed(t){let{props:n,uuid:s}=t;this.postMessage({op:"setConstraintMotorSpeed",props:n,uuid:s})}setFixedRotation(t){let{props:n,uuid:s}=t;this.postMessage({op:"setFixedRotation",props:n,uuid:s})}setIsTrigger(t){let{props:n,uuid:s}=t;this.postMessage({op:"setIsTrigger",props:n,uuid:s})}setLinearDamping(t){let{props:n,uuid:s}=t;this.postMessage({op:"setLinearDamping",props:n,uuid:s})}setLinearFactor(t){let{props:n,uuid:s}=t;this.postMessage({op:"setLinearFactor",props:n,uuid:s})}setMass(t){let{props:n,uuid:s}=t;this.postMessage({op:"setMass",props:n,uuid:s})}setMaterial(t){let{props:n,uuid:s}=t;this.postMessage({op:"setMaterial",props:n,uuid:s})}setPosition(t){let{props:n,uuid:s}=t;this.postMessage({op:"setPosition",props:n,uuid:s})}setQuaternion(t){let{props:[n,s,o,r],uuid:g}=t;this.postMessage({op:"setQuaternion",props:[n,s,o,r],uuid:g})}setRaycastVehicleBrake(t){let{props:n,uuid:s}=t;this.postMessage({op:"setRaycastVehicleBrake",props:n,uuid:s})}setRaycastVehicleSteeringValue(t){let{props:n,uuid:s}=t;this.postMessage({op:"setRaycastVehicleSteeringValue",props:n,uuid:s})}setRotation(t){let{props:n,uuid:s}=t;this.postMessage({op:"setRotation",props:n,uuid:s})}setSleepSpeedLimit(t){let{props:n,uuid:s}=t;this.postMessage({op:"setSleepSpeedLimit",props:n,uuid:s})}setSleepTimeLimit(t){let{props:n,uuid:s}=t;this.postMessage({op:"setSleepTimeLimit",props:n,uuid:s})}setSpringDamping(t){let{props:n,uuid:s}=t;this.postMessage({op:"setSpringDamping",props:n,uuid:s})}setSpringRestLength(t){let{props:n,uuid:s}=t;this.postMessage({op:"setSpringRestLength",props:n,uuid:s})}setSpringStiffness(t){let{props:n,uuid:s}=t;this.postMessage({op:"setSpringStiffness",props:n,uuid:s})}setUserData(t){let{props:n,uuid:s}=t;this.postMessage({op:"setUserData",props:n,uuid:s})}setVelocity(t){let{props:n,uuid:s}=t;this.postMessage({op:"setVelocity",props:n,uuid:s})}sleep(t){let{uuid:n}=t;this.postMessage({op:"sleep",uuid:n})}step(t){var n;const{buffers:{positions:s,quaternions:o}}=this;!s.byteLength&&!o.byteLength||(n=this.worker)==null||n.postMessage({op:"step",positions:s,props:t,quaternions:o},[s.buffer,o.buffer])}subscribe(t){let{props:{id:n,target:s,type:o},uuid:r}=t;this.postMessage({op:"subscribe",props:{id:n,target:s,type:o},uuid:r})}terminate(){var t;(t=this.worker)==null||t.terminate(),this.worker=null}unsubscribe(t){let{props:n}=t;this.postMessage({op:"unsubscribe",props:n})}wakeUp(t){let{uuid:n}=t;this.postMessage({op:"wakeUp",uuid:n})}postMessage(t){if(this.worker)return this.worker.postMessage(t);this.messageQueue.push(t)}}class ur{constructor(e){e===void 0&&(e=[0,0,0,0,0,0,0,0,0]),this.elements=e}identity(){const e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}setZero(){const e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0}setTrace(e){const t=this.elements;t[0]=e.x,t[4]=e.y,t[8]=e.z}getTrace(e){e===void 0&&(e=new K);const t=this.elements;return e.x=t[0],e.y=t[4],e.z=t[8],e}vmult(e,t){t===void 0&&(t=new K);const n=this.elements,s=e.x,o=e.y,r=e.z;return t.x=n[0]*s+n[1]*o+n[2]*r,t.y=n[3]*s+n[4]*o+n[5]*r,t.z=n[6]*s+n[7]*o+n[8]*r,t}smult(e){for(let t=0;t0){const o=1/s;this.x*=o,this.y*=o,this.z*=o}else this.x=0,this.y=0,this.z=0;return s}unit(e){e===void 0&&(e=new K);const t=this.x,n=this.y,s=this.z;let o=Math.sqrt(t*t+n*n+s*s);return o>0?(o=1/o,e.x=t*o,e.y=n*o,e.z=s*o):(e.x=1,e.y=0,e.z=0),e}length(){const e=this.x,t=this.y,n=this.z;return Math.sqrt(e*e+t*t+n*n)}lengthSquared(){return this.dot(this)}distanceTo(e){const t=this.x,n=this.y,s=this.z,o=e.x,r=e.y,g=e.z;return Math.sqrt((o-t)*(o-t)+(r-n)*(r-n)+(g-s)*(g-s))}distanceSquared(e){const t=this.x,n=this.y,s=this.z,o=e.x,r=e.y,g=e.z;return(o-t)*(o-t)+(r-n)*(r-n)+(g-s)*(g-s)}scale(e,t){t===void 0&&(t=new K);const n=this.x,s=this.y,o=this.z;return t.x=e*n,t.y=e*s,t.z=e*o,t}vmul(e,t){return t===void 0&&(t=new K),t.x=e.x*this.x,t.y=e.y*this.y,t.z=e.z*this.z,t}addScaledVector(e,t,n){return n===void 0&&(n=new K),n.x=this.x+e*t.x,n.y=this.y+e*t.y,n.z=this.z+e*t.z,n}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}isZero(){return this.x===0&&this.y===0&&this.z===0}negate(e){return e===void 0&&(e=new K),e.x=-this.x,e.y=-this.y,e.z=-this.z,e}tangents(e,t){const n=this.length();if(n>0){const s=_k,o=1/n;s.set(this.x*o,this.y*o,this.z*o);const r=Uk;Math.abs(s.x)<.9?(r.set(1,0,0),s.cross(r,e)):(r.set(0,1,0),s.cross(r,e)),s.cross(e,t)}else e.set(1,0,0),t.set(0,1,0)}toString(){return`${this.x},${this.y},${this.z}`}toArray(){return[this.x,this.y,this.z]}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}lerp(e,t,n){const s=this.x,o=this.y,r=this.z;n.x=s+(e.x-s)*t,n.y=o+(e.y-o)*t,n.z=r+(e.z-r)*t}almostEquals(e,t){return t===void 0&&(t=1e-6),!(Math.abs(this.x-e.x)>t||Math.abs(this.y-e.y)>t||Math.abs(this.z-e.z)>t)}almostZero(e){return e===void 0&&(e=1e-6),!(Math.abs(this.x)>e||Math.abs(this.y)>e||Math.abs(this.z)>e)}isAntiparallelTo(e,t){return this.negate(nR),nR.almostEquals(e,t)}clone(){return new K(this.x,this.y,this.z)}}K.ZERO=new K(0,0,0);K.UNIT_X=new K(1,0,0);K.UNIT_Y=new K(0,1,0);K.UNIT_Z=new K(0,0,1);const _k=new K,Uk=new K,nR=new K;class _s{constructor(e){e===void 0&&(e={}),this.lowerBound=new K,this.upperBound=new K,e.lowerBound&&this.lowerBound.copy(e.lowerBound),e.upperBound&&this.upperBound.copy(e.upperBound)}setFromPoints(e,t,n,s){const o=this.lowerBound,r=this.upperBound,g=n;o.copy(e[0]),g&&g.vmult(o,o),r.copy(o);for(let a=1;ar.x&&(r.x=l.x),l.xr.y&&(r.y=l.y),l.yr.z&&(r.z=l.z),l.z=o.x&&t.y<=s.y&&n.y>=o.y&&t.z<=s.z&&n.z>=o.z}getCorners(e,t,n,s,o,r,g,a){const l=this.lowerBound,I=this.upperBound;e.copy(l),t.set(I.x,l.y,l.z),n.set(I.x,I.y,l.z),s.set(l.x,I.y,I.z),o.set(I.x,l.y,I.z),r.set(l.x,I.y,l.z),g.set(l.x,l.y,I.z),a.copy(I)}toLocalFrame(e,t){const n=sR,s=n[0],o=n[1],r=n[2],g=n[3],a=n[4],l=n[5],I=n[6],u=n[7];this.getCorners(s,o,r,g,a,l,I,u);for(let d=0;d!==8;d++){const A=n[d];e.pointToLocal(A,A)}return t.setFromPoints(n)}toWorldFrame(e,t){const n=sR,s=n[0],o=n[1],r=n[2],g=n[3],a=n[4],l=n[5],I=n[6],u=n[7];this.getCorners(s,o,r,g,a,l,I,u);for(let d=0;d!==8;d++){const A=n[d];e.pointToWorld(A,A)}return t.setFromPoints(n)}overlapsRay(e){const{direction:t,from:n}=e,s=1/t.x,o=1/t.y,r=1/t.z,g=(this.lowerBound.x-n.x)*s,a=(this.upperBound.x-n.x)*s,l=(this.lowerBound.y-n.y)*o,I=(this.upperBound.y-n.y)*o,u=(this.lowerBound.z-n.z)*r,d=(this.upperBound.z-n.z)*r,A=Math.max(Math.max(Math.min(g,a),Math.min(l,I)),Math.min(u,d)),p=Math.min(Math.min(Math.max(g,a),Math.max(l,I)),Math.max(u,d));return!(p<0||A>p)}}const iR=new K,sR=[new K,new K,new K,new K,new K,new K,new K,new K];class Mi{constructor(e,t,n,s){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=1),this.x=e,this.y=t,this.z=n,this.w=s}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}toArray(){return[this.x,this.y,this.z,this.w]}setFromAxisAngle(e,t){const n=Math.sin(t*.5);return this.x=e.x*n,this.y=e.y*n,this.z=e.z*n,this.w=Math.cos(t*.5),this}toAxisAngle(e){e===void 0&&(e=new K),this.normalize();const t=2*Math.acos(this.w),n=Math.sqrt(1-this.w*this.w);return n<.001?(e.x=this.x,e.y=this.y,e.z=this.z):(e.x=this.x/n,e.y=this.y/n,e.z=this.z/n),[e,t]}setFromVectors(e,t){if(e.isAntiparallelTo(t)){const n=Dk,s=Jk;e.tangents(n,s),this.setFromAxisAngle(n,Math.PI)}else{const n=e.cross(t);this.x=n.x,this.y=n.y,this.z=n.z,this.w=Math.sqrt(e.length()**2*t.length()**2)+e.dot(t),this.normalize()}return this}mult(e,t){t===void 0&&(t=new Mi);const n=this.x,s=this.y,o=this.z,r=this.w,g=e.x,a=e.y,l=e.z,I=e.w;return t.x=n*I+r*g+s*l-o*a,t.y=s*I+r*a+o*g-n*l,t.z=o*I+r*l+n*a-s*g,t.w=r*I-n*g-s*a-o*l,t}inverse(e){e===void 0&&(e=new Mi);const t=this.x,n=this.y,s=this.z,o=this.w;this.conjugate(e);const r=1/(t*t+n*n+s*s+o*o);return e.x*=r,e.y*=r,e.z*=r,e.w*=r,e}conjugate(e){return e===void 0&&(e=new Mi),e.x=-this.x,e.y=-this.y,e.z=-this.z,e.w=this.w,e}normalize(){let e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(e=1/e,this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}normalizeFast(){const e=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}vmult(e,t){t===void 0&&(t=new K);const n=e.x,s=e.y,o=e.z,r=this.x,g=this.y,a=this.z,l=this.w,I=l*n+g*o-a*s,u=l*s+a*n-r*o,d=l*o+r*s-g*n,A=-r*n-g*s-a*o;return t.x=I*l+A*-r+u*-a-d*-g,t.y=u*l+A*-g+d*-r-I*-a,t.z=d*l+A*-a+I*-g-u*-r,t}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}toEuler(e,t){t===void 0&&(t="YZX");let n,s,o;const r=this.x,g=this.y,a=this.z,l=this.w;switch(t){case"YZX":const I=r*g+a*l;if(I>.499&&(n=2*Math.atan2(r,l),s=Math.PI/2,o=0),I<-.499&&(n=-2*Math.atan2(r,l),s=-Math.PI/2,o=0),n===void 0){const u=r*r,d=g*g,A=a*a;n=Math.atan2(2*g*l-2*r*a,1-2*d-2*A),s=Math.asin(2*I),o=Math.atan2(2*r*l-2*g*a,1-2*u-2*A)}break;default:throw new Error(`Euler order ${t} not supported yet.`)}e.y=n,e.z=s,e.x=o}setFromEuler(e,t,n,s){s===void 0&&(s="XYZ");const o=Math.cos(e/2),r=Math.cos(t/2),g=Math.cos(n/2),a=Math.sin(e/2),l=Math.sin(t/2),I=Math.sin(n/2);return s==="XYZ"?(this.x=a*r*g+o*l*I,this.y=o*l*g-a*r*I,this.z=o*r*I+a*l*g,this.w=o*r*g-a*l*I):s==="YXZ"?(this.x=a*r*g+o*l*I,this.y=o*l*g-a*r*I,this.z=o*r*I-a*l*g,this.w=o*r*g+a*l*I):s==="ZXY"?(this.x=a*r*g-o*l*I,this.y=o*l*g+a*r*I,this.z=o*r*I+a*l*g,this.w=o*r*g-a*l*I):s==="ZYX"?(this.x=a*r*g-o*l*I,this.y=o*l*g+a*r*I,this.z=o*r*I-a*l*g,this.w=o*r*g+a*l*I):s==="YZX"?(this.x=a*r*g+o*l*I,this.y=o*l*g+a*r*I,this.z=o*r*I-a*l*g,this.w=o*r*g-a*l*I):s==="XZY"&&(this.x=a*r*g-o*l*I,this.y=o*l*g-a*r*I,this.z=o*r*I+a*l*g,this.w=o*r*g+a*l*I),this}clone(){return new Mi(this.x,this.y,this.z,this.w)}slerp(e,t,n){n===void 0&&(n=new Mi);const s=this.x,o=this.y,r=this.z,g=this.w;let a=e.x,l=e.y,I=e.z,u=e.w,d,A,p,b,f;return A=s*a+o*l+r*I+g*u,A<0&&(A=-A,a=-a,l=-l,I=-I,u=-u),1-A>1e-6?(d=Math.acos(A),p=Math.sin(d),b=Math.sin((1-t)*d)/p,f=Math.sin(t*d)/p):(b=1-t,f=t),n.x=b*s+f*a,n.y=b*o+f*l,n.z=b*r+f*I,n.w=b*g+f*u,n}integrate(e,t,n,s){s===void 0&&(s=new Mi);const o=e.x*n.x,r=e.y*n.y,g=e.z*n.z,a=this.x,l=this.y,I=this.z,u=this.w,d=t*.5;return s.x+=d*(o*u+r*I-g*l),s.y+=d*(r*u+g*a-o*I),s.z+=d*(g*u+o*l-r*a),s.w+=d*(-o*a-r*l-g*I),s}}const Dk=new K,Jk=new K,Pk={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256};class et{constructor(e){e===void 0&&(e={}),this.id=et.idCounter++,this.type=e.type||0,this.boundingSphereRadius=0,this.collisionResponse=e.collisionResponse?e.collisionResponse:!0,this.collisionFilterGroup=e.collisionFilterGroup!==void 0?e.collisionFilterGroup:1,this.collisionFilterMask=e.collisionFilterMask!==void 0?e.collisionFilterMask:-1,this.material=e.material?e.material:null,this.body=null}updateBoundingSphereRadius(){throw`computeBoundingSphereRadius() not implemented for shape type ${this.type}`}volume(){throw`volume() not implemented for shape type ${this.type}`}calculateLocalInertia(e,t){throw`calculateLocalInertia() not implemented for shape type ${this.type}`}calculateWorldAABB(e,t,n,s){throw`calculateWorldAABB() not implemented for shape type ${this.type}`}}et.idCounter=0;et.types=Pk;class Pi{constructor(e){e===void 0&&(e={}),this.position=new K,this.quaternion=new Mi,e.position&&this.position.copy(e.position),e.quaternion&&this.quaternion.copy(e.quaternion)}pointToLocal(e,t){return Pi.pointToLocalFrame(this.position,this.quaternion,e,t)}pointToWorld(e,t){return Pi.pointToWorldFrame(this.position,this.quaternion,e,t)}vectorToWorldFrame(e,t){return t===void 0&&(t=new K),this.quaternion.vmult(e,t),t}static pointToLocalFrame(e,t,n,s){return s===void 0&&(s=new K),n.vsub(e,s),t.conjugate(oR),oR.vmult(s,s),s}static pointToWorldFrame(e,t,n,s){return s===void 0&&(s=new K),t.vmult(n,s),s.vadd(e,s),s}static vectorToWorldFrame(e,t,n){return n===void 0&&(n=new K),e.vmult(t,n),n}static vectorToLocalFrame(e,t,n,s){return s===void 0&&(s=new K),t.w*=-1,t.vmult(n,s),t.w*=-1,s}}const oR=new Mi;new K;new K;new K;new K;new K,new K,new K,new K,new K,new K,new K,new K;new K;new Mi;new _s;new ur;new ur;new ur;new K;new K;new K;new K;new K;new K;new K;new K;new K;new K;new Mi;new K;new K;new K;new K;class lG{constructor(){this.rayFromWorld=new K,this.rayToWorld=new K,this.hitNormalWorld=new K,this.hitPointWorld=new K,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}reset(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}abort(){this.shouldStop=!0}set(e,t,n,s,o,r,g){this.rayFromWorld.copy(e),this.rayToWorld.copy(t),this.hitNormalWorld.copy(n),this.hitPointWorld.copy(s),this.shape=o,this.body=r,this.distance=g}}let gX,aX,lX,cX,IX,CX,uX;const $y={CLOSEST:1,ANY:2,ALL:4};gX=et.types.SPHERE;aX=et.types.PLANE;lX=et.types.BOX;cX=et.types.CYLINDER;IX=et.types.CONVEXPOLYHEDRON;CX=et.types.HEIGHTFIELD;uX=et.types.TRIMESH;class bi{get[gX](){return this._intersectSphere}get[aX](){return this._intersectPlane}get[lX](){return this._intersectBox}get[cX](){return this._intersectConvex}get[IX](){return this._intersectConvex}get[CX](){return this._intersectHeightfield}get[uX](){return this._intersectTrimesh}constructor(e,t){e===void 0&&(e=new K),t===void 0&&(t=new K),this.from=e.clone(),this.to=t.clone(),this.direction=new K,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=bi.ANY,this.result=new lG,this.hasHit=!1,this.callback=n=>{}}intersectWorld(e,t){return this.mode=t.mode||bi.ANY,this.result=t.result||new lG,this.skipBackfaces=!!t.skipBackfaces,this.collisionFilterMask=typeof t.collisionFilterMask<"u"?t.collisionFilterMask:-1,this.collisionFilterGroup=typeof t.collisionFilterGroup<"u"?t.collisionFilterGroup:-1,this.checkCollisionResponse=typeof t.checkCollisionResponse<"u"?t.checkCollisionResponse:!0,t.from&&this.from.copy(t.from),t.to&&this.to.copy(t.to),this.callback=t.callback||(()=>{}),this.hasHit=!1,this.result.reset(),this.updateDirection(),this.getAABB(rR),sb.length=0,e.broadphase.aabbQuery(e,rR,sb),this.intersectBodies(sb),this.hasHit}intersectBody(e,t){t&&(this.result=t,this.updateDirection());const n=this.checkCollisionResponse;if(n&&!e.collisionResponse||!(this.collisionFilterGroup&e.collisionFilterMask)||!(e.collisionFilterGroup&this.collisionFilterMask))return;const s=Ok,o=Qk;for(let r=0,g=e.shapes.length;re.boundingSphereRadius)return;const g=this[e.type];g&&g.call(this,e,t,n,s,e)}_intersectBox(e,t,n,s,o){return this._intersectConvex(e.convexPolyhedronRepresentation,t,n,s,o)}_intersectPlane(e,t,n,s,o){const r=this.from,g=this.to,a=this.direction,l=new K(0,0,1);t.vmult(l,l);const I=new K;r.vsub(n,I);const u=I.dot(l);g.vsub(n,I);const d=I.dot(l);if(u*d>0||r.distanceTo(g)=0&&b<=1&&(r.lerp(g,b,A),A.vsub(n,p),p.normalize(),this.reportIntersection(p,A,o,s,-1)),this.result.shouldStop)return;f>=0&&f<=1&&(r.lerp(g,f,A),A.vsub(n,p),p.normalize(),this.reportIntersection(p,A,o,s,-1))}}_intersectConvex(e,t,n,s,o,r){const g=t_,a=aR,l=r&&r.faceList||null,I=e.faces,u=e.vertices,d=e.faceNormals,A=this.direction,p=this.from,b=this.to,f=p.distanceTo(b),h=l?l.length:I.length,G=this.result;for(let y=0;!G.shouldStop&&yf||this.reportIntersection(g,Ui,o,s,v)}}}}_intersectTrimesh(e,t,n,s,o,r){const g=n_,a=a_,l=l_,I=aR,u=i_,d=s_,A=o_,p=g_,b=r_,f=e.indices;e.vertices;const h=this.from,G=this.to,y=this.direction;l.position.copy(n),l.quaternion.copy(t),Pi.vectorToLocalFrame(n,t,y,u),Pi.pointToLocalFrame(n,t,h,d),Pi.pointToLocalFrame(n,t,G,A),A.x*=e.scale.x,A.y*=e.scale.y,A.z*=e.scale.z,d.x*=e.scale.x,d.y*=e.scale.y,d.z*=e.scale.z,A.vsub(d,u),u.normalize();const v=d.distanceSquared(A);e.tree.rayQuery(this,l,a);for(let W=0,R=a.length;!this.result.shouldStop&&W!==R;W++){const x=a[W];e.getNormal(x,g),e.getVertex(f[x*3],to),to.vsub(d,I);const M=u.dot(g),V=g.dot(I)/M;if(V<0)continue;u.scale(V,Ui),Ui.vadd(d,Ui),e.getVertex(f[x*3+1],Ro),e.getVertex(f[x*3+2],So);const w=Ui.distanceSquared(d);!(bi.pointInTriangle(Ui,Ro,to,So)||bi.pointInTriangle(Ui,to,Ro,So))||w>v||(Pi.vectorToWorldFrame(t,g,b),Pi.pointToWorldFrame(n,t,Ui,p),this.reportIntersection(b,p,o,s,x))}a.length=0}reportIntersection(e,t,n,s,o){const r=this.from,g=this.to,a=r.distanceTo(t),l=this.result;if(!(this.skipBackfaces&&e.dot(this.direction)>0))switch(l.hitFaceIndex=typeof o<"u"?o:-1,this.mode){case bi.ALL:this.hasHit=!0,l.set(r,g,e,t,n,s,a),l.hasHit=!0,this.callback(l);break;case bi.CLOSEST:(a=0&&(u=o*l-r*g)>=0&&I+uDate.now()-i}new K;class dr{constructor(e){e===void 0&&(e=[0,0,0,0,0,0,0,0,0]),this.elements=e}identity(){const e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}setZero(){const e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0}setTrace(e){const t=this.elements;t[0]=e.x,t[4]=e.y,t[8]=e.z}getTrace(e){e===void 0&&(e=new L);const t=this.elements;return e.x=t[0],e.y=t[4],e.z=t[8],e}vmult(e,t){t===void 0&&(t=new L);const n=this.elements,s=e.x,o=e.y,r=e.z;return t.x=n[0]*s+n[1]*o+n[2]*r,t.y=n[3]*s+n[4]*o+n[5]*r,t.z=n[6]*s+n[7]*o+n[8]*r,t}smult(e){for(let t=0;t0){const o=1/s;this.x*=o,this.y*=o,this.z*=o}else this.x=0,this.y=0,this.z=0;return s}unit(e){e===void 0&&(e=new L);const t=this.x,n=this.y,s=this.z;let o=Math.sqrt(t*t+n*n+s*s);return o>0?(o=1/o,e.x=t*o,e.y=n*o,e.z=s*o):(e.x=1,e.y=0,e.z=0),e}length(){const e=this.x,t=this.y,n=this.z;return Math.sqrt(e*e+t*t+n*n)}lengthSquared(){return this.dot(this)}distanceTo(e){const t=this.x,n=this.y,s=this.z,o=e.x,r=e.y,g=e.z;return Math.sqrt((o-t)*(o-t)+(r-n)*(r-n)+(g-s)*(g-s))}distanceSquared(e){const t=this.x,n=this.y,s=this.z,o=e.x,r=e.y,g=e.z;return(o-t)*(o-t)+(r-n)*(r-n)+(g-s)*(g-s)}scale(e,t){t===void 0&&(t=new L);const n=this.x,s=this.y,o=this.z;return t.x=e*n,t.y=e*s,t.z=e*o,t}vmul(e,t){return t===void 0&&(t=new L),t.x=e.x*this.x,t.y=e.y*this.y,t.z=e.z*this.z,t}addScaledVector(e,t,n){return n===void 0&&(n=new L),n.x=this.x+e*t.x,n.y=this.y+e*t.y,n.z=this.z+e*t.z,n}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}isZero(){return this.x===0&&this.y===0&&this.z===0}negate(e){return e===void 0&&(e=new L),e.x=-this.x,e.y=-this.y,e.z=-this.z,e}tangents(e,t){const n=this.length();if(n>0){const s=C_,o=1/n;s.set(this.x*o,this.y*o,this.z*o);const r=u_;Math.abs(s.x)<.9?(r.set(1,0,0),s.cross(r,e)):(r.set(0,1,0),s.cross(r,e)),s.cross(e,t)}else e.set(1,0,0),t.set(0,1,0)}toString(){return`${this.x},${this.y},${this.z}`}toArray(){return[this.x,this.y,this.z]}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}lerp(e,t,n){const s=this.x,o=this.y,r=this.z;n.x=s+(e.x-s)*t,n.y=o+(e.y-o)*t,n.z=r+(e.z-r)*t}almostEquals(e,t){return t===void 0&&(t=1e-6),!(Math.abs(this.x-e.x)>t||Math.abs(this.y-e.y)>t||Math.abs(this.z-e.z)>t)}almostZero(e){return e===void 0&&(e=1e-6),!(Math.abs(this.x)>e||Math.abs(this.y)>e||Math.abs(this.z)>e)}isAntiparallelTo(e,t){return this.negate(lR),lR.almostEquals(e,t)}clone(){return new L(this.x,this.y,this.z)}}L.ZERO=new L(0,0,0);L.UNIT_X=new L(1,0,0);L.UNIT_Y=new L(0,1,0);L.UNIT_Z=new L(0,0,1);const C_=new L,u_=new L,lR=new L;class Us{constructor(e){e===void 0&&(e={}),this.lowerBound=new L,this.upperBound=new L,e.lowerBound&&this.lowerBound.copy(e.lowerBound),e.upperBound&&this.upperBound.copy(e.upperBound)}setFromPoints(e,t,n,s){const o=this.lowerBound,r=this.upperBound,g=n;o.copy(e[0]),g&&g.vmult(o,o),r.copy(o);for(let a=1;ar.x&&(r.x=l.x),l.xr.y&&(r.y=l.y),l.yr.z&&(r.z=l.z),l.z=o.x&&t.y<=s.y&&n.y>=o.y&&t.z<=s.z&&n.z>=o.z}getCorners(e,t,n,s,o,r,g,a){const l=this.lowerBound,I=this.upperBound;e.copy(l),t.set(I.x,l.y,l.z),n.set(I.x,I.y,l.z),s.set(l.x,I.y,I.z),o.set(I.x,l.y,I.z),r.set(l.x,I.y,l.z),g.set(l.x,l.y,I.z),a.copy(I)}toLocalFrame(e,t){const n=IR,s=n[0],o=n[1],r=n[2],g=n[3],a=n[4],l=n[5],I=n[6],u=n[7];this.getCorners(s,o,r,g,a,l,I,u);for(let d=0;d!==8;d++){const A=n[d];e.pointToLocal(A,A)}return t.setFromPoints(n)}toWorldFrame(e,t){const n=IR,s=n[0],o=n[1],r=n[2],g=n[3],a=n[4],l=n[5],I=n[6],u=n[7];this.getCorners(s,o,r,g,a,l,I,u);for(let d=0;d!==8;d++){const A=n[d];e.pointToWorld(A,A)}return t.setFromPoints(n)}overlapsRay(e){const{direction:t,from:n}=e,s=1/t.x,o=1/t.y,r=1/t.z,g=(this.lowerBound.x-n.x)*s,a=(this.upperBound.x-n.x)*s,l=(this.lowerBound.y-n.y)*o,I=(this.upperBound.y-n.y)*o,u=(this.lowerBound.z-n.z)*r,d=(this.upperBound.z-n.z)*r,A=Math.max(Math.max(Math.min(g,a),Math.min(l,I)),Math.min(u,d)),p=Math.min(Math.min(Math.max(g,a),Math.max(l,I)),Math.max(u,d));return!(p<0||A>p)}}const cR=new L,IR=[new L,new L,new L,new L,new L,new L,new L,new L];class Xi{constructor(e,t,n,s){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=1),this.x=e,this.y=t,this.z=n,this.w=s}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}toArray(){return[this.x,this.y,this.z,this.w]}setFromAxisAngle(e,t){const n=Math.sin(t*.5);return this.x=e.x*n,this.y=e.y*n,this.z=e.z*n,this.w=Math.cos(t*.5),this}toAxisAngle(e){e===void 0&&(e=new L),this.normalize();const t=2*Math.acos(this.w),n=Math.sqrt(1-this.w*this.w);return n<.001?(e.x=this.x,e.y=this.y,e.z=this.z):(e.x=this.x/n,e.y=this.y/n,e.z=this.z/n),[e,t]}setFromVectors(e,t){if(e.isAntiparallelTo(t)){const n=d_,s=A_;e.tangents(n,s),this.setFromAxisAngle(n,Math.PI)}else{const n=e.cross(t);this.x=n.x,this.y=n.y,this.z=n.z,this.w=Math.sqrt(e.length()**2*t.length()**2)+e.dot(t),this.normalize()}return this}mult(e,t){t===void 0&&(t=new Xi);const n=this.x,s=this.y,o=this.z,r=this.w,g=e.x,a=e.y,l=e.z,I=e.w;return t.x=n*I+r*g+s*l-o*a,t.y=s*I+r*a+o*g-n*l,t.z=o*I+r*l+n*a-s*g,t.w=r*I-n*g-s*a-o*l,t}inverse(e){e===void 0&&(e=new Xi);const t=this.x,n=this.y,s=this.z,o=this.w;this.conjugate(e);const r=1/(t*t+n*n+s*s+o*o);return e.x*=r,e.y*=r,e.z*=r,e.w*=r,e}conjugate(e){return e===void 0&&(e=new Xi),e.x=-this.x,e.y=-this.y,e.z=-this.z,e.w=this.w,e}normalize(){let e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(e=1/e,this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}normalizeFast(){const e=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}vmult(e,t){t===void 0&&(t=new L);const n=e.x,s=e.y,o=e.z,r=this.x,g=this.y,a=this.z,l=this.w,I=l*n+g*o-a*s,u=l*s+a*n-r*o,d=l*o+r*s-g*n,A=-r*n-g*s-a*o;return t.x=I*l+A*-r+u*-a-d*-g,t.y=u*l+A*-g+d*-r-I*-a,t.z=d*l+A*-a+I*-g-u*-r,t}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}toEuler(e,t){t===void 0&&(t="YZX");let n,s,o;const r=this.x,g=this.y,a=this.z,l=this.w;switch(t){case"YZX":const I=r*g+a*l;if(I>.499&&(n=2*Math.atan2(r,l),s=Math.PI/2,o=0),I<-.499&&(n=-2*Math.atan2(r,l),s=-Math.PI/2,o=0),n===void 0){const u=r*r,d=g*g,A=a*a;n=Math.atan2(2*g*l-2*r*a,1-2*d-2*A),s=Math.asin(2*I),o=Math.atan2(2*r*l-2*g*a,1-2*u-2*A)}break;default:throw new Error(`Euler order ${t} not supported yet.`)}e.y=n,e.z=s,e.x=o}setFromEuler(e,t,n,s){s===void 0&&(s="XYZ");const o=Math.cos(e/2),r=Math.cos(t/2),g=Math.cos(n/2),a=Math.sin(e/2),l=Math.sin(t/2),I=Math.sin(n/2);return s==="XYZ"?(this.x=a*r*g+o*l*I,this.y=o*l*g-a*r*I,this.z=o*r*I+a*l*g,this.w=o*r*g-a*l*I):s==="YXZ"?(this.x=a*r*g+o*l*I,this.y=o*l*g-a*r*I,this.z=o*r*I-a*l*g,this.w=o*r*g+a*l*I):s==="ZXY"?(this.x=a*r*g-o*l*I,this.y=o*l*g+a*r*I,this.z=o*r*I+a*l*g,this.w=o*r*g-a*l*I):s==="ZYX"?(this.x=a*r*g-o*l*I,this.y=o*l*g+a*r*I,this.z=o*r*I-a*l*g,this.w=o*r*g+a*l*I):s==="YZX"?(this.x=a*r*g+o*l*I,this.y=o*l*g+a*r*I,this.z=o*r*I-a*l*g,this.w=o*r*g-a*l*I):s==="XZY"&&(this.x=a*r*g-o*l*I,this.y=o*l*g-a*r*I,this.z=o*r*I+a*l*g,this.w=o*r*g+a*l*I),this}clone(){return new Xi(this.x,this.y,this.z,this.w)}slerp(e,t,n){n===void 0&&(n=new Xi);const s=this.x,o=this.y,r=this.z,g=this.w;let a=e.x,l=e.y,I=e.z,u=e.w,d,A,p,b,f;return A=s*a+o*l+r*I+g*u,A<0&&(A=-A,a=-a,l=-l,I=-I,u=-u),1-A>1e-6?(d=Math.acos(A),p=Math.sin(d),b=Math.sin((1-t)*d)/p,f=Math.sin(t*d)/p):(b=1-t,f=t),n.x=b*s+f*a,n.y=b*o+f*l,n.z=b*r+f*I,n.w=b*g+f*u,n}integrate(e,t,n,s){s===void 0&&(s=new Xi);const o=e.x*n.x,r=e.y*n.y,g=e.z*n.z,a=this.x,l=this.y,I=this.z,u=this.w,d=t*.5;return s.x+=d*(o*u+r*I-g*l),s.y+=d*(r*u+g*a-o*I),s.z+=d*(g*u+o*l-r*a),s.w+=d*(-o*a-r*l-g*I),s}}const d_=new L,A_=new L,h_={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256};class tt{constructor(e){e===void 0&&(e={}),this.id=tt.idCounter++,this.type=e.type||0,this.boundingSphereRadius=0,this.collisionResponse=e.collisionResponse?e.collisionResponse:!0,this.collisionFilterGroup=e.collisionFilterGroup!==void 0?e.collisionFilterGroup:1,this.collisionFilterMask=e.collisionFilterMask!==void 0?e.collisionFilterMask:-1,this.material=e.material?e.material:null,this.body=null}updateBoundingSphereRadius(){throw`computeBoundingSphereRadius() not implemented for shape type ${this.type}`}volume(){throw`volume() not implemented for shape type ${this.type}`}calculateLocalInertia(e,t){throw`calculateLocalInertia() not implemented for shape type ${this.type}`}calculateWorldAABB(e,t,n,s){throw`calculateWorldAABB() not implemented for shape type ${this.type}`}}tt.idCounter=0;tt.types=h_;class Oi{constructor(e){e===void 0&&(e={}),this.position=new L,this.quaternion=new Xi,e.position&&this.position.copy(e.position),e.quaternion&&this.quaternion.copy(e.quaternion)}pointToLocal(e,t){return Oi.pointToLocalFrame(this.position,this.quaternion,e,t)}pointToWorld(e,t){return Oi.pointToWorldFrame(this.position,this.quaternion,e,t)}vectorToWorldFrame(e,t){return t===void 0&&(t=new L),this.quaternion.vmult(e,t),t}static pointToLocalFrame(e,t,n,s){return s===void 0&&(s=new L),n.vsub(e,s),t.conjugate(CR),CR.vmult(s,s),s}static pointToWorldFrame(e,t,n,s){return s===void 0&&(s=new L),t.vmult(n,s),s.vadd(e,s),s}static vectorToWorldFrame(e,t,n){return n===void 0&&(n=new L),e.vmult(t,n),n}static vectorToLocalFrame(e,t,n,s){return s===void 0&&(s=new L),t.w*=-1,t.vmult(n,s),t.w*=-1,s}}const CR=new Xi;new L;new L;new L;new L;new L,new L,new L,new L,new L,new L,new L,new L;new L;new Xi;new Us;new dr;new dr;new dr;new L;new L;new L;new L;new L;new L;new L;new L;new L;new L;new Xi;new L;new L;new L;new L;class cG{constructor(){this.rayFromWorld=new L,this.rayToWorld=new L,this.hitNormalWorld=new L,this.hitPointWorld=new L,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}reset(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}abort(){this.shouldStop=!0}set(e,t,n,s,o,r,g){this.rayFromWorld.copy(e),this.rayToWorld.copy(t),this.hitNormalWorld.copy(n),this.hitPointWorld.copy(s),this.shape=o,this.body=r,this.distance=g}}let dX,AX,hX,pX,mX,fX,bX;const eB={CLOSEST:1,ANY:2,ALL:4};dX=tt.types.SPHERE;AX=tt.types.PLANE;hX=tt.types.BOX;pX=tt.types.CYLINDER;mX=tt.types.CONVEXPOLYHEDRON;fX=tt.types.HEIGHTFIELD;bX=tt.types.TRIMESH;class Gi{get[dX](){return this._intersectSphere}get[AX](){return this._intersectPlane}get[hX](){return this._intersectBox}get[pX](){return this._intersectConvex}get[mX](){return this._intersectConvex}get[fX](){return this._intersectHeightfield}get[bX](){return this._intersectTrimesh}constructor(e,t){e===void 0&&(e=new L),t===void 0&&(t=new L),this.from=e.clone(),this.to=t.clone(),this.direction=new L,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=Gi.ANY,this.result=new cG,this.hasHit=!1,this.callback=n=>{}}intersectWorld(e,t){return this.mode=t.mode||Gi.ANY,this.result=t.result||new cG,this.skipBackfaces=!!t.skipBackfaces,this.collisionFilterMask=typeof t.collisionFilterMask<"u"?t.collisionFilterMask:-1,this.collisionFilterGroup=typeof t.collisionFilterGroup<"u"?t.collisionFilterGroup:-1,this.checkCollisionResponse=typeof t.checkCollisionResponse<"u"?t.checkCollisionResponse:!0,t.from&&this.from.copy(t.from),t.to&&this.to.copy(t.to),this.callback=t.callback||(()=>{}),this.hasHit=!1,this.result.reset(),this.updateDirection(),this.getAABB(uR),rb.length=0,e.broadphase.aabbQuery(e,uR,rb),this.intersectBodies(rb),this.hasHit}intersectBody(e,t){t&&(this.result=t,this.updateDirection());const n=this.checkCollisionResponse;if(n&&!e.collisionResponse||!(this.collisionFilterGroup&e.collisionFilterMask)||!(e.collisionFilterGroup&this.collisionFilterMask))return;const s=p_,o=m_;for(let r=0,g=e.shapes.length;re.boundingSphereRadius)return;const g=this[e.type];g&&g.call(this,e,t,n,s,e)}_intersectBox(e,t,n,s,o){return this._intersectConvex(e.convexPolyhedronRepresentation,t,n,s,o)}_intersectPlane(e,t,n,s,o){const r=this.from,g=this.to,a=this.direction,l=new L(0,0,1);t.vmult(l,l);const I=new L;r.vsub(n,I);const u=I.dot(l);g.vsub(n,I);const d=I.dot(l);if(u*d>0||r.distanceTo(g)=0&&b<=1&&(r.lerp(g,b,A),A.vsub(n,p),p.normalize(),this.reportIntersection(p,A,o,s,-1)),this.result.shouldStop)return;f>=0&&f<=1&&(r.lerp(g,f,A),A.vsub(n,p),p.normalize(),this.reportIntersection(p,A,o,s,-1))}}_intersectConvex(e,t,n,s,o,r){const g=B_,a=AR,l=r&&r.faceList||null,I=e.faces,u=e.vertices,d=e.faceNormals,A=this.direction,p=this.from,b=this.to,f=p.distanceTo(b),h=l?l.length:I.length,G=this.result;for(let y=0;!G.shouldStop&&yf||this.reportIntersection(g,Di,o,s,v)}}}}_intersectTrimesh(e,t,n,s,o,r){const g=v_,a=x_,l=V_,I=AR,u=Z_,d=w_,A=R_,p=W_,b=S_,f=e.indices;e.vertices;const h=this.from,G=this.to,y=this.direction;l.position.copy(n),l.quaternion.copy(t),Oi.vectorToLocalFrame(n,t,y,u),Oi.pointToLocalFrame(n,t,h,d),Oi.pointToLocalFrame(n,t,G,A),A.x*=e.scale.x,A.y*=e.scale.y,A.z*=e.scale.z,d.x*=e.scale.x,d.y*=e.scale.y,d.z*=e.scale.z,A.vsub(d,u),u.normalize();const v=d.distanceSquared(A);e.tree.rayQuery(this,l,a);for(let W=0,R=a.length;!this.result.shouldStop&&W!==R;W++){const x=a[W];e.getNormal(x,g),e.getVertex(f[x*3],no),no.vsub(d,I);const M=u.dot(g),V=g.dot(I)/M;if(V<0)continue;u.scale(V,Di),Di.vadd(d,Di),e.getVertex(f[x*3+1],Wo),e.getVertex(f[x*3+2],xo);const w=Di.distanceSquared(d);!(Gi.pointInTriangle(Di,Wo,no,xo)||Gi.pointInTriangle(Di,no,Wo,xo))||w>v||(Oi.vectorToWorldFrame(t,g,b),Oi.pointToWorldFrame(n,t,Di,p),this.reportIntersection(b,p,o,s,x))}a.length=0}reportIntersection(e,t,n,s,o){const r=this.from,g=this.to,a=r.distanceTo(t),l=this.result;if(!(this.skipBackfaces&&e.dot(this.direction)>0))switch(l.hitFaceIndex=typeof o<"u"?o:-1,this.mode){case Gi.ALL:this.hasHit=!0,l.set(r,g,e,t,n,s,a),l.hasHit=!0,this.callback(l);break;case Gi.CLOSEST:(a=0&&(u=o*l-r*g)>=0&&I+uDate.now()-i}new L;const X_=k.createContext(null),H_=()=>k.useContext(X_),GX=k.createContext(null),yX=()=>{const i=k.useContext(GX);if(!i)throw new Error("Physics context not found. @react-three/cannon & components can only be used within a Physics provider");return i};new H(1,1,1);new H;new Ee;const hR=new wt;function IG(i){const e=k.useRef(null);return i&&typeof i!="function"?i:e}function pR(i){return i.charAt(0).toUpperCase()+i.slice(1)}function ei(i,e){const t=e===void 0?"":`/${e}`;return typeof i=="function"?null:i&&i.current&&`${i.current.uuid}${t}`}const F_=new Ki,N_=new Dt,Y_=i=>e=>i(F_.setFromQuaternion(N_.fromArray(e)).toArray());let BX=0;function ab(i,e,t,n,s,o){return o===void 0&&(o="bodies"),r=>{const g=BX++;t[g]={[n]:r};const a=ei(i,s);return a&&e.subscribe({props:{id:g,target:o,type:n},uuid:a}),()=>{delete t[g],e.unsubscribe({props:g})}}}function mR(i,e){let{position:t=[0,0,0],rotation:n=[0,0,0],userData:s={}}=e;i.userData=s,i.position.set(...t),i.rotation.set(...n),i.updateMatrix()}function fR(i,e,t){let{onCollide:n,onCollideBegin:s,onCollideEnd:o}=e;i[t]={collide:n,collideBegin:s,collideEnd:o}}function $C(i,e,t,n,s){n===void 0&&(n=null),s===void 0&&(s=[]);const o=IG(n),{events:r,refs:g,scaleOverrides:a,subscriptions:l,worker:I}=yX(),u=H_();k.useLayoutEffect(()=>{o.current||(o.current=new wt);const A=o.current,p=I,b=A instanceof pr?(A.instanceMatrix.setUsage(dV),A.count):1,f=A instanceof pr?new Array(b).fill(0).map((G,y)=>`${A.uuid}/${y}`):[A.uuid],h=A instanceof pr?f.map((G,y)=>{const v=e(y);return mR(hR,v),A.setMatrixAt(y,hR.matrix),A.instanceMatrix.needsUpdate=!0,g[G]=A,u==null||u.add(G,v,i),fR(r,v,G),{...v,args:t(v.args)}}):f.map((G,y)=>{const v=e(y);return mR(A,v),g[G]=A,u==null||u.add(G,v,i),fR(r,v,G),{...v,args:t(v.args)}});return p.addBodies({props:h.map(G=>{let{onCollide:y,onCollideBegin:v,onCollideEnd:W,...R}=G;return{onCollide:!!y,...R}}),type:i,uuid:f}),()=>{f.forEach(G=>{delete g[G],u==null||u.remove(G),delete r[G]}),p.removeBodies({uuid:f})}},s);const d=k.useMemo(()=>{const A=(y,v)=>{const W=`set${pR(y)}`;return{set:R=>{const x=ei(o,v);x&&I[W]({props:R,uuid:x})},subscribe:ab(o,I,l,y,v)}},p=y=>({copy:W=>{let{w:R,x,y:M,z:V}=W;const w=ei(o,y);w&&I.setQuaternion({props:[x,M,V,R],uuid:w})},set:(W,R,x,M)=>{const V=ei(o,y);V&&I.setQuaternion({props:[W,R,x,M],uuid:V})},subscribe:ab(o,I,l,"quaternion",y)}),b=y=>({copy:v=>{let{x:W,y:R,z:x}=v;const M=ei(o,y);M&&I.setRotation({props:[W,R,x],uuid:M})},set:(v,W,R)=>{const x=ei(o,y);x&&I.setRotation({props:[v,W,R],uuid:x})},subscribe:v=>{const W=BX++,R="bodies",x="quaternion",M=ei(o,y);return l[W]={[x]:Y_(v)},M&&I.subscribe({props:{id:W,target:R,type:x},uuid:M}),()=>{delete l[W],I.unsubscribe({props:W})}}}),f=(y,v)=>{const W=`set${pR(y)}`;return{copy:R=>{let{x,y:M,z:V}=R;const w=ei(o,v);w&&I[W]({props:[x,M,V],uuid:w})},set:(R,x,M)=>{const V=ei(o,v);V&&I[W]({props:[R,x,M],uuid:V})},subscribe:ab(o,I,l,y,v)}};function h(y){return{allowSleep:A("allowSleep",y),angularDamping:A("angularDamping",y),angularFactor:f("angularFactor",y),angularVelocity:f("angularVelocity",y),applyForce(v,W){const R=ei(o,y);R&&I.applyForce({props:[v,W],uuid:R})},applyImpulse(v,W){const R=ei(o,y);R&&I.applyImpulse({props:[v,W],uuid:R})},applyLocalForce(v,W){const R=ei(o,y);R&&I.applyLocalForce({props:[v,W],uuid:R})},applyLocalImpulse(v,W){const R=ei(o,y);R&&I.applyLocalImpulse({props:[v,W],uuid:R})},applyTorque(v){const W=ei(o,y);W&&I.applyTorque({props:[v],uuid:W})},collisionFilterGroup:A("collisionFilterGroup",y),collisionFilterMask:A("collisionFilterMask",y),collisionResponse:A("collisionResponse",y),fixedRotation:A("fixedRotation",y),isTrigger:A("isTrigger",y),linearDamping:A("linearDamping",y),linearFactor:f("linearFactor",y),mass:A("mass",y),material:A("material",y),position:f("position",y),quaternion:p(y),rotation:b(y),scaleOverride(v){const W=ei(o,y);W&&(a[W]=new H(...v))},sleep(){const v=ei(o,y);v&&I.sleep({uuid:v})},sleepSpeedLimit:A("sleepSpeedLimit",y),sleepTimeLimit:A("sleepTimeLimit",y),userData:A("userData",y),velocity:f("velocity",y),wakeUp(){const v=ei(o,y);v&&I.wakeUp({uuid:v})}}}const G={};return{...h(void 0),at:y=>G[y]||(G[y]=h(y))}},[]);return[o,d]}function K_(i,e,t){return $C("Plane",i,()=>[],e,t)}function L_(i,e,t){const n=[1,1,1];return $C("Box",i,function(s){return s===void 0&&(s=n),s},e,t)}function z_(i,e,t){return $C("Cylinder",i,function(n){return n===void 0&&(n=[]),n},e,t)}function T_(i,e,t){return $C("Sphere",i,function(n){if(n===void 0&&(n=[1]),!Array.isArray(n))throw new Error("useSphere args must be an array");return[n[0]]},e,t)}function vX(i,e,t){return $C("Compound",i,n=>n,e,t)}function ZX(i,e,t,n,s){n===void 0&&(n={}),s===void 0&&(s=[]);const{worker:o}=yX(),r=kh.generateUUID(),g=IG(e),a=IG(t);k.useEffect(()=>{if(g.current&&a.current)return o.addConstraint({props:[g.current.uuid,a.current.uuid,n],type:i,uuid:r}),()=>o.removeConstraint({uuid:r})},s);const l=k.useMemo(()=>{const I={disable:()=>o.disableConstraint({uuid:r}),enable:()=>o.enableConstraint({uuid:r})};return i==="Hinge"?{...I,disableMotor:()=>o.disableConstraintMotor({uuid:r}),enableMotor:()=>o.enableConstraintMotor({uuid:r}),setMotorMaxForce:u=>o.setConstraintMotorMaxForce({props:u,uuid:r}),setMotorSpeed:u=>o.setConstraintMotorSpeed({props:u,uuid:r})}:I},s);return[g,a,l]}function E_(i,e,t,n){return i===void 0&&(i=null),e===void 0&&(e=null),n===void 0&&(n=[]),ZX("PointToPoint",i,e,t,n)}function k_(i,e,t,n){return i===void 0&&(i=null),e===void 0&&(e=null),n===void 0&&(n=[]),ZX("ConeTwist",i,e,t,n)}const __=new H,U_=new H(1,1,1),D_=new Dt,AA=new Ee;function bR(i,e,t,n,s){return n===void 0&&(n=U_),i!==void 0?(AA.compose(__.fromArray(e,i*3),D_.fromArray(t,i*4),n),s&&(s.matrixAutoUpdate=!1,s.matrix.copy(AA)),AA):AA.identity()}const J_=()=>{const i=[];return e=>i.includes(e)?!1:!!i.push(e)};function P_(i){let{allowSleep:e=!1,axisIndex:t=0,broadphase:n="Naive",children:s,defaultContactMaterial:o={contactEquationStiffness:1e6},frictionGravity:r=null,gravity:g=[0,-9.81,0],isPaused:a=!1,iterations:l=5,maxSubSteps:I=10,quatNormalizeFast:u=!1,quatNormalizeSkip:d=0,shouldInvalidate:A=!0,size:p=1e3,solver:b="GS",stepSize:f=1/60,tolerance:h=.001}=i;const{invalidate:G}=Qn(),[{bodies:y,events:v,refs:W,scaleOverrides:R,subscriptions:x,worker:M}]=k.useState(()=>({bodies:{},events:{},refs:{},scaleOverrides:{},subscriptions:{},worker:new Ek({allowSleep:e,axisIndex:t,broadphase:n,defaultContactMaterial:o,frictionGravity:r,gravity:g,iterations:l,quatNormalizeFast:u,quatNormalizeSkip:d,size:p,solver:b,tolerance:h})}));let V=0;const w=k.useCallback((he,N)=>{a||(V+=N,M.step({maxSubSteps:I,stepSize:f,timeSinceLastCalled:V}),V=0)},[a,I,f]),Y=he=>{var N;let{body:D,contact:{bi:U,bj:te,...ye},target:Re,...ee}=he;const fe=(N=v[Re])==null?void 0:N.collide;fe&&fe({body:W[D],contact:{bi:W[U],bj:W[te],...ye},target:W[Re],...ee})},Q=he=>{var N,D;let{bodyA:U,bodyB:te}=he;const ye=(N=v[U])==null?void 0:N.collideBegin;ye&&ye({body:W[te],op:"event",target:W[U],type:"collideBegin"});const Re=(D=v[te])==null?void 0:D.collideBegin;Re&&Re({body:W[U],op:"event",target:W[te],type:"collideBegin"})},E=he=>{var N,D;let{bodyA:U,bodyB:te}=he;const ye=(N=v[U])==null?void 0:N.collideEnd;ye&&ye({body:W[te],op:"event",target:W[U],type:"collideEnd"});const Re=(D=v[te])==null?void 0:D.collideEnd;Re&&Re({body:W[U],op:"event",target:W[te],type:"collideEnd"})},se=he=>{let{active:N,bodies:D=[],observations:U,positions:te,quaternions:ye}=he;for(let Re=0;Re{let[ee,fe,xe]=Re;const It=(x[ee]||{})[xe];It&&It(fe)}),!!N){for(const Re of Object.values(W).filter(J_()))if(Re instanceof pr)for(let ee=0;ee{var N;let{body:D,ray:{uuid:U,...te},...ye}=he;const Re=(N=v[U])==null?void 0:N.rayhit;Re&&Re({body:D?W[D]:null,ray:{uuid:U,...te},...ye})};Yn(w),k.useEffect(()=>(M.connect(),M.init(),M.on("collide",Y),M.on("collideBegin",Q),M.on("collideEnd",E),M.on("frame",se),M.on("rayhit",ge),()=>{M.terminate(),M.removeAllListeners()}),[]),k.useEffect(()=>{M.axisIndex=t},[t]),k.useEffect(()=>{M.broadphase=n},[n]),k.useEffect(()=>{M.gravity=g},[g]),k.useEffect(()=>{M.iterations=l},[l]),k.useEffect(()=>{M.tolerance=h},[h]);const de=k.useMemo(()=>({bodies:y,events:v,refs:W,scaleOverrides:R,subscriptions:x,worker:M}),[y,v,W,x,M]);return J.jsx(GX.Provider,{value:de,children:s})}const wX=k.createRef();let Fl;const QI=new H;function bp(i){const[,,e]=E_(wX,i,{pivotA:[0,0,0],pivotB:[0,0,0]});k.useEffect(()=>void e.disable(),[]);const t=k.useCallback(o=>{Fl!=null&&(Fl=void 0,document.body.style.cursor="grab",o.target.releasePointerCapture(o.pointerId),e.disable())},[]),n=k.useCallback(o=>{Fl==null&&(Fl=o.pointerId,QI.copy(o.point),document.body.style.cursor="grabbing",o.stopPropagation(),o.target.setPointerCapture(o.pointerId),e.enable())},[]),s=k.useCallback(o=>{Fl==o.pointerId&&QI.copy(o.point)});return{onPointerUp:t,onPointerMove:s,onPointerDown:n}}function O_(){const[,i]=T_(()=>({collisionFilterMask:0,type:"Kinematic",mass:0,args:[.5]}),wX);return Yn(()=>{Fl!=null&&i.position.set(QI.x,QI.y,QI.z)}),null}function Q_(i,e=0,t=0,n=0){const s=.45*i,o=.4*i,r=.4*i,g=.15*i,a=.15*i,l=0*i,I=.28*i,u=.6*i,d=.2*i,A=.5*i,p=.15*i,b=.15*i,f=.5*i,h={color:"lightblue",args:[b,f,a],mass:i,position:[-s/3,f/2,0]},G={color:"lightblue",args:[b,f,a],mass:i,position:[s/3,f/2,0]},y={color:"lightblue",args:[p,A,a],mass:i,position:[-s/3,h.position[1]+f/2+A/2,0]},v={color:"lightblue",args:[p,A,a],mass:i,position:[s/3,G.position[1]+f/2+A/2,0]},W={color:"lightblue",args:[s,d,a],mass:i,position:[0,y.position[1]+A/2+d/2,0]},R={color:"indianred",args:[s,u,a*1.5],mass:i,position:[0,W.position[1]+d/2+u/2,0]},x={color:"lightpink",args:[I,I,I],mass:i,position:[0,R.position[1]+u/2+I/2+l,0]},M={color:"indianred",args:[o,g,g],mass:i,position:[-s/2-o/2,R.position[1]+u/2,0]},V={color:"indianred",args:[o,g,g],mass:i,position:[s/2+o/2,R.position[1]+u/2,0]},w={color:"lightpink",args:[r,a,a],mass:i,position:[M.position[0]-r/2-o/2,M.position[1],0]},Y={color:"lightpink",args:[r,a,a],mass:i,position:[V.position[0]+r/2+o/2,V.position[1],0]},Q={bodyA:"head",bodyB:"upperBody",pivotA:[0,-I-l/2,0],pivotB:[0,u/2,0],axisA:[0,1,0],axisB:[0,1,0],angle:e,twistAngle:n},E={bodyA:"lowerLeftLeg",bodyB:"upperLeftLeg",pivotA:[0,f/2,0],pivotB:[0,-A/2,0],axisA:[0,1,0],axisB:[0,1,0],angle:e,twistAngle:n},se={bodyA:"lowerRightLeg",bodyB:"upperRightLeg",pivotA:[0,f/2,0],pivotB:[0,-A/2,0],axisA:[0,1,0],axisB:[0,1,0],angle:e,twistAngle:n},ge={bodyA:"upperLeftLeg",bodyB:"pelvis",pivotA:[0,A/2,0],pivotB:[-s/3,-d/2,0],axisA:[0,1,0],axisB:[0,1,0],angle:e,twistAngle:n},de={bodyA:"upperRightLeg",bodyB:"pelvis",pivotA:[0,A/2,0],pivotB:[s/3,-d/2,0],axisA:[0,1,0],axisB:[0,1,0],angle:e,twistAngle:n},he={bodyA:"pelvis",bodyB:"upperBody",pivotA:[0,d/2,0],pivotB:[0,-u/2,0],axisA:[0,1,0],axisB:[0,1,0],angle:e,twistAngle:n},N={bodyA:"upperBody",bodyB:"upperLeftArm",pivotA:[o/2,0,0],pivotB:[-s/2,u/2,0],axisA:[1,0,0],axisB:[1,0,0],angle:t},D={bodyA:"upperBody",bodyB:"upperRightArm",pivotA:[-o/2,0,0],pivotB:[s/2,u/2,0],axisA:[1,0,0],axisB:[1,0,0],angle:t,twistAngle:n},U={bodyA:"lowerLeftArm",bodyB:"upperLeftArm",pivotA:[r/2,0,0],pivotB:[-o/2,0,0],axisA:[1,0,0],axisB:[1,0,0],angle:e,twistAngle:n},te={bodyA:"lowerRightArm",bodyB:"upperRightArm",pivotA:[-r/2,0,0],pivotB:[o/2,0,0],axisA:[1,0,0],axisB:[1,0,0],angle:e,twistAngle:n};return{shapes:{lowerLeftLeg:h,lowerRightLeg:G,upperLeftLeg:y,upperRightLeg:v,pelvis:W,upperBody:R,head:x,upperLeftArm:M,upperRightArm:V,lowerLeftArm:w,lowerRightArm:Y},joints:{neckJoint:Q,leftKneeJoint:E,rightKneeJoint:se,leftHipJoint:ge,rightHipJoint:de,spineJoint:he,leftShoulder:N,rightShoulder:D,leftElbowJoint:U,rightElbowJoint:te}}}const Hi=k.forwardRef(({children:i,transparent:e=!1,opacity:t=1,color:n="white",args:s=[1,1,1],...o},r)=>J.jsxs(tk,{args:s,receiveShadow:!0,castShadow:!0,ref:r,...o,children:[J.jsx("meshStandardMaterial",{color:n,transparent:e,opacity:t}),i]})),{shapes:j_,joints:Vo}=Q_(5.5,Math.PI/16,Math.PI/16,0),GR=k.createContext(),io=({config:i,children:e,render:t,name:n,...s})=>{const{color:o,args:r,mass:g,position:a}=j_[n],l=k.useContext(GR),[I]=L_(()=>({mass:g,args:r,position:a,linearDamping:.99,...s}));k_(I,l,i);const u=bp(I);return J.jsxs(GR.Provider,{value:I,children:[J.jsx(Hi,{castShadow:!0,receiveShadow:!0,ref:I,...s,...u,scale:r,name:n,color:o,children:t}),e]})};function q_(){const i=k.useRef(),e=k.useRef();return Yn(t=>{e.current.position.y=Math.sin(t.clock.elapsedTime*2)*.1,i.current.scale.y=(1+Math.sin(t.clock.elapsedTime*2))*.6}),J.jsxs(J.Fragment,{children:[J.jsxs("group",{ref:e,children:[J.jsx(Hi,{position:[-.3,.1,.5],args:[.2,.1,.1],color:"black",transparent:!0,opacity:.8}),J.jsx(Hi,{position:[.3,.1,.5],args:[.2,.1,.1],color:"black",transparent:!0,opacity:.8})]}),J.jsx(Hi,{ref:i,position:[0,-.2,.5],args:[.3,.05,.1],color:"#700000",transparent:!0,opacity:.8})]})}function $_(i){return J.jsxs(io,{name:"upperBody",...i,children:[J.jsx(io,{...i,name:"head",config:Vo.neckJoint,render:J.jsx(q_,{})}),J.jsx(io,{...i,name:"upperLeftArm",config:Vo.leftShoulder,children:J.jsx(io,{...i,name:"lowerLeftArm",config:Vo.leftElbowJoint})}),J.jsx(io,{...i,name:"upperRightArm",config:Vo.rightShoulder,children:J.jsx(io,{...i,name:"lowerRightArm",config:Vo.rightElbowJoint})}),J.jsxs(io,{...i,name:"pelvis",config:Vo.spineJoint,children:[J.jsx(io,{...i,name:"upperLeftLeg",config:Vo.leftHipJoint,children:J.jsx(io,{...i,name:"lowerLeftLeg",config:Vo.leftKneeJoint})}),J.jsx(io,{...i,name:"upperRightLeg",config:Vo.rightHipJoint,children:J.jsx(io,{...i,name:"lowerRightLeg",config:Vo.rightKneeJoint})})]})]})}function eU(i){const[e]=vX(()=>({mass:24,linearDamping:.95,angularDamping:.95,shapes:[{type:"Box",mass:10,position:[0,0,0],args:[3.1,3.1,.5]},{type:"Box",mass:10,position:[0,-1.75,1.25],args:[3.1,.5,3.1]},{type:"Box",mass:1,position:[-1.25,-3.5,0],args:[.5,3,.5]},{type:"Box",mass:1,position:[1.25,-3.5,0],args:[.5,3,.5]},{type:"Box",mass:1,position:[-1.25,-3.5,2.5],args:[.5,3,.5]},{type:"Box",mass:1,position:[1.25,-3.5,2.5],args:[.5,3,.5]}],...i})),t=bp(e);return J.jsxs("group",{ref:e,...t,children:[J.jsx(Hi,{position:[0,0,0],scale:[3.1,3.1,.5]}),J.jsx(Hi,{position:[0,-1.75,1.25],scale:[3.1,.5,3.1]}),J.jsx(Hi,{position:[5+-6.25,-3.5,0],scale:[.5,3,.5]}),J.jsx(Hi,{position:[5+-3.75,-3.5,0],scale:[.5,3,.5]}),J.jsx(Hi,{position:[5+-6.25,-3.5,2.5],scale:[.5,3,.5]}),J.jsx(Hi,{position:[5+-3.75,-3.5,2.5],scale:[.5,3,.5]})]})}function tU(i){const{nodes:e,materials:t}=pp("cup.glb"),[n]=z_(()=>({mass:1,args:[.62,.62,1.2,16],linearDamping:.95,angularDamping:.95,...i})),s=bp(n);return J.jsx("group",{ref:n,...s,dispose:null,children:J.jsxs("group",{rotation:[Math.PI/2,0,0],scale:[.012,.012,.012],children:[J.jsx("mesh",{receiveShadow:!0,castShadow:!0,material:t.default,geometry:e["buffer-0-mesh-0"].geometry}),J.jsx("mesh",{material:t.Liquid,geometry:e["buffer-0-mesh-0_1"].geometry})]})})}function nU(i){const[e]=vX(()=>({mass:54,linearDamping:.95,angularDamping:.95,shapes:[{type:"Box",mass:50,position:[0,0,0],args:[5,.5,5]},{type:"Box",mass:1,position:[2,-2.25,2],args:[.5,4,.5]},{type:"Box",mass:1,position:[-2,-2.25,-2],args:[.5,4,.5]},{type:"Box",mass:1,position:[-2,-2.25,2],args:[.5,4,.5]},{type:"Box",mass:1,position:[2,-2.25,-2],args:[.5,4,.5]}],...i})),t=bp(e);return J.jsxs("group",{ref:e,...t,children:[J.jsx(Hi,{scale:[5,.5,5],position:[0,0,0]}),J.jsx(Hi,{scale:[.5,4,.5],position:[2,-2.25,2]}),J.jsx(Hi,{scale:[.5,4,.5],position:[-2,-2.25,-2]}),J.jsx(Hi,{scale:[.5,4,.5],position:[-2,-2.25,2]}),J.jsx(Hi,{scale:[.5,4,.5],position:[2,-2.25,-2]})]})}function iU(i){return J.jsxs("mesh",{position:[0,10,0],children:[J.jsx("cylinderGeometry",{args:[.5,1.5,2,32]}),J.jsx("meshStandardMaterial",{}),J.jsx(sk,{castShadow:!0,penumbra:.2,radiusTop:.4,radiusBottom:40,distance:80,angle:.45,attenuation:20,anglePower:5,intensity:1,opacity:.2})]})}function EA(i,e,t){return Math.max(e,Math.min(t,i))}const sU=.05,yR=.1;function RX(i,e,t){const n=e.gamepad;if(n==null)return;const s=t.components;for(const o in s){let r=i[o];r==null&&(i[o]=r={});const{gamepadIndices:g}=s[o];let a=!1,l=!1;if(g.button!=null&&g.buttonsU)}g.xAxis!=null&&g.xAxisyR)),g.yAxis!=null&&g.yAxisyR)),r.state=a?"pressed":l?"touched":"default"}}function BR(i,e){if(e===fy)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Va||e===KC){let t=i.getIndex();if(t===null){const r=[],g=i.getAttribute("position");if(g!==void 0){for(let a=0;a=2.0 are supported."));return}const l=new KU(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let I=0;I=0&&g[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(r),l.setPlugins(g),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,o){n.parse(e,t,s,o)})}}function rU(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const Ft={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class gU{constructor(e){this.parser=e,this.name=Ft.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,r)}}class GU{constructor(e){this.parser=e,this.name=Ft.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],g=s.images[r.source];let a=n.textureLoader;if(g.uri){const l=n.options.manager.getHandler(g.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,r.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class yU{constructor(e){this.parser=e,this.name=Ft.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],g=s.images[r.source];let a=n.textureLoader;if(g.uri){const l=n.options.manager.getHandler(g.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,r.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class BU{constructor(e){this.name=Ft.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],o=this.parser.getDependency("buffer",s.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(g){const a=s.byteOffset||0,l=s.byteLength||0,I=s.count,u=s.byteStride,d=new Uint8Array(g,a,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(I,u,d,s.mode,s.filter).then(function(A){return A.buffer}):r.ready.then(function(){const A=new ArrayBuffer(I*u);return r.decodeGltfBuffer(new Uint8Array(A),I,u,d,s.mode,s.filter),A})})}else return null}}class vU{constructor(e){this.name=Ft.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const l of s.primitives)if(l.mode!==Ms.TRIANGLES&&l.mode!==Ms.TRIANGLE_STRIP&&l.mode!==Ms.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=n.extensions[this.name].attributes,g=[],a={};for(const l in r)g.push(this.parser.getDependency("accessor",r[l]).then(I=>(a[l]=I,a[l])));return g.length<1?null:(g.push(this.parser.createNodeMesh(e)),Promise.all(g).then(l=>{const I=l.pop(),u=I.isGroup?I.children:[I],d=l[0].count,A=[];for(const p of u){const b=new Ee,f=new H,h=new Dt,G=new H(1,1,1),y=new pr(p.geometry,p.material,d);for(let v=0;v0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const YU=new Ee;class KU{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new rU,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=!1,o=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||s&&o<98?this.textureLoader=new Ly(this.options.manager):this.textureLoader=new Ty(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Li(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const g={scene:r[0][s.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:s.asset,parser:n,userData:{}};return jg(o,g,s),eg(g,s),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(g)})).then(function(){for(const a of g.scenes)a.updateMatrixWorld();e(g)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,o=t.length;s{const a=this.associations.get(r);a!=null&&this.associations.set(g,a);for(const[l,I]of r.children.entries())o(I,g.children[l])};return o(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&f.setY(V,R[x*a+1]),a>=3&&f.setZ(V,R[x*a+2]),a>=4&&f.setW(V,R[x*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,r=t.images[o];let g=this.textureLoader;if(r.uri){const a=n.manager.getHandler(r.uri);a!==null&&(g=a)}return this.loadTextureImage(e,o,g)}loadTextureImage(e,t,n){const s=this,o=this.json,r=o.textures[e],g=o.images[t],a=(g.uri||g.bufferView)+":"+r.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,n).then(function(I){I.flipY=!1,I.name=r.name||g.name||"",I.name===""&&typeof g.uri=="string"&&g.uri.startsWith("data:image/")===!1&&(I.name=g.uri);const d=(o.samplers||{})[r.sampler]||{};return I.magFilter=ZR[d.magFilter]||In,I.minFilter=ZR[d.minFilter]||$i,I.wrapS=wR[d.wrapS]||Ao,I.wrapT=wR[d.wrapT]||Ao,s.associations.set(I,{textures:e}),I}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){const n=this,s=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const r=s.images[e],g=self.URL||self.webkitURL;let a=r.uri||"",l=!1;if(r.bufferView!==void 0)a=n.getDependency("bufferView",r.bufferView).then(function(u){l=!0;const d=new Blob([u],{type:r.mimeType});return a=g.createObjectURL(d),a});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const I=Promise.resolve(a).then(function(u){return new Promise(function(d,A){let p=d;t.isImageBitmapLoader===!0&&(p=function(b){const f=new jt(b);f.needsUpdate=!0,d(f)}),t.load(hs.resolveURL(u,o.path),p,void 0,A)})}).then(function(u){return l===!0&&g.revokeObjectURL(a),u.userData.mimeType=r.mimeType||NU(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=I,I}assignTexture(e,t,n,s){const o=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),o.extensions[Ft.KHR_TEXTURE_TRANSFORM]){const g=n.extensions!==void 0?n.extensions[Ft.KHR_TEXTURE_TRANSFORM]:void 0;if(g){const a=o.associations.get(r);r=o.extensions[Ft.KHR_TEXTURE_TRANSFORM].extendTexture(r,g),o.associations.set(r,a)}}return s!==void 0&&(r.colorSpace=s),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const g="PointsMaterial:"+n.uuid;let a=this.cache.get(g);a||(a=new _C,on.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(g,a)),n=a}else if(e.isLine){const g="LineBasicMaterial:"+n.uuid;let a=this.cache.get(g);a||(a=new ai,on.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(g,a)),n=a}if(s||o||r){let g="ClonedMaterial:"+n.uuid+":";s&&(g+="derivative-tangents:"),o&&(g+="vertex-colors:"),r&&(g+="flat-shading:");let a=this.cache.get(g);a||(a=n.clone(),o&&(a.vertexColors=!0),r&&(a.flatShading=!0),s&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(g,a),this.associations.set(a,this.associations.get(n))),n=a}e.material=n}getMaterialType(){return La}loadMaterial(e){const t=this,n=this.json,s=this.extensions,o=n.materials[e];let r;const g={},a=o.extensions||{},l=[];if(a[Ft.KHR_MATERIALS_UNLIT]){const u=s[Ft.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),l.push(u.extendParams(g,o,t))}else{const u=o.pbrMetallicRoughness||{};if(g.color=new Me(1,1,1),g.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;g.color.setRGB(d[0],d[1],d[2],qn),g.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(g,"map",u.baseColorTexture,ni)),g.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,g.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(g,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(g,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,g)})))}o.doubleSided===!0&&(g.side=Ns);const I=o.alphaMode||cb.OPAQUE;if(I===cb.BLEND?(g.transparent=!0,g.depthWrite=!1):(g.transparent=!1,I===cb.MASK&&(g.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&r!==Fn&&(l.push(t.assignTexture(g,"normalMap",o.normalTexture)),g.normalScale=new ce(1,1),o.normalTexture.scale!==void 0)){const u=o.normalTexture.scale;g.normalScale.set(u,u)}if(o.occlusionTexture!==void 0&&r!==Fn&&(l.push(t.assignTexture(g,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(g.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&r!==Fn){const u=o.emissiveFactor;g.emissive=new Me().setRGB(u[0],u[1],u[2],qn)}return o.emissiveTexture!==void 0&&r!==Fn&&l.push(t.assignTexture(g,"emissiveMap",o.emissiveTexture,ni)),Promise.all(l).then(function(){const u=new r(g);return o.name&&(u.name=o.name),eg(u,o),t.associations.set(u,{materials:e}),o.extensions&&jg(s,u,o),u})}createUniqueName(e){const t=Kt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function o(g){return n[Ft.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(g,t).then(function(a){return RR(a,g,t)})}const r=[];for(let g=0,a=e.length;g0&&HU(h,o),h.name=t.createUniqueName(o.name||"mesh_"+e),eg(h,o),f.extensions&&jg(s,h,f),t.assignFinalMaterial(h),u.push(h)}for(let A=0,p=u.length;A1?I=new Ls:l.length===1?I=l[0]:I=new wt,I!==l[0])for(let u=0,d=l.length;u{const u=new Map;for(const[d,A]of s.associations)(d instanceof on||d instanceof jt)&&u.set(d,A);return I.traverse(d=>{const A=s.associations.get(d);A!=null&&u.set(d,A)}),u};return s.associations=l(o),o})}_createAnimationTracks(e,t,n,s,o){const r=[],g=e.name?e.name:e.uuid,a=[];jr[o.path]===jr.weights?e.traverse(function(d){d.morphTargetInfluences&&a.push(d.name?d.name:d.uuid)}):a.push(g);let l;switch(jr[o.path]){case jr.weights:l=Rr;break;case jr.rotation:l=Eo;break;case jr.position:case jr.scale:l=Sr;break;default:switch(n.itemSize){case 1:l=Rr;break;case 2:case 3:default:l=Sr;break}break}const I=s.interpolation!==void 0?VU[s.interpolation]:Zr,u=this._getArrayFromAccessor(n);for(let d=0,A=a.length;d{t instanceof tn&&t.material instanceof on&&(t.material.colorWrite=(e==null?void 0:e.colorWrite)??!0)})}function PU(i,e){return{type:"hand",inputSource:i,pose:zU(i.hand),assetPath:UU(i.handedness,e)}}function OU({inputSource:i,pose:e},t,n){TU(e,t,i.hand,n,i.handedness)}const QU=["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"];function jU(i,e,t){const n=new Float32Array(i.size*16),s=QU.map(o=>{const r=e.getObjectByName(o);if(r==null)throw new Error(`missing joint "${o}" in hand model`);return r.matrixAutoUpdate=!1,r});return o=>{if(o==null)return;const r=typeof t=="function"?t():t;if(r==null)return;o.fillPoses(i.values(),r,n);const g=s.length;for(let a=0;at.push(s);return e.addEventListener("selectstart",n),e.addEventListener("selectend",n),e.addEventListener("select",n),e.addEventListener("squeeze",n),e.addEventListener("squeezestart",n),e.addEventListener("squeezeend",n),{cleanup(){e.removeEventListener("selectstart",n),e.removeEventListener("selectend",n),e.removeEventListener("select",n),e.removeEventListener("squeeze",n),e.removeEventListener("squeezestart",n),e.removeEventListener("squeezeend",n)},state:{type:"transientPointer",inputSource:i,events:t}}}function SR(i){if(i.hand!=null)return"hand";switch(i.targetRayMode){case"gaze":return"gaze";case"screen":return"screenInput";case"tracked-pointer":return"controller";case"transient-pointer":return"transientPointer"}}function eD(i){const e=new rJ(i);return{controller:async(t,n)=>({state:await gJ(n,e)}),hand:(t,n)=>({state:PU(n,i)}),gaze:(t,n)=>({state:{type:"gaze",inputSource:n}}),screenInput:(t,n)=>({state:{type:"screenInput",inputSource:n}}),transientPointer:(t,n)=>$U(n,t)}}function tD(i,e){let t=new Set;const n=eD(e),s=new Map;return(o,r,g,a)=>{var I;t=new Set(o.inputSources);const l={};if(a==="all"){l.controllerStates=[],l.gazeStates=[],l.handStates=[],l.screenInputStates=[],l.transientPointerStates=[];for(const u of s.values())u()}else if(a!=null){const u=a.length;for(let d=0;dh===A);if(f===-1)throw new Error(`unable to find removed input source ${A}`);b.splice(f,1),(I=s.get(A))==null||I(),s.delete(A)}}return g!=null&&g.forEach(async u=>{const d=SR(u);let A=n[d](o,u),p;if(A instanceof Promise){if(p=await A,!t.has(u))return;i[d](p.state)}else p=A,WR(`${d}States`,l,r).push(p.state);p.cleanup!=null&&s.set(u,p.cleanup)}),l}}function WR(i,e,t){let n=e[i];return n==null&&(e[i]=n=t==null?[]:[...t[i]]),n}function nD(i,e){const t=(n,s)=>{s!=null&&n.visibilityState===s.visibilityState||e(n.visibilityState==="visible")};return t(i.getState()),i.subscribe(t)}class iD extends Fn{constructor(){super({transparent:!0,toneMapped:!1,depthWrite:!1})}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.vertexShader=`varying vec2 vLocalPosition; `+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include ",`#include vLocalPosition = position.xy * 2.0;`),e.fragmentShader=`varying vec2 vLocalPosition; diff --git a/examples/rag-doll/index.html b/examples/rag-doll/index.html index 278012b..7be7388 100644 --- a/examples/rag-doll/index.html +++ b/examples/rag-doll/index.html @@ -4,7 +4,7 @@ Document - +