I have an .obj file which has Vertex Colors in it. That is it doesn't have seperate .mtl file for its Texture . The .obj File itself contains the color for each vertex.
I wanted to load it using three.js
I knew I can load a normal .obj file with .mtl using :
objLoader = new THREE.OBJLoader();
objLoader.load('meshlabshristi3.obj', function(object) {
scene.add(object);
});
But mine has vertex colors so I found it can be done with OBJLoader2.js so tried executing it like :
var objLoader = new THREE.OBJLoader2();
objLoader.load('assets/faceimage9.obj', function(object) {
scene.add(object);
});
But it throws errors saying
OBJLoader2.js:6 Uncaught SyntaxError: Cannot use import statement outside a module
index.html:80 Uncaught TypeError: THREE.OBJLoader2 is not a constructor
at init (index.html:80)
at index.html:31
Am I doing it wrong or is there any other problem . Can anyone post the exact code to load a vertex colored mesh . Thanks in advance for anyone who tried to read and solve it ...
If anyone need a vertex colored mesh to work on I had attached below.. Vertex Colored Model
For the comment below I attach this image:
