@babylonjs/core 6.45.0 → 6.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animation.js +1 -1
- package/Animations/animation.js.map +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js +2 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
- package/Bones/skeleton.js +2 -2
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/camera.d.ts +3 -3
- package/Cameras/camera.js +2 -1
- package/Cameras/camera.js.map +1 -1
- package/Cameras/cameraInputsManager.js +1 -1
- package/Cameras/cameraInputsManager.js.map +1 -1
- package/Cameras/targetCamera.js +4 -0
- package/Cameras/targetCamera.js.map +1 -1
- package/Compute/computeShader.d.ts +4 -2
- package/Compute/computeShader.js +7 -3
- package/Compute/computeShader.js.map +1 -1
- package/Debug/directionalLightFrustumViewer.js +6 -6
- package/Debug/directionalLightFrustumViewer.js.map +1 -1
- package/Engines/Extensions/engine.computeShader.d.ts +2 -1
- package/Engines/Extensions/engine.computeShader.js +1 -0
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.js +3 -3
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/Native/nativePipelineContext.js +1 -1
- package/Engines/Native/nativePipelineContext.js.map +1 -1
- package/Engines/WebGL/webGLPipelineContext.js +1 -1
- package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuComputeContext.js +7 -3
- package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
- package/Engines/engine.d.ts +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -15
- package/Engines/webgpuEngine.js.map +1 -1
- package/Layers/glowLayer.js +2 -1
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js +2 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/Lights/light.js +2 -1
- package/Lights/light.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +9 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/sceneLoader.d.ts +6 -1
- package/Loading/sceneLoader.js +6 -5
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +2 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -1
- package/Materials/Node/nodeMaterial.js +5 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +1 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.js +2 -1
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js +2 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js +2 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/Textures/baseTexture.js +2 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +2 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.js +1 -1
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/texture.js +2 -1
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/colorCurves.d.ts +1 -1
- package/Materials/colorCurves.functions.d.ts +5 -0
- package/Materials/colorCurves.functions.js +8 -0
- package/Materials/colorCurves.functions.js.map +1 -0
- package/Materials/colorCurves.js +8 -8
- package/Materials/colorCurves.js.map +1 -1
- package/Materials/fresnelParameters.js +1 -1
- package/Materials/fresnelParameters.js.map +1 -1
- package/Materials/imageProcessingConfiguration.d.ts +3 -48
- package/Materials/imageProcessingConfiguration.defines.d.ts +46 -0
- package/Materials/imageProcessingConfiguration.defines.js +27 -0
- package/Materials/imageProcessingConfiguration.defines.js.map +1 -0
- package/Materials/imageProcessingConfiguration.functions.d.ts +13 -0
- package/Materials/imageProcessingConfiguration.functions.js +41 -0
- package/Materials/imageProcessingConfiguration.functions.js.map +1 -0
- package/Materials/imageProcessingConfiguration.js +18 -69
- package/Materials/imageProcessingConfiguration.js.map +1 -1
- package/Materials/material.js +2 -1
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.d.ts +33 -33
- package/Materials/materialHelper.js +244 -286
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/materialPluginBase.js +2 -1
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialStencilState.js +2 -1
- package/Materials/materialStencilState.js.map +1 -1
- package/Materials/shaderMaterial.js +1 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -1
- package/Materials/standardMaterial.js +2 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.js +2 -2
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.color.d.ts +392 -66
- package/Maths/math.color.js +541 -65
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.like.d.ts +17 -28
- package/Maths/math.like.js.map +1 -1
- package/Maths/math.plane.d.ts +2 -1
- package/Maths/math.plane.js.map +1 -1
- package/Maths/math.polar.d.ts +1 -1
- package/Maths/math.polar.js.map +1 -1
- package/Maths/math.scalar.d.ts +6 -6
- package/Maths/math.scalar.functions.d.ts +51 -0
- package/Maths/math.scalar.functions.js +80 -0
- package/Maths/math.scalar.functions.js.map +1 -0
- package/Maths/math.scalar.js +48 -73
- package/Maths/math.scalar.js.map +1 -1
- package/Maths/math.vector.d.ts +571 -72
- package/Maths/math.vector.js +917 -119
- package/Maths/math.vector.js.map +1 -1
- package/Maths/math.viewport.d.ts +2 -1
- package/Maths/math.viewport.js.map +1 -1
- package/Maths/tensor.d.ts +411 -0
- package/Maths/tensor.js +3 -0
- package/Maths/tensor.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js +20 -4
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +2 -1
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/mesh.js +2 -2
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +4 -0
- package/Meshes/mesh.vertexData.js +10 -0
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/transformNode.js +2 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/arrayTools.d.ts +2 -19
- package/Misc/arrayTools.js.map +1 -1
- package/Misc/decorators.d.ts +0 -80
- package/Misc/decorators.functions.d.ts +7 -0
- package/Misc/decorators.functions.js +52 -0
- package/Misc/decorators.functions.js.map +1 -0
- package/Misc/decorators.js +2 -318
- package/Misc/decorators.js.map +1 -1
- package/Misc/decorators.serialization.d.ts +81 -0
- package/Misc/decorators.serialization.js +269 -0
- package/Misc/decorators.serialization.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/sceneRecorder.js +1 -1
- package/Misc/sceneRecorder.js.map +1 -1
- package/Misc/sceneSerializer.js +8 -1
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/tools.functions.d.ts +14 -0
- package/Misc/tools.functions.js +23 -0
- package/Misc/tools.functions.js.map +1 -0
- package/Misc/tools.js +5 -6
- package/Misc/tools.js.map +1 -1
- package/Morph/morphTarget.js +2 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Particles/EmitterTypes/boxParticleEmitter.js +8 -8
- package/Particles/EmitterTypes/boxParticleEmitter.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +8 -11
- package/Particles/baseParticleSystem.js +9 -40
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +71 -1
- package/Particles/gpuParticleSystem.js +102 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particle.d.ts +3 -3
- package/Particles/particle.js +3 -3
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.d.ts +81 -455
- package/Particles/particleSystem.functions.d.ts +61 -0
- package/Particles/particleSystem.functions.js +79 -0
- package/Particles/particleSystem.functions.js.map +1 -0
- package/Particles/particleSystem.js +390 -1984
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +485 -0
- package/Particles/thinParticleSystem.js +1768 -0
- package/Particles/thinParticleSystem.js.map +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +2 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +2 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +2 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +2 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.js +2 -1
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.js +2 -1
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.js +2 -1
- package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js +2 -1
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.js +2 -1
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/displayPassPostProcess.js +1 -1
- package/PostProcesses/displayPassPostProcess.js.map +1 -1
- package/PostProcesses/filterPostProcess.js +2 -1
- package/PostProcesses/filterPostProcess.js.map +1 -1
- package/PostProcesses/fxaaPostProcess.js +1 -1
- package/PostProcesses/fxaaPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.js +2 -1
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.js +2 -1
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/passPostProcess.js +1 -1
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.js +2 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/refractionPostProcess.js +2 -1
- package/PostProcesses/refractionPostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.js +2 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js +2 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.js +2 -1
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/Probes/reflectionProbe.js +2 -1
- package/Probes/reflectionProbe.js.map +1 -1
- package/Sprites/spriteManager.d.ts +4 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
- package/XR/features/WebXRControllerTeleportation.js +75 -31
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/node.js +2 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +105 -0
- package/types.js.map +1 -1
package/Maths/math.vector.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import { Scalar } from "./math.scalar.js";
|
|
3
2
|
import { Epsilon } from "./math.constants.js";
|
|
4
3
|
import { ArrayTools } from "../Misc/arrayTools.js";
|
|
5
4
|
import { RegisterClass } from "../Misc/typeStore.js";
|
|
6
5
|
import { PerformanceConfigurator } from "../Engines/performanceConfigurator.js";
|
|
7
6
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
7
|
+
import { Clamp, Lerp, NormalizeRadians, RandomRange, WithinEpsilon } from "./math.scalar.functions.js";
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
9
|
const _ExtractAsInt = (value) => {
|
|
10
10
|
return parseInt(value.toString().replace(/\W/g, ""));
|
|
@@ -69,11 +69,11 @@ export class Vector2 {
|
|
|
69
69
|
* Update the current vector from an array
|
|
70
70
|
* Example Playground https://playground.babylonjs.com/#QYBWV4#39
|
|
71
71
|
* @param array defines the destination array
|
|
72
|
-
* @param
|
|
72
|
+
* @param offset defines the offset in the destination array
|
|
73
73
|
* @returns the current Vector2
|
|
74
74
|
*/
|
|
75
|
-
fromArray(array,
|
|
76
|
-
Vector2.FromArrayToRef(array,
|
|
75
|
+
fromArray(array, offset = 0) {
|
|
76
|
+
Vector2.FromArrayToRef(array, offset, this);
|
|
77
77
|
return this;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
@@ -82,9 +82,7 @@ export class Vector2 {
|
|
|
82
82
|
* @returns a new array with 2 elements: the Vector2 coordinates.
|
|
83
83
|
*/
|
|
84
84
|
asArray() {
|
|
85
|
-
|
|
86
|
-
this.toArray(result, 0);
|
|
87
|
-
return result;
|
|
85
|
+
return [this.x, this.y];
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
90
88
|
* Sets the Vector2 coordinates with the given Vector2 coordinates
|
|
@@ -119,6 +117,14 @@ export class Vector2 {
|
|
|
119
117
|
set(x, y) {
|
|
120
118
|
return this.copyFromFloats(x, y);
|
|
121
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Copies the given float to the current Vector2 coordinates
|
|
122
|
+
* @param v defines the x and y coordinates of the operand
|
|
123
|
+
* @returns the current updated Vector2
|
|
124
|
+
*/
|
|
125
|
+
setAll(v) {
|
|
126
|
+
return this.copyFromFloats(v, v);
|
|
127
|
+
}
|
|
122
128
|
/**
|
|
123
129
|
* Add another vector with the current one
|
|
124
130
|
* Example Playground https://playground.babylonjs.com/#QYBWV4#11
|
|
@@ -151,6 +157,17 @@ export class Vector2 {
|
|
|
151
157
|
this.y += otherVector.y;
|
|
152
158
|
return this;
|
|
153
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Adds the given coordinates to the current Vector2
|
|
162
|
+
* @param x defines the x coordinate of the operand
|
|
163
|
+
* @param y defines the y coordinate of the operand
|
|
164
|
+
* @returns the current updated Vector2
|
|
165
|
+
*/
|
|
166
|
+
addInPlaceFromFloats(x, y) {
|
|
167
|
+
this.x += x;
|
|
168
|
+
this.y += y;
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
154
171
|
/**
|
|
155
172
|
* Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
|
|
156
173
|
* Example Playground https://playground.babylonjs.com/#QYBWV4#14
|
|
@@ -262,11 +279,69 @@ export class Vector2 {
|
|
|
262
279
|
* @returns the current updated Vector2
|
|
263
280
|
*/
|
|
264
281
|
divideInPlace(otherVector) {
|
|
265
|
-
|
|
282
|
+
this.x = this.x / otherVector.x;
|
|
283
|
+
this.y = this.y / otherVector.y;
|
|
284
|
+
return this;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Updates the current Vector2 with the minimal coordinate values between its and the given vector ones
|
|
288
|
+
* @param other defines the second operand
|
|
289
|
+
* @returns the current updated Vector2
|
|
290
|
+
*/
|
|
291
|
+
minimizeInPlace(other) {
|
|
292
|
+
return this.minimizeInPlaceFromFloats(other.x, other.y);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Updates the current Vector2 with the maximal coordinate values between its and the given vector ones.
|
|
296
|
+
* @param other defines the second operand
|
|
297
|
+
* @returns the current updated Vector2
|
|
298
|
+
*/
|
|
299
|
+
maximizeInPlace(other) {
|
|
300
|
+
return this.maximizeInPlaceFromFloats(other.x, other.y);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Updates the current Vector2 with the minimal coordinate values between its and the given coordinates
|
|
304
|
+
* @param x defines the x coordinate of the operand
|
|
305
|
+
* @param y defines the y coordinate of the operand
|
|
306
|
+
* @returns the current updated Vector2
|
|
307
|
+
*/
|
|
308
|
+
minimizeInPlaceFromFloats(x, y) {
|
|
309
|
+
this.x = Math.min(x, this.x);
|
|
310
|
+
this.y = Math.min(y, this.y);
|
|
311
|
+
return this;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Updates the current Vector2 with the maximal coordinate values between its and the given coordinates.
|
|
315
|
+
* @param x defines the x coordinate of the operand
|
|
316
|
+
* @param y defines the y coordinate of the operand
|
|
317
|
+
* @returns the current updated Vector2
|
|
318
|
+
*/
|
|
319
|
+
maximizeInPlaceFromFloats(x, y) {
|
|
320
|
+
this.x = Math.max(x, this.x);
|
|
321
|
+
this.y = Math.max(y, this.y);
|
|
322
|
+
return this;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Returns a new Vector2 set with the subtraction of the given floats from the current Vector2 coordinates
|
|
326
|
+
* @param x defines the x coordinate of the operand
|
|
327
|
+
* @param y defines the y coordinate of the operand
|
|
328
|
+
* @returns the resulting Vector2
|
|
329
|
+
*/
|
|
330
|
+
subtractFromFloats(x, y) {
|
|
331
|
+
return new this.constructor(this.x - x, this.y - y);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Subtracts the given floats from the current Vector2 coordinates and set the given vector "result" with this result
|
|
335
|
+
* @param x defines the x coordinate of the operand
|
|
336
|
+
* @param y defines the y coordinate of the operand
|
|
337
|
+
* @param result defines the Vector2 object where to store the result
|
|
338
|
+
* @returns the result
|
|
339
|
+
*/
|
|
340
|
+
subtractFromFloatsToRef(x, y, result) {
|
|
341
|
+
return result.copyFromFloats(this.x - x, this.y - y);
|
|
266
342
|
}
|
|
267
343
|
/**
|
|
268
344
|
* Gets a new Vector2 with current Vector2 negated coordinates
|
|
269
|
-
* Example Playground https://playground.babylonjs.com/#QYBWV4#22
|
|
270
345
|
* @returns a new Vector2
|
|
271
346
|
*/
|
|
272
347
|
negate() {
|
|
@@ -309,9 +384,7 @@ export class Vector2 {
|
|
|
309
384
|
* @returns a new Vector2
|
|
310
385
|
*/
|
|
311
386
|
scale(scale) {
|
|
312
|
-
|
|
313
|
-
this.scaleToRef(scale, result);
|
|
314
|
-
return result;
|
|
387
|
+
return new this.constructor(this.x * scale, this.y * scale);
|
|
315
388
|
}
|
|
316
389
|
/**
|
|
317
390
|
* Scale the current Vector2 values by a factor to a given Vector2
|
|
@@ -354,7 +427,16 @@ export class Vector2 {
|
|
|
354
427
|
* @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
|
|
355
428
|
*/
|
|
356
429
|
equalsWithEpsilon(otherVector, epsilon = Epsilon) {
|
|
357
|
-
return otherVector &&
|
|
430
|
+
return otherVector && WithinEpsilon(this.x, otherVector.x, epsilon) && WithinEpsilon(this.y, otherVector.y, epsilon);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Returns true if the current Vector2 coordinates equals the given floats
|
|
434
|
+
* @param x defines the x coordinate of the operand
|
|
435
|
+
* @param y defines the y coordinate of the operand
|
|
436
|
+
* @returns true if both vectors are equal
|
|
437
|
+
*/
|
|
438
|
+
equalsToFloats(x, y) {
|
|
439
|
+
return this.x === x && this.y === y;
|
|
358
440
|
}
|
|
359
441
|
/**
|
|
360
442
|
* Gets a new Vector2 from current Vector2 floored values
|
|
@@ -365,6 +447,16 @@ export class Vector2 {
|
|
|
365
447
|
floor() {
|
|
366
448
|
return new this.constructor(Math.floor(this.x), Math.floor(this.y));
|
|
367
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* Gets the current Vector2's floored values and stores them in result
|
|
452
|
+
* @param result the Vector2 to store the result in
|
|
453
|
+
* @returns the result Vector2
|
|
454
|
+
*/
|
|
455
|
+
floorToRef(result) {
|
|
456
|
+
result.x = Math.floor(this.x);
|
|
457
|
+
result.y = Math.floor(this.y);
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
368
460
|
/**
|
|
369
461
|
* Gets a new Vector2 from current Vector2 fractional values
|
|
370
462
|
* Example Playground https://playground.babylonjs.com/#QYBWV4#34
|
|
@@ -374,6 +466,16 @@ export class Vector2 {
|
|
|
374
466
|
fract() {
|
|
375
467
|
return new this.constructor(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
|
|
376
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Gets the current Vector2's fractional values and stores them in result
|
|
471
|
+
* @param result the Vector2 to store the result in
|
|
472
|
+
* @returns the result Vector2
|
|
473
|
+
*/
|
|
474
|
+
fractToRef(result) {
|
|
475
|
+
result.x = this.x - Math.floor(this.x);
|
|
476
|
+
result.y = this.y - Math.floor(this.y);
|
|
477
|
+
return result;
|
|
478
|
+
}
|
|
377
479
|
/**
|
|
378
480
|
* Rotate the current vector into a given result vector
|
|
379
481
|
* Example Playground https://playground.babylonjs.com/#QYBWV4#49
|
|
@@ -431,19 +533,19 @@ export class Vector2 {
|
|
|
431
533
|
* @returns the new Vector2
|
|
432
534
|
*/
|
|
433
535
|
normalizeToNew() {
|
|
434
|
-
const normalized = new this.constructor(
|
|
536
|
+
const normalized = new this.constructor();
|
|
435
537
|
this.normalizeToRef(normalized);
|
|
436
538
|
return normalized;
|
|
437
539
|
}
|
|
438
540
|
/**
|
|
439
541
|
* Normalize the current Vector2 to the reference
|
|
440
|
-
* @param reference define the
|
|
542
|
+
* @param reference define the Vector to update
|
|
441
543
|
* @returns the updated Vector2
|
|
442
544
|
*/
|
|
443
545
|
normalizeToRef(reference) {
|
|
444
546
|
const len = this.length();
|
|
445
|
-
if (len === 0
|
|
446
|
-
return reference.
|
|
547
|
+
if (len === 0) {
|
|
548
|
+
return reference.copyFrom(this);
|
|
447
549
|
}
|
|
448
550
|
return this.scaleToRef(1.0 / len, reference);
|
|
449
551
|
}
|
|
@@ -485,7 +587,17 @@ export class Vector2 {
|
|
|
485
587
|
* @returns a Vector2 with random values between min and max
|
|
486
588
|
*/
|
|
487
589
|
static Random(min = 0, max = 1) {
|
|
488
|
-
return new Vector2(
|
|
590
|
+
return new Vector2(RandomRange(min, max), RandomRange(min, max));
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Sets a Vector2 with random values between min and max
|
|
594
|
+
* @param min the minimum random value
|
|
595
|
+
* @param max the maximum random value
|
|
596
|
+
* @param ref the ref to store the values in
|
|
597
|
+
* @returns the ref with random values between min and max
|
|
598
|
+
*/
|
|
599
|
+
static RandomToRef(min = 0, max = 1, ref) {
|
|
600
|
+
return ref.copyFromFloats(RandomRange(min, max), RandomRange(min, max));
|
|
489
601
|
}
|
|
490
602
|
/**
|
|
491
603
|
* Gets a zero Vector2 that must not be updated
|
|
@@ -516,6 +628,17 @@ export class Vector2 {
|
|
|
516
628
|
result.y = array[offset + 1];
|
|
517
629
|
return result;
|
|
518
630
|
}
|
|
631
|
+
/**
|
|
632
|
+
* Sets the given vector "result" with the given floats.
|
|
633
|
+
* @param x defines the x coordinate of the source
|
|
634
|
+
* @param y defines the y coordinate of the source
|
|
635
|
+
* @param result defines the Vector2 where to store the result
|
|
636
|
+
* @returns the result vector
|
|
637
|
+
*/
|
|
638
|
+
static FromFloatsToRef(x, y, result) {
|
|
639
|
+
result.copyFromFloats(x, y);
|
|
640
|
+
return result;
|
|
641
|
+
}
|
|
519
642
|
/**
|
|
520
643
|
* Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
|
|
521
644
|
* Example Playground https://playground.babylonjs.com/#QYBWV4#65
|
|
@@ -541,6 +664,21 @@ export class Vector2 {
|
|
|
541
664
|
(-value1.y + 3.0 * value2.y - 3.0 * value3.y + value4.y) * cubed);
|
|
542
665
|
return new value1.constructor(x, y);
|
|
543
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* Sets reference with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
|
|
669
|
+
* If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
|
|
670
|
+
* If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
|
|
671
|
+
* @param value defines the value to clamp
|
|
672
|
+
* @param min defines the lower limit
|
|
673
|
+
* @param max defines the upper limit
|
|
674
|
+
* @param ref the reference
|
|
675
|
+
* @returns the reference
|
|
676
|
+
*/
|
|
677
|
+
static ClampToRef(value, min, max, ref) {
|
|
678
|
+
ref.x = Clamp(value.x, min.x, max.x);
|
|
679
|
+
ref.y = Clamp(value.y, min.y, max.y);
|
|
680
|
+
return ref;
|
|
681
|
+
}
|
|
544
682
|
/**
|
|
545
683
|
* Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
|
|
546
684
|
* If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
|
|
@@ -552,12 +690,8 @@ export class Vector2 {
|
|
|
552
690
|
* @returns a new Vector2
|
|
553
691
|
*/
|
|
554
692
|
static Clamp(value, min, max) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
x = x < min.x ? min.x : x;
|
|
558
|
-
let y = value.y;
|
|
559
|
-
y = y > max.y ? max.y : y;
|
|
560
|
-
y = y < min.y ? min.y : y;
|
|
693
|
+
const x = Clamp(value.x, min.x, max.x);
|
|
694
|
+
const y = Clamp(value.y, min.y, max.y);
|
|
561
695
|
return new value.constructor(x, y);
|
|
562
696
|
}
|
|
563
697
|
/**
|
|
@@ -791,6 +925,11 @@ export class Vector2 {
|
|
|
791
925
|
}
|
|
792
926
|
}
|
|
793
927
|
Vector2._ZeroReadOnly = Vector2.Zero();
|
|
928
|
+
Vector2;
|
|
929
|
+
Object.defineProperties(Vector2.prototype, {
|
|
930
|
+
dimension: { value: [2] },
|
|
931
|
+
rank: { value: 1 },
|
|
932
|
+
});
|
|
794
933
|
/**
|
|
795
934
|
* Class used to store (x,y,z) vector representation
|
|
796
935
|
* A Vector3 is the main object used in 3D geometry
|
|
@@ -871,9 +1010,7 @@ export class Vector3 {
|
|
|
871
1010
|
* @returns a new array of numbers
|
|
872
1011
|
*/
|
|
873
1012
|
asArray() {
|
|
874
|
-
|
|
875
|
-
this.toArray(result, 0);
|
|
876
|
-
return result;
|
|
1013
|
+
return [this._x, this._y, this._z];
|
|
877
1014
|
}
|
|
878
1015
|
/**
|
|
879
1016
|
* Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
|
|
@@ -892,11 +1029,11 @@ export class Vector3 {
|
|
|
892
1029
|
* Update the current vector from an array
|
|
893
1030
|
* Example Playground https://playground.babylonjs.com/#R1F8YU#24
|
|
894
1031
|
* @param array defines the destination array
|
|
895
|
-
* @param
|
|
1032
|
+
* @param offset defines the offset in the destination array
|
|
896
1033
|
* @returns the current Vector3
|
|
897
1034
|
*/
|
|
898
|
-
fromArray(array,
|
|
899
|
-
Vector3.FromArrayToRef(array,
|
|
1035
|
+
fromArray(array, offset = 0) {
|
|
1036
|
+
Vector3.FromArrayToRef(array, offset, this);
|
|
900
1037
|
return this;
|
|
901
1038
|
}
|
|
902
1039
|
/**
|
|
@@ -914,7 +1051,11 @@ export class Vector3 {
|
|
|
914
1051
|
* @returns the current updated Vector3
|
|
915
1052
|
*/
|
|
916
1053
|
addInPlace(otherVector) {
|
|
917
|
-
|
|
1054
|
+
this._x += otherVector._x;
|
|
1055
|
+
this._y += otherVector._y;
|
|
1056
|
+
this._z += otherVector._z;
|
|
1057
|
+
this._isDirty = true;
|
|
1058
|
+
return this;
|
|
918
1059
|
}
|
|
919
1060
|
/**
|
|
920
1061
|
* Adds the given coordinates to the current Vector3
|
|
@@ -1206,10 +1347,7 @@ export class Vector3 {
|
|
|
1206
1347
|
* @returns true if both vectors are distant less than epsilon
|
|
1207
1348
|
*/
|
|
1208
1349
|
equalsWithEpsilon(otherVector, epsilon = Epsilon) {
|
|
1209
|
-
return (otherVector &&
|
|
1210
|
-
Scalar.WithinEpsilon(this._x, otherVector._x, epsilon) &&
|
|
1211
|
-
Scalar.WithinEpsilon(this._y, otherVector._y, epsilon) &&
|
|
1212
|
-
Scalar.WithinEpsilon(this._z, otherVector._z, epsilon));
|
|
1350
|
+
return otherVector && WithinEpsilon(this._x, otherVector._x, epsilon) && WithinEpsilon(this._y, otherVector._y, epsilon) && WithinEpsilon(this._z, otherVector._z, epsilon);
|
|
1213
1351
|
}
|
|
1214
1352
|
/**
|
|
1215
1353
|
* Returns true if the current Vector3 coordinates equals the given floats
|
|
@@ -1291,7 +1429,11 @@ export class Vector3 {
|
|
|
1291
1429
|
* @returns the current updated Vector3
|
|
1292
1430
|
*/
|
|
1293
1431
|
divideInPlace(otherVector) {
|
|
1294
|
-
|
|
1432
|
+
this._x = this._x / otherVector._x;
|
|
1433
|
+
this._y = this._y / otherVector._y;
|
|
1434
|
+
this._z = this._z / otherVector._z;
|
|
1435
|
+
this._isDirty = true;
|
|
1436
|
+
return this;
|
|
1295
1437
|
}
|
|
1296
1438
|
/**
|
|
1297
1439
|
* Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
|
|
@@ -1360,14 +1502,14 @@ export class Vector3 {
|
|
|
1360
1502
|
isNonUniformWithinEpsilon(epsilon) {
|
|
1361
1503
|
const absX = Math.abs(this._x);
|
|
1362
1504
|
const absY = Math.abs(this._y);
|
|
1363
|
-
if (!
|
|
1505
|
+
if (!WithinEpsilon(absX, absY, epsilon)) {
|
|
1364
1506
|
return true;
|
|
1365
1507
|
}
|
|
1366
1508
|
const absZ = Math.abs(this._z);
|
|
1367
|
-
if (!
|
|
1509
|
+
if (!WithinEpsilon(absX, absZ, epsilon)) {
|
|
1368
1510
|
return true;
|
|
1369
1511
|
}
|
|
1370
|
-
if (!
|
|
1512
|
+
if (!WithinEpsilon(absY, absZ, epsilon)) {
|
|
1371
1513
|
return true;
|
|
1372
1514
|
}
|
|
1373
1515
|
return false;
|
|
@@ -1387,13 +1529,37 @@ export class Vector3 {
|
|
|
1387
1529
|
}
|
|
1388
1530
|
return false;
|
|
1389
1531
|
}
|
|
1532
|
+
/**
|
|
1533
|
+
* Gets the current Vector3's floored values and stores them in result
|
|
1534
|
+
* @param result the vector to store the result in
|
|
1535
|
+
* @returns the result vector
|
|
1536
|
+
*/
|
|
1537
|
+
floorToRef(result) {
|
|
1538
|
+
result._x = Math.floor(this._x);
|
|
1539
|
+
result._y = Math.floor(this._y);
|
|
1540
|
+
result._z = Math.floor(this._z);
|
|
1541
|
+
result._isDirty = true;
|
|
1542
|
+
return result;
|
|
1543
|
+
}
|
|
1390
1544
|
/**
|
|
1391
1545
|
* Gets a new Vector3 from current Vector3 floored values
|
|
1392
1546
|
* Example Playground https://playground.babylonjs.com/#R1F8YU#22
|
|
1393
1547
|
* @returns a new Vector3
|
|
1394
1548
|
*/
|
|
1395
1549
|
floor() {
|
|
1396
|
-
return new this.constructor(Math.floor(this.
|
|
1550
|
+
return new this.constructor(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Gets the current Vector3's fractional values and stores them in result
|
|
1554
|
+
* @param result the vector to store the result in
|
|
1555
|
+
* @returns the result vector
|
|
1556
|
+
*/
|
|
1557
|
+
fractToRef(result) {
|
|
1558
|
+
result._x = this.x - Math.floor(this._x);
|
|
1559
|
+
result._y = this.y - Math.floor(this._y);
|
|
1560
|
+
result._z = this.z - Math.floor(this._z);
|
|
1561
|
+
result._isDirty = true;
|
|
1562
|
+
return result;
|
|
1397
1563
|
}
|
|
1398
1564
|
/**
|
|
1399
1565
|
* Gets a new Vector3 from current Vector3 fractional values
|
|
@@ -1401,7 +1567,7 @@ export class Vector3 {
|
|
|
1401
1567
|
* @returns a new Vector3
|
|
1402
1568
|
*/
|
|
1403
1569
|
fract() {
|
|
1404
|
-
return new this.constructor(this.
|
|
1570
|
+
return new this.constructor(this.x - Math.floor(this._x), this.y - Math.floor(this._y), this.z - Math.floor(this._z));
|
|
1405
1571
|
}
|
|
1406
1572
|
// Properties
|
|
1407
1573
|
/**
|
|
@@ -1410,7 +1576,7 @@ export class Vector3 {
|
|
|
1410
1576
|
* @returns the length of the Vector3
|
|
1411
1577
|
*/
|
|
1412
1578
|
length() {
|
|
1413
|
-
return Math.sqrt(this.
|
|
1579
|
+
return Math.sqrt(this.lengthSquared());
|
|
1414
1580
|
}
|
|
1415
1581
|
/**
|
|
1416
1582
|
* Gets the squared length of the Vector3
|
|
@@ -1522,7 +1688,7 @@ export class Vector3 {
|
|
|
1522
1688
|
normalizeToRef(reference) {
|
|
1523
1689
|
const len = this.length();
|
|
1524
1690
|
if (len === 0 || len === 1.0) {
|
|
1525
|
-
return reference.
|
|
1691
|
+
return reference.copyFrom(this);
|
|
1526
1692
|
}
|
|
1527
1693
|
return this.scaleToRef(1.0 / len, reference);
|
|
1528
1694
|
}
|
|
@@ -1608,7 +1774,7 @@ export class Vector3 {
|
|
|
1608
1774
|
const v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
|
|
1609
1775
|
let dot = Vector3.Dot(v0, v1);
|
|
1610
1776
|
// Vectors are normalized so dot will be in [-1, 1] (aside precision issues enough to break the result which explains the below clamp)
|
|
1611
|
-
dot =
|
|
1777
|
+
dot = Clamp(dot, -1, 1);
|
|
1612
1778
|
const angle = Math.acos(dot);
|
|
1613
1779
|
const n = MathTmp.Vector3[3];
|
|
1614
1780
|
Vector3.CrossToRef(v0, v1, n);
|
|
@@ -1641,7 +1807,7 @@ export class Vector3 {
|
|
|
1641
1807
|
Vector3.CrossToRef(vNormal, v0, right);
|
|
1642
1808
|
Vector3.CrossToRef(right, vNormal, forward);
|
|
1643
1809
|
const angle = Math.atan2(Vector3.Dot(v1, right), Vector3.Dot(v1, forward));
|
|
1644
|
-
return
|
|
1810
|
+
return NormalizeRadians(angle);
|
|
1645
1811
|
}
|
|
1646
1812
|
/**
|
|
1647
1813
|
* Gets the rotation that aligns the roll axis (Y) to the line joining the start point to the target point and stores it in the ref Vector3
|
|
@@ -1684,7 +1850,7 @@ export class Vector3 {
|
|
|
1684
1850
|
* @returns The slerped vector
|
|
1685
1851
|
*/
|
|
1686
1852
|
static SlerpToRef(vector0, vector1, slerp, result) {
|
|
1687
|
-
slerp =
|
|
1853
|
+
slerp = Clamp(slerp, 0, 1);
|
|
1688
1854
|
const vector0Dir = MathTmp.Vector3[0];
|
|
1689
1855
|
const vector1Dir = MathTmp.Vector3[1];
|
|
1690
1856
|
vector0Dir.copyFrom(vector0);
|
|
@@ -1710,7 +1876,7 @@ export class Vector3 {
|
|
|
1710
1876
|
vector0Dir.scaleInPlace(scale0);
|
|
1711
1877
|
vector1Dir.scaleInPlace(scale1);
|
|
1712
1878
|
result.copyFrom(vector0Dir).addInPlace(vector1Dir);
|
|
1713
|
-
result.scaleInPlace(
|
|
1879
|
+
result.scaleInPlace(Lerp(vector0Length, vector1Length, slerp));
|
|
1714
1880
|
return result;
|
|
1715
1881
|
}
|
|
1716
1882
|
/**
|
|
@@ -1917,7 +2083,17 @@ export class Vector3 {
|
|
|
1917
2083
|
* @returns a Vector3 with random values between min and max
|
|
1918
2084
|
*/
|
|
1919
2085
|
static Random(min = 0, max = 1) {
|
|
1920
|
-
return new Vector3(
|
|
2086
|
+
return new Vector3(RandomRange(min, max), RandomRange(min, max), RandomRange(min, max));
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Sets a Vector3 with random values between min and max
|
|
2090
|
+
* @param min the minimum random value
|
|
2091
|
+
* @param max the maximum random value
|
|
2092
|
+
* @param ref the ref to store the values in
|
|
2093
|
+
* @returns the ref with random values between min and max
|
|
2094
|
+
*/
|
|
2095
|
+
static RandomToRef(min = 0, max = 1, ref) {
|
|
2096
|
+
return ref.copyFromFloats(RandomRange(min, max), RandomRange(min, max), RandomRange(min, max));
|
|
1921
2097
|
}
|
|
1922
2098
|
/**
|
|
1923
2099
|
* Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
|
|
@@ -2312,7 +2488,7 @@ export class Vector3 {
|
|
|
2312
2488
|
Vector3.TransformCoordinatesToRef(source, matrix, result);
|
|
2313
2489
|
const m = matrix.m;
|
|
2314
2490
|
const num = source._x * m[3] + source._y * m[7] + source._z * m[11] + m[15];
|
|
2315
|
-
if (
|
|
2491
|
+
if (WithinEpsilon(num, 1.0)) {
|
|
2316
2492
|
result.scaleInPlace(1.0 / num);
|
|
2317
2493
|
}
|
|
2318
2494
|
return result;
|
|
@@ -2577,7 +2753,7 @@ export class Vector3 {
|
|
|
2577
2753
|
l = edge.length();
|
|
2578
2754
|
edge.normalizeFromLength(l);
|
|
2579
2755
|
let t = Vector3.Dot(tmp, edge) / Math.max(l, Epsilon);
|
|
2580
|
-
t =
|
|
2756
|
+
t = Clamp(t, 0, 1);
|
|
2581
2757
|
triProj.copyFrom(e0).addInPlace(edge.scaleInPlace(t * l));
|
|
2582
2758
|
ref.copyFrom(triProj);
|
|
2583
2759
|
return Vector3.Distance(vector, triProj);
|
|
@@ -2646,6 +2822,11 @@ Vector3._RightReadOnly = Vector3.Right();
|
|
|
2646
2822
|
Vector3._LeftReadOnly = Vector3.Left();
|
|
2647
2823
|
Vector3._ZeroReadOnly = Vector3.Zero();
|
|
2648
2824
|
Vector3._OneReadOnly = Vector3.One();
|
|
2825
|
+
Vector3;
|
|
2826
|
+
Object.defineProperties(Vector3.prototype, {
|
|
2827
|
+
dimension: { value: [3] },
|
|
2828
|
+
rank: { value: 1 },
|
|
2829
|
+
});
|
|
2649
2830
|
/**
|
|
2650
2831
|
* Vector4 class created for EulerAngle class conversion to Quaternion
|
|
2651
2832
|
*/
|
|
@@ -2706,9 +2887,7 @@ export class Vector4 {
|
|
|
2706
2887
|
* @returns the resulting array
|
|
2707
2888
|
*/
|
|
2708
2889
|
asArray() {
|
|
2709
|
-
|
|
2710
|
-
this.toArray(result, 0);
|
|
2711
|
-
return result;
|
|
2890
|
+
return [this.x, this.y, this.z, this.w];
|
|
2712
2891
|
}
|
|
2713
2892
|
/**
|
|
2714
2893
|
* Populates the given array from the given index with the Vector4 coordinates.
|
|
@@ -2729,11 +2908,11 @@ export class Vector4 {
|
|
|
2729
2908
|
/**
|
|
2730
2909
|
* Update the current vector from an array
|
|
2731
2910
|
* @param array defines the destination array
|
|
2732
|
-
* @param
|
|
2911
|
+
* @param offset defines the offset in the destination array
|
|
2733
2912
|
* @returns the current Vector3
|
|
2734
2913
|
*/
|
|
2735
|
-
fromArray(array,
|
|
2736
|
-
Vector4.FromArrayToRef(array,
|
|
2914
|
+
fromArray(array, offset = 0) {
|
|
2915
|
+
Vector4.FromArrayToRef(array, offset, this);
|
|
2737
2916
|
return this;
|
|
2738
2917
|
}
|
|
2739
2918
|
/**
|
|
@@ -2748,6 +2927,21 @@ export class Vector4 {
|
|
|
2748
2927
|
this.w += otherVector.w;
|
|
2749
2928
|
return this;
|
|
2750
2929
|
}
|
|
2930
|
+
/**
|
|
2931
|
+
* Adds the given coordinates to the current Vector4
|
|
2932
|
+
* @param x defines the x coordinate of the operand
|
|
2933
|
+
* @param y defines the y coordinate of the operand
|
|
2934
|
+
* @param z defines the z coordinate of the operand
|
|
2935
|
+
* @param w defines the w coordinate of the operand
|
|
2936
|
+
* @returns the current updated Vector4
|
|
2937
|
+
*/
|
|
2938
|
+
addInPlaceFromFloats(x, y, z, w) {
|
|
2939
|
+
this.x += x;
|
|
2940
|
+
this.y += y;
|
|
2941
|
+
this.z += z;
|
|
2942
|
+
this.w += w;
|
|
2943
|
+
return this;
|
|
2944
|
+
}
|
|
2751
2945
|
/**
|
|
2752
2946
|
* Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
|
|
2753
2947
|
* @param otherVector the vector to add
|
|
@@ -2802,9 +2996,6 @@ export class Vector4 {
|
|
|
2802
2996
|
result.w = this.w - otherVector.w;
|
|
2803
2997
|
return result;
|
|
2804
2998
|
}
|
|
2805
|
-
/**
|
|
2806
|
-
* Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
|
|
2807
|
-
*/
|
|
2808
2999
|
/**
|
|
2809
3000
|
* Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
|
|
2810
3001
|
* @param x value to subtract
|
|
@@ -2920,10 +3111,10 @@ export class Vector4 {
|
|
|
2920
3111
|
*/
|
|
2921
3112
|
equalsWithEpsilon(otherVector, epsilon = Epsilon) {
|
|
2922
3113
|
return (otherVector &&
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
3114
|
+
WithinEpsilon(this.x, otherVector.x, epsilon) &&
|
|
3115
|
+
WithinEpsilon(this.y, otherVector.y, epsilon) &&
|
|
3116
|
+
WithinEpsilon(this.z, otherVector.z, epsilon) &&
|
|
3117
|
+
WithinEpsilon(this.w, otherVector.w, epsilon));
|
|
2927
3118
|
}
|
|
2928
3119
|
/**
|
|
2929
3120
|
* Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
|
|
@@ -3049,6 +3240,48 @@ export class Vector4 {
|
|
|
3049
3240
|
}
|
|
3050
3241
|
return this;
|
|
3051
3242
|
}
|
|
3243
|
+
/**
|
|
3244
|
+
* Updates the current Vector4 with the minimal coordinate values between its and the given coordinates
|
|
3245
|
+
* @param x defines the x coordinate of the operand
|
|
3246
|
+
* @param y defines the y coordinate of the operand
|
|
3247
|
+
* @param z defines the z coordinate of the operand
|
|
3248
|
+
* @param w defines the w coordinate of the operand
|
|
3249
|
+
* @returns the current updated Vector4
|
|
3250
|
+
*/
|
|
3251
|
+
minimizeInPlaceFromFloats(x, y, z, w) {
|
|
3252
|
+
this.x = Math.min(x, this.x);
|
|
3253
|
+
this.y = Math.min(y, this.y);
|
|
3254
|
+
this.z = Math.min(z, this.z);
|
|
3255
|
+
this.w = Math.min(w, this.w);
|
|
3256
|
+
return this;
|
|
3257
|
+
}
|
|
3258
|
+
/**
|
|
3259
|
+
* Updates the current Vector4 with the maximal coordinate values between its and the given coordinates.
|
|
3260
|
+
* @param x defines the x coordinate of the operand
|
|
3261
|
+
* @param y defines the y coordinate of the operand
|
|
3262
|
+
* @param z defines the z coordinate of the operand
|
|
3263
|
+
* @param w defines the w coordinate of the operand
|
|
3264
|
+
* @returns the current updated Vector4
|
|
3265
|
+
*/
|
|
3266
|
+
maximizeInPlaceFromFloats(x, y, z, w) {
|
|
3267
|
+
this.x = Math.max(x, this.x);
|
|
3268
|
+
this.y = Math.max(y, this.y);
|
|
3269
|
+
this.z = Math.max(z, this.z);
|
|
3270
|
+
this.w = Math.max(w, this.w);
|
|
3271
|
+
return this;
|
|
3272
|
+
}
|
|
3273
|
+
/**
|
|
3274
|
+
* Gets the current Vector4's floored values and stores them in result
|
|
3275
|
+
* @param result the vector to store the result in
|
|
3276
|
+
* @returns the result vector
|
|
3277
|
+
*/
|
|
3278
|
+
floorToRef(result) {
|
|
3279
|
+
result.x = Math.floor(this.x);
|
|
3280
|
+
result.y = Math.floor(this.y);
|
|
3281
|
+
result.z = Math.floor(this.z);
|
|
3282
|
+
result.w = Math.floor(this.w);
|
|
3283
|
+
return result;
|
|
3284
|
+
}
|
|
3052
3285
|
/**
|
|
3053
3286
|
* Gets a new Vector4 from current Vector4 floored values
|
|
3054
3287
|
* @returns a new Vector4
|
|
@@ -3056,6 +3289,18 @@ export class Vector4 {
|
|
|
3056
3289
|
floor() {
|
|
3057
3290
|
return new this.constructor(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
|
|
3058
3291
|
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Gets the current Vector4's fractional values and stores them in result
|
|
3294
|
+
* @param result the vector to store the result in
|
|
3295
|
+
* @returns the result vector
|
|
3296
|
+
*/
|
|
3297
|
+
fractToRef(result) {
|
|
3298
|
+
result.x = this.x - Math.floor(this.x);
|
|
3299
|
+
result.y = this.y - Math.floor(this.y);
|
|
3300
|
+
result.z = this.z - Math.floor(this.z);
|
|
3301
|
+
result.w = this.w - Math.floor(this.w);
|
|
3302
|
+
return result;
|
|
3303
|
+
}
|
|
3059
3304
|
/**
|
|
3060
3305
|
* Gets a new Vector4 from current Vector4 fractional values
|
|
3061
3306
|
* @returns a new Vector4
|
|
@@ -3103,7 +3348,7 @@ export class Vector4 {
|
|
|
3103
3348
|
* @returns the new Vector4
|
|
3104
3349
|
*/
|
|
3105
3350
|
normalizeToNew() {
|
|
3106
|
-
const normalized = new this.constructor(
|
|
3351
|
+
const normalized = new this.constructor();
|
|
3107
3352
|
this.normalizeToRef(normalized);
|
|
3108
3353
|
return normalized;
|
|
3109
3354
|
}
|
|
@@ -3115,7 +3360,7 @@ export class Vector4 {
|
|
|
3115
3360
|
normalizeToRef(reference) {
|
|
3116
3361
|
const len = this.length();
|
|
3117
3362
|
if (len === 0 || len === 1.0) {
|
|
3118
|
-
return reference.
|
|
3363
|
+
return reference.copyFrom(this);
|
|
3119
3364
|
}
|
|
3120
3365
|
return this.scaleToRef(1.0 / len, reference);
|
|
3121
3366
|
}
|
|
@@ -3172,9 +3417,9 @@ export class Vector4 {
|
|
|
3172
3417
|
return this.copyFromFloats(x, y, z, w);
|
|
3173
3418
|
}
|
|
3174
3419
|
/**
|
|
3175
|
-
* Copies the given float to the current
|
|
3420
|
+
* Copies the given float to the current Vector4 coordinates
|
|
3176
3421
|
* @param v defines the x, y, z and w coordinates of the operand
|
|
3177
|
-
* @returns the current updated
|
|
3422
|
+
* @returns the current updated Vector4
|
|
3178
3423
|
*/
|
|
3179
3424
|
setAll(v) {
|
|
3180
3425
|
this.x = this.y = this.z = this.w = v;
|
|
@@ -3263,7 +3508,55 @@ export class Vector4 {
|
|
|
3263
3508
|
* @returns a Vector4 with random values between min and max
|
|
3264
3509
|
*/
|
|
3265
3510
|
static Random(min = 0, max = 1) {
|
|
3266
|
-
return new Vector4(
|
|
3511
|
+
return new Vector4(RandomRange(min, max), RandomRange(min, max), RandomRange(min, max), RandomRange(min, max));
|
|
3512
|
+
}
|
|
3513
|
+
/**
|
|
3514
|
+
* Sets a Vector4 with random values between min and max
|
|
3515
|
+
* @param min the minimum random value
|
|
3516
|
+
* @param max the maximum random value
|
|
3517
|
+
* @param ref the ref to store the values in
|
|
3518
|
+
* @returns the ref with random values between min and max
|
|
3519
|
+
*/
|
|
3520
|
+
static RandomToRef(min = 0, max = 1, ref) {
|
|
3521
|
+
return ref.copyFromFloats(RandomRange(min, max), RandomRange(min, max), RandomRange(min, max), RandomRange(min, max));
|
|
3522
|
+
}
|
|
3523
|
+
/**
|
|
3524
|
+
* Returns a new Vector4 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
|
|
3525
|
+
* If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
|
|
3526
|
+
* If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
|
|
3527
|
+
* @param value defines the current value
|
|
3528
|
+
* @param min defines the lower range value
|
|
3529
|
+
* @param max defines the upper range value
|
|
3530
|
+
* @returns the new Vector4
|
|
3531
|
+
*/
|
|
3532
|
+
static Clamp(value, min, max) {
|
|
3533
|
+
const result = new value.constructor();
|
|
3534
|
+
Vector4.ClampToRef(value, min, max, result);
|
|
3535
|
+
return result;
|
|
3536
|
+
}
|
|
3537
|
+
/**
|
|
3538
|
+
* Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
|
|
3539
|
+
* If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
|
|
3540
|
+
* If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
|
|
3541
|
+
* @param value defines the current value
|
|
3542
|
+
* @param min defines the lower range value
|
|
3543
|
+
* @param max defines the upper range value
|
|
3544
|
+
* @param result defines the Vector4 where to store the result
|
|
3545
|
+
* @returns result input
|
|
3546
|
+
*/
|
|
3547
|
+
static ClampToRef(value, min, max, result) {
|
|
3548
|
+
return result.copyFromFloats(Clamp(value.x, min.x, max.x), Clamp(value.y, min.y, max.y), Clamp(value.z, min.z, max.z), Clamp(value.w, min.w, max.w));
|
|
3549
|
+
}
|
|
3550
|
+
/**
|
|
3551
|
+
* Checks if a given vector is inside a specific range
|
|
3552
|
+
* Example Playground https://playground.babylonjs.com/#R1F8YU#75
|
|
3553
|
+
* @param v defines the vector to test
|
|
3554
|
+
* @param min defines the minimum range
|
|
3555
|
+
* @param max defines the maximum range
|
|
3556
|
+
*/
|
|
3557
|
+
static CheckExtends(v, min, max) {
|
|
3558
|
+
min.minimizeInPlace(v);
|
|
3559
|
+
max.maximizeInPlace(v);
|
|
3267
3560
|
}
|
|
3268
3561
|
/**
|
|
3269
3562
|
* Gets a zero Vector4 that must not be updated
|
|
@@ -3475,6 +3768,11 @@ export class Vector4 {
|
|
|
3475
3768
|
}
|
|
3476
3769
|
}
|
|
3477
3770
|
Vector4._ZeroReadOnly = Vector4.Zero();
|
|
3771
|
+
Vector4;
|
|
3772
|
+
Object.defineProperties(Vector4.prototype, {
|
|
3773
|
+
dimension: { value: [4] },
|
|
3774
|
+
rank: { value: 1 },
|
|
3775
|
+
});
|
|
3478
3776
|
/**
|
|
3479
3777
|
* Class used to store quaternion data
|
|
3480
3778
|
* Example Playground - Overview - https://playground.babylonjs.com/#L49EJ7#100
|
|
@@ -3580,6 +3878,9 @@ export class Quaternion {
|
|
|
3580
3878
|
array[index + 3] = this._w;
|
|
3581
3879
|
return this;
|
|
3582
3880
|
}
|
|
3881
|
+
fromArray(array, index = 0) {
|
|
3882
|
+
return Quaternion.FromArrayToRef(array, index, this);
|
|
3883
|
+
}
|
|
3583
3884
|
/**
|
|
3584
3885
|
* Check if two quaternions are equals
|
|
3585
3886
|
* Example Playground https://playground.babylonjs.com/#L49EJ7#38
|
|
@@ -3598,10 +3899,10 @@ export class Quaternion {
|
|
|
3598
3899
|
*/
|
|
3599
3900
|
equalsWithEpsilon(otherQuaternion, epsilon = Epsilon) {
|
|
3600
3901
|
return (otherQuaternion &&
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3902
|
+
WithinEpsilon(this._x, otherQuaternion._x, epsilon) &&
|
|
3903
|
+
WithinEpsilon(this._y, otherQuaternion._y, epsilon) &&
|
|
3904
|
+
WithinEpsilon(this._z, otherQuaternion._z, epsilon) &&
|
|
3905
|
+
WithinEpsilon(this._w, otherQuaternion._w, epsilon));
|
|
3605
3906
|
}
|
|
3606
3907
|
/**
|
|
3607
3908
|
* Clone the current quaternion
|
|
@@ -3654,6 +3955,9 @@ export class Quaternion {
|
|
|
3654
3955
|
set(x, y, z, w) {
|
|
3655
3956
|
return this.copyFromFloats(x, y, z, w);
|
|
3656
3957
|
}
|
|
3958
|
+
setAll(value) {
|
|
3959
|
+
return this.copyFromFloats(value, value, value, value);
|
|
3960
|
+
}
|
|
3657
3961
|
/**
|
|
3658
3962
|
* Adds two quaternions
|
|
3659
3963
|
* Example Playground https://playground.babylonjs.com/#L49EJ7#10
|
|
@@ -3677,6 +3981,41 @@ export class Quaternion {
|
|
|
3677
3981
|
this._isDirty = true;
|
|
3678
3982
|
return this;
|
|
3679
3983
|
}
|
|
3984
|
+
addToRef(other, result) {
|
|
3985
|
+
result._x = this._x + other._x;
|
|
3986
|
+
result._y = this._y + other._y;
|
|
3987
|
+
result._z = this._z + other._z;
|
|
3988
|
+
result._w = this._w + other._w;
|
|
3989
|
+
result._isDirty = true;
|
|
3990
|
+
return result;
|
|
3991
|
+
}
|
|
3992
|
+
addInPlaceFromFloats(x, y, z, w) {
|
|
3993
|
+
this._x += x;
|
|
3994
|
+
this._y += y;
|
|
3995
|
+
this._z += z;
|
|
3996
|
+
this._w += w;
|
|
3997
|
+
this._isDirty = true;
|
|
3998
|
+
return this;
|
|
3999
|
+
}
|
|
4000
|
+
subtractToRef(other, result) {
|
|
4001
|
+
result._x = this._x - other._x;
|
|
4002
|
+
result._y = this._y - other._y;
|
|
4003
|
+
result._z = this._z - other._z;
|
|
4004
|
+
result._w = this._w - other._w;
|
|
4005
|
+
result._isDirty = true;
|
|
4006
|
+
return result;
|
|
4007
|
+
}
|
|
4008
|
+
subtractFromFloats(x, y, z, w) {
|
|
4009
|
+
return this.subtractFromFloatsToRef(x, y, z, w, new this.constructor());
|
|
4010
|
+
}
|
|
4011
|
+
subtractFromFloatsToRef(x, y, z, w, result) {
|
|
4012
|
+
result._x = this._x - x;
|
|
4013
|
+
result._y = this._y - y;
|
|
4014
|
+
result._z = this._z - z;
|
|
4015
|
+
result._w = this._w - w;
|
|
4016
|
+
result._isDirty = true;
|
|
4017
|
+
return result;
|
|
4018
|
+
}
|
|
3680
4019
|
/**
|
|
3681
4020
|
* Subtract two quaternions
|
|
3682
4021
|
* Example Playground https://playground.babylonjs.com/#L49EJ7#57
|
|
@@ -3782,39 +4121,145 @@ export class Quaternion {
|
|
|
3782
4121
|
/**
|
|
3783
4122
|
* Updates the current quaternion with the multiplication of itself with the given one "q1"
|
|
3784
4123
|
* Example Playground https://playground.babylonjs.com/#L49EJ7#46
|
|
3785
|
-
* @param
|
|
4124
|
+
* @param other defines the second operand
|
|
3786
4125
|
* @returns the currentupdated quaternion
|
|
3787
4126
|
*/
|
|
3788
|
-
multiplyInPlace(
|
|
3789
|
-
this.multiplyToRef(
|
|
4127
|
+
multiplyInPlace(other) {
|
|
4128
|
+
return this.multiplyToRef(other, this);
|
|
4129
|
+
}
|
|
4130
|
+
multiplyByFloats(x, y, z, w) {
|
|
4131
|
+
this._x *= x;
|
|
4132
|
+
this._y *= y;
|
|
4133
|
+
this._z *= z;
|
|
4134
|
+
this._w *= w;
|
|
4135
|
+
this._isDirty = true;
|
|
3790
4136
|
return this;
|
|
3791
4137
|
}
|
|
3792
4138
|
/**
|
|
3793
|
-
*
|
|
3794
|
-
*
|
|
3795
|
-
* @param ref defines the target quaternion
|
|
3796
|
-
* @returns result input
|
|
4139
|
+
* @internal
|
|
4140
|
+
* Do not use
|
|
3797
4141
|
*/
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
return ref;
|
|
4142
|
+
divide(_other) {
|
|
4143
|
+
throw new ReferenceError("Can not divide a quaternion");
|
|
3801
4144
|
}
|
|
3802
4145
|
/**
|
|
3803
|
-
*
|
|
3804
|
-
*
|
|
3805
|
-
* @returns the current updated quaternion
|
|
4146
|
+
* @internal
|
|
4147
|
+
* Do not use
|
|
3806
4148
|
*/
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
this._y *= -1;
|
|
3810
|
-
this._z *= -1;
|
|
3811
|
-
this._isDirty = true;
|
|
3812
|
-
return this;
|
|
4149
|
+
divideToRef(_other, _result) {
|
|
4150
|
+
throw new ReferenceError("Can not divide a quaternion");
|
|
3813
4151
|
}
|
|
3814
4152
|
/**
|
|
3815
|
-
*
|
|
3816
|
-
*
|
|
3817
|
-
|
|
4153
|
+
* @internal
|
|
4154
|
+
* Do not use
|
|
4155
|
+
*/
|
|
4156
|
+
divideInPlace(_other) {
|
|
4157
|
+
throw new ReferenceError("Can not divide a quaternion");
|
|
4158
|
+
}
|
|
4159
|
+
/**
|
|
4160
|
+
* @internal
|
|
4161
|
+
* Do not use
|
|
4162
|
+
*/
|
|
4163
|
+
minimizeInPlace() {
|
|
4164
|
+
throw new ReferenceError("Can not minimize a quaternion");
|
|
4165
|
+
}
|
|
4166
|
+
/**
|
|
4167
|
+
* @internal
|
|
4168
|
+
* Do not use
|
|
4169
|
+
*/
|
|
4170
|
+
minimizeInPlaceFromFloats() {
|
|
4171
|
+
throw new ReferenceError("Can not minimize a quaternion");
|
|
4172
|
+
}
|
|
4173
|
+
/**
|
|
4174
|
+
* @internal
|
|
4175
|
+
* Do not use
|
|
4176
|
+
*/
|
|
4177
|
+
maximizeInPlace() {
|
|
4178
|
+
throw new ReferenceError("Can not maximize a quaternion");
|
|
4179
|
+
}
|
|
4180
|
+
/**
|
|
4181
|
+
* @internal
|
|
4182
|
+
* Do not use
|
|
4183
|
+
*/
|
|
4184
|
+
maximizeInPlaceFromFloats() {
|
|
4185
|
+
throw new ReferenceError("Can not maximize a quaternion");
|
|
4186
|
+
}
|
|
4187
|
+
negate() {
|
|
4188
|
+
return this.negateToRef(new this.constructor());
|
|
4189
|
+
}
|
|
4190
|
+
negateInPlace() {
|
|
4191
|
+
this._x = -this._x;
|
|
4192
|
+
this._y = -this._y;
|
|
4193
|
+
this._z = -this._z;
|
|
4194
|
+
this._w = -this._w;
|
|
4195
|
+
this._isDirty = true;
|
|
4196
|
+
return this;
|
|
4197
|
+
}
|
|
4198
|
+
negateToRef(result) {
|
|
4199
|
+
result._x = -this._x;
|
|
4200
|
+
result._y = -this._y;
|
|
4201
|
+
result._z = -this._z;
|
|
4202
|
+
result._w = -this._w;
|
|
4203
|
+
result._isDirty = true;
|
|
4204
|
+
return result;
|
|
4205
|
+
}
|
|
4206
|
+
equalsToFloats(x, y, z, w) {
|
|
4207
|
+
return this._x === x && this._y === y && this._z === z && this._w === w;
|
|
4208
|
+
}
|
|
4209
|
+
/**
|
|
4210
|
+
* @internal
|
|
4211
|
+
* Do not use
|
|
4212
|
+
*/
|
|
4213
|
+
floorToRef(_result) {
|
|
4214
|
+
throw new ReferenceError("Can not floor a quaternion");
|
|
4215
|
+
}
|
|
4216
|
+
/**
|
|
4217
|
+
* @internal
|
|
4218
|
+
* Do not use
|
|
4219
|
+
*/
|
|
4220
|
+
floor() {
|
|
4221
|
+
throw new ReferenceError("Can not floor a quaternion");
|
|
4222
|
+
}
|
|
4223
|
+
/**
|
|
4224
|
+
* @internal
|
|
4225
|
+
* Do not use
|
|
4226
|
+
*/
|
|
4227
|
+
fractToRef(_result) {
|
|
4228
|
+
throw new ReferenceError("Can not fract a quaternion");
|
|
4229
|
+
}
|
|
4230
|
+
/**
|
|
4231
|
+
* @internal
|
|
4232
|
+
* Do not use
|
|
4233
|
+
*/
|
|
4234
|
+
fract() {
|
|
4235
|
+
throw new ReferenceError("Can not fract a quaternion");
|
|
4236
|
+
}
|
|
4237
|
+
/**
|
|
4238
|
+
* Conjugates the current quaternion and stores the result in the given quaternion
|
|
4239
|
+
* Example Playground https://playground.babylonjs.com/#L49EJ7#81
|
|
4240
|
+
* @param ref defines the target quaternion
|
|
4241
|
+
* @returns result input
|
|
4242
|
+
*/
|
|
4243
|
+
conjugateToRef(ref) {
|
|
4244
|
+
ref.copyFromFloats(-this._x, -this._y, -this._z, this._w);
|
|
4245
|
+
return ref;
|
|
4246
|
+
}
|
|
4247
|
+
/**
|
|
4248
|
+
* Conjugates in place the current quaternion
|
|
4249
|
+
* Example Playground https://playground.babylonjs.com/#L49EJ7#82
|
|
4250
|
+
* @returns the current updated quaternion
|
|
4251
|
+
*/
|
|
4252
|
+
conjugateInPlace() {
|
|
4253
|
+
this._x *= -1;
|
|
4254
|
+
this._y *= -1;
|
|
4255
|
+
this._z *= -1;
|
|
4256
|
+
this._isDirty = true;
|
|
4257
|
+
return this;
|
|
4258
|
+
}
|
|
4259
|
+
/**
|
|
4260
|
+
* Conjugates (1-q) the current quaternion
|
|
4261
|
+
* Example Playground https://playground.babylonjs.com/#L49EJ7#83
|
|
4262
|
+
* @returns a new quaternion
|
|
3818
4263
|
*/
|
|
3819
4264
|
conjugate() {
|
|
3820
4265
|
return new this.constructor(-this._x, -this._y, -this._z, this._w);
|
|
@@ -4076,7 +4521,7 @@ export class Quaternion {
|
|
|
4076
4521
|
*/
|
|
4077
4522
|
static SmoothToRef(source, goal, deltaTime, lerpTime, result) {
|
|
4078
4523
|
let slerp = lerpTime === 0 ? 1 : deltaTime / lerpTime;
|
|
4079
|
-
slerp =
|
|
4524
|
+
slerp = Clamp(slerp, 0, 1);
|
|
4080
4525
|
Quaternion.SlerpToRef(source, goal, slerp, result);
|
|
4081
4526
|
return result;
|
|
4082
4527
|
}
|
|
@@ -4179,6 +4624,19 @@ export class Quaternion {
|
|
|
4179
4624
|
result._isDirty = true;
|
|
4180
4625
|
return result;
|
|
4181
4626
|
}
|
|
4627
|
+
/**
|
|
4628
|
+
* Sets the given quaternion "result" with the given floats.
|
|
4629
|
+
* @param x defines the x coordinate of the source
|
|
4630
|
+
* @param y defines the y coordinate of the source
|
|
4631
|
+
* @param z defines the z coordinate of the source
|
|
4632
|
+
* @param w defines the w coordinate of the source
|
|
4633
|
+
* @param result defines the quaternion where to store the result
|
|
4634
|
+
* @returns the result quaternion
|
|
4635
|
+
*/
|
|
4636
|
+
static FromFloatsToRef(x, y, z, w, result) {
|
|
4637
|
+
result.copyFromFloats(x, y, z, w);
|
|
4638
|
+
return result;
|
|
4639
|
+
}
|
|
4182
4640
|
/**
|
|
4183
4641
|
* Create a quaternion from Euler rotation angles
|
|
4184
4642
|
* Example Playground https://playground.babylonjs.com/#L49EJ7#33
|
|
@@ -4536,7 +4994,113 @@ export class Quaternion {
|
|
|
4536
4994
|
quat.normalizeToRef(result);
|
|
4537
4995
|
return result;
|
|
4538
4996
|
}
|
|
4997
|
+
/**
|
|
4998
|
+
* Returns a new Quaternion set with the coordinates of "value", if the quaternion "value" is in the cube defined by the quaternions "min" and "max"
|
|
4999
|
+
* If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
|
|
5000
|
+
* If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
|
|
5001
|
+
* @param value defines the current value
|
|
5002
|
+
* @param min defines the lower range value
|
|
5003
|
+
* @param max defines the upper range value
|
|
5004
|
+
* @returns the new Quaternion
|
|
5005
|
+
*/
|
|
5006
|
+
static Clamp(value, min, max) {
|
|
5007
|
+
const result = new value.constructor();
|
|
5008
|
+
Quaternion.ClampToRef(value, min, max, result);
|
|
5009
|
+
return result;
|
|
5010
|
+
}
|
|
5011
|
+
/**
|
|
5012
|
+
* Sets the given quaternion "result" with the coordinates of "value", if the quaternion "value" is in the cube defined by the quaternions "min" and "max"
|
|
5013
|
+
* If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
|
|
5014
|
+
* If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
|
|
5015
|
+
* @param value defines the current value
|
|
5016
|
+
* @param min defines the lower range value
|
|
5017
|
+
* @param max defines the upper range value
|
|
5018
|
+
* @param result defines the Quaternion where to store the result
|
|
5019
|
+
* @returns result input
|
|
5020
|
+
*/
|
|
5021
|
+
static ClampToRef(value, min, max, result) {
|
|
5022
|
+
return result.copyFromFloats(Clamp(value.x, min.x, max.x), Clamp(value.y, min.y, max.y), Clamp(value.z, min.z, max.z), Clamp(value.w, min.w, max.w));
|
|
5023
|
+
}
|
|
5024
|
+
/**
|
|
5025
|
+
* Returns a new Quaternion with random values between min and max
|
|
5026
|
+
* @param min the minimum random value
|
|
5027
|
+
* @param max the maximum random value
|
|
5028
|
+
* @returns a Quaternion with random values between min and max
|
|
5029
|
+
*/
|
|
5030
|
+
static Random(min = 0, max = 1) {
|
|
5031
|
+
return new Quaternion(RandomRange(min, max), RandomRange(min, max), RandomRange(min, max), RandomRange(min, max));
|
|
5032
|
+
}
|
|
5033
|
+
/**
|
|
5034
|
+
* Sets a Quaternion with random values between min and max
|
|
5035
|
+
* @param min the minimum random value
|
|
5036
|
+
* @param max the maximum random value
|
|
5037
|
+
* @param ref the ref to store the values in
|
|
5038
|
+
* @returns the ref with random values between min and max
|
|
5039
|
+
*/
|
|
5040
|
+
static RandomToRef(min = 0, max = 1, ref) {
|
|
5041
|
+
return ref.copyFromFloats(RandomRange(min, max), RandomRange(min, max), RandomRange(min, max), RandomRange(min, max));
|
|
5042
|
+
}
|
|
5043
|
+
/**
|
|
5044
|
+
* Do not use
|
|
5045
|
+
* @internal
|
|
5046
|
+
*/
|
|
5047
|
+
static Minimize() {
|
|
5048
|
+
throw new ReferenceError("Quaternion.Minimize does not make sense");
|
|
5049
|
+
}
|
|
5050
|
+
/**
|
|
5051
|
+
* Do not use
|
|
5052
|
+
* @internal
|
|
5053
|
+
*/
|
|
5054
|
+
static Maximize() {
|
|
5055
|
+
throw new ReferenceError("Quaternion.Maximize does not make sense");
|
|
5056
|
+
}
|
|
5057
|
+
/**
|
|
5058
|
+
* Returns the distance (float) between the quaternions "value1" and "value2".
|
|
5059
|
+
* @param value1 value to calulate the distance between
|
|
5060
|
+
* @param value2 value to calulate the distance between
|
|
5061
|
+
* @returns the distance between the two quaternions
|
|
5062
|
+
*/
|
|
5063
|
+
static Distance(value1, value2) {
|
|
5064
|
+
return Math.sqrt(Quaternion.DistanceSquared(value1, value2));
|
|
5065
|
+
}
|
|
5066
|
+
/**
|
|
5067
|
+
* Returns the squared distance (float) between the quaternions "value1" and "value2".
|
|
5068
|
+
* @param value1 value to calulate the distance between
|
|
5069
|
+
* @param value2 value to calulate the distance between
|
|
5070
|
+
* @returns the distance between the two quaternions squared
|
|
5071
|
+
*/
|
|
5072
|
+
static DistanceSquared(value1, value2) {
|
|
5073
|
+
const x = value1.x - value2.x;
|
|
5074
|
+
const y = value1.y - value2.y;
|
|
5075
|
+
const z = value1.z - value2.z;
|
|
5076
|
+
const w = value1.w - value2.w;
|
|
5077
|
+
return x * x + y * y + z * z + w * w;
|
|
5078
|
+
}
|
|
5079
|
+
/**
|
|
5080
|
+
* Returns a new Quaternion located at the center between the quaternions "value1" and "value2".
|
|
5081
|
+
* @param value1 value to calulate the center between
|
|
5082
|
+
* @param value2 value to calulate the center between
|
|
5083
|
+
* @returns the center between the two quaternions
|
|
5084
|
+
*/
|
|
5085
|
+
static Center(value1, value2) {
|
|
5086
|
+
return Quaternion.CenterToRef(value1, value2, Quaternion.Zero());
|
|
5087
|
+
}
|
|
5088
|
+
/**
|
|
5089
|
+
* Gets the center of the quaternions "value1" and "value2" and stores the result in the quaternion "ref"
|
|
5090
|
+
* @param value1 defines first quaternion
|
|
5091
|
+
* @param value2 defines second quaternion
|
|
5092
|
+
* @param ref defines third quaternion
|
|
5093
|
+
* @returns ref
|
|
5094
|
+
*/
|
|
5095
|
+
static CenterToRef(value1, value2, ref) {
|
|
5096
|
+
return ref.copyFromFloats((value1.x + value2.x) / 2, (value1.y + value2.y) / 2, (value1.z + value2.z) / 2, (value1.w + value2.w) / 2);
|
|
5097
|
+
}
|
|
4539
5098
|
}
|
|
5099
|
+
Quaternion;
|
|
5100
|
+
Object.defineProperties(Quaternion.prototype, {
|
|
5101
|
+
dimension: { value: [4] },
|
|
5102
|
+
rank: { value: 1 },
|
|
5103
|
+
});
|
|
4540
5104
|
/**
|
|
4541
5105
|
* Class used to store matrix data (4x4)
|
|
4542
5106
|
* Note on matrix definitions in Babylon.js for setting values directly
|
|
@@ -4711,13 +5275,15 @@ export class Matrix {
|
|
|
4711
5275
|
toString() {
|
|
4712
5276
|
return `{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]}\n${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]}\n${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]}\n${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`;
|
|
4713
5277
|
}
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
5278
|
+
toArray(array = null, index = 0) {
|
|
5279
|
+
if (!array) {
|
|
5280
|
+
return this._m;
|
|
5281
|
+
}
|
|
5282
|
+
const m = this._m;
|
|
5283
|
+
for (let i = 0; i < 16; i++) {
|
|
5284
|
+
array[index + i] = m[i];
|
|
5285
|
+
}
|
|
5286
|
+
return this;
|
|
4721
5287
|
}
|
|
4722
5288
|
/**
|
|
4723
5289
|
* Returns the matrix as a Float32Array or Array<number>
|
|
@@ -4727,6 +5293,28 @@ export class Matrix {
|
|
|
4727
5293
|
asArray() {
|
|
4728
5294
|
return this._m;
|
|
4729
5295
|
}
|
|
5296
|
+
fromArray(array, index = 0) {
|
|
5297
|
+
return Matrix.FromArrayToRef(array, index, this);
|
|
5298
|
+
}
|
|
5299
|
+
copyFromFloats(...floats) {
|
|
5300
|
+
return Matrix.FromArrayToRef(floats, 0, this);
|
|
5301
|
+
}
|
|
5302
|
+
set(...values) {
|
|
5303
|
+
const m = this._m;
|
|
5304
|
+
for (let i = 0; i < 16; i++) {
|
|
5305
|
+
m[i] = values[i];
|
|
5306
|
+
}
|
|
5307
|
+
this.markAsUpdated();
|
|
5308
|
+
return this;
|
|
5309
|
+
}
|
|
5310
|
+
setAll(value) {
|
|
5311
|
+
const m = this._m;
|
|
5312
|
+
for (let i = 0; i < 16; i++) {
|
|
5313
|
+
m[i] = value;
|
|
5314
|
+
}
|
|
5315
|
+
this.markAsUpdated();
|
|
5316
|
+
return this;
|
|
5317
|
+
}
|
|
4730
5318
|
/**
|
|
4731
5319
|
* Inverts the current matrix in place
|
|
4732
5320
|
* Example Playground - https://playground.babylonjs.com/#AV9X17#118
|
|
@@ -4788,6 +5376,57 @@ export class Matrix {
|
|
|
4788
5376
|
this.markAsUpdated();
|
|
4789
5377
|
return this;
|
|
4790
5378
|
}
|
|
5379
|
+
addInPlace(other) {
|
|
5380
|
+
const m = this._m, otherM = other.m;
|
|
5381
|
+
for (let i = 0; i < 16; i++) {
|
|
5382
|
+
m[i] += otherM[i];
|
|
5383
|
+
}
|
|
5384
|
+
this.markAsUpdated();
|
|
5385
|
+
return this;
|
|
5386
|
+
}
|
|
5387
|
+
addInPlaceFromFloats(...floats) {
|
|
5388
|
+
const m = this._m;
|
|
5389
|
+
for (let i = 0; i < 16; i++) {
|
|
5390
|
+
m[i] += floats[i];
|
|
5391
|
+
}
|
|
5392
|
+
this.markAsUpdated();
|
|
5393
|
+
return this;
|
|
5394
|
+
}
|
|
5395
|
+
subtract(other) {
|
|
5396
|
+
const m = this._m, otherM = other.m;
|
|
5397
|
+
for (let i = 0; i < 16; i++) {
|
|
5398
|
+
m[i] -= otherM[i];
|
|
5399
|
+
}
|
|
5400
|
+
this.markAsUpdated();
|
|
5401
|
+
return this;
|
|
5402
|
+
}
|
|
5403
|
+
subtractToRef(other, result) {
|
|
5404
|
+
const m = this._m, otherM = other.m, resultM = result._m;
|
|
5405
|
+
for (let i = 0; i < 16; i++) {
|
|
5406
|
+
resultM[i] = m[i] - otherM[i];
|
|
5407
|
+
}
|
|
5408
|
+
result.markAsUpdated();
|
|
5409
|
+
return result;
|
|
5410
|
+
}
|
|
5411
|
+
subtractInPlace(other) {
|
|
5412
|
+
const m = this._m, otherM = other.m;
|
|
5413
|
+
for (let i = 0; i < 16; i++) {
|
|
5414
|
+
m[i] -= otherM[i];
|
|
5415
|
+
}
|
|
5416
|
+
this.markAsUpdated();
|
|
5417
|
+
return this;
|
|
5418
|
+
}
|
|
5419
|
+
subtractFromFloats(...floats) {
|
|
5420
|
+
return this.subtractFromFloatsToRef(...floats, new this.constructor());
|
|
5421
|
+
}
|
|
5422
|
+
subtractFromFloatsToRef(...args) {
|
|
5423
|
+
const result = args.pop(), m = this._m, resultM = result._m, values = args;
|
|
5424
|
+
for (let i = 0; i < 16; i++) {
|
|
5425
|
+
resultM[i] = m[i] - values[i];
|
|
5426
|
+
}
|
|
5427
|
+
result.markAsUpdated();
|
|
5428
|
+
return result;
|
|
5429
|
+
}
|
|
4791
5430
|
/**
|
|
4792
5431
|
* Sets the given matrix to the current inverted Matrix
|
|
4793
5432
|
* Example Playground - https://playground.babylonjs.com/#AV9X17#119
|
|
@@ -4942,18 +5581,6 @@ export class Matrix {
|
|
|
4942
5581
|
this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
|
|
4943
5582
|
return this;
|
|
4944
5583
|
}
|
|
4945
|
-
/**
|
|
4946
|
-
* Multiply two matrices
|
|
4947
|
-
* Example Playground - https://playground.babylonjs.com/#AV9X17#15
|
|
4948
|
-
* A.multiply(B) means apply B to A so result is B x A
|
|
4949
|
-
* @param other defines the second operand
|
|
4950
|
-
* @returns a new matrix set with the multiplication result of the current Matrix and the given one
|
|
4951
|
-
*/
|
|
4952
|
-
multiply(other) {
|
|
4953
|
-
const result = new this.constructor();
|
|
4954
|
-
this.multiplyToRef(other, result);
|
|
4955
|
-
return result;
|
|
4956
|
-
}
|
|
4957
5584
|
/**
|
|
4958
5585
|
* Copy the current matrix from the given one
|
|
4959
5586
|
* Example Playground - https://playground.babylonjs.com/#AV9X17#21
|
|
@@ -4993,6 +5620,47 @@ export class Matrix {
|
|
|
4993
5620
|
array[offset + 15] = source[15];
|
|
4994
5621
|
return this;
|
|
4995
5622
|
}
|
|
5623
|
+
/**
|
|
5624
|
+
* Multiply two matrices
|
|
5625
|
+
* Example Playground - https://playground.babylonjs.com/#AV9X17#15
|
|
5626
|
+
* A.multiply(B) means apply B to A so result is B x A
|
|
5627
|
+
* @param other defines the second operand
|
|
5628
|
+
* @returns a new matrix set with the multiplication result of the current Matrix and the given one
|
|
5629
|
+
*/
|
|
5630
|
+
multiply(other) {
|
|
5631
|
+
const result = new this.constructor();
|
|
5632
|
+
this.multiplyToRef(other, result);
|
|
5633
|
+
return result;
|
|
5634
|
+
}
|
|
5635
|
+
multiplyInPlace(other) {
|
|
5636
|
+
const m = this._m, otherM = other.m;
|
|
5637
|
+
for (let i = 0; i < 16; i++) {
|
|
5638
|
+
m[i] *= otherM[i];
|
|
5639
|
+
}
|
|
5640
|
+
this.markAsUpdated();
|
|
5641
|
+
return this;
|
|
5642
|
+
}
|
|
5643
|
+
multiplyByFloats(...floats) {
|
|
5644
|
+
const m = this._m;
|
|
5645
|
+
for (let i = 0; i < 16; i++) {
|
|
5646
|
+
m[i] = floats[i];
|
|
5647
|
+
}
|
|
5648
|
+
this.markAsUpdated();
|
|
5649
|
+
return this;
|
|
5650
|
+
}
|
|
5651
|
+
/**
|
|
5652
|
+
* Multiples the current matrix by the given floats and stores them in the given ref
|
|
5653
|
+
* @param args The floats and ref
|
|
5654
|
+
* @returns The updated ref
|
|
5655
|
+
*/
|
|
5656
|
+
multiplyByFloatsToRef(...args) {
|
|
5657
|
+
const result = args.pop(), m = this._m, resultM = result._m, values = args;
|
|
5658
|
+
for (let i = 0; i < 16; i++) {
|
|
5659
|
+
resultM[i] = m[i] * values[i];
|
|
5660
|
+
}
|
|
5661
|
+
result.markAsUpdated();
|
|
5662
|
+
return result;
|
|
5663
|
+
}
|
|
4996
5664
|
/**
|
|
4997
5665
|
* Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
|
|
4998
5666
|
* A.multiplyToRef(B, R) means apply B to A and store in R and R = B x A
|
|
@@ -5050,6 +5718,76 @@ export class Matrix {
|
|
|
5050
5718
|
result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
|
|
5051
5719
|
return this;
|
|
5052
5720
|
}
|
|
5721
|
+
divide(other) {
|
|
5722
|
+
return this.divideToRef(other, new this.constructor());
|
|
5723
|
+
}
|
|
5724
|
+
divideToRef(other, result) {
|
|
5725
|
+
const m = this._m, otherM = other.m, resultM = result._m;
|
|
5726
|
+
for (let i = 0; i < 16; i++) {
|
|
5727
|
+
resultM[i] = m[i] / otherM[i];
|
|
5728
|
+
}
|
|
5729
|
+
result.markAsUpdated();
|
|
5730
|
+
return result;
|
|
5731
|
+
}
|
|
5732
|
+
divideInPlace(other) {
|
|
5733
|
+
const m = this._m, otherM = other.m;
|
|
5734
|
+
for (let i = 0; i < 16; i++) {
|
|
5735
|
+
m[i] /= otherM[i];
|
|
5736
|
+
}
|
|
5737
|
+
this.markAsUpdated();
|
|
5738
|
+
return this;
|
|
5739
|
+
}
|
|
5740
|
+
minimizeInPlace(other) {
|
|
5741
|
+
const m = this._m, otherM = other.m;
|
|
5742
|
+
for (let i = 0; i < 16; i++) {
|
|
5743
|
+
m[i] = Math.min(m[i], otherM[i]);
|
|
5744
|
+
}
|
|
5745
|
+
this.markAsUpdated();
|
|
5746
|
+
return this;
|
|
5747
|
+
}
|
|
5748
|
+
minimizeInPlaceFromFloats(...floats) {
|
|
5749
|
+
const m = this._m;
|
|
5750
|
+
for (let i = 0; i < 16; i++) {
|
|
5751
|
+
m[i] = Math.min(m[i], floats[i]);
|
|
5752
|
+
}
|
|
5753
|
+
this.markAsUpdated();
|
|
5754
|
+
return this;
|
|
5755
|
+
}
|
|
5756
|
+
maximizeInPlace(other) {
|
|
5757
|
+
const m = this._m, otherM = other.m;
|
|
5758
|
+
for (let i = 0; i < 16; i++) {
|
|
5759
|
+
m[i] = Math.min(m[i], otherM[i]);
|
|
5760
|
+
}
|
|
5761
|
+
this.markAsUpdated();
|
|
5762
|
+
return this;
|
|
5763
|
+
}
|
|
5764
|
+
maximizeInPlaceFromFloats(...floats) {
|
|
5765
|
+
const m = this._m;
|
|
5766
|
+
for (let i = 0; i < 16; i++) {
|
|
5767
|
+
m[i] = Math.min(m[i], floats[i]);
|
|
5768
|
+
}
|
|
5769
|
+
this.markAsUpdated();
|
|
5770
|
+
return this;
|
|
5771
|
+
}
|
|
5772
|
+
negate() {
|
|
5773
|
+
return this.negateToRef(new this.constructor());
|
|
5774
|
+
}
|
|
5775
|
+
negateInPlace() {
|
|
5776
|
+
const m = this._m;
|
|
5777
|
+
for (let i = 0; i < 16; i++) {
|
|
5778
|
+
m[i] = -m[i];
|
|
5779
|
+
}
|
|
5780
|
+
this.markAsUpdated();
|
|
5781
|
+
return this;
|
|
5782
|
+
}
|
|
5783
|
+
negateToRef(result) {
|
|
5784
|
+
const m = this._m, resultM = result._m;
|
|
5785
|
+
for (let i = 0; i < 16; i++) {
|
|
5786
|
+
resultM[i] = -m[i];
|
|
5787
|
+
}
|
|
5788
|
+
result.markAsUpdated();
|
|
5789
|
+
return result;
|
|
5790
|
+
}
|
|
5053
5791
|
/**
|
|
5054
5792
|
* Check equality between this matrix and a second one
|
|
5055
5793
|
* @param value defines the second matrix to compare
|
|
@@ -5084,6 +5822,46 @@ export class Matrix {
|
|
|
5084
5822
|
m[14] === om[14] &&
|
|
5085
5823
|
m[15] === om[15]);
|
|
5086
5824
|
}
|
|
5825
|
+
equalsWithEpsilon(other, epsilon = 0) {
|
|
5826
|
+
const m = this._m, otherM = other.m;
|
|
5827
|
+
for (let i = 0; i < 16; i++) {
|
|
5828
|
+
if (!WithinEpsilon(m[i], otherM[i], epsilon)) {
|
|
5829
|
+
return false;
|
|
5830
|
+
}
|
|
5831
|
+
}
|
|
5832
|
+
return true;
|
|
5833
|
+
}
|
|
5834
|
+
equalsToFloats(...floats) {
|
|
5835
|
+
const m = this._m;
|
|
5836
|
+
for (let i = 0; i < 16; i++) {
|
|
5837
|
+
if (m[i] != floats[i]) {
|
|
5838
|
+
return false;
|
|
5839
|
+
}
|
|
5840
|
+
}
|
|
5841
|
+
return true;
|
|
5842
|
+
}
|
|
5843
|
+
floor() {
|
|
5844
|
+
return this.floorToRef(new this.constructor());
|
|
5845
|
+
}
|
|
5846
|
+
floorToRef(result) {
|
|
5847
|
+
const m = this._m, resultM = result._m;
|
|
5848
|
+
for (let i = 0; i < 16; i++) {
|
|
5849
|
+
resultM[i] = Math.floor(m[i]);
|
|
5850
|
+
}
|
|
5851
|
+
result.markAsUpdated();
|
|
5852
|
+
return result;
|
|
5853
|
+
}
|
|
5854
|
+
fract() {
|
|
5855
|
+
return this.fractToRef(new this.constructor());
|
|
5856
|
+
}
|
|
5857
|
+
fractToRef(result) {
|
|
5858
|
+
const m = this._m, resultM = result._m;
|
|
5859
|
+
for (let i = 0; i < 16; i++) {
|
|
5860
|
+
resultM[i] = m[i] - Math.floor(m[i]);
|
|
5861
|
+
}
|
|
5862
|
+
result.markAsUpdated();
|
|
5863
|
+
return result;
|
|
5864
|
+
}
|
|
5087
5865
|
/**
|
|
5088
5866
|
* Clone the current matrix
|
|
5089
5867
|
* Example Playground - https://playground.babylonjs.com/#AV9X17#18
|
|
@@ -5297,6 +6075,14 @@ export class Matrix {
|
|
|
5297
6075
|
result.markAsUpdated();
|
|
5298
6076
|
return result;
|
|
5299
6077
|
}
|
|
6078
|
+
scaleInPlace(scale) {
|
|
6079
|
+
const m = this._m;
|
|
6080
|
+
for (let i = 0; i < 16; i++) {
|
|
6081
|
+
m[i] *= scale;
|
|
6082
|
+
}
|
|
6083
|
+
this.markAsUpdated();
|
|
6084
|
+
return this;
|
|
6085
|
+
}
|
|
5300
6086
|
/**
|
|
5301
6087
|
* Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
|
|
5302
6088
|
* Example Playground - https://playground.babylonjs.com/#AV9X17#17
|
|
@@ -6611,25 +7397,37 @@ export class Matrix {
|
|
|
6611
7397
|
}
|
|
6612
7398
|
Matrix._UpdateFlagSeed = 0;
|
|
6613
7399
|
Matrix._IdentityReadOnly = Matrix.Identity();
|
|
7400
|
+
Object.defineProperties(Matrix.prototype, {
|
|
7401
|
+
dimension: { value: [4, 4] },
|
|
7402
|
+
rank: { value: 2 },
|
|
7403
|
+
});
|
|
6614
7404
|
/**
|
|
6615
7405
|
* @internal
|
|
6616
7406
|
* Same as Tmp but not exported to keep it only for math functions to avoid conflicts
|
|
6617
7407
|
*/
|
|
6618
7408
|
class MathTmp {
|
|
6619
7409
|
}
|
|
7410
|
+
// Temporary Vector3s
|
|
6620
7411
|
MathTmp.Vector3 = ArrayTools.BuildTuple(11, Vector3.Zero);
|
|
7412
|
+
// Temporary Matricies
|
|
6621
7413
|
MathTmp.Matrix = ArrayTools.BuildTuple(2, Matrix.Identity);
|
|
7414
|
+
// Temporary Quaternions
|
|
6622
7415
|
MathTmp.Quaternion = ArrayTools.BuildTuple(3, Quaternion.Zero);
|
|
6623
7416
|
/**
|
|
6624
7417
|
* @internal
|
|
6625
7418
|
*/
|
|
6626
7419
|
export class TmpVectors {
|
|
6627
7420
|
}
|
|
6628
|
-
|
|
6629
|
-
TmpVectors.
|
|
6630
|
-
|
|
6631
|
-
TmpVectors.
|
|
6632
|
-
|
|
7421
|
+
/** 3 temp Vector2 at once should be enough */
|
|
7422
|
+
TmpVectors.Vector2 = ArrayTools.BuildTuple(3, Vector2.Zero);
|
|
7423
|
+
/** 13 temp Vector3 at once should be enough */
|
|
7424
|
+
TmpVectors.Vector3 = ArrayTools.BuildTuple(13, Vector3.Zero);
|
|
7425
|
+
/** 3 temp Vector4 at once should be enough */
|
|
7426
|
+
TmpVectors.Vector4 = ArrayTools.BuildTuple(3, Vector4.Zero);
|
|
7427
|
+
/** 2 temp Quaternion at once should be enough */
|
|
7428
|
+
TmpVectors.Quaternion = ArrayTools.BuildTuple(2, Quaternion.Zero);
|
|
7429
|
+
/** 8 temp Matrices at once should be enough */
|
|
7430
|
+
TmpVectors.Matrix = ArrayTools.BuildTuple(8, Matrix.Identity);
|
|
6633
7431
|
RegisterClass("BABYLON.Vector2", Vector2);
|
|
6634
7432
|
RegisterClass("BABYLON.Vector3", Vector3);
|
|
6635
7433
|
RegisterClass("BABYLON.Vector4", Vector4);
|