@babylonjs/core 6.26.0 → 6.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Collisions/intersectionInfo.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator.js.map +1 -1
- package/Engines/WebGPU/webgpuBundleList.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.d.ts +3 -4
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +5 -6
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +22 -0
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +26 -0
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +3 -5
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +5 -6
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.d.ts +3 -4
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +5 -6
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
- package/FlowGraph/flowGraphConnection.d.ts +1 -1
- package/FlowGraph/flowGraphConnection.js +2 -1
- package/FlowGraph/flowGraphConnection.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +10 -0
- package/FlowGraph/flowGraphContext.js +14 -0
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.js.map +1 -1
- package/FlowGraph/flowGraphRichTypes.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.js +1 -0
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/Loading/loadingScreen.js.map +1 -1
- package/Materials/Background/backgroundMaterial.d.ts +16 -0
- package/Materials/Background/backgroundMaterial.js +44 -0
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +0 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +6 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +10 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +27 -5
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mergeGeometryBlock.js +16 -4
- package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
- package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.d.ts +5 -0
- package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +3 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/csg.js.map +1 -1
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/meshSimplification.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -1
- package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/v1/physicsEngine.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/bloomEffect.js.map +1 -1
- package/Rendering/boundingBoxRenderer.js +6 -2
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/backgroundFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/backgroundFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js +1 -8
- package/Shaders/ShadersInclude/backgroundUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrHelperFunctions.js +1 -3
- package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
- package/Shaders/background.fragment.js +11 -1
- package/Shaders/background.fragment.js.map +1 -1
- package/Shaders/default.fragment.js +0 -1
- package/Shaders/default.fragment.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.js.map +1 -1
- package/XR/native/nativeXRRenderTarget.js.map +1 -1
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
- package/XR/webXRWebGLLayer.js.map +1 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cannonJSPlugin.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Physics/v1/Plugins/cannonJSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAKxD,gBAAgB;AAChB,MAAM,OAAO,cAAc;IAavB,YAA2B,wBAAiC,IAAI,EAAE,aAAqB,EAAE,EAAE,eAAe,GAAG,MAAM;QAAxF,0BAAqB,GAArB,qBAAqB,CAAgB;QAXzD,SAAI,GAAW,gBAAgB,CAAC;QAC/B,sBAAiB,GAAG,IAAI,KAAK,EAAE,CAAC;QAChC,mBAAc,GAAW,CAAC,GAAG,EAAE,CAAC;QAGhC,oCAA+B,GAAG,IAAI,KAAK,EAAO,CAAC;QACnD,gBAAW,GAAG,IAAI,CAAC;QACnB,mBAAc,GAAe,IAAI,UAAU,EAAE,CAAC;QAqd9C,cAAS,GAAG,IAAI,UAAU,CAAC,CAAC,kBAAkB,EAAE,CAAC,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC;QAC1E,aAAQ,GAAG,IAAI,UAAU,CAAC,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AAC","sourcesContent":["import type { Nullable, FloatArray } from \"../../../types\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport { Vector3, Matrix, Quaternion } from \"../../../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../../../Buffers/buffer\";\r\nimport type { AbstractMesh } from \"../../../Meshes/abstractMesh\";\r\nimport type { IPhysicsEnginePlugin, PhysicsImpostorJoint } from \"../IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnabledObject } from \"../physicsImpostor\";\r\nimport { PhysicsImpostor } from \"../physicsImpostor\";\r\nimport type { IMotorEnabledJoint, DistanceJointData, SpringJointData } from \"../physicsJoint\";\r\nimport { PhysicsJoint } from \"../physicsJoint\";\r\nimport { PhysicsRaycastResult } from \"../../physicsRaycastResult\";\r\nimport type { TransformNode } from \"../../../Meshes/transformNode\";\r\nimport { PhysicsEngine } from \"../physicsEngine\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\n\r\n//declare var require: any;\r\ndeclare let CANNON: any;\r\n\r\n/** @internal */\r\nexport class CannonJSPlugin implements IPhysicsEnginePlugin {\r\n public world: any;\r\n public name: string = \"CannonJSPlugin\";\r\n private _physicsMaterials = new Array();\r\n private _fixedTimeStep: number = 1 / 60;\r\n private _cannonRaycastResult: any;\r\n private _raycastResult: PhysicsRaycastResult;\r\n private _physicsBodiesToRemoveAfterStep = new Array<any>();\r\n private _firstFrame = true;\r\n private _tmpQuaternion: Quaternion = new Quaternion();\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public BJSCANNON: any;\r\n\r\n public constructor(private _useDeltaForWorldStep: boolean = true, iterations: number = 10, cannonInjection = CANNON) {\r\n this.BJSCANNON = cannonInjection;\r\n if (!this.isSupported()) {\r\n Logger.Error(\"CannonJS is not available. Please make sure you included the js file.\");\r\n return;\r\n }\r\n\r\n this._extendNamespace();\r\n\r\n this.world = new this.BJSCANNON.World();\r\n this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();\r\n this.world.solver.iterations = iterations;\r\n this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();\r\n this._raycastResult = new PhysicsRaycastResult();\r\n }\r\n\r\n /**\r\n *\r\n * @returns plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return 1;\r\n }\r\n\r\n public setGravity(gravity: Vector3): void {\r\n const vec = gravity;\r\n this.world.gravity.set(vec.x, vec.y, vec.z);\r\n }\r\n\r\n public setTimeStep(timeStep: number) {\r\n this._fixedTimeStep = timeStep;\r\n }\r\n\r\n public getTimeStep(): number {\r\n return this._fixedTimeStep;\r\n }\r\n\r\n public executeStep(delta: number, impostors: Array<PhysicsImpostor>): void {\r\n // due to cannon's architecture, the first frame's before-step is skipped.\r\n if (this._firstFrame) {\r\n this._firstFrame = false;\r\n for (const impostor of impostors) {\r\n if (!(impostor.type == PhysicsImpostor.HeightmapImpostor || impostor.type === PhysicsImpostor.PlaneImpostor)) {\r\n impostor.beforeStep();\r\n }\r\n }\r\n }\r\n this.world.step(this._useDeltaForWorldStep ? delta : this._fixedTimeStep);\r\n this._removeMarkedPhysicsBodiesFromWorld();\r\n }\r\n\r\n private _removeMarkedPhysicsBodiesFromWorld(): void {\r\n if (this._physicsBodiesToRemoveAfterStep.length > 0) {\r\n this._physicsBodiesToRemoveAfterStep.forEach((physicsBody) => {\r\n if (typeof this.world.removeBody === \"function\") {\r\n this.world.removeBody(physicsBody);\r\n } else {\r\n this.world.remove(physicsBody);\r\n }\r\n });\r\n this._physicsBodiesToRemoveAfterStep.length = 0;\r\n }\r\n }\r\n\r\n public applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n const worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);\r\n const impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);\r\n\r\n impostor.physicsBody.applyImpulse(impulse, worldPoint);\r\n }\r\n\r\n public applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n const worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);\r\n const impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);\r\n\r\n impostor.physicsBody.applyForce(impulse, worldPoint);\r\n }\r\n\r\n public generatePhysicsBody(impostor: PhysicsImpostor) {\r\n // When calling forceUpdate generatePhysicsBody is called again, ensure that the updated body does not instantly collide with removed body\r\n this._removeMarkedPhysicsBodiesFromWorld();\r\n\r\n //parent-child relationship. Does this impostor have a parent impostor?\r\n if (impostor.parent) {\r\n if (impostor.physicsBody) {\r\n this.removePhysicsBody(impostor);\r\n //TODO is that needed?\r\n impostor.forceUpdate();\r\n }\r\n return;\r\n }\r\n\r\n //should a new body be created for this impostor?\r\n if (impostor.isBodyInitRequired()) {\r\n const shape = this._createShape(impostor);\r\n if (!shape) {\r\n Logger.Warn(\"It was not possible to create a physics body for this object.\");\r\n return;\r\n }\r\n\r\n //unregister events if body is being changed\r\n const oldBody = impostor.physicsBody;\r\n if (oldBody) {\r\n this.removePhysicsBody(impostor);\r\n }\r\n\r\n //create the body and material\r\n const material = this._addMaterial(\"mat-\" + impostor.uniqueId, impostor.getParam(\"friction\"), impostor.getParam(\"restitution\"));\r\n\r\n const bodyCreationObject = {\r\n mass: impostor.getParam(\"mass\"),\r\n material: material,\r\n };\r\n // A simple extend, in case native options were used.\r\n const nativeOptions = impostor.getParam(\"nativeOptions\");\r\n for (const key in nativeOptions) {\r\n if (Object.prototype.hasOwnProperty.call(nativeOptions, key)) {\r\n (<any>bodyCreationObject)[key] = nativeOptions[key];\r\n }\r\n }\r\n impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);\r\n impostor.physicsBody.addEventListener(\"collide\", impostor.onCollide);\r\n this.world.addEventListener(\"preStep\", impostor.beforeStep);\r\n this.world.addEventListener(\"postStep\", impostor.afterStep);\r\n impostor.physicsBody.addShape(shape);\r\n if (typeof this.world.addBody === \"function\") {\r\n this.world.addBody(impostor.physicsBody);\r\n } else {\r\n this.world.add(impostor.physicsBody);\r\n }\r\n\r\n //try to keep the body moving in the right direction by taking old properties.\r\n //Should be tested!\r\n if (oldBody) {\r\n [\"force\", \"torque\", \"velocity\", \"angularVelocity\"].forEach(function (param) {\r\n const vec = oldBody[param];\r\n impostor.physicsBody[param].set(vec.x, vec.y, vec.z);\r\n });\r\n }\r\n this._processChildMeshes(impostor);\r\n }\r\n\r\n //now update the body's transformation\r\n this._updatePhysicsBodyTransformation(impostor);\r\n }\r\n\r\n private _processChildMeshes(mainImpostor: PhysicsImpostor) {\r\n const meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];\r\n const mainRotation: Nullable<Quaternion> = mainImpostor.object.rotationQuaternion;\r\n if (mainRotation) {\r\n mainRotation.conjugateToRef(this._tmpQuaternion);\r\n } else {\r\n this._tmpQuaternion.set(0, 0, 0, 1);\r\n }\r\n\r\n if (meshChildren.length) {\r\n const processMesh = (mesh: AbstractMesh) => {\r\n if (!mesh.rotationQuaternion) {\r\n return;\r\n }\r\n\r\n const childImpostor = mesh.getPhysicsImpostor();\r\n if (childImpostor) {\r\n const parent = childImpostor.parent;\r\n if (parent !== mainImpostor && mesh.parent) {\r\n const pPosition = mesh.getAbsolutePosition().subtract((mesh.parent as TransformNode).getAbsolutePosition());\r\n const q = mesh.rotationQuaternion.multiply(this._tmpQuaternion);\r\n\r\n if (childImpostor.physicsBody) {\r\n this.removePhysicsBody(childImpostor);\r\n childImpostor.physicsBody = null;\r\n }\r\n childImpostor.parent = mainImpostor;\r\n childImpostor.resetUpdateFlags();\r\n mainImpostor.physicsBody.addShape(\r\n this._createShape(childImpostor),\r\n new this.BJSCANNON.Vec3(pPosition.x, pPosition.y, pPosition.z),\r\n new this.BJSCANNON.Quaternion(q.x, q.y, q.z, q.w)\r\n );\r\n //Add the mass of the children.\r\n mainImpostor.physicsBody.mass += childImpostor.getParam(\"mass\");\r\n }\r\n }\r\n mesh.getChildMeshes(true)\r\n .filter((m) => !!m.physicsImpostor)\r\n .forEach(processMesh);\r\n };\r\n meshChildren.filter((m) => !!m.physicsImpostor).forEach(processMesh);\r\n }\r\n }\r\n\r\n public removePhysicsBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.removeEventListener(\"collide\", impostor.onCollide);\r\n this.world.removeEventListener(\"preStep\", impostor.beforeStep);\r\n this.world.removeEventListener(\"postStep\", impostor.afterStep);\r\n\r\n // Only remove the physics body after the physics step to avoid disrupting cannon's internal state\r\n if (this._physicsBodiesToRemoveAfterStep.indexOf(impostor.physicsBody) === -1) {\r\n this._physicsBodiesToRemoveAfterStep.push(impostor.physicsBody);\r\n }\r\n }\r\n\r\n public generateJoint(impostorJoint: PhysicsImpostorJoint) {\r\n const mainBody = impostorJoint.mainImpostor.physicsBody;\r\n const connectedBody = impostorJoint.connectedImpostor.physicsBody;\r\n if (!mainBody || !connectedBody) {\r\n return;\r\n }\r\n let constraint: any;\r\n const jointData = impostorJoint.joint.jointData;\r\n //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html\r\n const constraintData = {\r\n pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().set(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z) : null,\r\n pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().set(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z) : null,\r\n axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().set(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z) : null,\r\n axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().set(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z) : null,\r\n maxForce: jointData.nativeParams.maxForce,\r\n collideConnected: !!jointData.collision,\r\n };\r\n switch (impostorJoint.joint.type) {\r\n case PhysicsJoint.HingeJoint:\r\n case PhysicsJoint.Hinge2Joint:\r\n constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);\r\n break;\r\n case PhysicsJoint.DistanceJoint:\r\n constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, (<DistanceJointData>jointData).maxDistance || 2);\r\n break;\r\n case PhysicsJoint.SpringJoint: {\r\n const springData = <SpringJointData>jointData;\r\n constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {\r\n restLength: springData.length,\r\n stiffness: springData.stiffness,\r\n damping: springData.damping,\r\n localAnchorA: constraintData.pivotA,\r\n localAnchorB: constraintData.pivotB,\r\n });\r\n break;\r\n }\r\n case PhysicsJoint.LockJoint:\r\n constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);\r\n break;\r\n case PhysicsJoint.PointToPointJoint:\r\n case PhysicsJoint.BallAndSocketJoint:\r\n default:\r\n constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);\r\n break;\r\n }\r\n //set the collideConnected flag after the creation, since DistanceJoint ignores it.\r\n constraint.collideConnected = !!jointData.collision;\r\n impostorJoint.joint.physicsJoint = constraint;\r\n //don't add spring as constraint, as it is not one.\r\n if (impostorJoint.joint.type !== PhysicsJoint.SpringJoint) {\r\n this.world.addConstraint(constraint);\r\n } else {\r\n (<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback =\r\n (<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback ||\r\n function () {\r\n constraint.applyForce();\r\n };\r\n impostorJoint.mainImpostor.registerAfterPhysicsStep((<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback);\r\n }\r\n }\r\n\r\n public removeJoint(impostorJoint: PhysicsImpostorJoint) {\r\n if (impostorJoint.joint.type !== PhysicsJoint.SpringJoint) {\r\n this.world.removeConstraint(impostorJoint.joint.physicsJoint);\r\n } else {\r\n impostorJoint.mainImpostor.unregisterAfterPhysicsStep((<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback);\r\n }\r\n }\r\n\r\n private _addMaterial(name: string, friction: number, restitution: number) {\r\n let index;\r\n let mat;\r\n\r\n for (index = 0; index < this._physicsMaterials.length; index++) {\r\n mat = this._physicsMaterials[index];\r\n\r\n if (mat.friction === friction && mat.restitution === restitution) {\r\n return mat;\r\n }\r\n }\r\n\r\n const currentMat = new this.BJSCANNON.Material(name);\r\n currentMat.friction = friction;\r\n currentMat.restitution = restitution;\r\n\r\n this._physicsMaterials.push(currentMat);\r\n return currentMat;\r\n }\r\n\r\n private _checkWithEpsilon(value: number): number {\r\n return value < Epsilon ? Epsilon : value;\r\n }\r\n\r\n private _createShape(impostor: PhysicsImpostor) {\r\n const object = impostor.object;\r\n\r\n let returnValue;\r\n const impostorExtents = impostor.getObjectExtents();\r\n switch (impostor.type) {\r\n case PhysicsImpostor.SphereImpostor: {\r\n const radiusX = impostorExtents.x;\r\n const radiusY = impostorExtents.y;\r\n const radiusZ = impostorExtents.z;\r\n\r\n returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);\r\n\r\n break;\r\n }\r\n //TMP also for cylinder - TODO Cannon supports cylinder natively.\r\n case PhysicsImpostor.CylinderImpostor: {\r\n let nativeParams = impostor.getParam(\"nativeOptions\");\r\n if (!nativeParams) {\r\n nativeParams = {};\r\n }\r\n const radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(impostorExtents.x) / 2;\r\n const radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(impostorExtents.x) / 2;\r\n const height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(impostorExtents.y);\r\n const numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;\r\n returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);\r\n\r\n // Rotate 90 degrees as this shape is horizontal in cannon\r\n const quat = new this.BJSCANNON.Quaternion();\r\n quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);\r\n const translation = new this.BJSCANNON.Vec3(0, 0, 0);\r\n returnValue.transformAllPoints(translation, quat);\r\n break;\r\n }\r\n case PhysicsImpostor.BoxImpostor: {\r\n const box = impostorExtents.scale(0.5);\r\n returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));\r\n break;\r\n }\r\n case PhysicsImpostor.PlaneImpostor:\r\n Logger.Warn(\"Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead\");\r\n returnValue = new this.BJSCANNON.Plane();\r\n break;\r\n case PhysicsImpostor.MeshImpostor: {\r\n // should transform the vertex data to world coordinates!!\r\n const rawVerts = object.getVerticesData ? object.getVerticesData(VertexBuffer.PositionKind) : [];\r\n const rawFaces = object.getIndices ? object.getIndices() : [];\r\n if (!rawVerts) {\r\n Logger.Warn(\"Tried to create a MeshImpostor for an object without vertices. This will fail.\");\r\n return;\r\n }\r\n // get only scale! so the object could transform correctly.\r\n const oldPosition = object.position.clone();\r\n const oldRotation = object.rotation && object.rotation.clone();\r\n const oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();\r\n object.position.copyFromFloats(0, 0, 0);\r\n object.rotation && object.rotation.copyFromFloats(0, 0, 0);\r\n object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());\r\n\r\n object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();\r\n\r\n const transform = object.computeWorldMatrix(true);\r\n // convert rawVerts to object space\r\n const transformedVertices = new Array<number>();\r\n let index: number;\r\n for (index = 0; index < rawVerts.length; index += 3) {\r\n Vector3.TransformCoordinates(Vector3.FromArray(rawVerts, index), transform).toArray(transformedVertices, index);\r\n }\r\n\r\n Logger.Warn(\"MeshImpostor only collides against spheres.\");\r\n returnValue = new this.BJSCANNON.Trimesh(transformedVertices, <number[]>rawFaces);\r\n //now set back the transformation!\r\n object.position.copyFrom(oldPosition);\r\n oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);\r\n oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);\r\n break;\r\n }\r\n case PhysicsImpostor.HeightmapImpostor: {\r\n const oldPosition2 = object.position.clone();\r\n const oldRotation2 = object.rotation && object.rotation.clone();\r\n const oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();\r\n object.position.copyFromFloats(0, 0, 0);\r\n object.rotation && object.rotation.copyFromFloats(0, 0, 0);\r\n object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());\r\n object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();\r\n object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);\r\n\r\n returnValue = this._createHeightmap(object);\r\n object.position.copyFrom(oldPosition2);\r\n oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);\r\n oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);\r\n object.computeWorldMatrix(true);\r\n break;\r\n }\r\n case PhysicsImpostor.ParticleImpostor:\r\n returnValue = new this.BJSCANNON.Particle();\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));\r\n break;\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n private _createHeightmap(object: IPhysicsEnabledObject, pointDepth?: number) {\r\n let pos = <FloatArray>object.getVerticesData(VertexBuffer.PositionKind);\r\n const transform = object.computeWorldMatrix(true);\r\n // convert rawVerts to object space\r\n const transformedVertices = new Array<number>();\r\n let index: number;\r\n for (index = 0; index < pos.length; index += 3) {\r\n Vector3.TransformCoordinates(Vector3.FromArray(pos, index), transform).toArray(transformedVertices, index);\r\n }\r\n pos = transformedVertices;\r\n const matrix = new Array<Array<any>>();\r\n\r\n //For now pointDepth will not be used and will be automatically calculated.\r\n //Future reference - try and find the best place to add a reference to the pointDepth variable.\r\n const arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);\r\n const boundingInfo = object.getBoundingInfo();\r\n const dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);\r\n const minY = boundingInfo.boundingBox.extendSizeWorld.z;\r\n\r\n const elementSize = (dim * 2) / arraySize;\r\n\r\n for (let i = 0; i < pos.length; i = i + 3) {\r\n const x = Math.round(pos[i + 0] / elementSize + arraySize / 2);\r\n const z = Math.round((pos[i + 1] / elementSize - arraySize / 2) * -1);\r\n const y = -pos[i + 2] + minY;\r\n if (!matrix[x]) {\r\n matrix[x] = [];\r\n }\r\n if (!matrix[x][z]) {\r\n matrix[x][z] = y;\r\n }\r\n matrix[x][z] = Math.max(y, matrix[x][z]);\r\n }\r\n\r\n for (let x = 0; x <= arraySize; ++x) {\r\n if (!matrix[x]) {\r\n let loc = 1;\r\n while (!matrix[(x + loc) % arraySize]) {\r\n loc++;\r\n }\r\n matrix[x] = matrix[(x + loc) % arraySize].slice();\r\n //console.log(\"missing x\", x);\r\n }\r\n for (let z = 0; z <= arraySize; ++z) {\r\n if (!matrix[x][z]) {\r\n let loc = 1;\r\n let newValue;\r\n while (newValue === undefined) {\r\n newValue = matrix[x][(z + loc++) % arraySize];\r\n }\r\n matrix[x][z] = newValue;\r\n }\r\n }\r\n }\r\n\r\n const shape = new this.BJSCANNON.Heightfield(matrix, {\r\n elementSize: elementSize,\r\n });\r\n\r\n //For future reference, needed for body transformation\r\n shape.minY = minY;\r\n\r\n return shape;\r\n }\r\n\r\n private _minus90X = new Quaternion(-0.7071067811865475, 0, 0, 0.7071067811865475);\r\n private _plus90X = new Quaternion(0.7071067811865475, 0, 0, 0.7071067811865475);\r\n private _tmpPosition: Vector3 = Vector3.Zero();\r\n private _tmpDeltaPosition: Vector3 = Vector3.Zero();\r\n private _tmpUnityRotation: Quaternion = new Quaternion();\r\n\r\n private _updatePhysicsBodyTransformation(impostor: PhysicsImpostor) {\r\n const object = impostor.object;\r\n //make sure it is updated...\r\n object.computeWorldMatrix && object.computeWorldMatrix(true);\r\n if (!object.getBoundingInfo()) {\r\n return;\r\n }\r\n const center = impostor.getObjectCenter();\r\n //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)\r\n // The delta between the mesh position and the mesh bounding box center\r\n this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));\r\n this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);\r\n this._tmpPosition.copyFrom(center);\r\n let quaternion = object.rotationQuaternion;\r\n\r\n if (!quaternion) {\r\n return;\r\n }\r\n\r\n //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.\r\n //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron\r\n if (impostor.type === PhysicsImpostor.PlaneImpostor || impostor.type === PhysicsImpostor.HeightmapImpostor) {\r\n //-90 DEG in X, precalculated\r\n quaternion = quaternion.multiply(this._minus90X);\r\n //Invert! (Precalculated, 90 deg in X)\r\n //No need to clone. this will never change.\r\n impostor.setDeltaRotation(this._plus90X);\r\n }\r\n\r\n //If it is a heightfield, if should be centered.\r\n if (impostor.type === PhysicsImpostor.HeightmapImpostor) {\r\n const mesh = <AbstractMesh>(<any>object);\r\n let boundingInfo = mesh.getBoundingInfo();\r\n //calculate the correct body position:\r\n const rotationQuaternion = mesh.rotationQuaternion;\r\n mesh.rotationQuaternion = this._tmpUnityRotation;\r\n mesh.computeWorldMatrix(true);\r\n\r\n //get original center with no rotation\r\n const c = center.clone();\r\n\r\n let oldPivot = mesh.getPivotMatrix();\r\n if (oldPivot) {\r\n // create a copy the pivot Matrix as it is modified in place\r\n oldPivot = oldPivot.clone();\r\n } else {\r\n oldPivot = Matrix.Identity();\r\n }\r\n\r\n //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)\r\n const p = Matrix.Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);\r\n mesh.setPreTransformMatrix(p);\r\n mesh.computeWorldMatrix(true);\r\n // force bounding box recomputation\r\n boundingInfo = mesh.getBoundingInfo();\r\n\r\n //calculate the translation\r\n const translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();\r\n\r\n this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);\r\n //add it inverted to the delta\r\n this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));\r\n this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;\r\n //rotation is back\r\n mesh.rotationQuaternion = rotationQuaternion;\r\n\r\n mesh.setPreTransformMatrix(oldPivot);\r\n mesh.computeWorldMatrix(true);\r\n } else if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n this._tmpDeltaPosition.copyFromFloats(0, 0, 0);\r\n }\r\n\r\n impostor.setDeltaPosition(this._tmpDeltaPosition);\r\n //Now update the impostor object\r\n impostor.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z);\r\n impostor.physicsBody.quaternion.set(quaternion.x, quaternion.y, quaternion.z, quaternion.w);\r\n }\r\n\r\n public setTransformationFromPhysicsBody(impostor: PhysicsImpostor) {\r\n impostor.object.position.set(impostor.physicsBody.position.x, impostor.physicsBody.position.y, impostor.physicsBody.position.z);\r\n if (impostor.object.rotationQuaternion) {\r\n const q = impostor.physicsBody.quaternion;\r\n impostor.object.rotationQuaternion.set(q.x, q.y, q.z, q.w);\r\n }\r\n }\r\n\r\n public setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion) {\r\n impostor.physicsBody.position.set(newPosition.x, newPosition.y, newPosition.z);\r\n impostor.physicsBody.quaternion.set(newRotation.x, newRotation.y, newRotation.z, newRotation.w);\r\n }\r\n\r\n public isSupported(): boolean {\r\n return this.BJSCANNON !== undefined;\r\n }\r\n\r\n public setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.velocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.angularVelocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.velocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n public getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.angularVelocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n\r\n public setBodyMass(impostor: PhysicsImpostor, mass: number) {\r\n impostor.physicsBody.mass = mass;\r\n impostor.physicsBody.updateMassProperties();\r\n }\r\n\r\n public getBodyMass(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.mass;\r\n }\r\n\r\n public getBodyFriction(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.material.friction;\r\n }\r\n\r\n public setBodyFriction(impostor: PhysicsImpostor, friction: number) {\r\n impostor.physicsBody.material.friction = friction;\r\n }\r\n\r\n public getBodyRestitution(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.material.restitution;\r\n }\r\n\r\n public setBodyRestitution(impostor: PhysicsImpostor, restitution: number) {\r\n impostor.physicsBody.material.restitution = restitution;\r\n }\r\n\r\n public sleepBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.sleep();\r\n }\r\n\r\n public wakeUpBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.wakeUp();\r\n }\r\n\r\n public updateDistanceJoint(joint: PhysicsJoint, maxDistance: number) {\r\n joint.physicsJoint.distance = maxDistance;\r\n }\r\n\r\n public setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number) {\r\n if (!motorIndex) {\r\n joint.physicsJoint.enableMotor();\r\n joint.physicsJoint.setMotorSpeed(speed);\r\n if (maxForce) {\r\n this.setLimit(joint, maxForce);\r\n }\r\n }\r\n }\r\n\r\n public setLimit(joint: IMotorEnabledJoint, minForce: number, maxForce?: number) {\r\n joint.physicsJoint.motorEquation.maxForce = maxForce;\r\n joint.physicsJoint.motorEquation.minForce = minForce === void 0 ? -minForce : minForce;\r\n }\r\n\r\n public syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor) {\r\n const body = impostor.physicsBody;\r\n\r\n mesh.position.x = body.position.x;\r\n mesh.position.y = body.position.y;\r\n mesh.position.z = body.position.z;\r\n\r\n if (mesh.rotationQuaternion) {\r\n mesh.rotationQuaternion.x = body.quaternion.x;\r\n mesh.rotationQuaternion.y = body.quaternion.y;\r\n mesh.rotationQuaternion.z = body.quaternion.z;\r\n mesh.rotationQuaternion.w = body.quaternion.w;\r\n }\r\n }\r\n\r\n public getRadius(impostor: PhysicsImpostor): number {\r\n const shape = impostor.physicsBody.shapes[0];\r\n return shape.boundingSphereRadius;\r\n }\r\n\r\n public getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void {\r\n const shape = impostor.physicsBody.shapes[0];\r\n result.x = shape.halfExtents.x * 2;\r\n result.y = shape.halfExtents.y * 2;\r\n result.z = shape.halfExtents.z * 2;\r\n }\r\n\r\n public dispose() {}\r\n\r\n private _extendNamespace() {\r\n //this will force cannon to execute at least one step when using interpolation\r\n const step_tmp1 = new this.BJSCANNON.Vec3();\r\n const engine = this.BJSCANNON;\r\n this.BJSCANNON.World.prototype.step = function (dt: number, timeSinceLastCalled: number, maxSubSteps: number) {\r\n maxSubSteps = maxSubSteps || 10;\r\n timeSinceLastCalled = timeSinceLastCalled || 0;\r\n if (timeSinceLastCalled === 0) {\r\n this.internalStep(dt);\r\n this.time += dt;\r\n } else {\r\n let internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);\r\n internalSteps = Math.min(internalSteps, maxSubSteps) || 1;\r\n const t0 = performance.now();\r\n for (let i = 0; i !== internalSteps; i++) {\r\n this.internalStep(dt);\r\n if (performance.now() - t0 > dt * 1000) {\r\n break;\r\n }\r\n }\r\n this.time += timeSinceLastCalled;\r\n const h = this.time % dt;\r\n const h_div_dt = h / dt;\r\n const interpvelo = step_tmp1;\r\n const bodies = this.bodies;\r\n for (let j = 0; j !== bodies.length; j++) {\r\n const b = bodies[j];\r\n if (b.type !== engine.Body.STATIC && b.sleepState !== engine.Body.SLEEPING) {\r\n b.position.vsub(b.previousPosition, interpvelo);\r\n interpvelo.scale(h_div_dt, interpvelo);\r\n b.position.vadd(interpvelo, b.interpolatedPosition);\r\n } else {\r\n b.interpolatedPosition.set(b.position.x, b.position.y, b.position.z);\r\n b.interpolatedQuaternion.set(b.quaternion.x, b.quaternion.y, b.quaternion.z, b.quaternion.w);\r\n }\r\n }\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n this._raycastResult.reset(from, to);\r\n this.raycastToRef(from, to, this._raycastResult);\r\n return this._raycastResult;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n this._cannonRaycastResult.reset();\r\n this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);\r\n\r\n result.reset(from, to);\r\n if (this._cannonRaycastResult.hasHit) {\r\n // TODO: do we also want to get the body it hit?\r\n result.setHitData(\r\n {\r\n x: this._cannonRaycastResult.hitNormalWorld.x,\r\n y: this._cannonRaycastResult.hitNormalWorld.y,\r\n z: this._cannonRaycastResult.hitNormalWorld.z,\r\n },\r\n {\r\n x: this._cannonRaycastResult.hitPointWorld.x,\r\n y: this._cannonRaycastResult.hitPointWorld.y,\r\n z: this._cannonRaycastResult.hitPointWorld.z,\r\n }\r\n );\r\n result.setHitDistance(this._cannonRaycastResult.distance);\r\n }\r\n }\r\n}\r\n\r\nPhysicsEngine.DefaultPluginFactory = () => {\r\n return new CannonJSPlugin();\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"cannonJSPlugin.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Physics/v1/Plugins/cannonJSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAKxD,gBAAgB;AAChB,MAAM,OAAO,cAAc;IAavB,YACY,wBAAiC,IAAI,EAC7C,aAAqB,EAAE,EACvB,eAAe,GAAG,MAAM;QAFhB,0BAAqB,GAArB,qBAAqB,CAAgB;QAZ1C,SAAI,GAAW,gBAAgB,CAAC;QAC/B,sBAAiB,GAAG,IAAI,KAAK,EAAE,CAAC;QAChC,mBAAc,GAAW,CAAC,GAAG,EAAE,CAAC;QAGhC,oCAA+B,GAAG,IAAI,KAAK,EAAO,CAAC;QACnD,gBAAW,GAAG,IAAI,CAAC;QACnB,mBAAc,GAAe,IAAI,UAAU,EAAE,CAAC;QAyd9C,cAAS,GAAG,IAAI,UAAU,CAAC,CAAC,kBAAkB,EAAE,CAAC,EAAE,CAAC,EAAE,kBAAkB,CAAC,C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OAAO,IAAI,cAAc,EAAE,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import type { Nullable, FloatArray } from \"../../../types\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport { Vector3, Matrix, Quaternion } from \"../../../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../../../Buffers/buffer\";\r\nimport type { AbstractMesh } from \"../../../Meshes/abstractMesh\";\r\nimport type { IPhysicsEnginePlugin, PhysicsImpostorJoint } from \"../IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnabledObject } from \"../physicsImpostor\";\r\nimport { PhysicsImpostor } from \"../physicsImpostor\";\r\nimport type { IMotorEnabledJoint, DistanceJointData, SpringJointData } from \"../physicsJoint\";\r\nimport { PhysicsJoint } from \"../physicsJoint\";\r\nimport { PhysicsRaycastResult } from \"../../physicsRaycastResult\";\r\nimport type { TransformNode } from \"../../../Meshes/transformNode\";\r\nimport { PhysicsEngine } from \"../physicsEngine\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\n\r\n//declare var require: any;\r\ndeclare let CANNON: any;\r\n\r\n/** @internal */\r\nexport class CannonJSPlugin implements IPhysicsEnginePlugin {\r\n public world: any;\r\n public name: string = \"CannonJSPlugin\";\r\n private _physicsMaterials = new Array();\r\n private _fixedTimeStep: number = 1 / 60;\r\n private _cannonRaycastResult: any;\r\n private _raycastResult: PhysicsRaycastResult;\r\n private _physicsBodiesToRemoveAfterStep = new Array<any>();\r\n private _firstFrame = true;\r\n private _tmpQuaternion: Quaternion = new Quaternion();\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public BJSCANNON: any;\r\n\r\n public constructor(\r\n private _useDeltaForWorldStep: boolean = true,\r\n iterations: number = 10,\r\n cannonInjection = CANNON\r\n ) {\r\n this.BJSCANNON = cannonInjection;\r\n if (!this.isSupported()) {\r\n Logger.Error(\"CannonJS is not available. Please make sure you included the js file.\");\r\n return;\r\n }\r\n\r\n this._extendNamespace();\r\n\r\n this.world = new this.BJSCANNON.World();\r\n this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();\r\n this.world.solver.iterations = iterations;\r\n this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();\r\n this._raycastResult = new PhysicsRaycastResult();\r\n }\r\n\r\n /**\r\n *\r\n * @returns plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return 1;\r\n }\r\n\r\n public setGravity(gravity: Vector3): void {\r\n const vec = gravity;\r\n this.world.gravity.set(vec.x, vec.y, vec.z);\r\n }\r\n\r\n public setTimeStep(timeStep: number) {\r\n this._fixedTimeStep = timeStep;\r\n }\r\n\r\n public getTimeStep(): number {\r\n return this._fixedTimeStep;\r\n }\r\n\r\n public executeStep(delta: number, impostors: Array<PhysicsImpostor>): void {\r\n // due to cannon's architecture, the first frame's before-step is skipped.\r\n if (this._firstFrame) {\r\n this._firstFrame = false;\r\n for (const impostor of impostors) {\r\n if (!(impostor.type == PhysicsImpostor.HeightmapImpostor || impostor.type === PhysicsImpostor.PlaneImpostor)) {\r\n impostor.beforeStep();\r\n }\r\n }\r\n }\r\n this.world.step(this._useDeltaForWorldStep ? delta : this._fixedTimeStep);\r\n this._removeMarkedPhysicsBodiesFromWorld();\r\n }\r\n\r\n private _removeMarkedPhysicsBodiesFromWorld(): void {\r\n if (this._physicsBodiesToRemoveAfterStep.length > 0) {\r\n this._physicsBodiesToRemoveAfterStep.forEach((physicsBody) => {\r\n if (typeof this.world.removeBody === \"function\") {\r\n this.world.removeBody(physicsBody);\r\n } else {\r\n this.world.remove(physicsBody);\r\n }\r\n });\r\n this._physicsBodiesToRemoveAfterStep.length = 0;\r\n }\r\n }\r\n\r\n public applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n const worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);\r\n const impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);\r\n\r\n impostor.physicsBody.applyImpulse(impulse, worldPoint);\r\n }\r\n\r\n public applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n const worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);\r\n const impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);\r\n\r\n impostor.physicsBody.applyForce(impulse, worldPoint);\r\n }\r\n\r\n public generatePhysicsBody(impostor: PhysicsImpostor) {\r\n // When calling forceUpdate generatePhysicsBody is called again, ensure that the updated body does not instantly collide with removed body\r\n this._removeMarkedPhysicsBodiesFromWorld();\r\n\r\n //parent-child relationship. Does this impostor have a parent impostor?\r\n if (impostor.parent) {\r\n if (impostor.physicsBody) {\r\n this.removePhysicsBody(impostor);\r\n //TODO is that needed?\r\n impostor.forceUpdate();\r\n }\r\n return;\r\n }\r\n\r\n //should a new body be created for this impostor?\r\n if (impostor.isBodyInitRequired()) {\r\n const shape = this._createShape(impostor);\r\n if (!shape) {\r\n Logger.Warn(\"It was not possible to create a physics body for this object.\");\r\n return;\r\n }\r\n\r\n //unregister events if body is being changed\r\n const oldBody = impostor.physicsBody;\r\n if (oldBody) {\r\n this.removePhysicsBody(impostor);\r\n }\r\n\r\n //create the body and material\r\n const material = this._addMaterial(\"mat-\" + impostor.uniqueId, impostor.getParam(\"friction\"), impostor.getParam(\"restitution\"));\r\n\r\n const bodyCreationObject = {\r\n mass: impostor.getParam(\"mass\"),\r\n material: material,\r\n };\r\n // A simple extend, in case native options were used.\r\n const nativeOptions = impostor.getParam(\"nativeOptions\");\r\n for (const key in nativeOptions) {\r\n if (Object.prototype.hasOwnProperty.call(nativeOptions, key)) {\r\n (<any>bodyCreationObject)[key] = nativeOptions[key];\r\n }\r\n }\r\n impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);\r\n impostor.physicsBody.addEventListener(\"collide\", impostor.onCollide);\r\n this.world.addEventListener(\"preStep\", impostor.beforeStep);\r\n this.world.addEventListener(\"postStep\", impostor.afterStep);\r\n impostor.physicsBody.addShape(shape);\r\n if (typeof this.world.addBody === \"function\") {\r\n this.world.addBody(impostor.physicsBody);\r\n } else {\r\n this.world.add(impostor.physicsBody);\r\n }\r\n\r\n //try to keep the body moving in the right direction by taking old properties.\r\n //Should be tested!\r\n if (oldBody) {\r\n [\"force\", \"torque\", \"velocity\", \"angularVelocity\"].forEach(function (param) {\r\n const vec = oldBody[param];\r\n impostor.physicsBody[param].set(vec.x, vec.y, vec.z);\r\n });\r\n }\r\n this._processChildMeshes(impostor);\r\n }\r\n\r\n //now update the body's transformation\r\n this._updatePhysicsBodyTransformation(impostor);\r\n }\r\n\r\n private _processChildMeshes(mainImpostor: PhysicsImpostor) {\r\n const meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];\r\n const mainRotation: Nullable<Quaternion> = mainImpostor.object.rotationQuaternion;\r\n if (mainRotation) {\r\n mainRotation.conjugateToRef(this._tmpQuaternion);\r\n } else {\r\n this._tmpQuaternion.set(0, 0, 0, 1);\r\n }\r\n\r\n if (meshChildren.length) {\r\n const processMesh = (mesh: AbstractMesh) => {\r\n if (!mesh.rotationQuaternion) {\r\n return;\r\n }\r\n\r\n const childImpostor = mesh.getPhysicsImpostor();\r\n if (childImpostor) {\r\n const parent = childImpostor.parent;\r\n if (parent !== mainImpostor && mesh.parent) {\r\n const pPosition = mesh.getAbsolutePosition().subtract((mesh.parent as TransformNode).getAbsolutePosition());\r\n const q = mesh.rotationQuaternion.multiply(this._tmpQuaternion);\r\n\r\n if (childImpostor.physicsBody) {\r\n this.removePhysicsBody(childImpostor);\r\n childImpostor.physicsBody = null;\r\n }\r\n childImpostor.parent = mainImpostor;\r\n childImpostor.resetUpdateFlags();\r\n mainImpostor.physicsBody.addShape(\r\n this._createShape(childImpostor),\r\n new this.BJSCANNON.Vec3(pPosition.x, pPosition.y, pPosition.z),\r\n new this.BJSCANNON.Quaternion(q.x, q.y, q.z, q.w)\r\n );\r\n //Add the mass of the children.\r\n mainImpostor.physicsBody.mass += childImpostor.getParam(\"mass\");\r\n }\r\n }\r\n mesh.getChildMeshes(true)\r\n .filter((m) => !!m.physicsImpostor)\r\n .forEach(processMesh);\r\n };\r\n meshChildren.filter((m) => !!m.physicsImpostor).forEach(processMesh);\r\n }\r\n }\r\n\r\n public removePhysicsBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.removeEventListener(\"collide\", impostor.onCollide);\r\n this.world.removeEventListener(\"preStep\", impostor.beforeStep);\r\n this.world.removeEventListener(\"postStep\", impostor.afterStep);\r\n\r\n // Only remove the physics body after the physics step to avoid disrupting cannon's internal state\r\n if (this._physicsBodiesToRemoveAfterStep.indexOf(impostor.physicsBody) === -1) {\r\n this._physicsBodiesToRemoveAfterStep.push(impostor.physicsBody);\r\n }\r\n }\r\n\r\n public generateJoint(impostorJoint: PhysicsImpostorJoint) {\r\n const mainBody = impostorJoint.mainImpostor.physicsBody;\r\n const connectedBody = impostorJoint.connectedImpostor.physicsBody;\r\n if (!mainBody || !connectedBody) {\r\n return;\r\n }\r\n let constraint: any;\r\n const jointData = impostorJoint.joint.jointData;\r\n //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html\r\n const constraintData = {\r\n pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().set(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z) : null,\r\n pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().set(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z) : null,\r\n axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().set(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z) : null,\r\n axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().set(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z) : null,\r\n maxForce: jointData.nativeParams.maxForce,\r\n collideConnected: !!jointData.collision,\r\n };\r\n switch (impostorJoint.joint.type) {\r\n case PhysicsJoint.HingeJoint:\r\n case PhysicsJoint.Hinge2Joint:\r\n constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);\r\n break;\r\n case PhysicsJoint.DistanceJoint:\r\n constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, (<DistanceJointData>jointData).maxDistance || 2);\r\n break;\r\n case PhysicsJoint.SpringJoint: {\r\n const springData = <SpringJointData>jointData;\r\n constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {\r\n restLength: springData.length,\r\n stiffness: springData.stiffness,\r\n damping: springData.damping,\r\n localAnchorA: constraintData.pivotA,\r\n localAnchorB: constraintData.pivotB,\r\n });\r\n break;\r\n }\r\n case PhysicsJoint.LockJoint:\r\n constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);\r\n break;\r\n case PhysicsJoint.PointToPointJoint:\r\n case PhysicsJoint.BallAndSocketJoint:\r\n default:\r\n constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);\r\n break;\r\n }\r\n //set the collideConnected flag after the creation, since DistanceJoint ignores it.\r\n constraint.collideConnected = !!jointData.collision;\r\n impostorJoint.joint.physicsJoint = constraint;\r\n //don't add spring as constraint, as it is not one.\r\n if (impostorJoint.joint.type !== PhysicsJoint.SpringJoint) {\r\n this.world.addConstraint(constraint);\r\n } else {\r\n (<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback =\r\n (<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback ||\r\n function () {\r\n constraint.applyForce();\r\n };\r\n impostorJoint.mainImpostor.registerAfterPhysicsStep((<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback);\r\n }\r\n }\r\n\r\n public removeJoint(impostorJoint: PhysicsImpostorJoint) {\r\n if (impostorJoint.joint.type !== PhysicsJoint.SpringJoint) {\r\n this.world.removeConstraint(impostorJoint.joint.physicsJoint);\r\n } else {\r\n impostorJoint.mainImpostor.unregisterAfterPhysicsStep((<SpringJointData>impostorJoint.joint.jointData).forceApplicationCallback);\r\n }\r\n }\r\n\r\n private _addMaterial(name: string, friction: number, restitution: number) {\r\n let index;\r\n let mat;\r\n\r\n for (index = 0; index < this._physicsMaterials.length; index++) {\r\n mat = this._physicsMaterials[index];\r\n\r\n if (mat.friction === friction && mat.restitution === restitution) {\r\n return mat;\r\n }\r\n }\r\n\r\n const currentMat = new this.BJSCANNON.Material(name);\r\n currentMat.friction = friction;\r\n currentMat.restitution = restitution;\r\n\r\n this._physicsMaterials.push(currentMat);\r\n return currentMat;\r\n }\r\n\r\n private _checkWithEpsilon(value: number): number {\r\n return value < Epsilon ? Epsilon : value;\r\n }\r\n\r\n private _createShape(impostor: PhysicsImpostor) {\r\n const object = impostor.object;\r\n\r\n let returnValue;\r\n const impostorExtents = impostor.getObjectExtents();\r\n switch (impostor.type) {\r\n case PhysicsImpostor.SphereImpostor: {\r\n const radiusX = impostorExtents.x;\r\n const radiusY = impostorExtents.y;\r\n const radiusZ = impostorExtents.z;\r\n\r\n returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);\r\n\r\n break;\r\n }\r\n //TMP also for cylinder - TODO Cannon supports cylinder natively.\r\n case PhysicsImpostor.CylinderImpostor: {\r\n let nativeParams = impostor.getParam(\"nativeOptions\");\r\n if (!nativeParams) {\r\n nativeParams = {};\r\n }\r\n const radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(impostorExtents.x) / 2;\r\n const radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(impostorExtents.x) / 2;\r\n const height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(impostorExtents.y);\r\n const numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;\r\n returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);\r\n\r\n // Rotate 90 degrees as this shape is horizontal in cannon\r\n const quat = new this.BJSCANNON.Quaternion();\r\n quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);\r\n const translation = new this.BJSCANNON.Vec3(0, 0, 0);\r\n returnValue.transformAllPoints(translation, quat);\r\n break;\r\n }\r\n case PhysicsImpostor.BoxImpostor: {\r\n const box = impostorExtents.scale(0.5);\r\n returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));\r\n break;\r\n }\r\n case PhysicsImpostor.PlaneImpostor:\r\n Logger.Warn(\"Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead\");\r\n returnValue = new this.BJSCANNON.Plane();\r\n break;\r\n case PhysicsImpostor.MeshImpostor: {\r\n // should transform the vertex data to world coordinates!!\r\n const rawVerts = object.getVerticesData ? object.getVerticesData(VertexBuffer.PositionKind) : [];\r\n const rawFaces = object.getIndices ? object.getIndices() : [];\r\n if (!rawVerts) {\r\n Logger.Warn(\"Tried to create a MeshImpostor for an object without vertices. This will fail.\");\r\n return;\r\n }\r\n // get only scale! so the object could transform correctly.\r\n const oldPosition = object.position.clone();\r\n const oldRotation = object.rotation && object.rotation.clone();\r\n const oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();\r\n object.position.copyFromFloats(0, 0, 0);\r\n object.rotation && object.rotation.copyFromFloats(0, 0, 0);\r\n object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());\r\n\r\n object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();\r\n\r\n const transform = object.computeWorldMatrix(true);\r\n // convert rawVerts to object space\r\n const transformedVertices = new Array<number>();\r\n let index: number;\r\n for (index = 0; index < rawVerts.length; index += 3) {\r\n Vector3.TransformCoordinates(Vector3.FromArray(rawVerts, index), transform).toArray(transformedVertices, index);\r\n }\r\n\r\n Logger.Warn(\"MeshImpostor only collides against spheres.\");\r\n returnValue = new this.BJSCANNON.Trimesh(transformedVertices, <number[]>rawFaces);\r\n //now set back the transformation!\r\n object.position.copyFrom(oldPosition);\r\n oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);\r\n oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);\r\n break;\r\n }\r\n case PhysicsImpostor.HeightmapImpostor: {\r\n const oldPosition2 = object.position.clone();\r\n const oldRotation2 = object.rotation && object.rotation.clone();\r\n const oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();\r\n object.position.copyFromFloats(0, 0, 0);\r\n object.rotation && object.rotation.copyFromFloats(0, 0, 0);\r\n object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());\r\n object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();\r\n object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);\r\n\r\n returnValue = this._createHeightmap(object);\r\n object.position.copyFrom(oldPosition2);\r\n oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);\r\n oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);\r\n object.computeWorldMatrix(true);\r\n break;\r\n }\r\n case PhysicsImpostor.ParticleImpostor:\r\n returnValue = new this.BJSCANNON.Particle();\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));\r\n break;\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n private _createHeightmap(object: IPhysicsEnabledObject, pointDepth?: number) {\r\n let pos = <FloatArray>object.getVerticesData(VertexBuffer.PositionKind);\r\n const transform = object.computeWorldMatrix(true);\r\n // convert rawVerts to object space\r\n const transformedVertices = new Array<number>();\r\n let index: number;\r\n for (index = 0; index < pos.length; index += 3) {\r\n Vector3.TransformCoordinates(Vector3.FromArray(pos, index), transform).toArray(transformedVertices, index);\r\n }\r\n pos = transformedVertices;\r\n const matrix = new Array<Array<any>>();\r\n\r\n //For now pointDepth will not be used and will be automatically calculated.\r\n //Future reference - try and find the best place to add a reference to the pointDepth variable.\r\n const arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);\r\n const boundingInfo = object.getBoundingInfo();\r\n const dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);\r\n const minY = boundingInfo.boundingBox.extendSizeWorld.z;\r\n\r\n const elementSize = (dim * 2) / arraySize;\r\n\r\n for (let i = 0; i < pos.length; i = i + 3) {\r\n const x = Math.round(pos[i + 0] / elementSize + arraySize / 2);\r\n const z = Math.round((pos[i + 1] / elementSize - arraySize / 2) * -1);\r\n const y = -pos[i + 2] + minY;\r\n if (!matrix[x]) {\r\n matrix[x] = [];\r\n }\r\n if (!matrix[x][z]) {\r\n matrix[x][z] = y;\r\n }\r\n matrix[x][z] = Math.max(y, matrix[x][z]);\r\n }\r\n\r\n for (let x = 0; x <= arraySize; ++x) {\r\n if (!matrix[x]) {\r\n let loc = 1;\r\n while (!matrix[(x + loc) % arraySize]) {\r\n loc++;\r\n }\r\n matrix[x] = matrix[(x + loc) % arraySize].slice();\r\n //console.log(\"missing x\", x);\r\n }\r\n for (let z = 0; z <= arraySize; ++z) {\r\n if (!matrix[x][z]) {\r\n let loc = 1;\r\n let newValue;\r\n while (newValue === undefined) {\r\n newValue = matrix[x][(z + loc++) % arraySize];\r\n }\r\n matrix[x][z] = newValue;\r\n }\r\n }\r\n }\r\n\r\n const shape = new this.BJSCANNON.Heightfield(matrix, {\r\n elementSize: elementSize,\r\n });\r\n\r\n //For future reference, needed for body transformation\r\n shape.minY = minY;\r\n\r\n return shape;\r\n }\r\n\r\n private _minus90X = new Quaternion(-0.7071067811865475, 0, 0, 0.7071067811865475);\r\n private _plus90X = new Quaternion(0.7071067811865475, 0, 0, 0.7071067811865475);\r\n private _tmpPosition: Vector3 = Vector3.Zero();\r\n private _tmpDeltaPosition: Vector3 = Vector3.Zero();\r\n private _tmpUnityRotation: Quaternion = new Quaternion();\r\n\r\n private _updatePhysicsBodyTransformation(impostor: PhysicsImpostor) {\r\n const object = impostor.object;\r\n //make sure it is updated...\r\n object.computeWorldMatrix && object.computeWorldMatrix(true);\r\n if (!object.getBoundingInfo()) {\r\n return;\r\n }\r\n const center = impostor.getObjectCenter();\r\n //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)\r\n // The delta between the mesh position and the mesh bounding box center\r\n this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));\r\n this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);\r\n this._tmpPosition.copyFrom(center);\r\n let quaternion = object.rotationQuaternion;\r\n\r\n if (!quaternion) {\r\n return;\r\n }\r\n\r\n //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.\r\n //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron\r\n if (impostor.type === PhysicsImpostor.PlaneImpostor || impostor.type === PhysicsImpostor.HeightmapImpostor) {\r\n //-90 DEG in X, precalculated\r\n quaternion = quaternion.multiply(this._minus90X);\r\n //Invert! (Precalculated, 90 deg in X)\r\n //No need to clone. this will never change.\r\n impostor.setDeltaRotation(this._plus90X);\r\n }\r\n\r\n //If it is a heightfield, if should be centered.\r\n if (impostor.type === PhysicsImpostor.HeightmapImpostor) {\r\n const mesh = <AbstractMesh>(<any>object);\r\n let boundingInfo = mesh.getBoundingInfo();\r\n //calculate the correct body position:\r\n const rotationQuaternion = mesh.rotationQuaternion;\r\n mesh.rotationQuaternion = this._tmpUnityRotation;\r\n mesh.computeWorldMatrix(true);\r\n\r\n //get original center with no rotation\r\n const c = center.clone();\r\n\r\n let oldPivot = mesh.getPivotMatrix();\r\n if (oldPivot) {\r\n // create a copy the pivot Matrix as it is modified in place\r\n oldPivot = oldPivot.clone();\r\n } else {\r\n oldPivot = Matrix.Identity();\r\n }\r\n\r\n //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)\r\n const p = Matrix.Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);\r\n mesh.setPreTransformMatrix(p);\r\n mesh.computeWorldMatrix(true);\r\n // force bounding box recomputation\r\n boundingInfo = mesh.getBoundingInfo();\r\n\r\n //calculate the translation\r\n const translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();\r\n\r\n this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);\r\n //add it inverted to the delta\r\n this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));\r\n this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;\r\n //rotation is back\r\n mesh.rotationQuaternion = rotationQuaternion;\r\n\r\n mesh.setPreTransformMatrix(oldPivot);\r\n mesh.computeWorldMatrix(true);\r\n } else if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n this._tmpDeltaPosition.copyFromFloats(0, 0, 0);\r\n }\r\n\r\n impostor.setDeltaPosition(this._tmpDeltaPosition);\r\n //Now update the impostor object\r\n impostor.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z);\r\n impostor.physicsBody.quaternion.set(quaternion.x, quaternion.y, quaternion.z, quaternion.w);\r\n }\r\n\r\n public setTransformationFromPhysicsBody(impostor: PhysicsImpostor) {\r\n impostor.object.position.set(impostor.physicsBody.position.x, impostor.physicsBody.position.y, impostor.physicsBody.position.z);\r\n if (impostor.object.rotationQuaternion) {\r\n const q = impostor.physicsBody.quaternion;\r\n impostor.object.rotationQuaternion.set(q.x, q.y, q.z, q.w);\r\n }\r\n }\r\n\r\n public setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion) {\r\n impostor.physicsBody.position.set(newPosition.x, newPosition.y, newPosition.z);\r\n impostor.physicsBody.quaternion.set(newRotation.x, newRotation.y, newRotation.z, newRotation.w);\r\n }\r\n\r\n public isSupported(): boolean {\r\n return this.BJSCANNON !== undefined;\r\n }\r\n\r\n public setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.velocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.angularVelocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.velocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n public getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.angularVelocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n\r\n public setBodyMass(impostor: PhysicsImpostor, mass: number) {\r\n impostor.physicsBody.mass = mass;\r\n impostor.physicsBody.updateMassProperties();\r\n }\r\n\r\n public getBodyMass(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.mass;\r\n }\r\n\r\n public getBodyFriction(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.material.friction;\r\n }\r\n\r\n public setBodyFriction(impostor: PhysicsImpostor, friction: number) {\r\n impostor.physicsBody.material.friction = friction;\r\n }\r\n\r\n public getBodyRestitution(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.material.restitution;\r\n }\r\n\r\n public setBodyRestitution(impostor: PhysicsImpostor, restitution: number) {\r\n impostor.physicsBody.material.restitution = restitution;\r\n }\r\n\r\n public sleepBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.sleep();\r\n }\r\n\r\n public wakeUpBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.wakeUp();\r\n }\r\n\r\n public updateDistanceJoint(joint: PhysicsJoint, maxDistance: number) {\r\n joint.physicsJoint.distance = maxDistance;\r\n }\r\n\r\n public setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number) {\r\n if (!motorIndex) {\r\n joint.physicsJoint.enableMotor();\r\n joint.physicsJoint.setMotorSpeed(speed);\r\n if (maxForce) {\r\n this.setLimit(joint, maxForce);\r\n }\r\n }\r\n }\r\n\r\n public setLimit(joint: IMotorEnabledJoint, minForce: number, maxForce?: number) {\r\n joint.physicsJoint.motorEquation.maxForce = maxForce;\r\n joint.physicsJoint.motorEquation.minForce = minForce === void 0 ? -minForce : minForce;\r\n }\r\n\r\n public syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor) {\r\n const body = impostor.physicsBody;\r\n\r\n mesh.position.x = body.position.x;\r\n mesh.position.y = body.position.y;\r\n mesh.position.z = body.position.z;\r\n\r\n if (mesh.rotationQuaternion) {\r\n mesh.rotationQuaternion.x = body.quaternion.x;\r\n mesh.rotationQuaternion.y = body.quaternion.y;\r\n mesh.rotationQuaternion.z = body.quaternion.z;\r\n mesh.rotationQuaternion.w = body.quaternion.w;\r\n }\r\n }\r\n\r\n public getRadius(impostor: PhysicsImpostor): number {\r\n const shape = impostor.physicsBody.shapes[0];\r\n return shape.boundingSphereRadius;\r\n }\r\n\r\n public getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void {\r\n const shape = impostor.physicsBody.shapes[0];\r\n result.x = shape.halfExtents.x * 2;\r\n result.y = shape.halfExtents.y * 2;\r\n result.z = shape.halfExtents.z * 2;\r\n }\r\n\r\n public dispose() {}\r\n\r\n private _extendNamespace() {\r\n //this will force cannon to execute at least one step when using interpolation\r\n const step_tmp1 = new this.BJSCANNON.Vec3();\r\n const engine = this.BJSCANNON;\r\n this.BJSCANNON.World.prototype.step = function (dt: number, timeSinceLastCalled: number, maxSubSteps: number) {\r\n maxSubSteps = maxSubSteps || 10;\r\n timeSinceLastCalled = timeSinceLastCalled || 0;\r\n if (timeSinceLastCalled === 0) {\r\n this.internalStep(dt);\r\n this.time += dt;\r\n } else {\r\n let internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);\r\n internalSteps = Math.min(internalSteps, maxSubSteps) || 1;\r\n const t0 = performance.now();\r\n for (let i = 0; i !== internalSteps; i++) {\r\n this.internalStep(dt);\r\n if (performance.now() - t0 > dt * 1000) {\r\n break;\r\n }\r\n }\r\n this.time += timeSinceLastCalled;\r\n const h = this.time % dt;\r\n const h_div_dt = h / dt;\r\n const interpvelo = step_tmp1;\r\n const bodies = this.bodies;\r\n for (let j = 0; j !== bodies.length; j++) {\r\n const b = bodies[j];\r\n if (b.type !== engine.Body.STATIC && b.sleepState !== engine.Body.SLEEPING) {\r\n b.position.vsub(b.previousPosition, interpvelo);\r\n interpvelo.scale(h_div_dt, interpvelo);\r\n b.position.vadd(interpvelo, b.interpolatedPosition);\r\n } else {\r\n b.interpolatedPosition.set(b.position.x, b.position.y, b.position.z);\r\n b.interpolatedQuaternion.set(b.quaternion.x, b.quaternion.y, b.quaternion.z, b.quaternion.w);\r\n }\r\n }\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n this._raycastResult.reset(from, to);\r\n this.raycastToRef(from, to, this._raycastResult);\r\n return this._raycastResult;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n this._cannonRaycastResult.reset();\r\n this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);\r\n\r\n result.reset(from, to);\r\n if (this._cannonRaycastResult.hasHit) {\r\n // TODO: do we also want to get the body it hit?\r\n result.setHitData(\r\n {\r\n x: this._cannonRaycastResult.hitNormalWorld.x,\r\n y: this._cannonRaycastResult.hitNormalWorld.y,\r\n z: this._cannonRaycastResult.hitNormalWorld.z,\r\n },\r\n {\r\n x: this._cannonRaycastResult.hitPointWorld.x,\r\n y: this._cannonRaycastResult.hitPointWorld.y,\r\n z: this._cannonRaycastResult.hitPointWorld.z,\r\n }\r\n );\r\n result.setHitDistance(this._cannonRaycastResult.distance);\r\n }\r\n }\r\n}\r\n\r\nPhysicsEngine.DefaultPluginFactory = () => {\r\n return new CannonJSPlugin();\r\n};\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oimoJSPlugin.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Physics/v1/Plugins/oimoJSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAIxD,gBAAgB;AAChB,MAAM,OAAO,YAAY;IAQrB,YAAoB,wBAAiC,IAAI,EAAE,UAAmB,EAAE,aAAa,GAAG,IAAI;QAAhF,0BAAqB,GAArB,qBAAqB,CAAgB;QANlD,SAAI,GAAW,cAAc,CAAC;QAI7B,mBAAc,GAAW,CAAC,GAAG,EAAE,CAAC;QA+BhC,uBAAkB,GAA2B,EAAE,CAAC;QA8MhD,uBAAkB,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QA1OjD,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAChC,UAAU,EAAE,UAAU;SACzB,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACn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AAU,GAAG,CAAC,CAAC;QAChC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IACnC,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,MAAM,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAE7E,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,MAAM,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAE7E,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import type { IPhysicsEnabledObject } from \"../physicsImpostor\";\r\nimport { PhysicsImpostor } from \"../physicsImpostor\";\r\nimport type { IMotorEnabledJoint, DistanceJointData, SpringJointData } from \"../physicsJoint\";\r\nimport { PhysicsJoint } from \"../physicsJoint\";\r\nimport type { AbstractMesh } from \"../../../Meshes/abstractMesh\";\r\nimport { Vector3, Quaternion } from \"../../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport { PhysicsRaycastResult } from \"../../physicsRaycastResult\";\r\nimport type { IPhysicsEnginePlugin, PhysicsImpostorJoint } from \"../IPhysicsEnginePlugin\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\n\r\ndeclare let OIMO: any;\r\n\r\n/** @internal */\r\nexport class OimoJSPlugin implements IPhysicsEnginePlugin {\r\n public world: any;\r\n public name: string = \"OimoJSPlugin\";\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public BJSOIMO: any;\r\n private _raycastResult: PhysicsRaycastResult;\r\n private _fixedTimeStep: number = 1 / 60;\r\n\r\n constructor(private _useDeltaForWorldStep: boolean = true, iterations?: number, oimoInjection = OIMO) {\r\n this.BJSOIMO = oimoInjection;\r\n this.world = new this.BJSOIMO.World({\r\n iterations: iterations,\r\n });\r\n this.world.clear();\r\n this._raycastResult = new PhysicsRaycastResult();\r\n }\r\n\r\n /**\r\n *\r\n * @returns plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return 1;\r\n }\r\n\r\n public setGravity(gravity: Vector3) {\r\n this.world.gravity.set(gravity.x, gravity.y, gravity.z);\r\n }\r\n\r\n public setTimeStep(timeStep: number) {\r\n this.world.timeStep = timeStep;\r\n }\r\n\r\n public getTimeStep(): number {\r\n return this.world.timeStep;\r\n }\r\n\r\n private _tmpImpostorsArray: Array<PhysicsImpostor> = [];\r\n\r\n public executeStep(delta: number, impostors: Array<PhysicsImpostor>) {\r\n impostors.forEach(function (impostor) {\r\n impostor.beforeStep();\r\n });\r\n\r\n this.world.timeStep = this._useDeltaForWorldStep ? delta : this._fixedTimeStep;\r\n this.world.step();\r\n\r\n impostors.forEach((impostor) => {\r\n impostor.afterStep();\r\n //update the ordered impostors array\r\n this._tmpImpostorsArray[impostor.uniqueId] = impostor;\r\n });\r\n\r\n //check for collisions\r\n let contact = this.world.contacts;\r\n\r\n while (contact !== null) {\r\n if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {\r\n contact = contact.next;\r\n continue;\r\n }\r\n //is this body colliding with any other? get the impostor\r\n const mainImpostor = this._tmpImpostorsArray[+contact.body1.name];\r\n const collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];\r\n\r\n if (!mainImpostor || !collidingImpostor) {\r\n contact = contact.next;\r\n continue;\r\n }\r\n\r\n mainImpostor.onCollide({ body: collidingImpostor.physicsBody, point: null, distance: 0, impulse: 0, normal: null });\r\n collidingImpostor.onCollide({ body: mainImpostor.physicsBody, point: null, distance: 0, impulse: 0, normal: null });\r\n contact = contact.next;\r\n }\r\n }\r\n\r\n public applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n const mass = impostor.physicsBody.mass;\r\n impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));\r\n }\r\n public applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n Logger.Warn(\"Oimo doesn't support applying force. Using impulse instead.\");\r\n this.applyImpulse(impostor, force, contactPoint);\r\n }\r\n public generatePhysicsBody(impostor: PhysicsImpostor) {\r\n //parent-child relationship. Does this impostor has a parent impostor?\r\n if (impostor.parent) {\r\n if (impostor.physicsBody) {\r\n this.removePhysicsBody(impostor);\r\n //TODO is that needed?\r\n impostor.forceUpdate();\r\n }\r\n return;\r\n }\r\n\r\n if (impostor.isBodyInitRequired()) {\r\n const bodyConfig: any = {\r\n name: impostor.uniqueId,\r\n //Oimo must have mass, also for static objects.\r\n config: [impostor.getParam(\"mass\") || 0.001, impostor.getParam(\"friction\"), impostor.getParam(\"restitution\")],\r\n size: [],\r\n type: [],\r\n pos: [],\r\n posShape: [],\r\n rot: [],\r\n rotShape: [],\r\n move: impostor.getParam(\"mass\") !== 0,\r\n density: impostor.getParam(\"mass\"),\r\n friction: impostor.getParam(\"friction\"),\r\n restitution: impostor.getParam(\"restitution\"),\r\n //Supporting older versions of Oimo\r\n world: this.world,\r\n };\r\n\r\n const impostors = [impostor];\r\n const addToArray = (parent: IPhysicsEnabledObject) => {\r\n if (!parent.getChildMeshes) {\r\n return;\r\n }\r\n parent.getChildMeshes().forEach(function (m) {\r\n if (m.physicsImpostor) {\r\n impostors.push(m.physicsImpostor);\r\n //m.physicsImpostor._init();\r\n }\r\n });\r\n };\r\n addToArray(impostor.object);\r\n\r\n const checkWithEpsilon = (value: number): number => {\r\n return Math.max(value, Epsilon);\r\n };\r\n\r\n const globalQuaternion: Quaternion = new Quaternion();\r\n\r\n impostors.forEach((i) => {\r\n if (!i.object.rotationQuaternion) {\r\n return;\r\n }\r\n //get the correct bounding box\r\n const oldQuaternion = i.object.rotationQuaternion;\r\n globalQuaternion.copyFrom(oldQuaternion);\r\n\r\n i.object.rotationQuaternion.set(0, 0, 0, 1);\r\n i.object.computeWorldMatrix(true);\r\n\r\n const rot = globalQuaternion.toEulerAngles();\r\n const impostorExtents = i.getObjectExtents();\r\n\r\n // eslint-disable-next-line no-loss-of-precision\r\n const radToDeg = 57.295779513082320876;\r\n\r\n if (i === impostor) {\r\n const center = impostor.getObjectCenter();\r\n\r\n impostor.object.getAbsolutePivotPoint().subtractToRef(center, this._tmpPositionVector);\r\n this._tmpPositionVector.divideInPlace(impostor.object.scaling);\r\n\r\n //Can also use Array.prototype.push.apply\r\n bodyConfig.pos.push(center.x);\r\n bodyConfig.pos.push(center.y);\r\n bodyConfig.pos.push(center.z);\r\n bodyConfig.posShape.push(0, 0, 0);\r\n\r\n bodyConfig.rotShape.push(0, 0, 0);\r\n } else {\r\n const localPosition = i.object.position.clone();\r\n bodyConfig.posShape.push(localPosition.x);\r\n bodyConfig.posShape.push(localPosition.y);\r\n bodyConfig.posShape.push(localPosition.z);\r\n\r\n // bodyConfig.pos.push(0, 0, 0);\r\n\r\n bodyConfig.rotShape.push(rot.x * radToDeg, rot.y * radToDeg, rot.z * radToDeg);\r\n }\r\n\r\n i.object.rotationQuaternion.copyFrom(globalQuaternion);\r\n\r\n // register mesh\r\n switch (i.type) {\r\n case PhysicsImpostor.ParticleImpostor:\r\n Logger.Warn(\"No Particle support in OIMO.js. using SphereImpostor instead\");\r\n // eslint-disable-next-line no-fallthrough\r\n case PhysicsImpostor.SphereImpostor: {\r\n const radiusX = impostorExtents.x;\r\n const radiusY = impostorExtents.y;\r\n const radiusZ = impostorExtents.z;\r\n\r\n const size = Math.max(checkWithEpsilon(radiusX), checkWithEpsilon(radiusY), checkWithEpsilon(radiusZ)) / 2;\r\n\r\n bodyConfig.type.push(\"sphere\");\r\n //due to the way oimo works with compounds, add 3 times\r\n bodyConfig.size.push(size);\r\n bodyConfig.size.push(size);\r\n bodyConfig.size.push(size);\r\n break;\r\n }\r\n case PhysicsImpostor.CylinderImpostor: {\r\n const sizeX = checkWithEpsilon(impostorExtents.x) / 2;\r\n const sizeY = checkWithEpsilon(impostorExtents.y);\r\n bodyConfig.type.push(\"cylinder\");\r\n bodyConfig.size.push(sizeX);\r\n bodyConfig.size.push(sizeY);\r\n //due to the way oimo works with compounds, add one more value.\r\n bodyConfig.size.push(sizeY);\r\n break;\r\n }\r\n case PhysicsImpostor.PlaneImpostor:\r\n case PhysicsImpostor.BoxImpostor:\r\n default: {\r\n const sizeX = checkWithEpsilon(impostorExtents.x);\r\n const sizeY = checkWithEpsilon(impostorExtents.y);\r\n const sizeZ = checkWithEpsilon(impostorExtents.z);\r\n\r\n bodyConfig.type.push(\"box\");\r\n //if (i === impostor) {\r\n bodyConfig.size.push(sizeX);\r\n bodyConfig.size.push(sizeY);\r\n bodyConfig.size.push(sizeZ);\r\n //} else {\r\n // bodyConfig.size.push(0,0,0);\r\n //}\r\n break;\r\n }\r\n }\r\n\r\n //actually not needed, but hey...\r\n i.object.rotationQuaternion = oldQuaternion;\r\n });\r\n impostor.physicsBody = this.world.add(bodyConfig);\r\n // set the quaternion, ignoring the previously defined (euler) rotation\r\n impostor.physicsBody.resetQuaternion(globalQuaternion);\r\n // update with delta 0, so the body will receive the new rotation.\r\n impostor.physicsBody.updatePosition(0);\r\n } else {\r\n this._tmpPositionVector.copyFromFloats(0, 0, 0);\r\n }\r\n\r\n impostor.setDeltaPosition(this._tmpPositionVector);\r\n\r\n //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);\r\n //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);\r\n }\r\n\r\n private _tmpPositionVector: Vector3 = Vector3.Zero();\r\n\r\n public removePhysicsBody(impostor: PhysicsImpostor) {\r\n //impostor.physicsBody.dispose();\r\n this.world.removeRigidBody(impostor.physicsBody);\r\n }\r\n\r\n public generateJoint(impostorJoint: PhysicsImpostorJoint) {\r\n const mainBody = impostorJoint.mainImpostor.physicsBody;\r\n const connectedBody = impostorJoint.connectedImpostor.physicsBody;\r\n\r\n if (!mainBody || !connectedBody) {\r\n return;\r\n }\r\n const jointData = impostorJoint.joint.jointData;\r\n const options = jointData.nativeParams || {};\r\n let type;\r\n const nativeJointData: any = {\r\n body1: mainBody,\r\n body2: connectedBody,\r\n\r\n axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),\r\n axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),\r\n pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),\r\n pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),\r\n\r\n min: options.min,\r\n max: options.max,\r\n collision: options.collision || jointData.collision,\r\n spring: options.spring,\r\n\r\n //supporting older version of Oimo\r\n world: this.world,\r\n };\r\n switch (impostorJoint.joint.type) {\r\n case PhysicsJoint.BallAndSocketJoint:\r\n type = \"jointBall\";\r\n break;\r\n case PhysicsJoint.SpringJoint: {\r\n Logger.Warn(\"OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead\");\r\n const springData = <SpringJointData>jointData;\r\n nativeJointData.min = springData.length || nativeJointData.min;\r\n //Max should also be set, just make sure it is at least min\r\n nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);\r\n }\r\n // eslint-disable-next-line no-fallthrough\r\n case PhysicsJoint.DistanceJoint:\r\n type = \"jointDistance\";\r\n nativeJointData.max = (<DistanceJointData>jointData).maxDistance;\r\n break;\r\n case PhysicsJoint.PrismaticJoint:\r\n type = \"jointPrisme\";\r\n break;\r\n case PhysicsJoint.SliderJoint:\r\n type = \"jointSlide\";\r\n break;\r\n case PhysicsJoint.WheelJoint:\r\n type = \"jointWheel\";\r\n break;\r\n case PhysicsJoint.HingeJoint:\r\n default:\r\n type = \"jointHinge\";\r\n break;\r\n }\r\n nativeJointData.type = type;\r\n impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);\r\n }\r\n\r\n public removeJoint(impostorJoint: PhysicsImpostorJoint) {\r\n //Bug in Oimo prevents us from disposing a joint in the playground\r\n //joint.joint.physicsJoint.dispose();\r\n //So we will bruteforce it!\r\n try {\r\n this.world.removeJoint(impostorJoint.joint.physicsJoint);\r\n } catch (e) {\r\n Logger.Warn(e);\r\n }\r\n }\r\n\r\n public isSupported(): boolean {\r\n return this.BJSOIMO !== undefined;\r\n }\r\n\r\n public setTransformationFromPhysicsBody(impostor: PhysicsImpostor) {\r\n if (!impostor.physicsBody.sleeping) {\r\n if (impostor.physicsBody.shapes.next) {\r\n let parent = impostor.physicsBody.shapes;\r\n while (parent.next) {\r\n parent = parent.next;\r\n }\r\n impostor.object.position.set(parent.position.x, parent.position.y, parent.position.z);\r\n } else {\r\n const pos = impostor.physicsBody.getPosition();\r\n impostor.object.position.set(pos.x, pos.y, pos.z);\r\n }\r\n\r\n if (impostor.object.rotationQuaternion) {\r\n const quat = impostor.physicsBody.getQuaternion();\r\n impostor.object.rotationQuaternion.set(quat.x, quat.y, quat.z, quat.w);\r\n }\r\n }\r\n }\r\n\r\n public setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion) {\r\n const body = impostor.physicsBody;\r\n // disable bidirectional for compound meshes\r\n if (impostor.physicsBody.shapes.next) {\r\n return;\r\n }\r\n body.position.set(newPosition.x, newPosition.y, newPosition.z);\r\n body.orientation.set(newRotation.x, newRotation.y, newRotation.z, newRotation.w);\r\n body.syncShapes();\r\n body.awake();\r\n }\r\n\r\n /*private _getLastShape(body: any): any {\r\n var lastShape = body.shapes;\r\n while (lastShape.next) {\r\n lastShape = lastShape.next;\r\n }\r\n return lastShape;\r\n }*/\r\n\r\n public setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.linearVelocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.angularVelocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.linearVelocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n public getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.angularVelocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n\r\n public setBodyMass(impostor: PhysicsImpostor, mass: number) {\r\n const staticBody: boolean = mass === 0;\r\n //this will actually set the body's density and not its mass.\r\n //But this is how oimo treats the mass variable.\r\n impostor.physicsBody.shapes.density = staticBody ? 1 : mass;\r\n impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);\r\n }\r\n\r\n public getBodyMass(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.density;\r\n }\r\n\r\n public getBodyFriction(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.friction;\r\n }\r\n\r\n public setBodyFriction(impostor: PhysicsImpostor, friction: number) {\r\n impostor.physicsBody.shapes.friction = friction;\r\n }\r\n\r\n public getBodyRestitution(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.restitution;\r\n }\r\n\r\n public setBodyRestitution(impostor: PhysicsImpostor, restitution: number) {\r\n impostor.physicsBody.shapes.restitution = restitution;\r\n }\r\n\r\n public sleepBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.sleep();\r\n }\r\n\r\n public wakeUpBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.awake();\r\n }\r\n\r\n public updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number) {\r\n joint.physicsJoint.limitMotor.upperLimit = maxDistance;\r\n if (minDistance !== void 0) {\r\n joint.physicsJoint.limitMotor.lowerLimit = minDistance;\r\n }\r\n }\r\n\r\n public setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number) {\r\n if (force !== undefined) {\r\n Logger.Warn(\"OimoJS plugin currently has unexpected behavior when using setMotor with force parameter\");\r\n } else {\r\n force = 1e6;\r\n }\r\n speed *= -1;\r\n\r\n //TODO separate rotational and transational motors.\r\n const motor = motorIndex\r\n ? joint.physicsJoint.rotationalLimitMotor2\r\n : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;\r\n if (motor) {\r\n motor.setMotor(speed, force);\r\n }\r\n }\r\n\r\n public setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number) {\r\n //TODO separate rotational and transational motors.\r\n const motor = motorIndex\r\n ? joint.physicsJoint.rotationalLimitMotor2\r\n : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;\r\n if (motor) {\r\n motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);\r\n }\r\n }\r\n\r\n public syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor) {\r\n const body = impostor.physicsBody;\r\n\r\n mesh.position.x = body.position.x;\r\n mesh.position.y = body.position.y;\r\n mesh.position.z = body.position.z;\r\n\r\n if (mesh.rotationQuaternion) {\r\n mesh.rotationQuaternion.x = body.orientation.x;\r\n mesh.rotationQuaternion.y = body.orientation.y;\r\n mesh.rotationQuaternion.z = body.orientation.z;\r\n mesh.rotationQuaternion.w = body.orientation.w;\r\n }\r\n }\r\n\r\n public getRadius(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.radius;\r\n }\r\n\r\n public getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void {\r\n const shape = impostor.physicsBody.shapes;\r\n result.x = shape.halfWidth * 2;\r\n result.y = shape.halfHeight * 2;\r\n result.z = shape.halfDepth * 2;\r\n }\r\n\r\n public dispose() {\r\n this.world.clear();\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n Logger.Warn(\"raycast is not currently supported by the Oimo physics plugin\");\r\n\r\n this._raycastResult.reset(from, to);\r\n\r\n return this._raycastResult;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n Logger.Warn(\"raycast is not currently supported by the Oimo physics plugin\");\r\n\r\n result.reset(from, to);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"oimoJSPlugin.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Physics/v1/Plugins/oimoJSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAIxD,gBAAgB;AAChB,MAAM,OAAO,YAAY;IAQrB,YACY,wBAAiC,IAAI,EAC7C,UAAmB,EACnB,aAAa,GAAG,IAAI;QAFZ,0BAAqB,GAArB,qBAAqB,CAAgB;QAP1C,SAAI,GAAW,cAAc,CAAC;QAI7B,mBAAc,GAAW,CAAC,GAAG,EAAE,CAAC;QAmChC,uBAAkB,GAA2B,EAAE,CAAC;QA8MhD,uBAAkB,GAAY,OAAO,CAAC,IAAI,E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9C,CAAC;IAEM,eAAe,CAAC,QAAyB,EAAE,MAAe;QAC7D,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC;QAC1C,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;QAChC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IACnC,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,MAAM,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAE7E,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,MAAM,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAE7E,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["import type { IPhysicsEnabledObject } from \"../physicsImpostor\";\r\nimport { PhysicsImpostor } from \"../physicsImpostor\";\r\nimport type { IMotorEnabledJoint, DistanceJointData, SpringJointData } from \"../physicsJoint\";\r\nimport { PhysicsJoint } from \"../physicsJoint\";\r\nimport type { AbstractMesh } from \"../../../Meshes/abstractMesh\";\r\nimport { Vector3, Quaternion } from \"../../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport { PhysicsRaycastResult } from \"../../physicsRaycastResult\";\r\nimport type { IPhysicsEnginePlugin, PhysicsImpostorJoint } from \"../IPhysicsEnginePlugin\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\n\r\ndeclare let OIMO: any;\r\n\r\n/** @internal */\r\nexport class OimoJSPlugin implements IPhysicsEnginePlugin {\r\n public world: any;\r\n public name: string = \"OimoJSPlugin\";\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public BJSOIMO: any;\r\n private _raycastResult: PhysicsRaycastResult;\r\n private _fixedTimeStep: number = 1 / 60;\r\n\r\n constructor(\r\n private _useDeltaForWorldStep: boolean = true,\r\n iterations?: number,\r\n oimoInjection = OIMO\r\n ) {\r\n this.BJSOIMO = oimoInjection;\r\n this.world = new this.BJSOIMO.World({\r\n iterations: iterations,\r\n });\r\n this.world.clear();\r\n this._raycastResult = new PhysicsRaycastResult();\r\n }\r\n\r\n /**\r\n *\r\n * @returns plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return 1;\r\n }\r\n\r\n public setGravity(gravity: Vector3) {\r\n this.world.gravity.set(gravity.x, gravity.y, gravity.z);\r\n }\r\n\r\n public setTimeStep(timeStep: number) {\r\n this.world.timeStep = timeStep;\r\n }\r\n\r\n public getTimeStep(): number {\r\n return this.world.timeStep;\r\n }\r\n\r\n private _tmpImpostorsArray: Array<PhysicsImpostor> = [];\r\n\r\n public executeStep(delta: number, impostors: Array<PhysicsImpostor>) {\r\n impostors.forEach(function (impostor) {\r\n impostor.beforeStep();\r\n });\r\n\r\n this.world.timeStep = this._useDeltaForWorldStep ? delta : this._fixedTimeStep;\r\n this.world.step();\r\n\r\n impostors.forEach((impostor) => {\r\n impostor.afterStep();\r\n //update the ordered impostors array\r\n this._tmpImpostorsArray[impostor.uniqueId] = impostor;\r\n });\r\n\r\n //check for collisions\r\n let contact = this.world.contacts;\r\n\r\n while (contact !== null) {\r\n if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {\r\n contact = contact.next;\r\n continue;\r\n }\r\n //is this body colliding with any other? get the impostor\r\n const mainImpostor = this._tmpImpostorsArray[+contact.body1.name];\r\n const collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];\r\n\r\n if (!mainImpostor || !collidingImpostor) {\r\n contact = contact.next;\r\n continue;\r\n }\r\n\r\n mainImpostor.onCollide({ body: collidingImpostor.physicsBody, point: null, distance: 0, impulse: 0, normal: null });\r\n collidingImpostor.onCollide({ body: mainImpostor.physicsBody, point: null, distance: 0, impulse: 0, normal: null });\r\n contact = contact.next;\r\n }\r\n }\r\n\r\n public applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n const mass = impostor.physicsBody.mass;\r\n impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));\r\n }\r\n public applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {\r\n Logger.Warn(\"Oimo doesn't support applying force. Using impulse instead.\");\r\n this.applyImpulse(impostor, force, contactPoint);\r\n }\r\n public generatePhysicsBody(impostor: PhysicsImpostor) {\r\n //parent-child relationship. Does this impostor has a parent impostor?\r\n if (impostor.parent) {\r\n if (impostor.physicsBody) {\r\n this.removePhysicsBody(impostor);\r\n //TODO is that needed?\r\n impostor.forceUpdate();\r\n }\r\n return;\r\n }\r\n\r\n if (impostor.isBodyInitRequired()) {\r\n const bodyConfig: any = {\r\n name: impostor.uniqueId,\r\n //Oimo must have mass, also for static objects.\r\n config: [impostor.getParam(\"mass\") || 0.001, impostor.getParam(\"friction\"), impostor.getParam(\"restitution\")],\r\n size: [],\r\n type: [],\r\n pos: [],\r\n posShape: [],\r\n rot: [],\r\n rotShape: [],\r\n move: impostor.getParam(\"mass\") !== 0,\r\n density: impostor.getParam(\"mass\"),\r\n friction: impostor.getParam(\"friction\"),\r\n restitution: impostor.getParam(\"restitution\"),\r\n //Supporting older versions of Oimo\r\n world: this.world,\r\n };\r\n\r\n const impostors = [impostor];\r\n const addToArray = (parent: IPhysicsEnabledObject) => {\r\n if (!parent.getChildMeshes) {\r\n return;\r\n }\r\n parent.getChildMeshes().forEach(function (m) {\r\n if (m.physicsImpostor) {\r\n impostors.push(m.physicsImpostor);\r\n //m.physicsImpostor._init();\r\n }\r\n });\r\n };\r\n addToArray(impostor.object);\r\n\r\n const checkWithEpsilon = (value: number): number => {\r\n return Math.max(value, Epsilon);\r\n };\r\n\r\n const globalQuaternion: Quaternion = new Quaternion();\r\n\r\n impostors.forEach((i) => {\r\n if (!i.object.rotationQuaternion) {\r\n return;\r\n }\r\n //get the correct bounding box\r\n const oldQuaternion = i.object.rotationQuaternion;\r\n globalQuaternion.copyFrom(oldQuaternion);\r\n\r\n i.object.rotationQuaternion.set(0, 0, 0, 1);\r\n i.object.computeWorldMatrix(true);\r\n\r\n const rot = globalQuaternion.toEulerAngles();\r\n const impostorExtents = i.getObjectExtents();\r\n\r\n // eslint-disable-next-line no-loss-of-precision\r\n const radToDeg = 57.295779513082320876;\r\n\r\n if (i === impostor) {\r\n const center = impostor.getObjectCenter();\r\n\r\n impostor.object.getAbsolutePivotPoint().subtractToRef(center, this._tmpPositionVector);\r\n this._tmpPositionVector.divideInPlace(impostor.object.scaling);\r\n\r\n //Can also use Array.prototype.push.apply\r\n bodyConfig.pos.push(center.x);\r\n bodyConfig.pos.push(center.y);\r\n bodyConfig.pos.push(center.z);\r\n bodyConfig.posShape.push(0, 0, 0);\r\n\r\n bodyConfig.rotShape.push(0, 0, 0);\r\n } else {\r\n const localPosition = i.object.position.clone();\r\n bodyConfig.posShape.push(localPosition.x);\r\n bodyConfig.posShape.push(localPosition.y);\r\n bodyConfig.posShape.push(localPosition.z);\r\n\r\n // bodyConfig.pos.push(0, 0, 0);\r\n\r\n bodyConfig.rotShape.push(rot.x * radToDeg, rot.y * radToDeg, rot.z * radToDeg);\r\n }\r\n\r\n i.object.rotationQuaternion.copyFrom(globalQuaternion);\r\n\r\n // register mesh\r\n switch (i.type) {\r\n case PhysicsImpostor.ParticleImpostor:\r\n Logger.Warn(\"No Particle support in OIMO.js. using SphereImpostor instead\");\r\n // eslint-disable-next-line no-fallthrough\r\n case PhysicsImpostor.SphereImpostor: {\r\n const radiusX = impostorExtents.x;\r\n const radiusY = impostorExtents.y;\r\n const radiusZ = impostorExtents.z;\r\n\r\n const size = Math.max(checkWithEpsilon(radiusX), checkWithEpsilon(radiusY), checkWithEpsilon(radiusZ)) / 2;\r\n\r\n bodyConfig.type.push(\"sphere\");\r\n //due to the way oimo works with compounds, add 3 times\r\n bodyConfig.size.push(size);\r\n bodyConfig.size.push(size);\r\n bodyConfig.size.push(size);\r\n break;\r\n }\r\n case PhysicsImpostor.CylinderImpostor: {\r\n const sizeX = checkWithEpsilon(impostorExtents.x) / 2;\r\n const sizeY = checkWithEpsilon(impostorExtents.y);\r\n bodyConfig.type.push(\"cylinder\");\r\n bodyConfig.size.push(sizeX);\r\n bodyConfig.size.push(sizeY);\r\n //due to the way oimo works with compounds, add one more value.\r\n bodyConfig.size.push(sizeY);\r\n break;\r\n }\r\n case PhysicsImpostor.PlaneImpostor:\r\n case PhysicsImpostor.BoxImpostor:\r\n default: {\r\n const sizeX = checkWithEpsilon(impostorExtents.x);\r\n const sizeY = checkWithEpsilon(impostorExtents.y);\r\n const sizeZ = checkWithEpsilon(impostorExtents.z);\r\n\r\n bodyConfig.type.push(\"box\");\r\n //if (i === impostor) {\r\n bodyConfig.size.push(sizeX);\r\n bodyConfig.size.push(sizeY);\r\n bodyConfig.size.push(sizeZ);\r\n //} else {\r\n // bodyConfig.size.push(0,0,0);\r\n //}\r\n break;\r\n }\r\n }\r\n\r\n //actually not needed, but hey...\r\n i.object.rotationQuaternion = oldQuaternion;\r\n });\r\n impostor.physicsBody = this.world.add(bodyConfig);\r\n // set the quaternion, ignoring the previously defined (euler) rotation\r\n impostor.physicsBody.resetQuaternion(globalQuaternion);\r\n // update with delta 0, so the body will receive the new rotation.\r\n impostor.physicsBody.updatePosition(0);\r\n } else {\r\n this._tmpPositionVector.copyFromFloats(0, 0, 0);\r\n }\r\n\r\n impostor.setDeltaPosition(this._tmpPositionVector);\r\n\r\n //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);\r\n //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);\r\n }\r\n\r\n private _tmpPositionVector: Vector3 = Vector3.Zero();\r\n\r\n public removePhysicsBody(impostor: PhysicsImpostor) {\r\n //impostor.physicsBody.dispose();\r\n this.world.removeRigidBody(impostor.physicsBody);\r\n }\r\n\r\n public generateJoint(impostorJoint: PhysicsImpostorJoint) {\r\n const mainBody = impostorJoint.mainImpostor.physicsBody;\r\n const connectedBody = impostorJoint.connectedImpostor.physicsBody;\r\n\r\n if (!mainBody || !connectedBody) {\r\n return;\r\n }\r\n const jointData = impostorJoint.joint.jointData;\r\n const options = jointData.nativeParams || {};\r\n let type;\r\n const nativeJointData: any = {\r\n body1: mainBody,\r\n body2: connectedBody,\r\n\r\n axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),\r\n axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),\r\n pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),\r\n pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),\r\n\r\n min: options.min,\r\n max: options.max,\r\n collision: options.collision || jointData.collision,\r\n spring: options.spring,\r\n\r\n //supporting older version of Oimo\r\n world: this.world,\r\n };\r\n switch (impostorJoint.joint.type) {\r\n case PhysicsJoint.BallAndSocketJoint:\r\n type = \"jointBall\";\r\n break;\r\n case PhysicsJoint.SpringJoint: {\r\n Logger.Warn(\"OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead\");\r\n const springData = <SpringJointData>jointData;\r\n nativeJointData.min = springData.length || nativeJointData.min;\r\n //Max should also be set, just make sure it is at least min\r\n nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);\r\n }\r\n // eslint-disable-next-line no-fallthrough\r\n case PhysicsJoint.DistanceJoint:\r\n type = \"jointDistance\";\r\n nativeJointData.max = (<DistanceJointData>jointData).maxDistance;\r\n break;\r\n case PhysicsJoint.PrismaticJoint:\r\n type = \"jointPrisme\";\r\n break;\r\n case PhysicsJoint.SliderJoint:\r\n type = \"jointSlide\";\r\n break;\r\n case PhysicsJoint.WheelJoint:\r\n type = \"jointWheel\";\r\n break;\r\n case PhysicsJoint.HingeJoint:\r\n default:\r\n type = \"jointHinge\";\r\n break;\r\n }\r\n nativeJointData.type = type;\r\n impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);\r\n }\r\n\r\n public removeJoint(impostorJoint: PhysicsImpostorJoint) {\r\n //Bug in Oimo prevents us from disposing a joint in the playground\r\n //joint.joint.physicsJoint.dispose();\r\n //So we will bruteforce it!\r\n try {\r\n this.world.removeJoint(impostorJoint.joint.physicsJoint);\r\n } catch (e) {\r\n Logger.Warn(e);\r\n }\r\n }\r\n\r\n public isSupported(): boolean {\r\n return this.BJSOIMO !== undefined;\r\n }\r\n\r\n public setTransformationFromPhysicsBody(impostor: PhysicsImpostor) {\r\n if (!impostor.physicsBody.sleeping) {\r\n if (impostor.physicsBody.shapes.next) {\r\n let parent = impostor.physicsBody.shapes;\r\n while (parent.next) {\r\n parent = parent.next;\r\n }\r\n impostor.object.position.set(parent.position.x, parent.position.y, parent.position.z);\r\n } else {\r\n const pos = impostor.physicsBody.getPosition();\r\n impostor.object.position.set(pos.x, pos.y, pos.z);\r\n }\r\n\r\n if (impostor.object.rotationQuaternion) {\r\n const quat = impostor.physicsBody.getQuaternion();\r\n impostor.object.rotationQuaternion.set(quat.x, quat.y, quat.z, quat.w);\r\n }\r\n }\r\n }\r\n\r\n public setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion) {\r\n const body = impostor.physicsBody;\r\n // disable bidirectional for compound meshes\r\n if (impostor.physicsBody.shapes.next) {\r\n return;\r\n }\r\n body.position.set(newPosition.x, newPosition.y, newPosition.z);\r\n body.orientation.set(newRotation.x, newRotation.y, newRotation.z, newRotation.w);\r\n body.syncShapes();\r\n body.awake();\r\n }\r\n\r\n /*private _getLastShape(body: any): any {\r\n var lastShape = body.shapes;\r\n while (lastShape.next) {\r\n lastShape = lastShape.next;\r\n }\r\n return lastShape;\r\n }*/\r\n\r\n public setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.linearVelocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3) {\r\n impostor.physicsBody.angularVelocity.set(velocity.x, velocity.y, velocity.z);\r\n }\r\n\r\n public getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.linearVelocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n public getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3> {\r\n const v = impostor.physicsBody.angularVelocity;\r\n if (!v) {\r\n return null;\r\n }\r\n return new Vector3(v.x, v.y, v.z);\r\n }\r\n\r\n public setBodyMass(impostor: PhysicsImpostor, mass: number) {\r\n const staticBody: boolean = mass === 0;\r\n //this will actually set the body's density and not its mass.\r\n //But this is how oimo treats the mass variable.\r\n impostor.physicsBody.shapes.density = staticBody ? 1 : mass;\r\n impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);\r\n }\r\n\r\n public getBodyMass(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.density;\r\n }\r\n\r\n public getBodyFriction(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.friction;\r\n }\r\n\r\n public setBodyFriction(impostor: PhysicsImpostor, friction: number) {\r\n impostor.physicsBody.shapes.friction = friction;\r\n }\r\n\r\n public getBodyRestitution(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.restitution;\r\n }\r\n\r\n public setBodyRestitution(impostor: PhysicsImpostor, restitution: number) {\r\n impostor.physicsBody.shapes.restitution = restitution;\r\n }\r\n\r\n public sleepBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.sleep();\r\n }\r\n\r\n public wakeUpBody(impostor: PhysicsImpostor) {\r\n impostor.physicsBody.awake();\r\n }\r\n\r\n public updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number) {\r\n joint.physicsJoint.limitMotor.upperLimit = maxDistance;\r\n if (minDistance !== void 0) {\r\n joint.physicsJoint.limitMotor.lowerLimit = minDistance;\r\n }\r\n }\r\n\r\n public setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number) {\r\n if (force !== undefined) {\r\n Logger.Warn(\"OimoJS plugin currently has unexpected behavior when using setMotor with force parameter\");\r\n } else {\r\n force = 1e6;\r\n }\r\n speed *= -1;\r\n\r\n //TODO separate rotational and transational motors.\r\n const motor = motorIndex\r\n ? joint.physicsJoint.rotationalLimitMotor2\r\n : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;\r\n if (motor) {\r\n motor.setMotor(speed, force);\r\n }\r\n }\r\n\r\n public setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number) {\r\n //TODO separate rotational and transational motors.\r\n const motor = motorIndex\r\n ? joint.physicsJoint.rotationalLimitMotor2\r\n : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;\r\n if (motor) {\r\n motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);\r\n }\r\n }\r\n\r\n public syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor) {\r\n const body = impostor.physicsBody;\r\n\r\n mesh.position.x = body.position.x;\r\n mesh.position.y = body.position.y;\r\n mesh.position.z = body.position.z;\r\n\r\n if (mesh.rotationQuaternion) {\r\n mesh.rotationQuaternion.x = body.orientation.x;\r\n mesh.rotationQuaternion.y = body.orientation.y;\r\n mesh.rotationQuaternion.z = body.orientation.z;\r\n mesh.rotationQuaternion.w = body.orientation.w;\r\n }\r\n }\r\n\r\n public getRadius(impostor: PhysicsImpostor): number {\r\n return impostor.physicsBody.shapes.radius;\r\n }\r\n\r\n public getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void {\r\n const shape = impostor.physicsBody.shapes;\r\n result.x = shape.halfWidth * 2;\r\n result.y = shape.halfHeight * 2;\r\n result.z = shape.halfDepth * 2;\r\n }\r\n\r\n public dispose() {\r\n this.world.clear();\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n Logger.Warn(\"raycast is not currently supported by the Oimo physics plugin\");\r\n\r\n this._raycastResult.reset(from, to);\r\n\r\n return this._raycastResult;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n Logger.Warn(\"raycast is not currently supported by the Oimo physics plugin\");\r\n\r\n result.reset(from, to);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v1/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAMlD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,aAAa;IActB;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAC9B,MAAM,WAAW,CAAC,gBAAgB,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACH,YAAY,OAA0B,EAA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I,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE;gBACtC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;aAC7B;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,0BAA0B,CAAC,IAAS;QACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,EAAE;gBACzC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;aAC7B;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { PhysicsImpostorJoint, IPhysicsEnginePlugin } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { PhysicsImpostor, IPhysicsEnabledObject } from \"./physicsImpostor\";\r\nimport type { PhysicsJoint } from \"./physicsJoint\";\r\nimport type { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /**\r\n * Global value used to control the smallest number supported by the simulation\r\n */\r\n private _impostors: Array<PhysicsImpostor> = [];\r\n private _joints: Array<PhysicsImpostorJoint> = [];\r\n private _subTimeStep: number = 0;\r\n private _uniqueIdCounter = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePlugin {\r\n throw _WarnImport(\"CannonJSPlugin\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(gravity: Nullable<Vector3>, private _physicsPlugin: IPhysicsEnginePlugin = PhysicsEngine.DefaultPluginFactory()) {\r\n if (!this._physicsPlugin.isSupported()) {\r\n throw new Error(\"Physics Engine \" + this._physicsPlugin.name + \" cannot be found. \" + \"Please make sure it is included.\");\r\n }\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._impostors.forEach(function (impostor) {\r\n impostor.dispose();\r\n });\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n public addImpostor(impostor: PhysicsImpostor) {\r\n this._impostors.push(impostor);\r\n impostor.uniqueId = this._uniqueIdCounter++;\r\n //if no parent, generate the body\r\n if (!impostor.parent) {\r\n this._physicsPlugin.generatePhysicsBody(impostor);\r\n }\r\n }\r\n\r\n /**\r\n * Remove an impostor from the engine.\r\n * This impostor and its mesh will not longer be updated by the physics engine.\r\n * @param impostor the impostor to remove\r\n */\r\n public removeImpostor(impostor: PhysicsImpostor) {\r\n const index = this._impostors.indexOf(impostor);\r\n if (index > -1) {\r\n const removed = this._impostors.splice(index, 1);\r\n //Is it needed?\r\n if (removed.length) {\r\n this.getPhysicsPlugin().removePhysicsBody(impostor);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Add a joint to the physics engine\r\n * @param mainImpostor defines the main impostor to which the joint is added.\r\n * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint\r\n * @param joint defines the joint that will connect both impostors.\r\n */\r\n public addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint) {\r\n const impostorJoint = {\r\n mainImpostor: mainImpostor,\r\n connectedImpostor: connectedImpostor,\r\n joint: joint,\r\n };\r\n joint.physicsPlugin = this._physicsPlugin;\r\n this._joints.push(impostorJoint);\r\n this._physicsPlugin.generateJoint(impostorJoint);\r\n }\r\n\r\n /**\r\n * Removes a joint from the simulation\r\n * @param mainImpostor defines the impostor used with the joint\r\n * @param connectedImpostor defines the other impostor connected to the main one by the joint\r\n * @param joint defines the joint to remove\r\n */\r\n public removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint) {\r\n const matchingJoints = this._joints.filter(function (impostorJoint) {\r\n return impostorJoint.connectedImpostor === connectedImpostor && impostorJoint.joint === joint && impostorJoint.mainImpostor === mainImpostor;\r\n });\r\n if (matchingJoints.length) {\r\n this._physicsPlugin.removeJoint(matchingJoints[0]);\r\n //TODO remove it from the list as well\r\n }\r\n }\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n //check if any mesh has no body / requires an update\r\n this._impostors.forEach((impostor) => {\r\n if (impostor.isBodyInitRequired()) {\r\n this._physicsPlugin.generatePhysicsBody(impostor);\r\n }\r\n });\r\n\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._impostors);\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePlugin {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Gets the list of physic impostors\r\n * @returns an array of PhysicsImpostor\r\n */\r\n public getImpostors(): Array<PhysicsImpostor> {\r\n return this._impostors;\r\n }\r\n\r\n /**\r\n * Gets the impostor for a physics enabled object\r\n * @param object defines the object impersonated by the impostor\r\n * @returns the PhysicsImpostor or null if not found\r\n */\r\n public getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor> {\r\n for (let i = 0; i < this._impostors.length; ++i) {\r\n if (this._impostors[i].object === object) {\r\n return this._impostors[i];\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the impostor for a physics body object\r\n * @param body defines physics body used by the impostor\r\n * @returns the PhysicsImpostor or null if not found\r\n */\r\n public getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor> {\r\n for (let i = 0; i < this._impostors.length; ++i) {\r\n if (this._impostors[i].physicsBody === body) {\r\n return this._impostors[i];\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n return this._physicsPlugin.raycast(from, to);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult) {\r\n return this._physicsPlugin.raycastToRef(from, to, result);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v1/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAMlD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,aAAa;IActB;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CA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AI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,2BAA2B,CAAC,MAA6B;QAC5D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE;gBACtC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;aAC7B;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,0BAA0B,CAAC,IAAS;QACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,EAAE;gBACzC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;aAC7B;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { PhysicsImpostorJoint, IPhysicsEnginePlugin } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { PhysicsImpostor, IPhysicsEnabledObject } from \"./physicsImpostor\";\r\nimport type { PhysicsJoint } from \"./physicsJoint\";\r\nimport type { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /**\r\n * Global value used to control the smallest number supported by the simulation\r\n */\r\n private _impostors: Array<PhysicsImpostor> = [];\r\n private _joints: Array<PhysicsImpostorJoint> = [];\r\n private _subTimeStep: number = 0;\r\n private _uniqueIdCounter = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePlugin {\r\n throw _WarnImport(\"CannonJSPlugin\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(\r\n gravity: Nullable<Vector3>,\r\n private _physicsPlugin: IPhysicsEnginePlugin = PhysicsEngine.DefaultPluginFactory()\r\n ) {\r\n if (!this._physicsPlugin.isSupported()) {\r\n throw new Error(\"Physics Engine \" + this._physicsPlugin.name + \" cannot be found. \" + \"Please make sure it is included.\");\r\n }\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._impostors.forEach(function (impostor) {\r\n impostor.dispose();\r\n });\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n public addImpostor(impostor: PhysicsImpostor) {\r\n this._impostors.push(impostor);\r\n impostor.uniqueId = this._uniqueIdCounter++;\r\n //if no parent, generate the body\r\n if (!impostor.parent) {\r\n this._physicsPlugin.generatePhysicsBody(impostor);\r\n }\r\n }\r\n\r\n /**\r\n * Remove an impostor from the engine.\r\n * This impostor and its mesh will not longer be updated by the physics engine.\r\n * @param impostor the impostor to remove\r\n */\r\n public removeImpostor(impostor: PhysicsImpostor) {\r\n const index = this._impostors.indexOf(impostor);\r\n if (index > -1) {\r\n const removed = this._impostors.splice(index, 1);\r\n //Is it needed?\r\n if (removed.length) {\r\n this.getPhysicsPlugin().removePhysicsBody(impostor);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Add a joint to the physics engine\r\n * @param mainImpostor defines the main impostor to which the joint is added.\r\n * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint\r\n * @param joint defines the joint that will connect both impostors.\r\n */\r\n public addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint) {\r\n const impostorJoint = {\r\n mainImpostor: mainImpostor,\r\n connectedImpostor: connectedImpostor,\r\n joint: joint,\r\n };\r\n joint.physicsPlugin = this._physicsPlugin;\r\n this._joints.push(impostorJoint);\r\n this._physicsPlugin.generateJoint(impostorJoint);\r\n }\r\n\r\n /**\r\n * Removes a joint from the simulation\r\n * @param mainImpostor defines the impostor used with the joint\r\n * @param connectedImpostor defines the other impostor connected to the main one by the joint\r\n * @param joint defines the joint to remove\r\n */\r\n public removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint) {\r\n const matchingJoints = this._joints.filter(function (impostorJoint) {\r\n return impostorJoint.connectedImpostor === connectedImpostor && impostorJoint.joint === joint && impostorJoint.mainImpostor === mainImpostor;\r\n });\r\n if (matchingJoints.length) {\r\n this._physicsPlugin.removeJoint(matchingJoints[0]);\r\n //TODO remove it from the list as well\r\n }\r\n }\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n //check if any mesh has no body / requires an update\r\n this._impostors.forEach((impostor) => {\r\n if (impostor.isBodyInitRequired()) {\r\n this._physicsPlugin.generatePhysicsBody(impostor);\r\n }\r\n });\r\n\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._impostors);\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePlugin {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Gets the list of physic impostors\r\n * @returns an array of PhysicsImpostor\r\n */\r\n public getImpostors(): Array<PhysicsImpostor> {\r\n return this._impostors;\r\n }\r\n\r\n /**\r\n * Gets the impostor for a physics enabled object\r\n * @param object defines the object impersonated by the impostor\r\n * @returns the PhysicsImpostor or null if not found\r\n */\r\n public getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor> {\r\n for (let i = 0; i < this._impostors.length; ++i) {\r\n if (this._impostors[i].object === object) {\r\n return this._impostors[i];\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the impostor for a physics body object\r\n * @param body defines physics body used by the impostor\r\n * @returns the PhysicsImpostor or null if not found\r\n */\r\n public getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor> {\r\n for (let i = 0; i < this._impostors.length; ++i) {\r\n if (this._impostors[i].physicsBody === body) {\r\n return this._impostors[i];\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n return this._physicsPlugin.raycast(from, to);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult) {\r\n return this._physicsPlugin.raycastToRef(from, to, result);\r\n }\r\n}\r\n"]}
|