2016-02-12 57 views
0

我正在嘗試重新創建this Three.js example。它從一組預定義的塊面生成地形幾何。然而,簡單地複製代碼開始,我遇到了一個問題。在three.js中轉換基本幾何

這裏是用於從例如一個塊面的代碼:

var pxGeometry = new THREE.PlaneGeometry(100, 100); 

pxGeometry.faces[ 0 ].vertexColors = [ light, shadow, light ]; 
pxGeometry.faces[ 1 ].vertexColors = [ shadow, shadow, light ]; 
pxGeometry.faceVertexUvs[ 0 ][ 0 ][ 0 ].y = 0.5; 
pxGeometry.faceVertexUvs[ 0 ][ 0 ][ 2 ].y = 0.5; 
pxGeometry.faceVertexUvs[ 0 ][ 1 ][ 2 ].y = 0.5; 
pxGeometry.rotateY(Math.PI/2); 
pxGeometry.translate(50, 0, 0); 

這拋出pxGeometry.rotateY is not a function

據我所知,旋轉和翻譯功能在PlaneGeometry默認情況下不可用。但是,如果是這種情況,我無法看到這些示例中添加了哪些內容。

如何在Three.js中旋轉,平移和縮放基本幾何圖形?

+0

您引用的示例確實使用了r74。 – gaitat

+0

@gaitat我更新了問題。我只是直接複製代碼並添加了最新的cdn,所以我認爲一定是問題所在。這就是說,我仍然無法找到問題。 –

+1

那麼問題不在您發佈的代碼中。這裏是你的代碼使用R74擺弄沒有錯誤:http://jsfiddle.net/8fhxw4je/ – gaitat

回答

1

THREE.PlaneGeometry的原型建立在THREE.Geometry原型之上。你可以看到here。這意味着THREE.Geometry的所有方法也可用於THREE.PlaneGeometry實例。

THREE.Geometry有一個rotateY方法。你可以看到here in the documentationhere in the file

因此要回答您的問題:您可以使用THREE.Geometry中的所有方法來旋轉,平移和縮放基本幾何圖形。