I used vite to build the vue3 project. Here is the version of babylonjs I used
the code in vscode:
public async RegisterInspectorOnInput(scene: Scene) {
console.log(scene, "scene");
if (!scene) return;
const isEnv = import.meta.env.MODE === "development";
if (isEnv) {
await Promise.all([import("@babylonjs/core/Debug/debugLayer"), import("@babylonjs/inspector")]);
scene.debugLayer.show({ embedMode: true });
}
const toggleInspector = () => {
if (scene.debugLayer.isVisible()) scene.debugLayer.hide();
else scene.debugLayer.show();
};
scene.onKeyboardObservable.add((kbInfo) => {
if (kbInfo.type === KeyboardEventTypes.KEYDOWN && kbInfo.event.key === "i") {
toggleInspector();
}
});
}
And this method is called when appropriate
setupScene(): { scene: Scene; camera: ArcRotateCamera } {
const scene = new Scene(this.manager.engine);
scene.clearColor = new Color4(1, 0, 0, 0);
scene.autoClear = false; // Color buffer
scene.autoClearDepthAndStencil = false; // Depth and stencil, obviously
const camera = new ArcRotateCamera("mainSceneCamera", Math.PI / 2, Math.PI / 2, 10, Vector3.Zero(), scene);
camera.wheelPrecision = 30;
camera.attachControl(this.manager.canvas, true);
// call it
this.registerInspectorOnInput(scene);
return {
scene,
camera
};
}
The inspector works fine except for clicking the statistics button
Crash log: