本文整理汇总了TypeScript中THREE.SphereGeometry.translate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SphereGeometry.translate方法的具体用法?TypeScript SphereGeometry.translate怎么用?TypeScript SphereGeometry.translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.SphereGeometry
的用法示例。
在下文中一共展示了SphereGeometry.translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildPommel
/**
* Creates a spherical pommel and merges it with the swords geometry.
* Given: the geometry of the sword, and some parameters about
* the geometry of the sword
* Returns: The Sword
*/
buildPommel(template : SwordTemplate, genParams : GenerationParameters, sword: Sword, numHands: number = 1, pommelBladeWidthRatio = 0.50) : Sword {
var pommelRadius = genParams.bladeThickness;
var pommelGeometry = new THREE.SphereGeometry(pommelRadius, 5, 5);
var handleLength = 0.4 * numHands;
// Translates the pommel to fall below the handle
pommelGeometry.translate(0,-handleLength,0);
// Convert the box to a buffer geometry
var pommelBufferGeometry = new THREE.BufferGeometry().fromGeometry(pommelGeometry);
// Number of vertices in the model prior to appending this geometry
var priorNumVertices = sword.geometryData.vertices.length / 3;
// Append the vertices to the swords vertex array and add their indices to the vertex indices array
var vertices = pommelBufferGeometry.getAttribute("position");
// Loop through all of the position attributes and add the XYZ values to the swords geometry
for (var i = 0; i < vertices.count; i++) {
sword.geometryData.addVertex(vertices.getX(i), vertices.getY(i), vertices.getZ(i));
}
// Append the vertices to the swords vertex array and add their indices to the vertex indices array
var normals = pommelBufferGeometry.getAttribute("normal");
// Loop through all of the position attributes and add the XYZ values to the swords geometry
for (var i = 0; i < vertices.count; i++) {
sword.geometryData.addNormal(normals.getX(i), normals.getY(i), normals.getZ(i));
}
// Add a color for each vertex (Gold)
for (var i = 0; i < vertices.count; i++) {
sword.geometryData.addColor(0.9, 0.8, 0.35);
}
var triangles = pommelBufferGeometry.getIndex();
if (triangles != undefined) {
// Loop through all of the triangles and add the values to the swords geometry
for (var i = 0; i < triangles.count; i++) {
sword.geometryData.addTriangle(triangles.getX(i), triangles.getY(i), triangles.getZ(i));
}
} else {
// We need to add index values based on the vertices being added
Assert.equal(vertices.count % 3, 0, "ERROR:: Verices are not organized into triangles");
for (var i = 0; i < vertices.count;) {
sword.geometryData.addTriangle(priorNumVertices + i, priorNumVertices + i + 1, priorNumVertices + i + 2);
i += 3;
}
}
return sword;
}