BJS4 - Import error BABYLON.OBJExport.OBJ - Webpack

#1

In the playground, I am able to use

console.log(BABYLON.OBJExport.OBJ([sphere]));

When I create a react project with the same code, I get:
TypeError: Cannot read property ‘OBJ’ of undefined

In this project I have installed:

npm install --save babylonjs

npm install --save babylonjs babylonjs-serializers

And in the code it is imported as:

import * as BABYLON from "babylonjs";

import "babylonjs-serializers";
#2

This is a question for master of modules @sebavan

#3

Try this maybe

import * as Exporter from 'babylonjs-serializers'

and

Exporter.OBJ([sphere]));
#4

Got:
TypeError: babylonjs_serializers__WEBPACK_IMPORTED_MODULE_10__.OBJ is not a function

Nice try though, thanks

#5

You need to rely on the dedicated class:

import { OBJExport } from ‘babylonjs-serializers’;

and then:

OBJExport.OBJ([sphere]));

#6

It worked!!!, thanks

1 Like