@babylonjs/core 6.4.0 → 6.5.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.
Files changed (57) hide show
  1. package/Engines/WebGPU/webgpuCacheBindGroups.js +1 -1
  2. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  3. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -2
  4. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  5. package/Engines/WebGPU/webgpuClearQuad.js +1 -1
  6. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  7. package/Engines/WebGPU/webgpuDrawContext.js +1 -1
  8. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  9. package/Engines/WebGPU/webgpuMaterialContext.d.ts +1 -0
  10. package/Engines/WebGPU/webgpuMaterialContext.js +1 -0
  11. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  12. package/Engines/WebGPU/webgpuPipelineContext.d.ts +3 -1
  13. package/Engines/WebGPU/webgpuPipelineContext.js +2 -0
  14. package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
  15. package/Engines/thinEngine.js +2 -2
  16. package/Engines/thinEngine.js.map +1 -1
  17. package/Engines/webgpuEngine.js +1 -0
  18. package/Engines/webgpuEngine.js.map +1 -1
  19. package/Lights/Shadows/cascadedShadowGenerator.js +14 -2
  20. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  21. package/Lights/Shadows/shadowGenerator.js +1 -0
  22. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  23. package/Materials/Node/Blocks/curveBlock.d.ts +97 -0
  24. package/Materials/Node/Blocks/curveBlock.js +287 -0
  25. package/Materials/Node/Blocks/curveBlock.js.map +1 -0
  26. package/Materials/Node/Blocks/index.d.ts +1 -0
  27. package/Materials/Node/Blocks/index.js +1 -0
  28. package/Materials/Node/Blocks/index.js.map +1 -1
  29. package/Materials/Textures/renderTargetTexture.js +5 -3
  30. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  31. package/Materials/materialDefines.js +1 -0
  32. package/Materials/materialDefines.js.map +1 -1
  33. package/Maths/math.path.d.ts +33 -0
  34. package/Maths/math.path.js +116 -0
  35. package/Maths/math.path.js.map +1 -1
  36. package/Meshes/Builders/index.d.ts +1 -0
  37. package/Meshes/Builders/index.js +1 -0
  38. package/Meshes/Builders/index.js.map +1 -1
  39. package/Meshes/Builders/textBuilder.d.ts +51 -0
  40. package/Meshes/Builders/textBuilder.js +210 -0
  41. package/Meshes/Builders/textBuilder.js.map +1 -0
  42. package/Meshes/WebGPU/webgpuDataBuffer.d.ts +1 -1
  43. package/Meshes/WebGPU/webgpuDataBuffer.js +2 -1
  44. package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
  45. package/Meshes/mesh.js +10 -8
  46. package/Meshes/mesh.js.map +1 -1
  47. package/Meshes/meshBuilder.d.ts +2 -0
  48. package/Meshes/meshBuilder.js +2 -0
  49. package/Meshes/meshBuilder.js.map +1 -1
  50. package/Meshes/transformNode.js +4 -0
  51. package/Meshes/transformNode.js.map +1 -1
  52. package/Rendering/prePassRenderer.d.ts +4 -0
  53. package/Rendering/prePassRenderer.js +14 -1
  54. package/Rendering/prePassRenderer.js.map +1 -1
  55. package/package.json +1 -1
  56. package/scene.js +13 -0
  57. package/scene.js.map +1 -1
