{"ast":null,"code":"import { Matrix, Quaternion, TmpVectors, Vector3 } from \"../../../Maths/math.vector.js\";\nimport { PhysicsPrestepType } from \"../IPhysicsEnginePlugin.js\";\nimport { Logger } from \"../../../Misc/logger.js\";\nimport { PhysicsShape } from \"../physicsShape.js\";\nimport { BoundingBox } from \"../../../Culling/boundingBox.js\";\nimport { Mesh } from \"../../../Meshes/mesh.js\";\nimport { InstancedMesh } from \"../../../Meshes/instancedMesh.js\";\nimport { VertexBuffer } from \"../../../Buffers/buffer.js\";\nimport { BuildArray } from \"../../../Misc/arrayTools.js\";\nimport { Observable } from \"../../../Misc/observable.js\";\nclass MeshAccumulator {\n /**\n * Constructor of the mesh accumulator\n * @param mesh - The mesh used to compute the world matrix.\n * @param collectIndices - use mesh indices\n * @param scene - The scene used to determine the right handed system.\n *\n * Merge mesh and its children so whole hierarchy can be used as a mesh shape or convex hull\n */\n constructor(mesh, collectIndices, scene) {\n this._vertices = []; /// Vertices in body space\n this._indices = [];\n this._isRightHanded = scene.useRightHandedSystem;\n this._collectIndices = collectIndices;\n }\n /**\n * Adds a mesh to the physics engine.\n * @param mesh The mesh to add.\n * @param includeChildren Whether to include the children of the mesh.\n *\n * This method adds a mesh to the physics engine by computing the world matrix,\n * multiplying it with the body from world matrix, and then transforming the\n * coordinates of the mesh's vertices. It also adds the indices of the mesh\n * to the physics engine. If includeChildren is true, it will also add the\n * children of the mesh to the physics engine, ignoring any children which\n * have a physics impostor. This is useful for creating a physics engine\n * that accurately reflects the mesh and its children.\n */\n addNodeMeshes(mesh, includeChildren) {\n // Force absoluteScaling to be computed; we're going to use that to bake\n // the scale of any parent nodes into this shape, as physics engines\n // usually use rigid transforms, so can't handle arbitrary scale.\n mesh.computeWorldMatrix(true);\n const rootScaled = TmpVectors.Matrix[0];\n Matrix.ScalingToRef(mesh.absoluteScaling.x, mesh.absoluteScaling.y, mesh.absoluteScaling.z, rootScaled);\n if (mesh instanceof Mesh) {\n this._addMesh(mesh, rootScaled);\n } else if (mesh instanceof InstancedMesh) {\n this._addMesh(mesh.sourceMesh, rootScaled);\n }\n if (includeChildren) {\n const worldToRoot = TmpVectors.Matrix[1];\n mesh.computeWorldMatrix().invertToRef(worldToRoot);\n const worldToRootScaled = TmpVectors.Matrix[2];\n worldToRoot.multiplyToRef(rootScaled, worldToRootScaled);\n const children = mesh.getChildMeshes(false);\n // Ignore any children which have a physics body.\n // Other plugin implementations do not have this check, which appears to be\n // a bug, as otherwise, the mesh will have a duplicate collider\n children.filter(m => !m.physicsBody).forEach(m => {\n const childToWorld = m.computeWorldMatrix();\n const childToRootScaled = TmpVectors.Matrix[3];\n childToWorld.multiplyToRef(worldToRootScaled, childToRootScaled);\n if (m instanceof Mesh) {\n this._addMesh(m, childToRootScaled);\n } else if (m instanceof InstancedMesh) {\n this._addMesh(m.sourceMesh, childToRootScaled);\n }\n });\n }\n }\n _addMesh(mesh, meshToRoot) {\n const vertexData = mesh.getVerticesData(VertexBuffer.PositionKind) || [];\n const numVerts = vertexData.length / 3;\n const indexOffset = this._vertices.length;\n for (let v = 0; v < numVerts; v++) {\n const pos = new Vector3(vertexData[v * 3 + 0], vertexData[v * 3 + 1], vertexData[v * 3 + 2]);\n this._vertices.push(Vector3.TransformCoordinates(pos, meshToRoot));\n }\n if (this._collectIndices) {\n const meshIndices = mesh.getIndices();\n if (meshIndices) {\n for (let i = 0; i < meshIndices.length; i += 3) {\n // Havok wants the correct triangle winding to enable the interior triangle optimization\n if (this._isRightHanded) {\n this._indices.push(meshIndices[i + 0] + indexOffset);\n this._indices.push(meshIndices[i + 1] + indexOffset);\n this._indices.push(meshIndices[i + 2] + indexOffset);\n } else {\n this._indices.push(meshIndices[i + 2] + indexOffset);\n this._indices.push(meshIndices[i + 1] + indexOffset);\n this._indices.push(meshIndices[i + 0] + indexOffset);\n }\n }\n }\n }\n }\n /**\n * Allocate and populate the vertex positions inside the physics plugin.\n *\n * @param plugin - The plugin to allocate the memory in.\n * @returns An array of floats, whose backing memory is inside the plugin. The array contains the\n * positions of the mesh vertices, where a position is defined by three floats. You must call\n * freeBuffer() on the returned array once you have finished with it, in order to free the\n * memory inside the plugin..\n */\n getVertices(plugin) {\n const nFloats = this._vertices.length * 3;\n const bytesPerFloat = 4;\n const nBytes = nFloats * bytesPerFloat;\n const bufferBegin = plugin._malloc(nBytes);\n const ret = new Float32Array(plugin.HEAPU8.buffer, bufferBegin, nFloats);\n for (let i = 0; i < this._vertices.length; i++) {\n ret[i * 3 + 0] = this._vertices[i].x;\n ret[i * 3 + 1] = this._vertices[i].y;\n ret[i * 3 + 2] = this._vertices[i].z;\n }\n return {\n offset: bufferBegin,\n numObjects: nFloats\n };\n }\n freeBuffer(plugin, arr) {\n plugin._free(arr.offset);\n }\n /**\n * Allocate and populate the triangle indices inside the physics plugin\n *\n * @param plugin - The plugin to allocate the memory in.\n * @returns A new Int32Array, whose backing memory is inside the plugin. The array contains the indices\n * of the triangle positions, where a single triangle is defined by three indices. You must call\n * freeBuffer() on this array once you have finished with it, to free the memory inside the plugin..\n */\n getTriangles(plugin) {\n const bytesPerInt = 4;\n const nBytes = this._indices.length * bytesPerInt;\n const bufferBegin = plugin._malloc(nBytes);\n const ret = new Int32Array(plugin.HEAPU8.buffer, bufferBegin, this._indices.length);\n for (let i = 0; i < this._indices.length; i++) {\n ret[i] = this._indices[i];\n }\n return {\n offset: bufferBegin,\n numObjects: this._indices.length\n };\n }\n}\nclass BodyPluginData {\n constructor(bodyId) {\n this.hpBodyId = bodyId;\n this.userMassProps = {\n centerOfMass: undefined,\n mass: undefined,\n inertia: undefined,\n inertiaOrientation: undefined\n };\n }\n}\n/*\nclass ShapePath\n{\n public colliderId: number;\n public pathData: number;\n}\n*/\nclass CollisionContactPoint {\n constructor() {\n this.bodyId = BigInt(0); //0,2\n //public colliderId: number = 0; //2,4\n //public shapePath: ShapePath = new ShapePath(); //4,8\n this.position = new Vector3(); //8,11\n this.normal = new Vector3(); //11,14\n //public triIdx: number = 0; //14,15\n }\n}\nclass CollisionEvent {\n constructor() {\n this.contactOnA = new CollisionContactPoint(); //1\n this.contactOnB = new CollisionContactPoint();\n this.impulseApplied = 0;\n this.type = 0;\n }\n // eslint-disable-next-line @typescript-eslint/naming-convention\n static readToRef(buffer, offset, eventOut) {\n const intBuf = new Int32Array(buffer, offset);\n const floatBuf = new Float32Array(buffer, offset);\n const offA = 2;\n eventOut.contactOnA.bodyId = BigInt(intBuf[offA]); // 0) {\n for (const instance of body._pluginDataInstances) {\n this._bodyCollisionObservable.delete(instance.hpBodyId[0]);\n this._hknp.HP_World_RemoveBody(this.world, instance.hpBodyId);\n this._bodies.delete(instance.hpBodyId[0]);\n }\n }\n if (body._pluginData) {\n this._bodyCollisionObservable.delete(body._pluginData.hpBodyId[0]);\n this._hknp.HP_World_RemoveBody(this.world, body._pluginData.hpBodyId);\n this._bodies.delete(body._pluginData.hpBodyId[0]);\n }\n }\n /**\n * Initializes the body instances for a given physics body and mesh.\n *\n * @param body - The physics body to initialize.\n * @param motionType - How the body will be handled by the engine\n * @param mesh - The mesh to initialize.\n *\n * This code is useful for creating a physics body from a mesh. It creates a\n * body instance for each instance of the mesh and adds it to the world. It also\n * sets the position of the body instance to the position of the mesh instance.\n * This allows for the physics engine to accurately simulate the mesh in the\n * world.\n */\n initBodyInstances(body, motionType, mesh) {\n var _mesh$_thinInstanceDa, _mesh$_thinInstanceDa2;\n const instancesCount = (_mesh$_thinInstanceDa = (_mesh$_thinInstanceDa2 = mesh._thinInstanceDataStorage) === null || _mesh$_thinInstanceDa2 === void 0 ? void 0 : _mesh$_thinInstanceDa2.instancesCount) !== null && _mesh$_thinInstanceDa !== void 0 ? _mesh$_thinInstanceDa : 0;\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, false);\n body._pluginDataInstances.forEach((bodyId, index) => {\n this._bodies.set(bodyId.hpBodyId[0], {\n body: body,\n index: index\n });\n });\n }\n _createOrUpdateBodyInstances(body, motionType, matrixData, startIndex, endIndex, update) {\n const rotation = TmpVectors.Quaternion[0];\n const rotationMatrix = Matrix.Identity();\n for (let i = startIndex; i < endIndex; i++) {\n const position = [matrixData[i * 16 + 12], matrixData[i * 16 + 13], matrixData[i * 16 + 14]];\n let hkbody;\n if (!update) {\n hkbody = this._hknp.HP_Body_Create()[1];\n } else {\n hkbody = body._pluginDataInstances[i].hpBodyId;\n }\n rotationMatrix.setRowFromFloats(0, matrixData[i * 16 + 0], matrixData[i * 16 + 1], matrixData[i * 16 + 2], 0);\n rotationMatrix.setRowFromFloats(1, matrixData[i * 16 + 4], matrixData[i * 16 + 5], matrixData[i * 16 + 6], 0);\n rotationMatrix.setRowFromFloats(2, matrixData[i * 16 + 8], matrixData[i * 16 + 9], matrixData[i * 16 + 10], 0);\n Quaternion.FromRotationMatrixToRef(rotationMatrix, rotation);\n const transform = [position, [rotation.x, rotation.y, rotation.z, rotation.w]];\n this._hknp.HP_Body_SetQTransform(hkbody, transform);\n if (!update) {\n const pluginData = new BodyPluginData(hkbody);\n if (body._pluginDataInstances.length) {\n // If an instance already exists, copy any user-provided mass properties\n pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;\n }\n this._internalSetMotionType(pluginData, motionType);\n this._internalUpdateMassProperties(pluginData);\n body._pluginDataInstances.push(pluginData);\n this._hknp.HP_World_AddBody(this.world, hkbody, body.startAsleep);\n pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(hkbody)[1];\n }\n }\n }\n /**\n * Update the internal body instances for a given physics body to match the instances in a mesh.\n * @param body the body that will be updated\n * @param mesh the mesh with reference instances\n */\n updateBodyInstances(body, mesh) {\n var _mesh$_thinInstanceDa3, _mesh$_thinInstanceDa4;\n const instancesCount = (_mesh$_thinInstanceDa3 = (_mesh$_thinInstanceDa4 = mesh._thinInstanceDataStorage) === null || _mesh$_thinInstanceDa4 === void 0 ? void 0 : _mesh$_thinInstanceDa4.instancesCount) !== null && _mesh$_thinInstanceDa3 !== void 0 ? _mesh$_thinInstanceDa3 : 0;\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n const pluginInstancesCount = body._pluginDataInstances.length;\n const motionType = this.getMotionType(body);\n if (instancesCount > pluginInstancesCount) {\n this._createOrUpdateBodyInstances(body, motionType, matrixData, pluginInstancesCount, instancesCount, false);\n const firstBodyShape = this._hknp.HP_Body_GetShape(body._pluginDataInstances[0].hpBodyId)[1];\n // firstBodyShape[0] might be 0 in the case where thin instances data is set (with thinInstancesSetBuffer call) after body creation\n // in that case, use the shape provided at body creation.\n if (!firstBodyShape[0]) {\n var _body$shape;\n firstBodyShape[0] = (_body$shape = body.shape) === null || _body$shape === void 0 ? void 0 : _body$shape._pluginData[0];\n }\n for (let i = pluginInstancesCount; i < instancesCount; i++) {\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, firstBodyShape);\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\n this._bodies.set(body._pluginDataInstances[i].hpBodyId[0], {\n body: body,\n index: i\n });\n }\n } else if (instancesCount < pluginInstancesCount) {\n const instancesToRemove = pluginInstancesCount - instancesCount;\n for (let i = 0; i < instancesToRemove; i++) {\n const hkbody = body._pluginDataInstances.pop();\n this._bodies.delete(hkbody.hpBodyId[0]);\n this._hknp.HP_World_RemoveBody(this.world, hkbody.hpBodyId);\n this._hknp.HP_Body_Release(hkbody.hpBodyId);\n }\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, true);\n }\n }\n /**\n * Synchronizes the transform of a physics body with its transform node.\n * @param body - The physics body to synchronize.\n *\n * This function is useful for keeping the physics body's transform in sync with its transform node.\n * This is important for ensuring that the physics body is accurately represented in the physics engine.\n */\n sync(body) {\n this.syncTransform(body, body.transformNode);\n }\n /**\n * Synchronizes the transform of a physics body with the transform of its\n * corresponding transform node.\n *\n * @param body - The physics body to synchronize.\n * @param transformNode - The destination Transform Node.\n *\n * This code is useful for synchronizing the position and orientation of a\n * physics body with the position and orientation of its corresponding\n * transform node. This is important for ensuring that the physics body and\n * the transform node are in the same position and orientation in the scene.\n * This is necessary for the physics engine to accurately simulate the\n * physical behavior of the body.\n */\n syncTransform(body, transformNode) {\n if (body._pluginDataInstances.length) {\n // instances\n const m = transformNode;\n const matrixData = m._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n const instancesCount = body._pluginDataInstances.length;\n for (let i = 0; i < instancesCount; i++) {\n const bufOffset = body._pluginDataInstances[i].worldTransformOffset;\n const transformBuffer = new Float32Array(this._hknp.HEAPU8.buffer, this._bodyBuffer + bufOffset, 16);\n const index = i * 16;\n for (let mi = 0; mi < 15; mi++) {\n if ((mi & 3) != 3) {\n matrixData[index + mi] = transformBuffer[mi];\n }\n }\n matrixData[index + 15] = 1;\n }\n m.thinInstanceBufferUpdated(\"matrix\");\n } else {\n try {\n // regular\n const bodyTransform = this._hknp.HP_Body_GetQTransform(body._pluginData.hpBodyId)[1];\n const bodyTranslation = bodyTransform[0];\n const bodyOrientation = bodyTransform[1];\n const quat = TmpVectors.Quaternion[0];\n quat.set(bodyOrientation[0], bodyOrientation[1], bodyOrientation[2], bodyOrientation[3]);\n const parent = transformNode.parent;\n // transform position/orientation in parent space\n if (parent && !parent.getWorldMatrix().isIdentity()) {\n var _transformNode$rotati;\n parent.computeWorldMatrix(true);\n // Save scaling for future use\n TmpVectors.Vector3[1].copyFrom(transformNode.scaling);\n quat.normalize();\n const finalTransform = TmpVectors.Matrix[0];\n const finalTranslation = TmpVectors.Vector3[0];\n finalTranslation.copyFromFloats(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);\n Matrix.ComposeToRef(transformNode.absoluteScaling, quat, finalTranslation, finalTransform);\n const parentInverseTransform = TmpVectors.Matrix[1];\n parent.getWorldMatrix().invertToRef(parentInverseTransform);\n const localTransform = TmpVectors.Matrix[2];\n finalTransform.multiplyToRef(parentInverseTransform, localTransform);\n localTransform.decomposeToTransformNode(transformNode);\n (_transformNode$rotati = transformNode.rotationQuaternion) === null || _transformNode$rotati === void 0 || _transformNode$rotati.normalize();\n // Keep original scaling. Re-injecting scaling can introduce discontinuity between frames. Basically, it grows or shrinks.\n transformNode.scaling.copyFrom(TmpVectors.Vector3[1]);\n } else {\n transformNode.position.set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);\n if (transformNode.rotationQuaternion) {\n transformNode.rotationQuaternion.copyFrom(quat);\n } else {\n quat.toEulerAnglesToRef(transformNode.rotation);\n }\n }\n } catch (e) {\n Logger.Error(`Syncing transform failed for node ${transformNode.name}: ${e.message}...`);\n }\n }\n }\n /**\n * Sets the shape of a physics body.\n * @param body - The physics body to set the shape for.\n * @param shape - The physics shape to set.\n *\n * This function is used to set the shape of a physics body. It is useful for\n * creating a physics body with a specific shape, such as a box or a sphere,\n * which can then be used to simulate physical interactions in a physics engine.\n * This function is especially useful for meshes with multiple instances, as it\n * will set the shape for each instance of the mesh.\n */\n setShape(body, shape) {\n var _body$transformNode$_, _m$_thinInstanceDataS, _m$_thinInstanceDataS2;\n const shapeHandle = shape && shape._pluginData ? shape._pluginData : BigInt(0);\n if (!(body.transformNode instanceof Mesh) || !((_body$transformNode$_ = body.transformNode._thinInstanceDataStorage) !== null && _body$transformNode$_ !== void 0 && _body$transformNode$_.matrixData)) {\n this._hknp.HP_Body_SetShape(body._pluginData.hpBodyId, shapeHandle);\n this._internalUpdateMassProperties(body._pluginData);\n return;\n }\n const m = body.transformNode;\n const instancesCount = (_m$_thinInstanceDataS = (_m$_thinInstanceDataS2 = m._thinInstanceDataStorage) === null || _m$_thinInstanceDataS2 === void 0 ? void 0 : _m$_thinInstanceDataS2.instancesCount) !== null && _m$_thinInstanceDataS !== void 0 ? _m$_thinInstanceDataS : 0;\n for (let i = 0; i < instancesCount; i++) {\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, shapeHandle);\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\n }\n }\n /**\n * Returns a reference to the first instance of the plugin data for a physics body.\n * @param body\n * @param instanceIndex\n * @returns a reference to the first instance\n */\n _getPluginReference(body, instanceIndex) {\n var _body$_pluginDataInst;\n return (_body$_pluginDataInst = body._pluginDataInstances) !== null && _body$_pluginDataInst !== void 0 && _body$_pluginDataInst.length ? body._pluginDataInstances[instanceIndex !== null && instanceIndex !== void 0 ? instanceIndex : 0] : body._pluginData;\n }\n /**\n * Gets the shape of a physics body. This will create a new shape object\n *\n * @param body - The physics body.\n * @returns The shape of the physics body.\n *\n */\n getShape(body) {\n const pluginRef = this._getPluginReference(body);\n const shapePluginData = this._hknp.HP_Body_GetShape(pluginRef.hpBodyId)[1];\n if (shapePluginData != 0) {\n const scene = body.transformNode.getScene();\n return new PhysicsShape({\n pluginData: shapePluginData\n }, scene);\n }\n return null;\n }\n /**\n * Gets the type of a physics shape.\n * @param shape - The physics shape to get the type for.\n * @returns The type of the physics shape.\n *\n */\n getShapeType(shape) {\n if (shape.type) {\n return shape.type;\n } else {\n // {\n this._hknp.HP_Body_SetEventMask(bodyPluginData.hpBodyId, eventMask);\n }, instanceIndex);\n }\n /**\n * Retrieves the event mask of a physics body.\n *\n * @param body - The physics body to retrieve the event mask from.\n * @param instanceIndex - The index of the instance to retrieve the event mask from.\n * @returns The event mask of the physics body.\n *\n */\n getEventMask(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetEventMask(pluginRef.hpBodyId)[1];\n }\n _fromMassPropertiesTuple(massPropsTuple) {\n return {\n centerOfMass: Vector3.FromArray(massPropsTuple[0]),\n mass: massPropsTuple[1],\n inertia: Vector3.FromArray(massPropsTuple[2]),\n inertiaOrientation: Quaternion.FromArray(massPropsTuple[3])\n };\n }\n _internalUpdateMassProperties(pluginData) {\n // Recompute the mass based on the shape\n const newProps = this._internalComputeMassProperties(pluginData);\n const massProps = pluginData.userMassProps;\n // Override the computed values with any the user has set\n if (massProps.centerOfMass) {\n newProps[0] = massProps.centerOfMass.asArray();\n }\n if (massProps.mass != undefined) {\n newProps[1] = massProps.mass;\n }\n if (massProps.inertia) {\n newProps[2] = massProps.inertia.asArray();\n }\n if (massProps.inertiaOrientation) {\n newProps[3] = massProps.inertiaOrientation.asArray();\n }\n this._hknp.HP_Body_SetMassProperties(pluginData.hpBodyId, newProps);\n }\n _internalSetMotionType(pluginData, motionType) {\n switch (motionType) {\n case 0 /* PhysicsMotionType.STATIC */:\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.STATIC);\n break;\n case 1 /* PhysicsMotionType.ANIMATED */:\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.KINEMATIC);\n break;\n case 2 /* PhysicsMotionType.DYNAMIC */:\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.DYNAMIC);\n break;\n }\n }\n /**\n * sets the motion type of a physics body.\n * @param body - The physics body to set the motion type for.\n * @param motionType - The motion type to set.\n * @param instanceIndex - The index of the instance to set the motion type for. If undefined, the motion type of all the bodies will be set.\n */\n setMotionType(body, motionType, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginData => {\n this._internalSetMotionType(pluginData, motionType);\n }, instanceIndex);\n }\n /**\n * Gets the motion type of a physics body.\n * @param body - The physics body to get the motion type from.\n * @param instanceIndex - The index of the instance to get the motion type from. If not specified, the motion type of the first instance will be returned.\n * @returns The motion type of the physics body.\n */\n getMotionType(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const type = this._hknp.HP_Body_GetMotionType(pluginRef.hpBodyId)[1];\n switch (type) {\n case this._hknp.MotionType.STATIC:\n return 0 /* PhysicsMotionType.STATIC */;\n case this._hknp.MotionType.KINEMATIC:\n return 1 /* PhysicsMotionType.ANIMATED */;\n case this._hknp.MotionType.DYNAMIC:\n return 2 /* PhysicsMotionType.DYNAMIC */;\n }\n throw new Error(\"Unknown motion type: \" + type);\n }\n /**\n * sets the activation control mode of a physics body, for instance if you need the body to never sleep.\n * @param body - The physics body to set the activation control mode.\n * @param controlMode - The activation control mode.\n */\n setActivationControl(body, controlMode) {\n switch (controlMode) {\n case 1 /* PhysicsActivationControl.ALWAYS_ACTIVE */:\n this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.ALWAYS_ACTIVE);\n break;\n case 2 /* PhysicsActivationControl.ALWAYS_INACTIVE */:\n this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.ALWAYS_INACTIVE);\n break;\n case 0 /* PhysicsActivationControl.SIMULATION_CONTROLLED */:\n this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.SIMULATION_CONTROLLED);\n break;\n }\n }\n _internalComputeMassProperties(pluginData) {\n const shapeRes = this._hknp.HP_Body_GetShape(pluginData.hpBodyId);\n if (shapeRes[0] == this._hknp.Result.RESULT_OK) {\n const shapeMass = this._hknp.HP_Shape_BuildMassProperties(shapeRes[1]);\n if (shapeMass[0] == this._hknp.Result.RESULT_OK) {\n return shapeMass[1];\n }\n }\n // Failed; return a unit inertia\n return [[0, 0, 0], 1, [1, 1, 1], [0, 0, 0, 1]];\n }\n /**\n * Computes the mass properties of a physics body, from it's shape\n *\n * @param body - The physics body to copmute the mass properties of\n * @param instanceIndex - The index of the instance to compute the mass properties of.\n * @returns The mass properties of the physics body.\n */\n computeMassProperties(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const computed = this._internalComputeMassProperties(pluginRef);\n return this._fromMassPropertiesTuple(computed);\n }\n /**\n * Sets the mass properties of a physics body.\n *\n * @param body - The physics body to set the mass properties of.\n * @param massProps - The mass properties to set.\n * @param instanceIndex - The index of the instance to set the mass properties of. If undefined, the mass properties of all the bodies will be set.\n * This function is useful for setting the mass properties of a physics body,\n * such as its mass, inertia, and center of mass. This is important for\n * accurately simulating the physics of the body in the physics engine.\n *\n */\n setMassProperties(body, massProps, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginData => {\n pluginData.userMassProps = massProps;\n this._internalUpdateMassProperties(pluginData);\n }, instanceIndex);\n }\n /**\n * Gets the mass properties of a physics body.\n * @param body - The physics body to get the mass properties from.\n * @param instanceIndex - The index of the instance to get the mass properties from. If not specified, the mass properties of the first instance will be returned.\n * @returns The mass properties of the physics body.\n */\n getMassProperties(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const massPropsTuple = this._hknp.HP_Body_GetMassProperties(pluginRef.hpBodyId)[1];\n return this._fromMassPropertiesTuple(massPropsTuple);\n }\n /**\n * Sets the linear damping of the given body.\n * @param body - The body to set the linear damping for.\n * @param damping - The linear damping to set.\n * @param instanceIndex - The index of the instance to set the linear damping for. If not specified, the linear damping of the first instance will be set.\n *\n * This method is useful for controlling the linear damping of a body in a physics engine.\n * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body.\n * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.\n */\n setLinearDamping(body, damping, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginData => {\n this._hknp.HP_Body_SetLinearDamping(pluginData.hpBodyId, damping);\n }, instanceIndex);\n }\n /**\n * Gets the linear damping of the given body.\n * @param body - The body to get the linear damping from.\n * @param instanceIndex - The index of the instance to get the linear damping from. If not specified, the linear damping of the first instance will be returned.\n * @returns The linear damping of the given body.\n *\n * This method is useful for getting the linear damping of a body in a physics engine.\n * Linear damping is a force that opposes the motion of the body and is proportional to the velocity of the body.\n * It is used to simulate the effects of air resistance and other forms of friction.\n */\n getLinearDamping(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetLinearDamping(pluginRef.hpBodyId)[1];\n }\n /**\n * Sets the angular damping of a physics body.\n * @param body - The physics body to set the angular damping for.\n * @param damping - The angular damping value to set.\n * @param instanceIndex - The index of the instance to set the angular damping for. If not specified, the angular damping of the first instance will be set.\n *\n * This function is useful for controlling the angular velocity of a physics body.\n * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.\n */\n setAngularDamping(body, damping, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginData => {\n this._hknp.HP_Body_SetAngularDamping(pluginData.hpBodyId, damping);\n }, instanceIndex);\n }\n /**\n * Gets the angular damping of a physics body.\n * @param body - The physics body to get the angular damping from.\n * @param instanceIndex - The index of the instance to get the angular damping from. If not specified, the angular damping of the first instance will be returned.\n * @returns The angular damping of the body.\n *\n * This function is useful for retrieving the angular damping of a physics body,\n * which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping.\n */\n getAngularDamping(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetAngularDamping(pluginRef.hpBodyId)[1];\n }\n /**\n * Sets the linear velocity of a physics body.\n * @param body - The physics body to set the linear velocity of.\n * @param linVel - The linear velocity to set.\n * @param instanceIndex - The index of the instance to set the linear velocity of. If not specified, the linear velocity of the first instance will be set.\n *\n * This function is useful for setting the linear velocity of a physics body, which is necessary for simulating\n * motion in a physics engine. The linear velocity is the speed and direction of the body's movement.\n */\n setLinearVelocity(body, linVel, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginData => {\n this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, this._bVecToV3(linVel));\n }, instanceIndex);\n }\n /**\n * Gets the linear velocity of a physics body and stores it in a given vector.\n * @param body - The physics body to get the linear velocity from.\n * @param linVel - The vector to store the linear velocity in.\n * @param instanceIndex - The index of the instance to get the linear velocity from. If not specified, the linear velocity of the first instance will be returned.\n *\n * This function is useful for retrieving the linear velocity of a physics body,\n * which can be used to determine the speed and direction of the body. This\n * information can be used to simulate realistic physics behavior in a game.\n */\n getLinearVelocityToRef(body, linVel, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const lv = this._hknp.HP_Body_GetLinearVelocity(pluginRef.hpBodyId)[1];\n this._v3ToBvecRef(lv, linVel);\n }\n /*\n * Apply an operation either to all instances of a body, if instanceIndex is not specified, or to a specific instance.\n */\n _applyToBodyOrInstances(body, fnToApply, instanceIndex) {\n var _body$_pluginDataInst2;\n if (((_body$_pluginDataInst2 = body._pluginDataInstances) === null || _body$_pluginDataInst2 === void 0 ? void 0 : _body$_pluginDataInst2.length) > 0 && instanceIndex === undefined) {\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\n fnToApply(body._pluginDataInstances[i]);\n }\n } else {\n fnToApply(this._getPluginReference(body, instanceIndex));\n }\n }\n /**\n * Applies an impulse to a physics body at a given location.\n * @param body - The physics body to apply the impulse to.\n * @param impulse - The impulse vector to apply.\n * @param location - The location in world space to apply the impulse.\n * @param instanceIndex - The index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.\n *\n * This method is useful for applying an impulse to a physics body at a given location.\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\n */\n applyImpulse(body, impulse, location, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginRef => {\n this._hknp.HP_Body_ApplyImpulse(pluginRef.hpBodyId, this._bVecToV3(location), this._bVecToV3(impulse));\n }, instanceIndex);\n }\n /**\n * Applies an angular impulse(torque) to a physics body\n * @param body - The physics body to apply the impulse to.\n * @param angularImpulse - The torque value\n * @param instanceIndex - The index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.\n */\n applyAngularImpulse(body, angularImpulse, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginRef => {\n this._hknp.HP_Body_ApplyAngularImpulse(pluginRef.hpBodyId, this._bVecToV3(angularImpulse));\n }, instanceIndex);\n }\n /**\n * Applies a force to a physics body at a given location.\n * @param body - The physics body to apply the impulse to.\n * @param force - The force vector to apply.\n * @param location - The location in world space to apply the impulse.\n * @param instanceIndex - The index of the instance to apply the force to. If not specified, the force will be applied to all instances.\n *\n * This method is useful for applying a force to a physics body at a given location.\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\n */\n applyForce(body, force, location, instanceIndex) {\n force.scaleToRef(this.getTimeStep(), this._tmpVec3[0]);\n this.applyImpulse(body, this._tmpVec3[0], location, instanceIndex);\n }\n /**\n * Sets the angular velocity of a physics body.\n *\n * @param body - The physics body to set the angular velocity of.\n * @param angVel - The angular velocity to set.\n * @param instanceIndex - The index of the instance to set the angular velocity of. If not specified, the angular velocity of the first instance will be set.\n *\n * This function is useful for setting the angular velocity of a physics body in a physics engine.\n * This allows for more realistic simulations of physical objects, as they can be given a rotational velocity.\n */\n setAngularVelocity(body, angVel, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginRef => {\n this._hknp.HP_Body_SetAngularVelocity(pluginRef.hpBodyId, this._bVecToV3(angVel));\n }, instanceIndex);\n }\n /**\n * Gets the angular velocity of a body.\n * @param body - The body to get the angular velocity from.\n * @param angVel - The vector3 to store the angular velocity.\n * @param instanceIndex - The index of the instance to get the angular velocity from. If not specified, the angular velocity of the first instance will be returned.\n *\n * This method is useful for getting the angular velocity of a body in a physics engine. It\n * takes the body and a vector3 as parameters and stores the angular velocity of the body\n * in the vector3. This is useful for getting the angular velocity of a body in order to\n * calculate the motion of the body in the physics engine.\n */\n getAngularVelocityToRef(body, angVel, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const av = this._hknp.HP_Body_GetAngularVelocity(pluginRef.hpBodyId)[1];\n this._v3ToBvecRef(av, angVel);\n }\n /**\n * Sets the transformation of the given physics body to the given transform node.\n * @param body The physics body to set the transformation for.\n * @param node The transform node to set the transformation from.\n * Sets the transformation of the given physics body to the given transform node.\n *\n * This function is useful for setting the transformation of a physics body to a\n * transform node, which is necessary for the physics engine to accurately simulate\n * the motion of the body. It also takes into account instances of the transform\n * node, which is necessary for accurate simulation of multiple bodies with the\n * same transformation.\n */\n setPhysicsBodyTransformation(body, node) {\n if (body.getPrestepType() == PhysicsPrestepType.TELEPORT) {\n const transformNode = body.transformNode;\n if (body.numInstances > 0) {\n // instances\n const m = transformNode;\n const matrixData = m._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n const instancesCount = body.numInstances;\n this._createOrUpdateBodyInstances(body, body.getMotionType(), matrixData, 0, instancesCount, true);\n } else {\n // regular\n this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node));\n }\n } else if (body.getPrestepType() == PhysicsPrestepType.ACTION) {\n this.setTargetTransform(body, node.absolutePosition, node.absoluteRotationQuaternion);\n } else if (body.getPrestepType() == PhysicsPrestepType.DISABLED) {\n Logger.Warn(\"Prestep type is set to DISABLED. Unable to set physics body transformation.\");\n } else {\n Logger.Warn(\"Invalid prestep type set to physics body.\");\n }\n }\n /**\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\n * @param body The physics body to set the target transformation for.\n * @param position The target position\n * @param rotation The target rotation\n * @param instanceIndex The index of the instance in an instanced body\n */\n setTargetTransform(body, position, rotation, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginRef => {\n this._hknp.HP_Body_SetTargetQTransform(pluginRef.hpBodyId, [this._bVecToV3(position), this._bQuatToV4(rotation)]);\n }, instanceIndex);\n }\n /**\n * Sets the gravity factor of a body\n * @param body the physics body to set the gravity factor for\n * @param factor the gravity factor\n * @param instanceIndex the index of the instance in an instanced body\n */\n setGravityFactor(body, factor, instanceIndex) {\n this._applyToBodyOrInstances(body, pluginRef => {\n this._hknp.HP_Body_SetGravityFactor(pluginRef.hpBodyId, factor);\n }, instanceIndex);\n }\n /**\n * Get the gravity factor of a body\n * @param body the physics body to get the gravity factor from\n * @param instanceIndex the index of the instance in an instanced body. If not specified, the gravity factor of the first instance will be returned.\n * @returns the gravity factor\n */\n getGravityFactor(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetGravityFactor(pluginRef.hpBodyId)[1];\n }\n /**\n * Disposes a physics body.\n *\n * @param body - The physics body to dispose.\n *\n * This method is useful for releasing the resources associated with a physics body when it is no longer needed.\n * This is important for avoiding memory leaks in the physics engine.\n */\n disposeBody(body) {\n if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {\n for (const instance of body._pluginDataInstances) {\n this._hknp.HP_Body_Release(instance.hpBodyId);\n instance.hpBodyId = undefined;\n }\n }\n if (body._pluginData) {\n this._hknp.HP_Body_Release(body._pluginData.hpBodyId);\n body._pluginData.hpBodyId = undefined;\n }\n }\n _createOptionsFromGroundMesh(options) {\n const mesh = options.groundMesh;\n if (!mesh) {\n return;\n }\n let pos = mesh.getVerticesData(VertexBuffer.PositionKind);\n const transform = mesh.computeWorldMatrix(true);\n // convert rawVerts to object space\n const transformedVertices = [];\n let index;\n for (index = 0; index < pos.length; index += 3) {\n Vector3.FromArrayToRef(pos, index, TmpVectors.Vector3[0]);\n Vector3.TransformCoordinatesToRef(TmpVectors.Vector3[0], transform, TmpVectors.Vector3[1]);\n TmpVectors.Vector3[1].toArray(transformedVertices, index);\n }\n pos = transformedVertices;\n const arraySize = ~~(Math.sqrt(pos.length / 3) - 1);\n const boundingInfo = mesh.getBoundingInfo();\n const dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.z);\n const minX = boundingInfo.boundingBox.minimumWorld.x;\n const minY = boundingInfo.boundingBox.minimumWorld.y;\n const minZ = boundingInfo.boundingBox.minimumWorld.z;\n const matrix = new Float32Array((arraySize + 1) * (arraySize + 1));\n const elementSize = dim * 2 / arraySize;\n for (let i = 0; i < matrix.length; i++) {\n matrix[i] = minY;\n }\n for (let i = 0; i < pos.length; i = i + 3) {\n const x = Math.round((pos[i + 0] - minX) / elementSize);\n const z = arraySize - Math.round((pos[i + 2] - minZ) / elementSize);\n const y = pos[i + 1] - minY;\n matrix[z * (arraySize + 1) + x] = y;\n }\n options.numHeightFieldSamplesX = arraySize + 1;\n options.numHeightFieldSamplesZ = arraySize + 1;\n options.heightFieldSizeX = boundingInfo.boundingBox.extendSizeWorld.x * 2;\n options.heightFieldSizeZ = boundingInfo.boundingBox.extendSizeWorld.z * 2;\n options.heightFieldData = matrix;\n }\n /**\n * Initializes a physics shape with the given type and parameters.\n * @param shape - The physics shape to initialize.\n * @param type - The type of shape to initialize.\n * @param options - The parameters for the shape.\n *\n * This code is useful for initializing a physics shape with the given type and parameters.\n * It allows for the creation of a sphere, box, capsule, container, cylinder, mesh, and heightfield.\n * Depending on the type of shape, different parameters are required.\n * For example, a sphere requires a radius, while a box requires extents and a rotation.\n */\n initShape(shape, type, options) {\n switch (type) {\n case 0 /* PhysicsShapeType.SPHERE */:\n {\n const radius = options.radius || 1;\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\n shape._pluginData = this._hknp.HP_Shape_CreateSphere(center, radius)[1];\n }\n break;\n case 3 /* PhysicsShapeType.BOX */:\n {\n const rotation = options.rotation ? this._bQuatToV4(options.rotation) : [0, 0, 0, 1];\n const extent = options.extents ? this._bVecToV3(options.extents) : [1, 1, 1];\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\n shape._pluginData = this._hknp.HP_Shape_CreateBox(center, rotation, extent)[1];\n }\n break;\n case 1 /* PhysicsShapeType.CAPSULE */:\n {\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\n const radius = options.radius || 0;\n shape._pluginData = this._hknp.HP_Shape_CreateCapsule(pointA, pointB, radius)[1];\n }\n break;\n case 5 /* PhysicsShapeType.CONTAINER */:\n {\n shape._pluginData = this._hknp.HP_Shape_CreateContainer()[1];\n }\n break;\n case 2 /* PhysicsShapeType.CYLINDER */:\n {\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\n const radius = options.radius || 0;\n shape._pluginData = this._hknp.HP_Shape_CreateCylinder(pointA, pointB, radius)[1];\n }\n break;\n case 4 /* PhysicsShapeType.CONVEX_HULL */:\n case 6 /* PhysicsShapeType.MESH */:\n {\n const mesh = options.mesh;\n if (mesh) {\n const includeChildMeshes = !!options.includeChildMeshes;\n const needIndices = type != 4 /* PhysicsShapeType.CONVEX_HULL */;\n const accum = new MeshAccumulator(mesh, needIndices, mesh === null || mesh === void 0 ? void 0 : mesh.getScene());\n accum.addNodeMeshes(mesh, includeChildMeshes);\n const positions = accum.getVertices(this._hknp);\n const numVec3s = positions.numObjects / 3;\n if (type == 4 /* PhysicsShapeType.CONVEX_HULL */) {\n shape._pluginData = this._hknp.HP_Shape_CreateConvexHull(positions.offset, numVec3s)[1];\n } else {\n const triangles = accum.getTriangles(this._hknp);\n const numTriangles = triangles.numObjects / 3;\n shape._pluginData = this._hknp.HP_Shape_CreateMesh(positions.offset, numVec3s, triangles.offset, numTriangles)[1];\n accum.freeBuffer(this._hknp, triangles);\n }\n accum.freeBuffer(this._hknp, positions);\n } else {\n throw new Error(\"No mesh provided to create physics shape.\");\n }\n }\n break;\n case 7 /* PhysicsShapeType.HEIGHTFIELD */:\n {\n if (options.groundMesh) {\n // update options with datas from groundMesh\n this._createOptionsFromGroundMesh(options);\n }\n if (options.numHeightFieldSamplesX && options.numHeightFieldSamplesZ && options.heightFieldSizeX && options.heightFieldSizeZ && options.heightFieldData) {\n const totalNumHeights = options.numHeightFieldSamplesX * options.numHeightFieldSamplesZ;\n const numBytes = totalNumHeights * 4;\n const bufferBegin = this._hknp._malloc(numBytes);\n const heightBuffer = new Float32Array(this._hknp.HEAPU8.buffer, bufferBegin, totalNumHeights);\n for (let x = 0; x < options.numHeightFieldSamplesX; x++) {\n for (let z = 0; z < options.numHeightFieldSamplesZ; z++) {\n const hkBufferIndex = z * options.numHeightFieldSamplesX + x;\n const bjsBufferIndex = (options.numHeightFieldSamplesX - 1 - x) * options.numHeightFieldSamplesZ + z;\n heightBuffer[hkBufferIndex] = options.heightFieldData[bjsBufferIndex];\n }\n }\n const scaleX = options.heightFieldSizeX / (options.numHeightFieldSamplesX - 1);\n const scaleZ = options.heightFieldSizeZ / (options.numHeightFieldSamplesZ - 1);\n shape._pluginData = this._hknp.HP_Shape_CreateHeightField(options.numHeightFieldSamplesX, options.numHeightFieldSamplesZ, [scaleX, 1, scaleZ], bufferBegin)[1];\n this._hknp._free(bufferBegin);\n } else {\n throw new Error(\"Missing required heightfield parameters\");\n }\n }\n break;\n default:\n throw new Error(\"Unsupported Shape Type.\");\n break;\n }\n this._shapes.set(shape._pluginData[0], shape);\n }\n /**\n * Sets the shape filter membership mask of a body\n * @param shape - The physics body to set the shape filter membership mask for.\n * @param membershipMask - The shape filter membership mask to set.\n */\n setShapeFilterMembershipMask(shape, membershipMask) {\n const collideWith = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membershipMask, collideWith]);\n }\n /**\n * Gets the shape filter membership mask of a body\n * @param shape - The physics body to get the shape filter membership mask from.\n * @returns The shape filter membership mask of the given body.\n */\n getShapeFilterMembershipMask(shape) {\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\n }\n /**\n * Sets the shape filter collide mask of a body\n * @param shape - The physics body to set the shape filter collide mask for.\n * @param collideMask - The shape filter collide mask to set.\n */\n setShapeFilterCollideMask(shape, collideMask) {\n const membership = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membership, collideMask]);\n }\n /**\n * Gets the shape filter collide mask of a body\n * @param shape - The physics body to get the shape filter collide mask from.\n * @returns The shape filter collide mask of the given body.\n */\n getShapeFilterCollideMask(shape) {\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\n }\n /**\n * Sets the material of a physics shape.\n * @param shape - The physics shape to set the material of.\n * @param material - The material to set.\n *\n */\n setMaterial(shape, material) {\n var _material$friction, _material$staticFrict, _material$restitution, _material$frictionCom, _material$restitution2;\n const dynamicFriction = (_material$friction = material.friction) !== null && _material$friction !== void 0 ? _material$friction : 0.5;\n const staticFriction = (_material$staticFrict = material.staticFriction) !== null && _material$staticFrict !== void 0 ? _material$staticFrict : dynamicFriction;\n const restitution = (_material$restitution = material.restitution) !== null && _material$restitution !== void 0 ? _material$restitution : 0.0;\n const frictionCombine = (_material$frictionCom = material.frictionCombine) !== null && _material$frictionCom !== void 0 ? _material$frictionCom : 1 /* PhysicsMaterialCombineMode.MINIMUM */;\n const restitutionCombine = (_material$restitution2 = material.restitutionCombine) !== null && _material$restitution2 !== void 0 ? _material$restitution2 : 2 /* PhysicsMaterialCombineMode.MAXIMUM */;\n const hpMaterial = [staticFriction, dynamicFriction, restitution, this._materialCombineToNative(frictionCombine), this._materialCombineToNative(restitutionCombine)];\n this._hknp.HP_Shape_SetMaterial(shape._pluginData, hpMaterial);\n }\n /**\n * Gets the material associated with a physics shape.\n * @param shape - The shape to get the material from.\n * @returns The material associated with the shape.\n */\n getMaterial(shape) {\n const hkMaterial = this._hknp.HP_Shape_GetMaterial(shape._pluginData)[1];\n return {\n staticFriction: hkMaterial[0],\n friction: hkMaterial[1],\n restitution: hkMaterial[2],\n frictionCombine: this._nativeToMaterialCombine(hkMaterial[3]),\n restitutionCombine: this._nativeToMaterialCombine(hkMaterial[4])\n };\n }\n /**\n * Sets the density of a physics shape.\n * @param shape - The physics shape to set the density of.\n * @param density - The density to set.\n *\n */\n setDensity(shape, density) {\n this._hknp.HP_Shape_SetDensity(shape._pluginData, density);\n }\n /**\n * Calculates the density of a given physics shape.\n *\n * @param shape - The physics shape to calculate the density of.\n * @returns The density of the given physics shape.\n *\n */\n getDensity(shape) {\n return this._hknp.HP_Shape_GetDensity(shape._pluginData)[1];\n }\n /**\n * Gets the transform infos of a given transform node.\n * This code is useful for getting the position and orientation of a given transform node.\n * It first checks if the node has a rotation quaternion, and if not, it creates one from the node's rotation.\n * It then creates an array containing the position and orientation of the node and returns it.\n * @param node - The transform node.\n * @returns An array containing the position and orientation of the node.\n */\n _getTransformInfos(node) {\n if (node.parent) {\n node.computeWorldMatrix(true);\n return [this._bVecToV3(node.absolutePosition), this._bQuatToV4(node.absoluteRotationQuaternion)];\n }\n let orientation = TmpVectors.Quaternion[0];\n if (node.rotationQuaternion) {\n orientation = node.rotationQuaternion;\n } else {\n const r = node.rotation;\n Quaternion.FromEulerAnglesToRef(r.x, r.y, r.z, orientation);\n }\n const transform = [this._bVecToV3(node.position), this._bQuatToV4(orientation)];\n return transform;\n }\n /**\n * Adds a child shape to the given shape.\n * @param shape - The parent shape.\n * @param newChild - The child shape to add.\n * @param translation - The relative translation of the child from the parent shape\n * @param rotation - The relative rotation of the child from the parent shape\n * @param scale - The relative scale scale of the child from the parent shaep\n *\n */\n addChild(shape, newChild, translation, rotation, scale) {\n const transformNative = [translation ? this._bVecToV3(translation) : [0, 0, 0], rotation ? this._bQuatToV4(rotation) : [0, 0, 0, 1], scale ? this._bVecToV3(scale) : [1, 1, 1]];\n this._hknp.HP_Shape_AddChild(shape._pluginData, newChild._pluginData, transformNative);\n }\n /**\n * Removes a child shape from a parent shape.\n * @param shape - The parent shape.\n * @param childIndex - The index of the child shape to remove.\n *\n */\n removeChild(shape, childIndex) {\n this._hknp.HP_Shape_RemoveChild(shape._pluginData, childIndex);\n }\n /**\n * Returns the number of children of the given shape.\n *\n * @param shape - The shape to get the number of children from.\n * @returns The number of children of the given shape.\n *\n */\n getNumChildren(shape) {\n return this._hknp.HP_Shape_GetNumChildren(shape._pluginData)[1];\n }\n /**\n * Marks the shape as a trigger\n * @param shape the shape to mark as a trigger\n * @param isTrigger if the shape is a trigger\n */\n setTrigger(shape, isTrigger) {\n this._hknp.HP_Shape_SetTrigger(shape._pluginData, isTrigger);\n }\n /**\n * Calculates the bounding box of a given physics shape.\n *\n * @param _shape - The physics shape to calculate the bounding box for.\n * @returns The calculated bounding box.\n *\n * This method is useful for physics engines as it allows to calculate the\n * boundaries of a given shape. Knowing the boundaries of a shape is important\n * for collision detection and other physics calculations.\n */\n getBoundingBox(_shape) {\n // get local AABB\n const aabb = this._hknp.HP_Shape_GetBoundingBox(_shape._pluginData, [[0, 0, 0], [0, 0, 0, 1]])[1];\n TmpVectors.Vector3[0].set(aabb[0][0], aabb[0][1], aabb[0][2]); // min\n TmpVectors.Vector3[1].set(aabb[1][0], aabb[1][1], aabb[1][2]); // max\n const boundingbox = new BoundingBox(TmpVectors.Vector3[0], TmpVectors.Vector3[1], Matrix.IdentityReadOnly);\n return boundingbox;\n }\n /**\n * Calculates the world bounding box of a given physics body.\n *\n * @param body - The physics body to calculate the bounding box for.\n * @returns The calculated bounding box.\n *\n * This method is useful for physics engines as it allows to calculate the\n * boundaries of a given body.\n */\n getBodyBoundingBox(body) {\n // get local AABB\n const aabb = this.getBoundingBox(body.shape);\n const boundingbox = new BoundingBox(aabb.minimum, aabb.maximum, body.transformNode.getWorldMatrix());\n return boundingbox;\n }\n /**\n * Gets the geometry of a physics body.\n *\n * @param body - The physics body.\n * @returns An object containing the positions and indices of the body's geometry.\n *\n */\n getBodyGeometry(body) {\n var _body$_pluginDataInst3;\n const dataInfo = ((_body$_pluginDataInst3 = body._pluginDataInstances) === null || _body$_pluginDataInst3 === void 0 ? void 0 : _body$_pluginDataInst3.length) > 0 ? body._pluginDataInstances[0] : body._pluginData;\n const shape = this._hknp.HP_Body_GetShape(dataInfo.hpBodyId)[1];\n const geometryRes = this._hknp.HP_Shape_CreateDebugDisplayGeometry(shape);\n if (geometryRes[0] != this._hknp.Result.RESULT_OK) {\n return {\n positions: [],\n indices: []\n };\n }\n const geometryInfo = this._hknp.HP_DebugGeometry_GetInfo(geometryRes[1])[1];\n const positionsInPlugin = new Float32Array(this._hknp.HEAPU8.buffer, geometryInfo[0], geometryInfo[1] * 3); // 3 floats per position\n const indicesInPlugin = new Uint32Array(this._hknp.HEAPU8.buffer, geometryInfo[2], geometryInfo[3] * 3); // 3 indices per triangle\n // HP_DebugGeometry_Release will free the buffer in the plugin. To avoid a\n // use-after-free, we need to make a copy of the data here.\n const positions = positionsInPlugin.slice(0);\n const indices = indicesInPlugin.slice(0);\n this._hknp.HP_DebugGeometry_Release(geometryRes[1]);\n return {\n positions: positions,\n indices: indices\n };\n }\n /**\n * Releases a physics shape from the physics engine.\n *\n * @param shape - The physics shape to be released.\n *\n * This method is useful for releasing a physics shape from the physics engine, freeing up resources and preventing memory leaks.\n */\n disposeShape(shape) {\n this._hknp.HP_Shape_Release(shape._pluginData);\n shape._pluginData = undefined;\n }\n // constraint\n /**\n * Initializes a physics constraint with the given parameters.\n *\n * @param constraint - The physics constraint to be initialized.\n * @param body - The main body\n * @param childBody - The child body.\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n *\n * This function is useful for setting up a physics constraint in a physics engine.\n */\n initConstraint(constraint, body, childBody, instanceIndex, childInstanceIndex) {\n var _constraint$_pluginDa, _options$axisA, _options$axisB;\n const type = constraint.type;\n const options = constraint.options;\n if (!type || !options) {\n Logger.Warn(\"No constraint type or options. Constraint is invalid.\");\n return;\n }\n if (body._pluginDataInstances.length > 0 && instanceIndex === undefined || childBody._pluginDataInstances.length > 0 && childInstanceIndex === undefined) {\n Logger.Warn(\"Body is instanced but no instance index was specified. Constraint will not be applied.\");\n return;\n }\n constraint._pluginData = (_constraint$_pluginDa = constraint._pluginData) !== null && _constraint$_pluginDa !== void 0 ? _constraint$_pluginDa : [];\n const jointId = this._hknp.HP_Constraint_Create()[1];\n constraint._pluginData.push(jointId);\n // body parenting\n const bodyA = this._getPluginReference(body, instanceIndex).hpBodyId;\n const bodyB = this._getPluginReference(childBody, childInstanceIndex).hpBodyId;\n this._hknp.HP_Constraint_SetParentBody(jointId, bodyA);\n this._hknp.HP_Constraint_SetChildBody(jointId, bodyB);\n this._constraintToBodyIdPair.set(jointId[0], [bodyA[0], bodyB[0]]);\n // anchors\n const pivotA = options.pivotA ? this._bVecToV3(options.pivotA) : this._bVecToV3(Vector3.Zero());\n const axisA = (_options$axisA = options.axisA) !== null && _options$axisA !== void 0 ? _options$axisA : new Vector3(1, 0, 0);\n const perpAxisA = this._tmpVec3[0];\n if (options.perpAxisA) {\n perpAxisA.copyFrom(options.perpAxisA);\n } else {\n axisA.getNormalToRef(perpAxisA);\n }\n this._hknp.HP_Constraint_SetAnchorInParent(jointId, pivotA, this._bVecToV3(axisA), this._bVecToV3(perpAxisA));\n const pivotB = options.pivotB ? this._bVecToV3(options.pivotB) : this._bVecToV3(Vector3.Zero());\n const axisB = (_options$axisB = options.axisB) !== null && _options$axisB !== void 0 ? _options$axisB : new Vector3(1, 0, 0);\n const perpAxisB = this._tmpVec3[0];\n if (options.perpAxisB) {\n perpAxisB.copyFrom(options.perpAxisB);\n } else {\n axisB.getNormalToRef(perpAxisB);\n }\n this._hknp.HP_Constraint_SetAnchorInChild(jointId, pivotB, this._bVecToV3(axisB), this._bVecToV3(perpAxisB));\n // Save the options that were used for initializing the constraint for debugging purposes\n // Check first to avoid copying the same options multiple times\n if (!constraint._initOptions) {\n constraint._initOptions = {\n axisA: axisA.clone(),\n axisB: axisB.clone(),\n perpAxisA: perpAxisA.clone(),\n perpAxisB: perpAxisB.clone(),\n pivotA: new Vector3(pivotA[0], pivotA[1], pivotA[2]),\n pivotB: new Vector3(pivotB[0], pivotB[1], pivotB[2])\n };\n }\n if (type == 5 /* PhysicsConstraintType.LOCK */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n } else if (type == 2 /* PhysicsConstraintType.DISTANCE */) {\n const distance = options.maxDistance || 0;\n const dist3d = this._hknp.ConstraintAxis.LINEAR_DISTANCE;\n this._hknp.HP_Constraint_SetAxisMode(jointId, dist3d, this._hknp.ConstraintAxisLimitMode.LIMITED);\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, dist3d, distance);\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, dist3d, distance);\n } else if (type == 3 /* PhysicsConstraintType.HINGE */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n } else if (type == 6 /* PhysicsConstraintType.PRISMATIC */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n } else if (type == 4 /* PhysicsConstraintType.SLIDER */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n } else if (type == 1 /* PhysicsConstraintType.BALL_AND_SOCKET */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n } else if (type == 7 /* PhysicsConstraintType.SIX_DOF */) {\n const sixdofData = constraint;\n for (const l of sixdofData.limits) {\n var _l$minLimit, _l$maxLimit;\n const axId = this._constraintAxisToNative(l.axis);\n if (((_l$minLimit = l.minLimit) !== null && _l$minLimit !== void 0 ? _l$minLimit : -1) == 0 && ((_l$maxLimit = l.maxLimit) !== null && _l$maxLimit !== void 0 ? _l$maxLimit : -1) == 0) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LOCKED);\n } else {\n if (l.minLimit != undefined) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, axId, l.minLimit);\n }\n if (l.maxLimit != undefined) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, axId, l.maxLimit);\n }\n }\n if (l.stiffness) {\n this._hknp.HP_Constraint_SetAxisStiffness(jointId, axId, l.stiffness);\n }\n if (l.damping) {\n this._hknp.HP_Constraint_SetAxisDamping(jointId, axId, l.damping);\n }\n }\n } else {\n throw new Error(\"Unsupported Constraint Type.\");\n }\n const collisionEnabled = !!options.collision;\n this._hknp.HP_Constraint_SetCollisionsEnabled(jointId, collisionEnabled);\n this._hknp.HP_Constraint_SetEnabled(jointId, true);\n }\n /**\n * Get a list of all the pairs of bodies that are connected by this constraint.\n * @param constraint the constraint to search from\n * @returns a list of parent, child pairs\n */\n getBodiesUsingConstraint(constraint) {\n const pairs = [];\n for (const jointId of constraint._pluginData) {\n const bodyIds = this._constraintToBodyIdPair.get(jointId[0]);\n if (bodyIds) {\n const parentBodyInfo = this._bodies.get(bodyIds[0]);\n const childBodyInfo = this._bodies.get(bodyIds[1]);\n if (parentBodyInfo && childBodyInfo) {\n pairs.push({\n parentBody: parentBodyInfo.body,\n parentBodyIndex: parentBodyInfo.index,\n childBody: childBodyInfo.body,\n childBodyIndex: childBodyInfo.index\n });\n }\n }\n }\n return pairs;\n }\n /**\n * Adds a constraint to the physics engine.\n *\n * @param body - The main body to which the constraint is applied.\n * @param childBody - The body to which the constraint is applied.\n * @param constraint - The constraint to be applied.\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n */\n addConstraint(body, childBody, constraint, instanceIndex, childInstanceIndex) {\n // 0) {\n const [, hitData] = this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector, 0)[1];\n this._populateHitData(hitData, result);\n result.calculateHitDistance();\n }\n }\n /**\n * Given a point, returns the closest physics\n * body to that point.\n * @param query the query to perform. @see IPhysicsPointProximityQuery\n * @param result contact point on the hit shape, in world space\n */\n pointProximity(query, result) {\n var _query$collisionFilte, _query$collisionFilte2, _query$collisionFilte3, _query$collisionFilte4;\n const queryMembership = (_query$collisionFilte = query === null || query === void 0 || (_query$collisionFilte2 = query.collisionFilter) === null || _query$collisionFilte2 === void 0 ? void 0 : _query$collisionFilte2.membership) !== null && _query$collisionFilte !== void 0 ? _query$collisionFilte : ~0;\n const queryCollideWith = (_query$collisionFilte3 = query === null || query === void 0 || (_query$collisionFilte4 = query.collisionFilter) === null || _query$collisionFilte4 === void 0 ? void 0 : _query$collisionFilte4.collideWith) !== null && _query$collisionFilte3 !== void 0 ? _query$collisionFilte3 : ~0;\n result.reset();\n const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];\n const hkQuery = [this._bVecToV3(query.position), query.maxDistance, [queryMembership, queryCollideWith], query.shouldHitTriggers, bodyToIgnore];\n this._hknp.HP_World_PointProximityWithCollector(this.world, this._queryCollector, hkQuery);\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\n const [distance, hitData] = this._hknp.HP_QueryCollector_GetPointProximityResult(this._queryCollector, 0)[1];\n this._populateHitData(hitData, result);\n result.setHitDistance(distance);\n }\n }\n /**\n * Given a shape in a specific position and orientation, returns the closest point to that shape.\n * @param query the query to perform. @see IPhysicsShapeProximityCastQuery\n * @param inputShapeResult contact point on input shape, in input shape space\n * @param hitShapeResult contact point on hit shape, in world space\n */\n shapeProximity(query, inputShapeResult, hitShapeResult) {\n inputShapeResult.reset();\n hitShapeResult.reset();\n const shapeId = query.shape._pluginData;\n const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];\n const hkQuery = [shapeId, this._bVecToV3(query.position), this._bQuatToV4(query.rotation), query.maxDistance, query.shouldHitTriggers, bodyToIgnore];\n this._hknp.HP_World_ShapeProximityWithCollector(this.world, this._queryCollector, hkQuery);\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\n const [distance, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeProximityResult(this._queryCollector, 0)[1];\n this._populateHitData(hitInputData, inputShapeResult);\n this._populateHitData(hitShapeData, hitShapeResult);\n inputShapeResult.setHitDistance(distance);\n hitShapeResult.setHitDistance(distance);\n }\n }\n /**\n * Given a shape in a specific orientation, cast it from the start to end position specified by the query, and return the first hit.\n * @param query the query to perform. @see IPhysicsShapeCastQuery\n * @param inputShapeResult contact point on input shape, in input shape space\n * @param hitShapeResult contact point on hit shape, in world space\n */\n shapeCast(query, inputShapeResult, hitShapeResult) {\n inputShapeResult.reset();\n hitShapeResult.reset();\n const shapeId = query.shape._pluginData;\n const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];\n const hkQuery = [shapeId, this._bQuatToV4(query.rotation), this._bVecToV3(query.startPosition), this._bVecToV3(query.endPosition), query.shouldHitTriggers, bodyToIgnore];\n this._hknp.HP_World_ShapeCastWithCollector(this.world, this._queryCollector, hkQuery);\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\n const [fractionAlongRay, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeCastResult(this._queryCollector, 0)[1];\n this._populateHitData(hitInputData, inputShapeResult);\n this._populateHitData(hitShapeData, hitShapeResult);\n inputShapeResult.setHitFraction(fractionAlongRay);\n hitShapeResult.setHitFraction(fractionAlongRay);\n }\n }\n /**\n * Return the collision observable for a particular physics body.\n * @param body the physics body\n * @returns the collision observable for the body\n */\n getCollisionObservable(body) {\n const bodyId = body._pluginData.hpBodyId[0];\n let observable = this._bodyCollisionObservable.get(bodyId);\n if (!observable) {\n observable = new Observable();\n this._bodyCollisionObservable.set(bodyId, observable);\n }\n return observable;\n }\n /**\n * Return the collision ended observable for a particular physics body.\n * @param body the physics body\n * @returns\n */\n getCollisionEndedObservable(body) {\n const bodyId = body._pluginData.hpBodyId[0];\n let observable = this._bodyCollisionEndedObservable.get(bodyId);\n if (!observable) {\n observable = new Observable();\n this._bodyCollisionEndedObservable.set(bodyId, observable);\n }\n return observable;\n }\n /**\n * Enable collision to be reported for a body when a callback is setup on the world\n * @param body the physics body\n * @param enabled whether to enable or disable collision events\n */\n setCollisionCallbackEnabled(body, enabled) {\n // Register for collide events by default\n const collideEvents = this._hknp.EventType.COLLISION_STARTED.value | this._hknp.EventType.COLLISION_CONTINUED.value | this._hknp.EventType.COLLISION_FINISHED.value;\n if (body._pluginDataInstances && body._pluginDataInstances.length) {\n body._pluginDataInstances.forEach(bodyId => {\n this._hknp.HP_Body_SetEventMask(bodyId.hpBodyId, enabled ? collideEvents : 0);\n });\n } else if (body._pluginData) {\n this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, enabled ? collideEvents : 0);\n }\n }\n /**\n * Enable collision ended to be reported for a body when a callback is setup on the world\n * @param body the physics body\n * @param enabled whether to enable or disable collision ended events\n */\n setCollisionEndedCallbackEnabled(body, enabled) {\n // Register to collide ended events\n const pluginRef = this._getPluginReference(body);\n let currentCollideEvents = this._hknp.HP_Body_GetEventMask(pluginRef.hpBodyId)[1];\n // update with the ended mask\n currentCollideEvents = enabled ? currentCollideEvents | this._hknp.EventType.COLLISION_FINISHED.value : currentCollideEvents & ~this._hknp.EventType.COLLISION_FINISHED.value;\n if (body._pluginDataInstances && body._pluginDataInstances.length) {\n body._pluginDataInstances.forEach(bodyId => {\n this._hknp.HP_Body_SetEventMask(bodyId.hpBodyId, currentCollideEvents);\n });\n } else if (body._pluginData) {\n this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, currentCollideEvents);\n }\n }\n _notifyTriggers() {\n let eventAddress = this._hknp.HP_World_GetTriggerEvents(this.world)[1];\n const event = new TriggerEvent();\n while (eventAddress) {\n TriggerEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);\n const bodyInfoA = this._bodies.get(event.bodyIdA);\n const bodyInfoB = this._bodies.get(event.bodyIdB);\n // Bodies may have been disposed between events. Check both still exist.\n if (bodyInfoA && bodyInfoB) {\n const triggerCollisionInfo = {\n collider: bodyInfoA.body,\n colliderIndex: bodyInfoA.index,\n collidedAgainst: bodyInfoB.body,\n collidedAgainstIndex: bodyInfoB.index,\n type: this._nativeTriggerCollisionValueToCollisionType(event.type)\n };\n this.onTriggerCollisionObservable.notifyObservers(triggerCollisionInfo);\n }\n eventAddress = this._hknp.HP_World_GetNextTriggerEvent(this.world, eventAddress);\n }\n }\n /**\n * Runs thru all detected collisions and filter by body\n */\n _notifyCollisions() {\n let eventAddress = this._hknp.HP_World_GetCollisionEvents(this.world)[1];\n const event = new CollisionEvent();\n const worldAddr = Number(this.world);\n while (eventAddress) {\n CollisionEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);\n const bodyInfoA = this._bodies.get(event.contactOnA.bodyId);\n const bodyInfoB = this._bodies.get(event.contactOnB.bodyId);\n // Bodies may have been disposed between events. Check both still exist.\n if (bodyInfoA && bodyInfoB) {\n const collisionInfo = {\n collider: bodyInfoA.body,\n colliderIndex: bodyInfoA.index,\n collidedAgainst: bodyInfoB.body,\n collidedAgainstIndex: bodyInfoB.index,\n type: this._nativeCollisionValueToCollisionType(event.type)\n };\n if (collisionInfo.type === \"COLLISION_FINISHED\" /* PhysicsEventType.COLLISION_FINISHED */) {\n this.onCollisionEndedObservable.notifyObservers(collisionInfo);\n } else {\n event.contactOnB.position.subtractToRef(event.contactOnA.position, this._tmpVec3[0]);\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnA.normal);\n collisionInfo.point = event.contactOnA.position;\n collisionInfo.distance = distance;\n collisionInfo.impulse = event.impulseApplied;\n collisionInfo.normal = event.contactOnA.normal;\n this.onCollisionObservable.notifyObservers(collisionInfo);\n }\n if (this._bodyCollisionObservable.size && collisionInfo.type !== \"COLLISION_FINISHED\" /* PhysicsEventType.COLLISION_FINISHED */) {\n const observableA = this._bodyCollisionObservable.get(event.contactOnA.bodyId);\n const observableB = this._bodyCollisionObservable.get(event.contactOnB.bodyId);\n event.contactOnA.position.subtractToRef(event.contactOnB.position, this._tmpVec3[0]);\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnB.normal);\n if (observableA) {\n observableA.notifyObservers(collisionInfo);\n }\n if (observableB) {\n const collisionInfoB = {\n collider: bodyInfoB.body,\n colliderIndex: bodyInfoB.index,\n collidedAgainst: bodyInfoA.body,\n collidedAgainstIndex: bodyInfoA.index,\n point: event.contactOnB.position,\n distance: distance,\n impulse: event.impulseApplied,\n normal: event.contactOnB.normal,\n type: this._nativeCollisionValueToCollisionType(event.type)\n };\n observableB.notifyObservers(collisionInfoB);\n }\n } else if (this._bodyCollisionEndedObservable.size) {\n const observableA = this._bodyCollisionEndedObservable.get(event.contactOnA.bodyId);\n const observableB = this._bodyCollisionEndedObservable.get(event.contactOnB.bodyId);\n event.contactOnA.position.subtractToRef(event.contactOnB.position, this._tmpVec3[0]);\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnB.normal);\n if (observableA) {\n observableA.notifyObservers(collisionInfo);\n }\n if (observableB) {\n const collisionInfoB = {\n collider: bodyInfoB.body,\n colliderIndex: bodyInfoB.index,\n collidedAgainst: bodyInfoA.body,\n collidedAgainstIndex: bodyInfoA.index,\n point: event.contactOnB.position,\n distance: distance,\n impulse: event.impulseApplied,\n normal: event.contactOnB.normal,\n type: this._nativeCollisionValueToCollisionType(event.type)\n };\n observableB.notifyObservers(collisionInfoB);\n }\n }\n }\n eventAddress = this._hknp.HP_World_GetNextCollisionEvent(worldAddr, eventAddress);\n }\n }\n /**\n * Gets the number of bodies in the world\n */\n get numBodies() {\n return this._hknp.HP_World_GetNumBodies(this.world)[1];\n }\n /**\n * Dispose the world and free resources\n */\n dispose() {\n if (this._queryCollector) {\n this._hknp.HP_QueryCollector_Release(this._queryCollector);\n this._queryCollector = undefined;\n }\n if (this.world) {\n this._hknp.HP_World_Release(this.world);\n this.world = undefined;\n }\n }\n _v3ToBvecRef(v, vec3) {\n vec3.set(v[0], v[1], v[2]);\n }\n _bVecToV3(v) {\n return [v._x, v._y, v._z];\n }\n _bQuatToV4(q) {\n return [q._x, q._y, q._z, q._w];\n }\n _constraintMotorTypeToNative(motorType) {\n switch (motorType) {\n case 2 /* PhysicsConstraintMotorType.POSITION */:\n return this._hknp.ConstraintMotorType.POSITION;\n case 1 /* PhysicsConstraintMotorType.VELOCITY */:\n return this._hknp.ConstraintMotorType.VELOCITY;\n }\n return this._hknp.ConstraintMotorType.NONE;\n }\n _nativeToMotorType(motorType) {\n switch (motorType) {\n case this._hknp.ConstraintMotorType.POSITION:\n return 2 /* PhysicsConstraintMotorType.POSITION */;\n case this._hknp.ConstraintMotorType.VELOCITY:\n return 1 /* PhysicsConstraintMotorType.VELOCITY */;\n }\n return 0 /* PhysicsConstraintMotorType.NONE */;\n }\n _materialCombineToNative(mat) {\n switch (mat) {\n case 0 /* PhysicsMaterialCombineMode.GEOMETRIC_MEAN */:\n return this._hknp.MaterialCombine.GEOMETRIC_MEAN;\n case 1 /* PhysicsMaterialCombineMode.MINIMUM */:\n return this._hknp.MaterialCombine.MINIMUM;\n case 2 /* PhysicsMaterialCombineMode.MAXIMUM */:\n return this._hknp.MaterialCombine.MAXIMUM;\n case 3 /* PhysicsMaterialCombineMode.ARITHMETIC_MEAN */:\n return this._hknp.MaterialCombine.ARITHMETIC_MEAN;\n case 4 /* PhysicsMaterialCombineMode.MULTIPLY */:\n return this._hknp.MaterialCombine.MULTIPLY;\n }\n }\n _nativeToMaterialCombine(mat) {\n switch (mat) {\n case this._hknp.MaterialCombine.GEOMETRIC_MEAN:\n return 0 /* PhysicsMaterialCombineMode.GEOMETRIC_MEAN */;\n case this._hknp.MaterialCombine.MINIMUM:\n return 1 /* PhysicsMaterialCombineMode.MINIMUM */;\n case this._hknp.MaterialCombine.MAXIMUM:\n return 2 /* PhysicsMaterialCombineMode.MAXIMUM */;\n case this._hknp.MaterialCombine.ARITHMETIC_MEAN:\n return 3 /* PhysicsMaterialCombineMode.ARITHMETIC_MEAN */;\n case this._hknp.MaterialCombine.MULTIPLY:\n return 4 /* PhysicsMaterialCombineMode.MULTIPLY */;\n default:\n return undefined;\n }\n }\n _constraintAxisToNative(axId) {\n switch (axId) {\n case 0 /* PhysicsConstraintAxis.LINEAR_X */:\n return this._hknp.ConstraintAxis.LINEAR_X;\n case 1 /* PhysicsConstraintAxis.LINEAR_Y */:\n return this._hknp.ConstraintAxis.LINEAR_Y;\n case 2 /* PhysicsConstraintAxis.LINEAR_Z */:\n return this._hknp.ConstraintAxis.LINEAR_Z;\n case 3 /* PhysicsConstraintAxis.ANGULAR_X */:\n return this._hknp.ConstraintAxis.ANGULAR_X;\n case 4 /* PhysicsConstraintAxis.ANGULAR_Y */:\n return this._hknp.ConstraintAxis.ANGULAR_Y;\n case 5 /* PhysicsConstraintAxis.ANGULAR_Z */:\n return this._hknp.ConstraintAxis.ANGULAR_Z;\n case 6 /* PhysicsConstraintAxis.LINEAR_DISTANCE */:\n return this._hknp.ConstraintAxis.LINEAR_DISTANCE;\n }\n }\n _nativeToLimitMode(mode) {\n switch (mode) {\n case this._hknp.ConstraintAxisLimitMode.FREE:\n return 0 /* PhysicsConstraintAxisLimitMode.FREE */;\n case this._hknp.ConstraintAxisLimitMode.LIMITED:\n return 1 /* PhysicsConstraintAxisLimitMode.LIMITED */;\n case this._hknp.ConstraintAxisLimitMode.LOCKED:\n return 2 /* PhysicsConstraintAxisLimitMode.LOCKED */;\n }\n return 0 /* PhysicsConstraintAxisLimitMode.FREE */;\n }\n _limitModeToNative(mode) {\n switch (mode) {\n case 0 /* PhysicsConstraintAxisLimitMode.FREE */:\n return this._hknp.ConstraintAxisLimitMode.FREE;\n case 1 /* PhysicsConstraintAxisLimitMode.LIMITED */:\n return this._hknp.ConstraintAxisLimitMode.LIMITED;\n case 2 /* PhysicsConstraintAxisLimitMode.LOCKED */:\n return this._hknp.ConstraintAxisLimitMode.LOCKED;\n }\n }\n _nativeCollisionValueToCollisionType(type) {\n switch (type) {\n case this._hknp.EventType.COLLISION_STARTED.value:\n return \"COLLISION_STARTED\" /* PhysicsEventType.COLLISION_STARTED */;\n case this._hknp.EventType.COLLISION_FINISHED.value:\n return \"COLLISION_FINISHED\" /* PhysicsEventType.COLLISION_FINISHED */;\n case this._hknp.EventType.COLLISION_CONTINUED.value:\n return \"COLLISION_CONTINUED\" /* PhysicsEventType.COLLISION_CONTINUED */;\n }\n return \"COLLISION_STARTED\" /* PhysicsEventType.COLLISION_STARTED */;\n }\n _nativeTriggerCollisionValueToCollisionType(type) {\n switch (type) {\n case 8:\n return \"TRIGGER_ENTERED\" /* PhysicsEventType.TRIGGER_ENTERED */;\n case 16:\n return \"TRIGGER_EXITED\" /* PhysicsEventType.TRIGGER_EXITED */;\n }\n return \"TRIGGER_ENTERED\" /* PhysicsEventType.TRIGGER_ENTERED */;\n }\n}","map":{"version":3,"names":["Matrix","Quaternion","TmpVectors","Vector3","PhysicsPrestepType","Logger","PhysicsShape","BoundingBox","Mesh","InstancedMesh","VertexBuffer","BuildArray","Observable","MeshAccumulator","constructor","mesh","collectIndices","scene","_vertices","_indices","_isRightHanded","useRightHandedSystem","_collectIndices","addNodeMeshes","includeChildren","computeWorldMatrix","rootScaled","ScalingToRef","absoluteScaling","x","y","z","_addMesh","sourceMesh","worldToRoot","invertToRef","worldToRootScaled","multiplyToRef","children","getChildMeshes","filter","m","physicsBody","forEach","childToWorld","childToRootScaled","meshToRoot","vertexData","getVerticesData","PositionKind","numVerts","length","indexOffset","v","pos","push","TransformCoordinates","meshIndices","getIndices","i","getVertices","plugin","nFloats","bytesPerFloat","nBytes","bufferBegin","_malloc","ret","Float32Array","HEAPU8","buffer","offset","numObjects","freeBuffer","arr","_free","getTriangles","bytesPerInt","Int32Array","BodyPluginData","bodyId","hpBodyId","userMassProps","centerOfMass","undefined","mass","inertia","inertiaOrientation","CollisionContactPoint","BigInt","position","normal","CollisionEvent","contactOnA","contactOnB","impulseApplied","type","readToRef","eventOut","intBuf","floatBuf","offA","set","offB","TriggerEvent","bodyIdA","bodyIdB","HavokPlugin","_useDeltaForWorldStep","hpInjection","HK","_hknp","name","_fixedTimeStep","_tmpVec3","Zero","_bodies","Map","_shapes","_bodyCollisionObservable","_constraintToBodyIdPair","_bodyCollisionEndedObservable","onCollisionObservable","onCollisionEndedObservable","onTriggerCollisionObservable","Error","isSupported","world","HP_World_Create","_queryCollector","HP_QueryCollector_Create","setGravity","gravity","HP_World_SetGravity","_bVecToV3","setTimeStep","timeStep","getTimeStep","executeStep","delta","physicsBodies","disablePreStep","setPhysicsBodyTransformation","transformNode","deltaTime","HP_World_SetIdealStepTime","HP_World_Step","_bodyBuffer","HP_World_GetBodyBuffer","disableSync","sync","_notifyCollisions","_notifyTriggers","getPluginVersion","setVelocityLimits","maxLinearVelocity","maxAngularVelocity","HP_World_SetSpeedLimit","getMaxLinearVelocity","limits","HP_World_GetSpeedLimit","getMaxAngularVelocity","initBody","body","motionType","orientation","_pluginData","HP_Body_Create","_internalSetMotionType","transform","_bQuatToV4","HP_Body_SetQTransform","HP_World_AddBody","startAsleep","index","removeBody","_pluginDataInstances","instance","delete","HP_World_RemoveBody","initBodyInstances","_mesh$_thinInstanceDa","_mesh$_thinInstanceDa2","instancesCount","_thinInstanceDataStorage","matrixData","_createOrUpdateBodyInstances","startIndex","endIndex","update","rotation","rotationMatrix","Identity","hkbody","setRowFromFloats","FromRotationMatrixToRef","w","pluginData","_internalUpdateMassProperties","worldTransformOffset","HP_Body_GetWorldTransformOffset","updateBodyInstances","_mesh$_thinInstanceDa3","_mesh$_thinInstanceDa4","pluginInstancesCount","getMotionType","firstBodyShape","HP_Body_GetShape","_body$shape","shape","HP_Body_SetShape","instancesToRemove","pop","HP_Body_Release","syncTransform","bufOffset","transformBuffer","mi","thinInstanceBufferUpdated","bodyTransform","HP_Body_GetQTransform","bodyTranslation","bodyOrientation","quat","parent","getWorldMatrix","isIdentity","_transformNode$rotati","copyFrom","scaling","normalize","finalTransform","finalTranslation","copyFromFloats","ComposeToRef","parentInverseTransform","localTransform","decomposeToTransformNode","rotationQuaternion","toEulerAnglesToRef","e","message","setShape","_body$transformNode$_","_m$_thinInstanceDataS","_m$_thinInstanceDataS2","shapeHandle","_getPluginReference","instanceIndex","_body$_pluginDataInst","getShape","pluginRef","shapePluginData","getScene","getShapeType","HP_Shape_GetType","setEventMask","eventMask","_applyToBodyOrInstances","bodyPluginData","HP_Body_SetEventMask","getEventMask","HP_Body_GetEventMask","_fromMassPropertiesTuple","massPropsTuple","FromArray","newProps","_internalComputeMassProperties","massProps","asArray","HP_Body_SetMassProperties","HP_Body_SetMotionType","MotionType","STATIC","KINEMATIC","DYNAMIC","setMotionType","HP_Body_GetMotionType","setActivationControl","controlMode","HP_Body_SetActivationControl","ActivationControl","ALWAYS_ACTIVE","ALWAYS_INACTIVE","SIMULATION_CONTROLLED","shapeRes","Result","RESULT_OK","shapeMass","HP_Shape_BuildMassProperties","computeMassProperties","computed","setMassProperties","getMassProperties","HP_Body_GetMassProperties","setLinearDamping","damping","HP_Body_SetLinearDamping","getLinearDamping","HP_Body_GetLinearDamping","setAngularDamping","HP_Body_SetAngularDamping","getAngularDamping","HP_Body_GetAngularDamping","setLinearVelocity","linVel","HP_Body_SetLinearVelocity","getLinearVelocityToRef","lv","HP_Body_GetLinearVelocity","_v3ToBvecRef","fnToApply","_body$_pluginDataInst2","applyImpulse","impulse","location","HP_Body_ApplyImpulse","applyAngularImpulse","angularImpulse","HP_Body_ApplyAngularImpulse","applyForce","force","scaleToRef","setAngularVelocity","angVel","HP_Body_SetAngularVelocity","getAngularVelocityToRef","av","HP_Body_GetAngularVelocity","node","getPrestepType","TELEPORT","numInstances","_getTransformInfos","ACTION","setTargetTransform","absolutePosition","absoluteRotationQuaternion","DISABLED","Warn","HP_Body_SetTargetQTransform","setGravityFactor","factor","HP_Body_SetGravityFactor","getGravityFactor","HP_Body_GetGravityFactor","disposeBody","_createOptionsFromGroundMesh","options","groundMesh","transformedVertices","FromArrayToRef","TransformCoordinatesToRef","toArray","arraySize","Math","sqrt","boundingInfo","getBoundingInfo","dim","min","boundingBox","extendSizeWorld","minX","minimumWorld","minY","minZ","matrix","elementSize","round","numHeightFieldSamplesX","numHeightFieldSamplesZ","heightFieldSizeX","heightFieldSizeZ","heightFieldData","initShape","radius","center","HP_Shape_CreateSphere","extent","extents","HP_Shape_CreateBox","pointA","pointB","HP_Shape_CreateCapsule","HP_Shape_CreateContainer","HP_Shape_CreateCylinder","includeChildMeshes","needIndices","accum","positions","numVec3s","HP_Shape_CreateConvexHull","triangles","numTriangles","HP_Shape_CreateMesh","totalNumHeights","numBytes","heightBuffer","hkBufferIndex","bjsBufferIndex","scaleX","scaleZ","HP_Shape_CreateHeightField","setShapeFilterMembershipMask","membershipMask","collideWith","HP_Shape_GetFilterInfo","HP_Shape_SetFilterInfo","getShapeFilterMembershipMask","setShapeFilterCollideMask","collideMask","membership","getShapeFilterCollideMask","setMaterial","material","_material$friction","_material$staticFrict","_material$restitution","_material$frictionCom","_material$restitution2","dynamicFriction","friction","staticFriction","restitution","frictionCombine","restitutionCombine","hpMaterial","_materialCombineToNative","HP_Shape_SetMaterial","getMaterial","hkMaterial","HP_Shape_GetMaterial","_nativeToMaterialCombine","setDensity","density","HP_Shape_SetDensity","getDensity","HP_Shape_GetDensity","r","FromEulerAnglesToRef","addChild","newChild","translation","scale","transformNative","HP_Shape_AddChild","removeChild","childIndex","HP_Shape_RemoveChild","getNumChildren","HP_Shape_GetNumChildren","setTrigger","isTrigger","HP_Shape_SetTrigger","getBoundingBox","_shape","aabb","HP_Shape_GetBoundingBox","boundingbox","IdentityReadOnly","getBodyBoundingBox","minimum","maximum","getBodyGeometry","_body$_pluginDataInst3","dataInfo","geometryRes","HP_Shape_CreateDebugDisplayGeometry","indices","geometryInfo","HP_DebugGeometry_GetInfo","positionsInPlugin","indicesInPlugin","Uint32Array","slice","HP_DebugGeometry_Release","disposeShape","HP_Shape_Release","initConstraint","constraint","childBody","childInstanceIndex","_constraint$_pluginDa","_options$axisA","_options$axisB","jointId","HP_Constraint_Create","bodyA","bodyB","HP_Constraint_SetParentBody","HP_Constraint_SetChildBody","pivotA","axisA","perpAxisA","getNormalToRef","HP_Constraint_SetAnchorInParent","pivotB","axisB","perpAxisB","HP_Constraint_SetAnchorInChild","_initOptions","clone","HP_Constraint_SetAxisMode","ConstraintAxis","LINEAR_X","ConstraintAxisLimitMode","LOCKED","LINEAR_Y","LINEAR_Z","ANGULAR_X","ANGULAR_Y","ANGULAR_Z","distance","maxDistance","dist3d","LINEAR_DISTANCE","LIMITED","HP_Constraint_SetAxisMinLimit","HP_Constraint_SetAxisMaxLimit","sixdofData","l","_l$minLimit","_l$maxLimit","axId","_constraintAxisToNative","axis","minLimit","maxLimit","stiffness","HP_Constraint_SetAxisStiffness","HP_Constraint_SetAxisDamping","collisionEnabled","collision","HP_Constraint_SetCollisionsEnabled","HP_Constraint_SetEnabled","getBodiesUsingConstraint","pairs","bodyIds","get","parentBodyInfo","childBodyInfo","parentBody","parentBodyIndex","childBodyIndex","addConstraint","setEnabled","isEnabled","getEnabled","firstId","HP_Constraint_GetEnabled","setCollisionsEnabled","getCollisionsEnabled","HP_Constraint_GetCollisionsEnabled","setAxisFriction","HP_Constraint_SetAxisFriction","getAxisFriction","HP_Constraint_GetAxisFriction","setAxisMode","limitMode","_limitModeToNative","getAxisMode","mode","HP_Constraint_GetAxisMode","_nativeToLimitMode","setAxisMinLimit","limit","getAxisMinLimit","HP_Constraint_GetAxisMinLimit","setAxisMaxLimit","getAxisMaxLimit","HP_Constraint_GetAxisMaxLimit","setAxisMotorType","motorType","HP_Constraint_SetAxisMotorType","_constraintMotorTypeToNative","getAxisMotorType","_nativeToMotorType","HP_Constraint_GetAxisMotorType","setAxisMotorTarget","target","HP_Constraint_SetAxisMotorTarget","getAxisMotorTarget","HP_Constraint_GetAxisMotorTarget","setAxisMotorMaxForce","maxForce","HP_Constraint_SetAxisMotorMaxForce","getAxisMotorMaxForce","HP_Constraint_GetAxisMotorMaxForce","disposeConstraint","HP_Constraint_Release","_populateHitData","hitData","result","hitBody","bodyIndex","hitShape","hitPos","hitNormal","hitTriangle","setHitData","raycast","from","to","query","_query$membership","_query$collideWith","_query$shouldHitTrigg","queryMembership","queryCollideWith","shouldHitTriggers","reset","bodyToIgnore","hkQuery","HP_World_CastRayWithCollector","HP_QueryCollector_GetNumHits","HP_QueryCollector_GetCastRayResult","calculateHitDistance","pointProximity","_query$collisionFilte","_query$collisionFilte2","_query$collisionFilte3","_query$collisionFilte4","collisionFilter","ignoreBody","HP_World_PointProximityWithCollector","HP_QueryCollector_GetPointProximityResult","setHitDistance","shapeProximity","inputShapeResult","hitShapeResult","shapeId","HP_World_ShapeProximityWithCollector","hitInputData","hitShapeData","HP_QueryCollector_GetShapeProximityResult","shapeCast","startPosition","endPosition","HP_World_ShapeCastWithCollector","fractionAlongRay","HP_QueryCollector_GetShapeCastResult","setHitFraction","getCollisionObservable","observable","getCollisionEndedObservable","setCollisionCallbackEnabled","enabled","collideEvents","EventType","COLLISION_STARTED","value","COLLISION_CONTINUED","COLLISION_FINISHED","setCollisionEndedCallbackEnabled","currentCollideEvents","eventAddress","HP_World_GetTriggerEvents","event","bodyInfoA","bodyInfoB","triggerCollisionInfo","collider","colliderIndex","collidedAgainst","collidedAgainstIndex","_nativeTriggerCollisionValueToCollisionType","notifyObservers","HP_World_GetNextTriggerEvent","HP_World_GetCollisionEvents","worldAddr","Number","collisionInfo","_nativeCollisionValueToCollisionType","subtractToRef","Dot","point","size","observableA","observableB","collisionInfoB","HP_World_GetNextCollisionEvent","numBodies","HP_World_GetNumBodies","dispose","HP_QueryCollector_Release","HP_World_Release","vec3","_x","_y","_z","q","_w","ConstraintMotorType","POSITION","VELOCITY","NONE","mat","MaterialCombine","GEOMETRIC_MEAN","MINIMUM","MAXIMUM","ARITHMETIC_MEAN","MULTIPLY","FREE"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Physics/v2/Plugins/havokPlugin.js"],"sourcesContent":["import { Matrix, Quaternion, TmpVectors, Vector3 } from \"../../../Maths/math.vector.js\";\nimport { PhysicsPrestepType, } from \"../IPhysicsEnginePlugin.js\";\nimport { Logger } from \"../../../Misc/logger.js\";\nimport { PhysicsShape } from \"../physicsShape.js\";\nimport { BoundingBox } from \"../../../Culling/boundingBox.js\";\nimport { Mesh } from \"../../../Meshes/mesh.js\";\nimport { InstancedMesh } from \"../../../Meshes/instancedMesh.js\";\nimport { VertexBuffer } from \"../../../Buffers/buffer.js\";\nimport { BuildArray } from \"../../../Misc/arrayTools.js\";\nimport { Observable } from \"../../../Misc/observable.js\";\nclass MeshAccumulator {\n /**\n * Constructor of the mesh accumulator\n * @param mesh - The mesh used to compute the world matrix.\n * @param collectIndices - use mesh indices\n * @param scene - The scene used to determine the right handed system.\n *\n * Merge mesh and its children so whole hierarchy can be used as a mesh shape or convex hull\n */\n constructor(mesh, collectIndices, scene) {\n this._vertices = []; /// Vertices in body space\n this._indices = [];\n this._isRightHanded = scene.useRightHandedSystem;\n this._collectIndices = collectIndices;\n }\n /**\n * Adds a mesh to the physics engine.\n * @param mesh The mesh to add.\n * @param includeChildren Whether to include the children of the mesh.\n *\n * This method adds a mesh to the physics engine by computing the world matrix,\n * multiplying it with the body from world matrix, and then transforming the\n * coordinates of the mesh's vertices. It also adds the indices of the mesh\n * to the physics engine. If includeChildren is true, it will also add the\n * children of the mesh to the physics engine, ignoring any children which\n * have a physics impostor. This is useful for creating a physics engine\n * that accurately reflects the mesh and its children.\n */\n addNodeMeshes(mesh, includeChildren) {\n // Force absoluteScaling to be computed; we're going to use that to bake\n // the scale of any parent nodes into this shape, as physics engines\n // usually use rigid transforms, so can't handle arbitrary scale.\n mesh.computeWorldMatrix(true);\n const rootScaled = TmpVectors.Matrix[0];\n Matrix.ScalingToRef(mesh.absoluteScaling.x, mesh.absoluteScaling.y, mesh.absoluteScaling.z, rootScaled);\n if (mesh instanceof Mesh) {\n this._addMesh(mesh, rootScaled);\n }\n else if (mesh instanceof InstancedMesh) {\n this._addMesh(mesh.sourceMesh, rootScaled);\n }\n if (includeChildren) {\n const worldToRoot = TmpVectors.Matrix[1];\n mesh.computeWorldMatrix().invertToRef(worldToRoot);\n const worldToRootScaled = TmpVectors.Matrix[2];\n worldToRoot.multiplyToRef(rootScaled, worldToRootScaled);\n const children = mesh.getChildMeshes(false);\n // Ignore any children which have a physics body.\n // Other plugin implementations do not have this check, which appears to be\n // a bug, as otherwise, the mesh will have a duplicate collider\n children\n .filter((m) => !m.physicsBody)\n .forEach((m) => {\n const childToWorld = m.computeWorldMatrix();\n const childToRootScaled = TmpVectors.Matrix[3];\n childToWorld.multiplyToRef(worldToRootScaled, childToRootScaled);\n if (m instanceof Mesh) {\n this._addMesh(m, childToRootScaled);\n }\n else if (m instanceof InstancedMesh) {\n this._addMesh(m.sourceMesh, childToRootScaled);\n }\n });\n }\n }\n _addMesh(mesh, meshToRoot) {\n const vertexData = mesh.getVerticesData(VertexBuffer.PositionKind) || [];\n const numVerts = vertexData.length / 3;\n const indexOffset = this._vertices.length;\n for (let v = 0; v < numVerts; v++) {\n const pos = new Vector3(vertexData[v * 3 + 0], vertexData[v * 3 + 1], vertexData[v * 3 + 2]);\n this._vertices.push(Vector3.TransformCoordinates(pos, meshToRoot));\n }\n if (this._collectIndices) {\n const meshIndices = mesh.getIndices();\n if (meshIndices) {\n for (let i = 0; i < meshIndices.length; i += 3) {\n // Havok wants the correct triangle winding to enable the interior triangle optimization\n if (this._isRightHanded) {\n this._indices.push(meshIndices[i + 0] + indexOffset);\n this._indices.push(meshIndices[i + 1] + indexOffset);\n this._indices.push(meshIndices[i + 2] + indexOffset);\n }\n else {\n this._indices.push(meshIndices[i + 2] + indexOffset);\n this._indices.push(meshIndices[i + 1] + indexOffset);\n this._indices.push(meshIndices[i + 0] + indexOffset);\n }\n }\n }\n }\n }\n /**\n * Allocate and populate the vertex positions inside the physics plugin.\n *\n * @param plugin - The plugin to allocate the memory in.\n * @returns An array of floats, whose backing memory is inside the plugin. The array contains the\n * positions of the mesh vertices, where a position is defined by three floats. You must call\n * freeBuffer() on the returned array once you have finished with it, in order to free the\n * memory inside the plugin..\n */\n getVertices(plugin) {\n const nFloats = this._vertices.length * 3;\n const bytesPerFloat = 4;\n const nBytes = nFloats * bytesPerFloat;\n const bufferBegin = plugin._malloc(nBytes);\n const ret = new Float32Array(plugin.HEAPU8.buffer, bufferBegin, nFloats);\n for (let i = 0; i < this._vertices.length; i++) {\n ret[i * 3 + 0] = this._vertices[i].x;\n ret[i * 3 + 1] = this._vertices[i].y;\n ret[i * 3 + 2] = this._vertices[i].z;\n }\n return { offset: bufferBegin, numObjects: nFloats };\n }\n freeBuffer(plugin, arr) {\n plugin._free(arr.offset);\n }\n /**\n * Allocate and populate the triangle indices inside the physics plugin\n *\n * @param plugin - The plugin to allocate the memory in.\n * @returns A new Int32Array, whose backing memory is inside the plugin. The array contains the indices\n * of the triangle positions, where a single triangle is defined by three indices. You must call\n * freeBuffer() on this array once you have finished with it, to free the memory inside the plugin..\n */\n getTriangles(plugin) {\n const bytesPerInt = 4;\n const nBytes = this._indices.length * bytesPerInt;\n const bufferBegin = plugin._malloc(nBytes);\n const ret = new Int32Array(plugin.HEAPU8.buffer, bufferBegin, this._indices.length);\n for (let i = 0; i < this._indices.length; i++) {\n ret[i] = this._indices[i];\n }\n return { offset: bufferBegin, numObjects: this._indices.length };\n }\n}\nclass BodyPluginData {\n constructor(bodyId) {\n this.hpBodyId = bodyId;\n this.userMassProps = { centerOfMass: undefined, mass: undefined, inertia: undefined, inertiaOrientation: undefined };\n }\n}\n/*\nclass ShapePath\n{\n public colliderId: number;\n public pathData: number;\n}\n*/\nclass CollisionContactPoint {\n constructor() {\n this.bodyId = BigInt(0); //0,2\n //public colliderId: number = 0; //2,4\n //public shapePath: ShapePath = new ShapePath(); //4,8\n this.position = new Vector3(); //8,11\n this.normal = new Vector3(); //11,14\n //public triIdx: number = 0; //14,15\n }\n}\nclass CollisionEvent {\n constructor() {\n this.contactOnA = new CollisionContactPoint(); //1\n this.contactOnB = new CollisionContactPoint();\n this.impulseApplied = 0;\n this.type = 0;\n }\n // eslint-disable-next-line @typescript-eslint/naming-convention\n static readToRef(buffer, offset, eventOut) {\n const intBuf = new Int32Array(buffer, offset);\n const floatBuf = new Float32Array(buffer, offset);\n const offA = 2;\n eventOut.contactOnA.bodyId = BigInt(intBuf[offA]); // 0) {\n for (const instance of body._pluginDataInstances) {\n this._bodyCollisionObservable.delete(instance.hpBodyId[0]);\n this._hknp.HP_World_RemoveBody(this.world, instance.hpBodyId);\n this._bodies.delete(instance.hpBodyId[0]);\n }\n }\n if (body._pluginData) {\n this._bodyCollisionObservable.delete(body._pluginData.hpBodyId[0]);\n this._hknp.HP_World_RemoveBody(this.world, body._pluginData.hpBodyId);\n this._bodies.delete(body._pluginData.hpBodyId[0]);\n }\n }\n /**\n * Initializes the body instances for a given physics body and mesh.\n *\n * @param body - The physics body to initialize.\n * @param motionType - How the body will be handled by the engine\n * @param mesh - The mesh to initialize.\n *\n * This code is useful for creating a physics body from a mesh. It creates a\n * body instance for each instance of the mesh and adds it to the world. It also\n * sets the position of the body instance to the position of the mesh instance.\n * This allows for the physics engine to accurately simulate the mesh in the\n * world.\n */\n initBodyInstances(body, motionType, mesh) {\n const instancesCount = mesh._thinInstanceDataStorage?.instancesCount ?? 0;\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, false);\n body._pluginDataInstances.forEach((bodyId, index) => {\n this._bodies.set(bodyId.hpBodyId[0], { body: body, index: index });\n });\n }\n _createOrUpdateBodyInstances(body, motionType, matrixData, startIndex, endIndex, update) {\n const rotation = TmpVectors.Quaternion[0];\n const rotationMatrix = Matrix.Identity();\n for (let i = startIndex; i < endIndex; i++) {\n const position = [matrixData[i * 16 + 12], matrixData[i * 16 + 13], matrixData[i * 16 + 14]];\n let hkbody;\n if (!update) {\n hkbody = this._hknp.HP_Body_Create()[1];\n }\n else {\n hkbody = body._pluginDataInstances[i].hpBodyId;\n }\n rotationMatrix.setRowFromFloats(0, matrixData[i * 16 + 0], matrixData[i * 16 + 1], matrixData[i * 16 + 2], 0);\n rotationMatrix.setRowFromFloats(1, matrixData[i * 16 + 4], matrixData[i * 16 + 5], matrixData[i * 16 + 6], 0);\n rotationMatrix.setRowFromFloats(2, matrixData[i * 16 + 8], matrixData[i * 16 + 9], matrixData[i * 16 + 10], 0);\n Quaternion.FromRotationMatrixToRef(rotationMatrix, rotation);\n const transform = [position, [rotation.x, rotation.y, rotation.z, rotation.w]];\n this._hknp.HP_Body_SetQTransform(hkbody, transform);\n if (!update) {\n const pluginData = new BodyPluginData(hkbody);\n if (body._pluginDataInstances.length) {\n // If an instance already exists, copy any user-provided mass properties\n pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;\n }\n this._internalSetMotionType(pluginData, motionType);\n this._internalUpdateMassProperties(pluginData);\n body._pluginDataInstances.push(pluginData);\n this._hknp.HP_World_AddBody(this.world, hkbody, body.startAsleep);\n pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(hkbody)[1];\n }\n }\n }\n /**\n * Update the internal body instances for a given physics body to match the instances in a mesh.\n * @param body the body that will be updated\n * @param mesh the mesh with reference instances\n */\n updateBodyInstances(body, mesh) {\n const instancesCount = mesh._thinInstanceDataStorage?.instancesCount ?? 0;\n const matrixData = mesh._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n const pluginInstancesCount = body._pluginDataInstances.length;\n const motionType = this.getMotionType(body);\n if (instancesCount > pluginInstancesCount) {\n this._createOrUpdateBodyInstances(body, motionType, matrixData, pluginInstancesCount, instancesCount, false);\n const firstBodyShape = this._hknp.HP_Body_GetShape(body._pluginDataInstances[0].hpBodyId)[1];\n // firstBodyShape[0] might be 0 in the case where thin instances data is set (with thinInstancesSetBuffer call) after body creation\n // in that case, use the shape provided at body creation.\n if (!firstBodyShape[0]) {\n firstBodyShape[0] = body.shape?._pluginData[0];\n }\n for (let i = pluginInstancesCount; i < instancesCount; i++) {\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, firstBodyShape);\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\n this._bodies.set(body._pluginDataInstances[i].hpBodyId[0], { body: body, index: i });\n }\n }\n else if (instancesCount < pluginInstancesCount) {\n const instancesToRemove = pluginInstancesCount - instancesCount;\n for (let i = 0; i < instancesToRemove; i++) {\n const hkbody = body._pluginDataInstances.pop();\n this._bodies.delete(hkbody.hpBodyId[0]);\n this._hknp.HP_World_RemoveBody(this.world, hkbody.hpBodyId);\n this._hknp.HP_Body_Release(hkbody.hpBodyId);\n }\n this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, true);\n }\n }\n /**\n * Synchronizes the transform of a physics body with its transform node.\n * @param body - The physics body to synchronize.\n *\n * This function is useful for keeping the physics body's transform in sync with its transform node.\n * This is important for ensuring that the physics body is accurately represented in the physics engine.\n */\n sync(body) {\n this.syncTransform(body, body.transformNode);\n }\n /**\n * Synchronizes the transform of a physics body with the transform of its\n * corresponding transform node.\n *\n * @param body - The physics body to synchronize.\n * @param transformNode - The destination Transform Node.\n *\n * This code is useful for synchronizing the position and orientation of a\n * physics body with the position and orientation of its corresponding\n * transform node. This is important for ensuring that the physics body and\n * the transform node are in the same position and orientation in the scene.\n * This is necessary for the physics engine to accurately simulate the\n * physical behavior of the body.\n */\n syncTransform(body, transformNode) {\n if (body._pluginDataInstances.length) {\n // instances\n const m = transformNode;\n const matrixData = m._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n const instancesCount = body._pluginDataInstances.length;\n for (let i = 0; i < instancesCount; i++) {\n const bufOffset = body._pluginDataInstances[i].worldTransformOffset;\n const transformBuffer = new Float32Array(this._hknp.HEAPU8.buffer, this._bodyBuffer + bufOffset, 16);\n const index = i * 16;\n for (let mi = 0; mi < 15; mi++) {\n if ((mi & 3) != 3) {\n matrixData[index + mi] = transformBuffer[mi];\n }\n }\n matrixData[index + 15] = 1;\n }\n m.thinInstanceBufferUpdated(\"matrix\");\n }\n else {\n try {\n // regular\n const bodyTransform = this._hknp.HP_Body_GetQTransform(body._pluginData.hpBodyId)[1];\n const bodyTranslation = bodyTransform[0];\n const bodyOrientation = bodyTransform[1];\n const quat = TmpVectors.Quaternion[0];\n quat.set(bodyOrientation[0], bodyOrientation[1], bodyOrientation[2], bodyOrientation[3]);\n const parent = transformNode.parent;\n // transform position/orientation in parent space\n if (parent && !parent.getWorldMatrix().isIdentity()) {\n parent.computeWorldMatrix(true);\n // Save scaling for future use\n TmpVectors.Vector3[1].copyFrom(transformNode.scaling);\n quat.normalize();\n const finalTransform = TmpVectors.Matrix[0];\n const finalTranslation = TmpVectors.Vector3[0];\n finalTranslation.copyFromFloats(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);\n Matrix.ComposeToRef(transformNode.absoluteScaling, quat, finalTranslation, finalTransform);\n const parentInverseTransform = TmpVectors.Matrix[1];\n parent.getWorldMatrix().invertToRef(parentInverseTransform);\n const localTransform = TmpVectors.Matrix[2];\n finalTransform.multiplyToRef(parentInverseTransform, localTransform);\n localTransform.decomposeToTransformNode(transformNode);\n transformNode.rotationQuaternion?.normalize();\n // Keep original scaling. Re-injecting scaling can introduce discontinuity between frames. Basically, it grows or shrinks.\n transformNode.scaling.copyFrom(TmpVectors.Vector3[1]);\n }\n else {\n transformNode.position.set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);\n if (transformNode.rotationQuaternion) {\n transformNode.rotationQuaternion.copyFrom(quat);\n }\n else {\n quat.toEulerAnglesToRef(transformNode.rotation);\n }\n }\n }\n catch (e) {\n Logger.Error(`Syncing transform failed for node ${transformNode.name}: ${e.message}...`);\n }\n }\n }\n /**\n * Sets the shape of a physics body.\n * @param body - The physics body to set the shape for.\n * @param shape - The physics shape to set.\n *\n * This function is used to set the shape of a physics body. It is useful for\n * creating a physics body with a specific shape, such as a box or a sphere,\n * which can then be used to simulate physical interactions in a physics engine.\n * This function is especially useful for meshes with multiple instances, as it\n * will set the shape for each instance of the mesh.\n */\n setShape(body, shape) {\n const shapeHandle = shape && shape._pluginData ? shape._pluginData : BigInt(0);\n if (!(body.transformNode instanceof Mesh) || !body.transformNode._thinInstanceDataStorage?.matrixData) {\n this._hknp.HP_Body_SetShape(body._pluginData.hpBodyId, shapeHandle);\n this._internalUpdateMassProperties(body._pluginData);\n return;\n }\n const m = body.transformNode;\n const instancesCount = m._thinInstanceDataStorage?.instancesCount ?? 0;\n for (let i = 0; i < instancesCount; i++) {\n this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, shapeHandle);\n this._internalUpdateMassProperties(body._pluginDataInstances[i]);\n }\n }\n /**\n * Returns a reference to the first instance of the plugin data for a physics body.\n * @param body\n * @param instanceIndex\n * @returns a reference to the first instance\n */\n _getPluginReference(body, instanceIndex) {\n return body._pluginDataInstances?.length ? body._pluginDataInstances[instanceIndex ?? 0] : body._pluginData;\n }\n /**\n * Gets the shape of a physics body. This will create a new shape object\n *\n * @param body - The physics body.\n * @returns The shape of the physics body.\n *\n */\n getShape(body) {\n const pluginRef = this._getPluginReference(body);\n const shapePluginData = this._hknp.HP_Body_GetShape(pluginRef.hpBodyId)[1];\n if (shapePluginData != 0) {\n const scene = body.transformNode.getScene();\n return new PhysicsShape({ pluginData: shapePluginData }, scene);\n }\n return null;\n }\n /**\n * Gets the type of a physics shape.\n * @param shape - The physics shape to get the type for.\n * @returns The type of the physics shape.\n *\n */\n getShapeType(shape) {\n if (shape.type) {\n return shape.type;\n }\n else {\n // {\n this._hknp.HP_Body_SetEventMask(bodyPluginData.hpBodyId, eventMask);\n }, instanceIndex);\n }\n /**\n * Retrieves the event mask of a physics body.\n *\n * @param body - The physics body to retrieve the event mask from.\n * @param instanceIndex - The index of the instance to retrieve the event mask from.\n * @returns The event mask of the physics body.\n *\n */\n getEventMask(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetEventMask(pluginRef.hpBodyId)[1];\n }\n _fromMassPropertiesTuple(massPropsTuple) {\n return {\n centerOfMass: Vector3.FromArray(massPropsTuple[0]),\n mass: massPropsTuple[1],\n inertia: Vector3.FromArray(massPropsTuple[2]),\n inertiaOrientation: Quaternion.FromArray(massPropsTuple[3]),\n };\n }\n _internalUpdateMassProperties(pluginData) {\n // Recompute the mass based on the shape\n const newProps = this._internalComputeMassProperties(pluginData);\n const massProps = pluginData.userMassProps;\n // Override the computed values with any the user has set\n if (massProps.centerOfMass) {\n newProps[0] = massProps.centerOfMass.asArray();\n }\n if (massProps.mass != undefined) {\n newProps[1] = massProps.mass;\n }\n if (massProps.inertia) {\n newProps[2] = massProps.inertia.asArray();\n }\n if (massProps.inertiaOrientation) {\n newProps[3] = massProps.inertiaOrientation.asArray();\n }\n this._hknp.HP_Body_SetMassProperties(pluginData.hpBodyId, newProps);\n }\n _internalSetMotionType(pluginData, motionType) {\n switch (motionType) {\n case 0 /* PhysicsMotionType.STATIC */:\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.STATIC);\n break;\n case 1 /* PhysicsMotionType.ANIMATED */:\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.KINEMATIC);\n break;\n case 2 /* PhysicsMotionType.DYNAMIC */:\n this._hknp.HP_Body_SetMotionType(pluginData.hpBodyId, this._hknp.MotionType.DYNAMIC);\n break;\n }\n }\n /**\n * sets the motion type of a physics body.\n * @param body - The physics body to set the motion type for.\n * @param motionType - The motion type to set.\n * @param instanceIndex - The index of the instance to set the motion type for. If undefined, the motion type of all the bodies will be set.\n */\n setMotionType(body, motionType, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginData) => {\n this._internalSetMotionType(pluginData, motionType);\n }, instanceIndex);\n }\n /**\n * Gets the motion type of a physics body.\n * @param body - The physics body to get the motion type from.\n * @param instanceIndex - The index of the instance to get the motion type from. If not specified, the motion type of the first instance will be returned.\n * @returns The motion type of the physics body.\n */\n getMotionType(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const type = this._hknp.HP_Body_GetMotionType(pluginRef.hpBodyId)[1];\n switch (type) {\n case this._hknp.MotionType.STATIC:\n return 0 /* PhysicsMotionType.STATIC */;\n case this._hknp.MotionType.KINEMATIC:\n return 1 /* PhysicsMotionType.ANIMATED */;\n case this._hknp.MotionType.DYNAMIC:\n return 2 /* PhysicsMotionType.DYNAMIC */;\n }\n throw new Error(\"Unknown motion type: \" + type);\n }\n /**\n * sets the activation control mode of a physics body, for instance if you need the body to never sleep.\n * @param body - The physics body to set the activation control mode.\n * @param controlMode - The activation control mode.\n */\n setActivationControl(body, controlMode) {\n switch (controlMode) {\n case 1 /* PhysicsActivationControl.ALWAYS_ACTIVE */:\n this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.ALWAYS_ACTIVE);\n break;\n case 2 /* PhysicsActivationControl.ALWAYS_INACTIVE */:\n this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.ALWAYS_INACTIVE);\n break;\n case 0 /* PhysicsActivationControl.SIMULATION_CONTROLLED */:\n this._hknp.HP_Body_SetActivationControl(body._pluginData.hpBodyId, this._hknp.ActivationControl.SIMULATION_CONTROLLED);\n break;\n }\n }\n _internalComputeMassProperties(pluginData) {\n const shapeRes = this._hknp.HP_Body_GetShape(pluginData.hpBodyId);\n if (shapeRes[0] == this._hknp.Result.RESULT_OK) {\n const shapeMass = this._hknp.HP_Shape_BuildMassProperties(shapeRes[1]);\n if (shapeMass[0] == this._hknp.Result.RESULT_OK) {\n return shapeMass[1];\n }\n }\n // Failed; return a unit inertia\n return [[0, 0, 0], 1, [1, 1, 1], [0, 0, 0, 1]];\n }\n /**\n * Computes the mass properties of a physics body, from it's shape\n *\n * @param body - The physics body to copmute the mass properties of\n * @param instanceIndex - The index of the instance to compute the mass properties of.\n * @returns The mass properties of the physics body.\n */\n computeMassProperties(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const computed = this._internalComputeMassProperties(pluginRef);\n return this._fromMassPropertiesTuple(computed);\n }\n /**\n * Sets the mass properties of a physics body.\n *\n * @param body - The physics body to set the mass properties of.\n * @param massProps - The mass properties to set.\n * @param instanceIndex - The index of the instance to set the mass properties of. If undefined, the mass properties of all the bodies will be set.\n * This function is useful for setting the mass properties of a physics body,\n * such as its mass, inertia, and center of mass. This is important for\n * accurately simulating the physics of the body in the physics engine.\n *\n */\n setMassProperties(body, massProps, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginData) => {\n pluginData.userMassProps = massProps;\n this._internalUpdateMassProperties(pluginData);\n }, instanceIndex);\n }\n /**\n * Gets the mass properties of a physics body.\n * @param body - The physics body to get the mass properties from.\n * @param instanceIndex - The index of the instance to get the mass properties from. If not specified, the mass properties of the first instance will be returned.\n * @returns The mass properties of the physics body.\n */\n getMassProperties(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const massPropsTuple = this._hknp.HP_Body_GetMassProperties(pluginRef.hpBodyId)[1];\n return this._fromMassPropertiesTuple(massPropsTuple);\n }\n /**\n * Sets the linear damping of the given body.\n * @param body - The body to set the linear damping for.\n * @param damping - The linear damping to set.\n * @param instanceIndex - The index of the instance to set the linear damping for. If not specified, the linear damping of the first instance will be set.\n *\n * This method is useful for controlling the linear damping of a body in a physics engine.\n * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body.\n * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body.\n */\n setLinearDamping(body, damping, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginData) => {\n this._hknp.HP_Body_SetLinearDamping(pluginData.hpBodyId, damping);\n }, instanceIndex);\n }\n /**\n * Gets the linear damping of the given body.\n * @param body - The body to get the linear damping from.\n * @param instanceIndex - The index of the instance to get the linear damping from. If not specified, the linear damping of the first instance will be returned.\n * @returns The linear damping of the given body.\n *\n * This method is useful for getting the linear damping of a body in a physics engine.\n * Linear damping is a force that opposes the motion of the body and is proportional to the velocity of the body.\n * It is used to simulate the effects of air resistance and other forms of friction.\n */\n getLinearDamping(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetLinearDamping(pluginRef.hpBodyId)[1];\n }\n /**\n * Sets the angular damping of a physics body.\n * @param body - The physics body to set the angular damping for.\n * @param damping - The angular damping value to set.\n * @param instanceIndex - The index of the instance to set the angular damping for. If not specified, the angular damping of the first instance will be set.\n *\n * This function is useful for controlling the angular velocity of a physics body.\n * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations.\n */\n setAngularDamping(body, damping, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginData) => {\n this._hknp.HP_Body_SetAngularDamping(pluginData.hpBodyId, damping);\n }, instanceIndex);\n }\n /**\n * Gets the angular damping of a physics body.\n * @param body - The physics body to get the angular damping from.\n * @param instanceIndex - The index of the instance to get the angular damping from. If not specified, the angular damping of the first instance will be returned.\n * @returns The angular damping of the body.\n *\n * This function is useful for retrieving the angular damping of a physics body,\n * which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping.\n */\n getAngularDamping(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetAngularDamping(pluginRef.hpBodyId)[1];\n }\n /**\n * Sets the linear velocity of a physics body.\n * @param body - The physics body to set the linear velocity of.\n * @param linVel - The linear velocity to set.\n * @param instanceIndex - The index of the instance to set the linear velocity of. If not specified, the linear velocity of the first instance will be set.\n *\n * This function is useful for setting the linear velocity of a physics body, which is necessary for simulating\n * motion in a physics engine. The linear velocity is the speed and direction of the body's movement.\n */\n setLinearVelocity(body, linVel, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginData) => {\n this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, this._bVecToV3(linVel));\n }, instanceIndex);\n }\n /**\n * Gets the linear velocity of a physics body and stores it in a given vector.\n * @param body - The physics body to get the linear velocity from.\n * @param linVel - The vector to store the linear velocity in.\n * @param instanceIndex - The index of the instance to get the linear velocity from. If not specified, the linear velocity of the first instance will be returned.\n *\n * This function is useful for retrieving the linear velocity of a physics body,\n * which can be used to determine the speed and direction of the body. This\n * information can be used to simulate realistic physics behavior in a game.\n */\n getLinearVelocityToRef(body, linVel, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const lv = this._hknp.HP_Body_GetLinearVelocity(pluginRef.hpBodyId)[1];\n this._v3ToBvecRef(lv, linVel);\n }\n /*\n * Apply an operation either to all instances of a body, if instanceIndex is not specified, or to a specific instance.\n */\n _applyToBodyOrInstances(body, fnToApply, instanceIndex) {\n if (body._pluginDataInstances?.length > 0 && instanceIndex === undefined) {\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\n fnToApply(body._pluginDataInstances[i]);\n }\n }\n else {\n fnToApply(this._getPluginReference(body, instanceIndex));\n }\n }\n /**\n * Applies an impulse to a physics body at a given location.\n * @param body - The physics body to apply the impulse to.\n * @param impulse - The impulse vector to apply.\n * @param location - The location in world space to apply the impulse.\n * @param instanceIndex - The index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.\n *\n * This method is useful for applying an impulse to a physics body at a given location.\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\n */\n applyImpulse(body, impulse, location, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginRef) => {\n this._hknp.HP_Body_ApplyImpulse(pluginRef.hpBodyId, this._bVecToV3(location), this._bVecToV3(impulse));\n }, instanceIndex);\n }\n /**\n * Applies an angular impulse(torque) to a physics body\n * @param body - The physics body to apply the impulse to.\n * @param angularImpulse - The torque value\n * @param instanceIndex - The index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.\n */\n applyAngularImpulse(body, angularImpulse, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginRef) => {\n this._hknp.HP_Body_ApplyAngularImpulse(pluginRef.hpBodyId, this._bVecToV3(angularImpulse));\n }, instanceIndex);\n }\n /**\n * Applies a force to a physics body at a given location.\n * @param body - The physics body to apply the impulse to.\n * @param force - The force vector to apply.\n * @param location - The location in world space to apply the impulse.\n * @param instanceIndex - The index of the instance to apply the force to. If not specified, the force will be applied to all instances.\n *\n * This method is useful for applying a force to a physics body at a given location.\n * This can be used to simulate physical forces such as explosions, collisions, and gravity.\n */\n applyForce(body, force, location, instanceIndex) {\n force.scaleToRef(this.getTimeStep(), this._tmpVec3[0]);\n this.applyImpulse(body, this._tmpVec3[0], location, instanceIndex);\n }\n /**\n * Sets the angular velocity of a physics body.\n *\n * @param body - The physics body to set the angular velocity of.\n * @param angVel - The angular velocity to set.\n * @param instanceIndex - The index of the instance to set the angular velocity of. If not specified, the angular velocity of the first instance will be set.\n *\n * This function is useful for setting the angular velocity of a physics body in a physics engine.\n * This allows for more realistic simulations of physical objects, as they can be given a rotational velocity.\n */\n setAngularVelocity(body, angVel, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginRef) => {\n this._hknp.HP_Body_SetAngularVelocity(pluginRef.hpBodyId, this._bVecToV3(angVel));\n }, instanceIndex);\n }\n /**\n * Gets the angular velocity of a body.\n * @param body - The body to get the angular velocity from.\n * @param angVel - The vector3 to store the angular velocity.\n * @param instanceIndex - The index of the instance to get the angular velocity from. If not specified, the angular velocity of the first instance will be returned.\n *\n * This method is useful for getting the angular velocity of a body in a physics engine. It\n * takes the body and a vector3 as parameters and stores the angular velocity of the body\n * in the vector3. This is useful for getting the angular velocity of a body in order to\n * calculate the motion of the body in the physics engine.\n */\n getAngularVelocityToRef(body, angVel, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n const av = this._hknp.HP_Body_GetAngularVelocity(pluginRef.hpBodyId)[1];\n this._v3ToBvecRef(av, angVel);\n }\n /**\n * Sets the transformation of the given physics body to the given transform node.\n * @param body The physics body to set the transformation for.\n * @param node The transform node to set the transformation from.\n * Sets the transformation of the given physics body to the given transform node.\n *\n * This function is useful for setting the transformation of a physics body to a\n * transform node, which is necessary for the physics engine to accurately simulate\n * the motion of the body. It also takes into account instances of the transform\n * node, which is necessary for accurate simulation of multiple bodies with the\n * same transformation.\n */\n setPhysicsBodyTransformation(body, node) {\n if (body.getPrestepType() == PhysicsPrestepType.TELEPORT) {\n const transformNode = body.transformNode;\n if (body.numInstances > 0) {\n // instances\n const m = transformNode;\n const matrixData = m._thinInstanceDataStorage.matrixData;\n if (!matrixData) {\n return; // TODO: error handling\n }\n const instancesCount = body.numInstances;\n this._createOrUpdateBodyInstances(body, body.getMotionType(), matrixData, 0, instancesCount, true);\n }\n else {\n // regular\n this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node));\n }\n }\n else if (body.getPrestepType() == PhysicsPrestepType.ACTION) {\n this.setTargetTransform(body, node.absolutePosition, node.absoluteRotationQuaternion);\n }\n else if (body.getPrestepType() == PhysicsPrestepType.DISABLED) {\n Logger.Warn(\"Prestep type is set to DISABLED. Unable to set physics body transformation.\");\n }\n else {\n Logger.Warn(\"Invalid prestep type set to physics body.\");\n }\n }\n /**\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\n * @param body The physics body to set the target transformation for.\n * @param position The target position\n * @param rotation The target rotation\n * @param instanceIndex The index of the instance in an instanced body\n */\n setTargetTransform(body, position, rotation, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginRef) => {\n this._hknp.HP_Body_SetTargetQTransform(pluginRef.hpBodyId, [this._bVecToV3(position), this._bQuatToV4(rotation)]);\n }, instanceIndex);\n }\n /**\n * Sets the gravity factor of a body\n * @param body the physics body to set the gravity factor for\n * @param factor the gravity factor\n * @param instanceIndex the index of the instance in an instanced body\n */\n setGravityFactor(body, factor, instanceIndex) {\n this._applyToBodyOrInstances(body, (pluginRef) => {\n this._hknp.HP_Body_SetGravityFactor(pluginRef.hpBodyId, factor);\n }, instanceIndex);\n }\n /**\n * Get the gravity factor of a body\n * @param body the physics body to get the gravity factor from\n * @param instanceIndex the index of the instance in an instanced body. If not specified, the gravity factor of the first instance will be returned.\n * @returns the gravity factor\n */\n getGravityFactor(body, instanceIndex) {\n const pluginRef = this._getPluginReference(body, instanceIndex);\n return this._hknp.HP_Body_GetGravityFactor(pluginRef.hpBodyId)[1];\n }\n /**\n * Disposes a physics body.\n *\n * @param body - The physics body to dispose.\n *\n * This method is useful for releasing the resources associated with a physics body when it is no longer needed.\n * This is important for avoiding memory leaks in the physics engine.\n */\n disposeBody(body) {\n if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {\n for (const instance of body._pluginDataInstances) {\n this._hknp.HP_Body_Release(instance.hpBodyId);\n instance.hpBodyId = undefined;\n }\n }\n if (body._pluginData) {\n this._hknp.HP_Body_Release(body._pluginData.hpBodyId);\n body._pluginData.hpBodyId = undefined;\n }\n }\n _createOptionsFromGroundMesh(options) {\n const mesh = options.groundMesh;\n if (!mesh) {\n return;\n }\n let pos = mesh.getVerticesData(VertexBuffer.PositionKind);\n const transform = mesh.computeWorldMatrix(true);\n // convert rawVerts to object space\n const transformedVertices = [];\n let index;\n for (index = 0; index < pos.length; index += 3) {\n Vector3.FromArrayToRef(pos, index, TmpVectors.Vector3[0]);\n Vector3.TransformCoordinatesToRef(TmpVectors.Vector3[0], transform, TmpVectors.Vector3[1]);\n TmpVectors.Vector3[1].toArray(transformedVertices, index);\n }\n pos = transformedVertices;\n const arraySize = ~~(Math.sqrt(pos.length / 3) - 1);\n const boundingInfo = mesh.getBoundingInfo();\n const dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.z);\n const minX = boundingInfo.boundingBox.minimumWorld.x;\n const minY = boundingInfo.boundingBox.minimumWorld.y;\n const minZ = boundingInfo.boundingBox.minimumWorld.z;\n const matrix = new Float32Array((arraySize + 1) * (arraySize + 1));\n const elementSize = (dim * 2) / arraySize;\n for (let i = 0; i < matrix.length; i++) {\n matrix[i] = minY;\n }\n for (let i = 0; i < pos.length; i = i + 3) {\n const x = Math.round((pos[i + 0] - minX) / elementSize);\n const z = arraySize - Math.round((pos[i + 2] - minZ) / elementSize);\n const y = pos[i + 1] - minY;\n matrix[z * (arraySize + 1) + x] = y;\n }\n options.numHeightFieldSamplesX = arraySize + 1;\n options.numHeightFieldSamplesZ = arraySize + 1;\n options.heightFieldSizeX = boundingInfo.boundingBox.extendSizeWorld.x * 2;\n options.heightFieldSizeZ = boundingInfo.boundingBox.extendSizeWorld.z * 2;\n options.heightFieldData = matrix;\n }\n /**\n * Initializes a physics shape with the given type and parameters.\n * @param shape - The physics shape to initialize.\n * @param type - The type of shape to initialize.\n * @param options - The parameters for the shape.\n *\n * This code is useful for initializing a physics shape with the given type and parameters.\n * It allows for the creation of a sphere, box, capsule, container, cylinder, mesh, and heightfield.\n * Depending on the type of shape, different parameters are required.\n * For example, a sphere requires a radius, while a box requires extents and a rotation.\n */\n initShape(shape, type, options) {\n switch (type) {\n case 0 /* PhysicsShapeType.SPHERE */:\n {\n const radius = options.radius || 1;\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\n shape._pluginData = this._hknp.HP_Shape_CreateSphere(center, radius)[1];\n }\n break;\n case 3 /* PhysicsShapeType.BOX */:\n {\n const rotation = options.rotation ? this._bQuatToV4(options.rotation) : [0, 0, 0, 1];\n const extent = options.extents ? this._bVecToV3(options.extents) : [1, 1, 1];\n const center = options.center ? this._bVecToV3(options.center) : [0, 0, 0];\n shape._pluginData = this._hknp.HP_Shape_CreateBox(center, rotation, extent)[1];\n }\n break;\n case 1 /* PhysicsShapeType.CAPSULE */:\n {\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\n const radius = options.radius || 0;\n shape._pluginData = this._hknp.HP_Shape_CreateCapsule(pointA, pointB, radius)[1];\n }\n break;\n case 5 /* PhysicsShapeType.CONTAINER */:\n {\n shape._pluginData = this._hknp.HP_Shape_CreateContainer()[1];\n }\n break;\n case 2 /* PhysicsShapeType.CYLINDER */:\n {\n const pointA = options.pointA ? this._bVecToV3(options.pointA) : [0, 0, 0];\n const pointB = options.pointB ? this._bVecToV3(options.pointB) : [0, 1, 0];\n const radius = options.radius || 0;\n shape._pluginData = this._hknp.HP_Shape_CreateCylinder(pointA, pointB, radius)[1];\n }\n break;\n case 4 /* PhysicsShapeType.CONVEX_HULL */:\n case 6 /* PhysicsShapeType.MESH */:\n {\n const mesh = options.mesh;\n if (mesh) {\n const includeChildMeshes = !!options.includeChildMeshes;\n const needIndices = type != 4 /* PhysicsShapeType.CONVEX_HULL */;\n const accum = new MeshAccumulator(mesh, needIndices, mesh?.getScene());\n accum.addNodeMeshes(mesh, includeChildMeshes);\n const positions = accum.getVertices(this._hknp);\n const numVec3s = positions.numObjects / 3;\n if (type == 4 /* PhysicsShapeType.CONVEX_HULL */) {\n shape._pluginData = this._hknp.HP_Shape_CreateConvexHull(positions.offset, numVec3s)[1];\n }\n else {\n const triangles = accum.getTriangles(this._hknp);\n const numTriangles = triangles.numObjects / 3;\n shape._pluginData = this._hknp.HP_Shape_CreateMesh(positions.offset, numVec3s, triangles.offset, numTriangles)[1];\n accum.freeBuffer(this._hknp, triangles);\n }\n accum.freeBuffer(this._hknp, positions);\n }\n else {\n throw new Error(\"No mesh provided to create physics shape.\");\n }\n }\n break;\n case 7 /* PhysicsShapeType.HEIGHTFIELD */:\n {\n if (options.groundMesh) {\n // update options with datas from groundMesh\n this._createOptionsFromGroundMesh(options);\n }\n if (options.numHeightFieldSamplesX && options.numHeightFieldSamplesZ && options.heightFieldSizeX && options.heightFieldSizeZ && options.heightFieldData) {\n const totalNumHeights = options.numHeightFieldSamplesX * options.numHeightFieldSamplesZ;\n const numBytes = totalNumHeights * 4;\n const bufferBegin = this._hknp._malloc(numBytes);\n const heightBuffer = new Float32Array(this._hknp.HEAPU8.buffer, bufferBegin, totalNumHeights);\n for (let x = 0; x < options.numHeightFieldSamplesX; x++) {\n for (let z = 0; z < options.numHeightFieldSamplesZ; z++) {\n const hkBufferIndex = z * options.numHeightFieldSamplesX + x;\n const bjsBufferIndex = (options.numHeightFieldSamplesX - 1 - x) * options.numHeightFieldSamplesZ + z;\n heightBuffer[hkBufferIndex] = options.heightFieldData[bjsBufferIndex];\n }\n }\n const scaleX = options.heightFieldSizeX / (options.numHeightFieldSamplesX - 1);\n const scaleZ = options.heightFieldSizeZ / (options.numHeightFieldSamplesZ - 1);\n shape._pluginData = this._hknp.HP_Shape_CreateHeightField(options.numHeightFieldSamplesX, options.numHeightFieldSamplesZ, [scaleX, 1, scaleZ], bufferBegin)[1];\n this._hknp._free(bufferBegin);\n }\n else {\n throw new Error(\"Missing required heightfield parameters\");\n }\n }\n break;\n default:\n throw new Error(\"Unsupported Shape Type.\");\n break;\n }\n this._shapes.set(shape._pluginData[0], shape);\n }\n /**\n * Sets the shape filter membership mask of a body\n * @param shape - The physics body to set the shape filter membership mask for.\n * @param membershipMask - The shape filter membership mask to set.\n */\n setShapeFilterMembershipMask(shape, membershipMask) {\n const collideWith = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membershipMask, collideWith]);\n }\n /**\n * Gets the shape filter membership mask of a body\n * @param shape - The physics body to get the shape filter membership mask from.\n * @returns The shape filter membership mask of the given body.\n */\n getShapeFilterMembershipMask(shape) {\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\n }\n /**\n * Sets the shape filter collide mask of a body\n * @param shape - The physics body to set the shape filter collide mask for.\n * @param collideMask - The shape filter collide mask to set.\n */\n setShapeFilterCollideMask(shape, collideMask) {\n const membership = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][0];\n this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membership, collideMask]);\n }\n /**\n * Gets the shape filter collide mask of a body\n * @param shape - The physics body to get the shape filter collide mask from.\n * @returns The shape filter collide mask of the given body.\n */\n getShapeFilterCollideMask(shape) {\n return this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\n }\n /**\n * Sets the material of a physics shape.\n * @param shape - The physics shape to set the material of.\n * @param material - The material to set.\n *\n */\n setMaterial(shape, material) {\n const dynamicFriction = material.friction ?? 0.5;\n const staticFriction = material.staticFriction ?? dynamicFriction;\n const restitution = material.restitution ?? 0.0;\n const frictionCombine = material.frictionCombine ?? 1 /* PhysicsMaterialCombineMode.MINIMUM */;\n const restitutionCombine = material.restitutionCombine ?? 2 /* PhysicsMaterialCombineMode.MAXIMUM */;\n const hpMaterial = [staticFriction, dynamicFriction, restitution, this._materialCombineToNative(frictionCombine), this._materialCombineToNative(restitutionCombine)];\n this._hknp.HP_Shape_SetMaterial(shape._pluginData, hpMaterial);\n }\n /**\n * Gets the material associated with a physics shape.\n * @param shape - The shape to get the material from.\n * @returns The material associated with the shape.\n */\n getMaterial(shape) {\n const hkMaterial = this._hknp.HP_Shape_GetMaterial(shape._pluginData)[1];\n return {\n staticFriction: hkMaterial[0],\n friction: hkMaterial[1],\n restitution: hkMaterial[2],\n frictionCombine: this._nativeToMaterialCombine(hkMaterial[3]),\n restitutionCombine: this._nativeToMaterialCombine(hkMaterial[4]),\n };\n }\n /**\n * Sets the density of a physics shape.\n * @param shape - The physics shape to set the density of.\n * @param density - The density to set.\n *\n */\n setDensity(shape, density) {\n this._hknp.HP_Shape_SetDensity(shape._pluginData, density);\n }\n /**\n * Calculates the density of a given physics shape.\n *\n * @param shape - The physics shape to calculate the density of.\n * @returns The density of the given physics shape.\n *\n */\n getDensity(shape) {\n return this._hknp.HP_Shape_GetDensity(shape._pluginData)[1];\n }\n /**\n * Gets the transform infos of a given transform node.\n * This code is useful for getting the position and orientation of a given transform node.\n * It first checks if the node has a rotation quaternion, and if not, it creates one from the node's rotation.\n * It then creates an array containing the position and orientation of the node and returns it.\n * @param node - The transform node.\n * @returns An array containing the position and orientation of the node.\n */\n _getTransformInfos(node) {\n if (node.parent) {\n node.computeWorldMatrix(true);\n return [this._bVecToV3(node.absolutePosition), this._bQuatToV4(node.absoluteRotationQuaternion)];\n }\n let orientation = TmpVectors.Quaternion[0];\n if (node.rotationQuaternion) {\n orientation = node.rotationQuaternion;\n }\n else {\n const r = node.rotation;\n Quaternion.FromEulerAnglesToRef(r.x, r.y, r.z, orientation);\n }\n const transform = [this._bVecToV3(node.position), this._bQuatToV4(orientation)];\n return transform;\n }\n /**\n * Adds a child shape to the given shape.\n * @param shape - The parent shape.\n * @param newChild - The child shape to add.\n * @param translation - The relative translation of the child from the parent shape\n * @param rotation - The relative rotation of the child from the parent shape\n * @param scale - The relative scale scale of the child from the parent shaep\n *\n */\n addChild(shape, newChild, translation, rotation, scale) {\n const transformNative = [\n translation ? this._bVecToV3(translation) : [0, 0, 0],\n rotation ? this._bQuatToV4(rotation) : [0, 0, 0, 1],\n scale ? this._bVecToV3(scale) : [1, 1, 1],\n ];\n this._hknp.HP_Shape_AddChild(shape._pluginData, newChild._pluginData, transformNative);\n }\n /**\n * Removes a child shape from a parent shape.\n * @param shape - The parent shape.\n * @param childIndex - The index of the child shape to remove.\n *\n */\n removeChild(shape, childIndex) {\n this._hknp.HP_Shape_RemoveChild(shape._pluginData, childIndex);\n }\n /**\n * Returns the number of children of the given shape.\n *\n * @param shape - The shape to get the number of children from.\n * @returns The number of children of the given shape.\n *\n */\n getNumChildren(shape) {\n return this._hknp.HP_Shape_GetNumChildren(shape._pluginData)[1];\n }\n /**\n * Marks the shape as a trigger\n * @param shape the shape to mark as a trigger\n * @param isTrigger if the shape is a trigger\n */\n setTrigger(shape, isTrigger) {\n this._hknp.HP_Shape_SetTrigger(shape._pluginData, isTrigger);\n }\n /**\n * Calculates the bounding box of a given physics shape.\n *\n * @param _shape - The physics shape to calculate the bounding box for.\n * @returns The calculated bounding box.\n *\n * This method is useful for physics engines as it allows to calculate the\n * boundaries of a given shape. Knowing the boundaries of a shape is important\n * for collision detection and other physics calculations.\n */\n getBoundingBox(_shape) {\n // get local AABB\n const aabb = this._hknp.HP_Shape_GetBoundingBox(_shape._pluginData, [\n [0, 0, 0],\n [0, 0, 0, 1],\n ])[1];\n TmpVectors.Vector3[0].set(aabb[0][0], aabb[0][1], aabb[0][2]); // min\n TmpVectors.Vector3[1].set(aabb[1][0], aabb[1][1], aabb[1][2]); // max\n const boundingbox = new BoundingBox(TmpVectors.Vector3[0], TmpVectors.Vector3[1], Matrix.IdentityReadOnly);\n return boundingbox;\n }\n /**\n * Calculates the world bounding box of a given physics body.\n *\n * @param body - The physics body to calculate the bounding box for.\n * @returns The calculated bounding box.\n *\n * This method is useful for physics engines as it allows to calculate the\n * boundaries of a given body.\n */\n getBodyBoundingBox(body) {\n // get local AABB\n const aabb = this.getBoundingBox(body.shape);\n const boundingbox = new BoundingBox(aabb.minimum, aabb.maximum, body.transformNode.getWorldMatrix());\n return boundingbox;\n }\n /**\n * Gets the geometry of a physics body.\n *\n * @param body - The physics body.\n * @returns An object containing the positions and indices of the body's geometry.\n *\n */\n getBodyGeometry(body) {\n const dataInfo = body._pluginDataInstances?.length > 0 ? body._pluginDataInstances[0] : body._pluginData;\n const shape = this._hknp.HP_Body_GetShape(dataInfo.hpBodyId)[1];\n const geometryRes = this._hknp.HP_Shape_CreateDebugDisplayGeometry(shape);\n if (geometryRes[0] != this._hknp.Result.RESULT_OK) {\n return { positions: [], indices: [] };\n }\n const geometryInfo = this._hknp.HP_DebugGeometry_GetInfo(geometryRes[1])[1];\n const positionsInPlugin = new Float32Array(this._hknp.HEAPU8.buffer, geometryInfo[0], geometryInfo[1] * 3); // 3 floats per position\n const indicesInPlugin = new Uint32Array(this._hknp.HEAPU8.buffer, geometryInfo[2], geometryInfo[3] * 3); // 3 indices per triangle\n // HP_DebugGeometry_Release will free the buffer in the plugin. To avoid a\n // use-after-free, we need to make a copy of the data here.\n const positions = positionsInPlugin.slice(0);\n const indices = indicesInPlugin.slice(0);\n this._hknp.HP_DebugGeometry_Release(geometryRes[1]);\n return { positions: positions, indices: indices };\n }\n /**\n * Releases a physics shape from the physics engine.\n *\n * @param shape - The physics shape to be released.\n *\n * This method is useful for releasing a physics shape from the physics engine, freeing up resources and preventing memory leaks.\n */\n disposeShape(shape) {\n this._hknp.HP_Shape_Release(shape._pluginData);\n shape._pluginData = undefined;\n }\n // constraint\n /**\n * Initializes a physics constraint with the given parameters.\n *\n * @param constraint - The physics constraint to be initialized.\n * @param body - The main body\n * @param childBody - The child body.\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n *\n * This function is useful for setting up a physics constraint in a physics engine.\n */\n initConstraint(constraint, body, childBody, instanceIndex, childInstanceIndex) {\n const type = constraint.type;\n const options = constraint.options;\n if (!type || !options) {\n Logger.Warn(\"No constraint type or options. Constraint is invalid.\");\n return;\n }\n if ((body._pluginDataInstances.length > 0 && instanceIndex === undefined) || (childBody._pluginDataInstances.length > 0 && childInstanceIndex === undefined)) {\n Logger.Warn(\"Body is instanced but no instance index was specified. Constraint will not be applied.\");\n return;\n }\n constraint._pluginData = constraint._pluginData ?? [];\n const jointId = this._hknp.HP_Constraint_Create()[1];\n constraint._pluginData.push(jointId);\n // body parenting\n const bodyA = this._getPluginReference(body, instanceIndex).hpBodyId;\n const bodyB = this._getPluginReference(childBody, childInstanceIndex).hpBodyId;\n this._hknp.HP_Constraint_SetParentBody(jointId, bodyA);\n this._hknp.HP_Constraint_SetChildBody(jointId, bodyB);\n this._constraintToBodyIdPair.set(jointId[0], [bodyA[0], bodyB[0]]);\n // anchors\n const pivotA = options.pivotA ? this._bVecToV3(options.pivotA) : this._bVecToV3(Vector3.Zero());\n const axisA = options.axisA ?? new Vector3(1, 0, 0);\n const perpAxisA = this._tmpVec3[0];\n if (options.perpAxisA) {\n perpAxisA.copyFrom(options.perpAxisA);\n }\n else {\n axisA.getNormalToRef(perpAxisA);\n }\n this._hknp.HP_Constraint_SetAnchorInParent(jointId, pivotA, this._bVecToV3(axisA), this._bVecToV3(perpAxisA));\n const pivotB = options.pivotB ? this._bVecToV3(options.pivotB) : this._bVecToV3(Vector3.Zero());\n const axisB = options.axisB ?? new Vector3(1, 0, 0);\n const perpAxisB = this._tmpVec3[0];\n if (options.perpAxisB) {\n perpAxisB.copyFrom(options.perpAxisB);\n }\n else {\n axisB.getNormalToRef(perpAxisB);\n }\n this._hknp.HP_Constraint_SetAnchorInChild(jointId, pivotB, this._bVecToV3(axisB), this._bVecToV3(perpAxisB));\n // Save the options that were used for initializing the constraint for debugging purposes\n // Check first to avoid copying the same options multiple times\n if (!constraint._initOptions) {\n constraint._initOptions = {\n axisA: axisA.clone(),\n axisB: axisB.clone(),\n perpAxisA: perpAxisA.clone(),\n perpAxisB: perpAxisB.clone(),\n pivotA: new Vector3(pivotA[0], pivotA[1], pivotA[2]),\n pivotB: new Vector3(pivotB[0], pivotB[1], pivotB[2]),\n };\n }\n if (type == 5 /* PhysicsConstraintType.LOCK */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n }\n else if (type == 2 /* PhysicsConstraintType.DISTANCE */) {\n const distance = options.maxDistance || 0;\n const dist3d = this._hknp.ConstraintAxis.LINEAR_DISTANCE;\n this._hknp.HP_Constraint_SetAxisMode(jointId, dist3d, this._hknp.ConstraintAxisLimitMode.LIMITED);\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, dist3d, distance);\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, dist3d, distance);\n }\n else if (type == 3 /* PhysicsConstraintType.HINGE */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n }\n else if (type == 6 /* PhysicsConstraintType.PRISMATIC */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n }\n else if (type == 4 /* PhysicsConstraintType.SLIDER */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n }\n else if (type == 1 /* PhysicsConstraintType.BALL_AND_SOCKET */) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED);\n this._hknp.HP_Constraint_SetAxisMode(jointId, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED);\n }\n else if (type == 7 /* PhysicsConstraintType.SIX_DOF */) {\n const sixdofData = constraint;\n for (const l of sixdofData.limits) {\n const axId = this._constraintAxisToNative(l.axis);\n if ((l.minLimit ?? -1) == 0 && (l.maxLimit ?? -1) == 0) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LOCKED);\n }\n else {\n if (l.minLimit != undefined) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\n this._hknp.HP_Constraint_SetAxisMinLimit(jointId, axId, l.minLimit);\n }\n if (l.maxLimit != undefined) {\n this._hknp.HP_Constraint_SetAxisMode(jointId, axId, this._hknp.ConstraintAxisLimitMode.LIMITED);\n this._hknp.HP_Constraint_SetAxisMaxLimit(jointId, axId, l.maxLimit);\n }\n }\n if (l.stiffness) {\n this._hknp.HP_Constraint_SetAxisStiffness(jointId, axId, l.stiffness);\n }\n if (l.damping) {\n this._hknp.HP_Constraint_SetAxisDamping(jointId, axId, l.damping);\n }\n }\n }\n else {\n throw new Error(\"Unsupported Constraint Type.\");\n }\n const collisionEnabled = !!options.collision;\n this._hknp.HP_Constraint_SetCollisionsEnabled(jointId, collisionEnabled);\n this._hknp.HP_Constraint_SetEnabled(jointId, true);\n }\n /**\n * Get a list of all the pairs of bodies that are connected by this constraint.\n * @param constraint the constraint to search from\n * @returns a list of parent, child pairs\n */\n getBodiesUsingConstraint(constraint) {\n const pairs = [];\n for (const jointId of constraint._pluginData) {\n const bodyIds = this._constraintToBodyIdPair.get(jointId[0]);\n if (bodyIds) {\n const parentBodyInfo = this._bodies.get(bodyIds[0]);\n const childBodyInfo = this._bodies.get(bodyIds[1]);\n if (parentBodyInfo && childBodyInfo) {\n pairs.push({ parentBody: parentBodyInfo.body, parentBodyIndex: parentBodyInfo.index, childBody: childBodyInfo.body, childBodyIndex: childBodyInfo.index });\n }\n }\n }\n return pairs;\n }\n /**\n * Adds a constraint to the physics engine.\n *\n * @param body - The main body to which the constraint is applied.\n * @param childBody - The body to which the constraint is applied.\n * @param constraint - The constraint to be applied.\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\n */\n addConstraint(body, childBody, constraint, instanceIndex, childInstanceIndex) {\n // 0) {\n const [, hitData] = this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector, 0)[1];\n this._populateHitData(hitData, result);\n result.calculateHitDistance();\n }\n }\n /**\n * Given a point, returns the closest physics\n * body to that point.\n * @param query the query to perform. @see IPhysicsPointProximityQuery\n * @param result contact point on the hit shape, in world space\n */\n pointProximity(query, result) {\n const queryMembership = query?.collisionFilter?.membership ?? ~0;\n const queryCollideWith = query?.collisionFilter?.collideWith ?? ~0;\n result.reset();\n const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];\n const hkQuery = [this._bVecToV3(query.position), query.maxDistance, [queryMembership, queryCollideWith], query.shouldHitTriggers, bodyToIgnore];\n this._hknp.HP_World_PointProximityWithCollector(this.world, this._queryCollector, hkQuery);\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\n const [distance, hitData] = this._hknp.HP_QueryCollector_GetPointProximityResult(this._queryCollector, 0)[1];\n this._populateHitData(hitData, result);\n result.setHitDistance(distance);\n }\n }\n /**\n * Given a shape in a specific position and orientation, returns the closest point to that shape.\n * @param query the query to perform. @see IPhysicsShapeProximityCastQuery\n * @param inputShapeResult contact point on input shape, in input shape space\n * @param hitShapeResult contact point on hit shape, in world space\n */\n shapeProximity(query, inputShapeResult, hitShapeResult) {\n inputShapeResult.reset();\n hitShapeResult.reset();\n const shapeId = query.shape._pluginData;\n const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];\n const hkQuery = [shapeId, this._bVecToV3(query.position), this._bQuatToV4(query.rotation), query.maxDistance, query.shouldHitTriggers, bodyToIgnore];\n this._hknp.HP_World_ShapeProximityWithCollector(this.world, this._queryCollector, hkQuery);\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\n const [distance, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeProximityResult(this._queryCollector, 0)[1];\n this._populateHitData(hitInputData, inputShapeResult);\n this._populateHitData(hitShapeData, hitShapeResult);\n inputShapeResult.setHitDistance(distance);\n hitShapeResult.setHitDistance(distance);\n }\n }\n /**\n * Given a shape in a specific orientation, cast it from the start to end position specified by the query, and return the first hit.\n * @param query the query to perform. @see IPhysicsShapeCastQuery\n * @param inputShapeResult contact point on input shape, in input shape space\n * @param hitShapeResult contact point on hit shape, in world space\n */\n shapeCast(query, inputShapeResult, hitShapeResult) {\n inputShapeResult.reset();\n hitShapeResult.reset();\n const shapeId = query.shape._pluginData;\n const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];\n const hkQuery = [shapeId, this._bQuatToV4(query.rotation), this._bVecToV3(query.startPosition), this._bVecToV3(query.endPosition), query.shouldHitTriggers, bodyToIgnore];\n this._hknp.HP_World_ShapeCastWithCollector(this.world, this._queryCollector, hkQuery);\n if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {\n const [fractionAlongRay, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeCastResult(this._queryCollector, 0)[1];\n this._populateHitData(hitInputData, inputShapeResult);\n this._populateHitData(hitShapeData, hitShapeResult);\n inputShapeResult.setHitFraction(fractionAlongRay);\n hitShapeResult.setHitFraction(fractionAlongRay);\n }\n }\n /**\n * Return the collision observable for a particular physics body.\n * @param body the physics body\n * @returns the collision observable for the body\n */\n getCollisionObservable(body) {\n const bodyId = body._pluginData.hpBodyId[0];\n let observable = this._bodyCollisionObservable.get(bodyId);\n if (!observable) {\n observable = new Observable();\n this._bodyCollisionObservable.set(bodyId, observable);\n }\n return observable;\n }\n /**\n * Return the collision ended observable for a particular physics body.\n * @param body the physics body\n * @returns\n */\n getCollisionEndedObservable(body) {\n const bodyId = body._pluginData.hpBodyId[0];\n let observable = this._bodyCollisionEndedObservable.get(bodyId);\n if (!observable) {\n observable = new Observable();\n this._bodyCollisionEndedObservable.set(bodyId, observable);\n }\n return observable;\n }\n /**\n * Enable collision to be reported for a body when a callback is setup on the world\n * @param body the physics body\n * @param enabled whether to enable or disable collision events\n */\n setCollisionCallbackEnabled(body, enabled) {\n // Register for collide events by default\n const collideEvents = this._hknp.EventType.COLLISION_STARTED.value | this._hknp.EventType.COLLISION_CONTINUED.value | this._hknp.EventType.COLLISION_FINISHED.value;\n if (body._pluginDataInstances && body._pluginDataInstances.length) {\n body._pluginDataInstances.forEach((bodyId) => {\n this._hknp.HP_Body_SetEventMask(bodyId.hpBodyId, enabled ? collideEvents : 0);\n });\n }\n else if (body._pluginData) {\n this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, enabled ? collideEvents : 0);\n }\n }\n /**\n * Enable collision ended to be reported for a body when a callback is setup on the world\n * @param body the physics body\n * @param enabled whether to enable or disable collision ended events\n */\n setCollisionEndedCallbackEnabled(body, enabled) {\n // Register to collide ended events\n const pluginRef = this._getPluginReference(body);\n let currentCollideEvents = this._hknp.HP_Body_GetEventMask(pluginRef.hpBodyId)[1];\n // update with the ended mask\n currentCollideEvents = enabled\n ? currentCollideEvents | this._hknp.EventType.COLLISION_FINISHED.value\n : currentCollideEvents & ~this._hknp.EventType.COLLISION_FINISHED.value;\n if (body._pluginDataInstances && body._pluginDataInstances.length) {\n body._pluginDataInstances.forEach((bodyId) => {\n this._hknp.HP_Body_SetEventMask(bodyId.hpBodyId, currentCollideEvents);\n });\n }\n else if (body._pluginData) {\n this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, currentCollideEvents);\n }\n }\n _notifyTriggers() {\n let eventAddress = this._hknp.HP_World_GetTriggerEvents(this.world)[1];\n const event = new TriggerEvent();\n while (eventAddress) {\n TriggerEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);\n const bodyInfoA = this._bodies.get(event.bodyIdA);\n const bodyInfoB = this._bodies.get(event.bodyIdB);\n // Bodies may have been disposed between events. Check both still exist.\n if (bodyInfoA && bodyInfoB) {\n const triggerCollisionInfo = {\n collider: bodyInfoA.body,\n colliderIndex: bodyInfoA.index,\n collidedAgainst: bodyInfoB.body,\n collidedAgainstIndex: bodyInfoB.index,\n type: this._nativeTriggerCollisionValueToCollisionType(event.type),\n };\n this.onTriggerCollisionObservable.notifyObservers(triggerCollisionInfo);\n }\n eventAddress = this._hknp.HP_World_GetNextTriggerEvent(this.world, eventAddress);\n }\n }\n /**\n * Runs thru all detected collisions and filter by body\n */\n _notifyCollisions() {\n let eventAddress = this._hknp.HP_World_GetCollisionEvents(this.world)[1];\n const event = new CollisionEvent();\n const worldAddr = Number(this.world);\n while (eventAddress) {\n CollisionEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);\n const bodyInfoA = this._bodies.get(event.contactOnA.bodyId);\n const bodyInfoB = this._bodies.get(event.contactOnB.bodyId);\n // Bodies may have been disposed between events. Check both still exist.\n if (bodyInfoA && bodyInfoB) {\n const collisionInfo = {\n collider: bodyInfoA.body,\n colliderIndex: bodyInfoA.index,\n collidedAgainst: bodyInfoB.body,\n collidedAgainstIndex: bodyInfoB.index,\n type: this._nativeCollisionValueToCollisionType(event.type),\n };\n if (collisionInfo.type === \"COLLISION_FINISHED\" /* PhysicsEventType.COLLISION_FINISHED */) {\n this.onCollisionEndedObservable.notifyObservers(collisionInfo);\n }\n else {\n event.contactOnB.position.subtractToRef(event.contactOnA.position, this._tmpVec3[0]);\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnA.normal);\n collisionInfo.point = event.contactOnA.position;\n collisionInfo.distance = distance;\n collisionInfo.impulse = event.impulseApplied;\n collisionInfo.normal = event.contactOnA.normal;\n this.onCollisionObservable.notifyObservers(collisionInfo);\n }\n if (this._bodyCollisionObservable.size && collisionInfo.type !== \"COLLISION_FINISHED\" /* PhysicsEventType.COLLISION_FINISHED */) {\n const observableA = this._bodyCollisionObservable.get(event.contactOnA.bodyId);\n const observableB = this._bodyCollisionObservable.get(event.contactOnB.bodyId);\n event.contactOnA.position.subtractToRef(event.contactOnB.position, this._tmpVec3[0]);\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnB.normal);\n if (observableA) {\n observableA.notifyObservers(collisionInfo);\n }\n if (observableB) {\n const collisionInfoB = {\n collider: bodyInfoB.body,\n colliderIndex: bodyInfoB.index,\n collidedAgainst: bodyInfoA.body,\n collidedAgainstIndex: bodyInfoA.index,\n point: event.contactOnB.position,\n distance: distance,\n impulse: event.impulseApplied,\n normal: event.contactOnB.normal,\n type: this._nativeCollisionValueToCollisionType(event.type),\n };\n observableB.notifyObservers(collisionInfoB);\n }\n }\n else if (this._bodyCollisionEndedObservable.size) {\n const observableA = this._bodyCollisionEndedObservable.get(event.contactOnA.bodyId);\n const observableB = this._bodyCollisionEndedObservable.get(event.contactOnB.bodyId);\n event.contactOnA.position.subtractToRef(event.contactOnB.position, this._tmpVec3[0]);\n const distance = Vector3.Dot(this._tmpVec3[0], event.contactOnB.normal);\n if (observableA) {\n observableA.notifyObservers(collisionInfo);\n }\n if (observableB) {\n const collisionInfoB = {\n collider: bodyInfoB.body,\n colliderIndex: bodyInfoB.index,\n collidedAgainst: bodyInfoA.body,\n collidedAgainstIndex: bodyInfoA.index,\n point: event.contactOnB.position,\n distance: distance,\n impulse: event.impulseApplied,\n normal: event.contactOnB.normal,\n type: this._nativeCollisionValueToCollisionType(event.type),\n };\n observableB.notifyObservers(collisionInfoB);\n }\n }\n }\n eventAddress = this._hknp.HP_World_GetNextCollisionEvent(worldAddr, eventAddress);\n }\n }\n /**\n * Gets the number of bodies in the world\n */\n get numBodies() {\n return this._hknp.HP_World_GetNumBodies(this.world)[1];\n }\n /**\n * Dispose the world and free resources\n */\n dispose() {\n if (this._queryCollector) {\n this._hknp.HP_QueryCollector_Release(this._queryCollector);\n this._queryCollector = undefined;\n }\n if (this.world) {\n this._hknp.HP_World_Release(this.world);\n this.world = undefined;\n }\n }\n _v3ToBvecRef(v, vec3) {\n vec3.set(v[0], v[1], v[2]);\n }\n _bVecToV3(v) {\n return [v._x, v._y, v._z];\n }\n _bQuatToV4(q) {\n return [q._x, q._y, q._z, q._w];\n }\n _constraintMotorTypeToNative(motorType) {\n switch (motorType) {\n case 2 /* PhysicsConstraintMotorType.POSITION */:\n return this._hknp.ConstraintMotorType.POSITION;\n case 1 /* PhysicsConstraintMotorType.VELOCITY */:\n return this._hknp.ConstraintMotorType.VELOCITY;\n }\n return this._hknp.ConstraintMotorType.NONE;\n }\n _nativeToMotorType(motorType) {\n switch (motorType) {\n case this._hknp.ConstraintMotorType.POSITION:\n return 2 /* PhysicsConstraintMotorType.POSITION */;\n case this._hknp.ConstraintMotorType.VELOCITY:\n return 1 /* PhysicsConstraintMotorType.VELOCITY */;\n }\n return 0 /* PhysicsConstraintMotorType.NONE */;\n }\n _materialCombineToNative(mat) {\n switch (mat) {\n case 0 /* PhysicsMaterialCombineMode.GEOMETRIC_MEAN */:\n return this._hknp.MaterialCombine.GEOMETRIC_MEAN;\n case 1 /* PhysicsMaterialCombineMode.MINIMUM */:\n return this._hknp.MaterialCombine.MINIMUM;\n case 2 /* PhysicsMaterialCombineMode.MAXIMUM */:\n return this._hknp.MaterialCombine.MAXIMUM;\n case 3 /* PhysicsMaterialCombineMode.ARITHMETIC_MEAN */:\n return this._hknp.MaterialCombine.ARITHMETIC_MEAN;\n case 4 /* PhysicsMaterialCombineMode.MULTIPLY */:\n return this._hknp.MaterialCombine.MULTIPLY;\n }\n }\n _nativeToMaterialCombine(mat) {\n switch (mat) {\n case this._hknp.MaterialCombine.GEOMETRIC_MEAN:\n return 0 /* PhysicsMaterialCombineMode.GEOMETRIC_MEAN */;\n case this._hknp.MaterialCombine.MINIMUM:\n return 1 /* PhysicsMaterialCombineMode.MINIMUM */;\n case this._hknp.MaterialCombine.MAXIMUM:\n return 2 /* PhysicsMaterialCombineMode.MAXIMUM */;\n case this._hknp.MaterialCombine.ARITHMETIC_MEAN:\n return 3 /* PhysicsMaterialCombineMode.ARITHMETIC_MEAN */;\n case this._hknp.MaterialCombine.MULTIPLY:\n return 4 /* PhysicsMaterialCombineMode.MULTIPLY */;\n default:\n return undefined;\n }\n }\n _constraintAxisToNative(axId) {\n switch (axId) {\n case 0 /* PhysicsConstraintAxis.LINEAR_X */:\n return this._hknp.ConstraintAxis.LINEAR_X;\n case 1 /* PhysicsConstraintAxis.LINEAR_Y */:\n return this._hknp.ConstraintAxis.LINEAR_Y;\n case 2 /* PhysicsConstraintAxis.LINEAR_Z */:\n return this._hknp.ConstraintAxis.LINEAR_Z;\n case 3 /* PhysicsConstraintAxis.ANGULAR_X */:\n return this._hknp.ConstraintAxis.ANGULAR_X;\n case 4 /* PhysicsConstraintAxis.ANGULAR_Y */:\n return this._hknp.ConstraintAxis.ANGULAR_Y;\n case 5 /* PhysicsConstraintAxis.ANGULAR_Z */:\n return this._hknp.ConstraintAxis.ANGULAR_Z;\n case 6 /* PhysicsConstraintAxis.LINEAR_DISTANCE */:\n return this._hknp.ConstraintAxis.LINEAR_DISTANCE;\n }\n }\n _nativeToLimitMode(mode) {\n switch (mode) {\n case this._hknp.ConstraintAxisLimitMode.FREE:\n return 0 /* PhysicsConstraintAxisLimitMode.FREE */;\n case this._hknp.ConstraintAxisLimitMode.LIMITED:\n return 1 /* PhysicsConstraintAxisLimitMode.LIMITED */;\n case this._hknp.ConstraintAxisLimitMode.LOCKED:\n return 2 /* PhysicsConstraintAxisLimitMode.LOCKED */;\n }\n return 0 /* PhysicsConstraintAxisLimitMode.FREE */;\n }\n _limitModeToNative(mode) {\n switch (mode) {\n case 0 /* PhysicsConstraintAxisLimitMode.FREE */:\n return this._hknp.ConstraintAxisLimitMode.FREE;\n case 1 /* PhysicsConstraintAxisLimitMode.LIMITED */:\n return this._hknp.ConstraintAxisLimitMode.LIMITED;\n case 2 /* PhysicsConstraintAxisLimitMode.LOCKED */:\n return this._hknp.ConstraintAxisLimitMode.LOCKED;\n }\n }\n _nativeCollisionValueToCollisionType(type) {\n switch (type) {\n case this._hknp.EventType.COLLISION_STARTED.value:\n return \"COLLISION_STARTED\" /* PhysicsEventType.COLLISION_STARTED */;\n case this._hknp.EventType.COLLISION_FINISHED.value:\n return \"COLLISION_FINISHED\" /* PhysicsEventType.COLLISION_FINISHED */;\n case this._hknp.EventType.COLLISION_CONTINUED.value:\n return \"COLLISION_CONTINUED\" /* PhysicsEventType.COLLISION_CONTINUED */;\n }\n return \"COLLISION_STARTED\" /* PhysicsEventType.COLLISION_STARTED */;\n }\n _nativeTriggerCollisionValueToCollisionType(type) {\n switch (type) {\n case 8:\n return \"TRIGGER_ENTERED\" /* PhysicsEventType.TRIGGER_ENTERED */;\n case 16:\n return \"TRIGGER_EXITED\" /* PhysicsEventType.TRIGGER_EXITED */;\n }\n return \"TRIGGER_ENTERED\" /* PhysicsEventType.TRIGGER_ENTERED */;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAEC,OAAO,QAAQ,+BAA+B;AACvF,SAASC,kBAAkB,QAAS,4BAA4B;AAChE,SAASC,MAAM,QAAQ,yBAAyB;AAChD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,WAAW,QAAQ,iCAAiC;AAC7D,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,UAAU,QAAQ,6BAA6B;AACxD,SAASC,UAAU,QAAQ,6BAA6B;AACxD,MAAMC,eAAe,CAAC;EAClB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACC,IAAI,EAAEC,cAAc,EAAEC,KAAK,EAAE;IACrC,IAAI,CAACC,SAAS,GAAG,EAAE,CAAC,CAAC;IACrB,IAAI,CAACC,QAAQ,GAAG,EAAE;IAClB,IAAI,CAACC,cAAc,GAAGH,KAAK,CAACI,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