我使用three.js使用ShapeGeometry渲染街道。
这是代码:
import { CONSTANTS, MATERIALS } from '../common'
let ret = new Array<THREE.Mesh>();
let rampShape = new THREE.Shape();
rampShape.moveTo(0,0);
rampShape.lineTo(0, ramp.width);
//some more line and curve drawing, which works perfectly
let geo = new THREE.ShapeGeometry(rampShape);
geo.faces.map( (x) => { x.color.set(MATERIALS.roadMaterial.color); });
let mesh = new THREE.Mesh(geo, MATERIALS.roadMaterial);
mesh.material.side = 2;
mesh.updateMatrix();
mesh.rotateX(-Math.PI/2);
mesh.rotateY(Math.PI);
//this is imported from another file
export const MATERIALS = {
roadMaterial: new THREE.MeshBasicMaterial({
color: 0x333333,
side: THREE.DoubleSide,
opacity: 1.0
})
}
但是当我旋转形状,或者从“另一边”看它时,我就消失了。我听说使用DoubleSided Materials解决了这个问题。
我添加了side = 2因为我认为也许这些打字稿enum会以某种方式混淆THREE.DoubleSided常量,但它无论如何都不起作用。
我使用tsd install命令安装了Typings,它们是最新的。
有人知道吗?如果我没有让它工作,我想我可以挤出形状 - 我想避免出于性能原因。