@babylonjs/gui 5.38.0 → 5.40.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/2D/advancedDynamicTexture.d.ts +1 -0
- package/2D/advancedDynamicTexture.js +8 -0
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/control.d.ts +13 -0
- package/2D/controls/control.js +25 -0
- package/2D/controls/control.js.map +1 -1
- package/2D/math2D.d.ts +19 -0
- package/2D/math2D.js +21 -0
- package/2D/math2D.js.map +1 -1
- package/package.json +2 -2
package/2D/math2D.d.ts
CHANGED
@@ -115,3 +115,22 @@ export declare class Matrix2D {
|
|
115
115
|
*/
|
116
116
|
static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
|
117
117
|
}
|
118
|
+
/**
|
119
|
+
* Useful math functions
|
120
|
+
*/
|
121
|
+
export declare class MathTools {
|
122
|
+
/**
|
123
|
+
* Default rounding precision for GUI elements. It should be
|
124
|
+
* set to a power of ten, where the exponent means the number
|
125
|
+
* of decimal digits to round to, i.e, 100 means 2 decimal digits,
|
126
|
+
* 1000 means 3 decimal digits, etc. Default is 100 (2 decimal digits).
|
127
|
+
*/
|
128
|
+
static DefaultRoundingPrecision: number;
|
129
|
+
/**
|
130
|
+
* Rounds a number to the nearest multiple of a given precision
|
131
|
+
* @param value the value to be rounded
|
132
|
+
* @param precision the multiple to which the value will be rounded. Default is 100 (2 decimal digits)
|
133
|
+
* @returns
|
134
|
+
*/
|
135
|
+
static Round(value: number, precision?: number): number;
|
136
|
+
}
|
package/2D/math2D.js
CHANGED
@@ -211,4 +211,25 @@ Matrix2D._TempScalingMatrix = Matrix2D.Identity();
|
|
211
211
|
Matrix2D._TempCompose0 = Matrix2D.Identity();
|
212
212
|
Matrix2D._TempCompose1 = Matrix2D.Identity();
|
213
213
|
Matrix2D._TempCompose2 = Matrix2D.Identity();
|
214
|
+
/**
|
215
|
+
* Useful math functions
|
216
|
+
*/
|
217
|
+
export class MathTools {
|
218
|
+
/**
|
219
|
+
* Rounds a number to the nearest multiple of a given precision
|
220
|
+
* @param value the value to be rounded
|
221
|
+
* @param precision the multiple to which the value will be rounded. Default is 100 (2 decimal digits)
|
222
|
+
* @returns
|
223
|
+
*/
|
224
|
+
static Round(value, precision = MathTools.DefaultRoundingPrecision) {
|
225
|
+
return Math.round(value * precision) / precision;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
/**
|
229
|
+
* Default rounding precision for GUI elements. It should be
|
230
|
+
* set to a power of ten, where the exponent means the number
|
231
|
+
* of decimal digits to round to, i.e, 100 means 2 decimal digits,
|
232
|
+
* 1000 means 3 decimal digits, etc. Default is 100 (2 decimal digits).
|
233
|
+
*/
|
234
|
+
MathTools.DefaultRoundingPrecision = 100;
|
214
235
|
//# sourceMappingURL=math2D.js.map
|
package/2D/math2D.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"math2D.js","sourceRoot":"","sources":["../../../../lts/gui/generated/2D/math2D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,gDAAkC;AAEpD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,OAAO;IACxC;;;;OAIG;IACH,YACI,MAAe;IACf,6CAA6C;IACtC,cAAsB,CAAC;QAE9B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAFnB,gBAAW,GAAX,WAAW,CAAY;IAGlC,CAAC;CACJ;AAED,+CAA+C;AAC/C,MAAM,OAAO,QAAQ;IAIjB;;;;;;;;OAQG;IACH,YAAY,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW;QAZxF,oEAAoE;QAC7D,MAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAY3B,IAAI,CAAC,U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,CAAC,0BAA0B,CAAC,CAAC;QAEzE,QAAQ,CAAC,yBAAyB,CAAC,aAAa,CAAC,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;QACtG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC3F,IAAI,YAAY,EAAE;YACd,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;YAClG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;SAC9D;aAAM;YACH,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;SACrF;IACL,CAAC;;AAnCc,kCAAyB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAChD,mCAA0B,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACjD,4BAAmB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAC1C,2BAAkB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACzC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\n\r\n/**\r\n * Class used to transport Vector2 information for pointer events\r\n */\r\nexport class Vector2WithInfo extends Vector2 {\r\n /**\r\n * Creates a new Vector2WithInfo\r\n * @param source defines the vector2 data to transport\r\n * @param buttonIndex defines the current mouse button index\r\n */\r\n public constructor(\r\n source: Vector2,\r\n /** defines the current mouse button index */\r\n public buttonIndex: number = 0\r\n ) {\r\n super(source.x, source.y);\r\n }\r\n}\r\n\r\n/** Class used to provide 2D matrix features */\r\nexport class Matrix2D {\r\n /** Gets the internal array of 6 floats used to store matrix data */\r\n public m = new Float32Array(6);\r\n\r\n /**\r\n * Creates a new matrix\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n */\r\n constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number) {\r\n this.fromValues(m00, m01, m10, m11, m20, m21);\r\n }\r\n\r\n /**\r\n * Fills the matrix from direct values\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n * @returns the current modified matrix\r\n */\r\n public fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D {\r\n this.m[0] = m00;\r\n this.m[1] = m01;\r\n this.m[2] = m10;\r\n this.m[3] = m11;\r\n this.m[4] = m20;\r\n this.m[5] = m21;\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets matrix determinant\r\n * @returns the determinant\r\n */\r\n public determinant(): number {\r\n return this.m[0] * this.m[3] - this.m[1] * this.m[2];\r\n }\r\n\r\n /**\r\n * Inverses the matrix and stores it in a target matrix\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public invertToRef(result: Matrix2D): Matrix2D {\r\n const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const det = this.determinant();\r\n if (det < Epsilon * Epsilon) {\r\n result.m[0] = 0;\r\n result.m[1] = 0;\r\n result.m[2] = 0;\r\n result.m[3] = 0;\r\n result.m[4] = 0;\r\n result.m[5] = 0;\r\n return this;\r\n }\r\n\r\n const detDiv = 1 / det;\r\n\r\n const det4 = l2 * l5 - l3 * l4;\r\n const det5 = l1 * l4 - l0 * l5;\r\n\r\n result.m[0] = l3 * detDiv;\r\n result.m[1] = -l1 * detDiv;\r\n result.m[2] = -l2 * detDiv;\r\n result.m[3] = l0 * detDiv;\r\n result.m[4] = det4 * detDiv;\r\n result.m[5] = det5 * detDiv;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Multiplies the current matrix with another one\r\n * @param other defines the second operand\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D {\r\n const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const r0 = other.m[0];\r\n const r1 = other.m[1];\r\n const r2 = other.m[2];\r\n const r3 = other.m[3];\r\n const r4 = other.m[4];\r\n const r5 = other.m[5];\r\n\r\n result.m[0] = l0 * r0 + l1 * r2;\r\n result.m[1] = l0 * r1 + l1 * r3;\r\n result.m[2] = l2 * r0 + l3 * r2;\r\n result.m[3] = l2 * r1 + l3 * r3;\r\n result.m[4] = l4 * r0 + l5 * r2 + r4;\r\n result.m[5] = l4 * r1 + l5 * r3 + r5;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current matrix to a set of 2 floats and stores the result in a vector2\r\n * @param x defines the x coordinate to transform\r\n * @param y defines the x coordinate to transform\r\n * @param result defines the target vector2\r\n * @returns the current matrix\r\n */\r\n public transformCoordinates(x: number, y: number, result: Vector2): Matrix2D {\r\n result.x = x * this.m[0] + y * this.m[2] + this.m[4];\r\n result.y = x * this.m[1] + y * this.m[3] + this.m[5];\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates an identity matrix\r\n * @returns a new matrix\r\n */\r\n public static Identity(): Matrix2D {\r\n return new Matrix2D(1, 0, 0, 1, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates an identity matrix and stores it in a target matrix\r\n * @param result defines the target matrix\r\n */\r\n public static IdentityToRef(result: Matrix2D): void {\r\n result.m[0] = 1;\r\n result.m[1] = 0;\r\n result.m[2] = 0;\r\n result.m[3] = 1;\r\n result.m[4] = 0;\r\n result.m[5] = 0;\r\n }\r\n\r\n /**\r\n * Creates a translation matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the translation\r\n * @param y defines the y coordinate of the translation\r\n * @param result defines the target matrix\r\n */\r\n public static TranslationToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(1, 0, 0, 1, x, y);\r\n }\r\n\r\n /**\r\n * Creates a scaling matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the scaling\r\n * @param y defines the y coordinate of the scaling\r\n * @param result defines the target matrix\r\n */\r\n public static ScalingToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(x, 0, 0, y, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates a rotation matrix and stores it in a target matrix\r\n * @param angle defines the rotation angle\r\n * @param result defines the target matrix\r\n */\r\n public static RotationToRef(angle: number, result: Matrix2D): void {\r\n const s = Math.sin(angle);\r\n const c = Math.cos(angle);\r\n\r\n result.fromValues(c, s, -s, c, 0, 0);\r\n }\r\n\r\n private static _TempPreTranslationMatrix = Matrix2D.Identity();\r\n private static _TempPostTranslationMatrix = Matrix2D.Identity();\r\n private static _TempRotationMatrix = Matrix2D.Identity();\r\n private static _TempScalingMatrix = Matrix2D.Identity();\r\n private static _TempCompose0 = Matrix2D.Identity();\r\n private static _TempCompose1 = Matrix2D.Identity();\r\n private static _TempCompose2 = Matrix2D.Identity();\r\n\r\n /**\r\n * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix\r\n * @param tx defines the x coordinate of the translation\r\n * @param ty defines the y coordinate of the translation\r\n * @param angle defines the rotation angle\r\n * @param scaleX defines the x coordinate of the scaling\r\n * @param scaleY defines the y coordinate of the scaling\r\n * @param parentMatrix defines the parent matrix to multiply by (can be null)\r\n * @param result defines the target matrix\r\n */\r\n public static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void {\r\n Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);\r\n\r\n Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);\r\n\r\n Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);\r\n\r\n Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);\r\n\r\n Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);\r\n Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);\r\n if (parentMatrix) {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);\r\n Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);\r\n } else {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);\r\n }\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"math2D.js","sourceRoot":"","sources":["../../../../lts/gui/generated/2D/math2D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,gDAAkC;AAEpD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,OAAO;IACxC;;;;OAIG;IACH,YACI,MAAe;IACf,6CAA6C;IACtC,cAAsB,CAAC;QAE9B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAFnB,gBAAW,GAAX,WAAW,CAAY;IAGlC,CAAC;CACJ;AAED,+CAA+C;AAC/C,MAAM,OAAO,QAAQ;IAIjB;;;;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,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACrD,CAAC;;AAhBD;;;;;GAKG;AACW,kCAAwB,GAAG,GAAG,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\n\r\n/**\r\n * Class used to transport Vector2 information for pointer events\r\n */\r\nexport class Vector2WithInfo extends Vector2 {\r\n /**\r\n * Creates a new Vector2WithInfo\r\n * @param source defines the vector2 data to transport\r\n * @param buttonIndex defines the current mouse button index\r\n */\r\n public constructor(\r\n source: Vector2,\r\n /** defines the current mouse button index */\r\n public buttonIndex: number = 0\r\n ) {\r\n super(source.x, source.y);\r\n }\r\n}\r\n\r\n/** Class used to provide 2D matrix features */\r\nexport class Matrix2D {\r\n /** Gets the internal array of 6 floats used to store matrix data */\r\n public m = new Float32Array(6);\r\n\r\n /**\r\n * Creates a new matrix\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n */\r\n constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number) {\r\n this.fromValues(m00, m01, m10, m11, m20, m21);\r\n }\r\n\r\n /**\r\n * Fills the matrix from direct values\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n * @returns the current modified matrix\r\n */\r\n public fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D {\r\n this.m[0] = m00;\r\n this.m[1] = m01;\r\n this.m[2] = m10;\r\n this.m[3] = m11;\r\n this.m[4] = m20;\r\n this.m[5] = m21;\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets matrix determinant\r\n * @returns the determinant\r\n */\r\n public determinant(): number {\r\n return this.m[0] * this.m[3] - this.m[1] * this.m[2];\r\n }\r\n\r\n /**\r\n * Inverses the matrix and stores it in a target matrix\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public invertToRef(result: Matrix2D): Matrix2D {\r\n const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const det = this.determinant();\r\n if (det < Epsilon * Epsilon) {\r\n result.m[0] = 0;\r\n result.m[1] = 0;\r\n result.m[2] = 0;\r\n result.m[3] = 0;\r\n result.m[4] = 0;\r\n result.m[5] = 0;\r\n return this;\r\n }\r\n\r\n const detDiv = 1 / det;\r\n\r\n const det4 = l2 * l5 - l3 * l4;\r\n const det5 = l1 * l4 - l0 * l5;\r\n\r\n result.m[0] = l3 * detDiv;\r\n result.m[1] = -l1 * detDiv;\r\n result.m[2] = -l2 * detDiv;\r\n result.m[3] = l0 * detDiv;\r\n result.m[4] = det4 * detDiv;\r\n result.m[5] = det5 * detDiv;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Multiplies the current matrix with another one\r\n * @param other defines the second operand\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D {\r\n const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const r0 = other.m[0];\r\n const r1 = other.m[1];\r\n const r2 = other.m[2];\r\n const r3 = other.m[3];\r\n const r4 = other.m[4];\r\n const r5 = other.m[5];\r\n\r\n result.m[0] = l0 * r0 + l1 * r2;\r\n result.m[1] = l0 * r1 + l1 * r3;\r\n result.m[2] = l2 * r0 + l3 * r2;\r\n result.m[3] = l2 * r1 + l3 * r3;\r\n result.m[4] = l4 * r0 + l5 * r2 + r4;\r\n result.m[5] = l4 * r1 + l5 * r3 + r5;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current matrix to a set of 2 floats and stores the result in a vector2\r\n * @param x defines the x coordinate to transform\r\n * @param y defines the x coordinate to transform\r\n * @param result defines the target vector2\r\n * @returns the current matrix\r\n */\r\n public transformCoordinates(x: number, y: number, result: Vector2): Matrix2D {\r\n result.x = x * this.m[0] + y * this.m[2] + this.m[4];\r\n result.y = x * this.m[1] + y * this.m[3] + this.m[5];\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates an identity matrix\r\n * @returns a new matrix\r\n */\r\n public static Identity(): Matrix2D {\r\n return new Matrix2D(1, 0, 0, 1, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates an identity matrix and stores it in a target matrix\r\n * @param result defines the target matrix\r\n */\r\n public static IdentityToRef(result: Matrix2D): void {\r\n result.m[0] = 1;\r\n result.m[1] = 0;\r\n result.m[2] = 0;\r\n result.m[3] = 1;\r\n result.m[4] = 0;\r\n result.m[5] = 0;\r\n }\r\n\r\n /**\r\n * Creates a translation matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the translation\r\n * @param y defines the y coordinate of the translation\r\n * @param result defines the target matrix\r\n */\r\n public static TranslationToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(1, 0, 0, 1, x, y);\r\n }\r\n\r\n /**\r\n * Creates a scaling matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the scaling\r\n * @param y defines the y coordinate of the scaling\r\n * @param result defines the target matrix\r\n */\r\n public static ScalingToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(x, 0, 0, y, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates a rotation matrix and stores it in a target matrix\r\n * @param angle defines the rotation angle\r\n * @param result defines the target matrix\r\n */\r\n public static RotationToRef(angle: number, result: Matrix2D): void {\r\n const s = Math.sin(angle);\r\n const c = Math.cos(angle);\r\n\r\n result.fromValues(c, s, -s, c, 0, 0);\r\n }\r\n\r\n private static _TempPreTranslationMatrix = Matrix2D.Identity();\r\n private static _TempPostTranslationMatrix = Matrix2D.Identity();\r\n private static _TempRotationMatrix = Matrix2D.Identity();\r\n private static _TempScalingMatrix = Matrix2D.Identity();\r\n private static _TempCompose0 = Matrix2D.Identity();\r\n private static _TempCompose1 = Matrix2D.Identity();\r\n private static _TempCompose2 = Matrix2D.Identity();\r\n\r\n /**\r\n * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix\r\n * @param tx defines the x coordinate of the translation\r\n * @param ty defines the y coordinate of the translation\r\n * @param angle defines the rotation angle\r\n * @param scaleX defines the x coordinate of the scaling\r\n * @param scaleY defines the y coordinate of the scaling\r\n * @param parentMatrix defines the parent matrix to multiply by (can be null)\r\n * @param result defines the target matrix\r\n */\r\n public static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void {\r\n Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);\r\n\r\n Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);\r\n\r\n Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);\r\n\r\n Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);\r\n\r\n Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);\r\n Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);\r\n if (parentMatrix) {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);\r\n Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);\r\n } else {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Useful math functions\r\n */\r\nexport class MathTools {\r\n /**\r\n * Default rounding precision for GUI elements. It should be\r\n * set to a power of ten, where the exponent means the number\r\n * of decimal digits to round to, i.e, 100 means 2 decimal digits,\r\n * 1000 means 3 decimal digits, etc. Default is 100 (2 decimal digits).\r\n */\r\n public static DefaultRoundingPrecision = 100;\r\n\r\n /**\r\n * Rounds a number to the nearest multiple of a given precision\r\n * @param value the value to be rounded\r\n * @param precision the multiple to which the value will be rounded. Default is 100 (2 decimal digits)\r\n * @returns\r\n */\r\n public static Round(value: number, precision: number = MathTools.DefaultRoundingPrecision): number {\r\n return Math.round(value * precision) / precision;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/gui",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.40.0",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^5.
|
21
|
+
"@babylonjs/core": "^5.40.0",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/gui": "1.0.0",
|
24
24
|
"rimraf": "^3.0.2",
|