@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/index.cjs CHANGED
@@ -201,6 +201,10 @@ function makeDefaultGLTFJson() {
201
201
  };
202
202
  }
203
203
  var GLTFScenegraph = class {
204
+ // internal
205
+ gltf;
206
+ sourceBuffers;
207
+ byteLength;
204
208
  // TODO - why is this not GLTFWithBuffers - what happens to images?
205
209
  constructor(gltf) {
206
210
  this.gltf = {
@@ -1448,7 +1452,7 @@ function processPrimitiveTextures(scenegraph, attributeName, featureTexturePrope
1448
1452
  }
1449
1453
 
1450
1454
  // dist/lib/utils/version.js
1451
- var VERSION = true ? "4.2.0-alpha.4" : "latest";
1455
+ var VERSION = true ? "4.2.0-alpha.5" : "latest";
1452
1456
 
1453
1457
  // dist/lib/parsers/parse-gltf.js
1454
1458
  var import_loader_utils4 = require("@loaders.gl/loader-utils");
@@ -2032,15 +2036,15 @@ __export(KHR_texture_transform_exports, {
2032
2036
  name: () => name8
2033
2037
  });
2034
2038
  var import_core = require("@math.gl/core");
2035
- var EXT_MESHOPT_TRANSFORM = "KHR_texture_transform";
2036
- var name8 = EXT_MESHOPT_TRANSFORM;
2039
+ var KHR_TEXTURE_TRANSFORM = "KHR_texture_transform";
2040
+ var name8 = KHR_TEXTURE_TRANSFORM;
2037
2041
  var scratchVector = new import_core.Vector3();
2038
2042
  var scratchRotationMatrix = new import_core.Matrix3();
2039
2043
  var scratchScaleMatrix = new import_core.Matrix3();
2040
2044
  async function decode7(gltfData, options) {
2041
2045
  var _a;
2042
2046
  const gltfScenegraph = new GLTFScenegraph(gltfData);
2043
- const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
2047
+ const hasExtension = gltfScenegraph.hasExtension(KHR_TEXTURE_TRANSFORM);
2044
2048
  if (!hasExtension || !((_a = options.gltf) == null ? void 0 : _a.loadBuffers)) {
2045
2049
  return;
2046
2050
  }
@@ -2050,28 +2054,20 @@ async function decode7(gltfData, options) {
2050
2054
  }
2051
2055
  }
2052
2056
  function transformTexCoords(materialIndex, gltfData) {
2053
- var _a, _b, _c;
2054
- const processedTexCoords = [];
2057
+ var _a, _b, _c, _d;
2055
2058
  const material = (_a = gltfData.json.materials) == null ? void 0 : _a[materialIndex];
2056
- const baseColorTexture = (_b = material == null ? void 0 : material.pbrMetallicRoughness) == null ? void 0 : _b.baseColorTexture;
2057
- if (baseColorTexture) {
2058
- transformPrimitives(gltfData, materialIndex, baseColorTexture, processedTexCoords);
2059
- }
2060
- const emisiveTexture = material == null ? void 0 : material.emissiveTexture;
2061
- if (emisiveTexture) {
2062
- transformPrimitives(gltfData, materialIndex, emisiveTexture, processedTexCoords);
2063
- }
2064
- const normalTexture = material == null ? void 0 : material.normalTexture;
2065
- if (normalTexture) {
2066
- transformPrimitives(gltfData, materialIndex, normalTexture, processedTexCoords);
2067
- }
2068
- const occlusionTexture = material == null ? void 0 : material.occlusionTexture;
2069
- if (occlusionTexture) {
2070
- transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);
2071
- }
2072
- const metallicRoughnessTexture = (_c = material == null ? void 0 : material.pbrMetallicRoughness) == null ? void 0 : _c.metallicRoughnessTexture;
2073
- if (metallicRoughnessTexture) {
2074
- transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);
2059
+ const materialTextures = [
2060
+ (_b = material == null ? void 0 : material.pbrMetallicRoughness) == null ? void 0 : _b.baseColorTexture,
2061
+ material == null ? void 0 : material.emissiveTexture,
2062
+ material == null ? void 0 : material.normalTexture,
2063
+ material == null ? void 0 : material.occlusionTexture,
2064
+ (_c = material == null ? void 0 : material.pbrMetallicRoughness) == null ? void 0 : _c.metallicRoughnessTexture
2065
+ ];
2066
+ const processedTexCoords = [];
2067
+ for (const textureInfo of materialTextures) {
2068
+ if (textureInfo && ((_d = textureInfo == null ? void 0 : textureInfo.extensions) == null ? void 0 : _d[KHR_TEXTURE_TRANSFORM])) {
2069
+ transformPrimitives(gltfData, materialIndex, textureInfo, processedTexCoords);
2070
+ }
2075
2071
  }
2076
2072
  }
2077
2073
  function transformPrimitives(gltfData, materialIndex, texture, processedTexCoords) {
@@ -2091,7 +2087,7 @@ function transformPrimitives(gltfData, materialIndex, texture, processedTexCoord
2091
2087
  }
2092
2088
  function getTransformParameters(texture, processedTexCoords) {
2093
2089
  var _a;
2094
- const textureInfo = (_a = texture.extensions) == null ? void 0 : _a[EXT_MESHOPT_TRANSFORM];
2090
+ const textureInfo = (_a = texture.extensions) == null ? void 0 : _a[KHR_TEXTURE_TRANSFORM];
2095
2091
  const { texCoord: originalTexCoord = 0 } = texture;
2096
2092
  const { texCoord = originalTexCoord } = textureInfo;
2097
2093
  const isProcessed = processedTexCoords.findIndex(([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord) !== -1;
@@ -2417,22 +2413,21 @@ var GLTF_KEYS = {
2417
2413
  texture: "textures"
2418
2414
  };
2419
2415
  var GLTFV1Normalizer = class {
2420
- constructor() {
2421
- this.idToIndexMap = {
2422
- animations: {},
2423
- accessors: {},
2424
- buffers: {},
2425
- bufferViews: {},
2426
- images: {},
2427
- materials: {},
2428
- meshes: {},
2429
- nodes: {},
2430
- samplers: {},
2431
- scenes: {},
2432
- skins: {},
2433
- textures: {}
2434
- };
2435
- }
2416
+ idToIndexMap = {
2417
+ animations: {},
2418
+ accessors: {},
2419
+ buffers: {},
2420
+ bufferViews: {},
2421
+ images: {},
2422
+ materials: {},
2423
+ meshes: {},
2424
+ nodes: {},
2425
+ samplers: {},
2426
+ scenes: {},
2427
+ skins: {},
2428
+ textures: {}
2429
+ };
2430
+ json;
2436
2431
  // constructor() {}
2437
2432
  /**
2438
2433
  * Convert (normalize) glTF < 2.0 to glTF 2.0
@@ -2961,11 +2956,13 @@ function getSizeFromAccessorType(type) {
2961
2956
  return COMPONENTS2[type];
2962
2957
  }
2963
2958
  var GLTFPostProcessor = class {
2964
- constructor() {
2965
- this.baseUri = "";
2966
- this.buffers = [];
2967
- this.images = [];
2968
- }
2959
+ baseUri = "";
2960
+ // @ts-expect-error
2961
+ jsonUnprocessed;
2962
+ // @ts-expect-error
2963
+ json;
2964
+ buffers = [];
2965
+ images = [];
2969
2966
  postProcess(gltf, options = {}) {
2970
2967
  const { json, buffers = [], images = [] } = gltf;
2971
2968
  const { baseUri = "" } = gltf;