Three.js - scale cylinder from point

落花浮王杯 提交于 2019-12-14 02:44:01

问题


Is it possible to increase the scale of a cylinder on the Y-axis from a specific point.

As instead of the cylinder growing from its origin up and down to the new scale, growing from the top upwards/downwards only like a bar chart.

Current code :

function animate() {
    render();
    cylinder.scale.y += 0.1;
    requestAnimationFrame(animate);
}

回答1:


You can create a intermediary Object3D to achieve this:

var cylinder = new THREE.Object3D();
scene.add( cylinder );

var cylinderMesh = new THREE.Mesh(geometry.material);
cylinder.add(cylinderMesh);

cylinderMesh.position.y = 2; // move pivot up
cylinder.scale.y += 0.1;


来源:https://stackoverflow.com/questions/26463244/three-js-scale-cylinder-from-point

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!