@babylonjs/core 6.48.0 → 6.49.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.
Files changed (62) hide show
  1. package/Behaviors/Meshes/baseSixDofDragBehavior.js +6 -6
  2. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  3. package/Behaviors/Meshes/sixDofDragBehavior.d.ts +1 -0
  4. package/Behaviors/Meshes/sixDofDragBehavior.js +5 -1
  5. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  6. package/Engines/ICanvas.d.ts +10 -0
  7. package/Engines/ICanvas.js.map +1 -1
  8. package/Engines/Native/nativeDataStream.d.ts +2 -1
  9. package/Engines/Native/nativeDataStream.js.map +1 -1
  10. package/Engines/Native/nativePipelineContext.js.map +1 -1
  11. package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
  12. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +6 -4
  13. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  14. package/Engines/nativeEngine.d.ts +2 -2
  15. package/Engines/nativeEngine.js.map +1 -1
  16. package/Engines/thinEngine.d.ts +2 -2
  17. package/Engines/thinEngine.js +2 -2
  18. package/Engines/thinEngine.js.map +1 -1
  19. package/Materials/PBR/pbrSubSurfaceConfiguration.js +6 -0
  20. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  21. package/Maths/math.like.d.ts +2 -2
  22. package/Maths/math.like.js.map +1 -1
  23. package/Maths/math.vector.d.ts +1 -1
  24. package/Maths/math.vector.js.map +1 -1
  25. package/Maths/tensor.d.ts +12 -8
  26. package/Maths/tensor.js.map +1 -1
  27. package/Meshes/Compression/dracoCompression.d.ts +12 -0
  28. package/Meshes/Compression/dracoCompression.js +20 -14
  29. package/Meshes/Compression/dracoCompression.js.map +1 -1
  30. package/Meshes/Node/Blocks/geometryDistanceBlock.js +1 -0
  31. package/Meshes/Node/Blocks/geometryDistanceBlock.js.map +1 -1
  32. package/Meshes/Node/Blocks/geometryDotBlock.js +1 -0
  33. package/Meshes/Node/Blocks/geometryDotBlock.js.map +1 -1
  34. package/Meshes/Node/Blocks/geometryLengthBlock.js +1 -0
  35. package/Meshes/Node/Blocks/geometryLengthBlock.js.map +1 -1
  36. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +1 -0
  37. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
  38. package/Meshes/abstractMesh.d.ts +5 -2
  39. package/Meshes/abstractMesh.js +5 -2
  40. package/Meshes/abstractMesh.js.map +1 -1
  41. package/Meshes/thinInstanceMesh.d.ts +9 -0
  42. package/Meshes/thinInstanceMesh.js +31 -4
  43. package/Meshes/thinInstanceMesh.js.map +1 -1
  44. package/Particles/pointsCloudSystem.js +26 -29
  45. package/Particles/pointsCloudSystem.js.map +1 -1
  46. package/Rendering/GlobalIllumination/giRSMManager.d.ts +1 -1
  47. package/Rendering/GlobalIllumination/giRSMManager.js +1 -1
  48. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  49. package/Rendering/reflectiveShadowMap.d.ts +5 -4
  50. package/Rendering/reflectiveShadowMap.js +1 -1
  51. package/Rendering/reflectiveShadowMap.js.map +1 -1
  52. package/Shaders/ShadersInclude/pbrDebug.js +1 -1
  53. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  54. package/Shaders/pbr.vertex.js +1 -1
  55. package/Shaders/pbr.vertex.js.map +1 -1
  56. package/XR/features/WebXRControllerPointerSelection.js +11 -0
  57. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  58. package/assets/Basis/basis_transcoder.wasm +0 -0
  59. package/assets/Draco/draco_decoder_gltf.wasm +0 -0
  60. package/package.json +2 -1
  61. package/types.d.ts +1 -1
  62. package/types.js.map +1 -1
package/Maths/tensor.d.ts CHANGED
@@ -3,15 +3,19 @@ import type { DeepImmutable, Flatten, FloatArray, Length } from "../types";
3
3
  * Computes the tensor dimension of a multi-dimensional array
4
4
  */
5
5
  export type Dimension<T> = T extends Array<infer U> ? [Length<T>, ...Dimension<U>] : T extends readonly [infer U, ...infer R] ? [Length<T>, ...Dimension<U>] : [];
6
+ /**
7
+ * Possible values for a Tensor
8
+ */
9
+ export type TensorValue = number[] | TensorValue[];
6
10
  /**
7
11
  * Extracts the value type of a Tensor
8
12
  */
9
- export type TensorValue<T> = T extends Tensor<infer V> ? V : never;
13
+ export type ValueOfTensor<T = unknown> = T extends Tensor<infer V> ? V : TensorValue;
10
14
  /**
11
15
  * Describes a mathematical tensor.
12
16
  * @see https://wikipedia.org/wiki/Tensor
13
17
  */
