@babylonjs/loaders 9.23.0 → 9.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/glTF/1.0/glTFBinaryExtension.d.ts +4 -14
  2. package/glTF/1.0/glTFBinaryExtension.js +6 -62
  3. package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
  4. package/glTF/1.0/glTFBinaryExtension.pure.d.ts +21 -0
  5. package/glTF/1.0/glTFBinaryExtension.pure.js +76 -0
  6. package/glTF/1.0/glTFBinaryExtension.pure.js.map +1 -0
  7. package/glTF/1.0/glTFLoader.d.ts +3 -142
  8. package/glTF/1.0/glTFLoader.js +7 -1840
  9. package/glTF/1.0/glTFLoader.js.map +1 -1
  10. package/glTF/1.0/glTFLoader.pure.d.ts +149 -0
  11. package/glTF/1.0/glTFLoader.pure.js +1854 -0
  12. package/glTF/1.0/glTFLoader.pure.js.map +1 -0
  13. package/glTF/1.0/glTFLoaderUtils.d.ts +2 -2
  14. package/glTF/1.0/glTFLoaderUtils.js +5 -5
  15. package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
  16. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +4 -11
  17. package/glTF/1.0/glTFMaterialsCommonExtension.js +6 -128
  18. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
  19. package/glTF/1.0/glTFMaterialsCommonExtension.pure.d.ts +18 -0
  20. package/glTF/1.0/glTFMaterialsCommonExtension.pure.js +142 -0
  21. package/glTF/1.0/glTFMaterialsCommonExtension.pure.js.map +1 -0
  22. package/glTF/1.0/pure.d.ts +3 -0
  23. package/glTF/1.0/pure.js +3 -0
  24. package/glTF/1.0/pure.js.map +1 -1
  25. package/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +0 -1
  26. package/glTF/2.0/Extensions/KHR_animation_pointer.data.d.ts +1 -1
  27. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js +3 -251
  28. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.d.ts +5 -0
  30. package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js +267 -0
  31. package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js.map +1 -0
  32. package/glTF/2.0/Extensions/KHR_animation_pointer.js +2 -1
  33. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  34. package/glTF/2.0/Extensions/dynamic.js +5 -1
  35. package/glTF/2.0/Extensions/dynamic.js.map +1 -1
  36. package/glTF/2.0/Extensions/pure.d.ts +1 -0
  37. package/glTF/2.0/Extensions/pure.js +1 -0
  38. package/glTF/2.0/Extensions/pure.js.map +1 -1
  39. package/glTF/2.0/glTFLoader.pure.d.ts +1 -1
  40. package/glTF/2.0/glTFLoader.pure.js +2 -2
  41. package/glTF/2.0/glTFLoader.pure.js.map +1 -1
  42. package/glTF/glTFFileLoader.pure.d.ts +8 -4
  43. package/glTF/glTFFileLoader.pure.js +13 -6
  44. package/glTF/glTFFileLoader.pure.js.map +1 -1
  45. package/package.json +3 -4
  46. /package/{bvh → BVH}/license.md +0 -0
@@ -1,16 +1,6 @@
1
- import { GLTFLoaderExtension } from "./glTFLoader.js";
2
- import { type Scene } from "@babylonjs/core/scene.js";
3
- import { type IGLTFLoaderData } from "../glTFFileLoader.js";
4
- import { type IGLTFRuntime } from "./glTFLoaderInterfaces.js";
5
1
  /**
6
- * @internal
7
- * @deprecated
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./glTFBinaryExtension.pure" for tree-shakeable, side-effect-free usage.
8
4
  */
9
- export declare class GLTFBinaryExtension extends GLTFLoaderExtension {
10
- private _bin;
11
- constructor();
12
- loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void): boolean;
13
- loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
14
- loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean;
15
- loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean;
16
- }
5
+ export * from "./glTFBinaryExtension.pure.js";
6
+ import "./glTFLoader.js";
@@ -1,65 +1,9 @@
1
- import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from "./glTFLoader.js";
2
- import { GLTFUtils } from "./glTFLoaderUtils.js";
3
- import { EComponentType } from "./glTFLoaderInterfaces.js";
4
- const BinaryExtensionBufferName = "binary_glTF";
5
1
  /**
6
- * @internal
7
- * @deprecated
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./glTFBinaryExtension.pure" for tree-shakeable, side-effect-free usage.
8
4
  */
9
- export class GLTFBinaryExtension extends GLTFLoaderExtension {
10
- constructor() {
11
- super("KHR_binary_glTF");
12
- }
13
- // eslint-disable-next-line no-restricted-syntax
14
- loadRuntimeAsync(scene, data, rootUrl, onSuccess) {
15
- const extensionsUsed = data.json.extensionsUsed;
16
- if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {
17
- return false;
18
- }
19
- this._bin = data.bin;
20
- onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));
21
- return true;
22
- }
23
- // eslint-disable-next-line no-restricted-syntax
24
- loadBufferAsync(gltfRuntime, id, onSuccess, onError) {
25
- if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {
26
- return false;
27
- }
28
- if (id !== BinaryExtensionBufferName) {
29
- return false;
30
- }
31
- // eslint-disable-next-line github/no-then
32
- this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, (error) => onError(error.message));
33
- return true;
34
- }
35
- // eslint-disable-next-line no-restricted-syntax
36
- loadTextureBufferAsync(gltfRuntime, id, onSuccess) {
37
- const texture = gltfRuntime.textures[id];
38
- const source = gltfRuntime.images[texture.source];
39
- if (!source.extensions || !(this.name in source.extensions)) {
40
- return false;
41
- }
42
- const sourceExt = source.extensions[this.name];
43
- const bufferView = gltfRuntime.bufferViews[sourceExt.bufferView];
44
- const buffer = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);
45
- onSuccess(buffer);
46
- return true;
47
- }
48
- // eslint-disable-next-line no-restricted-syntax
49
- loadShaderStringAsync(gltfRuntime, id, onSuccess) {
50
- const shader = gltfRuntime.shaders[id];
51
- if (!shader.extensions || !(this.name in shader.extensions)) {
52
- return false;
53
- }
54
- const binaryExtensionShader = shader.extensions[this.name];
55
- const bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];
56
- const shaderBytes = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);
57
- setTimeout(() => {
58
- const shaderString = GLTFUtils.DecodeBufferToText(shaderBytes);
59
- onSuccess(shaderString);
60
- });
61
- return true;
62
- }
63
- }
64
- GLTFLoader.RegisterExtension(new GLTFBinaryExtension());
5
+ export * from "./glTFBinaryExtension.pure.js";
6
+ import "./glTFLoader.js";
7
+ import { RegisterGLTFBinaryExtension } from "./glTFBinaryExtension.pure.js";
8
+ RegisterGLTFBinaryExtension();
65
9
  //# sourceMappingURL=glTFBinaryExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glTFBinaryExtension.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAiG,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIvJ,MAAM,yBAAyB,GAAG,aAAa,CAAC;AAahD;;;GAGG;AACH,MAAM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C;QAEvI,UAAU,CAAC,GAAG,EAAE;YACZ,MAAM,YAAY,GAAG,SAAS,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YAC/D,SAAS,CAAC,YAAY,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC","sourcesContent":["import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from \"./glTFLoader\";\r\nimport { GLTFUtils } from \"./glTFLoaderUtils\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { type IGLTFLoaderData } from \"../glTFFileLoader\";\r\nimport { type IGLTFRuntime, type IGLTFTexture, type IGLTFImage, type IGLTFBufferView, type IGLTFShader, EComponentType } from \"./glTFLoaderInterfaces\";\r\n\r\nimport { type IDataBuffer } from \"core/Misc/dataReader\";\r\n\r\nconst BinaryExtensionBufferName = \"binary_glTF\";\r\n\r\ninterface IGLTFBinaryExtensionShader {\r\n bufferView: string;\r\n}\r\n\r\ninterface IGLTFBinaryExtensionImage {\r\n bufferView: string;\r\n mimeType: string;\r\n height: number;\r\n width: number;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @deprecated\r\n */\r\nexport class GLTFBinaryExtension extends GLTFLoaderExtension {\r\n private _bin: IDataBuffer;\r\n\r\n public constructor() {\r\n super(\"KHR_binary_glTF\");\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void): boolean {\r\n const extensionsUsed = (<any>data.json).extensionsUsed;\r\n if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {\r\n return false;\r\n }\r\n\r\n this._bin = data.bin;\r\n onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean {\r\n if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {\r\n return false;\r\n }\r\n\r\n if (id !== BinaryExtensionBufferName) {\r\n return false;\r\n }\r\n\r\n // eslint-disable-next-line github/no-then\r\n this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, (error) => onError(error.message));\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean {\r\n const texture: IGLTFTexture = gltfRuntime.textures[id];\r\n const source: IGLTFImage = gltfRuntime.images[texture.source];\r\n if (!source.extensions || !(this.name in source.extensions)) {\r\n return false;\r\n }\r\n\r\n const sourceExt: IGLTFBinaryExtensionImage = source.extensions[this.name];\r\n const bufferView: IGLTFBufferView = gltfRuntime.bufferViews[sourceExt.bufferView];\r\n const buffer = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\r\n onSuccess(buffer);\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean {\r\n const shader: IGLTFShader = gltfRuntime.shaders[id];\r\n if (!shader.extensions || !(this.name in shader.extensions)) {\r\n return false;\r\n }\r\n\r\n const binaryExtensionShader: IGLTFBinaryExtensionShader = shader.extensions[this.name];\r\n const bufferView: IGLTFBufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];\r\n const shaderBytes = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\r\n\r\n setTimeout(() => {\r\n const shaderString = GLTFUtils.DecodeBufferToText(shaderBytes);\r\n onSuccess(shaderString);\r\n });\r\n\r\n return true;\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(new GLTFBinaryExtension());\r\n"]}
