javascript - WebGl - not loaded texture -
i receive error: uncaught securityerror: failed execute 'teximage2d' on 'webglrenderingcontext': cross-origin image @ file:///c:/users/.../img.jpg may not loaded.
var scene, camera, renderer; var geometry, material, mesh; init(); animate(); function init() { scene = new three.scene(); camera = new three.perspectivecamera( 75, window.innerwidth / window.innerheight, 1, 10000 ); camera.position.z = 1000; geometry = new three.cubegeometry( 300, 300, 300 ); material = new three.meshlambertmaterial({ map: three.imageutils.loadtexture('img.jpg') }); mesh = new three.mesh( geometry, material ); scene.add( mesh ); renderer = new three.webglrenderer(); renderer.setsize( window.innerwidth, window.innerheight ); renderer.setclearcolorhex( 0xfff8dc, 1 ); document.body.appendchild( renderer.domelement ); } function animate() { requestanimationframe( animate ); mesh.rotation.x += 0.02; mesh.rotation.y += 0.01; renderer.render( scene, camera ); }
i run simple static content server called mongoose locally on development machine. point folder contains project , can load page without worrying cross site scripting/origin issues,
Comments
Post a Comment