1.用紋理渲染圖形
給六個面添加一個紋理圖的形式
var geometry = new THREE.CubeGeometry( 1, 1, 1 );
var texture = THREE.ImageUtils.loadTexture("earth.jpg", null, function (t) {
});
//4.將紋理應用於材質
var material = new THREE.MeshBasicMaterial({ map: texture });
cube = new THREE.Mesh( geometry, material );
scene.add( cube );
給六個面每個面各添加一個紋理圖核心代碼如下:(注意這裏只添加圖片,不添加燈光是什麼也看不到的,即使給material
添加了顏色也看不到
// light
var light = new THREE.PointLight(0xffffff, 1, 1000);
light.position.set(10, 15, 20);
scene.add(light);
var geometry = new THREE.BoxGeometry( 10, 10, 10 );
var texture = THREE.ImageUtils.loadTexture('num.png', {}, function() {
renderer.render(scene, camera);
});
var material = new THREE.MeshLambertMaterial({
map: texture
});
cube = new THREE.Mesh( geometry, material );
scene.add( cube );