@onerjs/loaders 8.26.3 → 8.26.4

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 (69) hide show
  1. package/OBJ/solidParser.d.ts +7 -8
  2. package/OBJ/solidParser.js +53 -95
  3. package/OBJ/solidParser.js.map +1 -1
  4. package/glTF/2.0/Extensions/{KHR_materials_diffuse_roughness.d.ts → EXT_materials_diffuse_roughness.d.ts} +5 -5
  5. package/glTF/2.0/Extensions/{KHR_materials_diffuse_roughness.js → EXT_materials_diffuse_roughness.js} +18 -8
  6. package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.js.map +1 -0
  7. package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +1 -1
  8. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +10 -15
  9. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
  10. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +28 -44
  11. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  12. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +31 -6
  13. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  14. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +7 -3
  15. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +9 -5
  17. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  18. package/glTF/2.0/Extensions/KHR_materials_ior.js +10 -3
  19. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  20. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +11 -13
  21. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  22. package/glTF/2.0/Extensions/KHR_materials_sheen.js +22 -11
  23. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  24. package/glTF/2.0/Extensions/KHR_materials_specular.js +17 -9
  25. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  26. package/glTF/2.0/Extensions/KHR_materials_transmission.js +32 -21
  27. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  28. package/glTF/2.0/Extensions/KHR_materials_unlit.js +13 -7
  29. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  30. package/glTF/2.0/Extensions/KHR_materials_volume.js +22 -13
  31. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  32. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +2 -1
  33. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  34. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +8 -5
  35. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  36. package/glTF/2.0/Extensions/dynamic.js +3 -3
  37. package/glTF/2.0/Extensions/dynamic.js.map +1 -1
  38. package/glTF/2.0/Extensions/index.d.ts +1 -4
  39. package/glTF/2.0/Extensions/index.js +1 -4
  40. package/glTF/2.0/Extensions/index.js.map +1 -1
  41. package/glTF/2.0/glTFLoader.d.ts +0 -17
  42. package/glTF/2.0/glTFLoader.js +50 -104
  43. package/glTF/2.0/glTFLoader.js.map +1 -1
  44. package/glTF/2.0/index.d.ts +0 -2
  45. package/glTF/2.0/index.js +0 -2
  46. package/glTF/2.0/index.js.map +1 -1
  47. package/glTF/glTFFileLoader.d.ts +0 -5
  48. package/glTF/glTFFileLoader.js +0 -6
  49. package/glTF/glTFFileLoader.js.map +1 -1
  50. package/package.json +3 -3
  51. package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.d.ts +0 -42
  52. package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.js +0 -66
  53. package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.js.map +0 -1
  54. package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.d.ts +0 -42
  55. package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.js +0 -62
  56. package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.js.map +0 -1
  57. package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.d.ts +0 -43
  58. package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.js +0 -62
  59. package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.js.map +0 -1
  60. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js.map +0 -1
  61. package/glTF/2.0/materialLoadingAdapter.d.ts +0 -314
  62. package/glTF/2.0/materialLoadingAdapter.js +0 -2
  63. package/glTF/2.0/materialLoadingAdapter.js.map +0 -1
  64. package/glTF/2.0/openPbrMaterialLoadingAdapter.d.ts +0 -594
  65. package/glTF/2.0/openPbrMaterialLoadingAdapter.js +0 -902
  66. package/glTF/2.0/openPbrMaterialLoadingAdapter.js.map +0 -1
  67. package/glTF/2.0/pbrMaterialLoadingAdapter.d.ts +0 -612
  68. package/glTF/2.0/pbrMaterialLoadingAdapter.js +0 -973
  69. package/glTF/2.0/pbrMaterialLoadingAdapter.js.map +0 -1
