I want to upload a .json format with objLoader of three.js, everything works perfect in webpack dev-server but when I try to open it through Expressjs The error appears:
this is my threejs code
group = new THREE.Group();
const objLoader = new THREE.ObjectLoader();
objLoader.load('/dist/orig.json', (obj) => {
objLoader.parseMaterials(obj);
for ( let i = 0; i <= 300; i ++ ) {
let mesh = new THREE.Mesh( obj.geometry, obj.material );
mesh.position.x = Math.random() * 2000 - 1000;
mesh.position.y = Math.random() * 2000 - 1000;
mesh.position.z = Math.random() * 2000 - 1000;
mesh.rotation.x = Math.random() * 2 * Math.PI;
mesh.rotation.y = Math.random() * 2 * Math.PI;
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
group.add(mesh);
}
});
scene.add( group );
the model in .json format
{
"metadata": {
"version": 4.5,
"type": "Object",
"generator": "Object3D.toJSON"
},
"geometries": [
{
"uuid": "E659E6A4-5694-47CA-81D3-7A0B1C3CE82F",
"type": "BufferGeometry",
"data": {
"attributes": {
"position": {...
},
"normal": { ...
},
}
},
"boundingSphere": {
"center": [0.255983,14.427521,43.275352],
"radius": 62.117679
}
}
}],
"materials": [
{
"uuid": "786A7F66-D4CA-4E72-B923-D1CBC05E6A7A",
"type": "MeshNormalMaterial",
"depthFunc": 3,
"depthTest": true,
"depthWrite": true
}],
"object": {
"uuid": "52B0AF11-9409-4324-8D5E-892A13524F12",
"type": "Mesh",
"name": "Object.1",
"layers": 1,
"matrix": [1.634013,0,0,0,0,2.454071,0,0,0,0,2.481994,0,2.12552,19.763961,-34.185104,1],
"geometry": "E659E6A4-5694-47CA-81D3-7A0B1C3CE82F",
"material": "786A7F66-D4CA-4E72-B923-D1CBC05E6A7A"
}
}
Thanks