Babylon.js: When i load stl file, it shows importScene of undefined from undefined version

Created on 4 Dec 2018  路  4Comments  路  Source: BabylonJS/Babylon.js

Bugs

BABYLON.SceneLoader.Append('/assets/stl/', 'arm.stl', scene, function(scene) {

});
  • Expected result: expect to load stl
  • Current result: but it failed with exception as following:
    BJS - [02:26:40]: Unable to load from /assets/stl/arm.stl: importScene of undefined from undefined version: undefined, exporter version: undefinedimportScene has failed JSON parse
    image

Most helpful comment

@deltakosh I fixed by modify the import: import 'babylonjs-loaders'; Thanks

I tried with that import but I wasn't still able to load the .obj. It seems that webpack is doing something fancy behind. I solved with this quick workaround:

import { Engine, Scene, ArcRotateCamera, HemisphericLight, Vector3, Mesh, MeshBuilder, SceneLoader } from 'babylonjs';
import {OBJFileLoader} from 'babylonjs-loaders';


SceneLoader.RegisterPlugin(new OBJFileLoader())

All 4 comments

Hello did you make sure to reference the stl loader first?
https://doc.babylonjs.com/how_to/stl

@deltakosh yeah, i used angular js, and imported as following:

import * as BABYLON from 'babylonjs';
import * as BABYLON_LOADER from 'babylonjs-loaders';

export class TestComponent {
     testMethod() {
      // ... init scene
      BABYLON.SceneLoader.Append('/assets/stl/', 'arm.stl', scene, function(scene) {

    });
     }
}

@deltakosh I fixed by modify the import: import 'babylonjs-loaders'; Thanks

@deltakosh I fixed by modify the import: import 'babylonjs-loaders'; Thanks

I tried with that import but I wasn't still able to load the .obj. It seems that webpack is doing something fancy behind. I solved with this quick workaround:

import { Engine, Scene, ArcRotateCamera, HemisphericLight, Vector3, Mesh, MeshBuilder, SceneLoader } from 'babylonjs';
import {OBJFileLoader} from 'babylonjs-loaders';


SceneLoader.RegisterPlugin(new OBJFileLoader())

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nbduke picture nbduke  路  21Comments

deltakosh picture deltakosh  路  39Comments

individ2016 picture individ2016  路  39Comments

deltakosh picture deltakosh  路  61Comments

deltakosh picture deltakosh  路  23Comments