@@ -94,14 +94,13 @@ export declare class SolidParser {
94
94
  * If a tuple of (position, normal) is not set, add the data into the corresponding array
95
95
  * If the tuple already exist, add only their indice
96
96
  *
97
- * @param data The vertex's data
98
- * * indicesPositionFromObj: The index in positions array
99
- * * indicesUvsFromObj: The index in uvs array
100
- * * indicesNormalFromObj: The index in normals array
101
- * * positionVectorFromOBJ: The value of position at index objIndice
102
- * * textureVectorFromOBJ: The value of uvs
103
- * * normalsVectorFromOBJ: The value of normals at index objNormale
104
- * * positionColorsFromOBJ: The value of color at index objIndice
97
+ * @param indicePositionFromObj Integer The index in positions array
98
+ * @param indiceUvsFromObj Integer The index in uvs array
99
+ * @param indiceNormalFromObj Integer The index in normals array
100
+ * @param positionVectorFromOBJ Vector3 The value of position at index objIndice
101
+ * @param textureVectorFromOBJ Vector3 The value of uvs
102
+ * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
103
+ * @param positionColorsFromOBJ
105
104
  */
106
105
  private _setData;
107
106
  /**
@@ -78,26 +78,22 @@ export class SolidParser {
78
78
  * If a tuple of (position, normal) is not set, add the data into the corresponding array
79
79
  * If the tuple already exist, add only their indice
80
80
  *
81
- * @param data The vertex's data
82
- * * indicesPositionFromObj: The index in positions array
83
- * * indicesUvsFromObj: The index in uvs array
84
- * * indicesNormalFromObj: The index in normals array
85
- * * positionVectorFromOBJ: The value of position at index objIndice
86
- * * textureVectorFromOBJ: The value of uvs
87
- * * normalsVectorFromOBJ: The value of normals at index objNormale
88
- * * positionColorsFromOBJ: The value of color at index objIndice
81
+ * @param indicePositionFromObj Integer The index in positions array
82
+ * @param indiceUvsFromObj Integer The index in uvs array
83
+ * @param indiceNormalFromObj Integer The index in normals array
84
+ * @param positionVectorFromOBJ Vector3 The value of position at index objIndice
85
+ * @param textureVectorFromOBJ Vector3 The value of uvs
86
+ * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
87
+ * @param positionColorsFromOBJ
89
88
  */
90
- _setData(data) {
91
- //Use default values if undefined
92
- data.indiceUvsFromObj ?? (data.indiceUvsFromObj = -1);
93
- data.indiceNormalFromObj ?? (data.indiceNormalFromObj = -1);
89
+ _setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ, positionColorsFromOBJ) {
94
90
  //Check if this tuple already exists in the list of tuples
95
91
  let _index;
96
92
  if (this._loadingOptions.optimizeWithUV) {
97
- _index = this._isInArrayUV(this._tuplePosNorm, [data.indicePositionFromObj, data.indiceNormalFromObj, data.indiceUvsFromObj]);
93
+ _index = this._isInArrayUV(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj, indiceUvsFromObj]);
98
94
  }
99
95
  else {
100
- _index = this._isInArray(this._tuplePosNorm, [data.indicePositionFromObj, data.indiceNormalFromObj]);
96
+ _index = this._isInArray(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj]);
101
97
  }
102
98
  //If it not exists
