javascript - 创建自定义多面体几何的问题
问题描述
确实进行了调整DodecahedronGeometry
以使其成为菱形十二面体,当我尝试将其加载到其中时,所有与法线相连的新顶点和面都向外指向three.js
它不起作用。
有关如何将新形状添加到three.js
库中的任何提示或技巧。
/**
* @author Abe Pazos / https://hamoid.com
* @author Mugen87 / https://github.com/Mugen87
*/
import { Geometry } from '../core/Geometry.js';
import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
// RhombicDodecahedronGeometry
function RhombicDodecahedronGeometry( radius, detail ) {
Geometry.call( this );
this.type = 'RhombicDodecahedronGeometry';
this.parameters = {
radius: radius,
detail: detail
};
this.fromBufferGeometry( new RhombicDodecahedronBufferGeometry( radius, detail ) );
this.mergeVertices();
}
RhombicDodecahedronGeometry.prototype = Object.create( Geometry.prototype );
RhombicDodecahedronGeometry.prototype.constructor = RhombicDodecahedronGeometry;
// DodecahedronBufferGeometry
function RhombicDodecahedronBufferGeometry( radius, detail ) {
var vertices = [
// (±1, ±1, ±1)
- 1, - 1, - 1, 1, - 1, - 1,
1, - 1, 1, - 1, - 1, 1,
- 1, 1, 1, - 1, 1, 1,
1, 1, 1, 1, 1, - 1,
0, 2, 0, 0, - 2, 0,
0, 0, - 2, 0, 0, 2,
2, 0, 0, - 2, 0, 0
];
var indices = [
0, 3, 13, 9, 3, 0,
0, 13, 4, 10, 0, 4,
9, 0, 1, 1, 0, 10,
7, 10, 4, 4, 8, 7,
4, 13, 5, 8, 4, 5,
5, 13, 3, 5, 3, 11,
3, 2, 11, 3, 9, 2,
5, 11, 6, 8, 5, 6,
6, 11, 2, 6, 2, 12,
12, 7, 6, 7, 8, 6,
12, 1, 7, 7, 1, 10,
1, 12, 2, 2, 9, 1
];
PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
this.type = 'RhombicDodecahedronBufferGeometry';
this.parameters = {
radius: radius,
detail: detail
};
}
RhombicDodecahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
RhombicDodecahedronBufferGeometry.prototype.constructor = RhombicDodecahedronBufferGeometry;
export { RhombicDodecahedronGeometry, RhombicDodecahedronBufferGeometry };
解决方案
推荐阅读
- microsoft-graph-api - 在 Microsoft Graph API 中哪里可以找到“发送为”和“代表发送”邮件设置?
- reactjs - 如何从 Semantic UI React 进行响应式输入?
- wordpress - 如何监控 wordpress 插件使用统计?
- android - 无法从 START_ARRAY 令牌中反序列化 java.lang.Boolean 的实例
- javascript - 使用反应钩子的动态表单字段
- python - 如何对单个包使用 python 日志记录
- python - 使用“while”指示总和的代码错误
- r - dplyr 管道数据 - `.` 和 `.x` 之间的区别
- css - Normalize.css 未完全添加重置以响应应用程序
- c++ - C++:只有 .h 文件,而不是 .cpp 文件,需要包含在 #include 指令中,但为什么/如何?.h 文件总是只有声明吗?