@flighthq/interaction 0.3.0-next.1566.dcdf1d3 → 0.3.0-next.1584.a68fe91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/registerDefaultHitTests.d.ts.map +1 -1
- package/dist/registerDefaultHitTests.js +2 -1
- package/dist/registerDefaultHitTests.js.map +1 -1
- package/dist/registerShapeHitTest.d.ts +3 -3
- package/dist/registerShapeHitTest.d.ts.map +1 -1
- package/dist/registerShapeHitTest.js +5 -4
- package/dist/registerShapeHitTest.js.map +1 -1
- package/package.json +13 -13
- package/src/registerDefaultHitTests.test.ts +6 -1
- package/src/registerShapeHitTest.test.ts +30 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerDefaultHitTests.d.ts","sourceRoot":"","sources":["../src/registerDefaultHitTests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerDefaultHitTests.d.ts","sourceRoot":"","sources":["../src/registerDefaultHitTests.ts"],"names":[],"mappings":"AA6BA,wBAAgB,uBAAuB,IAAI,IAAI,CAY9C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisplayObjectKind, HtmlViewKind, MovieClipKind, QuadBatchKind, RichTextKind, Scale9ShapeKind, ShapeKind, SpriteKind, TextLabelKind, TilemapKind, } from '@flighthq/types/contract';
|
|
1
|
+
import { DisplayObjectKind, HtmlViewKind, MorphShapeKind, MovieClipKind, QuadBatchKind, RichTextKind, Scale9ShapeKind, ShapeKind, SpriteKind, TextLabelKind, TilemapKind, } from '@flighthq/types/contract';
|
|
2
2
|
import { defaultNode2DHitTestHandler, defaultHtmlViewHitTestHandler, defaultMovieClipHitTestHandler, defaultRichTextHitTestHandler, defaultShapeHitTestHandler, defaultTextHitTestHandler, } from './displayHitTests';
|
|
3
3
|
import { registerHitTest } from './hitTests';
|
|
4
4
|
import { defaultQuadBatchHitTestHandler, defaultSpriteHitTestHandler, defaultTilemapHitTestHandler, } from './spriteHitTests';
|
|
@@ -6,6 +6,7 @@ export function registerDefaultHitTests() {
|
|
|
6
6
|
registerHitTest(DisplayObjectKind, defaultNode2DHitTestHandler);
|
|
7
7
|
registerHitTest(HtmlViewKind, defaultHtmlViewHitTestHandler);
|
|
8
8
|
registerHitTest(MovieClipKind, defaultMovieClipHitTestHandler);
|
|
9
|
+
registerHitTest(MorphShapeKind, defaultShapeHitTestHandler);
|
|
9
10
|
registerHitTest(QuadBatchKind, defaultQuadBatchHitTestHandler);
|
|
10
11
|
registerHitTest(RichTextKind, defaultRichTextHitTestHandler);
|
|
11
12
|
registerHitTest(Scale9ShapeKind, defaultShapeHitTestHandler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerDefaultHitTests.js","sourceRoot":"","sources":["../src/registerDefaultHitTests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,uBAAuB;IACrC,eAAe,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC;IAChE,eAAe,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;IAC7D,eAAe,CAAC,aAAa,EAAE,8BAA8B,CAAC,CAAC;IAC/D,eAAe,CAAC,aAAa,EAAE,8BAA8B,CAAC,CAAC;IAC/D,eAAe,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;I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IACvD,eAAe,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;IACzD,eAAe,CAAC,aAAa,EAAE,yBAAyB,CAAC,CAAC;IAC1D,eAAe,CAAC,WAAW,EAAE,4BAA4B,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Opt-in exact hit provider for shapes: the `*Precise` queries then hit a Shape/Scale9Shape
|
|
3
|
-
* the point falls inside actual filled geometry (winding), not the bounding box. The coarse
|
|
4
|
-
* `registerDefaultHitTests` are unaffected.
|
|
2
|
+
* Opt-in exact hit provider for shapes: the `*Precise` queries then hit a Shape/MorphShape/Scale9Shape
|
|
3
|
+
* only where the point falls inside actual filled geometry (winding), not the bounding box. The coarse
|
|
4
|
+
* queries and `registerDefaultHitTests` are unaffected.
|
|
5
5
|
*
|
|
6
6
|
* Importing this module is the opt-in — it pulls `@flighthq/shape` + `@flighthq/path`, so the base
|
|
7
7
|
* interaction bundle stays free of them (tree-shaken unless referenced).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerShapeHitTest.d.ts","sourceRoot":"","sources":["../src/registerShapeHitTest.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"registerShapeHitTest.d.ts","sourceRoot":"","sources":["../src/registerShapeHitTest.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C"}
|
|
@@ -2,17 +2,18 @@ import { inverseMatrixTransformPointXY } from '@flighthq/geometry/contract';
|
|
|
2
2
|
import { getNodeWorldMatrix } from '@flighthq/node/contract';
|
|
3
3
|
import { containsPathPoint } from '@flighthq/path/contract';
|
|
4
4
|
import { getShapeFillRegions } from '@flighthq/shape/contract';
|
|
5
|
-
import { Scale9ShapeKind, ShapeKind } from '@flighthq/types/contract';
|
|
5
|
+
import { MorphShapeKind, Scale9ShapeKind, ShapeKind } from '@flighthq/types/contract';
|
|
6
6
|
import { registerHitTestPrecise } from './hitTests';
|
|
7
7
|
/**
|
|
8
|
-
* Opt-in exact hit provider for shapes: the `*Precise` queries then hit a Shape/Scale9Shape
|
|
9
|
-
* the point falls inside actual filled geometry (winding), not the bounding box. The coarse
|
|
10
|
-
* `registerDefaultHitTests` are unaffected.
|
|
8
|
+
* Opt-in exact hit provider for shapes: the `*Precise` queries then hit a Shape/MorphShape/Scale9Shape
|
|
9
|
+
* only where the point falls inside actual filled geometry (winding), not the bounding box. The coarse
|
|
10
|
+
* queries and `registerDefaultHitTests` are unaffected.
|
|
11
11
|
*
|
|
12
12
|
* Importing this module is the opt-in — it pulls `@flighthq/shape` + `@flighthq/path`, so the base
|
|
13
13
|
* interaction bundle stays free of them (tree-shaken unless referenced).
|
|
14
14
|
*/
|
|
15
15
|
export function registerShapeHitTest() {
|
|
16
|
+
registerHitTestPrecise(MorphShapeKind, hitTestShapeFill);
|
|
16
17
|
registerHitTestPrecise(ShapeKind, hitTestShapeFill);
|
|
17
18
|
registerHitTestPrecise(Scale9ShapeKind, hitTestShapeFill);
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerShapeHitTest.js","sourceRoot":"","sources":["../src/registerShapeHitTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"registerShapeHitTest.js","sourceRoot":"","sources":["../src/registerShapeHitTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EA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name": "@flighthq/interaction",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.1584.a68fe91",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flighthq/geometry": "0.3.0-next.
|
|
40
|
-
"@flighthq/node": "0.3.0-next.
|
|
41
|
-
"@flighthq/scene2d": "0.3.0-next.
|
|
42
|
-
"@flighthq/log": "0.3.0-next.
|
|
43
|
-
"@flighthq/path": "0.3.0-next.
|
|
44
|
-
"@flighthq/shape": "0.3.0-next.
|
|
45
|
-
"@flighthq/spatial": "0.3.0-next.
|
|
46
|
-
"@flighthq/signals": "0.3.0-next.
|
|
47
|
-
"@flighthq/bitmap": "0.3.0-next.
|
|
48
|
-
"@flighthq/text": "0.3.0-next.
|
|
49
|
-
"@flighthq/textlayout": "0.3.0-next.
|
|
50
|
-
"@flighthq/types": "0.3.0-next.
|
|
39
|
+
"@flighthq/geometry": "0.3.0-next.1584.a68fe91",
|
|
40
|
+
"@flighthq/node": "0.3.0-next.1584.a68fe91",
|
|
41
|
+
"@flighthq/scene2d": "0.3.0-next.1584.a68fe91",
|
|
42
|
+
"@flighthq/log": "0.3.0-next.1584.a68fe91",
|
|
43
|
+
"@flighthq/path": "0.3.0-next.1584.a68fe91",
|
|
44
|
+
"@flighthq/shape": "0.3.0-next.1584.a68fe91",
|
|
45
|
+
"@flighthq/spatial": "0.3.0-next.1584.a68fe91",
|
|
46
|
+
"@flighthq/signals": "0.3.0-next.1584.a68fe91",
|
|
47
|
+
"@flighthq/bitmap": "0.3.0-next.1584.a68fe91",
|
|
48
|
+
"@flighthq/text": "0.3.0-next.1584.a68fe91",
|
|
49
|
+
"@flighthq/textlayout": "0.3.0-next.1584.a68fe91",
|
|
50
|
+
"@flighthq/types": "0.3.0-next.1584.a68fe91"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@flighthq/quadbatch": "*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setRectangle } from '@flighthq/geometry/contract';
|
|
2
2
|
import { getNodeLocalBoundsRectangle } from '@flighthq/node/contract';
|
|
3
3
|
import { createSprite, createScene2D } from '@flighthq/scene2d/contract';
|
|
4
|
-
import { createShape } from '@flighthq/shape/contract';
|
|
4
|
+
import { createMorphShape, createShape } from '@flighthq/shape/contract';
|
|
5
5
|
|
|
6
6
|
import { findGraphHitTarget } from './hitTests';
|
|
7
7
|
import { setNodeHitTestEnabled } from './nodeInteractionState';
|
|
@@ -20,6 +20,11 @@ describe('registerDefaultHitTests', () => {
|
|
|
20
20
|
setRectangle(getNodeLocalBoundsRectangle(shape), 0, 0, 100, 100);
|
|
21
21
|
setNodeHitTestEnabled(shape, true);
|
|
22
22
|
expect(findGraphHitTarget(shape, 50, 50)).toBe(shape);
|
|
23
|
+
|
|
24
|
+
const morphShape = createMorphShape({ commands: [], endData: [], startData: [], winding: 'nonZero' });
|
|
25
|
+
setRectangle(getNodeLocalBoundsRectangle(morphShape), 0, 0, 100, 100);
|
|
26
|
+
setNodeHitTestEnabled(morphShape, true);
|
|
27
|
+
expect(findGraphHitTarget(morphShape, 50, 50)).toBe(morphShape);
|
|
23
28
|
});
|
|
24
29
|
|
|
25
30
|
it('containers return null for self hit', () => {
|
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
import { setRectangle } from '@flighthq/geometry/contract';
|
|
2
2
|
import { getNodeLocalBoundsRectangle } from '@flighthq/node/contract';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { appendPathCircle, appendPathRectangle, createPath, createPathMorph } from '@flighthq/path/contract';
|
|
4
|
+
import {
|
|
5
|
+
appendMorphShapePath,
|
|
6
|
+
appendShapeBeginFill,
|
|
7
|
+
appendShapeCircle,
|
|
8
|
+
appendShapeEndFill,
|
|
9
|
+
createMorphShape,
|
|
10
|
+
createShape,
|
|
11
|
+
setMorphShapeProgress,
|
|
12
|
+
} from '@flighthq/shape/contract';
|
|
13
|
+
import { MorphShapeKind, ShapeKind } from '@flighthq/types/contract';
|
|
5
14
|
|
|
6
15
|
import { findGraphHitTargetPrecise, hitTestGraphLocalBounds, hitTestGraphPoint, registerHitTest } from './hitTests';
|
|
7
16
|
import { setNodeHitTestEnabled } from './nodeInteractionState';
|
|
8
17
|
import { registerShapeHitTest } from './registerShapeHitTest';
|
|
9
18
|
|
|
10
19
|
describe('registerShapeHitTest', () => {
|
|
20
|
+
it('winding-tests the MorphShape live sample for precise queries', () => {
|
|
21
|
+
registerHitTest(MorphShapeKind, hitTestGraphLocalBounds);
|
|
22
|
+
registerShapeHitTest();
|
|
23
|
+
const start = createPath();
|
|
24
|
+
appendPathCircle(start, 50, 50, 40);
|
|
25
|
+
const end = createPath();
|
|
26
|
+
appendPathRectangle(end, 10, 10, 80, 80);
|
|
27
|
+
const shape = createMorphShape(createPathMorph(start, end)!);
|
|
28
|
+
appendShapeBeginFill(shape, 0xff0000ff, 1);
|
|
29
|
+
appendMorphShapePath(shape);
|
|
30
|
+
appendShapeEndFill(shape);
|
|
31
|
+
setRectangle(getNodeLocalBoundsRectangle(shape), 10, 10, 80, 80);
|
|
32
|
+
setNodeHitTestEnabled(shape, true);
|
|
33
|
+
|
|
34
|
+
expect(findGraphHitTargetPrecise(shape, 85, 85)).toBeNull();
|
|
35
|
+
setMorphShapeProgress(shape, 1);
|
|
36
|
+
expect(findGraphHitTargetPrecise(shape, 85, 85)).toBe(shape);
|
|
37
|
+
});
|
|
38
|
+
|
|
11
39
|
it('winding-tests the actual fill for precise queries, so a bbox corner outside the circle misses', () => {
|
|
12
40
|
registerHitTest(ShapeKind, hitTestGraphLocalBounds);
|
|
13
41
|
registerShapeHitTest();
|