diff --git a/dist/physx.js b/dist/physx.js index 2708418..fe945b2 100644 --- a/dist/physx.js +++ b/dist/physx.js @@ -35,7 +35,7 @@ eval("AFRAME.registerComponent('stats-panel', {\r\n schema: {\r\n merge: {ty \************************/ /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { -eval("// This is a modification of the physics/PhysX libraries\r\n// created by Lee Stemkoski\r\n// from the VARTISTE project @ https://vartiste.xyz/ \r\n// by Zachary Capalbo https://github.com/zach-capalbo/vartiste\r\n// with the goal of creating a simplified standalone codebase.\r\n// Further performance modifications by Diarmid Mackenzie.\r\n\r\n// original documentation: https://vartiste.xyz/docs.html#physics.js\r\n\r\n// Came via: https://github.com/stemkoski/A-Frame-Examples/blob/66f05fe5cf89879996f1f6a4c0475ce475e8796a/js/physics.js\r\n// and then via: https://github.com/diarmidmackenzie/christmas-scene/blob/a94ae7e7167937f10d34df8429fb71641e343bb1/lib/physics.js\r\n// ======================================================================\r\n\r\nlet PHYSX = __webpack_require__(/*! ./physx.release.js */ \"./src/physx.release.js\");\r\n\r\n// patching in Pool functions\r\nvar poolSize = 0\r\n\r\nfunction sysPool(name, type) {\r\n if (this.system._pool[name]) return this.system._pool[name]\r\n this.system._pool[name] = new type()\r\n // console.log(\"SysPooling\", type.name)\r\n return this.system._pool[name]\r\n}\r\n\r\nfunction pool(name, type) {\r\n if (this._pool[name]) return this._pool[name]\r\n this._pool[name] = new type()\r\n // console.log(\"Pooling\", type.name)\r\n return this._pool[name]\r\n}\r\n\r\nclass Pool {\r\n static init(where, {useSystem = false} = {}) {\r\n if (useSystem)\r\n {\r\n if (!where.system) {\r\n console.error(\"No system for system pool\", where.attrName)\r\n }\r\n if (!where.system._pool) where.system._pool = {};\r\n\r\n where.pool = sysPool;\r\n }\r\n else\r\n {\r\n where._pool = {}\r\n where.pool = pool;\r\n }\r\n }\r\n}\r\n\r\n// ==================================================================================================\r\n\r\n// patching in required Util functions from VARTISTE\r\n\r\nUtil = {}\r\n\r\nPool.init(Util);\r\n\r\n// Copies `matrix` into `obj`'s (a `THREE.Object3D`) `matrix`, and decomposes\r\n// it to `obj`'s position, rotation, and scale\r\nUtil.applyMatrix = function(matrix, obj) {\r\n obj.matrix.copy(matrix)\r\n matrix.decompose(obj.position, obj.rotation, obj.scale)\r\n}\r\n\r\nUtil.traverseCondition = function(obj3D, condition, fn) \r\n{\r\n if (!condition(obj3D)) return;\r\n\r\n fn(obj3D)\r\n for (let c of obj3D.children)\r\n {\r\n this.traverseCondition(c, condition, fn)\r\n }\r\n}\r\n\r\nUtil.positionObject3DAtTarget = function(obj, target, {scale, transformOffset, transformRoot} = {}) \r\n{\r\n if (typeof transformRoot === 'undefined') transformRoot = obj.parent\r\n\r\n target.updateWorldMatrix()\r\n let destMat = this.pool('dest', THREE.Matrix4)\r\n destMat.copy(target.matrixWorld)\r\n\r\n if (transformOffset) {\r\n let transformMat = this.pool('transformMat', THREE.Matrix4)\r\n transformMat.makeTranslation(transformOffset.x, transformOffset.y, transformOffset.z)\r\n destMat.multiply(transformMat)\r\n }\r\n\r\n if (scale) {\r\n let scaleVect = this.pool('scale', THREE.Vector3)\r\n scaleVect.setFromMatrixScale(destMat)\r\n scaleVect.set(scale.x / scaleVect.x, scale.y / scaleVect.y, scale.z / scaleVect.z)\r\n destMat.scale(scaleVect)\r\n }\r\n\r\n let invMat = this.pool('inv', THREE.Matrix4)\r\n\r\n transformRoot.updateWorldMatrix()\r\n invMat.copy(transformRoot.matrixWorld).invert()\r\n destMat.premultiply(invMat)\r\n\r\n Util.applyMatrix(destMat, obj)\r\n}\r\n\r\n// untested functions\r\n\r\n// Executes function `fn` when `entity` has finished loading, or immediately\r\n// if it has already loaded. `entity` may be a single `a-entity` element, or\r\n// an array of `a-entity` elements. If `fn` is not provided, it will return a\r\n// `Promise` that will resolve when `entity` is loaded (or immediately if\r\n// `entity` is already loaded).\r\nUtil.whenLoaded = function(entity, fn) {\r\n if (Array.isArray(entity) && fn) return whenLoadedAll(entity, fn)\r\n if (Array.isArray(entity)) return awaitLoadingAll(entity)\r\n if (fn) return whenLoadedSingle(entity, fn)\r\n return awaitLoadingSingle(entity)\r\n}\r\n\r\nfunction whenLoadedSingle(entity, fn) {\r\n if (entity.hasLoaded)\r\n {\r\n fn()\r\n }\r\n else\r\n {\r\n entity.addEventListener('loaded', fn)\r\n }\r\n}\r\n\r\nfunction whenLoadedAll(entities, fn) {\r\n let allLoaded = entities.map(() => false)\r\n for (let i = 0; i < entities.length; ++i)\r\n {\r\n let ii = i\r\n let entity = entities[ii]\r\n whenLoadedSingle(entity, () => {\r\n allLoaded[ii] = true\r\n if (allLoaded.every(t => t)) fn()\r\n })\r\n }\r\n}\r\n\r\nfunction awaitLoadingSingle(entity) {\r\n return new Promise((r, e) => whenLoadedSingle(entity, r))\r\n}\r\n\r\nasync function awaitLoadingAll(entities) {\r\n for (let entity of entities)\r\n {\r\n await awaitLoadingSingle(entity)\r\n }\r\n}\r\n\r\nUtil.whenComponentInitialized = function(el, component, fn) {\r\n if (el && el.components[component] && el.components[component].initialized) {\r\n return Promise.resolve(fn ? fn() : undefined)\r\n }\r\n\r\n return new Promise((r, e) => {\r\n if (el && el.components[component] && el.components[component].initialized) {\r\n return Promise.resolve(fn ? fn() : undefined)\r\n }\r\n\r\n let listener = (e) => {\r\n if (e.detail.name === component) {\r\n el.removeEventListener('componentinitialized', listener);\r\n if (fn) fn();\r\n r();\r\n }\r\n };\r\n el.addEventListener('componentinitialized', listener)\r\n })\r\n}\r\n\r\n// ========================================================================================\r\n\r\n// Extra utility functions for dealing with PhysX\r\n\r\nconst PhysXUtil = {\r\n // Gets the world position transform of the given object3D in PhysX format\r\n object3DPhysXTransform: (() => {\r\n let pos = new THREE.Vector3();\r\n let quat = new THREE.Quaternion();\r\n return function (obj) {\r\n obj.getWorldPosition(pos);\r\n obj.getWorldQuaternion(quat);\r\n\r\n return {\r\n translation: {\r\n x: pos.x,\r\n y: pos.y,\r\n z: pos.z,\r\n },\r\n rotation: {\r\n w: quat.w, // PhysX uses WXYZ quaternions,\r\n x: quat.x,\r\n y: quat.y,\r\n z: quat.z,\r\n },\r\n }\r\n }\r\n })(),\r\n\r\n // Converts a THREE.Matrix4 into a PhysX transform\r\n matrixToTransform: (() => {\r\n let pos = new THREE.Vector3();\r\n let quat = new THREE.Quaternion();\r\n let scale = new THREE.Vector3();\r\n let scaleInv = new THREE.Matrix4();\r\n let mat2 = new THREE.Matrix4();\r\n return function (matrix) {\r\n matrix.decompose(pos, quat, scale);\r\n\r\n return {\r\n translation: {\r\n x: pos.x,\r\n y: pos.y,\r\n z: pos.z,\r\n },\r\n rotation: {\r\n w: quat.w, // PhysX uses WXYZ quaternions,\r\n x: quat.x,\r\n y: quat.y,\r\n z: quat.z,\r\n },\r\n }\r\n }\r\n })(),\r\n\r\n // Converts an arry of layer numbers to an integer bitmask\r\n layersToMask: (() => {\r\n let layers = new THREE.Layers();\r\n return function(layerArray) {\r\n layers.disableAll();\r\n for (let layer of layerArray)\r\n {\r\n layers.enable(parseInt(layer));\r\n }\r\n return layers.mask;\r\n };\r\n })(),\r\n\r\n axisArrayToEnums: function(axes) {\r\n let enumAxes = []\r\n for (let axis of axes)\r\n {\r\n if (axis === 'swing') {\r\n enumAxes.push(PhysX.PxD6Axis.eSWING1)\r\n enumAxes.push(PhysX.PxD6Axis.eSWING2)\r\n continue\r\n }\r\n let enumKey = `e${axis.toUpperCase()}`\r\n if (!(enumKey in PhysX.PxD6Axis))\r\n {\r\n console.warn(`Unknown axis ${axis} (PxD6Axis::${enumKey})`)\r\n }\r\n enumAxes.push(PhysX.PxD6Axis[enumKey])\r\n }\r\n return enumAxes;\r\n }\r\n};\r\n\r\nlet PhysX\r\n\r\n// Implements the a physics system using an emscripten compiled PhysX engine.\r\n//\r\n//\r\n// If `autoLoad` is `true`, or when you call `startPhysX`, the `physx` system will\r\n// automatically load and initialize the physics system with reasonable defaults\r\n// and a ground plane. All you have to do is add [`physx-body`](#physx-body) to\r\n// the bodies that you want to be part of the simulation. The system will take\r\n// try to take care of things like collision meshes, position updates, etc\r\n// automatically. The simplest physics scene looks something like:\r\n//\r\n//```\r\n// \r\n// \r\n//\r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// If you want a little more control over how things behave, you can set the\r\n// [`physx-material`](#physx-material) component on the objects in your\r\n// simulation, or use [`physx-joint`s](#physx-joint),\r\n// [`physx-constraint`s](#physx-constraint) and [`physx-driver`s](#physx-driver)\r\n// to add some complexity to your scene.\r\n//\r\n// If you need more low-level control, the PhysX bindings are exposed through\r\n// the `PhysX` property of the system. So for instance, if you wanted to make\r\n// use of the [`PxCapsuleGeometry`](https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxapi/files/classPxCapsuleGeometry.html)\r\n// in your own component, you would call:\r\n//\r\n//```\r\n// let myGeometry = new this.el.sceneEl.PhysX.PxCapsuleGeometry(1.0, 2.0)\r\n//```\r\n//\r\n// The system uses [my fork](https://github.com/zach-capalbo/PhysX) of PhysX, built using the [Docker Wrapper](https://github.com/ashconnell/physx-js). To see what's exposed to JavaScript, see [PxWebBindings.cpp](https://github.com/zach-capalbo/PhysX/blob/emscripten_wip/physx/source/physxwebbindings/src/PxWebBindings.cpp)\r\n//\r\n// For a complete example of how to use this, you can see the\r\n// [aframe-vartiste-toolkit Physics\r\n// Playground](https://glitch.com/edit/#!/fascinated-hip-period?path=index.html)\r\n//\r\n// It is also helpful to refer to the [NVIDIA PhysX\r\n// documentation](https://gameworksdocs.nvidia.com/PhysX/4.0/documentation/PhysXGuide/Manual/Index.html)\r\nAFRAME.registerSystem('physx', {\r\n schema: {\r\n // Amount of time to wait after loading before starting the physics. Can be\r\n // useful if there is still some things loading or initializing elsewhere in\r\n // the scene\r\n delay: {default: 5000},\r\n\r\n // Throttle for running the physics simulation. On complex scenes, you can\r\n // increase this to avoid dropping video frames\r\n throttle: {default: 10},\r\n\r\n // If true, the PhysX will automatically be loaded and started. If false,\r\n // you will have to call `startPhysX()` manually to load and start the\r\n // physics engine\r\n autoLoad: {default: false},\r\n\r\n // Simulation speed multiplier. Increase or decrease to speed up or slow\r\n // down simulation time\r\n speed: {default: 1.0},\r\n\r\n // URL for the PhysX WASM bundle.\r\n wasmUrl: {default: \"https://cdn.jsdelivr.net/gh/c-frame/physx/wasm/physx.release.wasm\"},\r\n\r\n // If true, sets up a default scene with a ground plane and bounding\r\n // cylinder.\r\n useDefaultScene: {default: true},\r\n\r\n // NYI\r\n wrapBounds: {default: false},\r\n\r\n // Which collision layers the ground belongs to\r\n groundCollisionLayers: {default: [2]},\r\n\r\n // Which collision layers will collide with the ground\r\n groundCollisionMask: {default: [1,2,3,4]},\r\n\r\n // Global gravity vector\r\n gravity: {type: 'vec3', default: {x: 0, y: -9.8, z: 0}},\r\n\r\n // Whether to output stats, and how to output them. One or more of \"console\", \"events\", \"panel\"\r\n stats: {type: 'array', default: []}\r\n },\r\n init() {\r\n this.PhysXUtil = PhysXUtil;\r\n\r\n // for logging.\r\n this.cumTimeEngine = 0;\r\n this.cumTimeWrapper = 0;\r\n this.tickCounter = 0;\r\n\r\n\r\n this.objects = new Map();\r\n this.shapeMap = new Map();\r\n this.jointMap = new Map();\r\n this.boundaryShapes = new Set();\r\n this.worldHelper = new THREE.Object3D();\r\n this.el.object3D.add(this.worldHelper);\r\n this.tock = AFRAME.utils.throttleTick(this.tock, this.data.throttle, this)\r\n this.collisionObject = {thisShape: null, otherShape:null, points: [], impulses: [], otherComponent: null};\r\n\r\n let defaultTarget = document.createElement('a-entity')\r\n this.el.append(defaultTarget)\r\n this.defaultTarget = defaultTarget\r\n\r\n this.initializePhysX = new Promise((r, e) => {\r\n this.fulfillPhysXPromise = r;\r\n })\r\n\r\n this.initStats()\r\n\r\n this.el.addEventListener('inspectortoggle', (e) => {\r\n console.log(\"Inspector toggle\", e)\r\n if (e.detail === true)\r\n {\r\n this.running = false\r\n }\r\n })\r\n },\r\n\r\n initStats() {\r\n // Data used for performance monitoring.\r\n this.statsToConsole = this.data.stats.includes(\"console\")\r\n this.statsToEvents = this.data.stats.includes(\"events\")\r\n this.statsToPanel = this.data.stats.includes(\"panel\")\r\n\r\n this.bodyTypeToStatsPropertyMap = {\r\n \"static\": \"staticBodies\",\r\n \"dynamic\": \"dynamicBodies\",\r\n \"kinematic\": \"kinematicBodies\",\r\n }\r\n\r\n if (this.statsToConsole || this.statsToEvents || this.statsToPanel) {\r\n this.trackPerf = true;\r\n this.tickCounter = 0;\r\n this.statsTickData = {};\r\n this.statsBodyData = {};\r\n\r\n const scene = this.el.sceneEl;\r\n scene.setAttribute(\"stats-collector\", `inEvent: physics-tick-data;\r\n properties: engine, after, total;\r\n outputFrequency: 100;\r\n outEvent: physics-tick-summary;\r\n outputs: percentile__50, percentile__90, max`);\r\n }\r\n\r\n if (this.statsToPanel) {\r\n const scene = this.el.sceneEl;\r\n const space = \"   \"\r\n \r\n scene.setAttribute(\"stats-panel\", \"\")\r\n scene.setAttribute(\"stats-group__bodies\", `label: Physics Bodies`)\r\n scene.setAttribute(\"stats-row__b1\", `group: bodies;\r\n event:physics-body-data;\r\n properties: staticBodies;\r\n label: Static`)\r\n scene.setAttribute(\"stats-row__b2\", `group: bodies;\r\n event:physics-body-data;\r\n properties: dynamicBodies;\r\n label: Dynamic`)\r\n scene.setAttribute(\"stats-row__b3\", `group: bodies;\r\n event:physics-body-data;\r\n properties: kinematicBodies;\r\n label: Kinematic`)\r\n scene.setAttribute(\"stats-group__tick\", `label: Physics Ticks: Median${space}90th%${space}99th%`)\r\n scene.setAttribute(\"stats-row__1\", `group: tick; \r\n event:physics-tick-summary; \r\n properties: engine.percentile__50, \r\n engine.percentile__90, \r\n engine.max;\r\n label: Engine`)\r\n scene.setAttribute(\"stats-row__2\", `group: tick;\r\n event:physics-tick-summary;\r\n properties: after.percentile__50, \r\n after.percentile__90, \r\n after.max; \r\n label: After`)\r\n\r\n scene.setAttribute(\"stats-row__3\", `group: tick;\r\n event:physics-tick-summary;\r\n properties: total.percentile__50, \r\n total.percentile__90, \r\n total.max;\r\n label: Total`)\r\n }\r\n },\r\n findWasm() {\r\n return this.data.wasmUrl;\r\n },\r\n // Loads PhysX and starts the simulation\r\n async startPhysX() {\r\n this.running = true;\r\n let self = this;\r\n let resolveInitialized;\r\n let initialized = new Promise((r, e) => resolveInitialized = r)\r\n PhysX = PHYSX({\r\n locateFile() {\r\n return self.findWasm()\r\n },\r\n onRuntimeInitialized() {\r\n resolveInitialized();\r\n }\r\n });\r\n if (PhysX instanceof Promise) PhysX = await PhysX;\r\n this.PhysX = PhysX;\r\n await initialized;\r\n self.startPhysXScene()\r\n self.physXInitialized = true\r\n self.fulfillPhysXPromise()\r\n self.el.emit('physx-started', {})\r\n },\r\n startPhysXScene() {\r\n console.info(\"Starting PhysX scene\")\r\n const foundation = PhysX.PxCreateFoundation(\r\n PhysX.PX_PHYSICS_VERSION,\r\n new PhysX.PxDefaultAllocator(),\r\n new PhysX.PxDefaultErrorCallback()\r\n );\r\n this.foundation = foundation\r\n const physxSimulationCallbackInstance = PhysX.PxSimulationEventCallback.implement({\r\n onContactBegin: (shape0, shape1, points, impulses) => {\r\n let c0 = this.shapeMap.get(shape0.$$.ptr)\r\n let c1 = this.shapeMap.get(shape1.$$.ptr)\r\n\r\n if (c1 === c0) return;\r\n\r\n if (c0 && c0.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape0\r\n this.collisionObject.otherShape = shape1\r\n this.collisionObject.points = points\r\n this.collisionObject.impulses = impulses\r\n this.collisionObject.otherComponent = c1\r\n c0.el.emit('contactbegin', this.collisionObject)\r\n }\r\n\r\n if (c1 && c1.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape1\r\n this.collisionObject.otherShape = shape0\r\n this.collisionObject.points = points\r\n this.collisionObject.impulses = impulses\r\n this.collisionObject.otherComponent = c0\r\n c1.el.emit('contactbegin', this.collisionObject)\r\n }\r\n },\r\n onContactEnd: (shape0, shape1) => {\r\n let c0 = this.shapeMap.get(shape0.$$.ptr)\r\n let c1 = this.shapeMap.get(shape1.$$.ptr)\r\n\r\n if (c1 === c0) return;\r\n\r\n if (c0 && c0.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape0\r\n this.collisionObject.otherShape = shape1\r\n this.collisionObject.points = null\r\n this.collisionObject.impulses = null\r\n this.collisionObject.otherComponent = c1\r\n c0.el.emit('contactend', this.collisionObject)\r\n }\r\n\r\n if (c1 && c1.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape1\r\n this.collisionObject.otherShape = shape0\r\n this.collisionObject.points = null\r\n this.collisionObject.impulses = null\r\n this.collisionObject.otherComponent = c0\r\n c1.el.emit('contactend', this.collisionObject)\r\n }\r\n },\r\n onContactPersist: () => {},\r\n onTriggerBegin: () => {},\r\n onTriggerEnd: () => {},\r\n onConstraintBreak: (joint) => {\r\n let component = this.jointMap.get(joint.$$.ptr);\r\n\r\n if (!component) return;\r\n\r\n component.el.emit('constraintbreak', {})\r\n },\r\n });\r\n let tolerance = new PhysX.PxTolerancesScale();\r\n // tolerance.length /= 10;\r\n // console.log(\"Tolerances\", tolerance.length, tolerance.speed);\r\n this.physics = PhysX.PxCreatePhysics(\r\n PhysX.PX_PHYSICS_VERSION,\r\n foundation,\r\n tolerance,\r\n false,\r\n null\r\n )\r\n PhysX.PxInitExtensions(this.physics, null);\r\n\r\n this.cooking = PhysX.PxCreateCooking(\r\n PhysX.PX_PHYSICS_VERSION,\r\n foundation,\r\n new PhysX.PxCookingParams(tolerance)\r\n )\r\n\r\n const sceneDesc = PhysX.getDefaultSceneDesc(\r\n this.physics.getTolerancesScale(),\r\n 0,\r\n physxSimulationCallbackInstance\r\n )\r\n this.scene = this.physics.createScene(sceneDesc)\r\n\r\n this.setupDefaultEnvironment()\r\n },\r\n setupDefaultEnvironment() {\r\n this.defaultActorFlags = new PhysX.PxShapeFlags(\r\n PhysX.PxShapeFlag.eSCENE_QUERY_SHAPE.value |\r\n PhysX.PxShapeFlag.eSIMULATION_SHAPE.value\r\n )\r\n this.defaultFilterData = new PhysX.PxFilterData(PhysXUtil.layersToMask(this.data.groundCollisionLayers), PhysXUtil.layersToMask(this.data.groundCollisionMask), 0, 0);\r\n\r\n this.scene.setGravity(this.data.gravity)\r\n\r\n if (this.data.useDefaultScene)\r\n {\r\n this.createGroundPlane()\r\n this.createBoundingCylinder()\r\n }\r\n\r\n\r\n this.defaultTarget.setAttribute('physx-body', 'type', 'static')\r\n\r\n },\r\n createGroundPlane() {\r\n let geometry = new PhysX.PxPlaneGeometry();\r\n // let geometry = new PhysX.PxBoxGeometry(10, 1, 10);\r\n let material = this.physics.createMaterial(0.8, 0.8, 0.1);\r\n\r\n const shape = this.physics.createShape(geometry, material, false, this.defaultActorFlags)\r\n shape.setQueryFilterData(this.defaultFilterData)\r\n shape.setSimulationFilterData(this.defaultFilterData)\r\n const transform = {\r\n translation: {\r\n x: 0,\r\n y: 0,\r\n z: -5,\r\n },\r\n rotation: {\r\n w: 0.707107, // PhysX uses WXYZ quaternions,\r\n x: 0,\r\n y: 0,\r\n z: 0.707107,\r\n },\r\n }\r\n let body = this.physics.createRigidStatic(transform)\r\n body.attachShape(shape)\r\n this.scene.addActor(body, null)\r\n this.ground = body\r\n this.rigidBody = body\r\n },\r\n createBoundingCylinder() {\r\n const numPlanes = 16\r\n let geometry = new PhysX.PxPlaneGeometry();\r\n let material = this.physics.createMaterial(0.1, 0.1, 0.8);\r\n let spherical = new THREE.Spherical();\r\n spherical.radius = 30;\r\n let quat = new THREE.Quaternion();\r\n let pos = new THREE.Vector3;\r\n let euler = new THREE.Euler();\r\n\r\n for (let i = 0; i < numPlanes; ++i)\r\n {\r\n spherical.theta = i * 2.0 * Math.PI / numPlanes;\r\n pos.setFromSphericalCoords(spherical.radius, spherical.theta, spherical.phi)\r\n pos.x = - pos.y\r\n pos.y = 0;\r\n euler.set(0, spherical.theta, 0);\r\n quat.setFromEuler(euler)\r\n\r\n const shape = this.physics.createShape(geometry, material, false, this.defaultActorFlags)\r\n shape.setQueryFilterData(this.defaultFilterData)\r\n shape.setSimulationFilterData(this.defaultFilterData)\r\n const transform = {\r\n translation: {\r\n x: pos.x,\r\n y: pos.y,\r\n z: pos.z,\r\n },\r\n rotation: {\r\n w: quat.w, // PhysX uses WXYZ quaternions,\r\n x: quat.x,\r\n y: quat.y,\r\n z: quat.z,\r\n },\r\n }\r\n this.boundaryShapes.add(shape.$$.ptr)\r\n let body = this.physics.createRigidStatic(transform)\r\n body.attachShape(shape)\r\n this.scene.addActor(body, null)\r\n }\r\n },\r\n async registerComponentBody(component, {type}) {\r\n await this.initializePhysX;\r\n\r\n // const shape = this.physics.createShape(geometry, material, false, flags)\r\n const transform = PhysXUtil.object3DPhysXTransform(component.el.object3D);\r\n\r\n let body\r\n if (type === 'dynamic' || type === 'kinematic')\r\n {\r\n body = this.physics.createRigidDynamic(transform)\r\n\r\n // body.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_CCD, true);\r\n // body.setMaxContactImpulse(1e2);\r\n }\r\n else\r\n {\r\n body = this.physics.createRigidStatic(transform)\r\n }\r\n\r\n let attemptToUseDensity = true;\r\n let seenAnyDensity = false;\r\n let densities = new PhysX.VectorPxReal()\r\n for (let shape of component.createShapes(this.physics, this.defaultActorFlags))\r\n {\r\n body.attachShape(shape)\r\n\r\n if (isFinite(shape.density))\r\n {\r\n seenAnyDensity = true\r\n densities.push_back(shape.density)\r\n }\r\n else\r\n {\r\n attemptToUseDensity = false\r\n\r\n if (seenAnyDensity)\r\n {\r\n console.warn(\"Densities not set for all shapes. Will use total mass instead.\", component.el)\r\n }\r\n }\r\n }\r\n if (type === 'dynamic' || type === 'kinematic') {\r\n if (attemptToUseDensity && seenAnyDensity)\r\n {\r\n console.log(\"Setting density vector\", densities)\r\n body.updateMassAndInertia(densities)\r\n }\r\n else {\r\n body.setMassAndUpdateInertia(component.data.mass)\r\n }\r\n }\r\n densities.delete()\r\n this.scene.addActor(body, null)\r\n this.objects.set(component.el.object3D, body)\r\n component.rigidBody = body\r\n },\r\n registerShape(shape, component) {\r\n this.shapeMap.set(shape.$$.ptr, component);\r\n },\r\n registerJoint(joint, component) {\r\n this.jointMap.set(joint.$$.ptr, component);\r\n },\r\n removeBody(component) {\r\n let body = component.rigidBody\r\n this.objects.delete(component.el.object3D)\r\n body.release()\r\n },\r\n tock(t, dt) {\r\n if (t < this.data.delay) return\r\n if (!this.physXInitialized && this.data.autoLoad && !this.running) this.startPhysX()\r\n if (!this.physXInitialized) return\r\n if (!this.running) return\r\n\r\n const engineStartTime = performance.now();\r\n\r\n this.scene.simulate(THREE.MathUtils.clamp(dt * this.data.speed / 1000, 0, 0.03 * this.data.speed), true)\r\n //this.scene.simulate(0.02, true) // (experiment with fixed interval)\r\n this.scene.fetchResults(true)\r\n\r\n const engineEndTime = performance.now();\r\n\r\n for (let [obj, body] of this.objects)\r\n {\r\n // no updates needed for static objects.\r\n if (obj.el.components['physx-body'].data.type === 'static') continue;\r\n\r\n const transform = body.getGlobalPose()\r\n this.worldHelper.position.copy(transform.translation);\r\n this.worldHelper.quaternion.copy(transform.rotation);\r\n obj.getWorldScale(this.worldHelper.scale)\r\n Util.positionObject3DAtTarget(obj, this.worldHelper);\r\n }\r\n\r\n if (this.trackPerf) {\r\n const afterEndTime = performance.now();\r\n\r\n this.statsTickData.engine = engineEndTime - engineStartTime\r\n this.statsTickData.after = afterEndTime - engineEndTime\r\n this.statsTickData.total = afterEndTime - engineStartTime\r\n this.el.emit(\"physics-tick-data\", this.statsTickData)\r\n\r\n this.tickCounter++;\r\n\r\n if (this.tickCounter === 100) {\r\n\r\n this.countBodies()\r\n\r\n if (this.statsToConsole) {\r\n console.log(\"Physics tick stats:\", this.statsData)\r\n }\r\n\r\n if (this.statsToEvents || this.statsToPanel) {\r\n this.el.emit(\"physics-body-data\", this.statsBodyData)\r\n }\r\n\r\n this.tickCounter = 0;\r\n }\r\n }\r\n },\r\n\r\n countBodies() {\r\n\r\n // Aditional statistics beyond simple body counts should be possible.\r\n // They could be accessed via PxScene::getSimulationStatistics()\r\n // https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/Statistics.html\r\n // https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxSimulationStatistics.html\r\n // However this part of the API is not yet exposed in the\r\n // WASM PhysX build we are using\r\n // See: https://github.com/zach-capalbo/PhysX/blob/emscripten_wip/physx/source/physxwebbindings/src/PxWebBindings.cpp\r\n \r\n const statsData = this.statsBodyData\r\n statsData.staticBodies = 0\r\n statsData.kinematicBodies = 0\r\n statsData.dynamicBodies = 0\r\n\r\n this.objects.forEach((pxBody, object3D) => {\r\n const el = object3D.el\r\n const type = el.components['physx-body'].data.type\r\n const property = this.bodyTypeToStatsPropertyMap[type]\r\n statsData[property]++\r\n })\r\n },\r\n})\r\n\r\n// Controls physics properties for individual shapes or rigid bodies. You can\r\n// set this either on an entity with the `phyx-body` component, or on a shape or\r\n// model contained in an entity with the `physx-body` component. If it's set on\r\n// a `physx-body`, it will be the default material for all shapes in that body.\r\n// If it's set on an element containing geometry or a model, it will be the\r\n// material used for that shape only.\r\n//\r\n// For instance, in the following scene fragment:\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// `shape1`, which is part of the `bodyA` rigid body, will have static friction\r\n// of 1.0, since it has a material set on it. `shape2`, which is also part of\r\n// the `bodyA` rigid body, will have a static friction of 0.5, since that is\r\n// the body default. `bodyB` will have the component default of 0.2, since it is\r\n// a separate body.\r\nAFRAME.registerComponent('physx-material', {\r\n schema: {\r\n // Static friction\r\n staticFriction: {default: 0.2},\r\n // Dynamic friction\r\n dynamicFriction: {default: 0.2},\r\n // Restitution, or \"bounciness\"\r\n restitution: {default: 0.2},\r\n\r\n // Density for the shape. If densities are specified for _all_ shapes in a\r\n // rigid body, then the rigid body's mass properties will be automatically\r\n // calculated based on the different densities. However, if density\r\n // information is not specified for every shape, then the mass defined in\r\n // the overarching [`physx-body`](#physx-body) will be used instead.\r\n density: {type: 'number', default: NaN},\r\n\r\n // Which collision layers this shape is present on\r\n collisionLayers: {default: [1], type: 'array'},\r\n // Array containing all layers that this shape should collide with\r\n collidesWithLayers: {default: [1,2,3,4], type: 'array'},\r\n\r\n // If `collisionGroup` is greater than 0, this shape will *not* collide with\r\n // any other shape with the same `collisionGroup` value\r\n collisionGroup: {default: 0},\r\n\r\n // If >= 0, this will set the PhysX contact offset, indicating how far away\r\n // from the shape simulation contact events should begin.\r\n contactOffset: {default: -1.0},\r\n\r\n // If >= 0, this will set the PhysX rest offset\r\n restOffset: {default: -1.0},\r\n }\r\n})\r\n\r\n// Turns an entity into a PhysX rigid body. This is the main component for\r\n// creating physics objects.\r\n//\r\n// **Types**\r\n//\r\n// There are 3 types of supported rigid bodies. The type can be set by using the\r\n// `type` proeprty, but once initialized cannot be changed.\r\n//\r\n// - `dynamic` objects are objects that will have physics simulated on them. The\r\n// entity's world position, scale, and rotation will be used as the starting\r\n// condition for the simulation, however once the simulation starts the\r\n// entity's position and rotation will be replaced each frame with the results\r\n// of the simulation.\r\n// - `static` objects are objects that cannot move. They cab be used to create\r\n// collidable objects for `dynamic` objects, or for anchor points for joints.\r\n// - `kinematic` objects are objects that can be moved programmatically, but\r\n// will not be moved by the simulation. They can however, interact with and\r\n// collide with dynamic objects. Each frame, the entity's `object3D` will be\r\n// used to set the position and rotation for the simulation object.\r\n//\r\n// **Shapes**\r\n//\r\n// When the component is initialized, and on the `object3dset` event, all\r\n// visible meshes that are descendents of this entity will have shapes created\r\n// for them. Each individual mesh will have its own convex hull automatically\r\n// generated for it. This means you can have reasonably accurate collision\r\n// meshes both from building up shapes with a-frame geometry primitives, and\r\n// from importing 3D models.\r\n//\r\n// Visible meshes can be excluded from this shape generation process by setting\r\n// the `physx-no-collision` attribute on the corresponding `a-entity` element.\r\n// Invisible meshes can be included into this shape generation process by\r\n// settingt the `physx-hidden-collision` attribute on the corresponding\r\n// `a-entity` element. This can be especially useful when using an external tool\r\n// (like [Blender V-HACD](https://github.com/andyp123/blender_vhacd)) to create\r\n// a low-poly convex collision mesh for a high-poly or concave mesh. This leads\r\n// to this pattern for such cases:\r\n//\r\n// ```\r\n// \r\n// \r\n// \r\n// \r\n// ```\r\n//\r\n// Note, in such cases that if you are setting material properties on individual\r\n// shapes, then the property should go on the collision mesh entity\r\n//\r\n// **Use with the [Manipulator](#manipulator) component**\r\n//\r\n// If a dynamic entity is grabbed by the [Manipulator](#manipulator) component,\r\n// it will temporarily become a kinematic object. This means that collisions\r\n// will no longer impede its movement, and it will track the manipulator\r\n// exactly, (subject to any manipulator constraints, such as\r\n// [`manipulator-weight`](#manipulator-weight)). If you would rather have the\r\n// object remain dynamic, you will need to [redirect the grab](#redirect-grab)\r\n// to a `physx-joint` instead, or even easier, use the\r\n// [`dual-wieldable`](#dual-wieldable) component.\r\n//\r\n// As soon as the dynamic object is released, it will revert back to a dynamic\r\n// object. Objects with the type `kinematic` will remain kinematic.\r\n//\r\n// Static objects should not be moved. If a static object can be the target of a\r\n// manipulator grab (or any other kind of movement), it should be `kinematic`\r\n// instead.\r\nAFRAME.registerComponent('physx-body', {\r\n dependencies: ['physx-material'],\r\n schema: {\r\n // **[dynamic, static, kinematic]** Type of the rigid body to create\r\n type: {default: 'dynamic', oneOf: ['dynamic', 'static', 'kinematic']},\r\n\r\n // Total mass of the body\r\n mass: {default: 1.0},\r\n\r\n // If > 0, will set the rigid body's angular damping\r\n angularDamping: {default: 0.0},\r\n\r\n // If > 0, will set the rigid body's linear damping\r\n linearDamping: {default: 0.0},\r\n\r\n // If set to `true`, it will emit `contactbegin` and `contactend` events\r\n // when collisions occur\r\n emitCollisionEvents: {default: false},\r\n\r\n // If set to `true`, the object will receive extra attention by the\r\n // simulation engine (at a performance cost).\r\n highPrecision: {default: false},\r\n\r\n shapeOffset: {type: 'vec3', default: {x: 0, y: 0, z: 0}}\r\n },\r\n events: {\r\n stateadded: function(e) {\r\n if (e.detail === 'grabbed') {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, true)\r\n }\r\n },\r\n stateremoved: function(e) {\r\n if (e.detail === 'grabbed') {\r\n if (this.floating) {\r\n this.rigidBody.setLinearVelocity({x: 0, y: 0, z: 0}, true)\r\n }\r\n if (this.data.type !== 'kinematic')\r\n {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, false)\r\n }\r\n }\r\n },\r\n 'bbuttonup': function(e) {\r\n this.toggleGravity()\r\n },\r\n componentchanged: function(e) {\r\n if (e.name === 'physx-material')\r\n {\r\n this.el.emit('object3dset', {})\r\n }\r\n },\r\n object3dset: function(e) {\r\n if (this.rigidBody) {\r\n for (let shape of this.shapes)\r\n {\r\n this.rigidBody.detachShape(shape, false)\r\n }\r\n\r\n let attemptToUseDensity = true;\r\n let seenAnyDensity = false;\r\n let densities = new PhysX.VectorPxReal()\r\n let component = this\r\n let type = this.data.type\r\n let body = this.rigidBody\r\n for (let shape of component.createShapes(this.system.physics, this.system.defaultActorFlags))\r\n {\r\n body.attachShape(shape)\r\n\r\n if (isFinite(shape.density))\r\n {\r\n seenAnyDensity = true\r\n densities.push_back(shape.density)\r\n }\r\n else\r\n {\r\n attemptToUseDensity = false\r\n\r\n if (seenAnyDensity)\r\n {\r\n console.warn(\"Densities not set for all shapes. Will use total mass instead.\", component.el)\r\n }\r\n }\r\n }\r\n if (type === 'dynamic' || type === 'kinematic') {\r\n if (attemptToUseDensity && seenAnyDensity)\r\n {\r\n console.log(\"Setting density vector\", densities)\r\n body.updateMassAndInertia(densities)\r\n }\r\n else {\r\n body.setMassAndUpdateInertia(component.data.mass)\r\n }\r\n }\r\n }\r\n },\r\n contactbegin: function(e) {\r\n // console.log(\"Collision\", e.detail.points)\r\n }\r\n },\r\n init() {\r\n this.system = this.el.sceneEl.systems.physx\r\n this.physxRegisteredPromise = this.system.registerComponentBody(this, {type: this.data.type})\r\n this.el.setAttribute('grab-options', 'scalable', false)\r\n\r\n this.kinematicMove = this.kinematicMove.bind(this)\r\n if (this.el.sceneEl.systems['button-caster'])\r\n {\r\n this.el.sceneEl.systems['button-caster'].install(['bbutton'])\r\n }\r\n\r\n this.physxRegisteredPromise.then(() => this.update())\r\n },\r\n update(oldData) {\r\n if (!this.rigidBody) return;\r\n\r\n if (this.data.type === 'dynamic')\r\n {\r\n this.rigidBody.setAngularDamping(this.data.angularDamping)\r\n this.rigidBody.setLinearDamping(this.data.linearDamping)\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, false)\r\n if (this.data.highPrecision)\r\n {\r\n this.rigidBody.setSolverIterationCounts(4, 2);\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_CCD, true)\r\n }\r\n }\r\n\r\n if (!oldData || this.data.mass !== oldData.mass) this.el.emit('object3dset', {})\r\n },\r\n remove() {\r\n if (!this.rigidBody) return;\r\n this.system.removeBody(this)\r\n },\r\n createGeometry(o) {\r\n if (o.el.hasAttribute('geometry'))\r\n {\r\n let geometry = o.el.getAttribute('geometry');\r\n switch(geometry.primitive)\r\n {\r\n case 'sphere':\r\n return new PhysX.PxSphereGeometry(geometry.radius * this.el.object3D.scale.x * 0.98)\r\n case 'box':\r\n return new PhysX.PxBoxGeometry(geometry.width / 2, geometry.height / 2, geometry.depth / 2)\r\n default:\r\n return this.createConvexMeshGeometry(o.el.getObject3D('mesh'));\r\n }\r\n }\r\n },\r\n createConvexMeshGeometry(mesh, rootAncestor) {\r\n let vectors = new PhysX.PxVec3Vector()\r\n\r\n let g = mesh.geometry.attributes.position\r\n if (!g) return;\r\n if (g.count < 3) return;\r\n if (g.itemSize != 3) return;\r\n let t = new THREE.Vector3;\r\n\r\n if (rootAncestor)\r\n {\r\n let matrix = new THREE.Matrix4();\r\n mesh.updateMatrix();\r\n matrix.copy(mesh.matrix)\r\n let ancestor = mesh.parent;\r\n while(ancestor && ancestor !== rootAncestor)\r\n {\r\n ancestor.updateMatrix();\r\n matrix.premultiply(ancestor.matrix);\r\n ancestor = ancestor.parent;\r\n }\r\n for (let i = 0; i < g.count; ++i) {\r\n t.fromBufferAttribute(g, i)\r\n t.applyMatrix4(matrix);\r\n vectors.push_back(Object.assign({}, t));\r\n }\r\n }\r\n else\r\n {\r\n for (let i = 0; i < g.count; ++i) {\r\n t.fromBufferAttribute(g, i)\r\n vectors.push_back(Object.assign({}, t));\r\n }\r\n }\r\n\r\n let worldScale = new THREE.Vector3;\r\n let worldBasis = (rootAncestor || mesh);\r\n worldBasis.updateMatrixWorld();\r\n worldBasis.getWorldScale(worldScale);\r\n let convexMesh = this.system.cooking.createConvexMesh(vectors, this.system.physics)\r\n return new PhysX.PxConvexMeshGeometry(convexMesh, new PhysX.PxMeshScale({x: worldScale.x, y: worldScale.y, z: worldScale.z}, {w: 1, x: 0, y: 0, z: 0}), new PhysX.PxConvexMeshGeometryFlags(PhysX.PxConvexMeshGeometryFlag.eTIGHT_BOUNDS.value))\r\n },\r\n createShape(physics, geometry, materialData)\r\n {\r\n let material = physics.createMaterial(materialData.staticFriction, materialData.dynamicFriction, materialData.restitution);\r\n let shape = physics.createShape(geometry, material, false, this.system.defaultActorFlags)\r\n shape.setQueryFilterData(new PhysX.PxFilterData(PhysXUtil.layersToMask(materialData.collisionLayers), PhysXUtil.layersToMask(materialData.collidesWithLayers), materialData.collisionGroup, 0))\r\n shape.setSimulationFilterData(new PhysX.PxFilterData(PhysXUtil.layersToMask(materialData.collisionLayers), PhysXUtil.layersToMask(materialData.collidesWithLayers), materialData.collisionGroup, 0))\r\n\r\n if (materialData.contactOffset >= 0.0)\r\n {\r\n shape.setContactOffset(materialData.contactOffset)\r\n }\r\n if (materialData.restOffset >= 0.0)\r\n {\r\n shape.setRestOffset(materialData.restOffset)\r\n }\r\n\r\n shape.density = materialData.density;\r\n this.system.registerShape(shape, this)\r\n\r\n return shape;\r\n },\r\n createShapes(physics) {\r\n if (this.el.hasAttribute('geometry'))\r\n {\r\n let geometry = this.createGeometry(this.el.object3D);\r\n if (!geometry) return;\r\n let materialData = this.el.components['physx-material'].data\r\n this.shapes = [this.createShape(physics, geometry, materialData)];\r\n\r\n return this.shapes;\r\n }\r\n\r\n let shapes = []\r\n Util.traverseCondition(this.el.object3D,\r\n o => {\r\n if (o.el && o.el.hasAttribute(\"physx-no-collision\")) return false;\r\n if (o.el && !o.el.object3D.visible && !o.el.hasAttribute(\"physx-hidden-collision\")) return false;\r\n if (!o.visible && o.el && !o.el.hasAttribute(\"physx-hidden-collision\")) return false;\r\n if (o.userData && o.userData.vartisteUI) return false;\r\n return true\r\n },\r\n o => {\r\n if (o.geometry) {\r\n let geometry;\r\n if (false)\r\n {}\r\n else\r\n {\r\n geometry = this.createConvexMeshGeometry(o, this.el.object3D);\r\n }\r\n if (!geometry) {\r\n console.warn(\"Couldn't create geometry\", o)\r\n return;\r\n }\r\n\r\n let material, materialData;\r\n if (o.el && o.el.hasAttribute('physx-material'))\r\n {\r\n materialData = o.el.getAttribute('physx-material')\r\n }\r\n else\r\n {\r\n materialData = this.el.components['physx-material'].data\r\n }\r\n let shape = this.createShape(physics, geometry, materialData)\r\n\r\n // shape.setLocalPose({translation: this.data.shapeOffset, rotation: {w: 1, x: 0, y: 0, z: 0}})\r\n\r\n shapes.push(shape)\r\n }\r\n });\r\n\r\n this.shapes = shapes\r\n\r\n return shapes\r\n },\r\n // Turns gravity on and off\r\n toggleGravity() {\r\n this.rigidBody.setActorFlag(PhysX.PxActorFlag.eDISABLE_GRAVITY, !this.floating)\r\n this.floating = !this.floating\r\n },\r\n resetBodyPose() {\r\n this.rigidBody.setGlobalPose(PhysXUtil.object3DPhysXTransform(this.el.object3D), true)\r\n },\r\n kinematicMove() {\r\n this.rigidBody.setKinematicTarget(PhysXUtil.object3DPhysXTransform(this.el.object3D))\r\n },\r\n tock(t, dt) {\r\n if (this.rigidBody && this.data.type === 'kinematic' && !this.setKinematic)\r\n {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, true)\r\n this.setKinematic = true\r\n }\r\n if (this.rigidBody && (this.data.type === 'kinematic' || this.el.is(\"grabbed\"))) {\r\n // this.el.object3D.scale.set(1,1,1)\r\n this.kinematicMove()\r\n }\r\n }\r\n})\r\n\r\n// Creates a driver which exerts force to return the joint to the specified\r\n// (currently only the initial) position with the given velocity\r\n// characteristics.\r\n//\r\n// This can only be used on an entity with a `physx-joint` component. Currently\r\n// only supports **D6** joint type. E.g.\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n//```\r\nAFRAME.registerComponent('physx-joint-driver', {\r\n dependencies: ['physx-joint'],\r\n multiple: true,\r\n schema: {\r\n // Which axes the joint should operate on. Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n axes: {type: 'array', default: []},\r\n\r\n // How stiff the drive should be\r\n stiffness: {default: 1.0},\r\n\r\n // Damping to apply to the drive\r\n damping: {default: 1.0},\r\n\r\n // Maximum amount of force used to get to the target position\r\n forceLimit: {default: 3.4028234663852885981170418348452e+38},\r\n\r\n // If true, will operate directly on body acceleration rather than on force\r\n useAcceleration: {default: true},\r\n\r\n // Target linear velocity relative to the joint\r\n linearVelocity: {type: 'vec3', default: {x: 0, y: 0, z: 0}},\r\n\r\n // Targget angular velocity relative to the joint\r\n angularVelocity: {type: 'vec3', default: {x: 0, y: 0, z: 0}},\r\n\r\n // If true, will automatically lock axes which are not being driven\r\n lockOtherAxes: {default: false},\r\n\r\n // If true SLERP rotation mode. If false, will use SWING mode.\r\n slerpRotation: {default: true},\r\n },\r\n events: {\r\n 'physx-jointcreated': function(e) {\r\n this.setJointDriver()\r\n }\r\n },\r\n init() {\r\n this.el.setAttribute('phsyx-custom-constraint', \"\")\r\n },\r\n setJointDriver() {\r\n if (!this.enumAxes) this.update();\r\n if (this.el.components['physx-joint'].data.type !== 'D6') {\r\n console.warn(\"Only D6 joint drivers supported at the moment\")\r\n return;\r\n }\r\n\r\n let PhysX = this.el.sceneEl.systems.physx.PhysX;\r\n this.joint = this.el.components['physx-joint'].joint\r\n\r\n if (this.data.lockOtherAxes)\r\n {\r\n this.joint.setMotion(PhysX.PxD6Axis.eX, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eY, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eZ, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING1, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING2, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eTWIST, PhysX.PxD6Motion.eLOCKED)\r\n }\r\n\r\n for (let enumKey of this.enumAxes)\r\n {\r\n this.joint.setMotion(enumKey, PhysX.PxD6Motion.eFREE)\r\n }\r\n\r\n let drive = new PhysX.PxD6JointDrive;\r\n drive.stiffness = this.data.stiffness;\r\n drive.damping = this.data.damping;\r\n drive.forceLimit = this.data.forceLimit;\r\n drive.setAccelerationFlag(this.data.useAcceleration);\r\n\r\n for (let axis of this.driveAxes)\r\n {\r\n this.joint.setDrive(axis, drive);\r\n }\r\n\r\n console.log(\"Setting joint driver\", this.driveAxes, this.enumAxes)\r\n\r\n this.joint.setDrivePosition({translation: {x: 0, y: 0, z: 0}, rotation: {w: 1, x: 0, y: 0, z: 0}}, true)\r\n\r\n this.joint.setDriveVelocity(this.data.linearVelocity, this.data.angularVelocity, true);\r\n },\r\n update(oldData) {\r\n if (!PhysX) return;\r\n\r\n this.enumAxes = []\r\n for (let axis of this.data.axes)\r\n {\r\n if (axis === 'swing') {\r\n this.enumAxes.push(PhysX.PxD6Axis.eSWING1)\r\n this.enumAxes.push(PhysX.PxD6Axis.eSWING2)\r\n continue\r\n }\r\n let enumKey = `e${axis.toUpperCase()}`\r\n if (!(enumKey in PhysX.PxD6Axis))\r\n {\r\n console.warn(`Unknown axis ${axis} (PxD6Axis::${enumKey})`)\r\n }\r\n this.enumAxes.push(PhysX.PxD6Axis[enumKey])\r\n }\r\n\r\n this.driveAxes = []\r\n\r\n for (let axis of this.data.axes)\r\n {\r\n if (axis === 'swing') {\r\n if (this.data.slerpRotation)\r\n {\r\n this.driveAxes.push(PhysX.PxD6Drive.eSLERP)\r\n }\r\n else\r\n {\r\n this.driveAxes.push(PhysX.PxD6Drive.eSWING)\r\n }\r\n continue\r\n }\r\n\r\n if (axis === 'twist' && this.data.slerpRotation) {\r\n this.driveAxes.push(PhysX.PxD6Drive.eSLERP)\r\n continue;\r\n }\r\n\r\n let enumKey = `e${axis.toUpperCase()}`\r\n if (!(enumKey in PhysX.PxD6Drive))\r\n {\r\n console.warn(`Unknown axis ${axis} (PxD6Axis::${enumKey})`)\r\n }\r\n this.driveAxes.push(PhysX.PxD6Drive[enumKey])\r\n }\r\n }\r\n})\r\n\r\n// Adds a constraint to a [`physx-joint`](#physx-joint). Currently only **D6**\r\n// joints are supported.\r\n//\r\n// Can only be used on an entity with the `physx-joint` component. You can set\r\n// multiple constraints per joint. Note that in order to specify attributes of\r\n// individual axes, you will need to use multiple constraints. For instance:\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// In the above example, the box will be able to move from -1 to 20 in both the\r\n// x and z direction. It will be able to move from 0 to 3 in the y direction,\r\n// but this will be a soft constraint, subject to spring forces if the box goes\r\n// past in the y direction. All rotation will be locked. (Note that since no\r\n// target is specified, it will use the scene default target, effectively\r\n// jointed to joint's initial position in the world)\r\nAFRAME.registerComponent('physx-joint-constraint', {\r\n multiple: true,\r\n schema: {\r\n // Which axes are explicitly locked by this constraint and can't be moved at all.\r\n // Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n lockedAxes: {type: 'array', default: []},\r\n\r\n // Which axes are constrained by this constraint. These axes can be moved within the set limits.\r\n // Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n constrainedAxes: {type: 'array', default: []},\r\n\r\n // Which axes are explicitly freed by this constraint. These axes will not obey any limits set here.\r\n // Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n freeAxes: {type: 'array', default: []},\r\n\r\n // Limit on linear movement. Only affects `x`, `y`, and `z` axes.\r\n // First vector component is the minimum allowed position\r\n linearLimit: {type: 'vec2'},\r\n\r\n // Two angles specifying a cone in which the joint is allowed to swing, like\r\n // a pendulum.\r\n limitCone: {type: 'vec2'},\r\n\r\n // Minimum and maximum angles that the joint is allowed to twist\r\n twistLimit: {type: 'vec2'},\r\n\r\n // Spring damping for soft constraints\r\n damping: {default: 0.0},\r\n // Spring restitution for soft constraints\r\n restitution: {default: 0.0},\r\n // If greater than 0, will make this joint a soft constraint, and use a\r\n // spring force model\r\n stiffness: {default: 0.0},\r\n },\r\n events: {\r\n 'physx-jointcreated': function(e) {\r\n this.setJointConstraint()\r\n }\r\n },\r\n init() {\r\n this.el.setAttribute('phsyx-custom-constraint', \"\")\r\n },\r\n setJointConstraint() {\r\n if (this.el.components['physx-joint'].data.type !== 'D6') {\r\n console.warn(\"Only D6 joint constraints supported at the moment\")\r\n return;\r\n }\r\n\r\n if (!this.constrainedAxes) this.update();\r\n\r\n let joint = this.el.components['physx-joint'].joint;\r\n\r\n let llimit = () => {\r\n let l = new PhysX.PxJointLinearLimitPair(new PhysX.PxTolerancesScale(), this.data.linearLimit.x, this.data.linearLimit.y);\r\n l.stiffness = this.data.stiffness;\r\n l.damping = this.data.damping;\r\n // Setting stiffness automatically sets restitution to the same value.\r\n // Is it correct, then to override with default restitution value of 0, even if\r\n // no restitution value was specified?\r\n // Not sure - but commenting out this line doesn't help with problems observed with spring behaviour.\r\n // Seem spring.html example.\r\n l.restitution = this.data.restitution;\r\n return l\r\n }\r\n\r\n for (let axis of this.freeAxes)\r\n {\r\n joint.setMotion(axis, PhysX.PxD6Motion.eFREE)\r\n }\r\n\r\n for (let axis of this.lockedAxes)\r\n {\r\n joint.setMotion(axis, PhysX.PxD6Motion.eLOCKED)\r\n }\r\n\r\n for (let axis of this.constrainedAxes)\r\n {\r\n if (axis === PhysX.PxD6Axis.eX || axis === PhysX.PxD6Axis.eY || axis === PhysX.PxD6Axis.eZ)\r\n {\r\n joint.setMotion(axis, PhysX.PxD6Motion.eLIMITED)\r\n joint.setLinearLimit(axis, llimit())\r\n continue;\r\n }\r\n\r\n if (axis === PhysX.eTWIST)\r\n {\r\n joint.setMotion(PhysX.PxD6Axis.eTWIST, PhysX.PxD6Motion.eLIMITED)\r\n let pair = new PhysX.PxJointAngularLimitPair(this.data.limitTwist.x, this.data.limitTwist.y)\r\n pair.stiffness = this.data.stiffness\r\n pair.damping = this.data.damping\r\n pair.restitution = this.data.restitution\r\n joint.setTwistLimit(pair)\r\n continue;\r\n }\r\n\r\n joint.setMotion(axis, PhysX.PxD6Motion.eLIMITED)\r\n let cone = new PhysX.PxJointLimitCone(this.data.limitCone.x, this.data.limitCone.y)\r\n cone.damping = this.data.damping\r\n cone.stiffness = this.data.stiffness\r\n cone.restitution = this.data.restitution\r\n joint.setSwingLimit(cone)\r\n }\r\n },\r\n update(oldData) {\r\n if (!PhysX) return;\r\n\r\n this.constrainedAxes = PhysXUtil.axisArrayToEnums(this.data.constrainedAxes)\r\n this.lockedAxes = PhysXUtil.axisArrayToEnums(this.data.lockedAxes)\r\n this.freeAxes = PhysXUtil.axisArrayToEnums(this.data.freeAxes)\r\n }\r\n})\r\n\r\n// Creates a PhysX joint between an ancestor rigid body and a target rigid body.\r\n//\r\n// The physx-joint is designed to be used either on or within an entity with the\r\n// `physx-body` component. For instance:\r\n//\r\n// ```\r\n// \r\n// \r\n// \r\n// ```\r\n//\r\n// The position and rotation of the `physx-joint` will be used to create the\r\n// corresponding PhysX joint object. Multiple joints can be created on a body,\r\n// and multiple joints can target a body.\r\n//\r\n// **Stapler Example**\r\n//\r\n// Here's a simplified version of the stapler from the [physics playground demo]()\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// Notice the joint is created between the top part of the stapler (which\r\n// contains the joint) and the bottom part of the stapler at the position of the\r\n// `physx-joint` component's entitiy. This will be the pivot point for the\r\n// stapler's rotation.\r\n//\r\n// ![Stapler with joint highlighted](./static/images/staplerjoint.png)\r\nAFRAME.registerComponent('physx-joint', {\r\n multiple: true,\r\n schema: {\r\n // Rigid body joint type to use. See the [NVIDIA PhysX joint\r\n // documentation](https://gameworksdocs.nvidia.com/PhysX/4.0/documentation/PhysXGuide/Manual/Joints.html)\r\n // for details on each type\r\n type: {default: \"Spherical\", oneOf: [\"Fixed\", \"Spherical\", \"Distance\", \"Revolute\", \"Prismatic\", \"D6\"]},\r\n\r\n // Target object. If specified, must be an entity having the `physx-body`\r\n // component. If no target is specified, a scene default target will be\r\n // used, essentially joining the joint to its initial position in the world.\r\n target: {type: 'selector'},\r\n\r\n // Force needed to break the constraint. First component is the linear force, second component is angular force. Set both components are >= 0\r\n breakForce: {type: 'vec2', default: {x: -1, y: -1}},\r\n\r\n // If true, removes the entity containing this component when the joint is\r\n // broken.\r\n removeElOnBreak: {default: false},\r\n\r\n // If false, collision will be disabled between the rigid body containing\r\n // the joint and the target rigid body.\r\n collideWithTarget: {default: false},\r\n\r\n // When used with a D6 type, sets up a \"soft\" fixed joint. E.g., for grabbing things\r\n softFixed: {default: false},\r\n },\r\n events: {\r\n constraintbreak: function(e) {\r\n if (this.data.removeElOnBreak) {\r\n this.el.remove()\r\n }\r\n }\r\n },\r\n init() {\r\n this.system = this.el.sceneEl.systems.physx\r\n\r\n let parentEl = this.el\r\n\r\n while (parentEl && !parentEl.hasAttribute('physx-body'))\r\n {\r\n parentEl = parentEl.parentEl\r\n }\r\n\r\n if (!parentEl) {\r\n console.warn(\"physx-joint must be used within a physx-body\")\r\n return;\r\n }\r\n\r\n this.bodyEl = parentEl\r\n\r\n this.worldHelper = new THREE.Object3D;\r\n this.worldHelperParent = new THREE.Object3D;\r\n this.el.sceneEl.object3D.add(this.worldHelperParent);\r\n this.targetScale = new THREE.Vector3(1,1,1)\r\n this.worldHelperParent.add(this.worldHelper)\r\n\r\n if (!this.data.target) {\r\n this.data.target = this.system.defaultTarget\r\n }\r\n\r\n\r\n Util.whenLoaded([this.el, this.bodyEl, this.data.target], () => {\r\n this.createJoint()\r\n })\r\n },\r\n remove() {\r\n if (this.joint) {\r\n this.joint.release();\r\n this.joint = null;\r\n this.bodyEl.components['physx-body'].rigidBody.wakeUp()\r\n if (this.data.target.components['physx-body'].rigidBody.wakeUp) this.data.target.components['physx-body'].rigidBody.wakeUp()\r\n }\r\n },\r\n update() {\r\n if (!this.joint) return;\r\n\r\n if (this.data.breakForce.x >= 0 && this.data.breakForce.y >= 0)\r\n {\r\n this.joint.setBreakForce(this.data.breakForce.x, this.data.breakForce.y);\r\n }\r\n\r\n this.joint.setConstraintFlag(PhysX.PxConstraintFlag.eCOLLISION_ENABLED, this.data.collideWithTarget)\r\n\r\n if (this.el.hasAttribute('phsyx-custom-constraint')) return;\r\n\r\n switch (this.data.type)\r\n {\r\n case 'D6':\r\n {\r\n if (this.data.softFixed)\r\n {\r\n this.joint.setMotion(PhysX.PxD6Axis.eX, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eY, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eZ, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING1, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING2, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eTWIST, PhysX.PxD6Motion.eFREE)\r\n\r\n let drive = new PhysX.PxD6JointDrive;\r\n drive.stiffness = 1000;\r\n drive.damping = 500;\r\n drive.forceLimit = 1000;\r\n drive.setAccelerationFlag(false);\r\n this.joint.setDrive(PhysX.PxD6Drive.eX, drive);\r\n this.joint.setDrive(PhysX.PxD6Drive.eY, drive);\r\n this.joint.setDrive(PhysX.PxD6Drive.eZ, drive);\r\n // this.joint.setDrive(PhysX.PxD6Drive.eSWING, drive);\r\n // this.joint.setDrive(PhysX.PxD6Drive.eTWIST, drive);\r\n this.joint.setDrive(PhysX.PxD6Drive.eSLERP, drive);\r\n this.joint.setDrivePosition({translation: {x: 0, y: 0, z: 0}, rotation: {w: 1, x: 0, y: 0, z: 0}}, true)\r\n this.joint.setDriveVelocity({x: 0.0, y: 0.0, z: 0.0}, {x: 0, y: 0, z: 0}, true);\r\n }\r\n }\r\n break;\r\n }\r\n },\r\n getTransform(el) {\r\n Util.positionObject3DAtTarget(this.worldHelperParent, el.object3D, {scale: this.targetScale})\r\n\r\n Util.positionObject3DAtTarget(this.worldHelper, this.el.object3D, {scale: this.targetScale});\r\n\r\n let transform = PhysXUtil.matrixToTransform(this.worldHelper.matrix);\r\n\r\n return transform;\r\n },\r\n async createJoint() {\r\n await Util.whenComponentInitialized(this.bodyEl, 'physx-body')\r\n await Util.whenComponentInitialized(this.data.target, 'physx-body')\r\n await this.bodyEl.components['physx-body'].physxRegisteredPromise;\r\n await this.data.target.components['physx-body'].physxRegisteredPromise;\r\n\r\n if (this.joint) {\r\n this.joint.release();\r\n this.joint = null;\r\n }\r\n\r\n let thisTransform = this.getTransform(this.bodyEl);\r\n let targetTransform = this.getTransform(this.data.target);\r\n\r\n this.joint = PhysX[`Px${this.data.type}JointCreate`](this.system.physics,\r\n this.bodyEl.components['physx-body'].rigidBody, thisTransform,\r\n this.data.target.components['physx-body'].rigidBody, targetTransform,\r\n )\r\n this.system.registerJoint(this.joint, this)\r\n this.update();\r\n this.el.emit('physx-jointcreated', this.joint)\r\n }\r\n})\r\n\r\n\r\nAFRAME.registerSystem('physx-contact-event', {\r\n init() {\r\n this.worldHelper = new THREE.Object3D;\r\n this.el.sceneEl.object3D.add(this.worldHelper)\r\n }\r\n})\r\n\r\n// Emits a `contactevent` event when a collision meets the threshold. This\r\n// should be set on an entity with the `physx-body` component. The event detail\r\n// will contain these fields:\r\n// - `impulse`: The summed impulse of at all contact points\r\n// - `contact`: The originating contact event\r\nAFRAME.registerComponent('physx-contact-event', {\r\n dependencies: ['physx-body'],\r\n schema: {\r\n // Minimum total impulse threshold to emit the event\r\n impulseThreshold: {default: 0.01},\r\n\r\n // NYI\r\n maxDistance: {default: 10.0},\r\n // NYI\r\n maxDuration: {default: 5.0},\r\n\r\n // Delay after start of scene before emitting events. Useful to avoid a\r\n // zillion events as objects initially settle on the ground\r\n startDelay: {default: 6000},\r\n\r\n // If `true`, the event detail will include a `positionWorld` property which contains the weighted averaged location\r\n // of all contact points. Contact points are weighted by impulse amplitude.\r\n positionAtContact: {default: false},\r\n },\r\n events: {\r\n contactbegin: function(e) {\r\n if (this.el.sceneEl.time < this.data.startDelay) return\r\n let thisWorld = this.eventDetail.positionWorld;\r\n let cameraWorld = this.pool('cameraWorld', THREE.Vector3);\r\n\r\n let impulses = e.detail.impulses\r\n let impulseSum = 0\r\n for (let i = 0; i < impulses.size(); ++i)\r\n {\r\n impulseSum += impulses.get(i)\r\n }\r\n\r\n if (impulseSum < this.data.impulseThreshold) return;\r\n\r\n thisWorld.set(0, 0, 0)\r\n let impulse = 0.0;\r\n if (this.data.positionAtContact)\r\n {\r\n for (let i = 0; i < impulses.size(); ++i)\r\n {\r\n impulse = impulses.get(i);\r\n let position = e.detail.points.get(i);\r\n thisWorld.x += position.x * impulse;\r\n thisWorld.y += position.y * impulse;\r\n thisWorld.z += position.z * impulse;\r\n }\r\n thisWorld.multiplyScalar(1.0 / impulseSum)\r\n this.system.worldHelper.position.copy(thisWorld)\r\n Util.positionObject3DAtTarget(this.localHelper, this.system.worldHelper)\r\n this.eventDetail.position.copy(this.localHelper.position)\r\n }\r\n else\r\n {\r\n thisWorld.set(0, 0, 0)\r\n this.eventDetail.position.set(0, 0, 0)\r\n }\r\n\r\n this.eventDetail.impulse = impulseSum\r\n this.eventDetail.contact = e.detail\r\n\r\n this.el.emit('contactevent', this.eventDetail)\r\n }\r\n },\r\n init() {\r\n VARTISTE.Pool.init(this)\r\n\r\n this.eventDetail = {\r\n impulse: 0.0,\r\n positionWorld: new THREE.Vector3(),\r\n position: new THREE.Vector3(),\r\n contact: null,\r\n }\r\n\r\n if (this.data.debug) {\r\n let vis = document.createElement('a-entity')\r\n vis.setAttribute('geometry', 'primitive: sphere; radius: 0.1')\r\n vis.setAttribute('physx-no-collision', '')\r\n }\r\n\r\n this.localHelper = new THREE.Object3D();\r\n this.el.object3D.add(this.localHelper)\r\n\r\n this.el.setAttribute('physx-body', 'emitCollisionEvents', true)\r\n },\r\n remove() {\r\n this.el.object3D.remove(this.localHelper)\r\n }\r\n})\r\n\r\n// Plays a sound when a `physx-body` has a collision.\r\nAFRAME.registerComponent('physx-contact-sound', {\r\n dependencies: ['physx-contact-event'],\r\n schema: {\r\n // Sound file location or asset\r\n src: {type: 'string'},\r\n\r\n // Minimum total impulse to play the sound\r\n impulseThreshold: {default: 0.01},\r\n\r\n // NYI\r\n maxDistance: {default: 10.0},\r\n // NYI\r\n maxDuration: {default: 5.0},\r\n\r\n // Delay after start of scene before playing sounds. Useful to avoid a\r\n // zillion sounds playing as objects initially settle on the ground\r\n startDelay: {default: 6000},\r\n\r\n // If `true`, the sound will be positioned at the weighted averaged location\r\n // of all contact points. Contact points are weighted by impulse amplitude.\r\n // If `false`, the sound will be positioned at the entity's origin.\r\n positionAtContact: {default: false},\r\n },\r\n events: {\r\n contactevent: function(e) {\r\n if (this.data.positionAtContact)\r\n {\r\n this.sound.object3D.position.copy(e.detail.position)\r\n }\r\n\r\n this.sound.components.sound.stopSound();\r\n this.sound.components.sound.playSound();\r\n },\r\n },\r\n init() {\r\n let sound = document.createElement('a-entity')\r\n this.el.append(sound)\r\n sound.setAttribute('sound', {src: this.data.src})\r\n this.sound = sound\r\n\r\n this.el.setAttribute('physx-body', 'emitCollisionEvents', true)\r\n },\r\n update(oldData) {\r\n this.el.setAttribute('physx-contact-event', this.data)\r\n }\r\n})\r\n\r\n// Creates A-Frame entities from gltf custom properties.\r\n//\r\n// **WARNING** do not use this component with untrusted gltf models, since it\r\n// will let the model access arbitrary components.\r\n//\r\n// Should be set on an entity with the `gltf-model` component. Once the model is\r\n// loaded, this will traverse the object tree, and any objects containing user\r\n// data key `a-entity` will be turned into separate sub-entities. The user data\r\n// value for `a-entity` will be set as the attributes.\r\n//\r\n// For instance, say you export a model with the following kind of structure\r\n// from Blender (remembering to check \"Include → Custom Properties\"!):\r\n//\r\n//```\r\n// - Empty1\r\n// Custom Properties:\r\n// name: a-entity\r\n// value: physx-body=\"type: dynamic\"\r\n// Children:\r\n// - Mesh1\r\n// Custom Properties:\r\n// name: a-entity\r\n// value: physx-material=\"density: 30\" class=\"clickable\"\r\n// Children:\r\n// - Mesh2\r\n// - Mesh3\r\n// Custom Properties:\r\n// name: a-entity\r\n// value: physx-material=\"density: 100\" physx-contact-sound=\"src: #boom\"\r\n//```\r\n//\r\n// ![Screenshot showing the structure in Blender](./static/images/blenderentities.png)\r\n//\r\n// This will turn into the following HTML (with `setId` set to `true`):\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// **Experimental Blender Plugin**\r\n//\r\n// ![Screenshot showing experimental blender plugin](./static/images/blenderplugin.png)\r\n//\r\n// I've written a small plugin for [Blender](https://www.blender.org/) which can\r\n// automatically set up a lot of the common properties for use in this physics\r\n// system. _Note that it is super experimental and under development. Make a\r\n// backup before using._\r\n//\r\n// **Download Blender Plugin:** vartiste_toolkit_entity_helper.zip (v0.2.0)\r\n//\r\n// **GLB Viewer**\r\n//\r\n// You can test your `gltf-entities` enabled glb files locally by dragging and\r\n// dropping them into this [web viewer](https://fascinated-hip-period.glitch.me/viewer.html)\r\nAFRAME.registerComponent('gltf-entities', {\r\n dependencies: ['gltf-model'],\r\n schema: {\r\n // If true, will set created element's id based on the gltf object name\r\n setId: {default: false},\r\n // If `setId` is true, this will be prepended to the gltf object name when setting the element id\r\n idPrefix: {default: \"\"},\r\n\r\n // Automatically make entities clickable and propogate the grab (for use with [`manipulator`](#manipulator))\r\n autoPropogateGrab: {default: true},\r\n\r\n // Array of attribute names that should be copied from this entitiy to any new created entitity\r\n copyAttributes: {type: 'array'},\r\n\r\n // A list of names of attributes that are allowed to be set. Ignored if empty.\r\n allowedAttributes: {type: 'array'},\r\n },\r\n events: {\r\n 'model-loaded': function(e) {\r\n this.setupEntities()\r\n }\r\n },\r\n init() {},\r\n setupEntities() {\r\n let root = this.el.getObject3D('mesh')\r\n if (!root) return;\r\n\r\n this.setupObject(root, this.el)\r\n },\r\n setupObject(obj3d, currentRootEl)\r\n {\r\n if (obj3d.userData['a-entity']) {\r\n let el = document.createElement('a-entity')\r\n let attrs = obj3d.userData['a-entity']\r\n\r\n // sanitize\r\n el.innerHTML = attrs\r\n el.innerHTML = ``\r\n\r\n el = el.children[0]\r\n\r\n if (this.data.allowedAttributes.length)\r\n {\r\n for (let attr of el.attributes)\r\n {\r\n if (!this.data.allowedAttributes.includes(attr.name))\r\n {\r\n el.removeAttribute(attr.name)\r\n }\r\n }\r\n }\r\n\r\n if (this.data.setId && obj3d.name)\r\n {\r\n el.id = `${this.data.idPrefix}${obj3d.name}`\r\n }\r\n\r\n for (let attribute of this.data.copyAttributes)\r\n {\r\n if (this.el.hasAttribute(attribute))\r\n {\r\n el.setAttribute(attribute, this.el.getAttribute(attribute))\r\n }\r\n }\r\n\r\n if (this.data.autoPropogateGrab && this.el.classList.contains(\"clickable\"))\r\n {\r\n el.setAttribute('propogate-grab', \"\")\r\n el.classList.add(\"clickable\")\r\n }\r\n\r\n currentRootEl.append(el)\r\n Util.whenLoaded(el, () => {\r\n el.setObject3D('mesh', obj3d)\r\n obj3d.updateMatrix()\r\n Util.applyMatrix(obj3d.matrix, el.object3D)\r\n obj3d.matrix.identity()\r\n Util.applyMatrix(obj3d.matrix, obj3d)\r\n })\r\n currentRootEl = el\r\n }\r\n\r\n for (let child of obj3d.children)\r\n {\r\n this.setupObject(child, currentRootEl)\r\n }\r\n }\r\n})\r\n\n\n//# sourceURL=webpack://@c-frame/physx/./src/physics.js?"); +eval("// This is a modification of the physics/PhysX libraries\r\n// created by Lee Stemkoski\r\n// from the VARTISTE project @ https://vartiste.xyz/ \r\n// by Zachary Capalbo https://github.com/zach-capalbo/vartiste\r\n// with the goal of creating a simplified standalone codebase.\r\n// Further performance modifications by Diarmid Mackenzie.\r\n\r\n// original documentation: https://vartiste.xyz/docs.html#physics.js\r\n\r\n// Came via: https://github.com/stemkoski/A-Frame-Examples/blob/66f05fe5cf89879996f1f6a4c0475ce475e8796a/js/physics.js\r\n// and then via: https://github.com/diarmidmackenzie/christmas-scene/blob/a94ae7e7167937f10d34df8429fb71641e343bb1/lib/physics.js\r\n// ======================================================================\r\n\r\nlet PHYSX = __webpack_require__(/*! ./physx.release.js */ \"./src/physx.release.js\");\r\n\r\n// patching in Pool functions\r\nvar poolSize = 0\r\n\r\nfunction sysPool(name, type) {\r\n if (this.system._pool[name]) return this.system._pool[name]\r\n this.system._pool[name] = new type()\r\n // console.log(\"SysPooling\", type.name)\r\n return this.system._pool[name]\r\n}\r\n\r\nfunction pool(name, type) {\r\n if (this._pool[name]) return this._pool[name]\r\n this._pool[name] = new type()\r\n // console.log(\"Pooling\", type.name)\r\n return this._pool[name]\r\n}\r\n\r\nclass Pool {\r\n static init(where, {useSystem = false} = {}) {\r\n if (useSystem)\r\n {\r\n if (!where.system) {\r\n console.error(\"No system for system pool\", where.attrName)\r\n }\r\n if (!where.system._pool) where.system._pool = {};\r\n\r\n where.pool = sysPool;\r\n }\r\n else\r\n {\r\n where._pool = {}\r\n where.pool = pool;\r\n }\r\n }\r\n}\r\n\r\n// ==================================================================================================\r\n\r\n// patching in required Util functions from VARTISTE\r\n\r\nUtil = {}\r\n\r\nPool.init(Util);\r\n\r\n// Copies `matrix` into `obj`'s (a `THREE.Object3D`) `matrix`, and decomposes\r\n// it to `obj`'s position, rotation, and scale\r\nUtil.applyMatrix = function(matrix, obj) {\r\n obj.matrix.copy(matrix)\r\n matrix.decompose(obj.position, obj.rotation, obj.scale)\r\n}\r\n\r\nUtil.traverseCondition = function(obj3D, condition, fn) \r\n{\r\n if (!condition(obj3D)) return;\r\n\r\n fn(obj3D)\r\n for (let c of obj3D.children)\r\n {\r\n this.traverseCondition(c, condition, fn)\r\n }\r\n}\r\n\r\nUtil.positionObject3DAtTarget = function(obj, target, {scale, transformOffset, transformRoot} = {}) \r\n{\r\n if (typeof transformRoot === 'undefined') transformRoot = obj.parent\r\n\r\n target.updateWorldMatrix()\r\n let destMat = this.pool('dest', THREE.Matrix4)\r\n destMat.copy(target.matrixWorld)\r\n\r\n if (transformOffset) {\r\n let transformMat = this.pool('transformMat', THREE.Matrix4)\r\n transformMat.makeTranslation(transformOffset.x, transformOffset.y, transformOffset.z)\r\n destMat.multiply(transformMat)\r\n }\r\n\r\n if (scale) {\r\n let scaleVect = this.pool('scale', THREE.Vector3)\r\n scaleVect.setFromMatrixScale(destMat)\r\n scaleVect.set(scale.x / scaleVect.x, scale.y / scaleVect.y, scale.z / scaleVect.z)\r\n destMat.scale(scaleVect)\r\n }\r\n\r\n let invMat = this.pool('inv', THREE.Matrix4)\r\n\r\n transformRoot.updateWorldMatrix()\r\n invMat.copy(transformRoot.matrixWorld).invert()\r\n destMat.premultiply(invMat)\r\n\r\n Util.applyMatrix(destMat, obj)\r\n}\r\n\r\n// untested functions\r\n\r\n// Executes function `fn` when `entity` has finished loading, or immediately\r\n// if it has already loaded. `entity` may be a single `a-entity` element, or\r\n// an array of `a-entity` elements. If `fn` is not provided, it will return a\r\n// `Promise` that will resolve when `entity` is loaded (or immediately if\r\n// `entity` is already loaded).\r\nUtil.whenLoaded = function(entity, fn) {\r\n if (Array.isArray(entity) && fn) return whenLoadedAll(entity, fn)\r\n if (Array.isArray(entity)) return awaitLoadingAll(entity)\r\n if (fn) return whenLoadedSingle(entity, fn)\r\n return awaitLoadingSingle(entity)\r\n}\r\n\r\nfunction whenLoadedSingle(entity, fn) {\r\n if (entity.hasLoaded)\r\n {\r\n fn()\r\n }\r\n else\r\n {\r\n entity.addEventListener('loaded', fn)\r\n }\r\n}\r\n\r\nfunction whenLoadedAll(entities, fn) {\r\n let allLoaded = entities.map(() => false)\r\n for (let i = 0; i < entities.length; ++i)\r\n {\r\n let ii = i\r\n let entity = entities[ii]\r\n whenLoadedSingle(entity, () => {\r\n allLoaded[ii] = true\r\n if (allLoaded.every(t => t)) fn()\r\n })\r\n }\r\n}\r\n\r\nfunction awaitLoadingSingle(entity) {\r\n return new Promise((r, e) => whenLoadedSingle(entity, r))\r\n}\r\n\r\nasync function awaitLoadingAll(entities) {\r\n for (let entity of entities)\r\n {\r\n await awaitLoadingSingle(entity)\r\n }\r\n}\r\n\r\nUtil.whenComponentInitialized = function(el, component, fn) {\r\n if (el && el.components[component] && el.components[component].initialized) {\r\n return Promise.resolve(fn ? fn() : undefined)\r\n }\r\n\r\n return new Promise((r, e) => {\r\n if (el && el.components[component] && el.components[component].initialized) {\r\n return Promise.resolve(fn ? fn() : undefined)\r\n }\r\n\r\n let listener = (e) => {\r\n if (e.detail.name === component) {\r\n el.removeEventListener('componentinitialized', listener);\r\n if (fn) fn();\r\n r();\r\n }\r\n };\r\n el.addEventListener('componentinitialized', listener)\r\n })\r\n}\r\n\r\n// ========================================================================================\r\n\r\n// Extra utility functions for dealing with PhysX\r\n\r\nconst PhysXUtil = {\r\n // Gets the world position transform of the given object3D in PhysX format\r\n object3DPhysXTransform: (() => {\r\n let pos = new THREE.Vector3();\r\n let quat = new THREE.Quaternion();\r\n return function (obj) {\r\n obj.getWorldPosition(pos);\r\n obj.getWorldQuaternion(quat);\r\n\r\n return {\r\n translation: {\r\n x: pos.x,\r\n y: pos.y,\r\n z: pos.z,\r\n },\r\n rotation: {\r\n w: quat.w, // PhysX uses WXYZ quaternions,\r\n x: quat.x,\r\n y: quat.y,\r\n z: quat.z,\r\n },\r\n }\r\n }\r\n })(),\r\n\r\n // Converts a THREE.Matrix4 into a PhysX transform\r\n matrixToTransform: (() => {\r\n let pos = new THREE.Vector3();\r\n let quat = new THREE.Quaternion();\r\n let scale = new THREE.Vector3();\r\n let scaleInv = new THREE.Matrix4();\r\n let mat2 = new THREE.Matrix4();\r\n return function (matrix) {\r\n matrix.decompose(pos, quat, scale);\r\n\r\n return {\r\n translation: {\r\n x: pos.x,\r\n y: pos.y,\r\n z: pos.z,\r\n },\r\n rotation: {\r\n w: quat.w, // PhysX uses WXYZ quaternions,\r\n x: quat.x,\r\n y: quat.y,\r\n z: quat.z,\r\n },\r\n }\r\n }\r\n })(),\r\n\r\n // Converts an arry of layer numbers to an integer bitmask\r\n layersToMask: (() => {\r\n let layers = new THREE.Layers();\r\n return function(layerArray) {\r\n layers.disableAll();\r\n for (let layer of layerArray)\r\n {\r\n layers.enable(parseInt(layer));\r\n }\r\n return layers.mask;\r\n };\r\n })(),\r\n\r\n axisArrayToEnums: function(axes) {\r\n let enumAxes = []\r\n for (let axis of axes)\r\n {\r\n if (axis === 'swing') {\r\n enumAxes.push(PhysX.PxD6Axis.eSWING1)\r\n enumAxes.push(PhysX.PxD6Axis.eSWING2)\r\n continue\r\n }\r\n let enumKey = `e${axis.toUpperCase()}`\r\n if (!(enumKey in PhysX.PxD6Axis))\r\n {\r\n console.warn(`Unknown axis ${axis} (PxD6Axis::${enumKey})`)\r\n }\r\n enumAxes.push(PhysX.PxD6Axis[enumKey])\r\n }\r\n return enumAxes;\r\n }\r\n};\r\n\r\nlet PhysX\r\n\r\n// Implements the a physics system using an emscripten compiled PhysX engine.\r\n//\r\n//\r\n// If `autoLoad` is `true`, or when you call `startPhysX`, the `physx` system will\r\n// automatically load and initialize the physics system with reasonable defaults\r\n// and a ground plane. All you have to do is add [`physx-body`](#physx-body) to\r\n// the bodies that you want to be part of the simulation. The system will take\r\n// try to take care of things like collision meshes, position updates, etc\r\n// automatically. The simplest physics scene looks something like:\r\n//\r\n//```\r\n// \r\n// \r\n//\r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// If you want a little more control over how things behave, you can set the\r\n// [`physx-material`](#physx-material) component on the objects in your\r\n// simulation, or use [`physx-joint`s](#physx-joint),\r\n// [`physx-constraint`s](#physx-constraint) and [`physx-driver`s](#physx-driver)\r\n// to add some complexity to your scene.\r\n//\r\n// If you need more low-level control, the PhysX bindings are exposed through\r\n// the `PhysX` property of the system. So for instance, if you wanted to make\r\n// use of the [`PxCapsuleGeometry`](https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxapi/files/classPxCapsuleGeometry.html)\r\n// in your own component, you would call:\r\n//\r\n//```\r\n// let myGeometry = new this.el.sceneEl.PhysX.PxCapsuleGeometry(1.0, 2.0)\r\n//```\r\n//\r\n// The system uses [my fork](https://github.com/zach-capalbo/PhysX) of PhysX, built using the [Docker Wrapper](https://github.com/ashconnell/physx-js). To see what's exposed to JavaScript, see [PxWebBindings.cpp](https://github.com/zach-capalbo/PhysX/blob/emscripten_wip/physx/source/physxwebbindings/src/PxWebBindings.cpp)\r\n//\r\n// For a complete example of how to use this, you can see the\r\n// [aframe-vartiste-toolkit Physics\r\n// Playground](https://glitch.com/edit/#!/fascinated-hip-period?path=index.html)\r\n//\r\n// It is also helpful to refer to the [NVIDIA PhysX\r\n// documentation](https://gameworksdocs.nvidia.com/PhysX/4.0/documentation/PhysXGuide/Manual/Index.html)\r\nAFRAME.registerSystem('physx', {\r\n schema: {\r\n // Amount of time to wait after loading before starting the physics. Can be\r\n // useful if there is still some things loading or initializing elsewhere in\r\n // the scene\r\n delay: {default: 5000},\r\n\r\n // Throttle for running the physics simulation. On complex scenes, you can\r\n // increase this to avoid dropping video frames\r\n throttle: {default: 10},\r\n\r\n // If true, the PhysX will automatically be loaded and started. If false,\r\n // you will have to call `startPhysX()` manually to load and start the\r\n // physics engine\r\n autoLoad: {default: false},\r\n\r\n // Simulation speed multiplier. Increase or decrease to speed up or slow\r\n // down simulation time\r\n speed: {default: 1.0},\r\n\r\n // URL for the PhysX WASM bundle.\r\n wasmUrl: {default: \"https://cdn.jsdelivr.net/gh/c-frame/physx/wasm/physx.release.wasm\"},\r\n\r\n // If true, sets up a default scene with a ground plane and bounding\r\n // cylinder.\r\n useDefaultScene: {default: true},\r\n\r\n // NYI\r\n wrapBounds: {default: false},\r\n\r\n // Which collision layers the ground belongs to\r\n groundCollisionLayers: {default: [2]},\r\n\r\n // Which collision layers will collide with the ground\r\n groundCollisionMask: {default: [1,2,3,4]},\r\n\r\n // Global gravity vector\r\n gravity: {type: 'vec3', default: {x: 0, y: -9.8, z: 0}},\r\n\r\n // Whether to output stats, and how to output them. One or more of \"console\", \"events\", \"panel\"\r\n stats: {type: 'array', default: []}\r\n },\r\n init() {\r\n this.PhysXUtil = PhysXUtil;\r\n\r\n // for logging.\r\n this.cumTimeEngine = 0;\r\n this.cumTimeWrapper = 0;\r\n this.tickCounter = 0;\r\n\r\n\r\n this.objects = new Map();\r\n this.shapeMap = new Map();\r\n this.jointMap = new Map();\r\n this.boundaryShapes = new Set();\r\n this.worldHelper = new THREE.Object3D();\r\n this.el.object3D.add(this.worldHelper);\r\n this.tock = AFRAME.utils.throttleTick(this.tock, this.data.throttle, this)\r\n this.collisionObject = {thisShape: null, otherShape:null, points: [], impulses: [], otherComponent: null};\r\n\r\n let defaultTarget = document.createElement('a-entity')\r\n this.el.append(defaultTarget)\r\n this.defaultTarget = defaultTarget\r\n\r\n this.initializePhysX = new Promise((r, e) => {\r\n this.fulfillPhysXPromise = r;\r\n })\r\n\r\n this.initStats()\r\n\r\n this.el.addEventListener('inspectortoggle', (e) => {\r\n console.log(\"Inspector toggle\", e)\r\n if (e.detail === true)\r\n {\r\n this.running = false\r\n }\r\n })\r\n },\r\n\r\n initStats() {\r\n // Data used for performance monitoring.\r\n this.statsToConsole = this.data.stats.includes(\"console\")\r\n this.statsToEvents = this.data.stats.includes(\"events\")\r\n this.statsToPanel = this.data.stats.includes(\"panel\")\r\n\r\n this.bodyTypeToStatsPropertyMap = {\r\n \"static\": \"staticBodies\",\r\n \"dynamic\": \"dynamicBodies\",\r\n \"kinematic\": \"kinematicBodies\",\r\n }\r\n\r\n if (this.statsToConsole || this.statsToEvents || this.statsToPanel) {\r\n this.trackPerf = true;\r\n this.tickCounter = 0;\r\n this.statsTickData = {};\r\n this.statsBodyData = {};\r\n\r\n const scene = this.el.sceneEl;\r\n scene.setAttribute(\"stats-collector\", `inEvent: physics-tick-data;\r\n properties: engine, after, total;\r\n outputFrequency: 100;\r\n outEvent: physics-tick-summary;\r\n outputs: percentile__50, percentile__90, max`);\r\n }\r\n\r\n if (this.statsToPanel) {\r\n const scene = this.el.sceneEl;\r\n const space = \"   \"\r\n \r\n scene.setAttribute(\"stats-panel\", \"\")\r\n scene.setAttribute(\"stats-group__bodies\", `label: Physics Bodies`)\r\n scene.setAttribute(\"stats-row__b1\", `group: bodies;\r\n event:physics-body-data;\r\n properties: staticBodies;\r\n label: Static`)\r\n scene.setAttribute(\"stats-row__b2\", `group: bodies;\r\n event:physics-body-data;\r\n properties: dynamicBodies;\r\n label: Dynamic`)\r\n scene.setAttribute(\"stats-row__b3\", `group: bodies;\r\n event:physics-body-data;\r\n properties: kinematicBodies;\r\n label: Kinematic`)\r\n scene.setAttribute(\"stats-group__tick\", `label: Physics Ticks: Median${space}90th%${space}99th%`)\r\n scene.setAttribute(\"stats-row__1\", `group: tick; \r\n event:physics-tick-summary; \r\n properties: engine.percentile__50, \r\n engine.percentile__90, \r\n engine.max;\r\n label: Engine`)\r\n scene.setAttribute(\"stats-row__2\", `group: tick;\r\n event:physics-tick-summary;\r\n properties: after.percentile__50, \r\n after.percentile__90, \r\n after.max; \r\n label: After`)\r\n\r\n scene.setAttribute(\"stats-row__3\", `group: tick;\r\n event:physics-tick-summary;\r\n properties: total.percentile__50, \r\n total.percentile__90, \r\n total.max;\r\n label: Total`)\r\n }\r\n },\r\n findWasm() {\r\n return this.data.wasmUrl;\r\n },\r\n // Loads PhysX and starts the simulation\r\n async startPhysX() {\r\n this.running = true;\r\n let self = this;\r\n let resolveInitialized;\r\n let initialized = new Promise((r, e) => resolveInitialized = r)\r\n PhysX = PHYSX({\r\n locateFile() {\r\n return self.findWasm()\r\n },\r\n onRuntimeInitialized() {\r\n resolveInitialized();\r\n }\r\n });\r\n if (PhysX instanceof Promise) PhysX = await PhysX;\r\n this.PhysX = PhysX;\r\n await initialized;\r\n self.startPhysXScene()\r\n self.physXInitialized = true\r\n self.fulfillPhysXPromise()\r\n self.el.emit('physx-started', {})\r\n },\r\n startPhysXScene() {\r\n console.info(\"Starting PhysX scene\")\r\n const foundation = PhysX.PxCreateFoundation(\r\n PhysX.PX_PHYSICS_VERSION,\r\n new PhysX.PxDefaultAllocator(),\r\n new PhysX.PxDefaultErrorCallback()\r\n );\r\n this.foundation = foundation\r\n const physxSimulationCallbackInstance = PhysX.PxSimulationEventCallback.implement({\r\n onContactBegin: (shape0, shape1, points, impulses) => {\r\n let c0 = this.shapeMap.get(shape0.$$.ptr)\r\n let c1 = this.shapeMap.get(shape1.$$.ptr)\r\n\r\n if (c1 === c0) return;\r\n\r\n if (c0 && c0.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape0\r\n this.collisionObject.otherShape = shape1\r\n this.collisionObject.points = points\r\n this.collisionObject.impulses = impulses\r\n this.collisionObject.otherComponent = c1\r\n c0.el.emit('contactbegin', this.collisionObject)\r\n }\r\n\r\n if (c1 && c1.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape1\r\n this.collisionObject.otherShape = shape0\r\n this.collisionObject.points = points\r\n this.collisionObject.impulses = impulses\r\n this.collisionObject.otherComponent = c0\r\n c1.el.emit('contactbegin', this.collisionObject)\r\n }\r\n },\r\n onContactEnd: (shape0, shape1) => {\r\n let c0 = this.shapeMap.get(shape0.$$.ptr)\r\n let c1 = this.shapeMap.get(shape1.$$.ptr)\r\n\r\n if (c1 === c0) return;\r\n\r\n if (c0 && c0.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape0\r\n this.collisionObject.otherShape = shape1\r\n this.collisionObject.points = null\r\n this.collisionObject.impulses = null\r\n this.collisionObject.otherComponent = c1\r\n c0.el.emit('contactend', this.collisionObject)\r\n }\r\n\r\n if (c1 && c1.data.emitCollisionEvents) {\r\n this.collisionObject.thisShape = shape1\r\n this.collisionObject.otherShape = shape0\r\n this.collisionObject.points = null\r\n this.collisionObject.impulses = null\r\n this.collisionObject.otherComponent = c0\r\n c1.el.emit('contactend', this.collisionObject)\r\n }\r\n },\r\n onContactPersist: () => {},\r\n onTriggerBegin: () => {},\r\n onTriggerEnd: () => {},\r\n onConstraintBreak: (joint) => {\r\n let component = this.jointMap.get(joint.$$.ptr);\r\n\r\n if (!component) return;\r\n\r\n component.el.emit('constraintbreak', {})\r\n },\r\n });\r\n let tolerance = new PhysX.PxTolerancesScale();\r\n // tolerance.length /= 10;\r\n // console.log(\"Tolerances\", tolerance.length, tolerance.speed);\r\n this.physics = PhysX.PxCreatePhysics(\r\n PhysX.PX_PHYSICS_VERSION,\r\n foundation,\r\n tolerance,\r\n false,\r\n null\r\n )\r\n PhysX.PxInitExtensions(this.physics, null);\r\n\r\n this.cooking = PhysX.PxCreateCooking(\r\n PhysX.PX_PHYSICS_VERSION,\r\n foundation,\r\n new PhysX.PxCookingParams(tolerance)\r\n )\r\n\r\n const sceneDesc = PhysX.getDefaultSceneDesc(\r\n this.physics.getTolerancesScale(),\r\n 0,\r\n physxSimulationCallbackInstance\r\n )\r\n this.scene = this.physics.createScene(sceneDesc)\r\n\r\n this.setupDefaultEnvironment()\r\n },\r\n setupDefaultEnvironment() {\r\n this.defaultActorFlags = new PhysX.PxShapeFlags(\r\n PhysX.PxShapeFlag.eSCENE_QUERY_SHAPE.value |\r\n PhysX.PxShapeFlag.eSIMULATION_SHAPE.value\r\n )\r\n this.defaultFilterData = new PhysX.PxFilterData(PhysXUtil.layersToMask(this.data.groundCollisionLayers), PhysXUtil.layersToMask(this.data.groundCollisionMask), 0, 0);\r\n\r\n this.scene.setGravity(this.data.gravity)\r\n\r\n if (this.data.useDefaultScene)\r\n {\r\n this.createGroundPlane()\r\n this.createBoundingCylinder()\r\n }\r\n\r\n\r\n this.defaultTarget.setAttribute('physx-body', 'type', 'static')\r\n\r\n },\r\n createGroundPlane() {\r\n let geometry = new PhysX.PxPlaneGeometry();\r\n // let geometry = new PhysX.PxBoxGeometry(10, 1, 10);\r\n let material = this.physics.createMaterial(0.8, 0.8, 0.1);\r\n\r\n const shape = this.physics.createShape(geometry, material, false, this.defaultActorFlags)\r\n shape.setQueryFilterData(this.defaultFilterData)\r\n shape.setSimulationFilterData(this.defaultFilterData)\r\n const transform = {\r\n translation: {\r\n x: 0,\r\n y: 0,\r\n z: -5,\r\n },\r\n rotation: {\r\n w: 0.707107, // PhysX uses WXYZ quaternions,\r\n x: 0,\r\n y: 0,\r\n z: 0.707107,\r\n },\r\n }\r\n let body = this.physics.createRigidStatic(transform)\r\n body.attachShape(shape)\r\n this.scene.addActor(body, null)\r\n this.ground = body\r\n this.rigidBody = body\r\n },\r\n createBoundingCylinder() {\r\n const numPlanes = 16\r\n let geometry = new PhysX.PxPlaneGeometry();\r\n let material = this.physics.createMaterial(0.1, 0.1, 0.8);\r\n let spherical = new THREE.Spherical();\r\n spherical.radius = 30;\r\n let quat = new THREE.Quaternion();\r\n let pos = new THREE.Vector3;\r\n let euler = new THREE.Euler();\r\n\r\n for (let i = 0; i < numPlanes; ++i)\r\n {\r\n spherical.theta = i * 2.0 * Math.PI / numPlanes;\r\n pos.setFromSphericalCoords(spherical.radius, spherical.theta, spherical.phi)\r\n pos.x = - pos.y\r\n pos.y = 0;\r\n euler.set(0, spherical.theta, 0);\r\n quat.setFromEuler(euler)\r\n\r\n const shape = this.physics.createShape(geometry, material, false, this.defaultActorFlags)\r\n shape.setQueryFilterData(this.defaultFilterData)\r\n shape.setSimulationFilterData(this.defaultFilterData)\r\n const transform = {\r\n translation: {\r\n x: pos.x,\r\n y: pos.y,\r\n z: pos.z,\r\n },\r\n rotation: {\r\n w: quat.w, // PhysX uses WXYZ quaternions,\r\n x: quat.x,\r\n y: quat.y,\r\n z: quat.z,\r\n },\r\n }\r\n this.boundaryShapes.add(shape.$$.ptr)\r\n let body = this.physics.createRigidStatic(transform)\r\n body.attachShape(shape)\r\n this.scene.addActor(body, null)\r\n }\r\n },\r\n async registerComponentBody(component, {type}) {\r\n await this.initializePhysX;\r\n\r\n // const shape = this.physics.createShape(geometry, material, false, flags)\r\n const transform = PhysXUtil.object3DPhysXTransform(component.el.object3D);\r\n\r\n let body\r\n if (type === 'dynamic' || type === 'kinematic')\r\n {\r\n body = this.physics.createRigidDynamic(transform)\r\n\r\n // body.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_CCD, true);\r\n // body.setMaxContactImpulse(1e2);\r\n }\r\n else\r\n {\r\n body = this.physics.createRigidStatic(transform)\r\n }\r\n\r\n let attemptToUseDensity = true;\r\n let seenAnyDensity = false;\r\n let densities = new PhysX.VectorPxReal()\r\n for (let shape of component.createShapes(this.physics, this.defaultActorFlags))\r\n {\r\n body.attachShape(shape)\r\n\r\n if (isFinite(shape.density))\r\n {\r\n seenAnyDensity = true\r\n densities.push_back(shape.density)\r\n }\r\n else\r\n {\r\n attemptToUseDensity = false\r\n\r\n if (seenAnyDensity)\r\n {\r\n console.warn(\"Densities not set for all shapes. Will use total mass instead.\", component.el)\r\n }\r\n }\r\n }\r\n if (type === 'dynamic' || type === 'kinematic') {\r\n if (attemptToUseDensity && seenAnyDensity)\r\n {\r\n console.log(\"Setting density vector\", densities)\r\n body.updateMassAndInertia(densities)\r\n }\r\n else {\r\n body.setMassAndUpdateInertia(component.data.mass)\r\n }\r\n }\r\n densities.delete()\r\n this.scene.addActor(body, null)\r\n this.objects.set(component.el.object3D, body)\r\n component.rigidBody = body\r\n },\r\n registerShape(shape, component) {\r\n this.shapeMap.set(shape.$$.ptr, component);\r\n },\r\n registerJoint(joint, component) {\r\n this.jointMap.set(joint.$$.ptr, component);\r\n },\r\n removeBody(component) {\r\n let body = component.rigidBody\r\n this.objects.delete(component.el.object3D)\r\n body.release()\r\n },\r\n tock(t, dt) {\r\n if (t < this.data.delay) return\r\n if (!this.physXInitialized && this.data.autoLoad && !this.running) this.startPhysX()\r\n if (!this.physXInitialized) return\r\n if (!this.running) return\r\n\r\n const engineStartTime = performance.now();\r\n\r\n this.scene.simulate(THREE.MathUtils.clamp(dt * this.data.speed / 1000, 0, 0.03 * this.data.speed), true)\r\n //this.scene.simulate(0.02, true) // (experiment with fixed interval)\r\n this.scene.fetchResults(true)\r\n\r\n const engineEndTime = performance.now();\r\n\r\n for (let [obj, body] of this.objects)\r\n {\r\n // no updates needed for static objects.\r\n if (obj.el.components['physx-body'].data.type === 'static') continue;\r\n\r\n const transform = body.getGlobalPose()\r\n this.worldHelper.position.copy(transform.translation);\r\n this.worldHelper.quaternion.copy(transform.rotation);\r\n obj.getWorldScale(this.worldHelper.scale)\r\n Util.positionObject3DAtTarget(obj, this.worldHelper);\r\n }\r\n\r\n if (this.trackPerf) {\r\n const afterEndTime = performance.now();\r\n\r\n this.statsTickData.engine = engineEndTime - engineStartTime\r\n this.statsTickData.after = afterEndTime - engineEndTime\r\n this.statsTickData.total = afterEndTime - engineStartTime\r\n this.el.emit(\"physics-tick-data\", this.statsTickData)\r\n\r\n this.tickCounter++;\r\n\r\n if (this.tickCounter === 100) {\r\n\r\n this.countBodies()\r\n\r\n if (this.statsToConsole) {\r\n console.log(\"Physics tick stats:\", this.statsData)\r\n }\r\n\r\n if (this.statsToEvents || this.statsToPanel) {\r\n this.el.emit(\"physics-body-data\", this.statsBodyData)\r\n }\r\n\r\n this.tickCounter = 0;\r\n }\r\n }\r\n },\r\n\r\n countBodies() {\r\n\r\n // Aditional statistics beyond simple body counts should be possible.\r\n // They could be accessed via PxScene::getSimulationStatistics()\r\n // https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/Statistics.html\r\n // https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxSimulationStatistics.html\r\n // However this part of the API is not yet exposed in the\r\n // WASM PhysX build we are using\r\n // See: https://github.com/zach-capalbo/PhysX/blob/emscripten_wip/physx/source/physxwebbindings/src/PxWebBindings.cpp\r\n \r\n const statsData = this.statsBodyData\r\n statsData.staticBodies = 0\r\n statsData.kinematicBodies = 0\r\n statsData.dynamicBodies = 0\r\n\r\n this.objects.forEach((pxBody, object3D) => {\r\n const el = object3D.el\r\n const type = el.components['physx-body'].data.type\r\n const property = this.bodyTypeToStatsPropertyMap[type]\r\n statsData[property]++\r\n })\r\n },\r\n})\r\n\r\n// Controls physics properties for individual shapes or rigid bodies. You can\r\n// set this either on an entity with the `phyx-body` component, or on a shape or\r\n// model contained in an entity with the `physx-body` component. If it's set on\r\n// a `physx-body`, it will be the default material for all shapes in that body.\r\n// If it's set on an element containing geometry or a model, it will be the\r\n// material used for that shape only.\r\n//\r\n// For instance, in the following scene fragment:\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// `shape1`, which is part of the `bodyA` rigid body, will have static friction\r\n// of 1.0, since it has a material set on it. `shape2`, which is also part of\r\n// the `bodyA` rigid body, will have a static friction of 0.5, since that is\r\n// the body default. `bodyB` will have the component default of 0.2, since it is\r\n// a separate body.\r\nAFRAME.registerComponent('physx-material', {\r\n schema: {\r\n // Static friction\r\n staticFriction: {default: 0.2},\r\n // Dynamic friction\r\n dynamicFriction: {default: 0.2},\r\n // Restitution, or \"bounciness\"\r\n restitution: {default: 0.2},\r\n\r\n // Density for the shape. If densities are specified for _all_ shapes in a\r\n // rigid body, then the rigid body's mass properties will be automatically\r\n // calculated based on the different densities. However, if density\r\n // information is not specified for every shape, then the mass defined in\r\n // the overarching [`physx-body`](#physx-body) will be used instead.\r\n density: {type: 'number', default: NaN},\r\n\r\n // Which collision layers this shape is present on\r\n collisionLayers: {default: [1], type: 'array'},\r\n // Array containing all layers that this shape should collide with\r\n collidesWithLayers: {default: [1,2,3,4], type: 'array'},\r\n\r\n // If `collisionGroup` is greater than 0, this shape will *not* collide with\r\n // any other shape with the same `collisionGroup` value\r\n collisionGroup: {default: 0},\r\n\r\n // If >= 0, this will set the PhysX contact offset, indicating how far away\r\n // from the shape simulation contact events should begin.\r\n contactOffset: {default: -1.0},\r\n\r\n // If >= 0, this will set the PhysX rest offset\r\n restOffset: {default: -1.0},\r\n }\r\n})\r\n\r\n// Turns an entity into a PhysX rigid body. This is the main component for\r\n// creating physics objects.\r\n//\r\n// **Types**\r\n//\r\n// There are 3 types of supported rigid bodies. The type can be set by using the\r\n// `type` proeprty, but once initialized cannot be changed.\r\n//\r\n// - `dynamic` objects are objects that will have physics simulated on them. The\r\n// entity's world position, scale, and rotation will be used as the starting\r\n// condition for the simulation, however once the simulation starts the\r\n// entity's position and rotation will be replaced each frame with the results\r\n// of the simulation.\r\n// - `static` objects are objects that cannot move. They cab be used to create\r\n// collidable objects for `dynamic` objects, or for anchor points for joints.\r\n// - `kinematic` objects are objects that can be moved programmatically, but\r\n// will not be moved by the simulation. They can however, interact with and\r\n// collide with dynamic objects. Each frame, the entity's `object3D` will be\r\n// used to set the position and rotation for the simulation object.\r\n//\r\n// **Shapes**\r\n//\r\n// When the component is initialized, and on the `object3dset` event, all\r\n// visible meshes that are descendents of this entity will have shapes created\r\n// for them. Each individual mesh will have its own convex hull automatically\r\n// generated for it. This means you can have reasonably accurate collision\r\n// meshes both from building up shapes with a-frame geometry primitives, and\r\n// from importing 3D models.\r\n//\r\n// Visible meshes can be excluded from this shape generation process by setting\r\n// the `physx-no-collision` attribute on the corresponding `a-entity` element.\r\n// Invisible meshes can be included into this shape generation process by\r\n// settingt the `physx-hidden-collision` attribute on the corresponding\r\n// `a-entity` element. This can be especially useful when using an external tool\r\n// (like [Blender V-HACD](https://github.com/andyp123/blender_vhacd)) to create\r\n// a low-poly convex collision mesh for a high-poly or concave mesh. This leads\r\n// to this pattern for such cases:\r\n//\r\n// ```\r\n// \r\n// \r\n// \r\n// \r\n// ```\r\n//\r\n// Note, in such cases that if you are setting material properties on individual\r\n// shapes, then the property should go on the collision mesh entity\r\n//\r\n// **Use with the [Manipulator](#manipulator) component**\r\n//\r\n// If a dynamic entity is grabbed by the [Manipulator](#manipulator) component,\r\n// it will temporarily become a kinematic object. This means that collisions\r\n// will no longer impede its movement, and it will track the manipulator\r\n// exactly, (subject to any manipulator constraints, such as\r\n// [`manipulator-weight`](#manipulator-weight)). If you would rather have the\r\n// object remain dynamic, you will need to [redirect the grab](#redirect-grab)\r\n// to a `physx-joint` instead, or even easier, use the\r\n// [`dual-wieldable`](#dual-wieldable) component.\r\n//\r\n// As soon as the dynamic object is released, it will revert back to a dynamic\r\n// object. Objects with the type `kinematic` will remain kinematic.\r\n//\r\n// Static objects should not be moved. If a static object can be the target of a\r\n// manipulator grab (or any other kind of movement), it should be `kinematic`\r\n// instead.\r\nAFRAME.registerComponent('physx-body', {\r\n dependencies: ['physx-material'],\r\n schema: {\r\n // **[dynamic, static, kinematic]** Type of the rigid body to create\r\n type: {default: 'dynamic', oneOf: ['dynamic', 'static', 'kinematic']},\r\n\r\n // Total mass of the body\r\n mass: {default: 1.0},\r\n\r\n // If > 0, will set the rigid body's angular damping\r\n angularDamping: {default: 0.0},\r\n\r\n // If > 0, will set the rigid body's linear damping\r\n linearDamping: {default: 0.0},\r\n\r\n // If set to `true`, it will emit `contactbegin` and `contactend` events\r\n // when collisions occur\r\n emitCollisionEvents: {default: false},\r\n\r\n // If set to `true`, the object will receive extra attention by the\r\n // simulation engine (at a performance cost).\r\n highPrecision: {default: false},\r\n\r\n shapeOffset: {type: 'vec3', default: {x: 0, y: 0, z: 0}}\r\n },\r\n events: {\r\n stateadded: function(e) {\r\n if (e.detail === 'grabbed') {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, true)\r\n }\r\n },\r\n stateremoved: function(e) {\r\n if (e.detail === 'grabbed') {\r\n if (this.floating) {\r\n this.rigidBody.setLinearVelocity({x: 0, y: 0, z: 0}, true)\r\n }\r\n if (this.data.type !== 'kinematic')\r\n {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, false)\r\n }\r\n }\r\n },\r\n 'bbuttonup': function(e) {\r\n this.toggleGravity()\r\n },\r\n componentchanged: function(e) {\r\n if (e.name === 'physx-material')\r\n {\r\n this.el.emit('object3dset', {})\r\n }\r\n },\r\n object3dset: function(e) {\r\n if (this.rigidBody) {\r\n for (let shape of this.shapes)\r\n {\r\n this.rigidBody.detachShape(shape, false)\r\n }\r\n\r\n let attemptToUseDensity = true;\r\n let seenAnyDensity = false;\r\n let densities = new PhysX.VectorPxReal()\r\n let component = this\r\n let type = this.data.type\r\n let body = this.rigidBody\r\n for (let shape of component.createShapes(this.system.physics, this.system.defaultActorFlags))\r\n {\r\n body.attachShape(shape)\r\n\r\n if (isFinite(shape.density))\r\n {\r\n seenAnyDensity = true\r\n densities.push_back(shape.density)\r\n }\r\n else\r\n {\r\n attemptToUseDensity = false\r\n\r\n if (seenAnyDensity)\r\n {\r\n console.warn(\"Densities not set for all shapes. Will use total mass instead.\", component.el)\r\n }\r\n }\r\n }\r\n if (type === 'dynamic' || type === 'kinematic') {\r\n if (attemptToUseDensity && seenAnyDensity)\r\n {\r\n console.log(\"Setting density vector\", densities)\r\n body.updateMassAndInertia(densities)\r\n }\r\n else {\r\n body.setMassAndUpdateInertia(component.data.mass)\r\n }\r\n }\r\n }\r\n },\r\n contactbegin: function(e) {\r\n // console.log(\"Collision\", e.detail.points)\r\n }\r\n },\r\n init() {\r\n this.system = this.el.sceneEl.systems.physx\r\n this.physxRegisteredPromise = this.system.registerComponentBody(this, {type: this.data.type})\r\n this.el.setAttribute('grab-options', 'scalable', false)\r\n\r\n this.kinematicMove = this.kinematicMove.bind(this)\r\n if (this.el.sceneEl.systems['button-caster'])\r\n {\r\n this.el.sceneEl.systems['button-caster'].install(['bbutton'])\r\n }\r\n\r\n this.physxRegisteredPromise.then(() => this.update())\r\n },\r\n update(oldData) {\r\n if (!this.rigidBody) return;\r\n\r\n if (this.data.type === 'dynamic')\r\n {\r\n this.rigidBody.setAngularDamping(this.data.angularDamping)\r\n this.rigidBody.setLinearDamping(this.data.linearDamping)\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, false)\r\n }\r\n\r\n if (this.data.highPrecision)\r\n {\r\n this.rigidBody.setSolverIterationCounts(4, 2);\r\n if (this.data.type === 'dynamic') {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_CCD, true)\r\n }\r\n else if (this.data.type === 'kinematic') {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);\r\n }\r\n }\r\n\r\n if (!oldData || this.data.mass !== oldData.mass) this.el.emit('object3dset', {})\r\n },\r\n remove() {\r\n if (!this.rigidBody) return;\r\n this.system.removeBody(this)\r\n },\r\n createGeometry(o) {\r\n if (o.el.hasAttribute('geometry'))\r\n {\r\n let geometry = o.el.getAttribute('geometry');\r\n switch(geometry.primitive)\r\n {\r\n case 'sphere':\r\n return new PhysX.PxSphereGeometry(geometry.radius * this.el.object3D.scale.x * 0.98)\r\n case 'box':\r\n return new PhysX.PxBoxGeometry(geometry.width / 2, geometry.height / 2, geometry.depth / 2)\r\n default:\r\n return this.createConvexMeshGeometry(o.el.getObject3D('mesh'));\r\n }\r\n }\r\n },\r\n createConvexMeshGeometry(mesh, rootAncestor) {\r\n let vectors = new PhysX.PxVec3Vector()\r\n\r\n let g = mesh.geometry.attributes.position\r\n if (!g) return;\r\n if (g.count < 3) return;\r\n if (g.itemSize != 3) return;\r\n let t = new THREE.Vector3;\r\n\r\n if (rootAncestor)\r\n {\r\n let matrix = new THREE.Matrix4();\r\n mesh.updateMatrix();\r\n matrix.copy(mesh.matrix)\r\n let ancestor = mesh.parent;\r\n while(ancestor && ancestor !== rootAncestor)\r\n {\r\n ancestor.updateMatrix();\r\n matrix.premultiply(ancestor.matrix);\r\n ancestor = ancestor.parent;\r\n }\r\n for (let i = 0; i < g.count; ++i) {\r\n t.fromBufferAttribute(g, i)\r\n t.applyMatrix4(matrix);\r\n vectors.push_back(Object.assign({}, t));\r\n }\r\n }\r\n else\r\n {\r\n for (let i = 0; i < g.count; ++i) {\r\n t.fromBufferAttribute(g, i)\r\n vectors.push_back(Object.assign({}, t));\r\n }\r\n }\r\n\r\n let worldScale = new THREE.Vector3;\r\n let worldBasis = (rootAncestor || mesh);\r\n worldBasis.updateMatrixWorld();\r\n worldBasis.getWorldScale(worldScale);\r\n let convexMesh = this.system.cooking.createConvexMesh(vectors, this.system.physics)\r\n return new PhysX.PxConvexMeshGeometry(convexMesh, new PhysX.PxMeshScale({x: worldScale.x, y: worldScale.y, z: worldScale.z}, {w: 1, x: 0, y: 0, z: 0}), new PhysX.PxConvexMeshGeometryFlags(PhysX.PxConvexMeshGeometryFlag.eTIGHT_BOUNDS.value))\r\n },\r\n createShape(physics, geometry, materialData)\r\n {\r\n let material = physics.createMaterial(materialData.staticFriction, materialData.dynamicFriction, materialData.restitution);\r\n let shape = physics.createShape(geometry, material, false, this.system.defaultActorFlags)\r\n shape.setQueryFilterData(new PhysX.PxFilterData(PhysXUtil.layersToMask(materialData.collisionLayers), PhysXUtil.layersToMask(materialData.collidesWithLayers), materialData.collisionGroup, 0))\r\n shape.setSimulationFilterData(new PhysX.PxFilterData(PhysXUtil.layersToMask(materialData.collisionLayers), PhysXUtil.layersToMask(materialData.collidesWithLayers), materialData.collisionGroup, 0))\r\n\r\n if (materialData.contactOffset >= 0.0)\r\n {\r\n shape.setContactOffset(materialData.contactOffset)\r\n }\r\n if (materialData.restOffset >= 0.0)\r\n {\r\n shape.setRestOffset(materialData.restOffset)\r\n }\r\n\r\n shape.density = materialData.density;\r\n this.system.registerShape(shape, this)\r\n\r\n return shape;\r\n },\r\n createShapes(physics) {\r\n if (this.el.hasAttribute('geometry'))\r\n {\r\n let geometry = this.createGeometry(this.el.object3D);\r\n if (!geometry) return;\r\n let materialData = this.el.components['physx-material'].data\r\n this.shapes = [this.createShape(physics, geometry, materialData)];\r\n\r\n return this.shapes;\r\n }\r\n\r\n let shapes = []\r\n Util.traverseCondition(this.el.object3D,\r\n o => {\r\n if (o.el && o.el.hasAttribute(\"physx-no-collision\")) return false;\r\n if (o.el && !o.el.object3D.visible && !o.el.hasAttribute(\"physx-hidden-collision\")) return false;\r\n if (!o.visible && o.el && !o.el.hasAttribute(\"physx-hidden-collision\")) return false;\r\n if (o.userData && o.userData.vartisteUI) return false;\r\n return true\r\n },\r\n o => {\r\n if (o.geometry) {\r\n let geometry;\r\n if (false)\r\n {}\r\n else\r\n {\r\n geometry = this.createConvexMeshGeometry(o, this.el.object3D);\r\n }\r\n if (!geometry) {\r\n console.warn(\"Couldn't create geometry\", o)\r\n return;\r\n }\r\n\r\n let material, materialData;\r\n if (o.el && o.el.hasAttribute('physx-material'))\r\n {\r\n materialData = o.el.getAttribute('physx-material')\r\n }\r\n else\r\n {\r\n materialData = this.el.components['physx-material'].data\r\n }\r\n let shape = this.createShape(physics, geometry, materialData)\r\n\r\n // shape.setLocalPose({translation: this.data.shapeOffset, rotation: {w: 1, x: 0, y: 0, z: 0}})\r\n\r\n shapes.push(shape)\r\n }\r\n });\r\n\r\n this.shapes = shapes\r\n\r\n return shapes\r\n },\r\n // Turns gravity on and off\r\n toggleGravity() {\r\n this.rigidBody.setActorFlag(PhysX.PxActorFlag.eDISABLE_GRAVITY, !this.floating)\r\n this.floating = !this.floating\r\n },\r\n resetBodyPose() {\r\n this.rigidBody.setGlobalPose(PhysXUtil.object3DPhysXTransform(this.el.object3D), true)\r\n },\r\n kinematicMove() {\r\n this.rigidBody.setKinematicTarget(PhysXUtil.object3DPhysXTransform(this.el.object3D))\r\n },\r\n tock(t, dt) {\r\n if (this.rigidBody && this.data.type === 'kinematic' && !this.setKinematic)\r\n {\r\n this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, true)\r\n this.setKinematic = true\r\n }\r\n if (this.rigidBody && (this.data.type === 'kinematic' || this.el.is(\"grabbed\"))) {\r\n // this.el.object3D.scale.set(1,1,1)\r\n this.kinematicMove()\r\n }\r\n }\r\n})\r\n\r\n// Creates a driver which exerts force to return the joint to the specified\r\n// (currently only the initial) position with the given velocity\r\n// characteristics.\r\n//\r\n// This can only be used on an entity with a `physx-joint` component. Currently\r\n// only supports **D6** joint type. E.g.\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n//```\r\nAFRAME.registerComponent('physx-joint-driver', {\r\n dependencies: ['physx-joint'],\r\n multiple: true,\r\n schema: {\r\n // Which axes the joint should operate on. Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n axes: {type: 'array', default: []},\r\n\r\n // How stiff the drive should be\r\n stiffness: {default: 1.0},\r\n\r\n // Damping to apply to the drive\r\n damping: {default: 1.0},\r\n\r\n // Maximum amount of force used to get to the target position\r\n forceLimit: {default: 3.4028234663852885981170418348452e+38},\r\n\r\n // If true, will operate directly on body acceleration rather than on force\r\n useAcceleration: {default: true},\r\n\r\n // Target linear velocity relative to the joint\r\n linearVelocity: {type: 'vec3', default: {x: 0, y: 0, z: 0}},\r\n\r\n // Targget angular velocity relative to the joint\r\n angularVelocity: {type: 'vec3', default: {x: 0, y: 0, z: 0}},\r\n\r\n // If true, will automatically lock axes which are not being driven\r\n lockOtherAxes: {default: false},\r\n\r\n // If true SLERP rotation mode. If false, will use SWING mode.\r\n slerpRotation: {default: true},\r\n },\r\n events: {\r\n 'physx-jointcreated': function(e) {\r\n this.setJointDriver()\r\n }\r\n },\r\n init() {\r\n this.el.setAttribute('phsyx-custom-constraint', \"\")\r\n },\r\n setJointDriver() {\r\n if (!this.enumAxes) this.update();\r\n if (this.el.components['physx-joint'].data.type !== 'D6') {\r\n console.warn(\"Only D6 joint drivers supported at the moment\")\r\n return;\r\n }\r\n\r\n let PhysX = this.el.sceneEl.systems.physx.PhysX;\r\n this.joint = this.el.components['physx-joint'].joint\r\n\r\n if (this.data.lockOtherAxes)\r\n {\r\n this.joint.setMotion(PhysX.PxD6Axis.eX, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eY, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eZ, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING1, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING2, PhysX.PxD6Motion.eLOCKED)\r\n this.joint.setMotion(PhysX.PxD6Axis.eTWIST, PhysX.PxD6Motion.eLOCKED)\r\n }\r\n\r\n for (let enumKey of this.enumAxes)\r\n {\r\n this.joint.setMotion(enumKey, PhysX.PxD6Motion.eFREE)\r\n }\r\n\r\n let drive = new PhysX.PxD6JointDrive;\r\n drive.stiffness = this.data.stiffness;\r\n drive.damping = this.data.damping;\r\n drive.forceLimit = this.data.forceLimit;\r\n drive.setAccelerationFlag(this.data.useAcceleration);\r\n\r\n for (let axis of this.driveAxes)\r\n {\r\n this.joint.setDrive(axis, drive);\r\n }\r\n\r\n console.log(\"Setting joint driver\", this.driveAxes, this.enumAxes)\r\n\r\n this.joint.setDrivePosition({translation: {x: 0, y: 0, z: 0}, rotation: {w: 1, x: 0, y: 0, z: 0}}, true)\r\n\r\n this.joint.setDriveVelocity(this.data.linearVelocity, this.data.angularVelocity, true);\r\n },\r\n update(oldData) {\r\n if (!PhysX) return;\r\n\r\n this.enumAxes = []\r\n for (let axis of this.data.axes)\r\n {\r\n if (axis === 'swing') {\r\n this.enumAxes.push(PhysX.PxD6Axis.eSWING1)\r\n this.enumAxes.push(PhysX.PxD6Axis.eSWING2)\r\n continue\r\n }\r\n let enumKey = `e${axis.toUpperCase()}`\r\n if (!(enumKey in PhysX.PxD6Axis))\r\n {\r\n console.warn(`Unknown axis ${axis} (PxD6Axis::${enumKey})`)\r\n }\r\n this.enumAxes.push(PhysX.PxD6Axis[enumKey])\r\n }\r\n\r\n this.driveAxes = []\r\n\r\n for (let axis of this.data.axes)\r\n {\r\n if (axis === 'swing') {\r\n if (this.data.slerpRotation)\r\n {\r\n this.driveAxes.push(PhysX.PxD6Drive.eSLERP)\r\n }\r\n else\r\n {\r\n this.driveAxes.push(PhysX.PxD6Drive.eSWING)\r\n }\r\n continue\r\n }\r\n\r\n if (axis === 'twist' && this.data.slerpRotation) {\r\n this.driveAxes.push(PhysX.PxD6Drive.eSLERP)\r\n continue;\r\n }\r\n\r\n let enumKey = `e${axis.toUpperCase()}`\r\n if (!(enumKey in PhysX.PxD6Drive))\r\n {\r\n console.warn(`Unknown axis ${axis} (PxD6Axis::${enumKey})`)\r\n }\r\n this.driveAxes.push(PhysX.PxD6Drive[enumKey])\r\n }\r\n }\r\n})\r\n\r\n// Adds a constraint to a [`physx-joint`](#physx-joint). Currently only **D6**\r\n// joints are supported.\r\n//\r\n// Can only be used on an entity with the `physx-joint` component. You can set\r\n// multiple constraints per joint. Note that in order to specify attributes of\r\n// individual axes, you will need to use multiple constraints. For instance:\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// In the above example, the box will be able to move from -1 to 20 in both the\r\n// x and z direction. It will be able to move from 0 to 3 in the y direction,\r\n// but this will be a soft constraint, subject to spring forces if the box goes\r\n// past in the y direction. All rotation will be locked. (Note that since no\r\n// target is specified, it will use the scene default target, effectively\r\n// jointed to joint's initial position in the world)\r\nAFRAME.registerComponent('physx-joint-constraint', {\r\n multiple: true,\r\n schema: {\r\n // Which axes are explicitly locked by this constraint and can't be moved at all.\r\n // Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n lockedAxes: {type: 'array', default: []},\r\n\r\n // Which axes are constrained by this constraint. These axes can be moved within the set limits.\r\n // Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n constrainedAxes: {type: 'array', default: []},\r\n\r\n // Which axes are explicitly freed by this constraint. These axes will not obey any limits set here.\r\n // Should be some combination of `x`, `y`, `z`, `twist`, `swing`\r\n freeAxes: {type: 'array', default: []},\r\n\r\n // Limit on linear movement. Only affects `x`, `y`, and `z` axes.\r\n // First vector component is the minimum allowed position\r\n linearLimit: {type: 'vec2'},\r\n\r\n // Two angles specifying a cone in which the joint is allowed to swing, like\r\n // a pendulum.\r\n limitCone: {type: 'vec2'},\r\n\r\n // Minimum and maximum angles that the joint is allowed to twist\r\n twistLimit: {type: 'vec2'},\r\n\r\n // Spring damping for soft constraints\r\n damping: {default: 0.0},\r\n // Spring restitution for soft constraints\r\n restitution: {default: 0.0},\r\n // If greater than 0, will make this joint a soft constraint, and use a\r\n // spring force model\r\n stiffness: {default: 0.0},\r\n },\r\n events: {\r\n 'physx-jointcreated': function(e) {\r\n this.setJointConstraint()\r\n }\r\n },\r\n init() {\r\n this.el.setAttribute('phsyx-custom-constraint', \"\")\r\n },\r\n setJointConstraint() {\r\n if (this.el.components['physx-joint'].data.type !== 'D6') {\r\n console.warn(\"Only D6 joint constraints supported at the moment\")\r\n return;\r\n }\r\n\r\n if (!this.constrainedAxes) this.update();\r\n\r\n let joint = this.el.components['physx-joint'].joint;\r\n\r\n let llimit = () => {\r\n let l = new PhysX.PxJointLinearLimitPair(new PhysX.PxTolerancesScale(), this.data.linearLimit.x, this.data.linearLimit.y);\r\n l.stiffness = this.data.stiffness;\r\n l.damping = this.data.damping;\r\n // Setting stiffness automatically sets restitution to the same value.\r\n // Is it correct, then to override with default restitution value of 0, even if\r\n // no restitution value was specified?\r\n // Not sure - but commenting out this line doesn't help with problems observed with spring behaviour.\r\n // Seem spring.html example.\r\n l.restitution = this.data.restitution;\r\n return l\r\n }\r\n\r\n for (let axis of this.freeAxes)\r\n {\r\n joint.setMotion(axis, PhysX.PxD6Motion.eFREE)\r\n }\r\n\r\n for (let axis of this.lockedAxes)\r\n {\r\n joint.setMotion(axis, PhysX.PxD6Motion.eLOCKED)\r\n }\r\n\r\n for (let axis of this.constrainedAxes)\r\n {\r\n if (axis === PhysX.PxD6Axis.eX || axis === PhysX.PxD6Axis.eY || axis === PhysX.PxD6Axis.eZ)\r\n {\r\n joint.setMotion(axis, PhysX.PxD6Motion.eLIMITED)\r\n joint.setLinearLimit(axis, llimit())\r\n continue;\r\n }\r\n\r\n if (axis === PhysX.eTWIST)\r\n {\r\n joint.setMotion(PhysX.PxD6Axis.eTWIST, PhysX.PxD6Motion.eLIMITED)\r\n let pair = new PhysX.PxJointAngularLimitPair(this.data.limitTwist.x, this.data.limitTwist.y)\r\n pair.stiffness = this.data.stiffness\r\n pair.damping = this.data.damping\r\n pair.restitution = this.data.restitution\r\n joint.setTwistLimit(pair)\r\n continue;\r\n }\r\n\r\n joint.setMotion(axis, PhysX.PxD6Motion.eLIMITED)\r\n let cone = new PhysX.PxJointLimitCone(this.data.limitCone.x, this.data.limitCone.y)\r\n cone.damping = this.data.damping\r\n cone.stiffness = this.data.stiffness\r\n cone.restitution = this.data.restitution\r\n joint.setSwingLimit(cone)\r\n }\r\n },\r\n update(oldData) {\r\n if (!PhysX) return;\r\n\r\n this.constrainedAxes = PhysXUtil.axisArrayToEnums(this.data.constrainedAxes)\r\n this.lockedAxes = PhysXUtil.axisArrayToEnums(this.data.lockedAxes)\r\n this.freeAxes = PhysXUtil.axisArrayToEnums(this.data.freeAxes)\r\n }\r\n})\r\n\r\n// Creates a PhysX joint between an ancestor rigid body and a target rigid body.\r\n//\r\n// The physx-joint is designed to be used either on or within an entity with the\r\n// `physx-body` component. For instance:\r\n//\r\n// ```\r\n// \r\n// \r\n// \r\n// ```\r\n//\r\n// The position and rotation of the `physx-joint` will be used to create the\r\n// corresponding PhysX joint object. Multiple joints can be created on a body,\r\n// and multiple joints can target a body.\r\n//\r\n// **Stapler Example**\r\n//\r\n// Here's a simplified version of the stapler from the [physics playground demo]()\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// Notice the joint is created between the top part of the stapler (which\r\n// contains the joint) and the bottom part of the stapler at the position of the\r\n// `physx-joint` component's entitiy. This will be the pivot point for the\r\n// stapler's rotation.\r\n//\r\n// ![Stapler with joint highlighted](./static/images/staplerjoint.png)\r\nAFRAME.registerComponent('physx-joint', {\r\n multiple: true,\r\n schema: {\r\n // Rigid body joint type to use. See the [NVIDIA PhysX joint\r\n // documentation](https://gameworksdocs.nvidia.com/PhysX/4.0/documentation/PhysXGuide/Manual/Joints.html)\r\n // for details on each type\r\n type: {default: \"Spherical\", oneOf: [\"Fixed\", \"Spherical\", \"Distance\", \"Revolute\", \"Prismatic\", \"D6\"]},\r\n\r\n // Target object. If specified, must be an entity having the `physx-body`\r\n // component. If no target is specified, a scene default target will be\r\n // used, essentially joining the joint to its initial position in the world.\r\n target: {type: 'selector'},\r\n\r\n // Force needed to break the constraint. First component is the linear force, second component is angular force. Set both components are >= 0\r\n breakForce: {type: 'vec2', default: {x: -1, y: -1}},\r\n\r\n // If true, removes the entity containing this component when the joint is\r\n // broken.\r\n removeElOnBreak: {default: false},\r\n\r\n // If false, collision will be disabled between the rigid body containing\r\n // the joint and the target rigid body.\r\n collideWithTarget: {default: false},\r\n\r\n // When used with a D6 type, sets up a \"soft\" fixed joint. E.g., for grabbing things\r\n softFixed: {default: false},\r\n },\r\n events: {\r\n constraintbreak: function(e) {\r\n if (this.data.removeElOnBreak) {\r\n this.el.remove()\r\n }\r\n }\r\n },\r\n init() {\r\n this.system = this.el.sceneEl.systems.physx\r\n\r\n let parentEl = this.el\r\n\r\n while (parentEl && !parentEl.hasAttribute('physx-body'))\r\n {\r\n parentEl = parentEl.parentEl\r\n }\r\n\r\n if (!parentEl) {\r\n console.warn(\"physx-joint must be used within a physx-body\")\r\n return;\r\n }\r\n\r\n this.bodyEl = parentEl\r\n\r\n this.worldHelper = new THREE.Object3D;\r\n this.worldHelperParent = new THREE.Object3D;\r\n this.el.sceneEl.object3D.add(this.worldHelperParent);\r\n this.targetScale = new THREE.Vector3(1,1,1)\r\n this.worldHelperParent.add(this.worldHelper)\r\n\r\n if (!this.data.target) {\r\n this.data.target = this.system.defaultTarget\r\n }\r\n\r\n\r\n Util.whenLoaded([this.el, this.bodyEl, this.data.target], () => {\r\n this.createJoint()\r\n })\r\n },\r\n remove() {\r\n if (this.joint) {\r\n this.joint.release();\r\n this.joint = null;\r\n this.bodyEl.components['physx-body'].rigidBody.wakeUp()\r\n if (this.data.target.components['physx-body'].rigidBody.wakeUp) this.data.target.components['physx-body'].rigidBody.wakeUp()\r\n }\r\n },\r\n update() {\r\n if (!this.joint) return;\r\n\r\n if (this.data.breakForce.x >= 0 && this.data.breakForce.y >= 0)\r\n {\r\n this.joint.setBreakForce(this.data.breakForce.x, this.data.breakForce.y);\r\n }\r\n\r\n this.joint.setConstraintFlag(PhysX.PxConstraintFlag.eCOLLISION_ENABLED, this.data.collideWithTarget)\r\n\r\n if (this.el.hasAttribute('phsyx-custom-constraint')) return;\r\n\r\n switch (this.data.type)\r\n {\r\n case 'D6':\r\n {\r\n if (this.data.softFixed)\r\n {\r\n this.joint.setMotion(PhysX.PxD6Axis.eX, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eY, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eZ, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING1, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eSWING2, PhysX.PxD6Motion.eFREE)\r\n this.joint.setMotion(PhysX.PxD6Axis.eTWIST, PhysX.PxD6Motion.eFREE)\r\n\r\n let drive = new PhysX.PxD6JointDrive;\r\n drive.stiffness = 1000;\r\n drive.damping = 500;\r\n drive.forceLimit = 1000;\r\n drive.setAccelerationFlag(false);\r\n this.joint.setDrive(PhysX.PxD6Drive.eX, drive);\r\n this.joint.setDrive(PhysX.PxD6Drive.eY, drive);\r\n this.joint.setDrive(PhysX.PxD6Drive.eZ, drive);\r\n // this.joint.setDrive(PhysX.PxD6Drive.eSWING, drive);\r\n // this.joint.setDrive(PhysX.PxD6Drive.eTWIST, drive);\r\n this.joint.setDrive(PhysX.PxD6Drive.eSLERP, drive);\r\n this.joint.setDrivePosition({translation: {x: 0, y: 0, z: 0}, rotation: {w: 1, x: 0, y: 0, z: 0}}, true)\r\n this.joint.setDriveVelocity({x: 0.0, y: 0.0, z: 0.0}, {x: 0, y: 0, z: 0}, true);\r\n }\r\n }\r\n break;\r\n }\r\n },\r\n getTransform(el) {\r\n Util.positionObject3DAtTarget(this.worldHelperParent, el.object3D, {scale: this.targetScale})\r\n\r\n Util.positionObject3DAtTarget(this.worldHelper, this.el.object3D, {scale: this.targetScale});\r\n\r\n let transform = PhysXUtil.matrixToTransform(this.worldHelper.matrix);\r\n\r\n return transform;\r\n },\r\n async createJoint() {\r\n await Util.whenComponentInitialized(this.bodyEl, 'physx-body')\r\n await Util.whenComponentInitialized(this.data.target, 'physx-body')\r\n await this.bodyEl.components['physx-body'].physxRegisteredPromise;\r\n await this.data.target.components['physx-body'].physxRegisteredPromise;\r\n\r\n if (this.joint) {\r\n this.joint.release();\r\n this.joint = null;\r\n }\r\n\r\n let thisTransform = this.getTransform(this.bodyEl);\r\n let targetTransform = this.getTransform(this.data.target);\r\n\r\n this.joint = PhysX[`Px${this.data.type}JointCreate`](this.system.physics,\r\n this.bodyEl.components['physx-body'].rigidBody, thisTransform,\r\n this.data.target.components['physx-body'].rigidBody, targetTransform,\r\n )\r\n this.system.registerJoint(this.joint, this)\r\n this.update();\r\n this.el.emit('physx-jointcreated', this.joint)\r\n }\r\n})\r\n\r\n\r\nAFRAME.registerSystem('physx-contact-event', {\r\n init() {\r\n this.worldHelper = new THREE.Object3D;\r\n this.el.sceneEl.object3D.add(this.worldHelper)\r\n }\r\n})\r\n\r\n// Emits a `contactevent` event when a collision meets the threshold. This\r\n// should be set on an entity with the `physx-body` component. The event detail\r\n// will contain these fields:\r\n// - `impulse`: The summed impulse of at all contact points\r\n// - `contact`: The originating contact event\r\nAFRAME.registerComponent('physx-contact-event', {\r\n dependencies: ['physx-body'],\r\n schema: {\r\n // Minimum total impulse threshold to emit the event\r\n impulseThreshold: {default: 0.01},\r\n\r\n // NYI\r\n maxDistance: {default: 10.0},\r\n // NYI\r\n maxDuration: {default: 5.0},\r\n\r\n // Delay after start of scene before emitting events. Useful to avoid a\r\n // zillion events as objects initially settle on the ground\r\n startDelay: {default: 6000},\r\n\r\n // If `true`, the event detail will include a `positionWorld` property which contains the weighted averaged location\r\n // of all contact points. Contact points are weighted by impulse amplitude.\r\n positionAtContact: {default: false},\r\n },\r\n events: {\r\n contactbegin: function(e) {\r\n if (this.el.sceneEl.time < this.data.startDelay) return\r\n let thisWorld = this.eventDetail.positionWorld;\r\n let cameraWorld = this.pool('cameraWorld', THREE.Vector3);\r\n\r\n let impulses = e.detail.impulses\r\n let impulseSum = 0\r\n for (let i = 0; i < impulses.size(); ++i)\r\n {\r\n impulseSum += impulses.get(i)\r\n }\r\n\r\n if (impulseSum < this.data.impulseThreshold) return;\r\n\r\n thisWorld.set(0, 0, 0)\r\n let impulse = 0.0;\r\n if (this.data.positionAtContact)\r\n {\r\n for (let i = 0; i < impulses.size(); ++i)\r\n {\r\n impulse = impulses.get(i);\r\n let position = e.detail.points.get(i);\r\n thisWorld.x += position.x * impulse;\r\n thisWorld.y += position.y * impulse;\r\n thisWorld.z += position.z * impulse;\r\n }\r\n thisWorld.multiplyScalar(1.0 / impulseSum)\r\n this.system.worldHelper.position.copy(thisWorld)\r\n Util.positionObject3DAtTarget(this.localHelper, this.system.worldHelper)\r\n this.eventDetail.position.copy(this.localHelper.position)\r\n }\r\n else\r\n {\r\n thisWorld.set(0, 0, 0)\r\n this.eventDetail.position.set(0, 0, 0)\r\n }\r\n\r\n this.eventDetail.impulse = impulseSum\r\n this.eventDetail.contact = e.detail\r\n\r\n this.el.emit('contactevent', this.eventDetail)\r\n }\r\n },\r\n init() {\r\n VARTISTE.Pool.init(this)\r\n\r\n this.eventDetail = {\r\n impulse: 0.0,\r\n positionWorld: new THREE.Vector3(),\r\n position: new THREE.Vector3(),\r\n contact: null,\r\n }\r\n\r\n if (this.data.debug) {\r\n let vis = document.createElement('a-entity')\r\n vis.setAttribute('geometry', 'primitive: sphere; radius: 0.1')\r\n vis.setAttribute('physx-no-collision', '')\r\n }\r\n\r\n this.localHelper = new THREE.Object3D();\r\n this.el.object3D.add(this.localHelper)\r\n\r\n this.el.setAttribute('physx-body', 'emitCollisionEvents', true)\r\n },\r\n remove() {\r\n this.el.object3D.remove(this.localHelper)\r\n }\r\n})\r\n\r\n// Plays a sound when a `physx-body` has a collision.\r\nAFRAME.registerComponent('physx-contact-sound', {\r\n dependencies: ['physx-contact-event'],\r\n schema: {\r\n // Sound file location or asset\r\n src: {type: 'string'},\r\n\r\n // Minimum total impulse to play the sound\r\n impulseThreshold: {default: 0.01},\r\n\r\n // NYI\r\n maxDistance: {default: 10.0},\r\n // NYI\r\n maxDuration: {default: 5.0},\r\n\r\n // Delay after start of scene before playing sounds. Useful to avoid a\r\n // zillion sounds playing as objects initially settle on the ground\r\n startDelay: {default: 6000},\r\n\r\n // If `true`, the sound will be positioned at the weighted averaged location\r\n // of all contact points. Contact points are weighted by impulse amplitude.\r\n // If `false`, the sound will be positioned at the entity's origin.\r\n positionAtContact: {default: false},\r\n },\r\n events: {\r\n contactevent: function(e) {\r\n if (this.data.positionAtContact)\r\n {\r\n this.sound.object3D.position.copy(e.detail.position)\r\n }\r\n\r\n this.sound.components.sound.stopSound();\r\n this.sound.components.sound.playSound();\r\n },\r\n },\r\n init() {\r\n let sound = document.createElement('a-entity')\r\n this.el.append(sound)\r\n sound.setAttribute('sound', {src: this.data.src})\r\n this.sound = sound\r\n\r\n this.el.setAttribute('physx-body', 'emitCollisionEvents', true)\r\n },\r\n update(oldData) {\r\n this.el.setAttribute('physx-contact-event', this.data)\r\n }\r\n})\r\n\r\n// Creates A-Frame entities from gltf custom properties.\r\n//\r\n// **WARNING** do not use this component with untrusted gltf models, since it\r\n// will let the model access arbitrary components.\r\n//\r\n// Should be set on an entity with the `gltf-model` component. Once the model is\r\n// loaded, this will traverse the object tree, and any objects containing user\r\n// data key `a-entity` will be turned into separate sub-entities. The user data\r\n// value for `a-entity` will be set as the attributes.\r\n//\r\n// For instance, say you export a model with the following kind of structure\r\n// from Blender (remembering to check \"Include → Custom Properties\"!):\r\n//\r\n//```\r\n// - Empty1\r\n// Custom Properties:\r\n// name: a-entity\r\n// value: physx-body=\"type: dynamic\"\r\n// Children:\r\n// - Mesh1\r\n// Custom Properties:\r\n// name: a-entity\r\n// value: physx-material=\"density: 30\" class=\"clickable\"\r\n// Children:\r\n// - Mesh2\r\n// - Mesh3\r\n// Custom Properties:\r\n// name: a-entity\r\n// value: physx-material=\"density: 100\" physx-contact-sound=\"src: #boom\"\r\n//```\r\n//\r\n// ![Screenshot showing the structure in Blender](./static/images/blenderentities.png)\r\n//\r\n// This will turn into the following HTML (with `setId` set to `true`):\r\n//\r\n//```\r\n// \r\n// \r\n// \r\n// \r\n//```\r\n//\r\n// **Experimental Blender Plugin**\r\n//\r\n// ![Screenshot showing experimental blender plugin](./static/images/blenderplugin.png)\r\n//\r\n// I've written a small plugin for [Blender](https://www.blender.org/) which can\r\n// automatically set up a lot of the common properties for use in this physics\r\n// system. _Note that it is super experimental and under development. Make a\r\n// backup before using._\r\n//\r\n// **Download Blender Plugin:** vartiste_toolkit_entity_helper.zip (v0.2.0)\r\n//\r\n// **GLB Viewer**\r\n//\r\n// You can test your `gltf-entities` enabled glb files locally by dragging and\r\n// dropping them into this [web viewer](https://fascinated-hip-period.glitch.me/viewer.html)\r\nAFRAME.registerComponent('gltf-entities', {\r\n dependencies: ['gltf-model'],\r\n schema: {\r\n // If true, will set created element's id based on the gltf object name\r\n setId: {default: false},\r\n // If `setId` is true, this will be prepended to the gltf object name when setting the element id\r\n idPrefix: {default: \"\"},\r\n\r\n // Automatically make entities clickable and propogate the grab (for use with [`manipulator`](#manipulator))\r\n autoPropogateGrab: {default: true},\r\n\r\n // Array of attribute names that should be copied from this entitiy to any new created entitity\r\n copyAttributes: {type: 'array'},\r\n\r\n // A list of names of attributes that are allowed to be set. Ignored if empty.\r\n allowedAttributes: {type: 'array'},\r\n },\r\n events: {\r\n 'model-loaded': function(e) {\r\n this.setupEntities()\r\n }\r\n },\r\n init() {},\r\n setupEntities() {\r\n let root = this.el.getObject3D('mesh')\r\n if (!root) return;\r\n\r\n this.setupObject(root, this.el)\r\n },\r\n setupObject(obj3d, currentRootEl)\r\n {\r\n if (obj3d.userData['a-entity']) {\r\n let el = document.createElement('a-entity')\r\n let attrs = obj3d.userData['a-entity']\r\n\r\n // sanitize\r\n el.innerHTML = attrs\r\n el.innerHTML = ``\r\n\r\n el = el.children[0]\r\n\r\n if (this.data.allowedAttributes.length)\r\n {\r\n for (let attr of el.attributes)\r\n {\r\n if (!this.data.allowedAttributes.includes(attr.name))\r\n {\r\n el.removeAttribute(attr.name)\r\n }\r\n }\r\n }\r\n\r\n if (this.data.setId && obj3d.name)\r\n {\r\n el.id = `${this.data.idPrefix}${obj3d.name}`\r\n }\r\n\r\n for (let attribute of this.data.copyAttributes)\r\n {\r\n if (this.el.hasAttribute(attribute))\r\n {\r\n el.setAttribute(attribute, this.el.getAttribute(attribute))\r\n }\r\n }\r\n\r\n if (this.data.autoPropogateGrab && this.el.classList.contains(\"clickable\"))\r\n {\r\n el.setAttribute('propogate-grab', \"\")\r\n el.classList.add(\"clickable\")\r\n }\r\n\r\n currentRootEl.append(el)\r\n Util.whenLoaded(el, () => {\r\n el.setObject3D('mesh', obj3d)\r\n obj3d.updateMatrix()\r\n Util.applyMatrix(obj3d.matrix, el.object3D)\r\n obj3d.matrix.identity()\r\n Util.applyMatrix(obj3d.matrix, obj3d)\r\n })\r\n currentRootEl = el\r\n }\r\n\r\n for (let child of obj3d.children)\r\n {\r\n this.setupObject(child, currentRootEl)\r\n }\r\n }\r\n})\r\n\n\n//# sourceURL=webpack://@c-frame/physx/./src/physics.js?"); /***/ }), diff --git a/dist/physx.min.js b/dist/physx.min.js index 725236d..d017da2 100644 --- a/dist/physx.min.js +++ b/dist/physx.min.js @@ -1 +1 @@ -(()=>{var e={261:()=>{AFRAME.registerComponent("stats-panel",{schema:{merge:{type:"boolean",default:!0}},init(){const e=document.querySelector(".rs-container");if(e&&this.data.merge)return void(this.container=e);this.base=document.createElement("div"),this.base.classList.add("rs-base");const t=document.body||document.getElementsByTagName("body")[0];e&&!this.data.merge&&(this.base.style.top="auto",this.base.style.bottom="20px"),t.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 e;const t=this.el.components["stats-panel"];e=t?t.container:document.querySelector(".rs-container"),e?(this.groupHeader=document.createElement("h1"),this.groupHeader.innerHTML=this.data.label,e.appendChild(this.groupHeader),this.group=document.createElement("div"),this.group.classList.add("rs-group"),this.group.style.flexDirection="column",this.group.style.webKitFlexDirection="column",e.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 e="stats-group__"+this.data.group,t=this.el.components[e]||this.el.sceneEl.components[e]||this.el.components["stats-group"]||this.el.sceneEl.components["stats-group"];t?(this.counter=document.createElement("div"),this.counter.classList.add("rs-counter-base"),t.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((e=>{const t=document.createElement("div");t.classList.add("rs-counter-value"),t.innerHTML="...",this.counter.appendChild(t),this.counterValues[e]=t})),this.updateData=this.updateData.bind(this),this.el.addEventListener(this.data.event,this.updateData),this.splitCache={}):console.warn(`Couldn't find stats group ${e}`)},updateData(e){this.data.properties.forEach((t=>{const n=this.splitDot(t);let r=e.detail;for(i=0;i{this.outputDetail[e]={}})),this.statsReceived=this.statsReceived.bind(this),this.el.addEventListener(this.data.inEvent,this.statsReceived)},resetData(){this.counter=0,this.data.properties.forEach((e=>{this.statsData[e]=[]}))},statsReceived(e){this.updateData(e.detail),this.counter++,this.counter===this.data.outputFrequency&&(this.outputData(),this.resetData())},updateData(e){this.data.properties.forEach((t=>{let i=e;i=i[t],this.statsData[t].push(i)}))},outputData(){this.data.properties.forEach((e=>{this.data.outputs.forEach((t=>{this.outputDetail[e][t]=this.computeOutput(t,this.statsData[e])}))})),this.data.outEvent&&this.el.emit(this.data.outEvent,this.outputDetail),this.data.outputToConsole&&console.log(this.data.outputToConsole,this.outputDetail)},computeOutput(e,t){const i=e.split("__");let n;switch(i[0]){case"mean":n=t.reduce(((e,t)=>e+t),0)/t.length;break;case"max":n=Math.max(...t);break;case"min":n=Math.min(...t);break;case"percentile":const e=t.sort(((e,t)=>e-t)),r=+i[1].replace("_",".")/100,o=(t.length-1)*r,s=Math.floor(o),a=o-s;n=void 0!==e[s+1]?e[s]+a*(e[s+1]-e[s]):e[s]}return n.toFixed(2)}})},590:(e,t,i)=>{let n=i(651);function r(e,t){return this.system._pool[e]||(this.system._pool[e]=new t),this.system._pool[e]}function o(e,t){return this._pool[e]||(this._pool[e]=new t),this._pool[e]}function s(e,t){e.hasLoaded?t():e.addEventListener("loaded",t)}function a(e){return new Promise(((t,i)=>s(e,t)))}Util={},class{static init(e,{useSystem:t=!1}={}){t?(e.system||console.error("No system for system pool",e.attrName),e.system._pool||(e.system._pool={}),e.pool=r):(e._pool={},e.pool=o)}}.init(Util),Util.applyMatrix=function(e,t){t.matrix.copy(e),e.decompose(t.position,t.rotation,t.scale)},Util.traverseCondition=function(e,t,i){if(t(e)){i(e);for(let n of e.children)this.traverseCondition(n,t,i)}},Util.positionObject3DAtTarget=function(e,t,{scale:i,transformOffset:n,transformRoot:r}={}){void 0===r&&(r=e.parent),t.updateWorldMatrix();let o=this.pool("dest",THREE.Matrix4);if(o.copy(t.matrixWorld),n){let e=this.pool("transformMat",THREE.Matrix4);e.makeTranslation(n.x,n.y,n.z),o.multiply(e)}if(i){let e=this.pool("scale",THREE.Vector3);e.setFromMatrixScale(o),e.set(i.x/e.x,i.y/e.y,i.z/e.z),o.scale(e)}let s=this.pool("inv",THREE.Matrix4);r.updateWorldMatrix(),s.copy(r.matrixWorld).invert(),o.premultiply(s),Util.applyMatrix(o,e)},Util.whenLoaded=function(e,t){return Array.isArray(e)&&t?function(e,t){let i=e.map((()=>!1));for(let n=0;n{i[r]=!0,i.every((e=>e))&&t()}))}}(e,t):Array.isArray(e)?async function(e){for(let t of e)await a(t)}(e):t?s(e,t):a(e)},Util.whenComponentInitialized=function(e,t,i){return e&&e.components[t]&&e.components[t].initialized?Promise.resolve(i?i():void 0):new Promise(((n,r)=>{if(e&&e.components[t]&&e.components[t].initialized)return Promise.resolve(i?i():void 0);let o=r=>{r.detail.name===t&&(e.removeEventListener("componentinitialized",o),i&&i(),n())};e.addEventListener("componentinitialized",o)}))};const c={object3DPhysXTransform:(()=>{let e=new THREE.Vector3,t=new THREE.Quaternion;return function(i){return i.getWorldPosition(e),i.getWorldQuaternion(t),{translation:{x:e.x,y:e.y,z:e.z},rotation:{w:t.w,x:t.x,y:t.y,z:t.z}}}})(),matrixToTransform:(()=>{let e=new THREE.Vector3,t=new THREE.Quaternion,i=new THREE.Vector3;return new THREE.Matrix4,new THREE.Matrix4,function(n){return n.decompose(e,t,i),{translation:{x:e.x,y:e.y,z:e.z},rotation:{w:t.w,x:t.x,y:t.y,z:t.z}}}})(),layersToMask:(()=>{let e=new THREE.Layers;return function(t){e.disableAll();for(let i of t)e.enable(parseInt(i));return e.mask}})(),axisArrayToEnums:function(e){let t=[];for(let i of e){if("swing"===i){t.push(d.PxD6Axis.eSWING1),t.push(d.PxD6Axis.eSWING2);continue}let e=`e${i.toUpperCase()}`;e in d.PxD6Axis||console.warn(`Unknown axis ${i} (PxD6Axis::${e})`),t.push(d.PxD6Axis[e])}return t}};let d;AFRAME.registerSystem("physx",{schema:{delay:{default:5e3},throttle:{default:10},autoLoad:{default:!1},speed:{default:1},wasmUrl:{default:"https://cdn.jsdelivr.net/gh/c-frame/physx/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 e=document.createElement("a-entity");this.el.append(e),this.defaultTarget=e,this.initializePhysX=new Promise(((e,t)=>{this.fulfillPhysXPromise=e})),this.initStats(),this.el.addEventListener("inspectortoggle",(e=>{console.log("Inspector toggle",e),!0===e.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 e=this.el.sceneEl,t="   ";e.setAttribute("stats-panel",""),e.setAttribute("stats-group__bodies","label: Physics Bodies"),e.setAttribute("stats-row__b1","group: bodies;\n event:physics-body-data;\n properties: staticBodies;\n label: Static"),e.setAttribute("stats-row__b2","group: bodies;\n event:physics-body-data;\n properties: dynamicBodies;\n label: Dynamic"),e.setAttribute("stats-row__b3","group: bodies;\n event:physics-body-data;\n properties: kinematicBodies;\n label: Kinematic"),e.setAttribute("stats-group__tick",`label: Physics Ticks: Median${t}90th%${t}99th%`),e.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"),e.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"),e.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 e,t=this,i=new Promise(((t,i)=>e=t));d=n({locateFile:()=>t.findWasm(),onRuntimeInitialized(){e()}}),d instanceof Promise&&(d=await d),this.PhysX=d,await i,t.startPhysXScene(),t.physXInitialized=!0,t.fulfillPhysXPromise(),t.el.emit("physx-started",{})},startPhysXScene(){console.info("Starting PhysX scene");const e=d.PxCreateFoundation(d.PX_PHYSICS_VERSION,new d.PxDefaultAllocator,new d.PxDefaultErrorCallback);this.foundation=e;const t=d.PxSimulationEventCallback.implement({onContactBegin:(e,t,i,n)=>{let r=this.shapeMap.get(e.$$.ptr),o=this.shapeMap.get(t.$$.ptr);o!==r&&(r&&r.data.emitCollisionEvents&&(this.collisionObject.thisShape=e,this.collisionObject.otherShape=t,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=t,this.collisionObject.otherShape=e,this.collisionObject.points=i,this.collisionObject.impulses=n,this.collisionObject.otherComponent=r,o.el.emit("contactbegin",this.collisionObject)))},onContactEnd:(e,t)=>{let i=this.shapeMap.get(e.$$.ptr),n=this.shapeMap.get(t.$$.ptr);n!==i&&(i&&i.data.emitCollisionEvents&&(this.collisionObject.thisShape=e,this.collisionObject.otherShape=t,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=t,this.collisionObject.otherShape=e,this.collisionObject.points=null,this.collisionObject.impulses=null,this.collisionObject.otherComponent=i,n.el.emit("contactend",this.collisionObject)))},onContactPersist:()=>{},onTriggerBegin:()=>{},onTriggerEnd:()=>{},onConstraintBreak:e=>{let t=this.jointMap.get(e.$$.ptr);t&&t.el.emit("constraintbreak",{})}});let i=new d.PxTolerancesScale;this.physics=d.PxCreatePhysics(d.PX_PHYSICS_VERSION,e,i,!1,null),d.PxInitExtensions(this.physics,null),this.cooking=d.PxCreateCooking(d.PX_PHYSICS_VERSION,e,new d.PxCookingParams(i));const n=d.getDefaultSceneDesc(this.physics.getTolerancesScale(),0,t);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 e=new d.PxPlaneGeometry,t=this.physics.createMaterial(.8,.8,.1);const i=this.physics.createShape(e,t,!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 e=new d.PxPlaneGeometry,t=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(e,t,!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(e,{type:t}){await this.initializePhysX;const i=c.object3DPhysXTransform(e.el.object3D);let n;n="dynamic"===t||"kinematic"===t?this.physics.createRigidDynamic(i):this.physics.createRigidStatic(i);let r=!0,o=!1,s=new d.VectorPxReal;for(let t of e.createShapes(this.physics,this.defaultActorFlags))n.attachShape(t),isFinite(t.density)?(o=!0,s.push_back(t.density)):(r=!1,o&&console.warn("Densities not set for all shapes. Will use total mass instead.",e.el));"dynamic"!==t&&"kinematic"!==t||(r&&o?(console.log("Setting density vector",s),n.updateMassAndInertia(s)):n.setMassAndUpdateInertia(e.data.mass)),s.delete(),this.scene.addActor(n,null),this.objects.set(e.el.object3D,n),e.rigidBody=n},registerShape(e,t){this.shapeMap.set(e.$$.ptr,t)},registerJoint(e,t){this.jointMap.set(e.$$.ptr,t)},removeBody(e){let t=e.rigidBody;this.objects.delete(e.el.object3D),t.release()},tock(e,t){if(e{const n=i.el.components["physx-body"].data.type,r=this.bodyTypeToStatsPropertyMap[n];e[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(e){"grabbed"===e.detail&&this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eKINEMATIC,!0)},stateremoved:function(e){"grabbed"===e.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(e){this.toggleGravity()},componentchanged:function(e){"physx-material"===e.name&&this.el.emit("object3dset",{})},object3dset:function(e){if(this.rigidBody){for(let e of this.shapes)this.rigidBody.detachShape(e,!1);let e=!0,t=!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)?(t=!0,i.push_back(r.density)):(e=!1,t&&console.warn("Densities not set for all shapes. Will use total mass instead.",n.el));"dynamic"!==r&&"kinematic"!==r||(e&&t?(console.log("Setting density vector",i),o.updateMassAndInertia(i)):o.setMassAndUpdateInertia(n.data.mass))}},contactbegin:function(e){}},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(e){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&&(this.rigidBody.setSolverIterationCounts(4,2),this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eENABLE_CCD,!0))),e&&this.data.mass===e.mass||this.el.emit("object3dset",{}))},remove(){this.rigidBody&&this.system.removeBody(this)},createGeometry(e){if(e.el.hasAttribute("geometry")){let t=e.el.getAttribute("geometry");switch(t.primitive){case"sphere":return new d.PxSphereGeometry(t.radius*this.el.object3D.scale.x*.98);case"box":return new d.PxBoxGeometry(t.width/2,t.height/2,t.depth/2);default:return this.createConvexMeshGeometry(e.el.getObject3D("mesh"))}}},createConvexMeshGeometry(e,t){let i=new d.PxVec3Vector,n=e.geometry.attributes.position;if(!n)return;if(n.count<3)return;if(3!=n.itemSize)return;let r=new THREE.Vector3;if(t){let o=new THREE.Matrix4;e.updateMatrix(),o.copy(e.matrix);let s=e.parent;for(;s&&s!==t;)s.updateMatrix(),o.premultiply(s.matrix),s=s.parent;for(let e=0;e=0&&r.setContactOffset(i.contactOffset),i.restOffset>=0&&r.setRestOffset(i.restOffset),r.density=i.density,this.system.registerShape(r,this),r},createShapes(e){if(this.el.hasAttribute("geometry")){let t=this.createGeometry(this.el.object3D);if(!t)return;let i=this.el.components["physx-material"].data;return this.shapes=[this.createShape(e,t,i)],this.shapes}let t=[];return Util.traverseCondition(this.el.object3D,(e=>!(e.el&&e.el.hasAttribute("physx-no-collision")||e.el&&!e.el.object3D.visible&&!e.el.hasAttribute("physx-hidden-collision")||!e.visible&&e.el&&!e.el.hasAttribute("physx-hidden-collision")||e.userData&&e.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(e,n,r);t.push(o)}})),this.shapes=t,t},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(e,t){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(e){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 e=this.el.sceneEl.systems.physx.PhysX;this.joint=this.el.components["physx-joint"].joint,this.data.lockOtherAxes&&(this.joint.setMotion(e.PxD6Axis.eX,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eY,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eZ,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eSWING1,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eSWING2,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eTWIST,e.PxD6Motion.eLOCKED));for(let t of this.enumAxes)this.joint.setMotion(t,e.PxD6Motion.eFREE);let t=new e.PxD6JointDrive;t.stiffness=this.data.stiffness,t.damping=this.data.damping,t.forceLimit=this.data.forceLimit,t.setAccelerationFlag(this.data.useAcceleration);for(let e of this.driveAxes)this.joint.setDrive(e,t);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(e){if(d){this.enumAxes=[];for(let e of this.data.axes){if("swing"===e){this.enumAxes.push(d.PxD6Axis.eSWING1),this.enumAxes.push(d.PxD6Axis.eSWING2);continue}let t=`e${e.toUpperCase()}`;t in d.PxD6Axis||console.warn(`Unknown axis ${e} (PxD6Axis::${t})`),this.enumAxes.push(d.PxD6Axis[t])}this.driveAxes=[];for(let e of this.data.axes){if("swing"===e){this.data.slerpRotation?this.driveAxes.push(d.PxD6Drive.eSLERP):this.driveAxes.push(d.PxD6Drive.eSWING);continue}if("twist"===e&&this.data.slerpRotation){this.driveAxes.push(d.PxD6Drive.eSLERP);continue}let t=`e${e.toUpperCase()}`;t in d.PxD6Drive||console.warn(`Unknown axis ${e} (PxD6Axis::${t})`),this.driveAxes.push(d.PxD6Drive[t])}}}}),AFRAME.registerComponent("physx-joint-constraint",{multiple:!0,schema:{lockedAxes:{type:"array",default:[]},constrainedAxes:{type:"array",default:[]},freeAxes:{type:"array",default:[]},linearLimit:{type:"vec2"},limitCone:{type:"vec2"},twistLimit:{type:"vec2"},damping:{default:0},restitution:{default:0},stiffness:{default:0}},events:{"physx-jointcreated":function(e){this.setJointConstraint()}},init(){this.el.setAttribute("phsyx-custom-constraint","")},setJointConstraint(){if("D6"!==this.el.components["physx-joint"].data.type)return void console.warn("Only D6 joint constraints supported at the moment");this.constrainedAxes||this.update();let e=this.el.components["physx-joint"].joint,t=()=>{let e=new d.PxJointLinearLimitPair(new d.PxTolerancesScale,this.data.linearLimit.x,this.data.linearLimit.y);return e.stiffness=this.data.stiffness,e.damping=this.data.damping,e.restitution=this.data.restitution,e};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());continue}if(i===d.eTWIST){e.setMotion(d.PxD6Axis.eTWIST,d.PxD6Motion.eLIMITED);let t=new d.PxJointAngularLimitPair(this.data.limitTwist.x,this.data.limitTwist.y);t.stiffness=this.data.stiffness,t.damping=this.data.damping,t.restitution=this.data.restitution,e.setTwistLimit(t);continue}e.setMotion(i,d.PxD6Motion.eLIMITED);let n=new d.PxJointLimitCone(this.data.limitCone.x,this.data.limitCone.y);n.damping=this.data.damping,n.stiffness=this.data.stiffness,n.restitution=this.data.restitution,e.setSwingLimit(n)}},update(e){d&&(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}},events:{constraintbreak:function(e){this.data.removeElOnBreak&&this.el.remove()}},init(){this.system=this.el.sceneEl.systems.physx;let e=this.el;for(;e&&!e.hasAttribute("physx-body");)e=e.parentEl;e?(this.bodyEl=e,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,this.data.breakForce.y),this.joint.setConstraintFlag(d.PxConstraintFlag.eCOLLISION_ENABLED,this.data.collideWithTarget),!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 e=new d.PxD6JointDrive;e.stiffness=1e3,e.damping=500,e.forceLimit=1e3,e.setAccelerationFlag(!1),this.joint.setDrive(d.PxD6Drive.eX,e),this.joint.setDrive(d.PxD6Drive.eY,e),this.joint.setDrive(d.PxD6Drive.eZ,e),this.joint.setDrive(d.PxD6Drive.eSLERP,e),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(e){return Util.positionObject3DAtTarget(this.worldHelperParent,e.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 e=this.getTransform(this.bodyEl),t=this.getTransform(this.data.target);this.joint=d[`Px${this.data.type}JointCreate`](this.system.physics,this.bodyEl.components["physx-body"].rigidBody,e,this.data.target.components["physx-body"].rigidBody,t),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(e){if(this.el.sceneEl.time`,i=i.children[0],this.data.allowedAttributes.length)for(let e of i.attributes)this.data.allowedAttributes.includes(e.name)||i.removeAttribute(e.name);this.data.setId&&e.name&&(i.id=`${this.data.idPrefix}${e.name}`);for(let e of this.data.copyAttributes)this.el.hasAttribute(e)&&i.setAttribute(e,this.el.getAttribute(e));this.data.autoPropogateGrab&&this.el.classList.contains("clickable")&&(i.setAttribute("propogate-grab",""),i.classList.add("clickable")),t.append(i),Util.whenLoaded(i,(()=>{i.setObject3D("mesh",e),e.updateMatrix(),Util.applyMatrix(e.matrix,i.object3D),e.matrix.identity(),Util.applyMatrix(e.matrix,e)})),t=i}for(let i of e.children)this.setupObject(i,t)}})},651:(e,t,i)=>{var n,r=(n=(n="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){var t,r,o=void 0!==(e=e||{})?e:{};o.ready=new Promise((function(e,i){t=e,r=i})),Object.getOwnPropertyDescriptor(o.ready,"_main")||(Object.defineProperty(o.ready,"_main",{configurable:!0,get:function(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(e,t){throw t},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,y,E,_,T="";function g(e){return o.locateFile?o.locateFile(e,T):T+e}if(p)T=u?i(606).dirname(T)+"/":"//",f=function(e,t){return E||(E=i(351)),_||(_=i(606)),e=_.normalize(e),E.readFileSync(e,t?null:"utf8")},y=function(e){var t=f(e,!0);return t.buffer||(t=new Uint8Array(t)),M(t.buffer),t},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),c=process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof Ln))throw e})),process.on("unhandledRejection",Me),d=function(e){process.exit(e)},o.inspect=function(){return"[Emscripten Module object]"};else if(h)"undefined"!=typeof read&&(f=function(e){return read(e)}),y=function(e){var t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(M("object"==typeof(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs?c=scriptArgs:void 0!==arguments&&(c=arguments),"function"==typeof quit&&(d=function(e){quit(e)}),"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(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},u&&(y=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.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(e){D.shown||(D.shown={}),D.shown[e]||(D.shown[e]=1,m(e))}a=null,o.arguments&&(c=o.arguments),Object.getOwnPropertyDescriptor(o,"arguments")||Object.defineProperty(o,"arguments",{configurable:!0,get:function(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}});var b,w,P,R=function(e){};o.wasmBinary&&(b=o.wasmBinary),Object.getOwnPropertyDescriptor(o,"wasmBinary")||Object.defineProperty(o,"wasmBinary",{configurable:!0,get:function(){Me("Module.wasmBinary has been replaced with plain wasmBinary (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.noExitRuntime&&(w=o.noExitRuntime),Object.getOwnPropertyDescriptor(o,"noExitRuntime")||Object.defineProperty(o,"noExitRuntime",{configurable:!0,get:function(){Me("Module.noExitRuntime has been replaced with plain noExitRuntime (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"!=typeof WebAssembly&&Me("No WebAssembly support found. Build with -s WASM=0 to target JavaScript instead.");var A=new WebAssembly.Table({initial:3864,maximum:3864,element:"anyfunc"}),v=!1;function M(e,t){e||Me("Assertion failed: "+t)}var x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function S(e,t,i){for(var n=t+i,r=t;e[r]&&!(r>=n);)++r;if(r-t>16&&e.subarray&&x)return x.decode(e.subarray(t,r));for(var o="";t>10,56320|1023&d)}}else o+=String.fromCharCode((31&s)<<6|a)}else o+=String.fromCharCode(s)}return o}function F(e,t){return e?S(B,e,t):""}function j(e,t,i,n){if(!(n>0))return 0;for(var r=i,o=i+n-1,s=0;s=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s)),a<=127){if(i>=o)break;t[i++]=a}else if(a<=2047){if(i+1>=o)break;t[i++]=192|a>>6,t[i++]=128|63&a}else if(a<=65535){if(i+2>=o)break;t[i++]=224|a>>12,t[i++]=128|a>>6&63,t[i++]=128|63&a}else{if(i+3>=o)break;a>=2097152&&D("Invalid Unicode code point 0x"+a.toString(16)+" encountered when serializing a JS string to an UTF-8 string on the asm.js/wasm heap! (Valid unicode code points should be in range 0-0x1FFFFF)."),t[i++]=240|a>>18,t[i++]=128|a>>12&63,t[i++]=128|a>>6&63,t[i++]=128|63&a}}return t[i]=0,i-r}function C(e,t,i){return M("number"==typeof i,"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),j(e,B,t,i)}function I(e){for(var t=0,i=0;i=55296&&n<=57343&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++i)),n<=127?++t:t+=n<=2047?2:n<=65535?3:4}return t}var X="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function U(e,t){M(e%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");for(var i=e,n=i>>1,r=n+t/2;!(n>=r)&&z[n];)++n;if((i=n<<1)-e>32&&X)return X.decode(B.subarray(e,i));for(var o=0,s="";;){var a=G[e+2*o>>1];if(0==a||o==t/2)return s;++o,s+=String.fromCharCode(a)}}function N(e,t,i){if(M(t%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),M("number"==typeof i,"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),void 0===i&&(i=2147483647),i<2)return 0;for(var n=t,r=(i-=2)<2*e.length?i/2:e.length,o=0;o>1]=s,t+=2}return G[t>>1]=0,t-n}function H(e){return 2*e.length}function k(e,t){M(e%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var i=0,n="";!(i>=t/4);){var r=V[e+4*i>>2];if(0==r)break;if(++i,r>=65536){var o=r-65536;n+=String.fromCharCode(55296|o>>10,56320|1023&o)}else n+=String.fromCharCode(r)}return n}function L(e,t,i){if(M(t%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),M("number"==typeof i,"stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),void 0===i&&(i=2147483647),i<4)return 0;for(var n=t,r=n+i-4,o=0;o=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),V[t>>2]=s,(t+=4)+4>r)break}return V[t>>2]=0,t-n}function Q(e){for(var t=0,i=0;i=55296&&n<=57343&&++i,t+=4}return t}var $,W,B,G,z,V,Y,Z,q,J=65536;function K(e,t){return e%t>0&&(e+=t-e%t),e}function ee(e){$=e,o.HEAP8=W=new Int8Array(e),o.HEAP16=G=new Int16Array(e),o.HEAP32=V=new Int32Array(e),o.HEAPU8=B=new Uint8Array(e),o.HEAPU16=z=new Uint16Array(e),o.HEAPU32=Y=new Uint32Array(e),o.HEAPF32=Z=new Float32Array(e),o.HEAPF64=q=new Float64Array(e)}var te=5431632,ie=188752,ne=5431632,re=188592;M(te%16==0,"stack must start aligned"),M(ne%16==0,"heap must start aligned");var oe=5242880;o.TOTAL_STACK&&M(oe===o.TOTAL_STACK,"the stack size can no longer be determined at runtime");var se=o.INITIAL_MEMORY||16777216;function ae(){M(0==(3&ie)),Y[1+(ie>>2)]=34821223,Y[2+(ie>>2)]=2310721022,V[0]=1668509029}function ce(){var e=Y[1+(ie>>2)],t=Y[2+(ie>>2)];34821223==e&&2310721022==t||Me("Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+t.toString(16)+" "+e.toString(16)),1668509029!==V[0]&&Me("Runtime error: The application has corrupted its heap memory area (address zero)!")}function de(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var i=t.func;"number"==typeof i?void 0===t.arg?o.dynCall_v(i):o.dynCall_vi(i,t.arg):i(void 0===t.arg?null:t.arg)}else t(o)}}Object.getOwnPropertyDescriptor(o,"INITIAL_MEMORY")||Object.defineProperty(o,"INITIAL_MEMORY",{configurable:!0,get:function(){Me("Module.INITIAL_MEMORY has been replaced with plain INITIAL_INITIAL_MEMORY (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(se>=oe,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+se+"! (TOTAL_STACK="+oe+")"),M("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&void 0!==Int32Array.prototype.subarray&&void 0!==Int32Array.prototype.set,"JS engine does not provide full typed array support"),(P=o.wasmMemory?o.wasmMemory:new WebAssembly.Memory({initial:se/J,maximum:2147483648/J}))&&($=P.buffer),M((se=$.byteLength)%J==0),M(65536%J==0),ee($),V[re>>2]=ne,function(){var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian!"}();var le=[],ue=[],pe=[],he=[],fe=!1,ye=!1;function Ee(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)me(o.preRun.shift());de(le)}function _e(){ce(),M(!fe),fe=!0,de(ue)}function Te(){ce(),de(pe)}function ge(){ce(),ye=!0}function Oe(){if(ce(),o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)De(o.postRun.shift());de(he)}function me(e){le.unshift(e)}function De(e){he.unshift(e)}M(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),M(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),M(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),M(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),Math.abs,Math.ceil,Math.floor,Math.min;var be=0,we=null,Pe=null,Re={};function Ae(e){be++,o.monitorRunDependencies&&o.monitorRunDependencies(be),e?(M(!Re[e]),Re[e]=1,null===we&&"undefined"!=typeof setInterval&&(we=setInterval((function(){if(v)return clearInterval(we),void(we=null);var e=!1;for(var t in Re)e||(e=!0,m("still waiting on run dependencies:")),m("dependency: "+t);e&&m("(end of list)")}),1e4))):m("warning: run dependency added without ID")}function ve(e){if(be--,o.monitorRunDependencies&&o.monitorRunDependencies(be),e?(M(Re[e]),delete Re[e]):m("warning: run dependency removed without ID"),0==be&&(null!==we&&(clearInterval(we),we=null),Pe)){var t=Pe;Pe=null,t()}}function Me(e){throw o.onAbort&&o.onAbort(e),O(e+=""),m(e),v=!0,e="abort("+e+") at "+We(),new WebAssembly.RuntimeError(e)}o.preloadedImages={},o.preloadedAudios={};var xe={error:function(){Me("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -s FORCE_FILESYSTEM=1")},init:function(){xe.error()},createDataFile:function(){xe.error()},createPreloadedFile:function(){xe.error()},createLazyFile:function(){xe.error()},open:function(){xe.error()},mkdev:function(){xe.error()},registerDevice:function(){xe.error()},analyzePath:function(){xe.error()},loadFilesFromDB:function(){xe.error()},ErrnoError:function(){xe.error()}};function Se(e,t){return String.prototype.startsWith?e.startsWith(t):0===e.indexOf(t)}o.FS_createDataFile=xe.createDataFile,o.FS_createPreloadedFile=xe.createPreloadedFile;var Fe="data:application/octet-stream;base64,";function je(e){return Se(e,Fe)}var Ce="file://";function Ie(e){return Se(e,Ce)}function Xe(e,t){return function(){var i=e,n=t;return t||(n=o.asm),M(fe,"native function `"+i+"` called before runtime initialization"),M(!ye,"native function `"+i+"` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)"),n[e]||M(n[e],"exported native function `"+i+"` not found"),n[e].apply(null,arguments)}}var Ue="physx.release.wasm";function Ne(){try{if(b)return new Uint8Array(b);if(y)return y(Ue);throw"both async and sync fetching of the wasm failed"}catch(e){Me(e)}}function He(){return b||!l&&!u||"function"!=typeof fetch||Ie(Ue)?new Promise((function(e,t){e(Ne())})):fetch(Ue,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Ue+"'";return e.arrayBuffer()})).catch((function(){return Ne()}))}function ke(){var e={env:Cn,wasi_snapshot_preview1:Cn};function t(e,t){var i=e.exports;o.asm=i,ve("wasm-instantiate")}Ae("wasm-instantiate");var i=o;function n(e){M(o===i,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),i=null,t(e.instance)}function r(t){return He().then((function(t){return WebAssembly.instantiate(t,e)})).then(t,(function(e){m("failed to asynchronously prepare wasm: "+e),Me(e)}))}if(o.instantiateWasm)try{return o.instantiateWasm(e,t)}catch(e){return m("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(b||"function"!=typeof WebAssembly.instantiateStreaming||je(Ue)||Ie(Ue)||"function"!=typeof fetch)return r(n);fetch(Ue,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return m("wasm streaming compile failed: "+e),m("falling back to ArrayBuffer instantiation"),r(n)}))}))}(),{}}function Le(e){return D("warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling"),e}function Qe(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){var t=Le(e);return e===t?e:t+" ["+e+"]"}))}function $e(){var e=new Error;if(!e.stack){try{throw new Error}catch(t){e=t}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function We(){var e=$e();return o.extraStackTrace&&(e+="\n"+o.extraStackTrace()),Qe(e)}function Be(){Me("stack overflow")}je(Ue)||(Ue=g(Ue)),ue.push({func:function(){In()}});var Ge=48,ze=57;function Ve(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=Ge&&t<=ze?"_"+e:e}function Ye(e,t){return e=Ve(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}var Ze=[],qe=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Je(){for(var e=0,t=5;t>2])}var jt={},Ct={},It=void 0;function Xt(e){throw new It(e)}function Ut(e,t,i){function n(t){var n=i(t);n.length!==e.length&&Xt("Mismatched type converter count");for(var r=0;r>o])},destructorFunction:null})}function Qt(e){if(!(this instanceof Zt))return!1;if(!(e instanceof Zt))return!1;for(var t=this.$$.ptrType.registeredClass,i=this.$$.ptr,n=e.$$.ptrType.registeredClass,r=e.$$.ptr;t.baseClass;)i=t.upcast(i),t=t.baseClass;for(;n.baseClass;)r=n.upcast(r),n=n.baseClass;return t===n&&i===r}function $t(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function Wt(e){Et(e.$$.ptrType.registeredClass.name+" instance already deleted")}function Bt(){if(this.$$.ptr||Wt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=vt(Object.create(Object.getPrototypeOf(this),{$$:{value:$t(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function Gt(){this.$$.ptr||Wt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Et("Object already scheduled for deletion"),wt(this),At(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function zt(){return!this.$$.ptr}function Vt(){return this.$$.ptr||Wt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Et("Object already scheduled for deletion"),dt.push(this),1===dt.length&&ut&&ut(lt),this.$$.deleteScheduled=!0,this}function Yt(){Zt.prototype.isAliasOf=Qt,Zt.prototype.clone=Bt,Zt.prototype.delete=Gt,Zt.prototype.isDeleted=zt,Zt.prototype.deleteLater=Vt}function Zt(){}var qt={};function Jt(e,t,i){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||Et("Function '"+i+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].overloadTable+")!"),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function Kt(e,t,i){o.hasOwnProperty(e)?((void 0===i||void 0!==o[e].overloadTable&&void 0!==o[e].overloadTable[i])&&Et("Cannot register public name '"+e+"' twice"),Jt(o,e,e),o.hasOwnProperty(i)&&Et("Cannot register multiple overloads of a function with the same number of arguments ("+i+")!"),o[e].overloadTable[i]=t):(o[e]=t,void 0!==i&&(o[e].numArguments=i))}function ei(e,t,i,n,r,o,s,a){this.name=e,this.constructor=t,this.instancePrototype=i,this.rawDestructor=n,this.baseClass=r,this.getActualType=o,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function ti(e,t,i){for(;t!==i;)t.upcast||Et("Expected null or instance of "+i.name+", got an instance of "+t.name),e=t.upcast(e),t=t.baseClass;return e}function ii(e,t){if(null===t)return this.isReference&&Et("null is not a valid "+this.name),0;t.$$||Et('Cannot pass "'+ji(t)+'" as a '+this.name),t.$$.ptr||Et("Cannot pass deleted object as a pointer of type "+this.name);var i=t.$$.ptrType.registeredClass;return ti(t.$$.ptr,i,this.registeredClass)}function ni(e,t){var i;if(null===t)return this.isReference&&Et("null is not a valid "+this.name),this.isSmartPointer?(i=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,i),i):0;t.$$||Et('Cannot pass "'+ji(t)+'" as a '+this.name),t.$$.ptr||Et("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&t.$$.ptrType.isConst&&Et("Cannot convert argument of type "+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+" to parameter type "+this.name);var n=t.$$.ptrType.registeredClass;if(i=ti(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&Et("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?i=t.$$.smartPtr:Et("Cannot convert argument of type "+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:i=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)i=t.$$.smartPtr;else{var r=t.clone();i=this.rawShare(i,tt((function(){r.delete()}))),null!==e&&e.push(this.rawDestructor,i)}break;default:Et("Unsupporting sharing policy")}return i}function ri(e,t){if(null===t)return this.isReference&&Et("null is not a valid "+this.name),0;t.$$||Et('Cannot pass "'+ji(t)+'" as a '+this.name),t.$$.ptr||Et("Cannot pass deleted object as a pointer of type "+this.name),t.$$.ptrType.isConst&&Et("Cannot convert argument of type "+t.$$.ptrType.name+" to parameter type "+this.name);var i=t.$$.ptrType.registeredClass;return ti(t.$$.ptr,i,this.registeredClass)}function oi(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function si(e){this.rawDestructor&&this.rawDestructor(e)}function ai(e){null!==e&&e.delete()}function ci(e,t,i){if(t===i)return e;if(void 0===i.baseClass)return null;var n=ci(e,t,i.baseClass);return null===n?null:i.downcast(n)}function di(e,t){return t=_t(e,t),ft[t]}function li(e,t){return t.ptrType&&t.ptr||Xt("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&Xt("Both smartPtrType and smartPtr must be specified"),t.count={value:1},vt(Object.create(e,{$$:{value:t}}))}function ui(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var i=di(this.registeredClass,t);if(void 0!==i){if(0===i.$$.count.value)return i.$$.ptr=t,i.$$.smartPtr=e,i.clone();var n=i.clone();return this.destructor(e),n}function r(){return this.isSmartPointer?li(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):li(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o,s=this.registeredClass.getActualType(t),a=qt[s];if(!a)return r.call(this);o=this.isConst?a.constPointerType:a.pointerType;var c=ci(t,this.registeredClass,o.registeredClass);return null===c?r.call(this):this.isSmartPointer?li(o.registeredClass.instancePrototype,{ptrType:o,ptr:c,smartPtrType:this,smartPtr:e}):li(o.registeredClass.instancePrototype,{ptrType:o,ptr:c})}function pi(){hi.prototype.getPointee=oi,hi.prototype.destructor=si,hi.prototype.argPackAdvance=8,hi.prototype.readValueFromPointer=Ft,hi.prototype.deleteObject=ai,hi.prototype.fromWireType=ui}function hi(e,t,i,n,r,o,s,a,c,d,l){this.name=e,this.registeredClass=t,this.isReference=i,this.isConst=n,this.isSmartPointer=r,this.pointeeType=o,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=c,this.rawShare=d,this.rawDestructor=l,r||void 0!==t.baseClass?this.toWireType=ni:n?(this.toWireType=ii,this.destructorFunction=null):(this.toWireType=ri,this.destructorFunction=null)}function fi(e,t,i){o.hasOwnProperty(e)||Xt("Replacing nonexistant public symbol"),void 0!==o[e].overloadTable&&void 0!==i?o[e].overloadTable[i]=t:(o[e]=t,o[e].argCount=i)}function yi(e,t){e=st(e);var i=function(i){for(var n=[],r=1;r0?", ":"")+u),p+=(d?"var rv = ":"")+"invoker(fn"+(u.length>0?", ":"")+u+");\n",a)p+="runDestructors(destructors);\n";else for(c=s?1:2;c>2)+n]);return i}function Di(e,t,i,n,r,o,s){var a=mi(i,n);t=st(t),o=yi(r,o),Ut([],[e],(function(e){var n=(e=e[0]).name+"."+t;function r(){_i("Cannot call "+n+" due to unbound types",a)}var c=e.registeredClass.constructor;return void 0===c[t]?(r.argCount=i-1,c[t]=r):(Jt(c,t,n),c[t].overloadTable[i-1]=r),Ut([],a,(function(e){var r=[e[0],null].concat(e.slice(1)),a=Oi(n,r,null,o,s);return void 0===c[t].overloadTable?(a.argCount=i-1,c[t]=a):c[t].overloadTable[i-1]=a,[]})),[]}))}function bi(e,t,i,n,r,o){M(t>0);var s=mi(t,i);r=yi(n,r);var a=[o],c=[];Ut([],[e],(function(e){var i="constructor "+(e=e[0]).name;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new yt("Cannot register multiple constructors with identical number of parameters ("+(t-1)+") for class '"+e.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return e.registeredClass.constructor_body[t-1]=function(){_i("Cannot construct "+e.name+" due to unbound types",s)},Ut([],s,(function(n){return e.registeredClass.constructor_body[t-1]=function(){arguments.length!==t-1&&Et(i+" called with "+arguments.length+" arguments, expected "+(t-1)),c.length=0,a.length=t;for(var e=1;e4&&0==--qe[e].refcount&&(qe[e]=void 0,Ze.push(e))}function Mi(e,t){kt(e,{name:t=st(t),fromWireType:function(e){var t=qe[e].value;return vi(e),t},toWireType:function(e,t){return tt(t)},argPackAdvance:8,readValueFromPointer:Ft,destructorFunction:null})}function xi(e,t,i){switch(t){case 0:return function(e){var t=i?W:B;return this.fromWireType(t[e])};case 1:return function(e){var t=i?G:z;return this.fromWireType(t[e>>1])};case 2:return function(e){var t=i?V:Y;return this.fromWireType(t[e>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Si(e,t,i,n){var r=Ht(i);function o(){}t=st(t),o.values={},kt(e,{name:t,constructor:o,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:xi(t,r,n),destructorFunction:null}),Kt(t,o)}function Fi(e,t,i){var n=Dt(e,"enum");t=st(t);var r=n.constructor,o=Object.create(n.constructor.prototype,{value:{value:i},constructor:{value:Ye(n.name+"_"+t,(function(){}))}});r.values[i]=o,r[t]=o}function ji(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Ci(e,t){switch(t){case 2:return function(e){return this.fromWireType(Z[e>>2])};case 3:return function(e){return this.fromWireType(q[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ii(e,t,i){var n=Ht(i);kt(e,{name:t=st(t),fromWireType:function(e){return e},toWireType:function(e,t){if("number"!=typeof t&&"boolean"!=typeof t)throw new TypeError('Cannot convert "'+ji(t)+'" to '+this.name);return t},argPackAdvance:8,readValueFromPointer:Ci(t,n),destructorFunction:null})}function Xi(e,t,i,n,r,o){var s=mi(t,i);e=st(e),r=yi(n,r),Kt(e,(function(){_i("Cannot call "+e+" due to unbound types",s)}),t-1),Ut([],s,(function(i){var n=[i[0],null].concat(i.slice(1));return fi(e,Oi(e,n,null,r,o),t-1),[]}))}function Ui(e,t,i){switch(t){case 0:return i?function(e){return W[e]}:function(e){return B[e]};case 1:return i?function(e){return G[e>>1]}:function(e){return z[e>>1]};case 2:return i?function(e){return V[e>>2]}:function(e){return Y[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Ni(e,t,i,n,r){t=st(t),-1===r&&(r=4294967295);var o=Ht(i),s=function(e){return e};if(0===n){var a=32-8*i;s=function(e){return e<>>a}}var c=-1!=t.indexOf("unsigned");kt(e,{name:t,fromWireType:s,toWireType:function(e,i){if("number"!=typeof i&&"boolean"!=typeof i)throw new TypeError('Cannot convert "'+ji(i)+'" to '+this.name);if(ir)throw new TypeError('Passing a number "'+ji(i)+'" from JS side to C/C++ side to an argument of type "'+t+'", which is outside the valid range ['+n+", "+r+"]!");return c?i>>>0:0|i},argPackAdvance:8,readValueFromPointer:Ui(t,o,0!==n),destructorFunction:null})}function Hi(e,t,i){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function r(e){var t=Y,i=t[e>>=2],r=t[e+1];return new n($,r,i)}kt(e,{name:i=st(i),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{ignoreDuplicateRegistrations:!0})}function ki(e,t){var i="std::string"===(t=st(t));kt(e,{name:t,fromWireType:function(e){var t,n=Y[e>>2];if(i)for(var r=e+4,o=0;o<=n;++o){var s=e+4+o;if(0==B[s]||o==n){var a=F(r,s-r);void 0===t?t=a:(t+=String.fromCharCode(0),t+=a),r=s+1}}else{var c=new Array(n);for(o=0;o>2]=r,i&&n)C(t,o+4,r+1);else if(n)for(var s=0;s255&&(Xn(o),Et("String has UTF-16 code units that do not fit in 8 bits")),B[o+4+s]=a}else for(s=0;s>2],s=o(),c=e+4,d=0;d<=r;++d){var l=e+4+d*t;if(0==s[l>>a]||d==r){var u=n(c,l-c);void 0===i?i=u:(i+=String.fromCharCode(0),i+=u),c=l+t}}return Xn(e),i},toWireType:function(e,n){"string"!=typeof n&&Et("Cannot pass non-string to C++ string type "+i);var o=s(n),c=kn(4+o+t);return Y[c>>2]=o>>a,r(n,c+4,o+t),null!==e&&e.push(Xn,c),c},argPackAdvance:8,readValueFromPointer:Ft,destructorFunction:function(e){Xn(e)}})}function Qi(e,t,i,n,r,o){xt[e]={name:st(t),rawConstructor:yi(i,n),rawDestructor:yi(r,o),fields:[]}}function $i(e,t,i,n,r,o,s,a,c,d){xt[e].fields.push({fieldName:st(t),getterReturnType:i,getter:yi(n,r),getterContext:o,setterArgumentType:s,setter:yi(a,c),setterContext:d})}function Wi(e,t){kt(e,{isVoid:!0,name:t=st(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})}function Bi(e){var t=[];return V[e>>2]=tt(t),t}var Gi={};function zi(e){var t=Gi[e];return void 0===t?st(e):t}var Vi,Yi=[];function Zi(e,t,i,n,r){return(e=Yi[e])(t=gt(t),i=zi(i),Bi(n),r)}function qi(e,t,i,n){(e=Yi[e])(t=gt(t),i=zi(i),null,n)}function Ji(e){var t=Yi.length;return Yi.push(e),t}function Ki(e,t){for(var i=new Array(e),n=0;n>2)+n],"parameter "+n);return i}function en(e,t){for(var i=Ki(e,t),n=i[0],r=n.name+"_$"+i.slice(1).map((function(e){return e.name})).join("_")+"$",o=["retType"],s=[n],a="",c=0;c4&&(qe[e].refcount+=1)}function nn(e){St(qe[e].value),vi(e)}function rn(e,t){return tt((e=Dt(e,"_emval_take_value")).readValueFromPointer(t))}function on(){Me()}Vi=p?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof dateNow?dateNow:function(){return performance.now()};var sn=!0;function an(e){return V[Nn()>>2]=e,e}function cn(e,t){var i;if(0===e)i=Date.now();else{if(1!==e&&4!==e||!sn)return an(28),-1;i=Vi()}return V[t>>2]=i/1e3|0,V[t+4>>2]=i%1e3*1e3*1e3|0,0}function dn(){return 188592}function ln(e,t,i){B.copyWithin(e,t,t+i)}function un(){return B.length}function pn(e){try{return P.grow(e-$.byteLength+65535>>>16),ee(P.buffer),1}catch(t){console.error("emscripten_realloc_buffer: Attempted to grow heap from "+$.byteLength+" bytes to "+e+" bytes, but got error: "+t)}}function hn(e){e>>>=0;var t=un();M(e>t);var i=2147483648;if(e>i)return m("Cannot enlarge memory, asked to go up to "+e+" bytes, but the limit is 2147483648 bytes!"),!1;for(var n=1;n<=4;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var o=Math.min(i,K(Math.max(16777216,e,r),65536));if(pn(o))return!0}return m("Failed to grow the heap from "+t+" bytes to "+o+" bytes, not enough memory!"),!1}function fn(){void 0!==Hn&&Hn(0);var e=yn.buffers;e[1].length&&yn.printChar(1,10),e[2].length&&yn.printChar(2,10)}var yn={mappings:{},buffers:[null,[],[]],printChar:function(e,t){var i=yn.buffers[e];M(i),0===t||10===t?((1===e?O:m)(S(i,0)),i.length=0):i.push(t)},varargs:void 0,get:function(){return M(null!=yn.varargs),yn.varargs+=4,V[yn.varargs-4>>2]},getStr:function(e){return F(e)},get64:function(e,t){return M(e>=0?0===t:-1===t),e}};function En(e,t,i,n){for(var r=0,o=0;o>2],a=V[t+(8*o+4)>>2],c=0;c>2]=r,0}function _n(e){var t=Date.now();return V[e>>2]=t/1e3|0,V[e+4>>2]=t%1e3*1e3|0,0}function Tn(e){for(var t=Vi();Vi()-t>2],n=V[e+4>>2];return n<0||n>999999999||i<0?(an(28),-1):(0!==t&&(V[t>>2]=0,V[t+4>>2]=0),Tn(1e6*i+n/1e3))}function On(e){return 0}function mn(e){return 0}function Dn(){}function bn(){}function wn(){return 6}function Pn(e){Wn(e)}function Rn(e){Pn(e)}function An(){}function vn(){}function Mn(){}function xn(){}function Sn(){}function Fn(e){R(0|e)}et(),nt=o.PureVirtualError=it(Error,"PureVirtualError"),rt(),ht(),yt=o.BindingError=it(Error,"BindingError"),It=o.InternalError=it(Error,"InternalError"),Yt(),pi(),Ei=o.UnboundTypeError=it(Error,"UnboundTypeError");var jn,Cn={__handle_stack_overflow:Be,_embind_create_inheriting_constructor:Mt,_embind_finalize_value_object:Nt,_embind_register_bool:Lt,_embind_register_class:Ti,_embind_register_class_class_function:Di,_embind_register_class_constructor:bi,_embind_register_class_function:wi,_embind_register_class_property:Ri,_embind_register_constant:Ai,_embind_register_emval:Mi,_embind_register_enum:Si,_embind_register_enum_value:Fi,_embind_register_float:Ii,_embind_register_function:Xi,_embind_register_integer:Ni,_embind_register_memory_view:Hi,_embind_register_std_string:ki,_embind_register_std_wstring:Li,_embind_register_value_object:Qi,_embind_register_value_object_field:$i,_embind_register_void:Wi,_emval_call_method:Zi,_emval_call_void_method:qi,_emval_decref:vi,_emval_get_method_caller:en,_emval_incref:tn,_emval_run_destructors:nn,_emval_take_value:rn,abort:on,clock_gettime:cn,emscripten_get_sbrk_ptr:dn,emscripten_memcpy_big:ln,emscripten_resize_heap:hn,fd_write:En,gettimeofday:_n,memory:P,nanosleep:gn,pthread_attr_destroy:On,pthread_attr_init:mn,pthread_attr_setstacksize:Dn,pthread_cancel:bn,pthread_create:wn,pthread_exit:Rn,pthread_join:An,pthread_mutexattr_destroy:vn,pthread_mutexattr_init:Mn,pthread_mutexattr_setprotocol:xn,pthread_mutexattr_settype:Sn,setTempRet0:Fn,table:A},In=(ke(),o.___wasm_call_ctors=Xe("__wasm_call_ctors")),Xn=(o._memcpy=Xe("memcpy"),o._free=Xe("free")),Un=o.___getTypeName=Xe("__getTypeName"),Nn=(o.___embind_register_native_and_builtin_types=Xe("__embind_register_native_and_builtin_types"),o.___errno_location=Xe("__errno_location")),Hn=(o._htonl=Xe("htonl"),o._htons=Xe("htons"),o._ntohs=Xe("ntohs"),o._fflush=Xe("fflush")),kn=o._malloc=Xe("malloc");function Ln(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Qn(e){function i(){jn||(jn=!0,o.calledRun=!0,v||(_e(),Te(),t(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),M(!o._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Oe()))}e=e||c,be>0||(ae(),Ee(),be>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),i()}),1)):i(),ce()))}function $n(){var e=O,t=m,i=!1;O=m=function(e){i=!0};try{fn&&fn()}catch(e){}O=e,m=t,i&&(D("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc."),D("(this may also be due to not including full filesystem support - try building with -s FORCE_FILESYSTEM=1)"))}function Wn(e,t){$n(),t&&w&&0===e||(w?t||r("program exited (with status: "+e+"), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)"):(v=!0,ge(),o.onExit&&o.onExit(e)),d(e,new Ln(e)))}if(o.stackSave=Xe("stackSave"),o.stackRestore=Xe("stackRestore"),o.stackAlloc=Xe("stackAlloc"),o._emscripten_main_thread_process_queued_calls=Xe("emscripten_main_thread_process_queued_calls"),o.___set_stack_limit=Xe("__set_stack_limit"),o.__growWasmMemory=Xe("__growWasmMemory"),o.dynCall_viiiiiiii=Xe("dynCall_viiiiiiii"),o.dynCall_iiiii=Xe("dynCall_iiiii"),o.dynCall_iiii=Xe("dynCall_iiii"),o.dynCall_iii=Xe("dynCall_iii"),o.dynCall_ii=Xe("dynCall_ii"),o.dynCall_iiiiiii=Xe("dynCall_iiiiiii"),o.dynCall_iiiiii=Xe("dynCall_iiiiii"),o.dynCall_vi=Xe("dynCall_vi"),o.dynCall_vii=Xe("dynCall_vii"),o.dynCall_viii=Xe("dynCall_viii"),o.dynCall_fii=Xe("dynCall_fii"),o.dynCall_viif=Xe("dynCall_viif"),o.dynCall_iiff=Xe("dynCall_iiff"),o.dynCall_iifff=Xe("dynCall_iifff"),o.dynCall_iiiff=Xe("dynCall_iiiff"),o.dynCall_iiifff=Xe("dynCall_iiifff"),o.dynCall_viff=Xe("dynCall_viff"),o.dynCall_viiff=Xe("dynCall_viiff"),o.dynCall_viiii=Xe("dynCall_viiii"),o.dynCall_i=Xe("dynCall_i"),o.dynCall_iifffi=Xe("dynCall_iifffi"),o.dynCall_viiiii=Xe("dynCall_viiiii"),o.dynCall_dii=Xe("dynCall_dii"),o.dynCall_viid=Xe("dynCall_viid"),o.dynCall_vifi=Xe("dynCall_vifi"),o.dynCall_viifi=Xe("dynCall_viifi"),o.dynCall_iiiiifiiiii=Xe("dynCall_iiiiifiiiii"),o.dynCall_iiiiiifiiiiif=Xe("dynCall_iiiiiifiiiiif"),o.dynCall_iiiiiiii=Xe("dynCall_iiiiiiii"),o.dynCall_iiiiiiiii=Xe("dynCall_iiiiiiiii"),o.dynCall_iif=Xe("dynCall_iif"),o.dynCall_iiif=Xe("dynCall_iiif"),o.dynCall_iiffff=Xe("dynCall_iiffff"),o.dynCall_viiif=Xe("dynCall_viiif"),o.dynCall_iiiiffii=Xe("dynCall_iiiiffii"),o.dynCall_iiiif=Xe("dynCall_iiiif"),o.dynCall_v=Xe("dynCall_v"),o.dynCall_vif=Xe("dynCall_vif"),o.dynCall_fi=Xe("dynCall_fi"),o.dynCall_iifi=Xe("dynCall_iifi"),o.dynCall_viiiiiii=Xe("dynCall_viiiiiii"),o.dynCall_viiifi=Xe("dynCall_viiifi"),o.dynCall_viiffi=Xe("dynCall_viiffi"),o.dynCall_viifffi=Xe("dynCall_viifffi"),o.dynCall_viiiiii=Xe("dynCall_viiiiii"),o.dynCall_viiifiiiii=Xe("dynCall_viiifiiiii"),o.dynCall_viiiifiiiiif=Xe("dynCall_viiiifiiiiif"),o.dynCall_iiiifiiiii=Xe("dynCall_iiiifiiiii"),o.dynCall_iiiiifiiiiif=Xe("dynCall_iiiiifiiiiif"),o.dynCall_vifiiii=Xe("dynCall_vifiiii"),o.dynCall_viiiiiiiii=Xe("dynCall_viiiiiiiii"),o.dynCall_viffiiiif=Xe("dynCall_viffiiiif"),o.dynCall_viffiifffffiii=Xe("dynCall_viffiifffffiii"),o.dynCall_viffffiifffiiiiif=Xe("dynCall_viffffiifffiiiiif"),o.dynCall_iiiifffffii=Xe("dynCall_iiiifffffii"),o.dynCall_iiiifffffi=Xe("dynCall_iiiifffffi"),o.dynCall_viiiiiiiiiiifii=Xe("dynCall_viiiiiiiiiiifii"),o.dynCall_viiiiiiiiii=Xe("dynCall_viiiiiiiiii"),o.dynCall_viiiffi=Xe("dynCall_viiiffi"),o.dynCall_vifii=Xe("dynCall_vifii"),o.dynCall_viiiffii=Xe("dynCall_viiiffii"),o.dynCall_iiiiifiii=Xe("dynCall_iiiiifiii"),o.dynCall_iiiiiifiii=Xe("dynCall_iiiiiifiii"),o.dynCall_iiiiiiifiif=Xe("dynCall_iiiiiiifiif"),o.dynCall_iiiiiifiif=Xe("dynCall_iiiiiifiif"),o.dynCall_iiiifii=Xe("dynCall_iiiifii"),o.dynCall_fiiiiiifiifif=Xe("dynCall_fiiiiiifiifif"),o.dynCall_fiiiiiifiiiif=Xe("dynCall_fiiiiiifiiiif"),o.dynCall_fiff=Xe("dynCall_fiff"),o.dynCall_viiifii=Xe("dynCall_viiifii"),o.dynCall_iiiiiiiiii=Xe("dynCall_iiiiiiiiii"),o.dynCall_iiiiiiiiiii=Xe("dynCall_iiiiiiiiiii"),o.dynCall_viij=Xe("dynCall_viij"),o.dynCall_viiji=Xe("dynCall_viiji"),o.dynCall_viijijj=Xe("dynCall_viijijj"),o.dynCall_viijj=Xe("dynCall_viijj"),o.dynCall_iiiij=Xe("dynCall_iiiij"),o.dynCall_viiiij=Xe("dynCall_viiiij"),o.dynCall_ji=Xe("dynCall_ji"),o.dynCall_iidiiii=Xe("dynCall_iidiiii"),o.dynCall_jiji=Xe("dynCall_jiji"),Object.getOwnPropertyDescriptor(o,"intArrayFromString")||(o.intArrayFromString=function(){Me("'intArrayFromString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"intArrayToString")||(o.intArrayToString=function(){Me("'intArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ccall")||(o.ccall=function(){Me("'ccall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"cwrap")||(o.cwrap=function(){Me("'cwrap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setValue")||(o.setValue=function(){Me("'setValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getValue")||(o.getValue=function(){Me("'getValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"allocate")||(o.allocate=function(){Me("'allocate' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getMemory")||(o.getMemory=function(){Me("'getMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"UTF8ArrayToString")||(o.UTF8ArrayToString=function(){Me("'UTF8ArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UTF8ToString")||(o.UTF8ToString=function(){Me("'UTF8ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF8Array")||(o.stringToUTF8Array=function(){Me("'stringToUTF8Array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF8")||(o.stringToUTF8=function(){Me("'stringToUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"lengthBytesUTF8")||(o.lengthBytesUTF8=function(){Me("'lengthBytesUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackTrace")||(o.stackTrace=function(){Me("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnPreRun")||(o.addOnPreRun=function(){Me("'addOnPreRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnInit")||(o.addOnInit=function(){Me("'addOnInit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnPreMain")||(o.addOnPreMain=function(){Me("'addOnPreMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnExit")||(o.addOnExit=function(){Me("'addOnExit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnPostRun")||(o.addOnPostRun=function(){Me("'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeStringToMemory")||(o.writeStringToMemory=function(){Me("'writeStringToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeArrayToMemory")||(o.writeArrayToMemory=function(){Me("'writeArrayToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeAsciiToMemory")||(o.writeAsciiToMemory=function(){Me("'writeAsciiToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addRunDependency")||(o.addRunDependency=function(){Me("'addRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"removeRunDependency")||(o.removeRunDependency=function(){Me("'removeRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createFolder")||(o.FS_createFolder=function(){Me("'FS_createFolder' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createPath")||(o.FS_createPath=function(){Me("'FS_createPath' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createDataFile")||(o.FS_createDataFile=function(){Me("'FS_createDataFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createPreloadedFile")||(o.FS_createPreloadedFile=function(){Me("'FS_createPreloadedFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createLazyFile")||(o.FS_createLazyFile=function(){Me("'FS_createLazyFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createLink")||(o.FS_createLink=function(){Me("'FS_createLink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createDevice")||(o.FS_createDevice=function(){Me("'FS_createDevice' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_unlink")||(o.FS_unlink=function(){Me("'FS_unlink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"dynamicAlloc")||(o.dynamicAlloc=function(){Me("'dynamicAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"loadDynamicLibrary")||(o.loadDynamicLibrary=function(){Me("'loadDynamicLibrary' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"loadWebAssemblyModule")||(o.loadWebAssemblyModule=function(){Me("'loadWebAssemblyModule' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getLEB")||(o.getLEB=function(){Me("'getLEB' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getFunctionTables")||(o.getFunctionTables=function(){Me("'getFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"alignFunctionTables")||(o.alignFunctionTables=function(){Me("'alignFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registerFunctions")||(o.registerFunctions=function(){Me("'registerFunctions' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addFunction")||(o.addFunction=function(){Me("'addFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"removeFunction")||(o.removeFunction=function(){Me("'removeFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getFuncWrapper")||(o.getFuncWrapper=function(){Me("'getFuncWrapper' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"prettyPrint")||(o.prettyPrint=function(){Me("'prettyPrint' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"makeBigInt")||(o.makeBigInt=function(){Me("'makeBigInt' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"dynCall")||(o.dynCall=function(){Me("'dynCall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getCompilerSetting")||(o.getCompilerSetting=function(){Me("'getCompilerSetting' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"print")||(o.print=function(){Me("'print' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"printErr")||(o.printErr=function(){Me("'printErr' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getTempRet0")||(o.getTempRet0=function(){Me("'getTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setTempRet0")||(o.setTempRet0=function(){Me("'setTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"callMain")||(o.callMain=function(){Me("'callMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"abort")||(o.abort=function(){Me("'abort' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToNewUTF8")||(o.stringToNewUTF8=function(){Me("'stringToNewUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscripten_realloc_buffer")||(o.emscripten_realloc_buffer=function(){Me("'emscripten_realloc_buffer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ENV")||(o.ENV=function(){Me("'ENV' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ERRNO_CODES")||(o.ERRNO_CODES=function(){Me("'ERRNO_CODES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ERRNO_MESSAGES")||(o.ERRNO_MESSAGES=function(){Me("'ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setErrNo")||(o.setErrNo=function(){Me("'setErrNo' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"DNS")||(o.DNS=function(){Me("'DNS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GAI_ERRNO_MESSAGES")||(o.GAI_ERRNO_MESSAGES=function(){Me("'GAI_ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"Protocols")||(o.Protocols=function(){Me("'Protocols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"Sockets")||(o.Sockets=function(){Me("'Sockets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UNWIND_CACHE")||(o.UNWIND_CACHE=function(){Me("'UNWIND_CACHE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readAsmConstArgs")||(o.readAsmConstArgs=function(){Me("'readAsmConstArgs' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"jstoi_q")||(o.jstoi_q=function(){Me("'jstoi_q' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"jstoi_s")||(o.jstoi_s=function(){Me("'jstoi_s' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"abortStackOverflow")||(o.abortStackOverflow=function(){Me("'abortStackOverflow' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"reallyNegative")||(o.reallyNegative=function(){Me("'reallyNegative' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"formatString")||(o.formatString=function(){Me("'formatString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PATH")||(o.PATH=function(){Me("'PATH' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PATH_FS")||(o.PATH_FS=function(){Me("'PATH_FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SYSCALLS")||(o.SYSCALLS=function(){Me("'SYSCALLS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"syscallMmap2")||(o.syscallMmap2=function(){Me("'syscallMmap2' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"syscallMunmap")||(o.syscallMunmap=function(){Me("'syscallMunmap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"flush_NO_FILESYSTEM")||(o.flush_NO_FILESYSTEM=function(){Me("'flush_NO_FILESYSTEM' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"JSEvents")||(o.JSEvents=function(){Me("'JSEvents' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"specialHTMLTargets")||(o.specialHTMLTargets=function(){Me("'specialHTMLTargets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"demangle")||(o.demangle=function(){Me("'demangle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"demangleAll")||(o.demangleAll=function(){Me("'demangleAll' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"jsStackTrace")||(o.jsStackTrace=function(){Me("'jsStackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackTrace")||(o.stackTrace=function(){Me("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getEnvStrings")||(o.getEnvStrings=function(){Me("'getEnvStrings' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"checkWasiClock")||(o.checkWasiClock=function(){Me("'checkWasiClock' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToI64")||(o.writeI53ToI64=function(){Me("'writeI53ToI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToI64Clamped")||(o.writeI53ToI64Clamped=function(){Me("'writeI53ToI64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToI64Signaling")||(o.writeI53ToI64Signaling=function(){Me("'writeI53ToI64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToU64Clamped")||(o.writeI53ToU64Clamped=function(){Me("'writeI53ToU64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToU64Signaling")||(o.writeI53ToU64Signaling=function(){Me("'writeI53ToU64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readI53FromI64")||(o.readI53FromI64=function(){Me("'readI53FromI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readI53FromU64")||(o.readI53FromU64=function(){Me("'readI53FromU64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"convertI32PairToI53")||(o.convertI32PairToI53=function(){Me("'convertI32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"convertU32PairToI53")||(o.convertU32PairToI53=function(){Me("'convertU32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"Browser")||(o.Browser=function(){Me("'Browser' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"FS")||(o.FS=function(){Me("'FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"MEMFS")||(o.MEMFS=function(){Me("'MEMFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"TTY")||(o.TTY=function(){Me("'TTY' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PIPEFS")||(o.PIPEFS=function(){Me("'PIPEFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SOCKFS")||(o.SOCKFS=function(){Me("'SOCKFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GL")||(o.GL=function(){Me("'GL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGet")||(o.emscriptenWebGLGet=function(){Me("'emscriptenWebGLGet' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGetTexPixelData")||(o.emscriptenWebGLGetTexPixelData=function(){Me("'emscriptenWebGLGetTexPixelData' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGetUniform")||(o.emscriptenWebGLGetUniform=function(){Me("'emscriptenWebGLGetUniform' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGetVertexAttrib")||(o.emscriptenWebGLGetVertexAttrib=function(){Me("'emscriptenWebGLGetVertexAttrib' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"AL")||(o.AL=function(){Me("'AL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_unicode")||(o.SDL_unicode=function(){Me("'SDL_unicode' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_ttfContext")||(o.SDL_ttfContext=function(){Me("'SDL_ttfContext' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_audio")||(o.SDL_audio=function(){Me("'SDL_audio' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL")||(o.SDL=function(){Me("'SDL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_gfx")||(o.SDL_gfx=function(){Me("'SDL_gfx' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLUT")||(o.GLUT=function(){Me("'GLUT' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"EGL")||(o.EGL=function(){Me("'EGL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLFW_Window")||(o.GLFW_Window=function(){Me("'GLFW_Window' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLFW")||(o.GLFW=function(){Me("'GLFW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLEW")||(o.GLEW=function(){Me("'GLEW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"IDBStore")||(o.IDBStore=function(){Me("'IDBStore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"runAndAbortIfError")||(o.runAndAbortIfError=function(){Me("'runAndAbortIfError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_handle_array")||(o.emval_handle_array=function(){Me("'emval_handle_array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_free_list")||(o.emval_free_list=function(){Me("'emval_free_list' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_symbols")||(o.emval_symbols=function(){Me("'emval_symbols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_emval")||(o.init_emval=function(){Me("'init_emval' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"count_emval_handles")||(o.count_emval_handles=function(){Me("'count_emval_handles' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"get_first_emval")||(o.get_first_emval=function(){Me("'get_first_emval' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getStringOrSymbol")||(o.getStringOrSymbol=function(){Me("'getStringOrSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"requireHandle")||(o.requireHandle=function(){Me("'requireHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_newers")||(o.emval_newers=function(){Me("'emval_newers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"craftEmvalAllocator")||(o.craftEmvalAllocator=function(){Me("'craftEmvalAllocator' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_get_global")||(o.emval_get_global=function(){Me("'emval_get_global' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_methodCallers")||(o.emval_methodCallers=function(){Me("'emval_methodCallers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"InternalError")||(o.InternalError=function(){Me("'InternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"BindingError")||(o.BindingError=function(){Me("'BindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UnboundTypeError")||(o.UnboundTypeError=function(){Me("'UnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PureVirtualError")||(o.PureVirtualError=function(){Me("'PureVirtualError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_embind")||(o.init_embind=function(){Me("'init_embind' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwInternalError")||(o.throwInternalError=function(){Me("'throwInternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwBindingError")||(o.throwBindingError=function(){Me("'throwBindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwUnboundTypeError")||(o.throwUnboundTypeError=function(){Me("'throwUnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ensureOverloadTable")||(o.ensureOverloadTable=function(){Me("'ensureOverloadTable' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"exposePublicSymbol")||(o.exposePublicSymbol=function(){Me("'exposePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"replacePublicSymbol")||(o.replacePublicSymbol=function(){Me("'replacePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"extendError")||(o.extendError=function(){Me("'extendError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"createNamedFunction")||(o.createNamedFunction=function(){Me("'createNamedFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registeredInstances")||(o.registeredInstances=function(){Me("'registeredInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getBasestPointer")||(o.getBasestPointer=function(){Me("'getBasestPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registerInheritedInstance")||(o.registerInheritedInstance=function(){Me("'registerInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"unregisterInheritedInstance")||(o.unregisterInheritedInstance=function(){Me("'unregisterInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getInheritedInstance")||(o.getInheritedInstance=function(){Me("'getInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getInheritedInstanceCount")||(o.getInheritedInstanceCount=function(){Me("'getInheritedInstanceCount' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getLiveInheritedInstances")||(o.getLiveInheritedInstances=function(){Me("'getLiveInheritedInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registeredTypes")||(o.registeredTypes=function(){Me("'registeredTypes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"awaitingDependencies")||(o.awaitingDependencies=function(){Me("'awaitingDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"typeDependencies")||(o.typeDependencies=function(){Me("'typeDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registeredPointers")||(o.registeredPointers=function(){Me("'registeredPointers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registerType")||(o.registerType=function(){Me("'registerType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"whenDependentTypesAreResolved")||(o.whenDependentTypesAreResolved=function(){Me("'whenDependentTypesAreResolved' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"embind_charCodes")||(o.embind_charCodes=function(){Me("'embind_charCodes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"embind_init_charCodes")||(o.embind_init_charCodes=function(){Me("'embind_init_charCodes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readLatin1String")||(o.readLatin1String=function(){Me("'readLatin1String' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getTypeName")||(o.getTypeName=function(){Me("'getTypeName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"heap32VectorToArray")||(o.heap32VectorToArray=function(){Me("'heap32VectorToArray' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"requireRegisteredType")||(o.requireRegisteredType=function(){Me("'requireRegisteredType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getShiftFromSize")||(o.getShiftFromSize=function(){Me("'getShiftFromSize' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"integerReadValueFromPointer")||(o.integerReadValueFromPointer=function(){Me("'integerReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"enumReadValueFromPointer")||(o.enumReadValueFromPointer=function(){Me("'enumReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"floatReadValueFromPointer")||(o.floatReadValueFromPointer=function(){Me("'floatReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"simpleReadValueFromPointer")||(o.simpleReadValueFromPointer=function(){Me("'simpleReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"runDestructors")||(o.runDestructors=function(){Me("'runDestructors' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"new_")||(o.new_=function(){Me("'new_' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"craftInvokerFunction")||(o.craftInvokerFunction=function(){Me("'craftInvokerFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"embind__requireFunction")||(o.embind__requireFunction=function(){Me("'embind__requireFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"tupleRegistrations")||(o.tupleRegistrations=function(){Me("'tupleRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"structRegistrations")||(o.structRegistrations=function(){Me("'structRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"genericPointerToWireType")||(o.genericPointerToWireType=function(){Me("'genericPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"constNoSmartPtrRawPointerToWireType")||(o.constNoSmartPtrRawPointerToWireType=function(){Me("'constNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"nonConstNoSmartPtrRawPointerToWireType")||(o.nonConstNoSmartPtrRawPointerToWireType=function(){Me("'nonConstNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_RegisteredPointer")||(o.init_RegisteredPointer=function(){Me("'init_RegisteredPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer")||(o.RegisteredPointer=function(){Me("'RegisteredPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_getPointee")||(o.RegisteredPointer_getPointee=function(){Me("'RegisteredPointer_getPointee' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_destructor")||(o.RegisteredPointer_destructor=function(){Me("'RegisteredPointer_destructor' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_deleteObject")||(o.RegisteredPointer_deleteObject=function(){Me("'RegisteredPointer_deleteObject' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_fromWireType")||(o.RegisteredPointer_fromWireType=function(){Me("'RegisteredPointer_fromWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"runDestructor")||(o.runDestructor=function(){Me("'runDestructor' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"releaseClassHandle")||(o.releaseClassHandle=function(){Me("'releaseClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"finalizationGroup")||(o.finalizationGroup=function(){Me("'finalizationGroup' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"detachFinalizer_deps")||(o.detachFinalizer_deps=function(){Me("'detachFinalizer_deps' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"detachFinalizer")||(o.detachFinalizer=function(){Me("'detachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"attachFinalizer")||(o.attachFinalizer=function(){Me("'attachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"makeClassHandle")||(o.makeClassHandle=function(){Me("'makeClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_ClassHandle")||(o.init_ClassHandle=function(){Me("'init_ClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle")||(o.ClassHandle=function(){Me("'ClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_isAliasOf")||(o.ClassHandle_isAliasOf=function(){Me("'ClassHandle_isAliasOf' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwInstanceAlreadyDeleted")||(o.throwInstanceAlreadyDeleted=function(){Me("'throwInstanceAlreadyDeleted' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_clone")||(o.ClassHandle_clone=function(){Me("'ClassHandle_clone' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_delete")||(o.ClassHandle_delete=function(){Me("'ClassHandle_delete' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"deletionQueue")||(o.deletionQueue=function(){Me("'deletionQueue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_isDeleted")||(o.ClassHandle_isDeleted=function(){Me("'ClassHandle_isDeleted' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_deleteLater")||(o.ClassHandle_deleteLater=function(){Me("'ClassHandle_deleteLater' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"flushPendingDeletes")||(o.flushPendingDeletes=function(){Me("'flushPendingDeletes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"delayFunction")||(o.delayFunction=function(){Me("'delayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setDelayFunction")||(o.setDelayFunction=function(){Me("'setDelayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredClass")||(o.RegisteredClass=function(){Me("'RegisteredClass' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"shallowCopyInternalPointer")||(o.shallowCopyInternalPointer=function(){Me("'shallowCopyInternalPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"downcastPointer")||(o.downcastPointer=function(){Me("'downcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"upcastPointer")||(o.upcastPointer=function(){Me("'upcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"validateThis")||(o.validateThis=function(){Me("'validateThis' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"char_0")||(o.char_0=function(){Me("'char_0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"char_9")||(o.char_9=function(){Me("'char_9' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"makeLegalFunctionName")||(o.makeLegalFunctionName=function(){Me("'makeLegalFunctionName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"warnOnce")||(o.warnOnce=function(){Me("'warnOnce' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackSave")||(o.stackSave=function(){Me("'stackSave' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackRestore")||(o.stackRestore=function(){Me("'stackRestore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackAlloc")||(o.stackAlloc=function(){Me("'stackAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"AsciiToString")||(o.AsciiToString=function(){Me("'AsciiToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToAscii")||(o.stringToAscii=function(){Me("'stringToAscii' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UTF16ToString")||(o.UTF16ToString=function(){Me("'UTF16ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF16")||(o.stringToUTF16=function(){Me("'stringToUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"lengthBytesUTF16")||(o.lengthBytesUTF16=function(){Me("'lengthBytesUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UTF32ToString")||(o.UTF32ToString=function(){Me("'UTF32ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF32")||(o.stringToUTF32=function(){Me("'stringToUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"lengthBytesUTF32")||(o.lengthBytesUTF32=function(){Me("'lengthBytesUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"allocateUTF8")||(o.allocateUTF8=function(){Me("'allocateUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"allocateUTF8OnStack")||(o.allocateUTF8OnStack=function(){Me("'allocateUTF8OnStack' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),o.writeStackCookie=ae,o.checkStackCookie=ce,Object.getOwnPropertyDescriptor(o,"ALLOC_NORMAL")||Object.defineProperty(o,"ALLOC_NORMAL",{configurable:!0,get:function(){Me("'ALLOC_NORMAL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Object.getOwnPropertyDescriptor(o,"ALLOC_STACK")||Object.defineProperty(o,"ALLOC_STACK",{configurable:!0,get:function(){Me("'ALLOC_STACK' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Object.getOwnPropertyDescriptor(o,"ALLOC_DYNAMIC")||Object.defineProperty(o,"ALLOC_DYNAMIC",{configurable:!0,get:function(){Me("'ALLOC_DYNAMIC' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Object.getOwnPropertyDescriptor(o,"ALLOC_NONE")||Object.defineProperty(o,"ALLOC_NONE",{configurable:!0,get:function(){Me("'ALLOC_NONE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Pe=function e(){jn||Qn(),jn||(Pe=e)},o.run=Qn,o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return w=!0,Qn(),e.ready});e.exports=r},351:()=>{},606:()=>{}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}n(590),n(261)})(); \ No newline at end of file +(()=>{var e={261:()=>{AFRAME.registerComponent("stats-panel",{schema:{merge:{type:"boolean",default:!0}},init(){const e=document.querySelector(".rs-container");if(e&&this.data.merge)return void(this.container=e);this.base=document.createElement("div"),this.base.classList.add("rs-base");const t=document.body||document.getElementsByTagName("body")[0];e&&!this.data.merge&&(this.base.style.top="auto",this.base.style.bottom="20px"),t.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 e;const t=this.el.components["stats-panel"];e=t?t.container:document.querySelector(".rs-container"),e?(this.groupHeader=document.createElement("h1"),this.groupHeader.innerHTML=this.data.label,e.appendChild(this.groupHeader),this.group=document.createElement("div"),this.group.classList.add("rs-group"),this.group.style.flexDirection="column",this.group.style.webKitFlexDirection="column",e.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 e="stats-group__"+this.data.group,t=this.el.components[e]||this.el.sceneEl.components[e]||this.el.components["stats-group"]||this.el.sceneEl.components["stats-group"];t?(this.counter=document.createElement("div"),this.counter.classList.add("rs-counter-base"),t.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((e=>{const t=document.createElement("div");t.classList.add("rs-counter-value"),t.innerHTML="...",this.counter.appendChild(t),this.counterValues[e]=t})),this.updateData=this.updateData.bind(this),this.el.addEventListener(this.data.event,this.updateData),this.splitCache={}):console.warn(`Couldn't find stats group ${e}`)},updateData(e){this.data.properties.forEach((t=>{const n=this.splitDot(t);let r=e.detail;for(i=0;i{this.outputDetail[e]={}})),this.statsReceived=this.statsReceived.bind(this),this.el.addEventListener(this.data.inEvent,this.statsReceived)},resetData(){this.counter=0,this.data.properties.forEach((e=>{this.statsData[e]=[]}))},statsReceived(e){this.updateData(e.detail),this.counter++,this.counter===this.data.outputFrequency&&(this.outputData(),this.resetData())},updateData(e){this.data.properties.forEach((t=>{let i=e;i=i[t],this.statsData[t].push(i)}))},outputData(){this.data.properties.forEach((e=>{this.data.outputs.forEach((t=>{this.outputDetail[e][t]=this.computeOutput(t,this.statsData[e])}))})),this.data.outEvent&&this.el.emit(this.data.outEvent,this.outputDetail),this.data.outputToConsole&&console.log(this.data.outputToConsole,this.outputDetail)},computeOutput(e,t){const i=e.split("__");let n;switch(i[0]){case"mean":n=t.reduce(((e,t)=>e+t),0)/t.length;break;case"max":n=Math.max(...t);break;case"min":n=Math.min(...t);break;case"percentile":const e=t.sort(((e,t)=>e-t)),r=+i[1].replace("_",".")/100,o=(t.length-1)*r,s=Math.floor(o),a=o-s;n=void 0!==e[s+1]?e[s]+a*(e[s+1]-e[s]):e[s]}return n.toFixed(2)}})},590:(e,t,i)=>{let n=i(651);function r(e,t){return this.system._pool[e]||(this.system._pool[e]=new t),this.system._pool[e]}function o(e,t){return this._pool[e]||(this._pool[e]=new t),this._pool[e]}function s(e,t){e.hasLoaded?t():e.addEventListener("loaded",t)}function a(e){return new Promise(((t,i)=>s(e,t)))}Util={},class{static init(e,{useSystem:t=!1}={}){t?(e.system||console.error("No system for system pool",e.attrName),e.system._pool||(e.system._pool={}),e.pool=r):(e._pool={},e.pool=o)}}.init(Util),Util.applyMatrix=function(e,t){t.matrix.copy(e),e.decompose(t.position,t.rotation,t.scale)},Util.traverseCondition=function(e,t,i){if(t(e)){i(e);for(let n of e.children)this.traverseCondition(n,t,i)}},Util.positionObject3DAtTarget=function(e,t,{scale:i,transformOffset:n,transformRoot:r}={}){void 0===r&&(r=e.parent),t.updateWorldMatrix();let o=this.pool("dest",THREE.Matrix4);if(o.copy(t.matrixWorld),n){let e=this.pool("transformMat",THREE.Matrix4);e.makeTranslation(n.x,n.y,n.z),o.multiply(e)}if(i){let e=this.pool("scale",THREE.Vector3);e.setFromMatrixScale(o),e.set(i.x/e.x,i.y/e.y,i.z/e.z),o.scale(e)}let s=this.pool("inv",THREE.Matrix4);r.updateWorldMatrix(),s.copy(r.matrixWorld).invert(),o.premultiply(s),Util.applyMatrix(o,e)},Util.whenLoaded=function(e,t){return Array.isArray(e)&&t?function(e,t){let i=e.map((()=>!1));for(let n=0;n{i[r]=!0,i.every((e=>e))&&t()}))}}(e,t):Array.isArray(e)?async function(e){for(let t of e)await a(t)}(e):t?s(e,t):a(e)},Util.whenComponentInitialized=function(e,t,i){return e&&e.components[t]&&e.components[t].initialized?Promise.resolve(i?i():void 0):new Promise(((n,r)=>{if(e&&e.components[t]&&e.components[t].initialized)return Promise.resolve(i?i():void 0);let o=r=>{r.detail.name===t&&(e.removeEventListener("componentinitialized",o),i&&i(),n())};e.addEventListener("componentinitialized",o)}))};const c={object3DPhysXTransform:(()=>{let e=new THREE.Vector3,t=new THREE.Quaternion;return function(i){return i.getWorldPosition(e),i.getWorldQuaternion(t),{translation:{x:e.x,y:e.y,z:e.z},rotation:{w:t.w,x:t.x,y:t.y,z:t.z}}}})(),matrixToTransform:(()=>{let e=new THREE.Vector3,t=new THREE.Quaternion,i=new THREE.Vector3;return new THREE.Matrix4,new THREE.Matrix4,function(n){return n.decompose(e,t,i),{translation:{x:e.x,y:e.y,z:e.z},rotation:{w:t.w,x:t.x,y:t.y,z:t.z}}}})(),layersToMask:(()=>{let e=new THREE.Layers;return function(t){e.disableAll();for(let i of t)e.enable(parseInt(i));return e.mask}})(),axisArrayToEnums:function(e){let t=[];for(let i of e){if("swing"===i){t.push(d.PxD6Axis.eSWING1),t.push(d.PxD6Axis.eSWING2);continue}let e=`e${i.toUpperCase()}`;e in d.PxD6Axis||console.warn(`Unknown axis ${i} (PxD6Axis::${e})`),t.push(d.PxD6Axis[e])}return t}};let d;AFRAME.registerSystem("physx",{schema:{delay:{default:5e3},throttle:{default:10},autoLoad:{default:!1},speed:{default:1},wasmUrl:{default:"https://cdn.jsdelivr.net/gh/c-frame/physx/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 e=document.createElement("a-entity");this.el.append(e),this.defaultTarget=e,this.initializePhysX=new Promise(((e,t)=>{this.fulfillPhysXPromise=e})),this.initStats(),this.el.addEventListener("inspectortoggle",(e=>{console.log("Inspector toggle",e),!0===e.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 e=this.el.sceneEl,t="   ";e.setAttribute("stats-panel",""),e.setAttribute("stats-group__bodies","label: Physics Bodies"),e.setAttribute("stats-row__b1","group: bodies;\n event:physics-body-data;\n properties: staticBodies;\n label: Static"),e.setAttribute("stats-row__b2","group: bodies;\n event:physics-body-data;\n properties: dynamicBodies;\n label: Dynamic"),e.setAttribute("stats-row__b3","group: bodies;\n event:physics-body-data;\n properties: kinematicBodies;\n label: Kinematic"),e.setAttribute("stats-group__tick",`label: Physics Ticks: Median${t}90th%${t}99th%`),e.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"),e.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"),e.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 e,t=this,i=new Promise(((t,i)=>e=t));d=n({locateFile:()=>t.findWasm(),onRuntimeInitialized(){e()}}),d instanceof Promise&&(d=await d),this.PhysX=d,await i,t.startPhysXScene(),t.physXInitialized=!0,t.fulfillPhysXPromise(),t.el.emit("physx-started",{})},startPhysXScene(){console.info("Starting PhysX scene");const e=d.PxCreateFoundation(d.PX_PHYSICS_VERSION,new d.PxDefaultAllocator,new d.PxDefaultErrorCallback);this.foundation=e;const t=d.PxSimulationEventCallback.implement({onContactBegin:(e,t,i,n)=>{let r=this.shapeMap.get(e.$$.ptr),o=this.shapeMap.get(t.$$.ptr);o!==r&&(r&&r.data.emitCollisionEvents&&(this.collisionObject.thisShape=e,this.collisionObject.otherShape=t,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=t,this.collisionObject.otherShape=e,this.collisionObject.points=i,this.collisionObject.impulses=n,this.collisionObject.otherComponent=r,o.el.emit("contactbegin",this.collisionObject)))},onContactEnd:(e,t)=>{let i=this.shapeMap.get(e.$$.ptr),n=this.shapeMap.get(t.$$.ptr);n!==i&&(i&&i.data.emitCollisionEvents&&(this.collisionObject.thisShape=e,this.collisionObject.otherShape=t,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=t,this.collisionObject.otherShape=e,this.collisionObject.points=null,this.collisionObject.impulses=null,this.collisionObject.otherComponent=i,n.el.emit("contactend",this.collisionObject)))},onContactPersist:()=>{},onTriggerBegin:()=>{},onTriggerEnd:()=>{},onConstraintBreak:e=>{let t=this.jointMap.get(e.$$.ptr);t&&t.el.emit("constraintbreak",{})}});let i=new d.PxTolerancesScale;this.physics=d.PxCreatePhysics(d.PX_PHYSICS_VERSION,e,i,!1,null),d.PxInitExtensions(this.physics,null),this.cooking=d.PxCreateCooking(d.PX_PHYSICS_VERSION,e,new d.PxCookingParams(i));const n=d.getDefaultSceneDesc(this.physics.getTolerancesScale(),0,t);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 e=new d.PxPlaneGeometry,t=this.physics.createMaterial(.8,.8,.1);const i=this.physics.createShape(e,t,!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 e=new d.PxPlaneGeometry,t=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(e,t,!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(e,{type:t}){await this.initializePhysX;const i=c.object3DPhysXTransform(e.el.object3D);let n;n="dynamic"===t||"kinematic"===t?this.physics.createRigidDynamic(i):this.physics.createRigidStatic(i);let r=!0,o=!1,s=new d.VectorPxReal;for(let t of e.createShapes(this.physics,this.defaultActorFlags))n.attachShape(t),isFinite(t.density)?(o=!0,s.push_back(t.density)):(r=!1,o&&console.warn("Densities not set for all shapes. Will use total mass instead.",e.el));"dynamic"!==t&&"kinematic"!==t||(r&&o?(console.log("Setting density vector",s),n.updateMassAndInertia(s)):n.setMassAndUpdateInertia(e.data.mass)),s.delete(),this.scene.addActor(n,null),this.objects.set(e.el.object3D,n),e.rigidBody=n},registerShape(e,t){this.shapeMap.set(e.$$.ptr,t)},registerJoint(e,t){this.jointMap.set(e.$$.ptr,t)},removeBody(e){let t=e.rigidBody;this.objects.delete(e.el.object3D),t.release()},tock(e,t){if(e{const n=i.el.components["physx-body"].data.type,r=this.bodyTypeToStatsPropertyMap[n];e[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(e){"grabbed"===e.detail&&this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eKINEMATIC,!0)},stateremoved:function(e){"grabbed"===e.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(e){this.toggleGravity()},componentchanged:function(e){"physx-material"===e.name&&this.el.emit("object3dset",{})},object3dset:function(e){if(this.rigidBody){for(let e of this.shapes)this.rigidBody.detachShape(e,!1);let e=!0,t=!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)?(t=!0,i.push_back(r.density)):(e=!1,t&&console.warn("Densities not set for all shapes. Will use total mass instead.",n.el));"dynamic"!==r&&"kinematic"!==r||(e&&t?(console.log("Setting density vector",i),o.updateMassAndInertia(i)):o.setMassAndUpdateInertia(n.data.mass))}},contactbegin:function(e){}},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(e){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&&(this.rigidBody.setSolverIterationCounts(4,2),"dynamic"===this.data.type?this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eENABLE_CCD,!0):"kinematic"===this.data.type&&this.rigidBody.setRigidBodyFlag(d.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD,!0)),e&&this.data.mass===e.mass||this.el.emit("object3dset",{}))},remove(){this.rigidBody&&this.system.removeBody(this)},createGeometry(e){if(e.el.hasAttribute("geometry")){let t=e.el.getAttribute("geometry");switch(t.primitive){case"sphere":return new d.PxSphereGeometry(t.radius*this.el.object3D.scale.x*.98);case"box":return new d.PxBoxGeometry(t.width/2,t.height/2,t.depth/2);default:return this.createConvexMeshGeometry(e.el.getObject3D("mesh"))}}},createConvexMeshGeometry(e,t){let i=new d.PxVec3Vector,n=e.geometry.attributes.position;if(!n)return;if(n.count<3)return;if(3!=n.itemSize)return;let r=new THREE.Vector3;if(t){let o=new THREE.Matrix4;e.updateMatrix(),o.copy(e.matrix);let s=e.parent;for(;s&&s!==t;)s.updateMatrix(),o.premultiply(s.matrix),s=s.parent;for(let e=0;e=0&&r.setContactOffset(i.contactOffset),i.restOffset>=0&&r.setRestOffset(i.restOffset),r.density=i.density,this.system.registerShape(r,this),r},createShapes(e){if(this.el.hasAttribute("geometry")){let t=this.createGeometry(this.el.object3D);if(!t)return;let i=this.el.components["physx-material"].data;return this.shapes=[this.createShape(e,t,i)],this.shapes}let t=[];return Util.traverseCondition(this.el.object3D,(e=>!(e.el&&e.el.hasAttribute("physx-no-collision")||e.el&&!e.el.object3D.visible&&!e.el.hasAttribute("physx-hidden-collision")||!e.visible&&e.el&&!e.el.hasAttribute("physx-hidden-collision")||e.userData&&e.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(e,n,r);t.push(o)}})),this.shapes=t,t},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(e,t){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(e){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 e=this.el.sceneEl.systems.physx.PhysX;this.joint=this.el.components["physx-joint"].joint,this.data.lockOtherAxes&&(this.joint.setMotion(e.PxD6Axis.eX,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eY,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eZ,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eSWING1,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eSWING2,e.PxD6Motion.eLOCKED),this.joint.setMotion(e.PxD6Axis.eTWIST,e.PxD6Motion.eLOCKED));for(let t of this.enumAxes)this.joint.setMotion(t,e.PxD6Motion.eFREE);let t=new e.PxD6JointDrive;t.stiffness=this.data.stiffness,t.damping=this.data.damping,t.forceLimit=this.data.forceLimit,t.setAccelerationFlag(this.data.useAcceleration);for(let e of this.driveAxes)this.joint.setDrive(e,t);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(e){if(d){this.enumAxes=[];for(let e of this.data.axes){if("swing"===e){this.enumAxes.push(d.PxD6Axis.eSWING1),this.enumAxes.push(d.PxD6Axis.eSWING2);continue}let t=`e${e.toUpperCase()}`;t in d.PxD6Axis||console.warn(`Unknown axis ${e} (PxD6Axis::${t})`),this.enumAxes.push(d.PxD6Axis[t])}this.driveAxes=[];for(let e of this.data.axes){if("swing"===e){this.data.slerpRotation?this.driveAxes.push(d.PxD6Drive.eSLERP):this.driveAxes.push(d.PxD6Drive.eSWING);continue}if("twist"===e&&this.data.slerpRotation){this.driveAxes.push(d.PxD6Drive.eSLERP);continue}let t=`e${e.toUpperCase()}`;t in d.PxD6Drive||console.warn(`Unknown axis ${e} (PxD6Axis::${t})`),this.driveAxes.push(d.PxD6Drive[t])}}}}),AFRAME.registerComponent("physx-joint-constraint",{multiple:!0,schema:{lockedAxes:{type:"array",default:[]},constrainedAxes:{type:"array",default:[]},freeAxes:{type:"array",default:[]},linearLimit:{type:"vec2"},limitCone:{type:"vec2"},twistLimit:{type:"vec2"},damping:{default:0},restitution:{default:0},stiffness:{default:0}},events:{"physx-jointcreated":function(e){this.setJointConstraint()}},init(){this.el.setAttribute("phsyx-custom-constraint","")},setJointConstraint(){if("D6"!==this.el.components["physx-joint"].data.type)return void console.warn("Only D6 joint constraints supported at the moment");this.constrainedAxes||this.update();let e=this.el.components["physx-joint"].joint,t=()=>{let e=new d.PxJointLinearLimitPair(new d.PxTolerancesScale,this.data.linearLimit.x,this.data.linearLimit.y);return e.stiffness=this.data.stiffness,e.damping=this.data.damping,e.restitution=this.data.restitution,e};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());continue}if(i===d.eTWIST){e.setMotion(d.PxD6Axis.eTWIST,d.PxD6Motion.eLIMITED);let t=new d.PxJointAngularLimitPair(this.data.limitTwist.x,this.data.limitTwist.y);t.stiffness=this.data.stiffness,t.damping=this.data.damping,t.restitution=this.data.restitution,e.setTwistLimit(t);continue}e.setMotion(i,d.PxD6Motion.eLIMITED);let n=new d.PxJointLimitCone(this.data.limitCone.x,this.data.limitCone.y);n.damping=this.data.damping,n.stiffness=this.data.stiffness,n.restitution=this.data.restitution,e.setSwingLimit(n)}},update(e){d&&(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}},events:{constraintbreak:function(e){this.data.removeElOnBreak&&this.el.remove()}},init(){this.system=this.el.sceneEl.systems.physx;let e=this.el;for(;e&&!e.hasAttribute("physx-body");)e=e.parentEl;e?(this.bodyEl=e,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,this.data.breakForce.y),this.joint.setConstraintFlag(d.PxConstraintFlag.eCOLLISION_ENABLED,this.data.collideWithTarget),!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 e=new d.PxD6JointDrive;e.stiffness=1e3,e.damping=500,e.forceLimit=1e3,e.setAccelerationFlag(!1),this.joint.setDrive(d.PxD6Drive.eX,e),this.joint.setDrive(d.PxD6Drive.eY,e),this.joint.setDrive(d.PxD6Drive.eZ,e),this.joint.setDrive(d.PxD6Drive.eSLERP,e),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(e){return Util.positionObject3DAtTarget(this.worldHelperParent,e.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 e=this.getTransform(this.bodyEl),t=this.getTransform(this.data.target);this.joint=d[`Px${this.data.type}JointCreate`](this.system.physics,this.bodyEl.components["physx-body"].rigidBody,e,this.data.target.components["physx-body"].rigidBody,t),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(e){if(this.el.sceneEl.time`,i=i.children[0],this.data.allowedAttributes.length)for(let e of i.attributes)this.data.allowedAttributes.includes(e.name)||i.removeAttribute(e.name);this.data.setId&&e.name&&(i.id=`${this.data.idPrefix}${e.name}`);for(let e of this.data.copyAttributes)this.el.hasAttribute(e)&&i.setAttribute(e,this.el.getAttribute(e));this.data.autoPropogateGrab&&this.el.classList.contains("clickable")&&(i.setAttribute("propogate-grab",""),i.classList.add("clickable")),t.append(i),Util.whenLoaded(i,(()=>{i.setObject3D("mesh",e),e.updateMatrix(),Util.applyMatrix(e.matrix,i.object3D),e.matrix.identity(),Util.applyMatrix(e.matrix,e)})),t=i}for(let i of e.children)this.setupObject(i,t)}})},651:(e,t,i)=>{var n,r=(n=(n="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){var t,r,o=void 0!==(e=e||{})?e:{};o.ready=new Promise((function(e,i){t=e,r=i})),Object.getOwnPropertyDescriptor(o.ready,"_main")||(Object.defineProperty(o.ready,"_main",{configurable:!0,get:function(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(e,t){throw t},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,y,E,_,T="";function g(e){return o.locateFile?o.locateFile(e,T):T+e}if(p)T=u?i(606).dirname(T)+"/":"//",f=function(e,t){return E||(E=i(351)),_||(_=i(606)),e=_.normalize(e),E.readFileSync(e,t?null:"utf8")},y=function(e){var t=f(e,!0);return t.buffer||(t=new Uint8Array(t)),M(t.buffer),t},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),c=process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof Ln))throw e})),process.on("unhandledRejection",Me),d=function(e){process.exit(e)},o.inspect=function(){return"[Emscripten Module object]"};else if(h)"undefined"!=typeof read&&(f=function(e){return read(e)}),y=function(e){var t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(M("object"==typeof(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs?c=scriptArgs:void 0!==arguments&&(c=arguments),"function"==typeof quit&&(d=function(e){quit(e)}),"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(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},u&&(y=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.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(e){D.shown||(D.shown={}),D.shown[e]||(D.shown[e]=1,m(e))}a=null,o.arguments&&(c=o.arguments),Object.getOwnPropertyDescriptor(o,"arguments")||Object.defineProperty(o,"arguments",{configurable:!0,get:function(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("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(){Me("Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}});var b,w,P,R=function(e){};o.wasmBinary&&(b=o.wasmBinary),Object.getOwnPropertyDescriptor(o,"wasmBinary")||Object.defineProperty(o,"wasmBinary",{configurable:!0,get:function(){Me("Module.wasmBinary has been replaced with plain wasmBinary (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.noExitRuntime&&(w=o.noExitRuntime),Object.getOwnPropertyDescriptor(o,"noExitRuntime")||Object.defineProperty(o,"noExitRuntime",{configurable:!0,get:function(){Me("Module.noExitRuntime has been replaced with plain noExitRuntime (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"!=typeof WebAssembly&&Me("No WebAssembly support found. Build with -s WASM=0 to target JavaScript instead.");var A=new WebAssembly.Table({initial:3864,maximum:3864,element:"anyfunc"}),v=!1;function M(e,t){e||Me("Assertion failed: "+t)}var x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function S(e,t,i){for(var n=t+i,r=t;e[r]&&!(r>=n);)++r;if(r-t>16&&e.subarray&&x)return x.decode(e.subarray(t,r));for(var o="";t>10,56320|1023&d)}}else o+=String.fromCharCode((31&s)<<6|a)}else o+=String.fromCharCode(s)}return o}function F(e,t){return e?S(B,e,t):""}function j(e,t,i,n){if(!(n>0))return 0;for(var r=i,o=i+n-1,s=0;s=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s)),a<=127){if(i>=o)break;t[i++]=a}else if(a<=2047){if(i+1>=o)break;t[i++]=192|a>>6,t[i++]=128|63&a}else if(a<=65535){if(i+2>=o)break;t[i++]=224|a>>12,t[i++]=128|a>>6&63,t[i++]=128|63&a}else{if(i+3>=o)break;a>=2097152&&D("Invalid Unicode code point 0x"+a.toString(16)+" encountered when serializing a JS string to an UTF-8 string on the asm.js/wasm heap! (Valid unicode code points should be in range 0-0x1FFFFF)."),t[i++]=240|a>>18,t[i++]=128|a>>12&63,t[i++]=128|a>>6&63,t[i++]=128|63&a}}return t[i]=0,i-r}function C(e,t,i){return M("number"==typeof i,"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),j(e,B,t,i)}function I(e){for(var t=0,i=0;i=55296&&n<=57343&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++i)),n<=127?++t:t+=n<=2047?2:n<=65535?3:4}return t}var X="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function U(e,t){M(e%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");for(var i=e,n=i>>1,r=n+t/2;!(n>=r)&&z[n];)++n;if((i=n<<1)-e>32&&X)return X.decode(B.subarray(e,i));for(var o=0,s="";;){var a=G[e+2*o>>1];if(0==a||o==t/2)return s;++o,s+=String.fromCharCode(a)}}function N(e,t,i){if(M(t%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),M("number"==typeof i,"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),void 0===i&&(i=2147483647),i<2)return 0;for(var n=t,r=(i-=2)<2*e.length?i/2:e.length,o=0;o>1]=s,t+=2}return G[t>>1]=0,t-n}function H(e){return 2*e.length}function k(e,t){M(e%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var i=0,n="";!(i>=t/4);){var r=V[e+4*i>>2];if(0==r)break;if(++i,r>=65536){var o=r-65536;n+=String.fromCharCode(55296|o>>10,56320|1023&o)}else n+=String.fromCharCode(r)}return n}function L(e,t,i){if(M(t%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),M("number"==typeof i,"stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),void 0===i&&(i=2147483647),i<4)return 0;for(var n=t,r=n+i-4,o=0;o=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),V[t>>2]=s,(t+=4)+4>r)break}return V[t>>2]=0,t-n}function Q(e){for(var t=0,i=0;i=55296&&n<=57343&&++i,t+=4}return t}var $,W,B,G,z,V,Y,Z,q,J=65536;function K(e,t){return e%t>0&&(e+=t-e%t),e}function ee(e){$=e,o.HEAP8=W=new Int8Array(e),o.HEAP16=G=new Int16Array(e),o.HEAP32=V=new Int32Array(e),o.HEAPU8=B=new Uint8Array(e),o.HEAPU16=z=new Uint16Array(e),o.HEAPU32=Y=new Uint32Array(e),o.HEAPF32=Z=new Float32Array(e),o.HEAPF64=q=new Float64Array(e)}var te=5431632,ie=188752,ne=5431632,re=188592;M(te%16==0,"stack must start aligned"),M(ne%16==0,"heap must start aligned");var oe=5242880;o.TOTAL_STACK&&M(oe===o.TOTAL_STACK,"the stack size can no longer be determined at runtime");var se=o.INITIAL_MEMORY||16777216;function ae(){M(0==(3&ie)),Y[1+(ie>>2)]=34821223,Y[2+(ie>>2)]=2310721022,V[0]=1668509029}function ce(){var e=Y[1+(ie>>2)],t=Y[2+(ie>>2)];34821223==e&&2310721022==t||Me("Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+t.toString(16)+" "+e.toString(16)),1668509029!==V[0]&&Me("Runtime error: The application has corrupted its heap memory area (address zero)!")}function de(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var i=t.func;"number"==typeof i?void 0===t.arg?o.dynCall_v(i):o.dynCall_vi(i,t.arg):i(void 0===t.arg?null:t.arg)}else t(o)}}Object.getOwnPropertyDescriptor(o,"INITIAL_MEMORY")||Object.defineProperty(o,"INITIAL_MEMORY",{configurable:!0,get:function(){Me("Module.INITIAL_MEMORY has been replaced with plain INITIAL_INITIAL_MEMORY (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(se>=oe,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+se+"! (TOTAL_STACK="+oe+")"),M("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&void 0!==Int32Array.prototype.subarray&&void 0!==Int32Array.prototype.set,"JS engine does not provide full typed array support"),(P=o.wasmMemory?o.wasmMemory:new WebAssembly.Memory({initial:se/J,maximum:2147483648/J}))&&($=P.buffer),M((se=$.byteLength)%J==0),M(65536%J==0),ee($),V[re>>2]=ne,function(){var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian!"}();var le=[],ue=[],pe=[],he=[],fe=!1,ye=!1;function Ee(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)me(o.preRun.shift());de(le)}function _e(){ce(),M(!fe),fe=!0,de(ue)}function Te(){ce(),de(pe)}function ge(){ce(),ye=!0}function Oe(){if(ce(),o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)De(o.postRun.shift());de(he)}function me(e){le.unshift(e)}function De(e){he.unshift(e)}M(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),M(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),M(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),M(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),Math.abs,Math.ceil,Math.floor,Math.min;var be=0,we=null,Pe=null,Re={};function Ae(e){be++,o.monitorRunDependencies&&o.monitorRunDependencies(be),e?(M(!Re[e]),Re[e]=1,null===we&&"undefined"!=typeof setInterval&&(we=setInterval((function(){if(v)return clearInterval(we),void(we=null);var e=!1;for(var t in Re)e||(e=!0,m("still waiting on run dependencies:")),m("dependency: "+t);e&&m("(end of list)")}),1e4))):m("warning: run dependency added without ID")}function ve(e){if(be--,o.monitorRunDependencies&&o.monitorRunDependencies(be),e?(M(Re[e]),delete Re[e]):m("warning: run dependency removed without ID"),0==be&&(null!==we&&(clearInterval(we),we=null),Pe)){var t=Pe;Pe=null,t()}}function Me(e){throw o.onAbort&&o.onAbort(e),O(e+=""),m(e),v=!0,e="abort("+e+") at "+We(),new WebAssembly.RuntimeError(e)}o.preloadedImages={},o.preloadedAudios={};var xe={error:function(){Me("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -s FORCE_FILESYSTEM=1")},init:function(){xe.error()},createDataFile:function(){xe.error()},createPreloadedFile:function(){xe.error()},createLazyFile:function(){xe.error()},open:function(){xe.error()},mkdev:function(){xe.error()},registerDevice:function(){xe.error()},analyzePath:function(){xe.error()},loadFilesFromDB:function(){xe.error()},ErrnoError:function(){xe.error()}};function Se(e,t){return String.prototype.startsWith?e.startsWith(t):0===e.indexOf(t)}o.FS_createDataFile=xe.createDataFile,o.FS_createPreloadedFile=xe.createPreloadedFile;var Fe="data:application/octet-stream;base64,";function je(e){return Se(e,Fe)}var Ce="file://";function Ie(e){return Se(e,Ce)}function Xe(e,t){return function(){var i=e,n=t;return t||(n=o.asm),M(fe,"native function `"+i+"` called before runtime initialization"),M(!ye,"native function `"+i+"` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)"),n[e]||M(n[e],"exported native function `"+i+"` not found"),n[e].apply(null,arguments)}}var Ue="physx.release.wasm";function Ne(){try{if(b)return new Uint8Array(b);if(y)return y(Ue);throw"both async and sync fetching of the wasm failed"}catch(e){Me(e)}}function He(){return b||!l&&!u||"function"!=typeof fetch||Ie(Ue)?new Promise((function(e,t){e(Ne())})):fetch(Ue,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Ue+"'";return e.arrayBuffer()})).catch((function(){return Ne()}))}function ke(){var e={env:Cn,wasi_snapshot_preview1:Cn};function t(e,t){var i=e.exports;o.asm=i,ve("wasm-instantiate")}Ae("wasm-instantiate");var i=o;function n(e){M(o===i,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),i=null,t(e.instance)}function r(t){return He().then((function(t){return WebAssembly.instantiate(t,e)})).then(t,(function(e){m("failed to asynchronously prepare wasm: "+e),Me(e)}))}if(o.instantiateWasm)try{return o.instantiateWasm(e,t)}catch(e){return m("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(b||"function"!=typeof WebAssembly.instantiateStreaming||je(Ue)||Ie(Ue)||"function"!=typeof fetch)return r(n);fetch(Ue,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return m("wasm streaming compile failed: "+e),m("falling back to ArrayBuffer instantiation"),r(n)}))}))}(),{}}function Le(e){return D("warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling"),e}function Qe(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){var t=Le(e);return e===t?e:t+" ["+e+"]"}))}function $e(){var e=new Error;if(!e.stack){try{throw new Error}catch(t){e=t}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function We(){var e=$e();return o.extraStackTrace&&(e+="\n"+o.extraStackTrace()),Qe(e)}function Be(){Me("stack overflow")}je(Ue)||(Ue=g(Ue)),ue.push({func:function(){In()}});var Ge=48,ze=57;function Ve(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=Ge&&t<=ze?"_"+e:e}function Ye(e,t){return e=Ve(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}var Ze=[],qe=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Je(){for(var e=0,t=5;t>2])}var jt={},Ct={},It=void 0;function Xt(e){throw new It(e)}function Ut(e,t,i){function n(t){var n=i(t);n.length!==e.length&&Xt("Mismatched type converter count");for(var r=0;r>o])},destructorFunction:null})}function Qt(e){if(!(this instanceof Zt))return!1;if(!(e instanceof Zt))return!1;for(var t=this.$$.ptrType.registeredClass,i=this.$$.ptr,n=e.$$.ptrType.registeredClass,r=e.$$.ptr;t.baseClass;)i=t.upcast(i),t=t.baseClass;for(;n.baseClass;)r=n.upcast(r),n=n.baseClass;return t===n&&i===r}function $t(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function Wt(e){Et(e.$$.ptrType.registeredClass.name+" instance already deleted")}function Bt(){if(this.$$.ptr||Wt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=vt(Object.create(Object.getPrototypeOf(this),{$$:{value:$t(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function Gt(){this.$$.ptr||Wt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Et("Object already scheduled for deletion"),wt(this),At(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function zt(){return!this.$$.ptr}function Vt(){return this.$$.ptr||Wt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Et("Object already scheduled for deletion"),dt.push(this),1===dt.length&&ut&&ut(lt),this.$$.deleteScheduled=!0,this}function Yt(){Zt.prototype.isAliasOf=Qt,Zt.prototype.clone=Bt,Zt.prototype.delete=Gt,Zt.prototype.isDeleted=zt,Zt.prototype.deleteLater=Vt}function Zt(){}var qt={};function Jt(e,t,i){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||Et("Function '"+i+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].overloadTable+")!"),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function Kt(e,t,i){o.hasOwnProperty(e)?((void 0===i||void 0!==o[e].overloadTable&&void 0!==o[e].overloadTable[i])&&Et("Cannot register public name '"+e+"' twice"),Jt(o,e,e),o.hasOwnProperty(i)&&Et("Cannot register multiple overloads of a function with the same number of arguments ("+i+")!"),o[e].overloadTable[i]=t):(o[e]=t,void 0!==i&&(o[e].numArguments=i))}function ei(e,t,i,n,r,o,s,a){this.name=e,this.constructor=t,this.instancePrototype=i,this.rawDestructor=n,this.baseClass=r,this.getActualType=o,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function ti(e,t,i){for(;t!==i;)t.upcast||Et("Expected null or instance of "+i.name+", got an instance of "+t.name),e=t.upcast(e),t=t.baseClass;return e}function ii(e,t){if(null===t)return this.isReference&&Et("null is not a valid "+this.name),0;t.$$||Et('Cannot pass "'+ji(t)+'" as a '+this.name),t.$$.ptr||Et("Cannot pass deleted object as a pointer of type "+this.name);var i=t.$$.ptrType.registeredClass;return ti(t.$$.ptr,i,this.registeredClass)}function ni(e,t){var i;if(null===t)return this.isReference&&Et("null is not a valid "+this.name),this.isSmartPointer?(i=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,i),i):0;t.$$||Et('Cannot pass "'+ji(t)+'" as a '+this.name),t.$$.ptr||Et("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&t.$$.ptrType.isConst&&Et("Cannot convert argument of type "+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+" to parameter type "+this.name);var n=t.$$.ptrType.registeredClass;if(i=ti(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&Et("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?i=t.$$.smartPtr:Et("Cannot convert argument of type "+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:i=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)i=t.$$.smartPtr;else{var r=t.clone();i=this.rawShare(i,tt((function(){r.delete()}))),null!==e&&e.push(this.rawDestructor,i)}break;default:Et("Unsupporting sharing policy")}return i}function ri(e,t){if(null===t)return this.isReference&&Et("null is not a valid "+this.name),0;t.$$||Et('Cannot pass "'+ji(t)+'" as a '+this.name),t.$$.ptr||Et("Cannot pass deleted object as a pointer of type "+this.name),t.$$.ptrType.isConst&&Et("Cannot convert argument of type "+t.$$.ptrType.name+" to parameter type "+this.name);var i=t.$$.ptrType.registeredClass;return ti(t.$$.ptr,i,this.registeredClass)}function oi(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function si(e){this.rawDestructor&&this.rawDestructor(e)}function ai(e){null!==e&&e.delete()}function ci(e,t,i){if(t===i)return e;if(void 0===i.baseClass)return null;var n=ci(e,t,i.baseClass);return null===n?null:i.downcast(n)}function di(e,t){return t=_t(e,t),ft[t]}function li(e,t){return t.ptrType&&t.ptr||Xt("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&Xt("Both smartPtrType and smartPtr must be specified"),t.count={value:1},vt(Object.create(e,{$$:{value:t}}))}function ui(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var i=di(this.registeredClass,t);if(void 0!==i){if(0===i.$$.count.value)return i.$$.ptr=t,i.$$.smartPtr=e,i.clone();var n=i.clone();return this.destructor(e),n}function r(){return this.isSmartPointer?li(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):li(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o,s=this.registeredClass.getActualType(t),a=qt[s];if(!a)return r.call(this);o=this.isConst?a.constPointerType:a.pointerType;var c=ci(t,this.registeredClass,o.registeredClass);return null===c?r.call(this):this.isSmartPointer?li(o.registeredClass.instancePrototype,{ptrType:o,ptr:c,smartPtrType:this,smartPtr:e}):li(o.registeredClass.instancePrototype,{ptrType:o,ptr:c})}function pi(){hi.prototype.getPointee=oi,hi.prototype.destructor=si,hi.prototype.argPackAdvance=8,hi.prototype.readValueFromPointer=Ft,hi.prototype.deleteObject=ai,hi.prototype.fromWireType=ui}function hi(e,t,i,n,r,o,s,a,c,d,l){this.name=e,this.registeredClass=t,this.isReference=i,this.isConst=n,this.isSmartPointer=r,this.pointeeType=o,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=c,this.rawShare=d,this.rawDestructor=l,r||void 0!==t.baseClass?this.toWireType=ni:n?(this.toWireType=ii,this.destructorFunction=null):(this.toWireType=ri,this.destructorFunction=null)}function fi(e,t,i){o.hasOwnProperty(e)||Xt("Replacing nonexistant public symbol"),void 0!==o[e].overloadTable&&void 0!==i?o[e].overloadTable[i]=t:(o[e]=t,o[e].argCount=i)}function yi(e,t){e=st(e);var i=function(i){for(var n=[],r=1;r0?", ":"")+u),p+=(d?"var rv = ":"")+"invoker(fn"+(u.length>0?", ":"")+u+");\n",a)p+="runDestructors(destructors);\n";else for(c=s?1:2;c>2)+n]);return i}function Di(e,t,i,n,r,o,s){var a=mi(i,n);t=st(t),o=yi(r,o),Ut([],[e],(function(e){var n=(e=e[0]).name+"."+t;function r(){_i("Cannot call "+n+" due to unbound types",a)}var c=e.registeredClass.constructor;return void 0===c[t]?(r.argCount=i-1,c[t]=r):(Jt(c,t,n),c[t].overloadTable[i-1]=r),Ut([],a,(function(e){var r=[e[0],null].concat(e.slice(1)),a=Oi(n,r,null,o,s);return void 0===c[t].overloadTable?(a.argCount=i-1,c[t]=a):c[t].overloadTable[i-1]=a,[]})),[]}))}function bi(e,t,i,n,r,o){M(t>0);var s=mi(t,i);r=yi(n,r);var a=[o],c=[];Ut([],[e],(function(e){var i="constructor "+(e=e[0]).name;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new yt("Cannot register multiple constructors with identical number of parameters ("+(t-1)+") for class '"+e.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return e.registeredClass.constructor_body[t-1]=function(){_i("Cannot construct "+e.name+" due to unbound types",s)},Ut([],s,(function(n){return e.registeredClass.constructor_body[t-1]=function(){arguments.length!==t-1&&Et(i+" called with "+arguments.length+" arguments, expected "+(t-1)),c.length=0,a.length=t;for(var e=1;e4&&0==--qe[e].refcount&&(qe[e]=void 0,Ze.push(e))}function Mi(e,t){kt(e,{name:t=st(t),fromWireType:function(e){var t=qe[e].value;return vi(e),t},toWireType:function(e,t){return tt(t)},argPackAdvance:8,readValueFromPointer:Ft,destructorFunction:null})}function xi(e,t,i){switch(t){case 0:return function(e){var t=i?W:B;return this.fromWireType(t[e])};case 1:return function(e){var t=i?G:z;return this.fromWireType(t[e>>1])};case 2:return function(e){var t=i?V:Y;return this.fromWireType(t[e>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Si(e,t,i,n){var r=Ht(i);function o(){}t=st(t),o.values={},kt(e,{name:t,constructor:o,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:xi(t,r,n),destructorFunction:null}),Kt(t,o)}function Fi(e,t,i){var n=Dt(e,"enum");t=st(t);var r=n.constructor,o=Object.create(n.constructor.prototype,{value:{value:i},constructor:{value:Ye(n.name+"_"+t,(function(){}))}});r.values[i]=o,r[t]=o}function ji(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Ci(e,t){switch(t){case 2:return function(e){return this.fromWireType(Z[e>>2])};case 3:return function(e){return this.fromWireType(q[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ii(e,t,i){var n=Ht(i);kt(e,{name:t=st(t),fromWireType:function(e){return e},toWireType:function(e,t){if("number"!=typeof t&&"boolean"!=typeof t)throw new TypeError('Cannot convert "'+ji(t)+'" to '+this.name);return t},argPackAdvance:8,readValueFromPointer:Ci(t,n),destructorFunction:null})}function Xi(e,t,i,n,r,o){var s=mi(t,i);e=st(e),r=yi(n,r),Kt(e,(function(){_i("Cannot call "+e+" due to unbound types",s)}),t-1),Ut([],s,(function(i){var n=[i[0],null].concat(i.slice(1));return fi(e,Oi(e,n,null,r,o),t-1),[]}))}function Ui(e,t,i){switch(t){case 0:return i?function(e){return W[e]}:function(e){return B[e]};case 1:return i?function(e){return G[e>>1]}:function(e){return z[e>>1]};case 2:return i?function(e){return V[e>>2]}:function(e){return Y[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Ni(e,t,i,n,r){t=st(t),-1===r&&(r=4294967295);var o=Ht(i),s=function(e){return e};if(0===n){var a=32-8*i;s=function(e){return e<>>a}}var c=-1!=t.indexOf("unsigned");kt(e,{name:t,fromWireType:s,toWireType:function(e,i){if("number"!=typeof i&&"boolean"!=typeof i)throw new TypeError('Cannot convert "'+ji(i)+'" to '+this.name);if(ir)throw new TypeError('Passing a number "'+ji(i)+'" from JS side to C/C++ side to an argument of type "'+t+'", which is outside the valid range ['+n+", "+r+"]!");return c?i>>>0:0|i},argPackAdvance:8,readValueFromPointer:Ui(t,o,0!==n),destructorFunction:null})}function Hi(e,t,i){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function r(e){var t=Y,i=t[e>>=2],r=t[e+1];return new n($,r,i)}kt(e,{name:i=st(i),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{ignoreDuplicateRegistrations:!0})}function ki(e,t){var i="std::string"===(t=st(t));kt(e,{name:t,fromWireType:function(e){var t,n=Y[e>>2];if(i)for(var r=e+4,o=0;o<=n;++o){var s=e+4+o;if(0==B[s]||o==n){var a=F(r,s-r);void 0===t?t=a:(t+=String.fromCharCode(0),t+=a),r=s+1}}else{var c=new Array(n);for(o=0;o>2]=r,i&&n)C(t,o+4,r+1);else if(n)for(var s=0;s255&&(Xn(o),Et("String has UTF-16 code units that do not fit in 8 bits")),B[o+4+s]=a}else for(s=0;s>2],s=o(),c=e+4,d=0;d<=r;++d){var l=e+4+d*t;if(0==s[l>>a]||d==r){var u=n(c,l-c);void 0===i?i=u:(i+=String.fromCharCode(0),i+=u),c=l+t}}return Xn(e),i},toWireType:function(e,n){"string"!=typeof n&&Et("Cannot pass non-string to C++ string type "+i);var o=s(n),c=kn(4+o+t);return Y[c>>2]=o>>a,r(n,c+4,o+t),null!==e&&e.push(Xn,c),c},argPackAdvance:8,readValueFromPointer:Ft,destructorFunction:function(e){Xn(e)}})}function Qi(e,t,i,n,r,o){xt[e]={name:st(t),rawConstructor:yi(i,n),rawDestructor:yi(r,o),fields:[]}}function $i(e,t,i,n,r,o,s,a,c,d){xt[e].fields.push({fieldName:st(t),getterReturnType:i,getter:yi(n,r),getterContext:o,setterArgumentType:s,setter:yi(a,c),setterContext:d})}function Wi(e,t){kt(e,{isVoid:!0,name:t=st(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})}function Bi(e){var t=[];return V[e>>2]=tt(t),t}var Gi={};function zi(e){var t=Gi[e];return void 0===t?st(e):t}var Vi,Yi=[];function Zi(e,t,i,n,r){return(e=Yi[e])(t=gt(t),i=zi(i),Bi(n),r)}function qi(e,t,i,n){(e=Yi[e])(t=gt(t),i=zi(i),null,n)}function Ji(e){var t=Yi.length;return Yi.push(e),t}function Ki(e,t){for(var i=new Array(e),n=0;n>2)+n],"parameter "+n);return i}function en(e,t){for(var i=Ki(e,t),n=i[0],r=n.name+"_$"+i.slice(1).map((function(e){return e.name})).join("_")+"$",o=["retType"],s=[n],a="",c=0;c4&&(qe[e].refcount+=1)}function nn(e){St(qe[e].value),vi(e)}function rn(e,t){return tt((e=Dt(e,"_emval_take_value")).readValueFromPointer(t))}function on(){Me()}Vi=p?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof dateNow?dateNow:function(){return performance.now()};var sn=!0;function an(e){return V[Nn()>>2]=e,e}function cn(e,t){var i;if(0===e)i=Date.now();else{if(1!==e&&4!==e||!sn)return an(28),-1;i=Vi()}return V[t>>2]=i/1e3|0,V[t+4>>2]=i%1e3*1e3*1e3|0,0}function dn(){return 188592}function ln(e,t,i){B.copyWithin(e,t,t+i)}function un(){return B.length}function pn(e){try{return P.grow(e-$.byteLength+65535>>>16),ee(P.buffer),1}catch(t){console.error("emscripten_realloc_buffer: Attempted to grow heap from "+$.byteLength+" bytes to "+e+" bytes, but got error: "+t)}}function hn(e){e>>>=0;var t=un();M(e>t);var i=2147483648;if(e>i)return m("Cannot enlarge memory, asked to go up to "+e+" bytes, but the limit is 2147483648 bytes!"),!1;for(var n=1;n<=4;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var o=Math.min(i,K(Math.max(16777216,e,r),65536));if(pn(o))return!0}return m("Failed to grow the heap from "+t+" bytes to "+o+" bytes, not enough memory!"),!1}function fn(){void 0!==Hn&&Hn(0);var e=yn.buffers;e[1].length&&yn.printChar(1,10),e[2].length&&yn.printChar(2,10)}var yn={mappings:{},buffers:[null,[],[]],printChar:function(e,t){var i=yn.buffers[e];M(i),0===t||10===t?((1===e?O:m)(S(i,0)),i.length=0):i.push(t)},varargs:void 0,get:function(){return M(null!=yn.varargs),yn.varargs+=4,V[yn.varargs-4>>2]},getStr:function(e){return F(e)},get64:function(e,t){return M(e>=0?0===t:-1===t),e}};function En(e,t,i,n){for(var r=0,o=0;o>2],a=V[t+(8*o+4)>>2],c=0;c>2]=r,0}function _n(e){var t=Date.now();return V[e>>2]=t/1e3|0,V[e+4>>2]=t%1e3*1e3|0,0}function Tn(e){for(var t=Vi();Vi()-t>2],n=V[e+4>>2];return n<0||n>999999999||i<0?(an(28),-1):(0!==t&&(V[t>>2]=0,V[t+4>>2]=0),Tn(1e6*i+n/1e3))}function On(e){return 0}function mn(e){return 0}function Dn(){}function bn(){}function wn(){return 6}function Pn(e){Wn(e)}function Rn(e){Pn(e)}function An(){}function vn(){}function Mn(){}function xn(){}function Sn(){}function Fn(e){R(0|e)}et(),nt=o.PureVirtualError=it(Error,"PureVirtualError"),rt(),ht(),yt=o.BindingError=it(Error,"BindingError"),It=o.InternalError=it(Error,"InternalError"),Yt(),pi(),Ei=o.UnboundTypeError=it(Error,"UnboundTypeError");var jn,Cn={__handle_stack_overflow:Be,_embind_create_inheriting_constructor:Mt,_embind_finalize_value_object:Nt,_embind_register_bool:Lt,_embind_register_class:Ti,_embind_register_class_class_function:Di,_embind_register_class_constructor:bi,_embind_register_class_function:wi,_embind_register_class_property:Ri,_embind_register_constant:Ai,_embind_register_emval:Mi,_embind_register_enum:Si,_embind_register_enum_value:Fi,_embind_register_float:Ii,_embind_register_function:Xi,_embind_register_integer:Ni,_embind_register_memory_view:Hi,_embind_register_std_string:ki,_embind_register_std_wstring:Li,_embind_register_value_object:Qi,_embind_register_value_object_field:$i,_embind_register_void:Wi,_emval_call_method:Zi,_emval_call_void_method:qi,_emval_decref:vi,_emval_get_method_caller:en,_emval_incref:tn,_emval_run_destructors:nn,_emval_take_value:rn,abort:on,clock_gettime:cn,emscripten_get_sbrk_ptr:dn,emscripten_memcpy_big:ln,emscripten_resize_heap:hn,fd_write:En,gettimeofday:_n,memory:P,nanosleep:gn,pthread_attr_destroy:On,pthread_attr_init:mn,pthread_attr_setstacksize:Dn,pthread_cancel:bn,pthread_create:wn,pthread_exit:Rn,pthread_join:An,pthread_mutexattr_destroy:vn,pthread_mutexattr_init:Mn,pthread_mutexattr_setprotocol:xn,pthread_mutexattr_settype:Sn,setTempRet0:Fn,table:A},In=(ke(),o.___wasm_call_ctors=Xe("__wasm_call_ctors")),Xn=(o._memcpy=Xe("memcpy"),o._free=Xe("free")),Un=o.___getTypeName=Xe("__getTypeName"),Nn=(o.___embind_register_native_and_builtin_types=Xe("__embind_register_native_and_builtin_types"),o.___errno_location=Xe("__errno_location")),Hn=(o._htonl=Xe("htonl"),o._htons=Xe("htons"),o._ntohs=Xe("ntohs"),o._fflush=Xe("fflush")),kn=o._malloc=Xe("malloc");function Ln(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Qn(e){function i(){jn||(jn=!0,o.calledRun=!0,v||(_e(),Te(),t(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),M(!o._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Oe()))}e=e||c,be>0||(ae(),Ee(),be>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),i()}),1)):i(),ce()))}function $n(){var e=O,t=m,i=!1;O=m=function(e){i=!0};try{fn&&fn()}catch(e){}O=e,m=t,i&&(D("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc."),D("(this may also be due to not including full filesystem support - try building with -s FORCE_FILESYSTEM=1)"))}function Wn(e,t){$n(),t&&w&&0===e||(w?t||r("program exited (with status: "+e+"), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)"):(v=!0,ge(),o.onExit&&o.onExit(e)),d(e,new Ln(e)))}if(o.stackSave=Xe("stackSave"),o.stackRestore=Xe("stackRestore"),o.stackAlloc=Xe("stackAlloc"),o._emscripten_main_thread_process_queued_calls=Xe("emscripten_main_thread_process_queued_calls"),o.___set_stack_limit=Xe("__set_stack_limit"),o.__growWasmMemory=Xe("__growWasmMemory"),o.dynCall_viiiiiiii=Xe("dynCall_viiiiiiii"),o.dynCall_iiiii=Xe("dynCall_iiiii"),o.dynCall_iiii=Xe("dynCall_iiii"),o.dynCall_iii=Xe("dynCall_iii"),o.dynCall_ii=Xe("dynCall_ii"),o.dynCall_iiiiiii=Xe("dynCall_iiiiiii"),o.dynCall_iiiiii=Xe("dynCall_iiiiii"),o.dynCall_vi=Xe("dynCall_vi"),o.dynCall_vii=Xe("dynCall_vii"),o.dynCall_viii=Xe("dynCall_viii"),o.dynCall_fii=Xe("dynCall_fii"),o.dynCall_viif=Xe("dynCall_viif"),o.dynCall_iiff=Xe("dynCall_iiff"),o.dynCall_iifff=Xe("dynCall_iifff"),o.dynCall_iiiff=Xe("dynCall_iiiff"),o.dynCall_iiifff=Xe("dynCall_iiifff"),o.dynCall_viff=Xe("dynCall_viff"),o.dynCall_viiff=Xe("dynCall_viiff"),o.dynCall_viiii=Xe("dynCall_viiii"),o.dynCall_i=Xe("dynCall_i"),o.dynCall_iifffi=Xe("dynCall_iifffi"),o.dynCall_viiiii=Xe("dynCall_viiiii"),o.dynCall_dii=Xe("dynCall_dii"),o.dynCall_viid=Xe("dynCall_viid"),o.dynCall_vifi=Xe("dynCall_vifi"),o.dynCall_viifi=Xe("dynCall_viifi"),o.dynCall_iiiiifiiiii=Xe("dynCall_iiiiifiiiii"),o.dynCall_iiiiiifiiiiif=Xe("dynCall_iiiiiifiiiiif"),o.dynCall_iiiiiiii=Xe("dynCall_iiiiiiii"),o.dynCall_iiiiiiiii=Xe("dynCall_iiiiiiiii"),o.dynCall_iif=Xe("dynCall_iif"),o.dynCall_iiif=Xe("dynCall_iiif"),o.dynCall_iiffff=Xe("dynCall_iiffff"),o.dynCall_viiif=Xe("dynCall_viiif"),o.dynCall_iiiiffii=Xe("dynCall_iiiiffii"),o.dynCall_iiiif=Xe("dynCall_iiiif"),o.dynCall_v=Xe("dynCall_v"),o.dynCall_vif=Xe("dynCall_vif"),o.dynCall_fi=Xe("dynCall_fi"),o.dynCall_iifi=Xe("dynCall_iifi"),o.dynCall_viiiiiii=Xe("dynCall_viiiiiii"),o.dynCall_viiifi=Xe("dynCall_viiifi"),o.dynCall_viiffi=Xe("dynCall_viiffi"),o.dynCall_viifffi=Xe("dynCall_viifffi"),o.dynCall_viiiiii=Xe("dynCall_viiiiii"),o.dynCall_viiifiiiii=Xe("dynCall_viiifiiiii"),o.dynCall_viiiifiiiiif=Xe("dynCall_viiiifiiiiif"),o.dynCall_iiiifiiiii=Xe("dynCall_iiiifiiiii"),o.dynCall_iiiiifiiiiif=Xe("dynCall_iiiiifiiiiif"),o.dynCall_vifiiii=Xe("dynCall_vifiiii"),o.dynCall_viiiiiiiii=Xe("dynCall_viiiiiiiii"),o.dynCall_viffiiiif=Xe("dynCall_viffiiiif"),o.dynCall_viffiifffffiii=Xe("dynCall_viffiifffffiii"),o.dynCall_viffffiifffiiiiif=Xe("dynCall_viffffiifffiiiiif"),o.dynCall_iiiifffffii=Xe("dynCall_iiiifffffii"),o.dynCall_iiiifffffi=Xe("dynCall_iiiifffffi"),o.dynCall_viiiiiiiiiiifii=Xe("dynCall_viiiiiiiiiiifii"),o.dynCall_viiiiiiiiii=Xe("dynCall_viiiiiiiiii"),o.dynCall_viiiffi=Xe("dynCall_viiiffi"),o.dynCall_vifii=Xe("dynCall_vifii"),o.dynCall_viiiffii=Xe("dynCall_viiiffii"),o.dynCall_iiiiifiii=Xe("dynCall_iiiiifiii"),o.dynCall_iiiiiifiii=Xe("dynCall_iiiiiifiii"),o.dynCall_iiiiiiifiif=Xe("dynCall_iiiiiiifiif"),o.dynCall_iiiiiifiif=Xe("dynCall_iiiiiifiif"),o.dynCall_iiiifii=Xe("dynCall_iiiifii"),o.dynCall_fiiiiiifiifif=Xe("dynCall_fiiiiiifiifif"),o.dynCall_fiiiiiifiiiif=Xe("dynCall_fiiiiiifiiiif"),o.dynCall_fiff=Xe("dynCall_fiff"),o.dynCall_viiifii=Xe("dynCall_viiifii"),o.dynCall_iiiiiiiiii=Xe("dynCall_iiiiiiiiii"),o.dynCall_iiiiiiiiiii=Xe("dynCall_iiiiiiiiiii"),o.dynCall_viij=Xe("dynCall_viij"),o.dynCall_viiji=Xe("dynCall_viiji"),o.dynCall_viijijj=Xe("dynCall_viijijj"),o.dynCall_viijj=Xe("dynCall_viijj"),o.dynCall_iiiij=Xe("dynCall_iiiij"),o.dynCall_viiiij=Xe("dynCall_viiiij"),o.dynCall_ji=Xe("dynCall_ji"),o.dynCall_iidiiii=Xe("dynCall_iidiiii"),o.dynCall_jiji=Xe("dynCall_jiji"),Object.getOwnPropertyDescriptor(o,"intArrayFromString")||(o.intArrayFromString=function(){Me("'intArrayFromString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"intArrayToString")||(o.intArrayToString=function(){Me("'intArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ccall")||(o.ccall=function(){Me("'ccall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"cwrap")||(o.cwrap=function(){Me("'cwrap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setValue")||(o.setValue=function(){Me("'setValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getValue")||(o.getValue=function(){Me("'getValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"allocate")||(o.allocate=function(){Me("'allocate' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getMemory")||(o.getMemory=function(){Me("'getMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"UTF8ArrayToString")||(o.UTF8ArrayToString=function(){Me("'UTF8ArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UTF8ToString")||(o.UTF8ToString=function(){Me("'UTF8ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF8Array")||(o.stringToUTF8Array=function(){Me("'stringToUTF8Array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF8")||(o.stringToUTF8=function(){Me("'stringToUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"lengthBytesUTF8")||(o.lengthBytesUTF8=function(){Me("'lengthBytesUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackTrace")||(o.stackTrace=function(){Me("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnPreRun")||(o.addOnPreRun=function(){Me("'addOnPreRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnInit")||(o.addOnInit=function(){Me("'addOnInit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnPreMain")||(o.addOnPreMain=function(){Me("'addOnPreMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnExit")||(o.addOnExit=function(){Me("'addOnExit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addOnPostRun")||(o.addOnPostRun=function(){Me("'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeStringToMemory")||(o.writeStringToMemory=function(){Me("'writeStringToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeArrayToMemory")||(o.writeArrayToMemory=function(){Me("'writeArrayToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeAsciiToMemory")||(o.writeAsciiToMemory=function(){Me("'writeAsciiToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addRunDependency")||(o.addRunDependency=function(){Me("'addRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"removeRunDependency")||(o.removeRunDependency=function(){Me("'removeRunDependency' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createFolder")||(o.FS_createFolder=function(){Me("'FS_createFolder' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createPath")||(o.FS_createPath=function(){Me("'FS_createPath' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createDataFile")||(o.FS_createDataFile=function(){Me("'FS_createDataFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createPreloadedFile")||(o.FS_createPreloadedFile=function(){Me("'FS_createPreloadedFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createLazyFile")||(o.FS_createLazyFile=function(){Me("'FS_createLazyFile' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createLink")||(o.FS_createLink=function(){Me("'FS_createLink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_createDevice")||(o.FS_createDevice=function(){Me("'FS_createDevice' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"FS_unlink")||(o.FS_unlink=function(){Me("'FS_unlink' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(o,"dynamicAlloc")||(o.dynamicAlloc=function(){Me("'dynamicAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"loadDynamicLibrary")||(o.loadDynamicLibrary=function(){Me("'loadDynamicLibrary' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"loadWebAssemblyModule")||(o.loadWebAssemblyModule=function(){Me("'loadWebAssemblyModule' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getLEB")||(o.getLEB=function(){Me("'getLEB' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getFunctionTables")||(o.getFunctionTables=function(){Me("'getFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"alignFunctionTables")||(o.alignFunctionTables=function(){Me("'alignFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registerFunctions")||(o.registerFunctions=function(){Me("'registerFunctions' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"addFunction")||(o.addFunction=function(){Me("'addFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"removeFunction")||(o.removeFunction=function(){Me("'removeFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getFuncWrapper")||(o.getFuncWrapper=function(){Me("'getFuncWrapper' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"prettyPrint")||(o.prettyPrint=function(){Me("'prettyPrint' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"makeBigInt")||(o.makeBigInt=function(){Me("'makeBigInt' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"dynCall")||(o.dynCall=function(){Me("'dynCall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getCompilerSetting")||(o.getCompilerSetting=function(){Me("'getCompilerSetting' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"print")||(o.print=function(){Me("'print' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"printErr")||(o.printErr=function(){Me("'printErr' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getTempRet0")||(o.getTempRet0=function(){Me("'getTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setTempRet0")||(o.setTempRet0=function(){Me("'setTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"callMain")||(o.callMain=function(){Me("'callMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"abort")||(o.abort=function(){Me("'abort' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToNewUTF8")||(o.stringToNewUTF8=function(){Me("'stringToNewUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscripten_realloc_buffer")||(o.emscripten_realloc_buffer=function(){Me("'emscripten_realloc_buffer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ENV")||(o.ENV=function(){Me("'ENV' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ERRNO_CODES")||(o.ERRNO_CODES=function(){Me("'ERRNO_CODES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ERRNO_MESSAGES")||(o.ERRNO_MESSAGES=function(){Me("'ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setErrNo")||(o.setErrNo=function(){Me("'setErrNo' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"DNS")||(o.DNS=function(){Me("'DNS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GAI_ERRNO_MESSAGES")||(o.GAI_ERRNO_MESSAGES=function(){Me("'GAI_ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"Protocols")||(o.Protocols=function(){Me("'Protocols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"Sockets")||(o.Sockets=function(){Me("'Sockets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UNWIND_CACHE")||(o.UNWIND_CACHE=function(){Me("'UNWIND_CACHE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readAsmConstArgs")||(o.readAsmConstArgs=function(){Me("'readAsmConstArgs' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"jstoi_q")||(o.jstoi_q=function(){Me("'jstoi_q' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"jstoi_s")||(o.jstoi_s=function(){Me("'jstoi_s' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"abortStackOverflow")||(o.abortStackOverflow=function(){Me("'abortStackOverflow' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"reallyNegative")||(o.reallyNegative=function(){Me("'reallyNegative' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"formatString")||(o.formatString=function(){Me("'formatString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PATH")||(o.PATH=function(){Me("'PATH' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PATH_FS")||(o.PATH_FS=function(){Me("'PATH_FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SYSCALLS")||(o.SYSCALLS=function(){Me("'SYSCALLS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"syscallMmap2")||(o.syscallMmap2=function(){Me("'syscallMmap2' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"syscallMunmap")||(o.syscallMunmap=function(){Me("'syscallMunmap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"flush_NO_FILESYSTEM")||(o.flush_NO_FILESYSTEM=function(){Me("'flush_NO_FILESYSTEM' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"JSEvents")||(o.JSEvents=function(){Me("'JSEvents' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"specialHTMLTargets")||(o.specialHTMLTargets=function(){Me("'specialHTMLTargets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"demangle")||(o.demangle=function(){Me("'demangle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"demangleAll")||(o.demangleAll=function(){Me("'demangleAll' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"jsStackTrace")||(o.jsStackTrace=function(){Me("'jsStackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackTrace")||(o.stackTrace=function(){Me("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getEnvStrings")||(o.getEnvStrings=function(){Me("'getEnvStrings' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"checkWasiClock")||(o.checkWasiClock=function(){Me("'checkWasiClock' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToI64")||(o.writeI53ToI64=function(){Me("'writeI53ToI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToI64Clamped")||(o.writeI53ToI64Clamped=function(){Me("'writeI53ToI64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToI64Signaling")||(o.writeI53ToI64Signaling=function(){Me("'writeI53ToI64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToU64Clamped")||(o.writeI53ToU64Clamped=function(){Me("'writeI53ToU64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"writeI53ToU64Signaling")||(o.writeI53ToU64Signaling=function(){Me("'writeI53ToU64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readI53FromI64")||(o.readI53FromI64=function(){Me("'readI53FromI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readI53FromU64")||(o.readI53FromU64=function(){Me("'readI53FromU64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"convertI32PairToI53")||(o.convertI32PairToI53=function(){Me("'convertI32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"convertU32PairToI53")||(o.convertU32PairToI53=function(){Me("'convertU32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"Browser")||(o.Browser=function(){Me("'Browser' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"FS")||(o.FS=function(){Me("'FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"MEMFS")||(o.MEMFS=function(){Me("'MEMFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"TTY")||(o.TTY=function(){Me("'TTY' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PIPEFS")||(o.PIPEFS=function(){Me("'PIPEFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SOCKFS")||(o.SOCKFS=function(){Me("'SOCKFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GL")||(o.GL=function(){Me("'GL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGet")||(o.emscriptenWebGLGet=function(){Me("'emscriptenWebGLGet' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGetTexPixelData")||(o.emscriptenWebGLGetTexPixelData=function(){Me("'emscriptenWebGLGetTexPixelData' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGetUniform")||(o.emscriptenWebGLGetUniform=function(){Me("'emscriptenWebGLGetUniform' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emscriptenWebGLGetVertexAttrib")||(o.emscriptenWebGLGetVertexAttrib=function(){Me("'emscriptenWebGLGetVertexAttrib' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"AL")||(o.AL=function(){Me("'AL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_unicode")||(o.SDL_unicode=function(){Me("'SDL_unicode' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_ttfContext")||(o.SDL_ttfContext=function(){Me("'SDL_ttfContext' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_audio")||(o.SDL_audio=function(){Me("'SDL_audio' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL")||(o.SDL=function(){Me("'SDL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"SDL_gfx")||(o.SDL_gfx=function(){Me("'SDL_gfx' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLUT")||(o.GLUT=function(){Me("'GLUT' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"EGL")||(o.EGL=function(){Me("'EGL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLFW_Window")||(o.GLFW_Window=function(){Me("'GLFW_Window' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLFW")||(o.GLFW=function(){Me("'GLFW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"GLEW")||(o.GLEW=function(){Me("'GLEW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"IDBStore")||(o.IDBStore=function(){Me("'IDBStore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"runAndAbortIfError")||(o.runAndAbortIfError=function(){Me("'runAndAbortIfError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_handle_array")||(o.emval_handle_array=function(){Me("'emval_handle_array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_free_list")||(o.emval_free_list=function(){Me("'emval_free_list' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_symbols")||(o.emval_symbols=function(){Me("'emval_symbols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_emval")||(o.init_emval=function(){Me("'init_emval' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"count_emval_handles")||(o.count_emval_handles=function(){Me("'count_emval_handles' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"get_first_emval")||(o.get_first_emval=function(){Me("'get_first_emval' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getStringOrSymbol")||(o.getStringOrSymbol=function(){Me("'getStringOrSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"requireHandle")||(o.requireHandle=function(){Me("'requireHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_newers")||(o.emval_newers=function(){Me("'emval_newers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"craftEmvalAllocator")||(o.craftEmvalAllocator=function(){Me("'craftEmvalAllocator' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_get_global")||(o.emval_get_global=function(){Me("'emval_get_global' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"emval_methodCallers")||(o.emval_methodCallers=function(){Me("'emval_methodCallers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"InternalError")||(o.InternalError=function(){Me("'InternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"BindingError")||(o.BindingError=function(){Me("'BindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UnboundTypeError")||(o.UnboundTypeError=function(){Me("'UnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"PureVirtualError")||(o.PureVirtualError=function(){Me("'PureVirtualError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_embind")||(o.init_embind=function(){Me("'init_embind' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwInternalError")||(o.throwInternalError=function(){Me("'throwInternalError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwBindingError")||(o.throwBindingError=function(){Me("'throwBindingError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwUnboundTypeError")||(o.throwUnboundTypeError=function(){Me("'throwUnboundTypeError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ensureOverloadTable")||(o.ensureOverloadTable=function(){Me("'ensureOverloadTable' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"exposePublicSymbol")||(o.exposePublicSymbol=function(){Me("'exposePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"replacePublicSymbol")||(o.replacePublicSymbol=function(){Me("'replacePublicSymbol' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"extendError")||(o.extendError=function(){Me("'extendError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"createNamedFunction")||(o.createNamedFunction=function(){Me("'createNamedFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registeredInstances")||(o.registeredInstances=function(){Me("'registeredInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getBasestPointer")||(o.getBasestPointer=function(){Me("'getBasestPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registerInheritedInstance")||(o.registerInheritedInstance=function(){Me("'registerInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"unregisterInheritedInstance")||(o.unregisterInheritedInstance=function(){Me("'unregisterInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getInheritedInstance")||(o.getInheritedInstance=function(){Me("'getInheritedInstance' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getInheritedInstanceCount")||(o.getInheritedInstanceCount=function(){Me("'getInheritedInstanceCount' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getLiveInheritedInstances")||(o.getLiveInheritedInstances=function(){Me("'getLiveInheritedInstances' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registeredTypes")||(o.registeredTypes=function(){Me("'registeredTypes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"awaitingDependencies")||(o.awaitingDependencies=function(){Me("'awaitingDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"typeDependencies")||(o.typeDependencies=function(){Me("'typeDependencies' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registeredPointers")||(o.registeredPointers=function(){Me("'registeredPointers' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"registerType")||(o.registerType=function(){Me("'registerType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"whenDependentTypesAreResolved")||(o.whenDependentTypesAreResolved=function(){Me("'whenDependentTypesAreResolved' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"embind_charCodes")||(o.embind_charCodes=function(){Me("'embind_charCodes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"embind_init_charCodes")||(o.embind_init_charCodes=function(){Me("'embind_init_charCodes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"readLatin1String")||(o.readLatin1String=function(){Me("'readLatin1String' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getTypeName")||(o.getTypeName=function(){Me("'getTypeName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"heap32VectorToArray")||(o.heap32VectorToArray=function(){Me("'heap32VectorToArray' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"requireRegisteredType")||(o.requireRegisteredType=function(){Me("'requireRegisteredType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"getShiftFromSize")||(o.getShiftFromSize=function(){Me("'getShiftFromSize' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"integerReadValueFromPointer")||(o.integerReadValueFromPointer=function(){Me("'integerReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"enumReadValueFromPointer")||(o.enumReadValueFromPointer=function(){Me("'enumReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"floatReadValueFromPointer")||(o.floatReadValueFromPointer=function(){Me("'floatReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"simpleReadValueFromPointer")||(o.simpleReadValueFromPointer=function(){Me("'simpleReadValueFromPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"runDestructors")||(o.runDestructors=function(){Me("'runDestructors' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"new_")||(o.new_=function(){Me("'new_' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"craftInvokerFunction")||(o.craftInvokerFunction=function(){Me("'craftInvokerFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"embind__requireFunction")||(o.embind__requireFunction=function(){Me("'embind__requireFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"tupleRegistrations")||(o.tupleRegistrations=function(){Me("'tupleRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"structRegistrations")||(o.structRegistrations=function(){Me("'structRegistrations' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"genericPointerToWireType")||(o.genericPointerToWireType=function(){Me("'genericPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"constNoSmartPtrRawPointerToWireType")||(o.constNoSmartPtrRawPointerToWireType=function(){Me("'constNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"nonConstNoSmartPtrRawPointerToWireType")||(o.nonConstNoSmartPtrRawPointerToWireType=function(){Me("'nonConstNoSmartPtrRawPointerToWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_RegisteredPointer")||(o.init_RegisteredPointer=function(){Me("'init_RegisteredPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer")||(o.RegisteredPointer=function(){Me("'RegisteredPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_getPointee")||(o.RegisteredPointer_getPointee=function(){Me("'RegisteredPointer_getPointee' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_destructor")||(o.RegisteredPointer_destructor=function(){Me("'RegisteredPointer_destructor' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_deleteObject")||(o.RegisteredPointer_deleteObject=function(){Me("'RegisteredPointer_deleteObject' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredPointer_fromWireType")||(o.RegisteredPointer_fromWireType=function(){Me("'RegisteredPointer_fromWireType' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"runDestructor")||(o.runDestructor=function(){Me("'runDestructor' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"releaseClassHandle")||(o.releaseClassHandle=function(){Me("'releaseClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"finalizationGroup")||(o.finalizationGroup=function(){Me("'finalizationGroup' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"detachFinalizer_deps")||(o.detachFinalizer_deps=function(){Me("'detachFinalizer_deps' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"detachFinalizer")||(o.detachFinalizer=function(){Me("'detachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"attachFinalizer")||(o.attachFinalizer=function(){Me("'attachFinalizer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"makeClassHandle")||(o.makeClassHandle=function(){Me("'makeClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"init_ClassHandle")||(o.init_ClassHandle=function(){Me("'init_ClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle")||(o.ClassHandle=function(){Me("'ClassHandle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_isAliasOf")||(o.ClassHandle_isAliasOf=function(){Me("'ClassHandle_isAliasOf' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"throwInstanceAlreadyDeleted")||(o.throwInstanceAlreadyDeleted=function(){Me("'throwInstanceAlreadyDeleted' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_clone")||(o.ClassHandle_clone=function(){Me("'ClassHandle_clone' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_delete")||(o.ClassHandle_delete=function(){Me("'ClassHandle_delete' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"deletionQueue")||(o.deletionQueue=function(){Me("'deletionQueue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_isDeleted")||(o.ClassHandle_isDeleted=function(){Me("'ClassHandle_isDeleted' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"ClassHandle_deleteLater")||(o.ClassHandle_deleteLater=function(){Me("'ClassHandle_deleteLater' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"flushPendingDeletes")||(o.flushPendingDeletes=function(){Me("'flushPendingDeletes' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"delayFunction")||(o.delayFunction=function(){Me("'delayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"setDelayFunction")||(o.setDelayFunction=function(){Me("'setDelayFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"RegisteredClass")||(o.RegisteredClass=function(){Me("'RegisteredClass' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"shallowCopyInternalPointer")||(o.shallowCopyInternalPointer=function(){Me("'shallowCopyInternalPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"downcastPointer")||(o.downcastPointer=function(){Me("'downcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"upcastPointer")||(o.upcastPointer=function(){Me("'upcastPointer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"validateThis")||(o.validateThis=function(){Me("'validateThis' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"char_0")||(o.char_0=function(){Me("'char_0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"char_9")||(o.char_9=function(){Me("'char_9' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"makeLegalFunctionName")||(o.makeLegalFunctionName=function(){Me("'makeLegalFunctionName' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"warnOnce")||(o.warnOnce=function(){Me("'warnOnce' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackSave")||(o.stackSave=function(){Me("'stackSave' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackRestore")||(o.stackRestore=function(){Me("'stackRestore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stackAlloc")||(o.stackAlloc=function(){Me("'stackAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"AsciiToString")||(o.AsciiToString=function(){Me("'AsciiToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToAscii")||(o.stringToAscii=function(){Me("'stringToAscii' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UTF16ToString")||(o.UTF16ToString=function(){Me("'UTF16ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF16")||(o.stringToUTF16=function(){Me("'stringToUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"lengthBytesUTF16")||(o.lengthBytesUTF16=function(){Me("'lengthBytesUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"UTF32ToString")||(o.UTF32ToString=function(){Me("'UTF32ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"stringToUTF32")||(o.stringToUTF32=function(){Me("'stringToUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"lengthBytesUTF32")||(o.lengthBytesUTF32=function(){Me("'lengthBytesUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"allocateUTF8")||(o.allocateUTF8=function(){Me("'allocateUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(o,"allocateUTF8OnStack")||(o.allocateUTF8OnStack=function(){Me("'allocateUTF8OnStack' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}),o.writeStackCookie=ae,o.checkStackCookie=ce,Object.getOwnPropertyDescriptor(o,"ALLOC_NORMAL")||Object.defineProperty(o,"ALLOC_NORMAL",{configurable:!0,get:function(){Me("'ALLOC_NORMAL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Object.getOwnPropertyDescriptor(o,"ALLOC_STACK")||Object.defineProperty(o,"ALLOC_STACK",{configurable:!0,get:function(){Me("'ALLOC_STACK' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Object.getOwnPropertyDescriptor(o,"ALLOC_DYNAMIC")||Object.defineProperty(o,"ALLOC_DYNAMIC",{configurable:!0,get:function(){Me("'ALLOC_DYNAMIC' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Object.getOwnPropertyDescriptor(o,"ALLOC_NONE")||Object.defineProperty(o,"ALLOC_NONE",{configurable:!0,get:function(){Me("'ALLOC_NONE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Pe=function e(){jn||Qn(),jn||(Pe=e)},o.run=Qn,o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return w=!0,Qn(),e.ready});e.exports=r},351:()=>{},606:()=>{}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}n(590),n(261)})(); \ No newline at end of file diff --git a/src/physics.js b/src/physics.js index c9a3409..c71415c 100644 --- a/src/physics.js +++ b/src/physics.js @@ -1044,11 +1044,17 @@ AFRAME.registerComponent('physx-body', { this.rigidBody.setAngularDamping(this.data.angularDamping) this.rigidBody.setLinearDamping(this.data.linearDamping) this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, false) - if (this.data.highPrecision) - { - this.rigidBody.setSolverIterationCounts(4, 2); + } + + if (this.data.highPrecision) + { + this.rigidBody.setSolverIterationCounts(4, 2); + if (this.data.type === 'dynamic') { this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_CCD, true) } + else if (this.data.type === 'kinematic') { + this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true); + } } if (!oldData || this.data.mass !== oldData.mass) this.el.emit('object3dset', {})