Gbiner_local / 贝塞尔曲线插值函数
0 вподобань
0 форк(-ів)
1 файл(-ів)
Остання активність 2 years ago
贝塞尔插值函数应用
| 1 | export class BezierTool{ |
| 2 | // 多维二次贝塞尔曲线插值函数 |
| 3 | public static Bezier2D(t: number, start:Vector2, end:Vector2 ,control:Vector2): Vector2 { |
| 4 | let x = (1 - t) * (1 - t) * start.x + 2 * t * (1 - t) * control.x + t * t * end.x; |
| 5 | let y = (1 - t) * (1 - t) * start.y + 2 * t * (1 - t) * control.y + t * t * end.y; |
| 6 | return new Vector2(x, y); |
| 7 | } |
| 8 | |
| 9 | // 多维三次贝塞尔曲线插值函数 |
| 10 | public static Bezier3D(t: number, start:Vector2, end:Vector2 ,control1:Vector2,control2:Vector2): Vector2 { |
Gbiner_local / EventBus
0 вподобань
0 форк(-ів)
1 файл(-ів)
Остання активність 2 years ago
Base on Typescript的EventBus
| 1 | type Callback = (...args: any[]) => void | Promise<void>; |
| 2 | |
| 3 | export class EventBus { |
| 4 | private static listeners = new Map<string, Callback[]>(); |
| 5 | private static onceListeners = new Map<string, Callback[]>(); |
| 6 | |
| 7 | /** |
| 8 | * 为指定事件注册一个回调,该回调将在每次触发时调用 |
| 9 | * @param event |
| 10 | * @param callback |
Gbiner_local / 地面四叉树
0 вподобань
0 форк(-ів)
1 файл(-ів)
Остання активність 2 years ago
Typescript实现得地面四叉树
| 1 | const CELLSIZE = 50; |
| 2 | |
| 3 | // 四叉树 |
| 4 | export class QuadTreeNode<T> { |
| 5 | private _x: number; |
| 6 | private _y: number; |
| 7 | private _width: number; |
| 8 | private _height: number; |
| 9 | private _children: QuadTreeNode<T>[] | null; |
| 10 | private _value: T | null; |
Новіше
Пізніше