@splinetool/viewer 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4910,12 +4910,12 @@ gl_FragColor = vec4(resultColor, vColor.r);
4910
4910
  }
4911
4911
  `,Kp=new Qt({vertexShader:J6,fragmentShader:$6,uniforms:{depthContrast:{value:1}}}),Cm=new mh;Cm.wireframe=!0;var Ux=new M,XS=class extends Kn{constructor(e,t){super(),this.data=e,this.backupFog=new iw(16777215,.1,2e3),this.fogUseBGColor=!1,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.bgColor=new Ri(1,1,1,1),this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.needsRecomputeInstances=!1,this.ambientLight=new lD(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=H6(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=j6(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let n=r.children.indexOf(s);i.splice(0,0,n)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>M5(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner()}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(),r.resetBBoxNeedsUpdate(),Ms(r)&&cn(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r)}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),i.parent.remove(i),cn(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ms(i)&&(i.freeBooleanPointer(),r instanceof Po&&r.invalidateDownstreamBooleanData().recomputeBoolean()),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i)}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate();let n=e.localIndex;s.children.splice(n,0,s.children.pop()),Ms(i)&&(i.invalidateUpstreamBooleanData(),cn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Po&&r.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,i,r){if(t.type===0&&(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props)){let{states:n,rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}let s=this.find(e);if(s)try{k6(s,t,i,{scene:this,shared:r}),s instanceof Dr&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Yi(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Os&&this.switchActiveCamera(i)}this.expandInstances(t,!0),this.traverseEntity(i=>{cn(i)&&i.recomputeBoolean()}),this.doPendingExpandCloner()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ft.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Ft.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,n,a){e&&e!==r.uuid&&r.find(e)&&s.forInstancesRec(o=>{o.isInstanceRoot||(o.data=bd(o.data,l=>{let h=l.events.data(a.id),u=o.goUp(n);if(u){let c=[...C_(u.identity),e].join("-"),d=this.entityIdentityToEntity[c];if(d){let p=d.uuid;is.zoom(h,t)[i]=p}else{if(aa)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof bo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{r.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=bd(s.data,n=>{n.events.delete(r.id)}).data)}):r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),r.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,i,r)}),r.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,i,r)})):"actions"in r.data&&r.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,i,r)})})}),!0})}expandInstances(e,t){let i=new Set;this.traverseEntity(r=>{if(r instanceof bo&&r.isInstanceRoot)return r.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||r.resetBBoxNeedsUpdate(),!0});for(let r of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),Qg(r)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof bo&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)Vi(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new Os(XS.PERSONAL_CAMERA_ID,{...Td.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],i=r=>{for(let s of r.children)Vi(s)&&!s.raycastLock&&s.visible&&((Ms(s)||L6(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),X6(s,e,t)),i(s))};return i(this),t}forEachEntity(e){for(let t of this.children)Vi(t)&&e(t)}traverseEntity(e){for(let t of this.children)Vi(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)Ud.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Vi(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Yi(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Yi(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=Yi(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,n){let a={scene:this,shared:n},o=Zg(e,t,a);return o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,n)),o.updateState(t,a),o instanceof Dr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o)),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:n,recursive:a}=e[r],o=this.find(n),l=a?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new Gt;return i.setFromPoints(t),i.getCenter(Ux),Ux}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Qi)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof xn&&e(t.material[i]);else t.material instanceof xn&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let i,r;e>=t?(i=t/e,r=1):(i=1,r=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(n=>{n.uniforms[`f${n.id}_aspectRatio`].value.x=i,n.uniforms[`f${n.id}_aspectRatio`].value.y=r})})}},yu=XS;yu.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var ed=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},e8=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return i8(Math.atan2(r,i))},t8=(e,t,i)=>{let r={x:0,y:0};return i=Tm(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Tm=e=>e*(Math.PI/180),i8=e=>e*(180/Math.PI),r8=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,Jp=new Map,kx=e=>{Jp.has(e)&&clearTimeout(Jp.get(e)),Jp.set(e,setTimeout(e,100))},Wd=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},jx=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},YS=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),Hx=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},Pm=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},Kg=(e,t,i)=>{let r=qS(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let n="";for(let a=0,o=t.length;a<o;a+=1)n+=t[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},s8=(e,t)=>{let i=qS(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},qS=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},$p=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},n8=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},Dm=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},a8=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(QS="ontouchstart"in window,ZS=!!window.PointerEvent,KS=!!window.MSPointerEvent);var QS,ZS,KS,xl={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},so,ch={};ZS?so=xl.pointer:KS?so=xl.MSPointer:QS?(so=xl.touch,ch=xl.mouse):so=xl.mouse;function pa(){}pa.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};pa.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};pa.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(a){a.call(i,{type:s,target:i},t)})};pa.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=n8(t.options,e))};pa.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Wd(e,so[t],i._domHandlers_[t]),ch[t]&&Wd(e,ch[t],i._domHandlers_[t]),i};pa.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},jx(e,so[t],i._domHandlers_[t]),ch[t]&&jx(e,ch[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var Jg=pa;function Zt(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Zt.id,Zt.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Zt.prototype=new Jg;Zt.constructor=Zt;Zt.id=0;Zt.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Zt.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=s8("borderRadius","50%"),i=Kg("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},$p(r.el,i),this.options.shape==="circle"&&$p(r.back,t),$p(r.front,t),this.applyStyles(r),this};Zt.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};Zt.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Zt.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Zt.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Zt.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};Zt.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};Zt.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=Kg("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};Zt.prototype.restCallback=function(){var e=this,t={};t.front=Kg("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};Zt.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Zt.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,n,a;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?n="left":n="right"),e.lockX||(t>0?a="up":a="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:n,y:a,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+n,e),h.y||this.trigger("plain:"+a,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var o8=Zt;function kt(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=kt.id,kt.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}kt.prototype=new Jg;kt.constructor=kt;kt.id=0;kt.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};kt.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};kt.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};kt.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},n=i.options,a={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-a.x,y:e.y-a.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",n.zone.appendChild(o);var l=o.getBoundingClientRect();n.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new o8(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:t,position:e,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(Pm(h.ui.el,s),Pm(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};kt.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};kt.prototype.bindNipple=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};kt.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=e.force||e.pressure||e.webkitForce||0;n!==s&&(t.trigger("pressure",n),r.trigger("pressure "+t.identifier+":pressure",n),s=n)}.bind(r),100)};kt.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=YS(e),t.updateBox();var s=function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var o=[e[0]];o.identifier=a,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))};return Dm(e,s),t.manager.bindDocument(),!1};kt.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),n=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,a);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),n>0&&t.pressureFn(e,u,u.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=ed(a,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};kt.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};kt.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.scroll;if(!r8(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=ed(l,s.position),u=e8(l,s.position),c=Tm(u),d=h/o,p={distance:h,position:l},m,g;if(s.options.shape==="circle"?(m=Math.min(h,o),g=t8(s.position,m,u)):(g=a8(l,s.position,o),m=ed(g,s.position)),i.follow){if(h>o){let b=l.x-g.x,x=l.y-g.y;s.position.x+=b,s.position.y+=x,s.el.style.top=s.position.y-(t.box.top+n.y)+"px",s.el.style.left=s.position.x-(t.box.left+n.x)+"px",h=ed(l,s.position)}}else l=g,h=m;var f=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:f,y:v},i.dataOnly||Pm(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:d,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:c,degree:u},vector:{x:f/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:Tm(180-u),degree:180-u},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};kt.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[n.id]=n.identifier))};kt.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};kt.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var l8=kt;function ei(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=Hx(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(n){n.forEach(function(a){s=a.el.getBoundingClientRect(),a.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;Wd(window,"resize",function(){kx(i)});var r=function(){t.scroll=Hx()};return Wd(window,"scroll",function(){kx(r)}),t.collections}ei.prototype=new Jg;ei.constructor=ei;ei.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};ei.prototype.create=function(e){return this.createCollection(e)};ei.prototype.createCollection=function(e){var t=this,i=new l8(t,e);return t.bindCollection(i),t.collections.push(i),i};ei.prototype.bindCollection=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};ei.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};ei.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};ei.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};ei.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};ei.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};ei.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};ei.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};ei.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=YS(t);var n=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},a=function(o){r=i.getIdentifier(o),Dm(i.collections,n.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return Dm(t,a),!1};ei.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};ei.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var h8=ei,Gx=new h8,c8={create:function(e){return Gx.create(e)},factory:Gx},d8=Zd(Bb());function Ha(e,t){let i=new ke;if(!e.getAttribute("position"))return i.setAttribute("position",new Ee([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=jg(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Ee(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var u8=new Se,p8=new Se,Hr=[[0,0,0],[0,0,0],[0,0,0]];function JS(e){let t=e.elements;Hr[0][0]=t[0],Hr[0][1]=t[4],Hr[0][2]=t[8],Hr[1][0]=t[1],Hr[1][1]=t[5],Hr[1][2]=t[9],Hr[2][0]=t[2],Hr[2][1]=t[6],Hr[2][2]=t[10];let{u:i,v:r}=(0,d8.SVD)(Hr),s=u8.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),n=p8.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(n.transpose())}var f8=class extends mw{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new bn({color:65280,linewidth:10}),t=new M(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new M(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new M().addVectors(t,i.multiplyScalar(r)),n=new ke;return n.setFromPoints([t,s]),new od(n,e)}},$S=e=>e instanceof Mm||e instanceof bo;function m8(e,t){return e.distance-t.distance}function eA(e,t,i){if(!(!Vi(t)||!t.visible||t.raycastLock)){Ms(t)&&t.raycast(e,i);for(let r of t.children)eA(e,r,i)}}function Om(e,t,i){if(!i.some(s=>Xd(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>eA(e,s,r)),r.sort(m8),r}function Lm(e){let t=[];if(e.length){let i=e[0].object;Vi(i)&&t.push(i);let r=i.parent;for(;r;)$S(r)&&t.push(r),r=r.parent}return t}function Xd(e,t){if(Ms(t)){if(!t.raycastLock&&t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if($S(t))return tA(e,t)}function tA(e,t){if(!(!Vi(t)||!t.visible||t.raycastLock)){if(Ms(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=tA(e,i);if(r)return r}}}function g8(e){if(e.style.transform!==""){let t=getComputedStyle(e).getPropertyValue("transform");if(t!=="none"){let i=t.replace("matrix(","").split(",");return{x:parseFloat(i[0]),y:parseFloat(i[3])}}}return{x:1,y:1}}function Vx(e){let t=e.getViewport(new Ke),i=g8(e.domElement);return{left:t.x*i.x,top:t.y*i.y,width:t.z*i.x,height:t.w*i.y}}function v8(e,t,i,r){let s=i.height-r.height,n=(e-r.left-i.left)*(i.width/r.width),a=(t-s+r.top-i.top)*(i.height/r.height);return{x:n/i.width*2-1,y:-(a/i.height)*2+1}}var y8=class{constructor(e,t,i,r,s,n){this.isExport=n,this.raycaster=new f8,this.raycasterNeedsUpdate=!0,this.stopRaycast=!1,this._useWindowEvents=!1,this.sharedAssets=new mu(Nd.emptyData()),this.scene=new yu({...om.defaultData},this.sharedAssets),this.camera=new Os,this.renderer=e,this._useWindowEvents=t.data.publish.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect(),this._viewRect=Vx(this.renderer),this.stopRaycast=s,this.sharedAssets=r,this.scene=t,this.camera=i}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}get domRect(){return this._domRect}get viewRect(){return this._viewRect}updaterRect(){this._domRect=this.domElement.getBoundingClientRect(),this._viewRect=Vx(this.renderer)}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches!==void 0&&e.touches.length>0?e.touches[0]:e,r=v8(t-window.scrollX,i-window.scrollY,this._domRect,this._viewRect);this.raycaster.setFromCamera(r,this.camera)}},iA=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e))(iA||{}),_n=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},rA=new Map,Hl=new Map,no=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:n,delay:a,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Bl({src:l,volume:n,delay:a,loop:o}),Hl.has(i.uuid)?Hl.get(i.uuid).push(this):Hl.set(i.uuid,[this]),rA.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Im=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=rA.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Hl.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Hl.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},ao=class{constructor(e,t,i,r){if(this.data=t,t.interaction==="play")this.interaction=new no(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Im(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof no?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof no?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof no&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function x8(e,t){let i=e.material.layers.find(r=>r.uuid===t);return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var sA=new Map,Gl=new Map,Vl=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=x8(i,r);if(o)this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n);else throw new Error("Missing property");a!==void 0&&(this.delay=a),Gl.has(i.uuid)?Gl.get(i.uuid).push(this):Gl.set(i.uuid,[this]),sA.set(e,this),this.pause()}mute(){this.videoElement.muted=!0}unMute(){this.videoElement.muted=!1}play(e){let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?this.mute():t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{this.videoElement.play(),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){this.videoElement.pause(),this.status="paused"}stop(){this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay()}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){this.stop(),this.videoElement.muted=!0}},Bm=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=sA.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Gl.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Gl.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Yd=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new Vl(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Bm(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Vl?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Vl?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},b8="text/plain",w8="us-ascii",Wx=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),_8=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:n}=i.groups,a=r.split(";");n=t?"":n;let o=!1;a[a.length-1]==="base64"&&(a.pop(),o=!0);let l=(a.shift()||"").toLowerCase(),h=[...a.map(u=>{let[c,d=""]=u.split("=").map(p=>p.trim());return c==="charset"&&(d=d.toLowerCase(),d===w8)?"":`${c}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==b8)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${n?`#${n}`:""}`};function S8(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return _8(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let n=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,o="";for(;;){let h=n.exec(r.pathname);if(!h)break;let u=h[0],c=h.index,d=r.pathname.slice(a,c);o+=d.replace(/\/{2,}/g,"/"),o+=u,a=c+u.length}let l=r.pathname.slice(a,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let n=r.pathname.split("/"),a=n[n.length-1];Wx(a,t.removeDirectoryIndex)&&(n=n.slice(0,-1),r.pathname=n.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let n of[...r.searchParams.keys()])Wx(n,t.removeQueryParameters)&&r.searchParams.delete(n);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var A8=class{constructor({url:e,context:t}){if(!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:S8(e),this.context=t??"tab"}dispatch(){am?window.location.assign(this.url):this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent")}},M8=class{constructor(e,t,i,r){this.scene=t,this.sharedAssets=i,this.sceneData=e,this.managers=r}dispatch(){_A(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager.orbitControls?.reset(),this.managers.controlsManager?.gameControls.forEach(e=>e.reset(!0))}},nA={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},$g={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},E8=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],qd={CSS:{},springs:{}};function $r(e,t,i){return Math.min(Math.max(e,t),i)}function Wl(e,t){return e.indexOf(t)>-1}function ef(e,t){return e.apply(null,t)}var Fe={arr:function(e){return Array.isArray(e)},obj:function(e){return Wl(Object.prototype.toString.call(e),"Object")},pth:function(e){return Fe.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||Fe.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return Fe.hex(e)||Fe.rgb(e)||Fe.hsl(e)},key:function(e){return!nA.hasOwnProperty(e)&&!$g.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function aA(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function oA(e,t){var i=aA(e),r=$r(Fe.und(i[0])?1:i[0],.1,100),s=$r(Fe.und(i[1])?100:i[1],.1,100),n=$r(Fe.und(i[2])?10:i[2],.1,100),a=$r(Fe.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=n/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,u=1,c=l<1?(l*o+-a)/h:-a+o;function d(m){var g=t?t*m/1e3:m;return l<1?g=Math.exp(-g*l*o)*(u*Math.cos(h*g)+c*Math.sin(h*g)):g=(u+c*g)*Math.exp(-g*o),m===0||m===1?m:1-g}function p(){var m=qd.springs[e];if(m)return m;for(var g=1/6,f=0,v=0;;)if(f+=g,d(f)===1){if(v++,v>=16)break}else v=0;var y=f*g*1e3;return qd.springs[e]=y,y}return t?d:p}function C8(e){return e===void 0&&(e=10),function(t){return Math.ceil($r(t,1e-6,1)*e)*(1/e)}}var T8=function(){var e=11,t=1/(e-1);function i(u,c){return 1-3*c+3*u}function r(u,c){return 3*c-6*u}function s(u){return 3*u}function n(u,c,d){return((i(c,d)*u+r(c,d))*u+s(c))*u}function a(u,c,d){return 3*i(c,d)*u*u+2*r(c,d)*u+s(c)}function o(u,c,d,p,m){var g,f,v=0;do f=c+(d-c)/2,g=n(f,p,m)-u,g>0?d=f:c=f;while(Math.abs(g)>1e-7&&++v<10);return f}function l(u,c,d,p){for(var m=0;m<4;++m){var g=a(c,d,p);if(g===0)return c;var f=n(c,d,p)-u;c-=f/g}return c}function h(u,c,d,p){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var m=new Float32Array(e);if(u!==c||d!==p)for(var g=0;g<e;++g)m[g]=n(g*t,u,d);function f(v){for(var y=0,b=1,x=e-1;b!==x&&m[b]<=v;++b)y+=t;--b;var w=(v-m[b])/(m[b+1]-m[b]),_=y+w*t,A=a(_,u,d);return A>=.001?l(v,_,u,d):A===0?_:o(v,y,y+t,u,d)}return function(v){return u===c&&d===p||v===0||v===1?v:n(f(v),c,p)}}return h}(),lA=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,n=4;r<((s=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var n=$r(r,1,10),a=$r(s,.1,2);return function(o){return o===0||o===1?o:-n*Math.pow(2,10*(o-1))*Math.sin((o-1-a/(Math.PI*2)*Math.asin(1/n))*(Math.PI*2)/a)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(n){return Math.pow(n,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(n,a){return function(o){return 1-s(n,a)(1-o)}},e["easeInOut"+r]=function(n,a){return function(o){return o<.5?s(n,a)(o*2)/2:1-s(n,a)(o*-2+2)/2}}}),e}();function ev(e,t){if(Fe.fnc(e))return e;var i=e.split("(")[0],r=lA[i],s=aA(e);switch(i){case"spring":return oA(e,t);case"cubicBezier":return ef(T8,s);case"steps":return ef(C8,s);default:return ef(r,s)}}function hA(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function xu(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],n=0;n<i;n++)if(n in e){var a=e[n];t.call(r,a,n,e)&&s.push(a)}return s}function bu(e){return e.reduce(function(t,i){return t.concat(Fe.arr(i)?bu(i):i)},[])}function Xx(e){return Fe.arr(e)?e:(Fe.str(e)&&(e=hA(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function tv(e,t){return e.some(function(i){return i===t})}function iv(e){var t={};for(var i in e)t[i]=e[i];return t}function Rm(e,t){var i=iv(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function wu(e,t){var i=iv(e);for(var r in t)i[r]=Fe.und(e[r])?t[r]:e[r];return i}function P8(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function D8(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,u){return l+l+h+h+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),n=parseInt(r[2],16),a=parseInt(r[3],16);return"rgba("+s+","+n+","+a+",1)"}function O8(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,n=t[4]||1;function a(d,p,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(p-d)*6*m:m<1/2?p:m<2/3?d+(p-d)*(2/3-m)*6:d}var o,l,h;if(r==0)o=l=h=s;else{var u=s<.5?s*(1+r):s+r-s*r,c=2*s-u;o=a(c,u,i+1/3),l=a(c,u,i),h=a(c,u,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+n+")"}function L8(e){if(Fe.rgb(e))return P8(e);if(Fe.hex(e))return D8(e);if(Fe.hsl(e))return O8(e)}function Ts(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function I8(e){if(Wl(e,"translate")||e==="perspective")return"px";if(Wl(e,"rotate")||Wl(e,"skew"))return"deg"}function Nm(e,t){return Fe.fnc(e)?e(t.target,t.id,t.total):e}function es(e,t){return e.getAttribute(t)}function rv(e,t,i){var r=Ts(t);if(tv([i,"deg","rad","turn"],r))return t;var s=qd.CSS[t+i];if(!Fe.und(s))return s;var n=100,a=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(a),a.style.position="absolute",a.style.width=n+i;var l=n/a.offsetWidth;o.removeChild(a);var h=l*parseFloat(t);return qd.CSS[t+i]=h,h}function cA(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?rv(e,s,i):s}}function sv(e,t){if(Fe.dom(e)&&!Fe.inp(e)&&(es(e,t)||Fe.svg(e)&&e[t]))return"attribute";if(Fe.dom(e)&&tv(E8,t))return"transform";if(Fe.dom(e)&&t!=="transform"&&cA(e,t))return"css";if(e[t]!=null)return"object"}function dA(e){if(Fe.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function B8(e,t,i,r){var s=Wl(t,"scale")?1:0+I8(t),n=dA(e).get(t)||s;return i&&(i.transforms.list.set(t,n),i.transforms.last=t),r?rv(e,n,r):n}function nv(e,t,i,r){switch(sv(e,t)){case"transform":return B8(e,t,r,i);case"css":return cA(e,t,i);case"attribute":return es(e,t);default:return e[t]||0}}function av(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Ts(e)||0,s=parseFloat(t),n=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+n+r;case"-":return s-n+r;case"*":return s*n+r}}function uA(e,t){if(Fe.col(e))return L8(e);if(/\s/g.test(e))return e;var i=Ts(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function ov(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function R8(e){return Math.PI*2*es(e,"r")}function N8(e){return es(e,"width")*2+es(e,"height")*2}function z8(e){return ov({x:es(e,"x1"),y:es(e,"y1")},{x:es(e,"x2"),y:es(e,"y2")})}function pA(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var n=t.getItem(s);s>0&&(i+=ov(r,n)),r=n}return i}function F8(e){var t=e.points;return pA(e)+ov(t.getItem(t.numberOfItems-1),t.getItem(0))}function fA(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return R8(e);case"rect":return N8(e);case"line":return z8(e);case"polyline":return pA(e);case"polygon":return F8(e)}}function U8(e){var t=fA(e);return e.setAttribute("stroke-dasharray",t),t}function k8(e){for(var t=e.parentNode;Fe.svg(t)&&Fe.svg(t.parentNode);)t=t.parentNode;return t}function mA(e,t){var i=t||{},r=i.el||k8(e),s=r.getBoundingClientRect(),n=es(r,"viewBox"),a=s.width,o=s.height,l=i.viewBox||(n?n.split(" "):[0,0,a,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a/l[2],h:o/l[3]}}function j8(e,t){var i=Fe.str(e)?hA(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:mA(i),totalLength:fA(i)*(r/100)}}}function H8(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=mA(e.el,e.svg),s=i(),n=i(-1),a=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(a.y-n.y,a.x-n.x)*180/Math.PI}}function Yx(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=uA(Fe.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Fe.str(e)||t?r.split(i):[]}}function gA(e){var t=e?bu(Fe.arr(e)?e.map(Xx):Xx(e)):[];return xu(t,function(i,r,s){return s.indexOf(i)===r})}function vA(e){var t=gA(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:dA(i)}}})}function G8(e,t){var i=iv(t);if(/^spring/.test(i.easing)&&(i.duration=oA(i.easing)),Fe.arr(e)){var r=e.length,s=r===2&&!Fe.obj(e[0]);s?e={value:e}:Fe.fnc(t.duration)||(i.duration=t.duration/r)}var n=Fe.arr(e)?e:[e];return n.map(function(a,o){var l=Fe.obj(a)&&!Fe.pth(a)?a:{value:a};return Fe.und(l.delay)&&(l.delay=o?0:t.delay),Fe.und(l.endDelay)&&(l.endDelay=o===n.length-1?t.endDelay:0),l}).map(function(a){return wu(a,i)})}function V8(e){for(var t=xu(bu(e.map(function(n){return Object.keys(n)})),function(n){return Fe.key(n)}).reduce(function(n,a){return n.indexOf(a)<0&&n.push(a),n},[]),i={},r=function(n){var a=t[n];i[a]=e.map(function(o){var l={};for(var h in o)Fe.key(h)?h==a&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function W8(e,t){var i=[],r=t.keyframes;r&&(t=wu(V8(r),t));for(var s in t)Fe.key(s)&&i.push({name:s,tweens:G8(t[s],e)});return i}function X8(e,t){var i={};for(var r in e){var s=Nm(e[r],t);Fe.arr(s)&&(s=s.map(function(n){return Nm(n,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function Y8(e,t){var i;return e.tweens.map(function(r){var s=X8(r,t),n=s.value,a=Fe.arr(n)?n[1]:n,o=Ts(a),l=nv(t.target,e.name,o,t),h=i?i.to.original:l,u=Fe.arr(n)?n[0]:h,c=Ts(u)||Ts(l),d=o||c;return Fe.und(a)&&(a=h),s.from=Yx(u,d),s.to=Yx(av(a,u),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=ev(s.easing,s.duration),s.isPath=Fe.pth(n),s.isColor=Fe.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var yA={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var n="";r.list.forEach(function(a,o){n+=o+"("+a+") "}),e.style.transform=n}}};function xA(e,t){var i=vA(e);i.forEach(function(r){for(var s in t){var n=Nm(t[s],r),a=r.target,o=Ts(n),l=nv(a,s,o,r),h=o||Ts(l),u=av(uA(n,h),l),c=sv(a,s);yA[c](a,s,u,r.transforms,!0)}})}function q8(e,t){var i=sv(e.target,t.name);if(i){var r=Y8(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function Q8(e,t){return xu(bu(e.map(function(i){return t.map(function(r){return q8(i,r)})})),function(i){return!Fe.und(i)})}function bA(e,t){var i=e.length,r=function(n){return n.timelineOffset?n.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(n){return r(n)+n.duration})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(n){return r(n)+n.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(n){return r(n)+n.duration-n.endDelay})):t.endDelay,s}var qx=0;function Z8(e){var t=Rm(nA,e),i=Rm($g,e),r=W8(i,e),s=vA(e.targets),n=Q8(s,r),a=bA(n,i),o=qx;return qx++,wu(t,{id:o,children:[],animatables:s,animations:n,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}var ur=[],Qx=[],td,K8=function(){function e(){td=requestAnimationFrame(t)}function t(i){var r=ur.length;if(r){for(var s=0;s<r;){var n=ur[s];n.paused?(ur.splice(s,1),r-=1):(n.tick(i),s++)}e()}else td=cancelAnimationFrame(td)}return e}();function J8(){document.hidden?(ur.forEach(function(e){return e.pause()}),Qx=ur.slice(0),Ht.running=ur=[]):Qx.forEach(function(e){return e.play()})}typeof document<"u"&&document.addEventListener("visibilitychange",J8);function Ht(e){e===void 0&&(e={});var t=0,i=0,r=0,s,n=0,a=null;function o(b){var x=window.Promise&&new Promise(function(w){return a=w});return b.finished=x,x}var l=Z8(e),h=o(l);function u(){var b=l.direction;b!=="alternate"&&(l.direction=b!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,s.forEach(function(x){return x.reversed=l.reversed})}function c(b){return l.reversed?l.duration-b:b}function d(){t=0,i=c(l.currentTime)*(1/Ht.speed)}function p(b,x){x&&x.seek(b-x.timelineOffset)}function m(b){if(l.reversePlayback)for(var x=n;x--;)p(b,s[x]);else for(var w=0;w<n;w++)p(b,s[w])}function g(b){var x=0,w=l.animations,_=w.length;for(l.reversePlayback===!0&&l.rewind===!1&&(b=l.duration+l.delay-l.endDelay-b);x<_;){var A=w[x],S=A.animatable,E=A.tweens,C=E.length-1,T=E[C];C&&(T=xu(E,function(q){return b<q.end})[0]||T);for(var P=$r(b-T.start-T.delay,0,T.duration)/T.duration,R=isNaN(P)?1:T.easing(P),O=T.to.strings,U=T.round,j=[],z=T.to.numbers.length,L=void 0,G=0;G<z;G++){var F=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var N=T.to.numbers[G],V=T.from.numbers[G]||0;else var V=T.to.numbers[G],N=T.from.numbers[G]||0;T.isPath?F=H8(T.value,R*V):F=N+R*(V-N),U&&(T.isColor&&G>2||(F=Math.round(F*U)/U)),j.push(F)}var X=O.length;if(!X)L=j[0];else{L=O[0];for(var Z=0;Z<X;Z++){var ee=O[Z],W=O[Z+1],ne=j[Z];isNaN(ne)||(W?L+=ne+W:L+=ne+" ")}}yA[A.type](S.target,A.property,L,S.transforms),A.currentValue=L,x++}}function f(b){l[b]&&!l.passThrough&&l[b](l)}function v(){l.remaining&&l.remaining!==!0&&l.remaining--}function y(b){var x=l.duration,w=l.delay,_=x-l.endDelay,A=c(b);l.progress=$r(A/x*100,0,100),l.reversePlayback=A<l.currentTime,s&&m(A),!l.began&&l.currentTime>=0&&(l.began=!0,f("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,f("loopBegin")),A<=w&&l.currentTime!==0&&(g(0),f("change")),(A>=_&&l.currentTime!==x||!x)&&(g(x),f("change")),A>w&&A<_?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,f("changeBegin")),f("change"),g(A)):l.changeBegan?(l.changeCompleted=!0,l.changeBegan=!1,f("change"),f("changeComplete")):l.began&&A>_&&(f("change"),f("changeComplete")),l.currentTime=$r(A,0,x),l.began&&f("update"),b>=x&&(i=0,v(),l.remaining?(t=r,f("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&u()):(l.paused=!0,l.completed||(l.completed=!0,f("loopComplete"),f("complete"),!l.passThrough&&"Promise"in window&&(a(),h=o(l)))))}return l.reset=function(){var b=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=b==="reverse",l.remaining=l.loop,s=l.children,n=s.length;for(var x=n;x--;)l.children[x].reset();(l.reversed&&l.loop!==!0||b==="alternate"&&l.loop===1)&&l.remaining++,g(l.reversed?l.duration:0)},l.set=function(b,x){return xA(b,x),l},l.tick=function(b){r=b,t||(t=r),y((r+(i-t))*Ht.speed)},l.seek=function(b){y(c(b))},l.pause=function(){l.paused=!0,d()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,ur.push(l),d(),td||K8())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function Zx(e,t){for(var i=t.length;i--;)tv(e,t[i].animatable.target)&&t.splice(i,1)}function $8(e){for(var t=gA(e),i=ur.length;i--;){var r=ur[i],s=r.animations,n=r.children;Zx(t,s);for(var a=n.length;a--;){var o=n[a],l=o.animations;Zx(t,l),!l.length&&!o.children.length&&n.splice(a,1)}!s.length&&!n.length&&r.pause()}}function ej(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?ev(t.easing):null,s=t.grid,n=t.axis,a=t.from||0,o=a==="first",l=a==="center",h=a==="last",u=Fe.arr(e),c=parseFloat(u?e[0]:e),d=u?parseFloat(e[1]):0,p=Ts(u?e[1]:e)||0,m=t.start||0+(u?c:0),g=[],f=0;return function(v,y,b){if(o&&(a=0),l&&(a=(b-1)/2),h&&(a=b-1),!g.length){for(var x=0;x<b;x++){if(!s)g.push(Math.abs(a-x));else{var w=l?(s[0]-1)/2:a%s[0],_=l?(s[1]-1)/2:Math.floor(a/s[0]),A=x%s[0],S=Math.floor(x/s[0]),E=w-A,C=_-S,T=Math.sqrt(E*E+C*C);n==="x"&&(T=-E),n==="y"&&(T=-C),g.push(T)}f=Math.max.apply(Math,g)}r&&(g=g.map(function(R){return r(R/f)*f})),i==="reverse"&&(g=g.map(function(R){return n?R<0?R*-1:-R:Math.abs(f-R)}))}var P=u?(d-c)/f:c;return m+P*(Math.round(g[y]*100)/100)+p}}function tj(e){e===void 0&&(e={});var t=Ht(e);return t.duration=0,t.add=function(i,r){var s=ur.indexOf(t),n=t.children;s>-1&&ur.splice(s,1);function a(d){d.passThrough=!0}for(var o=0;o<n.length;o++)a(n[o]);var l=wu(i,Rm($g,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.direction=t.direction,l.timelineOffset=Fe.und(r)?h:av(r,h),a(t),l.rewind=t.rewind,t.seek(l.timelineOffset);var u=Ht(l);a(u),n.push(u);var c=bA(n,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}Ht.version="3.2.0";Ht.speed=1;Ht.running=ur;Ht.remove=$8;Ht.get=nv;Ht.set=xA;Ht.convertPx=rv;Ht.path=j8;Ht.setDashoffset=U8;Ht.stagger=ej;Ht.timeline=tj;Ht.easing=ev;Ht.penner=lA;Ht.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var Kx=Ht,Jx=new M,$x=new M,eb=new nt;function ij(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let n=1-s*s;if(n<=Number.EPSILON){let u=1-r;return i.w=u*e.w+r*t.w,i.x=u*e.x+r*t.x,i.y=u*e.y+r*t.y,i.z=u*e.z+r*t.z,i.normalize(),i}let a=Math.sqrt(n),o=Math.atan2(a,s),l=Math.sin((1-r)*o)/a,h=Math.sin(r*o)/a;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function Ah(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(a==null)return;let o=n??t[e],l=a;if(o!==l)return{update:h=>{let u=rt.lerp(o,l,h);s?t[e]=Math.trunc(u):t[e]=u},start:()=>{t[e]=o},end:()=>{t[e]=l}}}function wA(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=[...n??o],h=[...a];if(!(l.length!==h.length||Sg(l,h)))return{update:u=>{l.forEach((c,d)=>{let p=rt.lerp(c,h[d],u);t[e][d]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[e],l)},end:()=>{Object.assign(t[e],h)}}}function tb(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new M().fromArray(s):a.clone(),l=new M().fromArray(n);if(!o.equals(l))return{update:h=>{a.lerpVectors(o,l,h)},start:()=>{a.copy(o)},end:()=>{a.copy(l)}}}function rj(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new Se().fromArray(s):a.clone(),l=new M,h=new nt,u=new M;o.decompose(l,h,u);let c=new Se().fromArray(n),d=new M,p=new nt,m=new M;if(c.decompose(d,p,m),!o.equals(c))return{update:g=>{eb.slerpQuaternions(h,p,g),Jx.lerpVectors(l,d,g),$x.lerpVectors(u,m,g),a.compose(Jx,eb,$x)},start:()=>{a.compose(l,h,u)},end:()=>{a.compose(d,p,m)}}}function sj(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=n?typeof n=="string"?s.getColor(n).clone():new Ue().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Ue().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let u=o.clone();return t[e]=u,{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function nj(e,t,i){let r=[],s=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let a=s??e.zoom,o=n;a!==o&&r.push({update:l=>{e.zoom=rt.lerp(a,o,l),e.updateProjectionMatrix()},start:()=>{e.zoom=a,e.updateProjectionMatrix()},end:()=>{e.zoom=o,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let a=Ah("targetOffset",e,t,i);a&&r.push(a)}return r}function aj(e,t,i,r){let s=[];if(!("geometry"in i))return s;let n="geometry"in t?t.geometry:{},a=i.geometry;if(e instanceof hh){let p=n.scaleBaked??e.data.geometry.scaleBaked,m=a.scaleBaked??e.data.geometry.scaleBaked;return $n.isEqual(p,m)||s.push({update:g=>{e.updateGeometryInteractions({scaleBaked:[rt.lerp(p[0],m[0],g),rt.lerp(p[1],m[1],g),rt.lerp(p[2],m[2],g)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:p},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:m},r),e.invalidateDownstreamBooleanData()}}),s}let{width:o,height:l,depth:h}=n,{width:u,height:c,depth:d}=a;if(u!==void 0||c!==void 0||d!==void 0){let{width:p,height:m,depth:g}=e.geometry.userData.parameters,f=o??p,v=l??m,y=h??g,b=u??p,x=c??m,w=d??g;(f!==b||v!==x||y!==w)&&s.push({update:_=>{e.updateGeometryInteractions({width:rt.lerp(f,b,_),height:rt.lerp(v,x,_),depth:rt.lerp(y,w,_)},r),e.updateGeometryGroupsIfNeeded(),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({width:f,height:v,depth:y},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({width:b,height:x,depth:w},r),e.invalidateDownstreamBooleanData()}})}return s}function oj(e,t,i,r){let s=[];if(i.intensity!==void 0){let n=Ah("intensity",e,t,i);n&&s.push(n)}if(i.color!==void 0){let n=sj("color",e,t,i,r);n&&s.push(n)}return s}function lj(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let n="materials"in t&&t.materials?t.materials:[],a=i.materials;e.material.forEach((o,l)=>{if(!a[l])return;let h=n[l]??{},u=a[l];typeof h=="string"||typeof u=="string"||s.push(...ib(o,h,u,r))})}else{if(!("material"in i&&i.material))return s;let n="material"in t&&t.material?t.material:{},a=i.material;if(typeof n=="string"||typeof a=="string")return s;s.push(...ib(e.material,n,a,r))}return s}function ib(e,t,i,r){let s=[];for(let n of e.layers){let a=t.layers?.data(n.uuid),o=i.layers.data(n.uuid);if(!o||!(n.visible??!0)||!(o.visible??!0))continue;let l=n.getNames().filter(h=>!E_.some(u=>h.includes(u)));for(let h of l)try{let u=n.getValue(h),c;if(h==="colors")c=mj(n,a,o,h);else if(Array.isArray(u))h==="steps"&&(c=fj(n,a,o,h));else if(typeof u=="number")c=hj(n,a,o,h);else{if(typeof u=="boolean")continue;u instanceof H?c=cj(n,a,o,h):u instanceof M?c=dj(n,a,o,h):u instanceof Ri?c=pj(n,a,o,h,r):u instanceof Ue?c=uj(n,a,o,h,r):"isTexture"in u&&(c=gj(n,a,o,h))}c&&(Array.isArray(c)?s.push(...c):s.push(c))}catch(u){console.error(`lerpMaterial: unexpected material layer for ${h}`,u)}}return s}function hj(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:e.getValue(r),n=i[r];if(s!==n)return{update:a=>{e.setValue(r,rt.lerp(s,n,a))},start:()=>{e.setValue(r,s)},end:()=>{e.setValue(r,n)}}}function cj(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new H().fromArray(t[r]):s.clone(),a=new H().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function dj(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new M().fromArray(t[r]):s.clone(),a=new M().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function uj(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new Ue().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Ue().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let u=o.clone();return e.setValue(r,u),{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function pj(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new Ue().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Ri(a.r,a.g,a.b,a.a);if(l.equals(h))return;let u=o.clone();return e.setValue(r,u),{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function fj(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n,o=i[r];for(let l=0;l<n.length;++l){let h=a[l],u=o[l];h!==u&&s.push({update:c=>{n[l]=rt.lerp(h,u,c)},start:()=>{n[l]=h},end:()=>{n[l]=u}})}return s.length?s:void 0}function mj(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n.map(l=>l.toArray()),o=i[r];for(let l=0;l<n.length;++l){let h=[...a[l]],u=[...o[l]];Ad.isEqual(h,u)||s.push({update:c=>{n[l].fromArray(Ad.lerp(h,u,c))},start:()=>{n[l].fromArray(h)},end:()=>{n[l].fromArray(u)}})}return s.length?s:void 0}function gj(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let n=t?t[r]:s,a=i[r],o=[...n.repeat],l=[...n.offset],h=[...a.repeat],u=[...a.offset];if(!eo.isEqual(o,h)||!eo.isEqual(l,u))return{update:c=>{s.repeat=eo.lerp(o,h,c),s.offset=eo.lerp(l,u,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...u],s.updateMatrix()}}}var tf=new M,rb=new ui;function vj(e,t,i,r){let s=[],n=tb("position",e,t,i);n&&s.push(n);let a=tb("scale",e,t,i);a&&s.push(a);let o=yj(e,t,i,r);o&&s.push(o);let l=rj("hiddenMatrix",e,t,i);if(l&&s.push(l),n||a||o||l){let h=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Ms(e)&&cn(e.parent)&&e.invalidateDownstreamBooleanData(!0)};s.push({update:h,start:h,end:h})}return s}function yj(e,t,i,r){let s=t?.rotation?t.rotation:void 0,n=i.rotation;if(!n)return;let a=s?new M().fromArray(s):new M().setFromEuler(e.rotation),o=new M().fromArray(n);if(a.equals(o))return;let l=tf.subVectors(o,a);if(r&&l.toArray().every(h=>Math.abs(h)<2*Math.PI)){let h=new nt().setFromEuler(rb.setFromVector3(a)),u=new nt().setFromEuler(rb.setFromVector3(o));return{update:c=>{ij(h,u,e.quaternion,c)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}else return{update:h=>{tf.lerpVectors(a,o,h),e.rotation.setFromVector3(tf)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}function Go(e,t,i,r){if(typeof t[e]=="number")return Ah(e,t,i??{},r);if(Array.isArray(t[e]))return wA(e,t,i??{},r)}function xj(e,t,i){let r=[];if(!("cloner"in i)||!e.cloner)return r;let s=e.cloner,n="cloner"in t?t.cloner:{},a=i.cloner;b_.forEach(d=>{let p;d==="count"?p=Ah("count",s.parameters,n,a,!0):p=Go(d,s.parameters,n??{},a),p&&r.push(p)});let o=bj(s,n,a);o?.length&&r.push(...o);let l=wj(s,n,a);l?.length&&r.push(...l);let h=_j(s,n,a);h?.length&&r.push(...h);let u=Sj(s,n,a);u?.length&&r.push(...u);let c=Aj(s,n,a);return c?.length&&r.push(...c),r.length&&r.push({update:()=>{s.update()}}),r}function bj(e,t,i){if(e.parameters.type!=="radial")return;let r=t.radial,s=i.radial;if(!s)return;let n=e.parameters.radial,a=[];return w_.forEach(o=>{let l=Go(o,n,r??{},s);l&&a.push(l)}),a}function wj(e,t,i){if(e.parameters.type!=="linear")return;let r=t.linear,s=i.linear;if(!s)return;let n=[],a=e.parameters.linear;return __.forEach(o=>{let l=Go(o,a,r??{},s);l&&n.push(l)}),n}function _j(e,t,i){if(e.parameters.type!=="grid")return;let r=t.grid,s=i.grid;if(!s)return;let n=[],a=e.parameters.grid;return S_.forEach(o=>{let l;o==="count"?l=wA(o,a,r??{},s,!0):l=Go(o,a,r??{},s),l&&n.push(l)}),n}function Sj(e,t,i){if(e.parameters.type!=="toObject")return;let r=t.toObject,s=i.toObject;if(!s)return;let n=[],a=e.parameters.toObject;return A_.forEach(o=>{let l;o==="count"?l=Ah(o,a,r??{},s,!0):l=Go(o,a,r??{},s),l&&n.push(l)}),n}function Aj(e,t,i){if(!e.parameters.randomness)return;let r=t.randomnessObject,s=i.randomnessObject;if(!s)return;let n=[],a=e.parameters.randomnessObject;return M_.forEach(o=>{let l=Go(o,a,r??{},s);l&&n.push(l)}),n}function rf(e,t,i,r,s){let n=[];return e.data.visible&&n.push(...vj(e,t,i,s)),e.data.visible&&n.push(...xj(e,t,i)),Ms(e)?(e instanceof Dr&&e.data.visible&&n.push(...aj(e,t,i,r)),e.data.visible&&n.push(...lj(e,t,i,r))):O6(e)?e.data.visible&&n.push(...oj(e,t,i,r)):D6(e)&&n.push(...nj(e,t,i)),n.length?{update:a=>{n.forEach(o=>o.update(a))},start:a=>{n.forEach(o=>o.start?.(a))},end:a=>{n.forEach(o=>o.end?.(a))}}:void 0}var sb=new M;function _A(e,t,i,r=!1){let s=[];t.traverseObject(n=>{if(r&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(sb,!0),n.rigidBody?.setAngvel(sb,!0)),!Ft.is(n))return;let a=n.uuid,o=n.data;if(delete n.states,!o.states)return;let l=!1;s.some(h=>e.objects.isDescendantOf(a,h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&s.push(a),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let h of o.states)e.environment.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0||h.data.rotation!==void 0||h.data.hiddenMatrix!==void 0)||(n.states||(n.states={}),n.states[h.id]=Wn.patch(o,h.data));Mj(t,n,null,i,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0)})}function Mj(e,t,i,r,s=!1){t instanceof Dr&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof Dr&&t.updateGeometryGroupsIfNeeded()}function Ej(e){let t;switch(e.easing){case 0:t="cubicBezier( 0, 0, 1, 1 )";break;case 1:t="cubicBezier( .25, .1, .25, 1 )";break;case 2:t="cubicBezier( .42, 0, 1, 1 )";break;case 3:t="cubicBezier( 0, 0, .58, 1 )";break;case 4:t="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:i,control2:r}=e;t=`cubicBezier(
4912
4912
  ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
4913
- )`;break;case 6:let{mass:s,stiffness:n,damping:a,velocity:o}=e;t=`spring( ${s}, ${n}, ${a}, ${o} )`;break;default:t="linear"}return{duration:e.duration,easing:t}}function Cj(e){let t={delay:0,repeatDelay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=e.direction==="pingpong-rewind";else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(e.delayDirection){case"start-once":break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t}var Tj=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this.reverse=!1,this._playing=!1,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{let a,o;this.reverse?(a=this.to,o=this.from):(a=this.from,o=this.to),this.object.reversibleToState=o.id;let l=this.targets.t>.5?a.id:o.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=l,this.object.dispatchEvent({type:"beginState",state:l})},this.onChangeComplete=()=>{let a,o;this.reverse?(a=this.to,o=this.from):(a=this.from,o=this.to),this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=o.id;let l=this.targets.t<.5?a.id:o.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=l,this.object.dispatchEvent({type:"completeState",state:l})},this.onFirstLoop=()=>{if(this.useCurrentState){let a,o;this.reverse?(a=this.to,o=this.from):(a=this.from,o=this.to),this.callback=rf(this.object,a.data,o.data,this.sharedAssets,this.allowSlerp)}},t===i)throw new Error("Missing property");if(t===void 0){let a=this.getState(this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=this.getState(t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=this.getState(i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Cj(r),...Ej(r),change:this.onChange},this.callback=rf(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp),this.core=Kx({...this.params}),this.core.finished.then(()=>this._playing=!1)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}get playing(){return this._playing}getState(e){let t,i;if(typeof e=="string"?(t=e,i=this.object.states?.[t]):e===null&&(t=null,i=this.object.data),!(t===void 0||i===void 0))return{id:t,data:i}}play(){if(this._playing)return!1;this.core.play(),this._playing=!0}pause(){this.core?.pause(),this._playing=!1}stop(){this.pause(),this.seek(0),this.core?.reset(),this._playing=!1}seek(e){let t=e*(this.core?.duration??1);this.core?.seek(t)}toggle(e){this._changeBegan=!1,this._changeCompleted=!0,this.targets.t=0;let t;e!==void 0?e?(this.reverse=!1,t=this.to):(this.reverse=!0,t=this.from):this.object.reversibleToState===this.from.id?(this.reverse=!1,t=this.to):(this.reverse=!0,t=this.from),this.callback=rf(this.object,{},t.data,this.sharedAssets,this.allowSlerp),this.core=Kx({...this.params})}dispose(){this.pause()}},oo=class extends Ni{constructor(e,t,i){if(super(),this.data=e,this.scene=t,this.sharedAssets=i,!e.object)throw new Error("Missing property");let r=t.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<1)throw new Error("Missing property");this.startOnceDelay=e.tweens[1].data.delayDirection==="start-once"?e.tweens[1].data.delay:0}get playing(){return this.tween?.playing??!1}init(){try{let e=this.data.tweens[0],t=this.data.tweens[1];this.tween?.pause(),this.tween=new Tj(this.object,e.data.state,t.data.state,t.data,this.sharedAssets,this.data.allowSlerp??!1)}catch(e){e instanceof Error&&console.error(e.message)}}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.init(),this.tween?.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.tween?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.tween?.stop(),clearTimeout(this.timeoutId),delete this.timeoutId}seek(e){this.tween?.seek(e)}toggle(e){!this.tween||(clearTimeout(this.timeoutId),this.tween.changeCompleted?this.timeoutId=window.setTimeout(()=>{this.tween?.pause(),this.tween?.toggle(e),this.tween?.play()},this.startOnceDelay):(this.tween.pause(),this.tween.toggle(e),this.tween.play()))}dispose(){this.tween?.dispose()}};function oa(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Reset:[],Transition:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?al[e.type].includes("Audio")&&a.Audio.push(new ao(o,l,i,s)):l.type==="Video"?al[e.type].includes("Video")&&a.Video.push(new Yd(o,l,i)):l.type==="Link"?al[e.type].includes("Link")&&a.Link.push(new A8(l)):l.type==="Reset"?al[e.type].includes("Reset")&&a.Reset.push(new M8(r.data,r,s,n)):l.type==="Transition"&&al[e.type].includes("Transition")&&a.Transition.push(new oo(l,r,s))}catch{}}),a}function la(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof ao||i instanceof Yd||i instanceof oo)&&i.dispose()})})}var lv=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],SA=e=>lv.find(([t,i])=>i===e)?.[0],_u=e=>lv.find(([t])=>t===e)?.[1],Pj=(e,t)=>{let i=SA(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Dj=class extends _n{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target)return;let r=this.splineEvents[SA(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of lv)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=Pj(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Oj=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=oa(t,t.actions,i,r,s,n)}disconnect(){la(this.actions)}dispatch(){this.useToggle?(this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.actions.Transition.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?(this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.toggle(!0)))):this.actions.Transition.some(e=>e.playing)||(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.toggle(!1)))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},Lj=class extends _n{constructor(e,t,i){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this._prevObjects=[],this.onMouseDown=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseDown"))},this.onMouseUp=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent())},this.onMousePressRelease=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent(!0))},this.onKeyDown=n=>{this.heldKeys[n.key]||this.handleKeyEvent(n,"KeyDown"),this.heldKeys[n.key]=!0},this.onKeyUp=n=>{this.handleKeyEvent(n,"KeyUp")},this.onKeyPressDown=n=>{this.heldKeys[n.key]||this.handleKeyEvent(n,"KeyPress"),this.heldKeys[n.key]=!0},this.onKeyPressUp=n=>{this.handleKeyEvent(n,"KeyPress",!0)},this.releaseHeldKey=n=>{delete this.heldKeys[n.key]},this._onUserEvent=({eventName:n,target:a,reverse:o})=>{if(!n||!a)return;let l=_u(n);l&&(l==="MouseDown"||l==="MouseUp"||l==="MousePress"?(a.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[a.uuid]?.forEach(h=>{h.dispatchUserEvent(o)})):(l==="KeyDown"||l==="KeyUp"||l==="KeyPress")&&(a.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[a.uuid]?.forEach(h=>{h.dispatchUserEvent()})))};let{scene:r,sharedAssets:s}=this.eventContext;r.traverseEntity(n=>{if(!n.data?.events.length)return;let a=n.visible?["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"]:["KeyDown","KeyUp","KeyPress"];for(let o of a){let l=this.eventsPerObjects[o];n.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:u})=>{try{let c=new Oj(h,u,n,r,s,{controlsManager:t,eventManager:i});c.actions.Video.length&&(this.hasVideoAction=!0),l[n.uuid]?l[n.uuid].push(c):l[n.uuid]=[c]}catch{}}),l[n.uuid]?.length&&this.objectsPerTypes[o].push(n)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.domEventsNeeded.clear(),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKey),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,scene:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=Om(i,r,s);Lm(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{Xd(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,scene:a}=this.eventContext;if(s){let o=Om(n,a,i);r=Lm(o)}else i.forEach(o=>{Xd(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch())})})}},Ij=new M,Bj=new M,AA=class{constructor(e,t,i,r){this.actionsIn=oa(e,e.inActions,t,i,r),this.actionsOut=oa(e,e.outActions,t,i,r)}disconnect(){la(this.actionsIn),la(this.actionsOut)}},Rj=class extends AA{constructor(e,t,i,r){super(e,t,i,r),this.data=e,this.object=t,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{let o=Ij.setFromMatrixPosition(this.objects[0].matrixWorld),l=Bj.setFromMatrixPosition(this.objects[1].matrixWorld),h=o.distanceTo(l)<=this.distance?"in":"out";if(this.stage!==h){(this.stage==="in"?this.actionsIn:this.actionsOut).Transition.forEach(c=>c.pause());let u=h==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(c=>c.dispatchConditional()),u.Video.forEach(c=>c.dispatchConditional()),u.Transition.forEach(c=>c.play()),this.stage=h}};let{distance:s,fromObject:n,toObject:a}=e.condition;this.distance=s;for(let o of[n,a]){if(!o)throw new Error("Missing property");let l=i.find(o);if(!l)throw new Error("Missing property");this.objects.push(l)}}connect(){this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},Nj=class extends AA{constructor(e,t,i,r){super(e,t,i,r),this.data=e,this.object=t,this.onBegin=({target:a,state:o})=>{this.toState!==o&&(this.actionsOut.Audio.forEach(l=>l.dispatchConditional()),this.actionsOut.Video.forEach(l=>l.dispatchConditional()),this.actionsIn.Transition.forEach(l=>l.pause()),this.actionsOut.Transition.forEach(l=>l.play()))},this.onComplete=({target:a,state:o})=>{this.toState===o&&(this.actionsIn.Audio.forEach(l=>l.dispatchConditional()),this.actionsIn.Video.forEach(l=>l.dispatchConditional()),this.actionsOut.Transition.forEach(l=>l.pause()),this.actionsIn.Transition.forEach(l=>l.play()))};let{condition:s}=e;if(!s.object)throw new Error("Missing property");let n=i.find(s.object);if(!n)throw new Error("Missing property");if(this.toObject=n,s.state&&!this.toObject.states?.[s.state])throw new Error("Missing property");this.toState=s.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},zj=class extends _n{constructor(e){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length){for(let{data:s}of r.data.events)if(!s.disabled&&s.type==="Conditional")try{let n;s.condition.type==="Comparison"||(s.condition.type==="Distance"?n=new Rj(s,r,t,i):s.condition.type==="State"&&(n=new Nj(s,r,t,i))),n&&(this.eventsPerConditions[s.condition.type].push(n),(n.actionsIn.Video.length||n.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ga=new M,sf=new M,nf=new M,Rc=new M,nb=new ar,ab=.01,Fj={type:"requestRender"},Uj=function(){let e=new M,t=new M;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),ob=function(){let e=new Se;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t instanceof Qi&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),kj=class{constructor(e,t,i){this.data=e,this.object=t,this.tempPosition=new M,this.started=!1,this.paused=!0,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new M,this.target=e.target?i.find(e.target):void 0,this.maxDelta=e.maxDelta??0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.snapDampingFactor,this.object.getWorldPosition(this.worldPosition0)}},jj=class extends _n{constructor(e){super(e),this.events=[],this.onTargetChangeCallbacks=[],this.onMouseMove=i=>{if(!(Ze.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.tempPosition.copy(r.object.position),r.snapComplete=!1,r.isReset=!1,r.currentDampingFactor=r.snapDampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.tempPosition.copy(r.object.position),r.snapComplete=!1,(r.data.resetOnPointerLeave??!1)&&(r.isReset=!0,r.currentDampingFactor=r.snapDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new kj(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=this.onTargetChange(i);this.onTargetChangeCallbacks.push(r),i.target.addEventListener("requestRender",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);let i=0;for(let r of this.events)r.started=!1,r.paused=!0,r.target!==void 0&&r.target.removeEventListener("requestRender",this.onTargetChangeCallbacks[i++])}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tempPosition:t,object:i,maxDelta:r,plane:s}=e;if(i.getWorldPosition(nf),e.isReset)Rc.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Rc);else{let{camera:a,raycaster:o}=this.eventContext;if(s==="custom"?(a.getWorldDirection(sf),sf.negate(),Ga.copy(sf)):s==="xy"?Ga.set(0,0,1):s==="xz"?Ga.set(0,1,0):s==="yz"&&Ga.set(1,0,0),nb.setFromNormalAndCoplanarPoint(Ga,nf),!o.ray.intersectPlane(nb,Rc))return}let n=Uj(nf,Rc,r);if(e.currentDampingFactor>1||e.snapComplete===!1){e.started||(e.started=!0,t.copy(n));let a=Ga.subVectors(n,t).divideScalar(e.currentDampingFactor);t.add(a),ob(i,t),e.paused=a.length()<ab,e.snapComplete=a.length()<ab*100,e.snapComplete&&(e.currentDampingFactor=e.dampingFactor)}else ob(i,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),i.dispatchEvent(Fj)}},bl=new M,Nc=new M,Ln=new Se,wl=new nt,Va=new nt,zc=new M,af=new M,_l=new M,Fc=new ar,lb=1e-5,Hj={type:"requestRender"},Gj={type:"changeRotation"},Vj=function(){let e=new Se,t=new M,i=new M,r=new M;return(s,n)=>(n==="x"?(t.set(0,0,1),i.set(0,1,0),r.set(-1,0,0)):n==="y"?(t.set(1,0,0),i.set(0,0,1),r.set(0,-1,0)):(t.set(1,0,0),i.set(0,1,0),r.set(0,0,1)),t.applyMatrix4(s),i.applyMatrix4(s),r.applyMatrix4(s),e.makeBasis(t,i,r))}(),hb=function(){let e=new Se;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(JS(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Qi&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Wj=class{constructor(e,t,i){this.data=e,this.object=t,this.paused=!0,this.snapComplete=!1,this.isReset=!1,this.worldQuaternion0=new nt,this.target=e.target?i.find(e.target):void 0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.distance=e.distance??0,this.tilt=e.tilt??"up",this.axis=e.axis??"z",this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.dampingFactor,this.object.getWorldQuaternion(this.worldQuaternion0)}},Xj=class extends _n{constructor(e){super(e),this.events=[],this.onTargetChangeCallbacks=[],this.onMouseMove=i=>{if(!(Ze.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.snapComplete=!1,r.isReset=!1,r.currentDampingFactor=r.snapDampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.snapComplete=!1,(r.data.resetOnPointerLeave??!1)&&(r.isReset=!0,r.currentDampingFactor=r.snapDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Wj(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=this.onTargetChange(i);this.onTargetChangeCallbacks.push(r),i.target.addEventListener("requestRender",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);let i=0;for(let r of this.events)r.paused=!0,r.target!==void 0&&r.target.removeEventListener("requestRender",this.onTargetChangeCallbacks[i++])}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{target:t,tilt:i,axis:r,distance:s,plane:n,object:a}=e,{camera:o,raycaster:l}=this.eventContext;if(a.getWorldPosition(zc),!e.isReset){if(e.target)e.target.getWorldPosition(af);else if(n==="custom"?(o.getWorldDirection(Nc),Nc.negate(),s>0?Fc.set(Nc,-s):Fc.setFromNormalAndCoplanarPoint(Nc,zc)):(n==="xy"?bl.set(0,0,1):n==="xz"?bl.set(0,1,0):n==="yz"&&bl.set(1,0,0),Fc.setFromNormalAndCoplanarPoint(bl,zc)),!l.ray.intersectPlane(Fc,af))return}e.isReset||(t?i==="up"?_l.set(0,1,0):i==="target"&&_l.copy(t.up).applyMatrix4(Ln.extractRotation(t.matrixWorld)).normalize():n==="custom"?_l.set(0,1,0):_l.copy(bl)),e.isReset?Va.copy(e.worldQuaternion0):(Ln.lookAt(af,zc,_l),Ln.copy(Vj(Ln,r)),Va.setFromRotationMatrix(Ln)),e.currentDampingFactor>1||e.snapComplete===!1?(a.updateWorldMatrix(!0,!1),wl.setFromRotationMatrix(JS(a.matrixWorld)),wl.slerp(Va,1/e.currentDampingFactor),hb(a,Ln.makeRotationFromQuaternion(wl)),e.paused=8*(1-wl.dot(Va))<lb,e.snapComplete=8*(1-wl.dot(Va))<lb*100,e.snapComplete&&(e.currentDampingFactor=e.dampingFactor)):(hb(a,Ln.makeRotationFromQuaternion(Va)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),a.dispatchEvent(Hj),a.dispatchEvent(Gj)}},Yj=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=oa(t,t.actions,i,r,s)}disconnect(){la(this.actions)}dispatchEnter(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.toggle(!0)))}dispatchLeave(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.toggle(!1)))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>t.toggle(!e))}},qj=class extends _n{constructor(e){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=r=>{Ze.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseHoverEvent())},this.onMouseUp=r=>{Ze.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=r=>{Ze.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=_u(r);a&&a==="MouseHover"&&(s.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[s.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(!(!r.visible||!r.data?.events.length)){for(let{id:s,data:n}of r.data.events)if(!n.disabled&&n.type==="MouseHover")try{let a=new Yj(s,n,r,t,i);this.eventsPerObjects[r.uuid]?this.eventsPerObjects[r.uuid].push(a):this.eventsPerObjects[r.uuid]=[a]}catch{}this.eventsPerObjects[r.uuid]?.length&&this.objects.push(r)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Si&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Si&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,scene:s}=this.eventContext;if(i){let n=Om(r,s,this.objects);t=Lm(n)}else this.objects.forEach(n=>{Xd(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},Qj=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=oa(t,t.actions,i,r,s)}connect(){this.scrollCounter=0}disconnect(){la(this.actions)}dispatch(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(r=>{r.init()}));let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)})}},Zj=class extends _n{constructor(e){super(e),this.eventsPerObject=new Map,this.onWheel=r=>{[...this.eventsPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:r.deltaY}),n.forEach(a=>a.dispatch(r.deltaY))})},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=_u(r);a&&a==="Scroll"&&(s.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.eventsPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length)for(let{id:s,data:n}of r.data.events){if(n.disabled||n.type!=="Scroll")continue;let a=new Qj(s,n,r,t,i);this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])}})}connect(){[...this.eventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.eventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel))}disconnect(){window.removeEventListener("wheel",this.onWheel),this.domEventsNeeded.clear(),[...this.eventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},Kj=class{constructor(e,t,i,r){this.data=e,this.object=t,this.actions=oa(e,e.actions,t,i,r)}disconnect(){la(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof no?t.interaction.audioPlayer.play():t.interaction instanceof Im&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Vl?t.interaction.play(i==="autoplay"):t.interaction instanceof Bm&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Audio.forEach(t=>{t.interaction instanceof no?t.interaction.audioPlayer.play():t.interaction instanceof Im&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Vl?t.interaction.play():t.interaction instanceof Bm&&t.interaction.dispatch()})}},Jj=class extends _n{constructor(e){super(e),this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:r,isExport:s}=this.eventContext;(s?document:r).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(o=>{o.dispatchAfter("any")})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=_u(r);a&&a==="Start"&&(s.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length)for(let{data:s}of r.data.events){if(s.disabled||s.type!=="Start")continue;let n=new Kj(s,r,t,i);n.actions.Transition.length&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(i=>i.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())})}},$j=class{constructor(e,t,i,r){this.data=e,this.object=t,this.disabled=!0,this.actions=oa(e,e.actions,t,i,r),this.target=e.target,this.useToggle=e.toggle}disconnect(){la(this.actions)}dispatch(){this.disabled||(this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}},Ot;Gz.then(e=>Ot=e);var bi=new M,qs=new nt,In=new M,of=new ui(0,0,0,"YXZ"),eH={type:"updateMatrix"},MA={type:"beginEvent",eventName:"Collision"};function tH(e){if(e.scene.environment.usePhysics)return!0;let t=!1;return e.scene.objects.traverse((i,r)=>{for(let s of r.events)if(s.data.disabled!==!0&&s.data.type==="GameControl"&&s.data.collisionEnabled){t=!0;break}}),t}var cb=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0),db=e=>e.events.find(t=>t.data.disabled!==!0&&t.data.type==="Follow"),iH=class{constructor(e,t,i,r,s,n=!1){this.scene=t,this.sharedAssets=s,this.isExport=n,this.orbitControlsNeedsUpdate=!0,this.gameControls=[],this.gameControlStates=[],this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{},gamePads:[]},this.needsCollisionDetection=!1,this.initializationCounter=-1,this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.processRigidBody=f=>{if(f.bodyType()!==Ot.RigidBodyType.Dynamic)return;f.isSleeping()||this.nActiveRigidBodies++;let[v,y,b]=this.rigidBodyToMesh.get(f.handle);if(bi.copy(f.translation()).multiplyScalar(this.pixelsPerMeter),qs.copy(f.rotation()),v.matrixWorld.compose(bi,qs,y),v.hasNonUniformScale&&v.matrixWorld.multiply(v.shearScale),v.dispatchEvent(eH),b){let x=v.cloner;if(x&&x.objectForSample===void 0){x.matrixWorld.copy(v.matrixWorld);for(let w of x.children)w.updateMatrixWorld(!0)}for(let w of v.children)w.updateMatrixWorld(!0)}},this.handleCollisionEvents=(f,v,y)=>{if(y!==!1)if(this.gameControls.some(b=>b.object===this.sharedGameControlGlobals.colliderToEntity[f])){let b=this.sharedGameControlGlobals.colliderToEntity[v],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x===void 0)return;for(let w of x)w.data.target==="character"&&this.dispatchCollisionEvent(w,b)}else if(this.gameControls.some(b=>b.object===this.sharedGameControlGlobals.colliderToEntity[v])){let b=this.sharedGameControlGlobals.colliderToEntity[f],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x===void 0)return;for(let w of x)w.data.target==="character"&&this.dispatchCollisionEvent(w,b)}else{let b=this.sharedGameControlGlobals.colliderToEntity[f],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x!==void 0)for(let A of x)A.data.target==="scene"&&this.dispatchCollisionEvent(A,b);let w=this.sharedGameControlGlobals.colliderToEntity[v],_=this.sharedGameControlGlobals.eventsPerObjects[w?.uuid];if(_!==void 0)for(let A of _)A.data.target==="scene"&&this.dispatchCollisionEvent(A,w)}},this.onBeginState=()=>{this.orbitControls&&(this.orbitControls.enabled=!1,this.orbitControlsNeedsUpdate=!1)},this.onCompleteState=({target:f})=>{this.orbitControls&&(this.orbitControls.enabled=!0,this.orbitControls.resetTo(f.getTarget(bi),f.position,f.zoom,f.isUpVectorFlipped),f.prevState=null,f.currentState=null,f.reversibleToState=null,f.currentTransitionEvent=null,this.orbitControlsNeedsUpdate=!0)},this.domElement=i.domElement;let a;e.scene.publish.playCamera===null?a=yu.PERSONAL_CAMERA_ID:a=e.scene.publish.playCamera;let o=this.scene.find(a),l=!1,h,u=5,c=8,d=9,p="drag";if(this.usePhysics=e.scene.environment.usePhysics??ji.defaultData.usePhysics,this.pixelsPerMeter=e.scene.environment.pixelsPerMeter??ji.defaultData.pixelsPerMeter,e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach(f=>{f.data.disabled!==!0&&f.data.type==="GameControl"&&(h=f.data.keyAssignments,u=f.data.joystickPosLoc,c=f.data.joystickRotLoc,d=f.data.jumpTouchButtonLoc,p=f.data.rotByTouch)}),this.scene.traverseEntity(f=>{f.dataPatched.events.forEach(v=>{if(v.data.disabled||v.data.type!=="GameControl")return;let y=f;for(;(y=y.parent)?.parent!==null;)if(y.dataPatched.physics?.fusedBody)return;v.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([f,v.data])})}),this.usePhysics&&this.initPhysics(e.scene.environment.gravity??ji.defaultData.gravity),this.gameControlStates.forEach(([f,v])=>{l=l||v.camera===o.uuid||f.uuid===o.uuid;let y=new EA(f,i.domElement,{...v,keyAssignments:h},e.scene.environment,this.sharedGameControlGlobals,f.uuid!==o.uuid&&v.camera===o.uuid,o,this.scene,s);y.addEventListener("change",r),y.addEventListener("end",r),y.addEventListener("start",r),this.gameControls.push(y),Si&&v.touchControl&&(this.joystickToGameControls[u]!==void 0?this.joystickToGameControls[u].push([y,"pos"]):this.joystickToGameControls[u]=[[y,"pos"]],v.moveMode==="walk"&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([y,"jmp"]):this.joystickToGameControls[d]=[[y,"jmp"]]),p==="joystick"&&(this.joystickToGameControls[c]!==void 0?this.joystickToGameControls[c].push([y,"rot"]):this.joystickToGameControls[c]=[[y,"rot"]]))}),l===!1){let{enableRotate:f,enablePan:v,enableZoom:y,autoRotate:b,hoverRotatePanMode:x}=e.scene.publish.orbitControls;if(f||v||y||b||x!==0){this.orbitControls=new CA(o,i.domElement,this.isExport),this.orbitControls.addEventListener("change",r),this.orbitControls.addEventListener("end",r),this.orbitControls.addEventListener("start",r),this.orbitControls.fromJSON(e.scene.publish.orbitControls,e.scene.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.connect(),this.orbitControls.update();let w=this.orbitControls.object;w.addEventListener("beginState",this.onBeginState),w.addEventListener("completeState",this.onCompleteState)}}let m=i.domElement.width/i.getPixelRatio(),g=i.domElement.height/i.getPixelRatio();this.joystickToGameControls.forEach((f,v)=>{let y=document.body.appendChild(document.createElement("div")),[b,x,w]=(e.scene.publish.joystickSizeAndXYOffset??To.defaultData.joystickSizeAndXYOffset)[v],_=(m-5*b)/4+b,A={},S=f.some(P=>P[1]==="jmp"),E=S?0:b;v<10?(v<5?A.top=E/2:A.bottom=E/2,A.left=E/2+v%5*_):v===10?(A.left=E/2,A.top=g/2):(A.right=E/2,A.top=g/2),A.top?A.top-=x[1]:A.bottom+=x[1],A.left?A.left+=x[0]:A.right-=x[0];for(let P in A)A[P]+="px";if(S){let P=y.appendChild(document.createElement("div"));Object.assign(P.style,A,{position:"absolute",width:b+"px",height:b+"px",backgroundColor:`rgba(255,255,255,${w==="show"?.4:0})`,zIndex:"9999",borderRadius:b+"px",border:w==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let R=b/16*16*.4;w==="show"&&(P.innerHTML=`
4913
+ )`;break;case 6:let{mass:s,stiffness:n,damping:a,velocity:o}=e;t=`spring( ${s}, ${n}, ${a}, ${o} )`;break;default:t="linear"}return{duration:e.duration,easing:t}}function Cj(e){let t={delay:0,repeatDelay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=e.direction==="pingpong-rewind";else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(e.delayDirection){case"start-once":break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t}var Tj=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this.reverse=!1,this._playing=!1,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{let a,o;this.reverse?(a=this.to,o=this.from):(a=this.from,o=this.to),this.object.reversibleToState=o.id;let l=this.targets.t>.5?a.id:o.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=l,this.object.dispatchEvent({type:"beginState",state:l})},this.onChangeComplete=()=>{let a,o;this.reverse?(a=this.to,o=this.from):(a=this.from,o=this.to),this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=o.id;let l=this.targets.t<.5?a.id:o.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=l,this.object.dispatchEvent({type:"completeState",state:l})},this.onFirstLoop=()=>{if(this.useCurrentState){let a,o;this.reverse?(a=this.to,o=this.from):(a=this.from,o=this.to),this.callback=rf(this.object,a.data,o.data,this.sharedAssets,this.allowSlerp)}},t===i)throw new Error("Missing property");if(t===void 0){let a=this.getState(this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=this.getState(t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=this.getState(i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Cj(r),...Ej(r),change:this.onChange},this.callback=rf(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp),this.core=Kx({...this.params}),this.core.finished.then(()=>this._playing=!1)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}get playing(){return this._playing}getState(e){let t,i;if(typeof e=="string"?(t=e,i=this.object.states?.[t]):e===null&&(t=null,i=this.object.data),!(t===void 0||i===void 0))return{id:t,data:i}}play(){if(this._playing)return!1;this.core.play(),this._playing=!0}pause(){this.core?.pause(),this._playing=!1}stop(){this.pause(),this.seek(0),this.core?.reset(),this._playing=!1}seek(e){let t=e*(this.core?.duration??1);this.core?.seek(t)}toggle(e){this._changeBegan=!1,this._changeCompleted=!0,this.targets.t=0;let t;e!==void 0?e?(this.reverse=!1,t=this.to):(this.reverse=!0,t=this.from):this.object.reversibleToState===this.from.id?(this.reverse=!1,t=this.to):(this.reverse=!0,t=this.from),this.callback=rf(this.object,{},t.data,this.sharedAssets,this.allowSlerp),this.core=Kx({...this.params})}dispose(){this.pause()}},oo=class extends Ni{constructor(e,t,i){if(super(),this.data=e,this.scene=t,this.sharedAssets=i,!e.object)throw new Error("Missing property");let r=t.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<1)throw new Error("Missing property");this.startOnceDelay=e.tweens[1].data.delayDirection==="start-once"?e.tweens[1].data.delay:0}get playing(){return this.tween?.playing??!1}init(){try{let e=this.data.tweens[0],t=this.data.tweens[1];this.tween?.pause(),this.tween=new Tj(this.object,e.data.state,t.data.state,t.data,this.sharedAssets,this.data.allowSlerp??!1)}catch(e){e instanceof Error&&console.error(e.message)}}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.init(),this.tween?.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.tween?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.tween?.stop(),clearTimeout(this.timeoutId),delete this.timeoutId}seek(e){this.tween?.seek(e)}toggle(e){!this.tween||(clearTimeout(this.timeoutId),this.tween.changeCompleted?this.timeoutId=window.setTimeout(()=>{this.tween?.pause(),this.tween?.toggle(e),this.tween?.play()},this.startOnceDelay):(this.tween.pause(),this.tween.toggle(e),this.tween.play()))}dispose(){this.tween?.dispose()}};function oa(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Reset:[],Transition:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?al[e.type].includes("Audio")&&a.Audio.push(new ao(o,l,i,s)):l.type==="Video"?al[e.type].includes("Video")&&a.Video.push(new Yd(o,l,i)):l.type==="Link"?al[e.type].includes("Link")&&a.Link.push(new A8(l)):l.type==="Reset"?al[e.type].includes("Reset")&&a.Reset.push(new M8(r.data,r,s,n)):l.type==="Transition"&&al[e.type].includes("Transition")&&a.Transition.push(new oo(l,r,s))}catch{}}),a}function la(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof ao||i instanceof Yd||i instanceof oo)&&i.dispose()})})}var lv=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],SA=e=>lv.find(([t,i])=>i===e)?.[0],_u=e=>lv.find(([t])=>t===e)?.[1],Pj=(e,t)=>{let i=SA(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Dj=class extends _n{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target)return;let r=this.splineEvents[SA(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of lv)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=Pj(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Oj=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=oa(t,t.actions,i,r,s,n)}disconnect(){la(this.actions)}dispatch(){this.useToggle?(this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.actions.Transition.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?(this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.toggle(!0)))):this.actions.Transition.some(e=>e.playing)||(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.toggle(!1)))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},Lj=class extends _n{constructor(e,t,i){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this._prevObjects=[],this.onMouseDown=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseDown"))},this.onMouseUp=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent())},this.onMousePressRelease=n=>{Ze.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent(!0))},this.onKeyDown=n=>{this.heldKeys[n.key]||this.handleKeyEvent(n,"KeyDown"),this.heldKeys[n.key]=!0},this.onKeyUp=n=>{this.handleKeyEvent(n,"KeyUp")},this.onKeyPressDown=n=>{this.heldKeys[n.key]||this.handleKeyEvent(n,"KeyPress"),this.heldKeys[n.key]=!0},this.onKeyPressUp=n=>{this.handleKeyEvent(n,"KeyPress",!0)},this.releaseHeldKey=n=>{delete this.heldKeys[n.key]},this._onUserEvent=({eventName:n,target:a,reverse:o})=>{if(!n||!a)return;let l=_u(n);l&&(l==="MouseDown"||l==="MouseUp"||l==="MousePress"?(a.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[a.uuid]?.forEach(h=>{h.dispatchUserEvent(o)})):(l==="KeyDown"||l==="KeyUp"||l==="KeyPress")&&(a.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[a.uuid]?.forEach(h=>{h.dispatchUserEvent()})))};let{scene:r,sharedAssets:s}=this.eventContext;r.traverseEntity(n=>{if(!n.data?.events.length)return;let a=n.visible?["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"]:["KeyDown","KeyUp","KeyPress"];for(let o of a){let l=this.eventsPerObjects[o];n.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:u})=>{try{let c=new Oj(h,u,n,r,s,{controlsManager:t,eventManager:i});c.actions.Video.length&&(this.hasVideoAction=!0),l[n.uuid]?l[n.uuid].push(c):l[n.uuid]=[c]}catch{}}),l[n.uuid]?.length&&this.objectsPerTypes[o].push(n)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.domEventsNeeded.clear(),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKey),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,scene:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=Om(i,r,s);Lm(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{Xd(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,scene:a}=this.eventContext;if(s){let o=Om(n,a,i);r=Lm(o)}else i.forEach(o=>{Xd(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch())})})}},Ij=new M,Bj=new M,AA=class{constructor(e,t,i,r){this.actionsIn=oa(e,e.inActions,t,i,r),this.actionsOut=oa(e,e.outActions,t,i,r)}disconnect(){la(this.actionsIn),la(this.actionsOut)}},Rj=class extends AA{constructor(e,t,i,r){super(e,t,i,r),this.data=e,this.object=t,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{let o=Ij.setFromMatrixPosition(this.objects[0].matrixWorld),l=Bj.setFromMatrixPosition(this.objects[1].matrixWorld),h=o.distanceTo(l)<=this.distance?"in":"out";if(this.stage!==h){(this.stage==="in"?this.actionsIn:this.actionsOut).Transition.forEach(c=>c.pause());let u=h==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(c=>c.dispatchConditional()),u.Video.forEach(c=>c.dispatchConditional()),u.Transition.forEach(c=>c.play()),this.stage=h}};let{distance:s,fromObject:n,toObject:a}=e.condition;this.distance=s;for(let o of[n,a]){if(!o)throw new Error("Missing property");let l=i.find(o);if(!l)throw new Error("Missing property");this.objects.push(l)}}connect(){this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},Nj=class extends AA{constructor(e,t,i,r){super(e,t,i,r),this.data=e,this.object=t,this.onBegin=({target:a,state:o})=>{this.toState!==o&&(this.actionsOut.Audio.forEach(l=>l.dispatchConditional()),this.actionsOut.Video.forEach(l=>l.dispatchConditional()),this.actionsIn.Transition.forEach(l=>l.pause()),this.actionsOut.Transition.forEach(l=>l.play()))},this.onComplete=({target:a,state:o})=>{this.toState===o&&(this.actionsIn.Audio.forEach(l=>l.dispatchConditional()),this.actionsIn.Video.forEach(l=>l.dispatchConditional()),this.actionsOut.Transition.forEach(l=>l.pause()),this.actionsIn.Transition.forEach(l=>l.play()))};let{condition:s}=e;if(!s.object)throw new Error("Missing property");let n=i.find(s.object);if(!n)throw new Error("Missing property");if(this.toObject=n,s.state&&!this.toObject.states?.[s.state])throw new Error("Missing property");this.toState=s.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},zj=class extends _n{constructor(e){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length){for(let{data:s}of r.data.events)if(!s.disabled&&s.type==="Conditional")try{let n;s.condition.type==="Comparison"||(s.condition.type==="Distance"?n=new Rj(s,r,t,i):s.condition.type==="State"&&(n=new Nj(s,r,t,i))),n&&(this.eventsPerConditions[s.condition.type].push(n),(n.actionsIn.Video.length||n.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ga=new M,sf=new M,nf=new M,Rc=new M,nb=new ar,ab=.01,Fj={type:"requestRender"},Uj=function(){let e=new M,t=new M;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),ob=function(){let e=new Se;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t instanceof Qi&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),kj=class{constructor(e,t,i){this.data=e,this.object=t,this.tempPosition=new M,this.started=!1,this.paused=!0,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new M,this.target=e.target?i.find(e.target):void 0,this.maxDelta=e.maxDelta??0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.snapDampingFactor,this.object.getWorldPosition(this.worldPosition0)}},jj=class extends _n{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(Ze.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.tempPosition.copy(r.object.position),r.snapComplete=!1,r.isReset=!1,r.currentDampingFactor=r.snapDampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.tempPosition.copy(r.object.position),r.snapComplete=!1,(r.data.resetOnPointerLeave??!1)&&(r.isReset=!0,r.currentDampingFactor=r.snapDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new kj(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.started=!1,i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tempPosition:t,object:i,maxDelta:r,plane:s}=e;if(i.getWorldPosition(nf),e.isReset)Rc.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Rc);else{let{camera:a,raycaster:o}=this.eventContext;if(s==="custom"?(a.getWorldDirection(sf),sf.negate(),Ga.copy(sf)):s==="xy"?Ga.set(0,0,1):s==="xz"?Ga.set(0,1,0):s==="yz"&&Ga.set(1,0,0),nb.setFromNormalAndCoplanarPoint(Ga,nf),!o.ray.intersectPlane(nb,Rc))return}let n=Uj(nf,Rc,r);if(e.currentDampingFactor>1||e.snapComplete===!1){e.started||(e.started=!0,t.copy(n));let a=Ga.subVectors(n,t).divideScalar(e.currentDampingFactor);t.add(a),ob(i,t),e.paused=a.length()<ab,e.snapComplete=a.length()<ab*100,e.snapComplete&&(e.currentDampingFactor=e.dampingFactor)}else ob(i,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),i.dispatchEvent(Fj)}},bl=new M,Nc=new M,Ln=new Se,wl=new nt,Va=new nt,zc=new M,af=new M,_l=new M,Fc=new ar,lb=1e-5,Hj={type:"requestRender"},Gj={type:"changeRotation"},Vj=function(){let e=new Se,t=new M,i=new M,r=new M;return(s,n)=>(n==="x"?(t.set(0,0,1),i.set(0,1,0),r.set(-1,0,0)):n==="y"?(t.set(1,0,0),i.set(0,0,1),r.set(0,-1,0)):(t.set(1,0,0),i.set(0,1,0),r.set(0,0,1)),t.applyMatrix4(s),i.applyMatrix4(s),r.applyMatrix4(s),e.makeBasis(t,i,r))}(),hb=function(){let e=new Se;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(JS(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Qi&&cn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Wj=class{constructor(e,t,i){this.data=e,this.object=t,this.paused=!0,this.snapComplete=!1,this.isReset=!1,this.worldQuaternion0=new nt,this.target=e.target?i.find(e.target):void 0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.distance=e.distance??0,this.tilt=e.tilt??"up",this.axis=e.axis??"z",this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.dampingFactor,this.object.getWorldQuaternion(this.worldQuaternion0)}},Xj=class extends _n{constructor(e){super(e),this.events=[],this.onTargetChangeCallbacks=[],this.onMouseMove=i=>{if(!(Ze.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.snapComplete=!1,r.isReset=!1,r.currentDampingFactor=r.snapDampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.snapComplete=!1,(r.data.resetOnPointerLeave??!1)&&(r.isReset=!0,r.currentDampingFactor=r.snapDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Wj(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=this.onTargetChange(i);this.onTargetChangeCallbacks.push(r),i.target.addEventListener("requestRender",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Si&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);let i=0;for(let r of this.events)r.paused=!0,r.target!==void 0&&r.target.removeEventListener("requestRender",this.onTargetChangeCallbacks[i++])}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{target:t,tilt:i,axis:r,distance:s,plane:n,object:a}=e,{camera:o,raycaster:l}=this.eventContext;if(a.getWorldPosition(zc),!e.isReset){if(e.target)e.target.getWorldPosition(af);else if(n==="custom"?(o.getWorldDirection(Nc),Nc.negate(),s>0?Fc.set(Nc,-s):Fc.setFromNormalAndCoplanarPoint(Nc,zc)):(n==="xy"?bl.set(0,0,1):n==="xz"?bl.set(0,1,0):n==="yz"&&bl.set(1,0,0),Fc.setFromNormalAndCoplanarPoint(bl,zc)),!l.ray.intersectPlane(Fc,af))return}e.isReset||(t?i==="up"?_l.set(0,1,0):i==="target"&&_l.copy(t.up).applyMatrix4(Ln.extractRotation(t.matrixWorld)).normalize():n==="custom"?_l.set(0,1,0):_l.copy(bl)),e.isReset?Va.copy(e.worldQuaternion0):(Ln.lookAt(af,zc,_l),Ln.copy(Vj(Ln,r)),Va.setFromRotationMatrix(Ln)),e.currentDampingFactor>1||e.snapComplete===!1?(a.updateWorldMatrix(!0,!1),wl.setFromRotationMatrix(JS(a.matrixWorld)),wl.slerp(Va,1/e.currentDampingFactor),hb(a,Ln.makeRotationFromQuaternion(wl)),e.paused=8*(1-wl.dot(Va))<lb,e.snapComplete=8*(1-wl.dot(Va))<lb*100,e.snapComplete&&(e.currentDampingFactor=e.dampingFactor)):(hb(a,Ln.makeRotationFromQuaternion(Va)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),a.dispatchEvent(Hj),a.dispatchEvent(Gj)}},Yj=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=oa(t,t.actions,i,r,s)}disconnect(){la(this.actions)}dispatchEnter(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.toggle(!0)))}dispatchLeave(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.toggle(!1)))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>t.toggle(!e))}},qj=class extends _n{constructor(e){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=r=>{Ze.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseHoverEvent())},this.onMouseUp=r=>{Ze.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=r=>{Ze.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=_u(r);a&&a==="MouseHover"&&(s.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[s.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(!(!r.visible||!r.data?.events.length)){for(let{id:s,data:n}of r.data.events)if(!n.disabled&&n.type==="MouseHover")try{let a=new Yj(s,n,r,t,i);this.eventsPerObjects[r.uuid]?this.eventsPerObjects[r.uuid].push(a):this.eventsPerObjects[r.uuid]=[a]}catch{}this.eventsPerObjects[r.uuid]?.length&&this.objects.push(r)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Si&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Si&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,scene:s}=this.eventContext;if(i){let n=Om(r,s,this.objects);t=Lm(n)}else this.objects.forEach(n=>{Xd(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},Qj=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=oa(t,t.actions,i,r,s)}connect(){this.scrollCounter=0}disconnect(){la(this.actions)}dispatch(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(r=>{r.init()}));let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)})}},Zj=class extends _n{constructor(e){super(e),this.eventsPerObject=new Map,this.onWheel=r=>{[...this.eventsPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:r.deltaY}),n.forEach(a=>a.dispatch(r.deltaY))})},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=_u(r);a&&a==="Scroll"&&(s.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.eventsPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length)for(let{id:s,data:n}of r.data.events){if(n.disabled||n.type!=="Scroll")continue;let a=new Qj(s,n,r,t,i);this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])}})}connect(){[...this.eventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.eventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel))}disconnect(){window.removeEventListener("wheel",this.onWheel),this.domEventsNeeded.clear(),[...this.eventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},Kj=class{constructor(e,t,i,r){this.data=e,this.object=t,this.actions=oa(e,e.actions,t,i,r)}disconnect(){la(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof no?t.interaction.audioPlayer.play():t.interaction instanceof Im&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Vl?t.interaction.play(i==="autoplay"):t.interaction instanceof Bm&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Audio.forEach(t=>{t.interaction instanceof no?t.interaction.audioPlayer.play():t.interaction instanceof Im&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Vl?t.interaction.play():t.interaction instanceof Bm&&t.interaction.dispatch()})}},Jj=class extends _n{constructor(e){super(e),this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:r,isExport:s}=this.eventContext;(s?document:r).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(o=>{o.dispatchAfter("any")})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=_u(r);a&&a==="Start"&&(s.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length)for(let{data:s}of r.data.events){if(s.disabled||s.type!=="Start")continue;let n=new Kj(s,r,t,i);n.actions.Transition.length&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(i=>i.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())})}},$j=class{constructor(e,t,i,r){this.data=e,this.object=t,this.disabled=!0,this.actions=oa(e,e.actions,t,i,r),this.target=e.target,this.useToggle=e.toggle}disconnect(){la(this.actions)}dispatch(){this.disabled||(this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}},Ot;Gz.then(e=>Ot=e);var bi=new M,qs=new nt,In=new M,of=new ui(0,0,0,"YXZ"),eH={type:"updateMatrix"},MA={type:"beginEvent",eventName:"Collision"};function tH(e){if(e.scene.environment.usePhysics)return!0;let t=!1;return e.scene.objects.traverse((i,r)=>{for(let s of r.events)if(s.data.disabled!==!0&&s.data.type==="GameControl"&&s.data.collisionEnabled){t=!0;break}}),t}var cb=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0),db=e=>e.events.find(t=>t.data.disabled!==!0&&t.data.type==="Follow"),iH=class{constructor(e,t,i,r,s,n=!1){this.scene=t,this.sharedAssets=s,this.isExport=n,this.orbitControlsNeedsUpdate=!0,this.gameControls=[],this.gameControlStates=[],this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{},gamePads:[]},this.needsCollisionDetection=!1,this.initializationCounter=-1,this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.processRigidBody=f=>{if(f.bodyType()!==Ot.RigidBodyType.Dynamic)return;f.isSleeping()||this.nActiveRigidBodies++;let[v,y,b]=this.rigidBodyToMesh.get(f.handle);if(bi.copy(f.translation()).multiplyScalar(this.pixelsPerMeter),qs.copy(f.rotation()),v.matrixWorld.compose(bi,qs,y),v.hasNonUniformScale&&v.matrixWorld.multiply(v.shearScale),v.dispatchEvent(eH),b){let x=v.cloner;if(x&&x.objectForSample===void 0){x.matrixWorld.copy(v.matrixWorld);for(let w of x.children)w.updateMatrixWorld(!0)}for(let w of v.children)w.updateMatrixWorld(!0)}},this.handleCollisionEvents=(f,v,y)=>{if(y!==!1)if(this.gameControls.some(b=>b.object===this.sharedGameControlGlobals.colliderToEntity[f])){let b=this.sharedGameControlGlobals.colliderToEntity[v],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x===void 0)return;for(let w of x)w.data.target==="character"&&this.dispatchCollisionEvent(w,b)}else if(this.gameControls.some(b=>b.object===this.sharedGameControlGlobals.colliderToEntity[v])){let b=this.sharedGameControlGlobals.colliderToEntity[f],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x===void 0)return;for(let w of x)w.data.target==="character"&&this.dispatchCollisionEvent(w,b)}else{let b=this.sharedGameControlGlobals.colliderToEntity[f],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x!==void 0)for(let A of x)A.data.target==="scene"&&this.dispatchCollisionEvent(A,b);let w=this.sharedGameControlGlobals.colliderToEntity[v],_=this.sharedGameControlGlobals.eventsPerObjects[w?.uuid];if(_!==void 0)for(let A of _)A.data.target==="scene"&&this.dispatchCollisionEvent(A,w)}},this.onBeginState=()=>{this.orbitControls&&(this.orbitControls.enabled=!1,this.orbitControlsNeedsUpdate=!1)},this.onCompleteState=({target:f})=>{this.orbitControls&&(this.orbitControls.enabled=!0,this.orbitControls.resetTo(f.getTarget(bi),f.position,f.zoom,f.isUpVectorFlipped),f.prevState=null,f.currentState=null,f.reversibleToState=null,f.currentTransitionEvent=null,this.orbitControlsNeedsUpdate=!0)},this.domElement=i.domElement;let a;e.scene.publish.playCamera===null?a=yu.PERSONAL_CAMERA_ID:a=e.scene.publish.playCamera;let o=this.scene.find(a),l=!1,h,u=5,c=8,d=9,p="drag";if(this.usePhysics=e.scene.environment.usePhysics??ji.defaultData.usePhysics,this.pixelsPerMeter=e.scene.environment.pixelsPerMeter??ji.defaultData.pixelsPerMeter,e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach(f=>{f.data.disabled!==!0&&f.data.type==="GameControl"&&(h=f.data.keyAssignments,u=f.data.joystickPosLoc,c=f.data.joystickRotLoc,d=f.data.jumpTouchButtonLoc,p=f.data.rotByTouch)}),this.scene.traverseEntity(f=>{f.dataPatched.events.forEach(v=>{if(v.data.disabled||v.data.type!=="GameControl")return;let y=f;for(;(y=y.parent)?.parent!==null;)if(y.dataPatched.physics?.fusedBody)return;v.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([f,v.data])})}),this.usePhysics&&this.initPhysics(e.scene.environment.gravity??ji.defaultData.gravity),this.gameControlStates.forEach(([f,v])=>{l=l||v.camera===o.uuid||f.uuid===o.uuid;let y=new EA(f,i.domElement,{...v,keyAssignments:h},e.scene.environment,this.sharedGameControlGlobals,f.uuid!==o.uuid&&v.camera===o.uuid,o,this.scene,s);y.addEventListener("change",r),y.addEventListener("end",r),y.addEventListener("start",r),this.gameControls.push(y),Si&&v.touchControl&&(this.joystickToGameControls[u]!==void 0?this.joystickToGameControls[u].push([y,"pos"]):this.joystickToGameControls[u]=[[y,"pos"]],v.moveMode==="walk"&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([y,"jmp"]):this.joystickToGameControls[d]=[[y,"jmp"]]),p==="joystick"&&(this.joystickToGameControls[c]!==void 0?this.joystickToGameControls[c].push([y,"rot"]):this.joystickToGameControls[c]=[[y,"rot"]]))}),l===!1){let{enableRotate:f,enablePan:v,enableZoom:y,autoRotate:b,hoverRotatePanMode:x}=e.scene.publish.orbitControls;if(f||v||y||b||x!==0){this.orbitControls=new CA(o,i.domElement,this.isExport),this.orbitControls.addEventListener("change",r),this.orbitControls.addEventListener("end",r),this.orbitControls.addEventListener("start",r),this.orbitControls.fromJSON(e.scene.publish.orbitControls,e.scene.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.connect(),this.orbitControls.update();let w=this.orbitControls.object;w.addEventListener("beginState",this.onBeginState),w.addEventListener("completeState",this.onCompleteState)}}let m=i.domElement.width/i.getPixelRatio(),g=i.domElement.height/i.getPixelRatio();this.joystickToGameControls.forEach((f,v)=>{let y=document.body.appendChild(document.createElement("div")),[b,x,w]=(e.scene.publish.joystickSizeAndXYOffset??To.defaultData.joystickSizeAndXYOffset)[v],_=(m-5*b)/4+b,A={},S=f.some(P=>P[1]==="jmp"),E=S?0:b;v<10?(v<5?A.top=E/2:A.bottom=E/2,A.left=E/2+v%5*_):v===10?(A.left=E/2,A.top=g/2):(A.right=E/2,A.top=g/2),A.top?A.top-=x[1]:A.bottom+=x[1],A.left?A.left+=x[0]:A.right-=x[0];for(let P in A)A[P]+="px";if(S){let P=y.appendChild(document.createElement("div"));Object.assign(P.style,A,{position:"absolute",width:b+"px",height:b+"px",backgroundColor:`rgba(255,255,255,${w==="show"?.4:0})`,zIndex:"9999",borderRadius:b+"px",border:w==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let R=b/16*16*.4;w==="show"&&(P.innerHTML=`
4914
4914
  <svg width="${R}" height="${b*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
