@loaders.gl/gltf 3.4.0-alpha.3 → 3.4.0-alpha.5
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.min.js +15 -0
- package/dist/es5/index.js +7 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/es5/lib/api/normalize-gltf-v1.js.map +1 -1
- package/dist/es5/lib/api/post-process-gltf.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_texture_webp.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_binary_gltf.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_texture_basisu.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_texture_transform.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -1
- package/dist/es5/lib/gltf-utils/gltf-utils.js +23 -0
- package/dist/es5/lib/gltf-utils/gltf-utils.js.map +1 -1
- package/dist/es5/lib/gltf-utils/resolve-url.js.map +1 -1
- package/dist/es5/lib/parsers/parse-glb.js.map +1 -1
- package/dist/es5/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/meshopt/meshopt-decoder.js.map +1 -1
- package/dist/es5/webp/webp.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/esm/lib/api/normalize-gltf-v1.js.map +1 -1
- package/dist/esm/lib/api/post-process-gltf.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_texture_webp.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_binary_gltf.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_texture_basisu.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_texture_transform.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -1
- package/dist/esm/lib/gltf-utils/gltf-utils.js +19 -0
- package/dist/esm/lib/gltf-utils/gltf-utils.js.map +1 -1
- package/dist/esm/lib/gltf-utils/resolve-url.js.map +1 -1
- package/dist/esm/lib/parsers/parse-glb.js.map +1 -1
- package/dist/esm/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/meshopt/meshopt-decoder.js.map +1 -1
- package/dist/esm/webp/webp.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/gltf-utils/gltf-utils.d.ts +7 -0
- package/dist/lib/gltf-utils/gltf-utils.d.ts.map +1 -1
- package/dist/lib/gltf-utils/gltf-utils.js +23 -1
- package/package.json +6 -6
- package/src/index.ts +1 -0
- package/src/lib/gltf-utils/gltf-utils.ts +25 -0
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { GLBLoader } from './glb-loader';
|
|
|
6
6
|
export { GLBWriter } from './glb-writer';
|
|
7
7
|
export { default as GLTFScenegraph } from './lib/api/gltf-scenegraph';
|
|
8
8
|
export { postProcessGLTF } from './lib/api/post-process-gltf';
|
|
9
|
+
export { getMemoryUsageGLTF as _getMemoryUsageGLTF } from './lib/gltf-utils/gltf-utils';
|
|
9
10
|
export type { Mesh } from './lib/types/gltf-json-schema';
|
|
10
11
|
export type { GLTFObject } from './lib/types/gltf-types';
|
|
11
12
|
export type { Node, Accessor, Image } from './lib/types/gltf-postprocessed-schema';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,GAAG,EAAC,MAAM,uBAAuB,CAAC;AAC/C,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,wBAAwB,EAExB,oBAAoB,EACpB,+BAA+B,EAC/B,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAC;AACvD,YAAY,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,uCAAuC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,GAAG,EAAC,MAAM,uBAAuB,CAAC;AAC/C,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,wBAAwB,EAExB,oBAAoB,EACpB,+BAA+B,EAC/B,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,kBAAkB,IAAI,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AACtF,YAAY,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAC;AACvD,YAAY,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,uCAAuC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.postProcessGLTF = exports.GLTFScenegraph = exports.GLBWriter = exports.GLBLoader = exports.GLTFWriter = exports.GLTFLoader = void 0;
|
|
6
|
+
exports._getMemoryUsageGLTF = exports.postProcessGLTF = exports.GLTFScenegraph = exports.GLBWriter = exports.GLBLoader = exports.GLTFWriter = exports.GLTFLoader = void 0;
|
|
7
7
|
// glTF loader/writer definition objects
|
|
8
8
|
var gltf_loader_1 = require("./gltf-loader");
|
|
9
9
|
Object.defineProperty(exports, "GLTFLoader", { enumerable: true, get: function () { return gltf_loader_1.GLTFLoader; } });
|
|
@@ -19,3 +19,5 @@ var gltf_scenegraph_1 = require("./lib/api/gltf-scenegraph");
|
|
|
19
19
|
Object.defineProperty(exports, "GLTFScenegraph", { enumerable: true, get: function () { return __importDefault(gltf_scenegraph_1).default; } });
|
|
20
20
|
var post_process_gltf_1 = require("./lib/api/post-process-gltf");
|
|
21
21
|
Object.defineProperty(exports, "postProcessGLTF", { enumerable: true, get: function () { return post_process_gltf_1.postProcessGLTF; } });
|
|
22
|
+
var gltf_utils_1 = require("./lib/gltf-utils/gltf-utils");
|
|
23
|
+
Object.defineProperty(exports, "_getMemoryUsageGLTF", { enumerable: true, get: function () { return gltf_utils_1.getMemoryUsageGLTF; } });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GLTF } from '../types/gltf-types';
|
|
1
2
|
export declare function getAccessorTypeFromSize(size: any): string;
|
|
2
3
|
export declare function getComponentTypeFromArray(typedArray: any): number;
|
|
3
4
|
export declare function getAccessorArrayTypeAndLength(accessor: any, bufferView: any): {
|
|
@@ -5,4 +6,10 @@ export declare function getAccessorArrayTypeAndLength(accessor: any, bufferView:
|
|
|
5
6
|
length: number;
|
|
6
7
|
byteLength: number;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Calculate the GPU memory used by a GLTF tile, for both buffer and texture memory
|
|
11
|
+
* @param gltf - the gltf content of a GLTF tile
|
|
12
|
+
* @returns - total memory usage in bytes
|
|
13
|
+
*/
|
|
14
|
+
export declare function getMemoryUsageGLTF(gltf: GLTF): number;
|
|
8
15
|
//# sourceMappingURL=gltf-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/gltf-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gltf-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/gltf-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAyDzC,wBAAgB,uBAAuB,CAAC,IAAI,KAAA,UAG3C;AAED,wBAAgB,yBAAyB,CAAC,UAAU,KAAA,UAMnD;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA;;;;EAQjE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAiBrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccessorArrayTypeAndLength = exports.getComponentTypeFromArray = exports.getAccessorTypeFromSize = void 0;
|
|
3
|
+
exports.getMemoryUsageGLTF = exports.getAccessorArrayTypeAndLength = exports.getComponentTypeFromArray = exports.getAccessorTypeFromSize = void 0;
|
|
4
4
|
const assert_1 = require("../utils/assert");
|
|
5
5
|
const TYPES = ['SCALAR', 'VEC2', 'VEC3', 'VEC4'];
|
|
6
6
|
const ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
@@ -61,3 +61,25 @@ function getAccessorArrayTypeAndLength(accessor, bufferView) {
|
|
|
61
61
|
return { ArrayType, length, byteLength };
|
|
62
62
|
}
|
|
63
63
|
exports.getAccessorArrayTypeAndLength = getAccessorArrayTypeAndLength;
|
|
64
|
+
/**
|
|
65
|
+
* Calculate the GPU memory used by a GLTF tile, for both buffer and texture memory
|
|
66
|
+
* @param gltf - the gltf content of a GLTF tile
|
|
67
|
+
* @returns - total memory usage in bytes
|
|
68
|
+
*/
|
|
69
|
+
function getMemoryUsageGLTF(gltf) {
|
|
70
|
+
let { images, bufferViews } = gltf;
|
|
71
|
+
images = images || [];
|
|
72
|
+
bufferViews = bufferViews || [];
|
|
73
|
+
const imageBufferViews = images.map((i) => i.bufferView);
|
|
74
|
+
bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
|
|
75
|
+
const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
|
|
76
|
+
// Assume each pixel of the texture is 4 channel with mimmaps (which add 33%)
|
|
77
|
+
// TODO correctly handle compressed textures
|
|
78
|
+
const pixelCount = images.reduce((acc, image) => {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
const { width, height } = image.image;
|
|
81
|
+
return acc + width * height;
|
|
82
|
+
}, 0);
|
|
83
|
+
return bufferMemory + Math.ceil(4 * pixelCount * 1.33);
|
|
84
|
+
}
|
|
85
|
+
exports.getMemoryUsageGLTF = getMemoryUsageGLTF;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/gltf",
|
|
3
|
-
"version": "3.4.0-alpha.
|
|
3
|
+
"version": "3.4.0-alpha.5",
|
|
4
4
|
"description": "Framework-independent loader for the glTF format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@loaders.gl/draco": "3.4.0-alpha.
|
|
38
|
-
"@loaders.gl/images": "3.4.0-alpha.
|
|
39
|
-
"@loaders.gl/loader-utils": "3.4.0-alpha.
|
|
40
|
-
"@loaders.gl/textures": "3.4.0-alpha.
|
|
37
|
+
"@loaders.gl/draco": "3.4.0-alpha.5",
|
|
38
|
+
"@loaders.gl/images": "3.4.0-alpha.5",
|
|
39
|
+
"@loaders.gl/loader-utils": "3.4.0-alpha.5",
|
|
40
|
+
"@loaders.gl/textures": "3.4.0-alpha.5",
|
|
41
41
|
"@math.gl/core": "^3.5.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "686929f85b3420c15df051eab769942b260dd242"
|
|
44
44
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ export {GLBWriter} from './glb-writer';
|
|
|
42
42
|
// glTF Data Access Helper Class
|
|
43
43
|
export {default as GLTFScenegraph} from './lib/api/gltf-scenegraph';
|
|
44
44
|
export {postProcessGLTF} from './lib/api/post-process-gltf';
|
|
45
|
+
export {getMemoryUsageGLTF as _getMemoryUsageGLTF} from './lib/gltf-utils/gltf-utils';
|
|
45
46
|
export type {Mesh} from './lib/types/gltf-json-schema';
|
|
46
47
|
export type {GLTFObject} from './lib/types/gltf-types';
|
|
47
48
|
export type {Node, Accessor, Image} from './lib/types/gltf-postprocessed-schema';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {assert} from '../utils/assert';
|
|
2
|
+
import {GLTF} from '../types/gltf-types';
|
|
2
3
|
|
|
3
4
|
const TYPES = ['SCALAR', 'VEC2', 'VEC3', 'VEC4'];
|
|
4
5
|
|
|
@@ -77,3 +78,27 @@ export function getAccessorArrayTypeAndLength(accessor, bufferView) {
|
|
|
77
78
|
assert(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
78
79
|
return {ArrayType, length, byteLength};
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Calculate the GPU memory used by a GLTF tile, for both buffer and texture memory
|
|
84
|
+
* @param gltf - the gltf content of a GLTF tile
|
|
85
|
+
* @returns - total memory usage in bytes
|
|
86
|
+
*/
|
|
87
|
+
export function getMemoryUsageGLTF(gltf: GLTF): number {
|
|
88
|
+
let {images, bufferViews} = gltf;
|
|
89
|
+
images = images || [];
|
|
90
|
+
bufferViews = bufferViews || [];
|
|
91
|
+
const imageBufferViews = images.map((i) => i.bufferView);
|
|
92
|
+
bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view as any));
|
|
93
|
+
|
|
94
|
+
const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
|
|
95
|
+
|
|
96
|
+
// Assume each pixel of the texture is 4 channel with mimmaps (which add 33%)
|
|
97
|
+
// TODO correctly handle compressed textures
|
|
98
|
+
const pixelCount = images.reduce((acc, image) => {
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
const {width, height} = (image as any).image;
|
|
101
|
+
return acc + width * height;
|
|
102
|
+
}, 0);
|
|
103
|
+
return bufferMemory + Math.ceil(4 * pixelCount * 1.33);
|
|
104
|
+
}
|