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