i have this code:
var camera, scene, controls, renderer;
init();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.z = 10;
//lights
var light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(10, 10, 10);
scene.add(light);
controls = new THREE.OrbitControls(camera);
controls.addEventListener('change', render);
renderer = new THREE.WebGLRenderer({alpha: true});
renderer.setClearColor(0x000000, 0); // the default
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var jsonLoader = new THREE.JSONLoader();
var mesh;
jsonLoader.load('corona.js',
function (geometry, materials) {
console.log(JSON.stringify(materials));
console.log(JSON.stringify(geometry));
var material = new THREE.MeshFaceMaterial(materials);
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
}
);
}
function animate() {
requestAnimationFrame(animate);
controls.update();
render();
}
function render() {
renderer.render(scene, camera);
}
Like you can see i am using JSONLoader to show a Corona beer, but for some reason it is not showing anything. You can take a look at the live code here http://xsportfit.com/corona/index.html These is a list of the files i used for this example:
- http://xsportfit.com/corona/corona.obj
- http://xsportfit.com/corona/corona.mtl
- http://xsportfit.com/corona/corona.js
I have used convert_obj_three.py script to convert corona.obj into corona.js file