Skip to content

Commit

Permalink
Fix rect scale bug (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
cptbtptpbcptdtptp authored Jan 21, 2025
1 parent 20a0d77 commit fea3a18
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/gizmo/src/Rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,19 @@ export class RectControl extends GizmoComponent {
}

this._middleEntity.transform.worldMatrix = groupWorldMatrix;
const cameraPosition = this._camera.entity.transform.worldPosition;
const vec3 = RectControl._vec30.set(ele[12], ele[13], ele[14]);
const scale = Vector3.distance(cameraPosition, vec3) * Utils.rectFactor;
let scale: number;
if (this._camera.isOrthographic) {
scale = isModified
? this._camera.orthographicSize * Utils.rectFactor * 3 * 0.8
: this._camera.orthographicSize * Utils.rectFactor * 3;
} else {
const cameraPosition = this._camera.entity.transform.worldPosition;
const vec3 = RectControl._vec30.set(ele[12], ele[13], ele[14]);
scale = isModified
? Vector3.distance(cameraPosition, vec3) * Utils.rectFactor * 0.8
: Vector3.distance(cameraPosition, vec3) * Utils.rectFactor;
}

const anchorType = group.anchorType;
switch (mostSuitablePlane) {
case CoordinatePlane.XoY:
Expand Down Expand Up @@ -916,7 +926,7 @@ export class RectControl extends GizmoComponent {
// Invisible Renderer (for pick)
const pickRenderer = entity.addComponent(MeshRenderer);
pickRenderer.priority = 3;
const pickMesh = PrimitiveMesh.createCylinder(engine, 0.15, 0.15, 1);
const pickMesh = PrimitiveMesh.createCylinder(engine, 0.2, 0.2, 1);
pickRenderer.mesh = pickMesh;
pickRenderer.setMaterial(Utils.invisibleMaterialRect);
return entity;
Expand Down

0 comments on commit fea3a18

Please sign in to comment.