@@ -0,0 +1,210 @@
1
+ import { Path2 } from "../../Maths/math.path.js";
2
+ import { Vector3 } from "../../Maths/math.vector.js";
3
+ import { Mesh } from "../mesh.js";
4
+ import { ExtrudePolygon } from "./polygonBuilder.js";
5
+ // Shape functions
6
+ class ShapePath {
7
+ /** Create the ShapePath used to support glyphs */
8
+ constructor(resolution) {
9
+ this._paths = [];
10
+ this._tempPaths = [];
11
+ this._holes = [];
12
+ this._resolution = resolution;
13
+ }
14
+ /** Move the virtual cursor to a coordinate */
15
+ moveTo(x, y) {
16
+ this._currentPath = new Path2(x, y);
17
+ this._tempPaths.push(this._currentPath);
18
+ }
19
+ /** Draw a line from the virtual cursor to a given coordinate */
20
+ lineTo(x, y) {
21
+ this._currentPath.addLineTo(x, y);
22
+ }
23
+ /** Create a quadratic curve from the virtual cursor to a given coordinate */
24
+ quadraticCurveTo(cpx, cpy, x, y) {
25
+ this._currentPath.addQuadraticCurveTo(cpx, cpy, x, y, this._resolution);
26
+ }
27
+ /** Create a bezier curve from the virtual cursor to a given coordinate */
28
+ bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y) {
29
+ this._currentPath.addBezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y, this._resolution);
30
+ }
31
+ /** Extract holes based on CW / CCW */
32
+ extractHoles() {
33
+ for (const path of this._tempPaths) {
34
+ if (path.area() > 0) {
35
+ this._holes.push(path);
36
+ }
37
+ else {
38
+ this._paths.push(path);
39
+ }
40
+ }
41
+ if (!this._paths.length && this._holes.length) {
42
+ const temp = this._holes;
43
+ this._holes = this._paths;
44
+ this._paths = temp;
45
+ }
46
+ this._tempPaths.length = 0;
47
+ }
48
+ /** Gets the list of paths */
49
+ get paths() {
50
+ return this._paths;
51
+ }
52
+ /** Gets the list of holes */
53
+ get holes() {
54
+ return this._holes;
55
+ }
56
+ }
57
+ // Utility functions
58
+ function CreateShapePath(char, scale, offsetX, offsetY, resolution, fontData) {
59
+ const glyph = fontData.glyphs[char] || fontData.glyphs["?"];
60
+ if (!glyph) {
61
+ // return if there is no glyph data
62
+ return null;
63
+ }
64
+ const shapePath = new ShapePath(resolution);
65
+ if (glyph.o) {
66
+ const outline = glyph.o.split(" ");
67
+ for (let i = 0, l = outline.length; i < l;) {
68
+ const action = outline[i++];
69
+ switch (action) {
70
+ case "m": {
71
+ // moveTo
72
+ const x = parseInt(outline[i++]) * scale + offsetX;
73
+ const y = parseInt(outline[i++]) * scale + offsetY;
74
+ shapePath.moveTo(x, y);
75
+ break;
76
+ }
77
+ case "l": {
78
+ // lineTo
79
+ const x = parseInt(outline[i++]) * scale + offsetX;
80
+ const y = parseInt(outline[i++]) * scale + offsetY;
81
+ shapePath.lineTo(x, y);
82
+ break;
83
+ }
84
+ case "q": {
85
+ // quadraticCurveTo
86
+ const cpx = parseInt(outline[i++]) * scale + offsetX;
87
+ const cpy = parseInt(outline[i++]) * scale + offsetY;
88
+ const cpx1 = parseInt(outline[i++]) * scale + offsetX;
89
+ const cpy1 = parseInt(outline[i++]) * scale + offsetY;
90
+ shapePath.quadraticCurveTo(cpx1, cpy1, cpx, cpy);
91
+ break;
92
+ }
93
+ case "b": {
94
+ // bezierCurveTo
95
+ const cpx = parseInt(outline[i++]) * scale + offsetX;
96
+ const cpy = parseInt(outline[i++]) * scale + offsetY;
97
+ const cpx1 = parseInt(outline[i++]) * scale + offsetX;
98
+ const cpy1 = parseInt(outline[i++]) * scale + offsetY;
99
+ const cpx2 = parseInt(outline[i++]) * scale + offsetX;
100
+ const cpy2 = parseInt(outline[i++]) * scale + offsetY;
101
+ shapePath.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy);
102
+ break;
103
+ }
104
+ }
105
+ }
106
+ }
107
+ // Extract holes (based on clockwise data)
108
+ shapePath.extractHoles();
109
+ return { offsetX: glyph.ha * scale, shapePath: shapePath };
110
+ }
111
+ function CreateShapePaths(text, size, resolution, fontData) {
112
+ const chars = Array.from(text);
113
+ const scale = size / fontData.resolution;
114
+ const line_height = (fontData.boundingBox.yMax - fontData.boundingBox.yMin + fontData.underlineThickness) * scale;
115
+ const shapePaths = [];
116
+ let offsetX = 0, offsetY = 0;
117
+ for (let i = 0; i < chars.length; i++) {
118
+ const char = chars[i];
119
+ if (char === "\n") {
120
+ offsetX = 0;
121
+ offsetY -= line_height;
122
+ }
123
+ else {
124
+ const ret = CreateShapePath(char, scale, offsetX, offsetY, resolution, fontData);
125
+ if (ret) {
126
+ offsetX += ret.offsetX;
127
+ shapePaths.push(ret.shapePath);
128
+ }
129
+ }
130
+ }
131
+ return shapePaths;
132
+ }
133
+ /**
134
+ * Create a text mesh
135
+ * @param name defines the name of the mesh
136
+ * @param text defines the text to use to build the mesh
137
+ * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)
138
+ * @param options defines options used to create the mesh
139
+ * @param scene defines the hosting scene
140
+ * @returns a new Mesh
141
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/text
142
+ */
143
+ export function CreateText(name, text, fontData, options = {
144
+ size: 50,
145
+ resolution: 8,
146
+ depth: 1.0,
147
+ }, scene = null) {
148
+ // First we need to generate the paths
149
+ const shapePaths = CreateShapePaths(text, options.size || 50, options.resolution || 8, fontData);
150
+ // And extrude them
151
+ const meshes = [];
152
+ for (const shapePath of shapePaths) {
153
+ if (!shapePath.paths.length) {
154
+ continue;
155
+ }
156
+ const holes = shapePath.holes.slice(); // Copy it as we will update the copy
157
+ for (const path of shapePath.paths) {
158
+ const holeVectors = [];
159
+ const shapeVectors = [];
160
+ const points = path.getPoints();
161
+ for (const point of points) {
162
+ shapeVectors.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane
163
+ }
164
+ // Holes
165
+ const localHolesCopy = holes.slice();
166
+ for (const hole of localHolesCopy) {
167
+ const points = hole.getPoints();
168
+ let found = false;
169
+ for (const point of points) {
170
+ if (path.isPointInside(point)) {
171
+ found = true;
172
+ break;
173
+ }
174
+ }
175
+ if (!found) {
176
+ continue;
177
+ }
178
+ const holePoints = [];
179
+ for (const point of points) {
180
+ holePoints.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane
181
+ }
182
+ holeVectors.push(holePoints);
183
+ // Remove the hole as it was already used
184
+ holes.splice(holes.indexOf(hole), 1);
185
+ }
186
+ // Extrusion!
187
+ const mesh = ExtrudePolygon(name, {
188
+ shape: shapeVectors,
189
+ holes: holeVectors.length ? holeVectors : undefined,
190
+ depth: options.depth || 1.0,
191
+ sideOrientation: Mesh._GetDefaultSideOrientation(options.sideOrientation || Mesh.DOUBLESIDE),
192
+ }, scene);
193
+ meshes.push(mesh);
194
+ }
195
+ }
196
+ // Then we can merge everyone into one single mesh
197
+ const newMesh = Mesh.MergeMeshes(meshes, true, true);
198
+ if (newMesh) {
199
+ // Move pivot to center
200
+ const bbox = newMesh === null || newMesh === void 0 ? void 0 : newMesh.getBoundingInfo();
201
+ newMesh.position.x = -(bbox === null || bbox === void 0 ? void 0 : bbox.boundingBox.extendSizeWorld._x);
202
+ newMesh.position.y = -(bbox === null || bbox === void 0 ? void 0 : bbox.boundingBox.extendSizeWorld._y);
203
+ newMesh.position.z = -(bbox === null || bbox === void 0 ? void 0 : bbox.boundingBox.extendSizeWorld._z);
204
+ newMesh.name = name;
205
+ newMesh.rotation.x = -Math.PI / 2;
206
+ newMesh.bakeCurrentTransformIntoVertices();
207
+ }
208
+ return newMesh;
209
+ }
210
+ //# sourceMappingURL=textBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textBuilder.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Meshes/Builders/textBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsClD,kBAAkB;AAClB,MAAM,SAAS;IAOX,kDAAkD;IAClD,YAAY,UAAkB;QAPtB,WAAM,GAAY,EAAE,CAAC;QACrB,eAAU,GAAY,EAAE,CAAC;QACzB,WAAM,GAAY,EAAE,CAAC;QAMzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,8CAA8C;IAC9C,MAAM,CAAC,CAAS,EAAE,CAAS;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CA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ACJ;IAED,kDAAkD;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAErD,IAAI,OAAO,EAAE;QACT,uBAAuB;QACvB,MAAM,IAAI,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,EAAE,CAAC;QACxC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,eAAe,CAAC,EAAE,CAAA,CAAC;QAC3D,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,eAAe,CAAC,EAAE,CAAA,CAAC;QAC3D,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,eAAe,CAAC,EAAE,CAAA,CAAC;QAC3D,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAElC,OAAO,CAAC,gCAAgC,EAAE,CAAC;KAC9C;IAED,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { Path2 } from \"../../Maths/math.path\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { ExtrudePolygon } from \"./polygonBuilder\";\r\n\r\n/**\r\n * Parser inspired by https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/FontLoader.js\r\n */\r\n\r\n// Interfaces\r\n\r\n/**\r\n * Represents glyph data generated by http://gero3.github.io/facetype.js/\r\n */\r\nexport interface IGlyphData {\r\n /** Commands used to draw (line, move, curve, etc..) */\r\n o: string;\r\n\r\n /** Width */\r\n ha: number;\r\n}\r\n\r\n/**\r\n * Represents font data generated by http://gero3.github.io/facetype.js/\r\n */\r\nexport interface IFontData {\r\n /**\r\n * Font resolution\r\n */\r\n resolution: number;\r\n /** Underline tickness */\r\n underlineThickness: number;\r\n /** Bounding box */\r\n boundingBox: {\r\n yMax: number;\r\n yMin: number;\r\n };\r\n /** List of supported glyphs */\r\n glyphs: { [key: string]: IGlyphData };\r\n}\r\n\r\n// Shape functions\r\nclass ShapePath {\r\n private _paths: Path2[] = [];\r\n private _tempPaths: Path2[] = [];\r\n private _holes: Path2[] = [];\r\n private _currentPath: Path2;\r\n private _resolution: number;\r\n\r\n /** Create the ShapePath used to support glyphs */\r\n constructor(resolution: number) {\r\n this._resolution = resolution;\r\n }\r\n\r\n /** Move the virtual cursor to a coordinate */\r\n moveTo(x: number, y: number) {\r\n this._currentPath = new Path2(x, y);\r\n this._tempPaths.push(this._currentPath);\r\n }\r\n\r\n /** Draw a line from the virtual cursor to a given coordinate */\r\n lineTo(x: number, y: number) {\r\n this._currentPath.addLineTo(x, y);\r\n }\r\n\r\n /** Create a quadratic curve from the virtual cursor to a given coordinate */\r\n quadraticCurveTo(cpx: number, cpy: number, x: number, y: number) {\r\n this._currentPath.addQuadraticCurveTo(cpx, cpy, x, y, this._resolution);\r\n }\r\n\r\n /** Create a bezier curve from the virtual cursor to a given coordinate */\r\n bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number) {\r\n this._currentPath.addBezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y, this._resolution);\r\n }\r\n\r\n /** Extract holes based on CW / CCW */\r\n extractHoles() {\r\n for (const path of this._tempPaths) {\r\n if (path.area() > 0) {\r\n this._holes.push(path);\r\n } else {\r\n this._paths.push(path);\r\n }\r\n }\r\n\r\n if (!this._paths.length && this._holes.length) {\r\n const temp = this._holes;\r\n this._holes = this._paths;\r\n this._paths = temp;\r\n }\r\n\r\n this._tempPaths.length = 0;\r\n }\r\n\r\n /** Gets the list of paths */\r\n get paths() {\r\n return this._paths;\r\n }\r\n\r\n /** Gets the list of holes */\r\n get holes() {\r\n return this._holes;\r\n }\r\n}\r\n\r\n// Utility functions\r\nfunction CreateShapePath(\r\n char: string,\r\n scale: number,\r\n offsetX: number,\r\n offsetY: number,\r\n resolution: number,\r\n fontData: IFontData\r\n): Nullable<{\r\n offsetX: number;\r\n shapePath: ShapePath;\r\n}> {\r\n const glyph = fontData.glyphs[char] || fontData.glyphs[\"?\"];\r\n\r\n if (!glyph) {\r\n // return if there is no glyph data\r\n return null;\r\n }\r\n\r\n const shapePath = new ShapePath(resolution);\r\n\r\n if (glyph.o) {\r\n const outline = glyph.o.split(\" \");\r\n\r\n for (let i = 0, l = outline.length; i < l; ) {\r\n const action = outline[i++];\r\n\r\n switch (action) {\r\n case \"m\": {\r\n // moveTo\r\n const x = parseInt(outline[i++]) * scale + offsetX;\r\n const y = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.moveTo(x, y);\r\n break;\r\n }\r\n case \"l\": {\r\n // lineTo\r\n const x = parseInt(outline[i++]) * scale + offsetX;\r\n const y = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.lineTo(x, y);\r\n break;\r\n }\r\n case \"q\": {\r\n // quadraticCurveTo\r\n const cpx = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx1 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy1 = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.quadraticCurveTo(cpx1, cpy1, cpx, cpy);\r\n break;\r\n }\r\n case \"b\": {\r\n // bezierCurveTo\r\n const cpx = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx1 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy1 = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx2 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy2 = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Extract holes (based on clockwise data)\r\n shapePath.extractHoles();\r\n\r\n return { offsetX: glyph.ha * scale, shapePath: shapePath };\r\n}\r\n\r\nfunction CreateShapePaths(text: string, size: number, resolution: number, fontData: IFontData) {\r\n const chars = Array.from(text);\r\n const scale = size / fontData.resolution;\r\n const line_height = (fontData.boundingBox.yMax - fontData.boundingBox.yMin + fontData.underlineThickness) * scale;\r\n\r\n const shapePaths: ShapePath[] = [];\r\n\r\n let offsetX = 0,\r\n offsetY = 0;\r\n\r\n for (let i = 0; i < chars.length; i++) {\r\n const char = chars[i];\r\n\r\n if (char === \"\\n\") {\r\n offsetX = 0;\r\n offsetY -= line_height;\r\n } else {\r\n const ret = CreateShapePath(char, scale, offsetX, offsetY, resolution, fontData);\r\n\r\n if (ret) {\r\n offsetX += ret.offsetX;\r\n shapePaths.push(ret.shapePath);\r\n }\r\n }\r\n }\r\n\r\n return shapePaths;\r\n}\r\n\r\n/**\r\n * Create a text mesh\r\n * @param name defines the name of the mesh\r\n * @param text defines the text to use to build the mesh\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param options defines options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns a new Mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/text\r\n */\r\nexport function CreateText(\r\n name: string,\r\n text: string,\r\n fontData: IFontData,\r\n options: {\r\n size?: number;\r\n resolution?: number;\r\n depth?: number;\r\n sideOrientation?: number;\r\n } = {\r\n size: 50,\r\n resolution: 8,\r\n depth: 1.0,\r\n },\r\n scene: Nullable<Scene> = null\r\n): Nullable<Mesh> {\r\n // First we need to generate the paths\r\n const shapePaths = CreateShapePaths(text, options.size || 50, options.resolution || 8, fontData);\r\n\r\n // And extrude them\r\n const meshes: Mesh[] = [];\r\n for (const shapePath of shapePaths) {\r\n if (!shapePath.paths.length) {\r\n continue;\r\n }\r\n\r\n const holes = shapePath.holes.slice(); // Copy it as we will update the copy\r\n for (const path of shapePath.paths) {\r\n const holeVectors: Vector3[][] = [];\r\n const shapeVectors: Vector3[] = [];\r\n const points = path.getPoints();\r\n for (const point of points) {\r\n shapeVectors.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n\r\n // Holes\r\n const localHolesCopy = holes.slice();\r\n for (const hole of localHolesCopy) {\r\n const points = hole.getPoints();\r\n\r\n let found = false;\r\n for (const point of points) {\r\n if (path.isPointInside(point)) {\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n continue;\r\n }\r\n\r\n const holePoints: Vector3[] = [];\r\n for (const point of points) {\r\n holePoints.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n holeVectors.push(holePoints);\r\n\r\n // Remove the hole as it was already used\r\n holes.splice(holes.indexOf(hole), 1);\r\n }\r\n\r\n // Extrusion!\r\n const mesh = ExtrudePolygon(\r\n name,\r\n {\r\n shape: shapeVectors,\r\n holes: holeVectors.length ? holeVectors : undefined,\r\n depth: options.depth || 1.0,\r\n sideOrientation: Mesh._GetDefaultSideOrientation(options.sideOrientation || Mesh.DOUBLESIDE),\r\n },\r\n scene\r\n );\r\n meshes.push(mesh);\r\n }\r\n }\r\n\r\n // Then we can merge everyone into one single mesh\r\n const newMesh = Mesh.MergeMeshes(meshes, true, true);\r\n\r\n if (newMesh) {\r\n // Move pivot to center\r\n const bbox = newMesh?.getBoundingInfo();\r\n newMesh.position.x = -bbox?.boundingBox.extendSizeWorld._x;\r\n newMesh.position.y = -bbox?.boundingBox.extendSizeWorld._y;\r\n newMesh.position.z = -bbox?.boundingBox.extendSizeWorld._z;\r\n newMesh.name = name;\r\n\r\n newMesh.rotation.x = -Math.PI / 2;\r\n\r\n newMesh.bakeCurrentTransformIntoVertices();\r\n }\r\n\r\n return newMesh;\r\n}\r\n"]}
@@ -2,6 +2,6 @@ import { DataBuffer } from "../../Buffers/dataBuffer";
2
2
  /** @internal */
