three.js - 使用 PlaneGeometry - Three.js 创建具有弯曲边缘的平面
问题描述
我正在尝试创建一个带有弯曲/圆形边缘的 2D 正方形。据我了解,使用飞机是要走的路。我正在努力弄清楚如何做到这一点。看起来应该很简单。似乎也无法在网上找到任何直截了当的答案,所以我非常感谢您的帮助。
// Create plane
let geometry = new THREE.PlaneGeometry(1, 1)
// Round the edges somehow?
this.mesh = new THREE.Mesh(geometry, material)
this.mesh.rotation.x = -Math.PI / 2
this.container.add(this.mesh)
解决方案
根据@prisoner849 使用 THREE.Shape() 和 THREE.ShapeBufferGeometry() 的建议,设法让它工作。发布我的答案,但与此处的答案基本相同
let x = 1; let y = 1; let width = 50; let height = 50; let radius = 20
let shape = new THREE.Shape();
shape.moveTo( x, y + radius );
shape.lineTo( x, y + height - radius );
shape.quadraticCurveTo( x, y + height, x + radius, y + height );
shape.lineTo( x + width - radius, y + height );
shape.quadraticCurveTo( x + width, y + height, x + width, y + height - radius );
shape.lineTo( x + width, y + radius );
shape.quadraticCurveTo( x + width, y, x + width - radius, y );
shape.lineTo( x + radius, y );
shape.quadraticCurveTo( x, y, x, y + radius );
let geometry = new THREE.ShapeBufferGeometry( shape );
this.mesh = new THREE.Mesh(geometry, material)
this.mesh.rotation.x = -Math.PI / 2
this.container.add(this.mesh)
推荐阅读
- nunit - 如何解决 teamcity (Nunit) 中的错误?
- azure - 如何在 azure api 管理网关中更新共享订阅密钥?
- makefile - 生成文件变量的生成文件通配符,用于定义通用规则
- xamarin - 无法安装包“System.Xml.XmlDocument 4.3.0”,有人知道解决方案吗?
- java - 如何在 Java 中实现 Function1(它的 compose 和 andThen 方法)?
- asp.net - Crystal Report 查看器不显示嵌入的图像
- python - 简单的 RNN 拟合维度
- c# - 使用分析器运行时应用程序变得更快
- azure-active-directory - 如何在 Microsoft Graph 中发布 Oauth2PermissionGrants?
- excel - 使用 VBA 复制模块后的 MacOS Excel 内部错误