@babylonjs/core 7.28.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/Culling/ray.core.d.ts +13 -0
- package/Culling/ray.core.js +14 -6
- package/Culling/ray.core.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.js +24 -0
- package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
- 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/index.d.ts +1 -0
- package/Engines/index.js +1 -0
- package/Engines/index.js.map +1 -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 +2 -4
- package/Engines/webgpuEngine.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +1 -1
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +34 -18
- package/Loading/Plugins/babylonFileLoader.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/Textures/renderTargetTexture.js +1 -2
- package/Materials/Textures/renderTargetTexture.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/Builders/greasedLineBuilder.d.ts +0 -16
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +17 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +3 -2
- package/Meshes/GreasedLine/greasedLineBaseMesh.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/Set/setPositionsBlock.js +11 -4
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- 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/abstractMesh.d.ts +2 -0
- package/Meshes/abstractMesh.hotSpot.d.ts +30 -0
- package/Meshes/abstractMesh.hotSpot.js +84 -0
- package/Meshes/abstractMesh.hotSpot.js.map +1 -0
- package/Meshes/abstractMesh.js +2 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/index.d.ts +3 -0
- package/Meshes/index.js +3 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/lattice.d.ts +110 -0
- package/Meshes/lattice.js +224 -0
- package/Meshes/lattice.js.map +1 -0
- package/Meshes/lattice.material.d.ts +82 -0
- package/Meshes/lattice.material.js +259 -0
- package/Meshes/lattice.material.js.map +1 -0
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +1 -2
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/screenshotTools.js +0 -3
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +63 -0
- package/Misc/snapshotRenderingHelper.js +182 -0
- package/Misc/snapshotRenderingHelper.js.map +1 -0
- package/Morph/morphTargetManager.js +0 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Shaders/spriteMap.fragment.d.ts +4 -0
- package/Shaders/spriteMap.fragment.js +16 -3
- package/Shaders/spriteMap.fragment.js.map +1 -1
- package/Shaders/spriteMap.vertex.d.ts +3 -0
- package/Shaders/spriteMap.vertex.js +14 -2
- package/Shaders/spriteMap.vertex.js.map +1 -1
- package/ShadersWGSL/bilateralBlurQuality.fragment.js +1 -1
- package/ShadersWGSL/bilateralBlurQuality.fragment.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +1 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.js +2 -2
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.js +2 -2
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +1 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/rsmFullGlobalIllumination.fragment.js +1 -1
- package/ShadersWGSL/rsmFullGlobalIllumination.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/spriteMap.d.ts +7 -0
- package/Sprites/spriteMap.js +29 -1
- package/Sprites/spriteMap.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greasedLineBaseMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GreasedLine/greasedLineBaseMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAIlG;;;GAGG;AACH,MAAM,CAAN,IAAkB,2BAGjB;AAHD,WAAkB,2BAA2B;IACzC,yGAAsB,CAAA;IACtB,uGAAqB,CAAA;AACzB,CAAC,EAHiB,2BAA2B,KAA3B,2BAA2B,QAG5C;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAkB,0BAIjB;AAJD,WAAkB,0BAA0B;IACxC,iHAA2B,CAAA;IAC3B,yJAA+C,CAAA;IAC/C,iHAA2B,CAAA;AAC/B,CAAC,EAJiB,0BAA0B,KAA1B,0BAA0B,QAI3C;AAED;;;;;;;GAOG;AACH,MAAM,CAAN,IAAkB,kCAMjB;AAND,WAAkB,kCAAkC;IAChD,uJAAsC,CAAA;IACtC,qJAAqC,CAAA;IACrC,mIAA4B,CAAA;IAC5B,iIAA2B,CAAA;IAC3B,4HAAyB,CAAA;AAC7B,CAAC,EANiB,kCAAk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terialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { FloatArray, IndicesArray } from \"../../types\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport const enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport const enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport const enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_FACE_TO = 3,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: FloatArray;\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: FloatArray;\r\n protected _indices: IndicesArray;\r\n protected _uvs: FloatArray;\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: AbstractEngine;\r\n\r\n constructor(\r\n public override readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n !this.doNotSyncBoundingInfo && this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public addPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n for (const p of points) {\r\n this._points.push(p);\r\n }\r\n\r\n if (!this._lazy) {\r\n this.setPoints(this._points, options);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the line and it's resources\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false) {\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Returns the UVs\r\n */\r\n get uvs() {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Sets the UVs\r\n * @param uvs the UVs\r\n */\r\n set uvs(uvs: FloatArray) {\r\n this._uvs = uvs instanceof Float32Array ? uvs : new Float32Array(uvs);\r\n this._createVertexBuffers();\r\n }\r\n\r\n /**\r\n * Returns the points offsets\r\n * Return the points offsets\r\n */\r\n get offsets() {\r\n return this._offsets;\r\n }\r\n\r\n /**\r\n * Sets point offests\r\n * @param offsets offset table [x,y,z, x,y,z, ....]\r\n */\r\n set offsets(offsets: number[]) {\r\n this._offsets = offsets;\r\n if (!this._offsetsBuffer) {\r\n this._createOffsetsBuffer(offsets);\r\n } else {\r\n this._offsetsBuffer.update(offsets);\r\n }\r\n }\r\n\r\n /**\r\n * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]\r\n */\r\n get widths() {\r\n return this._widths;\r\n }\r\n\r\n /**\r\n * Sets widths at each line point\r\n * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]\r\n */\r\n set widths(widths: number[]) {\r\n this._widths = widths;\r\n if (!this._lazy) {\r\n this._widthsBuffer && this._widthsBuffer.update(widths);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors\r\n */\r\n get colorPointers() {\r\n return this._colorPointers;\r\n }\r\n\r\n /**\r\n * Sets the color pointer\r\n * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.\r\n */\r\n set colorPointers(colorPointers: number[]) {\r\n this._colorPointers = colorPointers;\r\n if (!this._lazy) {\r\n this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the pluginMaterial associated with line\r\n */\r\n get greasedLineMaterial(): IGreasedLineMaterial | undefined {\r\n if (this.material && this.material instanceof GreasedLineSimpleMaterial) {\r\n return this.material;\r\n }\r\n const materialPlugin = this.material?.pluginManager?.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);\r\n if (materialPlugin) {\r\n return <GreasedLinePluginMaterial>materialPlugin;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * Return copy the points.\r\n */\r\n get points() {\r\n const pointsCopy: number[][] = [];\r\n DeepCopier.DeepCopy(this._points, pointsCopy);\r\n return pointsCopy;\r\n }\r\n\r\n /**\r\n * Sets line points and rerenders the line.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public setPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n this._points = points;\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public override serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"greasedLineBaseMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GreasedLine/greasedLineBaseMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAGlG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAN,IAAkB,2BAGjB;AAHD,WAAkB,2BAA2B;IACzC,yGAAsB,CAAA;IACtB,uGAAqB,CAAA;AACzB,CAAC,EAHiB,2BAA2B,KAA3B,2BAA2B,QAG5C;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAkB,0BAIjB;AAJD,WAAkB,0BAA0B;IACxC,iHAA2B,CAAA;IAC3B,yJAA+C,CAAA;IAC/C,iHAA2B,CAAA;AAC/B,CAAC,EAJiB,0BAA0B,KAA1B,0BAA0B,QAI3C;AAED;;;;;;;GAOG;AACH,MAAM,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,UAAU,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IGreasedLineMaterial } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { FloatArray, IndicesArray } from \"../../types\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport const enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport const enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport const enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_FACE_TO = 3,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for converting the points to the internal number[][] format used by GreasedLine\r\n */\r\nexport interface GreasedLinePointsOptions {\r\n /**\r\n * If defined and a Float32Array is used for the points parameter,\r\n * it will create multiple disconnected lines.\r\n * This parameter defines how many entries from the array to use for one line.\r\n * One entry = 3 float values.\r\n */\r\n floatArrayStride?: number;\r\n}\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: FloatArray;\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n /**\r\n * Options for converting the points.\r\n */\r\n pointsOptions?: GreasedLinePointsOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: FloatArray;\r\n protected _indices: IndicesArray;\r\n protected _uvs: FloatArray;\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: AbstractEngine;\r\n\r\n constructor(\r\n public override readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n !this.doNotSyncBoundingInfo && this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public addPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n for (const p of points) {\r\n this._points.push(p);\r\n }\r\n\r\n if (!this._lazy) {\r\n this.setPoints(this._points, options);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the line and it's resources\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false) {\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Returns the UVs\r\n */\r\n get uvs() {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Sets the UVs\r\n * @param uvs the UVs\r\n */\r\n set uvs(uvs: FloatArray) {\r\n this._uvs = uvs instanceof Float32Array ? uvs : new Float32Array(uvs);\r\n this._createVertexBuffers();\r\n }\r\n\r\n /**\r\n * Returns the points offsets\r\n * Return the points offsets\r\n */\r\n get offsets() {\r\n return this._offsets;\r\n }\r\n\r\n /**\r\n * Sets point offests\r\n * @param offsets offset table [x,y,z, x,y,z, ....]\r\n */\r\n set offsets(offsets: number[]) {\r\n this._offsets = offsets;\r\n if (!this._offsetsBuffer) {\r\n this._createOffsetsBuffer(offsets);\r\n } else {\r\n this._offsetsBuffer.update(offsets);\r\n }\r\n }\r\n\r\n /**\r\n * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]\r\n */\r\n get widths() {\r\n return this._widths;\r\n }\r\n\r\n /**\r\n * Sets widths at each line point\r\n * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]\r\n */\r\n set widths(widths: number[]) {\r\n this._widths = widths;\r\n if (!this._lazy) {\r\n this._widthsBuffer && this._widthsBuffer.update(widths);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors\r\n */\r\n get colorPointers() {\r\n return this._colorPointers;\r\n }\r\n\r\n /**\r\n * Sets the color pointer\r\n * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.\r\n */\r\n set colorPointers(colorPointers: number[]) {\r\n this._colorPointers = colorPointers;\r\n if (!this._lazy) {\r\n this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the pluginMaterial associated with line\r\n */\r\n get greasedLineMaterial(): IGreasedLineMaterial | undefined {\r\n if (this.material && this.material instanceof GreasedLineSimpleMaterial) {\r\n return this.material;\r\n }\r\n const materialPlugin = this.material?.pluginManager?.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);\r\n if (materialPlugin) {\r\n return <GreasedLinePluginMaterial>materialPlugin;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * Return copy the points.\r\n */\r\n get points() {\r\n const pointsCopy: number[][] = [];\r\n DeepCopier.DeepCopy(this._points, pointsCopy);\r\n return pointsCopy;\r\n }\r\n\r\n /**\r\n * Sets line points and rerenders the line.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public setPoints(points: GreasedLinePoints, options?: GreasedLineMeshOptions) {\r\n this._points = GreasedLineTools.ConvertPoints(points, options?.pointsOptions ?? this._options.pointsOptions);\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(this._points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public override serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { NodeGeometryBlock } from "../../nodeGeometryBlock";
|
|
2
|
+
import type { NodeGeometryConnectionPoint } from "../../nodeGeometryBlockConnectionPoint";
|
|
3
|
+
import type { NodeGeometryBuildState } from "../../nodeGeometryBuildState";
|
|
4
|
+
import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometryExecutionContext";
|
|
5
|
+
import { Vector3 } from "../../../../Maths/math.vector";
|
|
6
|
+
/**
|
|
7
|
+
* Block used to apply Lattice on geometry
|
|
8
|
+
*/
|
|
9
|
+
export declare class LatticeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
|
|
10
|
+
private _vertexData;
|
|
11
|
+
private _currentIndexX;
|
|
12
|
+
private _currentIndexY;
|
|
13
|
+
private _currentIndexZ;
|
|
14
|
+
private _lattice;
|
|
15
|
+
private _indexVector3;
|
|
16
|
+
private _currentControl;
|
|
17
|
+
/**
|
|
18
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
19
|
+
* Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
|
|
20
|
+
*/
|
|
21
|
+
evaluateContext: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Resolution on x axis
|
|
24
|
+
*/
|
|
25
|
+
resolutionX: number;
|
|
26
|
+
/**
|
|
27
|
+
* Resolution on y axis
|
|
28
|
+
*/
|
|
29
|
+
resolutionY: number;
|
|
30
|
+
/**
|
|
31
|
+
* Resolution on z axis
|
|
32
|
+
*/
|
|
33
|
+
resolutionZ: number;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new LatticeBlock
|
|
36
|
+
* @param name defines the block name
|
|
37
|
+
*/
|
|
38
|
+
constructor(name: string);
|
|
39
|
+
/**
|
|
40
|
+
* Gets the current index in the current flow
|
|
41
|
+
* @returns the current index
|
|
42
|
+
*/
|
|
43
|
+
getExecutionIndex(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the current loop index in the current flow
|
|
46
|
+
* @returns the current loop index
|
|
47
|
+
*/
|
|
48
|
+
getExecutionLoopIndex(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the current face index in the current flow
|
|
51
|
+
* @returns the current face index
|
|
52
|
+
*/
|
|
53
|
+
getExecutionFaceIndex(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the current class name
|
|
56
|
+
* @returns the class name
|
|
57
|
+
*/
|
|
58
|
+
getClassName(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the geometry input component
|
|
61
|
+
*/
|
|
62
|
+
get geometry(): NodeGeometryConnectionPoint;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the controls input component
|
|
65
|
+
*/
|
|
66
|
+
get controls(): NodeGeometryConnectionPoint;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the geometry output component
|
|
69
|
+
*/
|
|
70
|
+
get output(): NodeGeometryConnectionPoint;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the value associated with a contextual positions
|
|
73
|
+
* In this case it will be the current position in the lattice
|
|
74
|
+
* @returns the current position in the lattice
|
|
75
|
+
*/
|
|
76
|
+
getOverridePositionsContextualValue(): Vector3;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the value associated with a contextual normals
|
|
79
|
+
* In this case it will be the current control point being processed
|
|
80
|
+
* @returns the current control point being processed
|
|
81
|
+
*/
|
|
82
|
+
getOverrideNormalsContextualValue(): Vector3;
|
|
83
|
+
protected _buildBlock(state: NodeGeometryBuildState): void;
|
|
84
|
+
protected _dumpPropertiesCode(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Serializes this block in a JSON representation
|
|
87
|
+
* @returns the serialized block object
|
|
88
|
+
*/
|
|
89
|
+
serialize(): any;
|
|
90
|
+
_deserialize(serializationObject: any): void;
|
|
91
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { __decorate } from "../../../../tslib.es6.js";
|
|
2
|
+
import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
|
|
3
|
+
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
4
|
+
import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
|
|
5
|
+
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
6
|
+
import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
|
|
7
|
+
import { Lattice } from "../../../lattice.js";
|
|
8
|
+
import { extractMinAndMax } from "../../../../Maths/math.functions.js";
|
|
9
|
+
/**
|
|
10
|
+
* Block used to apply Lattice on geometry
|
|
11
|
+
*/
|
|
12
|
+
export class LatticeBlock extends NodeGeometryBlock {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new LatticeBlock
|
|
15
|
+
* @param name defines the block name
|
|
16
|
+
*/
|
|
17
|
+
constructor(name) {
|
|
18
|
+
super(name);
|
|
19
|
+
this._indexVector3 = new Vector3();
|
|
20
|
+
this._currentControl = new Vector3();
|
|
21
|
+
/**
|
|
22
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
23
|
+
* Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
|
|
24
|
+
*/
|
|
25
|
+
this.evaluateContext = true;
|
|
26
|
+
/**
|
|
27
|
+
* Resolution on x axis
|
|
28
|
+
*/
|
|
29
|
+
this.resolutionX = 3;
|
|
30
|
+
/**
|
|
31
|
+
* Resolution on y axis
|
|
32
|
+
*/
|
|
33
|
+
this.resolutionY = 3;
|
|
34
|
+
/**
|
|
35
|
+
* Resolution on z axis
|
|
36
|
+
*/
|
|
37
|
+
this.resolutionZ = 3;
|
|
38
|
+
this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
39
|
+
this.registerInput("controls", NodeGeometryBlockConnectionPointTypes.Vector3);
|
|
40
|
+
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the current index in the current flow
|
|
44
|
+
* @returns the current index
|
|
45
|
+
*/
|
|
46
|
+
getExecutionIndex() {
|
|
47
|
+
return this._currentIndexX + this.resolutionX * (this._currentIndexY + this.resolutionY * this._currentIndexZ);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the current loop index in the current flow
|
|
51
|
+
* @returns the current loop index
|
|
52
|
+
*/
|
|
53
|
+
getExecutionLoopIndex() {
|
|
54
|
+
return this.getExecutionIndex();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets the current face index in the current flow
|
|
58
|
+
* @returns the current face index
|
|
59
|
+
*/
|
|
60
|
+
getExecutionFaceIndex() {
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current class name
|
|
65
|
+
* @returns the class name
|
|
66
|
+
*/
|
|
67
|
+
getClassName() {
|
|
68
|
+
return "LatticeBlock";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the geometry input component
|
|
72
|
+
*/
|
|
73
|
+
get geometry() {
|
|
74
|
+
return this._inputs[0];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the controls input component
|
|
78
|
+
*/
|
|
79
|
+
get controls() {
|
|
80
|
+
return this._inputs[1];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets the geometry output component
|
|
84
|
+
*/
|
|
85
|
+
get output() {
|
|
86
|
+
return this._outputs[0];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets the value associated with a contextual positions
|
|
90
|
+
* In this case it will be the current position in the lattice
|
|
91
|
+
* @returns the current position in the lattice
|
|
92
|
+
*/
|
|
93
|
+
getOverridePositionsContextualValue() {
|
|
94
|
+
return this._indexVector3;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the value associated with a contextual normals
|
|
98
|
+
* In this case it will be the current control point being processed
|
|
99
|
+
* @returns the current control point being processed
|
|
100
|
+
*/
|
|
101
|
+
getOverrideNormalsContextualValue() {
|
|
102
|
+
return this._currentControl;
|
|
103
|
+
}
|
|
104
|
+
_buildBlock(state) {
|
|
105
|
+
const func = (state) => {
|
|
106
|
+
state.pushExecutionContext(this);
|
|
107
|
+
this._vertexData = this.geometry.getConnectedValue(state);
|
|
108
|
+
if (this._vertexData) {
|
|
109
|
+
this._vertexData = this._vertexData.clone(); // Preserve source data
|
|
110
|
+
}
|
|
111
|
+
if (!this._vertexData || !this._vertexData.positions) {
|
|
112
|
+
state.restoreExecutionContext();
|
|
113
|
+
this.output._storedValue = null;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const positions = this._vertexData.positions;
|
|
117
|
+
const boundingInfo = extractMinAndMax(positions, 0, positions.length / 3);
|
|
118
|
+
// Building the lattice
|
|
119
|
+
this._lattice = new Lattice({
|
|
120
|
+
resolutionX: this.resolutionX,
|
|
121
|
+
resolutionY: this.resolutionY,
|
|
122
|
+
resolutionZ: this.resolutionZ,
|
|
123
|
+
size: boundingInfo.maximum.subtract(boundingInfo.minimum),
|
|
124
|
+
});
|
|
125
|
+
for (this._currentIndexX = 0; this._currentIndexX < this.resolutionX; this._currentIndexX++) {
|
|
126
|
+
for (this._currentIndexY = 0; this._currentIndexY < this.resolutionY; this._currentIndexY++) {
|
|
127
|
+
for (this._currentIndexZ = 0; this._currentIndexZ < this.resolutionZ; this._currentIndexZ++) {
|
|
128
|
+
this._indexVector3.set(this._currentIndexX, this._currentIndexY, this._currentIndexZ);
|
|
129
|
+
const latticeControl = this._lattice.data[this._currentIndexX][this._currentIndexY][this._currentIndexZ];
|
|
130
|
+
this._currentControl.copyFrom(latticeControl);
|
|
131
|
+
const tempVector3 = this.controls.getConnectedValue(state);
|
|
132
|
+
if (tempVector3) {
|
|
133
|
+
latticeControl.set(tempVector3.x, tempVector3.y, tempVector3.z);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Apply lattice
|
|
139
|
+
this._lattice.deform(positions);
|
|
140
|
+
// Storage
|
|
141
|
+
state.restoreExecutionContext();
|
|
142
|
+
return this._vertexData;
|
|
143
|
+
};
|
|
144
|
+
if (this.evaluateContext) {
|
|
145
|
+
this.output._storedFunction = func;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.output._storedFunction = null;
|
|
149
|
+
this.output._storedValue = func(state);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
_dumpPropertiesCode() {
|
|
153
|
+
let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
|
|
154
|
+
codeString += `${this._codeVariableName}.resolutionX = ${this.resolutionX};\n`;
|
|
155
|
+
codeString += `${this._codeVariableName}.resolutionY = ${this.resolutionY};\n`;
|
|
156
|
+
codeString += `${this._codeVariableName}.resolutionZ = ${this.resolutionZ};\n`;
|
|
157
|
+
return codeString;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Serializes this block in a JSON representation
|
|
161
|
+
* @returns the serialized block object
|
|
162
|
+
*/
|
|
163
|
+
serialize() {
|
|
164
|
+
const serializationObject = super.serialize();
|
|
165
|
+
serializationObject.evaluateContext = this.evaluateContext;
|
|
166
|
+
serializationObject.resolutionX = this.resolutionX;
|
|
167
|
+
serializationObject.resolutionY = this.resolutionY;
|
|
168
|
+
serializationObject.resolutionZ = this.resolutionZ;
|
|
169
|
+
return serializationObject;
|
|
170
|
+
}
|
|
171
|
+
_deserialize(serializationObject) {
|
|
172
|
+
super._deserialize(serializationObject);
|
|
173
|
+
if (serializationObject.evaluateContext !== undefined) {
|
|
174
|
+
this.evaluateContext = serializationObject.evaluateContext;
|
|
175
|
+
this.resolutionX = serializationObject.resolutionX;
|
|
176
|
+
this.resolutionY = serializationObject.resolutionY;
|
|
177
|
+
this.resolutionZ = serializationObject.resolutionZ;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
__decorate([
|
|
182
|
+
editableInPropertyPage("Evaluate context", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { rebuild: true } })
|
|
183
|
+
], LatticeBlock.prototype, "evaluateContext", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
editableInPropertyPage("resolutionX", 2 /* PropertyTypeForEdition.Int */, "ADVANCED", { notifiers: { rebuild: true }, min: 1, max: 10 })
|
|
186
|
+
], LatticeBlock.prototype, "resolutionX", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
editableInPropertyPage("resolutionY", 2 /* PropertyTypeForEdition.Int */, "ADVANCED", { notifiers: { rebuild: true }, min: 1, max: 10 })
|
|
189
|
+
], LatticeBlock.prototype, "resolutionY", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
editableInPropertyPage("resolutionZ", 2 /* PropertyTypeForEdition.Int */, "ADVANCED", { notifiers: { rebuild: true }, min: 1, max: 10 })
|
|
192
|
+
], LatticeBlock.prototype, "resolutionZ", void 0);
|
|
193
|
+
RegisterClass("BABYLON.LatticeBlock", LatticeBlock);
|
|
194
|
+
//# sourceMappingURL=latticeBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latticeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/latticeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAA0B,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,4BAA4B;AAC9C,OAAO,EAAE,gBAAgB,EAAE,4CAAkC;AAE7D;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,iBAAiB;IAkC/C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAjCR,kBAAa,GAAG,IAAI,OAAO,EAAE,CAAC;QAC9B,oBAAe,GAAG,IAAI,OAAO,EAAE,CAAC;QAExC;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAE9B;;WAEG;QAEI,g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CAA8B,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1G;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1G;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1G;AAmL3B,aAAa,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport { Lattice } from \"core/Meshes/lattice\";\r\nimport { extractMinAndMax } from \"core/Maths/math.functions\";\r\n\r\n/**\r\n * Block used to apply Lattice on geometry\r\n */\r\nexport class LatticeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndexX: number;\r\n private _currentIndexY: number;\r\n private _currentIndexZ: number;\r\n private _lattice: Lattice;\r\n private _indexVector3 = new Vector3();\r\n private _currentControl = new Vector3();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Resolution on x axis\r\n */\r\n @editableInPropertyPage(\"resolutionX\", PropertyTypeForEdition.Int, \"ADVANCED\", { notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionX = 3;\r\n\r\n /**\r\n * Resolution on y axis\r\n */\r\n @editableInPropertyPage(\"resolutionY\", PropertyTypeForEdition.Int, \"ADVANCED\", { notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionY = 3;\r\n\r\n /**\r\n * Resolution on z axis\r\n */\r\n @editableInPropertyPage(\"resolutionZ\", PropertyTypeForEdition.Int, \"ADVANCED\", { notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionZ = 3;\r\n\r\n /**\r\n * Create a new LatticeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"controls\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndexX + this.resolutionX * (this._currentIndexY + this.resolutionY * this._currentIndexZ);\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this.getExecutionIndex();\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"LatticeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the controls input component\r\n */\r\n public get controls(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual positions\r\n * In this case it will be the current position in the lattice\r\n * @returns the current position in the lattice\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._indexVector3;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual normals\r\n * In this case it will be the current control point being processed\r\n * @returns the current control point being processed\r\n */\r\n public getOverrideNormalsContextualValue() {\r\n return this._currentControl;\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n const positions = this._vertexData.positions;\r\n const boundingInfo = extractMinAndMax(positions!, 0, positions!.length / 3);\r\n\r\n // Building the lattice\r\n this._lattice = new Lattice({\r\n resolutionX: this.resolutionX,\r\n resolutionY: this.resolutionY,\r\n resolutionZ: this.resolutionZ,\r\n size: boundingInfo.maximum.subtract(boundingInfo.minimum),\r\n });\r\n\r\n for (this._currentIndexX = 0; this._currentIndexX < this.resolutionX; this._currentIndexX++) {\r\n for (this._currentIndexY = 0; this._currentIndexY < this.resolutionY; this._currentIndexY++) {\r\n for (this._currentIndexZ = 0; this._currentIndexZ < this.resolutionZ; this._currentIndexZ++) {\r\n this._indexVector3.set(this._currentIndexX, this._currentIndexY, this._currentIndexZ);\r\n const latticeControl = this._lattice.data[this._currentIndexX][this._currentIndexY][this._currentIndexZ];\r\n this._currentControl.copyFrom(latticeControl);\r\n const tempVector3 = this.controls.getConnectedValue(state) as Vector3;\r\n\r\n if (tempVector3) {\r\n latticeControl.set(tempVector3.x, tempVector3.y, tempVector3.z);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Apply lattice\r\n this._lattice.deform(positions);\r\n\r\n // Storage\r\n state.restoreExecutionContext();\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n\r\n codeString += `${this._codeVariableName}.resolutionX = ${this.resolutionX};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionY = ${this.resolutionY};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionZ = ${this.resolutionZ};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n serializationObject.resolutionX = this.resolutionX;\r\n serializationObject.resolutionY = this.resolutionY;\r\n serializationObject.resolutionZ = this.resolutionZ;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n this.resolutionX = serializationObject.resolutionX;\r\n this.resolutionY = serializationObject.resolutionY;\r\n this.resolutionZ = serializationObject.resolutionZ;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.LatticeBlock\", LatticeBlock);\r\n"]}
|
|
@@ -133,10 +133,17 @@ export class SetPositionsBlock extends NodeGeometryBlock {
|
|
|
133
133
|
// Indices remap
|
|
134
134
|
if (this._vertexData.indices) {
|
|
135
135
|
const newIndices = [];
|
|
136
|
-
for (let index = 0; index < this._vertexData.indices.length; index
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
for (let index = 0; index < this._vertexData.indices.length; index += 3) {
|
|
137
|
+
const a = this._vertexData.indices[index];
|
|
138
|
+
const b = this._vertexData.indices[index + 1];
|
|
139
|
+
const c = this._vertexData.indices[index + 2];
|
|
140
|
+
const remappedA = remap[a];
|
|
141
|
+
const remappedB = remap[b];
|
|
142
|
+
const remappedC = remap[c];
|
|
143
|
+
if (remappedA !== undefined && remappedB !== undefined && remappedC !== undefined) {
|
|
144
|
+
newIndices.push(remappedA);
|
|
145
|
+
newIndices.push(remappedB);
|
|
146
|
+
newIndices.push(remappedC);
|
|
140
147
|
}
|
|
141
148
|
}
|
|
142
149
|
this._vertexData.indices = newIndices;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setPositionsBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/setPositionsBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAKrG,OAAO,EAA0B,sBAAsB,EAAE,gDAAsC;AAG/F;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAWpD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZhB;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAS1B,IAAI,C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,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1C;IACL,CAAC;IAEkB,mBAAmB;QAClC,MAAM,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,GAAG,GAAG,IAAI,CAAC,iBAAiB,sBAAsB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;QAC7I,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;SAC9D;IACL,CAAC;CACJ;AAxOU;IADN,sBAAsB,CAAC,kBAAkB,0CAAkC,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;0DAC3F;AA0OlC,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport type { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport type { FloatArray } from \"core/types\";\r\n\r\n/**\r\n * Block used to set positions for a geometry\r\n */\r\nexport class SetPositionsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new SetPositionsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"positions\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SetPositionsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the positions input component\r\n */\r\n public get positions(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _remapVector3Data(source: FloatArray, remap: { [key: number]: number }): FloatArray {\r\n const newData: FloatArray = [];\r\n for (let index = 0; index < source.length; index += 3) {\r\n const remappedIndex = remap[index / 3];\r\n\r\n if (remappedIndex !== undefined) {\r\n newData.push(source[index], source[index + 1], source[index + 2]);\r\n }\r\n }\r\n return newData;\r\n }\r\n\r\n private _remapVector4Data(source: FloatArray, remap: { [key: number]: number }): FloatArray {\r\n const newData: FloatArray = [];\r\n for (let index = 0; index < source.length; index += 4) {\r\n const remappedIndex = remap[index / 4];\r\n\r\n if (remappedIndex !== undefined) {\r\n newData.push(source[index], source[index + 1], source[index + 2], source[index + 3]);\r\n }\r\n }\r\n return newData;\r\n }\r\n\r\n private _remapVector2Data(source: FloatArray, remap: { [key: number]: number }): FloatArray {\r\n const newData: FloatArray = [];\r\n for (let index = 0; index < source.length; index += 2) {\r\n const remappedIndex = remap[index / 2];\r\n\r\n if (remappedIndex !== undefined) {\r\n newData.push(source[index], source[index + 1]);\r\n }\r\n }\r\n return newData;\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n state.pushGeometryContext(this._vertexData);\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this.positions.isConnected) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n const remap: { [key: number]: number } = {};\r\n const vertexCount = this._vertexData.positions.length / 3;\r\n const newPositions: FloatArray = [];\r\n let activeIndex = 0;\r\n let resize = false;\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const tempVector3 = this.positions.getConnectedValue(state) as Vector3;\r\n if (tempVector3) {\r\n tempVector3.toArray(newPositions, activeIndex * 3);\r\n remap[this._currentIndex] = activeIndex;\r\n activeIndex++;\r\n } else {\r\n resize = true;\r\n }\r\n }\r\n\r\n if (resize) {\r\n // Indices remap\r\n if (this._vertexData.indices) {\r\n const newIndices: number[] = [];\r\n for (let index = 0; index < this._vertexData.indices.length; index++) {\r\n const remappedIndex = remap[this._vertexData.indices[index]];\r\n\r\n if (remappedIndex !== undefined) {\r\n newIndices.push(remappedIndex);\r\n }\r\n }\r\n\r\n this._vertexData.indices = newIndices;\r\n }\r\n\r\n // Normals remap\r\n if (this._vertexData.normals) {\r\n this._vertexData.normals = this._remapVector3Data(this._vertexData.normals, remap);\r\n }\r\n\r\n // Tangents remap\r\n if (this._vertexData.tangents) {\r\n this._vertexData.tangents = this._remapVector4Data(this._vertexData.tangents, remap);\r\n }\r\n\r\n // Colors remap\r\n if (this._vertexData.colors) {\r\n this._vertexData.colors = this._remapVector4Data(this._vertexData.colors, remap);\r\n }\r\n\r\n // UVs remap\r\n if (this._vertexData.uvs) {\r\n this._vertexData.uvs = this._remapVector2Data(this._vertexData.uvs, remap);\r\n }\r\n if (this._vertexData.uvs2) {\r\n this._vertexData.uvs2 = this._remapVector2Data(this._vertexData.uvs2, remap);\r\n }\r\n if (this._vertexData.uvs3) {\r\n this._vertexData.uvs3 = this._remapVector2Data(this._vertexData.uvs3, remap);\r\n }\r\n if (this._vertexData.uvs4) {\r\n this._vertexData.uvs4 = this._remapVector2Data(this._vertexData.uvs4, remap);\r\n }\r\n if (this._vertexData.uvs5) {\r\n this._vertexData.uvs5 = this._remapVector2Data(this._vertexData.uvs5, remap);\r\n }\r\n if (this._vertexData.uvs6) {\r\n this._vertexData.uvs6 = this._remapVector2Data(this._vertexData.uvs6, remap);\r\n }\r\n }\r\n\r\n // Update positions\r\n this._vertexData.positions = newPositions;\r\n\r\n // Storage\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetPositionsBlock\", SetPositionsBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"setPositionsBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/setPositionsBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAKrG,OAAO,EAA0B,sBAAsB,EAAE,gDAAsC;AAG/F;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAWpD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZhB;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAS1B,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E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AE,IAAI,EAAE,EAAE,CAAC;0DAC3F;AAiPlC,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport type { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport type { FloatArray } from \"core/types\";\r\n\r\n/**\r\n * Block used to set positions for a geometry\r\n */\r\nexport class SetPositionsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new SetPositionsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"positions\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SetPositionsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the positions input component\r\n */\r\n public get positions(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _remapVector3Data(source: FloatArray, remap: { [key: number]: number }): FloatArray {\r\n const newData: FloatArray = [];\r\n for (let index = 0; index < source.length; index += 3) {\r\n const remappedIndex = remap[index / 3];\r\n\r\n if (remappedIndex !== undefined) {\r\n newData.push(source[index], source[index + 1], source[index + 2]);\r\n }\r\n }\r\n return newData;\r\n }\r\n\r\n private _remapVector4Data(source: FloatArray, remap: { [key: number]: number }): FloatArray {\r\n const newData: FloatArray = [];\r\n for (let index = 0; index < source.length; index += 4) {\r\n const remappedIndex = remap[index / 4];\r\n\r\n if (remappedIndex !== undefined) {\r\n newData.push(source[index], source[index + 1], source[index + 2], source[index + 3]);\r\n }\r\n }\r\n return newData;\r\n }\r\n\r\n private _remapVector2Data(source: FloatArray, remap: { [key: number]: number }): FloatArray {\r\n const newData: FloatArray = [];\r\n for (let index = 0; index < source.length; index += 2) {\r\n const remappedIndex = remap[index / 2];\r\n\r\n if (remappedIndex !== undefined) {\r\n newData.push(source[index], source[index + 1]);\r\n }\r\n }\r\n return newData;\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n state.pushGeometryContext(this._vertexData);\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this.positions.isConnected) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n const remap: { [key: number]: number } = {};\r\n const vertexCount = this._vertexData.positions.length / 3;\r\n const newPositions: FloatArray = [];\r\n let activeIndex = 0;\r\n let resize = false;\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const tempVector3 = this.positions.getConnectedValue(state) as Vector3;\r\n if (tempVector3) {\r\n tempVector3.toArray(newPositions, activeIndex * 3);\r\n remap[this._currentIndex] = activeIndex;\r\n activeIndex++;\r\n } else {\r\n resize = true;\r\n }\r\n }\r\n\r\n if (resize) {\r\n // Indices remap\r\n if (this._vertexData.indices) {\r\n const newIndices: number[] = [];\r\n for (let index = 0; index < this._vertexData.indices.length; index += 3) {\r\n const a = this._vertexData.indices[index];\r\n const b = this._vertexData.indices[index + 1];\r\n const c = this._vertexData.indices[index + 2];\r\n const remappedA = remap[a];\r\n const remappedB = remap[b];\r\n const remappedC = remap[c];\r\n\r\n if (remappedA !== undefined && remappedB !== undefined && remappedC !== undefined) {\r\n newIndices.push(remappedA);\r\n newIndices.push(remappedB);\r\n newIndices.push(remappedC);\r\n }\r\n }\r\n\r\n this._vertexData.indices = newIndices;\r\n }\r\n\r\n // Normals remap\r\n if (this._vertexData.normals) {\r\n this._vertexData.normals = this._remapVector3Data(this._vertexData.normals, remap);\r\n }\r\n\r\n // Tangents remap\r\n if (this._vertexData.tangents) {\r\n this._vertexData.tangents = this._remapVector4Data(this._vertexData.tangents, remap);\r\n }\r\n\r\n // Colors remap\r\n if (this._vertexData.colors) {\r\n this._vertexData.colors = this._remapVector4Data(this._vertexData.colors, remap);\r\n }\r\n\r\n // UVs remap\r\n if (this._vertexData.uvs) {\r\n this._vertexData.uvs = this._remapVector2Data(this._vertexData.uvs, remap);\r\n }\r\n if (this._vertexData.uvs2) {\r\n this._vertexData.uvs2 = this._remapVector2Data(this._vertexData.uvs2, remap);\r\n }\r\n if (this._vertexData.uvs3) {\r\n this._vertexData.uvs3 = this._remapVector2Data(this._vertexData.uvs3, remap);\r\n }\r\n if (this._vertexData.uvs4) {\r\n this._vertexData.uvs4 = this._remapVector2Data(this._vertexData.uvs4, remap);\r\n }\r\n if (this._vertexData.uvs5) {\r\n this._vertexData.uvs5 = this._remapVector2Data(this._vertexData.uvs5, remap);\r\n }\r\n if (this._vertexData.uvs6) {\r\n this._vertexData.uvs6 = this._remapVector2Data(this._vertexData.uvs6, remap);\r\n }\r\n }\r\n\r\n // Update positions\r\n this._vertexData.positions = newPositions;\r\n\r\n // Storage\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetPositionsBlock\", SetPositionsBlock);\r\n"]}
|
|
@@ -22,6 +22,14 @@ export declare class GeometryClampBlock extends NodeGeometryBlock {
|
|
|
22
22
|
* Gets the value input component
|
|
23
23
|
*/
|
|
24
24
|
get value(): NodeGeometryConnectionPoint;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the min input component
|
|
27
|
+
*/
|
|
28
|
+
get min(): NodeGeometryConnectionPoint;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the max input component
|
|
31
|
+
*/
|
|
32
|
+
get max(): NodeGeometryConnectionPoint;
|
|
25
33
|
/**
|
|
26
34
|
* Gets the output component
|
|
27
35
|
*/
|
|
@@ -19,6 +19,8 @@ export class GeometryClampBlock extends NodeGeometryBlock {
|
|
|
19
19
|
/** Gets or sets the maximum range */
|
|
20
20
|
this.maximum = 1.0;
|
|
21
21
|
this.registerInput("value", NodeGeometryBlockConnectionPointTypes.AutoDetect);
|
|
22
|
+
this.registerInput("min", NodeGeometryBlockConnectionPointTypes.Float, true);
|
|
23
|
+
this.registerInput("max", NodeGeometryBlockConnectionPointTypes.Float, true);
|
|
22
24
|
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.BasedOnInput);
|
|
23
25
|
this._outputs[0]._typeConnectionSource = this._inputs[0];
|
|
24
26
|
this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
|
|
@@ -38,6 +40,18 @@ export class GeometryClampBlock extends NodeGeometryBlock {
|
|
|
38
40
|
get value() {
|
|
39
41
|
return this._inputs[0];
|
|
40
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets the min input component
|
|
45
|
+
*/
|
|
46
|
+
get min() {
|
|
47
|
+
return this._inputs[1];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the max input component
|
|
51
|
+
*/
|
|
52
|
+
get max() {
|
|
53
|
+
return this._inputs[2];
|
|
54
|
+
}
|
|
41
55
|
/**
|
|
42
56
|
* Gets the output component
|
|
43
57
|
*/
|
|
@@ -50,24 +64,26 @@ export class GeometryClampBlock extends NodeGeometryBlock {
|
|
|
50
64
|
this.output._storedValue = null;
|
|
51
65
|
return;
|
|
52
66
|
}
|
|
53
|
-
const func = (value) => {
|
|
54
|
-
return Math.max(
|
|
67
|
+
const func = (value, min, max) => {
|
|
68
|
+
return Math.max(min, Math.min(value, max));
|
|
55
69
|
};
|
|
56
70
|
this.output._storedFunction = (state) => {
|
|
57
71
|
const value = this.value.getConnectedValue(state);
|
|
72
|
+
const min = this.min.isConnected ? this.min.getConnectedValue(state) : this.minimum;
|
|
73
|
+
const max = this.max.isConnected ? this.max.getConnectedValue(state) : this.maximum;
|
|
58
74
|
switch (this.value.type) {
|
|
59
75
|
case NodeGeometryBlockConnectionPointTypes.Int:
|
|
60
76
|
case NodeGeometryBlockConnectionPointTypes.Float: {
|
|
61
|
-
return func(value);
|
|
77
|
+
return func(value, min, max);
|
|
62
78
|
}
|
|
63
79
|
case NodeGeometryBlockConnectionPointTypes.Vector2: {
|
|
64
|
-
return new Vector2(func(value.x), func(value.y));
|
|
80
|
+
return new Vector2(func(value.x, min, max), func(value.y, min, max));
|
|
65
81
|
}
|
|
66
82
|
case NodeGeometryBlockConnectionPointTypes.Vector3: {
|
|
67
|
-
return new Vector3(func(value.x), func(value.y), func(value.z));
|
|
83
|
+
return new Vector3(func(value.x, min, max), func(value.y, min, max), func(value.z, min, max));
|
|
68
84
|
}
|
|
69
85
|
case NodeGeometryBlockConnectionPointTypes.Vector4: {
|
|
70
|
-
return new Vector4(func(value.x), func(value.y), func(value.z), func(value.w));
|
|
86
|
+
return new Vector4(func(value.x, min, max), func(value.y, min, max), func(value.z, min, max), func(value.w, min, max));
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
89
|
return 0;
|