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