在threejs中以顶部为参考在一个方向上缩放几何图形 [英] Scaling a geometry in one direction with top as reference in threejs

查看:51
本文介绍了在threejs中以顶部为参考在一个方向上缩放几何图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用滑块事件缩放 THREE.PlaneGeometry.实际上,我正在尝试实施百叶窗.当我尝试相对于处理程序更改几何体的比例时,盲板在两侧均匀地缩放.它应该固定在顶部并在一个方向上缩放.我尝试更改网格原点的坐标并通过差异平移网格.但它不起作用.缩放始终从原点开始,平面几何在两侧增长.

I am trying to scale a THREE.PlaneGeometry with slider events. In effect I am trying to implement a window blind. When I try to change the scale of the geometry with respect to handler, the blind scales uniformly on both sides. It should be fixed at the top and scale in one direction. I tried changing the coordinates of the origin of the Mesh and translating the Mesh by the difference. But it doesn't work. The scaling happens from the origin all the time and the Plane Geometry grows on either side.

知道如何让它仅在一侧扩展吗?

Any idea of how I can make it scale on only one side?

推荐答案

您需要平移几何图形,使顶边穿过原点.

You need to translate your geometry so the top edge passes through the origin.

var geometry = new THREE.PlaneGeometry( 10, 10 );
geometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, - 10 / 2, 0 ) );

现在,当您缩放网格时,顶部将保持固定.

Now, when you scale your mesh, the top will remain fixed.

现在有一个你可以使用的内置方法:

There is now a built-in method you can use:

geometry.translate( 0, - 10 / 2, 0 );

three.js r.85

three.js r.85

这篇关于在threejs中以顶部为参考在一个方向上缩放几何图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