14
- export interface Tensor<V extends unknown[] = unknown[]> {
18
+ export interface Tensor<V extends TensorValue = TensorValue> {
15
19
  /**
16
20
  * An array of the size of each dimension.
17
21
  * For example, [3] for a Vector3 and [4,4] for a Matrix
@@ -48,7 +52,7 @@ export interface Tensor<V extends unknown[] = unknown[]> {
48
52
  * @param index defines the offset in the destination array
49
53
  * @returns the current instance
50
54
  */
51
- fromArray(array: FloatArray, index?: number): this;
55
+ fromArray(array: DeepImmutable<FloatArray>, index?: number): this;
52
56
  /**
53
57
  * Copy the current instance to an array
54
58
  * @returns a new array with the instance coordinates.
@@ -293,11 +297,11 @@ export interface Tensor<V extends unknown[] = unknown[]> {
293
297
  /**
294
298
  * Static side of Tensor
295
299
  */
296
- export interface TensorStatic<T extends Tensor> {
300
+ export interface TensorStatic<T extends Tensor<any[]>> {
297
301
  /**
298
302
  * Creates a new instance from the given coordinates
299
303
  */
300
- new (...coords: Flatten<TensorValue<T>>): T;
304
+ new (...coords: Flatten<ValueOfTensor<T>>): T;
301
305
  /**
302
306
  * So [[static]].prototype has typings, instead of just any
303
307
  */
@@ -323,7 +327,7 @@ export interface TensorStatic<T extends Tensor> {
323
327
  * @param offset defines the offset in the data source
324
328
  * @returns a new instance
325
329
  */
326
- FromArray(array: ArrayLike<number>, offset?: number): T;
330
+ FromArray(array: DeepImmutable<FloatArray>, offset?: number): T;
327
331
  /**
328
332
  * Sets "result" from the given index element of the given array
329
333
  * @param array defines the data source
@@ -331,12 +335,12 @@ export interface TensorStatic<T extends Tensor> {
331
335
  * @param result defines the target instance
332
336
  * @returns result input
333
337
  */
334
- FromArrayToRef(array: ArrayLike<number>, offset: number, result: T): T;
338
+ FromArrayToRef(array: DeepImmutable<FloatArray>, offset: number, result: T): T;
335
339
  /**
336
340
  * Sets the given instance "result" with the given floats.
337
341
  * @param args defines the coordinates of the source with the last paramater being the result
338
342
  */
339
- FromFloatsToRef(...args: [...Flatten<TensorValue<T>>, T]): T;
343
+ FromFloatsToRef(...args: [...Flatten<ValueOfTensor<T>>, T]): T;
340
344
  /**
341
345
  * Gets the dot product of the instance "left" and the instance "right"
342
346
  * @param left defines first instance
@@ -1 +1 @@
1
- {"version":3,"file":"tensor.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/tensor.ts"],"names":[],"mappings":";AA8dA,wDAAwD","sourcesContent":["import type { DeepImmutable, Flatten, FloatArray, Length } from \"../types\";\r\n\r\n/**\r\n * Computes the tensor dimension of a multi-dimensional array\r\n */\r\nexport type Dimension<T> = T extends Array<infer U> ? [Length<T>, ...Dimension<U>] : T extends readonly [infer U, ...infer R] ? [Length<T>, ...Dimension<U>] : [];\r\n\r\n/**\r\n * Extracts the value type of a Tensor\r\n */\r\nexport type TensorValue<T> = T extends Tensor<infer V> ? V : never;\r\n\r\n/**\r\n * Describes a mathematical tensor.\r\n * @see https://wikipedia.org/wiki/Tensor\r\n */\r\nexport interface Tensor<V extends unknown[] = unknown[]> {\r\n /**\r\n * An array of the size of each dimension.\r\n * For example, [3] for a Vector3 and [4,4] for a Matrix\r\n * @remarks\r\n * This is to allow implementations with using a getter\r\n */\r\n readonly dimension: Readonly<Dimension<V>>;\r\n\r\n /**\r\n * The rank of the tensor. This is the same as the length of the tensor's dimension array.\r\n * @remarks\r\n * This is to allow implementations with using a getter\r\n */\r\n readonly rank: number;\r\n\r\n /**\r\n * Gets class name\r\n * @returns the class name\r\n */\r\n\r\n getClassName(): string;\r\n\r\n /**\r\n * Gets current instance hash code\r\n * @returns the instance hash code as a number\r\n */\r\n getHashCode(): number;\r\n\r\n /**\r\n * Sets the instance coordinates in the given array from the given index.\r\n * @param array defines the source array\r\n * @param index defines the offset in source array\r\n * @returns the current instance\r\n */\r\n toArray(array: FloatArray, index?: number): this;\r\n\r\n /**\r\n * Update the current instance from an array\r\n * @param array defines the destination array\r\n * @param index defines the offset in the destination array\r\n * @returns the current instance\r\n */\r\n fromArray(array: FloatArray, index?: number): this;\r\n\r\n /**\r\n * Copy the current instance to an array\r\n * @returns a new array with the instance coordinates.\r\n */\r\n asArray(): Flatten<V>;\r\n\r\n /**\r\n * Sets the current instance coordinates with the given source coordinates\r\n * @param source defines the source instance\r\n * @returns the current updated instance\r\n */\r\n copyFrom(source: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the instance coordinates with the given floats\r\n * @returns the current updated instance\r\n */\r\n\r\n copyFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Sets the instance coordinates with the given floats\r\n * @returns the current updated instance\r\n */\r\n set(...values: Flatten<V>): this;\r\n\r\n /**\r\n * Sets the instance coordinates to the given value\r\n * @returns the current updated instance\r\n */\r\n setAll(value: number): this;\r\n\r\n /**\r\n * Add another instance with the current one\r\n * @param other defines the other instance\r\n * @returns a new instance set with the addition of the current instance and the given one coordinates\r\n */\r\n add(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the addition of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n addToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Set the instance coordinates by adding the given instance coordinates\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n addInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Adds the given coordinates to the current instance\r\n * @param floats the floats to add\r\n * @returns the current updated instance\r\n */\r\n addInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Returns a new instance set with the subtracted coordinates of other's coordinates from the current coordinates.\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n subtract(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the subtraction of the other's coordinates from the current coordinates.\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n subtractToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Sets the current instance coordinates by subtracting from it the given one coordinates\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n subtractInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Returns a new instance set with the subtraction of the given floats from the current instance coordinates\r\n * @param floats the coordinates to subtract\r\n * @returns the resulting instance\r\n */\r\n subtractFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Subtracts the given floats from the current instance coordinates and set the given instance \"result\" with this result\r\n * Note: Implementation uses array magic so types may be confusing.\r\n * @param args the coordinates to subtract with the last element as the result\r\n * @returns the result\r\n */\r\n subtractFromFloatsToRef(...args: [...Flatten<V>, this]): this;\r\n\r\n /**\r\n * Returns a new instance set with the multiplication of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n multiply(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets \"result\" coordinates with the multiplication of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n multiplyToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Multiplies in place the current instance coordinates by the given ones\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n multiplyInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Gets a new instance set with the instance coordinates multiplied by the given floats\r\n * @returns a new instance\r\n */\r\n multiplyByFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Returns a new instance set with the instance coordinates divided by the given one coordinates\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n divide(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the instance coordinates divided by the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n divideToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Divides the current instance coordinates by the given ones\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n divideInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the minmal coordinate values between its and the given instance ones.\r\n * @param other defines the other instance\r\n * @returns this current updated instance\r\n */\r\n minimizeInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the minmal coordinate values between its and the given floats.\r\n * @param floats defines the floats to compare against\r\n * @returns this current updated instance\r\n */\r\n minimizeInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Updates the current instance with the maximal coordinate values between its and the given instance ones.\r\n * @param other defines the other instance\r\n * @returns this current updated instance\r\n */\r\n maximizeInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the maximal coordinate values between its and the given floats.\r\n * @param floats defines the floats to compare against\r\n * @returns this current updated instance\r\n */\r\n maximizeInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Gets a new instance with current instance negated coordinates\r\n * @returns a new instance\r\n */\r\n negate(): this;\r\n\r\n /**\r\n * Negate this instance in place\r\n * @returns this\r\n */\r\n negateInPlace(): this;\r\n\r\n /**\r\n * Negate the current instance and stores the result in the given instance \"result\" coordinates\r\n * @param result defines the instance object where to store the result\r\n * @returns the result\r\n */\r\n negateToRef(result: this): this;\r\n\r\n /**\r\n * Multiply the instance coordinates by\r\n * @param scale defines the scaling factor\r\n * @returns the current updated instance\r\n */\r\n scaleInPlace(scale: number): this;\r\n\r\n /**\r\n * Returns a new instance scaled by \"scale\" from the current instance\r\n * @param scale defines the scaling factor\r\n * @returns a new instance\r\n */\r\n scale(scale: number): this;\r\n\r\n /**\r\n * Scale the current instance values by a factor to a given instance\r\n * @param scale defines the scale factor\r\n * @param result defines the instance object where to store the result\r\n * @returns result input\r\n */\r\n scaleToRef(scale: number, result: this): this;\r\n\r\n /**\r\n * Scale the current instance values by a factor and add the result to a given instance\r\n * @param scale defines the scale factor\r\n * @param result defines the instance object where to store the result\r\n * @returns result input\r\n */\r\n scaleAndAddToRef(scale: number, result: this): this;\r\n\r\n /**\r\n * Gets a boolean if two instances are equals\r\n * @param other defines the other instance\r\n * @returns true if the given instance coordinates strictly equal the current instance ones\r\n */\r\n equals(other: DeepImmutable<this>): boolean;\r\n\r\n /**\r\n * Gets a boolean if two instances are equals (using an epsilon value)\r\n * @param other defines the other instance\r\n * @param epsilon defines the minimal distance to consider equality\r\n * @returns true if the given instance coordinates are close to the current ones by a distance of epsilon.\r\n */\r\n equalsWithEpsilon(other: DeepImmutable<this>, epsilon?: number): boolean;\r\n\r\n /**\r\n * Returns true if the current Vectoe coordinates equals the given floats\r\n * @param floats defines the coordinates to compare against\r\n * @returns true if both instances are equal\r\n */\r\n equalsToFloats(...floats: Flatten<V>): boolean;\r\n\r\n /**\r\n * Gets a new instance from current instance floored values\r\n * eg (1.2, 2.31) returns (1, 2)\r\n * @returns a new instance\r\n */\r\n floor(): this;\r\n\r\n /**\r\n * Gets the current instance's floored values and stores them in result\r\n * @param result the instance to store the result in\r\n * @returns the result instance\r\n */\r\n floorToRef(result: this): this;\r\n\r\n /**\r\n * Gets a new instance from current instance fractional values\r\n * eg (1.2, 2.31) returns (0.2, 0.31)\r\n * @returns a new instance\r\n */\r\n fract(): this;\r\n\r\n /**\r\n * Gets the current instance's fractional values and stores them in result\r\n * @param result the instance to store the result in\r\n * @returns the result instance\r\n */\r\n fractToRef(result: this): this;\r\n\r\n /**\r\n * Gets a new instance copied from the instance\r\n * @returns a new instance\r\n */\r\n clone(): this;\r\n}\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n/**\r\n * Static side of Tensor\r\n */\r\nexport interface TensorStatic<T extends Tensor> {\r\n /**\r\n * Creates a new instance from the given coordinates\r\n */\r\n new (...coords: Flatten<TensorValue<T>>): T;\r\n\r\n /**\r\n * So [[static]].prototype has typings, instead of just any\r\n */\r\n prototype: T;\r\n\r\n /**\r\n * Returns a new instance with random values between min and max\r\n * @param min the minimum random value\r\n * @param max the maximum random value\r\n * @returns a instance with random values between min and max\r\n */\r\n Random(min?: number, max?: number): T;\r\n\r\n /**\r\n * Returns a new instance with random values between min and max\r\n * @param min the minimum random value\r\n * @param max the maximum random value\r\n * @param result the result to store the random values in\r\n * @returns the updated result instance\r\n */\r\n RandomToRef(min: number | undefined, max: number | undefined, result: T): T;\r\n\r\n /**\r\n * Gets a new instance from the given index element of the given array\r\n * @param array defines the data source\r\n * @param offset defines the offset in the data source\r\n * @returns a new instance\r\n */\r\n FromArray(array: ArrayLike<number>, offset?: number): T;\r\n\r\n /**\r\n * Sets \"result\" from the given index element of the given array\r\n * @param array defines the data source\r\n * @param offset defines the offset in the data source\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n FromArrayToRef(array: ArrayLike<number>, offset: number, result: T): T;\r\n\r\n /**\r\n * Sets the given instance \"result\" with the given floats.\r\n * @param args defines the coordinates of the source with the last paramater being the result\r\n */\r\n FromFloatsToRef(...args: [...Flatten<TensorValue<T>>, T]): T;\r\n\r\n /**\r\n * Gets the dot product of the instance \"left\" and the instance \"right\"\r\n * @param left defines first instance\r\n * @param right defines second instance\r\n * @returns the dot product (float)\r\n */\r\n Dot(left: DeepImmutable<T>, right: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Gets a new instance set with the minimal coordinate values from the \"left\" and \"right\" instances\r\n * @param left defines 1st instance\r\n * @param right defines 2nd instance\r\n * @returns a new instance\r\n */\r\n Minimize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets a new instance set with the maximal coordinate values from the \"left\" and \"right\" instances\r\n * @param left defines 1st instance\r\n * @param right defines 2nd instance\r\n * @returns a new instance\r\n */\r\n Maximize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets the distance between the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns the distance between instances\r\n */\r\n Distance(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Returns the squared distance between the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns the squared distance between instances\r\n */\r\n DistanceSquared(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Gets a new instance located at the center of the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns a new instance\r\n */\r\n Center(value1: DeepImmutable<T>, value2: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets the center of the instances \"value1\" and \"value2\" and stores the result in the instance \"ref\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @param ref defines third instance\r\n * @returns ref\r\n */\r\n CenterToRef(value1: DeepImmutable<T>, value2: DeepImmutable<T>, ref: T): T;\r\n\r\n /**\r\n * Returns a new instance set with same the coordinates than \"value\" ones if the instance \"value\" is in the square defined by \"min\" and \"max\".\r\n * If a coordinate of \"value\" is lower than \"min\" coordinates, the returned instance is given this \"min\" coordinate.\r\n * If a coordinate of \"value\" is greater than \"max\" coordinates, the returned instance is given this \"max\" coordinate\r\n * @param value defines the value to clamp\r\n * @param min defines the lower limit\r\n * @param max defines the upper limit\r\n * @returns a new instance\r\n */\r\n Clamp(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Returns a new instance set with same the coordinates than \"value\" ones if the instance \"value\" is in the square defined by \"min\" and \"max\".\r\n * If a coordinate of \"value\" is lower than \"min\" coordinates, the returned instance is given this \"min\" coordinate.\r\n * If a coordinate of \"value\" is greater than \"max\" coordinates, the returned instance is given this \"max\" coordinate\r\n * @param value defines the value to clamp\r\n * @param min defines the lower limit\r\n * @param max defines the upper limit\r\n * @param result defines the instance where to store the result\r\n * @returns the updated result instance\r\n */\r\n ClampToRef(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>, result: T): T;\r\n}\r\n/* eslint-enable @typescript-eslint/naming-convention */\r\n"]}
1
+ {"version":3,"file":"tensor.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/tensor.ts"],"names":[],"mappings":";AAkeA,wDAAwD","sourcesContent":["import type { DeepImmutable, Flatten, FloatArray, Length } from \"../types\";\r\n/**\r\n * Computes the tensor dimension of a multi-dimensional array\r\n */\r\nexport type Dimension<T> = T extends Array<infer U> ? [Length<T>, ...Dimension<U>] : T extends readonly [infer U, ...infer R] ? [Length<T>, ...Dimension<U>] : [];\r\n\r\n/**\r\n * Possible values for a Tensor\r\n */\r\nexport type TensorValue = number[] | TensorValue[];\r\n\r\n/**\r\n * Extracts the value type of a Tensor\r\n */\r\nexport type ValueOfTensor<T = unknown> = T extends Tensor<infer V> ? V : TensorValue;\r\n\r\n/**\r\n * Describes a mathematical tensor.\r\n * @see https://wikipedia.org/wiki/Tensor\r\n */\r\nexport interface Tensor<V extends TensorValue = TensorValue> {\r\n /**\r\n * An array of the size of each dimension.\r\n * For example, [3] for a Vector3 and [4,4] for a Matrix\r\n * @remarks\r\n * This is to allow implementations with using a getter\r\n */\r\n readonly dimension: Readonly<Dimension<V>>;\r\n\r\n /**\r\n * The rank of the tensor. This is the same as the length of the tensor's dimension array.\r\n * @remarks\r\n * This is to allow implementations with using a getter\r\n */\r\n readonly rank: number;\r\n\r\n /**\r\n * Gets class name\r\n * @returns the class name\r\n */\r\n\r\n getClassName(): string;\r\n\r\n /**\r\n * Gets current instance hash code\r\n * @returns the instance hash code as a number\r\n */\r\n getHashCode(): number;\r\n\r\n /**\r\n * Sets the instance coordinates in the given array from the given index.\r\n * @param array defines the source array\r\n * @param index defines the offset in source array\r\n * @returns the current instance\r\n */\r\n toArray(array: FloatArray, index?: number): this;\r\n\r\n /**\r\n * Update the current instance from an array\r\n * @param array defines the destination array\r\n * @param index defines the offset in the destination array\r\n * @returns the current instance\r\n */\r\n fromArray(array: DeepImmutable<FloatArray>, index?: number): this;\r\n\r\n /**\r\n * Copy the current instance to an array\r\n * @returns a new array with the instance coordinates.\r\n */\r\n asArray(): Flatten<V>;\r\n\r\n /**\r\n * Sets the current instance coordinates with the given source coordinates\r\n * @param source defines the source instance\r\n * @returns the current updated instance\r\n */\r\n copyFrom(source: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the instance coordinates with the given floats\r\n * @returns the current updated instance\r\n */\r\n\r\n copyFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Sets the instance coordinates with the given floats\r\n * @returns the current updated instance\r\n */\r\n set(...values: Flatten<V>): this;\r\n\r\n /**\r\n * Sets the instance coordinates to the given value\r\n * @returns the current updated instance\r\n */\r\n setAll(value: number): this;\r\n\r\n /**\r\n * Add another instance with the current one\r\n * @param other defines the other instance\r\n * @returns a new instance set with the addition of the current instance and the given one coordinates\r\n */\r\n add(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the addition of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n addToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Set the instance coordinates by adding the given instance coordinates\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n addInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Adds the given coordinates to the current instance\r\n * @param floats the floats to add\r\n * @returns the current updated instance\r\n */\r\n addInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Returns a new instance set with the subtracted coordinates of other's coordinates from the current coordinates.\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n subtract(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the subtraction of the other's coordinates from the current coordinates.\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n subtractToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Sets the current instance coordinates by subtracting from it the given one coordinates\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n subtractInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Returns a new instance set with the subtraction of the given floats from the current instance coordinates\r\n * @param floats the coordinates to subtract\r\n * @returns the resulting instance\r\n */\r\n subtractFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Subtracts the given floats from the current instance coordinates and set the given instance \"result\" with this result\r\n * Note: Implementation uses array magic so types may be confusing.\r\n * @param args the coordinates to subtract with the last element as the result\r\n * @returns the result\r\n */\r\n subtractFromFloatsToRef(...args: [...Flatten<V>, this]): this;\r\n\r\n /**\r\n * Returns a new instance set with the multiplication of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n multiply(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets \"result\" coordinates with the multiplication of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n multiplyToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Multiplies in place the current instance coordinates by the given ones\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n multiplyInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Gets a new instance set with the instance coordinates multiplied by the given floats\r\n * @returns a new instance\r\n */\r\n multiplyByFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Returns a new instance set with the instance coordinates divided by the given one coordinates\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n divide(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the instance coordinates divided by the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n divideToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Divides the current instance coordinates by the given ones\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n divideInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the minmal coordinate values between its and the given instance ones.\r\n * @param other defines the other instance\r\n * @returns this current updated instance\r\n */\r\n minimizeInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the minmal coordinate values between its and the given floats.\r\n * @param floats defines the floats to compare against\r\n * @returns this current updated instance\r\n */\r\n minimizeInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Updates the current instance with the maximal coordinate values between its and the given instance ones.\r\n * @param other defines the other instance\r\n * @returns this current updated instance\r\n */\r\n maximizeInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the maximal coordinate values between its and the given floats.\r\n * @param floats defines the floats to compare against\r\n * @returns this current updated instance\r\n */\r\n maximizeInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Gets a new instance with current instance negated coordinates\r\n * @returns a new instance\r\n */\r\n negate(): this;\r\n\r\n /**\r\n * Negate this instance in place\r\n * @returns this\r\n */\r\n negateInPlace(): this;\r\n\r\n /**\r\n * Negate the current instance and stores the result in the given instance \"result\" coordinates\r\n * @param result defines the instance object where to store the result\r\n * @returns the result\r\n */\r\n negateToRef(result: this): this;\r\n\r\n /**\r\n * Multiply the instance coordinates by\r\n * @param scale defines the scaling factor\r\n * @returns the current updated instance\r\n */\r\n scaleInPlace(scale: number): this;\r\n\r\n /**\r\n * Returns a new instance scaled by \"scale\" from the current instance\r\n * @param scale defines the scaling factor\r\n * @returns a new instance\r\n */\r\n scale(scale: number): this;\r\n\r\n /**\r\n * Scale the current instance values by a factor to a given instance\r\n * @param scale defines the scale factor\r\n * @param result defines the instance object where to store the result\r\n * @returns result input\r\n */\r\n scaleToRef(scale: number, result: this): this;\r\n\r\n /**\r\n * Scale the current instance values by a factor and add the result to a given instance\r\n * @param scale defines the scale factor\r\n * @param result defines the instance object where to store the result\r\n * @returns result input\r\n */\r\n scaleAndAddToRef(scale: number, result: this): this;\r\n\r\n /**\r\n * Gets a boolean if two instances are equals\r\n * @param other defines the other instance\r\n * @returns true if the given instance coordinates strictly equal the current instance ones\r\n */\r\n equals(other: DeepImmutable<this>): boolean;\r\n\r\n /**\r\n * Gets a boolean if two instances are equals (using an epsilon value)\r\n * @param other defines the other instance\r\n * @param epsilon defines the minimal distance to consider equality\r\n * @returns true if the given instance coordinates are close to the current ones by a distance of epsilon.\r\n */\r\n equalsWithEpsilon(other: DeepImmutable<this>, epsilon?: number): boolean;\r\n\r\n /**\r\n * Returns true if the current Vectoe coordinates equals the given floats\r\n * @param floats defines the coordinates to compare against\r\n * @returns true if both instances are equal\r\n */\r\n equalsToFloats(...floats: Flatten<V>): boolean;\r\n\r\n /**\r\n * Gets a new instance from current instance floored values\r\n * eg (1.2, 2.31) returns (1, 2)\r\n * @returns a new instance\r\n */\r\n floor(): this;\r\n\r\n /**\r\n * Gets the current instance's floored values and stores them in result\r\n * @param result the instance to store the result in\r\n * @returns the result instance\r\n */\r\n floorToRef(result: this): this;\r\n\r\n /**\r\n * Gets a new instance from current instance fractional values\r\n * eg (1.2, 2.31) returns (0.2, 0.31)\r\n * @returns a new instance\r\n */\r\n fract(): this;\r\n\r\n /**\r\n * Gets the current instance's fractional values and stores them in result\r\n * @param result the instance to store the result in\r\n * @returns the result instance\r\n */\r\n fractToRef(result: this): this;\r\n\r\n /**\r\n * Gets a new instance copied from the instance\r\n * @returns a new instance\r\n */\r\n clone(): this;\r\n}\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n/**\r\n * Static side of Tensor\r\n */\r\nexport interface TensorStatic<T extends Tensor<any[]>> {\r\n /**\r\n * Creates a new instance from the given coordinates\r\n */\r\n new (...coords: Flatten<ValueOfTensor<T>>): T;\r\n\r\n /**\r\n * So [[static]].prototype has typings, instead of just any\r\n */\r\n prototype: T;\r\n\r\n /**\r\n * Returns a new instance with random values between min and max\r\n * @param min the minimum random value\r\n * @param max the maximum random value\r\n * @returns a instance with random values between min and max\r\n */\r\n Random(min?: number, max?: number): T;\r\n\r\n /**\r\n * Returns a new instance with random values between min and max\r\n * @param min the minimum random value\r\n * @param max the maximum random value\r\n * @param result the result to store the random values in\r\n * @returns the updated result instance\r\n */\r\n RandomToRef(min: number | undefined, max: number | undefined, result: T): T;\r\n\r\n /**\r\n * Gets a new instance from the given index element of the given array\r\n * @param array defines the data source\r\n * @param offset defines the offset in the data source\r\n * @returns a new instance\r\n */\r\n FromArray(array: DeepImmutable<FloatArray>, offset?: number): T;\r\n\r\n /**\r\n * Sets \"result\" from the given index element of the given array\r\n * @param array defines the data source\r\n * @param offset defines the offset in the data source\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n FromArrayToRef(array: DeepImmutable<FloatArray>, offset: number, result: T): T;\r\n\r\n /**\r\n * Sets the given instance \"result\" with the given floats.\r\n * @param args defines the coordinates of the source with the last paramater being the result\r\n */\r\n FromFloatsToRef(...args: [...Flatten<ValueOfTensor<T>>, T]): T;\r\n\r\n /**\r\n * Gets the dot product of the instance \"left\" and the instance \"right\"\r\n * @param left defines first instance\r\n * @param right defines second instance\r\n * @returns the dot product (float)\r\n */\r\n Dot(left: DeepImmutable<T>, right: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Gets a new instance set with the minimal coordinate values from the \"left\" and \"right\" instances\r\n * @param left defines 1st instance\r\n * @param right defines 2nd instance\r\n * @returns a new instance\r\n */\r\n Minimize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets a new instance set with the maximal coordinate values from the \"left\" and \"right\" instances\r\n * @param left defines 1st instance\r\n * @param right defines 2nd instance\r\n * @returns a new instance\r\n */\r\n Maximize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets the distance between the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns the distance between instances\r\n */\r\n Distance(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Returns the squared distance between the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns the squared distance between instances\r\n */\r\n DistanceSquared(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Gets a new instance located at the center of the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns a new instance\r\n */\r\n Center(value1: DeepImmutable<T>, value2: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets the center of the instances \"value1\" and \"value2\" and stores the result in the instance \"ref\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @param ref defines third instance\r\n * @returns ref\r\n */\r\n CenterToRef(value1: DeepImmutable<T>, value2: DeepImmutable<T>, ref: T): T;\r\n\r\n /**\r\n * Returns a new instance set with same the coordinates than \"value\" ones if the instance \"value\" is in the square defined by \"min\" and \"max\".\r\n * If a coordinate of \"value\" is lower than \"min\" coordinates, the returned instance is given this \"min\" coordinate.\r\n * If a coordinate of \"value\" is greater than \"max\" coordinates, the returned instance is given this \"max\" coordinate\r\n * @param value defines the value to clamp\r\n * @param min defines the lower limit\r\n * @param max defines the upper limit\r\n * @returns a new instance\r\n */\r\n Clamp(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Returns a new instance set with same the coordinates than \"value\" ones if the instance \"value\" is in the square defined by \"min\" and \"max\".\r\n * If a coordinate of \"value\" is lower than \"min\" coordinates, the returned instance is given this \"min\" coordinate.\r\n * If a coordinate of \"value\" is greater than \"max\" coordinates, the returned instance is given this \"max\" coordinate\r\n * @param value defines the value to clamp\r\n * @param min defines the lower limit\r\n * @param max defines the upper limit\r\n * @param result defines the instance where to store the result\r\n * @returns the updated result instance\r\n */\r\n ClampToRef(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>, result: T): T;\r\n}\r\n/* eslint-enable @typescript-eslint/naming-convention */\r\n"]}
@@ -22,6 +22,18 @@ export interface IDracoCompressionConfiguration {
22
22
  * The url to the fallback JavaScript module.
23
23
  */
24
24
  fallbackUrl?: string;
25
+ /**
26
+ * Optional worker pool to use for async decoding instead of creating a new worker pool.
27
+ */
28
+ workerPool?: AutoReleaseWorkerPool;
29
+ /**
30
+ * Optional ArrayBuffer of the WebAssembly binary
31
+ */
32
+ wasmBinary?: ArrayBuffer;
33
+ /**
34
+ * The decoder module if already available.
35
+ */
36
+ jsModule?: any;
25
37
  };
26
38
  }
27
39
  /**
@@ -6,9 +6,9 @@ import { VertexBuffer } from "../buffer.js";
6
6
  import { VertexData } from "../mesh.vertexData.js";
7
7
  import { Logger } from "../../Misc/logger.js";
8
8
  import { decodeMesh, workerFunction, initializeWebWorker } from "./dracoCompressionWorker.js";
9
- function createDecoderAsync(wasmBinary) {
9
+ function createDecoderAsync(wasmBinary, jsModule) {
10
10
  return new Promise((resolve) => {
11
- DracoDecoderModule({ wasmBinary }).then((module) => {
11
+ (jsModule || DracoDecoderModule)({ wasmBinary }).then((module) => {
12
12
  resolve({ module });
13
13
  });
14
14
  });
@@ -77,28 +77,30 @@ export class DracoCompression {
77
77
  * @param numWorkers The number of workers for async operations Or an options object. Specify `0` to disable web workers and run synchronously in the current context.
78
78
  */
79
79
  constructor(numWorkers = DracoCompression.DefaultNumWorkers) {
80
+ const decoder = DracoCompression.Configuration.decoder;
80
81
  // check if the decoder binary and worker pool was injected
81
82
  // Note - it is expected that the developer checked if WebWorker, WebAssembly and the URL object are available
82
- if (typeof numWorkers === "object" && numWorkers.workerPool) {
83
+ if (decoder.workerPool || (typeof numWorkers === "object" && numWorkers.workerPool)) {
83
84
  // set the promise accordingly
84
- this._workerPoolPromise = Promise.resolve(numWorkers.workerPool);
85
+ this._workerPoolPromise = Promise.resolve(decoder.workerPool || numWorkers.workerPool);
85
86
  }
86
87
  else {
87
88
  // to avoid making big changes to the decider, if wasmBinary is provided use it in the wasmBinaryPromise
88
- const wasmBinaryProvided = typeof numWorkers === "object" && numWorkers.wasmBinary;
89
+ const wasmBinaryProvided = decoder.wasmBinary || (typeof numWorkers === "object" && numWorkers.wasmBinary);
90
+ const numberOfWorkers = typeof numWorkers === "number" ? numWorkers : numWorkers.numWorkers;
91
+ const useWorkers = numberOfWorkers && typeof Worker === "function" && typeof URL === "function";
92
+ const urlNeeded = useWorkers || (!useWorkers && !decoder.jsModule);
89
93
  // code maintained here for back-compat with no changes
90
- const decoder = DracoCompression.Configuration.decoder;
91
94
  const decoderInfo = decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object"
92
95
  ? {
93
- url: Tools.GetBabylonScriptURL(decoder.wasmUrl, true),
96
+ url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.wasmUrl, true) : "",
94
97
  wasmBinaryPromise: wasmBinaryProvided ? Promise.resolve(wasmBinaryProvided) : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(decoder.wasmBinaryUrl, true)),
95
98
  }
96
99
  : {
97
- url: Tools.GetBabylonScriptURL(decoder.fallbackUrl),
100
+ url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.fallbackUrl) : "",
98
101
  wasmBinaryPromise: Promise.resolve(undefined),
99
102
  };
100
- const numberOfWorkers = typeof numWorkers === "number" ? numWorkers : numWorkers.numWorkers;
101
- if (numberOfWorkers && typeof Worker === "function" && typeof URL === "function") {
103
+ if (useWorkers) {
102
104
  this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {
103
105
  const workerContent = `${decodeMesh}(${workerFunction})()`;
104
106
  const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
@@ -110,11 +112,15 @@ export class DracoCompression {
110
112
  }
111
113
  else {
112
114
  this._decoderModulePromise = decoderInfo.wasmBinaryPromise.then(async (decoderWasmBinary) => {
113
- if (!decoderInfo.url) {
114
- throw new Error("Draco decoder module is not available");
115
+ if (typeof DracoDecoderModule === "undefined") {
116
+ if (!decoder.jsModule) {
117
+ if (!decoderInfo.url) {
118
+ throw new Error("Draco decoder module is not available");
119
+ }
120
+ await Tools.LoadBabylonScriptAsync(decoderInfo.url);
121
+ }
115
122
  }
116
- await Tools.LoadBabylonScriptAsync(decoderInfo.url);
117
- return await createDecoderAsync(decoderWasmBinary);
123
+ return await createDecoderAsync(decoderWasmBinary, decoder.jsModule);
118
124
  });
119
125
  }
120
126
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dracoCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompression.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAoC,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAY7H,SAAS,kBAAkB,CAAC,UAAwB;IAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC/C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAgDD;;;;;;;;;;;;;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,CAAC;QAC/D,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,QAAQ,CAAC,OAAO,EAAE;YAClB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;SACzC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE;YACzC,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CACvC,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,IAAI,EACd,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EACxC,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,QAAQ,CAAC,aAAa,CACzB,CAAC;YAEF,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;SAC7C;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AA7UD;;;;;GAKG;AACW,8BAAa,GAAmC;IAC1D,OAAO,EAAE;QACL,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc,6BAA6B;QAC7D,aAAa,EAAE,GAAG,KAAK,CAAC,cAAc,0BAA0B;QAChE,WAAW,EAAE,GAAG,KAAK,CAAC,cAAc,wBAAwB;KAC/D;CACJ,CAAC;AAUF;;GAEG;AACW,kCAAiB,GAAG,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;AAW3D,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport { Geometry } from \"../geometry\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { DecoderModule } from \"draco3dgltf\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { decodeMesh, type AttributeData, type Message, workerFunction, initializeWebWorker } from \"./dracoCompressionWorker\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\ninterface MeshData {\r\n indices?: Uint16Array | Uint32Array;\r\n attributes: Array<AttributeData>;\r\n totalVertices: number;\r\n}\r\n\r\nfunction createDecoderAsync(wasmBinary?: ArrayBuffer): Promise<{ module: DecoderModule }> {\r\n return new Promise((resolve) => {\r\n DracoDecoderModule({ wasmBinary }).then((module) => {\r\n resolve({ module });\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Configuration for Draco compression\r\n */\r\nexport interface IDracoCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: {\r\n /**\r\n * The url to the WebAssembly module.\r\n */\r\n wasmUrl?: string;\r\n\r\n /**\r\n * The url to the WebAssembly binary.\r\n */\r\n wasmBinaryUrl?: string;\r\n\r\n /**\r\n * The url to the fallback JavaScript module.\r\n */\r\n fallbackUrl?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions {\r\n /**\r\n * The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n numWorkers?: number;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary.\r\n * If provided it will be used instead of loading the binary from wasmBinaryUrl.\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n /**\r\n * Optional worker pool to use for async decoding.\r\n * If provided, numWorkers will be ignored and the worker pool will be used instead.\r\n * If provided the draco script will not be loaded from the DracoConfiguration.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n}\r\n\r\n/**\r\n * Draco compression (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco module.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * DracoCompression.Configuration = {\r\n * decoder: {\r\n * wasmUrl: \"<url to the WebAssembly library>\",\r\n * wasmBinaryUrl: \"<url to the WebAssembly binary>\",\r\n * fallbackUrl: \"<url to the fallback JavaScript library>\",\r\n * }\r\n * };\r\n * ```\r\n *\r\n * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.\r\n * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.\r\n * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoCompression.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n *\r\n * @see https://playground.babylonjs.com/#DMZIBD#0\r\n */\r\nexport class DracoCompression implements IDisposable {\r\n private _workerPoolPromise?: Promise<AutoReleaseWorkerPool>;\r\n private _decoderModulePromise?: Promise<{ module: DecoderModule }>;\r\n\r\n /**\r\n * The configuration. Defaults to the following urls:\r\n * - wasmUrl: \"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js\"\r\n * - wasmBinaryUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.wasm\"\r\n * - fallbackUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.js\"\r\n */\r\n public static Configuration: IDracoCompressionConfiguration = {\r\n decoder: {\r\n wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,\r\n wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,\r\n fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,\r\n },\r\n };\r\n\r\n /**\r\n * Returns true if the decoder configuration is available.\r\n */\r\n public static get DecoderAvailable(): boolean {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\") || decoder.fallbackUrl);\r\n }\r\n\r\n /**\r\n * Default number of workers to create when creating the draco compression object.\r\n */\r\n public static DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();\r\n\r\n private static GetDefaultNumWorkers(): number {\r\n if (typeof navigator !== \"object\" || !navigator.hardwareConcurrency) {\r\n return 1;\r\n }\r\n\r\n // Use 50% of the available logical processors but capped at 4.\r\n return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);\r\n }\r\n\r\n private static _Default: Nullable<DracoCompression> = null;\r\n\r\n /**\r\n * Default instance for the draco compression object.\r\n */\r\n public static get Default(): DracoCompression {\r\n if (!DracoCompression._Default) {\r\n DracoCompression._Default = new DracoCompression();\r\n }\r\n\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param numWorkers The number of workers for async operations Or an options object. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n constructor(numWorkers: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n // check if the decoder binary and worker pool was injected\r\n // Note - it is expected that the developer checked if WebWorker, WebAssembly and the URL object are available\r\n if (typeof numWorkers === \"object\" && numWorkers.workerPool) {\r\n // set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(numWorkers.workerPool);\r\n } else {\r\n // to avoid making big changes to the decider, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = typeof numWorkers === \"object\" && numWorkers.wasmBinary;\r\n\r\n // code maintained here for back-compat with no changes\r\n const decoder = DracoCompression.Configuration.decoder;\r\n\r\n const decoderInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: Tools.GetBabylonScriptURL(decoder.wasmUrl, true),\r\n wasmBinaryPromise: wasmBinaryProvided ? Promise.resolve(wasmBinaryProvided) : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(decoder.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: Tools.GetBabylonScriptURL(decoder.fallbackUrl!),\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n\r\n const numberOfWorkers = typeof numWorkers === \"number\" ? numWorkers : numWorkers.numWorkers;\r\n if (numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\") {\r\n this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {\r\n const workerContent = `${decodeMesh}(${workerFunction})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n\r\n return new AutoReleaseWorkerPool(numberOfWorkers as number, () => {\r\n const worker = new Worker(workerBlobUrl);\r\n return initializeWebWorker(worker, decoderWasmBinary!, decoderInfo.url);\r\n });\r\n });\r\n } else {\r\n this._decoderModulePromise = decoderInfo.wasmBinaryPromise.then(async (decoderWasmBinary) => {\r\n if (!decoderInfo.url) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n\r\n await Tools.LoadBabylonScriptAsync(decoderInfo.url);\r\n return await createDecoderAsync(decoderWasmBinary as ArrayBuffer);\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n if (this._workerPoolPromise) {\r\n this._workerPoolPromise.then((workerPool) => {\r\n workerPool.dispose();\r\n });\r\n }\r\n\r\n delete this._workerPoolPromise;\r\n delete this._decoderModulePromise;\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n await this._decoderModulePromise;\r\n return;\r\n }\r\n }\r\n\r\n private _decodeMeshAsync(\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes?: { [kind: string]: number },\r\n gltfNormalizedOverride?: { [kind: string]: boolean }\r\n ): Promise<MeshData> {\r\n const dataView = data instanceof ArrayBuffer ? new Int8Array(data) : new Int8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const applyGltfNormalizedOverride = (kind: string, normalized: boolean): boolean => {\r\n if (gltfNormalizedOverride && gltfNormalizedOverride[kind] !== undefined) {\r\n if (normalized !== gltfNormalizedOverride[kind]) {\r\n Logger.Warn(\r\n `Normalized flag from Draco data (${normalized}) does not match normalized flag from glTF accessor (${gltfNormalizedOverride[kind]}). Using flag from glTF accessor.`\r\n );\r\n }\r\n\r\n return gltfNormalizedOverride[kind];\r\n } else {\r\n return normalized;\r\n }\r\n };\r\n\r\n if (this._workerPoolPromise) {\r\n return this._workerPoolPromise.then((workerPool) => {\r\n return new Promise<MeshData>((resolve, reject) => {\r\n workerPool.push((worker, onComplete) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n onComplete();\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"decodeMeshDone\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve({ indices: resultIndices!, attributes: resultAttributes, totalVertices: message.totalVertices });\r\n onComplete();\r\n break;\r\n }\r\n case \"indices\": {\r\n resultIndices = message.data;\r\n break;\r\n }\r\n case \"attribute\": {\r\n resultAttributes.push({\r\n kind: message.kind,\r\n data: message.data,\r\n size: message.size,\r\n byteOffset: message.byteOffset,\r\n byteStride: message.byteStride,\r\n normalized: applyGltfNormalizedOverride(message.kind, message.normalized),\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n const dataViewCopy = dataView.slice();\r\n worker.postMessage({ id: \"decodeMesh\", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);\r\n });\r\n });\r\n });\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n return this._decoderModulePromise.then((decoder) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const numPoints = decodeMesh(\r\n decoder.module,\r\n dataView,\r\n attributes,\r\n (indices) => {\r\n resultIndices = indices;\r\n },\r\n (kind, data, size, byteOffset, byteStride, normalized) => {\r\n resultAttributes.push({\r\n kind,\r\n data,\r\n size,\r\n byteOffset,\r\n byteStride,\r\n normalized,\r\n });\r\n }\r\n );\r\n\r\n return { indices: resultIndices!, attributes: resultAttributes, totalVertices: numPoints };\r\n });\r\n }\r\n\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon geometry.\r\n * @param name The name to use when creating the geometry\r\n * @param scene The scene to use when creating the geometry\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded geometry\r\n */\r\n public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {\r\n const meshData = await this._decodeMeshAsync(data, attributes);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /** @internal */\r\n public async _decodeMeshToGeometryForGltfAsync(\r\n name: string,\r\n scene: Scene,\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes: { [kind: string]: number },\r\n gltfNormalizedOverride: { [kind: string]: boolean }\r\n ): Promise<Geometry> {\r\n const meshData = await this._decodeMeshAsync(data, attributes, gltfNormalizedOverride);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon vertex data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded vertex data\r\n * @deprecated Use {@link decodeMeshToGeometryAsync} for better performance in some cases\r\n */\r\n public async decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<VertexData> {\r\n const meshData = await this._decodeMeshAsync(data, attributes);\r\n const vertexData = new VertexData();\r\n if (meshData.indices) {\r\n vertexData.indices = meshData.indices;\r\n }\r\n for (const attribute of meshData.attributes) {\r\n const floatData = VertexBuffer.GetFloatData(\r\n attribute.data,\r\n attribute.size,\r\n VertexBuffer.GetDataType(attribute.data),\r\n attribute.byteOffset,\r\n attribute.byteStride,\r\n attribute.normalized,\r\n meshData.totalVertices\r\n );\r\n\r\n vertexData.set(floatData, attribute.kind);\r\n }\r\n return vertexData;\r\n }\r\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AAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,QAAQ,CAAC,OAAO,EAAE;YAClB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;SACzC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE;YACzC,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CACvC,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,IAAI,EACd,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EACxC,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,QAAQ,CAAC,aAAa,CACzB,CAAC;YAEF,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;SAC7C;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AAhVD;;;;;GAKG;AACW,8BAAa,GAAmC;IAC1D,OAAO,EAAE;QACL,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc,6BAA6B;QAC7D,aAAa,EAAE,GAAG,KAAK,CAAC,cAAc,0BAA0B;QAChE,WAAW,EAAE,GAAG,KAAK,CAAC,cAAc,wBAAwB;KAC/D;CACJ,CAAC;AAUF;;GAEG;AACW,kCAAiB,GAAG,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;AAW3D,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport { Geometry } from \"../geometry\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { DecoderModule } from \"draco3dgltf\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { decodeMesh, type AttributeData, type Message, workerFunction, initializeWebWorker } from \"./dracoCompressionWorker\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\ninterface MeshData {\r\n indices?: Uint16Array | Uint32Array;\r\n attributes: Array<AttributeData>;\r\n totalVertices: number;\r\n}\r\n\r\nfunction createDecoderAsync(wasmBinary?: ArrayBuffer, jsModule?: DracoDecoderModule): Promise<{ module: DecoderModule }> {\r\n return new Promise((resolve) => {\r\n (jsModule || DracoDecoderModule)({ wasmBinary }).then((module) => {\r\n resolve({ module });\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Configuration for Draco compression\r\n */\r\nexport interface IDracoCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: {\r\n /**\r\n * The url to the WebAssembly module.\r\n */\r\n wasmUrl?: string;\r\n\r\n /**\r\n * The url to the WebAssembly binary.\r\n */\r\n wasmBinaryUrl?: string;\r\n\r\n /**\r\n * The url to the fallback JavaScript module.\r\n */\r\n fallbackUrl?: string;\r\n /**\r\n * Optional worker pool to use for async decoding instead of creating a new worker pool.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n\r\n /**\r\n * The decoder module if already available.\r\n */\r\n jsModule?: any /* DecoderModule */;\r\n };\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions {\r\n /**\r\n * The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n numWorkers?: number;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary.\r\n * If provided it will be used instead of loading the binary from wasmBinaryUrl.\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n /**\r\n * Optional worker pool to use for async decoding.\r\n * If provided, numWorkers will be ignored and the worker pool will be used instead.\r\n * If provided the draco script will not be loaded from the DracoConfiguration.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n}\r\n\r\n/**\r\n * Draco compression (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco module.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * DracoCompression.Configuration = {\r\n * decoder: {\r\n * wasmUrl: \"<url to the WebAssembly library>\",\r\n * wasmBinaryUrl: \"<url to the WebAssembly binary>\",\r\n * fallbackUrl: \"<url to the fallback JavaScript library>\",\r\n * }\r\n * };\r\n * ```\r\n *\r\n * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.\r\n * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.\r\n * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoCompression.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n *\r\n * @see https://playground.babylonjs.com/#DMZIBD#0\r\n */\r\nexport class DracoCompression implements IDisposable {\r\n private _workerPoolPromise?: Promise<AutoReleaseWorkerPool>;\r\n private _decoderModulePromise?: Promise<{ module: DecoderModule }>;\r\n\r\n /**\r\n * The configuration. Defaults to the following urls:\r\n * - wasmUrl: \"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js\"\r\n * - wasmBinaryUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.wasm\"\r\n * - fallbackUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.js\"\r\n */\r\n public static Configuration: IDracoCompressionConfiguration = {\r\n decoder: {\r\n wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,\r\n wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,\r\n fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,\r\n },\r\n };\r\n\r\n /**\r\n * Returns true if the decoder configuration is available.\r\n */\r\n public static get DecoderAvailable(): boolean {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\") || decoder.fallbackUrl);\r\n }\r\n\r\n /**\r\n * Default number of workers to create when creating the draco compression object.\r\n */\r\n public static DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();\r\n\r\n private static GetDefaultNumWorkers(): number {\r\n if (typeof navigator !== \"object\" || !navigator.hardwareConcurrency) {\r\n return 1;\r\n }\r\n\r\n // Use 50% of the available logical processors but capped at 4.\r\n return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);\r\n }\r\n\r\n private static _Default: Nullable<DracoCompression> = null;\r\n\r\n /**\r\n * Default instance for the draco compression object.\r\n */\r\n public static get Default(): DracoCompression {\r\n if (!DracoCompression._Default) {\r\n DracoCompression._Default = new DracoCompression();\r\n }\r\n\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param numWorkers The number of workers for async operations Or an options object. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n constructor(numWorkers: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n // check if the decoder binary and worker pool was injected\r\n // Note - it is expected that the developer checked if WebWorker, WebAssembly and the URL object are available\r\n if (decoder.workerPool || (typeof numWorkers === \"object\" && numWorkers.workerPool)) {\r\n // set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(decoder.workerPool || (numWorkers as IDracoCompressionOptions).workerPool!);\r\n } else {\r\n // to avoid making big changes to the decider, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = decoder.wasmBinary || (typeof numWorkers === \"object\" && numWorkers.wasmBinary);\r\n const numberOfWorkers = typeof numWorkers === \"number\" ? numWorkers : numWorkers.numWorkers;\r\n const useWorkers = numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\";\r\n const urlNeeded = useWorkers || (!useWorkers && !decoder.jsModule);\r\n // code maintained here for back-compat with no changes\r\n\r\n const decoderInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.wasmUrl, true) : \"\",\r\n wasmBinaryPromise: wasmBinaryProvided ? Promise.resolve(wasmBinaryProvided) : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(decoder.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.fallbackUrl!) : \"\",\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n if (useWorkers) {\r\n this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {\r\n const workerContent = `${decodeMesh}(${workerFunction})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n\r\n return new AutoReleaseWorkerPool(numberOfWorkers as number, () => {\r\n const worker = new Worker(workerBlobUrl);\r\n return initializeWebWorker(worker, decoderWasmBinary!, decoderInfo.url);\r\n });\r\n });\r\n } else {\r\n this._decoderModulePromise = decoderInfo.wasmBinaryPromise.then(async (decoderWasmBinary) => {\r\n if (typeof DracoDecoderModule === \"undefined\") {\r\n if (!decoder.jsModule) {\r\n if (!decoderInfo.url) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n await Tools.LoadBabylonScriptAsync(decoderInfo.url);\r\n }\r\n }\r\n return await createDecoderAsync(decoderWasmBinary as ArrayBuffer, decoder.jsModule);\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n if (this._workerPoolPromise) {\r\n this._workerPoolPromise.then((workerPool) => {\r\n workerPool.dispose();\r\n });\r\n }\r\n\r\n delete this._workerPoolPromise;\r\n delete this._decoderModulePromise;\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n await this._decoderModulePromise;\r\n return;\r\n }\r\n }\r\n\r\n private _decodeMeshAsync(\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes?: { [kind: string]: number },\r\n gltfNormalizedOverride?: { [kind: string]: boolean }\r\n ): Promise<MeshData> {\r\n const dataView = data instanceof ArrayBuffer ? new Int8Array(data) : new Int8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const applyGltfNormalizedOverride = (kind: string, normalized: boolean): boolean => {\r\n if (gltfNormalizedOverride && gltfNormalizedOverride[kind] !== undefined) {\r\n if (normalized !== gltfNormalizedOverride[kind]) {\r\n Logger.Warn(\r\n `Normalized flag from Draco data (${normalized}) does not match normalized flag from glTF accessor (${gltfNormalizedOverride[kind]}). Using flag from glTF accessor.`\r\n );\r\n }\r\n\r\n return gltfNormalizedOverride[kind];\r\n } else {\r\n return normalized;\r\n }\r\n };\r\n\r\n if (this._workerPoolPromise) {\r\n return this._workerPoolPromise.then((workerPool) => {\r\n return new Promise<MeshData>((resolve, reject) => {\r\n workerPool.push((worker, onComplete) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n onComplete();\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"decodeMeshDone\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve({ indices: resultIndices!, attributes: resultAttributes, totalVertices: message.totalVertices });\r\n onComplete();\r\n break;\r\n }\r\n case \"indices\": {\r\n resultIndices = message.data;\r\n break;\r\n }\r\n case \"attribute\": {\r\n resultAttributes.push({\r\n kind: message.kind,\r\n data: message.data,\r\n size: message.size,\r\n byteOffset: message.byteOffset,\r\n byteStride: message.byteStride,\r\n normalized: applyGltfNormalizedOverride(message.kind, message.normalized),\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n const dataViewCopy = dataView.slice();\r\n worker.postMessage({ id: \"decodeMesh\", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);\r\n });\r\n });\r\n });\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n return this._decoderModulePromise.then((decoder) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const numPoints = decodeMesh(\r\n decoder.module,\r\n dataView,\r\n attributes,\r\n (indices) => {\r\n resultIndices = indices;\r\n },\r\n (kind, data, size, byteOffset, byteStride, normalized) => {\r\n resultAttributes.push({\r\n kind,\r\n data,\r\n size,\r\n byteOffset,\r\n byteStride,\r\n normalized,\r\n });\r\n }\r\n );\r\n\r\n return { indices: resultIndices!, attributes: resultAttributes, totalVertices: numPoints };\r\n });\r\n }\r\n\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon geometry.\r\n * @param name The name to use when creating the geometry\r\n * @param scene The scene to use when creating the geometry\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded geometry\r\n */\r\n public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {\r\n const meshData = await this._decodeMeshAsync(data, attributes);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /** @internal */\r\n public async _decodeMeshToGeometryForGltfAsync(\r\n name: string,\r\n scene: Scene,\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes: { [kind: string]: number },\r\n gltfNormalizedOverride: { [kind: string]: boolean }\r\n ): Promise<Geometry> {\r\n const meshData = await this._decodeMeshAsync(data, attributes, gltfNormalizedOverride);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon vertex data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded vertex data\r\n * @deprecated Use {@link decodeMeshToGeometryAsync} for better performance in some cases\r\n */\r\n public async decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<VertexData> {\r\n const meshData = await this._decodeMeshAsync(data, attributes);\r\n const vertexData = new VertexData();\r\n if (meshData.indices) {\r\n vertexData.indices = meshData.indices;\r\n }\r\n for (const attribute of meshData.attributes) {\r\n const floatData = VertexBuffer.GetFloatData(\r\n attribute.data,\r\n attribute.size,\r\n VertexBuffer.GetDataType(attribute.data),\r\n attribute.byteOffset,\r\n attribute.byteStride,\r\n attribute.normalized,\r\n meshData.totalVertices\r\n );\r\n\r\n vertexData.set(floatData, attribute.kind);\r\n }\r\n return vertexData;\r\n }\r\n}\r\n"]}
@@ -15,6 +15,7 @@ export class GeometryDistanceBlock extends NodeGeometryBlock {
15
15
  this.registerInput("right", NodeGeometryBlockConnectionPointTypes.AutoDetect);
16
16
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Float);
17
17
  this._linkConnectionTypes(0, 1);
18
+ this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);
18
19
  this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
19
20
  this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
20
21
  this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
@@ -1 +1 @@
1
- {"version":3,"file":"geometryDistanceBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryDistanceBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBA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QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACnD,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,OAAO;SACV;QAED,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QACzC,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n\r\n/**\r\n * Block used to get the distance between 2 values\r\n */\r\nexport class GeometryDistanceBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new GeometryDistanceBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"GeometryDistanceBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left operand input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right operand input component\r\n */\r\n public get right(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this.left.isConnected || !this.right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n const left = this.left.getConnectedValue(state);\r\n const right = this.right.getConnectedValue(state);\r\n\r\n return left.subtract(right).length();\r\n };\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryDistanceBlock\", GeometryDistanceBlock);\r\n"]}
1
+ {"version":3,"file":"geometryDistanceBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryDistanceBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IACxD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC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AI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACnD,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,OAAO;SACV;QAED,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QACzC,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n\r\n/**\r\n * Block used to get the distance between 2 values\r\n */\r\nexport class GeometryDistanceBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new GeometryDistanceBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"GeometryDistanceBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left operand input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right operand input component\r\n */\r\n public get right(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this.left.isConnected || !this.right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n const left = this.left.getConnectedValue(state);\r\n const right = this.right.getConnectedValue(state);\r\n\r\n return left.subtract(right).length();\r\n };\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryDistanceBlock\", GeometryDistanceBlock);\r\n"]}
@@ -15,6 +15,7 @@ export class GeometryDotBlock extends NodeGeometryBlock {
15
15
  this.registerInput("right", NodeGeometryBlockConnectionPointTypes.AutoDetect);
16
16
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Float);
17
17
  this._linkConnectionTypes(0, 1);
18
+ this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);
18
19
  this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
