Skip to content

Commit

Permalink
Merge pull request #825 from galacean/dev
Browse files Browse the repository at this point in the history
Merge origin/dev into origin/main
  • Loading branch information
yiiqii authored Jan 3, 2025
2 parents 54343cc + c662878 commit 950578c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions packages/effects-core/src/plugins/interact/mesh-collider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { TriangleLike } from '@galacean/effects-math/es/core/type';
import type { Geometry } from '../../render/geometry';
import type { BoundingBoxTriangle } from './click-handler';
import { HitTestType } from './click-handler';
import type { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
import { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
import { Vector3 } from '@galacean/effects-math/es/core/vector3';

/**
Expand All @@ -12,8 +12,11 @@ export class MeshCollider {
private boundingBoxData: BoundingBoxTriangle;
private geometry: Geometry;
private triangles: TriangleLike[] = [];
private worldMatrix = new Matrix4();

getBoundingBoxData (): BoundingBoxTriangle {
this.applyWorldMatrix(this.boundingBoxData.area);

return this.boundingBoxData;
}

Expand Down Expand Up @@ -41,6 +44,8 @@ export class MeshCollider {
area.push({ p0: point0, p1: point1, p2: point2 });
area.push({ p0: point0, p1: point2, p2: point3 });

this.applyWorldMatrix(area);

return {
type: HitTestType.triangle,
area,
Expand All @@ -57,13 +62,8 @@ export class MeshCollider {
for (const triangle of this.triangles) {
area.push({ p0: triangle.p0, p1: triangle.p1, p2: triangle.p2 });
}

if (worldMatrix) {
area.forEach(triangle => {
triangle.p0 = worldMatrix.transformPoint(triangle.p0 as Vector3, new Vector3());
triangle.p1 = worldMatrix.transformPoint(triangle.p1 as Vector3, new Vector3());
triangle.p2 = worldMatrix.transformPoint(triangle.p2 as Vector3, new Vector3());
});
this.worldMatrix.copyFrom(worldMatrix);
}

this.boundingBoxData = {
Expand All @@ -90,4 +90,14 @@ export class MeshCollider {

return res;
}

private applyWorldMatrix (area: TriangleLike[]) {
area.forEach(triangle => {
triangle.p0 = this.worldMatrix.transformPoint(triangle.p0 as Vector3, new Vector3());
triangle.p1 = this.worldMatrix.transformPoint(triangle.p1 as Vector3, new Vector3());
triangle.p2 = this.worldMatrix.transformPoint(triangle.p2 as Vector3, new Vector3());
});

return area;
}
}
2 changes: 1 addition & 1 deletion plugin-packages/rich-text/src/rich-text-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class RichTextComponent extends TextComponent {
height += charInfo.lineHeight;
}
//恢复默认设置
context.font = `10px ${options.fontFamily || textStyle.fontFamily}`;
context.font = `${options.fontWeight || textStyle.textWeight} 10px ${options.fontFamily || textStyle.fontFamily}`;
const textWidth = context.measureText(text).width;
const textHeight = fontSize * this.singleLineHeight * this.textStyle.fontScale;

Expand Down

0 comments on commit 950578c

Please sign in to comment.