@shapediver/viewer.data-engine.geometry-engine 2.9.10 → 2.10.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.
@@ -94,7 +94,8 @@ export class MaterialLoader {
94
94
  }
95
95
 
96
96
  if (pbrSpecularGlossiness.diffuseTexture !== undefined) {
97
- const diffuseTextureOptions = pbrSpecularGlossiness.diffuseTexture.extensions && pbrSpecularGlossiness.diffuseTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? pbrSpecularGlossiness.diffuseTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
97
+ const diffuseTextureOptions = pbrSpecularGlossiness.diffuseTexture.extensions && pbrSpecularGlossiness.diffuseTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? pbrSpecularGlossiness.diffuseTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
98
+ if(pbrSpecularGlossiness.diffuseTexture.texCoord !== undefined) diffuseTextureOptions.texCoord = pbrSpecularGlossiness.diffuseTexture.texCoord;
98
99
  specularGlossinessMaterialDataProperties.map = this.loadMap(pbrSpecularGlossiness.diffuseTexture.index, diffuseTextureOptions);
99
100
  }
100
101
  specularGlossinessMaterialDataProperties.emissiveness = '#000000';
@@ -106,7 +107,8 @@ export class MaterialLoader {
106
107
  }
107
108
 
108
109
  if (pbrSpecularGlossiness.specularGlossinessTexture !== undefined) {
109
- const specularGlossinessTextureOptions = pbrSpecularGlossiness.specularGlossinessTexture.extensions && pbrSpecularGlossiness.specularGlossinessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? pbrSpecularGlossiness.specularGlossinessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
110
+ const specularGlossinessTextureOptions = pbrSpecularGlossiness.specularGlossinessTexture.extensions && pbrSpecularGlossiness.specularGlossinessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? pbrSpecularGlossiness.specularGlossinessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
111
+ if(pbrSpecularGlossiness.specularGlossinessTexture.texCoord !== undefined) specularGlossinessTextureOptions.texCoord = pbrSpecularGlossiness.specularGlossinessTexture.texCoord;
110
112
  specularGlossinessMaterialDataProperties.specularGlossinessMap = this.loadMap(pbrSpecularGlossiness.specularGlossinessTexture.index, specularGlossinessTextureOptions);
111
113
  }
112
114
  } else if (materialExtensions[GLTF_EXTENSIONS.KHR_MATERIALS_UNLIT]) {
@@ -120,7 +122,8 @@ export class MaterialLoader {
120
122
  unlitMaterialDataProperties.opacity = material.pbrMetallicRoughness.baseColorFactor[3];
121
123
  }
122
124
  if (material.pbrMetallicRoughness.baseColorTexture !== undefined) {
123
- const baseColorTextureOptions = material.pbrMetallicRoughness.baseColorTexture.extensions && material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
125
+ const baseColorTextureOptions = material.pbrMetallicRoughness.baseColorTexture.extensions && material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
126
+ if(material.pbrMetallicRoughness.baseColorTexture.texCoord !== undefined) baseColorTextureOptions.texCoord = material.pbrMetallicRoughness.baseColorTexture.texCoord;
124
127
  unlitMaterialDataProperties.map = this.loadMap(material.pbrMetallicRoughness.baseColorTexture.index, baseColorTextureOptions);
125
128
  }
126
129
  }
@@ -133,7 +136,8 @@ export class MaterialLoader {
133
136
  standardMaterialDataProperties.opacity = material.pbrMetallicRoughness.baseColorFactor[3];
134
137
  }
135
138
  if (material.pbrMetallicRoughness.baseColorTexture !== undefined) {
136
- const baseColorTextureOptions = material.pbrMetallicRoughness.baseColorTexture.extensions && material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
139
+ const baseColorTextureOptions = material.pbrMetallicRoughness.baseColorTexture.extensions && material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.pbrMetallicRoughness.baseColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
140
+ if(material.pbrMetallicRoughness.baseColorTexture.texCoord !== undefined) baseColorTextureOptions.texCoord = material.pbrMetallicRoughness.baseColorTexture.texCoord;
137
141
  standardMaterialDataProperties.map = this.loadMap(material.pbrMetallicRoughness.baseColorTexture.index, baseColorTextureOptions);
138
142
  }
