2013-09-22 66 views
-1

我一直在嘗試爲夜晚的較大部分做出一個導出代碼,它很快會讓我紋理立方體並將它們導出到我製作的遊戲中,但對於某些原因,我不能讓我的立方體覆蓋我想要的全部128x128寬度和高度。等距立方體,大小與瓷磚大小不匹配128x128

我有以下代碼:

function init(){ 

     if(Detector.webgl){ 
      renderer = new THREE.WebGLRenderer({ 
       antialias  : false, // to get smoother output 
       preserveDrawingBuffer : true // to allow screenshot 
      }); 
      renderer.setClearColorHex(0xBBBBBB, 1); 
     // uncomment if webgl is required 
     //}else{ 
     // Detector.addGetWebGLMessage(); 
     // return true; 
     }else{ 
      renderer = new THREE.CanvasRenderer(); 
     } 
     renderer.setSize(128,128); 
     document.getElementById('container').appendChild(renderer.domElement); 

     // add Stats.js - https://github.com/mrdoob/stats.js 
     stats = new Stats(); 
     stats.domElement.style.position = 'absolute'; 
     stats.domElement.style.bottom = '0px'; 
     document.body.appendChild(stats.domElement); 

     var zoom = 1.0; 

     // create a scene 
     scene = new THREE.Scene(); 

     // put a camera in the scene 
     camera = new THREE.OrthographicCamera(WIDTH/-zoom, HEIGHT/zoom, WIDTH/zoom, HEIGHT/-zoom, -2000, 1000); 
     //camera = new THREE.PerspectiveCamera(35, window.innerWidth/window.innerHeight, 1, 10000); 
     camera.position.set(0.45,0.45,0.45); 
     camera.lookAt(scene.position); 
     //camera.position.set(0, 0, 5); 
     scene.add(camera); 

     // create a camera contol 
     //cameraControls = new THREEx.DragPanControls(camera) 

     // transparently support window resize 
     THREEx.WindowResize.bind(renderer, camera); 
     // allow 'p' to make screenshot 
     THREEx.Screenshot.bindKey(renderer); 
     // allow 'f' to go fullscreen where this feature is supported 
     //if(THREEx.FullScreen.available()){ 
     // THREEx.FullScreen.bindKey();   
     // document.getElementById('inlineDoc').innerHTML += "- <i>f</i> for fullscreen"; 
     //} 

     // here you add your objects 
     // - you will most likely replace this part by your own 
     //var geometry = new THREE.TorusGeometry(1, 0.42); 
     var cubeSize = 128; 

     var geometry = new THREE.CubeGeometry(cubeSize, cubeSize, cubeSize); 
     var material = new THREE.MeshNormalMaterial(); 
     mesh= new THREE.Mesh(geometry, material); 
     mesh.rotation.x = 0; 
     mesh.rotation.y = 0; 
     mesh.rotation.z = 0; 
     scene.add(mesh); 
    } 

我一直在嘗試不同的「放大」,但它最終還是過大或過小。 這一切的關鍵是結束了一個代碼,可以產生這樣的:

https://dl.dropboxusercontent.com/u/5256694/cube_ex.png

我在做什麼錯?

親切的問候

+0

是有時emperical數據比試圖找到更好的邏輯。我解決了這個問題,但是我還沒有想到爲什麼我使用的價值,工作= / – Hiam

回答

0

而是想着THREE.OrthographicCamera參數爲「縮放」級別的,你應該把它們當作相機能夠看到邊界平面座標。

也看到了答案Three.js - Orthographic camera爲更多細節在three.js所

使用正交相機
相關問題