103
99
  if (_index === -1) {
@@ -107,27 +103,25 @@ export class SolidParser {
107
103
  this._indicesForBabylon.push(this._wrappedPositionForBabylon.length);
108
104
  //Push the position of vertice for Babylon
109
105
  //Each element is a Vector3(x,y,z)
110
- this._wrappedPositionForBabylon.push(data.positionVectorFromOBJ);
111
- if (data.textureVectorFromOBJ !== undefined) {
112
- //Push the uvs for Babylon
113
- //Each element is a Vector2(u,v)
114
- this._wrappedUvsForBabylon.push(data.textureVectorFromOBJ);
115
- }
116
- if (data.normalsVectorFromOBJ !== undefined) {
117
- //Push the normals for Babylon
118
- //Each element is a Vector3(x,y,z)
119
- this._wrappedNormalsForBabylon.push(data.normalsVectorFromOBJ);
120
- }
121
- if (data.positionColorsFromOBJ !== undefined) {
106
+ this._wrappedPositionForBabylon.push(positionVectorFromOBJ);
107
+ //Push the uvs for Babylon
108
+ //Each element is a Vector2(u,v)
109
+ //If the UVs are missing, set (u,v)=(0,0)
110
+ textureVectorFromOBJ = textureVectorFromOBJ ?? new Vector2(0, 0);
111
+ this._wrappedUvsForBabylon.push(textureVectorFromOBJ);
112
+ //Push the normals for Babylon
113
+ //Each element is a Vector3(x,y,z)
114
+ this._wrappedNormalsForBabylon.push(normalsVectorFromOBJ);
115
+ if (positionColorsFromOBJ !== undefined) {
122
116
  //Push the colors for Babylon
123
117
  //Each element is a BABYLON.Color4(r,g,b,a)
124
- this._wrappedColorsForBabylon.push(data.positionColorsFromOBJ);
118
+ this._wrappedColorsForBabylon.push(positionColorsFromOBJ);
125
119
  }
126
120
  //Add the tuple in the comparison list
127
- this._tuplePosNorm[data.indicePositionFromObj].normals.push(data.indiceNormalFromObj);
128
- this._tuplePosNorm[data.indicePositionFromObj].idx.push(this._curPositionInIndices++);
121
+ this._tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);
122
+ this._tuplePosNorm[indicePositionFromObj].idx.push(this._curPositionInIndices++);
129
123
  if (this._loadingOptions.optimizeWithUV) {
130
- this._tuplePosNorm[data.indicePositionFromObj].uv.push(data.indiceUvsFromObj);
124
+ this._tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj);
131
125
  }
132
126
  }
133
127
  else {
@@ -146,13 +140,9 @@ export class SolidParser {
146
140
  for (let l = 0; l < this._wrappedPositionForBabylon.length; l++) {
147
141
  //Push the x, y, z values of each element in the unwrapped array
148
142
  this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[l].x * this._handednessSign, this._wrappedPositionForBabylon[l].y, this._wrappedPositionForBabylon[l].z);
149
- if (this._wrappedNormalsForBabylon.length) {
150
- this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[l].x * this._handednessSign, this._wrappedNormalsForBabylon[l].y, this._wrappedNormalsForBabylon[l].z);
151
- }
152
- if (this._wrappedUvsForBabylon.length) {
153
- this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[l].x, this._wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
154
- }
155
- if (this._unwrappedColorsForBabylon.length) {
143
+ this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[l].x * this._handednessSign, this._wrappedNormalsForBabylon[l].y, this._wrappedNormalsForBabylon[l].z);
144
+ this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[l].x, this._wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
145
+ if (this._loadingOptions.importVertexColors) {
156
146
  //Push the r, g, b, a values of each element in the unwrapped array
157
147
  this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[l].r, this._wrappedColorsForBabylon[l].g, this._wrappedColorsForBabylon[l].b, this._wrappedColorsForBabylon[l].a);
158
148
  }
