three.js - THREEjs cant get a sphree to render to screen -
three.js - THREEjs cant get a sphree to render to screen -
hii trying sphree render screen. here js file.
function earth() { this.getearth = init(); function init() { var map = {map:three.imageutils.loadtexture("images/earth_surface_2048.jpg")}; var material = new three.meshbasicmaterial(map); var geometry = new three.spheregeometry(1,32,32); homecoming new three.mesh(geometry, material); } function update() { getearth.rotation.x += .01; } }
and here script in html file threejs included page.
<script> var renderer = null; var scene = null; var photographic camera = null; var mesh = null; var earth = null; $(document).ready( function() { var container = document.getelementbyid("container"); renderer = new three.webglrenderer({ antialias: true } ); renderer.setsize(container.offsetwidth,container.offsetheight); container.appendchild(renderer.domelement) scene = new three.scene(); photographic camera = new three.perspectivecamera( 45, container.offsetwidth / container.offsetheight, 1, 4000 ); earth = new earth(); scene.add(camera); scene.add(earth.getearth); renderer.render( scene, photographic camera ); } ); </script>
i no erros debugger, ideas ?
earth.getearth null or function. remember scene.add() silently ignoring stuff can't take, undefined values , on.
how changing var getearth = init();
this.getearth = init();
code outside of class scope see variable in earth object. althought advice against using method-like name variable containing object.
three.js webgl
Comments
Post a Comment