2013-09-22 57 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所

使用正交相机