How do you import a JSON model to Three.js...? -


i looking @ older question had code fixed this:

but won't work reason. there json files available work sure test with?

i tried json of ship exported using three.js editor (ship.js) , doesnt seem display anything- in fact, won't "hit" alert have set, indicating issue load of json file, perhaps?

<html>     <head></head>      <body>          <script src="three.min.js"></script>         <script> var camera, scene, renderer, mesh, loader;  init(); animate();  function init() {  camera = new three.perspectivecamera( 75, window.innerwidth / window.innerheight, 1, 10000 ); camera.position.z = 1000;  scene = new three.scene();  loader = new three.jsonloader();  loader.load( "ship.js", function( geometry ) {      //var geometry = new three.cubegeometry(5,10,5);  mesh = new three.mesh( geometry, new three.meshnormalmaterial() ); mesh.scale.set( 10, 10, 10 ); mesh.position.y = 0; mesh.position.x = 0; scene.add( mesh );             alert("hit");  } );    var ambientlight = new three.ambientlight(0x555555); scene.add(ambientlight);  var directionallight = new three.directionallight(0xffffff); directionallight.position.set(1, 1, 1).normalize(); scene.add(directionallight);  renderer = new three.webglrenderer(); renderer.setsize( window.innerwidth, window.innerheight );  document.body.appendchild( renderer.domelement );  }  function animate() {  requestanimationframe( animate );  mesh.rotation.x += 0.05;     mesh.rotation.y += 0.05;  renderer.render( scene, camera ); } </script>     </body> </html> 


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -