To determine the outcome, it depends on the type of geometry that is utilized. To illustrate, here is a demonstration using a traditional geometry (THREE.CylinderGeometry()
):
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.set(0, 2, 10);
var renderer = new THREE.WebGLRenderer({
antialias: true
});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var controls = new THREE.OrbitControls(camera, renderer.domElement);
scene.add(new THREE.GridHelper(10, 10));
var prismGeom = new THREE.CylinderGeometry(1, 1, 4, 8, 1);
for(let i=0; i< 8;i++){// upper base
prismGeom.vertices[i].y = 1 + THREE.Math.randFloat(-1, 1);
}
prismGeom.vertices[prismGeom.vertices.length - 2].y = 1 + THREE.Math.randFloat(-1, 1);// center of the upper base
prismGeom.translate(0, 2, 0);
var prism = new THREE.Mesh(prismGeom, new THREE.MeshBasicMaterial({color: "yellow", wireframe: true}));
scene.add(prism);
render();
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
}
body {
overflow: hidden;
margin: 0;
}
<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
If utilizing a buffer geometry is your preference, then access the vertex coordinates through methods in THREE.BufferAttibute()
, such as .setX
, .setY
, .setZ
, and more.