@babylonjs/core 6.29.2 → 6.31.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/Cameras/camera.js +1 -1
- package/Cameras/camera.js.map +1 -1
- package/Culling/ray.js +24 -24
- package/Culling/ray.js.map +1 -1
- package/Debug/skeletonViewer.js +2 -2
- package/Debug/skeletonViewer.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +8 -5
- package/Engines/Extensions/engine.views.js +14 -8
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +6 -3
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/engine.d.ts +16 -1
- package/Engines/engine.js +1 -1
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +4 -2
- package/Gizmos/axisDragGizmo.js +18 -6
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.d.ts +2 -2
- package/Gizmos/axisScaleGizmo.js +1 -1
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.d.ts +4 -4
- package/Gizmos/planeDragGizmo.js +1 -1
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +13 -7
- package/Gizmos/planeRotationGizmo.js +26 -10
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +6 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js +22 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.d.ts +14 -10
- package/Materials/Textures/multiRenderTarget.js +7 -5
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/imageProcessingConfiguration.d.ts +2 -2
- package/Materials/imageProcessingConfiguration.js +2 -2
- package/Materials/imageProcessingConfiguration.js.map +1 -1
- package/Maths/math.vector.d.ts +5 -5
- package/Maths/math.vector.js +5 -4
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/linesBuilder.js +4 -2
- package/Meshes/Builders/linesBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +3 -1
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/groundMesh.js +1 -1
- package/Meshes/groundMesh.js.map +1 -1
- package/Physics/physicsHelper.d.ts +1 -1
- package/Physics/physicsHelper.js +1 -1
- package/Physics/physicsHelper.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/bloomEffect.d.ts +1 -1
- package/PostProcesses/bloomEffect.js +1 -1
- package/PostProcesses/bloomEffect.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +1 -1
- package/PostProcesses/postProcess.js +1 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +5 -0
- package/Rendering/depthPeelingRenderer.js +33 -9
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthRenderer.js +9 -0
- package/Rendering/depthRenderer.js.map +1 -1
- package/Shaders/depth.vertex.d.ts +2 -0
- package/Shaders/depth.vertex.js +4 -0
- package/Shaders/depth.vertex.js.map +1 -1
- package/XR/features/WebXRAbstractFeature.d.ts +10 -1
- package/XR/features/WebXRAbstractFeature.js +13 -0
- package/XR/features/WebXRAbstractFeature.js.map +1 -1
- package/XR/features/WebXRLightEstimation.d.ts +5 -0
- package/XR/features/WebXRLightEstimation.js +14 -2
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.d.ts +81 -0
- package/XR/features/WebXRRawCameraAccess.js +169 -0
- package/XR/features/WebXRRawCameraAccess.js.map +1 -0
- package/XR/features/index.d.ts +1 -0
- package/XR/features/index.js +1 -0
- package/XR/features/index.js.map +1 -1
- package/XR/webXRFeaturesManager.d.ts +13 -0
- package/XR/webXRFeaturesManager.js +4 -0
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -1
- package/scene.js +11 -6
- package/scene.js.map +1 -1
|
@@ -24,10 +24,12 @@ export function CreateLineSystemVertexData(options) {
|
|
|
24
24
|
for (let l = 0; l < lines.length; l++) {
|
|
25
25
|
const points = lines[l];
|
|
26
26
|
for (let index = 0; index < points.length; index++) {
|
|
27
|
-
|
|
27
|
+
const { x, y, z } = points[index];
|
|
28
|
+
positions.push(x, y, z);
|
|
28
29
|
if (colors) {
|
|
29
30
|
const color = colors[l];
|
|
30
|
-
|
|
31
|
+
const { r, g, b, a } = color[index];
|
|
32
|
+
vertexColors.push(r, g, b, a);
|
|
31
33
|
}
|
|
32
34
|
if (index > 0) {
|
|
33
35
|
indices.push(idx - 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linesBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/linesBuilder.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,S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,IAAI,EAAE,YAAqB,KAAK,EAAE,WAAgC,IAAI,EAAa,EAAE;IAC/J,MAAM,OAAO,GAAG;QACZ,MAAM;QACN,SAAS;QACT,QAAQ;KACX,CAAC;IACF,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,IAAI,CAAC,iBAAiB,GAAG,CACrB,IAAY,EACZ,MAAiB,EACjB,QAAgB,EAChB,OAAe,EACf,MAAc,EACd,QAAyB,IAAI,EAC7B,SAAmB,EACnB,QAAoB,EACX,EAAE;IACX,MAAM,OAAO,GAAG;QACZ,MAAM;QACN,QAAQ;QACR,OAAO;QACP,MAAM;QACN,SAAS;QACT,QAAQ;KACX,CAAC;IACF,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Color4 } from \"../../Maths/math.color\";\r\nimport { _CreationDataStorage, Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { FloatArray, Nullable } from \"../../types\";\r\nimport { LinesMesh } from \"../../Meshes/linesMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { Logger } from \"../../Misc/logger\";\r\n\r\nimport type { Material } from \"../../Materials/material\";\r\n\r\n/**\r\n * Creates the VertexData of the LineSystem\r\n * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty\r\n * - lines an array of lines, each line being an array of successive Vector3\r\n * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point\r\n * @param options.lines\r\n * @param options.colors\r\n * @returns the VertexData of the LineSystem\r\n */\r\nexport function CreateLineSystemVertexData(options: { lines: Vector3[][]; colors?: Nullable<Color4[][]> }): VertexData {\r\n const indices = [];\r\n const positions = [];\r\n const lines = options.lines;\r\n const colors = options.colors;\r\n const vertexColors = [];\r\n let idx = 0;\r\n\r\n for (let l = 0; l < lines.length; l++) {\r\n const points = lines[l];\r\n for (let index = 0; index < points.length; index++) {\r\n positions.push(points[index].x, points[index].y, points[index].z);\r\n if (colors) {\r\n const color = colors[l];\r\n vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);\r\n }\r\n if (index > 0) {\r\n indices.push(idx - 1);\r\n indices.push(idx);\r\n }\r\n idx++;\r\n }\r\n }\r\n const vertexData = new VertexData();\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n if (colors) {\r\n vertexData.colors = vertexColors;\r\n }\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Create the VertexData for a DashedLines\r\n * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty\r\n * - points an array successive Vector3\r\n * - dashSize the size of the dashes relative to the dash number, optional, default 3\r\n * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1\r\n * - dashNb the intended total number of dashes, optional, default 200\r\n * @param options.points\r\n * @param options.dashSize\r\n * @param options.gapSize\r\n * @param options.dashNb\r\n * @returns the VertexData for the DashedLines\r\n */\r\nexport function CreateDashedLinesVertexData(options: { points: Vector3[]; dashSize?: number; gapSize?: number; dashNb?: number }): VertexData {\r\n const dashSize = options.dashSize || 3;\r\n const gapSize = options.gapSize || 1;\r\n const dashNb = options.dashNb || 200;\r\n const points = options.points;\r\n\r\n const positions: number[] = [];\r\n const indices: number[] = [];\r\n\r\n const curvect = Vector3.Zero();\r\n let lg = 0;\r\n let nb = 0;\r\n let shft = 0;\r\n let dashshft = 0;\r\n let curshft = 0;\r\n let idx = 0;\r\n let i = 0;\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n lg += curvect.length();\r\n }\r\n shft = lg / dashNb;\r\n dashshft = (dashSize * shft) / (dashSize + gapSize);\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n nb = Math.floor(curvect.length() / shft);\r\n curvect.normalize();\r\n for (let j = 0; j < nb; j++) {\r\n curshft = shft * j;\r\n positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);\r\n positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);\r\n indices.push(idx, idx + 1);\r\n idx += 2;\r\n }\r\n }\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n vertexData.positions = positions;\r\n vertexData.indices = indices;\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh\r\n * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter\r\n * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function\r\n * * The parameter `lines` is an array of lines, each line being an array of successive Vector3\r\n * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter\r\n * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point\r\n * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)\r\n * * The optional parameter `material` is the material to use to draw the lines if provided. If not, a default material will be created\r\n * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#lines-and-dashedlines\r\n * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#line-system\r\n * @param name defines the name of the new line system\r\n * @param options defines the options used to create the line system\r\n * @param options.lines\r\n * @param options.updatable\r\n * @param options.instance\r\n * @param options.colors\r\n * @param options.useVertexAlpha\r\n * @param options.material\r\n * @param scene defines the hosting scene\r\n * @returns a new line system mesh\r\n */\r\nexport function CreateLineSystem(\r\n name: string,\r\n options: { lines: Vector3[][]; updatable?: boolean; instance?: Nullable<LinesMesh>; colors?: Nullable<Color4[][]>; useVertexAlpha?: boolean; material?: Material },\r\n scene: Nullable<Scene> = null\r\n): LinesMesh {\r\n const instance = options.instance;\r\n const lines = options.lines;\r\n const colors = options.colors;\r\n\r\n if (instance) {\r\n // lines update\r\n const positions = instance.getVerticesData(VertexBuffer.PositionKind)!;\r\n let vertexColor;\r\n let lineColors;\r\n if (colors) {\r\n vertexColor = instance.getVerticesData(VertexBuffer.ColorKind)!;\r\n }\r\n let i = 0;\r\n let c = 0;\r\n for (let l = 0; l < lines.length; l++) {\r\n const points = lines[l];\r\n for (let p = 0; p < points.length; p++) {\r\n positions[i] = points[p].x;\r\n positions[i + 1] = points[p].y;\r\n positions[i + 2] = points[p].z;\r\n if (colors && vertexColor) {\r\n lineColors = colors[l];\r\n vertexColor[c] = lineColors[p].r;\r\n vertexColor[c + 1] = lineColors[p].g;\r\n vertexColor[c + 2] = lineColors[p].b;\r\n vertexColor[c + 3] = lineColors[p].a;\r\n c += 4;\r\n }\r\n i += 3;\r\n }\r\n }\r\n instance.updateVerticesData(VertexBuffer.PositionKind, positions, false, false);\r\n if (colors && vertexColor) {\r\n instance.updateVerticesData(VertexBuffer.ColorKind, vertexColor, false, false);\r\n }\r\n return instance;\r\n }\r\n\r\n // line system creation\r\n const useVertexColor = colors ? true : false;\r\n const lineSystem = new LinesMesh(name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha, options.material);\r\n const vertexData = CreateLineSystemVertexData(options);\r\n vertexData.applyToMesh(lineSystem, options.updatable);\r\n return lineSystem;\r\n}\r\n\r\n/**\r\n * Creates a line mesh\r\n * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter\r\n * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function\r\n * * The parameter `points` is an array successive Vector3\r\n * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#lines-and-dashedlines\r\n * * The optional parameter `colors` is an array of successive Color4, one per line point\r\n * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)\r\n * * The optional parameter `material` is the material to use to draw the lines if provided. If not, a default material will be created\r\n * * When updating an instance, remember that only point positions can change, not the number of points\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#lines\r\n * @param name defines the name of the new line system\r\n * @param options defines the options used to create the line system\r\n * @param options.points\r\n * @param options.updatable\r\n * @param options.instance\r\n * @param options.colors\r\n * @param options.useVertexAlpha\r\n * @param options.material\r\n * @param scene defines the hosting scene\r\n * @returns a new line mesh\r\n */\r\nexport function CreateLines(\r\n name: string,\r\n options: { points: Vector3[]; updatable?: boolean; instance?: Nullable<LinesMesh>; colors?: Color4[]; useVertexAlpha?: boolean; material?: Material },\r\n scene: Nullable<Scene> = null\r\n): LinesMesh {\r\n const colors = options.colors ? [options.colors] : null;\r\n const lines = CreateLineSystem(\r\n name,\r\n { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha, material: options.material },\r\n scene\r\n );\r\n return lines;\r\n}\r\n\r\n/**\r\n * Creates a dashed line mesh\r\n * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter\r\n * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function\r\n * * The parameter `points` is an array successive Vector3\r\n * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)\r\n * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)\r\n * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)\r\n * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#lines-and-dashedlines\r\n * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)\r\n * * The optional parameter `material` is the material to use to draw the lines if provided. If not, a default material will be created\r\n * * When updating an instance, remember that only point positions can change, not the number of points\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param options.points\r\n * @param options.dashSize\r\n * @param options.gapSize\r\n * @param options.dashNb\r\n * @param options.updatable\r\n * @param options.instance\r\n * @param options.useVertexAlpha\r\n * @param options.material\r\n * @param scene defines the hosting scene\r\n * @returns the dashed line mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#dashed-lines\r\n */\r\nexport function CreateDashedLines(\r\n name: string,\r\n options: { points: Vector3[]; dashSize?: number; gapSize?: number; dashNb?: number; updatable?: boolean; instance?: LinesMesh; useVertexAlpha?: boolean; material?: Material },\r\n scene: Nullable<Scene> = null\r\n): LinesMesh {\r\n const points = options.points;\r\n const instance = options.instance;\r\n const gapSize = options.gapSize || 1;\r\n const dashSize = options.dashSize || 3;\r\n\r\n if (instance) {\r\n // dashed lines update\r\n const positionFunction = (positions: FloatArray): void => {\r\n const curvect = Vector3.Zero();\r\n const nbSeg = positions.length / 6;\r\n let lg = 0;\r\n let nb = 0;\r\n let shft = 0;\r\n let dashshft = 0;\r\n let curshft = 0;\r\n let p = 0;\r\n let i = 0;\r\n let j = 0;\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n lg += curvect.length();\r\n }\r\n shft = lg / nbSeg;\r\n const dashSize = instance!._creationDataStorage!.dashSize;\r\n const gapSize = instance!._creationDataStorage!.gapSize;\r\n dashshft = (dashSize * shft) / (dashSize + gapSize);\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n nb = Math.floor(curvect.length() / shft);\r\n curvect.normalize();\r\n j = 0;\r\n while (j < nb && p < positions.length) {\r\n curshft = shft * j;\r\n positions[p] = points[i].x + curshft * curvect.x;\r\n positions[p + 1] = points[i].y + curshft * curvect.y;\r\n positions[p + 2] = points[i].z + curshft * curvect.z;\r\n positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;\r\n positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;\r\n positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;\r\n p += 6;\r\n j++;\r\n }\r\n }\r\n while (p < positions.length) {\r\n positions[p] = points[i].x;\r\n positions[p + 1] = points[i].y;\r\n positions[p + 2] = points[i].z;\r\n p += 3;\r\n }\r\n };\r\n if (options.dashNb || options.dashSize || options.gapSize || options.useVertexAlpha || options.material) {\r\n Logger.Warn(\"You have used an option other than points with the instance option. Please be aware that these other options will be ignored.\");\r\n }\r\n instance.updateMeshPositions(positionFunction, false);\r\n return instance;\r\n }\r\n // dashed lines creation\r\n const dashedLines = new LinesMesh(name, scene, null, undefined, undefined, undefined, options.useVertexAlpha, options.material);\r\n const vertexData = CreateDashedLinesVertexData(options);\r\n vertexData.applyToMesh(dashedLines, options.updatable);\r\n\r\n dashedLines._creationDataStorage = new _CreationDataStorage();\r\n dashedLines._creationDataStorage.dashSize = dashSize;\r\n dashedLines._creationDataStorage.gapSize = gapSize;\r\n return dashedLines;\r\n}\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use the functions directly from the module\r\n */\r\nexport const LinesBuilder = {\r\n CreateDashedLines,\r\n CreateLineSystem,\r\n CreateLines,\r\n};\r\n\r\nVertexData.CreateLineSystem = CreateLineSystemVertexData;\r\nVertexData.CreateDashedLines = CreateDashedLinesVertexData;\r\n\r\nMesh.CreateLines = (name: string, points: Vector3[], scene: Nullable<Scene> = null, updatable: boolean = false, instance: Nullable<LinesMesh> = null): LinesMesh => {\r\n const options = {\r\n points,\r\n updatable,\r\n instance,\r\n };\r\n return CreateLines(name, options, scene);\r\n};\r\n\r\nMesh.CreateDashedLines = (\r\n name: string,\r\n points: Vector3[],\r\n dashSize: number,\r\n gapSize: number,\r\n dashNb: number,\r\n scene: Nullable<Scene> = null,\r\n updatable?: boolean,\r\n instance?: LinesMesh\r\n): LinesMesh => {\r\n const options = {\r\n points,\r\n dashSize,\r\n gapSize,\r\n dashNb,\r\n updatable,\r\n instance,\r\n };\r\n return CreateDashedLines(name, options, scene);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"linesBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/linesBuilder.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAA8D;IACrG,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KA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G,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACxD,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvD,WAAW,CAAC,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC9D,WAAW,CAAC,oBAAoB,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACrD,WAAW,CAAC,oBAAoB,CAAC,OAAO,GAAG,OAAO,CAAC;IACnD,OAAO,WAAW,CAAC;AACvB,CAAC;AACD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;CACd,CAAC;AAEF,UAAU,CAAC,gBAAgB,GAAG,0BAA0B,CAAC;AACzD,UAAU,CAAC,iBAAiB,GAAG,2BAA2B,CAAC;AAE3D,IAAI,CAAC,WAAW,GAAG,CAAC,IAAY,EAAE,MAAiB,EAAE,QAAyB,IAAI,EAAE,YAAqB,KAAK,EAAE,WAAgC,IAAI,EAAa,EAAE;IAC/J,MAAM,OAAO,GAAG;QACZ,MAAM;QACN,SAAS;QACT,QAAQ;KACX,CAAC;IACF,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,IAAI,CAAC,iBAAiB,GAAG,CACrB,IAAY,EACZ,MAAiB,EACjB,QAAgB,EAChB,OAAe,EACf,MAAc,EACd,QAAyB,IAAI,EAC7B,SAAmB,EACnB,QAAoB,EACX,EAAE;IACX,MAAM,OAAO,GAAG;QACZ,MAAM;QACN,QAAQ;QACR,OAAO;QACP,MAAM;QACN,SAAS;QACT,QAAQ;KACX,CAAC;IACF,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Color4 } from \"../../Maths/math.color\";\r\nimport { _CreationDataStorage, Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { FloatArray, Nullable } from \"../../types\";\r\nimport { LinesMesh } from \"../../Meshes/linesMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { Logger } from \"../../Misc/logger\";\r\n\r\nimport type { Material } from \"../../Materials/material\";\r\n\r\n/**\r\n * Creates the VertexData of the LineSystem\r\n * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty\r\n * - lines an array of lines, each line being an array of successive Vector3\r\n * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point\r\n * @param options.lines\r\n * @param options.colors\r\n * @returns the VertexData of the LineSystem\r\n */\r\nexport function CreateLineSystemVertexData(options: { lines: Vector3[][]; colors?: Nullable<Color4[][]> }): VertexData {\r\n const indices = [];\r\n const positions = [];\r\n const lines = options.lines;\r\n const colors = options.colors;\r\n const vertexColors = [];\r\n let idx = 0;\r\n\r\n for (let l = 0; l < lines.length; l++) {\r\n const points = lines[l];\r\n for (let index = 0; index < points.length; index++) {\r\n const { x, y, z } = points[index];\r\n positions.push(x, y, z);\r\n if (colors) {\r\n const color = colors[l];\r\n const { r, g, b, a } = color[index];\r\n vertexColors.push(r, g, b, a);\r\n }\r\n if (index > 0) {\r\n indices.push(idx - 1);\r\n indices.push(idx);\r\n }\r\n idx++;\r\n }\r\n }\r\n const vertexData = new VertexData();\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n if (colors) {\r\n vertexData.colors = vertexColors;\r\n }\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Create the VertexData for a DashedLines\r\n * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty\r\n * - points an array successive Vector3\r\n * - dashSize the size of the dashes relative to the dash number, optional, default 3\r\n * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1\r\n * - dashNb the intended total number of dashes, optional, default 200\r\n * @param options.points\r\n * @param options.dashSize\r\n * @param options.gapSize\r\n * @param options.dashNb\r\n * @returns the VertexData for the DashedLines\r\n */\r\nexport function CreateDashedLinesVertexData(options: { points: Vector3[]; dashSize?: number; gapSize?: number; dashNb?: number }): VertexData {\r\n const dashSize = options.dashSize || 3;\r\n const gapSize = options.gapSize || 1;\r\n const dashNb = options.dashNb || 200;\r\n const points = options.points;\r\n\r\n const positions: number[] = [];\r\n const indices: number[] = [];\r\n\r\n const curvect = Vector3.Zero();\r\n let lg = 0;\r\n let nb = 0;\r\n let shft = 0;\r\n let dashshft = 0;\r\n let curshft = 0;\r\n let idx = 0;\r\n let i = 0;\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n lg += curvect.length();\r\n }\r\n shft = lg / dashNb;\r\n dashshft = (dashSize * shft) / (dashSize + gapSize);\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n nb = Math.floor(curvect.length() / shft);\r\n curvect.normalize();\r\n for (let j = 0; j < nb; j++) {\r\n curshft = shft * j;\r\n positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);\r\n positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);\r\n indices.push(idx, idx + 1);\r\n idx += 2;\r\n }\r\n }\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n vertexData.positions = positions;\r\n vertexData.indices = indices;\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh\r\n * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter\r\n * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function\r\n * * The parameter `lines` is an array of lines, each line being an array of successive Vector3\r\n * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter\r\n * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point\r\n * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)\r\n * * The optional parameter `material` is the material to use to draw the lines if provided. If not, a default material will be created\r\n * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#lines-and-dashedlines\r\n * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#line-system\r\n * @param name defines the name of the new line system\r\n * @param options defines the options used to create the line system\r\n * @param options.lines\r\n * @param options.updatable\r\n * @param options.instance\r\n * @param options.colors\r\n * @param options.useVertexAlpha\r\n * @param options.material\r\n * @param scene defines the hosting scene\r\n * @returns a new line system mesh\r\n */\r\nexport function CreateLineSystem(\r\n name: string,\r\n options: { lines: Vector3[][]; updatable?: boolean; instance?: Nullable<LinesMesh>; colors?: Nullable<Color4[][]>; useVertexAlpha?: boolean; material?: Material },\r\n scene: Nullable<Scene> = null\r\n): LinesMesh {\r\n const instance = options.instance;\r\n const lines = options.lines;\r\n const colors = options.colors;\r\n\r\n if (instance) {\r\n // lines update\r\n const positions = instance.getVerticesData(VertexBuffer.PositionKind)!;\r\n let vertexColor;\r\n let lineColors;\r\n if (colors) {\r\n vertexColor = instance.getVerticesData(VertexBuffer.ColorKind)!;\r\n }\r\n let i = 0;\r\n let c = 0;\r\n for (let l = 0; l < lines.length; l++) {\r\n const points = lines[l];\r\n for (let p = 0; p < points.length; p++) {\r\n positions[i] = points[p].x;\r\n positions[i + 1] = points[p].y;\r\n positions[i + 2] = points[p].z;\r\n if (colors && vertexColor) {\r\n lineColors = colors[l];\r\n vertexColor[c] = lineColors[p].r;\r\n vertexColor[c + 1] = lineColors[p].g;\r\n vertexColor[c + 2] = lineColors[p].b;\r\n vertexColor[c + 3] = lineColors[p].a;\r\n c += 4;\r\n }\r\n i += 3;\r\n }\r\n }\r\n instance.updateVerticesData(VertexBuffer.PositionKind, positions, false, false);\r\n if (colors && vertexColor) {\r\n instance.updateVerticesData(VertexBuffer.ColorKind, vertexColor, false, false);\r\n }\r\n return instance;\r\n }\r\n\r\n // line system creation\r\n const useVertexColor = colors ? true : false;\r\n const lineSystem = new LinesMesh(name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha, options.material);\r\n const vertexData = CreateLineSystemVertexData(options);\r\n vertexData.applyToMesh(lineSystem, options.updatable);\r\n return lineSystem;\r\n}\r\n\r\n/**\r\n * Creates a line mesh\r\n * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter\r\n * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function\r\n * * The parameter `points` is an array successive Vector3\r\n * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#lines-and-dashedlines\r\n * * The optional parameter `colors` is an array of successive Color4, one per line point\r\n * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)\r\n * * The optional parameter `material` is the material to use to draw the lines if provided. If not, a default material will be created\r\n * * When updating an instance, remember that only point positions can change, not the number of points\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#lines\r\n * @param name defines the name of the new line system\r\n * @param options defines the options used to create the line system\r\n * @param options.points\r\n * @param options.updatable\r\n * @param options.instance\r\n * @param options.colors\r\n * @param options.useVertexAlpha\r\n * @param options.material\r\n * @param scene defines the hosting scene\r\n * @returns a new line mesh\r\n */\r\nexport function CreateLines(\r\n name: string,\r\n options: { points: Vector3[]; updatable?: boolean; instance?: Nullable<LinesMesh>; colors?: Color4[]; useVertexAlpha?: boolean; material?: Material },\r\n scene: Nullable<Scene> = null\r\n): LinesMesh {\r\n const colors = options.colors ? [options.colors] : null;\r\n const lines = CreateLineSystem(\r\n name,\r\n { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha, material: options.material },\r\n scene\r\n );\r\n return lines;\r\n}\r\n\r\n/**\r\n * Creates a dashed line mesh\r\n * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter\r\n * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function\r\n * * The parameter `points` is an array successive Vector3\r\n * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)\r\n * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)\r\n * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)\r\n * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#lines-and-dashedlines\r\n * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)\r\n * * The optional parameter `material` is the material to use to draw the lines if provided. If not, a default material will be created\r\n * * When updating an instance, remember that only point positions can change, not the number of points\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param options.points\r\n * @param options.dashSize\r\n * @param options.gapSize\r\n * @param options.dashNb\r\n * @param options.updatable\r\n * @param options.instance\r\n * @param options.useVertexAlpha\r\n * @param options.material\r\n * @param scene defines the hosting scene\r\n * @returns the dashed line mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#dashed-lines\r\n */\r\nexport function CreateDashedLines(\r\n name: string,\r\n options: { points: Vector3[]; dashSize?: number; gapSize?: number; dashNb?: number; updatable?: boolean; instance?: LinesMesh; useVertexAlpha?: boolean; material?: Material },\r\n scene: Nullable<Scene> = null\r\n): LinesMesh {\r\n const points = options.points;\r\n const instance = options.instance;\r\n const gapSize = options.gapSize || 1;\r\n const dashSize = options.dashSize || 3;\r\n\r\n if (instance) {\r\n // dashed lines update\r\n const positionFunction = (positions: FloatArray): void => {\r\n const curvect = Vector3.Zero();\r\n const nbSeg = positions.length / 6;\r\n let lg = 0;\r\n let nb = 0;\r\n let shft = 0;\r\n let dashshft = 0;\r\n let curshft = 0;\r\n let p = 0;\r\n let i = 0;\r\n let j = 0;\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n lg += curvect.length();\r\n }\r\n shft = lg / nbSeg;\r\n const dashSize = instance!._creationDataStorage!.dashSize;\r\n const gapSize = instance!._creationDataStorage!.gapSize;\r\n dashshft = (dashSize * shft) / (dashSize + gapSize);\r\n for (i = 0; i < points.length - 1; i++) {\r\n points[i + 1].subtractToRef(points[i], curvect);\r\n nb = Math.floor(curvect.length() / shft);\r\n curvect.normalize();\r\n j = 0;\r\n while (j < nb && p < positions.length) {\r\n curshft = shft * j;\r\n positions[p] = points[i].x + curshft * curvect.x;\r\n positions[p + 1] = points[i].y + curshft * curvect.y;\r\n positions[p + 2] = points[i].z + curshft * curvect.z;\r\n positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;\r\n positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;\r\n positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;\r\n p += 6;\r\n j++;\r\n }\r\n }\r\n while (p < positions.length) {\r\n positions[p] = points[i].x;\r\n positions[p + 1] = points[i].y;\r\n positions[p + 2] = points[i].z;\r\n p += 3;\r\n }\r\n };\r\n if (options.dashNb || options.dashSize || options.gapSize || options.useVertexAlpha || options.material) {\r\n Logger.Warn(\"You have used an option other than points with the instance option. Please be aware that these other options will be ignored.\");\r\n }\r\n instance.updateMeshPositions(positionFunction, false);\r\n return instance;\r\n }\r\n // dashed lines creation\r\n const dashedLines = new LinesMesh(name, scene, null, undefined, undefined, undefined, options.useVertexAlpha, options.material);\r\n const vertexData = CreateDashedLinesVertexData(options);\r\n vertexData.applyToMesh(dashedLines, options.updatable);\r\n\r\n dashedLines._creationDataStorage = new _CreationDataStorage();\r\n dashedLines._creationDataStorage.dashSize = dashSize;\r\n dashedLines._creationDataStorage.gapSize = gapSize;\r\n return dashedLines;\r\n}\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use the functions directly from the module\r\n */\r\nexport const LinesBuilder = {\r\n CreateDashedLines,\r\n CreateLineSystem,\r\n CreateLines,\r\n};\r\n\r\nVertexData.CreateLineSystem = CreateLineSystemVertexData;\r\nVertexData.CreateDashedLines = CreateDashedLinesVertexData;\r\n\r\nMesh.CreateLines = (name: string, points: Vector3[], scene: Nullable<Scene> = null, updatable: boolean = false, instance: Nullable<LinesMesh> = null): LinesMesh => {\r\n const options = {\r\n points,\r\n updatable,\r\n instance,\r\n };\r\n return CreateLines(name, options, scene);\r\n};\r\n\r\nMesh.CreateDashedLines = (\r\n name: string,\r\n points: Vector3[],\r\n dashSize: number,\r\n gapSize: number,\r\n dashNb: number,\r\n scene: Nullable<Scene> = null,\r\n updatable?: boolean,\r\n instance?: LinesMesh\r\n): LinesMesh => {\r\n const options = {\r\n points,\r\n dashSize,\r\n gapSize,\r\n dashNb,\r\n updatable,\r\n instance,\r\n };\r\n return CreateDashedLines(name, options, scene);\r\n};\r\n"]}
|
|
@@ -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,CAA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,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IGreasedLineMaterial } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segmment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: number[];\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: number[];\r\n protected _indices: number[];\r\n protected _uvs: number[];\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: Engine;\r\n\r\n constructor(\r\n public readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n */\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 */\r\n public dispose() {\r\n super.dispose();\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Return the 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 */\r\n public setPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n this._points = points;\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}
|
|
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;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACnC,yGAAsB,CAAA;IACtB,uGAAqB,CAAA;AACzB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IAClC,iHAA2B,CAAA;IAC3B,yJAA+C,CAAA;IAC/C,iHAA2B,CAAA;AAC/B,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AAED;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,kCAKX;AALD,WAAY,kCAAkC;IAC1C,uJAAsC,CAAA;IACtC,qJAAqC,CAAA;IACrC,mIAA4B,CAAA;IAC5B,4HAAyB,CAAA;AAC7B,CAAC,EALW,kCAAkC,KAAlC,kCAAkC,QAK7C;AAsFD;;GAEG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,IAAI;IAkBlD,YACoB,IAAY,EAC5B,KAAY,EACF,QAAgC;;QAE1C,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAJ7B,SAAI,GAAJ,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U,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;SACvF;QACD,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtD,OAAO,UAAU,CAAC;IACtB,CAAC;IAES,oBAAoB,CAAC,OAAiB;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAEvC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IGreasedLineMaterial } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segmment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: number[];\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: number[];\r\n protected _indices: number[];\r\n protected _uvs: number[];\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: Engine;\r\n\r\n constructor(\r\n public readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n */\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 */\r\n public dispose() {\r\n super.dispose();\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Return the points offsets\r\n */\r\n get offsets() {\r\n return this._offsets;\r\n }\r\n\r\n /**\r\n * Sets point offests\r\n * @param offsets offset table [x,y,z, x,y,z, ....]\r\n */\r\n set offsets(offsets: number[]) {\r\n this._offsets = offsets;\r\n if (!this._offsetsBuffer) {\r\n this._createOffsetsBuffer(offsets);\r\n } else {\r\n this._offsetsBuffer.update(offsets);\r\n }\r\n }\r\n\r\n /**\r\n * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]\r\n */\r\n get widths() {\r\n return this._widths;\r\n }\r\n\r\n /**\r\n * Sets widths at each line point\r\n * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]\r\n */\r\n set widths(widths: number[]) {\r\n this._widths = widths;\r\n if (!this._lazy) {\r\n this._widthsBuffer && this._widthsBuffer.update(widths);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors\r\n */\r\n get colorPointers() {\r\n return this._colorPointers;\r\n }\r\n\r\n /**\r\n * Sets the color pointer\r\n * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.\r\n */\r\n set colorPointers(colorPointers: number[]) {\r\n this._colorPointers = colorPointers;\r\n if (!this._lazy) {\r\n this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the pluginMaterial associated with line\r\n */\r\n get greasedLineMaterial(): IGreasedLineMaterial | undefined {\r\n if (this.material && this.material instanceof GreasedLineSimpleMaterial) {\r\n return this.material;\r\n }\r\n const materialPlugin = this.material?.pluginManager?.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);\r\n if (materialPlugin) {\r\n return <GreasedLinePluginMaterial>materialPlugin;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * Return copy the points.\r\n */\r\n get points() {\r\n const pointsCopy: number[][] = [];\r\n DeepCopier.DeepCopy(this._points, pointsCopy);\r\n return pointsCopy;\r\n }\r\n\r\n /**\r\n * Sets line points and rerenders the line.\r\n * @param points points table\r\n */\r\n public setPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n this._points = points;\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeGeometry.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/nodeGeometry.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAoB9C;;;GAGG;AACH,MAAM,OAAO,YAAY;IAgBrB,8CAA8C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I,CAAC,SAAS,EAAE;gCACZ,YAAY,CAAC,KAAK,EAAE,CAAC;6BACxB;4BACD,OAAO,CAAC,YAAY,CAAC,CAAC;yBACzB;wBAAC,OAAO,GAAG,EAAE;4BACV,MAAM,CAAC,GAAG,CAAC,CAAC;yBACf;qBACJ;yBAAM;wBACH,MAAM,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAAC;qBACrD;iBACJ;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;;AAnoBc,8BAAiB,GAAW,CAAC,AAAZ,CAAa;AAM7C,gDAAgD;AAClC,sBAAS,GAAG,GAAG,KAAK,CAAC,cAAc,KAAK,MAAM,CAAC,OAAO,mDAAmD,AAAhG,CAAiG;AAExH,sCAAsC;AACxB,uBAAU,GAAG,SAAS,CAAC,UAAU,AAAvB,CAAwB;AAuDzC;IADN,SAAS,EAAE;0CACQ;AAMb;IADN,SAAS,CAAC,SAAS,CAAC;6CACE","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Mesh } from \"../mesh\";\r\nimport type { VertexData } from \"../mesh.vertexData\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { GeometryOutputBlock } from \"./Blocks/geometryOutputBlock\";\r\nimport type { NodeGeometryBlock } from \"./nodeGeometryBlock\";\r\nimport { NodeGeometryBuildState } from \"./nodeGeometryBuildState\";\r\nimport { GetClass } from \"../../Misc/typeStore\";\r\nimport { SerializationHelper, serialize } from \"../../Misc/decorators\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { WebRequest } from \"../../Misc/webRequest\";\r\nimport { BoxBlock } from \"./Blocks/Sources/boxBlock\";\r\nimport type { GeometryInputBlock } from \"./Blocks/geometryInputBlock\";\r\nimport { PrecisionDate } from \"../../Misc/precisionDate\";\r\nimport type { TeleportOutBlock } from \"./Blocks/Teleport/teleportOutBlock\";\r\nimport type { TeleportInBlock } from \"./Blocks/Teleport/teleportInBlock\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Color4 } from \"../../Maths/math.color\";\r\nimport { Engine } from \"../../Engines/engine\";\r\n\r\n// declare NODEGEOMETRYEDITOR namespace for compilation issue\r\ndeclare let NODEGEOMETRYEDITOR: any;\r\ndeclare let BABYLON: any;\r\n\r\n/**\r\n * Interface used to configure the node geometry editor\r\n */\r\nexport interface INodeGeometryEditorOptions {\r\n /** Define the URL to load node editor script from */\r\n editorURL?: string;\r\n /** Additional configuration for the NGE */\r\n nodeGeometryEditorConfig?: {\r\n backgroundColor?: Color4;\r\n hostScene?: Scene;\r\n hostMesh?: Mesh;\r\n };\r\n}\r\n\r\n/**\r\n * Defines a node based geometry\r\n * @see demo at https://playground.babylonjs.com#PYY6XE#69\r\n */\r\nexport class NodeGeometry {\r\n private static _BuildIdGenerator: number = 0;\r\n private _buildId: number = NodeGeometry._BuildIdGenerator++;\r\n private _buildWasSuccessful = false;\r\n private _vertexData: Nullable<VertexData> = null;\r\n private _buildExecutionTime: number = 0;\r\n\r\n /** Define the Url to load node editor script */\r\n public static EditorURL = `${Tools._DefaultCdnUrl}/v${Engine.Version}/nodeGeometryEditor/babylon.nodeGeometryEditor.js`;\r\n\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private BJSNODEGEOMETRYEDITOR = this._getGlobalNodeGeometryEditor();\r\n\r\n /** Get the inspector from bundle or global */\r\n private _getGlobalNodeGeometryEditor(): any {\r\n // UMD Global name detection from Webpack Bundle UMD Name.\r\n if (typeof NODEGEOMETRYEDITOR !== \"undefined\") {\r\n return NODEGEOMETRYEDITOR;\r\n }\r\n\r\n // In case of module let's check the global emitted from the editor entry point.\r\n if (typeof BABYLON !== \"undefined\" && typeof BABYLON.NodeGeometryEditor !== \"undefined\") {\r\n return BABYLON;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the time spent to build this block (in ms)\r\n */\r\n public get buildExecutionTime() {\r\n return this._buildExecutionTime;\r\n }\r\n\r\n /**\r\n * Gets or sets data used by visual editor\r\n * @see https://nge.babylonjs.com\r\n */\r\n public editorData: any = null;\r\n\r\n /**\r\n * Gets an array of blocks that needs to be serialized even if they are not yet connected\r\n */\r\n public attachedBlocks: NodeGeometryBlock[] = [];\r\n\r\n /**\r\n * Observable raised when the geometry is built\r\n */\r\n public onBuildObservable = new Observable<NodeGeometry>();\r\n\r\n /** Gets or sets the GeometryOutputBlock used to gather the final geometry data */\r\n public outputBlock: Nullable<GeometryOutputBlock> = null;\r\n\r\n /**\r\n * Snippet ID if the material was created from the snippet server\r\n */\r\n public snippetId: string;\r\n\r\n /**\r\n * The name of the geometry\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * A free comment about the geometry\r\n */\r\n @serialize(\"comment\")\r\n public comment: string;\r\n\r\n /**\r\n * Creates a new geometry\r\n * @param name defines the name of the geometry\r\n */\r\n public constructor(name: string) {\r\n this.name = name;\r\n }\r\n\r\n /**\r\n * Gets the current class name of the geometry e.g. \"NodeGeometry\"\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"NodeGeometry\";\r\n }\r\n\r\n /**\r\n * Get a block by its name\r\n * @param name defines the name of the block to retrieve\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByName(name: string) {\r\n let result = null;\r\n for (const block of this.attachedBlocks) {\r\n if (block.name === name) {\r\n if (!result) {\r\n result = block;\r\n } else {\r\n Tools.Warn(\"More than one block was found with the name `\" + name + \"`\");\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Get a block using a predicate\r\n * @param predicate defines the predicate used to find the good candidate\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByPredicate(predicate: (block: NodeGeometryBlock) => boolean) {\r\n for (const block of this.attachedBlocks) {\r\n if (predicate(block)) {\r\n return block;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the list of input blocks attached to this material\r\n * @returns an array of InputBlocks\r\n */\r\n public getInputBlocks() {\r\n const blocks: GeometryInputBlock[] = [];\r\n for (const block of this.attachedBlocks) {\r\n if (block.isInput) {\r\n blocks.push(block as GeometryInputBlock);\r\n }\r\n }\r\n\r\n return blocks;\r\n }\r\n\r\n /**\r\n * Launch the node geometry editor\r\n * @param config Define the configuration of the editor\r\n * @returns a promise fulfilled when the node editor is visible\r\n */\r\n public edit(config?: INodeGeometryEditorOptions): Promise<void> {\r\n return new Promise((resolve) => {\r\n this.BJSNODEGEOMETRYEDITOR = this.BJSNODEGEOMETRYEDITOR || this._getGlobalNodeGeometryEditor();\r\n if (typeof this.BJSNODEGEOMETRYEDITOR == \"undefined\") {\r\n const editorUrl = config && config.editorURL ? config.editorURL : NodeGeometry.EditorURL;\r\n\r\n // Load editor and add it to the DOM\r\n Tools.LoadBabylonScript(editorUrl, () => {\r\n this.BJSNODEGEOMETRYEDITOR = this.BJSNODEGEOMETRYEDITOR || this._getGlobalNodeGeometryEditor();\r\n this._createNodeEditor(config?.nodeGeometryEditorConfig);\r\n resolve();\r\n });\r\n } else {\r\n // Otherwise creates the editor\r\n this._createNodeEditor(config?.nodeGeometryEditorConfig);\r\n resolve();\r\n }\r\n });\r\n }\r\n\r\n /** Creates the node editor window. */\r\n private _createNodeEditor(additionalConfig?: any) {\r\n const nodeEditorConfig: any = {\r\n nodeGeometry: this,\r\n ...additionalConfig,\r\n };\r\n this.BJSNODEGEOMETRYEDITOR.NodeGeometryEditor.Show(nodeEditorConfig);\r\n }\r\n\r\n /**\r\n * Build the final geometry\r\n * @param verbose defines if the build should log activity\r\n * @param updateBuildId defines if the internal build Id should be updated (default is true)\r\n * @param autoConfigure defines if the autoConfigure method should be called when initializing blocks (default is false)\r\n */\r\n public build(verbose: boolean = false, updateBuildId = true, autoConfigure = false) {\r\n this._buildWasSuccessful = false;\r\n\r\n if (!this.outputBlock) {\r\n throw \"You must define the outputBlock property before building the geometry\";\r\n }\r\n const now = PrecisionDate.Now;\r\n // Initialize blocks\r\n this._initializeBlock(this.outputBlock, autoConfigure);\r\n\r\n // Build\r\n const state = new NodeGeometryBuildState();\r\n\r\n state.buildId = this._buildId;\r\n state.verbose = verbose;\r\n\r\n this.outputBlock.build(state);\r\n\r\n if (updateBuildId) {\r\n this._buildId = NodeGeometry._BuildIdGenerator++;\r\n }\r\n\r\n this._buildExecutionTime = PrecisionDate.Now - now;\r\n\r\n // Errors\r\n state.emitErrors();\r\n\r\n this._buildWasSuccessful = true;\r\n this._vertexData = state.vertexData;\r\n this.onBuildObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Creates a mesh from the geometry blocks\r\n * @param name defines the name of the mesh\r\n * @param scene The scene the mesh is scoped to\r\n * @returns The new mesh\r\n */\r\n public createMesh(name: string, scene: Nullable<Scene> = null): Nullable<Mesh> {\r\n if (!this._buildWasSuccessful) {\r\n this.build();\r\n }\r\n\r\n if (!this._vertexData) {\r\n return null;\r\n }\r\n\r\n const mesh = new Mesh(name, scene);\r\n this._vertexData.applyToMesh(mesh);\r\n\r\n mesh._internalMetadata = mesh._internalMetadata || {};\r\n mesh._internalMetadata.nodeGeometry = this;\r\n\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a mesh from the geometry blocks\r\n * @param mesh the mesh to update\r\n * @returns True if successfully updated\r\n */\r\n public updateMesh(mesh: Mesh) {\r\n if (!this._buildWasSuccessful) {\r\n this.build();\r\n }\r\n\r\n if (!this._vertexData) {\r\n return false;\r\n }\r\n\r\n this._vertexData.applyToMesh(mesh);\r\n\r\n mesh._internalMetadata = mesh._internalMetadata || {};\r\n mesh._internalMetadata.nodeGeometry = this;\r\n\r\n return mesh;\r\n }\r\n\r\n private _initializeBlock(node: NodeGeometryBlock, autoConfigure = true) {\r\n node.initialize();\r\n if (autoConfigure) {\r\n node.autoConfigure();\r\n }\r\n node._preparationId = this._buildId;\r\n\r\n if (this.attachedBlocks.indexOf(node) === -1) {\r\n this.attachedBlocks.push(node);\r\n }\r\n\r\n for (const input of node.inputs) {\r\n const connectedPoint = input.connectedPoint;\r\n if (connectedPoint) {\r\n const block = connectedPoint.ownerBlock;\r\n if (block !== node) {\r\n this._initializeBlock(block, autoConfigure);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current geometry\r\n */\r\n public clear() {\r\n this.outputBlock = null;\r\n this.attachedBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * Remove a block from the current geometry\r\n * @param block defines the block to remove\r\n */\r\n public removeBlock(block: NodeGeometryBlock) {\r\n const attachedBlockIndex = this.attachedBlocks.indexOf(block);\r\n if (attachedBlockIndex > -1) {\r\n this.attachedBlocks.splice(attachedBlockIndex, 1);\r\n }\r\n\r\n if (block === this.outputBlock) {\r\n this.outputBlock = null;\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current graph and load a new one from a serialization object\r\n * @param source defines the JSON representation of the geometry\r\n * @param merge defines whether or not the source must be merged or replace the current content\r\n */\r\n public parseSerializedObject(source: any, merge = false) {\r\n if (!merge) {\r\n this.clear();\r\n }\r\n\r\n const map: { [key: number]: NodeGeometryBlock } = {};\r\n\r\n // Create blocks\r\n for (const parsedBlock of source.blocks) {\r\n const blockType = GetClass(parsedBlock.customType);\r\n if (blockType) {\r\n const block: NodeGeometryBlock = new blockType();\r\n block._deserialize(parsedBlock);\r\n map[parsedBlock.id] = block;\r\n\r\n this.attachedBlocks.push(block);\r\n }\r\n }\r\n\r\n // Reconnect teleportation\r\n for (const block of this.attachedBlocks) {\r\n if (block.isTeleportOut) {\r\n const teleportOut = block as TeleportOutBlock;\r\n const id = teleportOut._tempEntryPointUniqueId;\r\n if (id) {\r\n const source = map[id] as TeleportInBlock;\r\n source.attachToEndpoint(teleportOut);\r\n }\r\n }\r\n }\r\n\r\n // Connections - Starts with input blocks only (except if in \"merge\" mode where we scan all blocks)\r\n for (let blockIndex = 0; blockIndex < source.blocks.length; blockIndex++) {\r\n const parsedBlock = source.blocks[blockIndex];\r\n const block = map[parsedBlock.id];\r\n\r\n if (!block) {\r\n continue;\r\n }\r\n\r\n if (block.inputs.length && parsedBlock.inputs.some((i: any) => i.targetConnectionName) && !merge) {\r\n continue;\r\n }\r\n this._restoreConnections(block, source, map);\r\n }\r\n\r\n // Outputs\r\n if (source.outputNodeId) {\r\n this.outputBlock = map[source.outputNodeId] as GeometryOutputBlock;\r\n }\r\n\r\n // UI related info\r\n if (source.locations || (source.editorData && source.editorData.locations)) {\r\n const locations: {\r\n blockId: number;\r\n x: number;\r\n y: number;\r\n }[] = source.locations || source.editorData.locations;\r\n\r\n for (const location of locations) {\r\n if (map[location.blockId]) {\r\n location.blockId = map[location.blockId].uniqueId;\r\n }\r\n }\r\n\r\n if (merge && this.editorData && this.editorData.locations) {\r\n locations.concat(this.editorData.locations);\r\n }\r\n\r\n if (source.locations) {\r\n this.editorData = {\r\n locations: locations,\r\n };\r\n } else {\r\n this.editorData = source.editorData;\r\n this.editorData.locations = locations;\r\n }\r\n\r\n const blockMap: number[] = [];\r\n\r\n for (const key in map) {\r\n blockMap[key] = map[key].uniqueId;\r\n }\r\n\r\n this.editorData.map = blockMap;\r\n }\r\n\r\n this.comment = source.comment;\r\n }\r\n\r\n private _restoreConnections(block: NodeGeometryBlock, source: any, map: { [key: number]: NodeGeometryBlock }) {\r\n for (const outputPoint of block.outputs) {\r\n for (const candidate of source.blocks) {\r\n const target = map[candidate.id];\r\n\r\n if (!target) {\r\n continue;\r\n }\r\n\r\n for (const input of candidate.inputs) {\r\n if (map[input.targetBlockId] === block && input.targetConnectionName === outputPoint.name) {\r\n const inputPoint = target.getInputByName(input.inputName);\r\n if (!inputPoint || inputPoint.isConnected) {\r\n continue;\r\n }\r\n\r\n outputPoint.connectTo(inputPoint, true);\r\n this._restoreConnections(target, source, map);\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Generate a string containing the code declaration required to create an equivalent of this geometry\r\n * @returns a string\r\n */\r\n public generateCode() {\r\n let alreadyDumped: NodeGeometryBlock[] = [];\r\n const blocks: NodeGeometryBlock[] = [];\r\n const uniqueNames: string[] = [\"const\", \"var\", \"let\"];\r\n // Gets active blocks\r\n if (this.outputBlock) {\r\n this._gatherBlocks(this.outputBlock, blocks);\r\n }\r\n\r\n // Generate\r\n let codeString = `let nodeGeometry = new BABYLON.NodeGeometry(\"${this.name || \"node geometry\"}\");\\n`;\r\n for (const node of blocks) {\r\n if (node.isInput && alreadyDumped.indexOf(node) === -1) {\r\n codeString += node._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n if (this.outputBlock) {\r\n // Connections\r\n alreadyDumped = [];\r\n codeString += \"// Connections\\n\";\r\n codeString += this.outputBlock._dumpCodeForOutputConnections(alreadyDumped);\r\n\r\n // Output nodes\r\n codeString += \"// Output nodes\\n\";\r\n codeString += `nodeGeometry.outputBlock = ${this.outputBlock._codeVariableName};\\n`;\r\n codeString += `nodeGeometry.build();\\n`;\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n private _gatherBlocks(rootNode: NodeGeometryBlock, list: NodeGeometryBlock[]) {\r\n if (list.indexOf(rootNode) !== -1) {\r\n return;\r\n }\r\n list.push(rootNode);\r\n\r\n for (const input of rootNode.inputs) {\r\n const connectedPoint = input.connectedPoint;\r\n if (connectedPoint) {\r\n const block = connectedPoint.ownerBlock;\r\n if (block !== rootNode) {\r\n this._gatherBlocks(block, list);\r\n }\r\n }\r\n }\r\n\r\n // Teleportation\r\n if (rootNode.isTeleportOut) {\r\n const block = rootNode as TeleportOutBlock;\r\n if (block.entryPoint) {\r\n this._gatherBlocks(block.entryPoint, list);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current geometry and set it to a default state\r\n */\r\n public setToDefault() {\r\n this.clear();\r\n\r\n this.editorData = null;\r\n\r\n // Source\r\n const dataBlock = new BoxBlock(\"Box\");\r\n dataBlock.autoConfigure();\r\n\r\n // Final output\r\n const output = new GeometryOutputBlock(\"Geometry Output\");\r\n dataBlock.geometry.connectTo(output.geometry);\r\n\r\n this.outputBlock = output;\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current geometry.\r\n * @param name defines the name to use for the new geometry\r\n */\r\n public clone(name: string): NodeGeometry {\r\n const serializationObject = this.serialize();\r\n\r\n const clone = SerializationHelper.Clone(() => new NodeGeometry(name), this);\r\n clone.name = name;\r\n\r\n clone.parseSerializedObject(serializationObject);\r\n clone._buildId = this._buildId;\r\n clone.build(false);\r\n\r\n return clone;\r\n }\r\n\r\n /**\r\n * Serializes this geometry in a JSON representation\r\n * @param selectedBlocks defines the list of blocks to save (if null the whole geometry will be saved)\r\n * @returns the serialized geometry object\r\n */\r\n public serialize(selectedBlocks?: NodeGeometryBlock[]): any {\r\n const serializationObject = selectedBlocks ? {} : SerializationHelper.Serialize(this);\r\n serializationObject.editorData = JSON.parse(JSON.stringify(this.editorData)); // Copy\r\n\r\n let blocks: NodeGeometryBlock[] = [];\r\n\r\n if (selectedBlocks) {\r\n blocks = selectedBlocks;\r\n } else {\r\n serializationObject.customType = \"BABYLON.NodeGeometry\";\r\n if (this.outputBlock) {\r\n serializationObject.outputNodeId = this.outputBlock.uniqueId;\r\n }\r\n }\r\n\r\n // Blocks\r\n serializationObject.blocks = [];\r\n\r\n for (const block of blocks) {\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n\r\n if (!selectedBlocks) {\r\n for (const block of this.attachedBlocks) {\r\n if (blocks.indexOf(block) !== -1) {\r\n continue;\r\n }\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Disposes the ressources\r\n */\r\n public dispose(): void {\r\n for (const block of this.attachedBlocks) {\r\n block.dispose();\r\n }\r\n\r\n this.attachedBlocks.length = 0;\r\n this.onBuildObservable.clear();\r\n }\r\n\r\n /**\r\n * Creates a new node geometry set to default basic configuration\r\n * @param name defines the name of the geometry\r\n * @returns a new NodeGeometry\r\n */\r\n public static CreateDefault(name: string) {\r\n const nodeGeometry = new NodeGeometry(name);\r\n\r\n nodeGeometry.setToDefault();\r\n nodeGeometry.build();\r\n\r\n return nodeGeometry;\r\n }\r\n\r\n /**\r\n * Creates a node geometry from parsed geometry data\r\n * @param source defines the JSON representation of the geometry\r\n * @returns a new node geometry\r\n */\r\n public static Parse(source: any): NodeGeometry {\r\n const nodeGeometry = SerializationHelper.Parse(() => new NodeGeometry(source.name), source, null);\r\n\r\n nodeGeometry.parseSerializedObject(source);\r\n nodeGeometry.build();\r\n\r\n return nodeGeometry;\r\n }\r\n\r\n /**\r\n * Creates a node geometry from a snippet saved by the node geometry editor\r\n * @param snippetId defines the snippet to load\r\n * @param nodeGeometry defines a node geometry to update (instead of creating a new one)\r\n * @param skipBuild defines whether to build the node geometry\r\n * @returns a promise that will resolve to the new node geometry\r\n */\r\n public static ParseFromSnippetAsync(snippetId: string, nodeGeometry?: NodeGeometry, skipBuild: boolean = false): Promise<NodeGeometry> {\r\n if (snippetId === \"_BLANK\") {\r\n return Promise.resolve(NodeGeometry.CreateDefault(\"blank\"));\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.nodeGeometry);\r\n\r\n if (!nodeGeometry) {\r\n nodeGeometry = SerializationHelper.Parse(() => new NodeGeometry(snippetId), serializationObject, null);\r\n }\r\n\r\n nodeGeometry.parseSerializedObject(serializationObject);\r\n nodeGeometry.snippetId = snippetId;\r\n\r\n try {\r\n if (!skipBuild) {\r\n nodeGeometry.build();\r\n }\r\n resolve(nodeGeometry);\r\n } catch (err) {\r\n reject(err);\r\n }\r\n } else {\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"nodeGeometry.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/nodeGeometry.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAoB9C;;;GAGG;AACH,MAAM,OAAO,YAAY;IAgBrB,8CAA8C;IACtC,4BAA4B;QAChC,0DAA0D;QAC1D,IAAI,OAAO,kBAAkB,KAAK,WAAW,EAAE;YAC3C,OAAO,kBAAkB,CAAC;SAC7B;QAED,gFAAgF;QAChF,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,OAAO,CAAC,kBAAkB,KAAK,WAAW,EAAE;YACrF,OAAO,OAAO,CAAC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CAAC,6BAA6B,GAAG,SAAS,CAAC,CAAC;qBACrD;iBACJ;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;;AAroBc,8BAAiB,GAAW,CAAC,AAAZ,CAAa;AAM7C,gDAAgD;AAClC,sBAAS,GAAG,GAAG,KAAK,CAAC,cAAc,KAAK,MAAM,CAAC,OAAO,mDAAmD,AAAhG,CAAiG;AAExH,sCAAsC;AACxB,uBAAU,GAAG,SAAS,CAAC,UAAU,AAAvB,CAAwB;AAuDzC;IADN,SAAS,EAAE;0CACQ;AAMb;IADN,SAAS,CAAC,SAAS,CAAC;6CACE","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Mesh } from \"../mesh\";\r\nimport type { VertexData } from \"../mesh.vertexData\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { GeometryOutputBlock } from \"./Blocks/geometryOutputBlock\";\r\nimport type { NodeGeometryBlock } from \"./nodeGeometryBlock\";\r\nimport { NodeGeometryBuildState } from \"./nodeGeometryBuildState\";\r\nimport { GetClass } from \"../../Misc/typeStore\";\r\nimport { SerializationHelper, serialize } from \"../../Misc/decorators\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { WebRequest } from \"../../Misc/webRequest\";\r\nimport { BoxBlock } from \"./Blocks/Sources/boxBlock\";\r\nimport type { GeometryInputBlock } from \"./Blocks/geometryInputBlock\";\r\nimport { PrecisionDate } from \"../../Misc/precisionDate\";\r\nimport type { TeleportOutBlock } from \"./Blocks/Teleport/teleportOutBlock\";\r\nimport type { TeleportInBlock } from \"./Blocks/Teleport/teleportInBlock\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Color4 } from \"../../Maths/math.color\";\r\nimport { Engine } from \"../../Engines/engine\";\r\n\r\n// declare NODEGEOMETRYEDITOR namespace for compilation issue\r\ndeclare let NODEGEOMETRYEDITOR: any;\r\ndeclare let BABYLON: any;\r\n\r\n/**\r\n * Interface used to configure the node geometry editor\r\n */\r\nexport interface INodeGeometryEditorOptions {\r\n /** Define the URL to load node editor script from */\r\n editorURL?: string;\r\n /** Additional configuration for the NGE */\r\n nodeGeometryEditorConfig?: {\r\n backgroundColor?: Color4;\r\n hostScene?: Scene;\r\n hostMesh?: Mesh;\r\n };\r\n}\r\n\r\n/**\r\n * Defines a node based geometry\r\n * @see demo at https://playground.babylonjs.com#PYY6XE#69\r\n */\r\nexport class NodeGeometry {\r\n private static _BuildIdGenerator: number = 0;\r\n private _buildId: number = NodeGeometry._BuildIdGenerator++;\r\n private _buildWasSuccessful = false;\r\n private _vertexData: Nullable<VertexData> = null;\r\n private _buildExecutionTime: number = 0;\r\n\r\n /** Define the Url to load node editor script */\r\n public static EditorURL = `${Tools._DefaultCdnUrl}/v${Engine.Version}/nodeGeometryEditor/babylon.nodeGeometryEditor.js`;\r\n\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private BJSNODEGEOMETRYEDITOR = this._getGlobalNodeGeometryEditor();\r\n\r\n /** Get the inspector from bundle or global */\r\n private _getGlobalNodeGeometryEditor(): any {\r\n // UMD Global name detection from Webpack Bundle UMD Name.\r\n if (typeof NODEGEOMETRYEDITOR !== \"undefined\") {\r\n return NODEGEOMETRYEDITOR;\r\n }\r\n\r\n // In case of module let's check the global emitted from the editor entry point.\r\n if (typeof BABYLON !== \"undefined\" && typeof BABYLON.NodeGeometryEditor !== \"undefined\") {\r\n return BABYLON;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the time spent to build this block (in ms)\r\n */\r\n public get buildExecutionTime() {\r\n return this._buildExecutionTime;\r\n }\r\n\r\n /**\r\n * Gets or sets data used by visual editor\r\n * @see https://nge.babylonjs.com\r\n */\r\n public editorData: any = null;\r\n\r\n /**\r\n * Gets an array of blocks that needs to be serialized even if they are not yet connected\r\n */\r\n public attachedBlocks: NodeGeometryBlock[] = [];\r\n\r\n /**\r\n * Observable raised when the geometry is built\r\n */\r\n public onBuildObservable = new Observable<NodeGeometry>();\r\n\r\n /** Gets or sets the GeometryOutputBlock used to gather the final geometry data */\r\n public outputBlock: Nullable<GeometryOutputBlock> = null;\r\n\r\n /**\r\n * Snippet ID if the material was created from the snippet server\r\n */\r\n public snippetId: string;\r\n\r\n /**\r\n * The name of the geometry\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * A free comment about the geometry\r\n */\r\n @serialize(\"comment\")\r\n public comment: string;\r\n\r\n /**\r\n * Creates a new geometry\r\n * @param name defines the name of the geometry\r\n */\r\n public constructor(name: string) {\r\n this.name = name;\r\n }\r\n\r\n /**\r\n * Gets the current class name of the geometry e.g. \"NodeGeometry\"\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"NodeGeometry\";\r\n }\r\n\r\n /**\r\n * Get a block by its name\r\n * @param name defines the name of the block to retrieve\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByName(name: string) {\r\n let result = null;\r\n for (const block of this.attachedBlocks) {\r\n if (block.name === name) {\r\n if (!result) {\r\n result = block;\r\n } else {\r\n Tools.Warn(\"More than one block was found with the name `\" + name + \"`\");\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Get a block using a predicate\r\n * @param predicate defines the predicate used to find the good candidate\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByPredicate(predicate: (block: NodeGeometryBlock) => boolean) {\r\n for (const block of this.attachedBlocks) {\r\n if (predicate(block)) {\r\n return block;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the list of input blocks attached to this material\r\n * @returns an array of InputBlocks\r\n */\r\n public getInputBlocks() {\r\n const blocks: GeometryInputBlock[] = [];\r\n for (const block of this.attachedBlocks) {\r\n if (block.isInput) {\r\n blocks.push(block as GeometryInputBlock);\r\n }\r\n }\r\n\r\n return blocks;\r\n }\r\n\r\n /**\r\n * Launch the node geometry editor\r\n * @param config Define the configuration of the editor\r\n * @returns a promise fulfilled when the node editor is visible\r\n */\r\n public edit(config?: INodeGeometryEditorOptions): Promise<void> {\r\n return new Promise((resolve) => {\r\n this.BJSNODEGEOMETRYEDITOR = this.BJSNODEGEOMETRYEDITOR || this._getGlobalNodeGeometryEditor();\r\n if (typeof this.BJSNODEGEOMETRYEDITOR == \"undefined\") {\r\n const editorUrl = config && config.editorURL ? config.editorURL : NodeGeometry.EditorURL;\r\n\r\n // Load editor and add it to the DOM\r\n Tools.LoadBabylonScript(editorUrl, () => {\r\n this.BJSNODEGEOMETRYEDITOR = this.BJSNODEGEOMETRYEDITOR || this._getGlobalNodeGeometryEditor();\r\n this._createNodeEditor(config?.nodeGeometryEditorConfig);\r\n resolve();\r\n });\r\n } else {\r\n // Otherwise creates the editor\r\n this._createNodeEditor(config?.nodeGeometryEditorConfig);\r\n resolve();\r\n }\r\n });\r\n }\r\n\r\n /** Creates the node editor window. */\r\n private _createNodeEditor(additionalConfig?: any) {\r\n const nodeEditorConfig: any = {\r\n nodeGeometry: this,\r\n ...additionalConfig,\r\n };\r\n this.BJSNODEGEOMETRYEDITOR.NodeGeometryEditor.Show(nodeEditorConfig);\r\n }\r\n\r\n /**\r\n * Build the final geometry\r\n * @param verbose defines if the build should log activity\r\n * @param updateBuildId defines if the internal build Id should be updated (default is true)\r\n * @param autoConfigure defines if the autoConfigure method should be called when initializing blocks (default is false)\r\n */\r\n public build(verbose: boolean = false, updateBuildId = true, autoConfigure = false) {\r\n this._buildWasSuccessful = false;\r\n\r\n if (!this.outputBlock) {\r\n throw \"You must define the outputBlock property before building the geometry\";\r\n }\r\n const now = PrecisionDate.Now;\r\n // Initialize blocks\r\n this._initializeBlock(this.outputBlock, autoConfigure);\r\n\r\n // Build\r\n const state = new NodeGeometryBuildState();\r\n\r\n state.buildId = this._buildId;\r\n state.verbose = verbose;\r\n\r\n this.outputBlock.build(state);\r\n\r\n if (updateBuildId) {\r\n this._buildId = NodeGeometry._BuildIdGenerator++;\r\n }\r\n\r\n this._buildExecutionTime = PrecisionDate.Now - now;\r\n\r\n // Errors\r\n state.emitErrors();\r\n\r\n this._buildWasSuccessful = true;\r\n this._vertexData = state.vertexData;\r\n this.onBuildObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Creates a mesh from the geometry blocks\r\n * @param name defines the name of the mesh\r\n * @param scene The scene the mesh is scoped to\r\n * @returns The new mesh\r\n */\r\n public createMesh(name: string, scene: Nullable<Scene> = null): Nullable<Mesh> {\r\n if (!this._buildWasSuccessful) {\r\n this.build();\r\n }\r\n\r\n if (!this._vertexData) {\r\n return null;\r\n }\r\n\r\n const mesh = new Mesh(name, scene);\r\n this._vertexData.applyToMesh(mesh);\r\n\r\n mesh._internalMetadata = mesh._internalMetadata || {};\r\n mesh._internalMetadata.nodeGeometry = this;\r\n\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a mesh from the geometry blocks\r\n * @param mesh the mesh to update\r\n * @returns True if successfully updated\r\n */\r\n public updateMesh(mesh: Mesh) {\r\n if (!this._buildWasSuccessful) {\r\n this.build();\r\n }\r\n\r\n if (!this._vertexData) {\r\n return false;\r\n }\r\n\r\n this._vertexData.applyToMesh(mesh);\r\n\r\n mesh._internalMetadata = mesh._internalMetadata || {};\r\n mesh._internalMetadata.nodeGeometry = this;\r\n\r\n return mesh;\r\n }\r\n\r\n private _initializeBlock(node: NodeGeometryBlock, autoConfigure = true) {\r\n node.initialize();\r\n if (autoConfigure) {\r\n node.autoConfigure();\r\n }\r\n node._preparationId = this._buildId;\r\n\r\n if (this.attachedBlocks.indexOf(node) === -1) {\r\n this.attachedBlocks.push(node);\r\n }\r\n\r\n for (const input of node.inputs) {\r\n const connectedPoint = input.connectedPoint;\r\n if (connectedPoint) {\r\n const block = connectedPoint.ownerBlock;\r\n if (block !== node) {\r\n this._initializeBlock(block, autoConfigure);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current geometry\r\n */\r\n public clear() {\r\n this.outputBlock = null;\r\n this.attachedBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * Remove a block from the current geometry\r\n * @param block defines the block to remove\r\n */\r\n public removeBlock(block: NodeGeometryBlock) {\r\n const attachedBlockIndex = this.attachedBlocks.indexOf(block);\r\n if (attachedBlockIndex > -1) {\r\n this.attachedBlocks.splice(attachedBlockIndex, 1);\r\n }\r\n\r\n if (block === this.outputBlock) {\r\n this.outputBlock = null;\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current graph and load a new one from a serialization object\r\n * @param source defines the JSON representation of the geometry\r\n * @param merge defines whether or not the source must be merged or replace the current content\r\n */\r\n public parseSerializedObject(source: any, merge = false) {\r\n if (!merge) {\r\n this.clear();\r\n }\r\n\r\n const map: { [key: number]: NodeGeometryBlock } = {};\r\n\r\n // Create blocks\r\n for (const parsedBlock of source.blocks) {\r\n const blockType = GetClass(parsedBlock.customType);\r\n if (blockType) {\r\n const block: NodeGeometryBlock = new blockType();\r\n block._deserialize(parsedBlock);\r\n map[parsedBlock.id] = block;\r\n\r\n this.attachedBlocks.push(block);\r\n }\r\n }\r\n\r\n // Reconnect teleportation\r\n for (const block of this.attachedBlocks) {\r\n if (block.isTeleportOut) {\r\n const teleportOut = block as TeleportOutBlock;\r\n const id = teleportOut._tempEntryPointUniqueId;\r\n if (id) {\r\n const source = map[id] as TeleportInBlock;\r\n if (source) {\r\n source.attachToEndpoint(teleportOut);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Connections - Starts with input blocks only (except if in \"merge\" mode where we scan all blocks)\r\n for (let blockIndex = 0; blockIndex < source.blocks.length; blockIndex++) {\r\n const parsedBlock = source.blocks[blockIndex];\r\n const block = map[parsedBlock.id];\r\n\r\n if (!block) {\r\n continue;\r\n }\r\n\r\n if (block.inputs.length && parsedBlock.inputs.some((i: any) => i.targetConnectionName) && !merge) {\r\n continue;\r\n }\r\n this._restoreConnections(block, source, map);\r\n }\r\n\r\n // Outputs\r\n if (source.outputNodeId) {\r\n this.outputBlock = map[source.outputNodeId] as GeometryOutputBlock;\r\n }\r\n\r\n // UI related info\r\n if (source.locations || (source.editorData && source.editorData.locations)) {\r\n const locations: {\r\n blockId: number;\r\n x: number;\r\n y: number;\r\n }[] = source.locations || source.editorData.locations;\r\n\r\n for (const location of locations) {\r\n if (map[location.blockId]) {\r\n location.blockId = map[location.blockId].uniqueId;\r\n }\r\n }\r\n\r\n if (merge && this.editorData && this.editorData.locations) {\r\n locations.concat(this.editorData.locations);\r\n }\r\n\r\n if (source.locations) {\r\n this.editorData = {\r\n locations: locations,\r\n };\r\n } else {\r\n this.editorData = source.editorData;\r\n this.editorData.locations = locations;\r\n }\r\n\r\n const blockMap: number[] = [];\r\n\r\n for (const key in map) {\r\n blockMap[key] = map[key].uniqueId;\r\n }\r\n\r\n this.editorData.map = blockMap;\r\n }\r\n\r\n this.comment = source.comment;\r\n }\r\n\r\n private _restoreConnections(block: NodeGeometryBlock, source: any, map: { [key: number]: NodeGeometryBlock }) {\r\n for (const outputPoint of block.outputs) {\r\n for (const candidate of source.blocks) {\r\n const target = map[candidate.id];\r\n\r\n if (!target) {\r\n continue;\r\n }\r\n\r\n for (const input of candidate.inputs) {\r\n if (map[input.targetBlockId] === block && input.targetConnectionName === outputPoint.name) {\r\n const inputPoint = target.getInputByName(input.inputName);\r\n if (!inputPoint || inputPoint.isConnected) {\r\n continue;\r\n }\r\n\r\n outputPoint.connectTo(inputPoint, true);\r\n this._restoreConnections(target, source, map);\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Generate a string containing the code declaration required to create an equivalent of this geometry\r\n * @returns a string\r\n */\r\n public generateCode() {\r\n let alreadyDumped: NodeGeometryBlock[] = [];\r\n const blocks: NodeGeometryBlock[] = [];\r\n const uniqueNames: string[] = [\"const\", \"var\", \"let\"];\r\n // Gets active blocks\r\n if (this.outputBlock) {\r\n this._gatherBlocks(this.outputBlock, blocks);\r\n }\r\n\r\n // Generate\r\n let codeString = `let nodeGeometry = new BABYLON.NodeGeometry(\"${this.name || \"node geometry\"}\");\\n`;\r\n for (const node of blocks) {\r\n if (node.isInput && alreadyDumped.indexOf(node) === -1) {\r\n codeString += node._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n if (this.outputBlock) {\r\n // Connections\r\n alreadyDumped = [];\r\n codeString += \"// Connections\\n\";\r\n codeString += this.outputBlock._dumpCodeForOutputConnections(alreadyDumped);\r\n\r\n // Output nodes\r\n codeString += \"// Output nodes\\n\";\r\n codeString += `nodeGeometry.outputBlock = ${this.outputBlock._codeVariableName};\\n`;\r\n codeString += `nodeGeometry.build();\\n`;\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n private _gatherBlocks(rootNode: NodeGeometryBlock, list: NodeGeometryBlock[]) {\r\n if (list.indexOf(rootNode) !== -1) {\r\n return;\r\n }\r\n list.push(rootNode);\r\n\r\n for (const input of rootNode.inputs) {\r\n const connectedPoint = input.connectedPoint;\r\n if (connectedPoint) {\r\n const block = connectedPoint.ownerBlock;\r\n if (block !== rootNode) {\r\n this._gatherBlocks(block, list);\r\n }\r\n }\r\n }\r\n\r\n // Teleportation\r\n if (rootNode.isTeleportOut) {\r\n const block = rootNode as TeleportOutBlock;\r\n if (block.entryPoint) {\r\n this._gatherBlocks(block.entryPoint, list);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current geometry and set it to a default state\r\n */\r\n public setToDefault() {\r\n this.clear();\r\n\r\n this.editorData = null;\r\n\r\n // Source\r\n const dataBlock = new BoxBlock(\"Box\");\r\n dataBlock.autoConfigure();\r\n\r\n // Final output\r\n const output = new GeometryOutputBlock(\"Geometry Output\");\r\n dataBlock.geometry.connectTo(output.geometry);\r\n\r\n this.outputBlock = output;\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current geometry.\r\n * @param name defines the name to use for the new geometry\r\n */\r\n public clone(name: string): NodeGeometry {\r\n const serializationObject = this.serialize();\r\n\r\n const clone = SerializationHelper.Clone(() => new NodeGeometry(name), this);\r\n clone.name = name;\r\n\r\n clone.parseSerializedObject(serializationObject);\r\n clone._buildId = this._buildId;\r\n clone.build(false);\r\n\r\n return clone;\r\n }\r\n\r\n /**\r\n * Serializes this geometry in a JSON representation\r\n * @param selectedBlocks defines the list of blocks to save (if null the whole geometry will be saved)\r\n * @returns the serialized geometry object\r\n */\r\n public serialize(selectedBlocks?: NodeGeometryBlock[]): any {\r\n const serializationObject = selectedBlocks ? {} : SerializationHelper.Serialize(this);\r\n serializationObject.editorData = JSON.parse(JSON.stringify(this.editorData)); // Copy\r\n\r\n let blocks: NodeGeometryBlock[] = [];\r\n\r\n if (selectedBlocks) {\r\n blocks = selectedBlocks;\r\n } else {\r\n serializationObject.customType = \"BABYLON.NodeGeometry\";\r\n if (this.outputBlock) {\r\n serializationObject.outputNodeId = this.outputBlock.uniqueId;\r\n }\r\n }\r\n\r\n // Blocks\r\n serializationObject.blocks = [];\r\n\r\n for (const block of blocks) {\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n\r\n if (!selectedBlocks) {\r\n for (const block of this.attachedBlocks) {\r\n if (blocks.indexOf(block) !== -1) {\r\n continue;\r\n }\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Disposes the ressources\r\n */\r\n public dispose(): void {\r\n for (const block of this.attachedBlocks) {\r\n block.dispose();\r\n }\r\n\r\n this.attachedBlocks.length = 0;\r\n this.onBuildObservable.clear();\r\n }\r\n\r\n /**\r\n * Creates a new node geometry set to default basic configuration\r\n * @param name defines the name of the geometry\r\n * @returns a new NodeGeometry\r\n */\r\n public static CreateDefault(name: string) {\r\n const nodeGeometry = new NodeGeometry(name);\r\n\r\n nodeGeometry.setToDefault();\r\n nodeGeometry.build();\r\n\r\n return nodeGeometry;\r\n }\r\n\r\n /**\r\n * Creates a node geometry from parsed geometry data\r\n * @param source defines the JSON representation of the geometry\r\n * @returns a new node geometry\r\n */\r\n public static Parse(source: any): NodeGeometry {\r\n const nodeGeometry = SerializationHelper.Parse(() => new NodeGeometry(source.name), source, null);\r\n\r\n nodeGeometry.parseSerializedObject(source);\r\n nodeGeometry.build();\r\n\r\n return nodeGeometry;\r\n }\r\n\r\n /**\r\n * Creates a node geometry from a snippet saved by the node geometry editor\r\n * @param snippetId defines the snippet to load\r\n * @param nodeGeometry defines a node geometry to update (instead of creating a new one)\r\n * @param skipBuild defines whether to build the node geometry\r\n * @returns a promise that will resolve to the new node geometry\r\n */\r\n public static ParseFromSnippetAsync(snippetId: string, nodeGeometry?: NodeGeometry, skipBuild: boolean = false): Promise<NodeGeometry> {\r\n if (snippetId === \"_BLANK\") {\r\n return Promise.resolve(NodeGeometry.CreateDefault(\"blank\"));\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.nodeGeometry);\r\n\r\n if (!nodeGeometry) {\r\n nodeGeometry = SerializationHelper.Parse(() => new NodeGeometry(snippetId), serializationObject, null);\r\n }\r\n\r\n nodeGeometry.parseSerializedObject(serializationObject);\r\n nodeGeometry.snippetId = snippetId;\r\n\r\n try {\r\n if (!skipBuild) {\r\n nodeGeometry.build();\r\n }\r\n resolve(nodeGeometry);\r\n } catch (err) {\r\n reject(err);\r\n }\r\n } else {\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n}\r\n"]}
|
package/Meshes/groundMesh.js
CHANGED
|
@@ -169,7 +169,7 @@ export class GroundMesh extends Mesh {
|
|
|
169
169
|
}
|
|
170
170
|
return this;
|
|
171
171
|
}
|
|
172
|
-
// Compute each quad element values and update the
|
|
172
|
+
// Compute each quad element values and update the heightMap array :
|
|
173
173
|
// slope : Vector2(c, h) = 2D diagonal line equation setting apart two triangular facets in a quad : z = cx + h
|
|
174
174
|
// facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
|
|
175
175
|
// facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
|
package/Meshes/groundMesh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groundMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/groundMesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,IAAI,CAAC,iBAAiB,GAAG,CAAC,UAAe,EAAE,KAAY,EAAQ,EAAE;IAC7D,OAAO,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAI;IAuBhC,YAAY,IAAY,EAAE,KAAa;QACnC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAvBvB,oCAAoC;QAC7B,mBAAc,GAAG,KAAK,CAAC;IAuB9B,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,IAA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7C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAEtD,MAAM,CAAC,cAAc,GAAG,UAAU,CAAC,aAAa,IAAI,CAAC,CAAC;QACtD,MAAM,CAAC,cAAc,GAAG,UAAU,CAAC,aAAa,IAAI,CAAC,CAAC;QAEtD,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,MAAM,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;QAEnC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../scene\";\r\nimport { Vector3, Vector2, TmpVectors, Vector4 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\n\r\nMesh._GroundMeshParser = (parsedMesh: any, scene: Scene): Mesh => {\r\n return GroundMesh.Parse(parsedMesh, scene);\r\n};\r\n\r\n/**\r\n * Mesh representing the ground\r\n */\r\nexport class GroundMesh extends Mesh {\r\n /** If octree should be generated */\r\n public generateOctree = false;\r\n\r\n private _heightQuads: { slope: Vector2; facet1: Vector4; facet2: Vector4 }[];\r\n\r\n /** @internal */\r\n public _subdivisionsX: number;\r\n /** @internal */\r\n public _subdivisionsY: number;\r\n /** @internal */\r\n public _width: number;\r\n /** @internal */\r\n public _height: number;\r\n /** @internal */\r\n public _minX: number;\r\n /** @internal */\r\n public _maxX: number;\r\n /** @internal */\r\n public _minZ: number;\r\n /** @internal */\r\n public _maxZ: number;\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n /**\r\n * \"GroundMesh\"\r\n * @returns \"GroundMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GroundMesh\";\r\n }\r\n\r\n /**\r\n * The minimum of x and y subdivisions\r\n */\r\n public get subdivisions(): number {\r\n return Math.min(this._subdivisionsX, this._subdivisionsY);\r\n }\r\n\r\n /**\r\n * X subdivisions\r\n */\r\n public get subdivisionsX(): number {\r\n return this._subdivisionsX;\r\n }\r\n\r\n /**\r\n * Y subdivisions\r\n */\r\n public get subdivisionsY(): number {\r\n return this._subdivisionsY;\r\n }\r\n\r\n /**\r\n * This function will divide the mesh into submeshes and update an octree to help to select the right submeshes\r\n * for rendering, picking and collision computations. Please note that you must have a decent number of submeshes\r\n * to get performance improvements when using an octree.\r\n * @param chunksCount the number of submeshes the mesh will be divided into\r\n * @param octreeBlocksSize the maximum size of the octree blocks (Default: 32)\r\n */\r\n public optimize(chunksCount: number, octreeBlocksSize = 32): void {\r\n this._subdivisionsX = chunksCount;\r\n this._subdivisionsY = chunksCount;\r\n this.subdivide(chunksCount);\r\n\r\n // Call the octree system optimization if it is defined.\r\n const thisAsAny = this as any;\r\n if (thisAsAny.createOrUpdateSubmeshesOctree) {\r\n thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);\r\n }\r\n }\r\n\r\n /**\r\n * Returns a height (y) value in the World system :\r\n * the ground altitude at the coordinates (x, z) expressed in the World system.\r\n * @param x x coordinate\r\n * @param z z coordinate\r\n * @returns the ground y position if (x, z) are outside the ground surface.\r\n */\r\n public getHeightAtCoordinates(x: number, z: number): number {\r\n const world = this.getWorldMatrix();\r\n const invMat = TmpVectors.Matrix[5];\r\n world.invertToRef(invMat);\r\n const tmpVect = TmpVectors.Vector3[8];\r\n Vector3.TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space\r\n x = tmpVect.x;\r\n z = tmpVect.z;\r\n if (x < this._minX || x >= this._maxX || z <= this._minZ || z > this._maxZ) {\r\n return this.position.y;\r\n }\r\n if (!this._heightQuads || this._heightQuads.length == 0) {\r\n this._initHeightQuads();\r\n this._computeHeightQuads();\r\n }\r\n const facet = this._getFacetAt(x, z);\r\n const y = -(facet.x * x + facet.z * z + facet.w) / facet.y;\r\n // return y in the World system\r\n Vector3.TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);\r\n return tmpVect.y;\r\n }\r\n\r\n /**\r\n * Returns a normalized vector (Vector3) orthogonal to the ground\r\n * at the ground coordinates (x, z) expressed in the World system.\r\n * @param x x coordinate\r\n * @param z z coordinate\r\n * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.\r\n */\r\n public getNormalAtCoordinates(x: number, z: number): Vector3 {\r\n const normal = new Vector3(0.0, 1.0, 0.0);\r\n this.getNormalAtCoordinatesToRef(x, z, normal);\r\n return normal;\r\n }\r\n\r\n /**\r\n * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground\r\n * at the ground coordinates (x, z) expressed in the World system.\r\n * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.\r\n * @param x x coordinate\r\n * @param z z coordinate\r\n * @param ref vector to store the result\r\n * @returns the GroundMesh.\r\n */\r\n public getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh {\r\n const world = this.getWorldMatrix();\r\n const tmpMat = TmpVectors.Matrix[5];\r\n world.invertToRef(tmpMat);\r\n const tmpVect = TmpVectors.Vector3[8];\r\n Vector3.TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space\r\n x = tmpVect.x;\r\n z = tmpVect.z;\r\n if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {\r\n return this;\r\n }\r\n if (!this._heightQuads || this._heightQuads.length == 0) {\r\n this._initHeightQuads();\r\n this._computeHeightQuads();\r\n }\r\n const facet = this._getFacetAt(x, z);\r\n Vector3.TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);\r\n return this;\r\n }\r\n\r\n /**\r\n * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()\r\n * if the ground has been updated.\r\n * This can be used in the render loop.\r\n * @returns the GroundMesh.\r\n */\r\n public updateCoordinateHeights(): GroundMesh {\r\n if (!this._heightQuads || this._heightQuads.length == 0) {\r\n this._initHeightQuads();\r\n }\r\n this._computeHeightQuads();\r\n return this;\r\n }\r\n\r\n // Returns the element \"facet\" from the heightQuads array relative to (x, z) local coordinates\r\n private _getFacetAt(x: number, z: number): Vector4 {\r\n // retrieve col and row from x, z coordinates in the ground local system\r\n const col = Math.floor(((x + this._maxX) * this._subdivisionsX) / this._width);\r\n const row = Math.floor((-(z + this._maxZ) * this._subdivisionsY) / this._height + this._subdivisionsY);\r\n const quad = this._heightQuads[row * this._subdivisionsX + col];\r\n let facet;\r\n if (z < quad.slope.x * x + quad.slope.y) {\r\n facet = quad.facet1;\r\n } else {\r\n facet = quad.facet2;\r\n }\r\n return facet;\r\n }\r\n\r\n // Creates and populates the heightMap array with \"facet\" elements :\r\n // a quad is two triangular facets separated by a slope, so a \"facet\" element is 1 slope + 2 facets\r\n // slope : Vector2(c, h) = 2D diagonal line equation setting apart two triangular facets in a quad : z = cx + h\r\n // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0\r\n // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0\r\n // Returns the GroundMesh.\r\n private _initHeightQuads(): GroundMesh {\r\n const subdivisionsX = this._subdivisionsX;\r\n const subdivisionsY = this._subdivisionsY;\r\n this._heightQuads = new Array();\r\n for (let row = 0; row < subdivisionsY; row++) {\r\n for (let col = 0; col < subdivisionsX; col++) {\r\n const quad = { slope: Vector2.Zero(), facet1: new Vector4(0.0, 0.0, 0.0, 0.0), facet2: new Vector4(0.0, 0.0, 0.0, 0.0) };\r\n this._heightQuads[row * subdivisionsX + col] = quad;\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n // Compute each quad element values and update the the heightMap array :\r\n // slope : Vector2(c, h) = 2D diagonal line equation setting apart two triangular facets in a quad : z = cx + h\r\n // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0\r\n // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0\r\n // Returns the GroundMesh.\r\n private _computeHeightQuads(): GroundMesh {\r\n const positions = this.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n if (!positions) {\r\n return this;\r\n }\r\n\r\n const v1 = TmpVectors.Vector3[3];\r\n const v2 = TmpVectors.Vector3[2];\r\n const v3 = TmpVectors.Vector3[1];\r\n const v4 = TmpVectors.Vector3[0];\r\n const v1v2 = TmpVectors.Vector3[4];\r\n const v1v3 = TmpVectors.Vector3[5];\r\n const v1v4 = TmpVectors.Vector3[6];\r\n const norm1 = TmpVectors.Vector3[7];\r\n const norm2 = TmpVectors.Vector3[8];\r\n let i = 0;\r\n let j = 0;\r\n let k = 0;\r\n let cd = 0; // 2D slope coefficient : z = cd * x + h\r\n let h = 0;\r\n let d1 = 0; // facet plane equation : ax + by + cz + d = 0\r\n let d2 = 0;\r\n\r\n const subdivisionsX = this._subdivisionsX;\r\n const subdivisionsY = this._subdivisionsY;\r\n\r\n for (let row = 0; row < subdivisionsY; row++) {\r\n for (let col = 0; col < subdivisionsX; col++) {\r\n i = col * 3;\r\n j = row * (subdivisionsX + 1) * 3;\r\n k = (row + 1) * (subdivisionsX + 1) * 3;\r\n v1.x = positions[j + i];\r\n v1.y = positions[j + i + 1];\r\n v1.z = positions[j + i + 2];\r\n v2.x = positions[j + i + 3];\r\n v2.y = positions[j + i + 4];\r\n v2.z = positions[j + i + 5];\r\n v3.x = positions[k + i];\r\n v3.y = positions[k + i + 1];\r\n v3.z = positions[k + i + 2];\r\n v4.x = positions[k + i + 3];\r\n v4.y = positions[k + i + 4];\r\n v4.z = positions[k + i + 5];\r\n\r\n // 2D slope V1V4\r\n cd = (v4.z - v1.z) / (v4.x - v1.x);\r\n h = v1.z - cd * v1.x; // v1 belongs to the slope\r\n\r\n // facet equations :\r\n // we compute each facet normal vector\r\n // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0\r\n // we compute the value d by applying the equation to v1 which belongs to the plane\r\n // then we store the facet equation in a Vector4\r\n v2.subtractToRef(v1, v1v2);\r\n v3.subtractToRef(v1, v1v3);\r\n v4.subtractToRef(v1, v1v4);\r\n Vector3.CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class\r\n Vector3.CrossToRef(v1v2, v1v4, norm2);\r\n norm1.normalize();\r\n norm2.normalize();\r\n d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);\r\n d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);\r\n\r\n const quad = this._heightQuads[row * subdivisionsX + col];\r\n quad.slope.copyFromFloats(cd, h);\r\n quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);\r\n quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Serializes this ground mesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.subdivisionsX = this._subdivisionsX;\r\n serializationObject.subdivisionsY = this._subdivisionsY;\r\n\r\n serializationObject.minX = this._minX;\r\n serializationObject.maxX = this._maxX;\r\n\r\n serializationObject.minZ = this._minZ;\r\n serializationObject.maxZ = this._maxZ;\r\n\r\n serializationObject.width = this._width;\r\n serializationObject.height = this._height;\r\n }\r\n\r\n /**\r\n * Parses a serialized ground mesh\r\n * @param parsedMesh the serialized mesh\r\n * @param scene the scene to create the ground mesh in\r\n * @returns the created ground mesh\r\n */\r\n public static Parse(parsedMesh: any, scene: Scene): GroundMesh {\r\n const result = new GroundMesh(parsedMesh.name, scene);\r\n\r\n result._subdivisionsX = parsedMesh.subdivisionsX || 1;\r\n result._subdivisionsY = parsedMesh.subdivisionsY || 1;\r\n\r\n result._minX = parsedMesh.minX;\r\n result._maxX = parsedMesh.maxX;\r\n\r\n result._minZ = parsedMesh.minZ;\r\n result._maxZ = parsedMesh.maxZ;\r\n\r\n result._width = parsedMesh.width;\r\n result._height = parsedMesh.height;\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"groundMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/groundMesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,IAAI,CAAC,iBAAiB,GAAG,CAAC,UAAe,EAAE,KAAY,EAAQ,EAAE;IAC7D,OAAO,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAI;IAuBhC,YAAY,IAAY,EAAE,KAAa;QACnC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAvBvB,oCAAoC;QAC7B,mBAAc,GAAG,KAAK,CAAC;IAuB9B,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,QAAQ,CAAC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AAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,MAAM,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;QAEnC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../scene\";\r\nimport { Vector3, Vector2, TmpVectors, Vector4 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\n\r\nMesh._GroundMeshParser = (parsedMesh: any, scene: Scene): Mesh => {\r\n return GroundMesh.Parse(parsedMesh, scene);\r\n};\r\n\r\n/**\r\n * Mesh representing the ground\r\n */\r\nexport class GroundMesh extends Mesh {\r\n /** If octree should be generated */\r\n public generateOctree = false;\r\n\r\n private _heightQuads: { slope: Vector2; facet1: Vector4; facet2: Vector4 }[];\r\n\r\n /** @internal */\r\n public _subdivisionsX: number;\r\n /** @internal */\r\n public _subdivisionsY: number;\r\n /** @internal */\r\n public _width: number;\r\n /** @internal */\r\n public _height: number;\r\n /** @internal */\r\n public _minX: number;\r\n /** @internal */\r\n public _maxX: number;\r\n /** @internal */\r\n public _minZ: number;\r\n /** @internal */\r\n public _maxZ: number;\r\n\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene);\r\n }\r\n\r\n /**\r\n * \"GroundMesh\"\r\n * @returns \"GroundMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GroundMesh\";\r\n }\r\n\r\n /**\r\n * The minimum of x and y subdivisions\r\n */\r\n public get subdivisions(): number {\r\n return Math.min(this._subdivisionsX, this._subdivisionsY);\r\n }\r\n\r\n /**\r\n * X subdivisions\r\n */\r\n public get subdivisionsX(): number {\r\n return this._subdivisionsX;\r\n }\r\n\r\n /**\r\n * Y subdivisions\r\n */\r\n public get subdivisionsY(): number {\r\n return this._subdivisionsY;\r\n }\r\n\r\n /**\r\n * This function will divide the mesh into submeshes and update an octree to help to select the right submeshes\r\n * for rendering, picking and collision computations. Please note that you must have a decent number of submeshes\r\n * to get performance improvements when using an octree.\r\n * @param chunksCount the number of submeshes the mesh will be divided into\r\n * @param octreeBlocksSize the maximum size of the octree blocks (Default: 32)\r\n */\r\n public optimize(chunksCount: number, octreeBlocksSize = 32): void {\r\n this._subdivisionsX = chunksCount;\r\n this._subdivisionsY = chunksCount;\r\n this.subdivide(chunksCount);\r\n\r\n // Call the octree system optimization if it is defined.\r\n const thisAsAny = this as any;\r\n if (thisAsAny.createOrUpdateSubmeshesOctree) {\r\n thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);\r\n }\r\n }\r\n\r\n /**\r\n * Returns a height (y) value in the World system :\r\n * the ground altitude at the coordinates (x, z) expressed in the World system.\r\n * @param x x coordinate\r\n * @param z z coordinate\r\n * @returns the ground y position if (x, z) are outside the ground surface.\r\n */\r\n public getHeightAtCoordinates(x: number, z: number): number {\r\n const world = this.getWorldMatrix();\r\n const invMat = TmpVectors.Matrix[5];\r\n world.invertToRef(invMat);\r\n const tmpVect = TmpVectors.Vector3[8];\r\n Vector3.TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space\r\n x = tmpVect.x;\r\n z = tmpVect.z;\r\n if (x < this._minX || x >= this._maxX || z <= this._minZ || z > this._maxZ) {\r\n return this.position.y;\r\n }\r\n if (!this._heightQuads || this._heightQuads.length == 0) {\r\n this._initHeightQuads();\r\n this._computeHeightQuads();\r\n }\r\n const facet = this._getFacetAt(x, z);\r\n const y = -(facet.x * x + facet.z * z + facet.w) / facet.y;\r\n // return y in the World system\r\n Vector3.TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);\r\n return tmpVect.y;\r\n }\r\n\r\n /**\r\n * Returns a normalized vector (Vector3) orthogonal to the ground\r\n * at the ground coordinates (x, z) expressed in the World system.\r\n * @param x x coordinate\r\n * @param z z coordinate\r\n * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.\r\n */\r\n public getNormalAtCoordinates(x: number, z: number): Vector3 {\r\n const normal = new Vector3(0.0, 1.0, 0.0);\r\n this.getNormalAtCoordinatesToRef(x, z, normal);\r\n return normal;\r\n }\r\n\r\n /**\r\n * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground\r\n * at the ground coordinates (x, z) expressed in the World system.\r\n * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.\r\n * @param x x coordinate\r\n * @param z z coordinate\r\n * @param ref vector to store the result\r\n * @returns the GroundMesh.\r\n */\r\n public getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh {\r\n const world = this.getWorldMatrix();\r\n const tmpMat = TmpVectors.Matrix[5];\r\n world.invertToRef(tmpMat);\r\n const tmpVect = TmpVectors.Vector3[8];\r\n Vector3.TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space\r\n x = tmpVect.x;\r\n z = tmpVect.z;\r\n if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {\r\n return this;\r\n }\r\n if (!this._heightQuads || this._heightQuads.length == 0) {\r\n this._initHeightQuads();\r\n this._computeHeightQuads();\r\n }\r\n const facet = this._getFacetAt(x, z);\r\n Vector3.TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);\r\n return this;\r\n }\r\n\r\n /**\r\n * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()\r\n * if the ground has been updated.\r\n * This can be used in the render loop.\r\n * @returns the GroundMesh.\r\n */\r\n public updateCoordinateHeights(): GroundMesh {\r\n if (!this._heightQuads || this._heightQuads.length == 0) {\r\n this._initHeightQuads();\r\n }\r\n this._computeHeightQuads();\r\n return this;\r\n }\r\n\r\n // Returns the element \"facet\" from the heightQuads array relative to (x, z) local coordinates\r\n private _getFacetAt(x: number, z: number): Vector4 {\r\n // retrieve col and row from x, z coordinates in the ground local system\r\n const col = Math.floor(((x + this._maxX) * this._subdivisionsX) / this._width);\r\n const row = Math.floor((-(z + this._maxZ) * this._subdivisionsY) / this._height + this._subdivisionsY);\r\n const quad = this._heightQuads[row * this._subdivisionsX + col];\r\n let facet;\r\n if (z < quad.slope.x * x + quad.slope.y) {\r\n facet = quad.facet1;\r\n } else {\r\n facet = quad.facet2;\r\n }\r\n return facet;\r\n }\r\n\r\n // Creates and populates the heightMap array with \"facet\" elements :\r\n // a quad is two triangular facets separated by a slope, so a \"facet\" element is 1 slope + 2 facets\r\n // slope : Vector2(c, h) = 2D diagonal line equation setting apart two triangular facets in a quad : z = cx + h\r\n // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0\r\n // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0\r\n // Returns the GroundMesh.\r\n private _initHeightQuads(): GroundMesh {\r\n const subdivisionsX = this._subdivisionsX;\r\n const subdivisionsY = this._subdivisionsY;\r\n this._heightQuads = new Array();\r\n for (let row = 0; row < subdivisionsY; row++) {\r\n for (let col = 0; col < subdivisionsX; col++) {\r\n const quad = { slope: Vector2.Zero(), facet1: new Vector4(0.0, 0.0, 0.0, 0.0), facet2: new Vector4(0.0, 0.0, 0.0, 0.0) };\r\n this._heightQuads[row * subdivisionsX + col] = quad;\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n // Compute each quad element values and update the heightMap array :\r\n // slope : Vector2(c, h) = 2D diagonal line equation setting apart two triangular facets in a quad : z = cx + h\r\n // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0\r\n // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0\r\n // Returns the GroundMesh.\r\n private _computeHeightQuads(): GroundMesh {\r\n const positions = this.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n if (!positions) {\r\n return this;\r\n }\r\n\r\n const v1 = TmpVectors.Vector3[3];\r\n const v2 = TmpVectors.Vector3[2];\r\n const v3 = TmpVectors.Vector3[1];\r\n const v4 = TmpVectors.Vector3[0];\r\n const v1v2 = TmpVectors.Vector3[4];\r\n const v1v3 = TmpVectors.Vector3[5];\r\n const v1v4 = TmpVectors.Vector3[6];\r\n const norm1 = TmpVectors.Vector3[7];\r\n const norm2 = TmpVectors.Vector3[8];\r\n let i = 0;\r\n let j = 0;\r\n let k = 0;\r\n let cd = 0; // 2D slope coefficient : z = cd * x + h\r\n let h = 0;\r\n let d1 = 0; // facet plane equation : ax + by + cz + d = 0\r\n let d2 = 0;\r\n\r\n const subdivisionsX = this._subdivisionsX;\r\n const subdivisionsY = this._subdivisionsY;\r\n\r\n for (let row = 0; row < subdivisionsY; row++) {\r\n for (let col = 0; col < subdivisionsX; col++) {\r\n i = col * 3;\r\n j = row * (subdivisionsX + 1) * 3;\r\n k = (row + 1) * (subdivisionsX + 1) * 3;\r\n v1.x = positions[j + i];\r\n v1.y = positions[j + i + 1];\r\n v1.z = positions[j + i + 2];\r\n v2.x = positions[j + i + 3];\r\n v2.y = positions[j + i + 4];\r\n v2.z = positions[j + i + 5];\r\n v3.x = positions[k + i];\r\n v3.y = positions[k + i + 1];\r\n v3.z = positions[k + i + 2];\r\n v4.x = positions[k + i + 3];\r\n v4.y = positions[k + i + 4];\r\n v4.z = positions[k + i + 5];\r\n\r\n // 2D slope V1V4\r\n cd = (v4.z - v1.z) / (v4.x - v1.x);\r\n h = v1.z - cd * v1.x; // v1 belongs to the slope\r\n\r\n // facet equations :\r\n // we compute each facet normal vector\r\n // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0\r\n // we compute the value d by applying the equation to v1 which belongs to the plane\r\n // then we store the facet equation in a Vector4\r\n v2.subtractToRef(v1, v1v2);\r\n v3.subtractToRef(v1, v1v3);\r\n v4.subtractToRef(v1, v1v4);\r\n Vector3.CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class\r\n Vector3.CrossToRef(v1v2, v1v4, norm2);\r\n norm1.normalize();\r\n norm2.normalize();\r\n d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);\r\n d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);\r\n\r\n const quad = this._heightQuads[row * subdivisionsX + col];\r\n quad.slope.copyFromFloats(cd, h);\r\n quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);\r\n quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Serializes this ground mesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.subdivisionsX = this._subdivisionsX;\r\n serializationObject.subdivisionsY = this._subdivisionsY;\r\n\r\n serializationObject.minX = this._minX;\r\n serializationObject.maxX = this._maxX;\r\n\r\n serializationObject.minZ = this._minZ;\r\n serializationObject.maxZ = this._maxZ;\r\n\r\n serializationObject.width = this._width;\r\n serializationObject.height = this._height;\r\n }\r\n\r\n /**\r\n * Parses a serialized ground mesh\r\n * @param parsedMesh the serialized mesh\r\n * @param scene the scene to create the ground mesh in\r\n * @returns the created ground mesh\r\n */\r\n public static Parse(parsedMesh: any, scene: Scene): GroundMesh {\r\n const result = new GroundMesh(parsedMesh.name, scene);\r\n\r\n result._subdivisionsX = parsedMesh.subdivisionsX || 1;\r\n result._subdivisionsY = parsedMesh.subdivisionsY || 1;\r\n\r\n result._minX = parsedMesh.minX;\r\n result._maxX = parsedMesh.maxX;\r\n\r\n result._minZ = parsedMesh.minZ;\r\n result._maxZ = parsedMesh.maxZ;\r\n\r\n result._width = parsedMesh.width;\r\n result._height = parsedMesh.height;\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|