問題: 在真棒Three.js中,我無法弄清楚如何將EllipseCurve轉換爲我可以擠出的路徑。Three.js - 我如何使用EllipseCurve作爲擠出路徑?
在下面的例子中,如果我取消了LineCurve3的註釋,我的方形很好地沿着它展開。如果我將它作爲EllipseCurve運行,則沒有錯誤,但屏幕上不顯示任何內容。我試圖將相機放大,以確保它不出於任何原因不在屏幕上。
我知道EllipseCurve正在正確生成,因爲我可以用線條材料(未在下面的代碼中顯示)寫出它。
代碼
var radius = 1100;
var degreesStart = 75;
var degreesEnd = 30;
var radiansStart = (degreesStart * Math.PI)/180;
var radiansEnd = ((degreesEnd) * Math.PI)/180;
// this won't seem to work as an extrude path, but doesn't give any errors
var path = new THREE.EllipseCurve(0, 0, radius, radius, radiansStart, radiansEnd, true);
// this works fine as an extrude path
//var path = new THREE.LineCurve3(new THREE.Vector3(0, 0, 0), new THREE.Vector3(1000, 1000, 0));
var extrusionSettings = { steps: 100, bevelEnabled: false, extrudePath: path };
// draw a square to extrude along the path
var sectionSize = [];
sectionSize.push(new THREE.Vector2(0, 0));
sectionSize.push(new THREE.Vector2(1000, 0));
sectionSize.push(new THREE.Vector2(1000, 1000));
sectionSize.push(new THREE.Vector2(0, 1000));
var sectionShape = new THREE.Shape(sectionSize);
var componentGeometry = new THREE.ExtrudeGeometry(sectionShape, extrusionSettings);
var component = new THREE.Mesh(componentGeometry, material);
group.add(component);
我曾嘗試: 我試圖使其工作都試圖從曲線與點提取到的路徑擠出使用。我覺得我得到的最接近是
var ellipsePath = new THREE.CurvePath(path.getSpacedPoints(20));
// where 'path' is my EllipseCurve in the code above
// (and then changed the extrusion settings to use 'ellipsePath ' instead).
這給了錯誤「無法讀取屬性‘distanceTo’空的」。
我似乎無法理解EllipseCurve如何與有關路徑的點相關。
任何人都可以點我在正確的方向請,或有一些代碼,你已經遇到了同樣的問題?非常感謝。
感謝您抽出時間來回答詹姆斯。我無法嘗試您的答案,因爲該項目現在已經採用瞭解決方法,並且在我們再次需要幫助之前(希望在幾周內我引用他們進行了一些更改)。我會盡我所能記住嘗試實現這一點,並回來獎勵你的努力! –
@ casual-bob在此先感謝。 –