@babylonjs-toolkit/next 9.34.1 → 9.34.10
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/lib/scenemanager.d.ts +34 -0
- package/lib/scenemanager.d.ts.map +1 -1
- package/lib/scenemanager.js +193 -3
- package/package.json +1 -1
package/lib/scenemanager.js
CHANGED
|
@@ -143,7 +143,7 @@ import { UnityScrollBar } from './unityscrollbar';
|
|
|
143
143
|
import { UnityDropdownMenu } from './unitydropdownmenu';
|
|
144
144
|
import { RectAreaLight } from '@babylonjs/core/Lights/rectAreaLight';
|
|
145
145
|
export class SceneManager {
|
|
146
|
-
static get Version() { return "9.34.
|
|
146
|
+
static get Version() { return "9.34.10 - R1"; }
|
|
147
147
|
static get Copyright() { return "All rights reserved (c) 2024 Mackey Kinard"; }
|
|
148
148
|
static IsPrecompilingShaders() {
|
|
149
149
|
return SceneManager.PrecompileShaders !== false;
|
|
@@ -338,6 +338,11 @@ export class SceneManager {
|
|
|
338
338
|
await assetsManager.loadAsync();
|
|
339
339
|
}
|
|
340
340
|
static ShowLoadingScreen(engine, hideLoadingUIWithEngine = true, defaultLoadingUIMarginTop = "150px") {
|
|
341
|
+
const pageCover = (LoadingScreenStages != null) ? LoadingScreenStages.FindPageCover() : null;
|
|
342
|
+
if (pageCover != null) {
|
|
343
|
+
LoadingScreenStages.AttachScreen(pageCover, defaultLoadingUIMarginTop);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
341
346
|
if (engine.loadingScreen != null) {
|
|
342
347
|
SceneManager._HideLoadingScreen = engine.loadingScreen.hideLoadingUI.bind(engine.loadingScreen);
|
|
343
348
|
if (hideLoadingUIWithEngine === false)
|
|
@@ -348,9 +353,20 @@ export class SceneManager {
|
|
|
348
353
|
if (anyLoadingScreen._loadingTextDiv != null && anyLoadingScreen._loadingTextDiv.style != null) {
|
|
349
354
|
anyLoadingScreen._loadingTextDiv.style.marginTop = defaultLoadingUIMarginTop;
|
|
350
355
|
}
|
|
356
|
+
if (LoadingScreenStages != null)
|
|
357
|
+
LoadingScreenStages.Attach(anyLoadingScreen, defaultLoadingUIMarginTop);
|
|
351
358
|
}
|
|
352
359
|
}
|
|
353
360
|
static HideLoadingScreen(engine, fade = true) {
|
|
361
|
+
if (LoadingScreenStages != null) {
|
|
362
|
+
const unrevealed = LoadingScreenStages.SceneToReveal(engine);
|
|
363
|
+
if (unrevealed != null) {
|
|
364
|
+
SceneManager._FadeLoadingScreen = fade;
|
|
365
|
+
SceneManager.HideSplashScreen(unrevealed);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
LoadingScreenStages.Detach();
|
|
369
|
+
}
|
|
354
370
|
if (engine.loadingScreen != null) {
|
|
355
371
|
if (fade === false) {
|
|
356
372
|
const anyLoadingScreen = engine.loadingScreen;
|
|
@@ -470,9 +486,11 @@ export class SceneManager {
|
|
|
470
486
|
});
|
|
471
487
|
}
|
|
472
488
|
static RevealSplashScreen(scene) {
|
|
489
|
+
const fade = SceneManager._FadeLoadingScreen;
|
|
490
|
+
SceneManager._FadeLoadingScreen = true;
|
|
473
491
|
if (scene != null && !scene.isDisposed) {
|
|
474
492
|
try {
|
|
475
|
-
SceneManager.HideLoadingScreen(scene.getEngine());
|
|
493
|
+
SceneManager.HideLoadingScreen(scene.getEngine(), fade);
|
|
476
494
|
}
|
|
477
495
|
catch (e) {
|
|
478
496
|
console.warn(e);
|
|
@@ -490,6 +508,16 @@ export class SceneManager {
|
|
|
490
508
|
console.warn(e);
|
|
491
509
|
}
|
|
492
510
|
}
|
|
511
|
+
else if (LoadingScreenStages != null && LoadingScreenStages.IsShowing()) {
|
|
512
|
+
const engine = (scene != null) ? scene.getEngine() : EngineStore.LastCreatedEngine;
|
|
513
|
+
try {
|
|
514
|
+
if (engine != null)
|
|
515
|
+
SceneManager.HideLoadingScreen(engine, fade);
|
|
516
|
+
}
|
|
517
|
+
catch (e) {
|
|
518
|
+
console.warn(e);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
493
521
|
if (typeof document === "undefined")
|
|
494
522
|
return;
|
|
495
523
|
try {
|
|
@@ -630,7 +658,7 @@ export class SceneManager {
|
|
|
630
658
|
if (splash == null)
|
|
631
659
|
splash = document.getElementById("xbabylonjsLoadingDiv");
|
|
632
660
|
if (splash == null)
|
|
633
|
-
return
|
|
661
|
+
return (LoadingScreenStages != null && LoadingScreenStages.IsShowing());
|
|
634
662
|
const style = window.getComputedStyle(splash);
|
|
635
663
|
return style.display !== "none" && style.visibility !== "hidden" && splash.style.opacity !== "0";
|
|
636
664
|
}
|
|
@@ -5511,6 +5539,7 @@ SceneManager.AllLayerMask = 0xFFFFFFFF;
|
|
|
5511
5539
|
SceneManager.DefaultLayerMask = 0x0FFFFFFF;
|
|
5512
5540
|
SceneManager.HiddenLayerMask = 0x10000000;
|
|
5513
5541
|
SceneManager._HideLoadingScreen = null;
|
|
5542
|
+
SceneManager._FadeLoadingScreen = true;
|
|
5514
5543
|
SceneManager.CVTOOLS_NAME = "CVTOOLS_unity_metadata";
|
|
5515
5544
|
SceneManager.CVTOOLS_MESH = "CVTOOLS_babylon_mesh";
|
|
5516
5545
|
SceneManager.CVTOOLS_HAND = "CVTOOLS_left_handed";
|
|
@@ -16290,6 +16319,167 @@ LoadingProgress.Clock = () => ((typeof performance !== "undefined") ? performanc
|
|
|
16290
16319
|
LoadingProgress.Jobs = new Map();
|
|
16291
16320
|
LoadingProgress.PostStates = new Map();
|
|
16292
16321
|
LoadingProgress.DisposeHooks = new Set();
|
|
16322
|
+
export class LoadingScreenStages {
|
|
16323
|
+
static Attach(loadingScreen, marginTop) {
|
|
16324
|
+
if (typeof document === "undefined" || loadingScreen == null)
|
|
16325
|
+
return;
|
|
16326
|
+
const screens = loadingScreen._loadingDivToRenderingCanvasMap;
|
|
16327
|
+
if (screens == null || typeof screens.forEach !== "function")
|
|
16328
|
+
return;
|
|
16329
|
+
const covers = [];
|
|
16330
|
+
screens.forEach((_canvas, screen) => { covers.push(screen); });
|
|
16331
|
+
LoadingScreenStages.Begin(covers, marginTop);
|
|
16332
|
+
}
|
|
16333
|
+
static FindPageCover() {
|
|
16334
|
+
if (typeof document === "undefined" || document.getElementById("xbabylonjsSplashScreen") != null)
|
|
16335
|
+
return null;
|
|
16336
|
+
return document.getElementById("xbabylonjsLoadingDiv");
|
|
16337
|
+
}
|
|
16338
|
+
static AttachScreen(screen, marginTop) {
|
|
16339
|
+
if (typeof document === "undefined" || screen == null)
|
|
16340
|
+
return;
|
|
16341
|
+
LoadingScreenStages.Begin([screen], marginTop);
|
|
16342
|
+
}
|
|
16343
|
+
static Begin(covers, marginTop) {
|
|
16344
|
+
LoadingScreenStages.Detach(true);
|
|
16345
|
+
if (covers.length === 0)
|
|
16346
|
+
return;
|
|
16347
|
+
covers.forEach((screen) => {
|
|
16348
|
+
screen.style.opacity = "0.995";
|
|
16349
|
+
screen.style.willChange = "opacity";
|
|
16350
|
+
LoadingScreenStages.Views.push(LoadingScreenStages.CreateView(screen, marginTop));
|
|
16351
|
+
});
|
|
16352
|
+
LoadingScreenStages.BarState = -1;
|
|
16353
|
+
LoadingScreenStages.BarProgress = null;
|
|
16354
|
+
LoadingScreenStages.PreviousHostDefers = SceneManager.HostDefersSceneStatus;
|
|
16355
|
+
SceneManager.HostDefersSceneStatus = true;
|
|
16356
|
+
LoadingScreenStages.Observer = SceneManager.OnLoaderStatusObservable.add(LoadingScreenStages.OnLoaderStatus);
|
|
16357
|
+
}
|
|
16358
|
+
static IsShowing() {
|
|
16359
|
+
return LoadingScreenStages.Views.some((view) => view.screen.isConnected !== false && view.screen.style.opacity !== "0");
|
|
16360
|
+
}
|
|
16361
|
+
static SceneToReveal(engine) {
|
|
16362
|
+
if (SceneShaderWarmup == null || LoadingScreenStages.IsShowing() !== true)
|
|
16363
|
+
return null;
|
|
16364
|
+
const scene = (engine.scenes != null && engine.scenes.length > 0) ? engine.scenes[engine.scenes.length - 1] : null;
|
|
16365
|
+
if (scene == null || scene.isDisposed || SceneShaderWarmup.IsSceneRevealed(scene))
|
|
16366
|
+
return null;
|
|
16367
|
+
return scene;
|
|
16368
|
+
}
|
|
16369
|
+
static FadeScreen(screen) {
|
|
16370
|
+
if (screen == null)
|
|
16371
|
+
return;
|
|
16372
|
+
const onFadeEnd = (event) => {
|
|
16373
|
+
if (event.target !== screen || event.propertyName !== "opacity")
|
|
16374
|
+
return;
|
|
16375
|
+
screen.removeEventListener("transitionend", onFadeEnd);
|
|
16376
|
+
screen.remove();
|
|
16377
|
+
};
|
|
16378
|
+
screen.addEventListener("transitionend", onFadeEnd);
|
|
16379
|
+
screen.style.opacity = "0";
|
|
16380
|
+
LoadingScreenStages.Detach();
|
|
16381
|
+
}
|
|
16382
|
+
static GetBarState() {
|
|
16383
|
+
return LoadingScreenStages.BarState;
|
|
16384
|
+
}
|
|
16385
|
+
static ShowStatus(status, details, progress, state) {
|
|
16386
|
+
const barProgress = LoadingScreenStages.NextBarProgress(progress, state);
|
|
16387
|
+
LoadingScreenStages.Views.forEach((view) => {
|
|
16388
|
+
if (status != null && status !== "")
|
|
16389
|
+
view.status.textContent = LoadingScreenStages.ToSentenceCase(status);
|
|
16390
|
+
if (details != null)
|
|
16391
|
+
view.details.textContent = LoadingScreenStages.ToSentenceCase(details);
|
|
16392
|
+
if (barProgress != null) {
|
|
16393
|
+
if (view.slide != null) {
|
|
16394
|
+
view.slide.cancel();
|
|
16395
|
+
view.slide = null;
|
|
16396
|
+
}
|
|
16397
|
+
view.fill.style.opacity = "";
|
|
16398
|
+
view.fill.style.width = Math.round(barProgress * 100) + "%";
|
|
16399
|
+
view.stage.setAttribute("aria-valuenow", "" + Math.round(barProgress * 100));
|
|
16400
|
+
}
|
|
16401
|
+
});
|
|
16402
|
+
}
|
|
16403
|
+
static Detach(removeStages = false) {
|
|
16404
|
+
if (LoadingScreenStages.Observer != null) {
|
|
16405
|
+
SceneManager.OnLoaderStatusObservable.remove(LoadingScreenStages.Observer);
|
|
16406
|
+
LoadingScreenStages.Observer = null;
|
|
16407
|
+
SceneManager.HostDefersSceneStatus = LoadingScreenStages.PreviousHostDefers;
|
|
16408
|
+
}
|
|
16409
|
+
LoadingScreenStages.Views.forEach((view) => {
|
|
16410
|
+
if (view.slide != null)
|
|
16411
|
+
view.slide.cancel();
|
|
16412
|
+
if (removeStages === true) {
|
|
16413
|
+
view.stage.remove();
|
|
16414
|
+
view.details.remove();
|
|
16415
|
+
}
|
|
16416
|
+
});
|
|
16417
|
+
LoadingScreenStages.Views = [];
|
|
16418
|
+
}
|
|
16419
|
+
static CreateView(screen, marginTop) {
|
|
16420
|
+
const details = document.createElement("div");
|
|
16421
|
+
details.style.cssText = "position:absolute;right:18px;bottom:12px;font-family:Arial;font-size:12px;color:white;text-align:right;z-index:2;opacity:0.9;letter-spacing:0.3px";
|
|
16422
|
+
const stage = document.createElement("div");
|
|
16423
|
+
stage.setAttribute("role", "progressbar");
|
|
16424
|
+
stage.setAttribute("aria-valuemin", "0");
|
|
16425
|
+
stage.setAttribute("aria-valuemax", "100");
|
|
16426
|
+
stage.style.cssText = "position:absolute;left:50%;top:50%;transform:translateX(-50%);width:min(320px, calc(100% - 32px));font-family:Arial;font-size:14px;color:white;text-align:center;z-index:1";
|
|
16427
|
+
stage.style.marginTop = marginTop;
|
|
16428
|
+
const status = document.createElement("div");
|
|
16429
|
+
status.style.cssText = "min-height:18px;margin-bottom:10px;letter-spacing:0.3px";
|
|
16430
|
+
status.textContent = LoadingScreenStages.START_TEXT;
|
|
16431
|
+
const track = document.createElement("div");
|
|
16432
|
+
track.style.cssText = "position:relative;width:100%;height:4px;overflow:hidden;border-radius:2px;background-color:rgba(255, 255, 255, 0.15)";
|
|
16433
|
+
const fill = document.createElement("div");
|
|
16434
|
+
fill.style.cssText = "width:30%;height:100%;border-radius:2px;transition:width 0.25s ease-out";
|
|
16435
|
+
fill.style.backgroundColor = LoadingScreenStages.BAR_COLOR;
|
|
16436
|
+
track.appendChild(fill);
|
|
16437
|
+
stage.appendChild(status);
|
|
16438
|
+
stage.appendChild(track);
|
|
16439
|
+
screen.appendChild(details);
|
|
16440
|
+
screen.appendChild(stage);
|
|
16441
|
+
return { screen: screen, stage: stage, status: status, details: details, fill: fill, slide: LoadingScreenStages.StartSlide(fill) };
|
|
16442
|
+
}
|
|
16443
|
+
static StartSlide(fill) {
|
|
16444
|
+
const reduced = (typeof window.matchMedia === "function") && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
16445
|
+
if (reduced || typeof fill.animate !== "function") {
|
|
16446
|
+
fill.style.width = "100%";
|
|
16447
|
+
fill.style.opacity = "0.4";
|
|
16448
|
+
return null;
|
|
16449
|
+
}
|
|
16450
|
+
return fill.animate([{ transform: "translateX(-100%)" }, { transform: "translateX(340%)" }], { duration: LoadingScreenStages.SLIDE_DURATION_MS, iterations: Infinity, easing: "ease-in-out" });
|
|
16451
|
+
}
|
|
16452
|
+
static OnLoaderStatus(update) {
|
|
16453
|
+
if (LoadingScreenStages.IsShowing() !== true) {
|
|
16454
|
+
LoadingScreenStages.Detach();
|
|
16455
|
+
return;
|
|
16456
|
+
}
|
|
16457
|
+
LoadingScreenStages.ShowStatus(update.status, update.details, update.progress, update.state);
|
|
16458
|
+
}
|
|
16459
|
+
static NextBarProgress(progress, state) {
|
|
16460
|
+
if (typeof progress !== "number" || !isFinite(progress))
|
|
16461
|
+
return null;
|
|
16462
|
+
const value = Math.max(0, Math.min(1, progress));
|
|
16463
|
+
const restart = (state !== LoadingScreenStages.BarState || !(state >= 0));
|
|
16464
|
+
LoadingScreenStages.BarState = state;
|
|
16465
|
+
LoadingScreenStages.BarProgress = (restart || LoadingScreenStages.BarProgress == null) ? value : Math.max(LoadingScreenStages.BarProgress, value);
|
|
16466
|
+
return LoadingScreenStages.BarProgress;
|
|
16467
|
+
}
|
|
16468
|
+
static ToSentenceCase(text) {
|
|
16469
|
+
if (text === "" || text !== text.toUpperCase())
|
|
16470
|
+
return text;
|
|
16471
|
+
const lower = text.toLowerCase();
|
|
16472
|
+
return lower.charAt(0).toUpperCase() + lower.slice(1);
|
|
16473
|
+
}
|
|
16474
|
+
}
|
|
16475
|
+
LoadingScreenStages.START_TEXT = "Loading Scene ...";
|
|
16476
|
+
LoadingScreenStages.BAR_COLOR = "#E0684B";
|
|
16477
|
+
LoadingScreenStages.SLIDE_DURATION_MS = 1200;
|
|
16478
|
+
LoadingScreenStages.Views = [];
|
|
16479
|
+
LoadingScreenStages.Observer = null;
|
|
16480
|
+
LoadingScreenStages.PreviousHostDefers = false;
|
|
16481
|
+
LoadingScreenStages.BarState = -1;
|
|
16482
|
+
LoadingScreenStages.BarProgress = null;
|
|
16293
16483
|
export class MaterialSamplerBudget {
|
|
16294
16484
|
static InstallForScene(scene) {
|
|
16295
16485
|
if (scene == null)
|