|
@@ -75,9 +75,16 @@ export class ObjsContainer {
|
|
|
|
|
|
if (n == 1) { //单对象
|
|
|
let obj = selected[0];
|
|
|
- //构建当前对象的转换矩阵
|
|
|
- let rect = new Rectangle(0, 0, obj.width, obj.height);
|
|
|
+
|
|
|
+ const s = obj.worldTransform.getScale();
|
|
|
+ let rect = new Rectangle(0, 0, obj.width * s.x, obj.height*s.y);
|
|
|
this.rect = rect;
|
|
|
+ obj.transform.scale.x = 1;
|
|
|
+ obj.transform.scale.y = 1;
|
|
|
+ obj.width = rect.width;
|
|
|
+ obj.height = rect.height;
|
|
|
+ obj.updateTransform();
|
|
|
+
|
|
|
this.parent.transform.setFromMatrix(obj.worldTransform);
|
|
|
this.parent.updateTransform();
|
|
|
this.parent.addChildWorldNoChange(obj);
|
|
@@ -85,6 +92,7 @@ export class ObjsContainer {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
while (n--) {
|
|
|
let obj = selected[n];
|
|
|
let box = obj.calculateBounds();
|
|
@@ -98,6 +106,7 @@ export class ObjsContainer {
|
|
|
|
|
|
this.rect = rect;
|
|
|
|
|
|
+
|
|
|
//设置位置
|
|
|
let p = this.parent.position;
|
|
|
p.x = center.x;
|
|
@@ -110,6 +119,8 @@ export class ObjsContainer {
|
|
|
|
|
|
//设置旋转
|
|
|
this.parent.scale = { x: 1, y: 1 } as any;
|
|
|
+ this.parent.width = rect.width;
|
|
|
+ this.parent.height = rect.height;
|
|
|
|
|
|
//设置旋转
|
|
|
this.parent.rotation = selectedRotation;
|
|
@@ -200,18 +211,40 @@ export class ObjsContainer {
|
|
|
this.parent.scale.x = x;
|
|
|
this.parent.scale.y = y;
|
|
|
this.parent.updateTransform();
|
|
|
-
|
|
|
this.updateCompState();
|
|
|
}
|
|
|
|
|
|
scaleX(x:number) {
|
|
|
this.parent.scale.x = x;
|
|
|
+
|
|
|
this.parent.updateTransform();
|
|
|
this.updateCompState();
|
|
|
}
|
|
|
+
|
|
|
scaleY(y:number) {
|
|
|
this.parent.scale.y = y;
|
|
|
+
|
|
|
this.parent.updateTransform();
|
|
|
+
|
|
|
+
|
|
|
+ this.updateCompState();
|
|
|
+ }
|
|
|
+
|
|
|
+ //清除当前元素的缩放 改为类容的宽度
|
|
|
+ applyScaleToChildSize() {
|
|
|
+ if (this.selected.length != 1 ) return;
|
|
|
+
|
|
|
+ const w = this.width *this.parent.scale.x;
|
|
|
+ const h = this.height *this.parent.scale.y;
|
|
|
+ this.parent.scale.x = 1;
|
|
|
+ this.parent.scale.y = 1;
|
|
|
+ this.parent.updateTransform();
|
|
|
+
|
|
|
+ this.rect.width = w;
|
|
|
+ this.rect.height = h;
|
|
|
+ this.selected[0].width = w;
|
|
|
+ this.selected[0].height = h;
|
|
|
+
|
|
|
this.updateCompState();
|
|
|
}
|
|
|
|