三个js孔未呈现为

时间:2017-12-14 09:27:21

标签: javascript three.js

我正在尝试创建一个简单的参数化形状(矩形),在中间有一个洞来创建一个框架。可悲的是,没有创建一个洞。控制台说THREE.ShapeUtils: Infinite Loop! Holes left:" + indepHoles.length + ", Probably Hole outside Shape!但是在调试会话后我发现它错了。这是我的代码,其中的注释包含.currentpoint

的x,y坐标
    var frameblock = new THREE.Shape();
frameblock.moveTo(topleft.x - 2*99/Math.SQRT2,topleft.y + 2*99/Math.SQRT2); // move to topleft x: -570 y: 410
frameblock.lineTo(topright.x + 99/Math.SQRT2,topright.y + 2*99/Math.SQRT2); // draw to topright x: 1092 y: 410
frameblock.lineTo(bottomright.x + 2* 99/Math.SQRT2  ,bottomright.y - 99/Math.SQRT2 ); //draw to bottomright x: 1092 y: -570
frameblock.lineTo(topleft.x - 2*99/Math.SQRT2,bottomleft.y - 99/Math.SQRT2); //draw to bottomleft x: -570 y:-570
frameblock.lineTo(topleft.x - 2*99/Math.SQRT2,topleft.y + 2*99/Math.SQRT2); // draw to topleft x: -570 y: 410

var framehole = new THREE.Path();
framehole.moveTo(topleft.x - 99/Math.SQRT2,topleft.y + 99/Math.SQRT2); // move to topleft x: -500 y: 340
framehole.lineTo(topright.x,topright.y + 99/Math.SQRT2); // draw to topright x:1022 y:340
framehole.lineTo(bottomright.x + 99/Math.SQRT2  ,bottomright.y); //draw to bottomright x:1022 y:-500
framehole.lineTo(topleft.x - 99/Math.SQRT2,bottomleft.y); //draw to bottomleft x: -500 y: -500
framehole.lineTo(topleft.x - 99/Math.SQRT2,topleft.y + 99/Math.SQRT2); // draw to topleft x: -500 y: 340

frameblock.holes.push(framehole);

var framegeometry = new THREE.ShapeGeometry(frameblock);

1 个答案:

答案 0 :(得分:1)

问题是它没有逆时针绘制。所以正确的顺序是:

print()