<script type="text/javascript"> functioninit(){ //渲染器 var renderer = new THREE.WebGLRenderer({ canvas:document.getElementById('mainCanvas') }); renderer.setClearColor(0x000000); //场景 var scene = new THREE.Scene(); //照相机 var camera = new THREE.OrthographicCamera(-10, 10, 7.5, -7.5, 0.1, 100); camera.position.set(-5, 25, 25); camera.lookAt(new THREE.Vector3(0, 0, 0)); scene.add(camera);
//光照 var light = new THREE.PointLight(0xffffff, 1, 1000); light.position.set(15,25,20); scene.add(light);
//材质 // var texture = THREE.ImageUtils.loadTexture('img',{},function(){ // renderer.render(scene,camera); // });
var materials = []; for(var i = 0;i<6;++i){ materials.push(new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture('img/'+i+'.png',{},function(){ renderer.render(scene,camera); }), overdraw: true
})); }
var cube = new THREE.Mesh(new THREE.CubeGeometry(5,5,5), new THREE.MeshFaceMaterial(materials)); scene.add(cube);
<script type="text/javascript"> functioninit(){ //渲染器 var renderer = new THREE.WebGLRenderer({ canvas:document.getElementById('mainCanvas') }); renderer.setClearColor(0x000000); //场景 var scene = new THREE.Scene(); //照相机 var camera = new THREE.OrthographicCamera(-10, 10, 7.5, -7.5, 0.1, 100); camera.position.set(0, 0, 25); camera.lookAt(new THREE.Vector3(0, 0, 0)); scene.add(camera);
//光照 var light = new THREE.PointLight(0xffffff, 1, 1000); light.position.set(15,25,20); scene.add(light);