19
20
  this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
20
21
  this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
@@ -1 +1 @@
1
- {"version":3,"file":"geometryDotBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryDotBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC7E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC9E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAE3E,IAAI,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAC/F,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,MAAM,CAAC,CAAC;QAChG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAC/F,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,MAAM,CAAC,CAAC;IACpG,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACnD,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,OAAO;SACV;QAED,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n\r\n/**\r\n * Block used to apply a dot product between 2 vectors\r\n */\r\nexport class GeometryDotBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new GeometryDotBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"GeometryDotBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left operand input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right operand input component\r\n */\r\n public get right(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this.left.isConnected || !this.right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n const left = this.left.getConnectedValue(state);\r\n const right = this.right.getConnectedValue(state);\r\n\r\n return left.dot(right);\r\n };\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryDotBlock\", GeometryDotBlock);\r\n"]}
1
+ {"version":3,"file":"geometryDotBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Bl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IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACnD,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,OAAO;SACV;QAED,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n\r\n/**\r\n * Block used to apply a dot product between 2 vectors\r\n */\r\nexport class GeometryDotBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new GeometryDotBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"GeometryDotBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left operand input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right operand input component\r\n */\r\n public get right(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this.left.isConnected || !this.right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n const left = this.left.getConnectedValue(state);\r\n const right = this.right.getConnectedValue(state);\r\n\r\n return left.dot(right);\r\n };\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryDotBlock\", GeometryDotBlock);\r\n"]}
@@ -13,6 +13,7 @@ export class GeometryLengthBlock extends NodeGeometryBlock {
13
13
  super(name);
14
14
  this.registerInput("value", NodeGeometryBlockConnectionPointTypes.AutoDetect);
15
15
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Float);
16
+ this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);
16
17
  this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
