如何限制THREE.TransformControls只有正比例值

时间:2017-06-23 12:31:30

标签: three.js

缩放Gizmo(THREE.TransformControls)是否可以只有正值? 负值会导致模型由内向外翻转。

1 个答案:

答案 0 :(得分:0)

我找到了:转到TransformControls.js和

替换

var newScaleX = oldScale.x * ( 1 + point.x / oldScale.x );
var newScaleY = oldScale.y * ( 1 + point.y / oldScale.y );
var newScaleZ = oldScale.z * ( 1 + point.z / oldScale.z );

point.applyMatrix4( tempMatrix.getInverse( worldRotationMatrix ) );

if ( scope.axis === "X" ) scope.object.scale.x = newScaleX;
if ( scope.axis === "Y" ) scope.object.scale.y = newScaleY;
if ( scope.axis === "Z" ) scope.object.scale.z = newScaleZ;

var newScaleX = oldScale.x * ( 1 + point.x / oldScale.x );
var newScaleY = oldScale.y * ( 1 + point.y / oldScale.y );
var newScaleZ = oldScale.z * ( 1 + point.z / oldScale.z );

point.applyMatrix4( tempMatrix.getInverse( worldRotationMatrix ) );

if (newScaleX>0)
    if ( scope.axis === "X" ) scope.object.scale.x = newScaleX;
if (newScaleY>0)
    if ( scope.axis === "Y" ) scope.object.scale.y = newScaleY;
if (newScaleZ>0)
    if ( scope.axis === "Z" ) scope.object.scale.z = newScaleZ;