@c-frame/physx
Version:
Physics for A-Frame using Nvidia PhysX
1 lines • 138 kB
JavaScript
(()=>{var t={261:()=>{AFRAME.registerComponent("stats-panel",{schema:{merge:{type:"boolean",default:!0}},init(){const t=document.querySelector(".rs-container");if(t&&this.data.merge)return void(this.container=t);this.base=document.createElement("div"),this.base.classList.add("rs-base");const e=document.body||document.getElementsByTagName("body")[0];t&&!this.data.merge&&(this.base.style.top="auto",this.base.style.bottom="20px"),e.appendChild(this.base),this.container=document.createElement("div"),this.container.classList.add("rs-container"),this.base.appendChild(this.container)}}),AFRAME.registerComponent("stats-group",{multiple:!0,schema:{label:{type:"string"}},init(){let t;const e=this.el.components["stats-panel"];t=e?e.container:document.querySelector(".rs-container"),t?(this.groupHeader=document.createElement("h1"),this.groupHeader.innerHTML=this.data.label,t.appendChild(this.groupHeader),this.group=document.createElement("div"),this.group.classList.add("rs-group"),this.group.style.flexDirection="column",this.group.style.webKitFlexDirection="column",t.appendChild(this.group)):console.warn("Couldn't find stats container to add stats to.\n Add either stats or stats-panel component to a-scene")}}),AFRAME.registerComponent("stats-row",{multiple:!0,schema:{group:{type:"string"},event:{type:"string"},properties:{type:"array"},label:{type:"string"}},init(){const t="stats-group__"+this.data.group,e=this.el.components[t]||this.el.sceneEl.components[t]||this.el.components["stats-group"]||this.el.sceneEl.components["stats-group"];e?(this.counter=document.createElement("div"),this.counter.classList.add("rs-counter-base"),e.group.appendChild(this.counter),this.counterId=document.createElement("div"),this.counterId.classList.add("rs-counter-id"),this.counterId.innerHTML=this.data.label,this.counter.appendChild(this.counterId),this.counterValues={},this.data.properties.forEach((t=>{const e=document.createElement("div");e.classList.add("rs-counter-value"),e.innerHTML="...",this.counter.appendChild(e),this.counterValues[t]=e})),this.updateStatsData=this.updateStatsData.bind(this),this.el.addEventListener(this.data.event,this.updateStatsData),this.splitCache={}):console.warn(`Couldn't find stats group ${t}`)},updateStatsData(t){this.data.properties&&this.data.properties.forEach((e=>{const n=this.splitDot(e);let r=t.detail;for(i=0;i<n.length;i++)r=r[n[i]];this.counterValues[e].innerHTML=r}))},splitDot(t){return t in this.splitCache||(this.splitCache[t]=t.split(".")),this.splitCache[t]}}),AFRAME.registerComponent("stats-collector",{multiple:!0,schema:{inEvent:{type:"string"},properties:{type:"array"},outputFrequency:{type:"number",default:100},outEvent:{type:"string"},outputs:{type:"array"},outputToConsole:{type:"string"}},init(){this.statsData={},this.resetData(),this.outputDetail={},this.data.properties.forEach((t=>{this.outputDetail[t]={}})),this.statsReceived=this.statsReceived.bind(this),this.el.addEventListener(this.data.inEvent,this.statsReceived)},resetData(){this.counter=0,this.data.properties.forEach((t=>{this.statsData[t]=[]}))},statsReceived(t){this.updateStatsData(t.detail),this.counter++,this.counter===this.data.outputFrequency&&(this.outputData(),this.resetData())},updateStatsData(t){this.data.properties.forEach((e=>{let i=t;i=i[e],this.statsData[e].push(i)}))},outputData(){this.data.properties.forEach((t=>{this.data.outputs.forEach((e=>{this.outputDetail[t][e]=this.computeOutput(e,this.statsData[t])}))})),this.data.outEvent&&this.el.emit(this.data.outEvent,this.outputDetail),this.data.outputToConsole&&console.log(this.data.outputToConsole,this.outputDetail)},computeOutput(t,e){const i=t.split("__");let n;switch(i[0]){case"mean":n=e.reduce(((t,e)=>t+e),0)/e.length;break;case"max":n=Math.max(...e);break;case"min":n=Math.min(...e);break;case"percentile":const t=e.sort(((t,e)=>t-e)),r=+i[1].replace("_",".")/100,o=(e.length-1)*r,s=Math.floor(o),a=o-s;n=void 0!==t[s+1]?t[s]+a*(t[s+1]-t[s]):t[s]}return n.toFixed(2)}})},590:(t,e,i)=>{let n=i(651);function r(t,e){return this.system._pool[t]||(this.system._pool[t]=new e),this.system._pool[t]}function o(t,e){return this._pool[t]||(this._pool[t]=new e),this._pool[t]}function s(t,e){t.hasLoaded?e():t.addEventListener("loaded",e)}function a(t){return new Promise(((e,i)=>s(t,e)))}Util={},class{static init(t,{useSystem:e=!1}={}){e?(t.system||console.error("No system for system pool",t.attrName),t.system._pool||(t.system._pool={}),t.pool=r):(t._pool={},t.pool=o)}}.init(Util),Util.applyMatrix=function(t,e){e.matrix.copy(t),t.decompose(e.position,e.rotation,e.scale)},Util.traverseCondition=function(t,e,i){if(e(t)){i(t);for(let n of t.children)this.traverseCondition(n,e,i)}},Util.positionObject3DAtTarget=function(t,e,{scale:i,transformOffset:n,transformRoot:r}={}){void 0===r&&(r=t.parent),e.updateWorldMatrix();let o=this.pool("dest",THREE.Matrix4);if(o.copy(e.matrixWorld),n){let t=this.pool("transformMat",THREE.Matrix4);t.makeTranslation(n.x,n.y,n.z),o.multiply(t)}if(i){let t=this.pool("scale",THREE.Vector3);t.setFromMatrixScale(o),t.set(i.x/t.x,i.y/t.y,i.z/t.z),o.scale(t)}let s=this.pool("inv",THREE.Matrix4);r.updateWorldMatrix(),s.copy(r.matrixWorld).invert(),o.premultiply(s),Util.applyMatrix(o,t)},Util.whenLoaded=function(t,e){return Array.isArray(t)&&e?function(t,e){let i=t.map((()=>!1));for(let n=0;n<t.length;++n){let r=n;s(t[r],(()=>{i[r]=!0,i.every((t=>t))&&e()}))}}(t,e):Array.isArray(t)?async function(t){for(let e of t)await a(e)}(t):e?s(t,e):a(t)},Util.whenComponentInitialized=function(t,e,i){return t&&t.components[e]&&t.components[e].initialized?Promise.resolve(i?i():void 0):new Promise(((n,r)=>{if(t&&t.components[e]&&t.components[e].initialized)return Promise.resolve(i?i():void 0);let o=r=>{r.detail.name===e&&(t.removeEventListener("componentinitialized",o),i&&i(),n())};t.addEventListener("componentinitialized",o)}))};const c={object3DPhysXTransform:(()=>{let t=new THREE.Vector3,e=new THREE.Quaternion;return function(i){return i.getWorldPosition(t),i.getWorldQuaternion(e),{translation:{x:t.x,y:t.y,z:t.z},rotation:{w:e.w,x:e.x,y:e.y,z:e.z}}}})(),matrixToTransform:(()=>{let t=new THREE.Vector3,e=new THREE.Quaternion,i=new THREE.Vector3;return new THREE.Matrix4,new THREE.Matrix4,function(n){return n.decompose(t,e,i),{translation:{x:t.x,y:t.y,z:t.z},rotation:{w:e.w,x:e.x,y:e.y,z:e.z}}}})(),layersToMask:(()=>{let t=new THREE.Layers;return function(e){t.disableAll();for(let i of e)t.enable(parseInt(i));return t.mask}})(),axisArrayToEnums:function(t){let e=[];for(let i of t){if("swing"===i){e.push(d.PxD6Axis.eSWING1),e.push(d.PxD6Axis.eSWING2);continue}let t=`e${i.toUpperCase()}`;t in d.PxD6Axis||console.warn(`Unknown axis ${i} (PxD6Axis::${t})`),e.push(d.PxD6Axis[t])}return e}};let d;AFRAME.registerSystem("physx",{schema:{delay:{default:5e3},throttle:{default:10},autoLoad:{default:!1},speed:{default:1},wasmUrl:{default:"../../wasm/physx.release.wasm"},useDefaultScene:{default:!0},wrapBounds:{default:!1},groundCollisionLayers:{default:[2]},groundCollisionMask:{default:[1,2,3,4]},gravity:{type:"vec3",default:{x:0,y:-9.8,z:0}},stats:{type:"array",default:[]}},init(){this.PhysXUtil=c,this.cumTimeEngine=0,this.cumTimeWrapper=0,this.tickCounter=0,this.objects=new Map,this.shapeMap=new Map,this.jointMap=new Map,this.boundaryShapes=new Set,this.worldHelper=new THREE.Object3D,this.el.object3D.add(this.worldHelper),this.tock=AFRAME.utils.throttleTick(this.tock,this.data.throttle,this),this.collisionObject={thisShape:null,otherShape:null,points:[],impulses:[],otherComponent:null};let t=document.createElement("a-entity");this.el.append(t),this.defaultTarget=t,this.initializePhysX=new Promise(((t,e)=>{this.fulfillPhysXPromise=t})),this.initStats(),this.el.addEventListener("inspectortoggle",(t=>{console.log("Inspector toggle",t),!0===t.detail&&(this.running=!1)}))},initStats(){if(this.statsToConsole=this.data.stats.includes("console"),this.statsToEvents=this.data.stats.includes("events"),this.statsToPanel=this.data.stats.includes("panel"),this.bodyTypeToStatsPropertyMap={static:"staticBodies",dynamic:"dynamicBodies",kinematic:"kinematicBodies"},(this.statsToConsole||this.statsToEvents||this.statsToPanel)&&(this.trackPerf=!0,this.tickCounter=0,this.statsTickData={},this.statsBodyData={},this.el.sceneEl.setAttribute("stats-collector","inEvent: physics-tick-data;\n properties: engine, after, total;\n outputFrequency: 100;\n outEvent: physics-tick-summary;\n outputs: percentile__50, percentile__90, max")),this.statsToPanel){const t=this.el.sceneEl,e="   ";t.setAttribute("stats-panel",""),t.setAttribute("stats-group__bodies","label: Physics Bodies"),t.setAttribute("stats-row__b1","group: bodies;\n event:physics-body-data;\n properties: staticBodies;\n label: Static"),t.setAttribute("stats-row__b2","group: bodies;\n event:physics-body-data;\n properties: dynamicBodies;\n label: Dynamic"),t.setAttribute("stats-row__b3","group: bodies;\n event:physics-body-data;\n properties: kinematicBodies;\n label: Kinematic"),t.setAttribute("stats-group__tick",`label: Physics Ticks: Median${e}90th%${e}99th%`),t.setAttribute("stats-row__1","group: tick; \n event:physics-tick-summary; \n properties: engine.percentile__50, \n engine.percentile__90, \n engine.max;\n label: Engine"),t.setAttribute("stats-row__2","group: tick;\n event:physics-tick-summary;\n properties: after.percentile__50, \n after.percentile__90, \n after.max; \n label: After"),t.setAttribute("stats-row__3","group: tick;\n event:physics-tick-summary;\n properties: total.percentile__50, \n total.percentile__90, \n total.max;\n label: Total")}},findWasm(){return this.data.wasmUrl},async startPhysX(){this.running=!0;let t,e=this,i=new Promise(((e,i)=>t=e)),r=n({locateFile:()=>e.findWasm(),onRuntimeInitialized(){t()}});r instanceof Promise&&(r=await r),this.PhysX=r,d=r,await i,e.startPhysXScene(),e.physXInitialized=!0,e.fulfillPhysXPromise(),e.el.emit("physx-started",{})},startPhysXScene(){console.info("Starting PhysX scene");const t=d.PxCreateFoundation(d.PX_PHYSICS_VERSION,new d.PxDefaultAllocator,new d.PxDefaultErrorCallback);this.foundation=t;const e=d.PxSimulationEventCallback.implement({onContactBegin:(t,e,i,n)=>{let r=this.shapeMap.get(t.$$.ptr),o=this.shapeMap.get(e.$$.ptr);o!==r&&(r&&r.data.emitCollisionEvents&&(this.collisionObject.thisShape=t,this.collisionObject.otherShape=e,this.collisionObject.points=i,this.collisionObject.impulses=n,this.collisionObject.otherComponent=o,r.el.emit("contactbegin",this.collisionObject)),o&&o.data.emitCollisionEvents&&(this.collisionObject.thisShape=e,this.collisionObject.otherShape=t,this.collisionObject.points=i,this.collisionObject.impulses=n,this.collisionObject.otherComponent=r,o.el.emit("contactbegin",this.collisionObject)))},onContactEnd:(t,e)=>{let i=this.shapeMap.get(t.$$.ptr),n=this.shapeMap.get(e.$$.ptr);n!==i&&(i&&i.data.emitCollisionEvents&&(this.collisionObject.thisShape=t,this.collisionObject.otherShape=e,this.collisionObject.points=null,this.collisionObject.impulses=null,this.collisionObject.otherComponent=n,i.el.emit("contactend",this.collisionObject)),n&&n.data.emitCollisionEvents&&(this.collisionObject.thisShape=e,this.collisionObject.otherShape=t,this.collisionObject.points=null,this.collisionObject.impulses=null,this.collisionObject.otherComponent=i,n.el.emit("contactend",this.collisionObject)))},onContactPersist:()=>{},onTriggerBegin:()=>{},onTriggerEnd:()=>{},onConstraintBreak:t=>{let e=this.jointMap.get(t.$$.ptr);e&&e.el.emit("constraintbreak",{})}});let i=new d.PxTolerancesScale;this.physics=d.PxCreatePhysics(d.PX_PHYSICS_VERSION,t,i,!1,null),d.PxInitExtensions(this.physics,null),this.cooking=d.PxCreateCooking(d.PX_PHYSICS_VERSION,t,new d.PxCookingParams(i));const n=d.getDefaultSceneDesc(this.physics.getTolerancesScale(),0,e);this.scene=this.physics.createScene(n),this.setupDefaultEnvironment()},setupDefaultEnvironment(){this.defaultActorFlags=new d.PxShapeFlags(d.PxShapeFlag.eSCENE_QUERY_SHAPE.value|d.PxShapeFlag.eSIMULATION_SHAPE.value),this.defaultFilterData=new d.PxFilterData(c.layersToMask(this.data.groundCollisionLayers),c.layersToMask(this.data.groundCollisionMask),0,0),this.scene.setGravity(this.data.gravity),this.data.useDefaultScene&&(this.createGroundPlane(),this.createBoundingCylinder()),this.defaultTarget.setAttribute("physx-body","type","static")},createGroundPlane(){let t=new d.PxPlaneGeometry,e=this.physics.createMaterial(.8,.8,.1);const i=this.physics.createShape(t,e,!1,this.defaultActorFlags);i.setQueryFilterData(this.defaultFilterData),i.setSimulationFilterData(this.defaultFilterData);let n=this.physics.createRigidStatic({translation:{x:0,y:0,z:-5},rotation:{w:.707107,x:0,y:0,z:.707107}});n.attachShape(i),this.scene.addActor(n,null),this.ground=n,this.rigidBody=n},createBoundingCylinder(){let t=new d.PxPlaneGeometry,e=this.physics.createMaterial(.1,.1,.8),i=new THREE.Spherical;i.radius=30;let n=new THREE.Quaternion,r=new THREE.Vector3,o=new THREE.Euler;for(let s=0;s<16;++s){i.theta=2*s*Math.PI/16,r.setFromSphericalCoords(i.radius,i.theta,i.phi),r.x=-r.y,r.y=0,o.set(0,i.theta,0),n.setFromEuler(o);const a=this.physics.createShape(t,e,!1,this.defaultActorFlags);a.setQueryFilterData(this.defaultFilterData),a.setSimulationFilterData(this.defaultFilterData);const c={translation:{x:r.x,y:r.y,z:r.z},rotation:{w:n.w,x:n.x,y:n.y,z:n.z}};this.boundaryShapes.add(a.$$.ptr);let d=this.physics.createRigidStatic(c);d.attachShape(a),this.scene.addActor(d,null)}},async registerComponentBody(t,{type:e}){await this.initializePhysX;const i=c.object3DPhysXTransform(t.el.object3D);let n;n="dynamic"===e||"kinematic"===e?this.physics.createRigidDynamic(i):this.physics.createRigidStatic(i);let r=!0,o=!1,s=new d.VectorPxReal;for(let e of t.createShapes(this.physics,this.defaultActorFlags))n.attachShape(e),isFinite(e.density)?(o=!0,s.push_back(e.density)):(r=!1,o&&console.warn("Densities not set for all shapes. Will use total mass instead.",t.el));"dynamic"!==e&&"kinematic"!==e||(r&&o?(console.log("Setting density vector",s),n.updateMassAndInertia(s)):n.setMassAndUpdateInertia(t.data.mass)),s.delete(),this.scene.addActor(n,null),this.objects.set(t.el.object3D,n),t.rigidBody=n},registerShape(t,e){this.shapeMap.set(t.$$.ptr,e)},registerJoint(t,e){this.jointMap.set(t.$$.ptr,e)},removeBody(t){let e=t.rigidBody;this.objects.delete(t.el.object3D),e.release()},tock(t,e){if(t<this.data.delay)return;if(this.physXInitialized||!this.data.autoLoad||this.running||this.startPhysX(),!this.physXInitialized)return;if(!this.running)return;const i=performance.now();this.scene.simulate(THREE.MathUtils.clamp(e*this.data.speed/1e3,0,.03*this.data.speed),!0),this.scene.fetchResults(!0);const n=performance.now();for(let[t,e]of this.objects){if("static"===t.el.components["physx-body"].data.type)continue;const i=e.getGlobalPose();this.worldHelper.position.copy(i.translation),this.worldHelper.quaternion.copy(i.rotation),t.getWorldScale(this.worldHelper.scale),Util.positionObject3DAtTarget(t,this.worldHelper)}if(this.trackPerf){const t=performance.now();this.statsTickData.engine=n-i,this.statsTickData.after=t-n,this.statsTickData.total=t-i,this.el.emit("physics-tick-data",this.statsTickData),this.tickCounter++,100===this.tickCounter&&(this.countBodies(),this.statsToConsole&&console.log("Physics tick stats:",this.statsData),(this.statsToEvents||this.statsToPanel)&&this.el.emit("physics-body-data",this.statsBodyData),this.tickCounter=0)}},countBodies(){const t=this.statsBodyData;t.staticBodies=0,t.kinematicBodies=0,t.dynamicBodies=0,this.objects.forEach(((e,i)=>{const n=i.el.components["physx-body"].data.type,r=this.bodyTypeToStatsPropertyMap[n];t[r]++}))}}),AFRAME.registerComponent("physx-material",{schema:{staticFriction:{default:.2},dynamicFriction:{default:.2},restitution:{default:.2},density:{type:"number",default:NaN},collisionLayers:{default:[1],type:"array"},collidesWithLayers:{default:[1,2,3,4],type:"array"},collisionGroup:{default:0},contactOffset:{default:-1},restOffset:{default:-1}}}),AFRAME.registerComponent("physx-body",{dependencies:["physx-material"],schema:{type:{default:"dynamic",oneOf:["dynamic","static","kinematic"]},mass:{default:1},angularDamping:{default:0},linearDamping:{default:0},emitCollisionEvents:{default:!1},highPrecision:{default:!1},shapeOffset:{type:"vec3",default:{x:0,y:0,z:0}}},events:{stateadded:function(t){"grabbed"===t.detail&&this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eKINEMATIC,!0)},stateremoved:function(t){"grabbed"===t.detail&&(this.floating&&this.rigidBody.setLinearVelocity({x:0,y:0,z:0},!0),"kinematic"!==this.data.type&&this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eKINEMATIC,!1))},bbuttonup:function(t){this.toggleGravity()},componentchanged:function(t){"physx-material"===t.name&&this.el.emit("object3dset",{})},object3dset:function(t){if(this.rigidBody){for(let t of this.shapes)this.rigidBody.detachShape(t,!1);let t=!0,e=!1,i=new d.VectorPxReal,n=this,r=this.data.type,o=this.rigidBody;for(let r of n.createShapes(this.system.physics,this.system.defaultActorFlags))o.attachShape(r),isFinite(r.density)?(e=!0,i.push_back(r.density)):(t=!1,e&&console.warn("Densities not set for all shapes. Will use total mass instead.",n.el));"dynamic"!==r&&"kinematic"!==r||(t&&e?(console.log("Setting density vector",i),o.updateMassAndInertia(i)):o.setMassAndUpdateInertia(n.data.mass))}},contactbegin:function(t){}},init(){this.system=this.el.sceneEl.systems.physx,this.physxRegisteredPromise=this.system.registerComponentBody(this,{type:this.data.type}),this.el.setAttribute("grab-options","scalable",!1),this.kinematicMove=this.kinematicMove.bind(this),this.el.sceneEl.systems["button-caster"]&&this.el.sceneEl.systems["button-caster"].install(["bbutton"]),this.physxRegisteredPromise.then((()=>this.update()))},update(t){this.rigidBody&&("dynamic"===this.data.type&&(this.rigidBody.setAngularDamping(this.data.angularDamping),this.rigidBody.setLinearDamping(this.data.linearDamping),this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eKINEMATIC,!1)),this.data.highPrecision&&("dynamic"===this.data.type?(this.rigidBody.setSolverIterationCounts(4,2),this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eENABLE_CCD,!0)):"kinematic"===this.data.type&&(this.rigidBody.setSolverIterationCounts(4,2),this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD,!0))),t&&this.data.mass===t.mass||this.el.emit("object3dset",{}))},remove(){this.rigidBody&&this.system.removeBody(this)},createGeometry(t){if(t.el.hasAttribute("geometry")){let e=t.el.getAttribute("geometry");switch(e.primitive){case"sphere":return new d.PxSphereGeometry(e.radius*this.el.object3D.scale.x*.98);case"box":return new d.PxBoxGeometry(e.width/2,e.height/2,e.depth/2);default:return this.createConvexMeshGeometry(t.el.getObject3D("mesh"))}}},createConvexMeshGeometry(t,e){let i=new d.PxVec3Vector,n=t.geometry.attributes.position;if(!n)return;if(n.count<3)return;if(3!=n.itemSize)return;let r=new THREE.Vector3;if(e){let o=new THREE.Matrix4;t.updateMatrix(),o.copy(t.matrix);let s=t.parent;for(;s&&s!==e;)s.updateMatrix(),o.premultiply(s.matrix),s=s.parent;for(let t=0;t<n.count;++t)r.fromBufferAttribute(n,t),r.applyMatrix4(o),i.push_back(Object.assign({},r))}else for(let t=0;t<n.count;++t)r.fromBufferAttribute(n,t),i.push_back(Object.assign({},r));let o=new THREE.Vector3,s=e||t;s.updateMatrixWorld(),s.getWorldScale(o);let a=this.system.cooking.createConvexMesh(i,this.system.physics);return new d.PxConvexMeshGeometry(a,new d.PxMeshScale({x:o.x,y:o.y,z:o.z},{w:1,x:0,y:0,z:0}),new d.PxConvexMeshGeometryFlags(d.PxConvexMeshGeometryFlag.eTIGHT_BOUNDS.value))},createShape(t,e,i){let n=t.createMaterial(i.staticFriction,i.dynamicFriction,i.restitution),r=t.createShape(e,n,!1,this.system.defaultActorFlags);return r.setQueryFilterData(new d.PxFilterData(c.layersToMask(i.collisionLayers),c.layersToMask(i.collidesWithLayers),i.collisionGroup,0)),r.setSimulationFilterData(new d.PxFilterData(c.layersToMask(i.collisionLayers),c.layersToMask(i.collidesWithLayers),i.collisionGroup,0)),i.contactOffset>=0&&r.setContactOffset(i.contactOffset),i.restOffset>=0&&r.setRestOffset(i.restOffset),r.density=i.density,this.system.registerShape(r,this),r},createShapes(t){if(this.el.hasAttribute("geometry")){let e=this.createGeometry(this.el.object3D);if(!e)return;let i=this.el.components["physx-material"].data;return this.shapes=[this.createShape(t,e,i)],this.shapes}let e=[];return Util.traverseCondition(this.el.object3D,(t=>!(t.el&&t.el.hasAttribute("physx-no-collision")||t.el&&!t.el.object3D.visible&&!t.el.hasAttribute("physx-hidden-collision")||!t.visible&&t.el&&!t.el.hasAttribute("physx-hidden-collision")||t.userData&&t.userData.vartisteUI)),(i=>{if(i.geometry){let n,r;if(n=this.createConvexMeshGeometry(i,this.el.object3D),!n)return void console.warn("Couldn't create geometry",i);r=i.el&&i.el.hasAttribute("physx-material")?i.el.getAttribute("physx-material"):this.el.components["physx-material"].data;let o=this.createShape(t,n,r);e.push(o)}})),this.shapes=e,e},toggleGravity(){this.rigidBody.setActorFlag(d.PxActorFlag.eDISABLE_GRAVITY,!this.floating),this.floating=!this.floating},resetBodyPose(){this.rigidBody.setGlobalPose(c.object3DPhysXTransform(this.el.object3D),!0)},kinematicMove(){this.rigidBody.setKinematicTarget(c.object3DPhysXTransform(this.el.object3D))},tock(t,e){this.rigidBody&&"kinematic"===this.data.type&&!this.setKinematic&&(this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eKINEMATIC,!0),this.setKinematic=!0),this.rigidBody&&("kinematic"===this.data.type||this.el.is("grabbed"))&&this.kinematicMove()}}),AFRAME.registerComponent("physx-joint-driver",{dependencies:["physx-joint"],multiple:!0,schema:{axes:{type:"array",default:[]},stiffness:{default:1},damping:{default:1},forceLimit:{default:34028234663852886e22},useAcceleration:{default:!0},linearVelocity:{type:"vec3",default:{x:0,y:0,z:0}},angularVelocity:{type:"vec3",default:{x:0,y:0,z:0}},lockOtherAxes:{default:!1},slerpRotation:{default:!0}},events:{"physx-jointcreated":function(t){this.setJointDriver()}},init(){this.el.setAttribute("phsyx-custom-constraint","")},setJointDriver(){if(this.enumAxes||this.update(),"D6"!==this.el.components["physx-joint"].data.type)return void console.warn("Only D6 joint drivers supported at the moment");let t=this.el.sceneEl.systems.physx.PhysX;this.joint=this.el.components["physx-joint"].joint,this.data.lockOtherAxes&&(this.joint.setMotion(t.PxD6Axis.eX,t.PxD6Motion.eLOCKED),this.joint.setMotion(t.PxD6Axis.eY,t.PxD6Motion.eLOCKED),this.joint.setMotion(t.PxD6Axis.eZ,t.PxD6Motion.eLOCKED),this.joint.setMotion(t.PxD6Axis.eSWING1,t.PxD6Motion.eLOCKED),this.joint.setMotion(t.PxD6Axis.eSWING2,t.PxD6Motion.eLOCKED),this.joint.setMotion(t.PxD6Axis.eTWIST,t.PxD6Motion.eLOCKED));for(let e of this.enumAxes)this.joint.setMotion(e,t.PxD6Motion.eFREE);let e=new t.PxD6JointDrive;e.stiffness=this.data.stiffness,e.damping=this.data.damping,e.forceLimit=this.data.forceLimit,e.setAccelerationFlag(this.data.useAcceleration);for(let t of this.driveAxes)this.joint.setDrive(t,e);console.log("Setting joint driver",this.driveAxes,this.enumAxes),this.joint.setDrivePosition({translation:{x:0,y:0,z:0},rotation:{w:1,x:0,y:0,z:0}},!0),this.joint.setDriveVelocity(this.data.linearVelocity,this.data.angularVelocity,!0)},update(t){if(d){this.enumAxes=[];for(let t of this.data.axes){if("swing"===t){this.enumAxes.push(d.PxD6Axis.eSWING1),this.enumAxes.push(d.PxD6Axis.eSWING2);continue}let e=`e${t.toUpperCase()}`;e in d.PxD6Axis||console.warn(`Unknown axis ${t} (PxD6Axis::${e})`),this.enumAxes.push(d.PxD6Axis[e])}this.driveAxes=[];for(let t of this.data.axes){if("swing"===t){this.data.slerpRotation?this.driveAxes.push(d.PxD6Drive.eSLERP):this.driveAxes.push(d.PxD6Drive.eSWING);continue}if("twist"===t&&this.data.slerpRotation){this.driveAxes.push(d.PxD6Drive.eSLERP);continue}let e=`e${t.toUpperCase()}`;e in d.PxD6Drive||console.warn(`Unknown axis ${t} (PxD6Axis::${e})`),this.driveAxes.push(d.PxD6Drive[e])}}}}),AFRAME.registerComponent("physx-joint-constraint",{multiple:!0,schema:{lockedAxes:{type:"array",default:[]},constrainedAxes:{type:"array",default:[]},freeAxes:{type:"array",default:[]},linearLimit:{type:"vec2"},angularLimit:{type:"vec2"},limitCone:{type:"vec2"},twistLimit:{type:"vec2"},damping:{default:0},restitution:{default:0},stiffness:{default:0}},events:{"physx-jointcreated":function(t){this.setJointConstraint()}},init(){this.propsInitialized=!1,this.el.setAttribute("phsyx-custom-constraint","")},setJointConstraint(){const t=this.el.components["physx-joint"].data.type;if("D6"!==t&&"Revolute"!==t&&"Prismatic"!==t)return void console.warn("Only D6, Revolute and Prismatic joint constraints supported at the moment");this.propsInitialized||this.update();const e=this.el.components["physx-joint"].joint;if("Revolute"===t){const t=new d.PxSpring(this.data.stiffness,this.data.damping),i=new d.PxJointAngularLimitPair(-THREE.MathUtils.degToRad(this.data.angularLimit.y),-THREE.MathUtils.degToRad(this.data.angularLimit.x),t);i.restitution=this.data.restitution,e.setLimit(i),e.setRevoluteJointFlag(d.PxRevoluteJointFlag.eLIMIT_ENABLED,!0)}if("Prismatic"===t){const t=new d.PxSpring(this.data.stiffness,this.data.damping),i=new d.PxJointLinearLimitPair(-this.data.linearLimit.y,-this.data.linearLimit.x,t);i.restitution=this.data.restitution,e.setLimit(i),e.setPrismaticJointFlag(d.PxPrismaticJointFlag.eLIMIT_ENABLED,!0)}if("D6"===t){const t=t=>{const e=new d.PxSpring(this.data.stiffness,this.data.damping);let i;return i=t===d.PxD6Axis.eX||t===d.PxD6Axis.eZ?new d.PxJointLinearLimitPair(-this.data.linearLimit.y,-this.data.linearLimit.x,e):new d.PxJointLinearLimitPair(this.data.linearLimit.x,this.data.linearLimit.y,e),i.restitution=this.data.restitution,i};for(let t of this.freeAxes)e.setMotion(t,d.PxD6Motion.eFREE);for(let t of this.lockedAxes)e.setMotion(t,d.PxD6Motion.eLOCKED);for(let i of this.constrainedAxes){if(i===d.PxD6Axis.eX||i===d.PxD6Axis.eY||i===d.PxD6Axis.eZ){e.setMotion(i,d.PxD6Motion.eLIMITED),e.setLinearLimit(i,t(i));continue}if(i===d.PxD6Axis.eTWIST){e.setMotion(d.PxD6Axis.eTWIST,d.PxD6Motion.eLIMITED);const t=new d.PxSpring(this.data.stiffness,this.data.damping),i=new d.PxJointAngularLimitPair(-THREE.MathUtils.degToRad(this.data.twistLimit.y),-THREE.MathUtils.degToRad(this.data.twistLimit.x),t);i.restitution=this.data.restitution,e.setTwistLimit(i);continue}e.setMotion(i,d.PxD6Motion.eLIMITED);const n=new d.PxSpring(this.data.stiffness,this.data.damping),r=new d.PxJointLimitCone(-THREE.MathUtils.degToRad(this.data.limitCone.y),-THREE.MathUtils.degToRad(this.data.limitCone.x),n);r.restitution=this.data.restitution,e.setSwingLimit(r)}}},update(t){d&&(this.propsInitialized=!0,this.constrainedAxes=c.axisArrayToEnums(this.data.constrainedAxes),this.lockedAxes=c.axisArrayToEnums(this.data.lockedAxes),this.freeAxes=c.axisArrayToEnums(this.data.freeAxes))}}),AFRAME.registerComponent("physx-joint",{multiple:!0,schema:{type:{default:"Spherical",oneOf:["Fixed","Spherical","Distance","Revolute","Prismatic","D6"]},target:{type:"selector"},breakForce:{type:"vec2",default:{x:-1,y:-1}},removeElOnBreak:{default:!1},collideWithTarget:{default:!1},softFixed:{default:!1},projectionTolerance:{type:"vec2",default:{x:-1,y:-1}}},events:{constraintbreak:function(t){this.data.removeElOnBreak&&this.el.remove()}},init(){this.system=this.el.sceneEl.systems.physx;let t=this.el;for(;t&&!t.hasAttribute("physx-body");)t=t.parentEl;t?(this.bodyEl=t,this.worldHelper=new THREE.Object3D,this.worldHelperParent=new THREE.Object3D,this.el.sceneEl.object3D.add(this.worldHelperParent),this.targetScale=new THREE.Vector3(1,1,1),this.worldHelperParent.add(this.worldHelper),this.data.target||(this.data.target=this.system.defaultTarget),Util.whenLoaded([this.el,this.bodyEl,this.data.target],(()=>{this.createJoint()}))):console.warn("physx-joint must be used within a physx-body")},remove(){this.joint&&(this.joint.release(),this.joint=null,this.bodyEl.components["physx-body"].rigidBody.wakeUp(),this.data.target.components["physx-body"].rigidBody.wakeUp&&this.data.target.components["physx-body"].rigidBody.wakeUp())},update(){if(this.joint&&(this.data.breakForce.x>=0&&this.data.breakForce.y>=0&&this.joint.setBreakForce(this.data.breakForce.x,THREE.MathUtils.degToRad(this.data.breakForce.y)),this.joint.setConstraintFlag(d.PxConstraintFlag.eCOLLISION_ENABLED,this.data.collideWithTarget),this.data.projectionTolerance.x>=0&&this.data.projectionTolerance.y>=0?(this.joint.setProjectionLinearTolerance(this.data.projectionTolerance.x),this.joint.setProjectionAngularTolerance(THREE.MathUtils.degToRad(this.data.projectionTolerance.y)),this.joint.setConstraintFlag(d.PxConstraintFlag.ePROJECTION,!0)):this.joint.setConstraintFlag(d.PxConstraintFlag.ePROJECTION,!1),!this.el.hasAttribute("phsyx-custom-constraint")&&"D6"===this.data.type)&&this.data.softFixed){this.joint.setMotion(d.PxD6Axis.eX,d.PxD6Motion.eFREE),this.joint.setMotion(d.PxD6Axis.eY,d.PxD6Motion.eFREE),this.joint.setMotion(d.PxD6Axis.eZ,d.PxD6Motion.eFREE),this.joint.setMotion(d.PxD6Axis.eSWING1,d.PxD6Motion.eFREE),this.joint.setMotion(d.PxD6Axis.eSWING2,d.PxD6Motion.eFREE),this.joint.setMotion(d.PxD6Axis.eTWIST,d.PxD6Motion.eFREE);let t=new d.PxD6JointDrive;t.stiffness=1e3,t.damping=500,t.forceLimit=1e3,t.setAccelerationFlag(!1),this.joint.setDrive(d.PxD6Drive.eX,t),this.joint.setDrive(d.PxD6Drive.eY,t),this.joint.setDrive(d.PxD6Drive.eZ,t),this.joint.setDrive(d.PxD6Drive.eSLERP,t),this.joint.setDrivePosition({translation:{x:0,y:0,z:0},rotation:{w:1,x:0,y:0,z:0}},!0),this.joint.setDriveVelocity({x:0,y:0,z:0},{x:0,y:0,z:0},!0)}},getTransform(t){return Util.positionObject3DAtTarget(this.worldHelperParent,t.object3D,{scale:this.targetScale}),Util.positionObject3DAtTarget(this.worldHelper,this.el.object3D,{scale:this.targetScale}),c.matrixToTransform(this.worldHelper.matrix)},async createJoint(){await Util.whenComponentInitialized(this.bodyEl,"physx-body"),await Util.whenComponentInitialized(this.data.target,"physx-body"),await this.bodyEl.components["physx-body"].physxRegisteredPromise,await this.data.target.components["physx-body"].physxRegisteredPromise,this.joint&&(this.joint.release(),this.joint=null);let t=this.getTransform(this.bodyEl),e=this.getTransform(this.data.target);this.joint=d[`Px${this.data.type}JointCreate`](this.system.physics,this.bodyEl.components["physx-body"].rigidBody,t,this.data.target.components["physx-body"].rigidBody,e),this.system.registerJoint(this.joint,this),this.update(),this.el.emit("physx-jointcreated",this.joint)}}),AFRAME.registerSystem("physx-contact-event",{init(){this.worldHelper=new THREE.Object3D,this.el.sceneEl.object3D.add(this.worldHelper)}}),AFRAME.registerComponent("physx-contact-event",{dependencies:["physx-body"],schema:{impulseThreshold:{default:.01},maxDistance:{default:10},maxDuration:{default:5},startDelay:{default:6e3},positionAtContact:{default:!1}},events:{contactbegin:function(t){if(this.el.sceneEl.time<this.data.startDelay)return;let e=this.eventDetail.positionWorld,i=(this.pool("cameraWorld",THREE.Vector3),t.detail.impulses),n=0;for(let t=0;t<i.size();++t)n+=i.get(t);if(n<this.data.impulseThreshold)return;e.set(0,0,0);let r=0;if(this.data.positionAtContact){for(let n=0;n<i.size();++n){r=i.get(n);let o=t.detail.points.get(n);e.x+=o.x*r,e.y+=o.y*r,e.z+=o.z*r}e.multiplyScalar(1/n),this.system.worldHelper.position.copy(e),Util.positionObject3DAtTarget(this.localHelper,this.system.worldHelper),this.eventDetail.position.copy(this.localHelper.position)}else e.set(0,0,0),this.eventDetail.position.set(0,0,0);this.eventDetail.impulse=n,this.eventDetail.contact=t.detail,this.el.emit("contactevent",this.eventDetail)}},init(){if(VARTISTE.Pool.init(this),this.eventDetail={impulse:0,positionWorld:new THREE.Vector3,position:new THREE.Vector3,contact:null},this.data.debug){let t=document.createElement("a-entity");t.setAttribute("geometry","primitive: sphere; radius: 0.1"),t.setAttribute("physx-no-collision","")}this.localHelper=new THREE.Object3D,this.el.object3D.add(this.localHelper),this.el.setAttribute("physx-body","emitCollisionEvents",!0)},remove(){this.el.object3D.remove(this.localHelper)}}),AFRAME.registerComponent("physx-contact-sound",{dependencies:["physx-contact-event"],schema:{src:{type:"string"},impulseThreshold:{default:.01},maxDistance:{default:10},maxDuration:{default:5},startDelay:{default:6e3},positionAtContact:{default:!1}},events:{contactevent:function(t){this.data.positionAtContact&&this.sound.object3D.position.copy(t.detail.position),this.sound.components.sound.stopSound(),this.sound.components.sound.playSound()}},init(){let t=document.createElement("a-entity");this.el.append(t),t.setAttribute("sound",{src:this.data.src}),this.sound=t,this.el.setAttribute("physx-body","emitCollisionEvents",!0)},update(t){this.el.setAttribute("physx-contact-event",this.data)}}),AFRAME.registerComponent("gltf-entities",{dependencies:["gltf-model"],schema:{setId:{default:!1},idPrefix:{default:""},autoPropogateGrab:{default:!0},copyAttributes:{type:"array"},allowedAttributes:{type:"array"}},events:{"model-loaded":function(t){this.setupEntities()}},init(){},setupEntities(){let t=this.el.getObject3D("mesh");t&&this.setupObject(t,this.el)},setupObject(t,e){if(t.userData["a-entity"]){let i=document.createElement("a-entity"),n=t.userData["a-entity"];if(i.innerHTML=n,i.innerHTML=`<a-entity ${i.innerText}></a-entity>`,i=i.children[0],this.data.allowedAttributes.length)for(let t of i.attributes)this.data.allowedAttributes.includes(t.name)||i.removeAttribute(t.name);this.data.setId&&t.name&&(i.id=`${this.data.idPrefix}${t.name}`);for(let t of this.data.copyAttributes)this.el.hasAttribute(t)&&i.setAttribute(t,this.el.getAttribute(t));this.data.autoPropogateGrab&&this.el.classList.contains("clickable")&&(i.setAttribute("propogate-grab",""),i.classList.add("clickable")),e.append(i),Util.whenLoaded(i,(()=>{i.setObject3D("mesh",t),t.updateMatrix(),Util.applyMatrix(t.matrix,i.object3D),t.matrix.identity(),Util.applyMatrix(t.matrix,t)})),e=i}for(let i of t.children)this.setupObject(i,e)}})},651:(t,e,i)=>{var n,r=(n=(n="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){var e,r,o=void 0!==(t=t||{})?t:{};o.ready=new Promise((function(t,i){e=t,r=i})),Object.getOwnPropertyDescriptor(o.ready,"_main")||(Object.defineProperty(o.ready,"_main",{configurable:!0,get:function(){Mt("You are getting _main on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_main",{configurable:!0,set:function(){Mt("You are setting _main on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_malloc")||(Object.defineProperty(o.ready,"_malloc",{configurable:!0,get:function(){Mt("You are getting _malloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_malloc",{configurable:!0,set:function(){Mt("You are setting _malloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_free")||(Object.defineProperty(o.ready,"_free",{configurable:!0,get:function(){Mt("You are getting _free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_free",{configurable:!0,set:function(){Mt("You are setting _free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_stackSave")||(Object.defineProperty(o.ready,"_stackSave",{configurable:!0,get:function(){Mt("You are getting _stackSave on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_stackSave",{configurable:!0,set:function(){Mt("You are setting _stackSave on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_stackRestore")||(Object.defineProperty(o.ready,"_stackRestore",{configurable:!0,get:function(){Mt("You are getting _stackRestore on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_stackRestore",{configurable:!0,set:function(){Mt("You are setting _stackRestore on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_stackAlloc")||(Object.defineProperty(o.ready,"_stackAlloc",{configurable:!0,get:function(){Mt("You are getting _stackAlloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_stackAlloc",{configurable:!0,set:function(){Mt("You are setting _stackAlloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"___data_end")||(Object.defineProperty(o.ready,"___data_end",{configurable:!0,get:function(){Mt("You are getting ___data_end on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"___data_end",{configurable:!0,set:function(){Mt("You are setting ___data_end on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"___wasm_call_ctors")||(Object.defineProperty(o.ready,"___wasm_call_ctors",{configurable:!0,get:function(){Mt("You are getting ___wasm_call_ctors on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"___wasm_call_ctors",{configurable:!0,set:function(){Mt("You are setting ___wasm_call_ctors on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_fflush")||(Object.defineProperty(o.ready,"_fflush",{configurable:!0,get:function(){Mt("You are getting _fflush on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_fflush",{configurable:!0,set:function(){Mt("You are setting _fflush on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"___errno_location")||(Object.defineProperty(o.ready,"___errno_location",{configurable:!0,get:function(){Mt("You are getting ___errno_location on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"___errno_location",{configurable:!0,set:function(){Mt("You are setting ___errno_location on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_htons")||(Object.defineProperty(o.ready,"_htons",{configurable:!0,get:function(){Mt("You are getting _htons on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_htons",{configurable:!0,set:function(){Mt("You are setting _htons on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_ntohs")||(Object.defineProperty(o.ready,"_ntohs",{configurable:!0,get:function(){Mt("You are getting _ntohs on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_ntohs",{configurable:!0,set:function(){Mt("You are setting _ntohs on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_memcpy")||(Object.defineProperty(o.ready,"_memcpy",{configurable:!0,get:function(){Mt("You are getting _memcpy on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_memcpy",{configurable:!0,set:function(){Mt("You are setting _memcpy on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_htonl")||(Object.defineProperty(o.ready,"_htonl",{configurable:!0,get:function(){Mt("You are getting _htonl on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_htonl",{configurable:!0,set:function(){Mt("You are setting _htonl on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"_emscripten_main_thread_process_queued_calls")||(Object.defineProperty(o.ready,"_emscripten_main_thread_process_queued_calls",{configurable:!0,get:function(){Mt("You are getting _emscripten_main_thread_process_queued_calls on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"_emscripten_main_thread_process_queued_calls",{configurable:!0,set:function(){Mt("You are setting _emscripten_main_thread_process_queued_calls on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(o.ready,"onRuntimeInitialized")||(Object.defineProperty(o.ready,"onRuntimeInitialized",{configurable:!0,get:function(){Mt("You are getting onRuntimeInitialized on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(o.ready,"onRuntimeInitialized",{configurable:!0,set:function(){Mt("You are setting onRuntimeInitialized on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}));var s,a={};for(s in o)o.hasOwnProperty(s)&&(a[s]=o[s]);var c=[],d=function(t,e){throw e},l=!1,u=!1,p=!1,h=!1;if(l="object"==typeof window,u="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,h=!l&&!p&&!u,o.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)");var f,E,y,_,T="";function g(t){return o.locateFile?o.locateFile(t,T):T+t}if(p)T=u?i(606).dirname(T)+"/":"//",f=function(t,e){return y||(y=i(351)),_||(_=i(606)),t=_.normalize(t),y.readFileSync(t,e?null:"utf8")},E=function(t){var e=f(t,!0);return e.buffer||(e=new Uint8Array(e)),M(e.buffer),e},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),c=process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof kn))throw t})),process.on("unhandledRejection",Mt),d=function(t){process.exit(t)},o.inspect=function(){return"[Emscripten Module object]"};else if(h)"undefined"!=typeof read&&(f=function(t){return read(t)}),E=function(t){var e;return"function"==typeof readbuffer?new Uint8Array(readbuffer(t)):(M("object"==typeof(e=read(t,"binary"))),e)},"undefined"!=typeof scriptArgs?c=scriptArgs:void 0!==arguments&&(c=arguments),"function"==typeof quit&&(d=function(t){quit(t)}),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print);else{if(!l&&!u)throw new Error("environment detection error");u?T=self.location.href:document.currentScript&&(T=document.currentScript.src),n&&(T=n),T=0!==T.indexOf("blob:")?T.substr(0,T.lastIndexOf("/")+1):"",f=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},u&&(E=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})}var O=o.print||console.log.bind(console),m=o.printErr||console.warn.bind(console);for(s in a)a.hasOwnProperty(s)&&(o[s]=a[s]);function D(t){D.shown||(D.shown={}),D.shown[t]||(D.shown[t]=1,m(t))}a=null,o.arguments&&(c=o.arguments),Object.getOwnPropertyDescriptor(o,"arguments")||Object.defineProperty(o,"arguments",{configurable:!0,get:function(){Mt("Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),o.thisProgram&&o.thisProgram,Object.getOwnPropertyDescriptor(o,"thisProgram")||Object.defineProperty(o,"thisProgram",{configurable:!0,get:function(){Mt("Module.thisProgram has been replaced with plain thisProgram (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),o.quit&&(d=o.quit),Object.getOwnPropertyDescriptor(o,"quit")||Object.defineProperty(o,"quit",{configurable:!0,get:function(){Mt("Module.quit has been replaced with plain quit_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),M(void 0===o.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),M(void 0===o.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),M(void 0===o.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),M(void 0===o.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),M(void 0===o.read,"Module.read option was removed (modify read_ in JS)"),M(void 0===o.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),M(void 0===o.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),M(void 0===o.setWindowTitle,"Module.setWindowTitle option was removed (modify setWindowTitle in JS)"),M(void 0===o.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),Object.getOwnPropertyDescriptor(o,"read")||Object.defineProperty(o,"read",{configurable:!0,get:function(){Mt("Module.read has been replaced with plain read_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),Object.getOwnPropertyDescriptor(o,"readAsync")||Object.defineProperty(o,"readAsync",{configurable:!0,get:function(){Mt("Module.readAsync has been replaced with plain readAsync (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),Object.getOwnPropertyDescriptor(o,"readBinary")||Object.defineProperty(o,"readBinary",{configurable:!0,get:function(){Mt("Module.readBinary has been replaced with plain readBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),Object.getOwnPropertyDescriptor(o,"setWindowTitle")||Object.defineProperty(o,"setWindowTitle",{configurable:!0,get:function(){Mt("Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is o