@babylonjs/core 7.0.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.d.ts +1 -1
- package/Animations/animationGroup.js +1 -1
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/runtimeAnimation.js +10 -3
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Compute/computeEffect.d.ts +3 -4
- package/Compute/computeEffect.js +40 -33
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.d.ts +2 -2
- package/Compute/computeShader.js.map +1 -1
- package/Engines/Extensions/engine.computeShader.d.ts +27 -3
- package/Engines/Extensions/engine.computeShader.js +1 -1
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +1 -1
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +12 -2
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +1 -2
- package/Engines/WebGL/webGLRenderTargetWrapper.js +2 -3
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js +22 -0
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuClearQuad.d.ts +2 -2
- package/Engines/WebGPU/webgpuClearQuad.js +8 -3
- package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
- package/Engines/WebGPU/webgpuComputePipelineContext.js +4 -2
- package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +1 -0
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.js +15 -0
- package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +10 -2
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +7 -7
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/nativeEngine.d.ts +1 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +14 -2
- package/Engines/renderTargetWrapper.js +23 -3
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +3 -7
- package/Engines/thinEngine.js +23 -9
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +2 -2
- package/Engines/webgpuEngine.js +19 -9
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +6 -1
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +2 -2
- package/Gizmos/boundingBoxGizmo.js +27 -17
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +6 -0
- package/Gizmos/scaleGizmo.js +10 -2
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +17 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +5 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.d.ts +2 -15
- package/Materials/Node/Blocks/addBlock.js +4 -32
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/baseMathBlock.d.ts +26 -0
- package/Materials/Node/Blocks/baseMathBlock.js +84 -0
- package/Materials/Node/Blocks/baseMathBlock.js.map +1 -0
- package/Materials/Node/Blocks/divideBlock.d.ts +2 -15
- package/Materials/Node/Blocks/divideBlock.js +4 -32
- package/Materials/Node/Blocks/divideBlock.js.map +1 -1
- package/Materials/Node/Blocks/multiplyBlock.d.ts +2 -15
- package/Materials/Node/Blocks/multiplyBlock.js +4 -32
- package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/subtractBlock.d.ts +2 -15
- package/Materials/Node/Blocks/subtractBlock.js +4 -32
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +4 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +7 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -5
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.d.ts +0 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js +3 -12
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.d.ts +1 -4
- package/Materials/PBR/pbrIridescenceConfiguration.js +5 -15
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.d.ts +0 -1
- package/Materials/PBR/pbrSheenConfiguration.js +3 -12
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +5 -17
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +0 -6
- package/Materials/Textures/baseTexture.js +0 -8
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +8 -24
- package/Materials/Textures/renderTargetTexture.js +13 -8
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +5 -8
- package/Materials/Textures/texture.js +10 -20
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/textureCreationOptions.d.ts +1 -0
- package/Materials/Textures/textureCreationOptions.js.map +1 -1
- package/Materials/Textures/thinTexture.js +1 -1
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Materials/effect.d.ts +3 -3
- package/Materials/effect.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +3 -3
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.d.ts +12 -0
- package/Maths/math.vector.js +17 -2
- package/Maths/math.vector.js.map +1 -1
- package/Maths/tensor.d.ts +13 -11
- package/Maths/tensor.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +14 -0
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/Builders/ribbonBuilder.js +32 -28
- package/Meshes/Builders/ribbonBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +18 -6
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +17 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.d.ts +0 -2
- package/Meshes/GreasedLine/greasedLineMesh.js +84 -77
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +19 -4
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.d.ts +6 -0
- package/Meshes/Node/Blocks/mathBlock.js +95 -23
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +4 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +7 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +6 -0
- package/Misc/greasedLineTools.js +21 -0
- package/Misc/greasedLineTools.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js +1 -1
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/reflectiveShadowMap.js +1 -1
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js +0 -4
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockIridescence.js +0 -3
- package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSheen.js +1 -5
- package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +2 -0
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -2
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/greasedLine.vertex.js +3 -3
- package/Shaders/greasedLine.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +4 -4
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/clearQuad.fragment.js +11 -0
- package/ShadersWGSL/clearQuad.fragment.js.map +1 -0
- package/ShadersWGSL/clearQuad.vertex.js +22 -0
- package/ShadersWGSL/clearQuad.vertex.js.map +1 -0
- package/XR/features/WebXRHandTracking.d.ts +5 -0
- package/XR/features/WebXRHandTracking.js +6 -0
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/node.js +1 -6
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/Shaders/clearQuad.fragment.js +0 -10
- package/Shaders/clearQuad.fragment.js.map +0 -1
- package/Shaders/clearQuad.vertex.js +0 -19
- package/Shaders/clearQuad.vertex.js.map +0 -1
- /package/{Shaders → ShadersWGSL}/clearQuad.fragment.d.ts +0 -0
- /package/{Shaders → ShadersWGSL}/clearQuad.vertex.d.ts +0 -0
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():
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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: [...
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 {};
|
package/Maths/tensor.js.map
CHANGED
|
@@ -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,yBAAy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C,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE3B,CAAC,EAAE,CAAC;gBAEJ,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE;oBACrB,CAAC,GAAG,CAAC,CAAC;iBACT;aACJ;SACJ;aAAM,IAAI,iBAAiB,KAAK,gCAAgC,CAAC,uBAAuB,EAAE;YACvF,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAExB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,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":"greas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AAU,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAExB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,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 // 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"]}
|
|
@@ -56,15 +56,16 @@ export function CreateRibbonVertexData(options) {
|
|
|
56
56
|
// positions and horizontal distances (u)
|
|
57
57
|
let idc = 0;
|
|
58
58
|
const closePathCorr = closePath ? 1 : 0; // the final index will be +1 if closePath
|
|
59
|
+
const closeArrayCorr = closeArray ? 1 : 0;
|
|
59
60
|
let path;
|
|
60
61
|
let l;
|
|
61
62
|
minlg = pathArray[0].length;
|
|
62
63
|
let vectlg;
|
|
63
64
|
let dist;
|
|
64
|
-
for (p = 0; p < pathArray.length; p++) {
|
|
65
|
+
for (p = 0; p < pathArray.length + closeArrayCorr; p++) {
|
|
65
66
|
uTotalDistance[p] = 0;
|
|
66
67
|
us[p] = [0];
|
|
67
|
-
path = pathArray[p];
|
|
68
|
+
path = p === pathArray.length ? pathArray[0] : pathArray[p];
|
|
68
69
|
l = path.length;
|
|
69
70
|
minlg = minlg < l ? minlg : l;
|
|
70
71
|
j = 0;
|
|
@@ -99,9 +100,9 @@ export function CreateRibbonVertexData(options) {
|
|
|
99
100
|
for (i = 0; i < minlg + closePathCorr; i++) {
|
|
100
101
|
vTotalDistance[i] = 0;
|
|
101
102
|
vs[i] = [0];
|
|
102
|
-
for (p = 0; p < pathArray.length - 1; p++) {
|
|
103
|
+
for (p = 0; p < pathArray.length - 1 + closeArrayCorr; p++) {
|
|
103
104
|
path1 = pathArray[p];
|
|
104
|
-
path2 = pathArray[p + 1];
|
|
105
|
+
path2 = p === pathArray.length - 1 ? pathArray[0] : pathArray[p + 1];
|
|
105
106
|
if (i === minlg) {
|
|
106
107
|
// closePath
|
|
107
108
|
vertex1 = path1[0];
|
|
@@ -116,17 +117,6 @@ export function CreateRibbonVertexData(options) {
|
|
|
116
117
|
vs[i].push(dist);
|
|
117
118
|
vTotalDistance[i] = dist;
|
|
118
119
|
}
|
|
119
|
-
if (closeArray && vertex2 && vertex1) {
|
|
120
|
-
path1 = pathArray[p];
|
|
121
|
-
path2 = pathArray[0];
|
|
122
|
-
if (i === minlg) {
|
|
123
|
-
// closePath
|
|
124
|
-
vertex2 = path2[0];
|
|
125
|
-
}
|
|
126
|
-
vectlg = vertex2.subtract(vertex1).length();
|
|
127
|
-
dist = vectlg + vTotalDistance[i];
|
|
128
|
-
vTotalDistance[i] = dist;
|
|
129
|
-
}
|
|
130
120
|
}
|
|
131
121
|
// uvs
|
|
132
122
|
let u;
|
|
@@ -137,7 +127,7 @@ export function CreateRibbonVertexData(options) {
|
|
|
137
127
|
}
|
|
138
128
|
}
|
|
139
129
|
else {
|
|
140
|
-
for (p = 0; p < pathArray.length; p++) {
|
|
130
|
+
for (p = 0; p < pathArray.length + closeArrayCorr; p++) {
|
|
141
131
|
for (i = 0; i < minlg + closePathCorr; i++) {
|
|
142
132
|
u = uTotalDistance[p] != 0.0 ? us[p][i] / uTotalDistance[p] : 0.0;
|
|
143
133
|
v = vTotalDistance[i] != 0.0 ? vs[i][p] / vTotalDistance[i] : 0.0;
|
|
@@ -157,7 +147,7 @@ export function CreateRibbonVertexData(options) {
|
|
|
157
147
|
let l2 = lg[p + 1] - 1; // path2 length
|
|
158
148
|
let min = l1 < l2 ? l1 : l2; // current path stop index
|
|
159
149
|
let shft = idx[1] - idx[0]; // shift
|
|
160
|
-
const path1nb =
|
|
150
|
+
const path1nb = lg.length - 1; // number of path1 to iterate on
|
|
161
151
|
while (pi <= min && p < path1nb) {
|
|
162
152
|
// stay under min and don't go over next to last path
|
|
163
153
|
// draw two triangles between path1 (p1) and path2 (p2) : (p1.pi, p2.pi, p1.pi+1) and (p2.pi+1, p1.pi+1, p2.pi) clockwise
|
|
@@ -167,17 +157,9 @@ export function CreateRibbonVertexData(options) {
|
|
|
167
157
|
if (pi === min) {
|
|
168
158
|
// if end of one of two consecutive paths reached, go to next existing path
|
|
169
159
|
p++;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
l1 = lg[p] - 1;
|
|
174
|
-
l2 = lg[0] - 1;
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
shft = idx[p + 1] - idx[p];
|
|
178
|
-
l1 = lg[p] - 1;
|
|
179
|
-
l2 = lg[p + 1] - 1;
|
|
180
|
-
}
|
|
160
|
+
shft = idx[p + 1] - idx[p];
|
|
161
|
+
l1 = lg[p] - 1;
|
|
162
|
+
l2 = lg[p + 1] - 1;
|
|
181
163
|
pi = idx[p];
|
|
182
164
|
min = l1 < l2 ? l1 + pi : l2 + pi;
|
|
183
165
|
}
|
|
@@ -199,9 +181,31 @@ export function CreateRibbonVertexData(options) {
|
|
|
199
181
|
normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
|
|
200
182
|
normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
|
|
201
183
|
normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
|
|
184
|
+
const l = Math.sqrt(normals[indexFirst] * normals[indexFirst] + normals[indexFirst + 1] * normals[indexFirst + 1] + normals[indexFirst + 2] * normals[indexFirst + 2]);
|
|
185
|
+
normals[indexFirst] /= l;
|
|
186
|
+
normals[indexFirst + 1] /= l;
|
|
187
|
+
normals[indexFirst + 2] /= l;
|
|
188
|
+
normals[indexLast] = normals[indexFirst];
|
|
189
|
+
normals[indexLast + 1] = normals[indexFirst + 1];
|
|
190
|
+
normals[indexLast + 2] = normals[indexFirst + 2];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (closeArray) {
|
|
194
|
+
let indexFirst = idx[0] * 3;
|
|
195
|
+
let indexLast = idx[pathArray.length] * 3;
|
|
196
|
+
for (i = 0; i < minlg + closePathCorr; i++) {
|
|
197
|
+
normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
|
|
198
|
+
normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
|
|
199
|
+
normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
|
|
200
|
+
const l = Math.sqrt(normals[indexFirst] * normals[indexFirst] + normals[indexFirst + 1] * normals[indexFirst + 1] + normals[indexFirst + 2] * normals[indexFirst + 2]);
|
|
201
|
+
normals[indexFirst] /= l;
|
|
202
|
+
normals[indexFirst + 1] /= l;
|
|
203
|
+
normals[indexFirst + 2] /= l;
|
|
202
204
|
normals[indexLast] = normals[indexFirst];
|
|
203
205
|
normals[indexLast + 1] = normals[indexFirst + 1];
|
|
204
206
|
normals[indexLast + 2] = normals[indexFirst + 2];
|
|
207
|
+
indexFirst += 3;
|
|
208
|
+
indexLast += 3;
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
211
|
// sides
|