3
3
  export declare class WebGPUDataBuffer extends DataBuffer {
4
4
  private _buffer;
5
- constructor(resource: GPUBuffer);
5
+ constructor(resource: GPUBuffer, capacity?: number);
6
6
  get underlyingResource(): any;
7
7
  }
@@ -1,8 +1,9 @@
1
1
  import { DataBuffer } from "../../Buffers/dataBuffer.js";
2
2
  /** @internal */
3
3
  export class WebGPUDataBuffer extends DataBuffer {
4
- constructor(resource) {
4
+ constructor(resource, capacity = 0) {
5
5
  super();
6
+ this.capacity = capacity;
6
7
  this._buffer = resource;
7
8
  }
8
9
  get underlyingResource() {
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuDataBuffer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Meshes/WebGPU/webgpuDataBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAG5C,YAAmB,QAAmB;QAClC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { DataBuffer } from \"../../Buffers/dataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/** @internal */\r\nexport class WebGPUDataBuffer extends DataBuffer {\r\n private _buffer: Nullable<GPUBuffer>;\r\n\r\n public constructor(resource: GPUBuffer) {\r\n super();\r\n this._buffer = resource;\r\n }\r\n\r\n public get underlyingResource(): any {\r\n return this._buffer;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuDataBuffer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Meshes/WebGPU/webgpuDataBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAG5C,YAAmB,QAAmB,EAAE,QAAQ,GAAG,CAAC;QAChD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { DataBuffer } from \"../../Buffers/dataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/** @internal */\r\nexport class WebGPUDataBuffer extends DataBuffer {\r\n private _buffer: Nullable<GPUBuffer>;\r\n\r\n public constructor(resource: GPUBuffer, capacity = 0) {\r\n super();\r\n this.capacity = capacity;\r\n this._buffer = resource;\r\n }\r\n\r\n public get underlyingResource(): any {\r\n return this._buffer;\r\n }\r\n}\r\n"]}
package/Meshes/mesh.js CHANGED
@@ -899,7 +899,7 @@ export class Mesh extends AbstractMesh {
899
899
  * @returns true if all associated assets are ready (material, textures, shaders)
900
900
  */
901
901
  isReady(completeCheck = false, forceInstanceSupport = false) {
902
- var _a, _b, _c, _d, _e, _f;
902
+ var _a, _b, _c, _d, _e, _f, _g;
903
903
  if (this.delayLoadState === 2) {
904
904
  return false;
905
905
  }
@@ -952,13 +952,15 @@ export class Mesh extends AbstractMesh {
952
952
  for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
953
953
  const generator = key.value;
954
954
  if (generator && (!((_a = generator.getShadowMap()) === null || _a === void 0 ? void 0 : _a.renderList) || (((_b = generator.getShadowMap()) === null || _b === void 0 ? void 0 : _b.renderList) && ((_d = (_c = generator.getShadowMap()) === null || _c === void 0 ? void 0 : _c.renderList) === null || _d === void 0 ? void 0 : _d.indexOf(this)) !== -1))) {
955
- if (generator.getShadowMap()) {
956
- engine.currentRenderPassId = generator.getShadowMap().renderPassId;
957
- }
958
- for (const subMesh of this.subMeshes) {
959
- if (!generator.isReady(subMesh, hardwareInstancedRendering, (_f = (_e = subMesh.getMaterial()) === null || _e === void 0 ? void 0 : _e.needAlphaBlendingForMesh(this)) !== null && _f !== void 0 ? _f : false)) {
960
- engine.currentRenderPassId = currentRenderPassId;
961
- return false;
955
+ const shadowMap = generator.getShadowMap();
956
+ const renderPassIds = (_e = shadowMap.renderPassIds) !== null && _e !== void 0 ? _e : [engine.currentRenderPassId];
957
+ for (let p = 0; p < renderPassIds.length; ++p) {
958
+ engine.currentRenderPassId = renderPassIds[p];
959
+ for (const subMesh of this.subMeshes) {
960
+ if (!generator.isReady(subMesh, hardwareInstancedRendering, (_g = (_f = subMesh.getMaterial()) === null || _f === void 0 ? void 0 : _f.needAlphaBlendingForMesh(this)) !== null && _g !== void 0 ? _g : false)) {
961
+ engine.currentRenderPassId = currentRenderPassId;
962
+ return false;
963
+ }
962
964
  }
963
965
  }
964
966
  engine.currentRenderPassId = currentRenderPassId;