139
143
  if (material.pbrMetallicRoughness.metallicFactor !== undefined) {
@@ -143,7 +147,8 @@ export class MaterialLoader {
143
147
  standardMaterialDataProperties.roughness = material.pbrMetallicRoughness.roughnessFactor;
144
148
  }
145
149
  if (material.pbrMetallicRoughness.metallicRoughnessTexture !== undefined) {
146
- const metallicRoughnessTextureOptions = material.pbrMetallicRoughness.metallicRoughnessTexture.extensions && material.pbrMetallicRoughness.metallicRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.pbrMetallicRoughness.metallicRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
150
+ const metallicRoughnessTextureOptions = material.pbrMetallicRoughness.metallicRoughnessTexture.extensions && material.pbrMetallicRoughness.metallicRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.pbrMetallicRoughness.metallicRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
151
+ if(material.pbrMetallicRoughness.metallicRoughnessTexture.texCoord !== undefined) metallicRoughnessTextureOptions.texCoord = material.pbrMetallicRoughness.metallicRoughnessTexture.texCoord;
147
152
  standardMaterialDataProperties.metalnessRoughnessMap = this.loadMap(material.pbrMetallicRoughness.metallicRoughnessTexture.index, metallicRoughnessTextureOptions);
148
153
  }
149
154
  }
