0
第一個畫布,id =「main」,設置爲窗口大小是否可行。這個畫布的相機被連接到一個物體,以便它可以像箭頭鍵一樣移動,就像駕駛一樣,起始位置(x,y,z)將是0,0,25。這工作正常。第二個畫布,id =「radar」,設置爲150 x 150,位於絕對底部:0和左側:0。第二臺攝像機是一個開銷,開始位置(x,y,z)將是0,110,0和rotation.x -1.75。這也適用。我怎樣才能讓他們同時工作。使用兩個攝像頭和兩個畫布
這裏是代碼
echo'function createRenderer(){';
echo'renderer = new THREE.WebGLRenderer({antialias: true});';
echo'renderer.setClearColor(0xffffff);';
echo'renderer.setSize(window.innerWidth, window.innerHeight);';
echo'main = renderer.domElement;';
echo'main.id = "main";';
echo'AddElem(GetElem("body"),main);';
echo'}';
echo'function createRadar(){';
echo'radar = CreateElem("canvas");';
echo'radar.id = "radar";';
//echo'context = radar.getContext("2d");';
echo'AddElem(GetElem("body"),radar);';
echo'}';
echo'function cameras(){';
echo'sphere0 = new Sphere(0,0,0);';
echo'sphere0.id="s0";';
echo'scene.add(sphere0);';
echo'camera1 = new THREE.PerspectiveCamera(70, window.innerWidth/window.innerHeight, 1, 10000);';
echo'camera1.matrixAutoUpdate = true;';
echo'Controls.init(sphere0,camera1,0,0,25);';
echo'camera2 = new THREE.PerspectiveCamera(70, window.innerWidth/window.innerHeight, 1, 10000);';
echo'camera2.position.x = 0;';
echo'camera2.rotation.x = -1.75;';
echo'camera2.position.y = 110;';
echo'camera2.position.z = 0;';
echo'scene.add(camera2);';
echo'}';
echo'function render() {';
echo'requestAnimationFrame(render);';
echo'camera2.lookAt(sphere0.position);';
echo'Controls.update();';
echo'camera2.position.x = sphere0.position.x;';
echo'camera2.position.z = sphere0.position.z;';
echo'camera2.updateProjectionMatrix();';
//echo'renderer.clear();';
echo'renderer.setViewport(1,1,148,148);';
echo'renderer.setRenderTarget(radar);';
echo'renderer.render(scene, camera2);';
echo'renderer.setViewport(0,0,window.innerWidth, window.innerHeight);';
echo'renderer.setRenderTarget(main);';
echo'renderer.render(scene, camera1);';
echo'}';
不,這只是當時在一個PHP文件... – 2014-12-16 06:56:13
無論我嘗試了什麼,我都無法使它工作。 – 2014-12-16 06:57:36