@babylonjs/core 8.25.2 → 8.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +20 -26
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.d.ts +11 -0
- package/Loading/Plugins/babylonFileLoader.js +25 -12
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -0
- package/Materials/Node/nodeMaterial.js +4 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.d.ts +1 -1
- package/Meshes/Builders/tiledBoxBuilder.js +36 -60
- package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js +19 -9
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/mesh.js +8 -7
- package/Meshes/mesh.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +3 -2
- package/Misc/greasedLineTools.js +4 -3
- package/Misc/greasedLineTools.js.map +1 -1
- package/Physics/joinedPhysicsEngineComponent.js +1 -1
- package/Physics/joinedPhysicsEngineComponent.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
- package/Rendering/depthRenderer.d.ts +2 -1
- package/Rendering/depthRenderer.js +5 -2
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/depthRendererSceneComponent.d.ts +3 -1
- package/Rendering/depthRendererSceneComponent.js +2 -2
- package/Rendering/depthRendererSceneComponent.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +6 -0
- package/Rendering/objectRenderer.js +14 -1
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/renderingGroup.d.ts +2 -0
- package/Rendering/renderingGroup.js +9 -7
- package/Rendering/renderingGroup.js.map +1 -1
- package/Rendering/renderingManager.d.ts +6 -0
- package/Rendering/renderingManager.js +14 -0
- package/Rendering/renderingManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +1 -1
- package/scene.js.map +1 -1
|
@@ -17,7 +17,7 @@ import { VertexData } from "../mesh.vertexData.js";
|
|
|
17
17
|
* * tileWidth sets the tile width and overwrites tileSize
|
|
18
18
|
* * tileHeight sets the tile width and overwrites tileSize
|
|
19
19
|
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
20
|
-
* * faceColors an array of 6
|
|
20
|
+
* * faceColors an array of 6 Color4 elements used to set different colors to each box side
|
|
21
21
|
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
22
22
|
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
23
23
|
* @param options.pattern
|
|
@@ -4,6 +4,8 @@ import { Mesh } from "../mesh.js";
|
|
|
4
4
|
import { VertexData } from "../mesh.vertexData.js";
|
|
5
5
|
import { CreateTiledPlaneVertexData } from "./tiledPlaneBuilder.js";
|
|
6
6
|
import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js";
|
|
7
|
+
const OP_ADD = 1;
|
|
8
|
+
const OP_SUB = -1;
|
|
7
9
|
/**
|
|
8
10
|
* Creates the VertexData for a tiled box
|
|
9
11
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
|
|
@@ -17,7 +19,7 @@ import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js"
|
|
|
17
19
|
* * tileWidth sets the tile width and overwrites tileSize
|
|
18
20
|
* * tileHeight sets the tile width and overwrites tileSize
|
|
19
21
|
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
20
|
-
* * faceColors an array of 6
|
|
22
|
+
* * faceColors an array of 6 Color4 elements used to set different colors to each box side
|
|
21
23
|
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
22
24
|
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
23
25
|
* @param options.pattern
|
|
@@ -108,8 +110,8 @@ export function CreateTiledBoxVertexData(options) {
|
|
|
108
110
|
sideOrientation: sideOrientation,
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
const positions = [];
|
|
114
|
+
const normals = [];
|
|
113
115
|
let uvs = [];
|
|
114
116
|
let indices = [];
|
|
115
117
|
const colors = [];
|
|
@@ -140,66 +142,40 @@ export function CreateTiledBoxVertexData(options) {
|
|
|
140
142
|
indices = indices.concat(faceVertexData[f].indices.map((x) => x + li));
|
|
141
143
|
li += facePositions[f].length;
|
|
142
144
|
if (faceColors) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
const color = faceColors[f];
|
|
146
|
+
for (let p = 0; p < facePositions[f].length; p++) {
|
|
147
|
+
colors.push(color.r, color.g, color.b, color.a);
|
|
145
148
|
}
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
.
|
|
152
|
-
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
.
|
|
156
|
-
|
|
157
|
-
.
|
|
158
|
-
|
|
159
|
-
.
|
|
160
|
-
|
|
161
|
-
.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
.map((entry) => [entry.x, entry.y, entry.z])
|
|
177
|
-
.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []));
|
|
178
|
-
normals = normals.concat(faceNormals[3]
|
|
179
|
-
.map((entry) => Vector3.TransformNormal(entry, mtrx3))
|
|
180
|
-
.map((entry) => [entry.x, entry.y, entry.z])
|
|
181
|
-
.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []));
|
|
182
|
-
const vec4 = new Vector3(0, halfHeight, 0);
|
|
183
|
-
const mtrx4 = Matrix.RotationX(Math.PI / 2);
|
|
184
|
-
positions = positions.concat(facePositions[4]
|
|
185
|
-
.map((entry) => Vector3.TransformNormal(entry, mtrx4).add(vec4))
|
|
186
|
-
.map((entry) => [entry.x, entry.y, entry.z])
|
|
187
|
-
.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []));
|
|
188
|
-
normals = normals.concat(faceNormals[4]
|
|
189
|
-
.map((entry) => Vector3.TransformNormal(entry, mtrx4))
|
|
190
|
-
.map((entry) => [entry.x, entry.y, entry.z])
|
|
191
|
-
.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []));
|
|
192
|
-
const mtrx5 = Matrix.RotationX(-Math.PI / 2);
|
|
193
|
-
positions = positions.concat(facePositions[5]
|
|
194
|
-
.map((entry) => Vector3.TransformNormal(entry, mtrx5).subtract(vec4))
|
|
195
|
-
.map((entry) => [entry.x, entry.y, entry.z])
|
|
196
|
-
.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []));
|
|
197
|
-
normals = normals.concat(faceNormals[5]
|
|
198
|
-
.map((entry) => Vector3.TransformNormal(entry, mtrx5))
|
|
199
|
-
.map((entry) => [entry.x, entry.y, entry.z])
|
|
200
|
-
.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []));
|
|
201
|
-
// sides
|
|
202
|
-
VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
|
|
151
|
+
// Define transforms for each face
|
|
152
|
+
const faceTransforms = [
|
|
153
|
+
// FRONT
|
|
154
|
+
{ m: Matrix.RotationY(Math.PI), t: new Vector3(0, 0, halfDepth), op: OP_ADD },
|
|
155
|
+
// BACK
|
|
156
|
+
{ m: Matrix.Identity(), t: new Vector3(0, 0, halfDepth), op: OP_SUB },
|
|
157
|
+
// RIGHT
|
|
158
|
+
{ m: Matrix.RotationY(-Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_ADD },
|
|
159
|
+
// LEFT
|
|
160
|
+
{ m: Matrix.RotationY(Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_SUB },
|
|
161
|
+
// TOP
|
|
162
|
+
{ m: Matrix.RotationX(Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_ADD },
|
|
163
|
+
// BOTTOM
|
|
164
|
+
{ m: Matrix.RotationX(-Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_SUB },
|
|
165
|
+
];
|
|
166
|
+
// Assemble positions and normals
|
|
167
|
+
for (let f = 0; f < nbFaces; f++) {
|
|
168
|
+
const { m, t, op } = faceTransforms[f];
|
|
169
|
+
for (const v of facePositions[f]) {
|
|
170
|
+
const p = Vector3.TransformCoordinates(v, m);
|
|
171
|
+
const final = op === OP_ADD ? p.add(t) : p.subtract(t);
|
|
172
|
+
positions.push(final.x, final.y, final.z);
|
|
173
|
+
}
|
|
174
|
+
for (const n of faceNormals[f]) {
|
|
175
|
+
const nn = Vector3.TransformNormal(n, m);
|
|
176
|
+
normals.push(nn.x, nn.y, nn.z);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
203
179
|
// Result
|
|
204
180
|
const vertexData = new VertexData();
|
|
205
181
|
vertexData.indices = indices;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiledBoxBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/tiledBoxBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,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IAC7B,UAAU,CAAC,GAAG,GAAG,GAAG,CAAC;IAErB,IAAI,UAAU,EAAE,CAAC;QACb,MAAM,WAAW,GAAG,eAAe,KAAK,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/F,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC;IACpC,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,cAAc,CAC1B,IAAY,EACZ,OAcC,EACD,QAAyB,IAAI;IAE7B,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAElC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnF,GAAG,CAAC,+BAA+B,GAAG,OAAO,CAAC,eAAe,CAAC;IAE9D,MAAM,UAAU,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAErD,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAE/C,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,gEAAgE;IAChE,cAAc;CACjB,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,wBAAwB,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { CreateTiledPlaneVertexData } from \"./tiledPlaneBuilder\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\n\r\n/**\r\n * Creates the VertexData for a tiled box\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color3 elements used to set different colors to each box side\r\n * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * @param options.pattern\r\n * @param options.size\r\n * @param options.width\r\n * @param options.height\r\n * @param options.depth\r\n * @param options.tileSize\r\n * @param options.tileWidth\r\n * @param options.tileHeight\r\n * @param options.faceUV\r\n * @param options.faceColors\r\n * @param options.alignHorizontal\r\n * @param options.alignVertical\r\n * @param options.sideOrientation\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @returns the VertexData of the TiledBox\r\n */\r\nexport function CreateTiledBoxVertexData(options: {\r\n pattern?: number;\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n sideOrientation?: number;\r\n}): VertexData {\r\n const nbFaces = 6;\r\n\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(6);\r\n const faceColors = options.faceColors;\r\n\r\n const flipTile = options.pattern || Mesh.NO_FLIP;\r\n\r\n const width = options.width || options.size || 1;\r\n const height = options.height || options.size || 1;\r\n const depth = options.depth || options.size || 1;\r\n const tileWidth = options.tileWidth || options.tileSize || 1;\r\n const tileHeight = options.tileHeight || options.tileSize || 1;\r\n const alignH = options.alignHorizontal || 0;\r\n const alignV = options.alignVertical || 0;\r\n\r\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n\r\n // default face colors and UV if undefined\r\n for (let f = 0; f < nbFaces; f++) {\r\n if (faceUV[f] === undefined) {\r\n faceUV[f] = new Vector4(0, 0, 1, 1);\r\n }\r\n if (faceColors && faceColors[f] === undefined) {\r\n faceColors[f] = new Color4(1, 1, 1, 1);\r\n }\r\n }\r\n\r\n const halfWidth = width / 2;\r\n const halfHeight = height / 2;\r\n const halfDepth = depth / 2;\r\n\r\n const faceVertexData: Array<VertexData> = [];\r\n\r\n for (let f = 0; f < 2; f++) {\r\n //front and back\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n for (let f = 2; f < 4; f++) {\r\n //sides\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: depth,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n let baseAlignV = alignV;\r\n if (alignV === Mesh.BOTTOM) {\r\n baseAlignV = Mesh.TOP;\r\n } else if (alignV === Mesh.TOP) {\r\n baseAlignV = Mesh.BOTTOM;\r\n }\r\n\r\n for (let f = 4; f < 6; f++) {\r\n //top and bottom\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: depth,\r\n alignVertical: baseAlignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n let positions: Array<number> = [];\r\n let normals: Array<number> = [];\r\n let uvs: Array<number> = [];\r\n let indices: Array<number> = [];\r\n const colors: Array<number> = [];\r\n const facePositions: Array<Array<Vector3>> = [];\r\n const faceNormals: Array<Array<Vector3>> = [];\r\n\r\n const newFaceUV: Array<Array<number>> = [];\r\n let lu: number = 0;\r\n\r\n let li: number = 0;\r\n\r\n for (let f = 0; f < nbFaces; f++) {\r\n const len = faceVertexData[f].positions!.length;\r\n facePositions[f] = [];\r\n faceNormals[f] = [];\r\n for (let p = 0; p < len / 3; p++) {\r\n facePositions[f].push(new Vector3(faceVertexData[f].positions![3 * p], faceVertexData[f].positions![3 * p + 1], faceVertexData[f].positions![3 * p + 2]));\r\n faceNormals[f].push(new Vector3(faceVertexData[f].normals![3 * p], faceVertexData[f].normals![3 * p + 1], faceVertexData[f].normals![3 * p + 2]));\r\n }\r\n // uvs\r\n lu = faceVertexData[f].uvs!.length;\r\n newFaceUV[f] = [];\r\n for (let i = 0; i < lu; i += 2) {\r\n newFaceUV[f][i] = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * faceVertexData[f].uvs![i];\r\n newFaceUV[f][i + 1] = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * faceVertexData[f].uvs![i + 1];\r\n\r\n if (useOpenGLOrientationForUV) {\r\n newFaceUV[f][i + 1] = 1.0 - newFaceUV[f][i + 1];\r\n }\r\n }\r\n uvs = uvs.concat(newFaceUV[f]);\r\n\r\n indices = indices.concat(<Array<number>>faceVertexData[f].indices!.map((x: number) => x + li));\r\n li += facePositions[f].length;\r\n if (faceColors) {\r\n for (let c = 0; c < 4; c++) {\r\n colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);\r\n }\r\n }\r\n }\r\n\r\n const vec0 = new Vector3(0, 0, halfDepth);\r\n const mtrx0 = Matrix.RotationY(Math.PI);\r\n positions = facePositions[0]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx0).add(vec0))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), []);\r\n normals = faceNormals[0]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx0))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), []);\r\n positions = positions.concat(\r\n facePositions[1]\r\n .map((entry) => entry.subtract(vec0))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n normals = normals.concat(faceNormals[1].map((entry) => [entry.x, entry.y, entry.z]).reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), []));\r\n\r\n const vec2 = new Vector3(halfWidth, 0, 0);\r\n const mtrx2 = Matrix.RotationY(-Math.PI / 2);\r\n positions = positions.concat(\r\n facePositions[2]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx2).add(vec2))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n normals = normals.concat(\r\n faceNormals[2]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx2))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n const mtrx3 = Matrix.RotationY(Math.PI / 2);\r\n positions = positions.concat(\r\n facePositions[3]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx3).subtract(vec2))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n normals = normals.concat(\r\n faceNormals[3]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx3))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n\r\n const vec4 = new Vector3(0, halfHeight, 0);\r\n const mtrx4 = Matrix.RotationX(Math.PI / 2);\r\n positions = positions.concat(\r\n facePositions[4]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx4).add(vec4))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n normals = normals.concat(\r\n faceNormals[4]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx4))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n const mtrx5 = Matrix.RotationX(-Math.PI / 2);\r\n positions = positions.concat(\r\n facePositions[5]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx5).subtract(vec4))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n normals = normals.concat(\r\n faceNormals[5]\r\n .map((entry) => Vector3.TransformNormal(entry, mtrx5))\r\n .map((entry) => [entry.x, entry.y, entry.z])\r\n .reduce((accumulator: Array<number>, currentValue) => accumulator.concat(currentValue), [])\r\n );\r\n\r\n // sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n\r\n if (faceColors) {\r\n const totalColors = sideOrientation === VertexData.DOUBLESIDE ? colors.concat(colors) : colors;\r\n vertexData.colors = totalColors;\r\n }\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a tiled box mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param name defines the name of the mesh\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color3 elements used to set different colors to each box side\r\n * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @param options.pattern\r\n * @param options.width\r\n * @param options.height\r\n * @param options.depth\r\n * @param options.tileSize\r\n * @param options.tileWidth\r\n * @param options.tileHeight\r\n * @param options.alignHorizontal\r\n * @param options.alignVertical\r\n * @param options.faceUV\r\n * @param options.faceColors\r\n * @param options.sideOrientation\r\n * @param options.updatable\r\n * @param scene defines the hosting scene\r\n * @returns the box mesh\r\n */\r\nexport function CreateTiledBox(\r\n name: string,\r\n options: {\r\n pattern?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: number;\r\n updatable?: boolean;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const box = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n box._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreateTiledBoxVertexData(options);\r\n\r\n vertexData.applyToMesh(box, options.updatable);\r\n\r\n return box;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use CreateTiledBox instead\r\n */\r\nexport const TiledBoxBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateTiledBox,\r\n};\r\n\r\nVertexData.CreateTi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UAAU,CAAC,cAAc,GAAG,wBAAwB,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { CreateTiledPlaneVertexData } from \"./tiledPlaneBuilder\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\n\r\nconst OP_ADD = 1;\r\nconst OP_SUB = -1;\r\n\r\n/**\r\n * Creates the VertexData for a tiled box\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color4 elements used to set different colors to each box side\r\n * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * @param options.pattern\r\n * @param options.size\r\n * @param options.width\r\n * @param options.height\r\n * @param options.depth\r\n * @param options.tileSize\r\n * @param options.tileWidth\r\n * @param options.tileHeight\r\n * @param options.faceUV\r\n * @param options.faceColors\r\n * @param options.alignHorizontal\r\n * @param options.alignVertical\r\n * @param options.sideOrientation\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @returns the VertexData of the TiledBox\r\n */\r\nexport function CreateTiledBoxVertexData(options: {\r\n pattern?: number;\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n sideOrientation?: number;\r\n}): VertexData {\r\n const nbFaces = 6;\r\n\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(6);\r\n const faceColors = options.faceColors;\r\n\r\n const flipTile = options.pattern || Mesh.NO_FLIP;\r\n\r\n const width = options.width || options.size || 1;\r\n const height = options.height || options.size || 1;\r\n const depth = options.depth || options.size || 1;\r\n const tileWidth = options.tileWidth || options.tileSize || 1;\r\n const tileHeight = options.tileHeight || options.tileSize || 1;\r\n const alignH = options.alignHorizontal || 0;\r\n const alignV = options.alignVertical || 0;\r\n\r\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n\r\n // default face colors and UV if undefined\r\n for (let f = 0; f < nbFaces; f++) {\r\n if (faceUV[f] === undefined) {\r\n faceUV[f] = new Vector4(0, 0, 1, 1);\r\n }\r\n if (faceColors && faceColors[f] === undefined) {\r\n faceColors[f] = new Color4(1, 1, 1, 1);\r\n }\r\n }\r\n\r\n const halfWidth = width / 2;\r\n const halfHeight = height / 2;\r\n const halfDepth = depth / 2;\r\n\r\n const faceVertexData: Array<VertexData> = [];\r\n\r\n for (let f = 0; f < 2; f++) {\r\n //front and back\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n for (let f = 2; f < 4; f++) {\r\n //sides\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: depth,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n let baseAlignV = alignV;\r\n if (alignV === Mesh.BOTTOM) {\r\n baseAlignV = Mesh.TOP;\r\n } else if (alignV === Mesh.TOP) {\r\n baseAlignV = Mesh.BOTTOM;\r\n }\r\n\r\n for (let f = 4; f < 6; f++) {\r\n //top and bottom\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: depth,\r\n alignVertical: baseAlignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n const positions: Array<number> = [];\r\n const normals: Array<number> = [];\r\n let uvs: Array<number> = [];\r\n let indices: Array<number> = [];\r\n const colors: Array<number> = [];\r\n const facePositions: Array<Array<Vector3>> = [];\r\n const faceNormals: Array<Array<Vector3>> = [];\r\n\r\n const newFaceUV: Array<Array<number>> = [];\r\n let lu: number = 0;\r\n\r\n let li: number = 0;\r\n\r\n for (let f = 0; f < nbFaces; f++) {\r\n const len = faceVertexData[f].positions!.length;\r\n facePositions[f] = [];\r\n faceNormals[f] = [];\r\n for (let p = 0; p < len / 3; p++) {\r\n facePositions[f].push(new Vector3(faceVertexData[f].positions![3 * p], faceVertexData[f].positions![3 * p + 1], faceVertexData[f].positions![3 * p + 2]));\r\n faceNormals[f].push(new Vector3(faceVertexData[f].normals![3 * p], faceVertexData[f].normals![3 * p + 1], faceVertexData[f].normals![3 * p + 2]));\r\n }\r\n // uvs\r\n lu = faceVertexData[f].uvs!.length;\r\n newFaceUV[f] = [];\r\n for (let i = 0; i < lu; i += 2) {\r\n newFaceUV[f][i] = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * faceVertexData[f].uvs![i];\r\n newFaceUV[f][i + 1] = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * faceVertexData[f].uvs![i + 1];\r\n\r\n if (useOpenGLOrientationForUV) {\r\n newFaceUV[f][i + 1] = 1.0 - newFaceUV[f][i + 1];\r\n }\r\n }\r\n uvs = uvs.concat(newFaceUV[f]);\r\n\r\n indices = indices.concat(<Array<number>>faceVertexData[f].indices!.map((x: number) => x + li));\r\n li += facePositions[f].length;\r\n if (faceColors) {\r\n const color = faceColors[f];\r\n for (let p = 0; p < facePositions[f].length; p++) {\r\n colors.push(color.r, color.g, color.b, color.a);\r\n }\r\n }\r\n }\r\n\r\n // Define transforms for each face\r\n const faceTransforms = [\r\n // FRONT\r\n { m: Matrix.RotationY(Math.PI), t: new Vector3(0, 0, halfDepth), op: OP_ADD },\r\n // BACK\r\n { m: Matrix.Identity(), t: new Vector3(0, 0, halfDepth), op: OP_SUB },\r\n // RIGHT\r\n { m: Matrix.RotationY(-Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_ADD },\r\n // LEFT\r\n { m: Matrix.RotationY(Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_SUB },\r\n // TOP\r\n { m: Matrix.RotationX(Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_ADD },\r\n // BOTTOM\r\n { m: Matrix.RotationX(-Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_SUB },\r\n ];\r\n\r\n // Assemble positions and normals\r\n for (let f = 0; f < nbFaces; f++) {\r\n const { m, t, op } = faceTransforms[f];\r\n\r\n for (const v of facePositions[f]) {\r\n const p = Vector3.TransformCoordinates(v, m);\r\n const final = op === OP_ADD ? p.add(t) : p.subtract(t);\r\n positions.push(final.x, final.y, final.z);\r\n }\r\n\r\n for (const n of faceNormals[f]) {\r\n const nn = Vector3.TransformNormal(n, m);\r\n normals.push(nn.x, nn.y, nn.z);\r\n }\r\n }\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n\r\n if (faceColors) {\r\n const totalColors = sideOrientation === VertexData.DOUBLESIDE ? colors.concat(colors) : colors;\r\n vertexData.colors = totalColors;\r\n }\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a tiled box mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param name defines the name of the mesh\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color3 elements used to set different colors to each box side\r\n * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @param options.pattern\r\n * @param options.width\r\n * @param options.height\r\n * @param options.depth\r\n * @param options.tileSize\r\n * @param options.tileWidth\r\n * @param options.tileHeight\r\n * @param options.alignHorizontal\r\n * @param options.alignVertical\r\n * @param options.faceUV\r\n * @param options.faceColors\r\n * @param options.sideOrientation\r\n * @param options.updatable\r\n * @param scene defines the hosting scene\r\n * @returns the box mesh\r\n */\r\nexport function CreateTiledBox(\r\n name: string,\r\n options: {\r\n pattern?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: number;\r\n updatable?: boolean;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const box = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n box._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreateTiledBoxVertexData(options);\r\n\r\n vertexData.applyToMesh(box, options.updatable);\r\n\r\n return box;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use CreateTiledBox instead\r\n */\r\nexport const TiledBoxBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateTiledBox,\r\n};\r\n\r\nVertexData.CreateTiledBox = CreateTiledBoxVertexData;\r\n"]}
|
|
@@ -60,22 +60,30 @@ export class GreasedLineMesh extends GreasedLineBaseMesh {
|
|
|
60
60
|
this._options.points = points;
|
|
61
61
|
this._initGreasedLine();
|
|
62
62
|
let indiceOffset = 0;
|
|
63
|
-
let vertexPositionsLen = 0, indicesLength = 0, uvLength = 0, previousAndSideLength = 0;
|
|
63
|
+
let vertexPositionsLen = 0, indicesLength = 0, uvLength = 0, previousAndSideLength = 0, maxLineLength = 0;
|
|
64
64
|
for (const p of points) {
|
|
65
|
+
maxLineLength = Math.max(p.length, maxLineLength);
|
|
65
66
|
vertexPositionsLen += p.length * 2;
|
|
66
67
|
indicesLength += (p.length - 3) * 2;
|
|
67
68
|
uvLength += (p.length * 4) / 3;
|
|
68
69
|
previousAndSideLength += (p.length * 8) / 3;
|
|
69
70
|
}
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
const
|
|
71
|
+
const buffer = new ArrayBuffer(vertexPositionsLen * 4 + indicesLength * (vertexPositionsLen > 65535 ? 4 : 2) + uvLength * 4 + previousAndSideLength * 4 * 2);
|
|
72
|
+
const tempBuffer = new ArrayBuffer((maxLineLength / 3 + maxLineLength * 4) * 4);
|
|
73
|
+
let byteOffset = 0;
|
|
74
|
+
const vertexPositionsArr = new Float32Array(buffer, byteOffset, vertexPositionsLen);
|
|
75
|
+
byteOffset += vertexPositionsArr.byteLength;
|
|
76
|
+
const indicesArr = vertexPositionsLen > 65535 ? new Uint32Array(buffer, byteOffset, indicesLength) : new Uint16Array(buffer, byteOffset, indicesLength);
|
|
77
|
+
byteOffset += indicesArr.byteLength;
|
|
78
|
+
const uvArr = new Float32Array(buffer, byteOffset, uvLength);
|
|
79
|
+
byteOffset += uvArr.byteLength;
|
|
80
|
+
const previousAndSide = new Float32Array(buffer, byteOffset, previousAndSideLength);
|
|
81
|
+
byteOffset += previousAndSide.byteLength;
|
|
74
82
|
// it's the same length here
|
|
75
|
-
const nextAndCounters = new Float32Array(previousAndSideLength);
|
|
83
|
+
const nextAndCounters = new Float32Array(buffer, byteOffset, previousAndSideLength);
|
|
76
84
|
let vertexPositionsOffset = 0, indicesOffset = 0, uvOffset = 0, previousAndSideOffset = 0, nextAndCountersOffset = 0;
|
|
77
85
|
for (const p of points) {
|
|
78
|
-
const lengthArray = GreasedLineTools.GetLineLengthArray(p);
|
|
86
|
+
const lengthArray = GreasedLineTools.GetLineLengthArray(p, tempBuffer);
|
|
79
87
|
const totalLength = lengthArray[lengthArray.length - 1];
|
|
80
88
|
for (let j = 0, jj = 0; jj < p.length; j++, jj += 3) {
|
|
81
89
|
const baseOffset = vertexPositionsOffset + jj * 2;
|
|
@@ -101,8 +109,10 @@ export class GreasedLineMesh extends GreasedLineBaseMesh {
|
|
|
101
109
|
const positions = vertexPositionsArr.subarray(vertexPositionsOffset, vertexPositionsOffset + currVertexPositionsOffsetLength);
|
|
102
110
|
vertexPositionsOffset += currVertexPositionsOffsetLength;
|
|
103
111
|
indicesOffset += (p.length - 3) * 2;
|
|
104
|
-
|
|
105
|
-
const
|
|
112
|
+
let byteOffset = lengthArray.byteLength;
|
|
113
|
+
const previous = new Float32Array(tempBuffer, byteOffset, positions.length);
|
|
114
|
+
byteOffset += previous.byteLength;
|
|
115
|
+
const next = new Float32Array(tempBuffer, byteOffset, positions.length);
|
|
106
116
|
const l = positions.length / 6;
|
|
107
117
|
let v;
|
|
108
118
|
if (GreasedLineMesh._CompareV3(0, l - 1, positions)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greasedLineMesh.js","sourceRoot":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AAhB,CAAiB;AACvB,+BAAe,GAAG,IAAI,OAAO,EAAE,AAAhB,CAAiB;AAChC,6BAAa,GAAG,IAAI,OAAO,EAAE,AAAhB,CAAiB","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport type { Ray, TrianglePickingPredicate } from \"../../Culling/ray\";\r\nimport { Buffer, VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { PickingInfo } from \"../../Collisions/pickingInfo\";\r\nimport type { Nullable, FloatArray } from \"../../types\";\r\nimport type { Node } from \"../../node\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"./greasedLineBaseMesh\";\r\nimport { GreasedLineBaseMesh } from \"./greasedLineBaseMesh\";\r\nimport type { VertexData } from \"../mesh.vertexData\";\r\n\r\nMesh._GreasedLineMeshParser = (parsedMesh: any, scene: Scene): Mesh => {\r\n return GreasedLineMesh.Parse(parsedMesh, scene);\r\n};\r\n\r\n/**\r\n * GreasedLineMesh\r\n * Use the GreasedLineBuilder.CreateGreasedLine function to create an instance of this class.\r\n */\r\nexport class GreasedLineMesh extends GreasedLineBaseMesh {\r\n private _previousAndSide: FloatArray;\r\n private _nextAndCounters: FloatArray;\r\n\r\n private static _V_START = new Vector3();\r\n private static _V_END = new Vector3();\r\n private static _V_OFFSET_START = new Vector3();\r\n private static _V_OFFSET_END = new Vector3();\r\n\r\n /**\r\n * Treshold used to pick the mesh\r\n */\r\n public intersectionThreshold = 0.1;\r\n\r\n /**\r\n * GreasedLineMesh\r\n * @param name name of the mesh\r\n * @param scene the scene\r\n * @param _options mesh options\r\n */\r\n constructor(\r\n public override readonly name: string,\r\n scene: Scene,\r\n _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, _options);\r\n\r\n this._previousAndSide = [];\r\n this._nextAndCounters = [];\r\n\r\n if (_options.points) {\r\n this.addPoints(GreasedLineTools.ConvertPoints(_options.points));\r\n }\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected _updateColorPointers() {\r\n if (this._options.colorPointers) {\r\n return;\r\n }\r\n\r\n let colorPointer = 0;\r\n this._colorPointers = [];\r\n for (const p of this._points) {\r\n for (let jj = 0; jj < p.length; jj += 3) {\r\n this._colorPointers.push(colorPointer);\r\n this._colorPointers.push(colorPointer++);\r\n }\r\n }\r\n }\r\n\r\n protected _updateWidths(): void {\r\n // intentionally left blank\r\n }\r\n\r\n protected _setPoints(points: number[][]) {\r\n this._points = points;\r\n this._options.points = points;\r\n\r\n this._initGreasedLine();\r\n\r\n let indiceOffset = 0;\r\n let vertexPositionsLen = 0,\r\n indicesLength = 0,\r\n uvLength = 0,\r\n previousAndSideLength = 0;\r\n for (const p of points) {\r\n vertexPositionsLen += p.length * 2;\r\n indicesLength += (p.length - 3) * 2;\r\n uvLength += (p.length * 4) / 3;\r\n previousAndSideLength += (p.length * 8) / 3;\r\n }\r\n const vertexPositionsArr = new Float32Array(vertexPositionsLen);\r\n const indicesArr = vertexPositionsLen > 65535 ? new Uint32Array(indicesLength) : new Uint16Array(indicesLength);\r\n const uvArr = new Float32Array(uvLength);\r\n const previousAndSide = new Float32Array(previousAndSideLength);\r\n // it's the same length here\r\n const nextAndCounters = new Float32Array(previousAndSideLength);\r\n let vertexPositionsOffset = 0,\r\n indicesOffset = 0,\r\n uvOffset = 0,\r\n previousAndSideOffset = 0,\r\n nextAndCountersOffset = 0;\r\n\r\n for (const p of points) {\r\n const lengthArray = GreasedLineTools.GetLineLengthArray(p);\r\n const totalLength = lengthArray[lengthArray.length - 1];\r\n for (let j = 0, jj = 0; jj < p.length; j++, jj += 3) {\r\n const baseOffset = vertexPositionsOffset + jj * 2;\r\n vertexPositionsArr[baseOffset + 0] = p[jj + 0];\r\n vertexPositionsArr[baseOffset + 1] = p[jj + 1];\r\n vertexPositionsArr[baseOffset + 2] = p[jj + 2];\r\n vertexPositionsArr[baseOffset + 3] = p[jj + 0];\r\n vertexPositionsArr[baseOffset + 4] = p[jj + 1];\r\n vertexPositionsArr[baseOffset + 5] = p[jj + 2];\r\n\r\n if (jj < p.length - 3) {\r\n const n = j * 2 + indiceOffset;\r\n const baseIndicesOffset = indicesOffset + jj * 2;\r\n indicesArr[baseIndicesOffset + 0] = n;\r\n indicesArr[baseIndicesOffset + 1] = n + 1;\r\n indicesArr[baseIndicesOffset + 2] = n + 2;\r\n indicesArr[baseIndicesOffset + 3] = n + 2;\r\n indicesArr[baseIndicesOffset + 4] = n + 1;\r\n indicesArr[baseIndicesOffset + 5] = n + 3;\r\n }\r\n }\r\n\r\n indiceOffset += (p.length / 3) * 2;\r\n const currVertexPositionsOffsetLength = p.length * 2;\r\n const positions = vertexPositionsArr.subarray(vertexPositionsOffset, vertexPositionsOffset + currVertexPositionsOffsetLength);\r\n vertexPositionsOffset += currVertexPositionsOffsetLength;\r\n indicesOffset += (p.length - 3) * 2;\r\n\r\n const previous = new Float32Array(positions.length);\r\n const next = new Float32Array(positions.length);\r\n const l = positions.length / 6;\r\n let v;\r\n if (GreasedLineMesh._CompareV3(0, l - 1, positions)) {\r\n v = positions.subarray((l - 2) * 6, (l - 1) * 6);\r\n } else {\r\n v = positions.subarray(0, 6);\r\n }\r\n previous.set(v);\r\n previous.set(positions.subarray(0, positions.length - 6), 6);\r\n next.set(positions.subarray(6));\r\n if (GreasedLineMesh._CompareV3(l - 1, 0, positions)) {\r\n v = positions.subarray(6, 12);\r\n } else {\r\n v = positions.subarray((l - 1) * 6, l * 6);\r\n }\r\n next.set(v, next.length - 6);\r\n\r\n for (let i = 0, sidesLength = positions.length / 3; i < sidesLength; i++) {\r\n previousAndSide[previousAndSideOffset++] = previous[i * 3];\r\n previousAndSide[previousAndSideOffset++] = previous[i * 3 + 1];\r\n previousAndSide[previousAndSideOffset++] = previous[i * 3 + 2];\r\n // side[i] = i % 2 ? -1 : 1;\r\n // side[i] = 1 - ((i & 1) << 1);\r\n previousAndSide[previousAndSideOffset++] = 1 - ((i & 1) << 1);\r\n nextAndCounters[nextAndCountersOffset++] = next[i * 3];\r\n nextAndCounters[nextAndCountersOffset++] = next[i * 3 + 1];\r\n nextAndCounters[nextAndCountersOffset++] = next[i * 3 + 2];\r\n // counters[i] = lengthArray[i >> 1] / totalLength;\r\n nextAndCounters[nextAndCountersOffset++] = lengthArray[i >> 1] / totalLength;\r\n }\r\n if (this._options.uvs) {\r\n for (let i = 0; i < this._options.uvs.length; i++) {\r\n uvArr[uvOffset++] = this._options.uvs[i];\r\n }\r\n } else {\r\n for (let j = 0; j < l; j++) {\r\n // uvs\r\n const lengthRatio = lengthArray[j] / totalLength;\r\n const uvOffsetBase = uvOffset + j * 4;\r\n uvArr[uvOffsetBase + 0] = lengthRatio;\r\n uvArr[uvOffsetBase + 1] = 0;\r\n uvArr[uvOffsetBase + 2] = lengthRatio;\r\n uvArr[uvOffsetBase + 3] = 1;\r\n }\r\n }\r\n }\r\n this._vertexPositions = vertexPositionsArr;\r\n this._indices = indicesArr;\r\n this._uvs = uvArr;\r\n this._previousAndSide = previousAndSide;\r\n this._nextAndCounters = nextAndCounters;\r\n\r\n if (!this._lazy) {\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers();\r\n !this.doNotSyncBoundingInfo && this.refreshBoundingInfo();\r\n }\r\n }\r\n\r\n /**\r\n * Clones the GreasedLineMesh.\r\n * @param name new line name\r\n * @param newParent new parent node\r\n * @returns cloned line\r\n */\r\n public override clone(name: string = `${this.name}-cloned`, newParent?: Nullable<Node>) {\r\n const lineOptions = this._createLineOptions();\r\n const deepCopiedLineOptions = {};\r\n DeepCopier.DeepCopy(lineOptions, deepCopiedLineOptions, [\"instance\"], undefined, true);\r\n\r\n const cloned = new GreasedLineMesh(name, this._scene, <GreasedLineMeshOptions>deepCopiedLineOptions);\r\n if (newParent) {\r\n cloned.parent = newParent;\r\n }\r\n\r\n cloned.material = this.material;\r\n\r\n return cloned;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public override serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n /**\r\n * Parses a serialized GreasedLineMesh\r\n * @param parsedMesh the serialized GreasedLineMesh\r\n * @param scene the scene to create the GreasedLineMesh in\r\n * @returns the created GreasedLineMesh\r\n */\r\n public static override Parse(parsedMesh: any, scene: Scene): Mesh {\r\n const lineOptions = <GreasedLineMeshOptions>parsedMesh.lineOptions;\r\n const name = <string>parsedMesh.name;\r\n const result = new GreasedLineMesh(name, scene, lineOptions);\r\n return result;\r\n }\r\n\r\n protected override _initGreasedLine() {\r\n super._initGreasedLine();\r\n\r\n this._previousAndSide = [];\r\n this._nextAndCounters = [];\r\n }\r\n /**\r\n * Checks whether a ray is intersecting this GreasedLineMesh\r\n * @param ray ray to check the intersection of this mesh with\r\n * @param fastCheck not supported\r\n * @param trianglePredicate not supported\r\n * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)\r\n * @param worldToUse not supported\r\n * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check\r\n * @returns the picking info\r\n */\r\n public override intersects(\r\n ray: Ray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n onlyBoundingInfo = false,\r\n worldToUse?: Matrix,\r\n skipBoundingInfo = false\r\n ): PickingInfo {\r\n const pickingInfo = new PickingInfo();\r\n const intersections = this.findAllIntersections(ray, fastCheck, trianglePredicate, onlyBoundingInfo, worldToUse, skipBoundingInfo, true);\r\n if (intersections?.length === 1) {\r\n const intersection = intersections[0];\r\n pickingInfo.hit = true;\r\n pickingInfo.distance = intersection.distance;\r\n pickingInfo.ray = ray;\r\n pickingInfo.pickedMesh = this;\r\n pickingInfo.pickedPoint = intersection.point;\r\n }\r\n return pickingInfo;\r\n }\r\n\r\n /**\r\n * Gets all intersections of a ray and the line\r\n * @param ray Ray to check the intersection of this mesh with\r\n * @param _fastCheck not supported\r\n * @param _trianglePredicate not supported\r\n * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)\r\n * @param _worldToUse not supported\r\n * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check\r\n * @param firstOnly If true, the first and only intersection is immediatelly returned if found\r\n * @returns intersection(s)\r\n */\r\n public findAllIntersections(\r\n ray: Ray,\r\n _fastCheck?: boolean,\r\n _trianglePredicate?: TrianglePickingPredicate,\r\n onlyBoundingInfo = false,\r\n _worldToUse?: Matrix,\r\n skipBoundingInfo = false,\r\n firstOnly = false\r\n ): { distance: number; point: Vector3 }[] | undefined {\r\n if (onlyBoundingInfo && !skipBoundingInfo && ray.intersectsSphere(this._boundingSphere, this.intersectionThreshold) === false) {\r\n return;\r\n }\r\n\r\n const indices = this.getIndices();\r\n const positions = this.getVerticesData(VertexBuffer.PositionKind);\r\n const widths = this._widths;\r\n\r\n const lineWidth = this.greasedLineMaterial?.width ?? 1;\r\n\r\n const intersects = [];\r\n if (indices && positions && widths) {\r\n let i = 0,\r\n l = 0;\r\n for (i = 0, l = indices.length - 1; i < l; i += 3) {\r\n const a = indices[i];\r\n const b = indices[i + 1];\r\n\r\n GreasedLineMesh._V_START.fromArray(positions, a * 3);\r\n GreasedLineMesh._V_END.fromArray(positions, b * 3);\r\n\r\n if (this._offsets) {\r\n GreasedLineMesh._V_OFFSET_START.fromArray(this._offsets, a * 3);\r\n GreasedLineMesh._V_OFFSET_END.fromArray(this._offsets, b * 3);\r\n GreasedLineMesh._V_START.addInPlace(GreasedLineMesh._V_OFFSET_START);\r\n GreasedLineMesh._V_END.addInPlace(GreasedLineMesh._V_OFFSET_END);\r\n }\r\n\r\n const iFloored = Math.floor(i / 3);\r\n const width = widths[iFloored] !== undefined ? widths[iFloored] : 1;\r\n const precision = (this.intersectionThreshold * (lineWidth * width)) / 2;\r\n\r\n const distance = ray.intersectionSegment(GreasedLineMesh._V_START, GreasedLineMesh._V_END, precision);\r\n if (distance !== -1) {\r\n intersects.push({\r\n distance: distance,\r\n point: ray.direction.normalize().multiplyByFloats(distance, distance, distance).add(ray.origin),\r\n });\r\n if (firstOnly) {\r\n return intersects;\r\n }\r\n }\r\n }\r\n i = l;\r\n }\r\n\r\n return intersects;\r\n }\r\n\r\n private get _boundingSphere() {\r\n return this.getBoundingInfo().boundingSphere;\r\n }\r\n\r\n private static _CompareV3(positionIdx1: number, positionIdx2: number, positions: FloatArray) {\r\n const arrayIdx1 = positionIdx1 * 6;\r\n const arrayIdx2 = positionIdx2 * 6;\r\n return positions[arrayIdx1] === positions[arrayIdx2] && positions[arrayIdx1 + 1] === positions[arrayIdx2 + 1] && positions[arrayIdx1 + 2] === positions[arrayIdx2 + 2];\r\n }\r\n\r\n protected override _createVertexBuffers() {\r\n const vertexData: VertexData = super._createVertexBuffers();\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n const previousAndSideBuffer = new Buffer(engine, this._previousAndSide, false, 4);\r\n this.setVerticesBuffer(previousAndSideBuffer.createVertexBuffer(\"grl_previousAndSide\", 0, 4));\r\n\r\n const nextAndCountersBuffer = new Buffer(engine, this._nextAndCounters, false, 4);\r\n this.setVerticesBuffer(nextAndCountersBuffer.createVertexBuffer(\"grl_nextAndCounters\", 0, 4));\r\n\r\n const widthBuffer = new Buffer(engine, this._widths, this._updatable, 1);\r\n this.setVerticesBuffer(widthBuffer.createVertexBuffer(\"grl_widths\", 0, 1));\r\n this._widthsBuffer = widthBuffer;\r\n\r\n const colorPointersBuffer = new Buffer(engine, this._colorPointers, this._updatable, 1);\r\n this.setVerticesBuffer(colorPointersBuffer.createVertexBuffer(\"grl_colorPointers\", 0, 1));\r\n this._colorPointersBuffer = colorPointersBuffer;\r\n\r\n return vertexData;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"greasedLineMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GreasedLine/greasedLineMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,IAAI,CAAC,sBAAsB,GAAG,CAAC,UAAe,EAAE,KAAY,EAAQ,EAAE;IAClE,OAAO,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;IAcpD;;;;;OAKG;IACH,YAC6B,IAAY,EACrC,KAAY,EACZ,QAAgC;QAEhC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAJJ,SAAI,GAAJ,IAAI,CAAQ;QAZzC;;WAEG;QACI,0BAAqB,GAAG,GAAG,CAAC;QAe/B,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAE3B,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QACpE,CAAC;IACL,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB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} from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport type { Ray, TrianglePickingPredicate } from \"../../Culling/ray\";\r\nimport { Buffer, VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { PickingInfo } from \"../../Collisions/pickingInfo\";\r\nimport type { Nullable, FloatArray } from \"../../types\";\r\nimport type { Node } from \"../../node\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"./greasedLineBaseMesh\";\r\nimport { GreasedLineBaseMesh } from \"./greasedLineBaseMesh\";\r\nimport type { VertexData } from \"../mesh.vertexData\";\r\n\r\nMesh._GreasedLineMeshParser = (parsedMesh: any, scene: Scene): Mesh => {\r\n return GreasedLineMesh.Parse(parsedMesh, scene);\r\n};\r\n\r\n/**\r\n * GreasedLineMesh\r\n * Use the GreasedLineBuilder.CreateGreasedLine function to create an instance of this class.\r\n */\r\nexport class GreasedLineMesh extends GreasedLineBaseMesh {\r\n private _previousAndSide: FloatArray;\r\n private _nextAndCounters: FloatArray;\r\n\r\n private static _V_START = new Vector3();\r\n private static _V_END = new Vector3();\r\n private static _V_OFFSET_START = new Vector3();\r\n private static _V_OFFSET_END = new Vector3();\r\n\r\n /**\r\n * Treshold used to pick the mesh\r\n */\r\n public intersectionThreshold = 0.1;\r\n\r\n /**\r\n * GreasedLineMesh\r\n * @param name name of the mesh\r\n * @param scene the scene\r\n * @param _options mesh options\r\n */\r\n constructor(\r\n public override readonly name: string,\r\n scene: Scene,\r\n _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, _options);\r\n\r\n this._previousAndSide = [];\r\n this._nextAndCounters = [];\r\n\r\n if (_options.points) {\r\n this.addPoints(GreasedLineTools.ConvertPoints(_options.points));\r\n }\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected _updateColorPointers() {\r\n if (this._options.colorPointers) {\r\n return;\r\n }\r\n\r\n let colorPointer = 0;\r\n this._colorPointers = [];\r\n for (const p of this._points) {\r\n for (let jj = 0; jj < p.length; jj += 3) {\r\n this._colorPointers.push(colorPointer);\r\n this._colorPointers.push(colorPointer++);\r\n }\r\n }\r\n }\r\n\r\n protected _updateWidths(): void {\r\n // intentionally left blank\r\n }\r\n\r\n protected _setPoints(points: number[][]) {\r\n this._points = points;\r\n this._options.points = points;\r\n\r\n this._initGreasedLine();\r\n\r\n let indiceOffset = 0;\r\n let vertexPositionsLen = 0,\r\n indicesLength = 0,\r\n uvLength = 0,\r\n previousAndSideLength = 0,\r\n maxLineLength = 0;\r\n for (const p of points) {\r\n maxLineLength = Math.max(p.length, maxLineLength);\r\n vertexPositionsLen += p.length * 2;\r\n indicesLength += (p.length - 3) * 2;\r\n uvLength += (p.length * 4) / 3;\r\n previousAndSideLength += (p.length * 8) / 3;\r\n }\r\n const buffer = new ArrayBuffer(vertexPositionsLen * 4 + indicesLength * (vertexPositionsLen > 65535 ? 4 : 2) + uvLength * 4 + previousAndSideLength * 4 * 2);\r\n const tempBuffer = new ArrayBuffer((maxLineLength / 3 + maxLineLength * 4) * 4);\r\n let byteOffset = 0;\r\n const vertexPositionsArr = new Float32Array(buffer, byteOffset, vertexPositionsLen);\r\n byteOffset += vertexPositionsArr.byteLength;\r\n const indicesArr = vertexPositionsLen > 65535 ? new Uint32Array(buffer, byteOffset, indicesLength) : new Uint16Array(buffer, byteOffset, indicesLength);\r\n byteOffset += indicesArr.byteLength;\r\n const uvArr = new Float32Array(buffer, byteOffset, uvLength);\r\n byteOffset += uvArr.byteLength;\r\n const previousAndSide = new Float32Array(buffer, byteOffset, previousAndSideLength);\r\n byteOffset += previousAndSide.byteLength;\r\n // it's the same length here\r\n const nextAndCounters = new Float32Array(buffer, byteOffset, previousAndSideLength);\r\n let vertexPositionsOffset = 0,\r\n indicesOffset = 0,\r\n uvOffset = 0,\r\n previousAndSideOffset = 0,\r\n nextAndCountersOffset = 0;\r\n\r\n for (const p of points) {\r\n const lengthArray = GreasedLineTools.GetLineLengthArray(p, tempBuffer);\r\n const totalLength = lengthArray[lengthArray.length - 1];\r\n for (let j = 0, jj = 0; jj < p.length; j++, jj += 3) {\r\n const baseOffset = vertexPositionsOffset + jj * 2;\r\n vertexPositionsArr[baseOffset + 0] = p[jj + 0];\r\n vertexPositionsArr[baseOffset + 1] = p[jj + 1];\r\n vertexPositionsArr[baseOffset + 2] = p[jj + 2];\r\n vertexPositionsArr[baseOffset + 3] = p[jj + 0];\r\n vertexPositionsArr[baseOffset + 4] = p[jj + 1];\r\n vertexPositionsArr[baseOffset + 5] = p[jj + 2];\r\n\r\n if (jj < p.length - 3) {\r\n const n = j * 2 + indiceOffset;\r\n const baseIndicesOffset = indicesOffset + jj * 2;\r\n indicesArr[baseIndicesOffset + 0] = n;\r\n indicesArr[baseIndicesOffset + 1] = n + 1;\r\n indicesArr[baseIndicesOffset + 2] = n + 2;\r\n indicesArr[baseIndicesOffset + 3] = n + 2;\r\n indicesArr[baseIndicesOffset + 4] = n + 1;\r\n indicesArr[baseIndicesOffset + 5] = n + 3;\r\n }\r\n }\r\n\r\n indiceOffset += (p.length / 3) * 2;\r\n const currVertexPositionsOffsetLength = p.length * 2;\r\n const positions = vertexPositionsArr.subarray(vertexPositionsOffset, vertexPositionsOffset + currVertexPositionsOffsetLength);\r\n vertexPositionsOffset += currVertexPositionsOffsetLength;\r\n indicesOffset += (p.length - 3) * 2;\r\n\r\n let byteOffset = lengthArray.byteLength;\r\n const previous = new Float32Array(tempBuffer, byteOffset, positions.length);\r\n byteOffset += previous.byteLength;\r\n const next = new Float32Array(tempBuffer, byteOffset, positions.length);\r\n const l = positions.length / 6;\r\n let v;\r\n if (GreasedLineMesh._CompareV3(0, l - 1, positions)) {\r\n v = positions.subarray((l - 2) * 6, (l - 1) * 6);\r\n } else {\r\n v = positions.subarray(0, 6);\r\n }\r\n previous.set(v);\r\n previous.set(positions.subarray(0, positions.length - 6), 6);\r\n next.set(positions.subarray(6));\r\n if (GreasedLineMesh._CompareV3(l - 1, 0, positions)) {\r\n v = positions.subarray(6, 12);\r\n } else {\r\n v = positions.subarray((l - 1) * 6, l * 6);\r\n }\r\n next.set(v, next.length - 6);\r\n\r\n for (let i = 0, sidesLength = positions.length / 3; i < sidesLength; i++) {\r\n previousAndSide[previousAndSideOffset++] = previous[i * 3];\r\n previousAndSide[previousAndSideOffset++] = previous[i * 3 + 1];\r\n previousAndSide[previousAndSideOffset++] = previous[i * 3 + 2];\r\n // side[i] = i % 2 ? -1 : 1;\r\n // side[i] = 1 - ((i & 1) << 1);\r\n previousAndSide[previousAndSideOffset++] = 1 - ((i & 1) << 1);\r\n nextAndCounters[nextAndCountersOffset++] = next[i * 3];\r\n nextAndCounters[nextAndCountersOffset++] = next[i * 3 + 1];\r\n nextAndCounters[nextAndCountersOffset++] = next[i * 3 + 2];\r\n // counters[i] = lengthArray[i >> 1] / totalLength;\r\n nextAndCounters[nextAndCountersOffset++] = lengthArray[i >> 1] / totalLength;\r\n }\r\n if (this._options.uvs) {\r\n for (let i = 0; i < this._options.uvs.length; i++) {\r\n uvArr[uvOffset++] = this._options.uvs[i];\r\n }\r\n } else {\r\n for (let j = 0; j < l; j++) {\r\n // uvs\r\n const lengthRatio = lengthArray[j] / totalLength;\r\n const uvOffsetBase = uvOffset + j * 4;\r\n uvArr[uvOffsetBase + 0] = lengthRatio;\r\n uvArr[uvOffsetBase + 1] = 0;\r\n uvArr[uvOffsetBase + 2] = lengthRatio;\r\n uvArr[uvOffsetBase + 3] = 1;\r\n }\r\n }\r\n }\r\n this._vertexPositions = vertexPositionsArr;\r\n this._indices = indicesArr;\r\n this._uvs = uvArr;\r\n this._previousAndSide = previousAndSide;\r\n this._nextAndCounters = nextAndCounters;\r\n\r\n if (!this._lazy) {\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers();\r\n !this.doNotSyncBoundingInfo && this.refreshBoundingInfo();\r\n }\r\n }\r\n\r\n /**\r\n * Clones the GreasedLineMesh.\r\n * @param name new line name\r\n * @param newParent new parent node\r\n * @returns cloned line\r\n */\r\n public override clone(name: string = `${this.name}-cloned`, newParent?: Nullable<Node>) {\r\n const lineOptions = this._createLineOptions();\r\n const deepCopiedLineOptions = {};\r\n DeepCopier.DeepCopy(lineOptions, deepCopiedLineOptions, [\"instance\"], undefined, true);\r\n\r\n const cloned = new GreasedLineMesh(name, this._scene, <GreasedLineMeshOptions>deepCopiedLineOptions);\r\n if (newParent) {\r\n cloned.parent = newParent;\r\n }\r\n\r\n cloned.material = this.material;\r\n\r\n return cloned;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public override serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n /**\r\n * Parses a serialized GreasedLineMesh\r\n * @param parsedMesh the serialized GreasedLineMesh\r\n * @param scene the scene to create the GreasedLineMesh in\r\n * @returns the created GreasedLineMesh\r\n */\r\n public static override Parse(parsedMesh: any, scene: Scene): Mesh {\r\n const lineOptions = <GreasedLineMeshOptions>parsedMesh.lineOptions;\r\n const name = <string>parsedMesh.name;\r\n const result = new GreasedLineMesh(name, scene, lineOptions);\r\n return result;\r\n }\r\n\r\n protected override _initGreasedLine() {\r\n super._initGreasedLine();\r\n\r\n this._previousAndSide = [];\r\n this._nextAndCounters = [];\r\n }\r\n /**\r\n * Checks whether a ray is intersecting this GreasedLineMesh\r\n * @param ray ray to check the intersection of this mesh with\r\n * @param fastCheck not supported\r\n * @param trianglePredicate not supported\r\n * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)\r\n * @param worldToUse not supported\r\n * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check\r\n * @returns the picking info\r\n */\r\n public override intersects(\r\n ray: Ray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n onlyBoundingInfo = false,\r\n worldToUse?: Matrix,\r\n skipBoundingInfo = false\r\n ): PickingInfo {\r\n const pickingInfo = new PickingInfo();\r\n const intersections = this.findAllIntersections(ray, fastCheck, trianglePredicate, onlyBoundingInfo, worldToUse, skipBoundingInfo, true);\r\n if (intersections?.length === 1) {\r\n const intersection = intersections[0];\r\n pickingInfo.hit = true;\r\n pickingInfo.distance = intersection.distance;\r\n pickingInfo.ray = ray;\r\n pickingInfo.pickedMesh = this;\r\n pickingInfo.pickedPoint = intersection.point;\r\n }\r\n return pickingInfo;\r\n }\r\n\r\n /**\r\n * Gets all intersections of a ray and the line\r\n * @param ray Ray to check the intersection of this mesh with\r\n * @param _fastCheck not supported\r\n * @param _trianglePredicate not supported\r\n * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)\r\n * @param _worldToUse not supported\r\n * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check\r\n * @param firstOnly If true, the first and only intersection is immediatelly returned if found\r\n * @returns intersection(s)\r\n */\r\n public findAllIntersections(\r\n ray: Ray,\r\n _fastCheck?: boolean,\r\n _trianglePredicate?: TrianglePickingPredicate,\r\n onlyBoundingInfo = false,\r\n _worldToUse?: Matrix,\r\n skipBoundingInfo = false,\r\n firstOnly = false\r\n ): { distance: number; point: Vector3 }[] | undefined {\r\n if (onlyBoundingInfo && !skipBoundingInfo && ray.intersectsSphere(this._boundingSphere, this.intersectionThreshold) === false) {\r\n return;\r\n }\r\n\r\n const indices = this.getIndices();\r\n const positions = this.getVerticesData(VertexBuffer.PositionKind);\r\n const widths = this._widths;\r\n\r\n const lineWidth = this.greasedLineMaterial?.width ?? 1;\r\n\r\n const intersects = [];\r\n if (indices && positions && widths) {\r\n let i = 0,\r\n l = 0;\r\n for (i = 0, l = indices.length - 1; i < l; i += 3) {\r\n const a = indices[i];\r\n const b = indices[i + 1];\r\n\r\n GreasedLineMesh._V_START.fromArray(positions, a * 3);\r\n GreasedLineMesh._V_END.fromArray(positions, b * 3);\r\n\r\n if (this._offsets) {\r\n GreasedLineMesh._V_OFFSET_START.fromArray(this._offsets, a * 3);\r\n GreasedLineMesh._V_OFFSET_END.fromArray(this._offsets, b * 3);\r\n GreasedLineMesh._V_START.addInPlace(GreasedLineMesh._V_OFFSET_START);\r\n GreasedLineMesh._V_END.addInPlace(GreasedLineMesh._V_OFFSET_END);\r\n }\r\n\r\n const iFloored = Math.floor(i / 3);\r\n const width = widths[iFloored] !== undefined ? widths[iFloored] : 1;\r\n const precision = (this.intersectionThreshold * (lineWidth * width)) / 2;\r\n\r\n const distance = ray.intersectionSegment(GreasedLineMesh._V_START, GreasedLineMesh._V_END, precision);\r\n if (distance !== -1) {\r\n intersects.push({\r\n distance: distance,\r\n point: ray.direction.normalize().multiplyByFloats(distance, distance, distance).add(ray.origin),\r\n });\r\n if (firstOnly) {\r\n return intersects;\r\n }\r\n }\r\n }\r\n i = l;\r\n }\r\n\r\n return intersects;\r\n }\r\n\r\n private get _boundingSphere() {\r\n return this.getBoundingInfo().boundingSphere;\r\n }\r\n\r\n private static _CompareV3(positionIdx1: number, positionIdx2: number, positions: FloatArray) {\r\n const arrayIdx1 = positionIdx1 * 6;\r\n const arrayIdx2 = positionIdx2 * 6;\r\n return positions[arrayIdx1] === positions[arrayIdx2] && positions[arrayIdx1 + 1] === positions[arrayIdx2 + 1] && positions[arrayIdx1 + 2] === positions[arrayIdx2 + 2];\r\n }\r\n\r\n protected override _createVertexBuffers() {\r\n const vertexData: VertexData = super._createVertexBuffers();\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n const previousAndSideBuffer = new Buffer(engine, this._previousAndSide, false, 4);\r\n this.setVerticesBuffer(previousAndSideBuffer.createVertexBuffer(\"grl_previousAndSide\", 0, 4));\r\n\r\n const nextAndCountersBuffer = new Buffer(engine, this._nextAndCounters, false, 4);\r\n this.setVerticesBuffer(nextAndCountersBuffer.createVertexBuffer(\"grl_nextAndCounters\", 0, 4));\r\n\r\n const widthBuffer = new Buffer(engine, this._widths, this._updatable, 1);\r\n this.setVerticesBuffer(widthBuffer.createVertexBuffer(\"grl_widths\", 0, 1));\r\n this._widthsBuffer = widthBuffer;\r\n\r\n const colorPointersBuffer = new Buffer(engine, this._colorPointers, this._updatable, 1);\r\n this.setVerticesBuffer(colorPointersBuffer.createVertexBuffer(\"grl_colorPointers\", 0, 1));\r\n this._colorPointersBuffer = colorPointersBuffer;\r\n\r\n return vertexData;\r\n }\r\n}\r\n"]}
|
package/Meshes/mesh.js
CHANGED
|
@@ -3998,9 +3998,12 @@ export class Mesh extends AbstractMesh {
|
|
|
3998
3998
|
return null;
|
|
3999
3999
|
}
|
|
4000
4000
|
if (subdivideWithSubMeshes) {
|
|
4001
|
-
indiceArray.push(mesh.getTotalIndices());
|
|
4001
|
+
indiceArray.push({ start: 0, count: mesh.getTotalIndices() });
|
|
4002
4002
|
}
|
|
4003
4003
|
if (multiMultiMaterials) {
|
|
4004
|
+
const indexOffset = indiceArray.reduce((accumulator, currentValue) => {
|
|
4005
|
+
return Math.max(accumulator, currentValue.start + currentValue.count);
|
|
4006
|
+
}, 0);
|
|
4004
4007
|
if (mesh.material) {
|
|
4005
4008
|
const material = mesh.material;
|
|
4006
4009
|
if (material instanceof MultiMaterial) {
|
|
@@ -4011,7 +4014,7 @@ export class Mesh extends AbstractMesh {
|
|
|
4011
4014
|
}
|
|
4012
4015
|
for (let subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
|
|
4013
4016
|
materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
|
|
4014
|
-
indiceArray.push(mesh.subMeshes[subIndex].indexCount);
|
|
4017
|
+
indiceArray.push({ start: indexOffset + mesh.subMeshes[subIndex].indexStart, count: mesh.subMeshes[subIndex].indexCount });
|
|
4015
4018
|
}
|
|
4016
4019
|
}
|
|
4017
4020
|
else {
|
|
@@ -4020,14 +4023,14 @@ export class Mesh extends AbstractMesh {
|
|
|
4020
4023
|
}
|
|
4021
4024
|
for (let subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
|
|
4022
4025
|
materialIndexArray.push(materialArray.indexOf(material));
|
|
4023
|
-
indiceArray.push(mesh.subMeshes[subIndex].indexCount);
|
|
4026
|
+
indiceArray.push({ start: indexOffset + mesh.subMeshes[subIndex].indexStart, count: mesh.subMeshes[subIndex].indexCount });
|
|
4024
4027
|
}
|
|
4025
4028
|
}
|
|
4026
4029
|
}
|
|
4027
4030
|
else {
|
|
4028
4031
|
for (let subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
|
|
4029
4032
|
materialIndexArray.push(0);
|
|
4030
|
-
indiceArray.push(mesh.subMeshes[subIndex].indexCount);
|
|
4033
|
+
indiceArray.push({ start: indexOffset + mesh.subMeshes[subIndex].indexStart, count: mesh.subMeshes[subIndex].indexCount });
|
|
4031
4034
|
}
|
|
4032
4035
|
}
|
|
4033
4036
|
}
|
|
@@ -4083,11 +4086,9 @@ export class Mesh extends AbstractMesh {
|
|
|
4083
4086
|
//-- removal of global submesh
|
|
4084
4087
|
meshSubclass.releaseSubMeshes();
|
|
4085
4088
|
index = 0;
|
|
4086
|
-
let offset = 0;
|
|
4087
4089
|
//-- apply subdivision according to index table
|
|
4088
4090
|
while (index < indiceArray.length) {
|
|
4089
|
-
SubMesh.CreateFromIndices(0,
|
|
4090
|
-
offset += indiceArray[index];
|
|
4091
|
+
SubMesh.CreateFromIndices(0, indiceArray[index].start, indiceArray[index].count, meshSubclass, undefined, false);
|
|
4091
4092
|
index++;
|
|
4092
4093
|
}
|
|
4093
4094
|
for (const subMesh of meshSubclass.subMeshes) {
|