rhodonite 0.19.9 → 0.20.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/README.md +32 -2
- package/VERSION-FILE +1 -1
- package/dist/esm/effekseer/main.d.ts +3 -1
- package/dist/esm/foundation/components/Animation/AnimationComponent.d.ts +15 -1
- package/dist/esm/foundation/components/Animation/AnimationStateRepository.d.ts +26 -10
- package/dist/esm/foundation/components/AnimationState/AnimationStateComponent.d.ts +14 -0
- package/dist/esm/foundation/components/CharacterController/CharacterAnimationController.d.ts +63 -0
- package/dist/esm/foundation/components/CharacterController/CharacterControllerComponent.d.ts +67 -0
- package/dist/esm/foundation/components/CharacterController/ICharacterControllerEntity.d.ts +4 -0
- package/dist/esm/foundation/components/CharacterController/createCharacterControllerEntity.d.ts +4 -0
- package/dist/esm/foundation/components/CharacterController/index.d.ts +4 -0
- package/dist/esm/foundation/components/ComponentTypes.d.ts +6 -0
- package/dist/esm/foundation/components/Physics/PhysicsComponent.d.ts +27 -0
- package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.d.ts +30 -0
- package/dist/esm/foundation/components/Shape/IShapeEntity.d.ts +4 -0
- package/dist/esm/foundation/components/Shape/ShapeComponent.d.ts +43 -0
- package/dist/esm/foundation/components/Shape/createShapeEntity.d.ts +3 -0
- package/dist/esm/foundation/components/Shape/index.d.ts +3 -0
- package/dist/esm/foundation/components/Skeletal/SkeletalComponent.d.ts +138 -45
- package/dist/esm/foundation/components/Transform/TransformComponent.d.ts +2 -3
- package/dist/esm/foundation/components/Trigger/ITriggerEntity.d.ts +4 -0
- package/dist/esm/foundation/components/Trigger/TriggerComponent.d.ts +58 -0
- package/dist/esm/foundation/components/Trigger/index.d.ts +2 -0
- package/dist/esm/foundation/components/Vrm/VrmComponent.d.ts +16 -1
- package/dist/esm/foundation/components/WellKnownComponentTIDs.d.ts +4 -1
- package/dist/esm/foundation/components/index.d.ts +3 -0
- package/dist/esm/foundation/core/Component.d.ts +63 -3
- package/dist/esm/foundation/core/ComponentMemoryRegistry.d.ts +59 -1
- package/dist/esm/foundation/core/Config.d.ts +8 -7
- package/dist/esm/foundation/core/Entity.d.ts +15 -0
- package/dist/esm/foundation/definitions/BoneDataType.d.ts +12 -1
- package/dist/esm/foundation/definitions/PhysicsShapeType.d.ts +1 -0
- package/dist/esm/foundation/definitions/ProcessApproach.d.ts +8 -4
- package/dist/esm/foundation/exporter/Gltf2ExporterOps.d.ts +2 -0
- package/dist/esm/foundation/geometry/Shape.d.ts +35 -0
- package/dist/esm/foundation/geometry/index.d.ts +1 -0
- package/dist/esm/foundation/geometry/shapes/Cylinder.d.ts +16 -0
- package/dist/esm/foundation/geometry/shapes/index.d.ts +1 -0
- package/dist/esm/foundation/gizmos/ShapeGizmo.d.ts +22 -0
- package/dist/esm/foundation/gizmos/index.d.ts +1 -0
- package/dist/esm/foundation/helpers/EntityHelper.d.ts +6 -0
- package/dist/esm/foundation/helpers/MeshHelper.d.ts +275 -15
- package/dist/esm/foundation/importer/AnimationAssigner.d.ts +62 -3
- package/dist/esm/foundation/importer/BoneDataTypeDetector.d.ts +31 -0
- package/dist/esm/foundation/importer/Gltf2Importer.d.ts +6 -0
- package/dist/esm/foundation/importer/KhrPhysicsImporter.d.ts +58 -0
- package/dist/esm/foundation/importer/VrmaImporter.d.ts +11 -3
- package/dist/esm/foundation/importer/index.d.ts +2 -0
- package/dist/esm/foundation/math/AbstractMatrix.d.ts +3 -2
- package/dist/esm/foundation/math/AbstractQuaternion.d.ts +2 -1
- package/dist/esm/foundation/math/AnimatedQuaternion.d.ts +4 -0
- package/dist/esm/foundation/math/AnimatedScalar.d.ts +4 -0
- package/dist/esm/foundation/math/AnimatedVector2.d.ts +4 -0
- package/dist/esm/foundation/math/AnimatedVector3.d.ts +4 -0
- package/dist/esm/foundation/math/AnimatedVector4.d.ts +4 -0
- package/dist/esm/foundation/math/AnimatedVectorN.d.ts +4 -0
- package/dist/esm/foundation/math/IAnimatedValue.d.ts +12 -0
- package/dist/esm/foundation/math/IMatrix.d.ts +2 -2
- package/dist/esm/foundation/math/IQuaternion.d.ts +4 -4
- package/dist/esm/foundation/math/LogQuaternion.d.ts +110 -38
- package/dist/esm/foundation/math/MathUtil.d.ts +63 -1
- package/dist/esm/foundation/math/Matrix22.d.ts +176 -30
- package/dist/esm/foundation/math/Matrix33.d.ts +206 -38
- package/dist/esm/foundation/math/Matrix44.d.ts +222 -39
- package/dist/esm/foundation/math/MutableMatrix22.d.ts +125 -130
- package/dist/esm/foundation/math/MutableMatrix33.d.ts +148 -162
- package/dist/esm/foundation/math/MutableMatrix44.d.ts +159 -183
- package/dist/esm/foundation/math/MutableQuaternion.d.ts +241 -132
- package/dist/esm/foundation/math/MutableScalar.d.ts +11 -12
- package/dist/esm/foundation/math/MutableVector2.d.ts +30 -31
- package/dist/esm/foundation/math/MutableVector3.d.ts +28 -26
- package/dist/esm/foundation/math/MutableVector4.d.ts +37 -37
- package/dist/esm/foundation/math/Quaternion.d.ts +529 -36
- package/dist/esm/foundation/math/Scalar.d.ts +13 -14
- package/dist/esm/foundation/math/Vector2.d.ts +38 -38
- package/dist/esm/foundation/math/Vector3.d.ts +55 -54
- package/dist/esm/foundation/math/Vector4.d.ts +54 -55
- package/dist/esm/foundation/misc/MiscUtil.d.ts +79 -16
- package/dist/esm/foundation/misc/Time.d.ts +10 -1
- package/dist/esm/foundation/physics/CharacterControllerStrategy.d.ts +65 -0
- package/dist/esm/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +17 -1
- package/dist/esm/foundation/physics/PhysicsProperty.d.ts +43 -0
- package/dist/esm/foundation/physics/PhysicsStrategy.d.ts +15 -0
- package/dist/esm/foundation/physics/PhysicsWorldQuery.d.ts +65 -0
- package/dist/esm/foundation/physics/Rapier/RapierCharacterControllerStrategy.d.ts +58 -0
- package/dist/esm/foundation/physics/Rapier/RapierPhysicsStrategy.d.ts +157 -19
- package/dist/esm/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.d.ts +11 -0
- package/dist/esm/foundation/physics/Rapier/index.d.ts +2 -0
- package/dist/esm/foundation/physics/ShapeTransformResolver.d.ts +19 -0
- package/dist/esm/foundation/physics/index.d.ts +2 -0
- package/dist/esm/index.js +728 -723
- package/dist/esm/types/AnimationTypes.d.ts +1 -1
- package/dist/esm/types/KHR_implicit_shapes.d.ts +47 -0
- package/dist/esm/types/KHR_physics_rigid_bodies.d.ts +54 -0
- package/dist/esm/types/VRMC.d.ts +12 -12
- package/dist/esm/types/VRMC_vrm_animation.d.ts +5 -0
- package/dist/esm/types/glTF2.d.ts +8 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/webgl/main.d.ts +2 -1
- package/dist/esm/webgl/textureLoader/KTX2TextureLoader.d.ts +12 -0
- package/dist/esmdev/effekseer/main.d.ts +3 -1
- package/dist/esmdev/foundation/components/Animation/AnimationComponent.d.ts +15 -1
- package/dist/esmdev/foundation/components/Animation/AnimationStateRepository.d.ts +26 -10
- package/dist/esmdev/foundation/components/AnimationState/AnimationStateComponent.d.ts +14 -0
- package/dist/esmdev/foundation/components/CharacterController/CharacterAnimationController.d.ts +63 -0
- package/dist/esmdev/foundation/components/CharacterController/CharacterControllerComponent.d.ts +67 -0
- package/dist/esmdev/foundation/components/CharacterController/ICharacterControllerEntity.d.ts +4 -0
- package/dist/esmdev/foundation/components/CharacterController/createCharacterControllerEntity.d.ts +4 -0
- package/dist/esmdev/foundation/components/CharacterController/index.d.ts +4 -0
- package/dist/esmdev/foundation/components/ComponentTypes.d.ts +6 -0
- package/dist/esmdev/foundation/components/Physics/PhysicsComponent.d.ts +27 -0
- package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.d.ts +30 -0
- package/dist/esmdev/foundation/components/Shape/IShapeEntity.d.ts +4 -0
- package/dist/esmdev/foundation/components/Shape/ShapeComponent.d.ts +43 -0
- package/dist/esmdev/foundation/components/Shape/createShapeEntity.d.ts +3 -0
- package/dist/esmdev/foundation/components/Shape/index.d.ts +3 -0
- package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.d.ts +138 -45
- package/dist/esmdev/foundation/components/Transform/TransformComponent.d.ts +2 -3
- package/dist/esmdev/foundation/components/Trigger/ITriggerEntity.d.ts +4 -0
- package/dist/esmdev/foundation/components/Trigger/TriggerComponent.d.ts +58 -0
- package/dist/esmdev/foundation/components/Trigger/index.d.ts +2 -0
- package/dist/esmdev/foundation/components/Vrm/VrmComponent.d.ts +16 -1
- package/dist/esmdev/foundation/components/WellKnownComponentTIDs.d.ts +4 -1
- package/dist/esmdev/foundation/components/index.d.ts +3 -0
- package/dist/esmdev/foundation/core/Component.d.ts +63 -3
- package/dist/esmdev/foundation/core/ComponentMemoryRegistry.d.ts +59 -1
- package/dist/esmdev/foundation/core/Config.d.ts +8 -7
- package/dist/esmdev/foundation/core/Entity.d.ts +15 -0
- package/dist/esmdev/foundation/definitions/BoneDataType.d.ts +12 -1
- package/dist/esmdev/foundation/definitions/PhysicsShapeType.d.ts +1 -0
- package/dist/esmdev/foundation/definitions/ProcessApproach.d.ts +8 -4
- package/dist/esmdev/foundation/exporter/Gltf2ExporterOps.d.ts +2 -0
- package/dist/esmdev/foundation/geometry/Shape.d.ts +35 -0
- package/dist/esmdev/foundation/geometry/index.d.ts +1 -0
- package/dist/esmdev/foundation/geometry/shapes/Cylinder.d.ts +16 -0
- package/dist/esmdev/foundation/geometry/shapes/index.d.ts +1 -0
- package/dist/esmdev/foundation/gizmos/ShapeGizmo.d.ts +22 -0
- package/dist/esmdev/foundation/gizmos/index.d.ts +1 -0
- package/dist/esmdev/foundation/helpers/EntityHelper.d.ts +6 -0
- package/dist/esmdev/foundation/helpers/MeshHelper.d.ts +275 -15
- package/dist/esmdev/foundation/importer/AnimationAssigner.d.ts +62 -3
- package/dist/esmdev/foundation/importer/BoneDataTypeDetector.d.ts +31 -0
- package/dist/esmdev/foundation/importer/Gltf2Importer.d.ts +6 -0
- package/dist/esmdev/foundation/importer/KhrPhysicsImporter.d.ts +58 -0
- package/dist/esmdev/foundation/importer/VrmaImporter.d.ts +11 -3
- package/dist/esmdev/foundation/importer/index.d.ts +2 -0
- package/dist/esmdev/foundation/math/AbstractMatrix.d.ts +3 -2
- package/dist/esmdev/foundation/math/AbstractQuaternion.d.ts +2 -1
- package/dist/esmdev/foundation/math/AnimatedQuaternion.d.ts +4 -0
- package/dist/esmdev/foundation/math/AnimatedScalar.d.ts +4 -0
- package/dist/esmdev/foundation/math/AnimatedVector2.d.ts +4 -0
- package/dist/esmdev/foundation/math/AnimatedVector3.d.ts +4 -0
- package/dist/esmdev/foundation/math/AnimatedVector4.d.ts +4 -0
- package/dist/esmdev/foundation/math/AnimatedVectorN.d.ts +4 -0
- package/dist/esmdev/foundation/math/IAnimatedValue.d.ts +12 -0
- package/dist/esmdev/foundation/math/IMatrix.d.ts +2 -2
- package/dist/esmdev/foundation/math/IQuaternion.d.ts +4 -4
- package/dist/esmdev/foundation/math/LogQuaternion.d.ts +110 -38
- package/dist/esmdev/foundation/math/MathUtil.d.ts +63 -1
- package/dist/esmdev/foundation/math/Matrix22.d.ts +176 -30
- package/dist/esmdev/foundation/math/Matrix33.d.ts +206 -38
- package/dist/esmdev/foundation/math/Matrix44.d.ts +222 -39
- package/dist/esmdev/foundation/math/MutableMatrix22.d.ts +125 -130
- package/dist/esmdev/foundation/math/MutableMatrix33.d.ts +148 -162
- package/dist/esmdev/foundation/math/MutableMatrix44.d.ts +159 -183
- package/dist/esmdev/foundation/math/MutableQuaternion.d.ts +241 -132
- package/dist/esmdev/foundation/math/MutableScalar.d.ts +11 -12
- package/dist/esmdev/foundation/math/MutableVector2.d.ts +30 -31
- package/dist/esmdev/foundation/math/MutableVector3.d.ts +28 -26
- package/dist/esmdev/foundation/math/MutableVector4.d.ts +37 -37
- package/dist/esmdev/foundation/math/Quaternion.d.ts +529 -36
- package/dist/esmdev/foundation/math/Scalar.d.ts +13 -14
- package/dist/esmdev/foundation/math/Vector2.d.ts +38 -38
- package/dist/esmdev/foundation/math/Vector3.d.ts +55 -54
- package/dist/esmdev/foundation/math/Vector4.d.ts +54 -55
- package/dist/esmdev/foundation/misc/MiscUtil.d.ts +79 -16
- package/dist/esmdev/foundation/misc/Time.d.ts +10 -1
- package/dist/esmdev/foundation/physics/CharacterControllerStrategy.d.ts +65 -0
- package/dist/esmdev/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +17 -1
- package/dist/esmdev/foundation/physics/PhysicsProperty.d.ts +43 -0
- package/dist/esmdev/foundation/physics/PhysicsStrategy.d.ts +15 -0
- package/dist/esmdev/foundation/physics/PhysicsWorldQuery.d.ts +65 -0
- package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.d.ts +58 -0
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.d.ts +157 -19
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.d.ts +11 -0
- package/dist/esmdev/foundation/physics/Rapier/index.d.ts +2 -0
- package/dist/esmdev/foundation/physics/ShapeTransformResolver.d.ts +19 -0
- package/dist/esmdev/foundation/physics/index.d.ts +2 -0
- package/dist/esmdev/index.js +35168 -27712
- package/dist/esmdev/types/AnimationTypes.d.ts +1 -1
- package/dist/esmdev/types/KHR_implicit_shapes.d.ts +47 -0
- package/dist/esmdev/types/KHR_physics_rigid_bodies.d.ts +54 -0
- package/dist/esmdev/types/VRMC.d.ts +12 -12
- package/dist/esmdev/types/VRMC_vrm_animation.d.ts +5 -0
- package/dist/esmdev/types/glTF2.d.ts +8 -0
- package/dist/esmdev/types/index.d.ts +2 -0
- package/dist/esmdev/webgl/main.d.ts +2 -1
- package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.d.ts +12 -0
- package/package.json +25 -23
|
@@ -13,6 +13,37 @@ declare function radianToDegree(rad: number): number;
|
|
|
13
13
|
* @returns The angle in radians
|
|
14
14
|
*/
|
|
15
15
|
declare function degreeToRadian(deg: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Encode a quaternion (x, y, z, w) into a 64-bit log-quaternion.
|
|
18
|
+
* Returns [lo, hi] as unsigned 32-bit integers.
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeLogQuat(qx: number, qy: number, qz: number, qw: number): number[];
|
|
21
|
+
/**
|
|
22
|
+
* Checks whether a determinant should be treated as zero.
|
|
23
|
+
*
|
|
24
|
+
* A plain `det === 0` test only catches exactly singular matrices. In practice
|
|
25
|
+
* a matrix whose determinant is tiny compared with its scale is just as
|
|
26
|
+
* dangerous, because its inverse amplifies rounding errors into garbage.
|
|
27
|
+
*
|
|
28
|
+
* @param det - The determinant of the matrix
|
|
29
|
+
* @param scale - The product of the row norms of the matrix (Hadamard bound)
|
|
30
|
+
* @param epsilon - The relative tolerance (defaults to the Float32 threshold)
|
|
31
|
+
* @returns True if the matrix should be considered singular
|
|
32
|
+
*/
|
|
33
|
+
declare function isSingularDet(det: number, scale: number, epsilon?: number): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the relative singularity tolerance for a typed array element size.
|
|
36
|
+
* @param bytesPerElement - 4 for Float32Array, 8 for Float64Array
|
|
37
|
+
* @returns The relative tolerance to use
|
|
38
|
+
*/
|
|
39
|
+
declare function getSingularEpsilon(bytesPerElement: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Converts a 32-bit floating point number to a 16-bit half-precision float.
|
|
42
|
+
* This implementation is based on the OpenEXR half-precision format with additional rounding.
|
|
43
|
+
* Implementation reference: https://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410
|
|
44
|
+
* @returns A function that converts a number to half-precision float representation
|
|
45
|
+
*/
|
|
46
|
+
declare const toHalfFloat: () => ((val: number) => number);
|
|
16
47
|
/**
|
|
17
48
|
* Checks whether a number is a power of two.
|
|
18
49
|
* @param x - The number to check
|
|
@@ -37,6 +68,29 @@ declare function isPowerOfTwoTexture(width: Size, height: Size): boolean;
|
|
|
37
68
|
* @returns A 2-element array containing the packed values
|
|
38
69
|
*/
|
|
39
70
|
declare function packNormalizedVec4ToVec2(x: number, y: number, z: number, w: number, criteria: number): number[];
|
|
71
|
+
declare function packSnormVec4ToUVec2(x: number, y: number, z: number, w: number): number[];
|
|
72
|
+
/**
|
|
73
|
+
* Checks whether the given three scale components are (almost) uniform.
|
|
74
|
+
* The signs are ignored (only the magnitudes are compared).
|
|
75
|
+
*
|
|
76
|
+
* @param x - The x component of the scale
|
|
77
|
+
* @param y - The y component of the scale
|
|
78
|
+
* @param z - The z component of the scale
|
|
79
|
+
* @returns True if the scale is uniform
|
|
80
|
+
*/
|
|
81
|
+
declare function isUniformScale(x: number, y: number, z: number): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Encodes the magnitude of a uniform scale for the Vec4x1 bone data type.
|
|
84
|
+
*
|
|
85
|
+
* The scale is stored as log2(scale) / 16 in a snorm16 value, and shaders decode it with exp2(value * 16).
|
|
86
|
+
* The relative error is therefore constant (at most about 1.7e-4) over 2^-16 .. 2^16, and 1.0 is exact.
|
|
87
|
+
* Scales out of the range are clamped by the snorm packing: a zero scale (often used to hide a part of a mesh)
|
|
88
|
+
* becomes 2^-16, which keeps the mesh invisible while keeping the skinning matrix invertible for normals.
|
|
89
|
+
*
|
|
90
|
+
* @param scale - The magnitude of the uniform scale (>= 0)
|
|
91
|
+
* @returns The value to be packed as snorm16 (it may be out of [-1, 1]; the packing clamps it)
|
|
92
|
+
*/
|
|
93
|
+
declare function encodeVec4x1Scale(scale: number): number;
|
|
40
94
|
/**
|
|
41
95
|
* Calculates the cumulative distribution function (CDF) for a Gaussian distribution.
|
|
42
96
|
* @param x - The value at which to evaluate the CDF
|
|
@@ -131,10 +185,18 @@ declare function computeGaussianDistributionRatioWhoseSumIsOne({ kernelSize, var
|
|
|
131
185
|
export declare const MathUtil: Readonly<{
|
|
132
186
|
radianToDegree: typeof radianToDegree;
|
|
133
187
|
degreeToRadian: typeof degreeToRadian;
|
|
134
|
-
|
|
188
|
+
encodeLogQuat: typeof encodeLogQuat;
|
|
189
|
+
isSingularDet: typeof isSingularDet;
|
|
190
|
+
getSingularEpsilon: typeof getSingularEpsilon;
|
|
191
|
+
SINGULAR_EPSILON: 0.000001;
|
|
192
|
+
SINGULAR_EPSILON_FLOAT64: 1e-12;
|
|
193
|
+
toHalfFloat: typeof toHalfFloat;
|
|
135
194
|
isPowerOfTwo: typeof isPowerOfTwo;
|
|
136
195
|
isPowerOfTwoTexture: typeof isPowerOfTwoTexture;
|
|
137
196
|
packNormalizedVec4ToVec2: typeof packNormalizedVec4ToVec2;
|
|
197
|
+
packSnormVec4ToUVec2: typeof packSnormVec4ToUVec2;
|
|
198
|
+
isUniformScale: typeof isUniformScale;
|
|
199
|
+
encodeVec4x1Scale: typeof encodeVec4x1Scale;
|
|
138
200
|
convertToStringAsGLSLFloat: typeof convertToStringAsGLSLFloat;
|
|
139
201
|
nearZeroToZero: typeof nearZeroToZero;
|
|
140
202
|
gaussianCdf: typeof gaussianCdf;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Array4 } from '../../types';
|
|
2
|
+
import type { FloatTypedArrayConstructor, TypedArray } from '../../types/CommonTypes';
|
|
2
3
|
import { AbstractMatrix } from './AbstractMatrix';
|
|
3
|
-
import type { IMatrix22 } from './IMatrix';
|
|
4
|
+
import type { IMatrix22, IMutableMatrix22 } from './IMatrix';
|
|
4
5
|
import type { IVector2 } from './IVector';
|
|
5
|
-
import type { Matrix33 } from './Matrix33';
|
|
6
|
-
import type { MutableMatrix22 } from './MutableMatrix22';
|
|
7
6
|
import type { MutableVector2 } from './MutableVector2';
|
|
8
7
|
import { Vector2 } from './Vector2';
|
|
9
8
|
/**
|
|
@@ -31,13 +30,16 @@ import { Vector2 } from './Vector2';
|
|
|
31
30
|
* const scale = Matrix22.scale(Vector2.fromCopyArray2([2, 3]));
|
|
32
31
|
* ```
|
|
33
32
|
*/
|
|
34
|
-
export declare class
|
|
33
|
+
export declare class Matrix22_<T extends FloatTypedArrayConstructor> extends AbstractMatrix implements IMatrix22 {
|
|
35
34
|
/**
|
|
36
|
-
* Creates a new
|
|
35
|
+
* Creates a new Matrix22_ instance.
|
|
37
36
|
*
|
|
38
|
-
* @param m -
|
|
37
|
+
* @param m - Typed array containing matrix values in column-major order
|
|
38
|
+
* @param _options - Configuration object containing the typed array constructor
|
|
39
39
|
*/
|
|
40
|
-
constructor(m:
|
|
40
|
+
constructor(m: TypedArray, _options: {
|
|
41
|
+
type: T;
|
|
42
|
+
});
|
|
41
43
|
/**
|
|
42
44
|
* Gets the matrix element at row 0, column 0.
|
|
43
45
|
*
|
|
@@ -109,7 +111,7 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
109
111
|
* // | 0 0 |
|
|
110
112
|
* ```
|
|
111
113
|
*/
|
|
112
|
-
static
|
|
114
|
+
static _zero(type: FloatTypedArrayConstructor): IMatrix22;
|
|
113
115
|
/**
|
|
114
116
|
* Creates a 2x2 identity matrix.
|
|
115
117
|
*
|
|
@@ -123,14 +125,14 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
123
125
|
* // | 0 1 |
|
|
124
126
|
* ```
|
|
125
127
|
*/
|
|
126
|
-
static
|
|
128
|
+
static _identity(type: FloatTypedArrayConstructor): IMatrix22;
|
|
127
129
|
/**
|
|
128
130
|
* Creates a dummy matrix with empty data.
|
|
129
131
|
* Used as a placeholder when no valid matrix data is available.
|
|
130
132
|
*
|
|
131
133
|
* @returns A new Matrix22 with empty Float32Array
|
|
132
134
|
*/
|
|
133
|
-
static
|
|
135
|
+
static _dummy(type: FloatTypedArrayConstructor): IMatrix22;
|
|
134
136
|
/**
|
|
135
137
|
* Creates the transpose of the given matrix.
|
|
136
138
|
* The transpose swaps rows and columns: (i,j) becomes (j,i).
|
|
@@ -147,7 +149,18 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
147
149
|
* // | 3 4 | | 2 4 |
|
|
148
150
|
* ```
|
|
149
151
|
*/
|
|
150
|
-
static
|
|
152
|
+
static _transpose(mat: IMatrix22, type: FloatTypedArrayConstructor): IMatrix22;
|
|
153
|
+
/**
|
|
154
|
+
* Attempts to create the inverse of the given matrix.
|
|
155
|
+
*
|
|
156
|
+
* Unlike `invert`, this method never returns a matrix filled with
|
|
157
|
+
* `Infinity`/`NaN`: it returns `null` when the matrix is numerically
|
|
158
|
+
* singular (see {@link MathUtil.isSingularDet}).
|
|
159
|
+
*
|
|
160
|
+
* @param mat - The matrix to invert
|
|
161
|
+
* @returns A new Matrix22, or null if the matrix is not invertible
|
|
162
|
+
*/
|
|
163
|
+
static _tryInvert(mat: IMatrix22, type: FloatTypedArrayConstructor): IMatrix22 | null;
|
|
151
164
|
/**
|
|
152
165
|
* Creates the inverse of the given matrix.
|
|
153
166
|
*
|
|
@@ -157,9 +170,13 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
157
170
|
* where A = | a b | and det(A) = ad - bc
|
|
158
171
|
* | c d |
|
|
159
172
|
*
|
|
173
|
+
* If the matrix is numerically singular, an identity matrix is returned
|
|
174
|
+
* instead of dividing by zero. Use {@link Matrix22.tryInvert} when the
|
|
175
|
+
* caller needs to detect the failure.
|
|
176
|
+
*
|
|
160
177
|
* @param mat - The matrix to invert
|
|
161
|
-
* @returns A new Matrix22 that is the inverse of the input matrix
|
|
162
|
-
*
|
|
178
|
+
* @returns A new Matrix22 that is the inverse of the input matrix,
|
|
179
|
+
* or the identity matrix if the input is singular
|
|
163
180
|
*
|
|
164
181
|
* @example
|
|
165
182
|
* ```typescript
|
|
@@ -170,17 +187,32 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
170
187
|
* // | 0 0.5 |
|
|
171
188
|
* ```
|
|
172
189
|
*/
|
|
173
|
-
static
|
|
190
|
+
static _invert(mat: IMatrix22, type: FloatTypedArrayConstructor): IMatrix22;
|
|
191
|
+
/**
|
|
192
|
+
* Attempts to calculate the inverse of the given matrix and stores the
|
|
193
|
+
* result in the output matrix.
|
|
194
|
+
*
|
|
195
|
+
* The output matrix is left untouched when the input is numerically
|
|
196
|
+
* singular, which lets callers keep the previous valid value.
|
|
197
|
+
*
|
|
198
|
+
* @param mat - The matrix to invert
|
|
199
|
+
* @param outMat - The mutable matrix to store the result
|
|
200
|
+
* @returns True if the inversion succeeded, false if the matrix is singular
|
|
201
|
+
*/
|
|
202
|
+
static _tryInvertTo(mat: IMatrix22, outMat: IMutableMatrix22): boolean;
|
|
174
203
|
/**
|
|
175
204
|
* Calculates the inverse of the given matrix and stores the result in the output matrix.
|
|
176
205
|
* This method avoids creating a new matrix instance for better performance.
|
|
177
206
|
*
|
|
207
|
+
* If the matrix is numerically singular, the output matrix is set to the
|
|
208
|
+
* identity matrix instead of being filled with `Infinity`/`NaN`.
|
|
209
|
+
* Use {@link Matrix22.tryInvertTo} when the caller needs to detect the failure.
|
|
210
|
+
*
|
|
178
211
|
* @param mat - The matrix to invert
|
|
179
212
|
* @param outMat - The mutable matrix to store the result
|
|
180
|
-
* @returns The output matrix containing the inverse
|
|
181
|
-
* @throws Error if the matrix is singular (determinant is 0)
|
|
213
|
+
* @returns The output matrix containing the inverse, or the identity matrix if the input is singular
|
|
182
214
|
*/
|
|
183
|
-
static
|
|
215
|
+
static _invertTo(mat: IMatrix22, outMat: IMutableMatrix22): IMutableMatrix22;
|
|
184
216
|
/**
|
|
185
217
|
* Creates a 2D rotation matrix for the given angle.
|
|
186
218
|
*
|
|
@@ -197,7 +229,7 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
197
229
|
* const rotation = Matrix22.rotate(Math.PI / 2);
|
|
198
230
|
* ```
|
|
199
231
|
*/
|
|
200
|
-
static
|
|
232
|
+
static _rotate(radian: number, type: FloatTypedArrayConstructor): IMatrix22;
|
|
201
233
|
/**
|
|
202
234
|
* Creates a 2D scaling matrix from a 2D vector.
|
|
203
235
|
*
|
|
@@ -214,7 +246,7 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
214
246
|
* // Creates a matrix that scales x by 2 and y by 3
|
|
215
247
|
* ```
|
|
216
248
|
*/
|
|
217
|
-
static
|
|
249
|
+
static _scale(vec: IVector2, type: FloatTypedArrayConstructor): IMatrix22;
|
|
218
250
|
/**
|
|
219
251
|
* Multiplies two 2x2 matrices and returns the result.
|
|
220
252
|
* Matrix multiplication is not commutative: A * B ≠ B * A in general.
|
|
@@ -230,7 +262,7 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
230
262
|
* const result = Matrix22.multiply(a, b); // Scale then rotate
|
|
231
263
|
* ```
|
|
232
264
|
*/
|
|
233
|
-
static
|
|
265
|
+
static _multiply(l_mat: IMatrix22, r_mat: IMatrix22, type: FloatTypedArrayConstructor): IMatrix22;
|
|
234
266
|
/**
|
|
235
267
|
* Multiplies two matrices and stores the result in the output matrix.
|
|
236
268
|
* This method avoids creating a new matrix instance for better performance.
|
|
@@ -243,7 +275,7 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
243
275
|
* @param outMat - The mutable matrix to store the result
|
|
244
276
|
* @returns The output matrix containing the product
|
|
245
277
|
*/
|
|
246
|
-
static
|
|
278
|
+
static _multiplyTo(l_mat: IMatrix22, r_mat: IMatrix22, outMat: IMutableMatrix22): IMutableMatrix22;
|
|
247
279
|
/**
|
|
248
280
|
* Returns a string representation of the matrix in a readable format.
|
|
249
281
|
*
|
|
@@ -401,7 +433,7 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
401
433
|
* // | 3 4 |
|
|
402
434
|
* ```
|
|
403
435
|
*/
|
|
404
|
-
static
|
|
436
|
+
static _fromCopy4RowMajor(m00: number, m01: number, m10: number, m11: number, type: FloatTypedArrayConstructor): IMatrix22;
|
|
405
437
|
/**
|
|
406
438
|
* Creates a new Matrix22 from individual components in column-major order.
|
|
407
439
|
*
|
|
@@ -417,7 +449,7 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
417
449
|
* @param m11 - Element at row 1, column 1
|
|
418
450
|
* @returns A new Matrix22 with the specified values
|
|
419
451
|
*/
|
|
420
|
-
static
|
|
452
|
+
static _fromCopy4ColumnMajor(m00: number, m10: number, m01: number, m11: number, type: FloatTypedArrayConstructor): IMatrix22;
|
|
421
453
|
/**
|
|
422
454
|
* Creates a new Matrix22 that directly uses the provided Float32Array.
|
|
423
455
|
* The array is used as-is without copying, so modifications to the array
|
|
@@ -426,35 +458,35 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
426
458
|
* @param float32Array - Float32Array containing matrix values in column-major order
|
|
427
459
|
* @returns A new Matrix22 using the provided array
|
|
428
460
|
*/
|
|
429
|
-
static
|
|
461
|
+
static _fromTypedArrayColumnMajor(array: TypedArray, type: FloatTypedArrayConstructor): IMatrix22;
|
|
430
462
|
/**
|
|
431
463
|
* Creates a new Matrix22 by copying values from a Float32Array in column-major order.
|
|
432
464
|
*
|
|
433
465
|
* @param float32Array - Float32Array containing matrix values in column-major order
|
|
434
466
|
* @returns A new Matrix22 with copied values
|
|
435
467
|
*/
|
|
436
|
-
static
|
|
468
|
+
static _fromCopyTypedArrayColumnMajor(array: TypedArray, type: FloatTypedArrayConstructor): IMatrix22;
|
|
437
469
|
/**
|
|
438
470
|
* Creates a new Matrix22 by copying values from a Float32Array in row-major order.
|
|
439
471
|
*
|
|
440
472
|
* @param array - Float32Array containing matrix values in row-major order
|
|
441
473
|
* @returns A new Matrix22 with values converted to column-major order
|
|
442
474
|
*/
|
|
443
|
-
static
|
|
475
|
+
static _fromCopyTypedArrayRowMajor(array: TypedArray, type: FloatTypedArrayConstructor): IMatrix22;
|
|
444
476
|
/**
|
|
445
477
|
* Creates a new Matrix22 by copying values from another IMatrix22.
|
|
446
478
|
*
|
|
447
479
|
* @param mat - The matrix to copy from
|
|
448
480
|
* @returns A new Matrix22 with copied values
|
|
449
481
|
*/
|
|
450
|
-
static
|
|
482
|
+
static _fromCopyMatrix22(mat: IMatrix22, type: FloatTypedArrayConstructor): IMatrix22;
|
|
451
483
|
/**
|
|
452
484
|
* Creates a new Matrix22 from a 4-element array in column-major order.
|
|
453
485
|
*
|
|
454
486
|
* @param array - Array4 containing exactly 4 numbers in column-major order
|
|
455
487
|
* @returns A new Matrix22 with the array values
|
|
456
488
|
*/
|
|
457
|
-
static
|
|
489
|
+
static _fromCopyArray4ColumnMajor(array: Array4<number>, type: FloatTypedArrayConstructor): IMatrix22;
|
|
458
490
|
/**
|
|
459
491
|
* Creates a new Matrix22 from a variable-length array in column-major order.
|
|
460
492
|
* Only the first 4 elements are used.
|
|
@@ -462,14 +494,14 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
462
494
|
* @param array - Array containing matrix values in column-major order
|
|
463
495
|
* @returns A new Matrix22 with the first 4 array values
|
|
464
496
|
*/
|
|
465
|
-
static
|
|
497
|
+
static _fromCopyArrayColumnMajor(array: Array<number>, type: FloatTypedArrayConstructor): IMatrix22;
|
|
466
498
|
/**
|
|
467
499
|
* Creates a new Matrix22 from a 4-element array in row-major order.
|
|
468
500
|
*
|
|
469
501
|
* @param array - Array4 containing exactly 4 numbers in row-major order
|
|
470
502
|
* @returns A new Matrix22 with values converted to column-major order
|
|
471
503
|
*/
|
|
472
|
-
static
|
|
504
|
+
static _fromCopyArray4RowMajor(array: Array4<number>, type: FloatTypedArrayConstructor): IMatrix22;
|
|
473
505
|
/**
|
|
474
506
|
* Creates a new Matrix22 from a variable-length array in row-major order.
|
|
475
507
|
* Only the first 4 elements are used.
|
|
@@ -477,5 +509,119 @@ export declare class Matrix22 extends AbstractMatrix implements IMatrix22 {
|
|
|
477
509
|
* @param array - Array containing matrix values in row-major order
|
|
478
510
|
* @returns A new Matrix22 with values converted to column-major order
|
|
479
511
|
*/
|
|
512
|
+
static _fromCopyArrayRowMajor(array: Array<number>, type: FloatTypedArrayConstructor): IMatrix22;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Immutable 2x2 matrix with 32-bit float components.
|
|
516
|
+
* This is the standard precision implementation for most 2D graphics operations.
|
|
517
|
+
*/
|
|
518
|
+
export declare class Matrix22 extends Matrix22_<Float32ArrayConstructor> {
|
|
519
|
+
/**
|
|
520
|
+
* Creates a new Matrix22 instance.
|
|
521
|
+
* @param m - The typed array containing the matrix components
|
|
522
|
+
*/
|
|
523
|
+
constructor(m: TypedArray);
|
|
524
|
+
/** Creates a zero matrix. */
|
|
525
|
+
static zero(): Matrix22;
|
|
526
|
+
/** Creates an identity matrix. */
|
|
527
|
+
static identity(): Matrix22;
|
|
528
|
+
/** Creates a dummy matrix with an empty array. */
|
|
529
|
+
static dummy(): Matrix22;
|
|
530
|
+
/** Creates the transpose of the given matrix. */
|
|
531
|
+
static transpose(mat: IMatrix22): Matrix22;
|
|
532
|
+
/** Attempts to invert the given matrix, returning null when it is singular. */
|
|
533
|
+
static tryInvert(mat: IMatrix22): Matrix22 | null;
|
|
534
|
+
/** Creates the inverse of the given matrix (identity when singular). */
|
|
535
|
+
static invert(mat: IMatrix22): Matrix22;
|
|
536
|
+
/** Attempts to invert the given matrix into outMat. */
|
|
537
|
+
static tryInvertTo<T extends IMutableMatrix22>(mat: IMatrix22, outMat: T): boolean;
|
|
538
|
+
/** Inverts the given matrix into outMat (identity when singular). */
|
|
539
|
+
static invertTo<T extends IMutableMatrix22>(mat: IMatrix22, outMat: T): T;
|
|
540
|
+
/** Creates a 2D rotation matrix. */
|
|
541
|
+
static rotate(radian: number): Matrix22;
|
|
542
|
+
/** Creates a 2D scaling matrix. */
|
|
543
|
+
static scale(vec: IVector2): Matrix22;
|
|
544
|
+
/** Multiplies two 2x2 matrices. */
|
|
545
|
+
static multiply(l_mat: IMatrix22, r_mat: IMatrix22): Matrix22;
|
|
546
|
+
/** Multiplies two matrices and stores the result in outMat. */
|
|
547
|
+
static multiplyTo<T extends IMutableMatrix22>(l_mat: IMatrix22, r_mat: IMatrix22, outMat: T): T;
|
|
548
|
+
/** Creates a matrix from row-major components. */
|
|
549
|
+
static fromCopy4RowMajor(m00: number, m01: number, m10: number, m11: number): Matrix22;
|
|
550
|
+
/** Creates a matrix from column-major components. */
|
|
551
|
+
static fromCopy4ColumnMajor(m00: number, m10: number, m01: number, m11: number): Matrix22;
|
|
552
|
+
/** Creates a matrix that directly uses the given Float32Array. */
|
|
553
|
+
static fromFloat32ArrayColumnMajor(array: Float32Array): Matrix22;
|
|
554
|
+
/** Creates a matrix by copying a Float32Array in column-major order. */
|
|
555
|
+
static fromCopyFloat32ArrayColumnMajor(array: Float32Array): Matrix22;
|
|
556
|
+
/** Creates a matrix by copying a Float32Array in row-major order. */
|
|
557
|
+
static fromCopyFloat32ArrayRowMajor(array: Float32Array): Matrix22;
|
|
558
|
+
/** Creates a matrix by copying another matrix. */
|
|
559
|
+
static fromCopyMatrix22(mat: IMatrix22): Matrix22;
|
|
560
|
+
/** Creates a matrix from a 4-element array in column-major order. */
|
|
561
|
+
static fromCopyArray9ColumnMajor(array: Array4<number>): Matrix22;
|
|
562
|
+
/** Creates a matrix from an array in column-major order. */
|
|
563
|
+
static fromCopyArrayColumnMajor(array: Array<number>): Matrix22;
|
|
564
|
+
/** Creates a matrix from a 4-element array in row-major order. */
|
|
565
|
+
static fromCopyArray9RowMajor(array: Array4<number>): Matrix22;
|
|
566
|
+
/** Creates a matrix from an array in row-major order. */
|
|
480
567
|
static fromCopyArrayRowMajor(array: Array<number>): Matrix22;
|
|
481
568
|
}
|
|
569
|
+
/**
|
|
570
|
+
* Immutable 2x2 matrix with 64-bit float components.
|
|
571
|
+
* Use this implementation when higher numerical precision is required.
|
|
572
|
+
*/
|
|
573
|
+
export declare class Matrix22D extends Matrix22_<Float64ArrayConstructor> {
|
|
574
|
+
/**
|
|
575
|
+
* Creates a new Matrix22D instance.
|
|
576
|
+
* @param m - The typed array containing the matrix components
|
|
577
|
+
*/
|
|
578
|
+
private constructor();
|
|
579
|
+
/** Creates a zero matrix. */
|
|
580
|
+
static zero(): Matrix22D;
|
|
581
|
+
/** Creates an identity matrix. */
|
|
582
|
+
static identity(): Matrix22D;
|
|
583
|
+
/** Creates a dummy matrix with an empty array. */
|
|
584
|
+
static dummy(): Matrix22D;
|
|
585
|
+
/** Creates the transpose of the given matrix. */
|
|
586
|
+
static transpose(mat: IMatrix22): Matrix22D;
|
|
587
|
+
/** Attempts to invert the given matrix, returning null when it is singular. */
|
|
588
|
+
static tryInvert(mat: IMatrix22): Matrix22D | null;
|
|
589
|
+
/** Creates the inverse of the given matrix (identity when singular). */
|
|
590
|
+
static invert(mat: IMatrix22): Matrix22D;
|
|
591
|
+
/** Attempts to invert the given matrix into outMat. */
|
|
592
|
+
static tryInvertTo<T extends IMutableMatrix22>(mat: IMatrix22, outMat: T): boolean;
|
|
593
|
+
/** Inverts the given matrix into outMat (identity when singular). */
|
|
594
|
+
static invertTo<T extends IMutableMatrix22>(mat: IMatrix22, outMat: T): T;
|
|
595
|
+
/** Creates a 2D rotation matrix. */
|
|
596
|
+
static rotate(radian: number): Matrix22D;
|
|
597
|
+
/** Creates a 2D scaling matrix. */
|
|
598
|
+
static scale(vec: IVector2): Matrix22D;
|
|
599
|
+
/** Multiplies two 2x2 matrices. */
|
|
600
|
+
static multiply(l_mat: IMatrix22, r_mat: IMatrix22): Matrix22D;
|
|
601
|
+
/** Multiplies two matrices and stores the result in outMat. */
|
|
602
|
+
static multiplyTo<T extends IMutableMatrix22>(l_mat: IMatrix22, r_mat: IMatrix22, outMat: T): T;
|
|
603
|
+
/** Creates a matrix from row-major components. */
|
|
604
|
+
static fromCopy4RowMajor(m00: number, m01: number, m10: number, m11: number): Matrix22D;
|
|
605
|
+
/** Creates a matrix from column-major components. */
|
|
606
|
+
static fromCopy4ColumnMajor(m00: number, m10: number, m01: number, m11: number): Matrix22D;
|
|
607
|
+
/** Creates a matrix that directly uses the given Float64Array. */
|
|
608
|
+
static fromFloat64ArrayColumnMajor(array: Float64Array): Matrix22D;
|
|
609
|
+
/** Creates a matrix by copying a Float64Array in column-major order. */
|
|
610
|
+
static fromCopyFloat64ArrayColumnMajor(array: Float64Array): Matrix22D;
|
|
611
|
+
/** Creates a matrix by copying a Float64Array in row-major order. */
|
|
612
|
+
static fromCopyFloat64ArrayRowMajor(array: Float64Array): Matrix22D;
|
|
613
|
+
/** Creates a matrix by copying another matrix. */
|
|
614
|
+
static fromCopyMatrix22(mat: IMatrix22): Matrix22D;
|
|
615
|
+
/** Creates a matrix from a 4-element array in column-major order. */
|
|
616
|
+
static fromCopyArray9ColumnMajor(array: Array4<number>): Matrix22D;
|
|
617
|
+
/** Creates a matrix from an array in column-major order. */
|
|
618
|
+
static fromCopyArrayColumnMajor(array: Array<number>): Matrix22D;
|
|
619
|
+
/** Creates a matrix from a 4-element array in row-major order. */
|
|
620
|
+
static fromCopyArray9RowMajor(array: Array4<number>): Matrix22D;
|
|
621
|
+
/** Creates a matrix from an array in row-major order. */
|
|
622
|
+
static fromCopyArrayRowMajor(array: Array<number>): Matrix22D;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Alias for the 32-bit (Float32Array) implementation, making the precision explicit.
|
|
626
|
+
*/
|
|
627
|
+
export { Matrix22 as Matrix22F };
|