Three.js OBJLoader does not load obj file -
i trying load obj file using objloader.js trying load "plane.obj" file exists inside same folder html files exists , "objloader.js" exists in same folder.
page doesn't show anything.
here code :
var scene = new three.scene(); camera = new three.perspectivecamera(75, window.innerwidth/window.innerheight, 0.1, 1000); var renderer = new three.webglrenderer(); renderer.setsize(window.innerwidth, window.innerheight); document.body.appendchild(renderer.domelement); var geometry = new three.cubegeometry(1,1,1); var material = new three.meshbasicmaterial({color: 0x00ff00}); var cube = new three.mesh(geometry, material); scene.add(cube); camera.position.z = 5; function render() { requestanimationframe(render); cube.rotation.x += 0.01; cube.rotation.y += 0.01; renderer.render(scene, camera); } var texture = three.imageutils.loadtexture( 'tex.jpg' ); var loader = new three.objloader(); loader.load( 'plane.obj', function ( object ) { scene.add( object ); } ); render();
this caused trying load resource file system. you're getting same origin policy security violation , need serve page , resources same protocol, domain , port. there few easy ways - use simple http server app via node js. check out how run things locally more options.
Comments
Post a Comment