@babylonjs/core 7.7.0 → 7.7.2

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.
Files changed (86) hide show
  1. package/Animations/animatable.js +1 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/runtimeAnimation.d.ts +2 -1
  4. package/Animations/runtimeAnimation.js +3 -2
  5. package/Animations/runtimeAnimation.js.map +1 -1
  6. package/Buffers/buffer.nonFloatVertexBuffers.d.ts +12 -0
  7. package/Buffers/buffer.nonFloatVertexBuffers.js +81 -0
  8. package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -0
  9. package/Culling/boundingBox.d.ts +2 -2
  10. package/Culling/boundingBox.js +2 -2
  11. package/Culling/boundingBox.js.map +1 -1
  12. package/DeviceInput/webDeviceInputSystem.js +8 -2
  13. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  14. package/Engines/IPipelineContext.d.ts +12 -5
  15. package/Engines/IPipelineContext.js.map +1 -1
  16. package/Engines/Native/nativeInterfaces.d.ts +6 -1
  17. package/Engines/Native/nativeInterfaces.js.map +1 -1
  18. package/Engines/Native/nativePipelineContext.d.ts +6 -1
  19. package/Engines/Native/nativePipelineContext.js +3 -1
  20. package/Engines/Native/nativePipelineContext.js.map +1 -1
  21. package/Engines/Native/nativeShaderProcessingContext.d.ts +13 -0
  22. package/Engines/Native/nativeShaderProcessingContext.js +11 -0
  23. package/Engines/Native/nativeShaderProcessingContext.js.map +1 -0
  24. package/Engines/Native/nativeShaderProcessors.d.ts +15 -0
  25. package/Engines/Native/nativeShaderProcessors.js +75 -0
  26. package/Engines/Native/nativeShaderProcessors.js.map +1 -0
  27. package/Engines/Processors/shaderProcessingOptions.d.ts +3 -0
  28. package/Engines/Processors/shaderProcessingOptions.js.map +1 -1
  29. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +0 -2
  30. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +4 -59
  31. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  32. package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +3 -0
  33. package/Engines/WebGPU/webgpuShaderProcessingContext.js +1 -0
  34. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  35. package/Engines/WebGPU/webgpuShaderProcessor.d.ts +0 -4
  36. package/Engines/WebGPU/webgpuShaderProcessor.js +0 -26
  37. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  38. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +4 -3
  39. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  40. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -1
  41. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +7 -7
  42. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  43. package/Engines/abstractEngine.js +2 -2
  44. package/Engines/abstractEngine.js.map +1 -1
  45. package/Engines/engine.d.ts +1 -1
  46. package/Engines/engineFeatures.d.ts +2 -0
  47. package/Engines/engineFeatures.js.map +1 -1
  48. package/Engines/nativeEngine.d.ts +7 -1
  49. package/Engines/nativeEngine.js +30 -9
  50. package/Engines/nativeEngine.js.map +1 -1
  51. package/Engines/nullEngine.d.ts +4 -0
  52. package/Engines/nullEngine.js +4 -0
  53. package/Engines/nullEngine.js.map +1 -1
  54. package/Engines/thinEngine.d.ts +4 -4
  55. package/Engines/thinEngine.js +1 -0
  56. package/Engines/thinEngine.js.map +1 -1
  57. package/Engines/webgpuEngine.js +1 -0
  58. package/Engines/webgpuEngine.js.map +1 -1
  59. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +4 -2
  60. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  61. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +8 -6
  62. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
  63. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +15 -12
  64. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  65. package/Materials/Node/Blocks/voronoiNoiseBlock.js +17 -21
  66. package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
  67. package/Materials/effect.d.ts +2 -2
  68. package/Materials/effect.js +2 -2
  69. package/Materials/effect.js.map +1 -1
  70. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  71. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  72. package/Meshes/mesh.js +6 -1
  73. package/Meshes/mesh.js.map +1 -1
  74. package/Misc/codeStringParsingTools.d.ts +11 -0
  75. package/Misc/codeStringParsingTools.js +31 -0
  76. package/Misc/codeStringParsingTools.js.map +1 -1
  77. package/Misc/pressureObserverWrapper.js +1 -1
  78. package/Misc/pressureObserverWrapper.js.map +1 -1
  79. package/Particles/solidParticleSystem.d.ts +5 -5
  80. package/Particles/solidParticleSystem.js.map +1 -1
  81. package/Shaders/gaussianSplatting.vertex.js +3 -3
  82. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  83. package/assets/Draco/draco_decoder.js +2 -0
  84. package/assets/Draco/draco_wasm_wrapper.js +1 -1
  85. package/assets/Draco/draco_wasm_wrapper_gltf.js +1 -1
  86. package/package.json +1 -1
