javascript - three.js JsonLoader is not showing JSON object converted from .obj -
i have 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); // 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 can see using jsonloader show corona beer, reason not showing anything. can take @ live code here http://xsportfit.com/corona/index.html these list of files used 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 convert corona.obj corona.js file
something wrong in json. can have displayed directly writing material. example
new three.meshlambertmaterial({ color:0xffffff, map:three.imageutils.loadtexture('botellatext.jpg') });
Comments
Post a Comment