@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.
Files changed (2) hide show
  1. package/dist/index.esm.js +49 -46
  2. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -1,8 +1,9 @@
1
- const I = "/SceneMetadata.json", Y = "/db/sign", w = "/db/tree_models.json", x = "/db/topology_paths.json", j = "/db/properties.json", O = "/db/animations.json", b = "/db/model_visions.json", S = "properties";
2
- class X {
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: i } = this.ssp;
42
- return i.fetchFile(this._resolvePath(t), "json");
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(I);
49
+ return this._fetchData(w);
49
50
  }
50
51
  /**
51
52
  * 获取场景树
52
53
  * @returns
53
54
  */
54
55
  async fetchTreeData() {
55
- return this._fetchData(w);
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 i = {
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((n) => {
70
- const e = { ...i, ...n };
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(j).then((t) => A(t, "modelId"));
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(O).then((t) => A(t, "modelId"));
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(b).then((t) => new Map(Object.entries(t)));
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: i } = t, n = async (e, h) => {
105
- const { ssp: r } = this, { THREE: { Matrix4: f } } = r, { id: d, name: l, renderType: y, path: c, matrix: p } = e, D = new f().fromArray(p);
106
- let o = null;
107
- if (y === "3D")
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
- o = await r.loadModel({
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 (y === "GROUP" || y === "STUB") && (o = r.createGroup({
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 (o && (D.decompose(o.position, o.quaternion, o.scale), h && r.addObject(o, h), i && this.propertiesData)) {
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 && (o.userData[S] = s);
132
+ s && (n.userData[O] = s);
132
133
  }
133
- e.children.length > 0 && await Promise.allSettled(e.children.map((s) => n(s, o)));
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) => n(e, null)));
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, i = 0, n = {}) {
172
- const { utils: { error: e }, animation: h, THREE: r } = this.ssp, { onStart: f, onUpdate: d } = n;
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 y = this.animationsData.get(t);
180
- if (y) {
181
- const c = y[i];
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 o;
187
+ let n;
185
188
  if (c.keyframes[p - 1]) {
186
189
  const a = c.keyframes[p - 1];
187
- o = {
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), o = {
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
- o,
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
- f?.(a);
234
+ y?.(a);
232
235
  }
233
236
  );
234
237
  }
235
238
  else
236
- e(`id: ${t} 未找到索引为 ${i} 的动画`);
239
+ e(`id: ${t} 未找到索引为 ${o} 的动画`);
237
240
  } else
238
241
  e(`id: ${t} 未找到动画`);
239
242
  }
240
243
  }
241
244
  function A(_, t) {
242
- const i = /* @__PURE__ */ new Map();
243
- return _.reduce((n, e) => {
244
- const h = n.get(e[t]);
245
- return h ? h.push(e) : n.set(e[t], [e]), n;
246
- }, i), i;
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
- O as ANIMATIONS_DATA_FILE_PATH,
250
- I as META_DATA_FILE_PATH,
251
- b as MODEL_VISIONS_DATA_FILE_PATH,
252
- j as PROPERTIES_DATA_FLEE_PATH,
253
- S as PROPERTIES_KEY,
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
- w as TREE_DATA_FILE_PATH,
257
- X as default
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.15.19",
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.15.19"
18
+ "soonspacejs": "2.16.1"
19
19
  }
20
20
  }