几何体
大约 2 分钟
几何体
引擎内置了近二十种几何体,每个几何体外形均可通过参数配置,外形参数主要包括geometry、material,本节主要列出了几何体创建时的默认参数。
基础几何体在三维开发应用中使用的频率并不高,三维应用的场景基础物体大部分是模型对象,基础几何体常用来做一些辅助的功能。
Box 方体
new VT.Box({
name: "Box",
geometry: {
width: 1,
height: 1,
depth: 1,
widthSegments: 1,
heightSegments: 1,
depthSegments: 1,
},
});
Capsule 胶囊体
new VT.Capsule({
name: "Capsule",
geometry: {
radius: 0.5,
height: 1.0,
segments: 30,
phiStart: 0,
phiLength: Math.PI * 2,
}
});
Cone 圆锥体
new VT.Cone({
name: "Cone",
geometry: {
radius: 1,
height: 1,
radialSegments: 20,
heightSegments: 1,
openEnded: false,
thetaStart: 0,
thetaLength: 2 * Math.PI,
}
});
Cylinder 圆柱体
new VT.Cylinder({
name: "Cylinder",
geometry: {
radiusTop: 1,
radiusBottom: 1,
radialSegments: 30,
height: 1,
heightSegments: 1,
openEnded: false,
thetaStart: 0,
thetaLength: 2 * Math.PI,
}
});
Dodecahedron 十二面体
new VT.Dodecahedron({
name: "Dodecahedron",
geometry: {
radius: 0.5,
detail: 0,
}
});
Doughnut 环形
new VT.Doughnut({
name: "Doughnut",
geometry: {
radius: 1,
innerRadius: 0.5,
segments: 30,
phiStart: 0,
phiLength: Math.PI * 2,
}
})
Icosahedron 二十面体
new VT.Icosahedron({
name: "Icosahedron",
geometry: {
radius: 0.5,
detail: 0,
}
});
Lathe 车削体
new VT.Lathe({
name: "Lathe",
geometry: {
points: [
{
"x": 0,
"y": 0.5
},
{
"x": 0.5,
"y": 0
},
{
"x": 0,
"y": -0.5
}
],
segments: 12,
phiStart: 0,
phiLength: 2 * Math.PI,
},
})
Octahedron 八面体
new VT.Octahedron({
name: "Octahedron",
geometry: {
radius: 0.5,
detail: 0,
},
});
Plane 平面
new VT.Plane({
name: "Plane",
geometry: {
width: 1,
height: 1,
widthSegments: 1,
heightSegments: 1,
},
})
Circle 圆形
new VT.Circle({
name: "circle",
geometry: {
radius: 0.5,
segments: 30, // 最小值为3
thetaStart: 0,
thetaLength: 2 * Math.PI,
}
});
Sphere 球形
new VT.Sphere({
name: "Sphere",
geometry: {
radius: 0.5,
widthSegments: 30,
heightSegments: 30,
phiStart: 0,
phiLength: Math.PI * 2,
thetaStart: 0,
thetaLength: Math.PI,
},
});
Ring 环形
new VT.Ring({
name: "Ring",
geometry: {
innerRadius: 0.4,
outerRadius: 0.5,
thetaSegments: 30, // 最小为3
phiSegments: 30,
thetaStart: 0,
thetaLength: Math.PI * 2
},
});
Tetrahedron 四面体
new VT.Tetrahedron({
name: "Tetrahedron",
geometry: {
radius: 0.5,
detail: 0,
},
});
Torus 环面
new VT.Torus({
name: "Torus",
geometry: {
radius: 0.5,
tube: 0.25,
radialSegments: 16,
tubularSegments: 16,
arc: Math.PI * 2
},
});
TorusKnot 环面纽结
new VT.TorusKnot({
name: "TorusKnot",
geometry: {
radius: 0.5,
tube: 0.2,
tubularSegments: 64,
radialSegments: 8,
p: 2, // 这个值决定了几何体将绕着其旋转对称轴旋转多少次,默认值是2。
q: 3 // 这个值决定了几何体将绕着其内部圆环旋转多少次,默认值是3。
}
});
CannedLiquid 罐装体
new VT.CannedLiquid({
name: "CannedLiquid",
geometry: {
radius: 0.5,
height: 1.0,
segments: 30,
phiStart: 0,
phiLength: Math.PI * 2,
ratio: 1,
clip: true,
header: true,
body: true,
footer: true,
},
material: {
side: 2,
transparent: true,
opacity: 0.95,
color: "#29C4F5"
}
})