Skip to content

Commit 33e336a

Browse files
devphilip21Philip Kim (Jaewon Kim)
authored andcommitted
feat(core): remove momentum operator
1 parent 06d1909 commit 33e336a

8 files changed

Lines changed: 0 additions & 406 deletions

File tree

docs/public/llms-full.txt

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -575,37 +575,6 @@ pan(element)
575575
});
576576
```
577577

578-
### momentum
579-
580-
Add physics-based inertia after gesture ends. Generates synthetic signals with decelerating velocity.
581-
582-
```typescript
583-
function momentum<T extends SignalWith<{ velocity: Vector; phase?: string }>>(options?: {
584-
friction?: number; // default 0.95, velocity retention per frame
585-
minVelocity?: number; // default 0.1
586-
maxDuration?: number; // default 2000ms
587-
}): Operator<T, T & { momentumDelta: Vector; isMomentum: boolean }>
588-
```
589-
590-
**Output:**
591-
- `momentumDelta`: Synthetic delta from momentum physics
592-
- `isMomentum`: `true` for synthetic momentum signals, `false` for direct input
593-
594-
```typescript
595-
pan(element)
596-
.pipe(
597-
rotate3d({ sensitivityX: 0.5 }),
598-
momentum({ friction: 0.95 })
599-
)
600-
.on((s) => {
601-
if (s.value.isMomentum) {
602-
rotationManager.addDelta(...s.value.momentumDelta);
603-
} else {
604-
rotationManager.addDelta(...s.value.rotation);
605-
}
606-
});
607-
```
608-
609578
### when
610579

611580
Gate signals based on another stream's state.
@@ -775,27 +744,6 @@ keydown(window, { code: ["Equal", "Minus"] })
775744
});
776745
```
777746

778-
### 3D Rotation with Momentum
779-
780-
```typescript
781-
import { pan } from "cereb";
782-
import { rotate3d, momentum } from "cereb/operators";
783-
784-
let rotation = [0, 0, 0];
785-
786-
pan(element)
787-
.pipe(
788-
rotate3d({ sensitivityX: 0.5, sensitivityY: 0.5 }),
789-
momentum({ friction: 0.95, minVelocity: 0.01 })
790-
)
791-
.on((s) => {
792-
const delta = s.value.isMomentum ? s.value.momentumDelta : s.value.rotation;
793-
rotation[0] += delta[0];
794-
rotation[1] += delta[1];
795-
element.style.transform = `rotateX(${rotation[0]}rad) rotateY(${rotation[1]}rad)`;
796-
});
797-
```
798-
799747
### Drawing Application
800748

801749
```typescript

docs/public/llms.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
- [zoom](https://cereb.dev/operator-api/zoom): Convert ratio to scale delta
4141
- [rotate3d](https://cereb.dev/operator-api/rotate3d): Convert pan to 3D rotation delta
4242
- [translate](https://cereb.dev/operator-api/translate): Convert pan to 2D translation
43-
- [momentum](https://cereb.dev/operator-api/momentum): Add physics-based inertia after gesture
4443
- [when](https://cereb.dev/operator-api/when): Gate by another stream's state
4544
- [throttle](https://cereb.dev/operator-api/throttle): Rate limiting
4645
- [debounce](https://cereb.dev/operator-api/debounce): Wait for silence

docs/src/config/sidebar.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@
135135
"label": "merge",
136136
"slug": "operator-api/merge"
137137
},
138-
{
139-
"label": "momentum",
140-
"slug": "operator-api/momentum"
141-
},
142138
{
143139
"label": "offset",
144140
"slug": "operator-api/offset"

docs/src/content/operator-api/momentum.mdx

Lines changed: 0 additions & 109 deletions
This file was deleted.

docs/src/content/operator-api/rotate3d.mdx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,6 @@ pan(canvas)
6868
});
6969
```
7070

71-
### With Momentum
72-
73-
Combine with `momentum` for inertial rotation after gesture ends:
74-
75-
```typescript
76-
import { pan } from "cereb";
77-
import { rotate3d, momentum } from "cereb/operators";
78-
79-
pan(element)
80-
.pipe(
81-
rotate3d({ sensitivityX: 0.5, sensitivityY: 0.5 }),
82-
momentum({ friction: 0.95, minVelocity: 0.01 })
83-
)
84-
.on((signal) => {
85-
if (signal.value.isMomentum) {
86-
rotationManager.addDelta(...signal.value.momentumDelta);
87-
} else {
88-
rotationManager.addDelta(...signal.value.rotation);
89-
}
90-
});
91-
```
92-
9371
## Session Handling
9472

9573
The operator resets its internal state when `phase` is `"end"` or `"cancel"`, making it ready for the next gesture session.

docs/src/pages/operator-api/momentum.astro

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/cereb/src/operators/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export { filter } from "./filter.js";
88
export { flatMap, mergeMap } from "./flat-map.js";
99
export { map } from "./map.js";
1010
export { merge, mergeWith } from "./merge.js";
11-
export type { MomentumInput, MomentumOptions, MomentumValue } from "./momentum.js";
12-
export { momentum } from "./momentum.js";
1311
export type { OffsetOptions, OffsetValue, PointerValue } from "./offset.js";
1412
export { offset } from "./offset.js";
1513
export { reduce } from "./reduce.js";

0 commit comments

Comments
 (0)