OBJExporter - not returning anything

Hi guys,

I must be doing something really stupid but this piece of code is not working for me and i can’t spot whats wrong. Basically testdata is not showing anything. Also If I just pass mesh as opposed to scene it still doesn’t work. I had OBJExporter working in older code when it wasn’t a module so not sure if that is the issue

Could you advise

var scene = new THREE.Scene();

const geometry = new THREE.BoxGeometry(100, 100, 100).clone();

const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });          

scene.add(new THREE.Mesh(geometry,material));

var exporter = new OBJExporter();

var testdata = exporter.parse(scene);

console.log("testdata is " + testdata);

I’ve created a live example based on your code and it seems to work as expected:

https://jsfiddle.net/2h1mpa6d/

Please try to modify the code in order to demonstrate the issue.

Ahh - So I tried your code and it worked! Only difference was where you were importing the modules from . I had downloaded the latest version of threejs from three.org - r119. Should there be any difference between what I downloaded three.js-master.zip and where you are pointed to online??

The URLs target the r119 release so the code should be identical :+1:.

Ok I spotted the problem - really stupid! I had an extra backslash when importing objExporter

import { OBJLoader2 } from ‘…//three/examples/jsm/loaders/OBJLoader2.js’;

should have been

import { OBJLoader2 } from ‘…/three/examples/jsm/loaders/OBJLoader2.js’;

Strange thing is I did a quick test and added text to the objExporter modue to see if it was being called and it returned the text when I had the double backslash.

Thanks for the help again

1 Like