Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/tools/playground/src/scss/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1080,3 +1080,7 @@
.editor-widget {
z-index: 1 !important;
}

.parameter-hints-widget {
overflow-y: auto;
}
39 changes: 19 additions & 20 deletions packages/tools/playground/src/tools/monaco/run/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
toolkit:
enable.toolkit ??
((autoProbe &&
(/\bBABYLON\.Toolkit\.SceneManager\.InitializePlayground\b/.test(allSource) ||
(/TOOLKIT\.SceneManager/u.test(allSource) ||
/\bSM\.InitializePlayground\b/.test(allSource) ||
location.href.includes("BabylonToolkit") ||
((): boolean => {
Expand All @@ -411,7 +411,7 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
toolkit: "https://cdn.jsdelivr.net/gh/BabylonJS/BabylonToolkit@master/Runtime/babylon.toolkit.js",
};

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

// SOUND
if (want.sound) {
try {
const anyB = (window as any).BABYLON as any;
const opts = (engine as any).getCreationOptions?.();
if (!opts || opts.audioEngine !== false) {
anyB.AbstractEngine.audioEngine = anyB.AbstractEngine.AudioEngineFactory(
engine.getRenderingCanvas(),
engine.getAudioContext?.(),
engine.getAudioDestination?.()
);
}
} catch {
/* ignore */
}
}

// TOOLKIT
if (want.toolkit) {
await loadScriptOnce(urls.toolkit || defaults.toolkit);
Expand All @@ -486,6 +469,7 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
return await import(/* webpackIgnore: true */ s);
});
const entrySpec = specKey(entryPath);
await initRuntime();
const mod = await importFn(entrySpec);
let engine: ThinEngine | null = null;
if (typeof mod.createEngine === "function") {
Expand All @@ -505,8 +489,23 @@ export async function CreateV2Runner(manifest: V2Manifest, opts: V2RunnerOptions
if (!engine) {
throw new Error("Failed to create engine.");
}
// Sound post-creation init
if (want.sound) {
try {
const anyB = (window as any).BABYLON as any;
const opts = (engine as any).getCreationOptions?.();
if (!opts || opts.audioEngine !== false) {
anyB.AbstractEngine.audioEngine = anyB.AbstractEngine.AudioEngineFactory(
engine.getRenderingCanvas(),
engine.getAudioContext?.(),
engine.getAudioDestination?.()
);
}
} catch {
/* ignore */
}
}
(window as any).engine = engine;
await initRuntime(engine);

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