@loaders.gl/gltf 4.2.0-alpha.5 → 4.2.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -920,6 +920,10 @@ var __exports__ = (() => {
920
920
  };
921
921
  }
922
922
  var GLTFScenegraph = class {
923
+ // internal
924
+ gltf;
925
+ sourceBuffers;
926
+ byteLength;
923
927
  // TODO - why is this not GLTFWithBuffers - what happens to images?
924
928
  constructor(gltf) {
925
929
  this.gltf = {
@@ -3349,6 +3353,9 @@ var __exports__ = (() => {
3349
3353
  };
3350
3354
  var INDEX_ITEM_SIZE = 4;
3351
3355
  var DracoParser = class {
3356
+ draco;
3357
+ decoder;
3358
+ metadataQuerier;
3352
3359
  // draco - the draco decoder, either import `draco3d` or load dynamically
3353
3360
  constructor(draco) {
3354
3361
  this.draco = draco;
@@ -5186,14 +5193,14 @@ var __exports__ = (() => {
5186
5193
  }
5187
5194
 
5188
5195
  // src/lib/extensions/KHR_texture_transform.ts
5189
- var EXT_MESHOPT_TRANSFORM = "KHR_texture_transform";
5190
- var name8 = EXT_MESHOPT_TRANSFORM;
5196
+ var KHR_TEXTURE_TRANSFORM = "KHR_texture_transform";
5197
+ var name8 = KHR_TEXTURE_TRANSFORM;
5191
5198
  var scratchVector = new Vector3();
5192
5199
  var scratchRotationMatrix = new Matrix3();
5193
5200
  var scratchScaleMatrix = new Matrix3();
5194
5201
  async function decode7(gltfData, options) {
5195
5202
  const gltfScenegraph = new GLTFScenegraph(gltfData);
5196
- const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
5203
+ const hasExtension = gltfScenegraph.hasExtension(KHR_TEXTURE_TRANSFORM);
5197
5204
  if (!hasExtension || !options.gltf?.loadBuffers) {
5198
5205
  return;
5199
5206
  }
@@ -5203,27 +5210,19 @@ var __exports__ = (() => {
5203
5210
  }
5204
5211
  }
5205
5212
  function transformTexCoords(materialIndex, gltfData) {
5206
- const processedTexCoords = [];
5207
5213
  const material = gltfData.json.materials?.[materialIndex];
5208
- const baseColorTexture = material?.pbrMetallicRoughness?.baseColorTexture;
5209
- if (baseColorTexture) {
5210
- transformPrimitives(gltfData, materialIndex, baseColorTexture, processedTexCoords);
5211
- }
5212
- const emisiveTexture = material?.emissiveTexture;
5213
- if (emisiveTexture) {
5214
- transformPrimitives(gltfData, materialIndex, emisiveTexture, processedTexCoords);
5215
- }
5216
- const normalTexture = material?.normalTexture;
5217
- if (normalTexture) {
5218
- transformPrimitives(gltfData, materialIndex, normalTexture, processedTexCoords);
5219
- }
5220
- const occlusionTexture = material?.occlusionTexture;
5221
- if (occlusionTexture) {
5222
- transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);
5223
- }
5224
- const metallicRoughnessTexture = material?.pbrMetallicRoughness?.metallicRoughnessTexture;
5225
- if (metallicRoughnessTexture) {
5226
- transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);
5214
+ const materialTextures = [
5215
+ material?.pbrMetallicRoughness?.baseColorTexture,
5216
+ material?.emissiveTexture,
5217
+ material?.normalTexture,
5218
+ material?.occlusionTexture,
5219
+ material?.pbrMetallicRoughness?.metallicRoughnessTexture
5220
+ ];
5221
+ const processedTexCoords = [];
5222
+ for (const textureInfo of materialTextures) {
5223
+ if (textureInfo && textureInfo?.extensions?.[KHR_TEXTURE_TRANSFORM]) {
5224
+ transformPrimitives(gltfData, materialIndex, textureInfo, processedTexCoords);
5225
+ }
5227
5226
  }
5228
5227
  }
5229
5228
  function transformPrimitives(gltfData, materialIndex, texture, processedTexCoords) {
@@ -5242,7 +5241,7 @@ var __exports__ = (() => {
5242
5241
  }
5243
5242
  }
5244
5243
  function getTransformParameters(texture, processedTexCoords) {
5245
- const textureInfo = texture.extensions?.[EXT_MESHOPT_TRANSFORM];
5244
+ const textureInfo = texture.extensions?.[KHR_TEXTURE_TRANSFORM];
5246
5245
  const { texCoord: originalTexCoord = 0 } = texture;
5247
5246
  const { texCoord = originalTexCoord } = textureInfo;
5248
5247
  const isProcessed = processedTexCoords.findIndex(
@@ -5581,22 +5580,21 @@ var __exports__ = (() => {
5581
5580
  texture: "textures"
5582
5581
  };
5583
5582
  var GLTFV1Normalizer = class {
5584
- constructor() {
5585
- this.idToIndexMap = {
5586
- animations: {},
5587
- accessors: {},
5588
- buffers: {},
5589
- bufferViews: {},
5590
- images: {},
5591
- materials: {},
5592
- meshes: {},
5593
- nodes: {},
5594
- samplers: {},
5595
- scenes: {},
5596
- skins: {},
5597
- textures: {}
5598
- };
5599
- }
5583
+ idToIndexMap = {
5584
+ animations: {},
5585
+ accessors: {},
5586
+ buffers: {},
5587
+ bufferViews: {},
5588
+ images: {},
5589
+ materials: {},
5590
+ meshes: {},
5591
+ nodes: {},
5592
+ samplers: {},
5593
+ scenes: {},
5594
+ skins: {},
5595
+ textures: {}
5596
+ };
5597
+ json;
5600
5598
  // constructor() {}
5601
5599
  /**
5602
5600
  * Convert (normalize) glTF < 2.0 to glTF 2.0
@@ -6126,11 +6124,13 @@ var __exports__ = (() => {
6126
6124
  return COMPONENTS2[type];
6127
6125
  }
6128
6126
  var GLTFPostProcessor = class {
6129
- constructor() {
6130
- this.baseUri = "";
6131
- this.buffers = [];
6132
- this.images = [];
6133
- }
6127
+ baseUri = "";
6128
+ // @ts-expect-error
6129
+ jsonUnprocessed;
6130
+ // @ts-expect-error
6131
+ json;
6132
+ buffers = [];
6133
+ images = [];
6134
6134
  postProcess(gltf, options = {}) {
6135
6135
  const { json, buffers = [], images = [] } = gltf;
6136
6136
  const { baseUri = "" } = gltf;