简体   繁体   English

如何在 Threejs 中绘制开口曲线形状

[英]How to draw open end curve shapes in Threejs

I am drawing curves/polygons by using ExtrudeBufferGeometry.我正在使用 ExtrudeBufferGeometry 绘制曲线/多边形。 Usually it always has closed ends.通常它总是有封闭的末端。 For example:例如: 在此处输入图片说明

My target is to draw similar shapes but open ended like我的目标是绘制类似的形状但开放式

在此处输入图片说明 在此处输入图片说明

Note that my target is not " LINES " or " Planes ".请注意,我的目标不是“ LINES ”或“ Planes ”。 It must have extrude and I just want continuous points keep combining with angle (angle can be any floating point value in radian)它必须有挤压,我只希望连续点与角度保持结合(角度可以是弧度中的任何浮点值)

Your solution lies in the ExtrudeGeometry documentation , where it states:您的解决方案位于ExtrudeGeometry 文档中,其中指出:

When creating a Mesh with this geometry, if you'd like to have a separate material used for its face and its extruded sides, you can use an array of materials.使用此几何体创建网格时,如果您希望将单独的材料用于其面和挤出的侧面,您可以使用一系列材料。 The first material will be applied to the face;第一种材料将应用于面部; the second material will be applied to the sides.第二种材料将应用于侧面。

So when generating the mesh, just pass 2 materials, the first one with visible: false so it doesn't get rendered.因此,在生成网格时,只需传递 2 个材质,第一个材质为visible: false因此它不会被渲染。

const geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings );

const materialFace = new THREE.MeshBasicMaterial( { visible: false } );
const materialSide = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );

const mesh = new THREE.Mesh( geometry, [materialFace, materialSide] ) ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM