@babylonjs/core 7.1.0 → 7.2.1

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 (113) hide show
  1. package/Animations/animationGroup.d.ts +1 -1
  2. package/Animations/animationGroup.js +1 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Compute/computeEffect.d.ts +0 -1
  5. package/Compute/computeEffect.js +40 -33
  6. package/Compute/computeEffect.js.map +1 -1
  7. package/Engines/Extensions/engine.computeShader.d.ts +25 -1
  8. package/Engines/Extensions/engine.computeShader.js +1 -1
  9. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  10. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +1 -2
  11. package/Engines/WebGL/webGLRenderTargetWrapper.js +2 -3
  12. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  13. package/Engines/WebGPU/Extensions/engine.computeShader.js +22 -0
  14. package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
  15. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -3
  16. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  17. package/Engines/WebGPU/webgpuComputePipelineContext.js +4 -2
  18. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  19. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -0
  20. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +6 -1
  21. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  22. package/Engines/WebGPU/webgpuTextureManager.js +2 -2
  23. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  24. package/Engines/renderTargetWrapper.d.ts +6 -2
  25. package/Engines/renderTargetWrapper.js +9 -2
  26. package/Engines/renderTargetWrapper.js.map +1 -1
  27. package/Engines/thinEngine.js +2 -2
  28. package/Engines/thinEngine.js.map +1 -1
  29. package/Engines/webgpuEngine.js +4 -5
  30. package/Engines/webgpuEngine.js.map +1 -1
  31. package/Gizmos/axisScaleGizmo.js +6 -1
  32. package/Gizmos/axisScaleGizmo.js.map +1 -1
  33. package/Gizmos/boundingBoxGizmo.d.ts +2 -2
  34. package/Gizmos/boundingBoxGizmo.js +27 -17
  35. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  36. package/Gizmos/scaleGizmo.d.ts +6 -0
  37. package/Gizmos/scaleGizmo.js +10 -2
  38. package/Gizmos/scaleGizmo.js.map +1 -1
  39. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  40. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  41. package/Lights/Shadows/shadowGenerator.js +17 -2
  42. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  43. package/Materials/PBR/pbrBaseMaterial.js +1 -5
  44. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  45. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +0 -1
  46. package/Materials/PBR/pbrClearCoatConfiguration.js +3 -12
  47. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  48. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +1 -4
  49. package/Materials/PBR/pbrIridescenceConfiguration.js +5 -15
  50. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  51. package/Materials/PBR/pbrSheenConfiguration.d.ts +0 -1
  52. package/Materials/PBR/pbrSheenConfiguration.js +3 -12
  53. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  54. package/Materials/PBR/pbrSubSurfaceConfiguration.js +5 -17
  55. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  56. package/Materials/Textures/baseTexture.d.ts +0 -6
  57. package/Materials/Textures/baseTexture.js +0 -8
  58. package/Materials/Textures/baseTexture.js.map +1 -1
  59. package/Materials/Textures/renderTargetTexture.d.ts +2 -1
  60. package/Materials/Textures/renderTargetTexture.js +3 -2
  61. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  62. package/Materials/Textures/texture.d.ts +0 -6
  63. package/Materials/Textures/texture.js +0 -15
  64. package/Materials/Textures/texture.js.map +1 -1
  65. package/Materials/Textures/thinTexture.js +1 -1
  66. package/Materials/Textures/thinTexture.js.map +1 -1
  67. package/Maths/math.vector.d.ts +12 -0
  68. package/Maths/math.vector.js +17 -2
  69. package/Maths/math.vector.js.map +1 -1
  70. package/Maths/tensor.d.ts +13 -11
  71. package/Maths/tensor.js.map +1 -1
  72. package/Meshes/Builders/greasedLineBuilder.js +14 -0
  73. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  74. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +14 -3
  75. package/Meshes/GreasedLine/greasedLineBaseMesh.js +18 -2
  76. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  77. package/Meshes/GreasedLine/greasedLineMesh.js +3 -4
  78. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  79. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +10 -1
  80. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  81. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -0
  82. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  83. package/Physics/v2/Plugins/havokPlugin.d.ts +7 -0
  84. package/Physics/v2/Plugins/havokPlugin.js +16 -0
  85. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  86. package/Physics/v2/physicsBody.d.ts +7 -1
  87. package/Physics/v2/physicsBody.js +10 -1
  88. package/Physics/v2/physicsBody.js.map +1 -1
  89. package/Physics/v2/physicsEngineComponent.d.ts +5 -0
  90. package/Physics/v2/physicsEngineComponent.js +13 -0
  91. package/Physics/v2/physicsEngineComponent.js.map +1 -1
  92. package/Rendering/depthPeelingRenderer.js +1 -1
  93. package/Rendering/depthPeelingRenderer.js.map +1 -1
  94. package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
  95. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  96. package/Shaders/ShadersInclude/pbrBlockClearcoat.js +0 -4
  97. package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
  98. package/Shaders/ShadersInclude/pbrBlockIridescence.js +0 -3
  99. package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
  100. package/Shaders/ShadersInclude/pbrBlockSheen.js +1 -5
  101. package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
  102. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -2
  103. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
  104. package/Shaders/greasedLine.vertex.js +3 -3
  105. package/Shaders/greasedLine.vertex.js.map +1 -1
  106. package/Shaders/pbr.fragment.js +4 -4
  107. package/Shaders/pbr.fragment.js.map +1 -1
  108. package/XR/features/WebXRHandTracking.d.ts +5 -0
  109. package/XR/features/WebXRHandTracking.js +6 -0
  110. package/XR/features/WebXRHandTracking.js.map +1 -1
  111. package/XR/webXRCamera.js +4 -0
  112. package/XR/webXRCamera.js.map +1 -1
  113. package/package.json +1 -1
package/Maths/tensor.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DeepImmutable, Flatten, FloatArray, Length } from "../types";
1
+ import type { DeepImmutable, Flatten, FloatArray, Length, Tuple } from "../types";
2
2
  /**
3
3
  * Computes the tensor dimension of a multi-dimensional array
4
4
  */
@@ -11,6 +11,7 @@ export type TensorValue = number[] | TensorValue[];
11
11
  * Extracts the value type of a Tensor
12
12
  */
13
13
  export type ValueOfTensor<T = unknown> = T extends Tensor<infer V> ? V : TensorValue;
14
+ type TensorNumberArray<V extends TensorValue> = Length<Dimension<V>> extends 2 ? Tuple<number, 16> : V;
14
15
  /**
15
16
  * Describes a mathematical tensor.
16
17
  * @see https://wikipedia.org/wiki/Tensor
@@ -57,7 +58,7 @@ export interface Tensor<V extends TensorValue = TensorValue> {
57
58
  * Copy the current instance to an array
58
59
  * @returns a new array with the instance coordinates.
59
60
  */
60
- asArray(): Flatten<V>;
61
+ asArray(): TensorNumberArray<V>;
61
62
  /**
62
63
  * Sets the current instance coordinates with the given source coordinates
63
64
  * @param source defines the source instance
@@ -68,12 +69,12 @@ export interface Tensor<V extends TensorValue = TensorValue> {
68
69
  * Sets the instance coordinates with the given floats
69
70
  * @returns the current updated instance
70
71
  */
71
- copyFromFloats(...floats: Flatten<V>): this;
72
+ copyFromFloats(...floats: TensorNumberArray<V>): this;
72
73
  /**
73
74
  * Sets the instance coordinates with the given floats
74
75
  * @returns the current updated instance
75
76
  */
76
- set(...values: Flatten<V>): this;
77
+ set(...values: TensorNumberArray<V>): this;
77
78
  /**
78
79
  * Sets the instance coordinates to the given value
79
80
  * @returns the current updated instance
@@ -103,7 +104,7 @@ export interface Tensor<V extends TensorValue = TensorValue> {
103
104
  * @param floats the floats to add
104
105
  * @returns the current updated instance
105
106
  */
106
- addInPlaceFromFloats(...floats: Flatten<V>): this;
107
+ addInPlaceFromFloats(...floats: TensorNumberArray<V>): this;
107
108
  /**
108
109
  * Returns a new instance set with the subtracted coordinates of other's coordinates from the current coordinates.
109
110
  * @param other defines the other instance
@@ -128,14 +129,14 @@ export interface Tensor<V extends TensorValue = TensorValue> {
128
129
  * @param floats the coordinates to subtract
129
130
  * @returns the resulting instance
130
131
  */
131
- subtractFromFloats(...floats: Flatten<V>): this;
132
+ subtractFromFloats(...floats: TensorNumberArray<V>): this;
132
133
  /**
133
134
  * Subtracts the given floats from the current instance coordinates and set the given instance "result" with this result
134
135
  * Note: Implementation uses array magic so types may be confusing.
135
136
  * @param args the coordinates to subtract with the last element as the result
136
137
  * @returns the result
137
138
  */
138
- subtractFromFloatsToRef(...args: [...Flatten<V>, this]): this;
139
+ subtractFromFloatsToRef(...args: [...TensorNumberArray<V>, this]): this;
139
140
  /**
140
141
  * Returns a new instance set with the multiplication of the current instance and the given one coordinates
141
142
  * @param other defines the other instance
@@ -159,7 +160,7 @@ export interface Tensor<V extends TensorValue = TensorValue> {
159
160
  * Gets a new instance set with the instance coordinates multiplied by the given floats
160
161
  * @returns a new instance
161
162
  */
162
- multiplyByFloats(...floats: Flatten<V>): this;
163
+ multiplyByFloats(...floats: TensorNumberArray<V>): this;
163
164
  /**
164
165
  * Returns a new instance set with the instance coordinates divided by the given one coordinates
165
166
  * @param other defines the other instance
@@ -190,7 +191,7 @@ export interface Tensor<V extends TensorValue = TensorValue> {
190
191
  * @param floats defines the floats to compare against
191
192
  * @returns this current updated instance
192
193
  */
193
- minimizeInPlaceFromFloats(...floats: Flatten<V>): this;
194
+ minimizeInPlaceFromFloats(...floats: TensorNumberArray<V>): this;
194
195
  /**
195
196
  * Updates the current instance with the maximal coordinate values between its and the given instance ones.
196
197
  * @param other defines the other instance
@@ -202,7 +203,7 @@ export interface Tensor<V extends TensorValue = TensorValue> {
202
203
  * @param floats defines the floats to compare against
203
204
  * @returns this current updated instance
204
205
  */
205
- maximizeInPlaceFromFloats(...floats: Flatten<V>): this;
206
+ maximizeInPlaceFromFloats(...floats: TensorNumberArray<V>): this;
206
207
  /**
207
208
  * Gets a new instance with current instance negated coordinates
208
209
  * @returns a new instance
@@ -263,7 +264,7 @@ export interface Tensor<V extends TensorValue = TensorValue> {
263
264
  * @param floats defines the coordinates to compare against
264
265
  * @returns true if both instances are equal
265
266
  */
266
- equalsToFloats(...floats: Flatten<V>): boolean;
267
+ equalsToFloats(...floats: TensorNumberArray<V>): boolean;
267
268
  /**
268
269
  * Gets a new instance from current instance floored values
269
270
  * eg (1.2, 2.31) returns (1, 2)
@@ -413,3 +414,4 @@ export interface TensorStatic<T extends Tensor<any[]>> {
413
414
  */
414
415
  ClampToRef(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>, result: T): T;
415
416
  }
417
+ export {};
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"tensor.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/tensor.ts"],"names":[],"mappings":";AAoeA,wDAAwD","sourcesContent":["import type { DeepImmutable, Flatten, FloatArray, Length, Tuple } 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\ntype TensorNumberArray<V extends TensorValue> = Length<Dimension<V>> extends 2 ? Tuple<number, 16> : V;\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(): TensorNumberArray<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: TensorNumberArray<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: TensorNumberArray<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: TensorNumberArray<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: TensorNumberArray<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: [...TensorNumberArray<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: TensorNumberArray<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: TensorNumberArray<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: TensorNumberArray<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: TensorNumberArray<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"]}
@@ -190,6 +190,7 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
190
190
  instance.addPoints(allPoints, initialGreasedLineOptions);
191
191
  }
192
192
  else {
193
+ // add widths
193
194
  const currentWidths = instance.widths;
194
195
  if (currentWidths) {
195
196
  const newWidths = currentWidths.slice();
@@ -202,6 +203,19 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
202
203
  instance.widths = widths;
203
204
  }
204
205
  instance.addPoints(allPoints);
206
+ // add UVs
207
+ if (options.uvs) {
208
+ const currentUVs = instance.uvs;
209
+ if (currentUVs) {
210
+ const newUVs = new Float32Array(currentUVs.length + options.uvs.length);
211
+ newUVs.set(currentUVs, 0);
212
+ newUVs.set(options.uvs, currentUVs.length);
213
+ instance.uvs = newUVs;
214
+ }
215
+ else {
216
+ instance.uvs = options.uvs;
217
+ }
218
+ }
205
219
  }
206
220
  }
207
221
  // add colors
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,kCAAkC,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjJ,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAC;AACxG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AAEtG;;;GAGG;AACH,MAAM,CAAN,IAAY,gCAyBX;AAzBD,WAAY,gCAAgC;IACxC;;OAEG;IACH,6HAA2B,CAAA;IAC3B;;OAEG;IACH,iIAA6B,CAAA;IAC7B;;OAEG;IACH,6HAA2B,CAAA;IAC3B;;OAEG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,CAAC,CAAC;gBAE3B,CAAC,IAAI,iBAAiB,CAAC;aAC1B;SACJ;aAAM,IAAI,iBAAiB,KAAK,gCAAgC,CAAC,uBAAuB,EAAE;YACvF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9B;SACJ;KACJ;SAAM;QACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;YACjC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9B;KACJ;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n let length = 0;\r\n if (Array.isArray(allPoints[0])) {\r\n allPoints.forEach((points) => {\r\n length += points.length / 3;\r\n });\r\n }\r\n\r\n const widths = CompleteGreasedLineWidthTable(length, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(length, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n const currentWidths = instance.widths;\r\n\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n instance.addPoints(allPoints);\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
1
+ {"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,kCAAkC,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjJ,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAE,2BAA2B,EAAE,M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,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9B;KACJ;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n let length = 0;\r\n if (Array.isArray(allPoints[0])) {\r\n allPoints.forEach((points) => {\r\n length += points.length / 3;\r\n });\r\n }\r\n\r\n const widths = CompleteGreasedLineWidthTable(length, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(length, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n // add widths\r\n const currentWidths = instance.widths;\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n\r\n instance.addPoints(allPoints);\r\n\r\n // add UVs\r\n if (options.uvs) {\r\n const currentUVs = instance.uvs;\r\n if (currentUVs) {\r\n const newUVs = new Float32Array(currentUVs.length + options.uvs.length);\r\n newUVs.set(currentUVs, 0);\r\n newUVs.set(options.uvs, currentUVs.length);\r\n instance.uvs = newUVs;\r\n } else {\r\n instance.uvs = options.uvs;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
@@ -29,12 +29,14 @@ export declare enum GreasedLineRibbonFacesMode {
29
29
  * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.
30
30
  * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.
31
31
  * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.
32
+ * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.
32
33
  * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.
33
34
  */
34
35
  export declare enum GreasedLineRibbonAutoDirectionMode {
35
36
  AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,
36
37
  AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,
37
38
  AUTO_DIRECTIONS_ENHANCED = 2,
39
+ AUTO_DIRECTIONS_FACE_TO = 3,
38
40
  AUTO_DIRECTIONS_NONE = 99
39
41
  }
40
42
  export type GreasedLineRibbonOptions = {
@@ -83,7 +85,7 @@ export interface GreasedLineMeshOptions {
83
85
  */
84
86
  points: GreasedLinePoints;
85
87
  /**
86
- * Each line segmment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.
88
+ * Each line segment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.
87
89
  * Defaults to empty array.
88
90
  */
89
91
  widths?: number[];
@@ -100,7 +102,7 @@ export interface GreasedLineMeshOptions {
100
102
  /**
101
103
  * UVs for the mesh
102
104
  */
103
- uvs?: number[];
105
+ uvs?: FloatArray;
104
106
  /**
105
107
  * If true, offsets and widths are updatable.
106
108
  * Defaults to false.
@@ -164,11 +166,20 @@ export declare abstract class GreasedLineBaseMesh extends Mesh {
164
166
  */
165
167
  dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
166
168
  /**
167
- *
168
169
  * @returns true if the mesh was created in lazy mode
169
170
  */
170
171
  isLazy(): boolean;
171
172
  /**
173
+ * Returns the UVs
174
+ */
175
+ get uvs(): FloatArray;
176
+ /**
177
+ * Sets the UVs
178
+ * @param uvs the UVs
179
+ */
180
+ set uvs(uvs: FloatArray);
181
+ /**
182
+ * Returns the points offsets
172
183
  * Return the points offsets
173
184
  */
174
185
  get offsets(): number[];
@@ -29,6 +29,7 @@ export var GreasedLineRibbonFacesMode;
29
29
  * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.
30
30
  * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.
31
31
  * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.
32
+ * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.
32
33
  * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.
33
34
  */
34
35
  export var GreasedLineRibbonAutoDirectionMode;
@@ -36,6 +37,7 @@ export var GreasedLineRibbonAutoDirectionMode;
36
37
  GreasedLineRibbonAutoDirectionMode[GreasedLineRibbonAutoDirectionMode["AUTO_DIRECTIONS_FROM_FIRST_SEGMENT"] = 0] = "AUTO_DIRECTIONS_FROM_FIRST_SEGMENT";
37
38
  GreasedLineRibbonAutoDirectionMode[GreasedLineRibbonAutoDirectionMode["AUTO_DIRECTIONS_FROM_ALL_SEGMENTS"] = 1] = "AUTO_DIRECTIONS_FROM_ALL_SEGMENTS";
38
39
  GreasedLineRibbonAutoDirectionMode[GreasedLineRibbonAutoDirectionMode["AUTO_DIRECTIONS_ENHANCED"] = 2] = "AUTO_DIRECTIONS_ENHANCED";
40
+ GreasedLineRibbonAutoDirectionMode[GreasedLineRibbonAutoDirectionMode["AUTO_DIRECTIONS_FACE_TO"] = 3] = "AUTO_DIRECTIONS_FACE_TO";
39
41
  GreasedLineRibbonAutoDirectionMode[GreasedLineRibbonAutoDirectionMode["AUTO_DIRECTIONS_NONE"] = 99] = "AUTO_DIRECTIONS_NONE";
40
42
  })(GreasedLineRibbonAutoDirectionMode || (GreasedLineRibbonAutoDirectionMode = {}));
41
43
  /**
@@ -109,13 +111,27 @@ export class GreasedLineBaseMesh extends Mesh {
109
111
  super.dispose(doNotRecurse, disposeMaterialAndTextures);
110
112
  }
111
113
  /**
112
- *
113
114
  * @returns true if the mesh was created in lazy mode
114
115
  */
115
116
  isLazy() {
116
117
  return this._lazy;
117
118
  }
118
119
  /**
120
+ * Returns the UVs
121
+ */
122
+ get uvs() {
123
+ return this._uvs;
124
+ }
125
+ /**
126
+ * Sets the UVs
127
+ * @param uvs the UVs
128
+ */
129
+ set uvs(uvs) {
130
+ this._uvs = uvs instanceof Float32Array ? uvs : new Float32Array(uvs);
131
+ this._createVertexBuffers();
132
+ }
133
+ /**
134
+ * Returns the points offsets
119
135
  * Return the points offsets
120
136
  */
121
137
  get offsets() {
@@ -211,7 +227,7 @@ export class GreasedLineBaseMesh extends Mesh {
211
227
  colorPointers: this._colorPointers,
212
228
  lazy: this._lazy,
213
229
  updatable: this._updatable,
214
- uvs: this._uvs instanceof Float32Array ? Array.from(this._uvs) : this._uvs,
230
+ uvs: this._uvs,
215
231
  widths: this._widths,
216
232
  ribbonOptions: this._options.ribbonOptions,
217
233
  };
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineBaseMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GreasedLine/greasedLineBaseMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAIlG;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACnC,yGAAsB,CAAA;IACtB,uGAAqB,CAAA;AACzB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IAClC,iHAA2B,CAAA;IAC3B,yJAA+C,CAAA;IAC/C,iHAA2B,CAAA;AAC/B,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AAED;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,kCAKX;AALD,WAAY,kCAAkC;IAC1C,uJAAsC,CAAA;IACtC,qJAAqC,CAAA;IACrC,mIAA4B,CAAA;IAC5B,4HAAyB,CAAA;AAC7B,CAAC,EALW,kCAAkC,KAAlC,kCAAkC,QAK7C;AAs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Ac,GAAG,KAAK;QACjD,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC7C,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QACnC,UAAU,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,IAAI,cAAc,EAAE;YAChB,UAAU,CAAC,OAAO,GAAG,EAAE,CAAC;YACxB,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;SACvF;QACD,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,UAAU,CAAC;IACtB,CAAC;IAES,oBAAoB,CAAC,OAAiB;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAEvC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IGreasedLineMaterial } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\nimport type { FloatArray, IndicesArray } from \"../../types\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segmment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: number[];\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: FloatArray;\r\n protected _indices: IndicesArray;\r\n protected _uvs: FloatArray;\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: Engine;\r\n\r\n constructor(\r\n public readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public addPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n for (const p of points) {\r\n this._points.push(p);\r\n }\r\n\r\n if (!this._lazy) {\r\n this.setPoints(this._points, options);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the line and it's resources\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false) {\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Return the points offsets\r\n */\r\n get offsets() {\r\n return this._offsets;\r\n }\r\n\r\n /**\r\n * Sets point offests\r\n * @param offsets offset table [x,y,z, x,y,z, ....]\r\n */\r\n set offsets(offsets: number[]) {\r\n this._offsets = offsets;\r\n if (!this._offsetsBuffer) {\r\n this._createOffsetsBuffer(offsets);\r\n } else {\r\n this._offsetsBuffer.update(offsets);\r\n }\r\n }\r\n\r\n /**\r\n * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]\r\n */\r\n get widths() {\r\n return this._widths;\r\n }\r\n\r\n /**\r\n * Sets widths at each line point\r\n * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]\r\n */\r\n set widths(widths: number[]) {\r\n this._widths = widths;\r\n if (!this._lazy) {\r\n this._widthsBuffer && this._widthsBuffer.update(widths);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors\r\n */\r\n get colorPointers() {\r\n return this._colorPointers;\r\n }\r\n\r\n /**\r\n * Sets the color pointer\r\n * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.\r\n */\r\n set colorPointers(colorPointers: number[]) {\r\n this._colorPointers = colorPointers;\r\n if (!this._lazy) {\r\n this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the pluginMaterial associated with line\r\n */\r\n get greasedLineMaterial(): IGreasedLineMaterial | undefined {\r\n if (this.material && this.material instanceof GreasedLineSimpleMaterial) {\r\n return this.material;\r\n }\r\n const materialPlugin = this.material?.pluginManager?.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);\r\n if (materialPlugin) {\r\n return <GreasedLinePluginMaterial>materialPlugin;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * Return copy the points.\r\n */\r\n get points() {\r\n const pointsCopy: number[][] = [];\r\n DeepCopier.DeepCopy(this._points, pointsCopy);\r\n return pointsCopy;\r\n }\r\n\r\n /**\r\n * Sets line points and rerenders the line.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public setPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n this._points = points;\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs instanceof Float32Array ? Array.from(this._uvs) : this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"greasedLineBaseMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GreasedLine/greasedLineBaseMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MA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Ac,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;SACvF;QACD,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,UAAU,CAAC;IACtB,CAAC;IAES,oBAAoB,CAAC,OAAiB;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAEvC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IGreasedLineMaterial } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\nimport type { FloatArray, IndicesArray } from \"../../types\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_FACE_TO = 3,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: FloatArray;\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: FloatArray;\r\n protected _indices: IndicesArray;\r\n protected _uvs: FloatArray;\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: Engine;\r\n\r\n constructor(\r\n public readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public addPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n for (const p of points) {\r\n this._points.push(p);\r\n }\r\n\r\n if (!this._lazy) {\r\n this.setPoints(this._points, options);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the line and it's resources\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false) {\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Returns the UVs\r\n */\r\n get uvs() {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Sets the UVs\r\n * @param uvs the UVs\r\n */\r\n set uvs(uvs: FloatArray) {\r\n this._uvs = uvs instanceof Float32Array ? uvs : new Float32Array(uvs);\r\n this._createVertexBuffers();\r\n }\r\n\r\n /**\r\n * Returns the points offsets\r\n * Return the points offsets\r\n */\r\n get offsets() {\r\n return this._offsets;\r\n }\r\n\r\n /**\r\n * Sets point offests\r\n * @param offsets offset table [x,y,z, x,y,z, ....]\r\n */\r\n set offsets(offsets: number[]) {\r\n this._offsets = offsets;\r\n if (!this._offsetsBuffer) {\r\n this._createOffsetsBuffer(offsets);\r\n } else {\r\n this._offsetsBuffer.update(offsets);\r\n }\r\n }\r\n\r\n /**\r\n * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]\r\n */\r\n get widths() {\r\n return this._widths;\r\n }\r\n\r\n /**\r\n * Sets widths at each line point\r\n * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]\r\n */\r\n set widths(widths: number[]) {\r\n this._widths = widths;\r\n if (!this._lazy) {\r\n this._widthsBuffer && this._widthsBuffer.update(widths);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors\r\n */\r\n get colorPointers() {\r\n return this._colorPointers;\r\n }\r\n\r\n /**\r\n * Sets the color pointer\r\n * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.\r\n */\r\n set colorPointers(colorPointers: number[]) {\r\n this._colorPointers = colorPointers;\r\n if (!this._lazy) {\r\n this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the pluginMaterial associated with line\r\n */\r\n get greasedLineMaterial(): IGreasedLineMaterial | undefined {\r\n if (this.material && this.material instanceof GreasedLineSimpleMaterial) {\r\n return this.material;\r\n }\r\n const materialPlugin = this.material?.pluginManager?.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);\r\n if (materialPlugin) {\r\n return <GreasedLinePluginMaterial>materialPlugin;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * Return copy the points.\r\n */\r\n get points() {\r\n const pointsCopy: number[][] = [];\r\n DeepCopier.DeepCopy(this._points, pointsCopy);\r\n return pointsCopy;\r\n }\r\n\r\n /**\r\n * Sets line points and rerenders the line.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public setPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n this._points = points;\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}