mrdoob/three.js — Issue #1034: Failed to draw in specified canvas?
Author: georgeou2003
Created: 2012-01-06 11:00:40+00:00
State: open

Hi, I am trying to draw objects in my specified html div canvas, following the example http://mrdoob.github.com/three.js/examples/webgl_multiple_canvases_grid.html

however, no error showed up, but nothing show on my canvas ,what could be the possible cause, and here is my code!

container=document.getElementById("canvasOperation");

camera = new THREE.Camera( 40,container.clientWidth / container.clientHeight, 1, 10000 );
camera.position.z = camdist;

camera.position.x = camdist * Math.cos( alpha *0.01745);
camera.position.z = camdist * Math.sin( alpha *0.01745 );
camera.position.y=40;

scene = new THREE.Scene();

projector = new THREE.Projector();

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( container.clientWidth, container.clientHeight );

container.appendChild( renderer.domElement );

stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );

var ambientLight = new THREE.AmbientLight( 0x303030 );
scene.addLight( ambientLight );

sun = new THREE.DirectionalLight( 0xffffff );
sun.position = camera.position.clone();
scene.addLight( sun );

var geom2=new THREE.CubeGeometry(10,10,10,10,10,10,10,10,10);
obj = new THREE.Line(geom2,new THREE.MeshLambertMaterial( { color: 0xff0000}));
scene.addObject( obj );

animate();