@soonspacejs/plugin-model-blast 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 +32 -31
  2. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -3,72 +3,73 @@ class P {
3
3
  constructor(t) {
4
4
  this.ssp = t;
5
5
  }
6
+ ssp;
6
7
  prevObjects = /* @__PURE__ */ new Set();
7
8
  childDirs = /* @__PURE__ */ new Map();
8
9
  childPositions = /* @__PURE__ */ new Map();
9
- start(t, n) {
10
+ start(t, e) {
10
11
  this.prevObjects.add(t);
11
- const { ssp: o } = this, s = o.utils.getBoundingBox(t), c = s.getSize(new r()), h = s.getCenter(new r()), b = n ?? Math.max(c.x, c.y, c.z);
12
- t.traverse((e) => {
13
- if (e.type === "Mesh") {
14
- if (!this.childDirs.has(e.uuid) || !this.childPositions.has(e.uuid)) {
15
- const g = o.utils.getBoundingBox(e).getCenter(new r()), f = new r().subVectors(g, h).normalize();
16
- if (e.parent) {
17
- const x = e.parent.getWorldQuaternion(new B());
12
+ const { ssp: o } = this, n = o.utils.getBoundingBox(t), c = n.getSize(new r()), h = n.getCenter(new r()), b = e ?? Math.max(c.x, c.y, c.z);
13
+ t.traverse((s) => {
14
+ if (s.type === "Mesh") {
15
+ if (!this.childDirs.has(s.uuid) || !this.childPositions.has(s.uuid)) {
16
+ const g = o.utils.getBoundingBox(s).getCenter(new r()), f = new r().subVectors(g, h).normalize();
17
+ if (s.parent) {
18
+ const x = s.parent.getWorldQuaternion(new B());
18
19
  x.invert(), f.applyQuaternion(x);
19
20
  }
20
21
  this.childDirs.set(
21
- e.uuid,
22
+ s.uuid,
22
23
  f
23
24
  ), this.childPositions.set(
24
- e.uuid,
25
- e.position.clone()
25
+ s.uuid,
26
+ s.position.clone()
26
27
  );
27
28
  }
28
- e.position.copy(
29
- new r().copy(this.childPositions.get(e.uuid)).add(
30
- new r().copy(this.childDirs.get(e.uuid)).multiplyScalar(b)
29
+ s.position.copy(
30
+ new r().copy(this.childPositions.get(s.uuid)).add(
31
+ new r().copy(this.childDirs.get(s.uuid)).multiplyScalar(b)
31
32
  )
32
33
  ), this.ssp.render();
33
34
  }
34
35
  });
35
36
  }
36
37
  stop(t) {
37
- let n = t;
38
- if (!n) {
38
+ let e = t;
39
+ if (!e) {
39
40
  const o = [...this.prevObjects].at(-1);
40
- o && (this.prevObjects.delete(o), n = o);
41
+ o && (this.prevObjects.delete(o), e = o);
41
42
  }
42
- n?.traverse((o) => {
43
+ e?.traverse((o) => {
43
44
  o.type === "Mesh" && this.childDirs.has(o.uuid) && this.childPositions.has(o.uuid) && (o.position.copy(this.childPositions.get(o.uuid)), this.childDirs.delete(o.uuid), this.childPositions.delete(o.uuid));
44
45
  }), this.ssp.render();
45
46
  }
46
47
  objectActionMap = /* @__PURE__ */ new Map();
47
- startForObjects(t, n) {
48
- const { ssp: o, objectActionMap: s } = this;
49
- if (!s.has(t)) {
48
+ startForObjects(t, e) {
49
+ const { ssp: o, objectActionMap: n } = this;
50
+ if (!n.has(t)) {
50
51
  const c = M(t, o);
51
- s.set(t, c);
52
+ n.set(t, c);
52
53
  }
53
- s.get(t)?.setTime(n);
54
+ n.get(t)?.setTime(e);
54
55
  }
55
56
  stopForObjects(t) {
56
- const { objectActionMap: n } = this;
57
- t || (t = [...n.keys()].at(-1)), t && (n.get(t)?.stop(), n.delete(t));
57
+ const { objectActionMap: e } = this;
58
+ t || (t = [...e.keys()].at(-1)), t && (e.get(t)?.stop(), e.delete(t));
58
59
  }
59
60
  }
60
61
  function M(l, t) {
61
- const n = t.utils.getBoundingBox, o = {}, s = {};
62
+ const e = t.utils.getBoundingBox, o = {}, n = {};
62
63
  let c = {};
63
64
  const h = new m();
64
65
  for (const u of l) {
65
- const i = n(u);
66
+ const i = e(u);
66
67
  c[u.uuid] = i, h.union(i);
67
68
  }
68
- const b = h.getCenter(new r()), e = h.getSize(new r()), y = Math.max(e.x, e.y, e.z), g = new r();
69
+ const b = h.getCenter(new r()), s = h.getSize(new r()), y = Math.max(s.x, s.y, s.z), g = new r();
69
70
  for (const u of l) {
70
71
  const { uuid: i, position: a, parent: p } = u;
71
- s[i] = a.clone(), c[i].getCenter(g);
72
+ n[i] = a.clone(), c[i].getCenter(g);
72
73
  const d = new r();
73
74
  if (d.subVectors(g, b), p) {
74
75
  const w = p.getWorldQuaternion(new B());
@@ -79,14 +80,14 @@ function M(l, t) {
79
80
  c = null;
80
81
  function f(u = y) {
81
82
  for (const i of l) {
82
- const { uuid: a, position: p } = i, d = o[a], w = s[a];
83
+ const { uuid: a, position: p } = i, d = o[a], w = n[a];
83
84
  p.copy(d).multiplyScalar(u).add(w);
84
85
  }
85
86
  t.render();
86
87
  }
87
88
  function x() {
88
89
  for (const u of l) {
89
- const { uuid: i, position: a } = u, p = s[i];
90
+ const { uuid: i, position: a } = u, p = n[i];
90
91
  a.copy(p);
91
92
  }
92
93
  t.render();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-model-blast",
3
3
  "pluginName": "ModelBlastPlugin",
4
- "version": "2.15.19",
4
+ "version": "2.16.1",
5
5
  "description": "Model blast 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
  }