@needle-tools/engine 4.16.5 → 4.17.0-next.52e0e32

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 (59) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/gltf-progressive-BJ9OrddA.js +28272 -0
  3. package/dist/gltf-progressive-Ck_bXBr_.umd.cjs +4022 -0
  4. package/dist/gltf-progressive-CqZYu6Hx.min.js +4022 -0
  5. package/dist/loader.worker-CCrD-Ycm.js +3 -0
  6. package/dist/{materialx-Dk-cjpFv.umd.cjs → materialx-C3cdjbh7.umd.cjs} +1 -1
  7. package/dist/{materialx-BgYphGV9.js → materialx-DQ6OMWe8.js} +6 -7
  8. package/dist/{materialx-bmTetdSz.min.js → materialx-DwkZECrV.min.js} +1 -1
  9. package/dist/{needle-engine.bundle-D7PAIzue.umd.cjs → needle-engine.bundle-BVYLwU3k.umd.cjs} +150 -150
  10. package/dist/{needle-engine.bundle-Cndz6kVg.min.js → needle-engine.bundle-BrDer0-s.min.js} +121 -121
  11. package/dist/{needle-engine.bundle-_FYakfzP.js → needle-engine.bundle-cGFD3FPS.js} +2456 -2495
  12. package/dist/needle-engine.d.ts +102 -193
  13. package/dist/needle-engine.js +3 -3
  14. package/dist/needle-engine.min.js +1 -1
  15. package/dist/needle-engine.umd.cjs +1 -1
  16. package/dist/three-examples.js +3294 -4643
  17. package/dist/three-examples.min.js +13 -47
  18. package/dist/three-examples.umd.cjs +12 -46
  19. package/dist/three.js +24892 -15999
  20. package/dist/three.min.js +214 -214
  21. package/dist/three.umd.cjs +208 -208
  22. package/dist/{vendor-DZ45lcA8.min.js → vendor-BPp9F5vR.min.js} +19 -19
  23. package/dist/{vendor-BsRxp-FT.js → vendor-CQMI3jTS.js} +862 -901
  24. package/dist/{vendor-BwxpsdCm.umd.cjs → vendor-CipoooTV.umd.cjs} +20 -20
  25. package/lib/engine/engine_application.d.ts +9 -0
  26. package/lib/engine/engine_application.js.map +1 -1
  27. package/lib/engine/engine_feature_flags.d.ts +3 -3
  28. package/lib/engine/engine_feature_flags.js +3 -5
  29. package/lib/engine/engine_feature_flags.js.map +1 -1
  30. package/lib/engine/engine_modules.d.ts +26 -30
  31. package/lib/engine/engine_modules.js +32 -103
  32. package/lib/engine/engine_modules.js.map +1 -1
  33. package/lib/engine/webcomponents/needle-engine.d.ts +57 -144
  34. package/lib/engine/webcomponents/needle-engine.js +1 -10
  35. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  36. package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
  37. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  38. package/package.json +4 -2
  39. package/plugins/next/meshbvhworker-import.cjs +40 -0
  40. package/plugins/next/next.js +34 -4
  41. package/plugins/vite/alias.d.ts +1 -1
  42. package/plugins/vite/alias.js +87 -82
  43. package/plugins/vite/build-pipeline.js +4 -3
  44. package/plugins/vite/dependencies.js +7 -5
  45. package/plugins/vite/drop.js +6 -8
  46. package/plugins/vite/editor-connection.js +2 -1
  47. package/plugins/vite/poster.js +2 -1
  48. package/plugins/vite/reload.js +7 -2
  49. package/plugins/vite/transform-codegen.js +6 -2
  50. package/src/engine/engine_application.ts +10 -0
  51. package/src/engine/engine_feature_flags.ts +3 -7
  52. package/src/engine/engine_modules.ts +39 -101
  53. package/src/engine/webcomponents/needle-engine.ts +59 -189
  54. package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
  55. package/dist/gltf-progressive-BacJPTD6.umd.cjs +0 -10
  56. package/dist/gltf-progressive-BmXoz_HR.min.js +0 -10
  57. package/dist/gltf-progressive-CzxjNmG6.js +0 -1537
  58. package/dist/loader.worker-BqODMeeW.js +0 -23
  59. package/plugins/next/meshbvhworker.cjs +0 -19
