@combos-fun/plugin-renderer-3d-event 0.1.15 → 0.1.16
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/agent-skill.md +15 -66
- package/package.json +3 -3
package/agent-skill.md
CHANGED
|
@@ -1,80 +1,29 @@
|
|
|
1
1
|
# `@combos-fun/plugin-renderer-3d-event` — Agent notes
|
|
2
2
|
|
|
3
|
-
Pointer
|
|
4
|
-
|
|
5
|
-
Prerequisite: follow the parent `@combos-fun/plugin-renderer-3d` skill for system order, hierarchy, and object tagging. Use `Event3D`, not the 2D `Event`.
|
|
6
|
-
|
|
7
|
-
## Public API
|
|
3
|
+
Pointer raycast. No keyboard. Parent: `plugin-renderer-3d`. Use `Event3D`, not 2D `Event`.
|
|
8
4
|
|
|
9
5
|
```ts
|
|
10
|
-
import {
|
|
11
|
-
Event3D,
|
|
12
|
-
Event3DSystem,
|
|
13
|
-
type Event3DParams,
|
|
14
|
-
type Event3DParam,
|
|
15
|
-
type Event3DHitArea,
|
|
16
|
-
type Event3DHitAreaType,
|
|
17
|
-
type Event3DSystemParams,
|
|
18
|
-
} from '@combos-fun/plugin-renderer-3d-event';
|
|
6
|
+
import { Event3D, Event3DSystem } from '@combos-fun/plugin-renderer-3d-event';
|
|
19
7
|
```
|
|
20
8
|
|
|
21
|
-
`componentName = 'Event3D'
|
|
22
|
-
|
|
23
|
-
## Hit area
|
|
24
|
-
|
|
25
|
-
`Event3DParams` contains optional `hitArea`. Without one, officially tagged visual meshes are pickable. An invisible hit area also makes an empty GameObject pickable:
|
|
9
|
+
`componentName = 'Event3D'`. `systemName = 'Event3DSystem'`.
|
|
26
10
|
|
|
27
|
-
|
|
28
|
-
|------|---------------------|
|
|
29
|
-
| `box` | `width: 1`, `height: 1`, `depth: 1` |
|
|
30
|
-
| `sphere` | `radius: 0.5` |
|
|
31
|
-
| `plane` | `width: 1`, `height: 1` |
|
|
11
|
+
`hitArea` is optional. Without it, tagged visual meshes are pickable. An invisible hit area makes an empty GameObject pickable.
|
|
32
12
|
|
|
33
|
-
|
|
13
|
+
| Type | Defaults |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `box` | `width` / `height` / `depth` = `1` |
|
|
16
|
+
| `sphere` | `radius` = `0.5` |
|
|
17
|
+
| `plane` | `width` / `height` = `1` |
|
|
34
18
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Emitted names: `touchstart`, `touchmove`, `touchend`, `tap`, `touchendoutside`, `touchcancel`.
|
|
19
|
+
Events: `touchstart`, `touchmove`, `touchend`, `tap`, `touchendoutside`, `touchcancel`.
|
|
38
20
|
|
|
39
21
|
```ts
|
|
40
|
-
event3D.on('tap', (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
payload.data.localPosition; // { x, y, z }, intersected object's local space
|
|
45
|
-
payload.gameObject; // resolved tagged GameObject
|
|
22
|
+
event3D.on('tap', ({ stopPropagation, data, gameObject }) => {
|
|
23
|
+
data.pointerId;
|
|
24
|
+
data.position; // { x, y } canvas CSS pixels
|
|
25
|
+
data.localPosition; // { x, y, z }
|
|
46
26
|
});
|
|
47
27
|
```
|
|
48
28
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- The nearest ray intersection that resolves to a GameObject with `Event3D` wins; intersections without `Event3D` are skipped.
|
|
52
|
-
- `touchstart` records the pressed target. `touchmove` emits only on the object currently under the pointer.
|
|
53
|
-
- Releasing on the original target emits `touchend` then `tap`.
|
|
54
|
-
- Releasing elsewhere emits `touchendoutside` on the pressed target; if another target is under the pointer, it also receives `touchend`.
|
|
55
|
-
- Pointer cancel/leave emits `touchcancel` on the pressed target.
|
|
56
|
-
- `stopPropagation()` forwards to the underlying browser event's `stopPropagation`.
|
|
57
|
-
- Removing `Event3D` removes its hit area, listeners, and pending pointer records. System destruction removes canvas listeners and all hit areas.
|
|
58
|
-
|
|
59
|
-
## Package-specific pitfalls
|
|
60
|
-
|
|
61
|
-
- Custom Three objects must be tagged through `attachVisual` or `tagObject3D`.
|
|
62
|
-
- A transparent hit area remains raycastable and can be the nearest hit.
|
|
63
|
-
- Pixi hit areas and 2D `EventSystem` do not participate in this raycast.
|
|
64
|
-
|
|
65
|
-
## Minimal example
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
const box = new GameObject('box');
|
|
69
|
-
box.addComponent(new Graphics3D({ shape: 'box', color: 0xffaa00 }));
|
|
70
|
-
box.addComponent(new Event3D({
|
|
71
|
-
hitArea: { type: 'box', width: 1, height: 1, depth: 1 },
|
|
72
|
-
}));
|
|
73
|
-
box.getComponent(Event3D)!.on('tap', ({ gameObject }) => {
|
|
74
|
-
// handle gameObject
|
|
75
|
-
});
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Verification
|
|
79
|
-
|
|
80
|
-
`pnpm --filter @combos-fun/plugin-renderer-3d-event run build`
|
|
29
|
+
Nearest hit that has `Event3D` wins. `touchmove` emits only while the pointer is over an `Event3D`. Release on the pressed target emits `touchend` then `tap`. Release elsewhere emits `touchendoutside` on the pressed target, and `touchend` on a different target under the pointer. Cancel or leave emits `touchcancel`. Unknown hit-area types create no mesh. `stopPropagation()` forwards to the browser event. Custom meshes must be tagged with `attachVisual` or `tagObject3D`. A transparent hit area still wins the raycast. 2D `Event` does not participate.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/plugin-renderer-3d-event",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Pointer / touch event input via Three.js raycasting",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-3d-event.esm.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"three": "^0.172.0",
|
|
30
|
-
"@combos-fun/
|
|
31
|
-
"@combos-fun/
|
|
30
|
+
"@combos-fun/engine": "0.1.16",
|
|
31
|
+
"@combos-fun/plugin-renderer-3d": "0.1.16"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"combos-fun",
|