mirror of
https://github.com/Doodle3D/Doodle3D-Core.git
synced 2024-12-22 11:03:48 +01:00
increase hit area of text shapes
Hit area of text shapes is now the boundingbox
This commit is contained in:
parent
1464a4b74f
commit
2b5d240487
@ -8,7 +8,7 @@ import { shapeToPoints } from '../../shape/shapeToPoints';
|
||||
import { LINE_COLLISION_MARGIN } from '../../constants/d2Constants';
|
||||
import { LINE_WIDTH } from '../../constants/d2Constants';
|
||||
import { PIXEL_RATIO } from '../../constants/general';
|
||||
import { Matrix } from 'cal';
|
||||
import { Matrix, Vector } from 'cal';
|
||||
|
||||
const HIT_ORDER = {
|
||||
RECT: 0,
|
||||
@ -132,8 +132,20 @@ export default class BaseTool extends EventGroup {
|
||||
const objects = shapeDatas
|
||||
.filter(shapeData => {
|
||||
const shapeMatrix = shapeData.transform.multiplyMatrix(matrix);
|
||||
let shapePoints = shapeToPoints(shapeData);
|
||||
|
||||
const isHit = shapeToPoints(shapeData)
|
||||
if (shapeData.type === 'TEXT') {
|
||||
if (shapeData.text.text === '') return false;
|
||||
const { min, max } = getPointsBounds(shapePoints);
|
||||
shapePoints = [{ points: [
|
||||
new Vector(min.x, min.y),
|
||||
new Vector(min.x, max.y),
|
||||
new Vector(max.x, max.y),
|
||||
new Vector(max.x, min.y)
|
||||
], holes: [] }];
|
||||
}
|
||||
|
||||
const isHit = shapePoints
|
||||
.some(({ points, holes }) => {
|
||||
const shape = applyMatrixOnShape([points, ...holes], shapeMatrix);
|
||||
const clipperShape = new ClipperShape(shape, shapeData.fill, true, true);
|
||||
|
Loading…
Reference in New Issue
Block a user