BJS4 - Import error BABYLON.OBJExport.OBJ - Webpack

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";

This is a question for master of modules @sebavan

Try this maybe

import * as Exporter from 'babylonjs-serializers'

and

Exporter.OBJ([sphere]));

Got:
TypeError: babylonjs_serializers__WEBPACK_IMPORTED_MODULE_10__.OBJ is not a function

Nice try though, thanks

You need to rely on the dedicated class:

import { OBJExport } from ‘babylonjs-serializers’;

and then:

OBJExport.OBJ([sphere]));

It worked!!!, thanks

1 Like