@webwallgl/editor 0.0.0-stage → 3.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 oneincase <462534624@qq.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.d.ts ADDED
@@ -0,0 +1,346 @@
1
+ // WebWallGL 编辑器包类型入口(随 dist 发布为 dist/lib/editor.d.ts)。
2
+ //
3
+ // 编辑器包是播放包的超集(docs/EDITOR-PLAN.md §0.5):先全量 re-export 播放包
4
+ // 公共类型,再追加编辑器专属声明。导出清单与 api/editor.ts 保持同步(verify-arch
5
+ // 机器比对);类型本体只能来自 ./types。
6
+ import type {
7
+ SceneInstance,
8
+ EditorControls,
9
+ EditorLayer,
10
+ EditorLayerKind,
11
+ EditorLayerAddSpec,
12
+ EditorHotAddCheck,
13
+ EditorOverlayMode,
14
+ EditorOverlayStats,
15
+ CameraQueueMode,
16
+ CameraPathKind,
17
+ CameraPathClipInfo,
18
+ CameraPathReport,
19
+ CameraPathPose,
20
+ CameraFovZoom,
21
+ EditorCaptureOptions,
22
+ EditorFrameOptions,
23
+ EditorHitTestOptions,
24
+ EditorLayerProps,
25
+ EditorLayerOutline,
26
+ EditorModelInfo,
27
+ EditorAttachmentPoint,
28
+ EditorBonePose,
29
+ EditorBonePoint,
30
+ MdlBoneDelta,
31
+ MdlClip,
32
+ MdlClipInit,
33
+ MdlPart,
34
+ MdlSpec,
35
+ EditorScriptIssue,
36
+ EditorUserPropertyDecl,
37
+ SceneScriptCheck,
38
+ ScenePkgFile,
39
+ ScenePkgResult,
40
+ WeCompatIssue,
41
+ WeCompatReport,
42
+ } from "./types";
43
+
44
+ export * from "webwallgl";
45
+ export type {
46
+ ScenePkgFile,
47
+ ScenePkgResult,
48
+ WeCompatIssue,
49
+ WeCompatReport,
50
+ EditorScriptIssue,
51
+ EditorUserPropertyDecl,
52
+ SceneScriptCheck,
53
+ EditorControls,
54
+ EditorLayer,
55
+ EditorLayerKind,
56
+ EditorLayerAddSpec,
57
+ EditorHotAddCheck,
58
+ EditorOverlayMode,
59
+ EditorOverlayStats,
60
+ CameraQueueMode,
61
+ CameraPathKind,
62
+ CameraPathClipInfo,
63
+ CameraPathReport,
64
+ CameraPathPose,
65
+ CameraFovZoom,
66
+ EditorCaptureOptions,
67
+ EditorFrameOptions,
68
+ EditorHitTestOptions,
69
+ EditorLayerProps,
70
+ EditorLayerOutline,
71
+ EditorModelInfo,
72
+ EditorAttachmentPoint,
73
+ EditorBonePose,
74
+ EditorBonePoint,
75
+ MdlBoneDelta,
76
+ MdlClip,
77
+ MdlClipInit,
78
+ MdlPart,
79
+ MdlSpec,
80
+ };
81
+
82
+ /**
83
+ * 取实例的编辑器控制面(时钟 / 出图 / 拾取 / 活层 / 热改)。只有场景壁纸有;
84
+ * 网页、视频壁纸,或场景尚未装配完成时返回 null。
85
+ */
86
+ export declare function editorOf(instance: SceneInstance): EditorControls | null;
87
+
88
+ /**
89
+ * SceneScript 语法预检:与引擎沙箱同一 transform、同为严格模式,只编译不执行。
90
+ * 给出出错行与可派发入口;noEntry 表示引擎会丢弃这段脚本。
91
+ */
92
+ export declare function checkSceneScript(script: string): SceneScriptCheck;
93
+
94
+ /**
95
+ * 保存清单打成 WE 原生 scene.pkg(PKGV0012)。materials 下没有同名 .tex 的
96
+ * png/jpg 原字节包成 .tex(官方 WE 只认 .tex),源图不进包;其余文件原样入包。
97
+ * project.json / 封面应留在包外,由调用方剔除。
98
+ */
99
+ export declare function buildScenePkg(files: readonly ScenePkgFile[]): ScenePkgResult;
100
+
101
+ /**
102
+ * WE 兼容性回读:用引擎自己的解析器(parsePkg / parseScene / resolveEffectChain)把导出产物
103
+ * 再读一遍,逐项检查 project.json、入口场景、各对象引用的文件、效果链与 shader 的 uniform 注释。
104
+ * files 可以是散装清单,也可以含 scene.pkg(包内条目一并可查)。
105
+ */
106
+ export declare function checkWeCompat(files: readonly ScenePkgFile[]): Promise<WeCompatReport>;
107
+
108
+ /** 从零编码 MDLV0023(W19 glTF 导入);spec 不合法时抛错(消息说明哪一项) */
109
+ export declare function encodeMdl(spec: MdlSpec): Uint8Array;
110
+
111
+ /**
112
+ * .mdl 各子网格的槽 0 材质 json 路径(非 UTF-8 的串为 null)。
113
+ * 网格表无法结构化读出(极旧 / 损坏文件)时返回 null。
114
+ */
115
+ export declare function mdlMeshMaterials(bytes: Uint8Array): Array<string | null> | null;
116
+
117
+ /**
118
+ * 把第 meshIndex 个子网格的槽 0 材质改指向 materialPath,返回新 .mdl 字节;
119
+ * 其余字节(顶点 / 索引 / 骨骼 / 动画)不变。越界或无法结构化读出时返回 null。
120
+ */
121
+ export declare function retargetMdlMaterial(bytes: Uint8Array, meshIndex: number, materialPath: string): Uint8Array | null;
122
+
123
+ /** .mdl 的动画片段表(无动画段给 []);网格表无法结构化读出时返回 null */
124
+ export declare function mdlClips(bytes: Uint8Array): MdlClip[] | null;
125
+
126
+ /**
127
+ * 关键帧影响权重(逐帧):radius < 0 整段 1;0 只有该帧;否则余弦衰减、距离 > radius 为 0。
128
+ * loop 片段按周期 frames − 1 计距离(末帧与首帧重合)
129
+ */
130
+ export declare function boneDeltaWeights(frames: number, frame: number, radius: number, loop: boolean): Float64Array;
131
+
132
+ /**
133
+ * 片段 animId 中骨 bone 的轨道在 frame 处叠局部 TRS 增量(平移 / 欧拉角相加、缩放相乘),按 radius 向两侧衰减,
134
+ * 返回新 .mdl 字节(其余轨道 / 网格逐字节不变;loop 首末帧重合关系保持)。片段 / 轨道 / 帧不存在时返回 null
135
+ */
136
+ export declare function applyBoneDelta(
137
+ bytes: Uint8Array,
138
+ animId: number,
139
+ bone: number,
140
+ frame: number,
141
+ delta: MdlBoneDelta,
142
+ radius: number,
143
+ ): Uint8Array | null;
144
+
145
+ /** 片段播放模式(W18b) */
146
+ export declare const CLIP_MODES: readonly ["loop", "mirror", "single"];
147
+
148
+ /** 轨道(每帧 9 个 f32)按归一化时间线性重采样到 m 帧,欧拉角走最短方向 */
149
+ export declare function resampleTrack(data: Float32Array, m: number): Float32Array;
150
+
151
+ /**
152
+ * 追加片段(W18b):pose = "copy" 复制参照片段 source(缺省首个)的轨道并按帧数重采样;"rest" 每帧填参照片段第 0 帧。
153
+ * 新 id = 现有最大 id + 1。没有可编辑动画段(无 MDLA 的模型不加段)/ 参照不存在 / 头不合法时 null
154
+ */
155
+ export declare function addMdlClip(
156
+ bytes: Uint8Array,
157
+ init: MdlClipInit,
158
+ pose?: "copy" | "rest",
159
+ source?: number,
160
+ ): { bytes: Uint8Array; id: number } | null;
161
+
162
+ /** 删片段;首个片段是引擎绑定参考,不许删。不存在 / 首个 / 不可编辑时 null */
163
+ export declare function removeMdlClip(bytes: Uint8Array, id: number): Uint8Array | null;
164
+
165
+ /** 清空全部片段(骨表一换,旧轨道的骨号整批失效);没有片段时 null */
166
+ export declare function clearMdlClips(bytes: Uint8Array): Uint8Array | null;
167
+
168
+ /** 改片段头;改帧数时轨道重采样、事件帧号钳进新范围,改 fps 时事件时刻重算 */
169
+ export declare function setMdlClipMeta(bytes: Uint8Array, id: number, meta: Partial<MdlClipInit>): Uint8Array | null;
170
+
171
+ /** 整表替换帧事件(按帧号排序;与原表 frame + name 相同的沿用原 JSON 串) */
172
+ export declare function setMdlClipEvents(
173
+ bytes: Uint8Array,
174
+ id: number,
175
+ events: ReadonlyArray<{ frame: number; name: string }>,
176
+ ): Uint8Array | null;
177
+
178
+ /** MDLS 段的骨数(无 MDLS 段 / 网格表不可结构化读出时 null)—— P0 */
179
+ export declare function mdlBoneCount(bytes: Uint8Array): number | null;
180
+
181
+ /**
182
+ * 第 boneIndex 根骨的记录头 `head0`(旧代码把它命名成 id)与矩阵尾的 JSON meta(骨骼约束 / 混规则
183
+ * 在 .mdl 里的疑似落点,语义未定)。越界 / 不可编辑时 null;无 meta 的骨 `meta` 为 null —— P0
184
+ */
185
+ export declare function mdlBoneMeta(
186
+ bytes: Uint8Array,
187
+ boneIndex: number,
188
+ ): { head0: number | null; parent: number; meta: string | null } | null;
189
+
190
+ /**
191
+ * 改第 boneIndex 根骨的 `head0` / `meta`(meta 必须是合法 JSON 串,`""` 表示清空),
192
+ * 返回新 .mdl 字节;同值时逐字节不变,其余字节不动。越界 / 非整数 head0 / 非法 JSON 时 null —— P0
193
+ */
194
+ export declare function setMdlBoneMeta(
195
+ bytes: Uint8Array,
196
+ boneIndex: number,
197
+ patch: { head0?: number; meta?: string },
198
+ ): Uint8Array | null;
199
+
200
+ /** 子网格数(网格表不可结构化读出时 null)—— P1 */
201
+ export declare function mdlMeshCount(bytes: Uint8Array): number | null;
202
+
203
+ /** 子网格摘要:顶点 / 索引规模、顶点字段 stride、蒙版数、部件表 —— P1 */
204
+ export declare function mdlMeshInfo(
205
+ bytes: Uint8Array,
206
+ meshIndex: number,
207
+ ): { vertexCount: number; stride: number; indexCount: number; indexWide: boolean; maskCount: number; parts: MdlPart[] | null } | null;
208
+
209
+ /** 子网格顶点位置(每顶点 xyz,模型空间);越界 / 不可编辑时 null —— P1 */
210
+ export declare function mdlMeshPositions(bytes: Uint8Array, meshIndex: number): Float32Array | null;
211
+
212
+ /** 子网格索引表(u32 展开,宽度按顶点数判定);越界 / 不可编辑时 null —— P1 */
213
+ export declare function mdlMeshIndices(bytes: Uint8Array, meshIndex: number): Uint32Array | null;
214
+
215
+ /**
216
+ * 写部件表(limb 表):区间须首尾相接铺满索引表,`null` / `[]` = 去掉部件表。
217
+ * 带蒙版的网格默认拒绝(显式 opts.allowMasked 才按原字节保留蒙版);v<21 / 越界 / 区间不合法时 null —— P1
218
+ */
219
+ export declare function setMdlParts(
220
+ bytes: Uint8Array,
221
+ meshIndex: number,
222
+ parts: MdlPart[] | null,
223
+ opts?: { allowMasked?: boolean },
224
+ ): Uint8Array | null;
225
+
226
+ /** 写顶点位置(每顶点 xyz,长度 = 顶点数 ×3);ver>=17 时同步重算 AABB —— P1 */
227
+ export declare function setMdlPositions(bytes: Uint8Array, meshIndex: number, positions: ArrayLike<number>): Uint8Array | null;
228
+
229
+ /** 只写顶点 z(透视挤出的深度),其余分量 / 索引 / 部件不动;ver>=17 时同步重算 AABB —— P1 */
230
+ export declare function setMdlVertexZ(bytes: Uint8Array, meshIndex: number, z: ArrayLike<number>): Uint8Array | null;
231
+
232
+ /**
233
+ * 写拓扑(索引表 = 三角形列表)。`parts` 缺省时老部件表能铺满新索引表就沿用,否则拒绝;
234
+ * `parts = null` 显式去掉部件表;带蒙版的网格拒绝 —— P1
235
+ */
236
+ export declare function setMdlTopology(
237
+ bytes: Uint8Array,
238
+ meshIndex: number,
239
+ indices: ArrayLike<number>,
240
+ parts?: MdlPart[] | null,
241
+ ): Uint8Array | null;
242
+
243
+ /** MDLS 一条骨记录(命名 / head0 / 父级 / 16 分量局部矩阵 / meta JSON 文本)—— P2 */
244
+ export type MdlBoneInfo = { name: string; head0: number; parent: number; matrix: Float32Array; meta: string };
245
+
246
+ /** 要写进 MDLS 的骨:matrix 省缺 = 单位矩阵 —— P2 */
247
+ export type MdlBoneSpec = {
248
+ name?: string;
249
+ parent: number;
250
+ matrix?: ArrayLike<number>;
251
+ head0?: number;
252
+ meta?: string;
253
+ };
254
+
255
+ /** 读骨骼表(顺序 = 引擎骨号);无 MDLS 或整份退成 raw 时 null —— P2 */
256
+ export declare function mdlBones(bytes: Uint8Array): MdlBoneInfo[] | null;
257
+
258
+ /** 只改骨名(数量须一致):父级 / 矩阵 / head0 / meta / 尾表原样保留 —— P2 */
259
+ export declare function setMdlBoneNames(bytes: Uint8Array, names: ReadonlyArray<string>): Uint8Array | null;
260
+
261
+ /**
262
+ * 重写整张骨骼表(骨数可变;parent 须 -1 或更靠前的骨,矩阵 16 分量且有限)。
263
+ * 尾表 = 按骨数定长的静态装配姿势:骨数不变默认原样保留,骨数变了默认丢弃(tail 可强制)—— P2
264
+ */
265
+ export declare function setMdlSkeleton(
266
+ bytes: Uint8Array,
267
+ bones: ReadonlyArray<MdlBoneSpec>,
268
+ opts?: { tail?: "auto" | "keep" | "drop" },
269
+ ): Uint8Array | null;
270
+
271
+ /** 蒙皮槽:每顶点 4 个骨号 + 4 个权重(非蒙皮 / 不可编辑时 null)—— P2 */
272
+ export declare function mdlSkin(
273
+ bytes: Uint8Array,
274
+ meshIndex: number,
275
+ ): { joints: Uint32Array; weights: Float32Array; boneCount: number | null } | null;
276
+
277
+ /** 写 4 槽权重(长度 = 顶点数 ×4,有限非负、每顶点 Σ>0);骨号不动 —— P2 */
278
+ export declare function setMdlWeights(bytes: Uint8Array, meshIndex: number, weights: ArrayLike<number>): Uint8Array | null;
279
+
280
+ /** 写 4 槽骨号(长度 = 顶点数 ×4,整数且落在 [0, 骨数) 内)—— P2 */
281
+ export declare function setMdlBoneIdx(bytes: Uint8Array, meshIndex: number, joints: ArrayLike<number>): Uint8Array | null;
282
+
283
+ /**
284
+ * WE 内置字体名(scene.json 里的 font: "systemfont_*")→ 本机 CSS font-family 栈。
285
+ * 不在表里的 font 值是工程内字体文件路径(fonts/*.ttf|otf)。
286
+ */
287
+ export declare const SYSTEM_FONT_FAMILIES: Readonly<Record<string, string>>;
288
+
289
+ /** 文字对象 pointsize → 场景像素的放大系数:em = pointsize × TEXT_EM_SCALE。 */
290
+ export declare const TEXT_EM_SCALE: number;
291
+
292
+ /**
293
+ * 相机路径(M12 / B7)—— 队列模式:只认这两个字面量,其余(含 undefined)落到默认值。
294
+ * 引擎把 `queuemode !== "random"` 一律当顺序,所以归一化不改变运行时行为。
295
+ */
296
+ export declare function normalizeQueueMode(v: unknown, dflt?: CameraQueueMode): CameraQueueMode;
297
+
298
+ /**
299
+ * 判定路径文档形态:`"object"` 对象级(`{paths:[{options, eye:{c0…}}]}`,挂相机对象的 `path`)、
300
+ * `"scene"` 场景级(`{paths:[{duration, transforms:[{eye,timestamp}]}]}`,挂 `scene.camera.paths`)。
301
+ * 空文档返回 `"unknown"`(两种格式都解释得通,不给假结论)。
302
+ */
303
+ export declare function kindOfCameraPathDoc(doc: unknown): CameraPathKind;
304
+
305
+ /**
306
+ * 逐段体检:形态 / 段数 / 总时长 / 队列模式 / 每段通道,外加 `issues`
307
+ * (空路径、零时长段、没有 eye或center、fov 与 zoom 都缺、一段都没解析出来)。
308
+ * 段解析与 tick 都转发引擎 `render/camera-path.js`,不另起一套时钟。
309
+ */
310
+ export declare function describeCameraPath(doc: unknown, queueMode?: unknown): CameraPathReport;
311
+
312
+ /**
313
+ * 顺序驱动队列(`times` 必须递增)并在这些时刻采样位姿。对象级走引擎状态机 tick、
314
+ * 场景级走纯函数 tick;没有可用段时返回空数组。
315
+ */
316
+ export declare function sampleCameraPath(
317
+ doc: unknown,
318
+ queueMode: unknown,
319
+ times: readonly number[],
320
+ basePose?: { eye?: unknown; center?: unknown; up?: unknown; fov?: unknown; zoom?: unknown },
321
+ ): CameraPathPose[];
322
+
323
+ /** 透视用 `fov`、正交用 `zoom`;缺失回落 fov 50 / zoom 1(与引擎 base 一致) */
324
+ export declare function resolveCameraFovZoom(
325
+ pose: { fov?: unknown; zoom?: unknown } | null | undefined,
326
+ perspective: boolean,
327
+ ): CameraFovZoom;
328
+
329
+ /** 读场景对象上的 `queuemode`,缺失或非法回落 `"sequential"`(= 引擎缺省) */
330
+ export declare function readQueueMode(obj: Record<string, unknown> | null | undefined): CameraQueueMode;
331
+
332
+ /**
333
+ * 写场景对象上的 `queuemode`;写回 `baseline`(缺省 `"sequential"`)时删键而不是写冗余值。
334
+ * 返回是否真的改动了文档。
335
+ */
336
+ export declare function writeQueueMode(
337
+ obj: Record<string, unknown> | null | undefined,
338
+ mode: CameraQueueMode,
339
+ baseline?: CameraQueueMode,
340
+ ): boolean;
341
+
342
+ /** 队列重排(`doc.paths` 内就地 splice);下标非法或原地不动返回 false */
343
+ export declare function moveCameraPathClip(doc: unknown, from: number, to: number): boolean;
344
+
345
+ /** 队列删段(`doc.paths` 内就地 splice);下标非法返回 false */
346
+ export declare function removeCameraPathClip(doc: unknown, index: number): boolean;
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@webwallgl/editor",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "description": "WebWallGL editor API: editable scene graph, picking, frame capture, .pkg export (superset of webwallgl)",
4
+ "version": "3.0.0",
5
+ "license": "MIT",
6
+ "author": "oneincase <462534624@qq.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/oneincase/webwallgl.git"
10
+ },
11
+ "homepage": "https://github.com/oneincase/webwallgl#readme",
12
+ "bugs": "https://github.com/oneincase/webwallgl/issues",
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "keywords": [
16
+ "wallpaper-engine",
17
+ "wallpaper",
18
+ "webgl",
19
+ "renderer",
20
+ "scene",
21
+ "browser",
22
+ "editor"
23
+ ],
24
+ "files": [
25
+ "webwallgl-editor.mjs",
26
+ "index.d.ts",
27
+ "types.d.ts"
28
+ ],
29
+ "module": "./webwallgl-editor.mjs",
30
+ "types": "./index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./index.d.ts",
34
+ "default": "./webwallgl-editor.mjs"
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
38
+ "peerDependencies": {
39
+ "webwallgl": "3.0.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ }
44
+ }