@@ -222,11 +212,10 @@ export class SolidParser {
222
212
  for (let k = 0; k < this._triangles.length; k++) {
223
213
  // Set position indice
224
214
  const indicePositionFromObj = parseInt(this._triangles[k]) - 1;
225
- this._setData({
226
- indicePositionFromObj,
227
- positionVectorFromOBJ: this._positions[indicePositionFromObj],
228
- positionColorsFromOBJ: this._getColor(indicePositionFromObj),
229
- });
215
+ this._setData(indicePositionFromObj, 0, 0, // In the pattern 1, normals and uvs are not defined
216
+ this._positions[indicePositionFromObj], // Get the vectors data
217
+ Vector2.Zero(), Vector3.Up(), // Create default vectors
218
+ this._getColor(indicePositionFromObj));
230
219
  }
231
220
  //Reset variable for the next line
232
221
  this._triangles.length = 0;
@@ -248,13 +237,10 @@ export class SolidParser {
248
237
  const indicePositionFromObj = parseInt(point[0]) - 1;
249
238
  //Set uv indice
250
239
  const indiceUvsFromObj = parseInt(point[1]) - 1;
251
- this._setData({
252
- indicePositionFromObj,
253
- indiceUvsFromObj,
254
- positionVectorFromOBJ: this._positions[indicePositionFromObj],
255
- textureVectorFromOBJ: this._uvs[indiceUvsFromObj],
256
- positionColorsFromOBJ: this._getColor(indicePositionFromObj),
257
- });
240
+ this._setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
241
+ this._positions[indicePositionFromObj], //Get the values for each element
242
+ this._uvs[indiceUvsFromObj] ?? Vector2.Zero(), Vector3.Up(), //Default value for normals
243
+ this._getColor(indicePositionFromObj));
258
244
  }
259
245
  //Reset variable for the next line
260
246
  this._triangles.length = 0;
@@ -278,14 +264,8 @@ export class SolidParser {
278
264
  const indiceUvsFromObj = parseInt(point[1]) - 1;
279
265
  // Set normal indice
280
266
  const indiceNormalFromObj = parseInt(point[2]) - 1;
281
- this._setData({
282
- indicePositionFromObj,
283
- indiceUvsFromObj,
284
- indiceNormalFromObj,
285
- positionVectorFromOBJ: this._positions[indicePositionFromObj],
286
- textureVectorFromOBJ: this._uvs[indiceUvsFromObj],
287
- normalsVectorFromOBJ: this._normals[indiceNormalFromObj],
288
- });
267
+ this._setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, this._positions[indicePositionFromObj], this._uvs[indiceUvsFromObj] ?? Vector2.Zero(), this._normals[indiceNormalFromObj] ?? Vector3.Up() //Set the vector for each component
268
+ );
289
269
  }
290
270
  //Reset variable for the next line
291
271
  this._triangles.length = 0;
@@ -305,13 +285,9 @@ export class SolidParser {
305
285
  // We check indices, and normals
306
286
  const indicePositionFromObj = parseInt(point[0]) - 1;
307
287
  const indiceNormalFromObj = parseInt(point[1]) - 1;
308
- this._setData({
309
- indicePositionFromObj,
310
- indiceNormalFromObj,
311
- positionVectorFromOBJ: this._positions[indicePositionFromObj],
312
- normalsVectorFromOBJ: this._normals[indiceNormalFromObj],
313
- positionColorsFromOBJ: this._getColor(indicePositionFromObj),
314
- });
288
+ this._setData(indicePositionFromObj, 1, //Default value for uv
289
+ indiceNormalFromObj, this._positions[indicePositionFromObj], //Get each vector of data
290
+ Vector2.Zero(), this._normals[indiceNormalFromObj], this._getColor(indicePositionFromObj));
315
291
  }
316
292
  //Reset variable for the next line
317
293
  this._triangles.length = 0;
@@ -335,15 +311,8 @@ export class SolidParser {
335
311
  const indiceUvsFromObj = this._uvs.length + parseInt(point[1]);
336
312
  // Set normal indice
337
313
  const indiceNormalFromObj = this._normals.length + parseInt(point[2]);
338
- this._setData({
339
- indicePositionFromObj,
340
- indiceUvsFromObj,
341
- indiceNormalFromObj,
342
- positionVectorFromOBJ: this._positions[indicePositionFromObj],
343
- textureVectorFromOBJ: this._uvs[indiceUvsFromObj],
344
- normalsVectorFromOBJ: this._normals[indiceNormalFromObj],
345
- positionColorsFromOBJ: this._getColor(indicePositionFromObj),
346
- });
314
+ this._setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, this._positions[indicePositionFromObj], this._uvs[indiceUvsFromObj], this._normals[indiceNormalFromObj], //Set the vector for each component
315
+ this._getColor(indicePositionFromObj));
347
316
  }
