1
我需要製作一個帶有紋理的球。我在WebGL和Three.js上很新。問題是我看到一個白色球體,但沒有它的紋理。作爲新用戶,我無法提交圖片。Three.js不顯示我的紋理
的部分代碼是這樣的:
function init() {
canvas = document.getElementById('canvas');
camera = new THREE.PerspectiveCamera(90, window.innerWidth/window.innerHeight, 1, 10000);
camera.position.z = 1000;
scene = new THREE.Scene();
camera.lookAt (scene.position);
var llum = new THREE.DirectionalLight();
llum.intensity=50;
llum.position.x=camera.position.x;
llum.position.y=camera.position.y;
llum.position.z=camera.position.z;
llum.lookAt(scene.position);
scene.add(llum);
var texture = THREE.ImageUtils.loadTexture('ull.jpg');
texture.needsUpdate = true;
var material = new THREE.MeshBasicMaterial(texture);
var quality = 16, step = 1024/quality;
var geom = new THREE.SphereGeometry(500,100,100);
mesh = new THREE.Mesh(geom, material);
scene.add(mesh);
renderer = new THREE.WebGLRenderer({ antialias: true});
renderer.setSize(window.innerWidth, window.innerHeight);
canvas.innerHTML = "";
//Afegim al canvas el que hem de renderitzar
canvas.appendChild(renderer.domElement);
document.addEventListener('mousemove', onDocumentMouseMove, false);
window.addEventListener('resize', onWindowResize, false);
}
在此先感謝。
該死!它只是工作。非常感謝。 – yafrack
沒有probs。請記住標記答案是正確的。 – mrdoob