@loaders.gl/gltf 4.2.0-alpha.5 → 4.2.0-beta.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"glb-writer.d.ts","sourceRoot":"","sources":["../src/glb-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAC,GAAG,EAAC,iCAA8B;AAC/C,OAAO,KAAK,EAAC,gBAAgB,EAAC,qCAAkC;AAIhE,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,iBAAiB,CAAC,GAAG,EAAE,KAAK,EAAE,gBAAgB,CAerE,CAAC"}
1
+ {"version":3,"file":"glb-writer.d.ts","sourceRoot":"","sources":["../src/glb-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAC,GAAG,EAAC,iCAA8B;AAC/C,OAAO,KAAK,EAAC,gBAAgB,EAAC,qCAAkC;AAIhE,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;0CAaS,gBAAgB;;CAEqB,CAAC;AAErE,iBAAS,UAAU,CAAC,GAAG,KAAA,EAAE,OAAO,KAAA,eAY/B"}
@@ -1,4 +1,4 @@
1
- import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
2
  import type { DracoLoaderOptions } from '@loaders.gl/draco';
3
3
  import type { ImageLoaderOptions } from '@loaders.gl/images';
4
4
  import type { TextureLoaderOptions } from '@loaders.gl/textures';
@@ -14,6 +14,28 @@ export type GLTFLoaderOptions = LoaderOptions & ImageLoaderOptions & TextureLoad
14
14
  /**
15
15
  * GLTF loader
16
16
  */
17
- export declare const GLTFLoader: LoaderWithParser<GLTFWithBuffers, never, GLBLoaderOptions>;
17
+ export declare const GLTFLoader: {
18
+ readonly dataType: GLTFWithBuffers;
19
+ readonly batchType: never;
20
+ readonly name: "glTF";
21
+ readonly id: "gltf";
22
+ readonly module: "gltf";
23
+ readonly version: any;
24
+ readonly extensions: ["gltf", "glb"];
25
+ readonly mimeTypes: ["model/gltf+json", "model/gltf-binary"];
26
+ readonly text: true;
27
+ readonly binary: true;
28
+ readonly tests: ["glTF"];
29
+ readonly parse: typeof parse;
30
+ readonly options: {
31
+ readonly gltf: {
32
+ readonly normalize: true;
33
+ readonly loadBuffers: true;
34
+ readonly loadImages: true;
35
+ readonly decompressMeshes: true;
36
+ };
37
+ readonly log: Console;
38
+ };
39
+ };
18
40
  export declare function parse(arrayBuffer: any, options: GLTFLoaderOptions | undefined, context: any): Promise<GLTFWithBuffers>;
19
41
  //# sourceMappingURL=gltf-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-loader.d.ts","sourceRoot":"","sources":["../src/gltf-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAC,gBAAgB,EAAC,oCAAiC;AAC/D,OAAO,KAAK,EAAC,eAAe,EAAC,kCAA+B;AAC5D,OAAO,KAAK,EAAC,gBAAgB,EAAC,wBAAqB;AAGnD;;GAEG;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/parse-gltf.js";
4
4
  * GLTF loader
5
5
  */
6
6
  export const GLTFLoader = {
7
+ dataType: null,
8
+ batchType: null,
7
9
  name: 'glTF',
8
10
  id: 'gltf',
9
11
  module: 'gltf',
@@ -1,4 +1,4 @@
1
- import type { Writer, WriterOptions } from '@loaders.gl/loader-utils';
1
+ import type { WriterOptions, WriterWithEncoder } from '@loaders.gl/loader-utils';
2
2
  export type GLTFWriterOptions = WriterOptions & {
3
3
  gltf?: {};
4
4
  byteOffset?: number;
@@ -6,21 +6,5 @@ export type GLTFWriterOptions = WriterOptions & {
6
6
  /**
7
7
  * GLTF exporter
8
8
  */
9
- export declare const GLTFWriter: {
10
- name: string;
11
- id: string;
12
- module: string;
13
- version: any;
14
- extensions: string[];
15
- mimeTypes: string[];
16
- binary: boolean;
17
- options: {
18
- gltf: {};
19
- };
20
- encode: (gltf: any, options?: GLTFWriterOptions) => Promise<ArrayBuffer>;
21
- encodeSync: typeof encodeSync;
22
- };
23
- declare function encodeSync(gltf: any, options?: GLTFWriterOptions): ArrayBuffer;
24
- export declare const _TypecheckGLBLoader: Writer;
25
- export {};
9
+ export declare const GLTFWriter: WriterWithEncoder<any, never, GLTFWriterOptions>;
26
10
  //# sourceMappingURL=gltf-writer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-writer.d.ts","sourceRoot":"","sources":["../src/gltf-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAIpE,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,IAAI,CAAC,EAAE,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;kCAaS,iBAAiB;;CAEhD,CAAC;AAEF,iBAAS,UAAU,CAAC,IAAI,KAAA,EAAE,OAAO,GAAE,iBAAsB,eAUxD;AAGD,eAAO,MAAM,mBAAmB,EAAE,MAAmB,CAAC"}
1
+ {"version":3,"file":"gltf-writer.d.ts","sourceRoot":"","sources":["../src/gltf-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAI/E,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,IAAI,CAAC,EAAE,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,kDAkB8B,CAAC"}
@@ -4,6 +4,8 @@ import { encodeGLTFSync } from "./lib/encoders/encode-gltf.js";
4
4
  * GLTF exporter
5
5
  */
6
6
  export const GLTFWriter = {
7
+ dataType: null,
8
+ batchType: null,
7
9
  name: 'glTF',
8
10
  id: 'gltf',
9
11
  module: 'gltf',
@@ -26,5 +28,3 @@ function encodeSync(gltf, options = {}) {
26
28
  encodeGLTFSync(gltf, dataView, byteOffset, options);
27
29
  return arrayBuffer;
28
30
  }
29
- // TYPE TESTS - TODO find a better way than exporting junk
30
- export const _TypecheckGLBLoader = GLTFWriter;
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.6" : "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
@@ -2730,6 +2725,8 @@ async function loadImage(gltf, image, index, options, context) {
2730
2725
 
2731
2726
  // dist/gltf-loader.js
2732
2727
  var GLTFLoader = {
2728
+ dataType: null,
2729
+ batchType: null,
2733
2730
  name: "glTF",
2734
2731
  id: "gltf",
2735
2732
  module: "gltf",
@@ -2825,6 +2822,8 @@ function convertBuffersToBase64(gltf, { firstBuffer = 0 } = {}) {
2825
2822
 
2826
2823
  // dist/gltf-writer.js
2827
2824
  var GLTFWriter = {
2825
+ dataType: null,
2826
+ batchType: null,
2828
2827
  name: "glTF",
2829
2828
  id: "gltf",
2830
2829
  module: "gltf",
@@ -2851,6 +2850,8 @@ function encodeSync(gltf, options = {}) {
2851
2850
 
2852
2851
  // dist/glb-loader.js
2853
2852
  var GLBLoader = {
2853
+ dataType: null,
2854
+ batchType: null,
2854
2855
  name: "GLB",
2855
2856
  id: "glb",
2856
2857
  module: "gltf",
@@ -2961,11 +2962,13 @@ function getSizeFromAccessorType(type) {
2961
2962
  return COMPONENTS2[type];
2962
2963
  }
2963
2964
  var GLTFPostProcessor = class {
2964
- constructor() {
2965
- this.baseUri = "";
2966
- this.buffers = [];
2967
- this.images = [];
2968
- }
2965
+ baseUri = "";
2966
+ // @ts-expect-error
2967
+ jsonUnprocessed;
2968
+ // @ts-expect-error
2969
+ json;
2970
+ buffers = [];
2971
+ images = [];
2969
2972
  postProcess(gltf, options = {}) {
2970
2973
  const { json, buffers = [], images = [] } = gltf;
2971
2974
  const { baseUri = "" } = gltf;