Import .wrl or VRML 97 mesh

I have a VRML 97 file I’d like to import and display. Can I do this in BabylonJS?
The code for what I’m doing is here:
var modelToLoad = "phase_1.wrl"; var modelURL = "models/"; if (currentMesh == null) { var mesh = BABYLON.SceneLoader.ImportMesh("", modelURL, modelToLoad, scene, function (newMeshes) { scene.removeMesh(currentMesh); currentMesh = null; currentMesh = newMeshes[0]; currentMesh.rotate(BABYLON.Axis.Z, -Math.PI, BABYLON.Space.LOCAL); currentMesh.translate(new BABYLON.Vector3(-1, -1, -1), 65, BABYLON.Space.LOCAL); }); }

However I get this error

babylon.js:16 BJS - [14:15:31]: Unable to import meshes from models/phase_1.wrl: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse

I did see this work: VRML Loader - Need Help but I don’t know if I need to use her loader or if I just need BabylonJs API call.

Hey @Strix!

Babylon doesn’t naturally import or support VRML files (Load from any file type - glTF, OBJ, STL, etc. - Babylon.js Documentation), so you’ll have to either use the custom importer from the previous VRML loader thread

OR find a different way to convert VRML Files to something Babylon supports like glTF or OBJ.

One option might be to use Blender to import the file and then export to glTF. Blender 2.8+ has a built in support for exporting .glTF files, AND supports importing VRML files from what I understand in this thread.

Hope this is helpful!!!

1 Like