@needle-tools/engine 5.1.0-canary.db0c38f → 5.1.0-canary.e9062c0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.needle/generated/needle-bindings.gen.d.ts +5 -0
- package/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-Dq0Ly8fW.umd.cjs → needle-engine.bundle--q_w7iXI.umd.cjs} +125 -125
- package/dist/{needle-engine.bundle-B29kieh0.js → needle-engine.bundle-CDKcuALa.js} +3481 -3422
- package/dist/{needle-engine.bundle-YnpzzOPL.min.js → needle-engine.bundle-w22UkaT_.min.js} +137 -137
- package/dist/needle-engine.d.ts +61 -41
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/api.d.ts +1 -1
- package/lib/engine/engine_context.d.ts +7 -3
- package/lib/engine/engine_context.js +16 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_init.js +5 -0
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_license.d.ts +2 -0
- package/lib/engine/engine_license.js +14 -6
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
- package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
- package/lib/engine/engine_pmrem.js +2 -2
- package/lib/engine/engine_pmrem.js.map +1 -1
- package/lib/engine/engine_scenedata.d.ts +8 -10
- package/lib/engine/engine_scenedata.js +44 -20
- package/lib/engine/engine_scenedata.js.map +1 -1
- package/lib/engine/engine_ssr.d.ts +2 -0
- package/lib/engine/engine_ssr.js +20 -0
- package/lib/engine/engine_ssr.js.map +1 -1
- package/lib/engine/engine_types.d.ts +2 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/webcomponents/jsx.d.ts +44 -0
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +2 -3
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-button.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine-components/Light.d.ts +6 -8
- package/lib/engine-components/Light.js +38 -27
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/needle-engine.d.ts +2 -0
- package/lib/needle-engine.js +2 -0
- package/lib/needle-engine.js.map +1 -1
- package/package.json +3 -2
- package/plugins/dts-generator/dts.codegen.js +255 -50
- package/plugins/dts-generator/dts.scan.js +37 -9
- package/plugins/dts-generator/dts.writer.js +1 -1
- package/plugins/dts-generator/glb.discovery.js +140 -23
- package/plugins/dts-generator/glb.extractor.js +48 -8
- package/plugins/dts-generator/glb.reader.js +80 -27
- package/plugins/dts-generator/index.js +1 -1
- package/plugins/types/needle-bindings.d.ts +25 -14
- package/plugins/types/userconfig.d.ts +12 -0
- package/plugins/vite/asap.js +1 -1
- package/plugins/vite/dependency-watcher.d.ts +2 -2
- package/plugins/vite/dependency-watcher.js +3 -4
- package/plugins/vite/drop.d.ts +2 -2
- package/plugins/vite/drop.js +3 -4
- package/plugins/vite/dts-generator.d.ts +2 -2
- package/plugins/vite/dts-generator.js +43 -9
- package/plugins/vite/index.d.ts +9 -3
- package/plugins/vite/index.js +23 -10
- package/plugins/vite/meta.js +4 -2
- package/plugins/vite/poster.d.ts +2 -2
- package/plugins/vite/poster.js +3 -5
- package/plugins/vite/reload.d.ts +2 -2
- package/plugins/vite/reload.js +4 -5
- package/src/engine/api.ts +1 -1
- package/src/engine/engine_context.ts +19 -3
- package/src/engine/engine_init.ts +4 -0
- package/src/engine/engine_license.ts +12 -10
- package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
- package/src/engine/engine_pmrem.ts +3 -3
- package/src/engine/engine_scenedata.ts +41 -18
- package/src/engine/engine_ssr.ts +29 -3
- package/src/engine/engine_types.ts +2 -0
- package/src/engine/webcomponents/jsx.d.ts +44 -0
- package/src/engine/webcomponents/logo-element.ts +1 -0
- package/src/engine/webcomponents/needle menu/needle-menu.ts +2 -1
- package/src/engine/webcomponents/needle-button.ts +1 -0
- package/src/engine/webcomponents/needle-engine.ts +1 -0
- package/src/engine-components/Light.ts +39 -26
- package/src/needle-engine.ts +3 -0
package/src/engine/engine_ssr.ts
CHANGED
|
@@ -9,14 +9,40 @@
|
|
|
9
9
|
* to a plain empty class so that `class Foo extends HTMLElementBase` is valid.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
|
|
13
|
+
/** True when running in an SSR/Node environment (no browser globals). */
|
|
14
|
+
export const SSR: boolean = typeof window === "undefined";
|
|
15
|
+
|
|
12
16
|
/** SSR-safe base class for web components. */
|
|
13
17
|
export const HTMLElementBase: typeof HTMLElement =
|
|
14
|
-
typeof HTMLElement !== "undefined" ? HTMLElement : (class {} as unknown as typeof HTMLElement);
|
|
18
|
+
typeof HTMLElement !== "undefined" ? HTMLElement : (class { } as unknown as typeof HTMLElement);
|
|
15
19
|
|
|
16
20
|
/** SSR-safe base class for pointer events. */
|
|
17
21
|
export const PointerEventBase: typeof PointerEvent =
|
|
18
|
-
typeof PointerEvent !== "undefined" ? PointerEvent : (class {} as unknown as typeof PointerEvent);
|
|
22
|
+
typeof PointerEvent !== "undefined" ? PointerEvent : (class { } as unknown as typeof PointerEvent);
|
|
19
23
|
|
|
20
24
|
/** SSR-safe base class for keyboard events. */
|
|
21
25
|
export const KeyboardEventBase: typeof KeyboardEvent =
|
|
22
|
-
typeof KeyboardEvent !== "undefined" ? KeyboardEvent : (class {} as unknown as typeof KeyboardEvent);
|
|
26
|
+
typeof KeyboardEvent !== "undefined" ? KeyboardEvent : (class { } as unknown as typeof KeyboardEvent);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// #region minimal polyfills
|
|
32
|
+
// Three.js FileLoader uses ProgressEvent in fetch stream callbacks.
|
|
33
|
+
// It doesn't exist in Node — install a minimal stub so SSR doesn't crash.
|
|
34
|
+
if (typeof globalThis.ProgressEvent === "undefined") {
|
|
35
|
+
(globalThis as any).ProgressEvent = class ProgressEvent {
|
|
36
|
+
readonly type: string;
|
|
37
|
+
readonly lengthComputable: boolean;
|
|
38
|
+
readonly loaded: number;
|
|
39
|
+
readonly total: number;
|
|
40
|
+
constructor(type: string, init?: { lengthComputable?: boolean; loaded?: number; total?: number }) {
|
|
41
|
+
this.type = type;
|
|
42
|
+
this.lengthComputable = init?.lengthComputable ?? false;
|
|
43
|
+
this.loaded = init?.loaded ?? 0;
|
|
44
|
+
this.total = init?.total ?? 0;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// #endregion
|
|
@@ -258,6 +258,8 @@ export declare interface ICameraController {
|
|
|
258
258
|
export declare interface ILight extends IComponent {
|
|
259
259
|
intensity: number;
|
|
260
260
|
color: Color;
|
|
261
|
+
/** The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"` */
|
|
262
|
+
readonly type: "directional" | "point" | "spot";
|
|
261
263
|
}
|
|
262
264
|
|
|
263
265
|
export declare interface ISharedMaterials {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSX IntrinsicElements declarations for Needle Engine web components.
|
|
3
|
+
*
|
|
4
|
+
* Covers both the global JSX namespace (Preact, SolidJS, Svelte, vanilla TS)
|
|
5
|
+
* and React's module-scoped JSX namespace (react-jsx / react-jsxdev transform).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface NeedleButtonJSXAttributes extends Partial<Omit<HTMLElement, "style" | "children">> {
|
|
9
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
10
|
+
ar?: boolean | string;
|
|
11
|
+
vr?: boolean | string;
|
|
12
|
+
quicklook?: boolean | string;
|
|
13
|
+
qrcode?: boolean | string;
|
|
14
|
+
unstyled?: boolean | string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface NeedleMenuJSXAttributes extends Partial<Omit<HTMLElement, "style" | "children">> {
|
|
18
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface NeedleLogoElementJSXAttributes extends Partial<Omit<HTMLElement, "style" | "children">> {
|
|
22
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface NeedleElements {
|
|
26
|
+
"needle-engine": import("./needle-engine.js").NeedleEngineAttributes;
|
|
27
|
+
"needle-button": NeedleButtonJSXAttributes;
|
|
28
|
+
"needle-menu": NeedleMenuJSXAttributes;
|
|
29
|
+
"needle-logo-element": NeedleLogoElementJSXAttributes;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Global JSX namespace — Preact, SolidJS, Svelte, vanilla TS
|
|
33
|
+
declare global {
|
|
34
|
+
namespace JSX {
|
|
35
|
+
interface IntrinsicElements extends NeedleElements {}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// React module-scoped JSX namespace
|
|
40
|
+
declare module "react" {
|
|
41
|
+
namespace JSX {
|
|
42
|
+
interface IntrinsicElements extends NeedleElements {}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -12,9 +12,10 @@ import { NeedleLogoElement } from "../logo-element.js";
|
|
|
12
12
|
import { getElementPriority, setElementPriority as _setElementPriority } from "./menu-priority.js";
|
|
13
13
|
import { NeedleSpatialMenu } from "./needle-menu-spatial.js";
|
|
14
14
|
|
|
15
|
+
// NOTE: keep JSX attributes in sync with ../jsx.d.ts
|
|
15
16
|
declare global {
|
|
16
17
|
interface HTMLElementTagNameMap {
|
|
17
|
-
"needle-
|
|
18
|
+
"needle-menu": NeedleMenuElement;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -4,6 +4,7 @@ import { ButtonsFactory } from "./buttons.js";
|
|
|
4
4
|
import { iconFontUrl, loadFont } from "./fonts.js";
|
|
5
5
|
import { WebXRButtonFactory } from "./WebXRButtons.js";
|
|
6
6
|
|
|
7
|
+
// NOTE: keep JSX attributes in sync with ./jsx.d.ts
|
|
7
8
|
declare global {
|
|
8
9
|
interface HTMLElementTagNameMap {
|
|
9
10
|
"needle-button": NeedleButtonElement;
|
|
@@ -17,6 +17,7 @@ import { arContainerClassName, AROverlayHandler } from "./needle-engine.ar-overl
|
|
|
17
17
|
import type { registerObservableAttribute } from "./needle-engine.extras.js";
|
|
18
18
|
import { calculateProgress01, EngineLoadingView, type ILoadingViewHandler } from "./needle-engine.loading.js";
|
|
19
19
|
|
|
20
|
+
// NOTE: keep JSX attributes in sync with ./jsx.d.ts
|
|
20
21
|
declare global {
|
|
21
22
|
interface HTMLElementTagNameMap {
|
|
22
23
|
"needle-engine": NeedleEngineWebComponent;
|
|
@@ -106,11 +106,40 @@ enum LightShadows {
|
|
|
106
106
|
export class Light extends Behaviour implements ILight {
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* The type of light
|
|
110
|
-
* Can not be changed at runtime.
|
|
109
|
+
* The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"`.
|
|
110
|
+
* Implements {@link ILight.type}. Can not be changed at runtime.
|
|
111
111
|
*/
|
|
112
|
+
get type(): ILight["type"] {
|
|
113
|
+
return this._type;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Numeric LightType serialized from Unity/Blender — converts to string on write */
|
|
112
117
|
@serializable()
|
|
113
|
-
|
|
118
|
+
set type(value: LightType | ILight["type"]) {
|
|
119
|
+
if (this.light && this.__didAwake) {
|
|
120
|
+
throw new Error("Changing the light type at runtime is not supported");
|
|
121
|
+
}
|
|
122
|
+
switch (value) {
|
|
123
|
+
case LightType.Directional:
|
|
124
|
+
this._type = "directional";
|
|
125
|
+
break;
|
|
126
|
+
case LightType.Point:
|
|
127
|
+
this._type = "point";
|
|
128
|
+
break;
|
|
129
|
+
case LightType.Spot:
|
|
130
|
+
this._type = "spot";
|
|
131
|
+
break;
|
|
132
|
+
case "directional":
|
|
133
|
+
case "point":
|
|
134
|
+
case "spot":
|
|
135
|
+
this._type = value;
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
throw new Error("Invalid light type: " + value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
private _type: ILight["type"] = "point";
|
|
142
|
+
|
|
114
143
|
|
|
115
144
|
/**
|
|
116
145
|
* The maximum distance the light affects.
|
|
@@ -345,7 +374,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
345
374
|
*/
|
|
346
375
|
public getWorldPosition(vec: Vector3): Vector3 {
|
|
347
376
|
if (this.light) {
|
|
348
|
-
if (this.type ===
|
|
377
|
+
if (this.type === "directional") {
|
|
349
378
|
return this.light.getWorldPosition(vec).multiplyScalar(1);
|
|
350
379
|
}
|
|
351
380
|
return this.light.getWorldPosition(vec);
|
|
@@ -372,12 +401,12 @@ export class Light extends Behaviour implements ILight {
|
|
|
372
401
|
else if (this.light.parent !== this.gameObject)
|
|
373
402
|
this.gameObject.add(this.light);
|
|
374
403
|
}
|
|
375
|
-
|
|
376
|
-
this.startCoroutine(this.updateMainLightRoutine(), FrameEvent.LateUpdate);
|
|
404
|
+
this.context.lights.add(this);
|
|
377
405
|
}
|
|
378
406
|
|
|
379
407
|
onDisable() {
|
|
380
408
|
if (debug) console.log("DISABLE LIGHT", this.name);
|
|
409
|
+
this.context.lights.delete(this);
|
|
381
410
|
if (this.light) {
|
|
382
411
|
if (this.selfIsLight)
|
|
383
412
|
this.light.intensity = 0;
|
|
@@ -399,14 +428,14 @@ export class Light extends Behaviour implements ILight {
|
|
|
399
428
|
this._intensity = this.light.intensity;
|
|
400
429
|
|
|
401
430
|
switch (this.type) {
|
|
402
|
-
case
|
|
431
|
+
case "directional":
|
|
403
432
|
this.setDirectionalLight(this.light as DirectionalLight);
|
|
404
433
|
break;
|
|
405
434
|
}
|
|
406
435
|
}
|
|
407
436
|
else if (!this.light) {
|
|
408
437
|
switch (this.type) {
|
|
409
|
-
case
|
|
438
|
+
case "directional":
|
|
410
439
|
// console.log(this);
|
|
411
440
|
const dirLight = new DirectionalLight(this.color, this.intensity * Math.PI);
|
|
412
441
|
// directional light target is at 0 0 0 by default
|
|
@@ -425,7 +454,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
425
454
|
}
|
|
426
455
|
break;
|
|
427
456
|
|
|
428
|
-
case
|
|
457
|
+
case "spot":
|
|
429
458
|
const spotLight = new SpotLight(this.color, this.intensity * Math.PI, this.range, toRadians(this.spotAngle / 2), 1 - toRadians(this.innerSpotAngle / 2) / toRadians(this.spotAngle / 2), 2);
|
|
430
459
|
spotLight.position.set(0, 0, 0);
|
|
431
460
|
spotLight.rotation.set(0, 0, 0);
|
|
@@ -437,7 +466,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
437
466
|
spotLightTarget.rotation.set(0, 0, 0);
|
|
438
467
|
break;
|
|
439
468
|
|
|
440
|
-
case
|
|
469
|
+
case "point":
|
|
441
470
|
const pointLight = new PointLight(this.color, this.intensity * Math.PI, this.range);
|
|
442
471
|
this.light = pointLight;
|
|
443
472
|
|
|
@@ -526,22 +555,6 @@ export class Light extends Behaviour implements ILight {
|
|
|
526
555
|
|
|
527
556
|
}
|
|
528
557
|
|
|
529
|
-
/**
|
|
530
|
-
* Coroutine that updates the main light reference in the context
|
|
531
|
-
* if this directional light should be the main light
|
|
532
|
-
*/
|
|
533
|
-
*updateMainLightRoutine() {
|
|
534
|
-
while (true) {
|
|
535
|
-
if (this.type === LightType.Directional) {
|
|
536
|
-
if (!this.context.mainLight || this.intensity > this.context.mainLight.intensity) {
|
|
537
|
-
this.context.mainLight = this;
|
|
538
|
-
}
|
|
539
|
-
yield;
|
|
540
|
-
}
|
|
541
|
-
break;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
558
|
/**
|
|
546
559
|
* Controls whether the renderer's shadow map type can be changed when soft shadows are used
|
|
547
560
|
*/
|
package/src/needle-engine.ts
CHANGED