@soonspacejs/plugin-model-blast 2.15.18 → 2.16.0
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 +32 -31
- 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,
|
|
10
|
+
start(t, e) {
|
|
10
11
|
this.prevObjects.add(t);
|
|
11
|
-
const { ssp: o } = this,
|
|
12
|
-
t.traverse((
|
|
13
|
-
if (
|
|
14
|
-
if (!this.childDirs.has(
|
|
15
|
-
const g = o.utils.getBoundingBox(
|
|
16
|
-
if (
|
|
17
|
-
const x =
|
|
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
|
-
|
|
22
|
+
s.uuid,
|
|
22
23
|
f
|
|
23
24
|
), this.childPositions.set(
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
s.uuid,
|
|
26
|
+
s.position.clone()
|
|
26
27
|
);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
new r().copy(this.childPositions.get(
|
|
30
|
-
new r().copy(this.childDirs.get(
|
|
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
|
|
38
|
-
if (!
|
|
38
|
+
let e = t;
|
|
39
|
+
if (!e) {
|
|
39
40
|
const o = [...this.prevObjects].at(-1);
|
|
40
|
-
o && (this.prevObjects.delete(o),
|
|
41
|
+
o && (this.prevObjects.delete(o), e = o);
|
|
41
42
|
}
|
|
42
|
-
|
|
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,
|
|
48
|
-
const { ssp: o, objectActionMap:
|
|
49
|
-
if (!
|
|
48
|
+
startForObjects(t, e) {
|
|
49
|
+
const { ssp: o, objectActionMap: n } = this;
|
|
50
|
+
if (!n.has(t)) {
|
|
50
51
|
const c = M(t, o);
|
|
51
|
-
|
|
52
|
+
n.set(t, c);
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
n.get(t)?.setTime(e);
|
|
54
55
|
}
|
|
55
56
|
stopForObjects(t) {
|
|
56
|
-
const { objectActionMap:
|
|
57
|
-
t || (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
|
|
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 =
|
|
66
|
+
const i = e(u);
|
|
66
67
|
c[u.uuid] = i, h.union(i);
|
|
67
68
|
}
|
|
68
|
-
const b = h.getCenter(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
|
-
|
|
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 =
|
|
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 =
|
|
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.
|
|
4
|
+
"version": "2.16.0",
|
|
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.
|
|
18
|
+
"soonspacejs": "2.16.0"
|
|
19
19
|
}
|
|
20
20
|
}
|