@loaders.gl/gltf 4.4.0-alpha.2 → 4.4.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.
- package/dist/dist.dev.js +491 -211
- 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 +92 -56
- 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.d.ts +2 -2
- package/dist/lib/gltf-utils/get-typed-array.d.ts.map +1 -1
- 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.d.ts +2 -1
- package/dist/lib/gltf-utils/resolve-url.d.ts.map +1 -1
- package/dist/lib/gltf-utils/resolve-url.js +15 -4
- 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 +13 -11
- 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 +7 -7
- 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 +19 -4
- package/src/lib/parsers/parse-gltf.ts +16 -13
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.4.0
|
|
1698
|
+
var VERSION = true ? "4.4.0" : "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,20 +1810,31 @@ 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
|
-
function resolveUrl(url, options) {
|
|
1817
|
+
function resolveUrl(url, options, context) {
|
|
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 =
|
|
1823
|
+
const baseUrl = (context == null ? void 0 : context.baseUrl) || getResolveBaseUrl((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.baseUrl);
|
|
1821
1824
|
if (!baseUrl) {
|
|
1822
|
-
throw new Error(`'
|
|
1825
|
+
throw new Error(`'baseUrl' must be provided to resolve relative url ${url}`);
|
|
1823
1826
|
}
|
|
1824
|
-
return baseUrl.
|
|
1827
|
+
return baseUrl.endsWith("/") ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
|
|
1828
|
+
}
|
|
1829
|
+
function getResolveBaseUrl(baseUrl) {
|
|
1830
|
+
if (!baseUrl) {
|
|
1831
|
+
return void 0;
|
|
1832
|
+
}
|
|
1833
|
+
if (baseUrl.endsWith("/")) {
|
|
1834
|
+
return baseUrl;
|
|
1835
|
+
}
|
|
1836
|
+
const slashIndex = baseUrl.lastIndexOf("/");
|
|
1837
|
+
return slashIndex >= 0 ? baseUrl.slice(0, slashIndex + 1) : "";
|
|
1825
1838
|
}
|
|
1826
1839
|
|
|
1827
1840
|
// dist/lib/extensions/EXT_meshopt_compression.js
|
|
@@ -2107,7 +2120,7 @@ __export(KHR_draco_mesh_compression_exports, {
|
|
|
2107
2120
|
name: () => name7,
|
|
2108
2121
|
preprocess: () => preprocess3
|
|
2109
2122
|
});
|
|
2110
|
-
var
|
|
2123
|
+
var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
2111
2124
|
var import_draco = require("@loaders.gl/draco");
|
|
2112
2125
|
|
|
2113
2126
|
// dist/lib/gltf-utils/gltf-attribute-utils.js
|
|
@@ -2207,10 +2220,10 @@ async function decompressPrimitive(scenegraph, primitive, options, context) {
|
|
|
2207
2220
|
return;
|
|
2208
2221
|
}
|
|
2209
2222
|
const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
|
|
2210
|
-
const bufferCopy = (0,
|
|
2223
|
+
const bufferCopy = (0, import_loader_utils5.sliceArrayBuffer)(buffer.buffer, buffer.byteOffset);
|
|
2211
2224
|
const dracoOptions = { ...options };
|
|
2212
2225
|
delete dracoOptions["3d-tiles"];
|
|
2213
|
-
const decodedData = await (0,
|
|
2226
|
+
const decodedData = await (0, import_loader_utils5.parseFromContext)(bufferCopy, import_draco.DracoLoader, dracoOptions, context);
|
|
2214
2227
|
const decodedAttributes = getGLTFAccessors(decodedData.attributes);
|
|
2215
2228
|
for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {
|
|
2216
2229
|
if (attributeName in primitive.attributes) {
|
|
@@ -2277,6 +2290,7 @@ __export(KHR_texture_transform_exports, {
|
|
|
2277
2290
|
name: () => name8
|
|
2278
2291
|
});
|
|
2279
2292
|
var import_core = require("@math.gl/core");
|
|
2293
|
+
var import_loader_utils6 = require("@loaders.gl/loader-utils");
|
|
2280
2294
|
var KHR_TEXTURE_TRANSFORM = "KHR_texture_transform";
|
|
2281
2295
|
var name8 = KHR_TEXTURE_TRANSFORM;
|
|
2282
2296
|
var scratchVector = new import_core.Vector3();
|
|
@@ -2348,7 +2362,7 @@ function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
|
2348
2362
|
const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
|
|
2349
2363
|
if (Number.isFinite(texCoordAccessor)) {
|
|
2350
2364
|
const accessor = (_a = gltfData.json.accessors) == null ? void 0 : _a[texCoordAccessor];
|
|
2351
|
-
if (accessor && accessor.bufferView) {
|
|
2365
|
+
if (accessor && accessor.bufferView !== void 0) {
|
|
2352
2366
|
const bufferView = (_b = gltfData.json.bufferViews) == null ? void 0 : _b[accessor.bufferView];
|
|
2353
2367
|
if (bufferView) {
|
|
2354
2368
|
const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
|
|
@@ -2365,7 +2379,7 @@ function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
|
2365
2379
|
result.set([scratchVector[0], scratchVector[1]], i * components);
|
|
2366
2380
|
}
|
|
2367
2381
|
if (originalTexCoord === texCoord) {
|
|
2368
|
-
updateGltf(accessor,
|
|
2382
|
+
updateGltf(accessor, gltfData, result, accessor.bufferView);
|
|
2369
2383
|
} else {
|
|
2370
2384
|
createAttribute(texCoord, accessor, primitive, gltfData, result);
|
|
2371
2385
|
}
|
|
@@ -2373,28 +2387,49 @@ function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
|
2373
2387
|
}
|
|
2374
2388
|
}
|
|
2375
2389
|
}
|
|
2376
|
-
function updateGltf(accessor,
|
|
2390
|
+
function updateGltf(accessor, gltfData, newTexCoordArray, originalBufferViewIndex) {
|
|
2377
2391
|
accessor.componentType = 5126;
|
|
2378
|
-
|
|
2379
|
-
|
|
2392
|
+
accessor.byteOffset = 0;
|
|
2393
|
+
const accessors = gltfData.json.accessors || [];
|
|
2394
|
+
const bufferViewReferenceCount = accessors.reduce((count, currentAccessor) => {
|
|
2395
|
+
return currentAccessor.bufferView === originalBufferViewIndex ? count + 1 : count;
|
|
2396
|
+
}, 0);
|
|
2397
|
+
const shouldCreateNewBufferView = bufferViewReferenceCount > 1;
|
|
2398
|
+
gltfData.buffers.push({
|
|
2399
|
+
arrayBuffer: (0, import_loader_utils6.ensureArrayBuffer)(newTexCoordArray.buffer),
|
|
2380
2400
|
byteOffset: 0,
|
|
2381
2401
|
byteLength: newTexCoordArray.buffer.byteLength
|
|
2382
2402
|
});
|
|
2383
|
-
|
|
2384
|
-
|
|
2403
|
+
const newBufferIndex = gltfData.buffers.length - 1;
|
|
2404
|
+
gltfData.json.bufferViews = gltfData.json.bufferViews || [];
|
|
2405
|
+
if (shouldCreateNewBufferView) {
|
|
2406
|
+
gltfData.json.bufferViews.push({
|
|
2407
|
+
buffer: newBufferIndex,
|
|
2408
|
+
byteLength: newTexCoordArray.buffer.byteLength,
|
|
2409
|
+
byteOffset: 0
|
|
2410
|
+
});
|
|
2411
|
+
accessor.bufferView = gltfData.json.bufferViews.length - 1;
|
|
2412
|
+
return;
|
|
2413
|
+
}
|
|
2414
|
+
const bufferView = gltfData.json.bufferViews[originalBufferViewIndex];
|
|
2415
|
+
if (!bufferView) {
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2418
|
+
bufferView.buffer = newBufferIndex;
|
|
2385
2419
|
bufferView.byteOffset = 0;
|
|
2386
|
-
|
|
2420
|
+
bufferView.byteLength = newTexCoordArray.buffer.byteLength;
|
|
2421
|
+
if (bufferView.byteStride !== void 0) {
|
|
2422
|
+
delete bufferView.byteStride;
|
|
2423
|
+
}
|
|
2387
2424
|
}
|
|
2388
2425
|
function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, newTexCoordArray) {
|
|
2389
2426
|
gltfData.buffers.push({
|
|
2390
|
-
arrayBuffer: newTexCoordArray.buffer,
|
|
2427
|
+
arrayBuffer: (0, import_loader_utils6.ensureArrayBuffer)(newTexCoordArray.buffer),
|
|
2391
2428
|
byteOffset: 0,
|
|
2392
2429
|
byteLength: newTexCoordArray.buffer.byteLength
|
|
2393
2430
|
});
|
|
2431
|
+
gltfData.json.bufferViews = gltfData.json.bufferViews || [];
|
|
2394
2432
|
const bufferViews = gltfData.json.bufferViews;
|
|
2395
|
-
if (!bufferViews) {
|
|
2396
|
-
return;
|
|
2397
|
-
}
|
|
2398
2433
|
bufferViews.push({
|
|
2399
2434
|
buffer: gltfData.buffers.length - 1,
|
|
2400
2435
|
byteLength: newTexCoordArray.buffer.byteLength,
|
|
@@ -2861,15 +2896,16 @@ async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, con
|
|
|
2861
2896
|
return gltf;
|
|
2862
2897
|
}
|
|
2863
2898
|
function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
2864
|
-
|
|
2865
|
-
|
|
2899
|
+
var _a, _b;
|
|
2900
|
+
if ((_a = options.core) == null ? void 0 : _a.baseUrl) {
|
|
2901
|
+
gltf.baseUri = (_b = options.core) == null ? void 0 : _b.baseUrl;
|
|
2866
2902
|
}
|
|
2867
|
-
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {
|
|
2903
|
+
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
|
|
2868
2904
|
const textDecoder = new TextDecoder();
|
|
2869
2905
|
data = textDecoder.decode(data);
|
|
2870
2906
|
}
|
|
2871
2907
|
if (typeof data === "string") {
|
|
2872
|
-
gltf.json = (0,
|
|
2908
|
+
gltf.json = (0, import_loader_utils7.parseJSON)(data);
|
|
2873
2909
|
} else if (data instanceof ArrayBuffer) {
|
|
2874
2910
|
const glb = {};
|
|
2875
2911
|
byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
|
|
@@ -2900,7 +2936,7 @@ async function loadBuffers(gltf, options, context) {
|
|
|
2900
2936
|
if (buffer.uri) {
|
|
2901
2937
|
const { fetch } = context;
|
|
2902
2938
|
assert(fetch);
|
|
2903
|
-
const uri = resolveUrl(buffer.uri, options);
|
|
2939
|
+
const uri = resolveUrl(buffer.uri, options, context);
|
|
2904
2940
|
const response = await ((_a = context == null ? void 0 : context.fetch) == null ? void 0 : _a.call(context, uri));
|
|
2905
2941
|
const arrayBuffer = await ((_b = response == null ? void 0 : response.arrayBuffer) == null ? void 0 : _b.call(response));
|
|
2906
2942
|
gltf.buffers[i] = {
|
|
@@ -2940,7 +2976,7 @@ function getReferencesImageIndices(gltf) {
|
|
|
2940
2976
|
async function loadImage(gltf, image, index, options, context) {
|
|
2941
2977
|
let arrayBuffer;
|
|
2942
2978
|
if (image.uri && !image.hasOwnProperty("bufferView")) {
|
|
2943
|
-
const uri = resolveUrl(image.uri, options);
|
|
2979
|
+
const uri = resolveUrl(image.uri, options, context);
|
|
2944
2980
|
const { fetch } = context;
|
|
2945
2981
|
const response = await fetch(uri);
|
|
2946
2982
|
arrayBuffer = await response.arrayBuffer();
|
|
@@ -2950,14 +2986,15 @@ async function loadImage(gltf, image, index, options, context) {
|
|
|
2950
2986
|
}
|
|
2951
2987
|
if (Number.isFinite(image.bufferView)) {
|
|
2952
2988
|
const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
|
|
2953
|
-
arrayBuffer = (0,
|
|
2989
|
+
arrayBuffer = (0, import_loader_utils7.sliceArrayBuffer)(array.buffer, array.byteOffset, array.byteLength);
|
|
2954
2990
|
}
|
|
2955
2991
|
assert(arrayBuffer, "glTF image has no data");
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
}
|
|
2992
|
+
const strictOptions = options;
|
|
2993
|
+
const gltfOptions = {
|
|
2994
|
+
...strictOptions,
|
|
2995
|
+
core: { ...strictOptions == null ? void 0 : strictOptions.core, mimeType: image.mimeType }
|
|
2996
|
+
};
|
|
2997
|
+
let parsedImage = await (0, import_loader_utils7.parseFromContext)(arrayBuffer, [import_images4.ImageLoader, import_textures.BasisLoader], gltfOptions, context);
|
|
2961
2998
|
if (parsedImage && parsedImage[0]) {
|
|
2962
2999
|
parsedImage = {
|
|
2963
3000
|
compressed: true,
|
|
@@ -2996,22 +3033,20 @@ var GLTFLoader = {
|
|
|
2996
3033
|
// Create image objects
|
|
2997
3034
|
decompressMeshes: true
|
|
2998
3035
|
// Decompress Draco encoded meshes
|
|
2999
|
-
}
|
|
3000
|
-
// common?
|
|
3001
|
-
log: console
|
|
3002
|
-
// eslint-disable-line
|
|
3036
|
+
}
|
|
3003
3037
|
}
|
|
3004
3038
|
};
|
|
3005
3039
|
async function parse(arrayBuffer, options = {}, context) {
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3040
|
+
var _a;
|
|
3041
|
+
const mergedOptions = { ...GLTFLoader.options, ...options };
|
|
3042
|
+
mergedOptions.gltf = { ...GLTFLoader.options.gltf, ...mergedOptions.gltf };
|
|
3043
|
+
const byteOffset = ((_a = options == null ? void 0 : options.glb) == null ? void 0 : _a.byteOffset) || 0;
|
|
3009
3044
|
const gltf = {};
|
|
3010
|
-
return await parseGLTF(gltf, arrayBuffer, byteOffset,
|
|
3045
|
+
return await parseGLTF(gltf, arrayBuffer, byteOffset, mergedOptions, context);
|
|
3011
3046
|
}
|
|
3012
3047
|
|
|
3013
3048
|
// dist/lib/encoders/encode-glb.js
|
|
3014
|
-
var
|
|
3049
|
+
var import_loader_utils8 = require("@loaders.gl/loader-utils");
|
|
3015
3050
|
var MAGIC_glTF2 = 1179937895;
|
|
3016
3051
|
var MAGIC_JSON = 1313821514;
|
|
3017
3052
|
var MAGIC_BIN = 5130562;
|
|
@@ -3033,7 +3068,7 @@ function encodeGLBSync(glb, dataView, byteOffset = 0, options = {}) {
|
|
|
3033
3068
|
}
|
|
3034
3069
|
byteOffset += 8;
|
|
3035
3070
|
const jsonString = JSON.stringify(json);
|
|
3036
|
-
byteOffset = (0,
|
|
3071
|
+
byteOffset = (0, import_loader_utils8.copyPaddedStringToDataView)(dataView, byteOffset, jsonString, 4);
|
|
3037
3072
|
if (dataView) {
|
|
3038
3073
|
const jsonByteLength = byteOffset - byteOffsetJsonHeader - 8;
|
|
3039
3074
|
dataView.setUint32(byteOffsetJsonHeader + 0, jsonByteLength, LE);
|
|
@@ -3045,7 +3080,7 @@ function encodeGLBSync(glb, dataView, byteOffset = 0, options = {}) {
|
|
|
3045
3080
|
dataView.setUint32(byteOffset + 4, MAGIC_BIN, LE);
|
|
3046
3081
|
}
|
|
3047
3082
|
byteOffset += 8;
|
|
3048
|
-
byteOffset = (0,
|
|
3083
|
+
byteOffset = (0, import_loader_utils8.copyPaddedArrayBufferToDataView)(dataView, byteOffset, binary, 4);
|
|
3049
3084
|
if (dataView) {
|
|
3050
3085
|
const binByteLength = byteOffset - byteOffsetBinHeader - 8;
|
|
3051
3086
|
dataView.setUint32(byteOffsetBinHeader + 0, binByteLength, LE);
|
|
@@ -3122,9 +3157,9 @@ async function parse2(arrayBuffer, options) {
|
|
|
3122
3157
|
return parseSync(arrayBuffer, options);
|
|
3123
3158
|
}
|
|
3124
3159
|
function parseSync(arrayBuffer, options) {
|
|
3125
|
-
|
|
3160
|
+
var _a;
|
|
3126
3161
|
const glb = {};
|
|
3127
|
-
parseGLBSync(glb, arrayBuffer, byteOffset, options == null ? void 0 : options.glb);
|
|
3162
|
+
parseGLBSync(glb, arrayBuffer, ((_a = options == null ? void 0 : options.glb) == null ? void 0 : _a.byteOffset) || 0, options == null ? void 0 : options.glb);
|
|
3128
3163
|
return glb;
|
|
3129
3164
|
}
|
|
3130
3165
|
|
|
@@ -3153,6 +3188,7 @@ function encodeSync2(glb, options) {
|
|
|
3153
3188
|
}
|
|
3154
3189
|
|
|
3155
3190
|
// dist/lib/api/post-process-gltf.js
|
|
3191
|
+
var import_loader_utils9 = require("@loaders.gl/loader-utils");
|
|
3156
3192
|
var COMPONENTS2 = {
|
|
3157
3193
|
SCALAR: 1,
|
|
3158
3194
|
VEC2: 2,
|
|
@@ -3452,7 +3488,7 @@ var GLTFPostProcessor = class {
|
|
|
3452
3488
|
const buffer = accessor.bufferView.buffer;
|
|
3453
3489
|
const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
|
|
3454
3490
|
const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
|
|
3455
|
-
let cutBuffer = buffer.arrayBuffer
|
|
3491
|
+
let cutBuffer = (0, import_loader_utils9.copyToArrayBuffer)(buffer.arrayBuffer, byteOffset, byteLength);
|
|
3456
3492
|
if (accessor.bufferView.byteStride) {
|
|
3457
3493
|
cutBuffer = this._getValueFromInterleavedBuffer(buffer, byteOffset, accessor.bufferView.byteStride, accessor.bytesPerElement, accessor.count);
|
|
3458
3494
|
}
|