@Override public void onUpdated(Node node, FrameTime frameTime) { if (isTransforming()) { return; } float t = MathHelper.clamp(frameTime.getDeltaSeconds() * LERP_SPEED, 0, 1); currentScaleRatio = MathHelper.lerp(currentScaleRatio, getClampedScaleRatio(), t); float finalScaleValue = getFinalScale(); Vector3 finalScale = new Vector3(finalScaleValue, finalScaleValue, finalScaleValue); getTransformableNode().setLocalScale(finalScale); }
private void updateRotation(FrameTime frameTime) { // Store in local variable for nullness static analysis. Quaternion desiredLocalRotation = this.desiredLocalRotation; if (desiredLocalRotation == null) { return; } Quaternion localRotation = getTransformableNode().getLocalRotation(); float lerpFactor = MathHelper.clamp(frameTime.getDeltaSeconds() * LERP_SPEED, 0, 1); localRotation = Quaternion.slerp(localRotation, desiredLocalRotation, lerpFactor); float dot = Math.abs(dotQuaternion(localRotation, desiredLocalRotation)); if (dot >= ROTATION_DOT_THRESHOLD) { localRotation = desiredLocalRotation; this.desiredLocalRotation = null; } getTransformableNode().setLocalRotation(localRotation); }
private void updatePosition(FrameTime frameTime) { // Store in local variable for nullness static analysis. Vector3 desiredLocalPosition = this.desiredLocalPosition; if (desiredLocalPosition == null) { return; } Vector3 localPosition = getTransformableNode().getLocalPosition(); float lerpFactor = MathHelper.clamp(frameTime.getDeltaSeconds() * LERP_SPEED, 0, 1); localPosition = Vector3.lerp(localPosition, desiredLocalPosition, lerpFactor); float lengthDiff = Math.abs(Vector3.subtract(desiredLocalPosition, localPosition).length()); if (lengthDiff <= POSITION_LENGTH_THRESHOLD) { localPosition = desiredLocalPosition; this.desiredLocalPosition = null; } getTransformableNode().setLocalPosition(localPosition); }