@babylonjs/core 5.22.1 → 5.24.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/Actions/abstractActionManager.d.ts +6 -6
- package/Actions/abstractActionManager.js +1 -1
- package/Actions/abstractActionManager.js.map +1 -1
- package/Actions/actionManager.d.ts +5 -5
- package/Actions/actionManager.js +5 -5
- package/Actions/actionManager.js.map +1 -1
- package/Animations/animatable.js +2 -1
- package/Animations/animatable.js.map +1 -1
- package/Animations/animation.js +137 -139
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.d.ts +3 -3
- package/Animations/animationGroup.js +3 -3
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/runtimeAnimation.js +6 -7
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioSceneComponent.d.ts +1 -1
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Audio/sound.d.ts +2 -1
- package/Audio/sound.js +21 -9
- package/Audio/sound.js.map +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.d.ts +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
- package/Behaviors/Cameras/bouncingBehavior.d.ts +1 -1
- package/Behaviors/Cameras/bouncingBehavior.js +1 -1
- package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
- package/Behaviors/Cameras/framingBehavior.d.ts +1 -1
- package/Behaviors/Cameras/framingBehavior.js +1 -1
- package/Behaviors/Cameras/framingBehavior.js.map +1 -1
- package/Bones/bone.d.ts +1 -1
- package/Bones/bone.js +1 -1
- package/Bones/bone.js.map +1 -1
- package/Bones/skeleton.d.ts +2 -2
- package/Bones/skeleton.js +11 -5
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/Inputs/BaseCameraMouseWheelInput.js +3 -22
- package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js +3 -3
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +1 -11
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +3 -3
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/followCameraMouseWheelInput.js +1 -4
- package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +3 -3
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/arcRotateCamera.d.ts +1 -1
- package/Cameras/arcRotateCamera.js +1 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +2 -2
- package/Cameras/camera.js +2 -2
- package/Cameras/camera.js.map +1 -1
- package/Cameras/freeCamera.d.ts +1 -1
- package/Cameras/freeCamera.js +1 -1
- package/Cameras/freeCamera.js.map +1 -1
- package/Cameras/gamepadCamera.d.ts +1 -1
- package/Cameras/gamepadCamera.js +1 -1
- package/Cameras/gamepadCamera.js.map +1 -1
- package/Cameras/targetCamera.d.ts +1 -1
- package/Cameras/targetCamera.js +1 -1
- package/Cameras/targetCamera.js.map +1 -1
- package/Cameras/touchCamera.d.ts +1 -1
- package/Cameras/touchCamera.js +1 -1
- package/Cameras/touchCamera.js.map +1 -1
- package/Cameras/universalCamera.d.ts +1 -1
- package/Cameras/universalCamera.js +1 -1
- package/Cameras/universalCamera.js.map +1 -1
- package/Cameras/virtualJoysticksCamera.d.ts +1 -1
- package/Cameras/virtualJoysticksCamera.js +1 -1
- package/Cameras/virtualJoysticksCamera.js.map +1 -1
- package/Culling/boundingBox.d.ts +2 -2
- package/Culling/boundingBox.js +2 -2
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/ray.d.ts +1 -1
- package/Culling/ray.js +1 -1
- package/Culling/ray.js.map +1 -1
- package/Debug/debugLayer.d.ts +1 -1
- package/Debug/debugLayer.js +1 -1
- package/Debug/debugLayer.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +20 -2
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +8 -10
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.query.d.ts +2 -2
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/ICanvas.d.ts +11 -0
- package/Engines/ICanvas.js.map +1 -1
- package/Engines/WebGL/webGLPipelineContext.d.ts +29 -19
- package/Engines/WebGL/webGLPipelineContext.js +99 -311
- package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/engine.d.ts +2 -2
- package/Engines/engine.js +2 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.d.ts +2 -2
- package/Engines/nativeEngine.js +2 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +1 -0
- package/Engines/renderTargetWrapper.js +5 -2
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +6 -5
- package/Engines/thinEngine.js +11 -7
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +4 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Events/clipboardEvents.d.ts +1 -1
- package/Events/clipboardEvents.js +1 -1
- package/Events/clipboardEvents.js.map +1 -1
- package/Events/deviceInputEvents.d.ts +11 -4
- package/Events/deviceInputEvents.js.map +1 -1
- package/Gamepads/Controllers/windowsMotionController.d.ts +1 -1
- package/Gamepads/Controllers/windowsMotionController.js +1 -1
- package/Gamepads/Controllers/windowsMotionController.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +4 -0
- package/Gizmos/boundingBoxGizmo.js +6 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Inputs/scene.inputManager.js +4 -4
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.d.ts +3 -3
- package/Layers/effectLayer.js +1 -1
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +3 -3
- package/Layers/glowLayer.js +2 -2
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +3 -3
- package/Layers/highlightLayer.js +2 -2
- package/Layers/highlightLayer.js.map +1 -1
- package/Lights/directionalLight.d.ts +2 -2
- package/Lights/directionalLight.js +2 -2
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/hemisphericLight.d.ts +3 -3
- package/Lights/hemisphericLight.js +3 -3
- package/Lights/hemisphericLight.js.map +1 -1
- package/Lights/light.d.ts +2 -2
- package/Lights/light.js +2 -2
- package/Lights/light.js.map +1 -1
- package/Lights/lightConstants.d.ts +1 -1
- package/Lights/lightConstants.js +1 -1
- package/Lights/lightConstants.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +3 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/sceneLoader.d.ts +1 -1
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +4 -0
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +4 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -1
- package/Materials/Node/nodeMaterial.js +5 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +4 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.d.ts +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.d.ts +2 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.js +9 -3
- package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +9 -9
- package/Materials/Textures/Procedurals/proceduralTexture.js +9 -9
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.d.ts +1 -1
- package/Materials/Textures/colorGradingTexture.js +1 -1
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.d.ts +2 -2
- package/Materials/Textures/cubeTexture.js +2 -2
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.d.ts +1 -1
- package/Materials/Textures/rawCubeTexture.js +1 -1
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +3 -5
- package/Materials/Textures/renderTargetTexture.js +19 -19
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/colorCurves.d.ts +3 -3
- package/Materials/colorCurves.js +3 -3
- package/Materials/colorCurves.js.map +1 -1
- package/Materials/effect.d.ts +27 -27
- package/Materials/effect.js +22 -288
- package/Materials/effect.js.map +1 -1
- package/Materials/fresnelParameters.d.ts +1 -1
- package/Materials/fresnelParameters.js +1 -1
- package/Materials/fresnelParameters.js.map +1 -1
- package/Materials/imageProcessingConfiguration.d.ts +4 -4
- package/Materials/imageProcessingConfiguration.js +4 -4
- package/Materials/imageProcessingConfiguration.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +25 -25
- package/Materials/shaderMaterial.js +25 -25
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js +4 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/index.d.ts +1 -0
- package/Maths/index.js +1 -0
- package/Maths/index.js.map +1 -1
- package/Maths/math.functions.d.ts +2 -2
- package/Maths/math.functions.js +2 -2
- package/Maths/math.functions.js.map +1 -1
- package/Maths/math.polar.d.ts +77 -0
- package/Maths/math.polar.js +114 -0
- package/Maths/math.polar.js.map +1 -0
- package/Maths/math.scalar.d.ts +2 -2
- package/Maths/math.scalar.js +2 -2
- package/Maths/math.scalar.js.map +1 -1
- package/Maths/math.vector.d.ts +13 -12
- package/Maths/math.vector.js +13 -12
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -1
- package/Meshes/abstractMesh.js +13 -2
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.d.ts +3 -3
- package/Meshes/geometry.js +3 -3
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/groundMesh.d.ts +5 -4
- package/Meshes/groundMesh.js +5 -4
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +1 -1
- package/Meshes/instancedMesh.js +1 -1
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +3 -3
- package/Meshes/mesh.js +7 -3
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.d.ts +1 -1
- package/Meshes/subMesh.js +1 -1
- package/Meshes/subMesh.js.map +1 -1
- package/Meshes/thinInstanceMesh.d.ts +1 -1
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Meshes/transformNode.js +6 -0
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.d.ts +2 -2
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +2 -2
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/HighDynamicRange/hdr.d.ts +3 -3
- package/Misc/HighDynamicRange/hdr.js +3 -3
- package/Misc/HighDynamicRange/hdr.js.map +1 -1
- package/Misc/HighDynamicRange/panoramaToCubemap.d.ts +1 -1
- package/Misc/HighDynamicRange/panoramaToCubemap.js +1 -1
- package/Misc/HighDynamicRange/panoramaToCubemap.js.map +1 -1
- package/Misc/arrayTools.d.ts +13 -12
- package/Misc/arrayTools.js +70 -39
- package/Misc/arrayTools.js.map +1 -1
- package/Misc/assetsManager.d.ts +3 -3
- package/Misc/assetsManager.js +3 -3
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/basis.js +17 -3
- package/Misc/basis.js.map +1 -1
- package/Misc/environmentTextureTools.d.ts +4 -4
- package/Misc/environmentTextureTools.js +5 -5
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/fileTools.d.ts +3 -3
- package/Misc/fileTools.js +19 -12
- package/Misc/fileTools.js.map +1 -1
- package/Misc/logger.js +1 -1
- package/Misc/logger.js.map +1 -1
- package/Misc/observable.d.ts +1 -1
- package/Misc/observable.js +1 -1
- package/Misc/observable.js.map +1 -1
- package/Misc/performanceMonitor.d.ts +3 -3
- package/Misc/performanceMonitor.js +3 -3
- package/Misc/performanceMonitor.js.map +1 -1
- package/Misc/rgbdTextureTools.d.ts +1 -1
- package/Misc/rgbdTextureTools.js +1 -1
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/sceneOptimizer.d.ts +7 -7
- package/Misc/sceneOptimizer.js +7 -7
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/stringDictionary.d.ts +6 -6
- package/Misc/stringDictionary.js +6 -6
- package/Misc/stringDictionary.js.map +1 -1
- package/Misc/textureTools.d.ts +4 -4
- package/Misc/textureTools.js +4 -4
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.d.ts +6 -6
- package/Misc/tools.js +6 -6
- package/Misc/tools.js.map +1 -1
- package/Misc/videoRecorder.d.ts +1 -1
- package/Misc/videoRecorder.js +1 -1
- package/Misc/videoRecorder.js.map +1 -1
- package/Offline/database.js +3 -3
- package/Offline/database.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +1 -1
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +1 -1
- package/Particles/gpuParticleSystem.js +1 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +1 -1
- package/Particles/particleSystem.js +1 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +4 -0
- package/Particles/solidParticleSystem.js +25 -3
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/Plugins/ammoJSPlugin.d.ts +1 -1
- package/Physics/Plugins/ammoJSPlugin.js +1 -1
- package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/Plugins/oimoJSPlugin.js +1 -1
- package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/physicsEngineComponent.d.ts +1 -1
- package/Physics/physicsEngineComponent.js +1 -1
- package/Physics/physicsEngineComponent.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +3 -3
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +1 -2
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +3 -3
- package/PostProcesses/blurPostProcess.js +3 -3
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +3 -3
- package/PostProcesses/volumetricLightScatteringPostProcess.js +3 -3
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +1 -0
- package/Rendering/depthPeelingRenderer.js +32 -5
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.d.ts +2 -2
- package/Rendering/edgesRenderer.js +1 -1
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.d.ts +4 -2
- package/Rendering/geometryBufferRenderer.js +5 -3
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/geometryBufferRendererSceneComponent.d.ts +2 -1
- package/Rendering/geometryBufferRendererSceneComponent.js +3 -2
- package/Rendering/geometryBufferRendererSceneComponent.js.map +1 -1
- package/Rendering/prePassRenderer.d.ts +11 -3
- package/Rendering/prePassRenderer.js +18 -3
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Rendering/subSurfaceConfiguration.d.ts +2 -2
- package/Rendering/subSurfaceConfiguration.js +2 -2
- package/Rendering/subSurfaceConfiguration.js.map +1 -1
- package/Sprites/spriteSceneComponent.js +4 -1
- package/Sprites/spriteSceneComponent.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +4 -0
- package/XR/features/WebXRControllerTeleportation.js +24 -19
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.d.ts +2 -2
- package/XR/motionController/webXRAbstractMotionController.js +2 -2
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/motionController/webXRControllerComponent.d.ts +1 -1
- package/XR/motionController/webXRControllerComponent.js +1 -1
- package/XR/motionController/webXRControllerComponent.js.map +1 -1
- package/XR/motionController/webXRMotionControllerManager.d.ts +3 -3
- package/XR/motionController/webXRMotionControllerManager.js +3 -3
- package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
- package/node.d.ts +4 -4
- package/node.js +3 -3
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +0 -4
- package/scene.d.ts +80 -63
- package/scene.js +92 -46
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +1 -1
- package/sceneComponent.js.map +1 -1
package/Maths/index.d.ts
CHANGED
package/Maths/index.js
CHANGED
package/Maths/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./math.scalar\";\r\nexport * from \"./math.functions\";\r\nexport * from \"./math\";\r\nexport * from \"./sphericalPolynomial\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./math.scalar\";\r\nexport * from \"./math.functions\";\r\nexport * from \"./math.polar\";\r\nexport * from \"./math\";\r\nexport * from \"./sphericalPolynomial\";\r\n"]}
|
|
@@ -8,7 +8,7 @@ import { Vector3 } from "./math.vector";
|
|
|
8
8
|
* @param indexStart defines the start index
|
|
9
9
|
* @param indexCount defines the end index
|
|
10
10
|
* @param bias defines bias value to add to the result
|
|
11
|
-
* @
|
|
11
|
+
* @returns minimum and maximum values
|
|
12
12
|
*/
|
|
13
13
|
export declare function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
|
|
14
14
|
minimum: Vector3;
|
|
@@ -21,7 +21,7 @@ export declare function extractMinAndMaxIndexed(positions: FloatArray, indices:
|
|
|
21
21
|
* @param count defines the number of positions to handle
|
|
22
22
|
* @param bias defines bias value to add to the result
|
|
23
23
|
* @param stride defines the stride size to use (distance between two positions in the positions array)
|
|
24
|
-
* @
|
|
24
|
+
* @returns minimum and maximum values
|
|
25
25
|
*/
|
|
26
26
|
export declare function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
|
|
27
27
|
minimum: Vector3;
|
package/Maths/math.functions.js
CHANGED
|
@@ -36,7 +36,7 @@ __decorate([
|
|
|
36
36
|
* @param indexStart defines the start index
|
|
37
37
|
* @param indexCount defines the end index
|
|
38
38
|
* @param bias defines bias value to add to the result
|
|
39
|
-
* @
|
|
39
|
+
* @returns minimum and maximum values
|
|
40
40
|
*/
|
|
41
41
|
export function extractMinAndMaxIndexed(positions, indices, indexStart, indexCount, bias = null) {
|
|
42
42
|
const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
@@ -62,7 +62,7 @@ export function extractMinAndMaxIndexed(positions, indices, indexStart, indexCou
|
|
|
62
62
|
* @param count defines the number of positions to handle
|
|
63
63
|
* @param bias defines bias value to add to the result
|
|
64
64
|
* @param stride defines the stride size to use (distance between two positions in the positions array)
|
|
65
|
-
* @
|
|
65
|
+
* @returns minimum and maximum values
|
|
66
66
|
*/
|
|
67
67
|
export function extractMinAndMax(positions, start, count, bias = null, stride) {
|
|
68
68
|
const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.functions.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/math.functions.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,4FAA4F;AAC5F,MAAM,WAAW;IAGN,MAAM,CAAC,uBAAuB,CAAC,SAAqB,EAAE,OAAqB,EAAE,UAAkB,EAAE,UAAkB,EAAE,OAAgB,EAAE,OAAgB;QAC1J,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE;YACnE,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;YAC5B,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAChC,OAAO,CAAC,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3C,OAAO,CAAC,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC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AI,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAErF,IAAI,CAAC,MAAM,EAAE;QACT,MAAM,GAAG,CAAC,CAAC;KACd;IAED,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAEhF,IAAI,IAAI,EAAE;QACN,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;KAC5C;IAED,OAAO;QACH,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,OAAO;KACnB,CAAC;AACN,CAAC","sourcesContent":["import type { FloatArray, Nullable, IndicesArray } from \"../types\";\r\nimport type { Vector2 } from \"./math.vector\";\r\nimport { Vector3 } from \"./math.vector\";\r\nimport { nativeOverride } from \"../Misc/decorators\";\r\n\r\n// This helper class is only here so we can apply the nativeOverride decorator to functions.\r\nclass MathHelpers {\r\n @nativeOverride.filter((...[positions, indices]: Parameters<typeof MathHelpers.extractMinAndMaxIndexed>) => !Array.isArray(positions) && !Array.isArray(indices))\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, minimum: Vector3, maximum: Vector3): void {\r\n for (let index = indexStart; index < indexStart + indexCount; index++) {\r\n const offset = indices[index] * 3;\r\n const x = positions[offset];\r\n const y = positions[offset + 1];\r\n const z = positions[offset + 2];\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n }\r\n }\r\n\r\n @nativeOverride.filter((...[positions]: Parameters<typeof MathHelpers.extractMinAndMax>) => !Array.isArray(positions))\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static extractMinAndMax(positions: FloatArray, start: number, count: number, stride: number, minimum: Vector3, maximum: Vector3): void {\r\n for (let index = start, offset = start * stride; index < start + count; index++, offset += stride) {\r\n const x = positions[offset];\r\n const y = positions[offset + 1];\r\n const z = positions[offset + 2];\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Extracts minimum and maximum values from a list of indexed positions\r\n * @param positions defines the positions to use\r\n * @param indices defines the indices to the positions\r\n * @param indexStart defines the start index\r\n * @param indexCount defines the end index\r\n * @param bias defines bias value to add to the result\r\n * @
|
|
1
|
+
{"version":3,"file":"math.functions.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/math.functions.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,4FAA4F;AAC5F,MAAM,WAAW;IAGN,MAAM,CAAC,uBAAuB,CAAC,SAAqB,EAAE,OAAqB,EAAE,UAAkB,EAAE,UAAkB,EAAE,OAAgB,EAAE,OAAgB;QAC1J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AAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;KAC5C;IAED,OAAO;QACH,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,OAAO;KACnB,CAAC;AACN,CAAC","sourcesContent":["import type { FloatArray, Nullable, IndicesArray } from \"../types\";\r\nimport type { Vector2 } from \"./math.vector\";\r\nimport { Vector3 } from \"./math.vector\";\r\nimport { nativeOverride } from \"../Misc/decorators\";\r\n\r\n// This helper class is only here so we can apply the nativeOverride decorator to functions.\r\nclass MathHelpers {\r\n @nativeOverride.filter((...[positions, indices]: Parameters<typeof MathHelpers.extractMinAndMaxIndexed>) => !Array.isArray(positions) && !Array.isArray(indices))\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, minimum: Vector3, maximum: Vector3): void {\r\n for (let index = indexStart; index < indexStart + indexCount; index++) {\r\n const offset = indices[index] * 3;\r\n const x = positions[offset];\r\n const y = positions[offset + 1];\r\n const z = positions[offset + 2];\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n }\r\n }\r\n\r\n @nativeOverride.filter((...[positions]: Parameters<typeof MathHelpers.extractMinAndMax>) => !Array.isArray(positions))\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static extractMinAndMax(positions: FloatArray, start: number, count: number, stride: number, minimum: Vector3, maximum: Vector3): void {\r\n for (let index = start, offset = start * stride; index < start + count; index++, offset += stride) {\r\n const x = positions[offset];\r\n const y = positions[offset + 1];\r\n const z = positions[offset + 2];\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Extracts minimum and maximum values from a list of indexed positions\r\n * @param positions defines the positions to use\r\n * @param indices defines the indices to the positions\r\n * @param indexStart defines the start index\r\n * @param indexCount defines the end index\r\n * @param bias defines bias value to add to the result\r\n * @returns minimum and maximum values\r\n */\r\nexport function extractMinAndMaxIndexed(\r\n positions: FloatArray,\r\n indices: IndicesArray,\r\n indexStart: number,\r\n indexCount: number,\r\n bias: Nullable<Vector2> = null\r\n): { minimum: Vector3; maximum: Vector3 } {\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n MathHelpers.extractMinAndMaxIndexed(positions, indices, indexStart, indexCount, minimum, maximum);\r\n\r\n if (bias) {\r\n minimum.x -= minimum.x * bias.x + bias.y;\r\n minimum.y -= minimum.y * bias.x + bias.y;\r\n minimum.z -= minimum.z * bias.x + bias.y;\r\n maximum.x += maximum.x * bias.x + bias.y;\r\n maximum.y += maximum.y * bias.x + bias.y;\r\n maximum.z += maximum.z * bias.x + bias.y;\r\n }\r\n\r\n return {\r\n minimum: minimum,\r\n maximum: maximum,\r\n };\r\n}\r\n\r\n/**\r\n * Extracts minimum and maximum values from a list of positions\r\n * @param positions defines the positions to use\r\n * @param start defines the start index in the positions array\r\n * @param count defines the number of positions to handle\r\n * @param bias defines bias value to add to the result\r\n * @param stride defines the stride size to use (distance between two positions in the positions array)\r\n * @returns minimum and maximum values\r\n */\r\nexport function extractMinAndMax(positions: FloatArray, start: number, count: number, bias: Nullable<Vector2> = null, stride?: number): { minimum: Vector3; maximum: Vector3 } {\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n if (!stride) {\r\n stride = 3;\r\n }\r\n\r\n MathHelpers.extractMinAndMax(positions, start, count, stride, minimum, maximum);\r\n\r\n if (bias) {\r\n minimum.x -= minimum.x * bias.x + bias.y;\r\n minimum.y -= minimum.y * bias.x + bias.y;\r\n minimum.z -= minimum.z * bias.x + bias.y;\r\n maximum.x += maximum.x * bias.x + bias.y;\r\n maximum.y += maximum.y * bias.x + bias.y;\r\n maximum.z += maximum.z * bias.x + bias.y;\r\n }\r\n\r\n return {\r\n minimum: minimum,\r\n maximum: maximum,\r\n };\r\n}\r\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { DeepImmutable } from "../types";
|
|
2
|
+
import type { Vector2, Vector3 } from "./math.vector";
|
|
3
|
+
/**
|
|
4
|
+
* Class used to store (r, theta) vector representation
|
|
5
|
+
*/
|
|
6
|
+
export declare class Polar {
|
|
7
|
+
radius: number;
|
|
8
|
+
theta: number;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new Polar object
|
|
11
|
+
* @param radius the radius of the vector
|
|
12
|
+
* @param theta the angle of the vector
|
|
13
|
+
*/
|
|
14
|
+
constructor(radius: number, theta: number);
|
|
15
|
+
/**
|
|
16
|
+
* Gets the rectangular coordinates of the current Polar
|
|
17
|
+
* @param ref the reference to assign the result
|
|
18
|
+
* @returns the updated reference
|
|
19
|
+
*/
|
|
20
|
+
toVector2ToRef(ref: Vector2): Vector2;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the rectangular coordinates of the current Polar
|
|
23
|
+
* @returns the rectangular coordinates
|
|
24
|
+
*/
|
|
25
|
+
toVector2(): Vector2;
|
|
26
|
+
/**
|
|
27
|
+
* Converts a given Vector2 to its polar coordinates
|
|
28
|
+
* @param v the Vector2 to convert
|
|
29
|
+
* @param ref the reference to assign the result
|
|
30
|
+
* @returns the updated reference
|
|
31
|
+
*/
|
|
32
|
+
static FromVector2ToRef(v: Vector2, ref: Polar): Polar;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a given Vector2 to its polar coordinates
|
|
35
|
+
* @param v the Vector2 to convert
|
|
36
|
+
* @returns a Polar
|
|
37
|
+
*/
|
|
38
|
+
static FromVector2(v: Vector2): Polar;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Class used for (radius, theta, phi) vector representation.
|
|
42
|
+
*/
|
|
43
|
+
export declare class Spherical {
|
|
44
|
+
radius: number;
|
|
45
|
+
theta: number;
|
|
46
|
+
phi: number;
|
|
47
|
+
/**
|
|
48
|
+
* @param radius spherical radius
|
|
49
|
+
* @param theta angle from positive y axis to radial line from 0 to PI (vertical)
|
|
50
|
+
* @param phi angle from positive x axis measured anticlockwise from -PI to PI (horizontal)
|
|
51
|
+
*/
|
|
52
|
+
constructor(radius: number, theta: number, phi: number);
|
|
53
|
+
/**
|
|
54
|
+
* Assigns the rectangular coordinates of the current Spherical to a Vector3
|
|
55
|
+
* @param ref the Vector3 to update
|
|
56
|
+
* @returns the updated Vector3
|
|
57
|
+
*/
|
|
58
|
+
toVector3ToRef(ref: DeepImmutable<Vector3>): Vector3;
|
|
59
|
+
/**
|
|
60
|
+
* Gets a Vector3 from the current spherical coordinates
|
|
61
|
+
* @returns the Vector3
|
|
62
|
+
*/
|
|
63
|
+
toVector3(): Vector3;
|
|
64
|
+
/**
|
|
65
|
+
* Assigns the spherical coordinates from a Vector3
|
|
66
|
+
* @param vector the vector to convert
|
|
67
|
+
* @param ref the Spherical to update
|
|
68
|
+
* @returns the updated ref
|
|
69
|
+
*/
|
|
70
|
+
static FromVector3ToRef(vector: DeepImmutable<Vector3>, ref: Spherical): Spherical;
|
|
71
|
+
/**
|
|
72
|
+
* Gets a Spherical from a Vector3
|
|
73
|
+
* @param vector defines the vector in (x, y, z) coordinate space
|
|
74
|
+
* @returns a new Spherical
|
|
75
|
+
*/
|
|
76
|
+
static FromVector3(vector: DeepImmutable<Vector3>): Spherical;
|
|
77
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { TmpVectors } from "./math.vector.js";
|
|
2
|
+
/**
|
|
3
|
+
* Class used to store (r, theta) vector representation
|
|
4
|
+
*/
|
|
5
|
+
export class Polar {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new Polar object
|
|
8
|
+
* @param radius the radius of the vector
|
|
9
|
+
* @param theta the angle of the vector
|
|
10
|
+
*/
|
|
11
|
+
constructor(radius, theta) {
|
|
12
|
+
this.radius = radius;
|
|
13
|
+
this.theta = theta;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets the rectangular coordinates of the current Polar
|
|
17
|
+
* @param ref the reference to assign the result
|
|
18
|
+
* @returns the updated reference
|
|
19
|
+
*/
|
|
20
|
+
toVector2ToRef(ref) {
|
|
21
|
+
const x = this.radius * Math.cos(this.theta);
|
|
22
|
+
const y = this.radius * Math.sin(this.theta);
|
|
23
|
+
ref.set(x, y);
|
|
24
|
+
return ref;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the rectangular coordinates of the current Polar
|
|
28
|
+
* @returns the rectangular coordinates
|
|
29
|
+
*/
|
|
30
|
+
toVector2() {
|
|
31
|
+
const ref = TmpVectors.Vector2[0];
|
|
32
|
+
return this.toVector2ToRef(ref);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Converts a given Vector2 to its polar coordinates
|
|
36
|
+
* @param v the Vector2 to convert
|
|
37
|
+
* @param ref the reference to assign the result
|
|
38
|
+
* @returns the updated reference
|
|
39
|
+
*/
|
|
40
|
+
static FromVector2ToRef(v, ref) {
|
|
41
|
+
const theta = Math.sign(v.y) * Math.acos(v.x / v.length());
|
|
42
|
+
ref.radius = v.length();
|
|
43
|
+
ref.theta = theta;
|
|
44
|
+
return ref;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts a given Vector2 to its polar coordinates
|
|
48
|
+
* @param v the Vector2 to convert
|
|
49
|
+
* @returns a Polar
|
|
50
|
+
*/
|
|
51
|
+
static FromVector2(v) {
|
|
52
|
+
const polar = new Polar(0, 0);
|
|
53
|
+
Polar.FromVector2ToRef(v, polar);
|
|
54
|
+
return polar;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Class used for (radius, theta, phi) vector representation.
|
|
59
|
+
*/
|
|
60
|
+
export class Spherical {
|
|
61
|
+
/**
|
|
62
|
+
* @param radius spherical radius
|
|
63
|
+
* @param theta angle from positive y axis to radial line from 0 to PI (vertical)
|
|
64
|
+
* @param phi angle from positive x axis measured anticlockwise from -PI to PI (horizontal)
|
|
65
|
+
*/
|
|
66
|
+
constructor(radius, theta, phi) {
|
|
67
|
+
this.radius = radius;
|
|
68
|
+
this.theta = theta;
|
|
69
|
+
this.phi = phi;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Assigns the rectangular coordinates of the current Spherical to a Vector3
|
|
73
|
+
* @param ref the Vector3 to update
|
|
74
|
+
* @returns the updated Vector3
|
|
75
|
+
*/
|
|
76
|
+
toVector3ToRef(ref) {
|
|
77
|
+
const x = this.radius * Math.sin(this.theta) * Math.cos(this.phi);
|
|
78
|
+
const y = this.radius * Math.cos(this.theta);
|
|
79
|
+
const z = this.radius * Math.sin(this.theta) * Math.sin(this.phi);
|
|
80
|
+
ref.set(x, y, z);
|
|
81
|
+
return ref;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets a Vector3 from the current spherical coordinates
|
|
85
|
+
* @returns the Vector3
|
|
86
|
+
*/
|
|
87
|
+
toVector3() {
|
|
88
|
+
const ref = TmpVectors.Vector3[0];
|
|
89
|
+
return this.toVector3ToRef(ref);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Assigns the spherical coordinates from a Vector3
|
|
93
|
+
* @param vector the vector to convert
|
|
94
|
+
* @param ref the Spherical to update
|
|
95
|
+
* @returns the updated ref
|
|
96
|
+
*/
|
|
97
|
+
static FromVector3ToRef(vector, ref) {
|
|
98
|
+
ref.radius = vector.length();
|
|
99
|
+
ref.theta = Math.acos(vector.y / ref.radius);
|
|
100
|
+
ref.phi = Math.atan2(vector.z, vector.x);
|
|
101
|
+
return ref;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gets a Spherical from a Vector3
|
|
105
|
+
* @param vector defines the vector in (x, y, z) coordinate space
|
|
106
|
+
* @returns a new Spherical
|
|
107
|
+
*/
|
|
108
|
+
static FromVector3(vector) {
|
|
109
|
+
const spherical = new Spherical(0, 0, 0);
|
|
110
|
+
Spherical.FromVector3ToRef(vector, spherical);
|
|
111
|
+
return spherical;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=math.polar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.polar.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/math.polar.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,KAAK;IAId;;;;OAIG;IACH,YAAY,MAAc,EAAE,KAAa;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,GAAY;QAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACd,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACI,MA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,CAAC,GAAG,CAAC,CAAC;QAClE,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACjB,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,gBAAgB,CAAC,MAA8B,EAAE,GAAc;QACzE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC7B,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7C,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACzC,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,MAA8B;QACpD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeepImmutable } from \"../types\";\r\nimport type { Vector2, Vector3 } from \"./math.vector\";\r\nimport { TmpVectors } from \"./math.vector\";\r\n\r\n/**\r\n * Class used to store (r, theta) vector representation\r\n */\r\nexport class Polar {\r\n public radius: number;\r\n public theta: number;\r\n\r\n /**\r\n * Creates a new Polar object\r\n * @param radius the radius of the vector\r\n * @param theta the angle of the vector\r\n */\r\n constructor(radius: number, theta: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n }\r\n\r\n /**\r\n * Gets the rectangular coordinates of the current Polar\r\n * @param ref the reference to assign the result\r\n * @returns the updated reference\r\n */\r\n public toVector2ToRef(ref: Vector2): Vector2 {\r\n const x = this.radius * Math.cos(this.theta);\r\n const y = this.radius * Math.sin(this.theta);\r\n ref.set(x, y);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets the rectangular coordinates of the current Polar\r\n * @returns the rectangular coordinates\r\n */\r\n public toVector2(): Vector2 {\r\n const ref = TmpVectors.Vector2[0];\r\n return this.toVector2ToRef(ref);\r\n }\r\n\r\n /**\r\n * Converts a given Vector2 to its polar coordinates\r\n * @param v the Vector2 to convert\r\n * @param ref the reference to assign the result\r\n * @returns the updated reference\r\n */\r\n public static FromVector2ToRef(v: Vector2, ref: Polar): Polar {\r\n const theta = Math.sign(v.y) * Math.acos(v.x / v.length());\r\n ref.radius = v.length();\r\n ref.theta = theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Converts a given Vector2 to its polar coordinates\r\n * @param v the Vector2 to convert\r\n * @returns a Polar\r\n */\r\n public static FromVector2(v: Vector2): Polar {\r\n const polar = new Polar(0, 0);\r\n Polar.FromVector2ToRef(v, polar);\r\n return polar;\r\n }\r\n}\r\n\r\n/**\r\n * Class used for (radius, theta, phi) vector representation.\r\n */\r\nexport class Spherical {\r\n public radius: number;\r\n public theta: number;\r\n public phi: number;\r\n\r\n /**\r\n * @param radius spherical radius\r\n * @param theta angle from positive y axis to radial line from 0 to PI (vertical)\r\n * @param phi angle from positive x axis measured anticlockwise from -PI to PI (horizontal)\r\n */\r\n constructor(radius: number, theta: number, phi: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n this.phi = phi;\r\n }\r\n\r\n /**\r\n * Assigns the rectangular coordinates of the current Spherical to a Vector3\r\n * @param ref the Vector3 to update\r\n * @returns the updated Vector3\r\n */\r\n public toVector3ToRef(ref: DeepImmutable<Vector3>): Vector3 {\r\n const x = this.radius * Math.sin(this.theta) * Math.cos(this.phi);\r\n const y = this.radius * Math.cos(this.theta);\r\n const z = this.radius * Math.sin(this.theta) * Math.sin(this.phi);\r\n ref.set(x, y, z);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets a Vector3 from the current spherical coordinates\r\n * @returns the Vector3\r\n */\r\n public toVector3(): Vector3 {\r\n const ref = TmpVectors.Vector3[0];\r\n return this.toVector3ToRef(ref);\r\n }\r\n\r\n /**\r\n * Assigns the spherical coordinates from a Vector3\r\n * @param vector the vector to convert\r\n * @param ref the Spherical to update\r\n * @returns the updated ref\r\n */\r\n public static FromVector3ToRef(vector: DeepImmutable<Vector3>, ref: Spherical): Spherical {\r\n ref.radius = vector.length();\r\n ref.theta = Math.acos(vector.y / ref.radius);\r\n ref.phi = Math.atan2(vector.z, vector.x);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets a Spherical from a Vector3\r\n * @param vector defines the vector in (x, y, z) coordinate space\r\n * @returns a new Spherical\r\n */\r\n public static FromVector3(vector: DeepImmutable<Vector3>): Spherical {\r\n const spherical = new Spherical(0, 0, 0);\r\n Spherical.FromVector3ToRef(vector, spherical);\r\n return spherical;\r\n }\r\n}\r\n"]}
|
package/Maths/math.scalar.d.ts
CHANGED
|
@@ -200,14 +200,14 @@ export declare class Scalar {
|
|
|
200
200
|
/**
|
|
201
201
|
* Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
|
|
202
202
|
* @param angle The angle to normalize in radian.
|
|
203
|
-
* @
|
|
203
|
+
* @returns The converted angle.
|
|
204
204
|
*/
|
|
205
205
|
static NormalizeRadians(angle: number): number;
|
|
206
206
|
/**
|
|
207
207
|
* Returns the highest common factor of two integers.
|
|
208
208
|
* @param a first parameter
|
|
209
209
|
* @param b second parameter
|
|
210
|
-
* @
|
|
210
|
+
* @returns HCF of a and b
|
|
211
211
|
*/
|
|
212
212
|
static HCF(a: number, b: number): number;
|
|
213
213
|
}
|
package/Maths/math.scalar.js
CHANGED
|
@@ -315,7 +315,7 @@ export class Scalar {
|
|
|
315
315
|
/**
|
|
316
316
|
* Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
|
|
317
317
|
* @param angle The angle to normalize in radian.
|
|
318
|
-
* @
|
|
318
|
+
* @returns The converted angle.
|
|
319
319
|
*/
|
|
320
320
|
static NormalizeRadians(angle) {
|
|
321
321
|
// More precise but slower version kept for reference.
|
|
@@ -331,7 +331,7 @@ export class Scalar {
|
|
|
331
331
|
* Returns the highest common factor of two integers.
|
|
332
332
|
* @param a first parameter
|
|
333
333
|
* @param b second parameter
|
|
334
|
-
* @
|
|
334
|
+
* @returns HCF of a and b
|
|
335
335
|
*/
|
|
336
336
|
static HCF(a, b) {
|
|
337
337
|
const r = a % b;
|
package/Maths/math.scalar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.scalar.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/math.scalar.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,MAAM;IAMf;;;;;;OAMG;IACI,MAAM,CAAC,aAAa,CAAC,CAAS,EAAE,CAAS,EAAE,UAAkB,YAAY;QAC5E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,CAAS;QACzB,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE3B,IAAI,CAAC,IAAI,EAAE,EAAE;YACT,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;SACpC;QAED,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,KAAa;QAC5B,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,sBAAsB;QAEtC,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,KA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AAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAErE,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS;QAClC,MAAM,CAAC,GAAW,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,EAAE;YACT,OAAO,CAAC,CAAC;SACZ;QACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;;AAnXD;;GAEG;AACW,YAAK,GAAW,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC","sourcesContent":["/**\r\n * Scalar computation library\r\n */\r\nexport class Scalar {\r\n /**\r\n * Two pi constants convenient for computation.\r\n */\r\n public static TwoPi: number = Math.PI * 2;\r\n\r\n /**\r\n * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n * @param a number\r\n * @param b number\r\n * @param epsilon (default = 1.401298E-45)\r\n * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n */\r\n public static WithinEpsilon(a: number, b: number, epsilon: number = 1.401298e-45): boolean {\r\n return Math.abs(a - b) <= epsilon;\r\n }\r\n\r\n /**\r\n * Returns a string : the upper case translation of the number i to hexadecimal.\r\n * @param i number\r\n * @returns the upper case translation of the number i to hexadecimal.\r\n */\r\n public static ToHex(i: number): string {\r\n const str = i.toString(16);\r\n\r\n if (i <= 15) {\r\n return (\"0\" + str).toUpperCase();\r\n }\r\n\r\n return str.toUpperCase();\r\n }\r\n\r\n /**\r\n * Returns -1 if value is negative and +1 is value is positive.\r\n * @param value the value\r\n * @returns the value itself if it's equal to zero.\r\n */\r\n public static Sign(value: number): number {\r\n value = +value; // convert to a number\r\n\r\n if (value === 0 || isNaN(value)) {\r\n return value;\r\n }\r\n\r\n return value > 0 ? 1 : -1;\r\n }\r\n\r\n /**\r\n * Returns the value itself if it's between min and max.\r\n * Returns min if the value is lower than min.\r\n * Returns max if the value is greater than max.\r\n * @param value the value to clmap\r\n * @param min the min value to clamp to (default: 0)\r\n * @param max the max value to clamp to (default: 1)\r\n * @returns the clamped value\r\n */\r\n public static Clamp(value: number, min = 0, max = 1): number {\r\n return Math.min(max, Math.max(min, value));\r\n }\r\n\r\n /**\r\n * the log2 of value.\r\n * @param value the value to compute log2 of\r\n * @returns the log2 of value.\r\n */\r\n public static Log2(value: number): number {\r\n return Math.log(value) * Math.LOG2E;\r\n }\r\n\r\n /**\r\n * the floor part of a log2 value.\r\n * @param value the value to compute log2 of\r\n * @returns the log2 of value.\r\n */\r\n public static ILog2(value: number): number {\r\n if (Math.log2) {\r\n return Math.floor(Math.log2(value));\r\n }\r\n\r\n if (value < 0) {\r\n return NaN;\r\n } else if (value === 0) {\r\n return -Infinity;\r\n }\r\n\r\n let n = 0;\r\n if (value < 1) {\r\n while (value < 1) {\r\n n++;\r\n value = value * 2;\r\n }\r\n n = -n;\r\n } else if (value > 1) {\r\n while (value > 1) {\r\n n++;\r\n value = Math.floor(value / 2);\r\n }\r\n }\r\n\r\n return n;\r\n }\r\n\r\n /**\r\n * Loops the value, so that it is never larger than length and never smaller than 0.\r\n *\r\n * This is similar to the modulo operator but it works with floating point numbers.\r\n * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.\r\n * With t = 5 and length = 2.5, the result would be 0.0.\r\n * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator\r\n * @param value the value\r\n * @param length the length\r\n * @returns the looped value\r\n */\r\n public static Repeat(value: number, length: number): number {\r\n return value - Math.floor(value / length) * length;\r\n }\r\n\r\n /**\r\n * Normalize the value between 0.0 and 1.0 using min and max values\r\n * @param value value to normalize\r\n * @param min max to normalize between\r\n * @param max min to normalize between\r\n * @returns the normalized value\r\n */\r\n public static Normalize(value: number, min: number, max: number): number {\r\n return (value - min) / (max - min);\r\n }\r\n\r\n /**\r\n * Denormalize the value from 0.0 and 1.0 using min and max values\r\n * @param normalized value to denormalize\r\n * @param min max to denormalize between\r\n * @param max min to denormalize between\r\n * @returns the denormalized value\r\n */\r\n public static Denormalize(normalized: number, min: number, max: number): number {\r\n return normalized * (max - min) + min;\r\n }\r\n\r\n /**\r\n * Calculates the shortest difference between two given angles given in degrees.\r\n * @param current current angle in degrees\r\n * @param target target angle in degrees\r\n * @returns the delta\r\n */\r\n public static DeltaAngle(current: number, target: number): number {\r\n let num: number = Scalar.Repeat(target - current, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return num;\r\n }\r\n\r\n /**\r\n * PingPongs the value t, so that it is never larger than length and never smaller than 0.\r\n * @param tx value\r\n * @param length length\r\n * @returns The returned value will move back and forth between 0 and length\r\n */\r\n public static PingPong(tx: number, length: number): number {\r\n const t: number = Scalar.Repeat(tx, length * 2.0);\r\n return length - Math.abs(t - length);\r\n }\r\n\r\n /**\r\n * Interpolates between min and max with smoothing at the limits.\r\n *\r\n * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up\r\n * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.\r\n * @param from from\r\n * @param to to\r\n * @param tx value\r\n * @returns the smooth stepped value\r\n */\r\n public static SmoothStep(from: number, to: number, tx: number): number {\r\n let t: number = Scalar.Clamp(tx);\r\n t = -2.0 * t * t * t + 3.0 * t * t;\r\n return to * t + from * (1.0 - t);\r\n }\r\n\r\n /**\r\n * Moves a value current towards target.\r\n *\r\n * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.\r\n * Negative values of maxDelta pushes the value away from target.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting value\r\n */\r\n public static MoveTowards(current: number, target: number, maxDelta: number): number {\r\n let result: number = 0;\r\n if (Math.abs(target - current) <= maxDelta) {\r\n result = target;\r\n } else {\r\n result = current + Scalar.Sign(target - current) * maxDelta;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n *\r\n * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta\r\n * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting angle\r\n */\r\n public static MoveTowardsAngle(current: number, target: number, maxDelta: number): number {\r\n const num: number = Scalar.DeltaAngle(current, target);\r\n let result: number = 0;\r\n if (-maxDelta < num && num < maxDelta) {\r\n result = target;\r\n } else {\r\n target = current + num;\r\n result = Scalar.MoveTowards(current, target, maxDelta);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a new scalar with values linearly interpolated of \"amount\" between the start scalar and the end scalar.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\n public static Lerp(start: number, end: number, amount: number): number {\r\n return start + (end - start) * amount;\r\n }\r\n\r\n /**\r\n * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\n public static LerpAngle(start: number, end: number, amount: number): number {\r\n let num: number = Scalar.Repeat(end - start, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return start + num * Scalar.Clamp(amount);\r\n }\r\n\r\n /**\r\n * Calculates the linear parameter t that produces the interpolant value within the range [a, b].\r\n * @param a start value\r\n * @param b target value\r\n * @param value value between a and b\r\n * @returns the inverseLerp value\r\n */\r\n public static InverseLerp(a: number, b: number, value: number): number {\r\n let result: number = 0;\r\n if (a != b) {\r\n result = Scalar.Clamp((value - a) / (b - a));\r\n } else {\r\n result = 0.0;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a new scalar located for \"amount\" (float) on the Hermite spline defined by the scalars \"value1\", \"value3\", \"tangent1\", \"tangent2\".\r\n * @see http://mathworld.wolfram.com/HermitePolynomial.html\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param amount defines the amount on the interpolation spline (between 0 and 1)\r\n * @returns hermite result\r\n */\r\n public static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number {\r\n const squared = amount * amount;\r\n const cubed = amount * squared;\r\n const part1 = 2.0 * cubed - 3.0 * squared + 1.0;\r\n const part2 = -2.0 * cubed + 3.0 * squared;\r\n const part3 = cubed - 2.0 * squared + amount;\r\n const part4 = cubed - squared;\r\n\r\n return value1 * part1 + value2 * part2 + tangent1 * part3 + tangent2 * part4;\r\n }\r\n\r\n /**\r\n * Returns a new scalar which is the 1st derivative of the Hermite spline defined by the scalars \"value1\", \"value2\", \"tangent1\", \"tangent2\".\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param time define where the derivative must be done\r\n * @returns 1st derivative\r\n */\r\n public static Hermite1stDerivative(value1: number, tangent1: number, value2: number, tangent2: number, time: number): number {\r\n const t2 = time * time;\r\n return (t2 - time) * 6 * value1 + (3 * t2 - 4 * time + 1) * tangent1 + (-t2 + time) * 6 * value2 + (3 * t2 - 2 * time) * tangent2;\r\n }\r\n\r\n /**\r\n * Returns a random float number between and min and max values\r\n * @param min min value of random\r\n * @param max max value of random\r\n * @returns random value\r\n */\r\n public static RandomRange(min: number, max: number): number {\r\n if (min === max) {\r\n return min;\r\n }\r\n return Math.random() * (max - min) + min;\r\n }\r\n\r\n /**\r\n * This function returns percentage of a number in a given range.\r\n *\r\n * RangeToPercent(40,20,60) will return 0.5 (50%)\r\n * RangeToPercent(34,0,100) will return 0.34 (34%)\r\n * @param number to convert to percentage\r\n * @param min min range\r\n * @param max max range\r\n * @returns the percentage\r\n */\r\n public static RangeToPercent(number: number, min: number, max: number): number {\r\n return (number - min) / (max - min);\r\n }\r\n\r\n /**\r\n * This function returns number that corresponds to the percentage in a given range.\r\n *\r\n * PercentToRange(0.34,0,100) will return 34.\r\n * @param percent to convert to number\r\n * @param min min range\r\n * @param max max range\r\n * @returns the number\r\n */\r\n public static PercentToRange(percent: number, min: number, max: number): number {\r\n return (max - min) * percent + min;\r\n }\r\n\r\n /**\r\n * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.\r\n * @param angle The angle to normalize in radian.\r\n * @return The converted angle.\r\n */\r\n public static NormalizeRadians(angle: number): number {\r\n // More precise but slower version kept for reference.\r\n // angle = angle % Tools.TwoPi;\r\n // angle = (angle + Tools.TwoPi) % Tools.TwoPi;\r\n\r\n //if (angle > Math.PI) {\r\n //\tangle -= Tools.TwoPi;\r\n //}\r\n\r\n angle -= Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi);\r\n\r\n return angle;\r\n }\r\n\r\n /**\r\n * Returns the highest common factor of two integers.\r\n * @param a first parameter\r\n * @param b second parameter\r\n * @return HCF of a and b\r\n */\r\n public static HCF(a: number, b: number): number {\r\n const r: number = a % b;\r\n if (r === 0) {\r\n return b;\r\n }\r\n return Scalar.HCF(b, r);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"math.scalar.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/math.scalar.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,MAAM;IAMf;;;;;;OAMG;IACI,MAAM,CAAC,aAAa,CAAC,CAAS,EAAE,CAAS,EAAE,UAAkB,YAAY;QAC5E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,CAAS;QACzB,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE3B,IAAI,CAAC,IAAI,EAAE,EA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AO,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,OAAO,GAAG,GAAG,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,KAAa;QACxC,sDAAsD;QACtD,+BAA+B;QAC/B,+CAA+C;QAE/C,wBAAwB;QACxB,wBAAwB;QACxB,GAAG;QAEH,KAAK,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAErE,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS;QAClC,MAAM,CAAC,GAAW,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,EAAE;YACT,OAAO,CAAC,CAAC;SACZ;QACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;;AAnXD;;GAEG;AACW,YAAK,GAAW,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC","sourcesContent":["/**\r\n * Scalar computation library\r\n */\r\nexport class Scalar {\r\n /**\r\n * Two pi constants convenient for computation.\r\n */\r\n public static TwoPi: number = Math.PI * 2;\r\n\r\n /**\r\n * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n * @param a number\r\n * @param b number\r\n * @param epsilon (default = 1.401298E-45)\r\n * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n */\r\n public static WithinEpsilon(a: number, b: number, epsilon: number = 1.401298e-45): boolean {\r\n return Math.abs(a - b) <= epsilon;\r\n }\r\n\r\n /**\r\n * Returns a string : the upper case translation of the number i to hexadecimal.\r\n * @param i number\r\n * @returns the upper case translation of the number i to hexadecimal.\r\n */\r\n public static ToHex(i: number): string {\r\n const str = i.toString(16);\r\n\r\n if (i <= 15) {\r\n return (\"0\" + str).toUpperCase();\r\n }\r\n\r\n return str.toUpperCase();\r\n }\r\n\r\n /**\r\n * Returns -1 if value is negative and +1 is value is positive.\r\n * @param value the value\r\n * @returns the value itself if it's equal to zero.\r\n */\r\n public static Sign(value: number): number {\r\n value = +value; // convert to a number\r\n\r\n if (value === 0 || isNaN(value)) {\r\n return value;\r\n }\r\n\r\n return value > 0 ? 1 : -1;\r\n }\r\n\r\n /**\r\n * Returns the value itself if it's between min and max.\r\n * Returns min if the value is lower than min.\r\n * Returns max if the value is greater than max.\r\n * @param value the value to clmap\r\n * @param min the min value to clamp to (default: 0)\r\n * @param max the max value to clamp to (default: 1)\r\n * @returns the clamped value\r\n */\r\n public static Clamp(value: number, min = 0, max = 1): number {\r\n return Math.min(max, Math.max(min, value));\r\n }\r\n\r\n /**\r\n * the log2 of value.\r\n * @param value the value to compute log2 of\r\n * @returns the log2 of value.\r\n */\r\n public static Log2(value: number): number {\r\n return Math.log(value) * Math.LOG2E;\r\n }\r\n\r\n /**\r\n * the floor part of a log2 value.\r\n * @param value the value to compute log2 of\r\n * @returns the log2 of value.\r\n */\r\n public static ILog2(value: number): number {\r\n if (Math.log2) {\r\n return Math.floor(Math.log2(value));\r\n }\r\n\r\n if (value < 0) {\r\n return NaN;\r\n } else if (value === 0) {\r\n return -Infinity;\r\n }\r\n\r\n let n = 0;\r\n if (value < 1) {\r\n while (value < 1) {\r\n n++;\r\n value = value * 2;\r\n }\r\n n = -n;\r\n } else if (value > 1) {\r\n while (value > 1) {\r\n n++;\r\n value = Math.floor(value / 2);\r\n }\r\n }\r\n\r\n return n;\r\n }\r\n\r\n /**\r\n * Loops the value, so that it is never larger than length and never smaller than 0.\r\n *\r\n * This is similar to the modulo operator but it works with floating point numbers.\r\n * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.\r\n * With t = 5 and length = 2.5, the result would be 0.0.\r\n * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator\r\n * @param value the value\r\n * @param length the length\r\n * @returns the looped value\r\n */\r\n public static Repeat(value: number, length: number): number {\r\n return value - Math.floor(value / length) * length;\r\n }\r\n\r\n /**\r\n * Normalize the value between 0.0 and 1.0 using min and max values\r\n * @param value value to normalize\r\n * @param min max to normalize between\r\n * @param max min to normalize between\r\n * @returns the normalized value\r\n */\r\n public static Normalize(value: number, min: number, max: number): number {\r\n return (value - min) / (max - min);\r\n }\r\n\r\n /**\r\n * Denormalize the value from 0.0 and 1.0 using min and max values\r\n * @param normalized value to denormalize\r\n * @param min max to denormalize between\r\n * @param max min to denormalize between\r\n * @returns the denormalized value\r\n */\r\n public static Denormalize(normalized: number, min: number, max: number): number {\r\n return normalized * (max - min) + min;\r\n }\r\n\r\n /**\r\n * Calculates the shortest difference between two given angles given in degrees.\r\n * @param current current angle in degrees\r\n * @param target target angle in degrees\r\n * @returns the delta\r\n */\r\n public static DeltaAngle(current: number, target: number): number {\r\n let num: number = Scalar.Repeat(target - current, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return num;\r\n }\r\n\r\n /**\r\n * PingPongs the value t, so that it is never larger than length and never smaller than 0.\r\n * @param tx value\r\n * @param length length\r\n * @returns The returned value will move back and forth between 0 and length\r\n */\r\n public static PingPong(tx: number, length: number): number {\r\n const t: number = Scalar.Repeat(tx, length * 2.0);\r\n return length - Math.abs(t - length);\r\n }\r\n\r\n /**\r\n * Interpolates between min and max with smoothing at the limits.\r\n *\r\n * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up\r\n * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.\r\n * @param from from\r\n * @param to to\r\n * @param tx value\r\n * @returns the smooth stepped value\r\n */\r\n public static SmoothStep(from: number, to: number, tx: number): number {\r\n let t: number = Scalar.Clamp(tx);\r\n t = -2.0 * t * t * t + 3.0 * t * t;\r\n return to * t + from * (1.0 - t);\r\n }\r\n\r\n /**\r\n * Moves a value current towards target.\r\n *\r\n * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.\r\n * Negative values of maxDelta pushes the value away from target.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting value\r\n */\r\n public static MoveTowards(current: number, target: number, maxDelta: number): number {\r\n let result: number = 0;\r\n if (Math.abs(target - current) <= maxDelta) {\r\n result = target;\r\n } else {\r\n result = current + Scalar.Sign(target - current) * maxDelta;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n *\r\n * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta\r\n * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting angle\r\n */\r\n public static MoveTowardsAngle(current: number, target: number, maxDelta: number): number {\r\n const num: number = Scalar.DeltaAngle(current, target);\r\n let result: number = 0;\r\n if (-maxDelta < num && num < maxDelta) {\r\n result = target;\r\n } else {\r\n target = current + num;\r\n result = Scalar.MoveTowards(current, target, maxDelta);\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a new scalar with values linearly interpolated of \"amount\" between the start scalar and the end scalar.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\n public static Lerp(start: number, end: number, amount: number): number {\r\n return start + (end - start) * amount;\r\n }\r\n\r\n /**\r\n * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\n public static LerpAngle(start: number, end: number, amount: number): number {\r\n let num: number = Scalar.Repeat(end - start, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return start + num * Scalar.Clamp(amount);\r\n }\r\n\r\n /**\r\n * Calculates the linear parameter t that produces the interpolant value within the range [a, b].\r\n * @param a start value\r\n * @param b target value\r\n * @param value value between a and b\r\n * @returns the inverseLerp value\r\n */\r\n public static InverseLerp(a: number, b: number, value: number): number {\r\n let result: number = 0;\r\n if (a != b) {\r\n result = Scalar.Clamp((value - a) / (b - a));\r\n } else {\r\n result = 0.0;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a new scalar located for \"amount\" (float) on the Hermite spline defined by the scalars \"value1\", \"value3\", \"tangent1\", \"tangent2\".\r\n * @see http://mathworld.wolfram.com/HermitePolynomial.html\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param amount defines the amount on the interpolation spline (between 0 and 1)\r\n * @returns hermite result\r\n */\r\n public static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number {\r\n const squared = amount * amount;\r\n const cubed = amount * squared;\r\n const part1 = 2.0 * cubed - 3.0 * squared + 1.0;\r\n const part2 = -2.0 * cubed + 3.0 * squared;\r\n const part3 = cubed - 2.0 * squared + amount;\r\n const part4 = cubed - squared;\r\n\r\n return value1 * part1 + value2 * part2 + tangent1 * part3 + tangent2 * part4;\r\n }\r\n\r\n /**\r\n * Returns a new scalar which is the 1st derivative of the Hermite spline defined by the scalars \"value1\", \"value2\", \"tangent1\", \"tangent2\".\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param time define where the derivative must be done\r\n * @returns 1st derivative\r\n */\r\n public static Hermite1stDerivative(value1: number, tangent1: number, value2: number, tangent2: number, time: number): number {\r\n const t2 = time * time;\r\n return (t2 - time) * 6 * value1 + (3 * t2 - 4 * time + 1) * tangent1 + (-t2 + time) * 6 * value2 + (3 * t2 - 2 * time) * tangent2;\r\n }\r\n\r\n /**\r\n * Returns a random float number between and min and max values\r\n * @param min min value of random\r\n * @param max max value of random\r\n * @returns random value\r\n */\r\n public static RandomRange(min: number, max: number): number {\r\n if (min === max) {\r\n return min;\r\n }\r\n return Math.random() * (max - min) + min;\r\n }\r\n\r\n /**\r\n * This function returns percentage of a number in a given range.\r\n *\r\n * RangeToPercent(40,20,60) will return 0.5 (50%)\r\n * RangeToPercent(34,0,100) will return 0.34 (34%)\r\n * @param number to convert to percentage\r\n * @param min min range\r\n * @param max max range\r\n * @returns the percentage\r\n */\r\n public static RangeToPercent(number: number, min: number, max: number): number {\r\n return (number - min) / (max - min);\r\n }\r\n\r\n /**\r\n * This function returns number that corresponds to the percentage in a given range.\r\n *\r\n * PercentToRange(0.34,0,100) will return 34.\r\n * @param percent to convert to number\r\n * @param min min range\r\n * @param max max range\r\n * @returns the number\r\n */\r\n public static PercentToRange(percent: number, min: number, max: number): number {\r\n return (max - min) * percent + min;\r\n }\r\n\r\n /**\r\n * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.\r\n * @param angle The angle to normalize in radian.\r\n * @returns The converted angle.\r\n */\r\n public static NormalizeRadians(angle: number): number {\r\n // More precise but slower version kept for reference.\r\n // angle = angle % Tools.TwoPi;\r\n // angle = (angle + Tools.TwoPi) % Tools.TwoPi;\r\n\r\n //if (angle > Math.PI) {\r\n //\tangle -= Tools.TwoPi;\r\n //}\r\n\r\n angle -= Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi);\r\n\r\n return angle;\r\n }\r\n\r\n /**\r\n * Returns the highest common factor of two integers.\r\n * @param a first parameter\r\n * @param b second parameter\r\n * @returns HCF of a and b\r\n */\r\n public static HCF(a: number, b: number): number {\r\n const r: number = a % b;\r\n if (r === 0) {\r\n return b;\r\n }\r\n return Scalar.HCF(b, r);\r\n }\r\n}\r\n"]}
|
package/Maths/math.vector.d.ts
CHANGED
|
@@ -941,19 +941,20 @@ export declare class Vector3 {
|
|
|
941
941
|
/**
|
|
942
942
|
* Get angle between two vectors
|
|
943
943
|
* Example Playground https://playground.babylonjs.com/#R1F8YU#86
|
|
944
|
-
* @param vector0
|
|
945
|
-
* @param vector1
|
|
944
|
+
* @param vector0 the starting point
|
|
945
|
+
* @param vector1 the ending point
|
|
946
946
|
* @param normal direction of the normal
|
|
947
|
-
* @
|
|
947
|
+
* @returns the angle between vector0 and vector1
|
|
948
948
|
*/
|
|
949
949
|
static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
|
|
950
950
|
/**
|
|
951
951
|
* Get angle between two vectors projected on a plane
|
|
952
952
|
* Example Playground https://playground.babylonjs.com/#R1F8YU#87
|
|
953
|
+
* Expectation compute time: 0.01 ms (median) and 0.02 ms (percentile 95%)
|
|
953
954
|
* @param vector0 angle between vector0 and vector1
|
|
954
955
|
* @param vector1 angle between vector0 and vector1
|
|
955
956
|
* @param normal Normal of the projection plane
|
|
956
|
-
* @returns the angle between vector0 and vector1 projected on the plane with the specified normal
|
|
957
|
+
* @returns the angle in radians (float) between vector0 and vector1 projected on the plane with the specified normal
|
|
957
958
|
*/
|
|
958
959
|
static GetAngleBetweenVectorsOnPlane(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
|
|
959
960
|
/**
|
|
@@ -1833,21 +1834,21 @@ export declare class Vector4 {
|
|
|
1833
1834
|
* Returns the distance (float) between the vectors "value1" and "value2".
|
|
1834
1835
|
* @param value1 value to calulate the distance between
|
|
1835
1836
|
* @param value2 value to calulate the distance between
|
|
1836
|
-
* @
|
|
1837
|
+
* @returns the distance between the two vectors
|
|
1837
1838
|
*/
|
|
1838
1839
|
static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
|
|
1839
1840
|
/**
|
|
1840
1841
|
* Returns the squared distance (float) between the vectors "value1" and "value2".
|
|
1841
1842
|
* @param value1 value to calulate the distance between
|
|
1842
1843
|
* @param value2 value to calulate the distance between
|
|
1843
|
-
* @
|
|
1844
|
+
* @returns the distance between the two vectors squared
|
|
1844
1845
|
*/
|
|
1845
1846
|
static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
|
|
1846
1847
|
/**
|
|
1847
1848
|
* Returns a new Vector4 located at the center between the vectors "value1" and "value2".
|
|
1848
1849
|
* @param value1 value to calulate the center between
|
|
1849
1850
|
* @param value2 value to calulate the center between
|
|
1850
|
-
* @
|
|
1851
|
+
* @returns the center between the two vectors
|
|
1851
1852
|
*/
|
|
1852
1853
|
static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
|
|
1853
1854
|
/**
|
|
@@ -1988,7 +1989,7 @@ export declare class Quaternion {
|
|
|
1988
1989
|
/**
|
|
1989
1990
|
* Check if two quaternions are equals
|
|
1990
1991
|
* @param otherQuaternion defines the second operand
|
|
1991
|
-
* @
|
|
1992
|
+
* @returns true if the current quaternion and the given one coordinates are strictly equals
|
|
1992
1993
|
*/
|
|
1993
1994
|
equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
|
|
1994
1995
|
/**
|
|
@@ -2829,7 +2830,7 @@ export declare class Matrix {
|
|
|
2829
2830
|
/**
|
|
2830
2831
|
* Creates a new rotation matrix for "angle" radians around the X axis
|
|
2831
2832
|
* @param angle defines the angle (in radians) to use
|
|
2832
|
-
* @
|
|
2833
|
+
* @returns the new matrix
|
|
2833
2834
|
*/
|
|
2834
2835
|
static RotationX(angle: number): Matrix;
|
|
2835
2836
|
/**
|
|
@@ -2847,7 +2848,7 @@ export declare class Matrix {
|
|
|
2847
2848
|
/**
|
|
2848
2849
|
* Creates a new rotation matrix for "angle" radians around the Y axis
|
|
2849
2850
|
* @param angle defines the angle (in radians) to use
|
|
2850
|
-
* @
|
|
2851
|
+
* @returns the new matrix
|
|
2851
2852
|
*/
|
|
2852
2853
|
static RotationY(angle: number): Matrix;
|
|
2853
2854
|
/**
|
|
@@ -2859,7 +2860,7 @@ export declare class Matrix {
|
|
|
2859
2860
|
/**
|
|
2860
2861
|
* Creates a new rotation matrix for "angle" radians around the Z axis
|
|
2861
2862
|
* @param angle defines the angle (in radians) to use
|
|
2862
|
-
* @
|
|
2863
|
+
* @returns the new matrix
|
|
2863
2864
|
*/
|
|
2864
2865
|
static RotationZ(angle: number): Matrix;
|
|
2865
2866
|
/**
|
|
@@ -2872,7 +2873,7 @@ export declare class Matrix {
|
|
|
2872
2873
|
* Creates a new rotation matrix for "angle" radians around the given axis
|
|
2873
2874
|
* @param axis defines the axis to use
|
|
2874
2875
|
* @param angle defines the angle (in radians) to use
|
|
2875
|
-
* @
|
|
2876
|
+
* @returns the new matrix
|
|
2876
2877
|
*/
|
|
2877
2878
|
static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
|
|
2878
2879
|
/**
|
package/Maths/math.vector.js
CHANGED
|
@@ -1439,10 +1439,10 @@ export class Vector3 {
|
|
|
1439
1439
|
/**
|
|
1440
1440
|
* Get angle between two vectors
|
|
1441
1441
|
* Example Playground https://playground.babylonjs.com/#R1F8YU#86
|
|
1442
|
-
* @param vector0
|
|
1443
|
-
* @param vector1
|
|
1442
|
+
* @param vector0 the starting point
|
|
1443
|
+
* @param vector1 the ending point
|
|
1444
1444
|
* @param normal direction of the normal
|
|
1445
|
-
* @
|
|
1445
|
+
* @returns the angle between vector0 and vector1
|
|
1446
1446
|
*/
|
|
1447
1447
|
static GetAngleBetweenVectors(vector0, vector1, normal) {
|
|
1448
1448
|
const v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
|
|
@@ -1461,10 +1461,11 @@ export class Vector3 {
|
|
|
1461
1461
|
/**
|
|
1462
1462
|
* Get angle between two vectors projected on a plane
|
|
1463
1463
|
* Example Playground https://playground.babylonjs.com/#R1F8YU#87
|
|
1464
|
+
* Expectation compute time: 0.01 ms (median) and 0.02 ms (percentile 95%)
|
|
1464
1465
|
* @param vector0 angle between vector0 and vector1
|
|
1465
1466
|
* @param vector1 angle between vector0 and vector1
|
|
1466
1467
|
* @param normal Normal of the projection plane
|
|
1467
|
-
* @returns the angle between vector0 and vector1 projected on the plane with the specified normal
|
|
1468
|
+
* @returns the angle in radians (float) between vector0 and vector1 projected on the plane with the specified normal
|
|
1468
1469
|
*/
|
|
1469
1470
|
static GetAngleBetweenVectorsOnPlane(vector0, vector1, normal) {
|
|
1470
1471
|
MathTmp.Vector3[0].copyFrom(vector0);
|
|
@@ -2979,7 +2980,7 @@ export class Vector4 {
|
|
|
2979
2980
|
* Returns the distance (float) between the vectors "value1" and "value2".
|
|
2980
2981
|
* @param value1 value to calulate the distance between
|
|
2981
2982
|
* @param value2 value to calulate the distance between
|
|
2982
|
-
* @
|
|
2983
|
+
* @returns the distance between the two vectors
|
|
2983
2984
|
*/
|
|
2984
2985
|
static Distance(value1, value2) {
|
|
2985
2986
|
return Math.sqrt(Vector4.DistanceSquared(value1, value2));
|
|
@@ -2988,7 +2989,7 @@ export class Vector4 {
|
|
|
2988
2989
|
* Returns the squared distance (float) between the vectors "value1" and "value2".
|
|
2989
2990
|
* @param value1 value to calulate the distance between
|
|
2990
2991
|
* @param value2 value to calulate the distance between
|
|
2991
|
-
* @
|
|
2992
|
+
* @returns the distance between the two vectors squared
|
|
2992
2993
|
*/
|
|
2993
2994
|
static DistanceSquared(value1, value2) {
|
|
2994
2995
|
const x = value1.x - value2.x;
|
|
@@ -3001,7 +3002,7 @@ export class Vector4 {
|
|
|
3001
3002
|
* Returns a new Vector4 located at the center between the vectors "value1" and "value2".
|
|
3002
3003
|
* @param value1 value to calulate the center between
|
|
3003
3004
|
* @param value2 value to calulate the center between
|
|
3004
|
-
* @
|
|
3005
|
+
* @returns the center between the two vectors
|
|
3005
3006
|
*/
|
|
3006
3007
|
static Center(value1, value2) {
|
|
3007
3008
|
return Vector4.CenterToRef(value1, value2, Vector4.Zero());
|
|
@@ -3223,7 +3224,7 @@ export class Quaternion {
|
|
|
3223
3224
|
/**
|
|
3224
3225
|
* Check if two quaternions are equals
|
|
3225
3226
|
* @param otherQuaternion defines the second operand
|
|
3226
|
-
* @
|
|
3227
|
+
* @returns true if the current quaternion and the given one coordinates are strictly equals
|
|
3227
3228
|
*/
|
|
3228
3229
|
equals(otherQuaternion) {
|
|
3229
3230
|
return otherQuaternion && this._x === otherQuaternion._x && this._y === otherQuaternion._y && this._z === otherQuaternion._z && this._w === otherQuaternion._w;
|
|
@@ -4991,7 +4992,7 @@ export class Matrix {
|
|
|
4991
4992
|
/**
|
|
4992
4993
|
* Creates a new rotation matrix for "angle" radians around the X axis
|
|
4993
4994
|
* @param angle defines the angle (in radians) to use
|
|
4994
|
-
* @
|
|
4995
|
+
* @returns the new matrix
|
|
4995
4996
|
*/
|
|
4996
4997
|
static RotationX(angle) {
|
|
4997
4998
|
const result = new Matrix();
|
|
@@ -5022,7 +5023,7 @@ export class Matrix {
|
|
|
5022
5023
|
/**
|
|
5023
5024
|
* Creates a new rotation matrix for "angle" radians around the Y axis
|
|
5024
5025
|
* @param angle defines the angle (in radians) to use
|
|
5025
|
-
* @
|
|
5026
|
+
* @returns the new matrix
|
|
5026
5027
|
*/
|
|
5027
5028
|
static RotationY(angle) {
|
|
5028
5029
|
const result = new Matrix();
|
|
@@ -5043,7 +5044,7 @@ export class Matrix {
|
|
|
5043
5044
|
/**
|
|
5044
5045
|
* Creates a new rotation matrix for "angle" radians around the Z axis
|
|
5045
5046
|
* @param angle defines the angle (in radians) to use
|
|
5046
|
-
* @
|
|
5047
|
+
* @returns the new matrix
|
|
5047
5048
|
*/
|
|
5048
5049
|
static RotationZ(angle) {
|
|
5049
5050
|
const result = new Matrix();
|
|
@@ -5065,7 +5066,7 @@ export class Matrix {
|
|
|
5065
5066
|
* Creates a new rotation matrix for "angle" radians around the given axis
|
|
5066
5067
|
* @param axis defines the axis to use
|
|
5067
5068
|
* @param angle defines the angle (in radians) to use
|
|
5068
|
-
* @
|
|
5069
|
+
* @returns the new matrix
|
|
5069
5070
|
*/
|
|
5070
5071
|
static RotationAxis(axis, angle) {
|
|
5071
5072
|
const result = new Matrix();
|