@needle-tools/engine 6.0.0-alpha.6 → 6.0.0-alpha.7
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 +5 -0
- package/dist/gltf-progressive-CRdzVlSY.umd.cjs +10 -0
- package/dist/gltf-progressive-OBdIERAY.min.js +10 -0
- package/dist/{gltf-progressive-B7lOWdLe.js → gltf-progressive-ZuAsp3FE.js} +237 -231
- package/dist/{materialx-x1m4IJd1.min.js → materialx-Bd0NThHa.min.js} +1 -1
- package/dist/{materialx-CzRx9AGf.umd.cjs → materialx-Clep-Dc8.umd.cjs} +2 -2
- package/dist/{materialx-Bd9BE6LR.js → materialx-m9EM4lhZ.js} +1 -1
- package/dist/{needle-engine.bundle-D6mZl1dR.min.js → needle-engine.bundle-B2_-yVCX.min.js} +148 -148
- package/dist/{needle-engine.bundle-DOHf03pR.umd.cjs → needle-engine.bundle-BOs3iHUC.umd.cjs} +147 -147
- package/dist/{needle-engine.bundle-Hu7ZAxEI.js → needle-engine.bundle-hBHg3HuX.js} +7015 -6941
- package/dist/needle-engine.d.ts +41 -20
- package/dist/needle-engine.js +335 -334
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{vendor-CDN1hirK.umd.cjs → vendor-Bb_SUKxZ.umd.cjs} +92 -92
- package/dist/{vendor-T07c_9f_.min.js → vendor-D1vc0sOe.min.js} +100 -100
- package/dist/{vendor-BatPc34p.js → vendor-ipoLrKAE.js} +3461 -3324
- package/lib/engine/api.d.ts +2 -1
- package/lib/engine/api.js +2 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_context.d.ts +2 -0
- package/lib/engine/engine_context.js +14 -0
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_init.js +2 -2
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_license.d.ts +7 -7
- package/lib/engine/engine_license.js +73 -73
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_loaders.gltf.d.ts +3 -1
- package/lib/engine/engine_loaders.gltf.js +6 -1
- package/lib/engine/engine_loaders.gltf.js.map +1 -1
- package/lib/engine/engine_networking_blob.js +3 -3
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +2 -0
- package/lib/engine/engine_physics.js +23 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.js.map +1 -1
- package/lib/engine/project-document/engine_document_extensions.d.ts +16 -0
- package/lib/engine/project-document/engine_document_extensions.js +29 -0
- package/lib/engine/project-document/engine_document_extensions.js.map +1 -0
- package/lib/engine/project-document/engine_document_runtime.js +1 -1
- package/lib/engine/project-document/engine_document_runtime.js.map +1 -1
- package/lib/engine/project-document/engine_project_document.js +39 -3
- package/lib/engine/project-document/engine_project_document.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +5 -5
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +2 -2
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine/xr/TempXRContext.js +2 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/package.json +3 -3
- package/plugins/common/license.js +4 -4
- package/plugins/vite/build-pipeline.js +6 -1
- package/plugins/vite/license.js +4 -4
- package/plugins/vite/logger.client.js +21 -8
- package/src/engine/api.ts +2 -1
- package/src/engine/engine_context.ts +11 -0
- package/src/engine/engine_init.ts +2 -2
- package/src/engine/engine_license.ts +70 -70
- package/src/engine/engine_loaders.gltf.ts +8 -2
- package/src/engine/engine_networking_blob.ts +3 -3
- package/src/engine/engine_physics.ts +22 -1
- package/src/engine/engine_utils_qrcode.ts +2 -2
- package/src/engine/project-document/engine_document_extensions.ts +39 -0
- package/src/engine/project-document/engine_document_runtime.ts +1 -1
- package/src/engine/project-document/engine_project_document.ts +46 -3
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +5 -5
- package/src/engine/webcomponents/needle-engine.loading.ts +2 -2
- package/src/engine/webcomponents/needle-engine.ts +2 -2
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
- package/dist/gltf-progressive-BpT9M5Mt.umd.cjs +0 -10
- package/dist/gltf-progressive-D0rzvhNG.min.js +0 -10
|
@@ -42,19 +42,19 @@ function setLicenseTimeout(ctx: IContext, callback: () => void, delay: number) {
|
|
|
42
42
|
return timer;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const $bvy: ((result: boolean) => void)[] = [];
|
|
46
46
|
|
|
47
47
|
// DO NOT EDIT MANUALLY
|
|
48
|
-
let
|
|
48
|
+
let yBXL: string = "";
|
|
49
49
|
// eslint-disable-next-line prefer-const
|
|
50
|
-
let
|
|
50
|
+
let VkS: string = "";
|
|
51
51
|
|
|
52
52
|
if (debug) {
|
|
53
|
-
console.log("License Type: " +
|
|
54
|
-
if (
|
|
55
|
-
console.log("License JWT: " +
|
|
53
|
+
console.log("License Type: " + yBXL);
|
|
54
|
+
if (VkS) {
|
|
55
|
+
console.log("License JWT: " + VkS);
|
|
56
56
|
try {
|
|
57
|
-
const payload = JSON.parse(atob(
|
|
57
|
+
const payload = JSON.parse(atob(VkS.split(".")[1].replace(/-/g, '+').replace(/_/g, '/')));
|
|
58
58
|
console.log("License JWT payload:", payload);
|
|
59
59
|
}
|
|
60
60
|
catch { console.log("License JWT payload: (failed to decode)"); }
|
|
@@ -65,8 +65,8 @@ if (debug) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/** @internal */
|
|
68
|
-
export function
|
|
69
|
-
switch (
|
|
68
|
+
export function __mor() {
|
|
69
|
+
switch (yBXL) {
|
|
70
70
|
case "pro":
|
|
71
71
|
case "enterprise":
|
|
72
72
|
return true;
|
|
@@ -75,8 +75,8 @@ export function $jVksoCHS() {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/** @internal */
|
|
78
|
-
export function
|
|
79
|
-
switch (
|
|
78
|
+
export function $TiDhB() {
|
|
79
|
+
switch (yBXL) {
|
|
80
80
|
case "indie":
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
@@ -84,8 +84,8 @@ export function _$sHuA() {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/** @internal */
|
|
87
|
-
export function
|
|
88
|
-
switch (
|
|
87
|
+
export function __cshwS() {
|
|
88
|
+
switch (yBXL) {
|
|
89
89
|
case "edu":
|
|
90
90
|
return true;
|
|
91
91
|
}
|
|
@@ -93,26 +93,26 @@ export function $BZiUJx() {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/** @internal */
|
|
96
|
-
export function
|
|
97
|
-
return
|
|
96
|
+
export function _yActo() {
|
|
97
|
+
return __mor() || $TiDhB() || __cshwS();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
/** @internal */
|
|
102
|
-
export function
|
|
103
|
-
if (
|
|
102
|
+
export function _PvsqpIB(cb: (result: boolean) => void) {
|
|
103
|
+
if (__mor() || $TiDhB() || __cshwS()) {
|
|
104
104
|
cb(true);
|
|
105
105
|
return () => {};
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
$bvy.push(cb);
|
|
108
108
|
return () => {
|
|
109
|
-
const index =
|
|
110
|
-
if (index >= 0)
|
|
109
|
+
const index = $bvy.indexOf(cb);
|
|
110
|
+
if (index >= 0) $bvy.splice(index, 1);
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
function
|
|
115
|
-
for (const cb of
|
|
114
|
+
function GuxGgwYi(result: boolean) {
|
|
115
|
+
for (const cb of $bvy) {
|
|
116
116
|
try {
|
|
117
117
|
cb(result);
|
|
118
118
|
}
|
|
@@ -127,7 +127,7 @@ function __QVQhCm(result: boolean) {
|
|
|
127
127
|
|
|
128
128
|
// ECDSA P-256 public key for verifying license JWTs (verification-only, safe to ship)
|
|
129
129
|
/* eslint-disable no-secrets/no-secrets -- public key, not a secret */
|
|
130
|
-
const
|
|
130
|
+
const $xvChBB = {
|
|
131
131
|
kty: "EC",
|
|
132
132
|
crv: "P-256",
|
|
133
133
|
x: "A34nyKMjhQYVgzeE4tyLUYdx34TAKogDa7v7PRaO9Lg",
|
|
@@ -151,7 +151,7 @@ function base64urlDecode(str: string): Uint8Array {
|
|
|
151
151
|
* Verify a JWT license token and return the `type` claim if valid.
|
|
152
152
|
* Returns null if the JWT is missing, malformed, or has an invalid signature.
|
|
153
153
|
*/
|
|
154
|
-
async function
|
|
154
|
+
async function _yCe(jwt: string): Promise<string | null> {
|
|
155
155
|
if (!jwt) return null;
|
|
156
156
|
try {
|
|
157
157
|
const parts = jwt.split(".");
|
|
@@ -161,7 +161,7 @@ async function _$IUNmiHVF(jwt: string): Promise<string | null> {
|
|
|
161
161
|
|
|
162
162
|
const key = await crypto.subtle.importKey(
|
|
163
163
|
"jwk",
|
|
164
|
-
|
|
164
|
+
$xvChBB,
|
|
165
165
|
{ name: "ECDSA", namedCurve: "P-256" },
|
|
166
166
|
false,
|
|
167
167
|
["verify"]
|
|
@@ -221,16 +221,16 @@ async function _$IUNmiHVF(jwt: string): Promise<string | null> {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
/** Verify the injected JWT and update the license type if valid.
|
|
224
|
-
* The engine ONLY trusts the JWT — the plain
|
|
224
|
+
* The engine ONLY trusts the JWT — the plain yBXL string is ignored. */
|
|
225
225
|
let _jwtVerificationPromise: Promise<void> | undefined = undefined;
|
|
226
|
-
async function
|
|
226
|
+
async function uztEyYP(): Promise<void> {
|
|
227
227
|
// The bundled JWT may be empty when a build supplies a signed license file.
|
|
228
228
|
// Do not return early: the meta tag below may provide the JWT instead.
|
|
229
229
|
// Keep the bundled binding mutable so Vite's esbuild pre-bundling does not
|
|
230
230
|
// treat its initial empty value as constant and remove JWT verification.
|
|
231
|
-
let jwt =
|
|
231
|
+
let jwt = VkS;
|
|
232
232
|
// Clear the bundled JWT after reading it; this assignment keeps the binding mutable.
|
|
233
|
-
|
|
233
|
+
VkS = "";
|
|
234
234
|
if (!jwt && typeof document !== "undefined") {
|
|
235
235
|
const licenseFile = document.querySelector('meta[name="needle-license"]')?.getAttribute("content");
|
|
236
236
|
if (licenseFile) {
|
|
@@ -247,14 +247,14 @@ async function wJwFeUbX(): Promise<void> {
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
const verifiedType = await
|
|
250
|
+
const verifiedType = await _yCe(jwt);
|
|
251
251
|
if (verifiedType) {
|
|
252
|
-
|
|
252
|
+
yBXL = verifiedType;
|
|
253
253
|
if (debug) console.log("License type set from verified JWT: " + verifiedType);
|
|
254
|
-
|
|
254
|
+
GuxGgwYi(_yActo());
|
|
255
255
|
}
|
|
256
256
|
else {
|
|
257
|
-
|
|
257
|
+
yBXL = "basic";
|
|
258
258
|
if (debug && jwt) console.warn("JWT verification failed — license reset to basic");
|
|
259
259
|
}
|
|
260
260
|
}
|
|
@@ -377,7 +377,7 @@ export namespace Telemetry {
|
|
|
377
377
|
// NOTE: this does NOT affect license enforcement — the /check call, the "forbidden"
|
|
378
378
|
// overlay and the watermark/logo run on separate, ungated code paths.
|
|
379
379
|
const attribute = domElement?.getAttribute("no-telemetry");
|
|
380
|
-
if (
|
|
380
|
+
if (__mor() && (attribute === "" || attribute === "true" || attribute === "1")) {
|
|
381
381
|
if (debug) console.debug("Telemetry is disabled via no-telemetry attribute");
|
|
382
382
|
return false;
|
|
383
383
|
}
|
|
@@ -705,21 +705,21 @@ export namespace Telemetry {
|
|
|
705
705
|
}
|
|
706
706
|
|
|
707
707
|
|
|
708
|
-
export function
|
|
708
|
+
export function _htxWDE() {
|
|
709
709
|
|
|
710
|
-
if(
|
|
710
|
+
if(yBXL === "") yBXL = "basic";
|
|
711
711
|
|
|
712
712
|
// Start JWT verification — must be here (not top-level) to avoid tree-shaking
|
|
713
|
-
_jwtVerificationPromise =
|
|
713
|
+
_jwtVerificationPromise = uztEyYP();
|
|
714
714
|
// Start after setting the initial type. At module scope the type was still "",
|
|
715
715
|
// so Basic builds skipped the runtime check entirely.
|
|
716
|
-
|
|
716
|
+
eNaXOZj = __mTgB();
|
|
717
717
|
|
|
718
718
|
Telemetry.init();
|
|
719
719
|
ContextRegistry.registerCallback(ContextEvent.ContextRegistered, evt => {
|
|
720
|
-
|
|
721
|
-
_$
|
|
722
|
-
setLicenseTimeout(evt.context, () =>
|
|
720
|
+
__vTpQGDw(evt.context);
|
|
721
|
+
_$ygon(evt.context);
|
|
722
|
+
setLicenseTimeout(evt.context, () => NNhYdA(evt.context), 2000);
|
|
723
723
|
});
|
|
724
724
|
// ContextCreated fires after the renderer exists, so the canvas is available for context-loss monitoring
|
|
725
725
|
ContextRegistry.registerCallback(ContextEvent.ContextCreated, evt => {
|
|
@@ -728,17 +728,17 @@ export function $bqSkkSKJ() {
|
|
|
728
728
|
});
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
-
export let
|
|
731
|
+
export let eNaXOZj: Promise<void> | undefined = undefined;
|
|
732
732
|
let applicationIsForbidden = false;
|
|
733
733
|
let applicationForbiddenText = "";
|
|
734
|
-
async function
|
|
734
|
+
async function __mTgB() {
|
|
735
735
|
// Only perform the runtime license check once
|
|
736
|
-
if (
|
|
736
|
+
if (eNaXOZj) return eNaXOZj;
|
|
737
737
|
// Wait for JWT verification to complete first (if running)
|
|
738
738
|
if (_jwtVerificationPromise) {
|
|
739
739
|
await _jwtVerificationPromise;
|
|
740
740
|
}
|
|
741
|
-
if (
|
|
741
|
+
if (yBXL === "basic") {
|
|
742
742
|
try {
|
|
743
743
|
const licenseUrl = "https://needle.tools/api/v1/needle-engine/check?location=" + encodeURIComponent(window.location.href) + "&version=" + VERSION + "&generator=" + encodeURIComponent(GENERATOR);
|
|
744
744
|
const res = await fetch(licenseUrl, {
|
|
@@ -750,27 +750,27 @@ async function __zwPG() {
|
|
|
750
750
|
if (res?.status === 200) {
|
|
751
751
|
applicationIsForbidden = false;
|
|
752
752
|
if (debug) console.log("License check succeeded");
|
|
753
|
-
|
|
754
|
-
|
|
753
|
+
yBXL = "pro";
|
|
754
|
+
GuxGgwYi(true);
|
|
755
755
|
}
|
|
756
756
|
else if (res?.status === 403) {
|
|
757
|
-
|
|
757
|
+
GuxGgwYi(false);
|
|
758
758
|
applicationIsForbidden = true;
|
|
759
759
|
applicationForbiddenText = await res.text();
|
|
760
760
|
}
|
|
761
761
|
else {
|
|
762
|
-
|
|
762
|
+
GuxGgwYi(false);
|
|
763
763
|
if (debug) console.log("License check failed with status " + res?.status);
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
766
|
catch (err) {
|
|
767
|
-
|
|
767
|
+
GuxGgwYi(false);
|
|
768
768
|
if (debug) console.error("License check failed", err);
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
|
-
else if (debug) console.log("Runtime license check is skipped because license is already applied as \"" +
|
|
771
|
+
else if (debug) console.log("Runtime license check is skipped because license is already applied as \"" + yBXL + "\"");
|
|
772
772
|
}
|
|
773
|
-
async function _$
|
|
773
|
+
async function _$ygon(ctx: IContext) {
|
|
774
774
|
function createForbiddenElement() {
|
|
775
775
|
const div = document.createElement("div");
|
|
776
776
|
div.className = "needle-forbidden";
|
|
@@ -835,40 +835,40 @@ async function _$XfWxk(ctx: IContext) {
|
|
|
835
835
|
}, 500)
|
|
836
836
|
}
|
|
837
837
|
|
|
838
|
-
async function
|
|
838
|
+
async function __vTpQGDw(ctx: IContext) {
|
|
839
839
|
try {
|
|
840
|
-
if (
|
|
841
|
-
return
|
|
840
|
+
if (!__mor() && !$TiDhB()) {
|
|
841
|
+
return OGuHjhL(ctx);
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
catch (err) {
|
|
845
845
|
if (debug) console.log("License check failed", err)
|
|
846
|
-
return
|
|
846
|
+
return OGuHjhL(ctx)
|
|
847
847
|
}
|
|
848
|
-
if (debug)
|
|
848
|
+
if (debug) OGuHjhL(ctx)
|
|
849
849
|
}
|
|
850
850
|
|
|
851
851
|
|
|
852
852
|
|
|
853
|
-
async function
|
|
853
|
+
async function OGuHjhL(ctx: IContext) {
|
|
854
854
|
|
|
855
855
|
// if the engine loads faster than the license check, we need to capture the ready event here
|
|
856
856
|
let isReady = false;
|
|
857
857
|
ctx.domElement.addEventListener("ready", () => isReady = true);
|
|
858
858
|
|
|
859
|
-
await
|
|
859
|
+
await eNaXOZj?.catch(() => { });
|
|
860
860
|
|
|
861
861
|
|
|
862
|
-
if (
|
|
863
|
-
if (
|
|
862
|
+
if (__mor() || $TiDhB()) return;
|
|
863
|
+
if (_yActo() === false) $xSLUxq();
|
|
864
864
|
|
|
865
865
|
// check if the engine is already ready (meaning has finished loading)
|
|
866
866
|
if (isReady) {
|
|
867
|
-
|
|
867
|
+
_$EZMmp(ctx);
|
|
868
868
|
}
|
|
869
869
|
else {
|
|
870
870
|
ctx.domElement.addEventListener("ready", () => {
|
|
871
|
-
|
|
871
|
+
_$EZMmp(ctx);
|
|
872
872
|
});
|
|
873
873
|
}
|
|
874
874
|
}
|
|
@@ -876,7 +876,7 @@ async function $KXTmgnjE(ctx: IContext) {
|
|
|
876
876
|
// const licenseElementIdentifier = "needle-license-element";
|
|
877
877
|
// const licenseDuration = 10000;
|
|
878
878
|
// const licenseDelay = 1200;
|
|
879
|
-
function
|
|
879
|
+
function _$EZMmp(ctx: IContext) {
|
|
880
880
|
|
|
881
881
|
const style = `
|
|
882
882
|
position: relative;
|
|
@@ -889,7 +889,7 @@ function __OzoZ(ctx: IContext) {
|
|
|
889
889
|
padding: 10px;
|
|
890
890
|
padding-left: 30px;
|
|
891
891
|
`;
|
|
892
|
-
if (
|
|
892
|
+
if (yBXL === "edu") {
|
|
893
893
|
if (navigator.webdriver) {
|
|
894
894
|
console.log("This project is supported by Needle for Education – https://needle.tools");
|
|
895
895
|
}
|
|
@@ -946,7 +946,7 @@ function __OzoZ(ctx: IContext) {
|
|
|
946
946
|
}
|
|
947
947
|
}, 1000);
|
|
948
948
|
|
|
949
|
-
if (
|
|
949
|
+
if (__cshwS()) {
|
|
950
950
|
const removeDelay = 20_000;
|
|
951
951
|
setLicenseTimeout(ctx, () => {
|
|
952
952
|
clearInterval(interval);
|
|
@@ -955,7 +955,7 @@ function __OzoZ(ctx: IContext) {
|
|
|
955
955
|
const intervalInMinutes = 5;
|
|
956
956
|
setLicenseTimeout(ctx, () => {
|
|
957
957
|
if (ctx.domElement.parentNode)
|
|
958
|
-
|
|
958
|
+
_$EZMmp(ctx);
|
|
959
959
|
}, 1000 * 60 * intervalInMinutes)
|
|
960
960
|
}, removeDelay);
|
|
961
961
|
}
|
|
@@ -966,7 +966,7 @@ function __OzoZ(ctx: IContext) {
|
|
|
966
966
|
const base64Logo = "data:image/webp;base64,UklGRrABAABXRUJQVlA4WAoAAAAQAAAAHwAAHwAAQUxQSKEAAAARN6CmbSM4WR7vdARON11EBDq3fLiNbVtVzpMCPlKAEzsx0Y/x+Ovuv4dn0EFE/ydAvz6YggXzgh5sVgXM/zOC/4sii7qgGvB5N7hmuQYwkvazWAu1JPW41FXSHq6pnaQWvqYH18Fc0j1hO/BFTtIeSBlJi5w6qIIO7IOrwhFsB2Yxukif0FTRLpXswHR8MxbslKe9VZsn/Ub5C7YFOpqSTABWUDgg6AAAAFAGAJ0BKiAAIAA+7VyoTqmkpCI3+qgBMB2JbACdMt69DwMIQBLhkTO6XwY00UEDK6cNIDnuNibPf0EgAP7Y1myuiQHLDsF/0h5unrGh6WAbv7aegg2ZMd3uRKfT/3SJztcaujYfTvMXspfCTmYcoO6a+vhC3ss4M8uM58t4siiu59I4aOl59e9Sr6xoxYlHf2v+NnBNpJYeJf8jABQAId/PXuBkLEFkiCucgSGEcfhvajql/j3reCGl0M5/9gQWy7ayNPs+wlvIxFnNfSlfuND4CZOCyxOHhRqOmHN4ULHo3tCSrUNvgAA=";
|
|
967
967
|
|
|
968
968
|
let lastLogTime = 0;
|
|
969
|
-
async function $
|
|
969
|
+
async function $xSLUxq(_logo?: string) {
|
|
970
970
|
const now = Date.now();
|
|
971
971
|
if (now - lastLogTime < 2000) return;
|
|
972
972
|
lastLogTime = now;
|
|
@@ -999,7 +999,7 @@ async function $vKd(_logo?: string) {
|
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
1001
|
|
|
1002
|
-
async function
|
|
1002
|
+
async function NNhYdA(context: IContext) {
|
|
1003
1003
|
// isAllowed() now also covers cross-origin-isolated pages (where beacons can't be sent)
|
|
1004
1004
|
// and Do Not Track / GPC.
|
|
1005
1005
|
if (!Telemetry.isAllowed(context)) {
|
|
@@ -1013,7 +1013,7 @@ async function _YuMDhu(context: IContext) {
|
|
|
1013
1013
|
|
|
1014
1014
|
// current url without query parameters
|
|
1015
1015
|
const currentUrl = window.location.href.split("?")[0];
|
|
1016
|
-
const license =
|
|
1016
|
+
const license = yBXL;
|
|
1017
1017
|
|
|
1018
1018
|
const beaconData = {
|
|
1019
1019
|
license,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
import { addDracoAndKTX2Loaders as addDracoAndKTX2LoadersGLTFProgressive, configureLoader, createLoaders, setDracoDecoderLocation, setKTX2TranscoderLocation } from '@needle-tools/gltf-progressive';
|
|
2
|
+
import { addDracoAndKTX2Loaders as addDracoAndKTX2LoadersGLTFProgressive, configureLoader, createLoaders, disposeLoaders, setDracoDecoderLocation, setKTX2TranscoderLocation } from '@needle-tools/gltf-progressive';
|
|
3
3
|
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
|
|
4
4
|
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
5
5
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
|
|
6
6
|
import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader.js';
|
|
7
7
|
|
|
8
|
-
import { Context } from "./engine_setup.js"
|
|
8
|
+
import type { Context } from "./engine_setup.js"
|
|
9
9
|
import { getParam } from "./engine_utils.js";
|
|
10
10
|
|
|
11
11
|
const debug = getParam("debugdecoders");
|
|
@@ -20,6 +20,12 @@ function ensureLoaders() {
|
|
|
20
20
|
return loaders;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/** Release shared decoder workers after the last engine context is destroyed. */
|
|
24
|
+
export function disposeGLTFLoaders() {
|
|
25
|
+
disposeLoaders();
|
|
26
|
+
loaders = null;
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
export function setDracoDecoderPath(path: string | undefined) {
|
|
24
30
|
if (path !== undefined && typeof path === "string") {
|
|
25
31
|
setDracoDecoderLocation(path);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileLoader } from "three";
|
|
2
2
|
|
|
3
3
|
import { showBalloonWarning } from "./debug/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { _yActo } from "./engine_license.js";
|
|
5
5
|
import { delay } from "./engine_utils.js";
|
|
6
6
|
import { md5AsBytes, md5Hex, sha256Base64 } from "./engine_utils_hash.js";
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ export namespace BlobStorage {
|
|
|
45
45
|
*/
|
|
46
46
|
export function canUpload(info: { filesize: number }) {
|
|
47
47
|
const sizeInMB = info.filesize / 1024 / 1024;
|
|
48
|
-
if (
|
|
48
|
+
if (_yActo()) {
|
|
49
49
|
return sizeInMB < maxSizeInMB;
|
|
50
50
|
}
|
|
51
51
|
return sizeInMB < maxFreeSizeInMB;
|
|
@@ -100,7 +100,7 @@ export namespace BlobStorage {
|
|
|
100
100
|
console.warn(`Your file is too large for uploading (${filesizeInMB.toFixed(1)}MB). Max allowed size is ${maxSizeInMB}MB`);
|
|
101
101
|
return null;
|
|
102
102
|
}
|
|
103
|
-
else if (!
|
|
103
|
+
else if (!_yActo() && filesizeInMB > maxFreeSizeInMB) {
|
|
104
104
|
if (opts?.silent !== true) showBalloonWarning(`File is too large for uploading. Please get a <a href=\"https://needle.tools/pricing\" target=\"_blank\">commercial license</a> to upload files larger than 5MB`);
|
|
105
105
|
console.warn(`Your file is too large for uploading (${filesizeInMB.toFixed(1)}MB). Max size is 5MB for non-commercial users. Please get a commercial license at https://needle.tools/pricing for larger files (up to 50MB)`);
|
|
106
106
|
return null;
|
|
@@ -183,6 +183,11 @@ export function setPhysicsEngineFactory(factory: ((context: Context) => IPhysics
|
|
|
183
183
|
|
|
184
184
|
export class Physics {
|
|
185
185
|
|
|
186
|
+
/** Release the shared BVH worker pool after the last engine context is destroyed. */
|
|
187
|
+
static disposeMeshBVHWorkers() {
|
|
188
|
+
NEMeshBVH.disposeWorkers();
|
|
189
|
+
}
|
|
190
|
+
|
|
186
191
|
private static _raycasting: number = 0;
|
|
187
192
|
/**
|
|
188
193
|
* Returns true if raycasting is currently in progress
|
|
@@ -805,7 +810,13 @@ namespace NEMeshBVH {
|
|
|
805
810
|
})
|
|
806
811
|
.finally(() => {
|
|
807
812
|
if (debugPhysics) console.log(">>>>> worker done", name, { hasBoundsTre: geom.boundsTree != undefined });
|
|
808
|
-
|
|
813
|
+
if (retiredWorkers.has(workerInstance)) {
|
|
814
|
+
retiredWorkers.delete(workerInstance);
|
|
815
|
+
workerInstance.dispose();
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
availableWorkers.push(workerInstance);
|
|
819
|
+
}
|
|
809
820
|
copy.dispose();
|
|
810
821
|
performance.mark("bvh.create.end");
|
|
811
822
|
performance.measure("bvh.create (worker)", "bvh.create.start", "bvh.create.end");
|
|
@@ -926,6 +937,16 @@ namespace NEMeshBVH {
|
|
|
926
937
|
const canUseWorkerSymbol = Symbol("Needle:MeshBVH-CanUseWorker");
|
|
927
938
|
const workerInstances: GenerateMeshBVHWorker[] = [];
|
|
928
939
|
const availableWorkers: GenerateMeshBVHWorker[] = [];
|
|
940
|
+
const retiredWorkers = new Set<GenerateMeshBVHWorker>();
|
|
941
|
+
|
|
942
|
+
export function disposeWorkers() {
|
|
943
|
+
for (const worker of workerInstances) {
|
|
944
|
+
if (worker.running) retiredWorkers.add(worker);
|
|
945
|
+
else worker.dispose();
|
|
946
|
+
}
|
|
947
|
+
workerInstances.length = 0;
|
|
948
|
+
availableWorkers.length = 0;
|
|
949
|
+
}
|
|
929
950
|
|
|
930
951
|
function internalSetupWorker() {
|
|
931
952
|
didSetupWorker = true;
|
|
@@ -4,7 +4,7 @@ import { Quaternion, Vector2, Vector3, Vector4 } from "three";
|
|
|
4
4
|
|
|
5
5
|
import { needleLogoOnlySVG } from "./assets/index.js";
|
|
6
6
|
import { isDevEnvironment } from "./debug/debug.js";
|
|
7
|
-
import {
|
|
7
|
+
import { _yActo } from "./engine_license.js";
|
|
8
8
|
import { InternalAttributeUtils } from "./engine_utils_attributes.js";
|
|
9
9
|
import type { NeedleEngineWebComponent } from "./webcomponents/needle-engine.js";
|
|
10
10
|
|
|
@@ -135,7 +135,7 @@ async function internalRenderQRCodeOverlays(canvas: HTMLCanvasElement, args: { s
|
|
|
135
135
|
console.debug("[QR Code] No web component found")
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const canUseCustomLogo =
|
|
138
|
+
const canUseCustomLogo = _yActo();
|
|
139
139
|
|
|
140
140
|
// Query logo src from needle-engine attribute.
|
|
141
141
|
// For any supported attribute it's possible to use "falsey" values (e.g. "0" or "false" to disable the logo in the QR code)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DocumentDefContext, DocumentExtensionProvider } from '@needle-tools/addressing/document';
|
|
2
|
+
|
|
3
|
+
/** Creates extension readers bound to each document's Engine context. */
|
|
4
|
+
export interface DocumentExtensionRegistration {
|
|
5
|
+
readonly version: number;
|
|
6
|
+
readonly migrations?: DocumentExtensionProvider['migrations'];
|
|
7
|
+
readonly valueCodecs?: DocumentExtensionProvider['valueCodecs'];
|
|
8
|
+
readonly components?: {
|
|
9
|
+
createReader(context: DocumentDefContext): NonNullable<DocumentExtensionProvider['components']>['apply'] | undefined;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const extensions = new Map<string, DocumentExtensionRegistration>();
|
|
14
|
+
|
|
15
|
+
/** Register before loading documents. Disposing affects subsequent evaluations. */
|
|
16
|
+
export function registerDocumentExtensionProvider(id: string, provider: DocumentExtensionRegistration): { dispose(): void } {
|
|
17
|
+
if (!id.trim() || extensions.has(id)) throw new Error(`Invalid or duplicate document extension '${id}'.`);
|
|
18
|
+
if (!Number.isSafeInteger(provider.version) || provider.version < 1) throw new Error('Document extension version must be a positive integer.');
|
|
19
|
+
extensions.set(id, { ...provider });
|
|
20
|
+
let disposed = false;
|
|
21
|
+
return { dispose() {
|
|
22
|
+
if (disposed) return;
|
|
23
|
+
disposed = true;
|
|
24
|
+
extensions.delete(id);
|
|
25
|
+
} };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Bind readers at composition time, after asset loading and before activation. */
|
|
29
|
+
export function resolveDocumentExtensions(context: DocumentDefContext): ReadonlyMap<string, DocumentExtensionProvider> {
|
|
30
|
+
const result = new Map<string, DocumentExtensionProvider>();
|
|
31
|
+
for (const [id, provider] of extensions) {
|
|
32
|
+
const apply = provider.components?.createReader(context);
|
|
33
|
+
result.set(id, { version: provider.version, migrations: provider.migrations,
|
|
34
|
+
valueCodecs: provider.valueCodecs,
|
|
35
|
+
...(apply ? { components: { apply } } : {}),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
@@ -57,7 +57,7 @@ export function createNeedleDocumentRuntime(context: Context): DocumentRuntime {
|
|
|
57
57
|
createNode: () => new Object3D() as unknown as DocumentNode,
|
|
58
58
|
createColor: value => new Color().fromArray(value),
|
|
59
59
|
parse: async (data, src, options) => (await parseSync(context, data, src, null, options)) as unknown as DocumentModel | null,
|
|
60
|
-
|
|
60
|
+
clone(template, referenceId) {
|
|
61
61
|
const provider: UIDProvider = {
|
|
62
62
|
seed: 0,
|
|
63
63
|
generateUUID: () => deriveStableId(referenceId, `seq:${provider.seed++}`),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { joinPath, type NeedleAddress } from "@needle-tools/addressing";
|
|
1
2
|
import {
|
|
2
3
|
applyDef as applySharedDef,
|
|
3
4
|
applyOver as applySharedOver,
|
|
@@ -16,6 +17,7 @@ import type { Object3D } from "three";
|
|
|
16
17
|
import type { SerializationContext } from "../engine_serialization_core.js";
|
|
17
18
|
import type { Context } from "../engine_setup.js";
|
|
18
19
|
import type { Model } from "../engine_types.js";
|
|
20
|
+
import { resolveDocumentExtensions } from './engine_document_extensions.js';
|
|
19
21
|
import { createNeedleDocumentRuntime, documentDefContext } from "./engine_document_runtime.js";
|
|
20
22
|
|
|
21
23
|
export { createDefSerializationContext } from "./engine_document_runtime.js";
|
|
@@ -43,17 +45,58 @@ export type ProjectEvaluationResult = Omit<SharedResult, "root" | "references" |
|
|
|
43
45
|
};
|
|
44
46
|
export type EvaluateProjectDocumentOptions = Omit<SharedOptions, "parent"> & { parent?: Object3D };
|
|
45
47
|
|
|
48
|
+
type DocumentTarget = NonNullable<ProjectDocument["defs"]>[number]["target"];
|
|
49
|
+
type DocumentDef = NonNullable<ProjectDocument["defs"]>[number];
|
|
50
|
+
type DocumentOver = NonNullable<ProjectDocument["overs"]>[number];
|
|
51
|
+
|
|
52
|
+
/** Documents saved before addressing 0.4 used namePath instead of the escaped path string. */
|
|
53
|
+
function withLegacyPath<T extends { address?: NeedleAddress }>(target: T): T {
|
|
54
|
+
const address = target.address as (NeedleAddress & { namePath?: unknown }) | undefined;
|
|
55
|
+
if (address?.path !== undefined || !Array.isArray(address?.namePath) || !address.namePath.length
|
|
56
|
+
|| !address.namePath.every((name): name is string => typeof name === "string")) return target;
|
|
57
|
+
return { ...target, address: { ...address, path: joinPath(address.namePath) } };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function withLegacyDef(def: DocumentDef): DocumentDef {
|
|
61
|
+
const target = withLegacyPath(def.target);
|
|
62
|
+
const copy = def.create?.copy;
|
|
63
|
+
const source = copy ? withLegacyPath(copy.source) : undefined;
|
|
64
|
+
if (target === def.target && source === copy?.source) return def;
|
|
65
|
+
return { ...def, target, create: copy && source ? { ...def.create, copy: { ...copy, source } } : def.create };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function withLegacyOver(over: DocumentOver): DocumentOver {
|
|
69
|
+
const target = withLegacyPath(over.target);
|
|
70
|
+
const value = over.value && typeof over.value === "object" && "address" in over.value
|
|
71
|
+
? withLegacyPath(over.value as DocumentTarget) : over.value;
|
|
72
|
+
return target === over.target && value === over.value ? over : { ...over, target, value };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function withLegacyPaths(document: ProjectDocument): ProjectDocument {
|
|
76
|
+
return {
|
|
77
|
+
...document,
|
|
78
|
+
references: document.references?.map(ref => {
|
|
79
|
+
const normalized = withLegacyPath(ref);
|
|
80
|
+
const parent = ref.parent ? withLegacyPath(ref.parent) : undefined;
|
|
81
|
+
return parent === ref.parent ? normalized : { ...normalized, parent };
|
|
82
|
+
}),
|
|
83
|
+
defs: document.defs?.map(withLegacyDef),
|
|
84
|
+
overs: document.overs?.map(withLegacyOver),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
46
88
|
/** Engine entry point: preserve pre-awake scheduling through the runtime adapter. */
|
|
47
89
|
export async function evaluateProjectDocument(context: Context, document: ProjectDocument, options?: EvaluateProjectDocumentOptions): Promise<ProjectEvaluationResult> {
|
|
48
|
-
return await evaluateShared(createNeedleDocumentRuntime(context), document,
|
|
90
|
+
return await evaluateShared(createNeedleDocumentRuntime(context), withLegacyPaths(document),
|
|
91
|
+
{ ...options, extensions: options?.extensions ?? resolveDocumentExtensions } as unknown as SharedOptions) as unknown as ProjectEvaluationResult;
|
|
49
92
|
}
|
|
50
93
|
|
|
51
94
|
export function applyDef(def: NonNullable<ProjectDocument["defs"]>[number], root: Object3D, references: Map<string, Object3D>, issue: (arc: "def", message: string) => void, serializationContext: SerializationContext): void {
|
|
52
|
-
applySharedDef(def, root as unknown as DocumentNode, references as unknown as Map<string, DocumentNode>, issue, documentDefContext(serializationContext));
|
|
95
|
+
applySharedDef(withLegacyDef(def), root as unknown as DocumentNode, references as unknown as Map<string, DocumentNode>, issue, documentDefContext(serializationContext));
|
|
53
96
|
}
|
|
54
97
|
|
|
55
98
|
export function applyOver(context: Context, over: NonNullable<ProjectDocument["overs"]>[number], root: Object3D, references: Map<string, Object3D>, state: OverApplyState, issue: (arc: "over", message: string) => void): void {
|
|
56
|
-
applySharedOver(createNeedleDocumentRuntime(context), over, root as unknown as DocumentNode, references as unknown as Map<string, DocumentNode>, state, issue);
|
|
99
|
+
applySharedOver(createNeedleDocumentRuntime(context), withLegacyOver(over), root as unknown as DocumentNode, references as unknown as Map<string, DocumentNode>, state, issue);
|
|
57
100
|
}
|
|
58
101
|
|
|
59
102
|
export function resolveMaterialEntity(model: Model, address: import("@needle-tools/addressing").NeedleAddress): Promise<object | null> {
|
|
@@ -2,7 +2,7 @@ import { Mesh, Object3D, TextureLoader, Vector4 } from "three";
|
|
|
2
2
|
import ThreeMeshUI from "three-mesh-ui";
|
|
3
3
|
|
|
4
4
|
import { addNewComponent } from "../../engine_components.js";
|
|
5
|
-
import {
|
|
5
|
+
import { _yActo } from "../../engine_license.js";
|
|
6
6
|
import { OneEuroFilterXYZ } from "../../engine_math.js";
|
|
7
7
|
import type { Context } from "../../engine_setup.js";
|
|
8
8
|
import { lookAtObject } from "../../engine_three_utils.js";
|
|
@@ -321,7 +321,7 @@ export class NeedleSpatialMenu {
|
|
|
321
321
|
}
|
|
322
322
|
if (this.menu) {
|
|
323
323
|
const index = this.menu.children.indexOf(this._poweredByNeedleElement as any);
|
|
324
|
-
if (!this._showNeedleLogo &&
|
|
324
|
+
if (!this._showNeedleLogo && _yActo()) {
|
|
325
325
|
if (index >= 0) {
|
|
326
326
|
this._poweredByNeedleElement.removeFromParent();
|
|
327
327
|
this.markDirty();
|