@@ -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;IA6GzB;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,M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ationState } 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 private _yoyoDirection: number = 1;\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;\r\n for (let index = 0; index < targetPropertyPath.length - 1; index++) {\r\n const name = targetPropertyPath[index];\r\n property = property[name];\r\n if (property === undefined) {\r\n throw new Error(`Invalid property (${name}) in property path (${targetPropertyPath.join(\".\")})`);\r\n }\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 if (this._activeTargets[targetIndex][this._targetPath] === undefined) {\r\n throw new Error(`Invalid property (${this._targetPath}) in property path (${targetPropertyPath.join(\".\")})`);\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 let yoyoLoop = false;\r\n const yoyoMode = loop && this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_YOYO;\r\n if (yoyoMode) {\r\n const position = (absoluteFrame - from) / frameRange;\r\n\r\n // Apply the yoyo curve\r\n const sin = Math.sin(position * Math.PI);\r\n const yoyoPosition = Math.abs(sin);\r\n\r\n // Map the yoyo position back to the range\r\n absoluteFrame = yoyoPosition * frameRange + from;\r\n\r\n const direction = sin >= 0 ? 1 : -1;\r\n if (this._yoyoDirection !== direction) {\r\n yoyoLoop = true;\r\n }\r\n\r\n this._yoyoDirection = direction;\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 ((!yoyoMode && ((speedRatio > 0 && this.currentFrame > currentFrame) || (speedRatio < 0 && this.currentFrame < currentFrame))) || (yoyoMode && yoyoLoop)) {\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,s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9B,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 private _yoyoDirection: number = 1;\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;\r\n for (let index = 0; index < targetPropertyPath.length - 1; index++) {\r\n const name = targetPropertyPath[index];\r\n property = property[name];\r\n if (property === undefined) {\r\n throw new Error(`Invalid property (${name}) in property path (${targetPropertyPath.join(\".\")})`);\r\n }\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 if (this._activeTargets[targetIndex][this._targetPath] === undefined) {\r\n throw new Error(`Invalid property (${this._targetPath}) in property path (${targetPropertyPath.join(\".\")})`);\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 * @param weight defines the weight to apply to the animation (-1.0 by default)\r\n */\r\n public goToFrame(frame: number, weight = -1): 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, weight);\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 let yoyoLoop = false;\r\n const yoyoMode = loop && this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_YOYO;\r\n if (yoyoMode) {\r\n const position = (absoluteFrame - from) / frameRange;\r\n\r\n // Apply the yoyo curve\r\n const sin = Math.sin(position * Math.PI);\r\n const yoyoPosition = Math.abs(sin);\r\n\r\n // Map the yoyo position back to the range\r\n absoluteFrame = yoyoPosition * frameRange + from;\r\n\r\n const direction = sin >= 0 ? 1 : -1;\r\n if (this._yoyoDirection !== direction) {\r\n yoyoLoop = true;\r\n }\r\n\r\n this._yoyoDirection = direction;\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 ((!yoyoMode && ((speedRatio > 0 && this.currentFrame > currentFrame) || (speedRatio < 0 && this.currentFrame < currentFrame))) || (yoyoMode && yoyoLoop)) {\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"]}
@@ -0,0 +1,12 @@
1
+ import type { Nullable } from "../types";
2
+ import type { Effect } from "../Materials/effect";
3
+ import { VertexBuffer } from "../Meshes/buffer";
4
+ /**
5
+ * Checks whether some vertex buffers that should be of type float are of a different type (int, byte...).
6
+ * If so, trigger a shader recompilation to give the shader processor the opportunity to update the code accordingly.
7
+ * @param vertexBuffers List of vertex buffers to check
8
+ * @param effect The effect (shaders) that should be recompiled if needed
9
+ */
10
+ export declare function checkNonFloatVertexBuffers(vertexBuffers: {
11
+ [key: string]: Nullable<VertexBuffer>;
12
+ }, effect: Effect): void;
@@ -0,0 +1,81 @@
1
+ import { VertexBuffer } from "../Meshes/buffer.js";
2
+ const vertexBufferKindForNonFloatProcessing = {
3
+ [VertexBuffer.PositionKind]: true,
4
+ [VertexBuffer.NormalKind]: true,
5
+ [VertexBuffer.TangentKind]: true,
6
+ [VertexBuffer.UVKind]: true,
7
+ [VertexBuffer.UV2Kind]: true,
8
+ [VertexBuffer.UV3Kind]: true,
9
+ [VertexBuffer.UV4Kind]: true,
10
+ [VertexBuffer.UV5Kind]: true,
11
+ [VertexBuffer.UV6Kind]: true,
12
+ [VertexBuffer.ColorKind]: true,
13
+ [VertexBuffer.ColorInstanceKind]: true,
14
+ [VertexBuffer.MatricesIndicesKind]: true,
15
+ [VertexBuffer.MatricesWeightsKind]: true,
16
+ [VertexBuffer.MatricesIndicesExtraKind]: true,
17
+ [VertexBuffer.MatricesWeightsExtraKind]: true,
18
+ };
19
+ /**
20
+ * Indicates if the type is a signed or unsigned type
21
+ * @param type Type to check
22
+ * @returns True if it is a signed type
23
+ */
24
+ function isSignedType(type) {
25
+ switch (type) {
26
+ case VertexBuffer.BYTE:
27
+ case VertexBuffer.SHORT:
28
+ case VertexBuffer.INT:
29
+ case VertexBuffer.FLOAT:
30
+ return true;
31
+ case VertexBuffer.UNSIGNED_BYTE:
32
+ case VertexBuffer.UNSIGNED_SHORT:
33
+ case VertexBuffer.UNSIGNED_INT:
34
+ return false;
35
+ default:
36
+ throw new Error(`Invalid type '${type}'`);
37
+ }
38
+ }
39
+ /**
40
+ * Checks whether some vertex buffers that should be of type float are of a different type (int, byte...).
41
+ * If so, trigger a shader recompilation to give the shader processor the opportunity to update the code accordingly.
42
+ * @param vertexBuffers List of vertex buffers to check
43
+ * @param effect The effect (shaders) that should be recompiled if needed
44
+ */
45
+ export function checkNonFloatVertexBuffers(vertexBuffers, effect) {
46
+ const engine = effect.getEngine();
47
+ const pipelineContext = effect._pipelineContext;
48
+ if (!pipelineContext?.vertexBufferKindToType) {
49
+ return;
50
+ }
51
+ let shaderProcessingContext = null;
52
+ for (const kind in vertexBuffers) {
53
+ const currentVertexBuffer = vertexBuffers[kind];
54
+ if (!currentVertexBuffer || !vertexBufferKindForNonFloatProcessing[kind]) {
55
+ continue;
56
+ }
57
+ const currentVertexBufferType = currentVertexBuffer.normalized ? VertexBuffer.FLOAT : currentVertexBuffer.type;
58
+ const vertexBufferType = pipelineContext.vertexBufferKindToType[kind];
59
+ if ((currentVertexBufferType !== VertexBuffer.FLOAT && vertexBufferType === undefined) ||
60
+ (vertexBufferType !== undefined && vertexBufferType !== currentVertexBufferType)) {
61
+ if (!shaderProcessingContext) {
62
+ shaderProcessingContext = engine._getShaderProcessingContext(effect.shaderLanguage);
63
+ }
64
+ pipelineContext.vertexBufferKindToType[kind] = currentVertexBufferType;
65
+ if (currentVertexBufferType !== VertexBuffer.FLOAT) {
66
+ shaderProcessingContext.vertexBufferKindToNumberOfComponents[kind] = VertexBuffer.DeduceStride(kind);
67
+ if (isSignedType(currentVertexBufferType)) {
68
+ shaderProcessingContext.vertexBufferKindToNumberOfComponents[kind] *= -1;
69
+ }
70
+ }
71
+ }
72
+ }
73
+ if (shaderProcessingContext) {
74
+ // We temporarily disable parallel compilation of shaders because we want new shaders to be compiled after the _processShaderCode call, so that they are in effect for the rest of the frame.
75
+ const parallelShaderCompile = engine._caps.parallelShaderCompile;
76
+ engine._caps.parallelShaderCompile = undefined;
77
+ effect._processShaderCode(null, engine._features._checkNonFloatVertexBuffersDontRecreatePipelineContext, shaderProcessingContext);
78
+ engine._caps.parallelShaderCompile = parallelShaderCompile;
79
+ }
80
+ }
81
+ //# sourceMappingURL=buffer.nonFloatVertexBuffers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.nonFloatVertexBuffers.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.nonFloatVertexBuffers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,qCAAqC,GAAgC;IACvE,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,IAAI;IACjC,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI;IAC/B,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,IAAI;IAChC,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,IAAI;IAC3B,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI;IAC5B,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI;IAC5B,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI;IAC5B,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI;IAC5B,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI;IAC5B,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;IAC9B,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,IAAI;IACtC,CAAC,YAAY,CAAC,mBAAmB,CAAC,EAAE,IAAI;IACxC,CAAC,YAAY,CAAC,mBAAmB,CAAC,EAAE,IAAI;IACxC,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE,IAAI;IAC7C,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE,IAAI;CAChD,CAAC;AAEF;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAY;IAC9B,QAAQ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EAAE;gBAC1B,uBAAuB,GAAG,MAAM,CAAC,2BAA2B,CAAC,MAAM,CAAC,cAAc,CAAE,CAAC;aACxF;YACD,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAAC;YACvE,IAAI,uBAAuB,KAAK,YAAY,CAAC,KAAK,EAAE;gBAChD,uBAAuB,CAAC,oCAAqC,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBACtG,IAAI,YAAY,CAAC,uBAAuB,CAAC,EAAE;oBACvC,uBAAuB,CAAC,oCAAqC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;iBAC7E;aACJ;SACJ;KACJ;IAED,IAAI,uBAAuB,EAAE;QACzB,6LAA6L;QAC7L,MAAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC;QACjE,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,SAAS,CAAC;QAE/C,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,sDAAsD,EAAE,uBAAuB,CAAC,CAAC;QAElI,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;KAC9D;AACL,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { ShaderProcessingContext } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { VertexBuffer } from \"../Meshes/buffer\";\r\n\r\nconst vertexBufferKindForNonFloatProcessing: { [kind: string]: boolean } = {\r\n [VertexBuffer.PositionKind]: true,\r\n [VertexBuffer.NormalKind]: true,\r\n [VertexBuffer.TangentKind]: true,\r\n [VertexBuffer.UVKind]: true,\r\n [VertexBuffer.UV2Kind]: true,\r\n [VertexBuffer.UV3Kind]: true,\r\n [VertexBuffer.UV4Kind]: true,\r\n [VertexBuffer.UV5Kind]: true,\r\n [VertexBuffer.UV6Kind]: true,\r\n [VertexBuffer.ColorKind]: true,\r\n [VertexBuffer.ColorInstanceKind]: true,\r\n [VertexBuffer.MatricesIndicesKind]: true,\r\n [VertexBuffer.MatricesWeightsKind]: true,\r\n [VertexBuffer.MatricesIndicesExtraKind]: true,\r\n [VertexBuffer.MatricesWeightsExtraKind]: true,\r\n};\r\n\r\n/**\r\n * Indicates if the type is a signed or unsigned type\r\n * @param type Type to check\r\n * @returns True if it is a signed type\r\n */\r\nfunction isSignedType(type: number): boolean {\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n case VertexBuffer.SHORT:\r\n case VertexBuffer.INT:\r\n case VertexBuffer.FLOAT:\r\n return true;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n case VertexBuffer.UNSIGNED_INT:\r\n return false;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Checks whether some vertex buffers that should be of type float are of a different type (int, byte...).\r\n * If so, trigger a shader recompilation to give the shader processor the opportunity to update the code accordingly.\r\n * @param vertexBuffers List of vertex buffers to check\r\n * @param effect The effect (shaders) that should be recompiled if needed\r\n */\r\nexport function checkNonFloatVertexBuffers(vertexBuffers: { [key: string]: Nullable<VertexBuffer> }, effect: Effect): void {\r\n const engine = effect.getEngine();\r\n const pipelineContext = effect._pipelineContext;\r\n\r\n if (!pipelineContext?.vertexBufferKindToType) {\r\n return;\r\n }\r\n\r\n let shaderProcessingContext: Nullable<ShaderProcessingContext> = null;\r\n\r\n for (const kind in vertexBuffers) {\r\n const currentVertexBuffer = vertexBuffers[kind];\r\n\r\n if (!currentVertexBuffer || !vertexBufferKindForNonFloatProcessing[kind]) {\r\n continue;\r\n }\r\n\r\n const currentVertexBufferType = currentVertexBuffer.normalized ? VertexBuffer.FLOAT : currentVertexBuffer.type;\r\n const vertexBufferType = pipelineContext.vertexBufferKindToType[kind];\r\n\r\n if (\r\n (currentVertexBufferType !== VertexBuffer.FLOAT && vertexBufferType === undefined) ||\r\n (vertexBufferType !== undefined && vertexBufferType !== currentVertexBufferType)\r\n ) {\r\n if (!shaderProcessingContext) {\r\n shaderProcessingContext = engine._getShaderProcessingContext(effect.shaderLanguage)!;\r\n }\r\n pipelineContext.vertexBufferKindToType[kind] = currentVertexBufferType;\r\n if (currentVertexBufferType !== VertexBuffer.FLOAT) {\r\n shaderProcessingContext.vertexBufferKindToNumberOfComponents![kind] = VertexBuffer.DeduceStride(kind);\r\n if (isSignedType(currentVertexBufferType)) {\r\n shaderProcessingContext.vertexBufferKindToNumberOfComponents![kind] *= -1;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (shaderProcessingContext) {\r\n // We temporarily disable parallel compilation of shaders because we want new shaders to be compiled after the _processShaderCode call, so that they are in effect for the rest of the frame.\r\n const parallelShaderCompile = engine._caps.parallelShaderCompile;\r\n engine._caps.parallelShaderCompile = undefined;\r\n\r\n effect._processShaderCode(null, engine._features._checkNonFloatVertexBuffersDontRecreatePipelineContext, shaderProcessingContext);\r\n\r\n engine._caps.parallelShaderCompile = parallelShaderCompile;\r\n }\r\n}\r\n"]}
@@ -21,11 +21,11 @@ export declare class BoundingBox implements ICullable {
21
21
  */
22
22
  readonly centerWorld: Vector3;
23
23
  /**
24
- * Gets the extend size in local space
24
+ * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!
25
25
  */
26
26
  readonly extendSize: Vector3;
27
27
  /**
28
- * Gets the extend size in world space
28
+ * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!
29
29
  */
30
30
  readonly extendSizeWorld: Vector3;
31
31
  /**
@@ -25,11 +25,11 @@ export class BoundingBox {
25
25
  */
26
26
  this.centerWorld = Vector3.Zero();
27
27
  /**
28
- * Gets the extend size in local space
28
+ * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!
29
29
  */
30
30
  this.extendSize = Vector3.Zero();
31
31
  /**
32
- * Gets the extend size in world space
32
+ * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!
33
33
  */
34
34
  this.extendSizeWorld = Vector3.Zero();
35
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD;;GAEG;AACH,MAAM,OAAO,WAAW;IA2DpB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAhEzG;;WAEG;QACa,YAAO,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5E;;WAEG;QACa,WAAM,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACjD;;WAEG;QACa,gBAAW,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACtD;;WAEG;QACa,eAAU,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACrD;;WAEG;QACa,oBAAe,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1D;;WAEG;QACa,eAAU,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/E;;WAEG;QACa,iBAAY,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACjF;;WAEG;QACa,iBAAY,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD;;WAEG;QACa,iBAAY,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD;;WAEG;QACa,YAAO,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAClD;;WAEG;QACa,YAAO,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAUlD,gBAAgB;QACT,sBAAi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../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport type { ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the extend size in local space\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the extend size in world space\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = ArrayTools.BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,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,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;gBACxB,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;oBACpD,OAAO,KAAK,CAAC;iBAChB;aACJ;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,eAA8C,EAAE,aAA0C;QAChH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;YACxB,IAAI,cAAc,GAAG,IAAI,CAAC;YAC1B,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;gBACxB,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;oBACrD,cAAc,GAAG,KAAK,CAAC;oBACvB,MAAM;iBACT;aACJ;YACD,IAAI,cAAc,EAAE;gBAChB,OAAO,KAAK,CAAC;aAChB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;AA9SuB,uBAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAAzC,CAA0C","sourcesContent":["import type { DeepImmutable, Nullable } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport type { ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = ArrayTools.BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
@@ -341,7 +341,7 @@ export class WebDeviceInputSystem {
341
341
  this._pointerMoveEvent = (evt) => {
342
342
  const deviceType = this._getPointerType(evt);
343
343
  let deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);
344
- // In the event that we're gettting pointermove events from touch inputs that we aren't tracking,
344
+ // In the event that we're getting pointermove events from touch inputs that we aren't tracking,
345
345
  // look for an available slot and retroactively connect it.
346
346
  if (deviceType === DeviceType.Touch && deviceSlot === -1) {
347
347
  const idx = this._activeTouchIds.indexOf(-1);
@@ -389,7 +389,13 @@ export class WebDeviceInputSystem {
389
389
  const deviceType = this._getPointerType(evt);
390
390
  let deviceSlot = deviceType === DeviceType.Mouse ? 0 : evt.pointerId;
391
391
  if (deviceType === DeviceType.Touch) {
392
- const idx = this._activeTouchIds.indexOf(-1);
392
+ // See if this pointerId is already using an existing slot
393
+ // (possible on some devices which raise the pointerMove event before the pointerDown event, e.g. when using a pen)
394
+ let idx = this._activeTouchIds.indexOf(evt.pointerId);
395
+ if (idx === -1) {
396
+ // If the pointerId wasn't already using a slot, find an open one
397
+ idx = this._activeTouchIds.indexOf(-1);
398
+ }
393
399
  if (idx >= 0) {
394
400
  deviceSlot = idx;
395
401
  this._activeTouchIds[idx] = evt.pointerId;