@loaders.gl/gltf 4.0.0-alpha.4 → 4.0.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.
Files changed (98) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/dist.min.js +4541 -0
  4. package/dist/glb-loader.d.ts +13 -0
  5. package/dist/glb-loader.d.ts.map +1 -0
  6. package/dist/glb-writer.d.ts +22 -0
  7. package/dist/glb-writer.d.ts.map +1 -0
  8. package/dist/gltf-loader.d.ts +18 -0
  9. package/dist/gltf-loader.d.ts.map +1 -0
  10. package/dist/gltf-writer.d.ts +25 -0
  11. package/dist/gltf-writer.d.ts.map +1 -0
  12. package/dist/index.d.ts +11 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/lib/api/gltf-extensions.d.ts +26 -0
  16. package/dist/lib/api/gltf-extensions.d.ts.map +1 -0
  17. package/dist/lib/api/gltf-scenegraph.d.ts +183 -0
  18. package/dist/lib/api/gltf-scenegraph.d.ts.map +1 -0
  19. package/dist/lib/api/gltf-scenegraph.js.map +1 -1
  20. package/dist/lib/api/normalize-gltf-v1.d.ts +2 -0
  21. package/dist/lib/api/normalize-gltf-v1.d.ts.map +1 -0
  22. package/dist/lib/api/normalize-gltf-v1.js +6 -3
  23. package/dist/lib/api/normalize-gltf-v1.js.map +1 -1
  24. package/dist/lib/api/post-process-gltf.d.ts +2 -0
  25. package/dist/lib/api/post-process-gltf.d.ts.map +1 -0
  26. package/dist/lib/api/post-process-gltf.js +37 -7
  27. package/dist/lib/api/post-process-gltf.js.map +1 -1
  28. package/dist/lib/encoders/encode-glb.d.ts +2 -0
  29. package/dist/lib/encoders/encode-glb.d.ts.map +1 -0
  30. package/dist/lib/encoders/encode-glb.js.map +1 -1
  31. package/dist/lib/encoders/encode-gltf.d.ts +2 -0
  32. package/dist/lib/encoders/encode-gltf.d.ts.map +1 -0
  33. package/dist/lib/encoders/encode-gltf.js.map +1 -1
  34. package/dist/lib/extensions/EXT_meshopt_compression.d.ts +10 -0
  35. package/dist/lib/extensions/EXT_meshopt_compression.d.ts.map +1 -0
  36. package/dist/lib/extensions/EXT_texture_webp.d.ts +12 -0
  37. package/dist/lib/extensions/EXT_texture_webp.d.ts.map +1 -0
  38. package/dist/lib/extensions/KHR_binary_gltf.d.ts +7 -0
  39. package/dist/lib/extensions/KHR_binary_gltf.d.ts.map +1 -0
  40. package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts +13 -0
  41. package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts.map +1 -0
  42. package/dist/lib/extensions/KHR_texture_basisu.d.ts +12 -0
  43. package/dist/lib/extensions/KHR_texture_basisu.d.ts.map +1 -0
  44. package/dist/lib/extensions/KHR_texture_basisu.js.map +1 -1
  45. package/dist/lib/extensions/deprecated/KHR_lights_punctual.d.ts +7 -0
  46. package/dist/lib/extensions/deprecated/KHR_lights_punctual.d.ts.map +1 -0
  47. package/dist/lib/extensions/deprecated/KHR_materials_unlit.d.ts +7 -0
  48. package/dist/lib/extensions/deprecated/KHR_materials_unlit.d.ts.map +1 -0
  49. package/dist/lib/extensions/deprecated/KHR_techniques_webgl.d.ts +7 -0
  50. package/dist/lib/extensions/deprecated/KHR_techniques_webgl.d.ts.map +1 -0
  51. package/dist/lib/gltf-utils/get-typed-array.d.ts +3 -0
  52. package/dist/lib/gltf-utils/get-typed-array.d.ts.map +1 -0
  53. package/dist/lib/gltf-utils/gltf-attribute-utils.d.ts +6 -0
  54. package/dist/lib/gltf-utils/gltf-attribute-utils.d.ts.map +1 -0
  55. package/dist/lib/gltf-utils/gltf-constants.d.ts +4 -0
  56. package/dist/lib/gltf-utils/gltf-constants.d.ts.map +1 -0
  57. package/dist/lib/gltf-utils/gltf-utils.d.ts +8 -0
  58. package/dist/lib/gltf-utils/gltf-utils.d.ts.map +1 -0
  59. package/dist/lib/gltf-utils/resolve-url.d.ts +2 -0
  60. package/dist/lib/gltf-utils/resolve-url.d.ts.map +1 -0
  61. package/dist/lib/parsers/parse-glb.d.ts +8 -0
  62. package/dist/lib/parsers/parse-glb.d.ts.map +1 -0
  63. package/dist/lib/parsers/parse-gltf.d.ts +14 -0
  64. package/dist/lib/parsers/parse-gltf.d.ts.map +1 -0
  65. package/dist/lib/parsers/parse-gltf.js +2 -2
  66. package/dist/lib/parsers/parse-gltf.js.map +1 -1
  67. package/dist/lib/types/glb-types.d.ts +17 -0
  68. package/dist/lib/types/glb-types.d.ts.map +1 -0
  69. package/dist/lib/types/gltf-json-schema.d.ts +720 -0
  70. package/dist/lib/types/gltf-json-schema.d.ts.map +1 -0
  71. package/dist/lib/types/gltf-postprocessed-schema.d.ts +686 -0
  72. package/dist/lib/types/gltf-postprocessed-schema.d.ts.map +1 -0
  73. package/dist/lib/types/gltf-types.d.ts +11 -0
  74. package/dist/lib/types/gltf-types.d.ts.map +1 -0
  75. package/dist/lib/utils/assert.d.ts +2 -0
  76. package/dist/lib/utils/assert.d.ts.map +1 -0
  77. package/dist/lib/utils/assert.js.map +1 -1
  78. package/dist/lib/utils/version.d.ts +2 -0
  79. package/dist/lib/utils/version.d.ts.map +1 -0
  80. package/dist/lib/utils/version.js +1 -1
  81. package/dist/lib/utils/version.js.map +1 -1
  82. package/dist/meshopt/meshopt-decoder.d.ts +6 -0
  83. package/dist/meshopt/meshopt-decoder.d.ts.map +1 -0
  84. package/dist/webp/webp.d.ts +7 -0
  85. package/dist/webp/webp.d.ts.map +1 -0
  86. package/package.json +8 -11
  87. package/src/index.ts +1 -0
  88. package/src/lib/api/gltf-scenegraph.ts +2 -2
  89. package/src/lib/api/{normalize-gltf-v1.js → normalize-gltf-v1.ts} +18 -16
  90. package/src/lib/api/{post-process-gltf.js → post-process-gltf.ts} +52 -9
  91. package/src/lib/encoders/{encode-glb.js → encode-glb.ts} +0 -0
  92. package/src/lib/encoders/{encode-gltf.js → encode-gltf.ts} +0 -0
  93. package/src/lib/extensions/KHR_texture_basisu.ts +2 -2
  94. package/src/lib/parsers/parse-gltf.ts +2 -2
  95. package/src/lib/types/gltf-postprocessed-schema.ts +3 -2
  96. package/src/lib/types/gltf-types.ts +4 -1
  97. package/src/lib/utils/{assert.js → assert.ts} +1 -1
  98. /package/src/lib/utils/{version.js → version.ts} +0 -0
