Is there a new Editor build workflow?

I’ve been trying to use the in-Editor Build button and keep receiving errors:

Button Error Logs

image

For what it’s worth, I ran npm run build in the integrated terminal and appeared to get the same errors.

Terminal Error Logs

I looked through some related posts on the forums

but their issues were solved by removing the Material Editor a while back.

My project contained only the default assets that are created when first setting up a project. I tried to setup my file path based on this tutorial with “editor-projects” and “web-projects” folders; and I looked through the Github tutorials as well.

I’m at a loss on how to go about troubleshooting what I’ve done wrong, so any tips or tricks on this would be greatly appreciated! :smile:

(And I might as well ping @julien-moreau :slightly_smiling_face:)

Hey @tbunker thanks for reporting!
That would help me a lot if you can send me your project, so I can open it and see what is going bad.

For my information, have you renamed the project using the toolbar “File => Rename Project” ? It looks like no more “index.ts” exists for the folder “{workspace_path}/src/scenes/scene” or the fodler “scene” has been renamed/removed. Do you confirm?

I did rename my project from “scene” to “Cube Tests” using Rename Project. I noticed there is a folder with that name in src/scenes, and inside that folder is where index.ts is.

I couldn’t upload the entire project. (Is 33MB too large?)

So here’s just the src folder:
src.zip (5.3 KB)

That means in the “src/index.ts” file, the path to “scenes/scene/index.ts” is no more valid and it should be now “scenes/Cube Tests/index.ts”. Let’s open the “index.ts” file in “src/index.ts” and search for “./scenes/scene” and replace to “./scenes/Cube Tests”

Can you try that while I’m testing your project if I can see other problems?

Renaming the paths in the .ts files when renaming a project is still in my todo list

1 Like

That worked!

So if I create another project (let’s say “Test2”), and a Test2 folder gets created in src/scenes, do I change the file path in index.ts depending on which project I’m wanting to build?

Exact, that means you’ll have to code in order to manage your scenes at the moment.

For example, let’s say you have 2 scenes: A and B.
The “index.ts” file in “src/” is main entry point of the application. By default, it loads the scene named “scene” and imports the components of the scene named “scene”.

Imagine you rename “scene” to “A” and create another scene that you name “B”.
In the index.ts file you’ll have to change the import from “./scenes/scene” to “./scenes/A”
Also, you’ll have to change the path to the scene to load in the “._load” function

from

const rootUrl = "./scenes/scene/";

to

const rootUrl = "./scenes/A/";

Also, for example, if you want to append A and B you’ll have to:
Import components:

  • import { runScene as runSceneA } from “./scenes/A”;
  • import { runScene as runSceneB } from “./scenes/B”;

Modify the ._load function from

SceneLoader.Append(rootUrl, "scene.babylon", this.scene, () => {
    this.scene.executeWhenReady(() => {
        // Attach camera.
        if (!this.scene.activeCamera) {
            throw new Error("No camera defined in the scene. Please add at least one camera in the project or create one yourself in the code.");
        }
        this.scene.activeCamera.attachControl(this.engine.getRenderingCanvas(), false);

        // Run the scene to attach scripts etc.
        runScene(this.scene, rootUrl);

        // Render.
        this.engine.runRenderLoop(() => this.scene.render());
    });
}, undefined, (_, message) => {
    console.error(message);
}, "babylon");

to

const rootUrlA = "./scenes/A/";
const rootUrlB = "./scenes/B/";

await Promise.all([
    SceneLoader.AppendAsync(rootUrlA, "scene.babylon", this.scene),
    SceneLoader.AppendAsync(rootUrlB, "scene.babylon", this.scene),
]);

this.scene.executeWhenReady(() => {
    // Attach camera.
    if (!this.scene.activeCamera) {
        throw new Error("No camera defined in the scene. Please add at least one camera in the project or create one yourself in the code.");
    }
    this.scene.activeCamera.attachControl(this.engine.getRenderingCanvas(), false);

    // Run the scene to attach scripts etc.
    runSceneA(this.scene, rootUrlA);
    runSceneB(this.scene, rootUrlB);

    // Render.
    this.engine.runRenderLoop(() => this.scene.render());
});

Something like that. It is open to the developer to adopt his own strategy.

Unfortunately, managing scenes still requires development skills and no tools are provided in the Editor to manage/switch etc. scenes. This is in my todolist and they’ll come ASAP!

1 Like

Awesome, thank you very much!