我有以下的HTMLHTML5 3D,帆布,three.js所
<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);
}
作品,
但如何寫入到畫布上使用jQuery?
$('#container').appendChild(renderer.domElement);
不起作用。
我注意到隨着信譽系統變得越來越流行,答案的質量正在慢慢下降。 – uSeRnAmEhAhAhAhAhA