Greetings fellow developers! I have written some code to import a JSON file and render it using three.js. The JSON file was exported from the three.js editor. Strangely, there are no errors appearing in the console.
window.onload = function(){
var shapeObjectUrl = "test.json";
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
var loader = new THREE.JSONLoader();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
loader.load(shapeObjectUrl,
function (geometry, materials) {
console.log(geometry, materials);
var mesh = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial());
scene.add(mesh);
console.log(mesh);
render();
});
camera.position.z = 5;
var render = function() {
requestAnimationFrame(render);
renderer.render(scene, camera);
};
};
Here is the content of the JSON file:
{
"metadata": {
...
}
}
Any assistance with this issue would be greatly appreciated.