17
18
  this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geometryLengthBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryLengthBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC9E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAE3E,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAC/F,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,MAAM,CAAC,CAAC;IACpG,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,qBAAqB,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,OAAO;SACV;QAED,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAClD,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n/**\r\n * Block used to get the length of a vector\r\n */\r\nexport class GeometryLengthBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new GeometryLengthBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"GeometryLengthBlock\";\r\n }\r\n\r\n /**\r\n * Gets the value input component\r\n */\r\n public get value(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this.value.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n const value = this.value.getConnectedValue(state);\r\n return value.length();\r\n };\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryLengthBlock\", GeometryLengthBlock);\r\n"]}
1
+ {"version":3,"file":"geometryLengthBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryLengthBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC9E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAE3E,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,GAAG,CAAC,CAAC;QAC7F,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAC/F,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,MAAM,CAAC,CAAC;IACpG,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,qBAAqB,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,OAAO;SACV;QAED,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAClD,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n/**\r\n * Block used to get the length of a vector\r\n */\r\nexport class GeometryLengthBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new GeometryLengthBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"GeometryLengthBlock\";\r\n }\r\n\r\n /**\r\n * Gets the value input component\r\n */\r\n public get value(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this.value.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n const value = this.value.getConnectedValue(state);\r\n return value.length();\r\n };\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryLengthBlock\", GeometryLengthBlock);\r\n"]}
@@ -265,6 +265,7 @@ __decorate([
265
265
  { label: "Reciprocal", value: GeometryTrigonometryBlockOperations.Reciprocal },
266
266
  { label: "ToDegrees", value: GeometryTrigonometryBlockOperations.ToDegrees },
267
267
  { label: "ToRadians", value: GeometryTrigonometryBlockOperations.ToRadians },
268
+ { label: "Fract", value: GeometryTrigonometryBlockOperations.Fract },
268
269
  ],
269
270
  })
270
271
  ], GeometryTrigonometryBlock.prototype, "operation", void 0);