我有以下 HTML
<canvas id="container" name ="container" width="300" height="300"></canvas>
和 JavaScript 代码
var WIDTH = 400, HEIGHT = 300;
var VIEW_ANGLE = 90, ASPECT = WIDTH / HEIGHT, NEAR = 1, FAR = 300;
renderer = new THREE.CanvasRenderer();
renderer.setSize( WIDTH, HEIGHT );
camera = new THREE.PerspectiveCamera(VIEW_ANGLE,ASPECT,NEAR,FAR);
camera.position.z = 200;
scene = new THREE.Scene();
scene.add(camera);
renderer.render( scene, camera );
document.body.appendChild( renderer.domElement );
//$('#container').appendChild(renderer.domElement);
$('#container').width(WIDTH);
$('#container').height(HEIGHT);
function getSphere() {
var radius = 50, segments = 16, rings = 16;
var geometry = new THREE.SphereGeometry(radius,segments,rings);
var material = new THREE.MeshLambertMaterial({
color: 0xCC0000
});
return new THREE.Mesh(geometry, material);
}
document.body.appendChild( renderer.domElement );
作品,
但是如何用 jQuery 写入画布呢?
$('#container').appendChild(renderer.domElement);
不起作用。