@@ -0,0 +1,13 @@
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { GLBParseOptions } from './lib/parsers/parse-glb';
3
+ export declare type GLBLoaderOptions = LoaderOptions & {
4
+ glb?: GLBParseOptions;
5
+ byteOffset?: number;
6
+ };
7
+ /**
8
+ * GLB Loader -
9
+ * GLB is the binary container format for GLTF
10
+ */
11
+ export declare const GLBLoader: LoaderWithParser;
12
+ export declare const _TypecheckGLBLoader: LoaderWithParser;
13
+ //# sourceMappingURL=glb-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glb-loader.d.ts","sourceRoot":"","sources":["../src/glb-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAI7D,oBAAY,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,gBAevB,CAAC;AAcF,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Writer } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * GLB exporter
4
+ * GLB is the binary container format for GLTF
5
+ */
6
+ export declare const GLBWriter: {
7
+ name: string;
8
+ id: string;
9
+ module: string;
10
+ version: any;
11
+ extensions: string[];
12
+ mimeTypes: string[];
13
+ binary: boolean;
14
+ encodeSync: typeof encodeSync;
15
+ options: {
16
+ glb: {};
17
+ };
18
+ };
19
+ declare function encodeSync(glb: any, options: any): ArrayBuffer;
20
+ export declare const _TypecheckGLBLoader: Writer;
21
+ export {};
22
+ //# sourceMappingURL=glb-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glb-writer.d.ts","sourceRoot":"","sources":["../src/glb-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;CAerB,CAAC;AAEF,iBAAS,UAAU,CAAC,GAAG,KAAA,EAAE,OAAO,KAAA,eAY/B;AAGD,eAAO,MAAM,mBAAmB,EAAE,MAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { DracoLoaderOptions } from '@loaders.gl/draco';
3
+ import type { ImageLoaderOptions } from '@loaders.gl/images';
4
+ import type { TextureLoaderOptions } from '@loaders.gl/textures';
5
+ import type { GLTFParseOptions } from './lib/parsers/parse-gltf';
6
+ import { GLBLoaderOptions } from './glb-loader';
7
+ /**
8
+ * GLTF loader options
9
+ */
10
+ export declare type GLTFLoaderOptions = LoaderOptions & ImageLoaderOptions & TextureLoaderOptions & GLBLoaderOptions & DracoLoaderOptions & {
11
+ gltf?: GLTFParseOptions;
12
+ };
13
+ /**
14
+ * GLTF loader
15
+ */
16
+ export declare const GLTFLoader: LoaderWithParser;
17
+ export declare function parse(arrayBuffer: any, options: GLTFLoaderOptions | undefined, context: any): Promise<Record<string, any>>;
18
+ //# sourceMappingURL=gltf-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltf-loader.d.ts","sourceRoot":"","sources":["../src/gltf-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,oBAAY,iBAAiB,GAAG,aAAa,GAC3C,kBAAkB,GAClB,oBAAoB,GACpB,gBAAgB,GAChB,kBAAkB,GAAG;IACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,gBAkCxB,CAAC;AAEF,wBAAsB,KAAK,CAAC,WAAW,KAAA,EAAE,OAAO,+BAAwB,EAAE,OAAO,KAAA,gCAShF"}
@@ -0,0 +1,25 @@
1
+ import type { Writer } from '@loaders.gl/loader-utils';
2
+ export declare type GLTFWriterOptions = {
3
+ gltf?: {};
4
+ byteOffset?: number;
5
+ };
6
+ /**
7
+ * GLTF exporter
8
+ */
9
+ export declare const GLTFWriter: {
10
+ name: string;
11
+ id: string;
12
+ module: string;
13
+ version: any;
14
+ extensions: string[];
15
+ mimeTypes: string[];
16
+ binary: boolean;
17
+ encodeSync: typeof encodeSync;
18
+ options: {
19
+ gltf: {};
20
+ };
21
+ };
22
+ declare function encodeSync(gltf: any, options?: GLTFWriterOptions): ArrayBuffer;
23
+ export declare const _TypecheckGLBLoader: Writer;
24
+ export {};
25
+ //# sourceMappingURL=gltf-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltf-writer.d.ts","sourceRoot":"","sources":["../src/gltf-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;CAetB,CAAC;AAEF,iBAAS,UAAU,CAAC,IAAI,KAAA,EAAE,OAAO,GAAE,iBAAsB,eAUxD;AAGD,eAAO,MAAM,mBAAmB,EAAE,MAAmB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type { GLB } from './lib/types/glb-types';
2
+ export type { GLTF, GLTFAccessor, GLTFBuffer, GLTFBufferView, GLTFMeshPrimitive, GLTFMesh, GLTFNode, GLTFMaterial, GLTFSampler, GLTFScene, GLTFSkin, GLTFTexture, GLTFImage, GLTFImagePostprocessed, GLTF_KHR_binary_glTF, GLTF_KHR_draco_mesh_compression, GLTF_KHR_texture_basisu, GLTF_EXT_meshopt_compression, GLTF_EXT_texture_webp } from './lib/types/gltf-types';
3
+ export { GLTFLoader } from './gltf-loader';
4
+ export { GLTFWriter } from './gltf-writer';
5
+ export { GLBLoader } from './glb-loader';
6
+ export { GLBWriter } from './glb-writer';
7
+ export { default as GLTFScenegraph } from './lib/api/gltf-scenegraph';
8
+ export { postProcessGLTF } from './lib/api/post-process-gltf';
9
+ export type { Mesh } from './lib/types/gltf-json-schema';
10
+ export type { GLTFObject } from './lib/types/gltf-types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,sBAAsB,EAEtB,oBAAoB,EACpB,+BAA+B,EAC/B,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,EACtB,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"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["GLTFLoader","GLTFWriter","GLBLoader","GLBWriter","default","GLTFScenegraph","postProcessGLTF"],"mappings":"AAyBA,SAAQA,UAAR,QAAyB,eAAzB;AACA,SAAQC,UAAR,QAAyB,eAAzB;AAGA,SAAQC,SAAR,QAAwB,cAAxB;AACA,SAAQC,SAAR,QAAwB,cAAxB;AAGA,SAAQC,OAAO,IAAIC,cAAnB,QAAwC,2BAAxC;AACA,SAAQC,eAAR,QAA8B,6BAA9B","sourcesContent":["/* eslint-disable camelcase, indent */\nexport type {GLB} from './lib/types/glb-types';\nexport type {\n GLTF,\n GLTFAccessor,\n GLTFBuffer,\n GLTFBufferView,\n GLTFMeshPrimitive,\n GLTFMesh,\n GLTFNode,\n GLTFMaterial,\n GLTFSampler,\n GLTFScene,\n GLTFSkin,\n GLTFTexture,\n GLTFImage,\n // The following extensions are handled by the GLTFLoader and removed from the parsed glTF (disable via options.gltf.excludeExtensions)\n GLTF_KHR_binary_glTF,\n GLTF_KHR_draco_mesh_compression,\n GLTF_KHR_texture_basisu,\n GLTF_EXT_meshopt_compression,\n GLTF_EXT_texture_webp\n} from './lib/types/gltf-types';\n\n// glTF loader/writer definition objects\nexport {GLTFLoader} from './gltf-loader';\nexport {GLTFWriter} from './gltf-writer';\n\n// GLB Loader & Writer (for custom formats that want to leverage the GLB binary \"envelope\")\nexport {GLBLoader} from './glb-loader';\nexport {GLBWriter} from './glb-writer';\n\n// glTF Data Access Helper Class\nexport {default as GLTFScenegraph} from './lib/api/gltf-scenegraph';\nexport {postProcessGLTF} from './lib/api/post-process-gltf';\nexport type {Mesh} from './lib/types/gltf-json-schema';\nexport type {GLTFObject} from './lib/types/gltf-types';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["GLTFLoader","GLTFWriter","GLBLoader","GLBWriter","default","GLTFScenegraph","postProcessGLTF"],"mappings":"AA0BA,SAAQA,UAAR,QAAyB,eAAzB;AACA,SAAQC,UAAR,QAAyB,eAAzB;AAGA,SAAQC,SAAR,QAAwB,cAAxB;AACA,SAAQC,SAAR,QAAwB,cAAxB;AAGA,SAAQC,OAAO,IAAIC,cAAnB,QAAwC,2BAAxC;AACA,SAAQC,eAAR,QAA8B,6BAA9B","sourcesContent":["/* eslint-disable camelcase, indent */\nexport type {GLB} from './lib/types/glb-types';\nexport type {\n GLTF,\n GLTFAccessor,\n GLTFBuffer,\n GLTFBufferView,\n GLTFMeshPrimitive,\n GLTFMesh,\n GLTFNode,\n GLTFMaterial,\n GLTFSampler,\n GLTFScene,\n GLTFSkin,\n GLTFTexture,\n GLTFImage,\n GLTFImagePostprocessed,\n // The following extensions are handled by the GLTFLoader and removed from the parsed glTF (disable via options.gltf.excludeExtensions)\n GLTF_KHR_binary_glTF,\n GLTF_KHR_draco_mesh_compression,\n GLTF_KHR_texture_basisu,\n GLTF_EXT_meshopt_compression,\n GLTF_EXT_texture_webp\n} from './lib/types/gltf-types';\n\n// glTF loader/writer definition objects\nexport {GLTFLoader} from './gltf-loader';\nexport {GLTFWriter} from './gltf-writer';\n\n// GLB Loader & Writer (for custom formats that want to leverage the GLB binary \"envelope\")\nexport {GLBLoader} from './glb-loader';\nexport {GLBWriter} from './glb-writer';\n\n// glTF Data Access Helper Class\nexport {default as GLTFScenegraph} from './lib/api/gltf-scenegraph';\nexport {postProcessGLTF} from './lib/api/post-process-gltf';\nexport type {Mesh} from './lib/types/gltf-json-schema';\nexport type {GLTFObject} from './lib/types/gltf-types';\n"],"file":"index.js"}
@@ -0,0 +1,26 @@
1
+ import { GLTF } from '../types/gltf-types';
2
+ import type { GLTFLoaderOptions } from '../../gltf-loader';
3
+ declare type GLTFExtensionPlugin = {
4
+ name: string;
5
+ preprocess?: (gltfData: {
6
+ json: GLTF;
7
+ }, options: GLTFLoaderOptions, context: any) => void;
8
+ decode?: (gltfData: {
9
+ json: GLTF;
10
+ }, options: GLTFLoaderOptions, context: any) => Promise<void>;
11
+ encode?: (gltfData: {
12
+ json: GLTF;
13
+ }, options: GLTFLoaderOptions) => void;
14
+ };
15
+ /**
16
+ * List of extensions processed by the GLTFLoader
17
+ * Note that may extensions can only be handled on the rendering stage and are left out here
18
+ * These are just extensions that can be handled fully or partially during loading.
19
+ */
20
+ export declare const EXTENSIONS: GLTFExtensionPlugin[];
21
+ /** Call before any resource loading starts */
22
+ export declare function preprocessExtensions(gltf: any, options?: GLTFLoaderOptions, context?: any): void;
23
+ /** Call after resource loading */
24
+ export declare function decodeExtensions(gltf: any, options?: GLTFLoaderOptions, context?: any): Promise<void>;
25
+ export {};
26
+ //# sourceMappingURL=gltf-extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltf-extensions.d.ts","sourceRoot":"","sources":["../../../src/lib/api/gltf-extensions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AACzC,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAkBzD,aAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAC,IAAI,EAAE,IAAI,CAAA;KAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,KAAA,KAAK,IAAI,CAAC;IACnF,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAC,IAAI,EAAE,IAAI,CAAA;KAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,KAAA,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAC,IAAI,EAAE,IAAI,CAAA;KAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,mBAAmB,EAc3C,CAAC;AAEF,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,IAAI,KAAA,EAAE,OAAO,GAAE,iBAAsB,EAAE,OAAO,CAAC,KAAA,QAKnF;AAED,kCAAkC;AAClC,wBAAsB,gBAAgB,CAAC,IAAI,KAAA,EAAE,OAAO,GAAE,iBAAsB,EAAE,OAAO,CAAC,KAAA,iBAOrF"}
@@ -0,0 +1,183 @@
1
+ import type { GLTF, GLTFScene, GLTFNode, GLTFMesh, GLTFSkin, GLTFMaterial, GLTFAccessor, GLTFSampler, GLTFTexture, GLTFImage, GLTFBuffer, GLTFBufferView } from '../types/gltf-types';
2
+ declare type GLTFWithBuffers = {
3
+ json: GLTF;
4
+ buffers: any[];
5
+ binary?: ArrayBuffer;
6
+ };
7
+ declare type Extension = {
8
+ [key: string]: any;
9
+ };
10
+ /**
11
+ * Class for structured access to GLTF data
12
+ */
13
+ export default class GLTFScenegraph {
14
+ gltf: GLTFWithBuffers;
15
+ sourceBuffers: any[];
16
+ byteLength: number;
17
+ constructor(gltf?: {
18
+ json: GLTF;
19
+ buffers?: any[];
20
+ });
21
+ get json(): GLTF;
22
+ getApplicationData(key: string): {
23
+ [key: string]: any;
24
+ };
25
+ getExtraData(key: string): {
26
+ [key: string]: any;
27
+ };
28
+ getExtension<T = Extension>(extensionName: string): T | null;
29
+ getRequiredExtension<T = Extension>(extensionName: string): T | null;
30
+ getRequiredExtensions(): string[];
31
+ getUsedExtensions(): string[];
32
+ getObjectExtension<T = Extension>(object: {
33
+ [key: string]: any;
34
+ }, extensionName: string): T | null;
35
+ getScene(index: number): GLTFScene;
36
+ getNode(index: number): GLTFNode;
37
+ getSkin(index: number): GLTFSkin;
38
+ getMesh(index: number): GLTFMesh;
39
+ getMaterial(index: number): GLTFMaterial;
40
+ getAccessor(index: number): GLTFAccessor;
41
+ getTexture(index: number): GLTFTexture;
42
+ getSampler(index: number): GLTFSampler;
43
+ getImage(index: number): GLTFImage;
44
+ getBufferView(index: number | object): GLTFBufferView;
45
+ getBuffer(index: number): GLTFBuffer;
46
+ getObject(array: string, index: number | object): object;
47
+ /**
48
+ * Accepts buffer view index or buffer view object
49
+ * @returns a `Uint8Array`
50
+ */
51
+ getTypedArrayForBufferView(bufferView: number | object): Uint8Array;
52
+ /** Accepts accessor index or accessor object
53
+ * @returns a typed array with type that matches the types
54
+ */
55
+ getTypedArrayForAccessor(accessor: number | object): any;
56
+ /** accepts accessor index or accessor object
57
+ * returns a `Uint8Array`
58
+ */
59
+ getTypedArrayForImageData(image: number | object): Uint8Array;
60
+ /**
61
+ * Add an extra application-defined key to the top-level data structure
62
+ */
63
+ addApplicationData(key: string, data: object): GLTFScenegraph;
64
+ /**
65
+ * `extras` - Standard GLTF field for storing application specific data
66
+ */
67
+ addExtraData(key: string, data: object): GLTFScenegraph;
68
+ addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph;
69
+ setObjectExtension(object: object, extensionName: string, data: object): void;
70
+ removeObjectExtension(object: object, extensionName: string): object;
71
+ /**
72
+ * Add to standard GLTF top level extension object, mark as used
73
+ */
74
+ addExtension(extensionName: string, extensionData?: object): object;
75
+ /**
76
+ * Standard GLTF top level extension object, mark as used and required
77
+ */
78
+ addRequiredExtension(extensionName: any, extensionData?: object): object;
79
+ /**
80
+ * Add extensionName to list of used extensions
81
+ */
82
+ registerUsedExtension(extensionName: string): void;
83
+ /**
84
+ * Add extensionName to list of required extensions
85
+ */
86
+ registerRequiredExtension(extensionName: string): void;
87
+ /**
88
+ * Removes an extension from the top-level list
89
+ */
90
+ removeExtension(extensionName: string): void;
91
+ /**
92
+ * Set default scene which is to be displayed at load time
93
+ */
94
+ setDefaultScene(sceneIndex: number): void;
95
+ /**
96
+ * @todo: add more properties for scene initialization:
97
+ * name`, `extensions`, `extras`
98
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene
99
+ */
100
+ addScene(scene: {
101
+ nodeIndices: number[];
102
+ }): number;
103
+ /**
104
+ * @todo: add more properties for node initialization:
105
+ * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`
106
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node
107
+ */
108
+ addNode(node: {
109
+ meshIndex: number;
110
+ matrix?: number[];
111
+ }): number;
112
+ /** Adds a mesh to the json part */
113
+ addMesh(mesh: {
114
+ attributes: object;
115
+ indices?: object;
116
+ material?: number;
117
+ mode?: number;
118
+ }): number;
119
+ addPointCloud(attributes: object): number;
120
+ /**
121
+ * Adds a binary image. Builds glTF "JSON metadata" and saves buffer reference
122
+ * Buffer will be copied into BIN chunk during "pack"
123
+ * Currently encodes as glTF image
124
+ * @param imageData
125
+ * @param mimeType
126
+ */
127
+ addImage(imageData: any, mimeTypeOpt?: string): number;
128
+ /**
129
+ * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index
130
+ * @param buffer
131
+ */
132
+ addBufferView(buffer: any): number;
133
+ /**
134
+ * Adds an accessor to a bufferView
135
+ * @param bufferViewIndex
136
+ * @param accessor
137
+ */
138
+ addAccessor(bufferViewIndex: number, accessor: object): number;
139
+ /**
140
+ * Add a binary buffer. Builds glTF "JSON metadata" and saves buffer reference
141
+ * Buffer will be copied into BIN chunk during "pack"
142
+ * Currently encodes buffers as glTF accessors, but this could be optimized
143
+ * @param sourceBuffer
144
+ * @param accessor
145
+ */
146
+ addBinaryBuffer(sourceBuffer: any, accessor?: object): number;
147
+ /**
148
+ * Adds a texture to the json part
149
+ * @todo: add more properties for texture initialization
150
+ * `sampler`, `name`, `extensions`, `extras`
151
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture
152
+ */
153
+ addTexture(texture: {
154
+ imageIndex: number;
155
+ }): number;
156
+ /** Adds a material to the json part */
157
+ addMaterial(pbrMaterialInfo: Object): number;
158
+ /** Pack the binary chunk */
159
+ createBinaryChunk(): void;
160
+ _removeStringFromArray(array: any, string: any): void;
161
+ /**
162
+ * Add attributes to buffers and create `attributes` object which is part of `mesh`
163
+ */
164
+ _addAttributes(attributes?: {}): {};
165
+ /**
166
+ * Add indices to buffers
167
+ */
168
+ _addIndices(indices: any): number;
169
+ /**
170
+ * Deduce gltf specific attribue name from input attribute name
171
+ */
172
+ _getGltfAttributeName(attributeName: any): any;
173
+ /**
174
+ * Calculate `min` and `max` arrays of accessor according to spec:
175
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor
176
+ */
177
+ _getAccessorMinMax(buffer: any, size: any): {
178
+ min: null;
179
+ max: null;
180
+ };
181
+ }
182
+ export {};
183
+ //# sourceMappingURL=gltf-scenegraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltf-scenegraph.d.ts","sourceRoot":"","sources":["../../../src/lib/api/gltf-scenegraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,cAAc,EACf,MAAM,qBAAqB,CAAC;AAW7B,aAAK,eAAe,GAAG;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAUF,aAAK,SAA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C,4BAA4B;IAC5B,iBAAiB,IAAI,IAAI;IA+BzB,sBAAsB,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA;IAYpC;;OAEG;IACH,cAAc,CAAC,UAAU,KAAK;IAW9B;;OAEG;IACH,WAAW,CAAC,OAAO,KAAA;IAInB;;OAEG;IACH,qBAAqB,CAAC,aAAa,KAAA;IAoBnC;;;OAGG;IACH,kBAAkB,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA;;;;CAmChC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/api/gltf-scenegraph.ts"],"names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorArrayTypeAndLength","getAccessorTypeFromSize","getComponentTypeFromArray","DEFAULT_GLTF_JSON","asset","version","generator","buffers","GLTFScenegraph","constructor","gltf","json","sourceBuffers","byteLength","getApplicationData","key","data","getExtraData","extras","getExtension","extensionName","isExtension","getUsedExtensions","find","name","extensions","getRequiredExtension","isRequired","getRequiredExtensions","extensionsRequired","extensionsUsed","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","getTypedArrayForAccessor","accessor","ArrayType","length","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","extension","addExtension","extensionData","addRequiredExtension","registerRequiredExtension","ext","push","removeExtension","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","images","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"mappings":";AAeA,SAAQA,sBAAR,QAAqC,oBAArC;AACA,SAAQC,WAAR,EAAqBC,WAArB,QAAuC,0BAAvC;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SACEC,6BADF,EAEEC,uBAFF,EAGEC,yBAHF,QAIO,0BAJP;AAYA,MAAMC,iBAAuB,GAAG;AAC9BC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE,KADJ;AAELC,IAAAA,SAAS,EAAE;AAFN,GADuB;AAK9BC,EAAAA,OAAO,EAAE;AALqB,CAAhC;AAYA,eAAe,MAAMC,cAAN,CAAqB;AAMlCC,EAAAA,WAAW,CAACC,IAAD,EAAuC;AAAA;;AAAA;;AAAA;;AAEhD,SAAKA,IAAL,GAAYA,IAAI,IAAI;AAClBC,MAAAA,IAAI,EAAE,EAAC,GAAGR;AAAJ,OADY;AAElBI,MAAAA,OAAO,EAAE;AAFS,KAApB;AAIA,SAAKK,aAAL,GAAqB,EAArB;AACA,SAAKC,UAAL,GAAkB,CAAlB;;AAGA,QAAI,KAAKH,IAAL,CAAUH,OAAV,IAAqB,KAAKG,IAAL,CAAUH,OAAV,CAAkB,CAAlB,CAAzB,EAA+C;AAC7C,WAAKM,UAAL,GAAkB,KAAKH,IAAL,CAAUH,OAAV,CAAkB,CAAlB,EAAqBM,UAAvC;AACA,WAAKD,aAAL,GAAqB,CAAC,KAAKF,IAAL,CAAUH,OAAV,CAAkB,CAAlB,CAAD,CAArB;AACD;AACF;;AAIO,MAAJI,IAAI,GAAS;AACf,WAAO,KAAKD,IAAL,CAAUC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AAGiI,cAAT,CAHyB,CAAjC;AAKD;AACF;;AACD,WAAOV,MAAP;AACD;;AA/mBiC","sourcesContent":["import type {\n GLTF,\n GLTFScene,\n GLTFNode,\n GLTFMesh,\n GLTFSkin,\n GLTFMaterial,\n GLTFAccessor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-types';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {\n getAccessorArrayTypeAndLength,\n getAccessorTypeFromSize,\n getComponentTypeFromArray\n} from '../gltf-utils/gltf-utils';\n\ntype GLTFWithBuffers = {\n json: GLTF;\n buffers: any[];\n binary?: ArrayBuffer;\n};\n\nconst DEFAULT_GLTF_JSON: GLTF = {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: []\n};\n\ntype Extension = {[key: string]: any};\n/**\n * Class for structured access to GLTF data\n */\nexport default class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n constructor(gltf?: {json: GLTF; buffers?: any[]}) {\n // @ts-ignore\n this.gltf = gltf || {\n json: {...DEFAULT_GLTF_JSON},\n buffers: []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const extras = this.json.extras || {};\n return extras[key];\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? extensions[extensionName] || true : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): object {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = this.json[array] && this.json[array][index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n accessor = this.getAccessor(accessor);\n // @ts-ignore\n const bufferView = this.getBufferView(accessor.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n // Create a new typed array as a view into the combined buffer\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // @ts-ignore\n const byteOffset = bufferView.byteOffset + accessor.byteOffset;\n return new ArrayType(arrayBuffer, byteOffset, length);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n this.json.extras[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: object, extensionName: string, data: object): void {\n // @ts-ignore\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: object, extensionName: string): object {\n // @ts-ignore\n const extensions = object.extensions || {};\n const extension = extensions[extensionName];\n delete extensions[extensionName];\n return extension;\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices: object; material: number; mode: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: 0,\n // Write offset from the start of the binary body\n byteOffset: this.byteLength,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"file":"gltf-scenegraph.js"}
1
+ {"version":3,"sources":["../../../src/lib/api/gltf-scenegraph.ts"],"names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorArrayTypeAndLength","getAccessorTypeFromSize","getComponentTypeFromArray","DEFAULT_GLTF_JSON","asset","version","generator","buffers","GLTFScenegraph","constructor","gltf","json","sourceBuffers","byteLength","getApplicationData","key","data","getExtraData","extras","getExtension","extensionName","isExtension","getUsedExtensions","find","name","extensions","getRequiredExtension","isRequired","getRequiredExtensions","extensionsRequired","extensionsUsed","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","getTypedArrayForAccessor","accessor","ArrayType","length","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","extension","addExtension","extensionData","addRequiredExtension","registerRequiredExtension","ext","push","removeExtension","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","images","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"mappings":";AAeA,SAAQA,sBAAR,QAAqC,oBAArC;AACA,SAAQC,WAAR,EAAqBC,WAArB,QAAuC,0BAAvC;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SACEC,6BADF,EAEEC,uBAFF,EAGEC,yBAHF,QAIO,0BAJP;AAYA,MAAMC,iBAAuB,GAAG;AAC9BC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE,KADJ;AAELC,IAAAA,SAAS,EAAE;AAFN,GADuB;AAK9BC,EAAAA,OAAO,EAAE;AALqB,CAAhC;AAYA,eAAe,MAAMC,cAAN,CAAqB;AAMlCC,EAAAA,WAAW,CAACC,IAAD,EAAuC;AAAA;;AAAA;;AAAA;;AAEhD,SAAKA,IAAL,GAAYA,IAAI,IAAI;AAClBC,MAAAA,IAAI,EAAE,EAAC,GAAGR;AAAJ,OADY;AAElBI,MAAAA,OAAO,EAAE;AAFS,KAApB;AAIA,SAAKK,aAAL,GAAqB,EAArB;AACA,SAAKC,UAAL,GAAkB,CAAlB;;AAGA,QAAI,KAAKH,IAAL,CAAUH,OAAV,IAAqB,KAAKG,IAAL,CAAUH,OAAV,CAAkB,CAAlB,CAAzB,EAA+C;AAC7C,WAAKM,UAAL,GAAkB,KAAKH,IAAL,CAAUH,OAAV,CAAkB,CAAlB,EAAqBM,UAAvC;AACA,WAAKD,aAAL,GAAqB,CAAC,KAAKF,IAAL,CAAUH,OAAV,CAAkB,CAAlB,CAAD,CAArB;AACD;AACF;;AAIO,MAAJI,IAAI,GAAS;AACf,WAAO,KAAKD,IAAL,CAAUC,IAAjB;AACD;;AAEDG,EAAAA,kBAAkB,CAACC,GAAD,EAAoC;AAEpD,UAAMC,IAAI,GAAG,KAAKL,IAAL,CAAUI,GAAV,CAAb;AACA,WAAOC,IAAP;AACD;;AAEDC,EAAAA,YAAY,CAAC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essor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-types';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {\n getAccessorArrayTypeAndLength,\n getAccessorTypeFromSize,\n getComponentTypeFromArray\n} from '../gltf-utils/gltf-utils';\n\ntype GLTFWithBuffers = {\n json: GLTF;\n buffers: any[];\n binary?: ArrayBuffer;\n};\n\nconst DEFAULT_GLTF_JSON: GLTF = {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: []\n};\n\ntype Extension = {[key: string]: any};\n/**\n * Class for structured access to GLTF data\n */\nexport default class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n constructor(gltf?: {json: GLTF; buffers?: any[]}) {\n // @ts-ignore\n this.gltf = gltf || {\n json: {...DEFAULT_GLTF_JSON},\n buffers: []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const extras = this.json.extras || {};\n return extras[key];\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? extensions[extensionName] || true : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): object {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = this.json[array] && this.json[array][index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n accessor = this.getAccessor(accessor);\n // @ts-ignore\n const bufferView = this.getBufferView(accessor.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n // Create a new typed array as a view into the combined buffer\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // @ts-ignore\n const byteOffset = bufferView.byteOffset + accessor.byteOffset;\n return new ArrayType(arrayBuffer, byteOffset, length);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n this.json.extras[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: object, extensionName: string, data: object): void {\n // @ts-ignore\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: object, extensionName: string): object {\n // @ts-ignore\n const extensions = object.extensions || {};\n const extension = extensions[extensionName];\n delete extensions[extensionName];\n return extension;\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix?: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices?: object; material?: number; mode?: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: 0,\n // Write offset from the start of the binary body\n byteOffset: this.byteLength,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"file":"gltf-scenegraph.js"}
@@ -0,0 +1,2 @@
1
+ export declare function normalizeGLTFV1(gltf: any, options?: {}): void;
2
+ //# sourceMappingURL=normalize-gltf-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-gltf-v1.d.ts","sourceRoot":"","sources":["../../../src/lib/api/normalize-gltf-v1.ts"],"names":[],"mappings":"AAqTA,wBAAgB,eAAe,CAAC,IAAI,KAAA,EAAE,OAAO,KAAK,QAEjD"}
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import * as KHR_binary_glTF from '../extensions/KHR_binary_gltf';
2
3
  const GLTF_ARRAYS = {
3
4
  accessors: 'accessor',
@@ -29,8 +30,8 @@ const GLTF_KEYS = {
29
30
  };
30
31
 
31
32
  class GLTFV1Normalizer {
32
- constructor(gltf) {
33
- this.idToIndexMap = {
33
+ constructor() {
34
+ _defineProperty(this, "idToIndexMap", {
34
35
  animations: {},
35
36
  accessors: {},
36
37
  buffers: {},
@@ -43,7 +44,9 @@ class GLTFV1Normalizer {
43
44
  scenes: {},
44
45
  skins: {},
45
46
  textures: {}
46
- };
47
+ });
48
+
49
+ _defineProperty(this, "json", void 0);
47
50
  }
48
51
 
49
52
  normalize(gltf, options) {