[MD]
# DebugShape LSE Export
将 DebugShape 插件的调试形状功能导出给 LSE (Legacy Script Engine) 脚本插件使用。
## 依赖
- LeviLamina
- DebugShape
- LegacyRemoteCall
## LSE 调用方法
### 导入函数
```javascript
// 创建形状
const createText = ll.import("DebugShape", "createText");
const createLine = ll.import("DebugShape", "createLine");
const createBox = ll.import("DebugShape", "createBox");
const createCircle = ll.import("DebugShape", "createCircle");
const createSphere = ll.import("DebugShape", "createSphere");
const createArrow = ll.import("DebugShape", "createArrow");
// 属性设置
const setText = ll.import("DebugShape", "setText");
const setLocation = ll.import("DebugShape", "setLocation");
const setColor = ll.import("DebugShape", "setColor");
const setScale = ll.import("DebugShape", "setScale");
const setDuration = ll.import("DebugShape", "setDuration");
const setRotation = ll.import("DebugShape", "setRotation");
const clearRotation = ll.import("DebugShape", "clearRotation");
// 属性获取
const getText = ll.import("DebugShape", "getText");
const getLocation = ll.import("DebugShape", "getLocation");
const getColor = ll.import("DebugShape", "getColor");
const getRotation = ll.import("DebugShape", "getRotation");
const getShapeType = ll.import("DebugShape", "getShapeType");
// 显示控制 - 渲染
const draw = ll.import("DebugShape", "draw");
const drawToPlayer = ll.import("DebugShape", "drawToPlayer");
const drawToDimension = ll.import("DebugShape", "drawToDimension");
// 显示控制 - 移除
const remove = ll.import("DebugShape", "remove");
const removeToPlayer = ll.import("DebugShape", "removeToPlayer");
const removeToDimension = ll.import("DebugShape", "removeToDimension");
// 显示控制 - 更新
const update = ll.import("DebugShape", "update");
const updateToPlayer = ll.import("DebugShape", "updateToPlayer");
const updateToDimension = ll.import("DebugShape", "updateToDimension");
// 批量操作
const drawBatch = ll.import("DebugShape", "drawBatch");
const destroyBatch = ll.import("DebugShape", "destroyBatch");
// 生命周期
const destroy = ll.import("DebugShape", "destroy");
const destroyAll = ll.import("DebugShape", "destroyAll");
```
## API 参考
### 创建形状
| 函数 | 参数 | 返回值 | 说明 |
|------|------|--------|------|
| `createText(x, y, z, text)` | x, y, z: float, text: string | int64 (ShapeID) | 创建悬浮字 |
| `createLine(x1, y1, z1, x2, y2, z2)` | 起点和终点坐标 | int64 (ShapeID) | 创建线段 |
| `createBox(x1, y1, z1, x2, y2, z2)` | 两个角点坐标 | int64 (ShapeID) | 创建方框 |
| `createCircle(x, y, z, scale)` | 中心坐标和缩放 | int64 (ShapeID) | 创建圆形 |
| `createSphere(x, y, z, scale)` | 中心坐标和缩放 | int64 (ShapeID) | 创建球体 |
| `createArrow(x1, y1, z1, x2, y2, z2)` | 起点和终点坐标 | int64 (ShapeID) | 创建箭头 |
### 属性操作
| 函数 | 参数 | 返回值 | 说明 |
|------|------|--------|------|
| `setText(id, text)` | id: int64, text: string | bool | 设置文本内容(仅Text类型) |
| `getText(id)` | id: int64 | string | 获取文本内容 |
| `setLocation(id, x, y, z)` | id: int64, x, y, z: float | bool | 设置位置 |
| `getLocation(id)` | id: int64 | [x, y, z] | 获取位置数组 |
| `setColor(id, r, g, b, a)` | id: int64, RGBA: float (0.0-1.0) | bool | 设置颜色 |
| `getColor(id)` | id: int64 | [r, g, b, a] | 获取颜色数组 |
| `setScale(id, scale)` | id: int64, scale: float | bool | 设置缩放 |
| `setDuration(id, seconds)` | id: int64, seconds: float | bool | 设置持续时间(秒) |
| `setRotation(id, pitch, yaw, roll)` | id: int64, 角度: float (弧度) | bool | 设置旋转角度,固定朝向 |
| `clearRotation(id)` | id: int64 | bool | 清除旋转,恢复 billboard 模式 |
| `getRotation(id)` | id: int64 | [pitch, yaw, roll] 或 [] | 获取旋转角度,billboard 模式返回空数组 |
| `getShapeType(id)` | id: int64 | int | 获取形状类型 |
### 旋转说明
默认情况下,文本形状使用 **billboard 模式**,即始终面向玩家。
使用 `setRotation()` 可以设置固定朝向,形状将不再跟随玩家视角旋转:
- `pitch` - 俯仰角(弧度),正值向下看,负值向上看
- `yaw` - 偏航角(弧度),0 为南,π/2 为西,π 为北,-π/2 为东
- `roll` - 翻滚角(弧度),通常为 0
使用 `clearRotation()` 可以恢复 billboard 模式。
### 形状类型枚举
| 类型 | 值 |
|------|-----|
| Line | 0 |
| Box | 1 |
| Sphere | 2 |
| Circle | 3 |
| Text | 4 |
| Arrow | 5 |
[/MD]