@@ -1,4 +1,13 @@
1
1
  import { Context } from "./engine_setup.js";
2
+ declare global {
3
+ interface UserActivation {
4
+ readonly hasBeenActive: boolean;
5
+ readonly isActive: boolean;
6
+ }
7
+ interface Navigator {
8
+ readonly userActivation: UserActivation;
9
+ }
10
+ }
2
11
  export declare enum ApplicationEvents {
3
12
  Visible = "application-visible",
4
13
  Hidden = "application-hidden",
@@ -1 +1 @@
1
- {"version":3,"file":"engine_application.js","sourceRoot":"","sources":["../../src/engine/engine_application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,oDAA+B,CAAA;IAC/B,kDAA6B,CAAA;IAC7B,4DAAuC,CAAA;AAC3C,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B;AAED,IAAI,yBAAyB,GAAG,KAAK,CAAC;AACtC,MAAM,wBAAwB,GAAe,EAAE,CAAC;AAChD;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IACzC,IAAI,yBAAyB;QAAE,OAAO;IACtC,IAAI,gBAAgB,EAAE;QAAE,OAAO,CAAC,KAAK,CAAC,uEAAuE,CAAC,CAAC;IAC/G,yBAAyB,GAAG,IAAI,CAAC;IACjC,MAAM,IAAI,GAAG,CAAC,GAAG,wBAAwB,CAAC,CAAC;IAC3C,wBAAwB,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AACD,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC;AACtE,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC;AACtE,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;AAClE,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC;AACtE,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;AACrE,QAAQ,CAAC,gBAAgB,CAAC,SAAS,E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,QAAQ;QACf,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAEO,UAAU,GAAY,IAAI,CAAC;IAEnC,gBAAgB;IAChB,YAAY,OAAgB;QACxB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3F,CAAC;IAEO,kBAAkB,CAAC,GAAG;QAC1B,0CAA0C;QAC1C,QAAQ,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;YACjC,KAAK,QAAQ;gBACT,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;gBACxB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxD,MAAM;YACV,KAAK,SAAS;gBACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;gBACvB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACzD,MAAM;QACd,CAAC;IACL,CAAC"}
@@ -1,3 +1,3 @@
1
- export declare namespace NEEDLE_ENGINE_FEATURE_FLAGS {
2
- let experimentalSmartHierarchyUpdate: boolean;
3
- }
1
+ export declare const NEEDLE_ENGINE_FEATURE_FLAGS: {
2
+ experimentalSmartHierarchyUpdate: boolean;
3
+ };
@@ -1,6 +1,4 @@
1
- export var NEEDLE_ENGINE_FEATURE_FLAGS;
2
- (function (NEEDLE_ENGINE_FEATURE_FLAGS) {
3
- // eslint-disable-next-line prefer-const
4
- NEEDLE_ENGINE_FEATURE_FLAGS.experimentalSmartHierarchyUpdate = false;
5
- })(NEEDLE_ENGINE_FEATURE_FLAGS || (NEEDLE_ENGINE_FEATURE_FLAGS = {}));
1
+ export const NEEDLE_ENGINE_FEATURE_FLAGS = {
2
+ experimentalSmartHierarchyUpdate: false,
3
+ };
6
4
  //# sourceMappingURL=engine_feature_flags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine_feature_flags.js","sourceRoot":"","sources":["../../src/engine/engine_feature_flags.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,2BAA2B,CAK3C;AALD,WAAiB,2BAA2B;IAExC,wCAAwC;IAC7B,4DAAgC,GAAG,KAAK,CAAC;AAExD,CAAC,EALgB,2BAA2B,KAA3B,2BAA2B,QAK3C"}
1
+ {"version":3,"file":"engine_feature_flags.js","sourceRoot":"","sources":["../../src/engine/engine_feature_flags.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACvC,gCAAgC,EAAE,KAAK;CAC1C,CAAC"}
@@ -5,41 +5,37 @@
5
5
  *
6
6
  * If a module is already loaded it's also available in the `MODULE` variable.
7
7
  */
8
- export declare namespace MODULES {
9
- namespace MaterialX {
10
- type TYPE = typeof import("@needle-tools/materialx");
11
- let MODULE: TYPE;
12
- let MAYBEMODULE: TYPE | null;
8
+ export declare const MODULES: {
9
+ MaterialX: {
10
+ MODULE: typeof import("@needle-tools/materialx");
11
+ MAYBEMODULE: typeof import("@needle-tools/materialx") | null;
13
12
  /** Wait for the module to be loaded (doesn't trigger a load) */
14
- function ready(): Promise<TYPE>;
13
+ ready(): Promise<typeof import("@needle-tools/materialx")>;
15
14
  /** Load the module */
16
- function load(): Promise<TYPE>;
17
- }
18
- namespace RAPIER_PHYSICS {
19
- type TYPE = typeof import("@dimforge/rapier3d-compat");
20
- let MODULE: TYPE;
21
- let MAYBEMODULE: TYPE | null;
15
+ load(): Promise<typeof import("@needle-tools/materialx")>;
16
+ };
17
+ RAPIER_PHYSICS: {
18
+ MODULE: typeof import("@dimforge/rapier3d-compat");
19
+ MAYBEMODULE: typeof import("@dimforge/rapier3d-compat") | null;
22
20
  /** Wait for the module to be loaded (doesn't trigger a load) */
23
- function ready(): Promise<TYPE>;
21
+ ready(): Promise<typeof import("@dimforge/rapier3d-compat")>;
24
22
  /** Load the module */
25
- function load(): Promise<TYPE>;
26
- }
27
- namespace POSTPROCESSING {
28
- type TYPE = typeof import("postprocessing");
29
- let MODULE: TYPE;
30
- let MAYBEMODULE: TYPE | null;
23
+ load(): Promise<typeof import("@dimforge/rapier3d-compat")>;
24
+ };
25
+ POSTPROCESSING: {
26
+ MODULE: typeof import("postprocessing");
27
+ MAYBEMODULE: typeof import("postprocessing") | null;
31
28
  /** Wait for the module to be loaded (doesn't trigger a load) */
32
- function ready(): Promise<TYPE>;
29
+ ready(): Promise<typeof import("postprocessing")>;
33
30
  /** Load the module */
34
- function load(): Promise<TYPE>;
35
- }
36
- namespace POSTPROCESSING_AO {
37
- type TYPE = typeof import("n8ao");
38
- let MODULE: TYPE;
39
- let MAYBEMODULE: TYPE | null;
31
+ load(): Promise<typeof import("postprocessing")>;
32
+ };
33
+ POSTPROCESSING_AO: {
34
+ MODULE: any;
35
+ MAYBEMODULE: any;
40
36
  /** Wait for the module to be loaded (doesn't trigger a load) */
41
- function ready(): Promise<TYPE>;
37
+ ready(): Promise<any>;
42
38
  /** Load the module */
43
- function load(): Promise<TYPE>;
44
- }
45
- }
39
+ load(): Promise<any>;
40
+ };
41
+ };
@@ -1,3 +1,29 @@
1
+ function createModule(loader) {
2
+ const callbacks = [];
3
+ const mod = {
4
+ MODULE: undefined,
5
+ MAYBEMODULE: null,
6
+ /** Wait for the module to be loaded (doesn't trigger a load) */
7
+ ready() {
8
+ if (mod.MODULE)
9
+ return Promise.resolve(mod.MODULE);
10
+ return new Promise(resolve => { callbacks.push(resolve); });
11
+ },
12
+ /** Load the module */
13
+ async load() {
14
+ if (mod.MODULE)
15
+ return mod.MODULE;
16
+ const module = await loader();
17
+ mod.MODULE = module;
18
+ mod.MAYBEMODULE = module;
19
+ for (const cb of callbacks)
20
+ cb(module);
21
+ callbacks.length = 0;
22
+ return module;
23
+ }
24
+ };
25
+ return mod;
26
+ }
1
27
  /**
2
28
  * External dependencies that are loaded on demand either by the engine automatically when needed or they can be loaded manually by calling the `load` function.
3
29
  *
@@ -5,107 +31,10 @@
5
31
  *
6
32
  * If a module is already loaded it's also available in the `MODULE` variable.
7
33
  */
8
- export var MODULES;
9
- (function (MODULES) {
10
- let MaterialX;
11
- (function (MaterialX) {
12
- MaterialX.MAYBEMODULE = null;
13
- const callbacks = [];
14
- /** Wait for the module to be loaded (doesn't trigger a load) */
15
- function ready() {
16
- if (MaterialX.MODULE)
17
- return Promise.resolve(MaterialX.MODULE);
18
- return new Promise((resolve) => { callbacks.push(resolve); });
19
- }
20
- MaterialX.ready = ready;
21
- ;
22
- /** Load the module */
23
- async function load() {
24
- if (MaterialX.MODULE)
25
- return MaterialX.MODULE;
26
- const module = await import("@needle-tools/materialx");
27
- MaterialX.MODULE = module;
28
- MaterialX.MAYBEMODULE = module;
29
- callbacks.forEach((callback) => callback(module));
30
- callbacks.length = 0;
31
- return module;
32
- }
33
- MaterialX.load = load;
34
- })(MaterialX = MODULES.MaterialX || (MODULES.MaterialX = {}));
35
- let RAPIER_PHYSICS;
36
- (function (RAPIER_PHYSICS) {
37
- RAPIER_PHYSICS.MAYBEMODULE = null;
38
- const callbacks = [];
39
- /** Wait for the module to be loaded (doesn't trigger a load) */
40
- function ready() {
41
- if (RAPIER_PHYSICS.MODULE)
42
- return Promise.resolve(RAPIER_PHYSICS.MODULE);
43
- return new Promise((resolve) => { callbacks.push(resolve); });
44
- }
45
- RAPIER_PHYSICS.ready = ready;
46
- ;
47
- /** Load the module */
48
- async function load() {
49
- if (RAPIER_PHYSICS.MODULE)
50
- return RAPIER_PHYSICS.MODULE;
51
- const module = await import("@dimforge/rapier3d-compat");
52
- RAPIER_PHYSICS.MODULE = module;
53
- RAPIER_PHYSICS.MAYBEMODULE = module;
54
- callbacks.forEach((callback) => callback(module));
55
- callbacks.length = 0;
56
- return module;
57
- }
58
- RAPIER_PHYSICS.load = load;
59
- })(RAPIER_PHYSICS = MODULES.RAPIER_PHYSICS || (MODULES.RAPIER_PHYSICS = {}));
60
- let POSTPROCESSING;
61
- (function (POSTPROCESSING) {
62
- POSTPROCESSING.MAYBEMODULE = null;
63
- const callbacks = [];
64
- /** Wait for the module to be loaded (doesn't trigger a load) */
65
- function ready() {
66
- if (POSTPROCESSING.MODULE)
67
- return Promise.resolve(POSTPROCESSING.MODULE);
68
- return new Promise((resolve) => { callbacks.push(resolve); });
69
- }
70
- POSTPROCESSING.ready = ready;
71
- ;
72
- /** Load the module */
73
- async function load() {
74
- if (POSTPROCESSING.MODULE)
75
- return POSTPROCESSING.MODULE;
76
- const module = await import("postprocessing");
77
- POSTPROCESSING.MODULE = module;
78
- POSTPROCESSING.MAYBEMODULE = module;
79
- callbacks.forEach((callback) => callback(module));
80
- callbacks.length = 0;
81
- return module;
82
- }
83
- POSTPROCESSING.load = load;
84
- })(POSTPROCESSING = MODULES.POSTPROCESSING || (MODULES.POSTPROCESSING = {}));
85
- let POSTPROCESSING_AO;
86
- (function (POSTPROCESSING_AO) {
87
- POSTPROCESSING_AO.MAYBEMODULE = null;
88
- const callbacks = [];
89
- /** Wait for the module to be loaded (doesn't trigger a load) */
90
- function ready() {
91
- if (POSTPROCESSING_AO.MODULE)
92
- return Promise.resolve(POSTPROCESSING_AO.MODULE);
93
- return new Promise((resolve) => { callbacks.push(resolve); });
94
- }
95
- POSTPROCESSING_AO.ready = ready;
96
- ;
97
- /** Load the module */
98
- async function load() {
99
- if (POSTPROCESSING_AO.MODULE)
100
- return POSTPROCESSING_AO.MODULE;
101
- const module = await import("n8ao");
102
- POSTPROCESSING_AO.MODULE = module;
103
- POSTPROCESSING_AO.MAYBEMODULE = module;
104
- callbacks.forEach((callback) => callback(module));
105
- callbacks.length = 0;
106
- return module;
107
- }
108
- POSTPROCESSING_AO.load = load;
109
- })(POSTPROCESSING_AO = MODULES.POSTPROCESSING_AO || (MODULES.POSTPROCESSING_AO = {}));
110
- })(MODULES || (MODULES = {}));
34
+ export const MODULES = {
35
+ MaterialX: createModule(() => import("@needle-tools/materialx")),
36
+ RAPIER_PHYSICS: createModule(() => import("@dimforge/rapier3d-compat")),
37
+ POSTPROCESSING: createModule(() => import("postprocessing")),
38
+ POSTPROCESSING_AO: createModule(() => import("n8ao")),
39
+ };
111
40
  //# sourceMappingURL=engine_modules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine_modules.js","sourceRoot":"","sources":["../../src/engine/engine_modules.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,MAAM,KAAW,OAAO,CAmGvB;AAnGD,WAAiB,OAAO;IAEpB,IAAiB,SAAS,CAsBzB;IAtBD,WAAiB,SAAS;QAGX,qBAAW,GAAgB,IAAI,CAAC;QAE3C,MAAM,SAAS,GAAkC,EAAE,CAAC;QACpD,gEAAgE;QAChE,SAAgB,KAAK;YACjB,IAAI,UAAA,MAAM;gBAAE,OAAO,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM,CAAC,CAAC;YAC3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,CAAC;QAHe,eAAK,QAGpB,CAAA;QAAA,CAAC;QACF,sBAAsB;QACf,KAAK,UAAU,IAAI;YACtB,IAAI,UAAA,MAAM;gBAAE,OAAO,UAAA,MAAM,CAAC;YAC1B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;YACvD,UAAA,MAAM,GAAG,MAAM,CAAC;YAChB,UAAA,WAAW,GAAG,MAAM,CAAC;YACrB,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAClD,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrB,OA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AAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAClB,CAAC;KACJ,CAAC;IACF,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB,SAAS,EAAE,YAAY,CACnB,GAAG,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAC1C;IACD,cAAc,EAAE,YAAY,CACxB,GAAG,EAAE,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC5C;IACD,cAAc,EAAE,YAAY,CACxB,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACjC;IACD,iBAAiB,EAAE,YAAY,CAC3B,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CACvB;CACJ,CAAC"}
@@ -6,6 +6,57 @@ declare global {
6
6
  }
7
7
  }
8
8
  type TonemappingAttributeOptions = "none" | "linear" | "neutral" | "agx";
9
+ /** Supported attributes for the `<needle-engine>` web component. */
10
+ export interface NeedleEngineAttributes {
11
+ /** Change which model gets loaded. */
12
+ 'src': string;
13
+ /** String attached to the context for caching/identification. */
14
+ 'hash': string;
15
+ /** Set to automatically add OrbitControls to the loaded scene. */
16
+ 'camera-controls': string;
17
+ /** Override the default draco decoder path location. */
18
+ 'dracoDecoderPath': string;
19
+ /** Override the default draco library type. */
20
+ 'dracoDecoderType': 'wasm' | 'js';
21
+ /** Override the default KTX2 transcoder/decoder path. */
22
+ 'ktx2DecoderPath': string;
23
+ /** Prevent context from being disposed when element is removed from DOM. */
24
+ 'keep-alive': 'true' | 'false';
25
+ /** Loading overlay style. */
26
+ 'loading-style': 'dark' | 'light' | 'auto';
27
+ /** URL to .exr, .hdr, .png, .jpg to be used as skybox. */
28
+ 'background-image': string;
29
+ /** Rotation of the background image in degrees. */
30
+ 'background-rotation': string | number;
31
+ /** URL to .exr, .hdr, .png, .jpg to be used for lighting. */
32
+ 'environment-image': string;
33
+ /** Intensity multiplier for environment lighting. */
34
+ 'environment-intensity': string;
35
+ /** Blurs the background image. 0 (sharp) to 1 (fully blurred). */
36
+ 'background-blurriness': string;
37
+ /** Intensity multiplier for the background image. */
38
+ 'background-intensity': string;
39
+ /** CSS background color if no skybox/background image is provided. */
40
+ 'background-color': string;
41
+ /** Enable/disable renderer canvas transparency. */
42
+ 'transparent': 'true' | 'false';
43
+ /** Enable/disable contact shadows. */
44
+ 'contact-shadows': 'true' | 'false';
45
+ /** Tonemapping mode. */
46
+ 'tone-mapping': TonemappingAttributeOptions;
47
+ /** Exposure multiplier for tonemapping. */
48
+ 'tone-mapping-exposure': string;
49
+ /** CSS selector or HTMLElement for camera focus. */
50
+ 'focus-rect': string | HTMLElement;
51
+ /** Allow pointer events to pass through transparent parts. */
52
+ 'clickthrough': 'true' | 'false';
53
+ /** Automatically fit model into camera view on load. */
54
+ 'auto-fit': 'true' | 'false';
55
+ /** Auto-rotate model until user interacts. */
56
+ 'auto-rotate': 'true' | 'false';
57
+ /** Play animations automatically on scene load. */
58
+ 'autoplay': 'true' | 'false';
59
+ }
9
60
  /**
10
61
  * The `<needle-engine>` web component. See {@link NeedleEngineAttributes} attributes for supported attributes
11
62
  * The web component creates and manages a Needle Engine context, which is responsible for rendering a 3D scene using threejs.
@@ -133,150 +184,12 @@ export declare class NeedleEngineWebComponent extends HTMLElement implements INe
133
184
  private setupElementsForMode;
134
185
  private foreachHtmlElement;
135
186
  private onBeforeBeginLoading;
136
- /** Change which model gets loaded. This will trigger a reload of the scene.
137
- * @example src="path/to/scene.glb"
138
- * @example src="[./path/scene1.glb, myOtherScene.gltf]"
139
- * */
140
- setAttribute(name: 'src', value: string): void;
141
- /** Optional. String attached to the context for caching/identification. */
142
- setAttribute(name: 'hash', value: string): void;
143
- /** Set to automatically add {@link OrbitControls} to the loaded scene */
144
- setAttribute(name: 'camera-controls', value: string): void;
145
- /** Override the default draco decoder path location. */
146
- setAttribute(name: 'dracoDecoderPath', value: string): void;
147
- /** Override the default draco library type. */
148
- setAttribute(name: 'dracoDecoderType', value: 'wasm' | 'js'): void;
149
- /** Override the default KTX2 transcoder/decoder path */
150
- setAttribute(name: 'ktx2DecoderPath', value: string): void;
151
- /** Prevent Needle Engine context from being disposed when the element is removed from the DOM */
152
- setAttribute(name: 'keep-alive', value: 'true' | 'false'): void;
153
- /** @private Public key used for licensing and feature gating. */
154
- setAttribute(name: 'public-key', value: string): void;
155
- /** @private Engine version string — usually set by the build/runtime. */
156
- setAttribute(name: 'version', value: string): void;
157
- /** URL to .exr, .hdr, .png, .jpg to be used as skybox */
158
- setAttribute(name: 'background-image', value: string): void;
159
- /** @private Rotation of the background image in degrees. */
160
- setAttribute(name: 'background-rotation', value: string | number): void;
161
- /** @deprecated Use 'environment-image' instead. */
162
- setAttribute(name: 'skybox-image', value: string): void;
163
- /** URL to .exr, .hdr, .png, .jpg to be used for lighting */
164
- setAttribute(name: 'environment-image', value: string): void;
165
- /** Intensity multiplier for environment lighting. */
166
- setAttribute(name: 'environment-intensity', value: string): void;
167
- /** Blurs the background image. Strength between 0 (sharp) and 1 (fully blurred). */
168
- setAttribute(name: 'background-blurriness', value: string): void;
169
- /** Intensity multiplier for the background image. */
170
- setAttribute(name: 'background-intensity', value: string): void;
171
- /**
172
- * CSS background color value to be used if no skybox or background image is provided.
173
- * @example "background-color='#ff0000'" will set the background color to red.
174
- */
175
- setAttribute(name: 'background-color', value: string): void;
176
- /** Enable/disable renderer canvas transparency. */
177
- setAttribute(name: 'transparent', value: 'true' | 'false'): void;
178
- /** Enable/disable contact shadows in the rendered scene */
179
- setAttribute(name: 'contact-shadows', value: 'true' | 'false'): void;
180
- /** Tonemapping mode. */
181
- setAttribute(name: 'tone-mapping', value: TonemappingAttributeOptions): void;
182
- /** Exposure multiplier for tonemapping. */
183
- setAttribute(name: 'tone-mapping-exposure', value: string): void;
184
- /** Defines a CSS selector or HTMLElement where the camera should be focused on. Content will be fit into this element. */
185
- setAttribute(name: 'focus-rect', value: string | HTMLElement): void;
186
- /** Allow pointer events to pass through transparent parts of the content to the underlying DOM elements. */
187
- setAttribute(name: 'clickthrough', value: 'true' | 'false'): void;
188
- /** Automatically fits the model into the camera view on load. */
189
- setAttribute(name: 'auto-fit', value: 'true' | 'false'): void;
190
- /** Automatically rotates the model until a user interacts with the scene. */
191
- setAttribute(name: 'auto-rotate', value: 'true' | 'false'): void;
192
- /** Play animations automatically on scene load */
193
- setAttribute(name: "autoplay", value: 'true' | 'false'): void;
194
- /** @private Used for switching the scene in SceneSwitcher */
195
- setAttribute(name: 'scene', value: string): void;
196
- /** @private Experimental.*/
197
- setAttribute(name: 'loading-blur', value: 'true' | 'false'): void;
198
- /** @private */
199
- setAttribute(name: 'alias', value: string): void;
200
- /** @private */
201
- setAttribute(name: 'hide-loading-overlay', value: 'true' | 'false'): void;
202
- /** @private */
203
- setAttribute(name: 'no-telemetry', value: 'true' | 'false'): void;
204
- /** Generic typed setter for known Needle Engine attributes */
205
- setAttribute(qualifiedName: ({} & string), value: string): void;
206
- /** Change which model gets loaded. This will trigger a reload of the scene.
207
- * @example src="path/to/scene.glb"
208
- * @example src="[./path/scene1.glb, myOtherScene.gltf]"
209
- * */
210
- getAttribute(name: 'src'): string | null;
211
- /** Optional. String attached to the context for caching/identification. */
212
- getAttribute(name: 'hash'): string | null;
213
- /** Set to automatically add {@link OrbitControls} to the loaded scene */
214
- getAttribute(name: 'camera-controls'): "true" | "false" | "none" | null;
215
- /** Override the default draco decoder path location. */
216
- getAttribute(name: 'dracoDecoderPath'): string | null;
217
- /** Override the default draco library type. */
218
- getAttribute(name: 'dracoDecoderType'): "wasm" | "js" | null;
219
- /** Override the default KTX2 transcoder/decoder path */
220
- getAttribute(name: 'ktx2DecoderPath'): string | null;
221
- /** Prevent Needle Engine context from being disposed when the element is removed from the DOM */
222
- getAttribute(name: 'keep-alive'): string | null;
223
- /** @private Public key used for licensing and feature gating. */
224
- getAttribute(name: 'public-key'): string | null;
225
- /** @private Engine version string — usually set by the build/runtime. */
226
- getAttribute(name: 'version'): string | null;
227
- /** URL to .exr, .hdr, .png, .jpg to be used as skybox */
228
- getAttribute(name: 'background-image'): string | null;
229
- /** @private Rotation of the background image in degrees. */
230
- getAttribute(name: 'background-rotation'): string | null;
231
- /** URL to .exr, .hdr, .png, .jpg to be used for lighting */
232
- getAttribute(name: 'environment-image'): string | null;
233
- /** Intensity multiplier for environment lighting. */
234
- getAttribute(name: 'environment-intensity'): string | null;
235
- /** Blurs the background image. Strength between 0 (sharp) and 1 (fully blurred). */
236
- getAttribute(name: 'background-blurriness'): string | null;
237
- /** Intensity multiplier for the background image. */
238
- getAttribute(name: 'background-intensity'): string | null;
239
- /**
240
- * CSS background color value to be used if no skybox or background image is provided.
241
- * @example "background-color='#ff0000'" will set the background color to red.
242
- */
243
- getAttribute(name: 'background-color'): string | null;
244
- /** Enable/disable renderer canvas transparency. */
245
- getAttribute(name: 'transparent'): string | null;
246
- /** Enable/disable contact shadows in the rendered scene */
247
- getAttribute(name: 'contact-shadows'): string | null;
248
- /** @deprecated Use 'contact-shadows' instead. */
249
- getAttribute(name: 'contactshadows'): string | null;
250
- /** Tonemapping mode. */
251
- getAttribute(name: 'tone-mapping'): TonemappingAttributeOptions | null;
252
- /** @deprecated Use 'tone-mapping' instead. */
253
- getAttribute(name: 'tonemapping'): TonemappingAttributeOptions | null;
254
- /** Exposure multiplier for tonemapping. */
255
- getAttribute(name: 'tone-mapping-exposure'): string | null;
256
- /** Defines a CSS selector or HTMLElement where the camera should be focused on. Content will be fit into this element. */
257
- getAttribute(name: 'focus-rect'): string | null;
258
- /** Allow pointer events to pass through transparent parts of the content to the underlying DOM elements. */
259
- getAttribute(name: 'clickthrough'): string | null;
260
- /** Automatically fits the model into the camera view on load. */
261
- getAttribute(name: 'auto-fit'): string | null;
262
- /** @deprecated Use 'auto-fit' instead. */
263
- getAttribute(name: 'autofit'): string | null;
264
- /** Automatically rotates the model until a user interacts with the scene. */
265
- getAttribute(name: 'auto-rotate'): string | null;
266
- /** Play animations automatically on scene load */
267
- getAttribute(name: "autoplay"): string | null;
268
- /** @private Used for switching the scene in SceneSwitcher */
269
- getAttribute(name: 'scene'): string | null;
270
- /** @private Experimental.*/
271
- getAttribute(name: 'loading-blur'): string | null;
272
- /** @private */
273
- getAttribute(name: 'alias'): string | null;
274
- /** @private */
275
- getAttribute(name: 'hide-loading-overlay'): string | null;
276
- /** @private */
277
- getAttribute(name: 'no-telemetry'): string | null;
278
- /** Typed getter for known NeedleEngine attribute names; returns the typed shape declared in NeedleEngineAttributes or null. */
279
- getAttribute(qualifiedName: ({} & string)): string | null;
187
+ /** Set a known Needle Engine attribute. See {@link NeedleEngineAttributes} for available attributes. */
188
+ setAttribute<K extends keyof NeedleEngineAttributes>(name: K, value: NeedleEngineAttributes[K]): void;
189
+ setAttribute(qualifiedName: string, value: string): void;
190
+ /** Get a known Needle Engine attribute. See {@link NeedleEngineAttributes} for available attributes. */
191
+ getAttribute<K extends keyof NeedleEngineAttributes>(qualifiedName: K): string | null;
192
+ getAttribute(qualifiedName: string): string | null;
280
193
  /**
281
194
  * Emitted when loading begins for the scene. The event is cancelable — calling `preventDefault()`
282
195
  * will stop the default loading UI behavior, so apps can implement custom loading flows.
@@ -849,18 +849,9 @@ export class NeedleEngineWebComponent extends HTMLElement {
849
849
  setKtx2TranscoderPath(customKtx2DecoderPath);
850
850
  }
851
851
  }
852
- // The ones we're using internally:
853
- /*
854
- setAttribute(name: "tabindex", value: string): void;
855
- */
856
852
  setAttribute(qualifiedName, value) {
857
- super.setAttribute(qualifiedName, value);
853
+ super.setAttribute(qualifiedName, typeof value === "string" ? value : String(value));
858
854
  }
859
- // The ones we're using interally:
860
- /*
861
- getAttribute(name: "autostart"): string | null;
862
- getAttribute(name: "tabindex"): string | null;
863
- */
864
855
  getAttribute(qualifiedName) {
865
856
  return super.getAttribute(qualifiedName);
866
857
  }