@babylonjs/core 7.29.0 → 7.30.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/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +4 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +2 -1
- package/Engines/nullEngine.d.ts +1 -0
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +4 -0
- package/Engines/webgpuEngine.js +1 -3
- package/Engines/webgpuEngine.js.map +1 -1
- package/Materials/Textures/rawTexture3D.d.ts +12 -0
- package/Materials/Textures/rawTexture3D.js +18 -0
- package/Materials/Textures/rawTexture3D.js.map +1 -1
- package/Materials/effect.d.ts +11 -0
- package/Materials/effect.js +20 -0
- package/Materials/effect.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +46 -46
- package/Materials/materialPluginBase.js +46 -60
- package/Materials/materialPluginBase.js.map +1 -1
- package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +91 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js +194 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryClampBlock.d.ts +8 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js +22 -6
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInterceptorBlock.d.ts +5 -0
- package/Meshes/Node/Blocks/geometryInterceptorBlock.js +5 -1
- package/Meshes/Node/Blocks/geometryInterceptorBlock.js.map +1 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +5 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js +4 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
- package/Meshes/Node/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +12 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/lattice.d.ts +18 -1
- package/Meshes/lattice.js +34 -6
- package/Meshes/lattice.js.map +1 -1
- package/Meshes/lattice.material.d.ts +82 -0
- package/Meshes/lattice.material.js +259 -0
- package/Meshes/lattice.material.js.map +1 -0
- package/Misc/screenshotTools.js +0 -3
- package/Misc/screenshotTools.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +1 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +1 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/Sprites/spriteManager.d.ts +10 -1
- package/Sprites/spriteManager.js +3 -2
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spritePackedManager.d.ts +6 -1
- package/Sprites/spritePackedManager.js +6 -2
- package/Sprites/spritePackedManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +16 -3
- package/Sprites/spriteRenderer.js +5 -3
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -172,6 +172,18 @@ export class NodeGeometryBuildState {
|
|
|
172
172
|
}
|
|
173
173
|
return this.geometryContext.metadata.collectionId || 0;
|
|
174
174
|
}
|
|
175
|
+
case NodeGeometryContextualSources.LatticeID: {
|
|
176
|
+
if (this.executionContext.getOverridePositionsContextualValue) {
|
|
177
|
+
return this.executionContext.getOverridePositionsContextualValue();
|
|
178
|
+
}
|
|
179
|
+
return Vector3.Zero();
|
|
180
|
+
}
|
|
181
|
+
case NodeGeometryContextualSources.LatticeControl: {
|
|
182
|
+
if (this.executionContext.getOverrideNormalsContextualValue) {
|
|
183
|
+
return this.executionContext.getOverrideNormalsContextualValue();
|
|
184
|
+
}
|
|
185
|
+
return Vector3.Zero();
|
|
186
|
+
}
|
|
175
187
|
}
|
|
176
188
|
return null;
|
|
177
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeGeometryBuildState.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/nodeGeometryBuildState.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AAGjG;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QACY,oBAAe,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,mBAAc,GAAG,IAAI,MAAM,EAAE,CAAC;QAC9B,oBAAe,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,2BAAsB,GAAG,IAAI,MAAM,EAAE,CAAC;QACtC,qBAAgB,GAAG,IAAI,MAAM,EAAE,CAAC;QAChC,iBAAY,GAAG,IAAI,OAAO,EAAE,CAAC;QAErC,8DAA8D;QACvD,kCAA6B,GAAkC,EAAE,CAAC;QACzE,gFAAgF;QACzE,qBAAgB,GAAoC,EAAE,CAAC;QAK9D,mCAAmC;QAC5B,eAAU,GAAyB,IAAI,CAAC;QAEvC,qBAAgB,GAAyB,IAAI,CAAC;QAC9C,sBAAiB,GAA4C,IAAI,CAAC;QAClE,uBAAkB,GAA6C,IAAI,CAAC;QAEpE,0BAAqB,GAAgC,EAAE,CAAC;QACxD,2BAAsB,GAAmD,EAAE,CAAC;QAC5E,4BAAuB,GAAoD,EAAE,CAAC;IA8S1F,CAAC;IA5SG,wCAAwC;IACxC,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,gBAA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BAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { VertexData } from \"../mesh.vertexData\";\r\nimport type { NodeGeometryConnectionPoint } from \"./nodeGeometryBlockConnectionPoint\";\r\nimport { NodeGeometryContextualSources } from \"./Enums/nodeGeometryContextualSources\";\r\nimport { Matrix, Vector2, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport type { INodeGeometryExecutionContext } from \"./Interfaces/nodeGeometryExecutionContext\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"./Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { INodeGeometryInstancingContext } from \"./Interfaces/nodeGeometryInstancingContext\";\r\n\r\n/**\r\n * Class used to store node based geometry build state\r\n */\r\nexport class NodeGeometryBuildState {\r\n private _rotationMatrix = new Matrix();\r\n private _scalingMatrix = new Matrix();\r\n private _positionMatrix = new Matrix();\r\n private _scalingRotationMatrix = new Matrix();\r\n private _transformMatrix = new Matrix();\r\n private _tempVector3 = new Vector3();\r\n\r\n /** Gets or sets the list of non connected mandatory inputs */\r\n public notConnectedNonOptionalInputs: NodeGeometryConnectionPoint[] = [];\r\n /** Gets or sets the list of non contextual inputs having no contextudal data */\r\n public noContextualData: NodeGeometryContextualSources[] = [];\r\n /** Gets or sets the build identifier */\r\n public buildId: number;\r\n /** Gets or sets a boolean indicating that verbose mode is on */\r\n public verbose: boolean;\r\n /** Gets or sets the vertex data */\r\n public vertexData: Nullable<VertexData> = null;\r\n\r\n private _geometryContext: Nullable<VertexData> = null;\r\n private _executionContext: Nullable<INodeGeometryExecutionContext> = null;\r\n private _instancingContext: Nullable<INodeGeometryInstancingContext> = null;\r\n\r\n private _geometryContextStack: Array<Nullable<VertexData>> = [];\r\n private _executionContextStack: Array<Nullable<INodeGeometryExecutionContext>> = [];\r\n private _instancingContextStack: Array<Nullable<INodeGeometryInstancingContext>> = [];\r\n\r\n /** Gets or sets the geometry context */\r\n public get geometryContext() {\r\n return this._geometryContext;\r\n }\r\n\r\n /** Gets or sets the execution context */\r\n public get executionContext() {\r\n return this._executionContext;\r\n }\r\n\r\n /** Gets or sets the instancing context */\r\n public get instancingContext() {\r\n return this._instancingContext;\r\n }\r\n\r\n /**\r\n * Push the new active geometry context\r\n * @param geometryContext defines the geometry context\r\n */\r\n public pushGeometryContext(geometryContext: VertexData) {\r\n this._geometryContext = geometryContext;\r\n this._geometryContextStack.push(this._geometryContext);\r\n }\r\n\r\n /**\r\n * Push the new active execution context\r\n * @param executionContext defines the execution context\r\n */\r\n public pushExecutionContext(executionContext: INodeGeometryExecutionContext) {\r\n this._executionContext = executionContext;\r\n this._executionContextStack.push(this._executionContext);\r\n }\r\n\r\n /**\r\n * Push the new active instancing context\r\n * @param instancingContext defines the instancing context\r\n */\r\n public pushInstancingContext(instancingContext: INodeGeometryInstancingContext) {\r\n this._instancingContext = instancingContext;\r\n this._instancingContextStack.push(this._instancingContext);\r\n }\r\n\r\n /**\r\n * Remove current geometry context and restore the previous one\r\n */\r\n public restoreGeometryContext() {\r\n this._geometryContextStack.pop();\r\n this._geometryContext = this._geometryContextStack.length > 0 ? this._geometryContextStack[this._geometryContextStack.length - 1] : null;\r\n }\r\n\r\n /**\r\n * Remove current execution context and restore the previous one\r\n */\r\n public restoreExecutionContext() {\r\n this._executionContextStack.pop();\r\n this._executionContext = this._executionContextStack.length > 0 ? this._executionContextStack[this._executionContextStack.length - 1] : null;\r\n }\r\n\r\n /**\r\n * Remove current isntancing context and restore the previous one\r\n */\r\n public restoreInstancingContext() {\r\n this._instancingContextStack.pop();\r\n this._instancingContext = this._instancingContextStack.length > 0 ? this._instancingContextStack[this._instancingContextStack.length - 1] : null;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual source\r\n * @param source Source of the contextual value\r\n * @param skipWarning Do not store the warning for reporting if true\r\n * @returns the value associated with the source\r\n */\r\n public getContextualValue(source: NodeGeometryContextualSources, skipWarning = false) {\r\n if (!this.executionContext) {\r\n if (!skipWarning) {\r\n this.noContextualData.push(source);\r\n }\r\n return null;\r\n }\r\n\r\n const index = this.executionContext.getExecutionIndex();\r\n\r\n switch (source) {\r\n case NodeGeometryContextualSources.Positions:\r\n if (this.executionContext.getOverridePositionsContextualValue) {\r\n return this.executionContext.getOverridePositionsContextualValue();\r\n }\r\n if (!this.geometryContext || !this.geometryContext.positions) {\r\n return Vector3.Zero();\r\n }\r\n return Vector3.FromArray(this.geometryContext.positions as ArrayLike<number>, index * 3);\r\n case NodeGeometryContextualSources.Normals:\r\n if (this.executionContext.getOverrideNormalsContextualValue) {\r\n return this.executionContext.getOverrideNormalsContextualValue();\r\n }\r\n if (!this.geometryContext || !this.geometryContext.normals) {\r\n return Vector3.Zero();\r\n }\r\n return Vector3.FromArray(this.geometryContext.normals as ArrayLike<number>, index * 3);\r\n case NodeGeometryContextualSources.Colors:\r\n if (!this.geometryContext || !this.geometryContext.colors) {\r\n return Vector4.Zero();\r\n }\r\n return Vector4.FromArray(this.geometryContext.colors as ArrayLike<number>, index * 4);\r\n case NodeGeometryContextualSources.Tangents:\r\n if (!this.geometryContext || !this.geometryContext.tangents) {\r\n return Vector4.Zero();\r\n }\r\n return Vector4.FromArray(this.geometryContext.tangents as ArrayLike<number>, index * 4);\r\n case NodeGeometryContextualSources.UV:\r\n if (this.executionContext.getOverrideUVs1ContextualValue) {\r\n return this.executionContext.getOverrideUVs1ContextualValue();\r\n }\r\n if (!this.geometryContext || !this.geometryContext.uvs) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV2:\r\n if (!this.geometryContext || !this.geometryContext.uvs2) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs2 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV3:\r\n if (!this.geometryContext || !this.geometryContext.uvs3) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs3 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV4:\r\n if (!this.geometryContext || !this.geometryContext.uvs4) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs4 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV5:\r\n if (!this.geometryContext || !this.geometryContext.uvs5) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs5 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV6:\r\n if (!this.geometryContext || !this.geometryContext.uvs6) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs6 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.VertexID:\r\n return index;\r\n case NodeGeometryContextualSources.FaceID:\r\n return this.executionContext.getExecutionFaceIndex();\r\n case NodeGeometryContextualSources.LoopID:\r\n return this.executionContext.getExecutionLoopIndex();\r\n case NodeGeometryContextualSources.InstanceID:\r\n return this.instancingContext ? this.instancingContext.getInstanceIndex() : 0;\r\n case NodeGeometryContextualSources.GeometryID:\r\n return !this.geometryContext ? 0 : this.geometryContext.uniqueId;\r\n case NodeGeometryContextualSources.CollectionID: {\r\n if (!this.geometryContext || !this.geometryContext.metadata) {\r\n return 0;\r\n }\r\n return this.geometryContext.metadata.collectionId || 0;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Adapt a value to a target type\r\n * @param source defines the value to adapt\r\n * @param targetType defines the target type\r\n * @returns the adapted value\r\n */\r\n adapt(source: NodeGeometryConnectionPoint, targetType: NodeGeometryBlockConnectionPointTypes) {\r\n const value = source.getConnectedValue(this) || 0;\r\n\r\n if (source.type === targetType) {\r\n return value;\r\n }\r\n\r\n switch (targetType) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n return new Vector2(value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n return new Vector3(value, value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n return new Vector4(value, value, value, value);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Adapt an input value to a target type\r\n * @param source defines the value to adapt\r\n * @param targetType defines the target type\r\n * @param defaultValue defines the default value to use if not connected\r\n * @returns the adapted value\r\n */\r\n adaptInput(source: NodeGeometryConnectionPoint, targetType: NodeGeometryBlockConnectionPointTypes, defaultValue: any) {\r\n if (!source.isConnected) {\r\n return source.value || defaultValue;\r\n }\r\n\r\n const value = source.getConnectedValue(this);\r\n\r\n if (source._connectedPoint?.type === targetType) {\r\n return value;\r\n }\r\n\r\n switch (targetType) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n return new Vector2(value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n return new Vector3(value, value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n return new Vector4(value, value, value, value);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Emits console errors and exceptions if there is a failing check\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n for (const notConnectedInput of this.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n\r\n for (const source of this.noContextualData) {\r\n errorMessage += `Contextual input ${NodeGeometryContextualSources[source]} has no context to pull data from (must be connected to a setXXX block or a instantiateXXX block).\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Build of NodeGeometry failed:\\n\" + errorMessage;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _instantiate(clone: VertexData, currentPosition: Vector3, rotation: Vector3, scaling: Vector3, additionalVertexData: VertexData[]) {\r\n // Transform\r\n Matrix.ScalingToRef(scaling.x, scaling.y, scaling.z, this._scalingMatrix);\r\n Matrix.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, this._rotationMatrix);\r\n Matrix.TranslationToRef(currentPosition.x, currentPosition.y, currentPosition.z, this._positionMatrix);\r\n\r\n this._scalingMatrix.multiplyToRef(this._rotationMatrix, this._scalingRotationMatrix);\r\n this._scalingRotationMatrix.multiplyToRef(this._positionMatrix, this._transformMatrix);\r\n for (let clonePositionIndex = 0; clonePositionIndex < clone.positions!.length; clonePositionIndex += 3) {\r\n this._tempVector3.fromArray(clone.positions!, clonePositionIndex);\r\n Vector3.TransformCoordinatesToRef(this._tempVector3, this._transformMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.positions!, clonePositionIndex);\r\n\r\n if (clone.normals) {\r\n this._tempVector3.fromArray(clone.normals, clonePositionIndex);\r\n Vector3.TransformNormalToRef(this._tempVector3, this._scalingRotationMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.normals, clonePositionIndex);\r\n }\r\n }\r\n\r\n additionalVertexData.push(clone);\r\n }\r\n\r\n /** @internal */\r\n public _instantiateWithMatrix(clone: VertexData, transform: Matrix, additionalVertexData: VertexData[]) {\r\n for (let clonePositionIndex = 0; clonePositionIndex < clone.positions!.length; clonePositionIndex += 3) {\r\n this._tempVector3.fromArray(clone.positions!, clonePositionIndex);\r\n Vector3.TransformCoordinatesToRef(this._tempVector3, transform, this._tempVector3);\r\n this._tempVector3.toArray(clone.positions!, clonePositionIndex);\r\n\r\n if (clone.normals) {\r\n this._tempVector3.fromArray(clone.normals, clonePositionIndex);\r\n Vector3.TransformNormalToRef(this._tempVector3, transform, this._tempVector3);\r\n this._tempVector3.toArray(clone.normals, clonePositionIndex);\r\n }\r\n }\r\n\r\n additionalVertexData.push(clone);\r\n }\r\n\r\n /** @internal */\r\n public _instantiateWithPositionAndMatrix(clone: VertexData, currentPosition: Vector3, transform: Matrix, additionalVertexData: VertexData[]) {\r\n Matrix.TranslationToRef(currentPosition.x, currentPosition.y, currentPosition.z, this._positionMatrix);\r\n transform.multiplyToRef(this._positionMatrix, this._transformMatrix);\r\n\r\n for (let clonePositionIndex = 0; clonePositionIndex < clone.positions!.length; clonePositionIndex += 3) {\r\n this._tempVector3.fromArray(clone.positions!, clonePositionIndex);\r\n Vector3.TransformCoordinatesToRef(this._tempVector3, this._transformMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.positions!, clonePositionIndex);\r\n\r\n if (clone.normals) {\r\n this._tempVector3.fromArray(clone.normals, clonePositionIndex);\r\n Vector3.TransformNormalToRef(this._tempVector3, this._transformMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.normals, clonePositionIndex);\r\n }\r\n }\r\n\r\n additionalVertexData.push(clone);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"nodeGeometryBuildState.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/nodeGeometryBuildState.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AAGjG;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QACY,oBAAe,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,mBAAc,GAAG,IAAI,MAAM,EAAE,CAAC;QAC9B,oBAAe,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,2BAAsB,GAAG,IAAI,MAAM,EAAE,CAAC;QACtC,qBAAgB,GAAG,IAAI,MAAM,EAAE,CAAC;QAChC,iBAAY,GAAG,IAAI,OAAO,EAAE,CAAC;QAErC,8DAA8D;QACvD,kCAA6B,GAAkC,EAAE,CAAC;QACzE,gFAAgF;QACzE,qBAAgB,GAAoC,EAAE,CAAC;QAK9D,mCAAmC;QAC5B,eAAU,GAAyB,IAAI,CAAC;QAEvC,qBAAgB,GAAyB,IAAI,CAAC;QAC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C,MAAM,EAAE,kBAAkB,IAAI,CAAC,EAAE;YACpG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,SAAU,EAAE,kBAAkB,CAAC,CAAC;YAClE,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAC/F,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,SAAU,EAAE,kBAAkB,CAAC,CAAC;YAEhE,IAAI,KAAK,CAAC,OAAO,EAAE;gBACf,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;gBAC/D,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;gBAC1F,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;aAChE;SACJ;QAED,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { VertexData } from \"../mesh.vertexData\";\r\nimport type { NodeGeometryConnectionPoint } from \"./nodeGeometryBlockConnectionPoint\";\r\nimport { NodeGeometryContextualSources } from \"./Enums/nodeGeometryContextualSources\";\r\nimport { Matrix, Vector2, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport type { INodeGeometryExecutionContext } from \"./Interfaces/nodeGeometryExecutionContext\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"./Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { INodeGeometryInstancingContext } from \"./Interfaces/nodeGeometryInstancingContext\";\r\n\r\n/**\r\n * Class used to store node based geometry build state\r\n */\r\nexport class NodeGeometryBuildState {\r\n private _rotationMatrix = new Matrix();\r\n private _scalingMatrix = new Matrix();\r\n private _positionMatrix = new Matrix();\r\n private _scalingRotationMatrix = new Matrix();\r\n private _transformMatrix = new Matrix();\r\n private _tempVector3 = new Vector3();\r\n\r\n /** Gets or sets the list of non connected mandatory inputs */\r\n public notConnectedNonOptionalInputs: NodeGeometryConnectionPoint[] = [];\r\n /** Gets or sets the list of non contextual inputs having no contextudal data */\r\n public noContextualData: NodeGeometryContextualSources[] = [];\r\n /** Gets or sets the build identifier */\r\n public buildId: number;\r\n /** Gets or sets a boolean indicating that verbose mode is on */\r\n public verbose: boolean;\r\n /** Gets or sets the vertex data */\r\n public vertexData: Nullable<VertexData> = null;\r\n\r\n private _geometryContext: Nullable<VertexData> = null;\r\n private _executionContext: Nullable<INodeGeometryExecutionContext> = null;\r\n private _instancingContext: Nullable<INodeGeometryInstancingContext> = null;\r\n\r\n private _geometryContextStack: Array<Nullable<VertexData>> = [];\r\n private _executionContextStack: Array<Nullable<INodeGeometryExecutionContext>> = [];\r\n private _instancingContextStack: Array<Nullable<INodeGeometryInstancingContext>> = [];\r\n\r\n /** Gets or sets the geometry context */\r\n public get geometryContext() {\r\n return this._geometryContext;\r\n }\r\n\r\n /** Gets or sets the execution context */\r\n public get executionContext() {\r\n return this._executionContext;\r\n }\r\n\r\n /** Gets or sets the instancing context */\r\n public get instancingContext() {\r\n return this._instancingContext;\r\n }\r\n\r\n /**\r\n * Push the new active geometry context\r\n * @param geometryContext defines the geometry context\r\n */\r\n public pushGeometryContext(geometryContext: VertexData) {\r\n this._geometryContext = geometryContext;\r\n this._geometryContextStack.push(this._geometryContext);\r\n }\r\n\r\n /**\r\n * Push the new active execution context\r\n * @param executionContext defines the execution context\r\n */\r\n public pushExecutionContext(executionContext: INodeGeometryExecutionContext) {\r\n this._executionContext = executionContext;\r\n this._executionContextStack.push(this._executionContext);\r\n }\r\n\r\n /**\r\n * Push the new active instancing context\r\n * @param instancingContext defines the instancing context\r\n */\r\n public pushInstancingContext(instancingContext: INodeGeometryInstancingContext) {\r\n this._instancingContext = instancingContext;\r\n this._instancingContextStack.push(this._instancingContext);\r\n }\r\n\r\n /**\r\n * Remove current geometry context and restore the previous one\r\n */\r\n public restoreGeometryContext() {\r\n this._geometryContextStack.pop();\r\n this._geometryContext = this._geometryContextStack.length > 0 ? this._geometryContextStack[this._geometryContextStack.length - 1] : null;\r\n }\r\n\r\n /**\r\n * Remove current execution context and restore the previous one\r\n */\r\n public restoreExecutionContext() {\r\n this._executionContextStack.pop();\r\n this._executionContext = this._executionContextStack.length > 0 ? this._executionContextStack[this._executionContextStack.length - 1] : null;\r\n }\r\n\r\n /**\r\n * Remove current isntancing context and restore the previous one\r\n */\r\n public restoreInstancingContext() {\r\n this._instancingContextStack.pop();\r\n this._instancingContext = this._instancingContextStack.length > 0 ? this._instancingContextStack[this._instancingContextStack.length - 1] : null;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual source\r\n * @param source Source of the contextual value\r\n * @param skipWarning Do not store the warning for reporting if true\r\n * @returns the value associated with the source\r\n */\r\n public getContextualValue(source: NodeGeometryContextualSources, skipWarning = false) {\r\n if (!this.executionContext) {\r\n if (!skipWarning) {\r\n this.noContextualData.push(source);\r\n }\r\n return null;\r\n }\r\n\r\n const index = this.executionContext.getExecutionIndex();\r\n\r\n switch (source) {\r\n case NodeGeometryContextualSources.Positions:\r\n if (this.executionContext.getOverridePositionsContextualValue) {\r\n return this.executionContext.getOverridePositionsContextualValue();\r\n }\r\n if (!this.geometryContext || !this.geometryContext.positions) {\r\n return Vector3.Zero();\r\n }\r\n return Vector3.FromArray(this.geometryContext.positions as ArrayLike<number>, index * 3);\r\n case NodeGeometryContextualSources.Normals:\r\n if (this.executionContext.getOverrideNormalsContextualValue) {\r\n return this.executionContext.getOverrideNormalsContextualValue();\r\n }\r\n if (!this.geometryContext || !this.geometryContext.normals) {\r\n return Vector3.Zero();\r\n }\r\n return Vector3.FromArray(this.geometryContext.normals as ArrayLike<number>, index * 3);\r\n case NodeGeometryContextualSources.Colors:\r\n if (!this.geometryContext || !this.geometryContext.colors) {\r\n return Vector4.Zero();\r\n }\r\n return Vector4.FromArray(this.geometryContext.colors as ArrayLike<number>, index * 4);\r\n case NodeGeometryContextualSources.Tangents:\r\n if (!this.geometryContext || !this.geometryContext.tangents) {\r\n return Vector4.Zero();\r\n }\r\n return Vector4.FromArray(this.geometryContext.tangents as ArrayLike<number>, index * 4);\r\n case NodeGeometryContextualSources.UV:\r\n if (this.executionContext.getOverrideUVs1ContextualValue) {\r\n return this.executionContext.getOverrideUVs1ContextualValue();\r\n }\r\n if (!this.geometryContext || !this.geometryContext.uvs) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV2:\r\n if (!this.geometryContext || !this.geometryContext.uvs2) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs2 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV3:\r\n if (!this.geometryContext || !this.geometryContext.uvs3) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs3 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV4:\r\n if (!this.geometryContext || !this.geometryContext.uvs4) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs4 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV5:\r\n if (!this.geometryContext || !this.geometryContext.uvs5) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs5 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.UV6:\r\n if (!this.geometryContext || !this.geometryContext.uvs6) {\r\n return Vector2.Zero();\r\n }\r\n return Vector2.FromArray(this.geometryContext.uvs6 as ArrayLike<number>, index * 2);\r\n case NodeGeometryContextualSources.VertexID:\r\n return index;\r\n case NodeGeometryContextualSources.FaceID:\r\n return this.executionContext.getExecutionFaceIndex();\r\n case NodeGeometryContextualSources.LoopID:\r\n return this.executionContext.getExecutionLoopIndex();\r\n case NodeGeometryContextualSources.InstanceID:\r\n return this.instancingContext ? this.instancingContext.getInstanceIndex() : 0;\r\n case NodeGeometryContextualSources.GeometryID:\r\n return !this.geometryContext ? 0 : this.geometryContext.uniqueId;\r\n case NodeGeometryContextualSources.CollectionID: {\r\n if (!this.geometryContext || !this.geometryContext.metadata) {\r\n return 0;\r\n }\r\n return this.geometryContext.metadata.collectionId || 0;\r\n }\r\n case NodeGeometryContextualSources.LatticeID: {\r\n if (this.executionContext.getOverridePositionsContextualValue) {\r\n return this.executionContext.getOverridePositionsContextualValue();\r\n }\r\n return Vector3.Zero();\r\n }\r\n case NodeGeometryContextualSources.LatticeControl: {\r\n if (this.executionContext.getOverrideNormalsContextualValue) {\r\n return this.executionContext.getOverrideNormalsContextualValue();\r\n }\r\n return Vector3.Zero();\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Adapt a value to a target type\r\n * @param source defines the value to adapt\r\n * @param targetType defines the target type\r\n * @returns the adapted value\r\n */\r\n adapt(source: NodeGeometryConnectionPoint, targetType: NodeGeometryBlockConnectionPointTypes) {\r\n const value = source.getConnectedValue(this) || 0;\r\n\r\n if (source.type === targetType) {\r\n return value;\r\n }\r\n\r\n switch (targetType) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n return new Vector2(value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n return new Vector3(value, value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n return new Vector4(value, value, value, value);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Adapt an input value to a target type\r\n * @param source defines the value to adapt\r\n * @param targetType defines the target type\r\n * @param defaultValue defines the default value to use if not connected\r\n * @returns the adapted value\r\n */\r\n adaptInput(source: NodeGeometryConnectionPoint, targetType: NodeGeometryBlockConnectionPointTypes, defaultValue: any) {\r\n if (!source.isConnected) {\r\n return source.value || defaultValue;\r\n }\r\n\r\n const value = source.getConnectedValue(this);\r\n\r\n if (source._connectedPoint?.type === targetType) {\r\n return value;\r\n }\r\n\r\n switch (targetType) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n return new Vector2(value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n return new Vector3(value, value, value);\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n return new Vector4(value, value, value, value);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Emits console errors and exceptions if there is a failing check\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n for (const notConnectedInput of this.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n\r\n for (const source of this.noContextualData) {\r\n errorMessage += `Contextual input ${NodeGeometryContextualSources[source]} has no context to pull data from (must be connected to a setXXX block or a instantiateXXX block).\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Build of NodeGeometry failed:\\n\" + errorMessage;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _instantiate(clone: VertexData, currentPosition: Vector3, rotation: Vector3, scaling: Vector3, additionalVertexData: VertexData[]) {\r\n // Transform\r\n Matrix.ScalingToRef(scaling.x, scaling.y, scaling.z, this._scalingMatrix);\r\n Matrix.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, this._rotationMatrix);\r\n Matrix.TranslationToRef(currentPosition.x, currentPosition.y, currentPosition.z, this._positionMatrix);\r\n\r\n this._scalingMatrix.multiplyToRef(this._rotationMatrix, this._scalingRotationMatrix);\r\n this._scalingRotationMatrix.multiplyToRef(this._positionMatrix, this._transformMatrix);\r\n for (let clonePositionIndex = 0; clonePositionIndex < clone.positions!.length; clonePositionIndex += 3) {\r\n this._tempVector3.fromArray(clone.positions!, clonePositionIndex);\r\n Vector3.TransformCoordinatesToRef(this._tempVector3, this._transformMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.positions!, clonePositionIndex);\r\n\r\n if (clone.normals) {\r\n this._tempVector3.fromArray(clone.normals, clonePositionIndex);\r\n Vector3.TransformNormalToRef(this._tempVector3, this._scalingRotationMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.normals, clonePositionIndex);\r\n }\r\n }\r\n\r\n additionalVertexData.push(clone);\r\n }\r\n\r\n /** @internal */\r\n public _instantiateWithMatrix(clone: VertexData, transform: Matrix, additionalVertexData: VertexData[]) {\r\n for (let clonePositionIndex = 0; clonePositionIndex < clone.positions!.length; clonePositionIndex += 3) {\r\n this._tempVector3.fromArray(clone.positions!, clonePositionIndex);\r\n Vector3.TransformCoordinatesToRef(this._tempVector3, transform, this._tempVector3);\r\n this._tempVector3.toArray(clone.positions!, clonePositionIndex);\r\n\r\n if (clone.normals) {\r\n this._tempVector3.fromArray(clone.normals, clonePositionIndex);\r\n Vector3.TransformNormalToRef(this._tempVector3, transform, this._tempVector3);\r\n this._tempVector3.toArray(clone.normals, clonePositionIndex);\r\n }\r\n }\r\n\r\n additionalVertexData.push(clone);\r\n }\r\n\r\n /** @internal */\r\n public _instantiateWithPositionAndMatrix(clone: VertexData, currentPosition: Vector3, transform: Matrix, additionalVertexData: VertexData[]) {\r\n Matrix.TranslationToRef(currentPosition.x, currentPosition.y, currentPosition.z, this._positionMatrix);\r\n transform.multiplyToRef(this._positionMatrix, this._transformMatrix);\r\n\r\n for (let clonePositionIndex = 0; clonePositionIndex < clone.positions!.length; clonePositionIndex += 3) {\r\n this._tempVector3.fromArray(clone.positions!, clonePositionIndex);\r\n Vector3.TransformCoordinatesToRef(this._tempVector3, this._transformMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.positions!, clonePositionIndex);\r\n\r\n if (clone.normals) {\r\n this._tempVector3.fromArray(clone.normals, clonePositionIndex);\r\n Vector3.TransformNormalToRef(this._tempVector3, this._transformMatrix, this._tempVector3);\r\n this._tempVector3.toArray(clone.normals, clonePositionIndex);\r\n }\r\n }\r\n\r\n additionalVertexData.push(clone);\r\n }\r\n}\r\n"]}
|
package/Meshes/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./geodesicMesh";
|
|
|
21
21
|
export * from "./subMesh";
|
|
22
22
|
export * from "./subMesh.project";
|
|
23
23
|
export * from "./lattice";
|
|
24
|
+
export * from "./lattice.material";
|
|
24
25
|
export * from "./meshLODLevel";
|
|
25
26
|
export * from "./transformNode";
|
|
26
27
|
export * from "./Builders/index";
|
package/Meshes/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export * from "./geodesicMesh.js";
|
|
|
23
23
|
export * from "./subMesh.js";
|
|
24
24
|
export * from "./subMesh.project.js";
|
|
25
25
|
export * from "./lattice.js";
|
|
26
|
+
export * from "./lattice.material.js";
|
|
26
27
|
export * from "./meshLODLevel.js";
|
|
27
28
|
export * from "./transformNode.js";
|
|
28
29
|
export * from "./Builders/index.js";
|
package/Meshes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,OAAO,oBAAoB,CAAC;AAC5B,gDAAgD;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,2CAA2C,CAAC;AAE1D,WAAW;AACX,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,sBAAsB;AACtB,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,kDAAkD,CAAC;AACjE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC","sourcesContent":["/* eslint-disable import/export */\r\n/* eslint-disable import/no-internal-modules */\r\nexport * from \"./abstractMesh\";\r\nimport \"./abstractMesh.decalMap\";\r\nexport * from \"./abstractMesh.hotSpot\";\r\nexport * from \"./Compression/index\";\r\nexport * from \"./csg\";\r\nexport * from \"./meshUVSpaceRenderer\";\r\nexport * from \"./geometry\";\r\nexport * from \"./groundMesh\";\r\nexport * from \"./goldbergMesh\";\r\nexport * from \"./trailMesh\";\r\nexport * from \"./instancedMesh\";\r\nexport * from \"./linesMesh\";\r\nexport * from \"./mesh\";\r\nexport * from \"./mesh.vertexData\";\r\nexport * from \"./meshBuilder\";\r\nexport * from \"./meshSimplification\";\r\nexport * from \"./meshSimplificationSceneComponent\";\r\nexport * from \"./meshUtils\";\r\nexport * from \"./polygonMesh\";\r\nexport * from \"./geodesicMesh\";\r\nexport * from \"./subMesh\";\r\nexport * from \"./subMesh.project\";\r\nexport * from \"./lattice\";\r\nexport * from \"./meshLODLevel\";\r\nexport * from \"./transformNode\";\r\nexport * from \"./Builders/index\";\r\nexport * from \"./WebGL/webGLDataBuffer\";\r\nexport * from \"./WebGPU/webgpuDataBuffer\";\r\nexport * from \"./GreasedLine/greasedLineMesh\";\r\nexport * from \"./GreasedLine/greasedLineRibbonMesh\";\r\nexport * from \"./GreasedLine/greasedLineBaseMesh\";\r\nimport \"./thinInstanceMesh\";\r\n// eslint-disable-next-line no-duplicate-imports\r\nexport * from \"./thinInstanceMesh\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMesh\";\r\n\r\n// LineMesh\r\nexport * from \"../Shaders/color.fragment\";\r\nexport * from \"../Shaders/color.vertex\";\r\nexport * from \"../ShadersWGSL/color.fragment\";\r\nexport * from \"../ShadersWGSL/color.vertex\";\r\n\r\n// MeshUVSPaceRenderer\r\nexport * from \"../Shaders/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.vertex\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,OAAO,oBAAoB,CAAC;AAC5B,gDAAgD;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,2CAA2C,CAAC;AAE1D,WAAW;AACX,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,sBAAsB;AACtB,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,kDAAkD,CAAC;AACjE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC","sourcesContent":["/* eslint-disable import/export */\r\n/* eslint-disable import/no-internal-modules */\r\nexport * from \"./abstractMesh\";\r\nimport \"./abstractMesh.decalMap\";\r\nexport * from \"./abstractMesh.hotSpot\";\r\nexport * from \"./Compression/index\";\r\nexport * from \"./csg\";\r\nexport * from \"./meshUVSpaceRenderer\";\r\nexport * from \"./geometry\";\r\nexport * from \"./groundMesh\";\r\nexport * from \"./goldbergMesh\";\r\nexport * from \"./trailMesh\";\r\nexport * from \"./instancedMesh\";\r\nexport * from \"./linesMesh\";\r\nexport * from \"./mesh\";\r\nexport * from \"./mesh.vertexData\";\r\nexport * from \"./meshBuilder\";\r\nexport * from \"./meshSimplification\";\r\nexport * from \"./meshSimplificationSceneComponent\";\r\nexport * from \"./meshUtils\";\r\nexport * from \"./polygonMesh\";\r\nexport * from \"./geodesicMesh\";\r\nexport * from \"./subMesh\";\r\nexport * from \"./subMesh.project\";\r\nexport * from \"./lattice\";\r\nexport * from \"./lattice.material\";\r\nexport * from \"./meshLODLevel\";\r\nexport * from \"./transformNode\";\r\nexport * from \"./Builders/index\";\r\nexport * from \"./WebGL/webGLDataBuffer\";\r\nexport * from \"./WebGPU/webgpuDataBuffer\";\r\nexport * from \"./GreasedLine/greasedLineMesh\";\r\nexport * from \"./GreasedLine/greasedLineRibbonMesh\";\r\nexport * from \"./GreasedLine/greasedLineBaseMesh\";\r\nimport \"./thinInstanceMesh\";\r\n// eslint-disable-next-line no-duplicate-imports\r\nexport * from \"./thinInstanceMesh\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMesh\";\r\n\r\n// LineMesh\r\nexport * from \"../Shaders/color.fragment\";\r\nexport * from \"../Shaders/color.vertex\";\r\nexport * from \"../ShadersWGSL/color.fragment\";\r\nexport * from \"../ShadersWGSL/color.vertex\";\r\n\r\n// MeshUVSPaceRenderer\r\nexport * from \"../Shaders/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.vertex\";\r\n"]}
|
package/Meshes/lattice.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare class Lattice {
|
|
|
29
29
|
private _resolutionZ;
|
|
30
30
|
private _position;
|
|
31
31
|
private _size;
|
|
32
|
+
private _cellSize;
|
|
32
33
|
private _data;
|
|
33
34
|
private _min;
|
|
34
35
|
private _max;
|
|
@@ -69,11 +70,23 @@ export declare class Lattice {
|
|
|
69
70
|
* Gets the data of the lattice
|
|
70
71
|
*/
|
|
71
72
|
get data(): Vector3[][][];
|
|
73
|
+
/**
|
|
74
|
+
* Gets the size of each cell in the lattice
|
|
75
|
+
*/
|
|
76
|
+
get cellSize(): Vector3;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the min bounds of the lattice
|
|
79
|
+
*/
|
|
80
|
+
get min(): Vector3;
|
|
81
|
+
/**
|
|
82
|
+
* Gets the max bounds of the lattice
|
|
83
|
+
*/
|
|
84
|
+
get max(): Vector3;
|
|
72
85
|
/**
|
|
73
86
|
* Creates a new Lattice
|
|
74
87
|
* @param options options for creating
|
|
75
88
|
*/
|
|
76
|
-
constructor(options
|
|
89
|
+
constructor(options?: Partial<ILatticeOptions>);
|
|
77
90
|
private _allocateData;
|
|
78
91
|
/**
|
|
79
92
|
* Update of the lattice data
|
|
@@ -84,6 +97,10 @@ export declare class Lattice {
|
|
|
84
97
|
* @param mesh mesh to deform
|
|
85
98
|
*/
|
|
86
99
|
deformMesh(mesh: Mesh): void;
|
|
100
|
+
/**
|
|
101
|
+
* Update the lattice internals (like min, max and cell size)
|
|
102
|
+
*/
|
|
103
|
+
updateInternals(): void;
|
|
87
104
|
/**
|
|
88
105
|
* Apply the lattice to a set of points
|
|
89
106
|
* @param positions vertex data to deform
|
package/Meshes/lattice.js
CHANGED
|
@@ -50,11 +50,30 @@ export class Lattice {
|
|
|
50
50
|
get data() {
|
|
51
51
|
return this._data;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets the size of each cell in the lattice
|
|
55
|
+
*/
|
|
56
|
+
get cellSize() {
|
|
57
|
+
return this._cellSize;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Gets the min bounds of the lattice
|
|
61
|
+
*/
|
|
62
|
+
get min() {
|
|
63
|
+
return this._min;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gets the max bounds of the lattice
|
|
67
|
+
*/
|
|
68
|
+
get max() {
|
|
69
|
+
return this._max;
|
|
70
|
+
}
|
|
53
71
|
/**
|
|
54
72
|
* Creates a new Lattice
|
|
55
73
|
* @param options options for creating
|
|
56
74
|
*/
|
|
57
75
|
constructor(options) {
|
|
76
|
+
this._cellSize = new Vector3();
|
|
58
77
|
// Cache
|
|
59
78
|
this._min = new Vector3(-0.5, -0.5, -0.5);
|
|
60
79
|
this._max = new Vector3(0.5, 0.5, 0.5);
|
|
@@ -125,19 +144,28 @@ export class Lattice {
|
|
|
125
144
|
mesh.setVerticesData(VertexBuffer.PositionKind, positions, true);
|
|
126
145
|
}
|
|
127
146
|
/**
|
|
128
|
-
*
|
|
129
|
-
* @param positions vertex data to deform
|
|
130
|
-
* @param target optional target array to store the result (operation will be done in place in not defined)
|
|
147
|
+
* Update the lattice internals (like min, max and cell size)
|
|
131
148
|
*/
|
|
132
|
-
|
|
149
|
+
updateInternals() {
|
|
133
150
|
const nx = this._resolutionX;
|
|
134
151
|
const ny = this._resolutionY;
|
|
135
152
|
const nz = this._resolutionZ;
|
|
136
153
|
// Calculate the size of each cell in the lattice
|
|
137
|
-
|
|
154
|
+
this._cellSize.set(this.size.x / (nx - 1), this.size.y / (ny - 1), this.size.z / (nz - 1));
|
|
138
155
|
// Calculate the lattice bounds
|
|
139
156
|
this._min.set(this.position.x - this.size.x / 2, this.position.y - this.size.y / 2, this.position.z - this.size.z / 2);
|
|
140
157
|
this._min.addToRef(this._size, this._max);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Apply the lattice to a set of points
|
|
161
|
+
* @param positions vertex data to deform
|
|
162
|
+
* @param target optional target array to store the result (operation will be done in place in not defined)
|
|
163
|
+
*/
|
|
164
|
+
deform(positions, target) {
|
|
165
|
+
const nx = this._resolutionX;
|
|
166
|
+
const ny = this._resolutionY;
|
|
167
|
+
const nz = this._resolutionZ;
|
|
168
|
+
this.updateInternals();
|
|
141
169
|
const min = this._min;
|
|
142
170
|
const max = this._max;
|
|
143
171
|
// Loop over each vertex
|
|
@@ -151,7 +179,7 @@ export class Lattice {
|
|
|
151
179
|
continue;
|
|
152
180
|
}
|
|
153
181
|
// Map vertex position to lattice local coordinates
|
|
154
|
-
const localPos = this._localPos.set((vertex.x - min.x) /
|
|
182
|
+
const localPos = this._localPos.set((vertex.x - min.x) / this._cellSize.x, (vertex.y - min.y) / this._cellSize.y, (vertex.z - min.z) / this._cellSize.z);
|
|
155
183
|
// Get integer lattice indices
|
|
156
184
|
const i0 = Math.floor(localPos.x);
|
|
157
185
|
const j0 = Math.floor(localPos.y);
|
package/Meshes/lattice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lattice.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/lattice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gCAA+B;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,0CAAyC;AAoBzD;;;;GAIG;AACH,MAAM,OAAO,OAAO;IAqBhB;;OAEG;IACI,YAAY;QACf,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,YAAmB,OAAiC;QAlEpD,QAAQ;QACA,SAAI,GAAG,IAAI,OAAO,CAAC,CAA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AAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YAEvC,0BAA0B;YAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAEjE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAC9D,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAE9D,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACrE,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEtC,kCAAkC;YAClC,WAAW,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC;SAC/C;IACL,CAAC;CACJ","sourcesContent":["import { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { Mesh } from \"./mesh\";\r\nimport type { FloatArray } from \"core/types\";\r\nimport { VertexBuffer } from \"./buffer\";\r\nimport { Clamp } from \"core/Maths/math.scalar.functions\";\r\n\r\n/**\r\n * Interface used to define options for creating a lattice\r\n */\r\nexport interface ILatticeOptions {\r\n /** resolution on x axis */\r\n resolutionX: number;\r\n /** resolution on y axis */\r\n resolutionY: number;\r\n /** resolution on z axis */\r\n resolutionZ: number;\r\n /** the lattice position in object space */\r\n position: Vector3;\r\n /** size of the lattice along each axis in object space */\r\n size: Vector3;\r\n /** Optional mesh to adapt the size to */\r\n autoAdaptToMesh?: Mesh;\r\n}\r\n\r\n/**\r\n * Class used to represent a lattice\r\n * #MDVD75#18 - Moving lattice bounds\r\n * #MDVD75#23 - Twist\r\n */\r\nexport class Lattice {\r\n private _resolutionX: number;\r\n private _resolutionY: number;\r\n private _resolutionZ: number;\r\n private _position: Vector3;\r\n private _size: Vector3;\r\n\r\n private _data: Vector3[][][];\r\n\r\n // Cache\r\n private _min = new Vector3(-0.5, -0.5, -0.5);\r\n private _max = new Vector3(0.5, 0.5, 0.5);\r\n private _localPos = new Vector3();\r\n private _tmpVector = new Vector3();\r\n private _lerpVector0 = new Vector3();\r\n private _lerpVector1 = new Vector3();\r\n private _lerpVector2 = new Vector3();\r\n private _lerpVector3 = new Vector3();\r\n private _lerpVector4 = new Vector3();\r\n private _lerpVector5 = new Vector3();\r\n\r\n /**\r\n * @returns the string \"Lattice\"\r\n */\r\n public getClassName(): string {\r\n return \"Lattice\";\r\n }\r\n\r\n /**\r\n * Gets the resolution on x axis\r\n */\r\n public get resolutionX(): number {\r\n return this._resolutionX;\r\n }\r\n\r\n /**\r\n * Gets the resolution on y axis\r\n */\r\n public get resolutionY(): number {\r\n return this._resolutionY;\r\n }\r\n\r\n /**\r\n * Gets the resolution on z axis\r\n */\r\n public get resolutionZ(): number {\r\n return this._resolutionZ;\r\n }\r\n\r\n /**\r\n * Gets the size of the lattice along each axis in object space\r\n * Updating the size requires you to call update afterwards\r\n */\r\n public get size(): Vector3 {\r\n return this._size;\r\n }\r\n\r\n /**\r\n * Gets the lattice position in object space\r\n */\r\n public get position(): Vector3 {\r\n return this._position;\r\n }\r\n\r\n /**\r\n * Gets the data of the lattice\r\n */\r\n public get data(): Vector3[][][] {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Creates a new Lattice\r\n * @param options options for creating\r\n */\r\n public constructor(options: Partial<ILatticeOptions>) {\r\n const localOptions: ILatticeOptions = {\r\n resolutionX: 3,\r\n resolutionY: 3,\r\n resolutionZ: 3,\r\n position: Vector3.Zero(),\r\n size: Vector3.One(),\r\n ...options,\r\n };\r\n\r\n this._resolutionX = localOptions.resolutionX;\r\n this._resolutionY = localOptions.resolutionY;\r\n this._resolutionZ = localOptions.resolutionZ;\r\n this._position = localOptions.position;\r\n this._size = localOptions.autoAdaptToMesh ? localOptions.autoAdaptToMesh.getBoundingInfo().boundingBox.extendSize.scale(2) : localOptions.size;\r\n\r\n // Allocate data\r\n this._allocateData();\r\n this.update();\r\n }\r\n\r\n private _allocateData() {\r\n this._data = new Array<Array<Array<Vector3>>>(this.resolutionX);\r\n for (let i = 0; i < this.resolutionX; i++) {\r\n this._data[i] = new Array<Array<Vector3>>(this.resolutionY);\r\n for (let j = 0; j < this.resolutionY; j++) {\r\n this._data[i][j] = new Array<Vector3>(this.resolutionZ);\r\n for (let k = 0; k < this.resolutionZ; k++) {\r\n this._data[i][j][k] = Vector3.Zero();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Update of the lattice data\r\n */\r\n public update() {\r\n for (let i = 0; i < this.resolutionX; i++) {\r\n for (let j = 0; j < this.resolutionY; j++) {\r\n for (let k = 0; k < this.resolutionZ; k++) {\r\n const x = -this.size.x / 2 + this.size.x * (i / (this.resolutionX - 1));\r\n const y = -this.size.y / 2 + this.size.y * (j / (this.resolutionY - 1));\r\n const z = -this.size.z / 2 + this.size.z * (k / (this.resolutionZ - 1));\r\n\r\n this._data[i][j][k].set(x, y, z);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Apply the lattice to a mesh\r\n * @param mesh mesh to deform\r\n */\r\n public deformMesh(mesh: Mesh) {\r\n const positions = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n if (!positions) {\r\n return;\r\n }\r\n\r\n // Apply the lattice\r\n this.deform(positions);\r\n\r\n // Update back the mesh\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions, true);\r\n }\r\n\r\n /**\r\n * Apply the lattice to a set of points\r\n * @param positions vertex data to deform\r\n * @param target optional target array to store the result (operation will be done in place in not defined)\r\n */\r\n public deform(positions: FloatArray, target?: FloatArray) {\r\n const nx = this._resolutionX;\r\n const ny = this._resolutionY;\r\n const nz = this._resolutionZ;\r\n\r\n // Calculate the size of each cell in the lattice\r\n const cellSize = new Vector3(this.size.x / (nx - 1), this.size.y / (ny - 1), this.size.z / (nz - 1));\r\n\r\n // Calculate the lattice bounds\r\n this._min.set(this.position.x - this.size.x / 2, this.position.y - this.size.y / 2, this.position.z - this.size.z / 2);\r\n this._min.addToRef(this._size, this._max);\r\n\r\n const min = this._min;\r\n const max = this._max;\r\n\r\n // Loop over each vertex\r\n for (let i = 0; i < positions.length; i += 3) {\r\n const vertex = this._tmpVector.fromArray(positions, i);\r\n\r\n // Check we are inside\r\n if (vertex.x < min.x || vertex.x > max.x || vertex.y < min.y || vertex.y > max.y || vertex.z < min.z || vertex.z > max.z) {\r\n if (target) {\r\n vertex.toArray(target, i);\r\n }\r\n continue;\r\n }\r\n\r\n // Map vertex position to lattice local coordinates\r\n const localPos = this._localPos.set((vertex.x - min.x) / cellSize.x, (vertex.y - min.y) / cellSize.y, (vertex.z - min.z) / cellSize.z);\r\n\r\n // Get integer lattice indices\r\n const i0 = Math.floor(localPos.x);\r\n const j0 = Math.floor(localPos.y);\r\n const k0 = Math.floor(localPos.z);\r\n\r\n const i1 = Math.min(i0 + 1, nx - 1);\r\n const j1 = Math.min(j0 + 1, ny - 1);\r\n const k1 = Math.min(k0 + 1, nz - 1);\r\n\r\n // Compute interpolation weights\r\n const tx = localPos.x - i0;\r\n const ty = localPos.y - j0;\r\n const tz = localPos.z - k0;\r\n\r\n // Ensure indices are within bounds\r\n const ii0 = Clamp(i0, 0, nx - 1);\r\n const jj0 = Clamp(j0, 0, ny - 1);\r\n const kk0 = Clamp(k0, 0, nz - 1);\r\n const ii1 = Clamp(i1, 0, nx - 1);\r\n const jj1 = Clamp(j1, 0, ny - 1);\r\n const kk1 = Clamp(k1, 0, nz - 1);\r\n\r\n // Get lattice control points\r\n const p000 = this._data[ii0][jj0][kk0];\r\n const p100 = this._data[ii1][jj0][kk0];\r\n const p010 = this._data[ii0][jj1][kk0];\r\n const p110 = this._data[ii1][jj1][kk0];\r\n const p001 = this._data[ii0][jj0][kk1];\r\n const p101 = this._data[ii1][jj0][kk1];\r\n const p011 = this._data[ii0][jj1][kk1];\r\n const p111 = this._data[ii1][jj1][kk1];\r\n\r\n // Trilinear interpolation\r\n const p00 = Vector3.LerpToRef(p000, p100, tx, this._lerpVector0);\r\n const p01 = Vector3.LerpToRef(p001, p101, tx, this._lerpVector1);\r\n const p10 = Vector3.LerpToRef(p010, p110, tx, this._lerpVector2);\r\n const p11 = Vector3.LerpToRef(p011, p111, tx, this._lerpVector3);\r\n\r\n const p0 = Vector3.LerpToRef(p00, p10, ty, this._lerpVector4);\r\n const p1 = Vector3.LerpToRef(p01, p11, ty, this._lerpVector5);\r\n\r\n const deformedPos = Vector3.LerpToRef(p0, p1, tz, this._lerpVector0);\r\n deformedPos.addInPlace(this.position);\r\n\r\n // Apply deformation to the vertex\r\n deformedPos.toArray(target || positions, i);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"lattice.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/lattice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gCAA+B;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,0CAAyC;AAoBzD;;;;GAIG;AACH,MAAM,OAAO,OAAO;IAsBhB;;OAEG;IACI,YAAY;QACf,OAAO,SAAS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C,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAEjE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAC9D,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAE9D,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACrE,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEtC,kCAAkC;YAClC,WAAW,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC;SAC/C;IACL,CAAC;CACJ","sourcesContent":["import { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { Mesh } from \"./mesh\";\r\nimport type { FloatArray } from \"core/types\";\r\nimport { VertexBuffer } from \"./buffer\";\r\nimport { Clamp } from \"core/Maths/math.scalar.functions\";\r\n\r\n/**\r\n * Interface used to define options for creating a lattice\r\n */\r\nexport interface ILatticeOptions {\r\n /** resolution on x axis */\r\n resolutionX: number;\r\n /** resolution on y axis */\r\n resolutionY: number;\r\n /** resolution on z axis */\r\n resolutionZ: number;\r\n /** the lattice position in object space */\r\n position: Vector3;\r\n /** size of the lattice along each axis in object space */\r\n size: Vector3;\r\n /** Optional mesh to adapt the size to */\r\n autoAdaptToMesh?: Mesh;\r\n}\r\n\r\n/**\r\n * Class used to represent a lattice\r\n * #MDVD75#18 - Moving lattice bounds\r\n * #MDVD75#23 - Twist\r\n */\r\nexport class Lattice {\r\n private _resolutionX: number;\r\n private _resolutionY: number;\r\n private _resolutionZ: number;\r\n private _position: Vector3;\r\n private _size: Vector3;\r\n private _cellSize = new Vector3();\r\n\r\n private _data: Vector3[][][];\r\n\r\n // Cache\r\n private _min = new Vector3(-0.5, -0.5, -0.5);\r\n private _max = new Vector3(0.5, 0.5, 0.5);\r\n private _localPos = new Vector3();\r\n private _tmpVector = new Vector3();\r\n private _lerpVector0 = new Vector3();\r\n private _lerpVector1 = new Vector3();\r\n private _lerpVector2 = new Vector3();\r\n private _lerpVector3 = new Vector3();\r\n private _lerpVector4 = new Vector3();\r\n private _lerpVector5 = new Vector3();\r\n\r\n /**\r\n * @returns the string \"Lattice\"\r\n */\r\n public getClassName(): string {\r\n return \"Lattice\";\r\n }\r\n\r\n /**\r\n * Gets the resolution on x axis\r\n */\r\n public get resolutionX(): number {\r\n return this._resolutionX;\r\n }\r\n\r\n /**\r\n * Gets the resolution on y axis\r\n */\r\n public get resolutionY(): number {\r\n return this._resolutionY;\r\n }\r\n\r\n /**\r\n * Gets the resolution on z axis\r\n */\r\n public get resolutionZ(): number {\r\n return this._resolutionZ;\r\n }\r\n\r\n /**\r\n * Gets the size of the lattice along each axis in object space\r\n * Updating the size requires you to call update afterwards\r\n */\r\n public get size(): Vector3 {\r\n return this._size;\r\n }\r\n\r\n /**\r\n * Gets the lattice position in object space\r\n */\r\n public get position(): Vector3 {\r\n return this._position;\r\n }\r\n\r\n /**\r\n * Gets the data of the lattice\r\n */\r\n public get data(): Vector3[][][] {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets the size of each cell in the lattice\r\n */\r\n public get cellSize(): Vector3 {\r\n return this._cellSize;\r\n }\r\n\r\n /**\r\n * Gets the min bounds of the lattice\r\n */\r\n public get min(): Vector3 {\r\n return this._min;\r\n }\r\n\r\n /**\r\n * Gets the max bounds of the lattice\r\n */\r\n public get max(): Vector3 {\r\n return this._max;\r\n }\r\n\r\n /**\r\n * Creates a new Lattice\r\n * @param options options for creating\r\n */\r\n public constructor(options?: Partial<ILatticeOptions>) {\r\n const localOptions: ILatticeOptions = {\r\n resolutionX: 3,\r\n resolutionY: 3,\r\n resolutionZ: 3,\r\n position: Vector3.Zero(),\r\n size: Vector3.One(),\r\n ...options,\r\n };\r\n\r\n this._resolutionX = localOptions.resolutionX;\r\n this._resolutionY = localOptions.resolutionY;\r\n this._resolutionZ = localOptions.resolutionZ;\r\n this._position = localOptions.position;\r\n this._size = localOptions.autoAdaptToMesh ? localOptions.autoAdaptToMesh.getBoundingInfo().boundingBox.extendSize.scale(2) : localOptions.size;\r\n\r\n // Allocate data\r\n this._allocateData();\r\n this.update();\r\n }\r\n\r\n private _allocateData() {\r\n this._data = new Array<Array<Array<Vector3>>>(this.resolutionX);\r\n for (let i = 0; i < this.resolutionX; i++) {\r\n this._data[i] = new Array<Array<Vector3>>(this.resolutionY);\r\n for (let j = 0; j < this.resolutionY; j++) {\r\n this._data[i][j] = new Array<Vector3>(this.resolutionZ);\r\n for (let k = 0; k < this.resolutionZ; k++) {\r\n this._data[i][j][k] = Vector3.Zero();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Update of the lattice data\r\n */\r\n public update() {\r\n for (let i = 0; i < this.resolutionX; i++) {\r\n for (let j = 0; j < this.resolutionY; j++) {\r\n for (let k = 0; k < this.resolutionZ; k++) {\r\n const x = -this.size.x / 2 + this.size.x * (i / (this.resolutionX - 1));\r\n const y = -this.size.y / 2 + this.size.y * (j / (this.resolutionY - 1));\r\n const z = -this.size.z / 2 + this.size.z * (k / (this.resolutionZ - 1));\r\n\r\n this._data[i][j][k].set(x, y, z);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Apply the lattice to a mesh\r\n * @param mesh mesh to deform\r\n */\r\n public deformMesh(mesh: Mesh) {\r\n const positions = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n if (!positions) {\r\n return;\r\n }\r\n\r\n // Apply the lattice\r\n this.deform(positions);\r\n\r\n // Update back the mesh\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions, true);\r\n }\r\n\r\n /**\r\n * Update the lattice internals (like min, max and cell size)\r\n */\r\n public updateInternals() {\r\n const nx = this._resolutionX;\r\n const ny = this._resolutionY;\r\n const nz = this._resolutionZ;\r\n\r\n // Calculate the size of each cell in the lattice\r\n this._cellSize.set(this.size.x / (nx - 1), this.size.y / (ny - 1), this.size.z / (nz - 1));\r\n\r\n // Calculate the lattice bounds\r\n this._min.set(this.position.x - this.size.x / 2, this.position.y - this.size.y / 2, this.position.z - this.size.z / 2);\r\n this._min.addToRef(this._size, this._max);\r\n }\r\n\r\n /**\r\n * Apply the lattice to a set of points\r\n * @param positions vertex data to deform\r\n * @param target optional target array to store the result (operation will be done in place in not defined)\r\n */\r\n public deform(positions: FloatArray, target?: FloatArray) {\r\n const nx = this._resolutionX;\r\n const ny = this._resolutionY;\r\n const nz = this._resolutionZ;\r\n\r\n this.updateInternals();\r\n\r\n const min = this._min;\r\n const max = this._max;\r\n\r\n // Loop over each vertex\r\n for (let i = 0; i < positions.length; i += 3) {\r\n const vertex = this._tmpVector.fromArray(positions, i);\r\n\r\n // Check we are inside\r\n if (vertex.x < min.x || vertex.x > max.x || vertex.y < min.y || vertex.y > max.y || vertex.z < min.z || vertex.z > max.z) {\r\n if (target) {\r\n vertex.toArray(target, i);\r\n }\r\n continue;\r\n }\r\n\r\n // Map vertex position to lattice local coordinates\r\n const localPos = this._localPos.set((vertex.x - min.x) / this._cellSize.x, (vertex.y - min.y) / this._cellSize.y, (vertex.z - min.z) / this._cellSize.z);\r\n\r\n // Get integer lattice indices\r\n const i0 = Math.floor(localPos.x);\r\n const j0 = Math.floor(localPos.y);\r\n const k0 = Math.floor(localPos.z);\r\n\r\n const i1 = Math.min(i0 + 1, nx - 1);\r\n const j1 = Math.min(j0 + 1, ny - 1);\r\n const k1 = Math.min(k0 + 1, nz - 1);\r\n\r\n // Compute interpolation weights\r\n const tx = localPos.x - i0;\r\n const ty = localPos.y - j0;\r\n const tz = localPos.z - k0;\r\n\r\n // Ensure indices are within bounds\r\n const ii0 = Clamp(i0, 0, nx - 1);\r\n const jj0 = Clamp(j0, 0, ny - 1);\r\n const kk0 = Clamp(k0, 0, nz - 1);\r\n const ii1 = Clamp(i1, 0, nx - 1);\r\n const jj1 = Clamp(j1, 0, ny - 1);\r\n const kk1 = Clamp(k1, 0, nz - 1);\r\n\r\n // Get lattice control points\r\n const p000 = this._data[ii0][jj0][kk0];\r\n const p100 = this._data[ii1][jj0][kk0];\r\n const p010 = this._data[ii0][jj1][kk0];\r\n const p110 = this._data[ii1][jj1][kk0];\r\n const p001 = this._data[ii0][jj0][kk1];\r\n const p101 = this._data[ii1][jj0][kk1];\r\n const p011 = this._data[ii0][jj1][kk1];\r\n const p111 = this._data[ii1][jj1][kk1];\r\n\r\n // Trilinear interpolation\r\n const p00 = Vector3.LerpToRef(p000, p100, tx, this._lerpVector0);\r\n const p01 = Vector3.LerpToRef(p001, p101, tx, this._lerpVector1);\r\n const p10 = Vector3.LerpToRef(p010, p110, tx, this._lerpVector2);\r\n const p11 = Vector3.LerpToRef(p011, p111, tx, this._lerpVector3);\r\n\r\n const p0 = Vector3.LerpToRef(p00, p10, ty, this._lerpVector4);\r\n const p1 = Vector3.LerpToRef(p01, p11, ty, this._lerpVector5);\r\n\r\n const deformedPos = Vector3.LerpToRef(p0, p1, tz, this._lerpVector0);\r\n deformedPos.addInPlace(this.position);\r\n\r\n // Apply deformation to the vertex\r\n deformedPos.toArray(target || positions, i);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Material } from "../Materials/material.js";
|
|
2
|
+
import { MaterialPluginBase } from "../Materials/materialPluginBase.js";
|
|
3
|
+
import type { Lattice } from "./lattice";
|
|
4
|
+
import { ShaderLanguage } from "../Materials/shaderLanguage.js";
|
|
5
|
+
import type { UniformBuffer } from "../Materials/uniformBuffer.js";
|
|
6
|
+
/**
|
|
7
|
+
* Material plugin to add hardware accelerated lattice support
|
|
8
|
+
* #HBZD72#5 - webgl2
|
|
9
|
+
* #HBZD72#6 - webgpu
|
|
10
|
+
*/
|
|
11
|
+
export declare class LatticePluginMaterial extends MaterialPluginBase {
|
|
12
|
+
private _lattice;
|
|
13
|
+
private _latticeDataTexture;
|
|
14
|
+
private _latticeData;
|
|
15
|
+
private _code;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new LatticePluginMaterial
|
|
18
|
+
* @param lattice defines the lattice this plugin is associated with
|
|
19
|
+
* @param material defines the material this plugin is associated with
|
|
20
|
+
*/
|
|
21
|
+
constructor(lattice: Lattice, material: Material);
|
|
22
|
+
/**
|
|
23
|
+
* Get the class name of the plugin
|
|
24
|
+
* @returns the string "LatticePluginMaterial"
|
|
25
|
+
*/
|
|
26
|
+
getClassName(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Defines if the plugin supports the specified shader language
|
|
29
|
+
* @param shaderLanguage defines the shader language to check
|
|
30
|
+
* @returns true if supported, false otherwise
|
|
31
|
+
*/
|
|
32
|
+
isCompatible(shaderLanguage: ShaderLanguage): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Must be called when the lattice data was updated
|
|
35
|
+
*/
|
|
36
|
+
refreshData(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the description of the uniforms to add to the ubo (if engine supports ubos) or to inject directly in the vertex/fragment shaders (if engine does not support ubos)
|
|
39
|
+
* @param shaderLanguage The shader language to use.
|
|
40
|
+
* @returns the description of the uniforms
|
|
41
|
+
*/
|
|
42
|
+
getUniforms(shaderLanguage: ShaderLanguage): {
|
|
43
|
+
ubo: {
|
|
44
|
+
name: string;
|
|
45
|
+
size: number;
|
|
46
|
+
type: string;
|
|
47
|
+
}[];
|
|
48
|
+
vertex?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
ubo: {
|
|
51
|
+
name: string;
|
|
52
|
+
size: number;
|
|
53
|
+
type: string;
|
|
54
|
+
}[];
|
|
55
|
+
vertex: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Binds the material data.
|
|
59
|
+
* @param uniformBuffer defines the Uniform buffer to fill in.
|
|
60
|
+
*/
|
|
61
|
+
bindForSubMesh(uniformBuffer: UniformBuffer): void;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the samplers used by the plugin.
|
|
64
|
+
* @param samplers list that the sampler names should be added to.
|
|
65
|
+
*/
|
|
66
|
+
getSamplers(samplers: string[]): void;
|
|
67
|
+
private _prepareCode;
|
|
68
|
+
/**
|
|
69
|
+
* Returns a list of custom shader code fragments to customize the shader.
|
|
70
|
+
* @param shaderType "vertex" or "fragment"
|
|
71
|
+
* @param shaderLanguage The shader language to use.
|
|
72
|
+
* @returns null if no code to be added, or a list of pointName =\> code.
|
|
73
|
+
*/
|
|
74
|
+
getCustomCode(shaderType: string, shaderLanguage?: ShaderLanguage): {
|
|
75
|
+
CUSTOM_VERTEX_DEFINITIONS: string;
|
|
76
|
+
CUSTOM_VERTEX_UPDATE_POSITION: string;
|
|
77
|
+
} | null;
|
|
78
|
+
/**
|
|
79
|
+
* Disposes the resources of the material.
|
|
80
|
+
*/
|
|
81
|
+
dispose(): void;
|
|
82
|
+
}
|