@needle-tools/engine 5.1.0-alpha.9 → 5.1.0-beta
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/dist/{needle-engine.bundle-mtqHZ45d.js → needle-engine.bundle-BWkDSRyF.js} +3686 -3627
- package/dist/{needle-engine.bundle-BotdnwVF.min.js → needle-engine.bundle-BvgS8xMP.min.js} +139 -139
- package/dist/{needle-engine.bundle-DagaNrZK.umd.cjs → needle-engine.bundle-CdVr_iIe.umd.cjs} +133 -133
- package/dist/needle-engine.d.ts +70 -29
- package/dist/needle-engine.js +606 -604
- 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/api.js +1 -1
- package/lib/engine/api.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 +72 -72
- package/lib/engine/engine_license.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_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.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/Component.js +2 -1
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +2 -0
- package/lib/engine-components/SceneSwitcher.js +26 -14
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SeeThrough.d.ts +39 -0
- package/lib/engine-components/SeeThrough.js +69 -1
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/api.d.ts +1 -0
- package/lib/engine-components/api.js +1 -0
- package/lib/engine-components/api.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 +1 -1
- package/plugins/common/license.js +4 -4
- package/plugins/vite/license.js +4 -4
- package/src/engine/api.ts +1 -1
- package/src/engine/engine_gameobject.ts +1 -1
- package/src/engine/engine_init.ts +2 -2
- package/src/engine/engine_license.ts +69 -69
- package/src/engine/engine_networking_blob.ts +3 -3
- package/src/engine/engine_utils_qrcode.ts +2 -2
- 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 +6 -6
- package/src/engine/webcomponents/needle-engine.ts +2 -2
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine-components/Component.ts +2 -1
- package/src/engine-components/SceneSwitcher.ts +23 -13
- package/src/engine-components/SeeThrough.ts +75 -1
- package/src/engine-components/api.ts +1 -0
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { showBalloonMessage } from "../../debug/debug.js";
|
|
2
2
|
import type { Context } from "../../engine_context.js";
|
|
3
|
-
import {
|
|
3
|
+
import { $fwGZrGe, $BWnhWzrW, Telemetry } from "../../engine_license.js";
|
|
4
4
|
import { isLocalNetwork } from "../../engine_networking_utils.js";
|
|
5
5
|
import { HTMLElementBase } from "../../engine_ssr.js";
|
|
6
6
|
import { DeviceUtilities, getParam } from "../../engine_utils.js";
|
|
@@ -778,8 +778,8 @@ export class NeedleMenuElement extends HTMLElementBase {
|
|
|
778
778
|
try {
|
|
779
779
|
// if the user has a license then we CAN hide the needle logo
|
|
780
780
|
// calling this method immediately will cause an issue with vite bundling tho
|
|
781
|
-
window.requestAnimationFrame(() => $
|
|
782
|
-
if (res == true &&
|
|
781
|
+
window.requestAnimationFrame(() => $BWnhWzrW(res => {
|
|
782
|
+
if (res == true && $fwGZrGe() && !debugNonCommercial) {
|
|
783
783
|
let visible = this._userRequestedLogoVisible;
|
|
784
784
|
if (visible === undefined) visible = false;
|
|
785
785
|
this.___onSetLogoVisible(visible);
|
|
@@ -830,7 +830,7 @@ export class NeedleMenuElement extends HTMLElementBase {
|
|
|
830
830
|
// ensure the menu is not hidden or removed
|
|
831
831
|
const requiredParent = this?.parentNode;
|
|
832
832
|
if (this.style.display != "flex" || this.style.visibility != "visible" || this.style.opacity != "1" || requiredParent != this._domElement?.shadowRoot) {
|
|
833
|
-
if (
|
|
833
|
+
if (!$fwGZrGe()) {
|
|
834
834
|
const change = changeEventCounter++;
|
|
835
835
|
// if a user doesn't have a local pro license *but* for development the menu is hidden then we show a warning
|
|
836
836
|
if (isLocalNetwork() && this._userRequestedMenuVisible === false) {
|
|
@@ -918,7 +918,7 @@ export class NeedleMenuElement extends HTMLElementBase {
|
|
|
918
918
|
showNeedleLogo(visible: boolean) {
|
|
919
919
|
this._userRequestedLogoVisible = visible;
|
|
920
920
|
if (!visible) {
|
|
921
|
-
if (
|
|
921
|
+
if (!$fwGZrGe() || debugNonCommercial) {
|
|
922
922
|
console.warn("[Needle Engine] You need a PRO license to hide the Needle Engine logo in production.");
|
|
923
923
|
const localNetwork = isLocalNetwork()
|
|
924
924
|
if (!localNetwork) return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { needleLogoOnlySVG } from "../assets/index.js"
|
|
2
2
|
import { isDevEnvironment, showBalloonWarning } from "../debug/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { $fwGZrGe, _XtEQ, ICD } from "../engine_license.js";
|
|
4
4
|
import { Mathf } from "../engine_math.js";
|
|
5
5
|
import { LoadingProgressArgs } from "../engine_setup.js";
|
|
6
6
|
import { getParam } from "../engine_utils.js";
|
|
@@ -205,7 +205,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
|
|
208
|
-
const hasLicense =
|
|
208
|
+
const hasLicense = _XtEQ();
|
|
209
209
|
if (!existing) {
|
|
210
210
|
this._loadingElement.style.position = "absolute";
|
|
211
211
|
this._loadingElement.style.width = "100%";
|
|
@@ -373,7 +373,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
373
373
|
|
|
374
374
|
// private async handleRuntimeLicense(loadingElement: HTMLElement) {
|
|
375
375
|
// // First check if we have a commercial license
|
|
376
|
-
// let commercialLicense =
|
|
376
|
+
// let commercialLicense = $fwGZrGe();
|
|
377
377
|
// // if it's the case then we don't need to perform a runtime check
|
|
378
378
|
// if (commercialLicense) return;
|
|
379
379
|
|
|
@@ -393,10 +393,10 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
393
393
|
// loadingElement.appendChild(nonCommercialContainer);
|
|
394
394
|
|
|
395
395
|
// // Use the runtime license check
|
|
396
|
-
// if (!isDevEnvironment() &&
|
|
396
|
+
// if (!isDevEnvironment() && ICD) {
|
|
397
397
|
// if (debugLicense) console.log("Waiting for runtime license check");
|
|
398
|
-
// await
|
|
399
|
-
// commercialLicense =
|
|
398
|
+
// await ICD;
|
|
399
|
+
// commercialLicense = $fwGZrGe();
|
|
400
400
|
// }
|
|
401
401
|
// if (commercialLicense) return;
|
|
402
402
|
// nonCommercialContainer.style.transition = "opacity .5s ease-in-out";
|
|
@@ -3,7 +3,7 @@ import type { Texture } from "three";
|
|
|
3
3
|
import { isDevEnvironment, showBalloonWarning } from "../debug/index.js";
|
|
4
4
|
import { PUBLIC_KEY, VERSION } from "../engine_constants.js";
|
|
5
5
|
import { ContextEvent, ContextRegistry } from "../engine_context_registry.js";
|
|
6
|
-
import {
|
|
6
|
+
import { $fwGZrGe } from "../engine_license.js";
|
|
7
7
|
import { onStart } from "../engine_lifecycle_api.js";
|
|
8
8
|
import { setDracoDecoderPath, setDracoDecoderType, setKtx2TranscoderPath } from "../engine_loaders.gltf.js";
|
|
9
9
|
import { Context, ContextCreateArgs } from "../engine_setup.js";
|
|
@@ -579,7 +579,7 @@ export class NeedleEngineWebComponent extends HTMLElementBase implements INeedle
|
|
|
579
579
|
|
|
580
580
|
|
|
581
581
|
// Loading start events
|
|
582
|
-
const allowOverridingDefaultLoading =
|
|
582
|
+
const allowOverridingDefaultLoading = $fwGZrGe();
|
|
583
583
|
// default loading can be overriden by calling preventDefault in the onload start event
|
|
584
584
|
this.ensureLoadStartIsRegistered();
|
|
585
585
|
let useDefaultLoading = this.dispatchEvent(new CustomEvent("loadstart", {
|
|
@@ -3,7 +3,7 @@ import { ArrayCamera, AxesHelper, Camera, Color, DirectionalLight, Fog, GridHelp
|
|
|
3
3
|
import { needleLogoOnlySVG } from "../assets/index.js";
|
|
4
4
|
import { isDevEnvironment } from "../debug/index.js";
|
|
5
5
|
import { ObjectUtils, PrimitiveType } from "../engine_create_objects.js";
|
|
6
|
-
import {
|
|
6
|
+
import { $fwGZrGe } from "../engine_license.js";
|
|
7
7
|
import { Mathf } from "../engine_math.js";
|
|
8
8
|
import { delay, DeviceUtilities } from "../engine_utils.js";
|
|
9
9
|
|
|
@@ -215,7 +215,7 @@ export class TemporaryXRContext {
|
|
|
215
215
|
this._scene.background = new Color(0x000000);
|
|
216
216
|
|
|
217
217
|
let logoSrc = needleLogoOnlySVG;
|
|
218
|
-
if (
|
|
218
|
+
if ($fwGZrGe()) {
|
|
219
219
|
const htmlComponent = document.querySelector("needle-engine");
|
|
220
220
|
if (htmlComponent) {
|
|
221
221
|
const licenseLogo = htmlComponent.getAttribute("logo-src");
|
|
@@ -1107,7 +1107,8 @@ export abstract class Component implements IComponent, EventTarget,
|
|
|
1107
1107
|
this.__didCompleteStart = false;
|
|
1108
1108
|
this.__inEnableOrDisableCallback = false;
|
|
1109
1109
|
this.__didEnable = false;
|
|
1110
|
-
|
|
1110
|
+
// Preserve copied/constructor-assigned enabled state while resetting lifecycle flags.
|
|
1111
|
+
// Cloned disabled components must not fall back to the default enabled=true state.
|
|
1111
1112
|
this.__destroyed = false;
|
|
1112
1113
|
this._internalInit(init);
|
|
1113
1114
|
return this;
|
|
@@ -614,7 +614,8 @@ export class SceneSwitcher extends Behaviour {
|
|
|
614
614
|
this._currentScene = undefined;
|
|
615
615
|
if (current) {
|
|
616
616
|
if (debug) console.log("[SceneSwitcher] UNLOAD", current.url, "HasURL?: " + current.hasUrl)
|
|
617
|
-
const
|
|
617
|
+
const activeSceneInstance = this._currentSceneAsset;
|
|
618
|
+
const sceneListener = this.tryGetSceneEventListener(activeSceneInstance as any as Object3D);
|
|
618
619
|
if (sceneListener?.sceneClosing) {
|
|
619
620
|
const res = sceneListener.sceneClosing();
|
|
620
621
|
if (res instanceof Promise) await res;
|
|
@@ -624,20 +625,24 @@ export class SceneSwitcher extends Behaviour {
|
|
|
624
625
|
// // then we unload it
|
|
625
626
|
if (current.hasUrl) {
|
|
626
627
|
current.unload();
|
|
627
|
-
if (
|
|
628
|
+
if (activeSceneInstance) destroy(activeSceneInstance, true, false);
|
|
628
629
|
}
|
|
629
630
|
else {
|
|
630
|
-
GameObject.remove(
|
|
631
|
+
GameObject.remove(activeSceneInstance);
|
|
631
632
|
}
|
|
633
|
+
this._currentSceneAsset = undefined;
|
|
632
634
|
}
|
|
633
635
|
}
|
|
634
636
|
|
|
635
637
|
private _currentlyLoadingScene?: AssetReference;
|
|
638
|
+
private _loadingRequestId: number = 0;
|
|
639
|
+
private _activeLoadingRequestId: number = 0;
|
|
636
640
|
/** @internal */
|
|
637
641
|
private async __internalSwitchScene(scene: AssetReference): Promise<boolean> {
|
|
638
642
|
|
|
639
643
|
await this.__unloadCurrentScene();
|
|
640
644
|
const index = this._currentIndex = this.scenes?.indexOf(scene) ?? -1;
|
|
645
|
+
const loadingRequestId = ++this._loadingRequestId;
|
|
641
646
|
|
|
642
647
|
try {
|
|
643
648
|
if (debug) console.debug(`${Date.now()} [SceneSwitcher] Loading scene start: ${scene.url} (index: ${index})`);
|
|
@@ -647,9 +652,10 @@ export class SceneSwitcher extends Behaviour {
|
|
|
647
652
|
const loadStartEvt = new CustomEvent<LoadSceneEvent>("loadscene-start", { detail: { scene: scene, switcher: this, index: index } })
|
|
648
653
|
this.dispatchEvent(loadStartEvt);
|
|
649
654
|
this.sceneLoadingStart?.invoke(loadStartEvt.detail);
|
|
650
|
-
await this.onStartLoading();
|
|
655
|
+
await this.onStartLoading(loadingRequestId);
|
|
651
656
|
// start loading and wait for the scene to be loaded
|
|
652
657
|
await scene.loadAssetAsync((_, prog) => {
|
|
658
|
+
if (loadingRequestId !== this._activeLoadingRequestId) return;
|
|
653
659
|
if (debug) {
|
|
654
660
|
const t01 = prog.loaded / prog.total;
|
|
655
661
|
const progressBarString = "[" + "=".repeat(Math.floor(t01 * 20)) + "-".repeat(20 - Math.floor(t01 * 20)) + "]";
|
|
@@ -659,12 +665,14 @@ export class SceneSwitcher extends Behaviour {
|
|
|
659
665
|
this.dispatchEvent(prog);
|
|
660
666
|
this.sceneLoadingProgress?.invoke(prog);
|
|
661
667
|
}).catch(console.error);
|
|
662
|
-
await this.onEndLoading();
|
|
668
|
+
await this.onEndLoading(loadingRequestId);
|
|
663
669
|
const finishedEvt = new CustomEvent<LoadSceneEvent>("loadscene-finished", { detail: { scene: scene, switcher: this, index: index } });
|
|
664
670
|
this.dispatchEvent(finishedEvt);
|
|
665
671
|
|
|
666
|
-
this.
|
|
667
|
-
|
|
672
|
+
if (loadingRequestId === this._activeLoadingRequestId) {
|
|
673
|
+
this._currentLoadingProgress = undefined;
|
|
674
|
+
this._currentlyLoadingScene = undefined;
|
|
675
|
+
}
|
|
668
676
|
|
|
669
677
|
if (finishedEvt.defaultPrevented) {
|
|
670
678
|
if (debug) console.warn("[SceneSwitcher] Adding loaded scene prevented:", scene, finishedEvt);
|
|
@@ -737,8 +745,8 @@ export class SceneSwitcher extends Behaviour {
|
|
|
737
745
|
history.pushState(stateName, "unused", location.href);
|
|
738
746
|
}
|
|
739
747
|
}
|
|
740
|
-
// Call SceneListener opened callback
|
|
741
|
-
const sceneListener = this.tryGetSceneEventListener(
|
|
748
|
+
// Call SceneListener opened callback on the scene instance that was actually added.
|
|
749
|
+
const sceneListener = this.tryGetSceneEventListener(this._currentSceneAsset as any as Object3D);
|
|
742
750
|
if (sceneListener?.sceneOpened) {
|
|
743
751
|
const res = sceneListener.sceneOpened(this);
|
|
744
752
|
if (res instanceof Promise) await res;
|
|
@@ -826,7 +834,8 @@ export class SceneSwitcher extends Behaviour {
|
|
|
826
834
|
private _isCurrentlyLoading: boolean = false;
|
|
827
835
|
private _currentLoadingProgress: ProgressEvent | undefined = undefined;
|
|
828
836
|
|
|
829
|
-
private async onStartLoading() {
|
|
837
|
+
private async onStartLoading(loadingRequestId: number) {
|
|
838
|
+
this._activeLoadingRequestId = loadingRequestId;
|
|
830
839
|
this._isCurrentlyLoading = true;
|
|
831
840
|
if (this.loadingScene) {
|
|
832
841
|
// save the last loading scene reference so that it can be changed at runtime
|
|
@@ -839,7 +848,7 @@ export class SceneSwitcher extends Behaviour {
|
|
|
839
848
|
this._loadingScenePromise = this.loadingScene?.loadAssetAsync().then(res => res != null);
|
|
840
849
|
}
|
|
841
850
|
await this._loadingScenePromise;
|
|
842
|
-
if (this._isCurrentlyLoading && this.loadingScene?.asset) {
|
|
851
|
+
if (loadingRequestId === this._activeLoadingRequestId && this._isCurrentlyLoading && this.loadingScene?.asset) {
|
|
843
852
|
if (debug) console.log("Add loading scene", this.loadingScene.url, this.loadingScene.asset)
|
|
844
853
|
const loadingScene = this.loadingScene.asset as any as Object3D;
|
|
845
854
|
GameObject.add(loadingScene, this.gameObject);
|
|
@@ -851,7 +860,7 @@ export class SceneSwitcher extends Behaviour {
|
|
|
851
860
|
}
|
|
852
861
|
}
|
|
853
862
|
// Invoke the event on a loading listener on the same object as the scene switcher
|
|
854
|
-
if (this._isCurrentlyLoading) {
|
|
863
|
+
if (loadingRequestId === this._activeLoadingRequestId && this._isCurrentlyLoading) {
|
|
855
864
|
const listener = this.tryGetSceneEventListener(this.gameObject);
|
|
856
865
|
if (listener) {
|
|
857
866
|
if (listener.sceneOpened) {
|
|
@@ -861,7 +870,8 @@ export class SceneSwitcher extends Behaviour {
|
|
|
861
870
|
}
|
|
862
871
|
}
|
|
863
872
|
}
|
|
864
|
-
private async onEndLoading() {
|
|
873
|
+
private async onEndLoading(loadingRequestId: number) {
|
|
874
|
+
if (loadingRequestId !== this._activeLoadingRequestId) return;
|
|
865
875
|
this._isCurrentlyLoading = false;
|
|
866
876
|
if (this.loadingScene?.asset) {
|
|
867
877
|
if (debug) console.log("Remove loading scene", this.loadingScene.url);
|
|
@@ -11,7 +11,7 @@ import { Behaviour } from "./Component.js";
|
|
|
11
11
|
import { IUSDExporterExtension } from "./export/usdz/Extension.js";
|
|
12
12
|
import { USDZExporter } from "./export/usdz/USDZExporter.js";
|
|
13
13
|
import type { OrbitControls } from "./OrbitControls.js";
|
|
14
|
-
import { Renderer } from "./Renderer.js";
|
|
14
|
+
import { Renderer, ShadowCastingMode } from "./Renderer.js";
|
|
15
15
|
|
|
16
16
|
const debugSeeThrough = getParam("debugseethrough");
|
|
17
17
|
|
|
@@ -164,6 +164,35 @@ export class SeeThrough extends Behaviour {
|
|
|
164
164
|
@serializable()
|
|
165
165
|
autoUpdate: boolean = true;
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* The alpha (opacity) the object is currently faded to, in the `[0, 1]` range.
|
|
169
|
+
* `1` means fully visible, `0` means fully hidden. This is the live, animated value
|
|
170
|
+
* (it lerps toward the target over {@link fadeDuration}), updated every frame the fade runs.
|
|
171
|
+
*
|
|
172
|
+
* External components can read this to react to the see-through state — e.g. toggling a
|
|
173
|
+
* collider, muting audio, or driving a UI prompt as the object fades in or out.
|
|
174
|
+
*
|
|
175
|
+
* @example React to the object becoming (almost) hidden
|
|
176
|
+
* ```ts
|
|
177
|
+
* if (seeThrough.currentAlpha < 0.1) {
|
|
178
|
+
* // object is essentially see-through now
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
* @default 1
|
|
182
|
+
*/
|
|
183
|
+
get currentAlpha(): number {
|
|
184
|
+
return this._currentAlpha;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Below this alpha the object stops casting a shadow. The shadow map only stores depth, so a
|
|
190
|
+
* faded object would otherwise keep casting a fully solid shadow (three.js does not fade shadows
|
|
191
|
+
* by opacity). Toggling shadow casting off near-invisible is the cleanest fix; we drive it via
|
|
192
|
+
* the {@link Renderer.shadowCastingMode} so it cooperates with the per-frame shadow settings the
|
|
193
|
+
* Renderer re-applies. Note this is a hard on/off, not a fade.
|
|
194
|
+
*/
|
|
195
|
+
public static readonly shadowHideThreshold = 0.05;
|
|
167
196
|
|
|
168
197
|
private readonly _referencePointVector: Vector3 = new Vector3();
|
|
169
198
|
private readonly _referencePointDir: Vector3 = new Vector3();
|
|
@@ -171,6 +200,9 @@ export class SeeThrough extends Behaviour {
|
|
|
171
200
|
private _renderer: Renderer[] | null = null;
|
|
172
201
|
private _needsUpdate = true;
|
|
173
202
|
private _id = i++;
|
|
203
|
+
private _currentAlpha: number = 1;
|
|
204
|
+
/** Renderers whose shadow casting we turned off while hidden, mapped to their original mode for restore. */
|
|
205
|
+
private readonly _suppressedShadowCasting = new Map<Renderer, ShadowCastingMode>();
|
|
174
206
|
|
|
175
207
|
/** * @internal */
|
|
176
208
|
onEnable() {
|
|
@@ -178,6 +210,12 @@ export class SeeThrough extends Behaviour {
|
|
|
178
210
|
this._renderer = null;
|
|
179
211
|
}
|
|
180
212
|
|
|
213
|
+
/** @internal */
|
|
214
|
+
onDestroy() {
|
|
215
|
+
// Don't leave renderers permanently non-casting if this component is removed.
|
|
216
|
+
this.restoreSuppressedShadowCasting();
|
|
217
|
+
}
|
|
218
|
+
|
|
181
219
|
/**
|
|
182
220
|
* @internal
|
|
183
221
|
*/
|
|
@@ -258,13 +296,49 @@ export class SeeThrough extends Behaviour {
|
|
|
258
296
|
if (newAlpha >= 0.99) newAlpha = 1;
|
|
259
297
|
else if (newAlpha <= 0.01) newAlpha = 0;
|
|
260
298
|
|
|
299
|
+
// Expose the live fade value so external components can react to it (see `currentAlpha`).
|
|
300
|
+
// Renderers are driven by the same target/duration, so the last applied value is representative.
|
|
301
|
+
this._currentAlpha = newAlpha;
|
|
302
|
+
|
|
261
303
|
// const currentTransparent = (block.getOverride("transparent")?.value ?? materials[0].transparent ?? false) as boolean;
|
|
262
304
|
|
|
263
305
|
block.setOverride("alphaHash", this.useAlphaHash);
|
|
264
306
|
block.setOverride("opacity", newAlpha);
|
|
265
307
|
block.setOverride("transparent", newAlpha >= 0.99999 ? false : !this.useAlphaHash);
|
|
308
|
+
|
|
309
|
+
// Stop casting a shadow once the object is essentially invisible (and restore it when it
|
|
310
|
+
// comes back). A faded object otherwise keeps a fully solid shadow — see shadowHideThreshold.
|
|
311
|
+
this.updateShadowCasting(renderer, newAlpha);
|
|
266
312
|
});
|
|
267
313
|
}
|
|
268
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Suppress or restore a renderer's shadow casting based on its current alpha.
|
|
317
|
+
* Driving {@link Renderer.shadowCastingMode} (rather than the raw `mesh.castShadow`) is required
|
|
318
|
+
* because the Renderer re-applies that setting every frame; we remember the original mode so it
|
|
319
|
+
* is restored exactly when the object fades back in.
|
|
320
|
+
*/
|
|
321
|
+
private updateShadowCasting(renderer: Renderer, alpha: number) {
|
|
322
|
+
const shouldHideShadow = alpha < SeeThrough.shadowHideThreshold;
|
|
323
|
+
if (shouldHideShadow) {
|
|
324
|
+
if (renderer.shadowCastingMode !== ShadowCastingMode.Off) {
|
|
325
|
+
this._suppressedShadowCasting.set(renderer, renderer.shadowCastingMode);
|
|
326
|
+
renderer.shadowCastingMode = ShadowCastingMode.Off;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else if (this._suppressedShadowCasting.has(renderer)) {
|
|
330
|
+
renderer.shadowCastingMode = this._suppressedShadowCasting.get(renderer)!;
|
|
331
|
+
this._suppressedShadowCasting.delete(renderer);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** Restore every renderer we suppressed shadow casting on, then clear the bookkeeping. */
|
|
336
|
+
private restoreSuppressedShadowCasting() {
|
|
337
|
+
for (const [renderer, mode] of this._suppressedShadowCasting) {
|
|
338
|
+
if (!renderer.destroyed) renderer.shadowCastingMode = mode;
|
|
339
|
+
}
|
|
340
|
+
this._suppressedShadowCasting.clear();
|
|
341
|
+
}
|
|
342
|
+
|
|
269
343
|
}
|
|
270
344
|
|
|
@@ -44,6 +44,7 @@ export { Behaviour, Component, GameObject } from "./Component.js";
|
|
|
44
44
|
export { AudioRolloffMode } from "./AudioSource.js";
|
|
45
45
|
export { ClearFlags } from "./Camera.js"
|
|
46
46
|
export { DragMode } from "./DragControls.js";
|
|
47
|
+
export { ShadowCastingMode, ReflectionProbeUsage } from "./Renderer.js";
|
|
47
48
|
export type { DropListenerNetworkEventArguments, DropListenerOnDropArguments } from "./DropListener.js";
|
|
48
49
|
export * from "./export/index.js"
|
|
49
50
|
export * from "./particlesystem/api.js"
|
|
@@ -3,7 +3,7 @@ import { Euler, Material, Matrix4, Mesh, Object3D, Quaternion, Vector3 } from "t
|
|
|
3
3
|
|
|
4
4
|
import { isDevEnvironment, showBalloonMessage, showBalloonWarning } from "../../../engine/debug/index.js";
|
|
5
5
|
import { findObjectOfType } from "../../../engine/engine_components.js";
|
|
6
|
-
import {
|
|
6
|
+
import { _XtEQ } from "../../../engine/engine_license.js";
|
|
7
7
|
import { serializable } from "../../../engine/engine_serialization.js";
|
|
8
8
|
import { getFormattedDate, Progress } from "../../../engine/engine_time_utils.js";
|
|
9
9
|
import { DeviceUtilities, getParam } from "../../../engine/engine_utils.js";
|
|
@@ -277,7 +277,7 @@ export class USDZExporter extends Behaviour {
|
|
|
277
277
|
let name = this.exportFileName ?? this.objectToExport?.name ?? this.name;
|
|
278
278
|
name += "-" + getFormattedDate(); // seems iOS caches the file in some cases, this ensures we always have a fresh file
|
|
279
279
|
|
|
280
|
-
if (!
|
|
280
|
+
if (!_XtEQ()) {
|
|
281
281
|
if (name !== "") name += "-";
|
|
282
282
|
name += "MadeWithNeedle";
|
|
283
283
|
}
|
|
@@ -682,7 +682,7 @@ export class USDZExporter extends Behaviour {
|
|
|
682
682
|
if (debug)
|
|
683
683
|
showBalloonMessage("Quicklook url: " + callToActionURL);
|
|
684
684
|
if (callToActionURL) {
|
|
685
|
-
if (!
|
|
685
|
+
if (!_XtEQ()) {
|
|
686
686
|
console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing", callToActionURL)
|
|
687
687
|
}
|
|
688
688
|
else {
|
|
@@ -697,7 +697,7 @@ export class USDZExporter extends Behaviour {
|
|
|
697
697
|
private buildQuicklookOverlay(): CustomBranding {
|
|
698
698
|
const obj: CustomBranding = {};
|
|
699
699
|
if (this.customBranding) Object.assign(obj, this.customBranding);
|
|
700
|
-
if (!
|
|
700
|
+
if (!_XtEQ()) {
|
|
701
701
|
console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing");
|
|
702
702
|
obj.callToAction = "Close";
|
|
703
703
|
obj.checkoutTitle = "🌵 Made with Needle";
|