|
|
@@ -10,7 +10,6 @@ import { getMouseColors } from "@/utils/colors.ts";
|
|
|
import { shallowReactive } from "vue";
|
|
|
import { InteractiveFix, InteractiveTo, MatResponseProps } from "../index.ts";
|
|
|
import { zeroEq } from "@/utils/math.ts";
|
|
|
-import { MathUtils } from "three";
|
|
|
import { getSupportedFont } from "@/utils/shared.ts";
|
|
|
import { ui18n } from "@/lang/index.ts";
|
|
|
import { installGlobalStyle } from "@/core/hook/use-global-style.ts";
|
|
|
@@ -117,16 +116,25 @@ export const getWidth = (data: TextData, scaleX: number) => {
|
|
|
export const matResponse = ({ data, mat, increment }: MatResponseProps<"text">) => {
|
|
|
if (increment) {
|
|
|
mat = mat.copy().multiply(new Transform(data.mat))
|
|
|
- }
|
|
|
- const { scaleX, x, y, rotation } = mat.decompose();
|
|
|
- if (!zeroEq(scaleX - 1)) {
|
|
|
- data.width = getWidth(data, scaleX)
|
|
|
+ }
|
|
|
+
|
|
|
+ const [a, b, c, d, x, y] = mat.m;
|
|
|
+ const localScaleX = Math.hypot(a, b);
|
|
|
+ const localScaleY = Math.hypot(c, d);
|
|
|
+ const rotation = Math.atan2(b, a);
|
|
|
+
|
|
|
+ if (!zeroEq(localScaleX - 1)) {
|
|
|
+ if (increment) return;
|
|
|
+ data.width = getWidth(data, localScaleX)
|
|
|
data.mat = new Transform()
|
|
|
.translate(x, y)
|
|
|
- .rotate(MathUtils.degToRad(rotation))
|
|
|
- .scale(1, 1).m
|
|
|
- } else {
|
|
|
+ .rotate(rotation).m
|
|
|
+ } else if (zeroEq(localScaleY - 1)) {
|
|
|
data.mat = mat.m
|
|
|
+ } else {
|
|
|
+ data.mat = new Transform()
|
|
|
+ .translate(x, y)
|
|
|
+ .rotate(rotation).m
|
|
|
}
|
|
|
return data
|
|
|
};
|
|
|
@@ -135,4 +143,4 @@ export const getPredefine = (key: keyof TextData) => {
|
|
|
if (key === 'stroke') {
|
|
|
return { canun: true }
|
|
|
}
|
|
|
-}
|
|
|
+}
|