@icjhd/cj-decimal-rvo
v2.1.14
Published
RVO2 动态避障(定点 Decimal / ORCA)
Readme
@icjhd/cj-decimal-rvo(定点 RVO2 / ORCA)
状态:已实现(源码可用)。 正式 npm release 仍走 vault/
pkg:add-local;本地压测可用cj-pkg/scripts/sync-decimal-rvo-local.mjssync 到 GameClient。
定位
| 包 | 数值 | 场景 |
|----|------|------|
| @icjhd/cj-rvo | 浮点 number | 单机表现、编辑器调试 |
| @icjhd/cj-decimal-rvo | 定点 Decimal 向量 + number 配置标量 | 帧同步 / 锁步权威避障 |
依赖
@icjhd/cj-decimal
源码
| 文件 | 说明 |
|------|------|
| assets/Common.ts | 定点 Vector2 / RVOMath |
| assets/Agent.ts | ORCA + LP1/2/3 |
| assets/KdTree.ts | Agent/Obstacle 树 |
| assets/Simulator.ts | 与 cj-rvo 同 API |
用法
import { Simulator, type IAgent } from 'db://assets/pkg-export/@icjhd/cj-decimal-rvo';
const sim = Simulator.inst;
const id = sim.addAgent({ x: 0, y: 0 }, { radius: 36, maxSpeed: 200 });
sim.setAgentPrefVelocity(id, vx, vy);
sim.step(1 / 20);
const v = sim.getAgentVelocity(id); // Vector2,分量是 Decimal本地 sync
cd E:\three-kingdom-3.8.8\cj-pkg
node scripts/sync-decimal-rvo-local.mjs
node scripts/smoke-decimal-rvo.mjsGameClient
见 ability-editor-dev-v2/doc/runtime-defect-plan-b/experiments/enemy-rvo-avoidance-20260919.md。