@@ -154,7 +159,9 @@ export class MaterialLoader {
154
159
  */
155
160
 
156
161
  if (material.normalTexture !== undefined) {
157
- const normalTextureOptions = material.normalTexture.extensions && material.normalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.normalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
162
+ const normalTextureOptions = material.normalTexture.extensions && material.normalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.normalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
163
+ if(material.normalTexture.texCoord !== undefined) normalTextureOptions.texCoord = material.normalTexture.texCoord;
164
+
158
165
  materialDataProperties.normalMap = this.loadMap(material.normalTexture.index, normalTextureOptions);
159
166
  materialDataProperties.normalScale = 1;
160
167
  if (material.normalTexture.scale !== undefined) {
@@ -162,14 +169,17 @@ export class MaterialLoader {
162
169
  }
163
170
  }
164
171
  if (material.occlusionTexture !== undefined) {
165
- const occlusionTextureOptions = material.occlusionTexture.extensions && material.occlusionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.occlusionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
172
+ const occlusionTextureOptions = material.occlusionTexture.extensions && material.occlusionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.occlusionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
173
+ if(material.occlusionTexture.texCoord !== undefined) occlusionTextureOptions.texCoord = material.occlusionTexture.texCoord;
174
+
166
175
  materialDataProperties.aoMap = this.loadMap(material.occlusionTexture.index, occlusionTextureOptions);
167
176
  if (material.occlusionTexture.strength !== undefined) {
168
177
  materialDataProperties.aoMapIntensity = material.occlusionTexture.strength;
169
178
  }
170
179
  }
171
180
  if (material.emissiveTexture !== undefined) {
172
- const emissiveTextureOptions = material.emissiveTexture.extensions && material.emissiveTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.emissiveTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
181
+ const emissiveTextureOptions = material.emissiveTexture.extensions && material.emissiveTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? material.emissiveTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
182
+ if(material.emissiveTexture.texCoord !== undefined) emissiveTextureOptions.texCoord = material.emissiveTexture.texCoord;
173
183
  materialDataProperties.emissiveMap = this.loadMap(material.emissiveTexture.index, emissiveTextureOptions);
174
184
  }
175
185
 
@@ -213,7 +223,8 @@ export class MaterialLoader {
213
223
  }
214
224
 
215
225
  if (clearcoatExtension.clearcoatTexture !== undefined) {
216
- const clearcoatTextureOptions = clearcoatExtension.clearcoatTexture.extensions && clearcoatExtension.clearcoatTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? clearcoatExtension.clearcoatTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
226
+ const clearcoatTextureOptions = clearcoatExtension.clearcoatTexture.extensions && clearcoatExtension.clearcoatTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? clearcoatExtension.clearcoatTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
227
+ if(clearcoatExtension.clearcoatTexture.texCoord !== undefined) clearcoatTextureOptions.texCoord = clearcoatExtension.clearcoatTexture.texCoord;
217
228
  standardMaterialDataProperties.clearcoatMap = this.loadMap(clearcoatExtension.clearcoatTexture.index, clearcoatTextureOptions);
218
229
  }
219
230
 
@@ -222,12 +233,14 @@ export class MaterialLoader {
222
233
  }
223
234
 
224
235
  if (clearcoatExtension.clearcoatRoughnessTexture !== undefined) {
225
- const clearcoatRoughnessTextureOptions = clearcoatExtension.clearcoatRoughnessTexture.extensions && clearcoatExtension.clearcoatRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? clearcoatExtension.clearcoatRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
236
+ const clearcoatRoughnessTextureOptions = clearcoatExtension.clearcoatRoughnessTexture.extensions && clearcoatExtension.clearcoatRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? clearcoatExtension.clearcoatRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
237
+ if(clearcoatExtension.clearcoatRoughnessTexture.texCoord !== undefined) clearcoatRoughnessTextureOptions.texCoord = clearcoatExtension.clearcoatRoughnessTexture.texCoord;
226
238
  standardMaterialDataProperties.clearcoatRoughnessMap = this.loadMap(clearcoatExtension.clearcoatRoughnessTexture.index, clearcoatRoughnessTextureOptions);
227
239
  }
228
240
 
229
241
  if (clearcoatExtension.clearcoatNormalTexture !== undefined) {
230
- const clearcoatNormalTextureOptions = clearcoatExtension.clearcoatNormalTexture.extensions && clearcoatExtension.clearcoatNormalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? clearcoatExtension.clearcoatNormalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
242
+ const clearcoatNormalTextureOptions = clearcoatExtension.clearcoatNormalTexture.extensions && clearcoatExtension.clearcoatNormalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? clearcoatExtension.clearcoatNormalTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
243
+ if(clearcoatExtension.clearcoatNormalTexture.texCoord !== undefined) clearcoatNormalTextureOptions.texCoord = clearcoatExtension.clearcoatNormalTexture.texCoord;
231
244
  standardMaterialDataProperties.clearcoatNormalMap = this.loadMap(clearcoatExtension.clearcoatNormalTexture.index, clearcoatNormalTextureOptions);
232
245
  }
233
246
  }
@@ -246,7 +259,8 @@ export class MaterialLoader {
246
259
  }
247
260
 
248
261
  if (transmissionExtension.transmissionTexture !== undefined) {
249
- const transmissionTextureOptions = transmissionExtension.transmissionTexture.extensions && transmissionExtension.transmissionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? transmissionExtension.transmissionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
262
+ const transmissionTextureOptions = transmissionExtension.transmissionTexture.extensions && transmissionExtension.transmissionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? transmissionExtension.transmissionTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
263
+ if(transmissionExtension.transmissionTexture.texCoord !== undefined) transmissionTextureOptions.texCoord = transmissionExtension.transmissionTexture.texCoord;
250
264
  standardMaterialDataProperties.transmissionMap = this.loadMap(transmissionExtension.transmissionTexture.index, transmissionTextureOptions);
251
265
  }
252
266
  }
@@ -258,7 +272,8 @@ export class MaterialLoader {
258
272
  }
259
273
 
260
274
  if (volumeExtension.thicknessTexture !== undefined) {
261
- const thicknessTextureOptions = volumeExtension.thicknessTexture.extensions && volumeExtension.thicknessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? volumeExtension.thicknessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
275
+ const thicknessTextureOptions = volumeExtension.thicknessTexture.extensions && volumeExtension.thicknessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? volumeExtension.thicknessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
276
+ if(volumeExtension.thicknessTexture.texCoord !== undefined) thicknessTextureOptions.texCoord = volumeExtension.thicknessTexture.texCoord;
262
277
  standardMaterialDataProperties.thicknessMap = this.loadMap(volumeExtension.thicknessTexture.index, thicknessTextureOptions);
263
278
  }
264
279
 
@@ -283,12 +298,14 @@ export class MaterialLoader {
283
298
  }
284
299
 