348
317
  //Reset variable for the next line
349
318
  this._triangles.length = 0;
@@ -364,16 +333,12 @@ export class SolidParser {
364
333
  //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited
365
334
  this._handledMesh.indices = this._indicesForBabylon.slice();
366
335
  this._handledMesh.positions = this._unwrappedPositionsForBabylon.slice();
367
- if (this._unwrappedNormalsForBabylon.length) {
368
- this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice();
369
- }
370
- if (this._unwrappedUVForBabylon.length) {
371
- this._handledMesh.uvs = this._unwrappedUVForBabylon.slice();
372
- }
373
- if (this._unwrappedColorsForBabylon.length) {
336
+ this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice();
337
+ this._handledMesh.uvs = this._unwrappedUVForBabylon.slice();
338
+ this._handledMesh.hasLines = this._hasLineData;
339
+ if (this._loadingOptions.importVertexColors) {
374
340
  this._handledMesh.colors = this._unwrappedColorsForBabylon.slice();
375
341
  }
376
- this._handledMesh.hasLines = this._hasLineData;
377
342
  //Reset the array for the next mesh
378
343
  this._indicesForBabylon.length = 0;
379
344
  this._unwrappedPositionsForBabylon.length = 0;
@@ -712,16 +677,12 @@ export class SolidParser {
712
677
  //Set array
713
678
  this._handledMesh.indices = this._indicesForBabylon;
714
679
  this._handledMesh.positions = this._unwrappedPositionsForBabylon;
715
- if (this._unwrappedNormalsForBabylon.length) {
716
- this._handledMesh.normals = this._unwrappedNormalsForBabylon;
717
- }
718
- if (this._unwrappedUVForBabylon.length) {
719
- this._handledMesh.uvs = this._unwrappedUVForBabylon;
720
- }
721
- if (this._unwrappedColorsForBabylon.length) {
680
+ this._handledMesh.normals = this._unwrappedNormalsForBabylon;
681
+ this._handledMesh.uvs = this._unwrappedUVForBabylon;
682
+ this._handledMesh.hasLines = this._hasLineData;
683
+ if (this._loadingOptions.importVertexColors) {
722
684
  this._handledMesh.colors = this._unwrappedColorsForBabylon;
723
685
  }
724
- this._handledMesh.hasLines = this._hasLineData;
725
686
  }
726
687
  // If any o or g keyword not found, create a mesh with a random id
727
688
  if (!this._hasMeshes) {
@@ -834,10 +795,10 @@ export class SolidParser {
834
795
  }
835
796
  const vertexData = new VertexData(); //The container for the values
836
797
  //Set the data for the babylonMesh
798
+ vertexData.uvs = this._handledMesh.uvs;
837
799
  vertexData.indices = this._handledMesh.indices;
838
800
  vertexData.positions = this._handledMesh.positions;
839
- if (this._loadingOptions.computeNormals || !this._handledMesh.normals) {
840
- // Compute normals if requested or if normals are not defined
801
+ if (this._loadingOptions.computeNormals) {
841
802
  const normals = new Array();
842
803
  VertexData.ComputeNormals(this._handledMesh.positions, this._handledMesh.indices, normals);
843
804
  vertexData.normals = normals;
@@ -845,10 +806,7 @@ export class SolidParser {
845
806
  else {
846
807
  vertexData.normals = this._handledMesh.normals;
847
808
  }
848
- if (this._handledMesh.uvs) {
849
- vertexData.uvs = this._handledMesh.uvs;
850
- }
851
- if (this._handledMesh.colors) {
809
+ if (this._loadingOptions.importVertexColors) {
852
810
  vertexData.colors = this._handledMesh.colors;
853
811
  }
854
812
  //Set the data from the VertexBuffer to the current Mesh