@loaders.gl/gltf 4.3.4 → 4.4.0-alpha.10
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 +279 -160
- package/dist/dist.min.js +1 -1
- package/dist/glb-loader.d.ts +9 -6
- package/dist/glb-loader.d.ts.map +1 -1
- package/dist/glb-loader.js +2 -2
- package/dist/glb-loader.js.map +1 -0
- package/dist/glb-writer.js +1 -0
- package/dist/glb-writer.js.map +1 -0
- package/dist/gltf-loader.d.ts +2 -3
- package/dist/gltf-loader.d.ts.map +1 -1
- package/dist/gltf-loader.js +6 -8
- package/dist/gltf-loader.js.map +1 -0
- package/dist/gltf-writer.js +1 -0
- package/dist/gltf-writer.js.map +1 -0
- package/dist/index.cjs +78 -51
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api/gltf-extensions.js +1 -0
- package/dist/lib/api/gltf-extensions.js.map +1 -0
- package/dist/lib/api/gltf-scenegraph.js +1 -0
- package/dist/lib/api/gltf-scenegraph.js.map +1 -0
- package/dist/lib/api/normalize-gltf-v1.js +1 -0
- package/dist/lib/api/normalize-gltf-v1.js.map +1 -0
- package/dist/lib/api/post-process-gltf.d.ts.map +1 -1
- package/dist/lib/api/post-process-gltf.js +3 -1
- package/dist/lib/api/post-process-gltf.js.map +1 -0
- package/dist/lib/encoders/encode-glb.js +1 -0
- package/dist/lib/encoders/encode-glb.js.map +1 -0
- package/dist/lib/encoders/encode-gltf.js +1 -0
- package/dist/lib/encoders/encode-gltf.js.map +1 -0
- package/dist/lib/extensions/EXT_mesh_features.js +1 -0
- package/dist/lib/extensions/EXT_mesh_features.js.map +1 -0
- package/dist/lib/extensions/EXT_meshopt_compression.js +1 -0
- package/dist/lib/extensions/EXT_meshopt_compression.js.map +1 -0
- package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_structural_metadata.js +3 -1
- package/dist/lib/extensions/EXT_structural_metadata.js.map +1 -0
- package/dist/lib/extensions/EXT_texture_webp.js +1 -0
- package/dist/lib/extensions/EXT_texture_webp.js.map +1 -0
- package/dist/lib/extensions/KHR_binary_gltf.js +1 -0
- package/dist/lib/extensions/KHR_binary_gltf.js.map +1 -0
- package/dist/lib/extensions/KHR_draco_mesh_compression.js +1 -0
- package/dist/lib/extensions/KHR_draco_mesh_compression.js.map +1 -0
- package/dist/lib/extensions/KHR_texture_basisu.js +1 -0
- package/dist/lib/extensions/KHR_texture_basisu.js.map +1 -0
- package/dist/lib/extensions/KHR_texture_transform.d.ts.map +1 -1
- package/dist/lib/extensions/KHR_texture_transform.js +36 -14
- package/dist/lib/extensions/KHR_texture_transform.js.map +1 -0
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js +1 -0
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -0
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.js +1 -0
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.js +1 -0
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js +1 -0
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
- package/dist/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -1
- package/dist/lib/extensions/utils/3d-tiles-utils.js +3 -1
- package/dist/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
- package/dist/lib/gltf-utils/get-typed-array.js +1 -0
- package/dist/lib/gltf-utils/get-typed-array.js.map +1 -0
- package/dist/lib/gltf-utils/gltf-attribute-utils.js +1 -0
- package/dist/lib/gltf-utils/gltf-attribute-utils.js.map +1 -0
- package/dist/lib/gltf-utils/gltf-constants.js +1 -0
- package/dist/lib/gltf-utils/gltf-constants.js.map +1 -0
- package/dist/lib/gltf-utils/gltf-utils.js +1 -0
- package/dist/lib/gltf-utils/gltf-utils.js.map +1 -0
- package/dist/lib/gltf-utils/resolve-url.js +2 -1
- package/dist/lib/gltf-utils/resolve-url.js.map +1 -0
- package/dist/lib/parsers/parse-glb.js +1 -0
- package/dist/lib/parsers/parse-glb.js.map +1 -0
- package/dist/lib/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-gltf.js +11 -8
- package/dist/lib/parsers/parse-gltf.js.map +1 -0
- package/dist/lib/types/glb-types.js +1 -0
- package/dist/lib/types/glb-types.js.map +1 -0
- package/dist/lib/types/gltf-ext-feature-metadata-schema.js +1 -0
- package/dist/lib/types/gltf-ext-feature-metadata-schema.js.map +1 -0
- package/dist/lib/types/gltf-ext-mesh-features-schema.js +1 -0
- package/dist/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
- package/dist/lib/types/gltf-ext-structural-metadata-schema.js +1 -0
- package/dist/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
- package/dist/lib/types/gltf-json-schema.js +1 -0
- package/dist/lib/types/gltf-json-schema.js.map +1 -0
- package/dist/lib/types/gltf-postprocessed-schema.js +1 -0
- package/dist/lib/types/gltf-postprocessed-schema.js.map +1 -0
- package/dist/lib/types/gltf-types.js +1 -0
- package/dist/lib/types/gltf-types.js.map +1 -0
- package/dist/lib/utils/assert.js +1 -0
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/lib/utils/version.js +2 -1
- package/dist/lib/utils/version.js.map +1 -0
- package/dist/meshopt/meshopt-decoder.js +1 -0
- package/dist/meshopt/meshopt-decoder.js.map +1 -0
- package/dist/webp/webp.js +1 -0
- package/dist/webp/webp.js.map +1 -0
- package/package.json +8 -8
- package/src/glb-loader.ts +10 -8
- package/src/gltf-loader.ts +8 -12
- package/src/lib/api/post-process-gltf.ts +3 -2
- package/src/lib/extensions/EXT_structural_metadata.ts +2 -1
- package/src/lib/extensions/KHR_texture_transform.ts +41 -17
- package/src/lib/extensions/utils/3d-tiles-utils.ts +2 -1
- package/src/lib/gltf-utils/resolve-url.ts +1 -1
- package/src/lib/parsers/parse-gltf.ts +14 -10
package/dist/gltf-loader.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StrictLoaderOptions } 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';
|
|
@@ -8,7 +8,7 @@ import type { GLBLoaderOptions } from "./glb-loader.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* GLTF loader options
|
|
10
10
|
*/
|
|
11
|
-
export type GLTFLoaderOptions =
|
|
11
|
+
export type GLTFLoaderOptions = StrictLoaderOptions & ImageLoaderOptions & TextureLoaderOptions & GLBLoaderOptions & DracoLoaderOptions & {
|
|
12
12
|
gltf?: ParseGLTFOptions;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
@@ -34,7 +34,6 @@ export declare const GLTFLoader: {
|
|
|
34
34
|
readonly loadImages: true;
|
|
35
35
|
readonly decompressMeshes: true;
|
|
36
36
|
};
|
|
37
|
-
readonly log: Console;
|
|
38
37
|
};
|
|
39
38
|
};
|
|
40
39
|
export declare function parse(arrayBuffer: any, options: GLTFLoaderOptions | undefined, context: any): Promise<GLTFWithBuffers>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-loader.d.ts","sourceRoot":"","sources":["../src/gltf-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,
|
|
1
|
+
{"version":3,"file":"gltf-loader.d.ts","sourceRoot":"","sources":["../src/gltf-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AACpF,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;AACH,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GACjD,kBAAkB,GAClB,oBAAoB,GACpB,gBAAgB,GAChB,kBAAkB,GAAG;IACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,UAAU;uBACQ,eAAe;wBACzB,KAAK;;;;;;;;;;;;;;;;;;;CAqBsD,CAAC;AAEjF,wBAAsB,KAAK,CACzB,WAAW,KAAA,EACX,OAAO,EAAE,iBAAiB,YAAK,EAC/B,OAAO,KAAA,GACN,OAAO,CAAC,eAAe,CAAC,CAQ1B"}
|
package/dist/gltf-loader.js
CHANGED
|
@@ -22,17 +22,15 @@ export const GLTFLoader = {
|
|
|
22
22
|
loadBuffers: true, // Fetch any linked .BIN buffers, decode base64
|
|
23
23
|
loadImages: true, // Create image objects
|
|
24
24
|
decompressMeshes: true // Decompress Draco encoded meshes
|
|
25
|
-
}
|
|
26
|
-
// common?
|
|
27
|
-
log: console // eslint-disable-line
|
|
25
|
+
}
|
|
28
26
|
}
|
|
29
27
|
};
|
|
30
28
|
export async function parse(arrayBuffer, options = {}, context) {
|
|
31
29
|
// Apps can call the parse method directly, we so apply default options here
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const { byteOffset = 0 } = options;
|
|
30
|
+
const mergedOptions = { ...GLTFLoader.options, ...options };
|
|
31
|
+
mergedOptions.gltf = { ...GLTFLoader.options.gltf, ...mergedOptions.gltf };
|
|
32
|
+
const byteOffset = options?.glb?.byteOffset || 0;
|
|
36
33
|
const gltf = {};
|
|
37
|
-
return await parseGLTF(gltf, arrayBuffer, byteOffset,
|
|
34
|
+
return await parseGLTF(gltf, arrayBuffer, byteOffset, mergedOptions, context);
|
|
38
35
|
}
|
|
36
|
+
//# sourceMappingURL=gltf-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-loader.js","sourceRoot":"","sources":["../src/gltf-loader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,+BAA4B;AAM5C,OAAO,EAAC,SAAS,EAAC,oCAAiC;AAanD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,IAAkC;IAC5C,SAAS,EAAE,IAAa;IACxB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,MAAM;IACV,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IAC3B,SAAS,EAAE,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;IAEnD,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,CAAC,MAAM,CAAC;IACf,KAAK;IAEL,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE,IAAI,EAAE,uDAAuD;YACxE,WAAW,EAAE,IAAI,EAAE,+CAA+C;YAClE,UAAU,EAAE,IAAI,EAAE,uBAAuB;YACzC,gBAAgB,EAAE,IAAI,CAAC,kCAAkC;SAC1D;KACF;CAC6E,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,WAAW,EACX,UAA6B,EAAE,EAC/B,OAAO;IAEP,4EAA4E;IAC5E,MAAM,aAAa,GAAG,EAAC,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,OAAO,EAAC,CAAC;IAC1D,aAAa,CAAC,IAAI,GAAG,EAAC,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,aAAa,CAAC,IAAI,EAAC,CAAC;IAEzE,MAAM,UAAU,GAAG,OAAO,EAAE,GAAG,EAAE,UAAU,IAAI,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,OAAO,MAAM,SAAS,CAAC,IAAuB,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AACnG,CAAC"}
|
package/dist/gltf-writer.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-writer.js","sourceRoot":"","sources":["../src/gltf-writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,+BAA4B;AAC5C,OAAO,EAAC,cAAc,EAAC,sCAAmC;AAE1D,OAAO,EAAC,gBAAgB,EAAC,qCAAkC;AAO3D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,IAAsB;IAChC,SAAS,EAAE,IAAa;IAExB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,MAAM;IACV,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,OAAO;IAEhB,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,2DAA2D;IAChF,SAAS,EAAE,CAAC,mBAAmB,CAAC,EAAE,qBAAqB;IACvD,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE;QACP,IAAI,EAAE,EAAE;KACT;IAED,MAAM,EAAE,KAAK,EAAE,IAAqB,EAAE,UAA6B,EAAE,EAAE,EAAE,CACvE,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;IAC3B,UAAU;CACyC,CAAC;AAEtD,SAAS,UAAU,CAAC,IAAqB,EAAE,UAA6B,EAAE;IACxE,MAAM,EAAC,UAAU,GAAG,CAAC,EAAC,GAAG,OAAO,CAAC;IACjC,MAAM,YAAY,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE5C,uDAAuD;IACvD,MAAM,UAAU,GAAG,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC3E,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC3C,cAAc,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAE5D,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -720,6 +720,7 @@ var GLTFScenegraph = class {
|
|
|
720
720
|
|
|
721
721
|
// dist/lib/extensions/utils/3d-tiles-utils.js
|
|
722
722
|
var import_images2 = require("@loaders.gl/images");
|
|
723
|
+
var import_loader_utils2 = require("@loaders.gl/loader-utils");
|
|
723
724
|
function emod(n) {
|
|
724
725
|
return (n % 1 + 1) % 1;
|
|
725
726
|
}
|
|
@@ -793,7 +794,7 @@ function convertRawBufferToMetadataArray(data, attributeType, componentType, ele
|
|
|
793
794
|
buffer = bufferArray.slice(offset, offset + byteLength).buffer;
|
|
794
795
|
offset = 0;
|
|
795
796
|
}
|
|
796
|
-
return new ArrayType(buffer, offset, length);
|
|
797
|
+
return new ArrayType((0, import_loader_utils2.ensureArrayBuffer)(buffer), offset, length);
|
|
797
798
|
}
|
|
798
799
|
function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
|
|
799
800
|
var _a, _b, _c, _d, _e;
|
|
@@ -1055,6 +1056,7 @@ __export(EXT_structural_metadata_exports, {
|
|
|
1055
1056
|
encode: () => encode2,
|
|
1056
1057
|
name: () => name2
|
|
1057
1058
|
});
|
|
1059
|
+
var import_loader_utils3 = require("@loaders.gl/loader-utils");
|
|
1058
1060
|
var EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
|
|
1059
1061
|
var name2 = EXT_STRUCTURAL_METADATA_NAME;
|
|
1060
1062
|
async function decode2(gltfData, options) {
|
|
@@ -1480,7 +1482,7 @@ function createPropertyDataString(strings) {
|
|
|
1480
1482
|
}
|
|
1481
1483
|
function createBufferView(typedArray, scenegraph) {
|
|
1482
1484
|
scenegraph.gltf.buffers.push({
|
|
1483
|
-
arrayBuffer: typedArray.buffer,
|
|
1485
|
+
arrayBuffer: (0, import_loader_utils3.ensureArrayBuffer)(typedArray.buffer),
|
|
1484
1486
|
byteOffset: typedArray.byteOffset,
|
|
1485
1487
|
byteLength: typedArray.byteLength
|
|
1486
1488
|
});
|
|
@@ -1693,15 +1695,15 @@ function processPrimitiveTextures(scenegraph, attributeName, featureTexturePrope
|
|
|
1693
1695
|
}
|
|
1694
1696
|
|
|
1695
1697
|
// dist/lib/utils/version.js
|
|
1696
|
-
var VERSION = true ? "4.
|
|
1698
|
+
var VERSION = true ? "4.4.0-alpha.10" : "latest";
|
|
1697
1699
|
|
|
1698
1700
|
// dist/lib/parsers/parse-gltf.js
|
|
1699
|
-
var
|
|
1701
|
+
var import_loader_utils7 = require("@loaders.gl/loader-utils");
|
|
1700
1702
|
var import_images4 = require("@loaders.gl/images");
|
|
1701
1703
|
var import_textures = require("@loaders.gl/textures");
|
|
1702
1704
|
|
|
1703
1705
|
// dist/lib/parsers/parse-glb.js
|
|
1704
|
-
var
|
|
1706
|
+
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
1705
1707
|
var LITTLE_ENDIAN = true;
|
|
1706
1708
|
var MAGIC_glTF = 1735152710;
|
|
1707
1709
|
var GLB_FILE_HEADER_SIZE = 12;
|
|
@@ -1749,18 +1751,18 @@ function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
|
|
|
1749
1751
|
}
|
|
1750
1752
|
}
|
|
1751
1753
|
function parseGLBV1(glb, dataView, byteOffset) {
|
|
1752
|
-
(0,
|
|
1754
|
+
(0, import_loader_utils4.assert)(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
1753
1755
|
const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN);
|
|
1754
1756
|
const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN);
|
|
1755
1757
|
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
1756
|
-
(0,
|
|
1758
|
+
(0, import_loader_utils4.assert)(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
|
|
1757
1759
|
parseJSONChunk(glb, dataView, byteOffset, contentLength);
|
|
1758
1760
|
byteOffset += contentLength;
|
|
1759
1761
|
byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
|
|
1760
1762
|
return byteOffset;
|
|
1761
1763
|
}
|
|
1762
1764
|
function parseGLBV2(glb, dataView, byteOffset, options) {
|
|
1763
|
-
(0,
|
|
1765
|
+
(0, import_loader_utils4.assert)(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
1764
1766
|
parseGLBChunksSync(glb, dataView, byteOffset, options);
|
|
1765
1767
|
return byteOffset + glb.header.byteLength;
|
|
1766
1768
|
}
|
|
@@ -1789,7 +1791,7 @@ function parseGLBChunksSync(glb, dataView, byteOffset, options) {
|
|
|
1789
1791
|
default:
|
|
1790
1792
|
break;
|
|
1791
1793
|
}
|
|
1792
|
-
byteOffset += (0,
|
|
1794
|
+
byteOffset += (0, import_loader_utils4.padToNBytes)(chunkLength, 4);
|
|
1793
1795
|
}
|
|
1794
1796
|
return byteOffset;
|
|
1795
1797
|
}
|
|
@@ -1798,7 +1800,7 @@ function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
|
|
|
1798
1800
|
const textDecoder = new TextDecoder("utf8");
|
|
1799
1801
|
const jsonText = textDecoder.decode(jsonChunk);
|
|
1800
1802
|
glb.json = JSON.parse(jsonText);
|
|
1801
|
-
return (0,
|
|
1803
|
+
return (0, import_loader_utils4.padToNBytes)(chunkLength, 4);
|
|
1802
1804
|
}
|
|
1803
1805
|
function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
|
|
1804
1806
|
glb.header.hasBinChunk = true;
|
|
@@ -1808,16 +1810,17 @@ function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
|
|
|
1808
1810
|
arrayBuffer: dataView.buffer
|
|
1809
1811
|
// TODO - copy, or create typed array view?
|
|
1810
1812
|
});
|
|
1811
|
-
return (0,
|
|
1813
|
+
return (0, import_loader_utils4.padToNBytes)(chunkLength, 4);
|
|
1812
1814
|
}
|
|
1813
1815
|
|
|
1814
1816
|
// dist/lib/gltf-utils/resolve-url.js
|
|
1815
1817
|
function resolveUrl(url, options) {
|
|
1818
|
+
var _a;
|
|
1816
1819
|
const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
|
|
1817
1820
|
if (absolute) {
|
|
1818
1821
|
return url;
|
|
1819
1822
|
}
|
|
1820
|
-
const baseUrl = options.baseUri || options.uri;
|
|
1823
|
+
const baseUrl = ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.baseUri) || options.baseUri || options.uri;
|
|
1821
1824
|
if (!baseUrl) {
|
|
1822
1825
|
throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
|
|
1823
1826
|
}
|
|
@@ -2107,7 +2110,7 @@ __export(KHR_draco_mesh_compression_exports, {
|
|
|
2107
2110
|
name: () => name7,
|
|
2108
2111
|
preprocess: () => preprocess3
|
|
2109
2112
|
});
|
|
2110
|
-
var
|
|
2113
|
+
var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
2111
2114
|
var import_draco = require("@loaders.gl/draco");
|
|
2112
2115
|
|
|
2113
2116
|
// dist/lib/gltf-utils/gltf-attribute-utils.js
|
|
@@ -2207,10 +2210,10 @@ async function decompressPrimitive(scenegraph, primitive, options, context) {
|
|
|
2207
2210
|
return;
|
|
2208
2211
|
}
|
|
2209
2212
|
const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
|
|
2210
|
-
const bufferCopy = (0,
|
|
2213
|
+
const bufferCopy = (0, import_loader_utils5.sliceArrayBuffer)(buffer.buffer, buffer.byteOffset);
|
|
2211
2214
|
const dracoOptions = { ...options };
|
|
2212
2215
|
delete dracoOptions["3d-tiles"];
|
|
2213
|
-
const decodedData = await (0,
|
|
2216
|
+
const decodedData = await (0, import_loader_utils5.parseFromContext)(bufferCopy, import_draco.DracoLoader, dracoOptions, context);
|
|
2214
2217
|
const decodedAttributes = getGLTFAccessors(decodedData.attributes);
|
|
2215
2218
|
for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {
|
|
2216
2219
|
if (attributeName in primitive.attributes) {
|
|
@@ -2277,6 +2280,7 @@ __export(KHR_texture_transform_exports, {
|
|
|
2277
2280
|
name: () => name8
|
|
2278
2281
|
});
|
|
2279
2282
|
var import_core = require("@math.gl/core");
|
|
2283
|
+
var import_loader_utils6 = require("@loaders.gl/loader-utils");
|
|
2280
2284
|
var KHR_TEXTURE_TRANSFORM = "KHR_texture_transform";
|
|
2281
2285
|
var name8 = KHR_TEXTURE_TRANSFORM;
|
|
2282
2286
|
var scratchVector = new import_core.Vector3();
|
|
@@ -2348,7 +2352,7 @@ function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
|
2348
2352
|
const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
|
|
2349
2353
|
if (Number.isFinite(texCoordAccessor)) {
|
|
2350
2354
|
const accessor = (_a = gltfData.json.accessors) == null ? void 0 : _a[texCoordAccessor];
|
|
2351
|
-
if (accessor && accessor.bufferView) {
|
|
2355
|
+
if (accessor && accessor.bufferView !== void 0) {
|
|
2352
2356
|
const bufferView = (_b = gltfData.json.bufferViews) == null ? void 0 : _b[accessor.bufferView];
|
|
2353
2357
|
if (bufferView) {
|
|
2354
2358
|
const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
|
|
@@ -2365,7 +2369,7 @@ function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
|
2365
2369
|
result.set([scratchVector[0], scratchVector[1]], i * components);
|
|
2366
2370
|
}
|
|
2367
2371
|
if (originalTexCoord === texCoord) {
|
|
2368
|
-
updateGltf(accessor,
|
|
2372
|
+
updateGltf(accessor, gltfData, result, accessor.bufferView);
|
|
2369
2373
|
} else {
|
|
2370
2374
|
createAttribute(texCoord, accessor, primitive, gltfData, result);
|
|
2371
2375
|
}
|
|
@@ -2373,28 +2377,49 @@ function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
|
2373
2377
|
}
|
|
2374
2378
|
}
|
|
2375
2379
|
}
|
|
2376
|
-
function updateGltf(accessor,
|
|
2380
|
+
function updateGltf(accessor, gltfData, newTexCoordArray, originalBufferViewIndex) {
|
|
2377
2381
|
accessor.componentType = 5126;
|
|
2378
|
-
|
|
2379
|
-
|
|
2382
|
+
accessor.byteOffset = 0;
|
|
2383
|
+
const accessors = gltfData.json.accessors || [];
|
|
2384
|
+
const bufferViewReferenceCount = accessors.reduce((count, currentAccessor) => {
|
|
2385
|
+
return currentAccessor.bufferView === originalBufferViewIndex ? count + 1 : count;
|
|
2386
|
+
}, 0);
|
|
2387
|
+
const shouldCreateNewBufferView = bufferViewReferenceCount > 1;
|
|
2388
|
+
gltfData.buffers.push({
|
|
2389
|
+
arrayBuffer: (0, import_loader_utils6.ensureArrayBuffer)(newTexCoordArray.buffer),
|
|
2380
2390
|
byteOffset: 0,
|
|
2381
2391
|
byteLength: newTexCoordArray.buffer.byteLength
|
|
2382
2392
|
});
|
|
2383
|
-
|
|
2384
|
-
|
|
2393
|
+
const newBufferIndex = gltfData.buffers.length - 1;
|
|
2394
|
+
gltfData.json.bufferViews = gltfData.json.bufferViews || [];
|
|
2395
|
+
if (shouldCreateNewBufferView) {
|
|
2396
|
+
gltfData.json.bufferViews.push({
|
|
2397
|
+
buffer: newBufferIndex,
|
|
2398
|
+
byteLength: newTexCoordArray.buffer.byteLength,
|
|
2399
|
+
byteOffset: 0
|
|
2400
|
+
});
|
|
2401
|
+
accessor.bufferView = gltfData.json.bufferViews.length - 1;
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
const bufferView = gltfData.json.bufferViews[originalBufferViewIndex];
|
|
2405
|
+
if (!bufferView) {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
bufferView.buffer = newBufferIndex;
|
|
2385
2409
|
bufferView.byteOffset = 0;
|
|
2386
|
-
|
|
2410
|
+
bufferView.byteLength = newTexCoordArray.buffer.byteLength;
|
|
2411
|
+
if (bufferView.byteStride !== void 0) {
|
|
2412
|
+
delete bufferView.byteStride;
|
|
2413
|
+
}
|
|
2387
2414
|
}
|
|
2388
2415
|
function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, newTexCoordArray) {
|
|
2389
2416
|
gltfData.buffers.push({
|
|
2390
|
-
arrayBuffer: newTexCoordArray.buffer,
|
|
2417
|
+
arrayBuffer: (0, import_loader_utils6.ensureArrayBuffer)(newTexCoordArray.buffer),
|
|
2391
2418
|
byteOffset: 0,
|
|
2392
2419
|
byteLength: newTexCoordArray.buffer.byteLength
|
|
2393
2420
|
});
|
|
2421
|
+
gltfData.json.bufferViews = gltfData.json.bufferViews || [];
|
|
2394
2422
|
const bufferViews = gltfData.json.bufferViews;
|
|
2395
|
-
if (!bufferViews) {
|
|
2396
|
-
return;
|
|
2397
|
-
}
|
|
2398
2423
|
bufferViews.push({
|
|
2399
2424
|
buffer: gltfData.buffers.length - 1,
|
|
2400
2425
|
byteLength: newTexCoordArray.buffer.byteLength,
|
|
@@ -2861,15 +2886,16 @@ async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, con
|
|
|
2861
2886
|
return gltf;
|
|
2862
2887
|
}
|
|
2863
2888
|
function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
2864
|
-
|
|
2865
|
-
|
|
2889
|
+
var _a, _b;
|
|
2890
|
+
if ((_a = options.core) == null ? void 0 : _a.baseUri) {
|
|
2891
|
+
gltf.baseUri = (_b = options.core) == null ? void 0 : _b.baseUri;
|
|
2866
2892
|
}
|
|
2867
|
-
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {
|
|
2893
|
+
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
|
|
2868
2894
|
const textDecoder = new TextDecoder();
|
|
2869
2895
|
data = textDecoder.decode(data);
|
|
2870
2896
|
}
|
|
2871
2897
|
if (typeof data === "string") {
|
|
2872
|
-
gltf.json = (0,
|
|
2898
|
+
gltf.json = (0, import_loader_utils7.parseJSON)(data);
|
|
2873
2899
|
} else if (data instanceof ArrayBuffer) {
|
|
2874
2900
|
const glb = {};
|
|
2875
2901
|
byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
|
|
@@ -2950,14 +2976,16 @@ async function loadImage(gltf, image, index, options, context) {
|
|
|
2950
2976
|
}
|
|
2951
2977
|
if (Number.isFinite(image.bufferView)) {
|
|
2952
2978
|
const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
|
|
2953
|
-
arrayBuffer = (0,
|
|
2979
|
+
arrayBuffer = (0, import_loader_utils7.sliceArrayBuffer)(array.buffer, array.byteOffset, array.byteLength);
|
|
2954
2980
|
}
|
|
2955
2981
|
assert(arrayBuffer, "glTF image has no data");
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2982
|
+
const strictOptions = options;
|
|
2983
|
+
const gltfOptions = {
|
|
2984
|
+
...strictOptions,
|
|
2985
|
+
core: { ...strictOptions == null ? void 0 : strictOptions.core, mimeType: image.mimeType },
|
|
2986
|
+
basis: strictOptions.basis || { format: (0, import_textures.selectSupportedBasisFormat)() }
|
|
2987
|
+
};
|
|
2988
|
+
let parsedImage = await (0, import_loader_utils7.parseFromContext)(arrayBuffer, [import_images4.ImageLoader, import_textures.BasisLoader], gltfOptions, context);
|
|
2961
2989
|
if (parsedImage && parsedImage[0]) {
|
|
2962
2990
|
parsedImage = {
|
|
2963
2991
|
compressed: true,
|
|
@@ -2996,22 +3024,20 @@ var GLTFLoader = {
|
|
|
2996
3024
|
// Create image objects
|
|
2997
3025
|
decompressMeshes: true
|
|
2998
3026
|
// Decompress Draco encoded meshes
|
|
2999
|
-
}
|
|
3000
|
-
// common?
|
|
3001
|
-
log: console
|
|
3002
|
-
// eslint-disable-line
|
|
3027
|
+
}
|
|
3003
3028
|
}
|
|
3004
3029
|
};
|
|
3005
3030
|
async function parse(arrayBuffer, options = {}, context) {
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3031
|
+
var _a;
|
|
3032
|
+
const mergedOptions = { ...GLTFLoader.options, ...options };
|
|
3033
|
+
mergedOptions.gltf = { ...GLTFLoader.options.gltf, ...mergedOptions.gltf };
|
|
3034
|
+
const byteOffset = ((_a = options == null ? void 0 : options.glb) == null ? void 0 : _a.byteOffset) || 0;
|
|
3009
3035
|
const gltf = {};
|
|
3010
|
-
return await parseGLTF(gltf, arrayBuffer, byteOffset,
|
|
3036
|
+
return await parseGLTF(gltf, arrayBuffer, byteOffset, mergedOptions, context);
|
|
3011
3037
|
}
|
|
3012
3038
|
|
|
3013
3039
|
// dist/lib/encoders/encode-glb.js
|
|
3014
|
-
var
|
|
3040
|
+
var import_loader_utils8 = require("@loaders.gl/loader-utils");
|
|
3015
3041
|
var MAGIC_glTF2 = 1179937895;
|
|
3016
3042
|
var MAGIC_JSON = 1313821514;
|
|
3017
3043
|
var MAGIC_BIN = 5130562;
|
|
@@ -3033,7 +3059,7 @@ function encodeGLBSync(glb, dataView, byteOffset = 0, options = {}) {
|
|
|
3033
3059
|
}
|
|
3034
3060
|
byteOffset += 8;
|
|
3035
3061
|
const jsonString = JSON.stringify(json);
|
|
3036
|
-
byteOffset = (0,
|
|
3062
|
+
byteOffset = (0, import_loader_utils8.copyPaddedStringToDataView)(dataView, byteOffset, jsonString, 4);
|
|
3037
3063
|
if (dataView) {
|
|
3038
3064
|
const jsonByteLength = byteOffset - byteOffsetJsonHeader - 8;
|
|
3039
3065
|
dataView.setUint32(byteOffsetJsonHeader + 0, jsonByteLength, LE);
|
|
@@ -3045,7 +3071,7 @@ function encodeGLBSync(glb, dataView, byteOffset = 0, options = {}) {
|
|
|
3045
3071
|
dataView.setUint32(byteOffset + 4, MAGIC_BIN, LE);
|
|
3046
3072
|
}
|
|
3047
3073
|
byteOffset += 8;
|
|
3048
|
-
byteOffset = (0,
|
|
3074
|
+
byteOffset = (0, import_loader_utils8.copyPaddedArrayBufferToDataView)(dataView, byteOffset, binary, 4);
|
|
3049
3075
|
if (dataView) {
|
|
3050
3076
|
const binByteLength = byteOffset - byteOffsetBinHeader - 8;
|
|
3051
3077
|
dataView.setUint32(byteOffsetBinHeader + 0, binByteLength, LE);
|
|
@@ -3122,9 +3148,9 @@ async function parse2(arrayBuffer, options) {
|
|
|
3122
3148
|
return parseSync(arrayBuffer, options);
|
|
3123
3149
|
}
|
|
3124
3150
|
function parseSync(arrayBuffer, options) {
|
|
3125
|
-
|
|
3151
|
+
var _a;
|
|
3126
3152
|
const glb = {};
|
|
3127
|
-
parseGLBSync(glb, arrayBuffer, byteOffset, options == null ? void 0 : options.glb);
|
|
3153
|
+
parseGLBSync(glb, arrayBuffer, ((_a = options == null ? void 0 : options.glb) == null ? void 0 : _a.byteOffset) || 0, options == null ? void 0 : options.glb);
|
|
3128
3154
|
return glb;
|
|
3129
3155
|
}
|
|
3130
3156
|
|
|
@@ -3153,6 +3179,7 @@ function encodeSync2(glb, options) {
|
|
|
3153
3179
|
}
|
|
3154
3180
|
|
|
3155
3181
|
// dist/lib/api/post-process-gltf.js
|
|
3182
|
+
var import_loader_utils9 = require("@loaders.gl/loader-utils");
|
|
3156
3183
|
var COMPONENTS2 = {
|
|
3157
3184
|
SCALAR: 1,
|
|
3158
3185
|
VEC2: 2,
|
|
@@ -3452,7 +3479,7 @@ var GLTFPostProcessor = class {
|
|
|
3452
3479
|
const buffer = accessor.bufferView.buffer;
|
|
3453
3480
|
const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
|
|
3454
3481
|
const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
|
|
3455
|
-
let cutBuffer = buffer.arrayBuffer
|
|
3482
|
+
let cutBuffer = (0, import_loader_utils9.copyToArrayBuffer)(buffer.arrayBuffer, byteOffset, byteLength);
|
|
3456
3483
|
if (accessor.bufferView.byteStride) {
|
|
3457
3484
|
cutBuffer = this._getValueFromInterleavedBuffer(buffer, byteOffset, accessor.bufferView.byteStride, accessor.bytesPerElement, accessor.count);
|
|
3458
3485
|
}
|