【发布时间】:2020-07-12 21:02:03
【问题描述】:
我想使用 Three.js 制作 3D 建筑。例如,我通过棋盘纹理制作了 6 面墙和 1 面地板。我对 wall1 和 wall4 使用了 clippingPlanes:
floor1.material.clippingPlanes = [plane1,plane4];
我用我的墙(墙 1 和墙 4)制作了我的飞机(平面 1 和平面 4)。比如我的wall4 planeGeometry和plane4代码在这里:
var wallGeometry4 = new THREE.PlaneGeometry(40, Floor_Height, 1, 1);
var wall4 = createMesh(wallGeometry4, "brick_diffuse.jpg", THREE.DoubleSide, 1024, 1024);
unit1.add(wall4);
wall4.position.x = -10;
wall4.position.y = 0;
wall4.position.z = -20;
wall4.rotation.y = 1.5 * Math.PI;
wall4.add(new THREE.EdgesHelper(wall4, 0x000000));
var plane4 = new THREE.Plane();
var normal4 = new THREE.Vector3();
var point4 = new THREE.Vector3();
normal4.set(0, 0, -1).applyQuaternion(wall4.quaternion);
point4.copy(wall4.position);
plane4.setFromNormalAndCoplanarPoint(normal4, point4);
但我看到 wall5 和 wall6 之间有一个空白区域,因为 plane4(用于剪裁地板)与 wall4 的大小不同。我认为Plane4是整个场景。如何更改我的飞机大小以正确剪辑?或者有什么办法可以让地板以墙为界?
【问题讨论】:
-
THREE.Plane()是一个无限的数学平面。 -
我该怎么办?如何正确填充地板?没有办法吗?
-
作为一个选项:您知道墙壁的尺寸,因此您可以获取角点,然后从它们构建形状几何。
-
另一种选择:使用相交剪裁来切出你的角落。 threejs.org/examples/?q=clipping#webgl_clipping_intersection
-
另一种选择是不要使用clippingPlanes,而是快速编写自己的剪辑
shaderMaterial
标签: three.js