@babylonjs/core 6.40.0 → 6.41.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/runtimeAnimation.js +2 -2
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Debug/physicsViewer.js +2 -2
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/thinEngine.js +2 -3
- package/Engines/thinEngine.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +8 -7
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +7 -6
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +9 -12
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +8 -7
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/drawWrapper.d.ts +15 -0
- package/Materials/drawWrapper.js +15 -0
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.d.ts +0 -16
- package/Materials/effect.js +0 -16
- package/Materials/effect.js.map +1 -1
- package/Materials/effectRenderer.js +0 -1
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/material.d.ts +3 -2
- package/Materials/material.js +14 -12
- package/Materials/material.js.map +1 -1
- package/Materials/pushMaterial.d.ts +2 -2
- package/Materials/pushMaterial.js +9 -6
- package/Materials/pushMaterial.js.map +1 -1
- package/Materials/shaderMaterial.js +10 -16
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js +8 -7
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Builders/boxBuilder.d.ts +0 -33
- package/Meshes/Builders/boxBuilder.js +0 -33
- package/Meshes/Builders/boxBuilder.js.map +1 -1
- package/Meshes/Builders/cylinderBuilder.d.ts +0 -31
- package/Meshes/Builders/cylinderBuilder.js +0 -31
- package/Meshes/Builders/cylinderBuilder.js.map +1 -1
- package/Meshes/Builders/decalBuilder.d.ts +0 -7
- package/Meshes/Builders/decalBuilder.js +0 -7
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/Builders/discBuilder.d.ts +0 -13
- package/Meshes/Builders/discBuilder.js +0 -13
- package/Meshes/Builders/discBuilder.js.map +1 -1
- package/Meshes/Builders/geodesicBuilder.d.ts +0 -13
- package/Meshes/Builders/geodesicBuilder.js +0 -13
- package/Meshes/Builders/geodesicBuilder.js.map +1 -1
- package/Meshes/Builders/hemisphereBuilder.d.ts +0 -3
- package/Meshes/Builders/hemisphereBuilder.js +0 -3
- package/Meshes/Builders/hemisphereBuilder.js.map +1 -1
- package/Meshes/Builders/icoSphereBuilder.d.ts +0 -19
- package/Meshes/Builders/icoSphereBuilder.js +0 -19
- package/Meshes/Builders/icoSphereBuilder.js.map +1 -1
- package/Meshes/Builders/latheBuilder.d.ts +0 -12
- package/Meshes/Builders/latheBuilder.js +0 -12
- package/Meshes/Builders/latheBuilder.js.map +1 -1
- package/Meshes/Builders/linesBuilder.d.ts +0 -26
- package/Meshes/Builders/linesBuilder.js +0 -26
- package/Meshes/Builders/linesBuilder.js.map +1 -1
- package/Meshes/Builders/planeBuilder.d.ts +0 -14
- package/Meshes/Builders/planeBuilder.js +0 -14
- package/Meshes/Builders/planeBuilder.js.map +1 -1
- package/Meshes/Builders/polygonBuilder.d.ts +0 -21
- package/Meshes/Builders/polygonBuilder.js +0 -21
- package/Meshes/Builders/polygonBuilder.js.map +1 -1
- package/Meshes/Builders/polyhedronBuilder.d.ts +0 -25
- package/Meshes/Builders/polyhedronBuilder.js +0 -25
- package/Meshes/Builders/polyhedronBuilder.js.map +1 -1
- package/Meshes/Builders/ribbonBuilder.d.ts +0 -22
- package/Meshes/Builders/ribbonBuilder.js +0 -22
- package/Meshes/Builders/ribbonBuilder.js.map +1 -1
- package/Meshes/Builders/shapeBuilder.d.ts +0 -32
- package/Meshes/Builders/shapeBuilder.js +0 -32
- package/Meshes/Builders/shapeBuilder.js.map +1 -1
- package/Meshes/Builders/sphereBuilder.d.ts +0 -22
- package/Meshes/Builders/sphereBuilder.js +0 -22
- package/Meshes/Builders/sphereBuilder.js.map +1 -1
- package/Meshes/Node/Blocks/geometryDesaturateBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/geometryDesaturateBlock.js +62 -0
- package/Meshes/Node/Blocks/geometryDesaturateBlock.js.map +1 -0
- package/Meshes/Node/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.js +4 -4
- package/Meshes/mesh.js.map +1 -1
- package/Physics/castingResult.d.ts +66 -0
- package/Physics/castingResult.js +61 -0
- package/Physics/castingResult.js.map +1 -0
- package/Physics/index.d.ts +4 -0
- package/Physics/index.js +4 -0
- package/Physics/index.js.map +1 -1
- package/Physics/physicsPointProximityQuery.d.ts +28 -0
- package/Physics/physicsPointProximityQuery.js +2 -0
- package/Physics/physicsPointProximityQuery.js.map +1 -0
- package/Physics/physicsRaycastResult.d.ts +2 -44
- package/Physics/physicsRaycastResult.js +7 -38
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/physicsShapeCastQuery.d.ts +32 -0
- package/Physics/physicsShapeCastQuery.js +2 -0
- package/Physics/physicsShapeCastQuery.js.map +1 -0
- package/Physics/physicsShapeProximityCastQuery.d.ts +32 -0
- package/Physics/physicsShapeProximityCastQuery.js +2 -0
- package/Physics/physicsShapeProximityCastQuery.js.map +1 -0
- package/Physics/proximityCastResult.d.ts +20 -0
- package/Physics/proximityCastResult.js +31 -0
- package/Physics/proximityCastResult.js.map +1 -0
- package/Physics/shapeCastResult.d.ts +16 -0
- package/Physics/shapeCastResult.js +24 -0
- package/Physics/shapeCastResult.js.map +1 -0
- package/Physics/v2/Plugins/havokPlugin.d.ts +28 -0
- package/Physics/v2/Plugins/havokPlugin.js +80 -11
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +2 -2
- package/XR/features/WebXRHandTracking.js +4 -5
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +25 -15
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/webXRCamera.d.ts +1 -0
- package/XR/webXRCamera.js +19 -8
- package/XR/webXRCamera.js.map +1 -1
- package/package.json +1 -1
|
@@ -412,12 +412,12 @@ export class RuntimeAnimation {
|
|
|
412
412
|
}
|
|
413
413
|
this._previousElapsedTime = elapsedTimeSinceAnimationStart;
|
|
414
414
|
this._previousAbsoluteFrame = absoluteFrame;
|
|
415
|
-
if (!loop && to >= from && absoluteFrame >= frameRange) {
|
|
415
|
+
if (!loop && to >= from && ((absoluteFrame >= frameRange && speedRatio > 0) || (absoluteFrame <= 0 && speedRatio < 0))) {
|
|
416
416
|
// If we are out of range and not looping get back to caller
|
|
417
417
|
returnValue = false;
|
|
418
418
|
highLimitValue = animation._getKeyValue(this._maxValue);
|
|
419
419
|
}
|
|
420
|
-
else if (!loop && from >= to && absoluteFrame <= frameRange) {
|
|
420
|
+
else if (!loop && from >= to && ((absoluteFrame <= frameRange && speedRatio < 0) || (absoluteFrame >= 0 && speedRatio > 0))) {
|
|
421
421
|
returnValue = false;
|
|
422
422
|
highLimitValue = animation._getKeyValue(this._minValue);
|
|
423
423
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeAnimation.js","sourceRoot":"","sources":["../../../../dev/core/src/Animations/runtimeAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EACH,SAAS,EACT,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,GAC5B,MAAM,aAAa,CAAC;AAMrB;;GAEG;AACH,MAAM,OAAO,gBAAgB;IA2GzB;;OAEG;IACH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AAI,CAAC;wBACpB,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;qBAC9B,CAAC,wDAAwD;iBAC7D;aACJ;SACJ;QAED,IAAI,CAAC,WAAW,EAAE;YACd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Matrix } from \"../Maths/math.vector\";\r\nimport type { _IAnimationState } from \"./animation\";\r\nimport {\r\n Animation,\r\n _staticOffsetValueColor3,\r\n _staticOffsetValueColor4,\r\n _staticOffsetValueQuaternion,\r\n _staticOffsetValueSize,\r\n _staticOffsetValueVector2,\r\n _staticOffsetValueVector3,\r\n} from \"./animation\";\r\nimport type { AnimationEvent } from \"./animationEvent\";\r\nimport type { Animatable } from \"./animatable\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IAnimationKey } from \"./animationKey\";\r\n\r\n/**\r\n * Defines a runtime animation\r\n */\r\nexport class RuntimeAnimation {\r\n private _events = new Array<AnimationEvent>();\r\n\r\n /**\r\n * The current frame of the runtime animation\r\n */\r\n private _currentFrame: number = 0;\r\n\r\n /**\r\n * The animation used by the runtime animation\r\n */\r\n private _animation: Animation;\r\n\r\n /**\r\n * The target of the runtime animation\r\n */\r\n private _target: any;\r\n\r\n /**\r\n * The initiating animatable\r\n */\r\n private _host: Animatable;\r\n\r\n /**\r\n * The original value of the runtime animation\r\n */\r\n private _originalValue = new Array<any>();\r\n\r\n /**\r\n * The original blend value of the runtime animation\r\n */\r\n private _originalBlendValue: Nullable<any> = null;\r\n\r\n /**\r\n * The offsets cache of the runtime animation\r\n */\r\n private _offsetsCache: { [key: string]: any } = {};\r\n\r\n /**\r\n * The high limits cache of the runtime animation\r\n */\r\n private _highLimitsCache: { [key: string]: any } = {};\r\n\r\n /**\r\n * Specifies if the runtime animation has been stopped\r\n */\r\n private _stopped = false;\r\n\r\n /**\r\n * The blending factor of the runtime animation\r\n */\r\n private _blendingFactor = 0;\r\n\r\n /**\r\n * The BabylonJS scene\r\n */\r\n private _scene: Scene;\r\n\r\n /**\r\n * The current value of the runtime animation\r\n */\r\n private _currentValue: Nullable<any> = null;\r\n\r\n /** @internal */\r\n public _animationState: _IAnimationState;\r\n\r\n /**\r\n * The active target of the runtime animation\r\n */\r\n private _activeTargets: any[];\r\n private _currentActiveTarget: Nullable<any> = null;\r\n private _directTarget: Nullable<any> = null;\r\n\r\n /**\r\n * The target path of the runtime animation\r\n */\r\n private _targetPath: string = \"\";\r\n\r\n /**\r\n * The weight of the runtime animation\r\n */\r\n private _weight = 1.0;\r\n\r\n /**\r\n * The absolute frame offset of the runtime animation\r\n */\r\n private _absoluteFrameOffset = 0;\r\n\r\n /**\r\n * The previous elapsed time (since start of animation) of the runtime animation\r\n */\r\n private _previousElapsedTime: number = 0;\r\n\r\n /**\r\n * The previous absolute frame of the runtime animation (meaning, without taking into account the from/to values, only the elapsed time and the fps)\r\n */\r\n private _previousAbsoluteFrame: number = 0;\r\n\r\n private _enableBlending: boolean;\r\n\r\n private _keys: IAnimationKey[];\r\n private _minFrame: number;\r\n private _maxFrame: number;\r\n private _minValue: any;\r\n private _maxValue: any;\r\n private _targetIsArray = false;\r\n\r\n /**\r\n * Gets the current frame of the runtime animation\r\n */\r\n public get currentFrame(): number {\r\n return this._currentFrame;\r\n }\r\n\r\n /**\r\n * Gets the weight of the runtime animation\r\n */\r\n public get weight(): number {\r\n return this._weight;\r\n }\r\n\r\n /**\r\n * Gets the current value of the runtime animation\r\n */\r\n public get currentValue(): any {\r\n return this._currentValue;\r\n }\r\n\r\n /**\r\n * Gets or sets the target path of the runtime animation\r\n */\r\n public get targetPath(): string {\r\n return this._targetPath;\r\n }\r\n\r\n /**\r\n * Gets the actual target of the runtime animation\r\n */\r\n public get target(): any {\r\n return this._currentActiveTarget;\r\n }\r\n\r\n /**\r\n * Gets the additive state of the runtime animation\r\n */\r\n public get isAdditive(): boolean {\r\n return this._host && this._host.isAdditive;\r\n }\r\n\r\n /** @internal */\r\n public _onLoop: () => void;\r\n\r\n /**\r\n * Create a new RuntimeAnimation object\r\n * @param target defines the target of the animation\r\n * @param animation defines the source animation object\r\n * @param scene defines the hosting scene\r\n * @param host defines the initiating Animatable\r\n */\r\n public constructor(target: any, animation: Animation, scene: Scene, host: Animatable) {\r\n this._animation = animation;\r\n this._target = target;\r\n this._scene = scene;\r\n this._host = host;\r\n this._activeTargets = [];\r\n\r\n animation._runtimeAnimations.push(this);\r\n\r\n // State\r\n this._animationState = {\r\n key: 0,\r\n repeatCount: 0,\r\n loopMode: this._getCorrectLoopMode(),\r\n };\r\n\r\n if (this._animation.dataType === Animation.ANIMATIONTYPE_MATRIX) {\r\n this._animationState.workValue = Matrix.Zero();\r\n }\r\n\r\n // Limits\r\n this._keys = this._animation.getKeys();\r\n this._minFrame = this._keys[0].frame;\r\n this._maxFrame = this._keys[this._keys.length - 1].frame;\r\n this._minValue = this._keys[0].value;\r\n this._maxValue = this._keys[this._keys.length - 1].value;\r\n\r\n // Add a start key at frame 0 if missing\r\n if (this._minFrame !== 0) {\r\n const newKey = { frame: 0, value: this._minValue };\r\n this._keys.splice(0, 0, newKey);\r\n }\r\n\r\n // Check data\r\n if (this._target instanceof Array) {\r\n let index = 0;\r\n for (const target of this._target) {\r\n this._preparePath(target, index);\r\n this._getOriginalValues(index);\r\n index++;\r\n }\r\n this._targetIsArray = true;\r\n } else {\r\n this._preparePath(this._target);\r\n this._getOriginalValues();\r\n this._targetIsArray = false;\r\n this._directTarget = this._activeTargets[0];\r\n }\r\n\r\n // Cloning events locally\r\n const events = animation.getEvents();\r\n if (events && events.length > 0) {\r\n events.forEach((e) => {\r\n this._events.push(e._clone());\r\n });\r\n }\r\n\r\n this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;\r\n }\r\n\r\n private _preparePath(target: any, targetIndex = 0) {\r\n const targetPropertyPath = this._animation.targetPropertyPath;\r\n\r\n if (targetPropertyPath.length > 1) {\r\n let property = target[targetPropertyPath[0]];\r\n\r\n for (let index = 1; index < targetPropertyPath.length - 1; index++) {\r\n property = property[targetPropertyPath[index]];\r\n }\r\n\r\n this._targetPath = targetPropertyPath[targetPropertyPath.length - 1];\r\n this._activeTargets[targetIndex] = property;\r\n } else {\r\n this._targetPath = targetPropertyPath[0];\r\n this._activeTargets[targetIndex] = target;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the animation from the runtime animation\r\n */\r\n public get animation(): Animation {\r\n return this._animation;\r\n }\r\n\r\n /**\r\n * Resets the runtime animation to the beginning\r\n * @param restoreOriginal defines whether to restore the target property to the original value\r\n */\r\n public reset(restoreOriginal = false): void {\r\n if (restoreOriginal) {\r\n if (this._target instanceof Array) {\r\n let index = 0;\r\n for (const target of this._target) {\r\n if (this._originalValue[index] !== undefined) {\r\n this._setValue(target, this._activeTargets[index], this._originalValue[index], -1, index);\r\n }\r\n index++;\r\n }\r\n } else {\r\n if (this._originalValue[0] !== undefined) {\r\n this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);\r\n }\r\n }\r\n }\r\n\r\n this._offsetsCache = {};\r\n this._highLimitsCache = {};\r\n this._currentFrame = 0;\r\n this._blendingFactor = 0;\r\n\r\n // Events\r\n for (let index = 0; index < this._events.length; index++) {\r\n this._events[index].isDone = false;\r\n }\r\n }\r\n\r\n /**\r\n * Specifies if the runtime animation is stopped\r\n * @returns Boolean specifying if the runtime animation is stopped\r\n */\r\n public isStopped(): boolean {\r\n return this._stopped;\r\n }\r\n\r\n /**\r\n * Disposes of the runtime animation\r\n */\r\n public dispose(): void {\r\n const index = this._animation.runtimeAnimations.indexOf(this);\r\n\r\n if (index > -1) {\r\n this._animation.runtimeAnimations.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Apply the interpolated value to the target\r\n * @param currentValue defines the value computed by the animation\r\n * @param weight defines the weight to apply to this value (Defaults to 1.0)\r\n */\r\n public setValue(currentValue: any, weight: number) {\r\n if (this._targetIsArray) {\r\n for (let index = 0; index < this._target.length; index++) {\r\n const target = this._target[index];\r\n this._setValue(target, this._activeTargets[index], currentValue, weight, index);\r\n }\r\n return;\r\n }\r\n this._setValue(this._target, this._directTarget, currentValue, weight, 0);\r\n }\r\n\r\n private _getOriginalValues(targetIndex = 0) {\r\n let originalValue: any;\r\n const target = this._activeTargets[targetIndex];\r\n\r\n if (target.getLocalMatrix && this._targetPath === \"_matrix\") {\r\n // For bones\r\n originalValue = target.getLocalMatrix();\r\n } else {\r\n originalValue = target[this._targetPath];\r\n }\r\n\r\n if (originalValue && originalValue.clone) {\r\n this._originalValue[targetIndex] = originalValue.clone();\r\n } else {\r\n this._originalValue[targetIndex] = originalValue;\r\n }\r\n }\r\n\r\n private _setValue(target: any, destination: any, currentValue: any, weight: number, targetIndex: number): void {\r\n // Set value\r\n this._currentActiveTarget = destination;\r\n\r\n this._weight = weight;\r\n\r\n if (this._enableBlending && this._blendingFactor <= 1.0) {\r\n if (!this._originalBlendValue) {\r\n const originalValue = destination[this._targetPath];\r\n\r\n if (originalValue.clone) {\r\n this._originalBlendValue = originalValue.clone();\r\n } else {\r\n this._originalBlendValue = originalValue;\r\n }\r\n }\r\n\r\n if (this._originalBlendValue.m) {\r\n // Matrix\r\n if (Animation.AllowMatrixDecomposeForInterpolation) {\r\n if (this._currentValue) {\r\n Matrix.DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);\r\n } else {\r\n this._currentValue = Matrix.DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);\r\n }\r\n } else {\r\n if (this._currentValue) {\r\n Matrix.LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);\r\n } else {\r\n this._currentValue = Matrix.Lerp(this._originalBlendValue, currentValue, this._blendingFactor);\r\n }\r\n }\r\n } else {\r\n this._currentValue = Animation._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);\r\n }\r\n\r\n const blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;\r\n this._blendingFactor += blendingSpeed;\r\n } else {\r\n if (!this._currentValue) {\r\n if (currentValue?.clone) {\r\n this._currentValue = currentValue.clone();\r\n } else {\r\n this._currentValue = currentValue;\r\n }\r\n } else if (this._currentValue.copyFrom) {\r\n this._currentValue.copyFrom(currentValue);\r\n } else {\r\n this._currentValue = currentValue;\r\n }\r\n }\r\n\r\n if (weight !== -1.0) {\r\n this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);\r\n } else {\r\n if (this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT) {\r\n if (this._currentValue.addToRef) {\r\n this._currentValue.addToRef(this._originalValue[targetIndex], destination[this._targetPath]);\r\n } else {\r\n destination[this._targetPath] = this._originalValue[targetIndex] + this._currentValue;\r\n }\r\n } else {\r\n destination[this._targetPath] = this._currentValue;\r\n }\r\n }\r\n\r\n if (target.markAsDirty) {\r\n target.markAsDirty(this._animation.targetProperty);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the loop pmode of the runtime animation\r\n * @returns Loop Mode\r\n */\r\n private _getCorrectLoopMode(): number | undefined {\r\n if (this._target && this._target.animationPropertiesOverride) {\r\n return this._target.animationPropertiesOverride.loopMode;\r\n }\r\n\r\n return this._animation.loopMode;\r\n }\r\n\r\n /**\r\n * Move the current animation to a given frame\r\n * @param frame defines the frame to move to\r\n */\r\n public goToFrame(frame: number): void {\r\n const keys = this._animation.getKeys();\r\n\r\n if (frame < keys[0].frame) {\r\n frame = keys[0].frame;\r\n } else if (frame > keys[keys.length - 1].frame) {\r\n frame = keys[keys.length - 1].frame;\r\n }\r\n\r\n // Need to reset animation events\r\n const events = this._events;\r\n if (events.length) {\r\n for (let index = 0; index < events.length; index++) {\r\n if (!events[index].onlyOnce) {\r\n // reset events in the future\r\n events[index].isDone = events[index].frame < frame;\r\n }\r\n }\r\n }\r\n\r\n this._currentFrame = frame;\r\n const currentValue = this._animation._interpolate(frame, this._animationState);\r\n\r\n this.setValue(currentValue, -1);\r\n }\r\n\r\n /**\r\n * @internal Internal use only\r\n */\r\n public _prepareForSpeedRatioChange(newSpeedRatio: number): void {\r\n const newAbsoluteFrame = (this._previousElapsedTime * (this._animation.framePerSecond * newSpeedRatio)) / 1000.0;\r\n\r\n this._absoluteFrameOffset = this._previousAbsoluteFrame - newAbsoluteFrame;\r\n }\r\n\r\n /**\r\n * Execute the current animation\r\n * @param elapsedTimeSinceAnimationStart defines the elapsed time (in milliseconds) since the animation was started\r\n * @param from defines the lower frame of the animation range\r\n * @param to defines the upper frame of the animation range\r\n * @param loop defines if the current animation must loop\r\n * @param speedRatio defines the current speed ratio\r\n * @param weight defines the weight of the animation (default is -1 so no weight)\r\n * @returns a boolean indicating if the animation is running\r\n */\r\n public animate(elapsedTimeSinceAnimationStart: number, from: number, to: number, loop: boolean, speedRatio: number, weight = -1.0): boolean {\r\n const animation = this._animation;\r\n const targetPropertyPath = animation.targetPropertyPath;\r\n if (!targetPropertyPath || targetPropertyPath.length < 1) {\r\n this._stopped = true;\r\n return false;\r\n }\r\n\r\n let returnValue = true;\r\n\r\n // Check limits\r\n if (from < this._minFrame || from > this._maxFrame) {\r\n from = this._minFrame;\r\n }\r\n if (to < this._minFrame || to > this._maxFrame) {\r\n to = this._maxFrame;\r\n }\r\n\r\n const frameRange = to - from;\r\n let offsetValue: any;\r\n\r\n // Compute the frame according to the elapsed time and the fps of the animation (\"from\" and \"to\" are not factored in!)\r\n let absoluteFrame = (elapsedTimeSinceAnimationStart * (animation.framePerSecond * speedRatio)) / 1000.0 + this._absoluteFrameOffset;\r\n let highLimitValue = 0;\r\n\r\n // Apply the yoyo function if required\r\n if (loop && this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_YOYO) {\r\n const position = (absoluteFrame - from) / frameRange;\r\n\r\n // Apply the yoyo curve\r\n const yoyoPosition = Math.abs(Math.sin(position * Math.PI));\r\n\r\n // Map the yoyo position back to the range\r\n absoluteFrame = yoyoPosition * frameRange + from;\r\n }\r\n\r\n this._previousElapsedTime = elapsedTimeSinceAnimationStart;\r\n this._previousAbsoluteFrame = absoluteFrame;\r\n\r\n if (!loop && to >= from && absoluteFrame >= frameRange) {\r\n // If we are out of range and not looping get back to caller\r\n returnValue = false;\r\n highLimitValue = animation._getKeyValue(this._maxValue);\r\n } else if (!loop && from >= to && absoluteFrame <= frameRange) {\r\n returnValue = false;\r\n highLimitValue = animation._getKeyValue(this._minValue);\r\n } else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {\r\n const keyOffset = to.toString() + from.toString();\r\n if (!this._offsetsCache[keyOffset]) {\r\n this._animationState.repeatCount = 0;\r\n this._animationState.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE; // force a specific codepath in animation._interpolate()!\r\n const fromValue = animation._interpolate(from, this._animationState);\r\n const toValue = animation._interpolate(to, this._animationState);\r\n\r\n this._animationState.loopMode = this._getCorrectLoopMode();\r\n switch (animation.dataType) {\r\n // Float\r\n case Animation.ANIMATIONTYPE_FLOAT:\r\n this._offsetsCache[keyOffset] = toValue - fromValue;\r\n break;\r\n // Quaternion\r\n case Animation.ANIMATIONTYPE_QUATERNION:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Vector3\r\n case Animation.ANIMATIONTYPE_VECTOR3:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Vector2\r\n case Animation.ANIMATIONTYPE_VECTOR2:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Size\r\n case Animation.ANIMATIONTYPE_SIZE:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Color3\r\n case Animation.ANIMATIONTYPE_COLOR3:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n this._highLimitsCache[keyOffset] = toValue;\r\n }\r\n\r\n highLimitValue = this._highLimitsCache[keyOffset];\r\n offsetValue = this._offsetsCache[keyOffset];\r\n }\r\n\r\n if (offsetValue === undefined) {\r\n switch (animation.dataType) {\r\n // Float\r\n case Animation.ANIMATIONTYPE_FLOAT:\r\n offsetValue = 0;\r\n break;\r\n // Quaternion\r\n case Animation.ANIMATIONTYPE_QUATERNION:\r\n offsetValue = _staticOffsetValueQuaternion;\r\n break;\r\n // Vector3\r\n case Animation.ANIMATIONTYPE_VECTOR3:\r\n offsetValue = _staticOffsetValueVector3;\r\n break;\r\n // Vector2\r\n case Animation.ANIMATIONTYPE_VECTOR2:\r\n offsetValue = _staticOffsetValueVector2;\r\n break;\r\n // Size\r\n case Animation.ANIMATIONTYPE_SIZE:\r\n offsetValue = _staticOffsetValueSize;\r\n break;\r\n // Color3\r\n case Animation.ANIMATIONTYPE_COLOR3:\r\n offsetValue = _staticOffsetValueColor3;\r\n break;\r\n case Animation.ANIMATIONTYPE_COLOR4:\r\n offsetValue = _staticOffsetValueColor4;\r\n break;\r\n }\r\n }\r\n\r\n // Compute value\r\n let currentFrame: number;\r\n\r\n if (this._host && this._host.syncRoot) {\r\n // If we must sync with an animatable, calculate the current frame based on the frame of the root animatable\r\n const syncRoot = this._host.syncRoot;\r\n const hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);\r\n currentFrame = from + frameRange * hostNormalizedFrame;\r\n } else {\r\n if ((absoluteFrame > 0 && from > to) || (absoluteFrame < 0 && from < to)) {\r\n currentFrame = returnValue && frameRange !== 0 ? to + (absoluteFrame % frameRange) : from;\r\n } else {\r\n currentFrame = returnValue && frameRange !== 0 ? from + (absoluteFrame % frameRange) : to;\r\n }\r\n }\r\n\r\n const events = this._events;\r\n\r\n // Reset event/state if looping\r\n if ((speedRatio > 0 && this.currentFrame > currentFrame) || (speedRatio < 0 && this.currentFrame < currentFrame)) {\r\n this._onLoop();\r\n\r\n // Need to reset animation events\r\n for (let index = 0; index < events.length; index++) {\r\n if (!events[index].onlyOnce) {\r\n // reset event, the animation is looping\r\n events[index].isDone = false;\r\n }\r\n }\r\n\r\n this._animationState.key = speedRatio > 0 ? 0 : animation.getKeys().length - 1;\r\n }\r\n this._currentFrame = currentFrame;\r\n this._animationState.repeatCount = frameRange === 0 ? 0 : (absoluteFrame / frameRange) >> 0;\r\n this._animationState.highLimitValue = highLimitValue;\r\n this._animationState.offsetValue = offsetValue;\r\n\r\n const currentValue = animation._interpolate(currentFrame, this._animationState);\r\n\r\n // Set value\r\n this.setValue(currentValue, weight);\r\n\r\n // Check events\r\n if (events.length) {\r\n for (let index = 0; index < events.length; index++) {\r\n // Make sure current frame has passed event frame and that event frame is within the current range\r\n // Also, handle both forward and reverse animations\r\n if (\r\n (frameRange >= 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||\r\n (frameRange < 0 && currentFrame <= events[index].frame && events[index].frame <= from)\r\n ) {\r\n const event = events[index];\r\n if (!event.isDone) {\r\n // If event should be done only once, remove it.\r\n if (event.onlyOnce) {\r\n events.splice(index, 1);\r\n index--;\r\n }\r\n event.isDone = true;\r\n event.action(currentFrame);\r\n } // Don't do anything if the event has already been done.\r\n }\r\n }\r\n }\r\n\r\n if (!returnValue) {\r\n this._stopped = true;\r\n }\r\n\r\n return returnValue;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"runtimeAnimation.js","sourceRoot":"","sources":["../../../../dev/core/src/Animations/runtimeAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EACH,SAAS,EACT,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,GAC5B,MAAM,aAAa,CAAC;AAMrB;;GAEG;AACH,MAAM,OAAO,gBAAgB;IA2GzB;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAA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,IAAI,KAAK,CAAC,QAAQ,EAAE;4BAChB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;4BACxB,KAAK,EAAE,CAAC;yBACX;wBACD,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;wBACpB,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;qBAC9B,CAAC,wDAAwD;iBAC7D;aACJ;SACJ;QAED,IAAI,CAAC,WAAW,EAAE;YACd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Matrix } from \"../Maths/math.vector\";\r\nimport type { _IAnimationState } from \"./animation\";\r\nimport {\r\n Animation,\r\n _staticOffsetValueColor3,\r\n _staticOffsetValueColor4,\r\n _staticOffsetValueQuaternion,\r\n _staticOffsetValueSize,\r\n _staticOffsetValueVector2,\r\n _staticOffsetValueVector3,\r\n} from \"./animation\";\r\nimport type { AnimationEvent } from \"./animationEvent\";\r\nimport type { Animatable } from \"./animatable\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IAnimationKey } from \"./animationKey\";\r\n\r\n/**\r\n * Defines a runtime animation\r\n */\r\nexport class RuntimeAnimation {\r\n private _events = new Array<AnimationEvent>();\r\n\r\n /**\r\n * The current frame of the runtime animation\r\n */\r\n private _currentFrame: number = 0;\r\n\r\n /**\r\n * The animation used by the runtime animation\r\n */\r\n private _animation: Animation;\r\n\r\n /**\r\n * The target of the runtime animation\r\n */\r\n private _target: any;\r\n\r\n /**\r\n * The initiating animatable\r\n */\r\n private _host: Animatable;\r\n\r\n /**\r\n * The original value of the runtime animation\r\n */\r\n private _originalValue = new Array<any>();\r\n\r\n /**\r\n * The original blend value of the runtime animation\r\n */\r\n private _originalBlendValue: Nullable<any> = null;\r\n\r\n /**\r\n * The offsets cache of the runtime animation\r\n */\r\n private _offsetsCache: { [key: string]: any } = {};\r\n\r\n /**\r\n * The high limits cache of the runtime animation\r\n */\r\n private _highLimitsCache: { [key: string]: any } = {};\r\n\r\n /**\r\n * Specifies if the runtime animation has been stopped\r\n */\r\n private _stopped = false;\r\n\r\n /**\r\n * The blending factor of the runtime animation\r\n */\r\n private _blendingFactor = 0;\r\n\r\n /**\r\n * The BabylonJS scene\r\n */\r\n private _scene: Scene;\r\n\r\n /**\r\n * The current value of the runtime animation\r\n */\r\n private _currentValue: Nullable<any> = null;\r\n\r\n /** @internal */\r\n public _animationState: _IAnimationState;\r\n\r\n /**\r\n * The active target of the runtime animation\r\n */\r\n private _activeTargets: any[];\r\n private _currentActiveTarget: Nullable<any> = null;\r\n private _directTarget: Nullable<any> = null;\r\n\r\n /**\r\n * The target path of the runtime animation\r\n */\r\n private _targetPath: string = \"\";\r\n\r\n /**\r\n * The weight of the runtime animation\r\n */\r\n private _weight = 1.0;\r\n\r\n /**\r\n * The absolute frame offset of the runtime animation\r\n */\r\n private _absoluteFrameOffset = 0;\r\n\r\n /**\r\n * The previous elapsed time (since start of animation) of the runtime animation\r\n */\r\n private _previousElapsedTime: number = 0;\r\n\r\n /**\r\n * The previous absolute frame of the runtime animation (meaning, without taking into account the from/to values, only the elapsed time and the fps)\r\n */\r\n private _previousAbsoluteFrame: number = 0;\r\n\r\n private _enableBlending: boolean;\r\n\r\n private _keys: IAnimationKey[];\r\n private _minFrame: number;\r\n private _maxFrame: number;\r\n private _minValue: any;\r\n private _maxValue: any;\r\n private _targetIsArray = false;\r\n\r\n /**\r\n * Gets the current frame of the runtime animation\r\n */\r\n public get currentFrame(): number {\r\n return this._currentFrame;\r\n }\r\n\r\n /**\r\n * Gets the weight of the runtime animation\r\n */\r\n public get weight(): number {\r\n return this._weight;\r\n }\r\n\r\n /**\r\n * Gets the current value of the runtime animation\r\n */\r\n public get currentValue(): any {\r\n return this._currentValue;\r\n }\r\n\r\n /**\r\n * Gets or sets the target path of the runtime animation\r\n */\r\n public get targetPath(): string {\r\n return this._targetPath;\r\n }\r\n\r\n /**\r\n * Gets the actual target of the runtime animation\r\n */\r\n public get target(): any {\r\n return this._currentActiveTarget;\r\n }\r\n\r\n /**\r\n * Gets the additive state of the runtime animation\r\n */\r\n public get isAdditive(): boolean {\r\n return this._host && this._host.isAdditive;\r\n }\r\n\r\n /** @internal */\r\n public _onLoop: () => void;\r\n\r\n /**\r\n * Create a new RuntimeAnimation object\r\n * @param target defines the target of the animation\r\n * @param animation defines the source animation object\r\n * @param scene defines the hosting scene\r\n * @param host defines the initiating Animatable\r\n */\r\n public constructor(target: any, animation: Animation, scene: Scene, host: Animatable) {\r\n this._animation = animation;\r\n this._target = target;\r\n this._scene = scene;\r\n this._host = host;\r\n this._activeTargets = [];\r\n\r\n animation._runtimeAnimations.push(this);\r\n\r\n // State\r\n this._animationState = {\r\n key: 0,\r\n repeatCount: 0,\r\n loopMode: this._getCorrectLoopMode(),\r\n };\r\n\r\n if (this._animation.dataType === Animation.ANIMATIONTYPE_MATRIX) {\r\n this._animationState.workValue = Matrix.Zero();\r\n }\r\n\r\n // Limits\r\n this._keys = this._animation.getKeys();\r\n this._minFrame = this._keys[0].frame;\r\n this._maxFrame = this._keys[this._keys.length - 1].frame;\r\n this._minValue = this._keys[0].value;\r\n this._maxValue = this._keys[this._keys.length - 1].value;\r\n\r\n // Add a start key at frame 0 if missing\r\n if (this._minFrame !== 0) {\r\n const newKey = { frame: 0, value: this._minValue };\r\n this._keys.splice(0, 0, newKey);\r\n }\r\n\r\n // Check data\r\n if (this._target instanceof Array) {\r\n let index = 0;\r\n for (const target of this._target) {\r\n this._preparePath(target, index);\r\n this._getOriginalValues(index);\r\n index++;\r\n }\r\n this._targetIsArray = true;\r\n } else {\r\n this._preparePath(this._target);\r\n this._getOriginalValues();\r\n this._targetIsArray = false;\r\n this._directTarget = this._activeTargets[0];\r\n }\r\n\r\n // Cloning events locally\r\n const events = animation.getEvents();\r\n if (events && events.length > 0) {\r\n events.forEach((e) => {\r\n this._events.push(e._clone());\r\n });\r\n }\r\n\r\n this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;\r\n }\r\n\r\n private _preparePath(target: any, targetIndex = 0) {\r\n const targetPropertyPath = this._animation.targetPropertyPath;\r\n\r\n if (targetPropertyPath.length > 1) {\r\n let property = target[targetPropertyPath[0]];\r\n\r\n for (let index = 1; index < targetPropertyPath.length - 1; index++) {\r\n property = property[targetPropertyPath[index]];\r\n }\r\n\r\n this._targetPath = targetPropertyPath[targetPropertyPath.length - 1];\r\n this._activeTargets[targetIndex] = property;\r\n } else {\r\n this._targetPath = targetPropertyPath[0];\r\n this._activeTargets[targetIndex] = target;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the animation from the runtime animation\r\n */\r\n public get animation(): Animation {\r\n return this._animation;\r\n }\r\n\r\n /**\r\n * Resets the runtime animation to the beginning\r\n * @param restoreOriginal defines whether to restore the target property to the original value\r\n */\r\n public reset(restoreOriginal = false): void {\r\n if (restoreOriginal) {\r\n if (this._target instanceof Array) {\r\n let index = 0;\r\n for (const target of this._target) {\r\n if (this._originalValue[index] !== undefined) {\r\n this._setValue(target, this._activeTargets[index], this._originalValue[index], -1, index);\r\n }\r\n index++;\r\n }\r\n } else {\r\n if (this._originalValue[0] !== undefined) {\r\n this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);\r\n }\r\n }\r\n }\r\n\r\n this._offsetsCache = {};\r\n this._highLimitsCache = {};\r\n this._currentFrame = 0;\r\n this._blendingFactor = 0;\r\n\r\n // Events\r\n for (let index = 0; index < this._events.length; index++) {\r\n this._events[index].isDone = false;\r\n }\r\n }\r\n\r\n /**\r\n * Specifies if the runtime animation is stopped\r\n * @returns Boolean specifying if the runtime animation is stopped\r\n */\r\n public isStopped(): boolean {\r\n return this._stopped;\r\n }\r\n\r\n /**\r\n * Disposes of the runtime animation\r\n */\r\n public dispose(): void {\r\n const index = this._animation.runtimeAnimations.indexOf(this);\r\n\r\n if (index > -1) {\r\n this._animation.runtimeAnimations.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Apply the interpolated value to the target\r\n * @param currentValue defines the value computed by the animation\r\n * @param weight defines the weight to apply to this value (Defaults to 1.0)\r\n */\r\n public setValue(currentValue: any, weight: number) {\r\n if (this._targetIsArray) {\r\n for (let index = 0; index < this._target.length; index++) {\r\n const target = this._target[index];\r\n this._setValue(target, this._activeTargets[index], currentValue, weight, index);\r\n }\r\n return;\r\n }\r\n this._setValue(this._target, this._directTarget, currentValue, weight, 0);\r\n }\r\n\r\n private _getOriginalValues(targetIndex = 0) {\r\n let originalValue: any;\r\n const target = this._activeTargets[targetIndex];\r\n\r\n if (target.getLocalMatrix && this._targetPath === \"_matrix\") {\r\n // For bones\r\n originalValue = target.getLocalMatrix();\r\n } else {\r\n originalValue = target[this._targetPath];\r\n }\r\n\r\n if (originalValue && originalValue.clone) {\r\n this._originalValue[targetIndex] = originalValue.clone();\r\n } else {\r\n this._originalValue[targetIndex] = originalValue;\r\n }\r\n }\r\n\r\n private _setValue(target: any, destination: any, currentValue: any, weight: number, targetIndex: number): void {\r\n // Set value\r\n this._currentActiveTarget = destination;\r\n\r\n this._weight = weight;\r\n\r\n if (this._enableBlending && this._blendingFactor <= 1.0) {\r\n if (!this._originalBlendValue) {\r\n const originalValue = destination[this._targetPath];\r\n\r\n if (originalValue.clone) {\r\n this._originalBlendValue = originalValue.clone();\r\n } else {\r\n this._originalBlendValue = originalValue;\r\n }\r\n }\r\n\r\n if (this._originalBlendValue.m) {\r\n // Matrix\r\n if (Animation.AllowMatrixDecomposeForInterpolation) {\r\n if (this._currentValue) {\r\n Matrix.DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);\r\n } else {\r\n this._currentValue = Matrix.DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);\r\n }\r\n } else {\r\n if (this._currentValue) {\r\n Matrix.LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);\r\n } else {\r\n this._currentValue = Matrix.Lerp(this._originalBlendValue, currentValue, this._blendingFactor);\r\n }\r\n }\r\n } else {\r\n this._currentValue = Animation._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);\r\n }\r\n\r\n const blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;\r\n this._blendingFactor += blendingSpeed;\r\n } else {\r\n if (!this._currentValue) {\r\n if (currentValue?.clone) {\r\n this._currentValue = currentValue.clone();\r\n } else {\r\n this._currentValue = currentValue;\r\n }\r\n } else if (this._currentValue.copyFrom) {\r\n this._currentValue.copyFrom(currentValue);\r\n } else {\r\n this._currentValue = currentValue;\r\n }\r\n }\r\n\r\n if (weight !== -1.0) {\r\n this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);\r\n } else {\r\n if (this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT) {\r\n if (this._currentValue.addToRef) {\r\n this._currentValue.addToRef(this._originalValue[targetIndex], destination[this._targetPath]);\r\n } else {\r\n destination[this._targetPath] = this._originalValue[targetIndex] + this._currentValue;\r\n }\r\n } else {\r\n destination[this._targetPath] = this._currentValue;\r\n }\r\n }\r\n\r\n if (target.markAsDirty) {\r\n target.markAsDirty(this._animation.targetProperty);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the loop pmode of the runtime animation\r\n * @returns Loop Mode\r\n */\r\n private _getCorrectLoopMode(): number | undefined {\r\n if (this._target && this._target.animationPropertiesOverride) {\r\n return this._target.animationPropertiesOverride.loopMode;\r\n }\r\n\r\n return this._animation.loopMode;\r\n }\r\n\r\n /**\r\n * Move the current animation to a given frame\r\n * @param frame defines the frame to move to\r\n */\r\n public goToFrame(frame: number): void {\r\n const keys = this._animation.getKeys();\r\n\r\n if (frame < keys[0].frame) {\r\n frame = keys[0].frame;\r\n } else if (frame > keys[keys.length - 1].frame) {\r\n frame = keys[keys.length - 1].frame;\r\n }\r\n\r\n // Need to reset animation events\r\n const events = this._events;\r\n if (events.length) {\r\n for (let index = 0; index < events.length; index++) {\r\n if (!events[index].onlyOnce) {\r\n // reset events in the future\r\n events[index].isDone = events[index].frame < frame;\r\n }\r\n }\r\n }\r\n\r\n this._currentFrame = frame;\r\n const currentValue = this._animation._interpolate(frame, this._animationState);\r\n\r\n this.setValue(currentValue, -1);\r\n }\r\n\r\n /**\r\n * @internal Internal use only\r\n */\r\n public _prepareForSpeedRatioChange(newSpeedRatio: number): void {\r\n const newAbsoluteFrame = (this._previousElapsedTime * (this._animation.framePerSecond * newSpeedRatio)) / 1000.0;\r\n\r\n this._absoluteFrameOffset = this._previousAbsoluteFrame - newAbsoluteFrame;\r\n }\r\n\r\n /**\r\n * Execute the current animation\r\n * @param elapsedTimeSinceAnimationStart defines the elapsed time (in milliseconds) since the animation was started\r\n * @param from defines the lower frame of the animation range\r\n * @param to defines the upper frame of the animation range\r\n * @param loop defines if the current animation must loop\r\n * @param speedRatio defines the current speed ratio\r\n * @param weight defines the weight of the animation (default is -1 so no weight)\r\n * @returns a boolean indicating if the animation is running\r\n */\r\n public animate(elapsedTimeSinceAnimationStart: number, from: number, to: number, loop: boolean, speedRatio: number, weight = -1.0): boolean {\r\n const animation = this._animation;\r\n const targetPropertyPath = animation.targetPropertyPath;\r\n if (!targetPropertyPath || targetPropertyPath.length < 1) {\r\n this._stopped = true;\r\n return false;\r\n }\r\n\r\n let returnValue = true;\r\n\r\n // Check limits\r\n if (from < this._minFrame || from > this._maxFrame) {\r\n from = this._minFrame;\r\n }\r\n if (to < this._minFrame || to > this._maxFrame) {\r\n to = this._maxFrame;\r\n }\r\n\r\n const frameRange = to - from;\r\n let offsetValue: any;\r\n\r\n // Compute the frame according to the elapsed time and the fps of the animation (\"from\" and \"to\" are not factored in!)\r\n let absoluteFrame = (elapsedTimeSinceAnimationStart * (animation.framePerSecond * speedRatio)) / 1000.0 + this._absoluteFrameOffset;\r\n let highLimitValue = 0;\r\n\r\n // Apply the yoyo function if required\r\n if (loop && this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_YOYO) {\r\n const position = (absoluteFrame - from) / frameRange;\r\n\r\n // Apply the yoyo curve\r\n const yoyoPosition = Math.abs(Math.sin(position * Math.PI));\r\n\r\n // Map the yoyo position back to the range\r\n absoluteFrame = yoyoPosition * frameRange + from;\r\n }\r\n\r\n this._previousElapsedTime = elapsedTimeSinceAnimationStart;\r\n this._previousAbsoluteFrame = absoluteFrame;\r\n\r\n if (!loop && to >= from && ((absoluteFrame >= frameRange && speedRatio > 0) || (absoluteFrame <= 0 && speedRatio < 0))) {\r\n // If we are out of range and not looping get back to caller\r\n returnValue = false;\r\n highLimitValue = animation._getKeyValue(this._maxValue);\r\n } else if (!loop && from >= to && ((absoluteFrame <= frameRange && speedRatio < 0) || (absoluteFrame >= 0 && speedRatio > 0))) {\r\n returnValue = false;\r\n highLimitValue = animation._getKeyValue(this._minValue);\r\n } else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {\r\n const keyOffset = to.toString() + from.toString();\r\n if (!this._offsetsCache[keyOffset]) {\r\n this._animationState.repeatCount = 0;\r\n this._animationState.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE; // force a specific codepath in animation._interpolate()!\r\n const fromValue = animation._interpolate(from, this._animationState);\r\n const toValue = animation._interpolate(to, this._animationState);\r\n\r\n this._animationState.loopMode = this._getCorrectLoopMode();\r\n switch (animation.dataType) {\r\n // Float\r\n case Animation.ANIMATIONTYPE_FLOAT:\r\n this._offsetsCache[keyOffset] = toValue - fromValue;\r\n break;\r\n // Quaternion\r\n case Animation.ANIMATIONTYPE_QUATERNION:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Vector3\r\n case Animation.ANIMATIONTYPE_VECTOR3:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Vector2\r\n case Animation.ANIMATIONTYPE_VECTOR2:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Size\r\n case Animation.ANIMATIONTYPE_SIZE:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n // Color3\r\n case Animation.ANIMATIONTYPE_COLOR3:\r\n this._offsetsCache[keyOffset] = toValue.subtract(fromValue);\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n this._highLimitsCache[keyOffset] = toValue;\r\n }\r\n\r\n highLimitValue = this._highLimitsCache[keyOffset];\r\n offsetValue = this._offsetsCache[keyOffset];\r\n }\r\n\r\n if (offsetValue === undefined) {\r\n switch (animation.dataType) {\r\n // Float\r\n case Animation.ANIMATIONTYPE_FLOAT:\r\n offsetValue = 0;\r\n break;\r\n // Quaternion\r\n case Animation.ANIMATIONTYPE_QUATERNION:\r\n offsetValue = _staticOffsetValueQuaternion;\r\n break;\r\n // Vector3\r\n case Animation.ANIMATIONTYPE_VECTOR3:\r\n offsetValue = _staticOffsetValueVector3;\r\n break;\r\n // Vector2\r\n case Animation.ANIMATIONTYPE_VECTOR2:\r\n offsetValue = _staticOffsetValueVector2;\r\n break;\r\n // Size\r\n case Animation.ANIMATIONTYPE_SIZE:\r\n offsetValue = _staticOffsetValueSize;\r\n break;\r\n // Color3\r\n case Animation.ANIMATIONTYPE_COLOR3:\r\n offsetValue = _staticOffsetValueColor3;\r\n break;\r\n case Animation.ANIMATIONTYPE_COLOR4:\r\n offsetValue = _staticOffsetValueColor4;\r\n break;\r\n }\r\n }\r\n\r\n // Compute value\r\n let currentFrame: number;\r\n\r\n if (this._host && this._host.syncRoot) {\r\n // If we must sync with an animatable, calculate the current frame based on the frame of the root animatable\r\n const syncRoot = this._host.syncRoot;\r\n const hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);\r\n currentFrame = from + frameRange * hostNormalizedFrame;\r\n } else {\r\n if ((absoluteFrame > 0 && from > to) || (absoluteFrame < 0 && from < to)) {\r\n currentFrame = returnValue && frameRange !== 0 ? to + (absoluteFrame % frameRange) : from;\r\n } else {\r\n currentFrame = returnValue && frameRange !== 0 ? from + (absoluteFrame % frameRange) : to;\r\n }\r\n }\r\n\r\n const events = this._events;\r\n\r\n // Reset event/state if looping\r\n if ((speedRatio > 0 && this.currentFrame > currentFrame) || (speedRatio < 0 && this.currentFrame < currentFrame)) {\r\n this._onLoop();\r\n\r\n // Need to reset animation events\r\n for (let index = 0; index < events.length; index++) {\r\n if (!events[index].onlyOnce) {\r\n // reset event, the animation is looping\r\n events[index].isDone = false;\r\n }\r\n }\r\n\r\n this._animationState.key = speedRatio > 0 ? 0 : animation.getKeys().length - 1;\r\n }\r\n this._currentFrame = currentFrame;\r\n this._animationState.repeatCount = frameRange === 0 ? 0 : (absoluteFrame / frameRange) >> 0;\r\n this._animationState.highLimitValue = highLimitValue;\r\n this._animationState.offsetValue = offsetValue;\r\n\r\n const currentValue = animation._interpolate(currentFrame, this._animationState);\r\n\r\n // Set value\r\n this.setValue(currentValue, weight);\r\n\r\n // Check events\r\n if (events.length) {\r\n for (let index = 0; index < events.length; index++) {\r\n // Make sure current frame has passed event frame and that event frame is within the current range\r\n // Also, handle both forward and reverse animations\r\n if (\r\n (frameRange >= 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||\r\n (frameRange < 0 && currentFrame <= events[index].frame && events[index].frame <= from)\r\n ) {\r\n const event = events[index];\r\n if (!event.isDone) {\r\n // If event should be done only once, remove it.\r\n if (event.onlyOnce) {\r\n events.splice(index, 1);\r\n index--;\r\n }\r\n event.isDone = true;\r\n event.action(currentFrame);\r\n } // Don't do anything if the event has already been done.\r\n }\r\n }\r\n }\r\n\r\n if (!returnValue) {\r\n this._stopped = true;\r\n }\r\n\r\n return returnValue;\r\n }\r\n}\r\n"]}
|
package/Debug/physicsViewer.js
CHANGED
|
@@ -661,7 +661,7 @@ export class PhysicsViewer {
|
|
|
661
661
|
vertexData.applyToMesh(mesh);
|
|
662
662
|
if (body._pluginDataInstances) {
|
|
663
663
|
const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);
|
|
664
|
-
mesh.thinInstanceSetBuffer("matrix", instanceBuffer, 16);
|
|
664
|
+
mesh.thinInstanceSetBuffer("matrix", instanceBuffer, 16, false);
|
|
665
665
|
}
|
|
666
666
|
mesh.material = this._getDebugMaterial(utilityLayerScene);
|
|
667
667
|
return mesh;
|
|
@@ -701,7 +701,7 @@ export class PhysicsViewer {
|
|
|
701
701
|
this._getMeshDebugInertiaMatrixToRef(props, matrixRef);
|
|
702
702
|
matrixRef.copyToArray(instanceBuffer, i * 16);
|
|
703
703
|
}
|
|
704
|
-
inertiaBoxMesh.thinInstanceSetBuffer("matrix", instanceBuffer, 16);
|
|
704
|
+
inertiaBoxMesh.thinInstanceSetBuffer("matrix", instanceBuffer, 16, false);
|
|
705
705
|
}
|
|
706
706
|
else {
|
|
707
707
|
const props = body.getMassProperties();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsViewer.js","sourceRoot":"","sources":["../../../../dev/core/src/Debug/physicsViewer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,aAA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C,CAAC;SAC5C;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;SAChC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;SACnC;QACD,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;SACrC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SACjC;QAED,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QAEjC,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC7B;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { Matrix, Quaternion, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from \"../Physics/v1/IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsMassProperties } from \"../Physics/v2/IPhysicsEnginePlugin\";\r\nimport { PhysicsImpostor } from \"../Physics/v1/physicsImpostor\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport type { ICreateCapsuleOptions } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { CreateCapsule } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { PhysicsBody } from \"../Physics/v2/physicsBody\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport { MeshBuilder } from \"../Meshes/meshBuilder\";\r\nimport type { PhysicsConstraint } from \"../Physics/v2/physicsConstraint\";\r\nimport { AxesViewer } from \"./axesViewer\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\n\r\n/**\r\n * Used to show the physics impostor around the specific mesh\r\n */\r\nexport class PhysicsViewer {\r\n /** @internal */\r\n protected _impostors: Array<Nullable<PhysicsImpostor>> = [];\r\n /** @internal */\r\n protected _meshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _bodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _constraints: Array<Nullable<PhysicsConstraint>> = [];\r\n /** @internal */\r\n protected _bodyMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _inertiaMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _constraintMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n /** @internal */\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _numConstraints = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _constraintRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\r\n\r\n private _debugBoxMesh: Mesh;\r\n private _debugSphereMesh: Mesh;\r\n private _debugCapsuleMesh: Mesh;\r\n private _debugCylinderMesh: Mesh;\r\n private _debugMaterial: StandardMaterial;\r\n private _debugInertiaMaterial: StandardMaterial;\r\n private _debugMeshMeshes = new Array<Mesh>();\r\n\r\n private _constraintAxesSize = 0.4;\r\n\r\n /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(scene?: Scene) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n const physicEngine = this._scene.getPhysicsEngine();\r\n\r\n if (physicEngine) {\r\n this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();\r\n }\r\n\r\n this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This code is useful for synchronizing the debug meshes of the physics engine with the physics impostor and mesh.\r\n * It checks if the impostor is disposed and if the plugin version is 1, then it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes are up to date with the physics engine.\r\n */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\r\n if (plugin?.getPluginVersion() === 1) {\r\n this._updateDebugMeshesV1();\r\n } else {\r\n this._updateDebugMeshesV2();\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This method is useful for synchronizing the debug meshes with the physics impostors.\r\n * It iterates through the impostors and meshes, and if the plugin version is 1, it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes accurately reflect the physics impostors, which is important for debugging the physics engine.\r\n */\r\n protected _updateDebugMeshesV1(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV1;\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n const impostor = this._impostors[i];\r\n\r\n if (!impostor) {\r\n continue;\r\n }\r\n\r\n if (impostor.isDisposed) {\r\n this.hideImpostor(this._impostors[i--]);\r\n } else {\r\n if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n continue;\r\n }\r\n const mesh = this._meshes[i];\r\n\r\n if (mesh && plugin) {\r\n plugin.syncMeshWithImpostor(mesh, impostor);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine for V2 plugin.\r\n *\r\n * This method is useful for synchronizing the debug meshes of the physics engine with the current state of the bodies.\r\n * It iterates through the bodies array and updates the debug meshes with the current transform of each body.\r\n * This ensures that the debug meshes accurately reflect the current state of the physics engine.\r\n */\r\n protected _updateDebugMeshesV2(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV2;\r\n for (let i = 0; i < this._numBodies; i++) {\r\n const body = this._bodies[i];\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n const body = this._inertiaBodies[i];\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\r\n }\r\n }\r\n\r\n protected _updateDebugInertia(body: PhysicsBody, inertiaMesh: AbstractMesh): void {\r\n const inertiaMatrixRef = Matrix.Identity();\r\n const transformMatrixRef = Matrix.Identity();\r\n const finalMatrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const inertiaAsMesh = inertiaMesh as Mesh;\r\n const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData!;\r\n const bodyTransformMatrixData = (body.transformNode as Mesh)._thinInstanceDataStorage.matrixData!;\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, transformMatrixRef);\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, finalMatrixRef);\r\n finalMatrixRef.copyToArray(inertiaMeshMatrixData, i * 16);\r\n }\r\n inertiaAsMesh.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n body.transformNode.rotationQuaternion?.toRotationMatrix(transformMatrixRef);\r\n transformMatrixRef.setTranslation(body.transformNode.position);\r\n if (body.transformNode.parent) {\r\n const parentTransform = body.transformNode.parent.computeWorldMatrix(true);\r\n transformMatrixRef.multiplyToRef(parentTransform, transformMatrixRef);\r\n }\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);\r\n inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraints() {\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n const constraint = this._constraints[i];\r\n const mesh = this._constraintMeshes[i];\r\n if (constraint && mesh) {\r\n this._updateDebugConstraint(constraint, mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given a scaling vector, make all of its components\r\n * 1, preserving the sign\r\n * @param scaling\r\n */\r\n protected _makeScalingUnitInPlace(scaling: Vector3) {\r\n if (Math.abs(scaling.x - 1) > Epsilon) {\r\n scaling.x = 1 * Math.sign(scaling.x);\r\n }\r\n if (Math.abs(scaling.y - 1) > Epsilon) {\r\n scaling.y = 1 * Math.sign(scaling.y);\r\n }\r\n if (Math.abs(scaling.z - 1) > Epsilon) {\r\n scaling.z = 1 * Math.sign(scaling.z);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh: AbstractMesh) {\r\n if (!constraint._initOptions) {\r\n return;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return;\r\n }\r\n\r\n parentingMesh.getDescendants(true).forEach((parentConstraintMesh) => {\r\n // Get the parent transform\r\n const parentCoordSystemNode = parentConstraintMesh.getDescendants(true)[0] as TransformNode;\r\n const childCoordSystemNode = parentConstraintMesh.getDescendants(true)[1] as TransformNode;\r\n\r\n const { parentBody, parentBodyIndex } = parentCoordSystemNode.metadata;\r\n const { childBody, childBodyIndex } = childCoordSystemNode.metadata;\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n this._makeScalingUnitInPlace(parentCoordSystemNode.scaling);\r\n\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n this._makeScalingUnitInPlace(childCoordSystemNode.scaling);\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = parentCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n parentTransformNode.position.copyFrom(pivotA);\r\n\r\n const childTransformNode = childCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n childTransformNode.position.copyFrom(pivotB);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]),\r\n parentTransformNode.rotationQuaternion!\r\n );\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]),\r\n childTransformNode.rotationQuaternion!\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Renders a specified physic impostor\r\n * @param impostor defines the impostor to render\r\n * @param targetMesh defines the mesh represented by the impostor\r\n * @returns the new debug mesh used to render the impostor\r\n */\r\n public showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugMesh(impostor, targetMesh);\r\n\r\n if (debugMesh) {\r\n this._impostors[this._numMeshes] = impostor;\r\n this._meshes[this._numMeshes] = debugMesh;\r\n\r\n if (this._numMeshes === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numMeshes++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics body.\r\n * @param body The physics body to show.\r\n * @returns The debug mesh, or null if the body is already shown.\r\n *\r\n * This function is useful for visualizing the physics body in the scene.\r\n * It creates a debug mesh for the given body and adds it to the scene.\r\n * It also registers a before render function to update the debug mesh position and rotation.\r\n */\r\n public showBody(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugBodyMesh(body);\r\n\r\n if (debugMesh) {\r\n this._bodies[this._numBodies] = body;\r\n this._bodyMeshes[this._numBodies] = debugMesh;\r\n\r\n if (this._numBodies === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug box corresponding to the inertia of a given body\r\n * @param body the physics body used to get the inertia\r\n * @returns the debug mesh used to show the inertia, or null if the body is already shown\r\n */\r\n public showInertia(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugInertiaMesh(body);\r\n if (debugMesh) {\r\n this._inertiaBodies[this._numInertiaBodies] = body;\r\n this._inertiaMeshes[this._numInertiaBodies] = debugMesh;\r\n\r\n if (this._numInertiaBodies === 0) {\r\n this._inertiaRenderFunction = () => this._updateInertiaMeshes();\r\n this._scene.registerBeforeRender(this._inertiaRenderFunction);\r\n }\r\n\r\n this._numInertiaBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics constraint.\r\n * @param constraint the physics constraint to show\r\n * @returns the debug mesh, or null if the constraint is already shown\r\n */\r\n public showConstraint(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] == constraint) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugConstraintMesh(constraint);\r\n if (debugMesh) {\r\n this._constraints[this._numConstraints] = constraint;\r\n this._constraintMeshes[this._numConstraints] = debugMesh;\r\n\r\n if (this._numConstraints === 0) {\r\n this._constraintRenderFunction = () => this._updateDebugConstraints();\r\n this._scene.registerBeforeRender(this._constraintRenderFunction);\r\n }\r\n\r\n this._numConstraints++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Hides an impostor from the scene.\r\n * @param impostor - The impostor to hide.\r\n *\r\n * This method is useful for hiding an impostor from the scene. It removes the\r\n * impostor from the utility layer scene, disposes the mesh, and removes the\r\n * impostor from the list of impostors. If the impostor is the last one in the\r\n * list, it also unregisters the render function.\r\n */\r\n public hideImpostor(impostor: Nullable<PhysicsImpostor>) {\r\n if (!impostor || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n const mesh = this._meshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n const index = this._debugMeshMeshes.indexOf(mesh as Mesh);\r\n if (index > -1) {\r\n this._debugMeshMeshes.splice(index, 1);\r\n }\r\n\r\n this._numMeshes--;\r\n if (this._numMeshes > 0) {\r\n this._meshes[i] = this._meshes[this._numMeshes];\r\n this._impostors[i] = this._impostors[this._numMeshes];\r\n this._meshes[this._numMeshes] = null;\r\n this._impostors[this._numMeshes] = null;\r\n } else {\r\n this._meshes[0] = null;\r\n this._impostors[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numMeshes === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body from the physics engine.\r\n * @param body - The body to hide.\r\n *\r\n * This function is useful for hiding a body from the physics engine.\r\n * It removes the body from the utility layer scene and disposes the mesh associated with it.\r\n * It also unregisters the render function if the number of bodies is 0.\r\n * This is useful for hiding a body from the physics engine without deleting it.\r\n */\r\n public hideBody(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] === body) {\r\n const mesh = this._bodyMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._numBodies--;\r\n if (this._numBodies > 0) {\r\n this._bodyMeshes[i] = this._bodyMeshes[this._numBodies];\r\n this._bodies[i] = this._bodies[this._numBodies];\r\n this._bodyMeshes[this._numBodies] = null;\r\n this._bodies[this._numBodies] = null;\r\n } else {\r\n this._bodyMeshes[0] = null;\r\n this._bodies[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body's inertia from the viewer utility layer\r\n * @param body the body to hide\r\n */\r\n public hideInertia(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] === body) {\r\n const mesh = this._inertiaMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._inertiaBodies.splice(i, 1);\r\n this._inertiaMeshes.splice(i, 1);\r\n\r\n this._numInertiaBodies--;\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numInertiaBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._inertiaRenderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hide a physics constraint from the viewer utility layer\r\n * @param constraint the constraint to hide\r\n */\r\n public hideConstraint(constraint: Nullable<PhysicsConstraint>) {\r\n if (!constraint || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] === constraint) {\r\n const mesh = this._constraintMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._constraints.splice(i, 1);\r\n this._constraintMeshes.splice(i, 1);\r\n\r\n this._numConstraints--;\r\n\r\n if (this._numConstraints > 0) {\r\n this._constraints[i] = this._constraints[this._numConstraints];\r\n this._constraintMeshes[i] = this._constraintMeshes[this._numConstraints];\r\n this._constraints[this._numConstraints] = null;\r\n this._constraintMeshes[this._numConstraints] = null;\r\n } else {\r\n this._constraints[0] = null;\r\n this._constraintMeshes[0] = null;\r\n }\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numConstraints === 0) {\r\n this._scene.unregisterBeforeRender(this._constraintRenderFunction);\r\n }\r\n }\r\n\r\n private _getDebugMaterial(scene: Scene): Material {\r\n if (!this._debugMaterial) {\r\n this._debugMaterial = new StandardMaterial(\"\", scene);\r\n this._debugMaterial.wireframe = true;\r\n this._debugMaterial.emissiveColor = Color3.White();\r\n this._debugMaterial.disableLighting = true;\r\n }\r\n\r\n return this._debugMaterial;\r\n }\r\n\r\n private _getDebugInertiaMaterial(scene: Scene): Material {\r\n if (!this._debugInertiaMaterial) {\r\n this._debugInertiaMaterial = new StandardMaterial(\"\", scene);\r\n this._debugInertiaMaterial.disableLighting = true;\r\n this._debugInertiaMaterial.alpha = 0.0;\r\n }\r\n\r\n return this._debugInertiaMaterial;\r\n }\r\n\r\n private _getDebugBoxMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugBoxMesh) {\r\n this._debugBoxMesh = CreateBox(\"physicsBodyBoxViewMesh\", { size: 1 }, scene);\r\n this._debugBoxMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugBoxMesh.material = this._getDebugMaterial(scene);\r\n this._debugBoxMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugBoxMesh.createInstance(\"physicsBodyBoxViewInstance\");\r\n }\r\n\r\n private _getDebugSphereMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugSphereMesh) {\r\n this._debugSphereMesh = CreateSphere(\"physicsBodySphereViewMesh\", { diameter: 1 }, scene);\r\n this._debugSphereMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugSphereMesh.material = this._getDebugMaterial(scene);\r\n this._debugSphereMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugSphereMesh.createInstance(\"physicsBodySphereViewInstance\");\r\n }\r\n\r\n private _getDebugCapsuleMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCapsuleMesh) {\r\n this._debugCapsuleMesh = CreateCapsule(\"physicsBodyCapsuleViewMesh\", { height: 1 } as ICreateCapsuleOptions, scene);\r\n this._debugCapsuleMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCapsuleMesh.material = this._getDebugMaterial(scene);\r\n this._debugCapsuleMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCapsuleMesh.createInstance(\"physicsBodyCapsuleViewInstance\");\r\n }\r\n\r\n private _getDebugCylinderMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCylinderMesh) {\r\n this._debugCylinderMesh = CreateCylinder(\"physicsBodyCylinderViewMesh\", { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);\r\n this._debugCylinderMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCylinderMesh.material = this._getDebugMaterial(scene);\r\n this._debugCylinderMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCylinderMesh.createInstance(\"physicsBodyCylinderViewInstance\");\r\n }\r\n\r\n private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {\r\n const wireframeOver = new Mesh(mesh.name, scene, null, mesh);\r\n wireframeOver.setParent(mesh);\r\n wireframeOver.position = Vector3.Zero();\r\n wireframeOver.material = this._getDebugMaterial(scene);\r\n\r\n this._debugMeshMeshes.push(wireframeOver);\r\n\r\n return wireframeOver;\r\n }\r\n\r\n private _getDebugMesh(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n // Only create child impostor debug meshes when evaluating the parent\r\n if (targetMesh && targetMesh.parent && (targetMesh.parent as Mesh).physicsImpostor) {\r\n return null;\r\n }\r\n\r\n let mesh: Nullable<AbstractMesh> = null;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n if (!impostor.physicsBody) {\r\n Logger.Warn(\"Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor.\");\r\n return null;\r\n }\r\n switch (impostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n impostor.getBoxSizeToRef(mesh.scaling);\r\n break;\r\n case PhysicsImpostor.SphereImpostor: {\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n const radius = impostor.getRadius();\r\n mesh.scaling.x = radius * 2;\r\n mesh.scaling.y = radius * 2;\r\n mesh.scaling.z = radius * 2;\r\n break;\r\n }\r\n case PhysicsImpostor.CapsuleImpostor: {\r\n mesh = this._getDebugCapsuleMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * 2 * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * 2 * impostor.object.scaling.z;\r\n break;\r\n }\r\n case PhysicsImpostor.MeshImpostor:\r\n if (targetMesh) {\r\n mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);\r\n }\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n if (targetMesh) {\r\n // Handle compound impostors\r\n const childMeshes = targetMesh.getChildMeshes().filter((c) => {\r\n return c.physicsImpostor ? 1 : 0;\r\n });\r\n childMeshes.forEach((m) => {\r\n if (m.physicsImpostor && m.getClassName() === \"Mesh\") {\r\n const boundingInfo = m.getBoundingInfo();\r\n const min = boundingInfo.boundingBox.minimum;\r\n const max = boundingInfo.boundingBox.maximum;\r\n switch (m.physicsImpostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n mesh.position.copyFrom(min);\r\n mesh.position.addInPlace(max);\r\n mesh.position.scaleInPlace(0.5);\r\n break;\r\n case PhysicsImpostor.SphereImpostor:\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n break;\r\n case PhysicsImpostor.CylinderImpostor:\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n break;\r\n default:\r\n mesh = null;\r\n break;\r\n }\r\n if (mesh) {\r\n mesh.scaling.x = max.x - min.x;\r\n mesh.scaling.y = max.y - min.y;\r\n mesh.scaling.z = max.z - min.z;\r\n mesh.parent = m;\r\n }\r\n }\r\n });\r\n } else {\r\n Logger.Warn(\"No target mesh parameter provided for NoImpostor. Skipping.\");\r\n }\r\n mesh = null;\r\n break;\r\n case PhysicsImpostor.CylinderImpostor: {\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * impostor.object.scaling.z;\r\n break;\r\n }\r\n }\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a debug mesh for a given physics body\r\n * @param body The physics body to create the debug mesh for\r\n * @returns The created debug mesh or null if the utility layer is not available\r\n *\r\n * This code is useful for creating a debug mesh for a given physics body.\r\n * It creates a Mesh object with a VertexData object containing the positions and indices\r\n * of the geometry of the body. The mesh is then assigned a debug material from the utility layer scene.\r\n * This allows for visualizing the physics body in the scene.\r\n */\r\n private _getDebugBodyMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n const mesh = new Mesh(\"custom\", utilityLayerScene);\r\n const vertexData = new VertexData();\r\n const geometry = body.getGeometry() as any;\r\n vertexData.positions = geometry.positions;\r\n vertexData.indices = geometry.indices;\r\n vertexData.applyToMesh(mesh);\r\n if (body._pluginDataInstances) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n mesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16);\r\n }\r\n mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\r\n }\r\n\r\n private _getMeshDebugInertiaMatrixToRef(massProps: PhysicsMassProperties, matrix: Matrix) {\r\n const orientation = massProps.inertiaOrientation ?? Quaternion.Identity();\r\n const inertiaLocal = massProps.inertia ?? Vector3.Zero();\r\n const center = massProps.centerOfMass ?? Vector3.Zero();\r\n\r\n const betaSqrd = (inertiaLocal.x - inertiaLocal.y + inertiaLocal.z) * 6;\r\n const beta = Math.sqrt(Math.max(betaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const gammaSqrd = inertiaLocal.x * 12 - betaSqrd;\r\n const gamma = Math.sqrt(Math.max(gammaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const alphaSqrd = inertiaLocal.z * 12 - betaSqrd;\r\n const alpha = Math.sqrt(Math.max(alphaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const extents = TmpVectors.Vector3[0];\r\n extents.set(alpha, beta, gamma);\r\n\r\n const scaling = Matrix.ScalingToRef(extents.x, extents.y, extents.z, TmpVectors.Matrix[0]);\r\n const rotation = orientation.toRotationMatrix(TmpVectors.Matrix[1]);\r\n const translation = Matrix.TranslationToRef(center.x, center.y, center.z, TmpVectors.Matrix[2]);\r\n\r\n scaling.multiplyToRef(rotation, matrix);\r\n matrix.multiplyToRef(translation, matrix);\r\n\r\n return matrix;\r\n }\r\n\r\n private _getDebugInertiaMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n // The base inertia mesh is going to be a 1x1 cube that's scaled and rotated according to the inertia\r\n const inertiaBoxMesh = MeshBuilder.CreateBox(\"custom\", { size: 1 }, utilityLayerScene);\r\n const matrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n for (let i = 0; i < body._pluginDataInstances.length; ++i) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.copyToArray(instanceBuffer, i * 16);\r\n }\r\n inertiaBoxMesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16);\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.decomposeToTransformNode(inertiaBoxMesh);\r\n }\r\n inertiaBoxMesh.enableEdgesRendering();\r\n inertiaBoxMesh.edgesWidth = 2.0;\r\n inertiaBoxMesh.edgesColor = new Color4(1, 0, 1, 1);\r\n inertiaBoxMesh.material = this._getDebugInertiaMaterial(utilityLayerScene);\r\n\r\n return inertiaBoxMesh;\r\n }\r\n\r\n private _getTransformFromBodyToRef(body: PhysicsBody, matrix: Matrix, instanceIndex?: number) {\r\n const tnode = body.transformNode;\r\n if (instanceIndex && instanceIndex >= 0) {\r\n return Matrix.FromArrayToRef((tnode as Mesh)._thinInstanceDataStorage.matrixData!, instanceIndex, matrix);\r\n } else {\r\n return matrix.copyFrom(tnode.getWorldMatrix());\r\n }\r\n }\r\n\r\n private _getDebugConstraintMesh(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n if (!constraint._initOptions) {\r\n return null;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return null;\r\n }\r\n\r\n // Create a mesh to parent all the constraint debug meshes to\r\n const parentingMesh = new Mesh(\"parentingDebugConstraint\", utilityLayerScene);\r\n\r\n // First, get a reference to all physic bodies that are using this constraint\r\n const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();\r\n\r\n for (const bodyPairInfo of bodiesUsingConstraint) {\r\n // Create a mesh to keep the pair of constraint axes\r\n const parentOfPair = new TransformNode(\"parentOfPair\", utilityLayerScene);\r\n parentOfPair.parent = parentingMesh;\r\n\r\n const { parentBody, parentBodyIndex, childBody, childBodyIndex } = bodyPairInfo;\r\n // Get the parent transform\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n const parentCoordSystemNode = new TransformNode(\"parentCoordSystem\", utilityLayerScene);\r\n // parentCoordSystemNode.parent = parentingMesh;\r\n parentCoordSystemNode.parent = parentOfPair;\r\n // Save parent and index here to be able to get the transform on update\r\n parentCoordSystemNode.metadata = { parentBody, parentBodyIndex };\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n\r\n const childCoordSystemNode = new TransformNode(\"childCoordSystem\", utilityLayerScene);\r\n // childCoordSystemNode.parent = parentingMesh;\r\n childCoordSystemNode.parent = parentOfPair;\r\n // Save child and index here to be able to get the transform on update\r\n childCoordSystemNode.metadata = { childBody, childBodyIndex };\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n const rotTransformParent = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisA, perpAxisA, axisA.cross(perpAxisA), TmpVectors.Matrix[0]));\r\n const rotTransformChild = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisB, perpAxisB, axisB.cross(perpAxisB), TmpVectors.Matrix[0]));\r\n\r\n const translateTransformParent = pivotA;\r\n const translateTransformChild = pivotB;\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = new TransformNode(\"constraint_parent\", utilityLayerScene);\r\n parentTransformNode.position.copyFrom(translateTransformParent);\r\n parentTransformNode.rotationQuaternion = rotTransformParent;\r\n parentTransformNode.parent = parentCoordSystemNode;\r\n\r\n const childTransformNode = new TransformNode(\"constraint_child\", utilityLayerScene);\r\n childTransformNode.parent = childCoordSystemNode;\r\n childTransformNode.position.copyFrom(translateTransformChild);\r\n childTransformNode.rotationQuaternion = rotTransformChild;\r\n\r\n // Create axes for the constraint\r\n const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n parentAxes.xAxis.parent = parentTransformNode;\r\n parentAxes.yAxis.parent = parentTransformNode;\r\n parentAxes.zAxis.parent = parentTransformNode;\r\n\r\n const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n childAxes.xAxis.parent = childTransformNode;\r\n childAxes.yAxis.parent = childTransformNode;\r\n childAxes.zAxis.parent = childTransformNode;\r\n }\r\n\r\n return parentingMesh;\r\n }\r\n\r\n /**\r\n * Clean up physics debug display\r\n */\r\n public dispose() {\r\n // impostors\r\n for (let index = this._numMeshes - 1; index >= 0; index--) {\r\n this.hideImpostor(this._impostors[0]);\r\n }\r\n // bodies\r\n for (let index = this._numBodies - 1; index >= 0; index--) {\r\n this.hideBody(this._bodies[0]);\r\n }\r\n // inertia\r\n for (let index = this._numInertiaBodies - 1; index >= 0; index--) {\r\n this.hideInertia(this._inertiaBodies[0]);\r\n }\r\n\r\n if (this._debugBoxMesh) {\r\n this._debugBoxMesh.dispose();\r\n }\r\n if (this._debugSphereMesh) {\r\n this._debugSphereMesh.dispose();\r\n }\r\n if (this._debugCylinderMesh) {\r\n this._debugCylinderMesh.dispose();\r\n }\r\n if (this._debugMaterial) {\r\n this._debugMaterial.dispose();\r\n }\r\n\r\n this._impostors.length = 0;\r\n this._scene = null;\r\n this._physicsEnginePlugin = null;\r\n\r\n if (this._utilityLayer) {\r\n this._utilityLayer.dispose();\r\n this._utilityLayer = null;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsViewer.js","sourceRoot":"","sources":["../../../../dev/core/src/Debug/physicsViewer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,aAAa;IA4CtB;;;OAGG;IACH,YAAY,KAAa;QA/CzB,gBAAgB;QACN,eAAU,GAA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,MAAM,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QAEjC,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC7B;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { Matrix, Quaternion, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from \"../Physics/v1/IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsMassProperties } from \"../Physics/v2/IPhysicsEnginePlugin\";\r\nimport { PhysicsImpostor } from \"../Physics/v1/physicsImpostor\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport type { ICreateCapsuleOptions } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { CreateCapsule } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { PhysicsBody } from \"../Physics/v2/physicsBody\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport { MeshBuilder } from \"../Meshes/meshBuilder\";\r\nimport type { PhysicsConstraint } from \"../Physics/v2/physicsConstraint\";\r\nimport { AxesViewer } from \"./axesViewer\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\n\r\n/**\r\n * Used to show the physics impostor around the specific mesh\r\n */\r\nexport class PhysicsViewer {\r\n /** @internal */\r\n protected _impostors: Array<Nullable<PhysicsImpostor>> = [];\r\n /** @internal */\r\n protected _meshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _bodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _constraints: Array<Nullable<PhysicsConstraint>> = [];\r\n /** @internal */\r\n protected _bodyMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _inertiaMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _constraintMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n /** @internal */\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _numConstraints = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _constraintRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\r\n\r\n private _debugBoxMesh: Mesh;\r\n private _debugSphereMesh: Mesh;\r\n private _debugCapsuleMesh: Mesh;\r\n private _debugCylinderMesh: Mesh;\r\n private _debugMaterial: StandardMaterial;\r\n private _debugInertiaMaterial: StandardMaterial;\r\n private _debugMeshMeshes = new Array<Mesh>();\r\n\r\n private _constraintAxesSize = 0.4;\r\n\r\n /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(scene?: Scene) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n const physicEngine = this._scene.getPhysicsEngine();\r\n\r\n if (physicEngine) {\r\n this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();\r\n }\r\n\r\n this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This code is useful for synchronizing the debug meshes of the physics engine with the physics impostor and mesh.\r\n * It checks if the impostor is disposed and if the plugin version is 1, then it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes are up to date with the physics engine.\r\n */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\r\n if (plugin?.getPluginVersion() === 1) {\r\n this._updateDebugMeshesV1();\r\n } else {\r\n this._updateDebugMeshesV2();\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This method is useful for synchronizing the debug meshes with the physics impostors.\r\n * It iterates through the impostors and meshes, and if the plugin version is 1, it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes accurately reflect the physics impostors, which is important for debugging the physics engine.\r\n */\r\n protected _updateDebugMeshesV1(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV1;\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n const impostor = this._impostors[i];\r\n\r\n if (!impostor) {\r\n continue;\r\n }\r\n\r\n if (impostor.isDisposed) {\r\n this.hideImpostor(this._impostors[i--]);\r\n } else {\r\n if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n continue;\r\n }\r\n const mesh = this._meshes[i];\r\n\r\n if (mesh && plugin) {\r\n plugin.syncMeshWithImpostor(mesh, impostor);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine for V2 plugin.\r\n *\r\n * This method is useful for synchronizing the debug meshes of the physics engine with the current state of the bodies.\r\n * It iterates through the bodies array and updates the debug meshes with the current transform of each body.\r\n * This ensures that the debug meshes accurately reflect the current state of the physics engine.\r\n */\r\n protected _updateDebugMeshesV2(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV2;\r\n for (let i = 0; i < this._numBodies; i++) {\r\n const body = this._bodies[i];\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n const body = this._inertiaBodies[i];\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\r\n }\r\n }\r\n\r\n protected _updateDebugInertia(body: PhysicsBody, inertiaMesh: AbstractMesh): void {\r\n const inertiaMatrixRef = Matrix.Identity();\r\n const transformMatrixRef = Matrix.Identity();\r\n const finalMatrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const inertiaAsMesh = inertiaMesh as Mesh;\r\n const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData!;\r\n const bodyTransformMatrixData = (body.transformNode as Mesh)._thinInstanceDataStorage.matrixData!;\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, transformMatrixRef);\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, finalMatrixRef);\r\n finalMatrixRef.copyToArray(inertiaMeshMatrixData, i * 16);\r\n }\r\n inertiaAsMesh.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n body.transformNode.rotationQuaternion?.toRotationMatrix(transformMatrixRef);\r\n transformMatrixRef.setTranslation(body.transformNode.position);\r\n if (body.transformNode.parent) {\r\n const parentTransform = body.transformNode.parent.computeWorldMatrix(true);\r\n transformMatrixRef.multiplyToRef(parentTransform, transformMatrixRef);\r\n }\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);\r\n inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraints() {\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n const constraint = this._constraints[i];\r\n const mesh = this._constraintMeshes[i];\r\n if (constraint && mesh) {\r\n this._updateDebugConstraint(constraint, mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given a scaling vector, make all of its components\r\n * 1, preserving the sign\r\n * @param scaling\r\n */\r\n protected _makeScalingUnitInPlace(scaling: Vector3) {\r\n if (Math.abs(scaling.x - 1) > Epsilon) {\r\n scaling.x = 1 * Math.sign(scaling.x);\r\n }\r\n if (Math.abs(scaling.y - 1) > Epsilon) {\r\n scaling.y = 1 * Math.sign(scaling.y);\r\n }\r\n if (Math.abs(scaling.z - 1) > Epsilon) {\r\n scaling.z = 1 * Math.sign(scaling.z);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh: AbstractMesh) {\r\n if (!constraint._initOptions) {\r\n return;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return;\r\n }\r\n\r\n parentingMesh.getDescendants(true).forEach((parentConstraintMesh) => {\r\n // Get the parent transform\r\n const parentCoordSystemNode = parentConstraintMesh.getDescendants(true)[0] as TransformNode;\r\n const childCoordSystemNode = parentConstraintMesh.getDescendants(true)[1] as TransformNode;\r\n\r\n const { parentBody, parentBodyIndex } = parentCoordSystemNode.metadata;\r\n const { childBody, childBodyIndex } = childCoordSystemNode.metadata;\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n this._makeScalingUnitInPlace(parentCoordSystemNode.scaling);\r\n\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n this._makeScalingUnitInPlace(childCoordSystemNode.scaling);\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = parentCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n parentTransformNode.position.copyFrom(pivotA);\r\n\r\n const childTransformNode = childCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n childTransformNode.position.copyFrom(pivotB);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]),\r\n parentTransformNode.rotationQuaternion!\r\n );\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]),\r\n childTransformNode.rotationQuaternion!\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Renders a specified physic impostor\r\n * @param impostor defines the impostor to render\r\n * @param targetMesh defines the mesh represented by the impostor\r\n * @returns the new debug mesh used to render the impostor\r\n */\r\n public showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugMesh(impostor, targetMesh);\r\n\r\n if (debugMesh) {\r\n this._impostors[this._numMeshes] = impostor;\r\n this._meshes[this._numMeshes] = debugMesh;\r\n\r\n if (this._numMeshes === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numMeshes++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics body.\r\n * @param body The physics body to show.\r\n * @returns The debug mesh, or null if the body is already shown.\r\n *\r\n * This function is useful for visualizing the physics body in the scene.\r\n * It creates a debug mesh for the given body and adds it to the scene.\r\n * It also registers a before render function to update the debug mesh position and rotation.\r\n */\r\n public showBody(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugBodyMesh(body);\r\n\r\n if (debugMesh) {\r\n this._bodies[this._numBodies] = body;\r\n this._bodyMeshes[this._numBodies] = debugMesh;\r\n\r\n if (this._numBodies === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug box corresponding to the inertia of a given body\r\n * @param body the physics body used to get the inertia\r\n * @returns the debug mesh used to show the inertia, or null if the body is already shown\r\n */\r\n public showInertia(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugInertiaMesh(body);\r\n if (debugMesh) {\r\n this._inertiaBodies[this._numInertiaBodies] = body;\r\n this._inertiaMeshes[this._numInertiaBodies] = debugMesh;\r\n\r\n if (this._numInertiaBodies === 0) {\r\n this._inertiaRenderFunction = () => this._updateInertiaMeshes();\r\n this._scene.registerBeforeRender(this._inertiaRenderFunction);\r\n }\r\n\r\n this._numInertiaBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics constraint.\r\n * @param constraint the physics constraint to show\r\n * @returns the debug mesh, or null if the constraint is already shown\r\n */\r\n public showConstraint(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] == constraint) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugConstraintMesh(constraint);\r\n if (debugMesh) {\r\n this._constraints[this._numConstraints] = constraint;\r\n this._constraintMeshes[this._numConstraints] = debugMesh;\r\n\r\n if (this._numConstraints === 0) {\r\n this._constraintRenderFunction = () => this._updateDebugConstraints();\r\n this._scene.registerBeforeRender(this._constraintRenderFunction);\r\n }\r\n\r\n this._numConstraints++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Hides an impostor from the scene.\r\n * @param impostor - The impostor to hide.\r\n *\r\n * This method is useful for hiding an impostor from the scene. It removes the\r\n * impostor from the utility layer scene, disposes the mesh, and removes the\r\n * impostor from the list of impostors. If the impostor is the last one in the\r\n * list, it also unregisters the render function.\r\n */\r\n public hideImpostor(impostor: Nullable<PhysicsImpostor>) {\r\n if (!impostor || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n const mesh = this._meshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n const index = this._debugMeshMeshes.indexOf(mesh as Mesh);\r\n if (index > -1) {\r\n this._debugMeshMeshes.splice(index, 1);\r\n }\r\n\r\n this._numMeshes--;\r\n if (this._numMeshes > 0) {\r\n this._meshes[i] = this._meshes[this._numMeshes];\r\n this._impostors[i] = this._impostors[this._numMeshes];\r\n this._meshes[this._numMeshes] = null;\r\n this._impostors[this._numMeshes] = null;\r\n } else {\r\n this._meshes[0] = null;\r\n this._impostors[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numMeshes === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body from the physics engine.\r\n * @param body - The body to hide.\r\n *\r\n * This function is useful for hiding a body from the physics engine.\r\n * It removes the body from the utility layer scene and disposes the mesh associated with it.\r\n * It also unregisters the render function if the number of bodies is 0.\r\n * This is useful for hiding a body from the physics engine without deleting it.\r\n */\r\n public hideBody(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] === body) {\r\n const mesh = this._bodyMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._numBodies--;\r\n if (this._numBodies > 0) {\r\n this._bodyMeshes[i] = this._bodyMeshes[this._numBodies];\r\n this._bodies[i] = this._bodies[this._numBodies];\r\n this._bodyMeshes[this._numBodies] = null;\r\n this._bodies[this._numBodies] = null;\r\n } else {\r\n this._bodyMeshes[0] = null;\r\n this._bodies[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body's inertia from the viewer utility layer\r\n * @param body the body to hide\r\n */\r\n public hideInertia(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] === body) {\r\n const mesh = this._inertiaMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._inertiaBodies.splice(i, 1);\r\n this._inertiaMeshes.splice(i, 1);\r\n\r\n this._numInertiaBodies--;\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numInertiaBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._inertiaRenderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hide a physics constraint from the viewer utility layer\r\n * @param constraint the constraint to hide\r\n */\r\n public hideConstraint(constraint: Nullable<PhysicsConstraint>) {\r\n if (!constraint || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] === constraint) {\r\n const mesh = this._constraintMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._constraints.splice(i, 1);\r\n this._constraintMeshes.splice(i, 1);\r\n\r\n this._numConstraints--;\r\n\r\n if (this._numConstraints > 0) {\r\n this._constraints[i] = this._constraints[this._numConstraints];\r\n this._constraintMeshes[i] = this._constraintMeshes[this._numConstraints];\r\n this._constraints[this._numConstraints] = null;\r\n this._constraintMeshes[this._numConstraints] = null;\r\n } else {\r\n this._constraints[0] = null;\r\n this._constraintMeshes[0] = null;\r\n }\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numConstraints === 0) {\r\n this._scene.unregisterBeforeRender(this._constraintRenderFunction);\r\n }\r\n }\r\n\r\n private _getDebugMaterial(scene: Scene): Material {\r\n if (!this._debugMaterial) {\r\n this._debugMaterial = new StandardMaterial(\"\", scene);\r\n this._debugMaterial.wireframe = true;\r\n this._debugMaterial.emissiveColor = Color3.White();\r\n this._debugMaterial.disableLighting = true;\r\n }\r\n\r\n return this._debugMaterial;\r\n }\r\n\r\n private _getDebugInertiaMaterial(scene: Scene): Material {\r\n if (!this._debugInertiaMaterial) {\r\n this._debugInertiaMaterial = new StandardMaterial(\"\", scene);\r\n this._debugInertiaMaterial.disableLighting = true;\r\n this._debugInertiaMaterial.alpha = 0.0;\r\n }\r\n\r\n return this._debugInertiaMaterial;\r\n }\r\n\r\n private _getDebugBoxMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugBoxMesh) {\r\n this._debugBoxMesh = CreateBox(\"physicsBodyBoxViewMesh\", { size: 1 }, scene);\r\n this._debugBoxMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugBoxMesh.material = this._getDebugMaterial(scene);\r\n this._debugBoxMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugBoxMesh.createInstance(\"physicsBodyBoxViewInstance\");\r\n }\r\n\r\n private _getDebugSphereMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugSphereMesh) {\r\n this._debugSphereMesh = CreateSphere(\"physicsBodySphereViewMesh\", { diameter: 1 }, scene);\r\n this._debugSphereMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugSphereMesh.material = this._getDebugMaterial(scene);\r\n this._debugSphereMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugSphereMesh.createInstance(\"physicsBodySphereViewInstance\");\r\n }\r\n\r\n private _getDebugCapsuleMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCapsuleMesh) {\r\n this._debugCapsuleMesh = CreateCapsule(\"physicsBodyCapsuleViewMesh\", { height: 1 } as ICreateCapsuleOptions, scene);\r\n this._debugCapsuleMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCapsuleMesh.material = this._getDebugMaterial(scene);\r\n this._debugCapsuleMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCapsuleMesh.createInstance(\"physicsBodyCapsuleViewInstance\");\r\n }\r\n\r\n private _getDebugCylinderMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCylinderMesh) {\r\n this._debugCylinderMesh = CreateCylinder(\"physicsBodyCylinderViewMesh\", { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);\r\n this._debugCylinderMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCylinderMesh.material = this._getDebugMaterial(scene);\r\n this._debugCylinderMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCylinderMesh.createInstance(\"physicsBodyCylinderViewInstance\");\r\n }\r\n\r\n private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {\r\n const wireframeOver = new Mesh(mesh.name, scene, null, mesh);\r\n wireframeOver.setParent(mesh);\r\n wireframeOver.position = Vector3.Zero();\r\n wireframeOver.material = this._getDebugMaterial(scene);\r\n\r\n this._debugMeshMeshes.push(wireframeOver);\r\n\r\n return wireframeOver;\r\n }\r\n\r\n private _getDebugMesh(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n // Only create child impostor debug meshes when evaluating the parent\r\n if (targetMesh && targetMesh.parent && (targetMesh.parent as Mesh).physicsImpostor) {\r\n return null;\r\n }\r\n\r\n let mesh: Nullable<AbstractMesh> = null;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n if (!impostor.physicsBody) {\r\n Logger.Warn(\"Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor.\");\r\n return null;\r\n }\r\n switch (impostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n impostor.getBoxSizeToRef(mesh.scaling);\r\n break;\r\n case PhysicsImpostor.SphereImpostor: {\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n const radius = impostor.getRadius();\r\n mesh.scaling.x = radius * 2;\r\n mesh.scaling.y = radius * 2;\r\n mesh.scaling.z = radius * 2;\r\n break;\r\n }\r\n case PhysicsImpostor.CapsuleImpostor: {\r\n mesh = this._getDebugCapsuleMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * 2 * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * 2 * impostor.object.scaling.z;\r\n break;\r\n }\r\n case PhysicsImpostor.MeshImpostor:\r\n if (targetMesh) {\r\n mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);\r\n }\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n if (targetMesh) {\r\n // Handle compound impostors\r\n const childMeshes = targetMesh.getChildMeshes().filter((c) => {\r\n return c.physicsImpostor ? 1 : 0;\r\n });\r\n childMeshes.forEach((m) => {\r\n if (m.physicsImpostor && m.getClassName() === \"Mesh\") {\r\n const boundingInfo = m.getBoundingInfo();\r\n const min = boundingInfo.boundingBox.minimum;\r\n const max = boundingInfo.boundingBox.maximum;\r\n switch (m.physicsImpostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n mesh.position.copyFrom(min);\r\n mesh.position.addInPlace(max);\r\n mesh.position.scaleInPlace(0.5);\r\n break;\r\n case PhysicsImpostor.SphereImpostor:\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n break;\r\n case PhysicsImpostor.CylinderImpostor:\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n break;\r\n default:\r\n mesh = null;\r\n break;\r\n }\r\n if (mesh) {\r\n mesh.scaling.x = max.x - min.x;\r\n mesh.scaling.y = max.y - min.y;\r\n mesh.scaling.z = max.z - min.z;\r\n mesh.parent = m;\r\n }\r\n }\r\n });\r\n } else {\r\n Logger.Warn(\"No target mesh parameter provided for NoImpostor. Skipping.\");\r\n }\r\n mesh = null;\r\n break;\r\n case PhysicsImpostor.CylinderImpostor: {\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * impostor.object.scaling.z;\r\n break;\r\n }\r\n }\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a debug mesh for a given physics body\r\n * @param body The physics body to create the debug mesh for\r\n * @returns The created debug mesh or null if the utility layer is not available\r\n *\r\n * This code is useful for creating a debug mesh for a given physics body.\r\n * It creates a Mesh object with a VertexData object containing the positions and indices\r\n * of the geometry of the body. The mesh is then assigned a debug material from the utility layer scene.\r\n * This allows for visualizing the physics body in the scene.\r\n */\r\n private _getDebugBodyMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n const mesh = new Mesh(\"custom\", utilityLayerScene);\r\n const vertexData = new VertexData();\r\n const geometry = body.getGeometry() as any;\r\n vertexData.positions = geometry.positions;\r\n vertexData.indices = geometry.indices;\r\n vertexData.applyToMesh(mesh);\r\n if (body._pluginDataInstances) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n mesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16, false);\r\n }\r\n mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\r\n }\r\n\r\n private _getMeshDebugInertiaMatrixToRef(massProps: PhysicsMassProperties, matrix: Matrix) {\r\n const orientation = massProps.inertiaOrientation ?? Quaternion.Identity();\r\n const inertiaLocal = massProps.inertia ?? Vector3.Zero();\r\n const center = massProps.centerOfMass ?? Vector3.Zero();\r\n\r\n const betaSqrd = (inertiaLocal.x - inertiaLocal.y + inertiaLocal.z) * 6;\r\n const beta = Math.sqrt(Math.max(betaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const gammaSqrd = inertiaLocal.x * 12 - betaSqrd;\r\n const gamma = Math.sqrt(Math.max(gammaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const alphaSqrd = inertiaLocal.z * 12 - betaSqrd;\r\n const alpha = Math.sqrt(Math.max(alphaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const extents = TmpVectors.Vector3[0];\r\n extents.set(alpha, beta, gamma);\r\n\r\n const scaling = Matrix.ScalingToRef(extents.x, extents.y, extents.z, TmpVectors.Matrix[0]);\r\n const rotation = orientation.toRotationMatrix(TmpVectors.Matrix[1]);\r\n const translation = Matrix.TranslationToRef(center.x, center.y, center.z, TmpVectors.Matrix[2]);\r\n\r\n scaling.multiplyToRef(rotation, matrix);\r\n matrix.multiplyToRef(translation, matrix);\r\n\r\n return matrix;\r\n }\r\n\r\n private _getDebugInertiaMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n // The base inertia mesh is going to be a 1x1 cube that's scaled and rotated according to the inertia\r\n const inertiaBoxMesh = MeshBuilder.CreateBox(\"custom\", { size: 1 }, utilityLayerScene);\r\n const matrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n for (let i = 0; i < body._pluginDataInstances.length; ++i) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.copyToArray(instanceBuffer, i * 16);\r\n }\r\n inertiaBoxMesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16, false);\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.decomposeToTransformNode(inertiaBoxMesh);\r\n }\r\n inertiaBoxMesh.enableEdgesRendering();\r\n inertiaBoxMesh.edgesWidth = 2.0;\r\n inertiaBoxMesh.edgesColor = new Color4(1, 0, 1, 1);\r\n inertiaBoxMesh.material = this._getDebugInertiaMaterial(utilityLayerScene);\r\n\r\n return inertiaBoxMesh;\r\n }\r\n\r\n private _getTransformFromBodyToRef(body: PhysicsBody, matrix: Matrix, instanceIndex?: number) {\r\n const tnode = body.transformNode;\r\n if (instanceIndex && instanceIndex >= 0) {\r\n return Matrix.FromArrayToRef((tnode as Mesh)._thinInstanceDataStorage.matrixData!, instanceIndex, matrix);\r\n } else {\r\n return matrix.copyFrom(tnode.getWorldMatrix());\r\n }\r\n }\r\n\r\n private _getDebugConstraintMesh(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n if (!constraint._initOptions) {\r\n return null;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return null;\r\n }\r\n\r\n // Create a mesh to parent all the constraint debug meshes to\r\n const parentingMesh = new Mesh(\"parentingDebugConstraint\", utilityLayerScene);\r\n\r\n // First, get a reference to all physic bodies that are using this constraint\r\n const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();\r\n\r\n for (const bodyPairInfo of bodiesUsingConstraint) {\r\n // Create a mesh to keep the pair of constraint axes\r\n const parentOfPair = new TransformNode(\"parentOfPair\", utilityLayerScene);\r\n parentOfPair.parent = parentingMesh;\r\n\r\n const { parentBody, parentBodyIndex, childBody, childBodyIndex } = bodyPairInfo;\r\n // Get the parent transform\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n const parentCoordSystemNode = new TransformNode(\"parentCoordSystem\", utilityLayerScene);\r\n // parentCoordSystemNode.parent = parentingMesh;\r\n parentCoordSystemNode.parent = parentOfPair;\r\n // Save parent and index here to be able to get the transform on update\r\n parentCoordSystemNode.metadata = { parentBody, parentBodyIndex };\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n\r\n const childCoordSystemNode = new TransformNode(\"childCoordSystem\", utilityLayerScene);\r\n // childCoordSystemNode.parent = parentingMesh;\r\n childCoordSystemNode.parent = parentOfPair;\r\n // Save child and index here to be able to get the transform on update\r\n childCoordSystemNode.metadata = { childBody, childBodyIndex };\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n const rotTransformParent = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisA, perpAxisA, axisA.cross(perpAxisA), TmpVectors.Matrix[0]));\r\n const rotTransformChild = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisB, perpAxisB, axisB.cross(perpAxisB), TmpVectors.Matrix[0]));\r\n\r\n const translateTransformParent = pivotA;\r\n const translateTransformChild = pivotB;\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = new TransformNode(\"constraint_parent\", utilityLayerScene);\r\n parentTransformNode.position.copyFrom(translateTransformParent);\r\n parentTransformNode.rotationQuaternion = rotTransformParent;\r\n parentTransformNode.parent = parentCoordSystemNode;\r\n\r\n const childTransformNode = new TransformNode(\"constraint_child\", utilityLayerScene);\r\n childTransformNode.parent = childCoordSystemNode;\r\n childTransformNode.position.copyFrom(translateTransformChild);\r\n childTransformNode.rotationQuaternion = rotTransformChild;\r\n\r\n // Create axes for the constraint\r\n const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n parentAxes.xAxis.parent = parentTransformNode;\r\n parentAxes.yAxis.parent = parentTransformNode;\r\n parentAxes.zAxis.parent = parentTransformNode;\r\n\r\n const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n childAxes.xAxis.parent = childTransformNode;\r\n childAxes.yAxis.parent = childTransformNode;\r\n childAxes.zAxis.parent = childTransformNode;\r\n }\r\n\r\n return parentingMesh;\r\n }\r\n\r\n /**\r\n * Clean up physics debug display\r\n */\r\n public dispose() {\r\n // impostors\r\n for (let index = this._numMeshes - 1; index >= 0; index--) {\r\n this.hideImpostor(this._impostors[0]);\r\n }\r\n // bodies\r\n for (let index = this._numBodies - 1; index >= 0; index--) {\r\n this.hideBody(this._bodies[0]);\r\n }\r\n // inertia\r\n for (let index = this._numInertiaBodies - 1; index >= 0; index--) {\r\n this.hideInertia(this._inertiaBodies[0]);\r\n }\r\n\r\n if (this._debugBoxMesh) {\r\n this._debugBoxMesh.dispose();\r\n }\r\n if (this._debugSphereMesh) {\r\n this._debugSphereMesh.dispose();\r\n }\r\n if (this._debugCylinderMesh) {\r\n this._debugCylinderMesh.dispose();\r\n }\r\n if (this._debugMaterial) {\r\n this._debugMaterial.dispose();\r\n }\r\n\r\n this._impostors.length = 0;\r\n this._scene = null;\r\n this._physicsEnginePlugin = null;\r\n\r\n if (this._utilityLayer) {\r\n this._utilityLayer.dispose();\r\n this._utilityLayer = null;\r\n }\r\n }\r\n}\r\n"]}
|