285
300
  if (sheenExtension.sheenColorTexture !== undefined) {
286
- const sheenColorTextureOptions = sheenExtension.sheenColorTexture.extensions && sheenExtension.sheenColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? sheenExtension.sheenColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
301
+ const sheenColorTextureOptions = sheenExtension.sheenColorTexture.extensions && sheenExtension.sheenColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? sheenExtension.sheenColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
302
+ if(sheenExtension.sheenColorTexture.texCoord !== undefined) sheenColorTextureOptions.texCoord = sheenExtension.sheenColorTexture.texCoord;
287
303
  standardMaterialDataProperties.sheenColorMap = this.loadMap(sheenExtension.sheenColorTexture.index, sheenColorTextureOptions);
288
304
  }
289
305
 
290
306
  if (sheenExtension.sheenRoughnessTexture !== undefined) {
291
- const sheenRoughnessTextureOptions = sheenExtension.sheenRoughnessTexture.extensions && sheenExtension.sheenRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? sheenExtension.sheenRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
307
+ const sheenRoughnessTextureOptions = sheenExtension.sheenRoughnessTexture.extensions && sheenExtension.sheenRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? sheenExtension.sheenRoughnessTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
308
+ if(sheenExtension.sheenRoughnessTexture.texCoord !== undefined) sheenRoughnessTextureOptions.texCoord = sheenExtension.sheenRoughnessTexture.texCoord;
292
309
  standardMaterialDataProperties.sheenRoughnessMap = this.loadMap(sheenExtension.sheenRoughnessTexture.index, sheenRoughnessTextureOptions);
293
310
  }
294
311
  }
@@ -305,12 +322,14 @@ export class MaterialLoader {
305
322
  }
306
323
 
307
324
  if (specularExtension.specularColorTexture !== undefined) {
308
- const specularColorTextureOptions = specularExtension.specularColorTexture.extensions && specularExtension.specularColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? specularExtension.specularColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
325
+ const specularColorTextureOptions = specularExtension.specularColorTexture.extensions && specularExtension.specularColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? specularExtension.specularColorTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
326
+ if(specularExtension.specularColorTexture.texCoord !== undefined) specularColorTextureOptions.texCoord = specularExtension.specularColorTexture.texCoord;
309
327
  standardMaterialDataProperties.specularColorMap = this.loadMap(specularExtension.specularColorTexture.index, specularColorTextureOptions);
310
328
  }
311
329
 
312
330
  if (specularExtension.specularTexture !== undefined) {
313
- const specularTextureOptions = specularExtension.specularTexture.extensions && specularExtension.specularTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? specularExtension.specularTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
331
+ const specularTextureOptions = specularExtension.specularTexture.extensions && specularExtension.specularTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] ? specularExtension.specularTexture.extensions[GLTF_EXTENSIONS.KHR_TEXTURE_TRANSFORM] : {};
332
+ if(specularExtension.specularTexture.texCoord !== undefined) specularTextureOptions.texCoord = specularExtension.specularTexture.texCoord;
314
333
  standardMaterialDataProperties.specularIntensityMap = this.loadMap(specularExtension.specularTexture.index, specularTextureOptions);
315
334
  }
316
335
  }
@@ -325,7 +344,7 @@ export class MaterialLoader {
325
344
 
326
345
  // #region Private Methods (1)
327
346
 
328
- private loadMap(textureId: number, properties?: { offset?: number[], scale?: number[], rotation?: number }): IMapData {
347
+ private loadMap(textureId: number, properties?: { offset?: number[], scale?: number[], rotation?: number, texCoord?: number }): IMapData {
329
348
  if (!this._content.textures) throw new Error('Textures not available.')
330
349
  const texture = this._content.textures[textureId];
331
350
  if (!this._content.images) throw new Error('Images not available.')
@@ -343,8 +362,9 @@ export class MaterialLoader {
343
362
  properties && properties.offset ? vec2.fromValues(properties.offset[0], properties.offset[1]) : undefined,
344
363
  properties && properties.scale ? vec2.fromValues(properties.scale[0], properties.scale[1]) : undefined,
345
364
  properties && properties.rotation !== undefined ? properties.rotation : 0,
365
+ properties?.texCoord,
346
366
  false
347
- );;
367
+ );
348
368
  }
349
369
 
350
370
  // #endregion Private Methods (1)