4915
4915
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4916
4916
  </svg>
4917
4917
  `),P.addEventListener("pointerdown",()=>{f.forEach(O=>{O[0].movementState.jump=1}),r()}),P.addEventListener("touchend",O=>O.preventDefault()),this.joysticks[v]=[void 0,y];return}let C={zone:y,mode:"static",position:A,size:b};w==="hide"&&(C.restOpacity=0);let T=c8.create(C);T.on("move",(P,R)=>{f.forEach(O=>{let U=O[0];O[1]==="pos"?R.force<.2?U.moveForce=0:(U.movementState.movePosZ=Math.sin(-R.angle.radian),U.movementState.movePosX=Math.cos(-R.angle.radian),R.force<.3?U.moveForce=(R.force-.2)/.1:U.moveForce=1):R.force<.2?U.rotForce=0:(U.movementState.rotPosX=R.vector.y,U.movementState.rotPosY=-R.vector.x,R.force<.3?U.rotForce=(R.force-.2)/.1:U.rotForce=1)}),r()}),T.on("end",(P,R)=>{f.forEach(O=>{let U=O[0];O[1]==="pos"?(U.movementState.movePosZ=0,U.movementState.movePosX=0,U.moveForce=1):(U.movementState.rotPosX=0,U.movementState.rotPosY=0,U.rotForce=1)})}),this.joysticks[v]=[T,y]}),this.usePhysics===!1&&this.needsCollisionDetection&&this.initBVH(),this.initializationCounter++,window.setTimeout(()=>this.collisionEvents.forEach(f=>f.disabled=!1),80)}attachVRControllers(e){e.forEach(t=>{t.addEventListener("connected",i=>{"gamepad"in i.data&&"axes"in i.data.gamepad&&this.sharedGameControlGlobals.gamePads.push(i.data.gamepad)})})}initBVH(){let e=[];if(this.scene.traverseObject(t=>{let i;if(t instanceof Vd)return;t instanceof Xn?i=t.object:i=t;let r=i.dataPatched;if(!r.visible)return!0;let s=t.geometry;if(cb(r)||db(r)||i.dataPatched.events.some(n=>n.data.disabled!==!0&&n.data.type==="GameControl")){t.updateMatrixWorldSVD();let n=[];if(s?.getAttribute("position")!==void 0&&n.push(Ha(s,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,n)),t.children.forEach(a=>a.updateMatrixWorld(!0)),n.length>0){let a=to(n,!1);t.boundsTree=new ai(a),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)}return!0}else s&&e.push(Ha(s,t.matrixWorld))}),e.length>0){let t=to(e,!1);this.sharedGameControlGlobals.staticMeshBVH=new ai(t)}}addCollider(e,t,i,r,s,n=!0){if(r?.getAttribute("position").count===0||r?.getIndex()?.count===0)return;let a;s!==void 0?s.collider.type==="sphere"?a=Ot.ColliderDesc.ball(s.collider.radius/this.pixelsPerMeter):s.collider.type==="capsule"?a=Ot.ColliderDesc.capsule((s.collider.height/2-s.collider.radius)/this.pixelsPerMeter,s.collider.radius/this.pixelsPerMeter):a=Ot.ColliderDesc.cuboid(s.collider.width/this.pixelsPerMeter/2,s.collider.height/this.pixelsPerMeter/2,s.collider.depth/this.pixelsPerMeter/2):r&&(i.colliderType==="trimesh"?a=Ot.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array):a=Ot.ColliderDesc.convexMesh(r.getAttribute("position").array,n?r.getIndex().array:void 0)),a.setFrictionCombineRule(Ot.CoefficientCombineRule.Average).setRestitutionCombineRule(Ot.CoefficientCombineRule.Average).setDensity(i.density).setFriction(i.friction).setRestitution(i.restitution);let o=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t);if(this.sharedGameControlGlobals.colliderToEntity[o.handle]=e,s!==void 0){bi.fromArray(s.collider.position).multiply(In.setFromMatrixScale(e.matrixWorld)).divideScalar(this.pixelsPerMeter),o.setTranslationWrtParent(bi);let l=new nt().setFromEuler(new ui().setFromVector3(new M().fromArray(s.collider.rotation)));o.setRotationWrtParent(l),o.setActiveEvents(Ot.ActiveEvents.COLLISION_EVENTS)}else this.sharedGameControlGlobals.eventsPerObjects[e.uuid]?.some(l=>l.target==="scene")&&o.setActiveEvents(Ot.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(e,t){return(i,r)=>{if(r===0)return;r===1?e.hasNonUniformScale?i.matrixWorld.multiplyMatrices(e.shearScale,i.hiddenMatrix):i.matrixWorld.copy(e.hiddenMatrix):i.matrixWorld.multiplyMatrices(i.parent.matrixWorld,i.hiddenMatrix),i.matrixWorld.multiply(i.matrix);let s=i.geometry;s?.getAttribute("position")!==void 0&&t.push(Ha(s,i.matrixWorld))}}initPhysics(e){this.sharedGameControlGlobals.rapierWorld=new Ot.World(new Ot.Vector3(0,e??-10,0)),this.events=new Ot.EventQueue(!0);let t=[];if(this.scene.traverseObject(a=>{let o;if(a instanceof Vd)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else a instanceof Xn?o=a.object:o=a;let l=o.dataPatched;if(!l.physics||!l.visible)return!0;a.updateMatrixWorldSVD();let h=cb(l),u=db(l),c,d=!1;for(let m of l.events)if(m.data.disabled!==!0){if(m.data.type==="GameControl")c=m.data;else if(m.data.type==="Collision"){d=!0;let g=new $j(m.data,o,this.scene,this.sharedAssets);this.collisionEvents.push(g),this.sharedGameControlGlobals.eventsPerObjects[o.uuid]?this.sharedGameControlGlobals.eventsPerObjects[o.uuid].push(g):this.sharedGameControlGlobals.eventsPerObjects[o.uuid]=[g]}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let p=a.geometry;if(l.physics.rigidBody==="dynamic"||h||u||d||c!==void 0){let m=[];if(p?.getAttribute("position")!==void 0&&m.push(Ha(p,a.shearScale)),l.physics.fusedBody){let g=this.gatherChildrenGeom(a,m);a.traverseObject(g),a.children.forEach(v=>v.updateMatrixWorld(!0));let f=a.cloner;f&&f.objectForSample===void 0&&l.physics.rigidBody==="dynamic"&&(f.traverseObject(g),f.children.forEach(v=>v.updateMatrixWorld(!0)))}if(m.length>0||c!==void 0){let g;c!==void 0?g=Ot.RigidBodyDesc.kinematicPositionBased():l.physics.rigidBody==="dynamic"?(g=Ot.RigidBodyDesc.dynamic(),g.setLinearDamping(l.physics.damping).setAdditionalMass(1e-9).setGravityScale(l.physics.gravityScale).enabledRotations(...l.physics.enabledRotation).enabledTranslations(...l.physics.enabledTranslation)):h||u?(g=Ot.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(a)):g=Ot.RigidBodyDesc.fixed();let f;f=m.length>0?to(m):void 0,(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(bi,qs,In),a.position0=bi.clone().divideScalar(this.pixelsPerMeter),a.rotation0=qs.clone(),bi.divideScalar(this.pixelsPerMeter),g.setTranslation(bi.x,bi.y,bi.z).setRotation(qs),p?f?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):f?.scale(In.x/this.pixelsPerMeter,In.y/this.pixelsPerMeter,In.z/this.pixelsPerMeter);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);c===void 0&&l.physics.rigidBody==="dynamic"&&this.rigidBodyToMesh.set(v.handle,[a,In.clone(),l.physics.fusedBody]),a.rigidBody=v;let y=!(l.geometry===void 0||l.geometry.type==="SubdivGeometry"||l.geometry.type==="NonParametricGeometry"||l.geometry.type==="BooleanGeometry"||l.geometry.type==="VectorGeometry"||l.geometry.type==="StarGeometry"||l.geometry.type==="RectangleGeometry"||l.geometry.type==="EllipseGeometry"||l.geometry.type==="TriangleGeometry"||l.geometry.type==="TorusGeometry"||l.geometry.type==="HelixGeometry");try{this.addCollider(o,v,l.physics,f,c,y)}catch{try{this.addCollider(o,v,l.physics,f,c,!1)}catch(b){console.error(b)}}}}else p&&t.push(Ha(p,a.matrixWorld)),l.physics.fusedBody&&a.traverse(m=>{!m.geometry||m===a||t.push(Ha(m.geometry,m.matrixWorld))});if(l.physics?.fusedBody===!0||c)return!0}),t.length===0)return;let i=to(t);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=Ot.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),n=Ot.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Ot.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Ot.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(n,s)}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}dispose(){if(this.scene.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.staticMeshBVH=void 0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.gameControls.forEach(e=>{e.reset(),e.dispose()}),this.gameControls=[],this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls){let e=this.orbitControls.object;e.removeEventListener("beginState",this.onBeginState),e.removeEventListener("completeState",this.onCompleteState),this.orbitControls.dispose(),this.orbitControls=void 0}for(let e of Object.values(this.sharedGameControlGlobals.eventsPerObjects))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.eventsPerObjects={},this.scene.updateMatrixWorld(!0)}update(e,t,i){let r=!0;if(this.orbitControls!==void 0&&this.orbitControlsNeedsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2)this.initializationCounter++,r=!1;else if(this.initializationCounter===2)for(let s of this.gameControls)r=!s.update(e,t,i)&&r;if(this.usePhysics){for(let s of this.sharedGameControlGlobals.entitiesWithTransformAnim){(s.hasNonUniformScale?s.matrixWorldRigid:s.matrixWorld).decompose(bi,qs,In),of.setFromQuaternion(qs);let n=s;n.prevR===void 0?(n.prevR=of.clone(),n.prevT=bi.clone()):(n.prevR.copy(of),n.prevT.copy(bi)),s.rigidBody.setNextKinematicTranslation(bi.divideScalar(this.pixelsPerMeter)),s.rigidBody.setNextKinematicRotation(qs)}this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),r=!this.updatePositions()&&r}return r}dispatchCollisionEvent(e,t){t.dispatchEvent(MA),e.dispatch()}},lf={type:"change"},rH={type:"lock"},sH={type:"unlock"},$V=new M,ub=new M,pb=new M,nH=new M,wi=new M,Ui=new M,Qs=new M,hf=new Se,fb=new Se,aH=new Se,e9=new Se,_r=new nt,ws=new nt,Gr=new ui(0,0,0,"YXZ"),oH=new M(1,0,0),Sr=new M(0,1,0),lH=new M(0,0,1),mb=new M(1,1,1),hH=1,cH=.025,dH=16e-6,uH=12,pH=20,li=new cr,tr=new Gt,fH={type:"requestRender"},gb=Math.PI/6,zm=class extends Ni{constructor(e,t,i,r,s,n,a,o,l){super(),this.object=e,this.domElement=t,this.sharedGameControlGlobals=s,this.cameraFollow=n,this.camera=a,this.scene=o,this.sharedAssets=l,this.enableDamping=!0,this.position0=new M,this.rotation0=new ui(0,0,0,"XYZ"),this.scale0=new M,this.hiddenMatrix0=new Se,this.target0=new M,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.euler0=new ui(0,0,0,"YXZ"),this.position0Cam=new M,this.quat0Cam=new nt,this.scale0Cam=new M,this.hiddenMatrix0Cam=new Se,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new cr(new M(0,-40,0),new M(0,40,0)),matrix:new Se,position:new M,rotation:new nt},this.euler=new ui(0,0,0,"YXZ"),this.eulerDelta=new M,this.lastPosition=new M,this.lastCameraQuaternion=new nt,this.lastCameraPosition=new M,this.PI_2=Math.PI/2,this.prevMouse=new H,this.velocityTarget=new M,this.velocity=new M,this.directionXZ=new M,this.rotVelocityStick=new M,this.rotVelocityTarget=new M,this.rotVelocity=new M,this.rotDirection=new M,this.nonColliderRotOffset=new Se,this.nonColliderPosOffset=new Se,this.firstPointerId=-1,this.rot=new M,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new Se,this.objectToTarget=new M,this.objectToTarget0=new M,this.objectToCamXZ=new M,this.objectToCamXZ0=new M,this.targetToCamera=new M,this.targetToCamera0=new M,this.cameraPolarAxis0=new M,this.targetPos=new M,this.targetQuat=new nt,this.lerpFactorPos=new M().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new nt,this.objXZQuatInv=new nt,this.objXZRotMat=new Se,this.isFirstPerson=!1,this.actions={},this.didHit=!1,this.groundVelocity=new M,this.pushedVelocity=new M,this.groundYRotation=0,this.objectRealQuat=new nt,this.colliderWorldQuat=new nt,this.groundNormal=new M,this.groundTilt=new nt,this.groundTiltInv=new nt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.onPointerDown=m=>{m.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=m.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Si&&(!Ld||Id>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(m.clientX,m.clientY))},this.onPointerUp=m=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),m.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=m=>{if(m.pointerId!==this.firstPointerId)return;let g=m.clientX-this.prevMouse.x,f=m.clientY-this.prevMouse.y;this.prevMouse.set(m.clientX,m.clientY),m.pointerType==="mouse"&&this.rotBy!=="keys"&&(Ld&&Id<15.5&&!Si?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-f*this.mouseOrbitSensitivity):(this.eulerDelta.y=-m.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-m.movementY*this.mouseOrbitSensitivity)),m.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-f*this.mouseOrbitSensitivity*5),this.dispatchEvent(lf)},this.onPointerlockChange=m=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(rH),zm.isLocked=!0):(this.dispatchEvent(sH),zm.isLocked=!1)},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.onKeyDown=m=>{!(m.target instanceof HTMLInputElement)&&(m.code==="ArrowLeft"||m.code==="ArrowUp"||m.code==="ArrowRight"||m.code==="ArrowDown"||m.code==="Space")&&m.preventDefault();for(let g of this.keyAssignments)if(m.key.toUpperCase()===g[1]||m.key===g[1]){this.movementState[g[0]]=1;break}this.dispatchEvent(lf)},this.onKeyUp=m=>{for(let g of this.keyAssignments)if(m.key.toUpperCase()===g[1]||m.key===g[1]||m.code.slice(3,m.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(m,g)=>{for(let f=2;f<4;f++){let v=m.axes[f];g===0?f===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(m.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,f===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},e===a&&(this.isFirstPerson=!0),this.position0.copy(this.object.position),this.rotation0.copy(this.object.rotation),this.scale0.copy(this.object.scale),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.rotation.reorder("YXZ"),this.euler0.copy(this.object.rotation);let h=this.object.rotation.y;if(this.objectRealQuat.copy(this.object.quaternion),this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,h,0),this.rot.setFromEuler(this.object.rotation),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){if(this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera?.parent?.parent){let y=this.camera.matrix.clone().invert().premultiply(this.camera.matrixWorld),b=y.clone().invert();this.camera.hiddenMatrix.multiply(b),this.camera.matrix.premultiply(y),this.camera.matrixWorld.decompose(this.camera.position,this.camera.quaternion,this.camera.scale)}this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m=new M(0,0,-1).applyQuaternion(this.camera.quaternion),g=new M().subVectors(this.object.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let f;if(Math.abs(m.y)<1e-6){g.y=0,m.y=0;let y=g.projectOnVector(m);this.targetToCamera0.copy(y).negate(),f=this.camera.position.clone().add(y)}else{let y=m.multiplyScalar(g.y/m.y);this.targetToCamera0.copy(y).negate(),f=y.clone().add(this.camera.position)}this.objectToTarget0.subVectors(f,this.object.position);let v=new ui().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.object instanceof Os&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.connect(),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*hH,this.speedOrbit=(i.speedRotate??100)*cH,this.mouseOrbitSensitivity=(i.speedRotate??100)*dH,this.keyAssignments=i.keyAssignments.map(m=>{let g=[m[0],m[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(r.gravity??ji.defaultData.gravity)*uH,this.pixelsPerMeter=r.pixelsPerMeter??ji.defaultData.pixelsPerMeter,this.usePhysics=r.usePhysics??ji.defaultData.usePhysics,this.jumpPower=i.jumpPower*pH,this.resetYPosition=i.resetYPosition,this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??hm.defaultDataThirdPerson.orientWith;let u=r.skinWidthRelative??ji.defaultData.skinWidthRelative,c=r.stepThreshRelative??ji.defaultData.stepThreshRelative;this.slopeThresh=(r.slopeThresh??ji.defaultData.slopeThresh)*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*u/this.pixelsPerMeter,this.stepThresh=i.collider.height*c/this.pixelsPerMeter):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*u/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*c/this.pixelsPerMeter):(this.offset=i.collider.height*u/this.pixelsPerMeter,this.stepThresh=i.collider.height*c/this.pixelsPerMeter),this.collider.type=i.collider.type;let d=new M().fromArray(i.collider.position),p=new nt().setFromEuler(new ui().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(d).multiply(this.object.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(d,p,mb),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),i.gameActions!==void 0&&Object.entries(i.gameActions).forEach(([m,g],f)=>{g.forEach(({id:v,data:y})=>{try{this.actions[m]===void 0&&(this.actions[m]=[]),y.type==="Transition"?this.actions[m].push(new oo(y,o,l)):y.type==="Audio"?this.actions[m].push(new ao(v,y,e,l)):y.type==="Video"&&this.actions[m].push(new Yd(v,y,e))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle")}reset(e=!1){if(this.object.rotation.copy(this.rotation0),this.object.position.copy(this.position0),this.object.scale.copy(this.scale0),this.object.hiddenMatrix.copy(this.hiddenMatrix0),e===!0){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.rotation.reorder("YXZ");let t=this.object.rotation.y;this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,t,0),this.rot.setFromEuler(this.object.rotation),this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}e===!1&&(this.object instanceof Os?this.object.matrixAutoUpdate=!0:this.object.updateMatrix()),this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.dispatchEvent(lf)}connect(){this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError)}disconnect(){this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError)}dispose(){this.disconnect(),Object.values(this.actions).forEach(e=>{e.forEach(t=>{(t instanceof oo||t instanceof ao||t instanceof Yd)&&t.dispose()})})}resetTo(e,t,i){}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].forEach(t=>{t instanceof oo?t.play():t instanceof ao&&t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].forEach(t=>{t instanceof oo?t.stop():t instanceof ao&&t.dispatchGameControl("stop")}),this.object.traverseEntity(t=>{t.currentState!==null&&t.changeSelectedState(null,{scene:this.scene,shared:this.sharedAssets})})))}update(e,t,i){if(this.gravity<0?this.object.position.y<this.resetYPosition:this.object.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,n=!1;if(this.usePhysics&&this.collisionEnabled){let o=Ui.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/10,1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(wi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,8,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(n=!0);let h=l.collider._parent;this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===h){(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(wi,ws,Ui),this.groundVelocity.subVectors(wi,u.prevT),this.object.getWorldPosition(Ui).add(this.collider.position).sub(u.position),this.groundYRotation=Gr.setFromQuaternion(ws).y-u.prevR.y,Qs.copy(Ui).applyAxisAngle(Sr,this.groundYRotation),this.groundVelocity.add(Qs.sub(Ui)).divideScalar(r);break}}else this.onObject=!1}this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.velocityTarget.y+=this.onObject?0:this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.directionXZ.normalize(),this.movementState.moveNegZ||this.movementState.movePosZ?this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce:this.velocityTarget.z=0,this.movementState.moveNegX||this.movementState.movePosX?this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce:this.velocityTarget.x=0,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("move")));let a=nH.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Ui.copy(a);o.y=0,a.set(0,a.y,o.length()*-1)}if(Gr.setFromVector3(this.rot),this.moveMode==="walk"&&(Gr.x=0),a.applyEuler(Gr),n&&(ws.setFromUnitVectors(Sr,this.groundNormal),a.applyQuaternion(ws)),i){let o=Gr.set(0,this.vrEulerYOffset*gb,0);i.applyEuler(o),a.x+=i.x,a.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=Ui;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=Qs.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),wi.copy(a).divideScalar(this.pixelsPerMeter),r);if(h.multiplyScalar(this.pixelsPerMeter),u!==null){this.pushedVelocity.copy(h),o.copy(u.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(a);l<0&&a.addScaledVector(o,-l),a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){let o=wi,l=Ui.copy(this.directionXZ);l.x*=-1,this.camera.getWorldDirection(o);let h=Qs.copy(Sr).multiplyScalar(o.dot(Sr));if(o.sub(h),this.orientWith==="camera"?this.rot.y=o.angleTo(l)*(o.cross(l).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera:this.rot.y=this.euler.y+Math.atan2(-this.directionXZ.z,this.directionXZ.x)-Math.PI/2,this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Sr,this.euler.y-this.euler0.y);let u=Ui.copy(this.objectToCamXZ).normalize(),c=Qs.copy(a).multiplyScalar(r);c.y=0;let d=c.sub(wi.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(d,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=rt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=rt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=rt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(Gr.copy(t),Gr.y=0):(Gr.copy(this.euler),Gr.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Gr)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*gb),_r.setFromAxisAngle(oH,this.rot.x),ws.setFromAxisAngle(Sr,this.rot.y),ws.multiply(_r),_r.setFromAxisAngle(lH,this.rot.z),ws.multiply(_r),this.object.quaternion.copy(ws),this.objectRealQuat.multiplyQuaternions(this.object.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=Ui.copy(a).multiplyScalar(r/this.pixelsPerMeter),l;this.didHit=!1;let h=new M;for(let u=0;u<5;u++){let c=o.length(),d=Qs.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(wi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,c,8,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity[l.collider.handle];if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.eventsPerObjects[p?.uuid];if(v)for(let y of v)y.data.target==="character"&&(p.dispatchEvent(MA),y.dispatch())}let m=ub.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=pb.copy(d).multiplyScalar(l.toi).dot(m),f=l.toi;if(f===0&&(this.object.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(f=l.toi*(g-this.offset)/g,h.addScaledVector(d,f)),o.copy(d).multiplyScalar(c-f),Math.acos(-m.y)>this.slopeThresh){let v=wi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter).add(h),y=Qs.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let b=v.add(y);b.y+=this.stepThresh;let x=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,8,void 0,void 0,this.object.rigidBody);x!==null&&x.toi===0&&(m.y=0,m.normalize())}o.addScaledVector(m,-o.dot(m))}else{u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.object.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(wi.copy(this.object.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(_r.copy(this.object.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=a.multiplyScalar(r/o);for(let h=0;h<o;h++)this.object.position.add(l),this.collisionAdjustment(r/o)}else this.object.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.object.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.updateMatrix(),this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.object.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.object.position),l=this.targetToCamera.add(o);hf.lookAt(l,o,Sr).setPosition(l),hf.decompose(this.targetPos,this.targetQuat,wi),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.matrixWorldNeedsUpdate=!0,this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=rt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=rt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.lastPosition.distanceToSquared(this.object.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.object.position),this.object.dispatchEvent(fH),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=_r.setFromAxisAngle(Sr,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?rt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=rt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=rt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=wi.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=ws.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Sr.angleTo(e)*180/Math.PI<15||Sr.angleTo(e)*180/Math.PI>85?_r.identity():_r.setFromUnitVectors(Sr,e),this.groundTilt.slerp(_r,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=pb.set(0,0,0);this.object.updateMatrix();let i=hf.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(wi,_r,Ui).compose(wi,_r,mb);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;tr.makeEmpty(),s.updateMatrixWorldSVD();let n=s.matrixWorldRigid,a=fb.copy(n).invert(),o=aH.copy(fb).multiply(i);li.copy(this.collider.segment),li.start.applyMatrix4(o),li.end.applyMatrix4(o);let l=ub.copy(this.object.position).applyMatrix4(a);tr.expandByPoint(li.start),tr.expandByPoint(li.end),tr.min.addScalar(-this.collider.radius),tr.max.addScalar(this.collider.radius),s.boundsTree.shapecast({intersectsBounds:h=>h.intersectsBox(tr),intersectsTriangle:h=>{let u=wi,c=Ui,d=h.closestPointToSegment(li,u,c);if(d<this.collider.radius){let p=this.collider.radius-d,m=c.sub(u).normalize(),g=Qs.copy(l);g.addScaledVector(m,p);let f=g.applyMatrix4(n).sub(this.object.position);t.add(f),li.start.addScaledVector(m,p),li.end.addScaledVector(m,p)}}})}),tr.makeEmpty(),li.copy(this.collider.segment),li.start.applyMatrix4(i),li.end.applyMatrix4(i),tr.expandByPoint(li.start),tr.expandByPoint(li.end),tr.min.addScalar(-this.collider.radius),tr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({intersectsBounds:s=>s.intersectsBox(tr),intersectsTriangle:s=>{let n=wi,a=Ui,o=s.closestPointToSegment(li,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),li.start.addScaledVector(h,l),li.end.addScaledVector(h,l)}}}),this.onObject=t.y>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.object.position.add(t)}},EA=zm;EA.isLocked=!1;var cf={type:"change"},vb={type:"changeZoom"},mH={type:"changePan"},Sl={type:"start"},Al={type:"end",changed:!0},gH={type:"end",changed:!1},df=new nt,yb=new H,vH=2*Math.PI,yH=1e-8,xH=.01,xb=2,uf=.125,bb=2,Uc=1,kc=1,Ml=.1,wb=new M,jc=new H,CA=class extends Ni{constructor(e,t,i=!1){super(),this.object=e,this.domElement=t,this.isExport=i,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,Ji.DOLLY_ROTATE,Ji.PAN],this.offset=new M,this.eye=new M,this.lastPosition=new M,this.lastQuaternion=new nt,this.current=new H,this.overShoot=new H,this.overRatio=new H,this.spherical=new ny,this.sphericalDelta=new ny,this.panOffset=new M,this.panLeftV=new M,this.panUpV=new M,this.panV=new M,this.rotateStart=new H,this.rotateEnd=new H,this.rotateDelta=new H,this.panStart=new H,this.panEnd=new H,this.panDelta=new H,this.dollyStart=new H,this.dollyEnd=new H,this.dollyDelta=new H,this.rotationRangeFactor=new H,this.panRangeFactor=new H,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.update=()=>{let r=this.object.position;this.offset.copy(r).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(df.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(df),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-uf),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),r.copy(this.target).add(this.offset);let s=this.spherical.phi%vH;return this.eye.copy(this.offset).normalize(),this.object.up.copy(_t.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),s>0&&s>Math.PI||s<0&&s>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-uf,this.sphericalDelta.phi*=1-uf):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>xH||8*(1-this.lastQuaternion.dot(this.object.quaternion))>yH?(this.dispatchEvent(cf),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)},this.onPointerDown=r=>{this.enabled!==!1&&(r.pointerType==="touch"||r.pointerType==="pen"&&Si?this.onPointerDownTouch(r):this.onPointerDownMouse(r),this.state!==-1&&(this.isPointerDown=!0,this.dispatchEvent(Sl),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),r.stopPropagation(),r.pointerType==="touch"||r.pointerType==="pen"&&Si||this.domElement.setPointerCapture(r.pointerId)))},this.onPointerLeave=r=>{this.resetHoverEffectOnPointerLeave?(this.hoverRotatePanMode===1?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,wb.subVectors(this.position0,this.target0),this.spherical.setFromVector3(wb),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):this.hoverRotatePanMode===2&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=r},this.onPointerEnter=r=>{this.resetHoverEffectOnPointerLeave||this.pointerLeaveEvent===void 0?jc.set(r.clientX-this.domElement.clientWidth/2,r.clientY-this.domElement.clientHeight/2):jc.set(r.clientX-this.pointerLeaveEvent.clientX,r.clientY-this.pointerLeaveEvent.clientY),this.hoverRotatePanMode===1?(this.rotateDelta.copy(jc).multiplyScalar(Uc*Ml).rotateAround(yb,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(r.clientX,r.clientY)):this.hoverRotatePanMode===2&&(this.panDelta.copy(jc).multiplyScalar(kc*Ml),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(r.clientX,r.clientY)),this.update()},this.onPointerMove=r=>{this.enabled!==!1&&(r.pointerType==="touch"||r.pointerType==="pen"&&Si?this.onPointerMoveTouch(r):this.onPointerMoveMouse(r),r.stopPropagation())},this.onPointerUp=r=>{this.isPointerDown=!1,Ze.length===0&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),this.hasChange?this.dispatchEvent(Al):this.dispatchEvent(gH),this.state=-1,r&&(r.stopPropagation(),r.pointerType==="touch"||r.pointerType==="pen"&&Si||this.domElement.releasePointerCapture(r.pointerId))},this.onPointerDownMouse=r=>{let s;switch(this.useKeyEvents?s=this.mouseButtons[r.button]:s=this.mouseButtonsPlay[r.button],s){case 0:if(r.altKey===!0&&!r.shiftKey&&!pc(r)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(r),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2;break;case 3:if(pc(r)||r.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(r),this.state=0}break;case 5:if(pc(r)||r.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(r),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=r=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(r);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(r);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(r);break}},this.onPointerDownTouch=r=>{switch(this.touches[Ze.length-1]){case Ji.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case Ji.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case Ji.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case Ji.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=r=>{switch(this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(r),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(r),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(r),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(r),this.update();break;default:this.state=-1}},this.dispatchEndDebounced=Kw(()=>this.dispatchEvent(Al),33),this.onMouseWheel=r=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||(this.isExport===!1&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&r.preventDefault(),this.dispatchEvent(Sl),this.handleMouseWheel(r),this.dispatchEndDebounced())},this.onGesture=r=>{if(this.enabled!==!1)if(r.preventDefault(),r.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Sl),r.scale>this.prevScale?this.dollyIn(this.getZoomScale()):r.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=r.scale,this.update()}else this.dispatchEvent(Al)},this.onContextMenu=r=>{this.enabled!==!1&&r.preventDefault()},this.onTouchEnd=r=>{r.preventDefault()},this.onKeyDown=r=>{this.enabled!==!1&&(this.key=r.key)},this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp(Ze[0]))},this.onPointerHover=r=>{r.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot||(this.isPointerDown=!0,this.hoverRotatePanMode===2?this.handleMouseMovePan(r,Ml):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(r,Ml))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.offset.copy(this.object.position).sub(this.target),this.spherical.setFromVector3(this.offset)}dispatchEvent(e){e.type==="start"?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(e)}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.isUpVectorFlipped=this.isUpVectorFlipped0,this.object.updateProjectionMatrix(),this.dispatchEvent(cf),this.update(),this.state=-1,this.pointerLeaveEvent=void 0}resetTo(e,t,i,r=!1){this.target.copy(e),this.object.position.copy(t),this.object.zoom=i,this.object.isUpVectorFlipped=r,this.object.updateProjectionMatrix(),this.dispatchEvent(cf),this.update(),this.state=-1}fromJSON(e,t){this.setEnableDampingSpeed(e.enableDamping),this.enablePan=e.enablePan,this.enableZoom=e.enableZoom,this.enableRotate=e.enableRotate,this.rotationLimitsMode=e.rotationLimitsMode,this.panLimitsMode=e.panLimitsMode,this.panSoftLimit=e.panSoftLimit,this.rotationSoftLimit=e.rotationSoftLimit,this.hoverRotatePanMode=e.hoverRotatePanMode,this.useWindowEvents=t==="window",this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),Ml=(e.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=e.zoomLimitsEnabled,this.minZoom=e.zoomLimits.min,this.maxZoom=Math.max(e.zoomLimits.min,e.zoomLimits.max),this.minDistance=1e3/e.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/e.zoomLimits.min),this.autoRotate=e.autoRotate,xb=e.autoRotateSpeed,this.autoRotateClockwise=e.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(df.copy(this.object.quaternion).invert());this.minV=-e.panVerticalOffset.min+i.y,this.maxV=e.panVerticalOffset.max+i.y,this.minH=-e.panHorizontalOffset.min+i.x,this.maxH=e.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Zs(this.spherical.phi-e.rotationVerticalOffset.min),this.maxPhi=Zs(this.spherical.phi+e.rotationVerticalOffset.max),this.minTheta=Zs(this.spherical.theta-e.rotationHorizontalOffset.min),this.maxTheta=Zs(this.spherical.theta+e.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,e.orbitTouches===1&&(this.touches[0]=Ji.ROTATE),e.panTouches===1&&(this.touches[0]=Ji.PAN),e.orbitTouches===2&&(this.touches[1]=Ji.DOLLY_ROTATE),e.panTouches===2&&(this.touches[1]=Ji.DOLLY_PAN),e.orbitTouches===3&&(this.touches[2]=Ji.ROTATE),e.panTouches===3&&(this.touches[2]=Ji.PAN),this.resetHoverEffectOnPointerLeave=e.resetHoverEffectOnPointerLeave??!1}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),am||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchend",this.onTouchEnd),this.hoverRotatePanMode!==0&&!this.useWindowEvents&&(this.domElement.addEventListener("pointerleave",this.onPointerLeave),this.domElement.addEventListener("pointerenter",this.onPointerEnter)),this.pointerLeaveEvent=void 0}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),am||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(e,t,i,r,s,n,a,o){this.overShoot.set(0,0);let l,h,u;e instanceof M?(l=e.x,h=e.y,this.current.set(this.target.x,this.target.y),u=!0):(l=e.theta,h=e.phi,this.current.set(Zs(this.spherical.theta),Zs(this.spherical.phi)),u=!1),i===0&&(this.current.x+=l,this.current.y+=h),(t===3||t===2)&&(!u&&this.isThetaFlipped?this.current.x>r&&this.current.x<0?this.overShoot.x=r-this.current.x:this.current.x<s&&this.current.x>0&&(this.overShoot.x=s-this.current.x):this.current.x>r?this.overShoot.x=r-this.current.x:this.current.x<s&&(this.overShoot.x=s-this.current.x),r===s&&(l=0)),(t===3||t===1)&&(this.current.y>n?this.overShoot.y=n-this.current.y:this.current.y<a&&(this.overShoot.y=a-this.current.y),n===a&&(h=0)),u||(this.overShoot.x=Zs(this.overShoot.x),this.overShoot.y=Zs(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(o),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=_b(Math.abs(this.overRatio.x)),this.overRatio.y=_b(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(l*this.overShoot.x<0&&(l*=1-this.overRatio.x),h*this.overShoot.y<0&&(h*=1-this.overRatio.y)):i===2&&(!u&&(this.overRatio.x>.002||this.overRatio.y>.002)||u&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(l=this.overShoot.x*.05,h=this.overShoot.y*.05,u?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):u?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(l+=this.overShoot.x,h+=this.overShoot.y),e instanceof M?(e.x=l,e.y=h):(e.theta=l,e.phi=h)}setEnableDampingSpeed(e){this.enableDamping=e,Uc=e===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*xb}getZoomScale(){return Math.pow(.95,bb)}rotateLeft(e){this.sphericalDelta.theta-=e}rotateUp(e){this.sphericalDelta.phi-=e}panLeft(e,t){this.panLeftV.setFromMatrixColumn(t,0),this.panLeftV.multiplyScalar(-e),this.panOffset.add(this.panLeftV)}panUp(e,t){this.panUpV.setFromMatrixColumn(t,1),this.panUpV.multiplyScalar(e),this.panOffset.add(this.panUpV)}pan(e,t){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let r=this.object.position;this.panV.copy(r).sub(this.target);let s=this.panV.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*s/i.clientHeight,this.object.matrix),this.panUp(2*t*s/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(mH)}dollyOut(e){this.object.isPerspectiveCamera?this.scale/=e:this.object.isOrthographicCamera&&(this.object.zoom*=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(vb)}dollyIn(e){this.object.isPerspectiveCamera?this.scale*=e:this.object.isOrthographicCamera&&(this.object.zoom/=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(vb)}zoomOut(e=this.getZoomScale()){this.dispatchEvent(Sl),this.dollyOut(e),this.dispatchEvent(Al)}zoomIn(e=this.getZoomScale()){this.dispatchEvent(Sl),this.dollyIn(e),this.dispatchEvent(Al)}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleMouseMoveRotate(e,t=1){Ld&&Id<15.5&&!Si?(this.rotateEnd.set(e.clientX,e.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)):this.rotateDelta.set(e.movementX,e.movementY),this.rotateDelta.multiplyScalar(Uc*t).rotateAround(yb,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.update()}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(e,t=1){Ld&&Id<15.5&&!Si?(this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)):this.panDelta.set(e.movementX,e.movementY),this.panDelta.multiplyScalar(kc*t),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(e){if(A5===!1&&pc(e)===!1&&bH(e)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-e.deltaX,-e.deltaY).multiplyScalar(kc),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),e.altKey?this.pan(0,this.panDelta.y):e.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;e.deltaY===0?e.deltaX<0?this.dollyIn(this.getZoomScale()):e.deltaX>0&&this.dollyOut(this.getZoomScale()):e.deltaY<0?this.dollyIn(this.getZoomScale()):e.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(Ze.length===2){let e=.5*(Ze[0].pageX+Ze[1].pageX),t=.5*(Ze[0].pageY+Ze[1].pageY);this.rotateStart.set(e,t)}else this.rotateStart.set(Ze[0].pageX,Ze[0].pageY)}handleTouchStartPan(){if(Ze.length===2){let e=.5*(Ze[0].pageX+Ze[1].pageX),t=.5*(Ze[0].pageY+Ze[1].pageY);this.panStart.set(e,t)}else this.panStart.set(Ze[0].pageX,Ze[0].pageY)}handleTouchStartDolly(){let e=Ze[0].pageX-Ze[1].pageX,t=Ze[0].pageY-Ze[1].pageY,i=Math.sqrt(e*e+t*t);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(e){if(Ze.length===2){let i=Mp(e),r=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this.rotateEnd.set(r,s)}else{if(e.pointerId!==Ze[0].pointerId)return;this.rotateEnd.set(e.pageX,e.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Uc);let t=this.domElement;t&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/t.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(e){if(Ze.length===2){let t=Mp(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this.panEnd.set(i,r)}else{if(e.pointerId!==Ze[0].pointerId)return;this.panEnd.set(e.pageX,e.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(kc),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(e){let t=Mp(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this.dollyEnd.set(0,s),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,bb)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(e){this.enableZoom&&this.handleTouchMoveDolly(e),this.enablePan&&this.handleTouchMovePan(e)}handleTouchMoveDollyRotate(e){this.enableZoom&&this.handleTouchMoveDolly(e),this.enableRotate&&this.handleTouchMoveRotate(e)}};function Zs(e){let t=Math.PI*2;for(;e<=-Math.PI;)e+=t;for(;e>Math.PI;)e-=t;return e}function _b(e){return 1-Math.pow(1-e,4)}function bH(e){return e.wheelDeltaY===0||e.deltaY===0?pu&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY:e.deltaMode===0}var pf=new WeakMap,wH=class extends tg{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new Of(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,n=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(n,a).then(t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let o in t.attributeTypes){let l=t.attributeTypes[o];l.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[o]=l.name)}let i=JSON.stringify(t);if(pf.has(e)){let o=pf.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,n=e.byteLength,a=this._getWorker(s,n).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),pf.set(e,{key:i,promise:a}),a}_createGeometry(e){let t=new ke;e.index&&t.setIndex(new qe(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],s=r.name,n=r.array,a=r.itemSize;t.setAttribute(s,new qe(n,a))}return t}_loadLibrary(e,t){let i=new Of(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let s=_H.toString(),n=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
4918
- `);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function _H(){let e,t;onmessage=function(a){let o=a.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let m=i(c,d,p,h),g=m.attributes.map(f=>f.array.buffer);m.index&&g.push(m.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:m},g)}catch(m){console.error(m),self.postMessage({type:"error",id:o.id,error:m.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(a,o,l,h){let u=h.attributeIDs,c=h.attributeTypes,d,p,m=o.GetEncodedGeometryType(l);if(m===a.TRIANGULAR_MESH)d=new a.Mesh,p=o.DecodeBufferToMesh(l,d);else if(m===a.POINT_CLOUD)d=new a.PointCloud,p=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let f in u){let v=self[c[f]],y,b;if(h.useUniqueIDs)b=u[f],y=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,a[u[f]]),b===-1)continue;y=o.GetAttribute(d,b)}g.attributes.push(s(a,o,d,f,v,y))}return m===a.TRIANGULAR_MESH&&(g.index=r(a,o,d)),a.destroy(d),g}function r(a,o,l){let h=l.num_faces()*3,u=h*4,c=a._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(a.HEAPF32.buffer,c,h).slice();return a._free(c),{array:d,itemSize:1}}function s(a,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,m=p*u.BYTES_PER_ELEMENT,g=n(a,u),f=a._malloc(m);o.GetAttributeDataArrayForAllPoints(l,c,g,m,f);let v=new u(a.HEAPF32.buffer,f,p).slice();return a._free(f),{name:h,array:v,itemSize:d}}function n(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var dn;function SH(){return dn||(dn=new wH,dn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),dn.decoderPending}async function AH(e){if(dn){let t={attributeIDs:dn.defaultAttributeIDs,attributeTypes:dn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await dn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function MH(e,t){let[i,r]=a_(qf.deserialize(new Uint8Array(e)));tF(i);let s=[];i.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&s.push(a)}),s.length&&await SH();for(let n of s){let a=await AH(fi(n.geometry.data.draco));if(a){a.index&&(n.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};a.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=o,n.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var Sb=Object.keys(iA).filter(e=>isNaN(Number(e))),EH=class{constructor(e,t,i,r,s,n,a,o,l,h){this.preventScroll=s,this.hideCursor=n,this.requestRender=o,this.isEnable=!1,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=u=>{(u.touches.length>1||this.preventScroll)&&u.preventDefault()},this.onMouseWheelPreventScroll=u=>{this.preventScroll&&u.preventDefault()},this.eventContext=new y8(e,t,i,a,r,h??!1),this.handlers={Spline:new Dj(this.eventContext),Conditional:new zj(this.eventContext),Start:new Jj(this.eventContext),Basic:new Lj(this.eventContext,l,this),MouseHover:new qj(this.eventContext),Scroll:new Zj(this.eventContext),Follow:new jj(this.eventContext),LookAt:new Xj(this.eventContext)}}activate(){let{scene:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),this.isEnable=!0,e.traverseEntity(r=>{console.log(r.uuid,"add listener"),r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),this.resize(),Sb.forEach(r=>{Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll)}deactivate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!1,t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),e.traverseEntity(i=>{console.log(i.uuid,"remove listener"),i.removeEventListener("requestRender",this.requestRender)}),Sb.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll)}reset(){this.deactivate(),this.activate()}resize(){this.eventContext.updaterRect()}updateUseWindowEvents(e){let t=this.isEnable;t&&this.deactivate(),console.log("EventManager.updateUseWindowEvents",{value:e,wasEnabled:t,handlers:this.handlers}),this.eventContext.useWindowEvents=e,t&&this.activate()}},CH=class{constructor(e,t,i,r,s){this._aspect=1,this._renderer=e,this._camera=t,this._frameSize=new H().copy(i),this._editorSize=new H().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewportForImageExport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.x,r=this._editorSize.y;this._aspect=e/t,this._camera.zoom*=Math.min(i/e,r/t),this._renderer.setViewport(0,0,e,t)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.x,r=this._editorSize.y,s=0,n=0,a=e,o=t;e<i&&(s=(i-e)*.5,s=-s,a=i),t<r&&(n=(r-t)*.5,n=-n,o=r),this._aspect=a/o,this._renderer.setViewport(s,n,a,o)}updateCamera(){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,i=this._fov;if(e>t){let r=TH(e,1080,2160,1,15)/100;i*=e/t,i*=1-r}this._camera.aspect=this._aspect,this._camera.fov=i,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function TH(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var TA={RED:0,GREEN:1,BLUE:2,ALPHA:3},Mh="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",PH=`#ifdef FRAMEBUFFER_PRECISION_HIGH
4918
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function _H(){let e,t;onmessage=function(a){let o=a.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let m=i(c,d,p,h),g=m.attributes.map(f=>f.array.buffer);m.index&&g.push(m.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:m},g)}catch(m){console.error(m),self.postMessage({type:"error",id:o.id,error:m.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(a,o,l,h){let u=h.attributeIDs,c=h.attributeTypes,d,p,m=o.GetEncodedGeometryType(l);if(m===a.TRIANGULAR_MESH)d=new a.Mesh,p=o.DecodeBufferToMesh(l,d);else if(m===a.POINT_CLOUD)d=new a.PointCloud,p=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let f in u){let v=self[c[f]],y,b;if(h.useUniqueIDs)b=u[f],y=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,a[u[f]]),b===-1)continue;y=o.GetAttribute(d,b)}g.attributes.push(s(a,o,d,f,v,y))}return m===a.TRIANGULAR_MESH&&(g.index=r(a,o,d)),a.destroy(d),g}function r(a,o,l){let h=l.num_faces()*3,u=h*4,c=a._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(a.HEAPF32.buffer,c,h).slice();return a._free(c),{array:d,itemSize:1}}function s(a,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,m=p*u.BYTES_PER_ELEMENT,g=n(a,u),f=a._malloc(m);o.GetAttributeDataArrayForAllPoints(l,c,g,m,f);let v=new u(a.HEAPF32.buffer,f,p).slice();return a._free(f),{name:h,array:v,itemSize:d}}function n(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var dn;function SH(){return dn||(dn=new wH,dn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),dn.decoderPending}async function AH(e){if(dn){let t={attributeIDs:dn.defaultAttributeIDs,attributeTypes:dn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await dn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function MH(e,t){let[i,r]=a_(qf.deserialize(new Uint8Array(e)));tF(i);let s=[];i.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&s.push(a)}),s.length&&await SH();for(let n of s){let a=await AH(fi(n.geometry.data.draco));if(a){a.index&&(n.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};a.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=o,n.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var Sb=Object.keys(iA).filter(e=>isNaN(Number(e))),EH=class{constructor(e,t,i,r,s,n,a,o,l,h){this.preventScroll=s,this.hideCursor=n,this.requestRender=o,this.isEnable=!1,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=u=>{(u.touches.length>1||this.preventScroll)&&u.preventDefault()},this.onMouseWheelPreventScroll=u=>{this.preventScroll&&u.preventDefault()},this.eventContext=new y8(e,t,i,a,r,h??!1),this.handlers={Spline:new Dj(this.eventContext),Conditional:new zj(this.eventContext),Start:new Jj(this.eventContext),Basic:new Lj(this.eventContext,l,this),MouseHover:new qj(this.eventContext),Scroll:new Zj(this.eventContext),Follow:new jj(this.eventContext),LookAt:new Xj(this.eventContext)}}activate(){let{scene:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),this.isEnable=!0,e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),this.resize(),Sb.forEach(r=>{Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll)}deactivate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!1,t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender)}),Sb.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll)}reset(){this.deactivate(),this.activate()}resize(){this.eventContext.updaterRect()}updateUseWindowEvents(e){let t=this.isEnable;t&&this.deactivate(),console.log("EventManager.updateUseWindowEvents",{value:e,wasEnabled:t,handlers:this.handlers}),this.eventContext.useWindowEvents=e,t&&this.activate()}},CH=class{constructor(e,t,i,r,s){this._aspect=1,this._renderer=e,this._camera=t,this._frameSize=new H().copy(i),this._editorSize=new H().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewportForImageExport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.x,r=this._editorSize.y;this._aspect=e/t,this._camera.zoom*=Math.min(i/e,r/t),this._renderer.setViewport(0,0,e,t)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.x,r=this._editorSize.y,s=0,n=0,a=e,o=t;e<i&&(s=(i-e)*.5,s=-s,a=i),t<r&&(n=(r-t)*.5,n=-n,o=r),this._aspect=a/o,this._renderer.setViewport(s,n,a,o)}updateCamera(){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,i=this._fov;if(e>t){let r=TH(e,1080,2160,1,15)/100;i*=e/t,i*=1-r}this._camera.aspect=this._aspect,this._camera.fov=i,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function TH(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var TA={RED:0,GREEN:1,BLUE:2,ALPHA:3},Mh="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",PH=`#ifdef FRAMEBUFFER_PRECISION_HIGH
4919
4919
  uniform mediump sampler2D inputBuffer;
4920
4920
  #else
4921
4921
  uniform lowp sampler2D inputBuffer;