@babylonjs/core 5.16.0 → 5.18.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/Animations/animatable.js +1 -1
- package/Animations/animatable.js.map +1 -1
- package/Animations/animation.d.ts +8 -1
- package/Animations/animation.js +8 -1
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.js +5 -4
- package/Animations/animationGroup.js.map +1 -1
- package/Bones/skeleton.js +1 -1
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js +2 -2
- package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraKeyboardInput.js +3 -3
- package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js +2 -2
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +3 -3
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/VR/webVRCamera.js +1 -1
- package/Cameras/VR/webVRCamera.js.map +1 -1
- package/Cameras/camera.js +3 -3
- package/Cameras/camera.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +13 -0
- package/Engines/Extensions/engine.views.js +16 -1
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Processors/shaderCodeCursor.js +2 -1
- package/Engines/Processors/shaderCodeCursor.js.map +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
- package/Engines/engine.d.ts +2 -10
- package/Engines/engine.js +0 -14
- package/Engines/engine.js.map +1 -1
- package/Engines/engineFeatures.d.ts +2 -0
- package/Engines/engineFeatures.js.map +1 -1
- package/Engines/nativeEngine.d.ts +6 -2
- package/Engines/nativeEngine.js +13 -6
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +10 -0
- package/Engines/thinEngine.js +26 -6
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +11 -8
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.d.ts +20 -13
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +27 -18
- package/Gizmos/boundingBoxGizmo.js +6 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.d.ts +8 -5
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.d.ts +48 -6
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.d.ts +17 -9
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/lightGizmo.d.ts +12 -7
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.d.ts +10 -8
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +23 -14
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +9 -7
- package/Gizmos/positionGizmo.js +1 -1
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +6 -4
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +15 -12
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Inputs/scene.inputManager.js +0 -3
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Loading/sceneLoader.js +5 -5
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.d.ts +12 -0
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +50 -0
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +18 -0
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +85 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.js +1 -1
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +18 -2
- package/Materials/Node/nodeMaterial.js +56 -27
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +2 -1
- package/Materials/Textures/baseTexture.js +4 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/prePassRenderTarget.js +1 -1
- package/Materials/Textures/prePassRenderTarget.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +11 -3
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/materialDefines.js +3 -1
- package/Materials/materialDefines.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +10 -1
- package/Materials/shaderMaterial.js +10 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.color.d.ts +9 -1
- package/Maths/math.color.js +13 -1
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.vector.d.ts +2 -2
- package/Maths/math.vector.js +18 -30
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/icoSphereBuilder.js +2 -2
- package/Meshes/Builders/icoSphereBuilder.js.map +1 -1
- package/Meshes/Compression/dracoCompression.js +1 -1
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.js +1 -2
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +5 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Misc/basis.js +3 -0
- package/Misc/basis.js.map +1 -1
- package/Misc/fileTools.js +2 -2
- package/Misc/fileTools.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +1 -1
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/smartArray.js +0 -1
- package/Misc/smartArray.js.map +1 -1
- package/Misc/tools.d.ts +2 -2
- package/Misc/tools.js +4 -1
- package/Misc/tools.js.map +1 -1
- package/Offline/database.js +6 -8
- package/Offline/database.js.map +1 -1
- package/Particles/computeShaderParticleSystem.js +2 -2
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/particleHelper.d.ts +12 -1
- package/Particles/particleHelper.js +12 -1
- package/Particles/particleHelper.js.map +1 -1
- package/Particles/particleSystem.js +2 -2
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemSet.js +1 -1
- package/Particles/particleSystemSet.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +3 -0
- package/Particles/solidParticleSystem.js +3 -0
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.js +2 -2
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/Physics/Plugins/ammoJSPlugin.d.ts +2 -2
- package/Physics/Plugins/ammoJSPlugin.js +29 -29
- package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/Plugins/cannonJSPlugin.d.ts +2 -2
- package/Physics/Plugins/cannonJSPlugin.js +26 -26
- package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
- package/Physics/Plugins/oimoJSPlugin.js +9 -11
- package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/physicsImpostor.d.ts +6 -6
- package/Physics/physicsImpostor.js +7 -6
- package/Physics/physicsImpostor.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +3 -3
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/Rendering/utilityLayerRenderer.js +1 -1
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/sprites.fragment.js +1 -1
- package/Shaders/sprites.fragment.js.map +1 -1
- package/Sprites/spriteManager.d.ts +10 -1
- package/Sprites/spriteManager.js +10 -1
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.js +1 -1
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRLayers.js +1 -1
- package/XR/features/WebXRLayers.js.map +1 -1
- package/assetContainer.js +12 -12
- package/assetContainer.js.map +1 -1
- package/node.js +1 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +2 -0
- package/scene.js +15 -8
- package/scene.js.map +1 -1
|
@@ -15,7 +15,7 @@ export declare class CannonJSPlugin implements IPhysicsEnginePlugin {
|
|
|
15
15
|
private _fixedTimeStep;
|
|
16
16
|
private _cannonRaycastResult;
|
|
17
17
|
private _raycastResult;
|
|
18
|
-
private
|
|
18
|
+
private _physicsBodiesToRemoveAfterStep;
|
|
19
19
|
private _firstFrame;
|
|
20
20
|
private _tmpQuaternion;
|
|
21
21
|
BJSCANNON: any;
|
|
@@ -59,7 +59,7 @@ export declare class CannonJSPlugin implements IPhysicsEnginePlugin {
|
|
|
59
59
|
wakeUpBody(impostor: PhysicsImpostor): void;
|
|
60
60
|
updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
|
|
61
61
|
setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
|
|
62
|
-
setLimit(joint: IMotorEnabledJoint,
|
|
62
|
+
setLimit(joint: IMotorEnabledJoint, minForce: number, maxForce?: number): void;
|
|
63
63
|
syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
|
|
64
64
|
getRadius(impostor: PhysicsImpostor): number;
|
|
65
65
|
getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
|
|
@@ -15,7 +15,7 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
15
15
|
this.name = "CannonJSPlugin";
|
|
16
16
|
this._physicsMaterials = new Array();
|
|
17
17
|
this._fixedTimeStep = 1 / 60;
|
|
18
|
-
this.
|
|
18
|
+
this._physicsBodiesToRemoveAfterStep = new Array();
|
|
19
19
|
this._firstFrame = true;
|
|
20
20
|
this._tmpQuaternion = new Quaternion();
|
|
21
21
|
this._minus90X = new Quaternion(-0.7071067811865475, 0, 0, 0.7071067811865475);
|
|
@@ -61,8 +61,8 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
61
61
|
};
|
|
62
62
|
CannonJSPlugin.prototype._removeMarkedPhysicsBodiesFromWorld = function () {
|
|
63
63
|
var _this = this;
|
|
64
|
-
if (this.
|
|
65
|
-
this.
|
|
64
|
+
if (this._physicsBodiesToRemoveAfterStep.length > 0) {
|
|
65
|
+
this._physicsBodiesToRemoveAfterStep.forEach(function (physicsBody) {
|
|
66
66
|
if (typeof _this.world.removeBody === "function") {
|
|
67
67
|
_this.world.removeBody(physicsBody);
|
|
68
68
|
}
|
|
@@ -70,7 +70,7 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
70
70
|
_this.world.remove(physicsBody);
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
-
this.
|
|
73
|
+
this._physicsBodiesToRemoveAfterStep.length = 0;
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
|
|
@@ -86,7 +86,7 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
86
86
|
CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
|
|
87
87
|
// When calling forceUpdate generatePhysicsBody is called again, ensure that the updated body does not instantly collide with removed body
|
|
88
88
|
this._removeMarkedPhysicsBodiesFromWorld();
|
|
89
|
-
//parent-child relationship. Does this impostor
|
|
89
|
+
//parent-child relationship. Does this impostor have a parent impostor?
|
|
90
90
|
if (impostor.parent) {
|
|
91
91
|
if (impostor.physicsBody) {
|
|
92
92
|
this.removePhysicsBody(impostor);
|
|
@@ -102,7 +102,7 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
102
102
|
Logger.Warn("It was not possible to create a physics body for this object.");
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
//unregister events
|
|
105
|
+
//unregister events if body is being changed
|
|
106
106
|
var oldBody_1 = impostor.physicsBody;
|
|
107
107
|
if (oldBody_1) {
|
|
108
108
|
this.removePhysicsBody(impostor);
|
|
@@ -188,8 +188,8 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
188
188
|
this.world.removeEventListener("preStep", impostor.beforeStep);
|
|
189
189
|
this.world.removeEventListener("postStep", impostor.afterStep);
|
|
190
190
|
// Only remove the physics body after the physics step to avoid disrupting cannon's internal state
|
|
191
|
-
if (this.
|
|
192
|
-
this.
|
|
191
|
+
if (this._physicsBodiesToRemoveAfterStep.indexOf(impostor.physicsBody) === -1) {
|
|
192
|
+
this._physicsBodiesToRemoveAfterStep.push(impostor.physicsBody);
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
|
|
@@ -282,12 +282,12 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
282
282
|
CannonJSPlugin.prototype._createShape = function (impostor) {
|
|
283
283
|
var object = impostor.object;
|
|
284
284
|
var returnValue;
|
|
285
|
-
var
|
|
285
|
+
var impostorExtents = impostor.getObjectExtents();
|
|
286
286
|
switch (impostor.type) {
|
|
287
287
|
case PhysicsImpostor.SphereImpostor: {
|
|
288
|
-
var radiusX =
|
|
289
|
-
var radiusY =
|
|
290
|
-
var radiusZ =
|
|
288
|
+
var radiusX = impostorExtents.x;
|
|
289
|
+
var radiusY = impostorExtents.y;
|
|
290
|
+
var radiusZ = impostorExtents.z;
|
|
291
291
|
returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
|
|
292
292
|
break;
|
|
293
293
|
}
|
|
@@ -297,9 +297,9 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
297
297
|
if (!nativeParams) {
|
|
298
298
|
nativeParams = {};
|
|
299
299
|
}
|
|
300
|
-
var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(
|
|
301
|
-
var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(
|
|
302
|
-
var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(
|
|
300
|
+
var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(impostorExtents.x) / 2;
|
|
301
|
+
var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(impostorExtents.x) / 2;
|
|
302
|
+
var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(impostorExtents.y);
|
|
303
303
|
var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
|
|
304
304
|
returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
|
|
305
305
|
// Rotate 90 degrees as this shape is horizontal in cannon
|
|
@@ -310,7 +310,7 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
310
310
|
break;
|
|
311
311
|
}
|
|
312
312
|
case PhysicsImpostor.BoxImpostor: {
|
|
313
|
-
var box =
|
|
313
|
+
var box = impostorExtents.scale(0.5);
|
|
314
314
|
returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
|
|
315
315
|
break;
|
|
316
316
|
}
|
|
@@ -336,13 +336,13 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
336
336
|
object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
|
|
337
337
|
var transform = object.computeWorldMatrix(true);
|
|
338
338
|
// convert rawVerts to object space
|
|
339
|
-
var
|
|
339
|
+
var transformedVertices = new Array();
|
|
340
340
|
var index = void 0;
|
|
341
341
|
for (index = 0; index < rawVerts.length; index += 3) {
|
|
342
|
-
Vector3.TransformCoordinates(Vector3.FromArray(rawVerts, index), transform).toArray(
|
|
342
|
+
Vector3.TransformCoordinates(Vector3.FromArray(rawVerts, index), transform).toArray(transformedVertices, index);
|
|
343
343
|
}
|
|
344
344
|
Logger.Warn("MeshImpostor only collides against spheres.");
|
|
345
|
-
returnValue = new this.BJSCANNON.Trimesh(
|
|
345
|
+
returnValue = new this.BJSCANNON.Trimesh(transformedVertices, rawFaces);
|
|
346
346
|
//now set back the transformation!
|
|
347
347
|
object.position.copyFrom(oldPosition);
|
|
348
348
|
oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
|
|
@@ -378,12 +378,12 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
378
378
|
var pos = object.getVerticesData(VertexBuffer.PositionKind);
|
|
379
379
|
var transform = object.computeWorldMatrix(true);
|
|
380
380
|
// convert rawVerts to object space
|
|
381
|
-
var
|
|
381
|
+
var transformedVertices = new Array();
|
|
382
382
|
var index;
|
|
383
383
|
for (index = 0; index < pos.length; index += 3) {
|
|
384
|
-
Vector3.TransformCoordinates(Vector3.FromArray(pos, index), transform).toArray(
|
|
384
|
+
Vector3.TransformCoordinates(Vector3.FromArray(pos, index), transform).toArray(transformedVertices, index);
|
|
385
385
|
}
|
|
386
|
-
pos =
|
|
386
|
+
pos = transformedVertices;
|
|
387
387
|
var matrix = new Array();
|
|
388
388
|
//For now pointDepth will not be used and will be automatically calculated.
|
|
389
389
|
//Future reference - try and find the best place to add a reference to the pointDepth variable.
|
|
@@ -435,12 +435,12 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
435
435
|
var object = impostor.object;
|
|
436
436
|
//make sure it is updated...
|
|
437
437
|
object.computeWorldMatrix && object.computeWorldMatrix(true);
|
|
438
|
-
// The delta between the mesh position and the mesh bounding box center
|
|
439
438
|
if (!object.getBoundingInfo()) {
|
|
440
439
|
return;
|
|
441
440
|
}
|
|
442
441
|
var center = impostor.getObjectCenter();
|
|
443
442
|
//m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
|
|
443
|
+
// The delta between the mesh position and the mesh bounding box center
|
|
444
444
|
this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
|
|
445
445
|
this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
|
|
446
446
|
this._tmpPosition.copyFrom(center);
|
|
@@ -571,9 +571,9 @@ var CannonJSPlugin = /** @class */ (function () {
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
};
|
|
574
|
-
CannonJSPlugin.prototype.setLimit = function (joint,
|
|
575
|
-
joint.physicsJoint.motorEquation.maxForce =
|
|
576
|
-
joint.physicsJoint.motorEquation.minForce =
|
|
574
|
+
CannonJSPlugin.prototype.setLimit = function (joint, minForce, maxForce) {
|
|
575
|
+
joint.physicsJoint.motorEquation.maxForce = maxForce;
|
|
576
|
+
joint.physicsJoint.motorEquation.minForce = minForce === void 0 ? -minForce : minForce;
|
|
577
577
|
};
|
|
578
578
|
CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
|
|
579
579
|
var body = impostor.physicsBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cannonJSPlugin.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Physics/Plugins/cannonJSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,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AE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAEnE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE;YAClC,gDAAgD;YAChD,IAAI,CAAC,cAAc,CAAC,UAAU,CAC1B;gBACI,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;gBAC7C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;gBAC7C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;aAChD,EACD;gBACI,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;gBAC5C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;gBAC5C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;aAC/C,CACJ,CAAC;YACF,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;SAC1E;QAED,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IACL,qBAAC;AAAD,CAAC,AA1uBD,IA0uBC;;AAED,aAAa,CAAC,oBAAoB,GAAG;IACjC,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 \"../../Physics/IPhysicsEngine\";\r\nimport type { IPhysicsEnabledObject } from \"../../Physics/physicsImpostor\";\r\nimport { PhysicsImpostor } from \"../../Physics/physicsImpostor\";\r\nimport type { IMotorEnabledJoint, DistanceJointData, SpringJointData } from \"../../Physics/physicsJoint\";\r\nimport { PhysicsJoint } from \"../../Physics/physicsJoint\";\r\nimport { PhysicsEngine } from \"../../Physics/physicsEngine\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n//declare var require: any;\r\ndeclare let CANNON: any;\r\n\r\n/** @hidden */\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 _physicsBodysToRemoveAfterStep = new Array<any>();\r\n private _firstFrame = true;\r\n private _tmpQuaternion: Quaternion = new Quaternion();\r\n //See https://github.com/schteppe/CANNON.js/blob/gh-pages/demos/collisionFilter.html\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 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._physicsBodysToRemoveAfterStep.length > 0) {\r\n this._physicsBodysToRemoveAfterStep.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._physicsBodysToRemoveAfterStep = [];\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 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 //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._physicsBodysToRemoveAfterStep.indexOf(impostor.physicsBody) === -1) {\r\n this._physicsBodysToRemoveAfterStep.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 < PhysicsEngine.Epsilon ? PhysicsEngine.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 extendSize = impostor.getObjectExtendSize();\r\n switch (impostor.type) {\r\n case PhysicsImpostor.SphereImpostor: {\r\n const radiusX = extendSize.x;\r\n const radiusY = extendSize.y;\r\n const radiusZ = extendSize.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(extendSize.x) / 2;\r\n const radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;\r\n const height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.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 = extendSize.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 temp = 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(temp, index);\r\n }\r\n\r\n Logger.Warn(\"MeshImpostor only collides against spheres.\");\r\n returnValue = new this.BJSCANNON.Trimesh(temp, <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 temp = 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(temp, index);\r\n }\r\n pos = temp;\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 // The delta between the mesh position and the mesh bounding box center\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 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, upperLimit: number, lowerLimit?: number) {\r\n joint.physicsJoint.motorEquation.maxForce = upperLimit;\r\n joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;\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._cannonRaycastResult.reset();\r\n this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);\r\n\r\n this._raycastResult.reset(from, to);\r\n if (this._cannonRaycastResult.hasHit) {\r\n // TODO: do we also want to get the body it hit?\r\n this._raycastResult.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 this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);\r\n }\r\n\r\n return this._raycastResult;\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":["../../../../../../lts/core/generated/Physics/Plugins/cannonJSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,O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KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAEnE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE;YAClC,gDAAgD;YAChD,IAAI,CAAC,cAAc,CAAC,UAAU,CAC1B;gBACI,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;gBAC7C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;gBAC7C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;aAChD,EACD;gBACI,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;gBAC5C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;gBAC5C,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;aAC/C,CACJ,CAAC;YACF,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;SAC1E;QAED,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IACL,qBAAC;AAAD,CAAC,AAzuBD,IAyuBC;;AAED,aAAa,CAAC,oBAAoB,GAAG;IACjC,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 \"../../Physics/IPhysicsEngine\";\r\nimport type { IPhysicsEnabledObject } from \"../../Physics/physicsImpostor\";\r\nimport { PhysicsImpostor } from \"../../Physics/physicsImpostor\";\r\nimport type { IMotorEnabledJoint, DistanceJointData, SpringJointData } from \"../../Physics/physicsJoint\";\r\nimport { PhysicsJoint } from \"../../Physics/physicsJoint\";\r\nimport { PhysicsEngine } from \"../../Physics/physicsEngine\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n//declare var require: any;\r\ndeclare let CANNON: any;\r\n\r\n/** @hidden */\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 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 < PhysicsEngine.Epsilon ? PhysicsEngine.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._cannonRaycastResult.reset();\r\n this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);\r\n\r\n this._raycastResult.reset(from, to);\r\n if (this._cannonRaycastResult.hasHit) {\r\n // TODO: do we also want to get the body it hit?\r\n this._raycastResult.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 this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);\r\n }\r\n\r\n return this._raycastResult;\r\n }\r\n}\r\n\r\nPhysicsEngine.DefaultPluginFactory = () => {\r\n return new CannonJSPlugin();\r\n};\r\n"]}
|
|
@@ -125,7 +125,7 @@ var OimoJSPlugin = /** @class */ (function () {
|
|
|
125
125
|
i.object.rotationQuaternion.set(0, 0, 0, 1);
|
|
126
126
|
i.object.computeWorldMatrix(true);
|
|
127
127
|
var rot = globalQuaternion_1.toEulerAngles();
|
|
128
|
-
var
|
|
128
|
+
var impostorExtents = i.getObjectExtents();
|
|
129
129
|
// eslint-disable-next-line no-loss-of-precision
|
|
130
130
|
var radToDeg = 57.295779513082320876;
|
|
131
131
|
if (i === impostor) {
|
|
@@ -154,9 +154,9 @@ var OimoJSPlugin = /** @class */ (function () {
|
|
|
154
154
|
Logger.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
|
|
155
155
|
// eslint-disable-next-line no-fallthrough
|
|
156
156
|
case PhysicsImpostor.SphereImpostor: {
|
|
157
|
-
var radiusX =
|
|
158
|
-
var radiusY =
|
|
159
|
-
var radiusZ =
|
|
157
|
+
var radiusX = impostorExtents.x;
|
|
158
|
+
var radiusY = impostorExtents.y;
|
|
159
|
+
var radiusZ = impostorExtents.z;
|
|
160
160
|
var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
|
|
161
161
|
bodyConfig_1.type.push("sphere");
|
|
162
162
|
//due to the way oimo works with compounds, add 3 times
|
|
@@ -166,8 +166,8 @@ var OimoJSPlugin = /** @class */ (function () {
|
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
case PhysicsImpostor.CylinderImpostor: {
|
|
169
|
-
var sizeX = checkWithEpsilon_1(
|
|
170
|
-
var sizeY = checkWithEpsilon_1(
|
|
169
|
+
var sizeX = checkWithEpsilon_1(impostorExtents.x) / 2;
|
|
170
|
+
var sizeY = checkWithEpsilon_1(impostorExtents.y);
|
|
171
171
|
bodyConfig_1.type.push("cylinder");
|
|
172
172
|
bodyConfig_1.size.push(sizeX);
|
|
173
173
|
bodyConfig_1.size.push(sizeY);
|
|
@@ -178,9 +178,9 @@ var OimoJSPlugin = /** @class */ (function () {
|
|
|
178
178
|
case PhysicsImpostor.PlaneImpostor:
|
|
179
179
|
case PhysicsImpostor.BoxImpostor:
|
|
180
180
|
default: {
|
|
181
|
-
var sizeX = checkWithEpsilon_1(
|
|
182
|
-
var sizeY = checkWithEpsilon_1(
|
|
183
|
-
var sizeZ = checkWithEpsilon_1(
|
|
181
|
+
var sizeX = checkWithEpsilon_1(impostorExtents.x);
|
|
182
|
+
var sizeY = checkWithEpsilon_1(impostorExtents.y);
|
|
183
|
+
var sizeZ = checkWithEpsilon_1(impostorExtents.z);
|
|
184
184
|
bodyConfig_1.type.push("box");
|
|
185
185
|
//if (i === impostor) {
|
|
186
186
|
bodyConfig_1.size.push(sizeX);
|
|
@@ -210,7 +210,6 @@ var OimoJSPlugin = /** @class */ (function () {
|
|
|
210
210
|
};
|
|
211
211
|
OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
|
|
212
212
|
//impostor.physicsBody.dispose();
|
|
213
|
-
//Same as : (older oimo versions)
|
|
214
213
|
this.world.removeRigidBody(impostor.physicsBody);
|
|
215
214
|
};
|
|
216
215
|
OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
|
|
@@ -296,7 +295,6 @@ var OimoJSPlugin = /** @class */ (function () {
|
|
|
296
295
|
var pos = impostor.physicsBody.getPosition();
|
|
297
296
|
impostor.object.position.set(pos.x, pos.y, pos.z);
|
|
298
297
|
}
|
|
299
|
-
//}
|
|
300
298
|
if (impostor.object.rotationQuaternion) {
|
|
301
299
|
var quat = impostor.physicsBody.getQuaternion();
|
|
302
300
|
impostor.object.rotationQuaternion.set(quat.x, quat.y, quat.z, quat.w);
|