Skip to content

Commit a4b23f5

Browse files
authored
[Playground] Fixes for editor v2 (#17347)
1. CSS fix for function parameters overflow 2. Change order of execution for the runner when we have external dependencies that are referenced in code from global namespace. The only external dep that relies on the existence of an Engine is Sound, so everything else can come first and then patch the engine for Sound if that's a dependency afterwards
1 parent 87b3b6a commit a4b23f5

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

packages/tools/playground/src/scss/editor.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,3 +1080,7 @@
10801080
.editor-widget {
10811081
z-index: 1 !important;
10821082
}
1083+
1084+
.parameter-hints-widget {
1085+
overflow-y: auto;
1086+
}

packages/tools/playground/src/tools/monaco/run/runner.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
391391
toolkit:
392392
enable.toolkit ??
393393
((autoProbe &&
394-
(/\bBABYLON\.Toolkit\.SceneManager\.InitializePlayground\b/.test(allSource) ||
394+
(/TOOLKIT\.SceneManager/u.test(allSource) ||
395395
/\bSM\.InitializePlayground\b/.test(allSource) ||
396396
location.href.includes("BabylonToolkit") ||
397397
((): boolean => {
@@ -411,7 +411,7 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
411411
toolkit: "https://cdn.jsdelivr.net/gh/BabylonJS/BabylonToolkit@master/Runtime/babylon.toolkit.js",
412412
};
413413

414-
async function initRuntime(engine: ThinEngine) {
414+
async function initRuntime(): Promise<void> {
415415
// AMMO
416416
if (want.ammo) {
417417
const hasFactory = typeof (window as any).Ammo === "function";
@@ -451,23 +451,6 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
451451
}
452452
}
453453

454-
// SOUND
455-
if (want.sound) {
456-
try {
457-
const anyB = (window as any).BABYLON as any;
458-
const opts = (engine as any).getCreationOptions?.();
459-
if (!opts || opts.audioEngine !== false) {
460-
anyB.AbstractEngine.audioEngine = anyB.AbstractEngine.AudioEngineFactory(
461-
engine.getRenderingCanvas(),
462-
engine.getAudioContext?.(),
463-
engine.getAudioDestination?.()
464-
);
465-
}
466-
} catch {
467-
/* ignore */
468-
}
469-
}
470-
471454
// TOOLKIT
472455
if (want.toolkit) {
473456
await loadScriptOnce(urls.toolkit || defaults.toolkit);
@@ -486,6 +469,7 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
486469
return await import(/* webpackIgnore: true */ s);
487470
});
488471
const entrySpec = specKey(entryPath);
472+
await initRuntime();
489473
const mod = await importFn(entrySpec);
490474
let engine: ThinEngine | null = null;
491475
if (typeof mod.createEngine === "function") {
@@ -505,8 +489,23 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
505489
if (!engine) {
506490
throw new Error("Failed to create engine.");
507491
}
492+
// Sound post-creation init
493+
if (want.sound) {
494+
try {
495+
const anyB = (window as any).BABYLON as any;
496+
const opts = (engine as any).getCreationOptions?.();
497+
if (!opts || opts.audioEngine !== false) {
498+
anyB.AbstractEngine.audioEngine = anyB.AbstractEngine.AudioEngineFactory(
499+
engine.getRenderingCanvas(),
500+
engine.getAudioContext?.(),
501+
engine.getAudioDestination?.()
502+
);
503+
}
504+
} catch {
505+
/* ignore */
506+
}
507+
}
508508
(window as any).engine = engine;
509-
await initRuntime(engine);
510509

511510
let createScene: any = null;
512511
if (mod.default?.CreateScene) {

0 commit comments

Comments
 (0)