@babylonjs/core 5.0.0-alpha.61 → 5.0.0-alpha.62

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 (103) hide show
  1. package/Audio/sound.js +1 -1
  2. package/Audio/sound.js.map +1 -1
  3. package/Behaviors/Cameras/autoRotationBehavior.d.ts +5 -0
  4. package/Behaviors/Cameras/autoRotationBehavior.js +7 -0
  5. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  6. package/Cameras/camera.js +1 -1
  7. package/Cameras/camera.js.map +1 -1
  8. package/DeviceInput/Implementations/webDeviceInputSystem.js +9 -9
  9. package/DeviceInput/Implementations/webDeviceInputSystem.js.map +1 -1
  10. package/Engines/Extensions/engine.dynamicTexture.d.ts +2 -1
  11. package/Engines/Extensions/engine.dynamicTexture.js +2 -1
  12. package/Engines/Extensions/engine.dynamicTexture.js.map +1 -1
  13. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +3 -11
  14. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
  15. package/Engines/WebGPU/Extensions/engine.multiRender.js +0 -4
  16. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  17. package/Engines/WebGPU/Extensions/engine.renderTarget.js +0 -4
  18. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  19. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +42 -61
  20. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  21. package/Engines/WebGPU/webgpuCacheSampler.js +6 -4
  22. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  23. package/Engines/WebGPU/webgpuConstants.d.ts +57 -13
  24. package/Engines/WebGPU/webgpuConstants.js +62 -13
  25. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  26. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +22 -3
  27. package/Engines/WebGPU/webgpuHardwareTexture.js +2 -1
  28. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  29. package/Engines/WebGPU/webgpuTextureHelper.d.ts +2 -2
  30. package/Engines/WebGPU/webgpuTextureHelper.js +233 -63
  31. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  32. package/Engines/engine.d.ts +82 -39
  33. package/Engines/engine.js +10 -1
  34. package/Engines/engine.js.map +1 -1
  35. package/Engines/nativeEngine.js +30 -10
  36. package/Engines/nativeEngine.js.map +1 -1
  37. package/Engines/thinEngine.js +2 -2
  38. package/Engines/thinEngine.js.map +1 -1
  39. package/Engines/webgpuEngine.js +2 -4
  40. package/Engines/webgpuEngine.js.map +1 -1
  41. package/Lights/pointLight.js +1 -1
  42. package/Lights/pointLight.js.map +1 -1
  43. package/Lights/spotLight.js +1 -1
  44. package/Lights/spotLight.js.map +1 -1
  45. package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
  46. package/Materials/Node/Blocks/Fragment/index.js +1 -0
  47. package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
  48. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +1 -3
  49. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
  50. package/Materials/Node/Blocks/Fragment/twirlBlock.d.ts +49 -0
  51. package/Materials/Node/Blocks/Fragment/twirlBlock.js +145 -0
  52. package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -0
  53. package/Materials/Node/Blocks/customBlock.d.ts +31 -0
  54. package/Materials/Node/Blocks/customBlock.js +144 -0
  55. package/Materials/Node/Blocks/customBlock.js.map +1 -0
  56. package/Materials/Node/Blocks/index.d.ts +1 -0
  57. package/Materials/Node/Blocks/index.js +1 -0
  58. package/Materials/Node/Blocks/index.js.map +1 -1
  59. package/Materials/PBR/pbrBaseMaterial.js +1 -1
  60. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  61. package/Materials/Textures/dynamicTexture.d.ts +2 -1
  62. package/Materials/Textures/dynamicTexture.js +4 -2
  63. package/Materials/Textures/dynamicTexture.js.map +1 -1
  64. package/Materials/Textures/thinRenderTargetTexture.js +1 -1
  65. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  66. package/Materials/Textures/thinTexture.d.ts +1 -2
  67. package/Materials/Textures/thinTexture.js +2 -4
  68. package/Materials/Textures/thinTexture.js.map +1 -1
  69. package/Materials/shaderMaterial.js +12 -0
  70. package/Materials/shaderMaterial.js.map +1 -1
  71. package/Maths/math.vector.d.ts +12 -8
  72. package/Maths/math.vector.js +22 -14
  73. package/Maths/math.vector.js.map +1 -1
  74. package/Meshes/abstractMesh.js +23 -22
  75. package/Meshes/abstractMesh.js.map +1 -1
  76. package/Meshes/geometry.js +2 -2
  77. package/Meshes/geometry.js.map +1 -1
  78. package/Meshes/mesh.d.ts +12 -0
  79. package/Meshes/mesh.js +182 -113
  80. package/Meshes/mesh.js.map +1 -1
  81. package/Meshes/mesh.vertexData.d.ts +6 -1
  82. package/Meshes/mesh.vertexData.js +295 -114
  83. package/Meshes/mesh.vertexData.js.map +1 -1
  84. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.d.ts +1 -0
  85. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +13 -8
  86. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  87. package/Misc/PerformanceViewer/performanceViewerCollector.js +1 -1
  88. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  89. package/Misc/coroutine.d.ts +45 -0
  90. package/Misc/coroutine.js +123 -0
  91. package/Misc/coroutine.js.map +1 -0
  92. package/Misc/index.d.ts +1 -0
  93. package/Misc/index.js +1 -0
  94. package/Misc/index.js.map +1 -1
  95. package/Misc/observableCoroutine.d.ts +9 -10
  96. package/Misc/observableCoroutine.js +31 -39
  97. package/Misc/observableCoroutine.js.map +1 -1
  98. package/Particles/subEmitter.js +1 -0
  99. package/Particles/subEmitter.js.map +1 -1
  100. package/XR/features/WebXRControllerPointerSelection.d.ts +14 -0
  101. package/XR/features/WebXRControllerPointerSelection.js +38 -10
  102. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  103. package/package.json +10 -1
