@loaders.gl/gltf 4.0.2 → 4.0.4
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 +7 -4
- package/dist/glb-writer.d.ts +2 -3
- package/dist/glb-writer.d.ts.map +1 -1
- package/dist/glb-writer.js +0 -1
- package/dist/glb-writer.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/lib/gltf-utils/get-typed-array.js +1 -1
- package/dist/lib/gltf-utils/get-typed-array.js.map +1 -1
- package/package.json +6 -6
- package/src/glb-writer.ts +2 -5
- package/src/lib/gltf-utils/get-typed-array.ts +1 -1
package/dist/dist.dev.js
CHANGED
|
@@ -97,7 +97,7 @@ var __exports__ = (() => {
|
|
|
97
97
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
98
98
|
|
|
99
99
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
100
|
-
var NPM_TAG = "
|
|
100
|
+
var NPM_TAG = "latest";
|
|
101
101
|
function getVersion() {
|
|
102
102
|
if (!globalThis._loadersgl_?.version) {
|
|
103
103
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
@@ -424,7 +424,10 @@ var __exports__ = (() => {
|
|
|
424
424
|
return await new Promise((resolve, reject) => {
|
|
425
425
|
try {
|
|
426
426
|
image.onload = () => resolve(image);
|
|
427
|
-
image.onerror = (
|
|
427
|
+
image.onerror = (error) => {
|
|
428
|
+
const message = error instanceof Error ? error.message : "error";
|
|
429
|
+
reject(new Error(message));
|
|
430
|
+
};
|
|
428
431
|
} catch (error) {
|
|
429
432
|
reject(error);
|
|
430
433
|
}
|
|
@@ -833,7 +836,7 @@ var __exports__ = (() => {
|
|
|
833
836
|
function getTypedArrayForAccessor(json, buffers, accessor) {
|
|
834
837
|
const gltfAccessor = typeof accessor === "number" ? json.accessors?.[accessor] : accessor;
|
|
835
838
|
if (!gltfAccessor) {
|
|
836
|
-
throw new Error(`No gltf accessor ${accessor}`);
|
|
839
|
+
throw new Error(`No gltf accessor ${JSON.stringify(accessor)}`);
|
|
837
840
|
}
|
|
838
841
|
const bufferView = json.bufferViews?.[gltfAccessor.bufferView || 0];
|
|
839
842
|
if (!bufferView) {
|
|
@@ -3162,7 +3165,7 @@ var __exports__ = (() => {
|
|
|
3162
3165
|
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
3163
3166
|
|
|
3164
3167
|
// ../textures/src/lib/utils/version.ts
|
|
3165
|
-
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
3168
|
+
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
3166
3169
|
|
|
3167
3170
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
3168
3171
|
var BASIS_EXTERNAL_LIBRARIES = {
|
package/dist/glb-writer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WriterWithEncoder, WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { GLB } from './lib/types/glb-types';
|
|
3
3
|
import type { GLBEncodeOptions } from './lib/encoders/encode-glb';
|
|
4
4
|
export type GLBWriterOptions = WriterOptions & {
|
|
@@ -8,6 +8,5 @@ export type GLBWriterOptions = WriterOptions & {
|
|
|
8
8
|
* GLB exporter
|
|
9
9
|
* GLB is the binary container format for GLTF
|
|
10
10
|
*/
|
|
11
|
-
export declare const GLBWriter:
|
|
12
|
-
export declare const _TypecheckGLBLoader: Writer;
|
|
11
|
+
export declare const GLBWriter: WriterWithEncoder<GLB, never, GLBWriterOptions>;
|
|
13
12
|
//# sourceMappingURL=glb-writer.d.ts.map
|
package/dist/glb-writer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glb-writer.d.ts","sourceRoot":"","sources":["../src/glb-writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"glb-writer.d.ts","sourceRoot":"","sources":["../src/glb-writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;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"}
|
package/dist/glb-writer.js
CHANGED
package/dist/glb-writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glb-writer.js","names":["encodeGLBSync","VERSION","GLBWriter","name","id","module","version","extensions","mimeTypes","binary","options","glb","encode","arguments","length","undefined","encodeSync","byteOffset","byteLength","arrayBuffer","ArrayBuffer","dataView","DataView"
|
|
1
|
+
{"version":3,"file":"glb-writer.js","names":["encodeGLBSync","VERSION","GLBWriter","name","id","module","version","extensions","mimeTypes","binary","options","glb","encode","arguments","length","undefined","encodeSync","byteOffset","byteLength","arrayBuffer","ArrayBuffer","dataView","DataView"],"sources":["../src/glb-writer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';\nimport type {GLB} from './lib/types/glb-types';\nimport type {GLBEncodeOptions} from './lib/encoders/encode-glb';\nimport {encodeGLBSync} from './lib/encoders/encode-glb';\nimport {VERSION} from './lib/utils/version';\n\nexport type GLBWriterOptions = WriterOptions & {\n glb?: GLBEncodeOptions;\n};\n\n/**\n * GLB exporter\n * GLB is the binary container format for GLTF\n */\nexport const GLBWriter: WriterWithEncoder<GLB, never, GLBWriterOptions> = {\n name: 'GLB',\n id: 'glb',\n module: 'gltf',\n version: VERSION,\n\n extensions: ['glb'],\n mimeTypes: ['model/gltf-binary'],\n binary: true,\n options: {\n glb: {}\n },\n\n encode: async (glb, options: GLBWriterOptions = {}) => encodeSync(glb, options),\n encodeSync\n};\n\nfunction encodeSync(glb, options) {\n const {byteOffset = 0} = options;\n\n // Calculate length and allocate buffer\n const byteLength = encodeGLBSync(glb, null, byteOffset, options);\n const arrayBuffer = new ArrayBuffer(byteLength);\n\n // Encode into buffer\n const dataView = new DataView(arrayBuffer);\n encodeGLBSync(glb, dataView, byteOffset, options);\n\n return arrayBuffer;\n}\n"],"mappings":"SAMQA,aAAa;AAAA,SACbC,OAAO;AAUf,OAAO,MAAMC,SAA0D,GAAG;EACxEC,IAAI,EAAE,KAAK;EACXC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEL,OAAO;EAEhBM,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,mBAAmB,CAAC;EAChCC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;EACR,CAAC;EAEDC,MAAM,EAAE,eAAAA,CAAOD,GAAG;IAAA,IAAED,OAAyB,GAAAG,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,OAAKG,UAAU,CAACL,GAAG,EAAED,OAAO,CAAC;EAAA;EAC/EM;AACF,CAAC;AAED,SAASA,UAAUA,CAACL,GAAG,EAAED,OAAO,EAAE;EAChC,MAAM;IAACO,UAAU,GAAG;EAAC,CAAC,GAAGP,OAAO;EAGhC,MAAMQ,UAAU,GAAGlB,aAAa,CAACW,GAAG,EAAE,IAAI,EAAEM,UAAU,EAAEP,OAAO,CAAC;EAChE,MAAMS,WAAW,GAAG,IAAIC,WAAW,CAACF,UAAU,CAAC;EAG/C,MAAMG,QAAQ,GAAG,IAAIC,QAAQ,CAACH,WAAW,CAAC;EAC1CnB,aAAa,CAACW,GAAG,EAAEU,QAAQ,EAAEJ,UAAU,EAAEP,OAAO,CAAC;EAEjD,OAAOS,WAAW;AACpB"}
|
package/dist/index.cjs
CHANGED
|
@@ -166,7 +166,7 @@ function getTypedArrayForAccessor(json, buffers, accessor) {
|
|
|
166
166
|
var _a, _b;
|
|
167
167
|
const gltfAccessor = typeof accessor === "number" ? (_a = json.accessors) == null ? void 0 : _a[accessor] : accessor;
|
|
168
168
|
if (!gltfAccessor) {
|
|
169
|
-
throw new Error(`No gltf accessor ${accessor}`);
|
|
169
|
+
throw new Error(`No gltf accessor ${JSON.stringify(accessor)}`);
|
|
170
170
|
}
|
|
171
171
|
const bufferView = (_b = json.bufferViews) == null ? void 0 : _b[gltfAccessor.bufferView || 0];
|
|
172
172
|
if (!bufferView) {
|
|
@@ -18,7 +18,7 @@ export function getTypedArrayForAccessor(json, buffers, accessor) {
|
|
|
18
18
|
var _json$accessors, _json$bufferViews;
|
|
19
19
|
const gltfAccessor = typeof accessor === 'number' ? (_json$accessors = json.accessors) === null || _json$accessors === void 0 ? void 0 : _json$accessors[accessor] : accessor;
|
|
20
20
|
if (!gltfAccessor) {
|
|
21
|
-
throw new Error(`No gltf accessor ${accessor}`);
|
|
21
|
+
throw new Error(`No gltf accessor ${JSON.stringify(accessor)}`);
|
|
22
22
|
}
|
|
23
23
|
const bufferView = (_json$bufferViews = json.bufferViews) === null || _json$bufferViews === void 0 ? void 0 : _json$bufferViews[gltfAccessor.bufferView || 0];
|
|
24
24
|
if (!bufferView) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-typed-array.js","names":["assert","getAccessorArrayTypeAndLength","getTypedArrayForBufferView","json","buffers","bufferViewIndex","bufferView","bufferViews","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","byteLength","getTypedArrayForImageData","imageIndex","image","images","getTypedArrayForAccessor","accessor","_json$accessors","_json$bufferViews","gltfAccessor","accessors","Error","bufferByteOffset","ArrayType","length","componentByteSize","numberOfComponentsInElement","elementByteSize","elementAddressScale","byteStride","result","i","count","values","set"],"sources":["../../../src/lib/gltf-utils/get-typed-array.ts"],"sourcesContent":["// TODO - GLTFScenegraph should use these\nimport {assert} from '../utils/assert';\nimport type {TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFExternalBuffer, GLTFAccessor} from '../types/gltf-types';\nimport {getAccessorArrayTypeAndLength} from './gltf-utils';\n\n// accepts buffer view index or buffer view object\n// returns a `Uint8Array`\nexport function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {\n const bufferView = json.bufferViews[bufferViewIndex];\n assert(bufferView);\n\n // Get hold of the arrayBuffer\n const bufferIndex = bufferView.buffer;\n const binChunk = buffers[bufferIndex];\n assert(binChunk);\n\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n}\n\n// accepts accessor index or accessor object\n// returns a `Uint8Array`\nexport function getTypedArrayForImageData(json, buffers, imageIndex) {\n const image = json.images[imageIndex];\n const bufferViewIndex = json.bufferViews[image.bufferView];\n return getTypedArrayForBufferView(json, buffers, bufferViewIndex);\n}\n\n/**\n * Gets data pointed by the accessor.\n * @param json - json part of gltf content of a GLTF tile.\n * @param buffers - Array containing buffers of data.\n * @param accessor - accepts accessor index or accessor object.\n * @returns {TypedArray} Typed array with type matching the type of data poited by the accessor.\n */\n// eslint-disable-next-line complexity\nexport function getTypedArrayForAccessor(\n json: GLTF,\n buffers: GLTFExternalBuffer[],\n accessor: GLTFAccessor | number\n): TypedArray {\n const gltfAccessor = typeof accessor === 'number' ? json.accessors?.[accessor] : accessor;\n if (!gltfAccessor) {\n throw new Error(`No gltf accessor ${accessor}`);\n }\n const bufferView = json.bufferViews?.[gltfAccessor.bufferView || 0];\n if (!bufferView) {\n throw new Error(`No gltf buffer view for accessor ${bufferView}`);\n }\n // Get `arrayBuffer` the `bufferView` looks at\n const {arrayBuffer, byteOffset: bufferByteOffset} = buffers[bufferView.buffer];\n // Resulting byteOffset is sum of the buffer, accessor and bufferView byte offsets\n const byteOffset =\n (bufferByteOffset || 0) + (gltfAccessor.byteOffset || 0) + (bufferView.byteOffset || 0);\n // Deduce TypedArray type and its length from `accessor` and `bufferView` data\n const {ArrayType, length, componentByteSize, numberOfComponentsInElement} =\n getAccessorArrayTypeAndLength(gltfAccessor, bufferView);\n // 'length' is a whole number of components of all elements in the buffer pointed by the accessor\n // Multiplier to calculate the address of the element in the arrayBuffer\n const elementByteSize = componentByteSize * numberOfComponentsInElement;\n const elementAddressScale = bufferView.byteStride || elementByteSize;\n // Creare an array of component's type where all components (not just elements) will reside\n if (typeof bufferView.byteStride === 'undefined' || bufferView.byteStride === elementByteSize) {\n // No iterleaving\n const result: TypedArray = new ArrayType(arrayBuffer, byteOffset, length);\n return result;\n }\n // Iterleaving\n const result: TypedArray = new ArrayType(length);\n for (let i = 0; i < gltfAccessor.count; i++) {\n const values = new ArrayType(\n arrayBuffer,\n byteOffset + i * elementAddressScale,\n numberOfComponentsInElement\n );\n result.set(values, i * numberOfComponentsInElement);\n }\n return result;\n}\n"],"mappings":"SACQA,MAAM;AAAA,SAGNC,6BAA6B;AAIrC,OAAO,SAASC,0BAA0BA,CAACC,IAAI,EAAEC,OAAO,EAAEC,eAAe,EAAE;EACzE,MAAMC,UAAU,GAAGH,IAAI,CAACI,WAAW,CAACF,eAAe,CAAC;EACpDL,MAAM,CAACM,UAAU,CAAC;EAGlB,MAAME,WAAW,GAAGF,UAAU,CAACG,MAAM;EACrC,MAAMC,QAAQ,GAAGN,OAAO,CAACI,WAAW,CAAC;EACrCR,MAAM,CAACU,QAAQ,CAAC;EAEhB,MAAMC,UAAU,GAAG,CAACL,UAAU,CAACK,UAAU,IAAI,CAAC,IAAID,QAAQ,CAACC,UAAU;EACrE,OAAO,IAAIC,UAAU,CAACF,QAAQ,CAACG,WAAW,EAAEF,UAAU,EAAEL,UAAU,CAACQ,UAAU,CAAC;AAChF;AAIA,OAAO,SAASC,yBAAyBA,CAACZ,IAAI,EAAEC,OAAO,EAAEY,UAAU,EAAE;EACnE,MAAMC,KAAK,GAAGd,IAAI,CAACe,MAAM,CAACF,UAAU,CAAC;EACrC,MAAMX,eAAe,GAAGF,IAAI,CAACI,WAAW,CAACU,KAAK,CAACX,UAAU,CAAC;EAC1D,OAAOJ,0BAA0B,CAACC,IAAI,EAAEC,OAAO,EAAEC,eAAe,CAAC;AACnE;AAUA,OAAO,SAASc,wBAAwBA,CACtChB,IAAU,EACVC,OAA6B,EAC7BgB,QAA+B,EACnB;EAAA,IAAAC,eAAA,EAAAC,iBAAA;EACZ,MAAMC,YAAY,GAAG,OAAOH,QAAQ,KAAK,QAAQ,IAAAC,eAAA,GAAGlB,IAAI,CAACqB,SAAS,cAAAH,eAAA,uBAAdA,eAAA,CAAiBD,QAAQ,CAAC,GAAGA,QAAQ;EACzF,IAAI,CAACG,YAAY,EAAE;IACjB,MAAM,IAAIE,KAAK,CAAE,
|
|
1
|
+
{"version":3,"file":"get-typed-array.js","names":["assert","getAccessorArrayTypeAndLength","getTypedArrayForBufferView","json","buffers","bufferViewIndex","bufferView","bufferViews","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","byteLength","getTypedArrayForImageData","imageIndex","image","images","getTypedArrayForAccessor","accessor","_json$accessors","_json$bufferViews","gltfAccessor","accessors","Error","JSON","stringify","bufferByteOffset","ArrayType","length","componentByteSize","numberOfComponentsInElement","elementByteSize","elementAddressScale","byteStride","result","i","count","values","set"],"sources":["../../../src/lib/gltf-utils/get-typed-array.ts"],"sourcesContent":["// TODO - GLTFScenegraph should use these\nimport {assert} from '../utils/assert';\nimport type {TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFExternalBuffer, GLTFAccessor} from '../types/gltf-types';\nimport {getAccessorArrayTypeAndLength} from './gltf-utils';\n\n// accepts buffer view index or buffer view object\n// returns a `Uint8Array`\nexport function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {\n const bufferView = json.bufferViews[bufferViewIndex];\n assert(bufferView);\n\n // Get hold of the arrayBuffer\n const bufferIndex = bufferView.buffer;\n const binChunk = buffers[bufferIndex];\n assert(binChunk);\n\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n}\n\n// accepts accessor index or accessor object\n// returns a `Uint8Array`\nexport function getTypedArrayForImageData(json, buffers, imageIndex) {\n const image = json.images[imageIndex];\n const bufferViewIndex = json.bufferViews[image.bufferView];\n return getTypedArrayForBufferView(json, buffers, bufferViewIndex);\n}\n\n/**\n * Gets data pointed by the accessor.\n * @param json - json part of gltf content of a GLTF tile.\n * @param buffers - Array containing buffers of data.\n * @param accessor - accepts accessor index or accessor object.\n * @returns {TypedArray} Typed array with type matching the type of data poited by the accessor.\n */\n// eslint-disable-next-line complexity\nexport function getTypedArrayForAccessor(\n json: GLTF,\n buffers: GLTFExternalBuffer[],\n accessor: GLTFAccessor | number\n): TypedArray {\n const gltfAccessor = typeof accessor === 'number' ? json.accessors?.[accessor] : accessor;\n if (!gltfAccessor) {\n throw new Error(`No gltf accessor ${JSON.stringify(accessor)}`);\n }\n const bufferView = json.bufferViews?.[gltfAccessor.bufferView || 0];\n if (!bufferView) {\n throw new Error(`No gltf buffer view for accessor ${bufferView}`);\n }\n // Get `arrayBuffer` the `bufferView` looks at\n const {arrayBuffer, byteOffset: bufferByteOffset} = buffers[bufferView.buffer];\n // Resulting byteOffset is sum of the buffer, accessor and bufferView byte offsets\n const byteOffset =\n (bufferByteOffset || 0) + (gltfAccessor.byteOffset || 0) + (bufferView.byteOffset || 0);\n // Deduce TypedArray type and its length from `accessor` and `bufferView` data\n const {ArrayType, length, componentByteSize, numberOfComponentsInElement} =\n getAccessorArrayTypeAndLength(gltfAccessor, bufferView);\n // 'length' is a whole number of components of all elements in the buffer pointed by the accessor\n // Multiplier to calculate the address of the element in the arrayBuffer\n const elementByteSize = componentByteSize * numberOfComponentsInElement;\n const elementAddressScale = bufferView.byteStride || elementByteSize;\n // Creare an array of component's type where all components (not just elements) will reside\n if (typeof bufferView.byteStride === 'undefined' || bufferView.byteStride === elementByteSize) {\n // No iterleaving\n const result: TypedArray = new ArrayType(arrayBuffer, byteOffset, length);\n return result;\n }\n // Iterleaving\n const result: TypedArray = new ArrayType(length);\n for (let i = 0; i < gltfAccessor.count; i++) {\n const values = new ArrayType(\n arrayBuffer,\n byteOffset + i * elementAddressScale,\n numberOfComponentsInElement\n );\n result.set(values, i * numberOfComponentsInElement);\n }\n return result;\n}\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/gltf",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Framework-independent loader for the glTF format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"build-bundle": "ocular-bundle ./src/index.ts"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@loaders.gl/draco": "4.0.
|
|
46
|
-
"@loaders.gl/images": "4.0.
|
|
47
|
-
"@loaders.gl/loader-utils": "4.0.
|
|
48
|
-
"@loaders.gl/textures": "4.0.
|
|
45
|
+
"@loaders.gl/draco": "4.0.4",
|
|
46
|
+
"@loaders.gl/images": "4.0.4",
|
|
47
|
+
"@loaders.gl/loader-utils": "4.0.4",
|
|
48
|
+
"@loaders.gl/textures": "4.0.4",
|
|
49
49
|
"@math.gl/core": "^4.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "4dc810fa04bb400f4aedfef98a83c7ef882ed3d7"
|
|
52
52
|
}
|
package/src/glb-writer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
// Copyright (c) vis.gl contributors
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';
|
|
5
5
|
import type {GLB} from './lib/types/glb-types';
|
|
6
6
|
import type {GLBEncodeOptions} from './lib/encoders/encode-glb';
|
|
7
7
|
import {encodeGLBSync} from './lib/encoders/encode-glb';
|
|
@@ -15,7 +15,7 @@ export type GLBWriterOptions = WriterOptions & {
|
|
|
15
15
|
* GLB exporter
|
|
16
16
|
* GLB is the binary container format for GLTF
|
|
17
17
|
*/
|
|
18
|
-
export const GLBWriter:
|
|
18
|
+
export const GLBWriter: WriterWithEncoder<GLB, never, GLBWriterOptions> = {
|
|
19
19
|
name: 'GLB',
|
|
20
20
|
id: 'glb',
|
|
21
21
|
module: 'gltf',
|
|
@@ -45,6 +45,3 @@ function encodeSync(glb, options) {
|
|
|
45
45
|
|
|
46
46
|
return arrayBuffer;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
// TYPE TESTS - TODO find a better way than exporting junk
|
|
50
|
-
export const _TypecheckGLBLoader: Writer = GLBWriter;
|
|
@@ -42,7 +42,7 @@ export function getTypedArrayForAccessor(
|
|
|
42
42
|
): TypedArray {
|
|
43
43
|
const gltfAccessor = typeof accessor === 'number' ? json.accessors?.[accessor] : accessor;
|
|
44
44
|
if (!gltfAccessor) {
|
|
45
|
-
throw new Error(`No gltf accessor ${accessor}`);
|
|
45
|
+
throw new Error(`No gltf accessor ${JSON.stringify(accessor)}`);
|
|
46
46
|
}
|
|
47
47
|
const bufferView = json.bufferViews?.[gltfAccessor.bufferView || 0];
|
|
48
48
|
if (!bufferView) {
|