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