@@ -1,6 +1,7 @@
1
1
  import { Nullable, FloatArray, IndicesArray } from "../types";
2
2
  import { Matrix, Vector3, Vector2, Vector4 } from "../Maths/math.vector";
3
3
  import { Color4, Color3 } from '../Maths/math.color';
4
+ import { Coroutine } from '../Misc/coroutine';
4
5
  declare type Geometry = import("../Meshes/geometry").Geometry;
5
6
  declare type Mesh = import("../Meshes/mesh").Mesh;
6
7
  import { ICreateCapsuleOptions } from "./Builders/capsuleBuilder";
@@ -183,7 +184,9 @@ export declare class VertexData {
183
184
  * @returns VertexData.
184
185
  */
185
186
  updateGeometry(geometry: Geometry): VertexData;
186
- private _applyTo;
187
+ private readonly _applyTo;
188
+ /** @hidden */
189
+ _applyToCoroutine(meshOrGeometry: IGetSetVerticesData, updatable: boolean | undefined, isAsync: boolean): Coroutine<VertexData>;
187
190
  private _update;
188
191
  private static _TransformVector3Coordinates;
189
192
  private static _TransformVector3Normals;
@@ -202,6 +205,8 @@ export declare class VertexData {
202
205
  * @returns the modified VertexData
203
206
  */
204
207
  merge(others: VertexData | VertexData[], use32BitsIndices?: boolean): VertexData;
208
+ /** @hidden */
209
+ _mergeCoroutine(others: VertexData | VertexData[], use32BitsIndices: boolean | undefined, isAsync: boolean): Coroutine<VertexData>;
205
210
  private static _mergeElement;
206
211
  private _validate;
207
212
  /**
@@ -1,15 +1,17 @@
1
- import { __decorate } from "tslib";
1
+ import { __decorate, __generator } from "tslib";
2
2
  import { Vector3, Vector4, TmpVectors } from "../Maths/math.vector.js";
3
3
  import { VertexBuffer } from "../Buffers/buffer.js";
4
4
  import { _WarnImport } from '../Misc/devTools.js';
5
5
  import { Color4 } from '../Maths/math.color.js';
6
6
  import { Logger } from '../Misc/logger.js';
7
7
  import { nativeOverride } from '../Misc/decorators.js';
8
+ import { makeSyncFunction, runCoroutineSync } from '../Misc/coroutine.js';
8
9
  /**
9
10
  * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
10
11
  */
11
12
  var VertexData = /** @class */ (function () {
12
13
  function VertexData() {
14
+ this._applyTo = makeSyncFunction(this._applyToCoroutine.bind(this));
13
15
  }
14
16
  /**
15
17
  * Uses the passed data array to set the set the values for the specified kind of data
@@ -73,7 +75,7 @@ var VertexData = /** @class */ (function () {
73
75
  * @returns the VertexData
74
76
  */
75
77
  VertexData.prototype.applyToMesh = function (mesh, updatable) {
76
- this._applyTo(mesh, updatable);
78
+ this._applyTo(mesh, updatable, false);
77
79
  return this;
78
80
  };
79
81
  /**
@@ -84,7 +86,7 @@ var VertexData = /** @class */ (function () {
84
86
  * @returns VertexData
85
87
  */
86
88
  VertexData.prototype.applyToGeometry = function (geometry, updatable) {
87
- this._applyTo(geometry, updatable);
89
+ this._applyTo(geometry, updatable, false);
88
90
  return this;
89
91
  };
90
92
  /**
@@ -109,57 +111,138 @@ var VertexData = /** @class */ (function () {
109
111
  this._update(geometry);
110
112
  return this;
111
113
  };
112
- VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
114
+ /** @hidden */
115
+ VertexData.prototype._applyToCoroutine = function (meshOrGeometry, updatable, isAsync) {
113
116
  if (updatable === void 0) { updatable = false; }
114
- if (this.positions) {
115
- meshOrGeometry.setVerticesData(VertexBuffer.PositionKind, this.positions, updatable);
116
- }
117
- if (this.normals) {
118
- meshOrGeometry.setVerticesData(VertexBuffer.NormalKind, this.normals, updatable);
119
- }
120
- if (this.tangents) {
121
- meshOrGeometry.setVerticesData(VertexBuffer.TangentKind, this.tangents, updatable);
122
- }
123
- if (this.uvs) {
124
- meshOrGeometry.setVerticesData(VertexBuffer.UVKind, this.uvs, updatable);
125
- }
126
- if (this.uvs2) {
127
- meshOrGeometry.setVerticesData(VertexBuffer.UV2Kind, this.uvs2, updatable);
128
- }
129
- if (this.uvs3) {
130
- meshOrGeometry.setVerticesData(VertexBuffer.UV3Kind, this.uvs3, updatable);
131
- }
132
- if (this.uvs4) {
133
- meshOrGeometry.setVerticesData(VertexBuffer.UV4Kind, this.uvs4, updatable);
134
- }
135
- if (this.uvs5) {
136
- meshOrGeometry.setVerticesData(VertexBuffer.UV5Kind, this.uvs5, updatable);
137
- }
138
- if (this.uvs6) {
139
- meshOrGeometry.setVerticesData(VertexBuffer.UV6Kind, this.uvs6, updatable);
140
- }
141
- if (this.colors) {
142
- meshOrGeometry.setVerticesData(VertexBuffer.ColorKind, this.colors, updatable);
143
- }
144
- if (this.matricesIndices) {
145
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, updatable);
146
- }
147
- if (this.matricesWeights) {
148
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, updatable);
149
- }
150
- if (this.matricesIndicesExtra) {
151
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
152
- }
153
- if (this.matricesWeightsExtra) {
154
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
155
- }
156
- if (this.indices) {
157
- meshOrGeometry.setIndices(this.indices, null, updatable);
158
- }
159
- else {
160
- meshOrGeometry.setIndices([], null);
161
- }
162
- return this;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0:
120
+ if (!this.positions) return [3 /*break*/, 2];
121
+ meshOrGeometry.setVerticesData(VertexBuffer.PositionKind, this.positions, updatable);
122
+ if (!isAsync) return [3 /*break*/, 2];
123
+ return [4 /*yield*/];
124
+ case 1:
125
+ _a.sent();
126
+ _a.label = 2;
127
+ case 2:
128
+ if (!this.normals) return [3 /*break*/, 4];
129
+ meshOrGeometry.setVerticesData(VertexBuffer.NormalKind, this.normals, updatable);
130
+ if (!isAsync) return [3 /*break*/, 4];
131
+ return [4 /*yield*/];
132
+ case 3:
133
+ _a.sent();
134
+ _a.label = 4;
135
+ case 4:
136
+ if (!this.tangents) return [3 /*break*/, 6];
137
+ meshOrGeometry.setVerticesData(VertexBuffer.TangentKind, this.tangents, updatable);
138
+ if (!isAsync) return [3 /*break*/, 6];
139
+ return [4 /*yield*/];
140
+ case 5:
141
+ _a.sent();
142
+ _a.label = 6;
143
+ case 6:
144
+ if (!this.uvs) return [3 /*break*/, 8];
145
+ meshOrGeometry.setVerticesData(VertexBuffer.UVKind, this.uvs, updatable);
146
+ if (!isAsync) return [3 /*break*/, 8];
147
+ return [4 /*yield*/];
148
+ case 7:
149
+ _a.sent();
150
+ _a.label = 8;
151
+ case 8:
152
+ if (!this.uvs2) return [3 /*break*/, 10];
153
+ meshOrGeometry.setVerticesData(VertexBuffer.UV2Kind, this.uvs2, updatable);
154
+ if (!isAsync) return [3 /*break*/, 10];
155
+ return [4 /*yield*/];
156
+ case 9:
157
+ _a.sent();
158
+ _a.label = 10;
159
+ case 10:
160
+ if (!this.uvs3) return [3 /*break*/, 12];
161
+ meshOrGeometry.setVerticesData(VertexBuffer.UV3Kind, this.uvs3, updatable);
162
+ if (!isAsync) return [3 /*break*/, 12];
163
+ return [4 /*yield*/];
164
+ case 11:
165
+ _a.sent();
166
+ _a.label = 12;
167
+ case 12:
168
+ if (!this.uvs4) return [3 /*break*/, 14];
169
+ meshOrGeometry.setVerticesData(VertexBuffer.UV4Kind, this.uvs4, updatable);
170
+ if (!isAsync) return [3 /*break*/, 14];
171
+ return [4 /*yield*/];
172
+ case 13:
173
+ _a.sent();
174
+ _a.label = 14;
175
+ case 14:
176
+ if (!this.uvs5) return [3 /*break*/, 16];
177
+ meshOrGeometry.setVerticesData(VertexBuffer.UV5Kind, this.uvs5, updatable);
178
+ if (!isAsync) return [3 /*break*/, 16];
179
+ return [4 /*yield*/];
180
+ case 15:
181
+ _a.sent();
182
+ _a.label = 16;
183
+ case 16:
184
+ if (!this.uvs6) return [3 /*break*/, 18];
185
+ meshOrGeometry.setVerticesData(VertexBuffer.UV6Kind, this.uvs6, updatable);
186
+ if (!isAsync) return [3 /*break*/, 18];
187
+ return [4 /*yield*/];
188
+ case 17:
189
+ _a.sent();
190
+ _a.label = 18;
191
+ case 18:
192
+ if (!this.colors) return [3 /*break*/, 20];
193
+ meshOrGeometry.setVerticesData(VertexBuffer.ColorKind, this.colors, updatable);
194
+ if (!isAsync) return [3 /*break*/, 20];
195
+ return [4 /*yield*/];
196
+ case 19:
197
+ _a.sent();
198
+ _a.label = 20;
199
+ case 20:
200
+ if (!this.matricesIndices) return [3 /*break*/, 22];
201
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, updatable);
202
+ if (!isAsync) return [3 /*break*/, 22];
203
+ return [4 /*yield*/];
204
+ case 21:
205
+ _a.sent();
206
+ _a.label = 22;
207
+ case 22:
208
+ if (!this.matricesWeights) return [3 /*break*/, 24];
209
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, updatable);
210
+ if (!isAsync) return [3 /*break*/, 24];
211
+ return [4 /*yield*/];
212
+ case 23:
213
+ _a.sent();
214
+ _a.label = 24;
215
+ case 24:
216
+ if (!this.matricesIndicesExtra) return [3 /*break*/, 26];
217
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
218
+ if (!isAsync) return [3 /*break*/, 26];
219
+ return [4 /*yield*/];
220
+ case 25:
221
+ _a.sent();
222
+ _a.label = 26;
223
+ case 26:
224
+ if (!this.matricesWeightsExtra) return [3 /*break*/, 28];
225
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
226
+ if (!isAsync) return [3 /*break*/, 28];
227
+ return [4 /*yield*/];
228
+ case 27:
229
+ _a.sent();
230
+ _a.label = 28;
231
+ case 28:
232
+ if (!this.indices) return [3 /*break*/, 31];
233
+ meshOrGeometry.setIndices(this.indices, null, updatable);
234
+ if (!isAsync) return [3 /*break*/, 30];
235
+ return [4 /*yield*/];
236
+ case 29:
237
+ _a.sent();
238
+ _a.label = 30;
239
+ case 30: return [3 /*break*/, 32];
240
+ case 31:
241
+ meshOrGeometry.setIndices([], null);
242
+ _a.label = 32;
243
+ case 32: return [2 /*return*/, this];
244
+ }
245
+ });
163
246
  };
164
247
  VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
165
248
  if (this.positions) {
@@ -278,73 +361,171 @@ var VertexData = /** @class */ (function () {
278
361
  * @returns the modified VertexData
279
362
  */
280
363
  VertexData.prototype.merge = function (others, use32BitsIndices) {
281
- var _a, _b, _c, _d;
282
364
  if (use32BitsIndices === void 0) { use32BitsIndices = false; }
283
- this._validate();
284
- others = Array.isArray(others) ? others : [others];
285
- for (var _i = 0, others_1 = others; _i < others_1.length; _i++) {
286
- var other = others_1[_i];
287
- other._validate();
288
- if (!this.normals !== !other.normals ||
289
- !this.tangents !== !other.tangents ||
290
- !this.uvs !== !other.uvs ||
291
- !this.uvs2 !== !other.uvs2 ||
292
- !this.uvs3 !== !other.uvs3 ||
293
- !this.uvs4 !== !other.uvs4 ||
294
- !this.uvs5 !== !other.uvs5 ||
295
- !this.uvs6 !== !other.uvs6 ||
296
- !this.colors !== !other.colors ||
297
- !this.matricesIndices !== !other.matricesIndices ||
298
- !this.matricesWeights !== !other.matricesWeights ||
299
- !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
300
- !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
301
- throw new Error("Cannot merge vertex data that do not have the same set of attributes");
302
- }
303
- }
304
- var totalIndices = others.reduce(function (indexSum, vertexData) { var _a, _b; return indexSum + ((_b = (_a = vertexData.indices) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); }, (_b = (_a = this.indices) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
305
- if (totalIndices > 0) {
306
- var indicesOffset = (_d = (_c = this.indices) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
307
- if (!this.indices) {
308
- this.indices = new Array(totalIndices);
309
- }
310
- if (this.indices.length !== totalIndices) {
311
- if (Array.isArray(this.indices)) {
312
- this.indices.length = totalIndices;
313
- }
314
- else {
315
- var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(totalIndices) : new Uint16Array(totalIndices);
316
- temp.set(this.indices);
317
- this.indices = temp;
318
- }
319
- }
320
- var positionsOffset = this.positions ? this.positions.length / 3 : 0;
321
- for (var _e = 0, others_2 = others; _e < others_2.length; _e++) {
322
- var other = others_2[_e];
323
- if (other.indices) {
324
- for (var index = 0; index < other.indices.length; index++) {
365
+ return runCoroutineSync(this._mergeCoroutine(others, use32BitsIndices, false));
366
+ };
367
+ /** @hidden */
368
+ VertexData.prototype._mergeCoroutine = function (others, use32BitsIndices, isAsync) {
369
+ var _i, others_1, other, totalIndices, indicesOffset, temp, positionsOffset, _a, others_2, other, index;
370
+ var _b, _c, _d, _e;
371
+ if (use32BitsIndices === void 0) { use32BitsIndices = false; }
372
+ return __generator(this, function (_f) {
373
+ switch (_f.label) {
374
+ case 0:
375
+ this._validate();
376
+ others = Array.isArray(others) ? others : [others];
377
+ for (_i = 0, others_1 = others; _i < others_1.length; _i++) {
378
+ other = others_1[_i];
379
+ other._validate();
380
+ if (!this.normals !== !other.normals ||
381
+ !this.tangents !== !other.tangents ||
382
+ !this.uvs !== !other.uvs ||
383
+ !this.uvs2 !== !other.uvs2 ||
384
+ !this.uvs3 !== !other.uvs3 ||
385
+ !this.uvs4 !== !other.uvs4 ||
386
+ !this.uvs5 !== !other.uvs5 ||
387
+ !this.uvs6 !== !other.uvs6 ||
388
+ !this.colors !== !other.colors ||
389
+ !this.matricesIndices !== !other.matricesIndices ||
390
+ !this.matricesWeights !== !other.matricesWeights ||
391
+ !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
392
+ !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
393
+ throw new Error("Cannot merge vertex data that do not have the same set of attributes");
394
+ }
395
+ }
396
+ totalIndices = others.reduce(function (indexSum, vertexData) { var _a, _b; return indexSum + ((_b = (_a = vertexData.indices) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); }, (_c = (_b = this.indices) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0);
397
+ if (!(totalIndices > 0)) return [3 /*break*/, 4];
398
+ indicesOffset = (_e = (_d = this.indices) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
399
+ if (!this.indices) {
400
+ this.indices = new Array(totalIndices);
401
+ }
402
+ if (this.indices.length !== totalIndices) {
403
+ if (Array.isArray(this.indices)) {
404
+ this.indices.length = totalIndices;
405
+ }
406
+ else {
407
+ temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(totalIndices) : new Uint16Array(totalIndices);
408
+ temp.set(this.indices);
409
+ this.indices = temp;
410
+ }
411
+ }
412
+ positionsOffset = this.positions ? this.positions.length / 3 : 0;
413
+ _a = 0, others_2 = others;
414
+ _f.label = 1;
415
+ case 1:
416
+ if (!(_a < others_2.length)) return [3 /*break*/, 4];
417
+ other = others_2[_a];
418
+ if (!other.indices) return [3 /*break*/, 3];
419
+ for (index = 0; index < other.indices.length; index++) {
325
420
  this.indices[indicesOffset + index] = other.indices[index] + positionsOffset;
326
421
  }
327
422
  // The call to _validate already checked for positions
328
423
  positionsOffset += other.positions.length / 3;
329
424
  indicesOffset += other.indices.length;
330
- }
425
+ if (!isAsync) return [3 /*break*/, 3];
426
+ return [4 /*yield*/];
427
+ case 2:
428
+ _f.sent();
429
+ _f.label = 3;
430
+ case 3:
431
+ _a++;
432
+ return [3 /*break*/, 1];
433
+ case 4:
434
+ this.positions = VertexData._mergeElement(this.positions, others.map(function (other) { return other.positions; }));
435
+ if (!isAsync) return [3 /*break*/, 6];
436
+ return [4 /*yield*/];
437
+ case 5:
438
+ _f.sent();
439
+ _f.label = 6;
440
+ case 6:
441
+ this.normals = VertexData._mergeElement(this.normals, others.map(function (other) { return other.normals; }));
442
+ if (!isAsync) return [3 /*break*/, 8];
443
+ return [4 /*yield*/];
444
+ case 7:
445
+ _f.sent();
446
+ _f.label = 8;
447
+ case 8:
448
+ this.tangents = VertexData._mergeElement(this.tangents, others.map(function (other) { return other.tangents; }));
449
+ if (!isAsync) return [3 /*break*/, 10];
450
+ return [4 /*yield*/];
451
+ case 9:
452
+ _f.sent();
453
+ _f.label = 10;
454
+ case 10:
455
+ this.uvs = VertexData._mergeElement(this.uvs, others.map(function (other) { return other.uvs; }));
456
+ if (!isAsync) return [3 /*break*/, 12];
457
+ return [4 /*yield*/];
458
+ case 11:
459
+ _f.sent();
460
+ _f.label = 12;
461
+ case 12:
462
+ this.uvs2 = VertexData._mergeElement(this.uvs2, others.map(function (other) { return other.uvs2; }));
463
+ if (!isAsync) return [3 /*break*/, 14];
464
+ return [4 /*yield*/];
465
+ case 13:
466
+ _f.sent();
467
+ _f.label = 14;
468
+ case 14:
469
+ this.uvs3 = VertexData._mergeElement(this.uvs3, others.map(function (other) { return other.uvs3; }));
470
+ if (!isAsync) return [3 /*break*/, 16];
471
+ return [4 /*yield*/];
472
+ case 15:
473
+ _f.sent();
474
+ _f.label = 16;
475
+ case 16:
476
+ this.uvs4 = VertexData._mergeElement(this.uvs4, others.map(function (other) { return other.uvs4; }));
477
+ if (!isAsync) return [3 /*break*/, 18];
478
+ return [4 /*yield*/];
479
+ case 17:
480
+ _f.sent();
481
+ _f.label = 18;
482
+ case 18:
483
+ this.uvs5 = VertexData._mergeElement(this.uvs5, others.map(function (other) { return other.uvs5; }));
484
+ if (!isAsync) return [3 /*break*/, 20];
485
+ return [4 /*yield*/];
486
+ case 19:
487
+ _f.sent();
488
+ _f.label = 20;
489
+ case 20:
490
+ this.uvs6 = VertexData._mergeElement(this.uvs6, others.map(function (other) { return other.uvs6; }));
491
+ if (!isAsync) return [3 /*break*/, 22];
492
+ return [4 /*yield*/];
493
+ case 21:
494
+ _f.sent();
495
+ _f.label = 22;
496
+ case 22:
497
+ this.colors = VertexData._mergeElement(this.colors, others.map(function (other) { return other.colors; }));
498
+ if (!isAsync) return [3 /*break*/, 24];
499
+ return [4 /*yield*/];
500
+ case 23:
501
+ _f.sent();
502
+ _f.label = 24;
503
+ case 24:
504
+ this.matricesIndices = VertexData._mergeElement(this.matricesIndices, others.map(function (other) { return other.matricesIndices; }));
505
+ if (!isAsync) return [3 /*break*/, 26];
506
+ return [4 /*yield*/];
507
+ case 25:
508
+ _f.sent();
509
+ _f.label = 26;
510
+ case 26:
511
+ this.matricesWeights = VertexData._mergeElement(this.matricesWeights, others.map(function (other) { return other.matricesWeights; }));
512
+ if (!isAsync) return [3 /*break*/, 28];
513
+ return [4 /*yield*/];
514
+ case 27:
515
+ _f.sent();
516
+ _f.label = 28;
517
+ case 28:
518
+ this.matricesIndicesExtra = VertexData._mergeElement(this.matricesIndicesExtra, others.map(function (other) { return other.matricesIndicesExtra; }));
519
+ if (!isAsync) return [3 /*break*/, 30];
520
+ return [4 /*yield*/];
521
+ case 29:
522
+ _f.sent();
523
+ _f.label = 30;
524
+ case 30:
525
+ this.matricesWeightsExtra = VertexData._mergeElement(this.matricesWeightsExtra, others.map(function (other) { return other.matricesWeightsExtra; }));
526
+ return [2 /*return*/, this];
331
527
  }
332
- }
333
- this.positions = VertexData._mergeElement(this.positions, others.map(function (other) { return other.positions; }));
334
- this.normals = VertexData._mergeElement(this.normals, others.map(function (other) { return other.normals; }));
335
- this.tangents = VertexData._mergeElement(this.tangents, others.map(function (other) { return other.tangents; }));
336
- this.uvs = VertexData._mergeElement(this.uvs, others.map(function (other) { return other.uvs; }));
337
- this.uvs2 = VertexData._mergeElement(this.uvs2, others.map(function (other) { return other.uvs2; }));
338
- this.uvs3 = VertexData._mergeElement(this.uvs3, others.map(function (other) { return other.uvs3; }));
339
- this.uvs4 = VertexData._mergeElement(this.uvs4, others.map(function (other) { return other.uvs4; }));
340
- this.uvs5 = VertexData._mergeElement(this.uvs5, others.map(function (other) { return other.uvs5; }));
341
- this.uvs6 = VertexData._mergeElement(this.uvs6, others.map(function (other) { return other.uvs6; }));
342
- this.colors = VertexData._mergeElement(this.colors, others.map(function (other) { return other.colors; }));
343
- this.matricesIndices = VertexData._mergeElement(this.matricesIndices, others.map(function (other) { return other.matricesIndices; }));
344
- this.matricesWeights = VertexData._mergeElement(this.matricesWeights, others.map(function (other) { return other.matricesWeights; }));
345
- this.matricesIndicesExtra = VertexData._mergeElement(this.matricesIndicesExtra, others.map(function (other) { return other.matricesIndicesExtra; }));
346
- this.matricesWeightsExtra = VertexData._mergeElement(this.matricesWeightsExtra, others.map(function (other) { return other.matricesWeightsExtra; }));
347
- return this;
528
+ });
348
529
  };
349
530
  VertexData._mergeElement = function (source, others) {
350
531
  var nonNullOthers = others.filter(function (other) { return other !== null && other !== undefined; });
@@ -447,7 +628,7 @@ var VertexData = /** @class */ (function () {
447
628
  * @returns a serialized object
448
629
  */
449
630
  VertexData.prototype.serialize = function () {
450
- var serializationObject = this.serialize();
631
+ var serializationObject = {};
451
632
  if (this.positions) {
452
633
  serializationObject.positions = this.positions;
453
634
  }