@needle-tools/engine 4.16.0-next.bc4d35d → 4.16.1
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/CHANGELOG.md +3 -0
- package/dist/{needle-engine.bundle-Cqmarm0m.min.js → needle-engine.bundle-C3aSGlMn.min.js} +18 -18
- package/dist/{needle-engine.bundle-KyGODqE9.js → needle-engine.bundle-CKIxz09L.js} +115 -116
- package/dist/{needle-engine.bundle-DT0VwGmo.umd.cjs → needle-engine.bundle-DSHShuiJ.umd.cjs} +19 -19
- package/dist/needle-engine.d.ts +15 -15
- 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/engine_context.js +2 -0
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +1 -1
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +1 -1
- package/lib/engine/webcomponents/needle-engine.js +21 -23
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/engine_context.ts +1 -0
- package/src/engine/webcomponents/logo-element.ts +1 -1
- package/src/engine/webcomponents/needle-engine.ts +41 -47
|
@@ -14,7 +14,7 @@ import { getParam } from "../engine_utils.js";
|
|
|
14
14
|
import { RGBAColor } from "../js-extensions/RGBAColor.js";
|
|
15
15
|
import { ensureFonts } from "./fonts.js";
|
|
16
16
|
import { arContainerClassName, AROverlayHandler } from "./needle-engine.ar-overlay.js";
|
|
17
|
-
import type { registerObservableAttribute} from "./needle-engine.extras.js";
|
|
17
|
+
import type { registerObservableAttribute } from "./needle-engine.extras.js";
|
|
18
18
|
import { calculateProgress01, EngineLoadingView, type ILoadingViewHandler } from "./needle-engine.loading.js";
|
|
19
19
|
|
|
20
20
|
declare global {
|
|
@@ -169,7 +169,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
169
169
|
public get context() { return this._context; }
|
|
170
170
|
|
|
171
171
|
private _context!: Context;
|
|
172
|
-
private _overlay_ar
|
|
172
|
+
private _overlay_ar!: AROverlayHandler;
|
|
173
173
|
private _loadingProgress01: number = 0;
|
|
174
174
|
private _loadingView?: ILoadingViewHandler;
|
|
175
175
|
private _previousSrc: string | null | string[] = null;
|
|
@@ -179,28 +179,8 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
179
179
|
|
|
180
180
|
constructor() {
|
|
181
181
|
super();
|
|
182
|
-
|
|
183
|
-
this.addEventListener("ready", this.onReady);
|
|
184
|
-
this._overlay_ar = new AROverlayHandler();
|
|
185
|
-
this._context = new Context({ domElement: this });
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
private ensureInitialized() {
|
|
189
|
-
if (!this._didInitialize) {
|
|
190
|
-
this._didInitialize = true;
|
|
191
|
-
this.initializeDom();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
private initializeDom() {
|
|
196
|
-
|
|
197
|
-
ensureFonts();
|
|
198
|
-
|
|
199
|
-
const shadow = this.attachShadow({ mode: 'open', delegatesFocus: true });
|
|
200
|
-
this.setAttribute("role", "application");
|
|
201
|
-
this.setAttribute("aria-label", "Needle Engine 3D scene");
|
|
182
|
+
this.attachShadow({ mode: 'open', delegatesFocus: true });
|
|
202
183
|
const template = document.createElement('template');
|
|
203
|
-
// #region CSS
|
|
204
184
|
template.innerHTML = `<style>
|
|
205
185
|
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');
|
|
206
186
|
|
|
@@ -266,7 +246,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
266
246
|
}
|
|
267
247
|
:host .quit-ar-button {
|
|
268
248
|
position: absolute;
|
|
269
|
-
|
|
249
|
+
/** top: env(titlebar-area-y); this doesnt work **/
|
|
270
250
|
top: 60px; /** camera access needs a bit more space **/
|
|
271
251
|
right: 20px;
|
|
272
252
|
z-index: 9999;
|
|
@@ -279,25 +259,36 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
279
259
|
<slot class="overlay-content" style="display: contents;"></slot>
|
|
280
260
|
</div>
|
|
281
261
|
`;
|
|
282
|
-
// #endregion
|
|
283
262
|
|
|
284
|
-
|
|
263
|
+
this.shadowRoot!.appendChild(template.content.cloneNode(true));
|
|
285
264
|
|
|
265
|
+
// TODO: do we want to rename this event?
|
|
266
|
+
this.addEventListener("ready", this.onReady);
|
|
286
267
|
this.addEventListener("error", this.onError);
|
|
287
268
|
}
|
|
288
269
|
|
|
270
|
+
private ensureInitialized() {
|
|
271
|
+
if (!this._didInitialize) {
|
|
272
|
+
this._didInitialize = true;
|
|
273
|
+
this.initializeDom();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// #region Init DOM
|
|
278
|
+
private initializeDom() {
|
|
279
|
+
ensureFonts();
|
|
280
|
+
this.setAttribute("role", "application");
|
|
281
|
+
this.setAttribute("aria-label", "Needle Engine 3D scene");
|
|
282
|
+
}
|
|
283
|
+
|
|
289
284
|
|
|
290
285
|
/**
|
|
291
286
|
* @internal
|
|
292
287
|
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (debug) {
|
|
296
|
-
console.log("<needle-engine> connected");
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
this.ensureInitialized();
|
|
288
|
+
connectedCallback() {
|
|
289
|
+
if (debug) console.log("<needle-engine> connected");
|
|
300
290
|
|
|
291
|
+
this.ensureInitialized();
|
|
301
292
|
this.setPublicKey();
|
|
302
293
|
this.setVersion();
|
|
303
294
|
|
|
@@ -306,9 +297,13 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
306
297
|
this.setAttribute("tabindex", "0");
|
|
307
298
|
|
|
308
299
|
|
|
300
|
+
this._overlay_ar = new AROverlayHandler();
|
|
301
|
+
this._context ??= new Context({ domElement: this }); // we might have one already if onLoad is running
|
|
309
302
|
this.addEventListener("xr-session-started", this.onXRSessionStarted);
|
|
310
303
|
this.onSetupDesktop();
|
|
311
304
|
|
|
305
|
+
|
|
306
|
+
|
|
312
307
|
if (!this.getAttribute("src")) {
|
|
313
308
|
const global = (globalThis as any)["needle:codegen_files"] as unknown as string;
|
|
314
309
|
if (debug) console.log("src is null, trying to load from globalThis[\"needle:codegen_files\"]", global);
|
|
@@ -455,6 +450,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
455
450
|
private async onLoad() {
|
|
456
451
|
|
|
457
452
|
if (!this.isConnected) return;
|
|
453
|
+
|
|
458
454
|
if (!this._context) {
|
|
459
455
|
if (debug) console.warn("Create new context");
|
|
460
456
|
this._context = new Context({ domElement: this });
|
|
@@ -489,7 +485,6 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
489
485
|
this.classList.add("loading");
|
|
490
486
|
|
|
491
487
|
|
|
492
|
-
|
|
493
488
|
// Loading start events
|
|
494
489
|
const allowOverridingDefaultLoading = hasCommercialLicense();
|
|
495
490
|
// default loading can be overriden by calling preventDefault in the onload start event
|
|
@@ -914,7 +909,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
914
909
|
setAttribute(name: 'ktx2DecoderPath', value: string): void;
|
|
915
910
|
/** Prevent Needle Engine context from being disposed when the element is removed from the DOM */
|
|
916
911
|
setAttribute(name: 'keep-alive', value: 'true' | 'false'): void;
|
|
917
|
-
|
|
912
|
+
|
|
918
913
|
/** @private Public key used for licensing and feature gating. */
|
|
919
914
|
setAttribute(name: 'public-key', value: string): void;
|
|
920
915
|
/** @private Engine version string — usually set by the build/runtime. */
|
|
@@ -922,7 +917,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
922
917
|
|
|
923
918
|
// LoadingAttributes
|
|
924
919
|
// ...
|
|
925
|
-
|
|
920
|
+
|
|
926
921
|
// SkyboxAttributes
|
|
927
922
|
/** URL to .exr, .hdr, .png, .jpg to be used as skybox */
|
|
928
923
|
setAttribute(name: 'background-image', value: string): void;
|
|
@@ -943,7 +938,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
943
938
|
* @example "background-color='#ff0000'" will set the background color to red.
|
|
944
939
|
*/
|
|
945
940
|
setAttribute(name: 'background-color', value: string): void;
|
|
946
|
-
|
|
941
|
+
|
|
947
942
|
// RenderingAttributes
|
|
948
943
|
/** Enable/disable renderer canvas transparency. */
|
|
949
944
|
setAttribute(name: 'transparent', value: 'true' | 'false'): void;
|
|
@@ -966,9 +961,9 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
966
961
|
setAttribute(name: "autoplay", value: 'true' | 'false'): void;
|
|
967
962
|
/** @private Used for switching the scene in SceneSwitcher */
|
|
968
963
|
setAttribute(name: 'scene', value: string): void;
|
|
969
|
-
|
|
964
|
+
|
|
970
965
|
// setAttribute(name: 'loadstart', value: string): void;
|
|
971
|
-
|
|
966
|
+
|
|
972
967
|
/** @private Experimental.*/
|
|
973
968
|
setAttribute(name: 'loading-blur', value: 'true' | 'false'): void;
|
|
974
969
|
/** @private */
|
|
@@ -981,9 +976,9 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
981
976
|
/** Generic typed setter for known Needle Engine attributes */
|
|
982
977
|
// Comment out to see errors inside NE for undocumented attributes
|
|
983
978
|
// setAttribute<T extends keyof NeedleEngineAttributes>(qualifiedName: T, value: NeedleEngineAttributes[T]): void;
|
|
984
|
-
|
|
979
|
+
|
|
985
980
|
setAttribute(qualifiedName: ({} & string), value: string): void;
|
|
986
|
-
|
|
981
|
+
|
|
987
982
|
// The ones we're using internally:
|
|
988
983
|
/*
|
|
989
984
|
setAttribute(name: "tabindex", value: string): void;
|
|
@@ -1012,7 +1007,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
1012
1007
|
getAttribute(name: 'ktx2DecoderPath'): string | null;
|
|
1013
1008
|
/** Prevent Needle Engine context from being disposed when the element is removed from the DOM */
|
|
1014
1009
|
getAttribute(name: 'keep-alive'): string | null;
|
|
1015
|
-
|
|
1010
|
+
|
|
1016
1011
|
/** @private Public key used for licensing and feature gating. */
|
|
1017
1012
|
getAttribute(name: 'public-key'): string | null;
|
|
1018
1013
|
/** @private Engine version string — usually set by the build/runtime. */
|
|
@@ -1083,13 +1078,13 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
1083
1078
|
/** Typed getter for known NeedleEngine attribute names; returns the typed shape declared in NeedleEngineAttributes or null. */
|
|
1084
1079
|
// getAttribute<T extends keyof NeedleEngineAttributes>(qualifiedName: T): NeedleEngineAttributes[T] | null;
|
|
1085
1080
|
getAttribute(qualifiedName: ({} & string)): string | null;
|
|
1086
|
-
|
|
1081
|
+
|
|
1087
1082
|
// The ones we're using interally:
|
|
1088
1083
|
/*
|
|
1089
1084
|
getAttribute(name: "autostart"): string | null;
|
|
1090
1085
|
getAttribute(name: "tabindex"): string | null;
|
|
1091
1086
|
*/
|
|
1092
|
-
|
|
1087
|
+
|
|
1093
1088
|
getAttribute(qualifiedName: string): string | null {
|
|
1094
1089
|
return super.getAttribute(qualifiedName);
|
|
1095
1090
|
}
|
|
@@ -1127,7 +1122,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
1127
1122
|
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
1128
1123
|
// This would be better but doesn't completely solve it
|
|
1129
1124
|
// addEventListener(type: ({} & string), listener: any, options?: boolean | AddEventListenerOptions): void;
|
|
1130
|
-
|
|
1125
|
+
|
|
1131
1126
|
// The ones we're using interally:
|
|
1132
1127
|
/*
|
|
1133
1128
|
addEventListener(type: "error", listener: (ev: ErrorEvent) => void, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -1136,8 +1131,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
1136
1131
|
addEventListener(type: "drop", listener: (ev: DragEvent) => void, options?: boolean | AddEventListenerOptions): void;
|
|
1137
1132
|
addEventListener(type: "dragover", listener: (ev: DragEvent) => void, options?: boolean | AddEventListenerOptions): void;
|
|
1138
1133
|
*/
|
|
1139
|
-
addEventListener(type: string, listener: any, options?: boolean | AddEventListenerOptions): void
|
|
1140
|
-
{
|
|
1134
|
+
addEventListener(type: string, listener: any, options?: boolean | AddEventListenerOptions): void {
|
|
1141
1135
|
return super.addEventListener(type, listener as EventListenerOrEventListenerObject, options);
|
|
1142
1136
|
}
|
|
1143
1137
|
}
|