1
+ {"version":3,"file":"glTFBinaryExtension.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,4BAA4B,CAAC;AAE3C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,2BAA2B,EAAE,CAAC","sourcesContent":["/**\n * Re-exports the pure implementation and applies the runtime registration side effect.\n * Import \"./glTFBinaryExtension.pure\" for tree-shakeable, side-effect-free usage.\n */\nexport * from \"./glTFBinaryExtension.pure\";\n\nimport \"./glTFLoader\";\nimport { RegisterGLTFBinaryExtension } from \"./glTFBinaryExtension.pure\";\nRegisterGLTFBinaryExtension();\n"]}
@@ -0,0 +1,21 @@
1
+ import { GLTFLoaderExtension } from "./glTFLoader.pure.js";
2
+ import { type Scene } from "@babylonjs/core/scene.pure.js";
3
+ import { type IGLTFLoaderData } from "../glTFFileLoader.pure.js";
4
+ import { type IGLTFRuntime } from "./glTFLoaderInterfaces.js";
5
+ /**
6
+ * @internal
7
+ * @deprecated
8
+ */
9
+ export declare class GLTFBinaryExtension extends GLTFLoaderExtension {
10
+ private _bin;
11
+ constructor();
12
+ loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void): boolean;
13
+ loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
14
+ loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean;
15
+ loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean;
16
+ }
17
+ /**
18
+ * Registers the KHR_binary_glTF extension.
19
+ * Safe to call multiple times; only the first call has an effect.
20
+ */
21
+ export declare function RegisterGLTFBinaryExtension(): void;
@@ -0,0 +1,76 @@
1
+ import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from "./glTFLoader.pure.js";
2
+ import { GLTFUtils } from "./glTFLoaderUtils.js";
3
+ import { EComponentType } from "./glTFLoaderInterfaces.js";
4
+ const BinaryExtensionBufferName = "binary_glTF";
5
+ /**
6
+ * @internal
7
+ * @deprecated
8
+ */
9
+ export class GLTFBinaryExtension extends GLTFLoaderExtension {
10
+ constructor() {
11
+ super("KHR_binary_glTF");
12
+ }
13
+ // eslint-disable-next-line no-restricted-syntax
14
+ loadRuntimeAsync(scene, data, rootUrl, onSuccess) {
15
+ const extensionsUsed = data.json.extensionsUsed;
16
+ if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {
17
+ return false;
18
+ }
19
+ this._bin = data.bin;
20
+ onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));
21
+ return true;
22
+ }
23
+ // eslint-disable-next-line no-restricted-syntax
24
+ loadBufferAsync(gltfRuntime, id, onSuccess, onError) {
25
+ if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {
26
+ return false;
27
+ }
28
+ if (id !== BinaryExtensionBufferName) {
29
+ return false;
30
+ }
31
+ // eslint-disable-next-line github/no-then
32
+ this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, (error) => onError(error.message));
33
+ return true;
34
+ }
35
+ // eslint-disable-next-line no-restricted-syntax
36
+ loadTextureBufferAsync(gltfRuntime, id, onSuccess) {
37
+ const texture = gltfRuntime.textures[id];
38
+ const source = gltfRuntime.images[texture.source];
39
+ if (!source.extensions || !(this.name in source.extensions)) {
40
+ return false;
41
+ }
42
+ const sourceExt = source.extensions[this.name];
43
+ const bufferView = gltfRuntime.bufferViews[sourceExt.bufferView];
44
+ const buffer = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);
45
+ onSuccess(buffer);
46
+ return true;
47
+ }
48
+ // eslint-disable-next-line no-restricted-syntax
49
+ loadShaderStringAsync(gltfRuntime, id, onSuccess) {
50
+ const shader = gltfRuntime.shaders[id];
51
+ if (!shader.extensions || !(this.name in shader.extensions)) {
52
+ return false;
53
+ }
54
+ const binaryExtensionShader = shader.extensions[this.name];
55
+ const bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];
56
+ const shaderBytes = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);
57
+ setTimeout(() => {
58
+ const shaderString = GLTFUtils.DecodeBufferToText(shaderBytes);
59
+ onSuccess(shaderString);
60
+ });
61
+ return true;
62
+ }
63
+ }
64
+ let _Registered = false;
65
+ /**
66
+ * Registers the KHR_binary_glTF extension.
67
+ * Safe to call multiple times; only the first call has an effect.
68
+ */
69
+ export function RegisterGLTFBinaryExtension() {
70
+ if (_Registered) {
71
+ return;
72
+ }
73
+ _Registered = true;
74
+ GLTFLoader.RegisterExtension(new GLTFBinaryExtension());
75
+ }
76
+ //# sourceMappingURL=glTFBinaryExtension.pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glTFBinaryExtension.pure.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.pure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAiG,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIvJ,MAAM,yBAAyB,GAAG,aAAa,CAAC;AAahD;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,mBAAmB;IAGxD;QACI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC7B,CAAC;IAED,gDAAgD;IAChC,gBAAgB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CAAC,YAAY,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACvC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,UAAU,CAAC,iBAAiB,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from \"./glTFLoader.pure\";\r\nimport { GLTFUtils } from \"./glTFLoaderUtils\";\r\nimport { type Scene } from \"core/scene.pure\";\r\nimport { type IGLTFLoaderData } from \"../glTFFileLoader.pure\";\r\nimport { type IGLTFRuntime, type IGLTFTexture, type IGLTFImage, type IGLTFBufferView, type IGLTFShader, EComponentType } from \"./glTFLoaderInterfaces\";\r\n\r\nimport { type IDataBuffer } from \"core/Misc/dataReader\";\r\n\r\nconst BinaryExtensionBufferName = \"binary_glTF\";\r\n\r\ninterface IGLTFBinaryExtensionShader {\r\n bufferView: string;\r\n}\r\n\r\ninterface IGLTFBinaryExtensionImage {\r\n bufferView: string;\r\n mimeType: string;\r\n height: number;\r\n width: number;\r\n}\r\n\r\n/**\r\n * @internal\r\n * @deprecated\r\n */\r\nexport class GLTFBinaryExtension extends GLTFLoaderExtension {\r\n private _bin: IDataBuffer;\r\n\r\n public constructor() {\r\n super(\"KHR_binary_glTF\");\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void): boolean {\r\n const extensionsUsed = (<any>data.json).extensionsUsed;\r\n if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {\r\n return false;\r\n }\r\n\r\n this._bin = data.bin;\r\n onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean {\r\n if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {\r\n return false;\r\n }\r\n\r\n if (id !== BinaryExtensionBufferName) {\r\n return false;\r\n }\r\n\r\n // eslint-disable-next-line github/no-then\r\n this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, (error) => onError(error.message));\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean {\r\n const texture: IGLTFTexture = gltfRuntime.textures[id];\r\n const source: IGLTFImage = gltfRuntime.images[texture.source];\r\n if (!source.extensions || !(this.name in source.extensions)) {\r\n return false;\r\n }\r\n\r\n const sourceExt: IGLTFBinaryExtensionImage = source.extensions[this.name];\r\n const bufferView: IGLTFBufferView = gltfRuntime.bufferViews[sourceExt.bufferView];\r\n const buffer = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\r\n onSuccess(buffer);\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n public override loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean {\r\n const shader: IGLTFShader = gltfRuntime.shaders[id];\r\n if (!shader.extensions || !(this.name in shader.extensions)) {\r\n return false;\r\n }\r\n\r\n const binaryExtensionShader: IGLTFBinaryExtensionShader = shader.extensions[this.name];\r\n const bufferView: IGLTFBufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];\r\n const shaderBytes = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\r\n\r\n setTimeout(() => {\r\n const shaderString = GLTFUtils.DecodeBufferToText(shaderBytes);\r\n onSuccess(shaderString);\r\n });\r\n\r\n return true;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n\r\n/**\r\n * Registers the KHR_binary_glTF extension.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterGLTFBinaryExtension(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n GLTFLoader.RegisterExtension(new GLTFBinaryExtension());\r\n}\r\n"]}
@@ -1,144 +1,5 @@
1
- import { type IGLTFRuntime } from "./glTFLoaderInterfaces.js";
2
- import { type Nullable } from "@babylonjs/core/types.js";
3
- import { Material } from "@babylonjs/core/Materials/material.js";
4
- import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
5
- import { type ISceneLoaderAsyncResult, type ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader.js";
6
- import { type Scene } from "@babylonjs/core/scene.js";
7
- import { type IGLTFLoader, type IGLTFLoaderData } from "../glTFFileLoader.js";
8
- import { type AssetContainer } from "@babylonjs/core/assetContainer.js";
9
1
  /**
10
- * Implementation of the base glTF spec
11
- * @internal
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./glTFLoader.pure" for tree-shakeable, side-effect-free usage.
12
4
  */
13
- export declare class GLTFLoaderBase {
14
- static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
15
- static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
16
- static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
17
- static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void): void;
18
- static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
19
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
20
- }
21
- /**
22
- * glTF V1 Loader
23
- * @internal
24
- * @deprecated
25
- */
26
- export declare class GLTFLoader implements IGLTFLoader {
27
- static Extensions: {
28
- [name: string]: GLTFLoaderExtension;
29
- };
30
- static RegisterExtension(extension: GLTFLoaderExtension): void;
31
- dispose(): void;
32
- private _importMeshAsync;
33
- /**
34
- * Imports one or more meshes from a loaded gltf file and adds them to the scene
35
- * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
36
- * @param scene the scene the meshes should be added to
37
- * @param assetContainer defines the asset container to use (can be null)
38
- * @param data gltf data containing information of the meshes in a loaded file
39
- * @param rootUrl root url to load from
40
- * @param onProgress event that fires when loading progress has occured
41
- * @returns a promise containg the loaded meshes, particles, skeletons and animations
42
- */
43
- importMeshAsync(meshesNames: any, scene: Scene, assetContainer: Nullable<AssetContainer>, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
44
- private _loadAsync;
45
- /**
46
- * Imports all objects from a loaded gltf file and adds them to the scene
47
- * @param scene the scene the objects should be added to
48
- * @param data gltf data containing information of the meshes in a loaded file
49
- * @param rootUrl root url to load from
50
- * @param onProgress event that fires when loading progress has occured
51
- * @returns a promise which completes when objects have been loaded to the scene
52
- */
53
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
54
- private _loadShadersAsync;
55
- private _loadBuffersAsync;
56
- private _createNodes;
57
- }
58
- /** @internal */
59
- export declare abstract class GLTFLoaderExtension {
60
- private _name;
61
- constructor(name: string);
62
- get name(): string;
63
- /**
64
- * Defines an override for loading the runtime
65
- * Return true to stop further extensions from loading the runtime
66
- * @param scene
67
- * @param data
68
- * @param rootUrl
69
- * @param onSuccess
70
- * @param onError
71
- * @returns true to stop further extensions from loading the runtime
72
- */
73
- loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
74
- /**
75
- * Defines an onverride for creating gltf runtime
76
- * Return true to stop further extensions from creating the runtime
77
- * @param gltfRuntime
78
- * @param onSuccess
79
- * @param onError
80
- * @returns true to stop further extensions from creating the runtime
81
- */
82
- loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
83
- /**
84
- * Defines an override for loading buffers
85
- * Return true to stop further extensions from loading this buffer
86
- * @param gltfRuntime
87
- * @param id
88
- * @param onSuccess
89
- * @param onError
90
- * @param onProgress
91
- * @returns true to stop further extensions from loading this buffer
92
- */
93
- loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
94
- /**
95
- * Defines an override for loading texture buffers
96
- * Return true to stop further extensions from loading this texture data
97
- * @param gltfRuntime
98
- * @param id
99
- * @param onSuccess
100
- * @param onError
101
- * @returns true to stop further extensions from loading this texture data
102
- */
103
- loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
104
- /**
105
- * Defines an override for creating textures
106
- * Return true to stop further extensions from loading this texture
107
- * @param gltfRuntime
108
- * @param id
109
- * @param buffer
110
- * @param onSuccess
111
- * @param onError
112
- * @returns true to stop further extensions from loading this texture
113
- */
114
- createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
115
- /**
116
- * Defines an override for loading shader strings
117
- * Return true to stop further extensions from loading this shader data
118
- * @param gltfRuntime
119
- * @param id
120
- * @param onSuccess
121
- * @param onError
122
- * @returns true to stop further extensions from loading this shader data
123
- */
124
- loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
125
- /**
126
- * Defines an override for loading materials
127
- * Return true to stop further extensions from loading this material
128
- * @param gltfRuntime
129
- * @param id
130
- * @param onSuccess
131
- * @param onError
132
- * @returns true to stop further extensions from loading this material
133
- */
134
- loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
135
- static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
136
- static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
137
- static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
138
- static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
139
- static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
140
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
141
- private static _LoadTextureBufferAsync;
142
- private static _CreateTextureAsync;
143
- private static _ApplyExtensions;
144
- }
5
+ export * from "./glTFLoader.pure.js";