I can't load a babylon scene

Hey, i’m trying to load this scene: https://srv-file10.gofile.io/download/hlb7H0/scene.babylon (I didn’t attach because it wont let news users) but I get this error.

Uncaught (in promise) TypeError: Cannot read property 'Parse' of null
    at Function.e.Parse (babylon.js?633b:16)
    at Ls (babylon.js?633b:16)
    at Object.load (babylon.js?633b:16)
    at eval (babylon.js?633b:16)
    at d (babylon.js?633b:16)
    at e (babylon.js?633b:16)
    at XMLHttpRequest.g (babylon.js?633b:16)

I’v loaded many scenes before but I guess Im getting this problem because of some materials(Someone had the same issue and you guys told him to import “@babylonjs/materials” but that didn’t work for me)?

Hello @Hyper and welcome to the forum

First is your scene working in the sandbox ???

Also could you share the repro on github for instance as it looks related to you import setup .

1 Like

Hey @sebavan thank you,

the scene is working in the sandbox and there is no need for a repro the code is actually simple:

loadScene(path, cam, disabledPH) {
    return SceneLoader.LoadAsync("", path, this.engine).then((scene) => {
      if (this.scene) {
        // this.scene.disablePhysicsEngine();
      if (this.debug) scene.debugLayer.show();
      if (cam)
        scene.activeCamera = new FreeCamera(
          new Vector3(0, 0, 0),
      scene.activeCamera.attachControl(this.canvas, true);
      if (!disabledPH) {
        // scene.enablePhysics(new Vector3(0, -10, 0), new OimoJSPlugin());
      this.scene = scene;

the relevant code is the first line. Also you might think I made a spelling mistake when calling the function but it’s 100% right.

This is not the part of the code that is problematic. I am pretty sure one of the feature of your scene does require more imports from the ES6 libs which are not present but it is impossible to troubleshoot without your current setup.

1 Like

BTW I’m not using any templates I started from scratch here are my imports:

import {
} from "babylonjs";
import "@babylonjs/materials";

Do you know where in the documention I can learn more about the required imports? or do you have an idea on what I’m missing

Ok I got it, you are mixing our es5 implementation and es6 one creating the issue.

Could you try import “babylonjs-materials”; instead ???


1 Like

Thank you so much It’s working :slight_smile:

1 Like