@soonspacejs/plugin-soonmanager2-sync 2.16.0 → 2.16.1
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/dist/index.esm.js +48 -46
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const w = "/SceneMetadata.json", Y = "/db/sign", I = "/db/tree_models.json", x = "/db/topology_paths.json", S = "/db/properties.json", b = "/db/animations.json", j = "/db/model_visions.json", O = "properties";
|
|
2
|
+
class V {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.ssp = t;
|
|
5
5
|
}
|
|
@@ -39,21 +39,21 @@ class X {
|
|
|
39
39
|
return `${this._path}${t}`;
|
|
40
40
|
}
|
|
41
41
|
async _fetchData(t) {
|
|
42
|
-
const { utils:
|
|
43
|
-
return
|
|
42
|
+
const { utils: o } = this.ssp;
|
|
43
|
+
return o.fetchFile(this._resolvePath(t), "json");
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* 获取场景元数据
|
|
47
47
|
*/
|
|
48
48
|
async fetchMetaData() {
|
|
49
|
-
return this._fetchData(
|
|
49
|
+
return this._fetchData(w);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* 获取场景树
|
|
53
53
|
* @returns
|
|
54
54
|
*/
|
|
55
55
|
async fetchTreeData() {
|
|
56
|
-
return this._fetchData(
|
|
56
|
+
return this._fetchData(I);
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 获取拓扑路径
|
|
@@ -61,14 +61,14 @@ class X {
|
|
|
61
61
|
*/
|
|
62
62
|
async fetchTopologyData() {
|
|
63
63
|
return this._fetchData(x).then((t) => {
|
|
64
|
-
const
|
|
64
|
+
const o = {
|
|
65
65
|
linkWidth: 0.1,
|
|
66
66
|
linkColor: ["#00ff00"],
|
|
67
67
|
nodeRadius: 0.05,
|
|
68
68
|
nodeColor: "#0000ff"
|
|
69
69
|
};
|
|
70
|
-
return t.map((
|
|
71
|
-
const e = { ...
|
|
70
|
+
return t.map((i) => {
|
|
71
|
+
const e = { ...o, ...i };
|
|
72
72
|
return e.imgUrl && (e.imgUrl = `${this.path}${e.imgUrl}`), e;
|
|
73
73
|
});
|
|
74
74
|
});
|
|
@@ -78,21 +78,21 @@ class X {
|
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
80
|
async fetchPropertiesData() {
|
|
81
|
-
return this._fetchData(
|
|
81
|
+
return this._fetchData(S).then((t) => A(t, "modelId"));
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* 获取动画
|
|
85
85
|
* @returns
|
|
86
86
|
*/
|
|
87
87
|
async fetchAnimationsData() {
|
|
88
|
-
return this._fetchData(
|
|
88
|
+
return this._fetchData(b).then((t) => A(t, "modelId"));
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* 获取模型视角
|
|
92
92
|
* @returns
|
|
93
93
|
*/
|
|
94
94
|
async fetchModelVisionsData() {
|
|
95
|
-
return this._fetchData(
|
|
95
|
+
return this._fetchData(j).then((t) => new Map(Object.entries(t)));
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* 加载场景树中的对象
|
|
@@ -102,16 +102,16 @@ class X {
|
|
|
102
102
|
console.error("treeData is null");
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
const { syncProperties:
|
|
106
|
-
const { ssp: r } = this, { THREE: { Matrix4:
|
|
107
|
-
let
|
|
108
|
-
if (
|
|
105
|
+
const { syncProperties: o } = t, i = async (e, h) => {
|
|
106
|
+
const { ssp: r } = this, { THREE: { Matrix4: y } } = r, { id: d, name: l, renderType: f, path: c, matrix: p } = e, D = new y().fromArray(p);
|
|
107
|
+
let n = null;
|
|
108
|
+
if (f === "3D")
|
|
109
109
|
if (c)
|
|
110
110
|
try {
|
|
111
111
|
const s = { ...e };
|
|
112
112
|
Reflect.deleteProperty(s, "children");
|
|
113
113
|
const m = c.replaceAll(/#/g, "%23");
|
|
114
|
-
|
|
114
|
+
n = await r.loadModel({
|
|
115
115
|
id: d,
|
|
116
116
|
name: l,
|
|
117
117
|
url: this._resolvePath(m),
|
|
@@ -122,18 +122,18 @@ class X {
|
|
|
122
122
|
}
|
|
123
123
|
else
|
|
124
124
|
r.utils.warn(`id: ${d} path 为空`);
|
|
125
|
-
else (
|
|
125
|
+
else (f === "GROUP" || f === "STUB") && (n = r.createGroup({
|
|
126
126
|
id: d,
|
|
127
127
|
name: l,
|
|
128
128
|
userData: { ...e }
|
|
129
129
|
}));
|
|
130
|
-
if (
|
|
130
|
+
if (n && (D.decompose(n.position, n.quaternion, n.scale), h && r.addObject(n, h), o && this.propertiesData)) {
|
|
131
131
|
const s = this.propertiesData.get(d);
|
|
132
|
-
s && (
|
|
132
|
+
s && (n.userData[O] = s);
|
|
133
133
|
}
|
|
134
|
-
e.children.length > 0 && await Promise.allSettled(e.children.map((s) =>
|
|
134
|
+
e.children.length > 0 && await Promise.allSettled(e.children.map((s) => i(s, n)));
|
|
135
135
|
};
|
|
136
|
-
await Promise.allSettled(this.treeData.map((e) =>
|
|
136
|
+
await Promise.allSettled(this.treeData.map((e) => i(e, null)));
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* 设置 path
|
|
@@ -158,7 +158,9 @@ class X {
|
|
|
158
158
|
(async () => {
|
|
159
159
|
t.syncModelVisions && (this.modelVisionsData = await this.fetchModelVisionsData());
|
|
160
160
|
})()
|
|
161
|
-
]), this.treeData = await this.fetchTreeData(), await this.loadObjects(t), t.needsModelsBoundsTree && this.ssp.computeModelsBoundsTree()
|
|
161
|
+
]), this.treeData = await this.fetchTreeData(), await this.loadObjects(t), t.needsModelsBoundsTree && this.ssp.computeModelsBoundsTree().catch((o) => {
|
|
162
|
+
o?.name !== "AbortError" && console.warn("[SoonSpace] BVH generation failed.", o);
|
|
163
|
+
});
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
164
166
|
* 获取拓扑路径列表
|
|
@@ -169,23 +171,23 @@ class X {
|
|
|
169
171
|
/**
|
|
170
172
|
* 播放动画
|
|
171
173
|
*/
|
|
172
|
-
async playAnimationById(t,
|
|
173
|
-
const { utils: { error: e }, animation: h, THREE: r } = this.ssp, { onStart:
|
|
174
|
+
async playAnimationById(t, o = 0, i = {}) {
|
|
175
|
+
const { utils: { error: e }, animation: h, THREE: r } = this.ssp, { onStart: y, onUpdate: d } = i;
|
|
174
176
|
this.animationsData || (this.animationsData = await this.fetchAnimationsData());
|
|
175
177
|
const l = this.ssp.getObjectById(t);
|
|
176
178
|
if (!l) {
|
|
177
179
|
e(`playAnimationById: id 为 ${t} 场景对象未找到`);
|
|
178
180
|
return;
|
|
179
181
|
}
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
182
|
-
const c =
|
|
182
|
+
const f = this.animationsData.get(t);
|
|
183
|
+
if (f) {
|
|
184
|
+
const c = f[o];
|
|
183
185
|
if (c)
|
|
184
186
|
for (let p = 0, D = c.keyframes.length; p < D; p++) {
|
|
185
|
-
let
|
|
187
|
+
let n;
|
|
186
188
|
if (c.keyframes[p - 1]) {
|
|
187
189
|
const a = c.keyframes[p - 1];
|
|
188
|
-
|
|
190
|
+
n = {
|
|
189
191
|
x: a.x,
|
|
190
192
|
y: a.y,
|
|
191
193
|
z: a.z,
|
|
@@ -198,7 +200,7 @@ class X {
|
|
|
198
200
|
};
|
|
199
201
|
} else {
|
|
200
202
|
const a = new r.Object3D(), u = new r.Matrix4().fromArray(l.userData.matrix);
|
|
201
|
-
a.applyMatrix4(u),
|
|
203
|
+
a.applyMatrix4(u), n = {
|
|
202
204
|
x: a.position.x,
|
|
203
205
|
y: a.position.y,
|
|
204
206
|
z: a.position.z,
|
|
@@ -222,38 +224,38 @@ class X {
|
|
|
222
224
|
scaleZ: s.scaleZ
|
|
223
225
|
};
|
|
224
226
|
await h(
|
|
225
|
-
|
|
227
|
+
n,
|
|
226
228
|
M,
|
|
227
229
|
{ delay: m, duration: P, mode: g, repeat: T === -1 ? 1 / 0 : T, yoyo: E },
|
|
228
230
|
(a, u) => {
|
|
229
231
|
l.position.set(a.x, a.y, a.z), l.rotation.set(a.rotationX, a.rotationY, a.rotationZ), l.scale.set(a.scaleX, a.scaleY, a.scaleZ), d?.(a, u);
|
|
230
232
|
},
|
|
231
233
|
(a) => {
|
|
232
|
-
|
|
234
|
+
y?.(a);
|
|
233
235
|
}
|
|
234
236
|
);
|
|
235
237
|
}
|
|
236
238
|
else
|
|
237
|
-
e(`id: ${t} 未找到索引为 ${
|
|
239
|
+
e(`id: ${t} 未找到索引为 ${o} 的动画`);
|
|
238
240
|
} else
|
|
239
241
|
e(`id: ${t} 未找到动画`);
|
|
240
242
|
}
|
|
241
243
|
}
|
|
242
244
|
function A(_, t) {
|
|
243
|
-
const
|
|
244
|
-
return _.reduce((
|
|
245
|
-
const h =
|
|
246
|
-
return h ? h.push(e) :
|
|
247
|
-
},
|
|
245
|
+
const o = /* @__PURE__ */ new Map();
|
|
246
|
+
return _.reduce((i, e) => {
|
|
247
|
+
const h = i.get(e[t]);
|
|
248
|
+
return h ? h.push(e) : i.set(e[t], [e]), i;
|
|
249
|
+
}, o), o;
|
|
248
250
|
}
|
|
249
251
|
export {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
b as ANIMATIONS_DATA_FILE_PATH,
|
|
253
|
+
w as META_DATA_FILE_PATH,
|
|
254
|
+
j as MODEL_VISIONS_DATA_FILE_PATH,
|
|
255
|
+
S as PROPERTIES_DATA_FLEE_PATH,
|
|
256
|
+
O as PROPERTIES_KEY,
|
|
255
257
|
Y as SIGN_PATH,
|
|
256
258
|
x as TOPOLOGY_DATA_FILE_PATH,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
+
I as TREE_DATA_FILE_PATH,
|
|
260
|
+
V as default
|
|
259
261
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-soonmanager2-sync",
|
|
3
3
|
"pluginName": "Soonmanager2SyncPlugin",
|
|
4
|
-
"version": "2.16.
|
|
4
|
+
"version": "2.16.1",
|
|
5
5
|
"description": "Sync soonmanager 2.x data plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
16
|
"gitHead": "4a87dd85050651088e11c3da777c49fab3db7e5d",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.16.
|
|
18
|
+
"soonspacejs": "2.16.1"
|
|
19
19
|
}
|
|
20
20
|
}
|