perfect-gui 4.12.10 → 5.0.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.
- package/README.md +3 -3
- package/dist/perfect-gui.js +378 -280
- package/package.json +1 -1
- package/src/components/Button.js +33 -20
- package/src/components/Color.js +64 -68
- package/src/components/Image.js +32 -16
- package/src/components/List.js +80 -76
- package/src/components/Slider.js +82 -54
- package/src/components/Toggle.js +59 -55
- package/src/components/Vector2.js +157 -72
- package/src/index.js +16 -17
package/dist/perfect-gui.js
CHANGED
|
@@ -1,75 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(t, e = {}
|
|
3
|
-
this.parent = t
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
class $ {
|
|
2
|
+
constructor(t, e = {}) {
|
|
3
|
+
if (this.parent = t, this.callback = null, typeof e != "object")
|
|
4
|
+
throw Error(
|
|
5
|
+
`[GUI] button() first parameter must be an object. Received: ${typeof e}.`
|
|
6
|
+
);
|
|
7
|
+
let r = e.label || " ";
|
|
8
|
+
const c = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? r : null, i = document.createElement("div");
|
|
9
|
+
i.className = "p-gui__button", i.textContent = r, c && i.setAttribute("title", c), i.addEventListener("click", () => {
|
|
10
|
+
this.callback && this.callback(), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
11
|
+
}), typeof e.color == "string" && (i.style.setProperty("--color-accent", e.color), i.style.setProperty(
|
|
12
|
+
"--color-accent-hover",
|
|
13
|
+
e.hoverColor || e.color
|
|
14
|
+
)), this.parent.wrapper.append(i);
|
|
15
|
+
}
|
|
16
|
+
onClick(t) {
|
|
17
|
+
return this.callback = t, this;
|
|
10
18
|
}
|
|
11
|
-
}
|
|
12
|
-
class
|
|
13
|
-
constructor(t, e
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(this.prop != null && this.obj == null || this.prop == null && this.obj != null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), a = (this.max - this.min) / 2;
|
|
31
|
-
const o = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? s : null, r = document.createElement("div");
|
|
32
|
-
r.className = "p-gui__slider", o && r.setAttribute("title", o), this.parent.wrapper.append(r);
|
|
19
|
+
}
|
|
20
|
+
class Y {
|
|
21
|
+
constructor(t, e, r, c) {
|
|
22
|
+
this.parent = t, this.propReferences = [];
|
|
23
|
+
let i = {}, a = null;
|
|
24
|
+
if (e && typeof e == "object" && typeof r == "string")
|
|
25
|
+
this.obj = e, this.prop = r, this.isObject = !0, i = c || {}, this.callback = null;
|
|
26
|
+
else if (e && typeof e == "object")
|
|
27
|
+
this.isObject = !1, i = e, a = typeof i.value == "number" ? i.value : null;
|
|
28
|
+
else
|
|
29
|
+
throw Error("[GUI] slider() invalid parameters.");
|
|
30
|
+
let s = typeof i.label == "string" && i.label || " ";
|
|
31
|
+
this.isObject && s == " " && (s = this.prop), this.min = i.min ?? 0, this.max = i.max ?? 1, this.step = i.step || (this.max - this.min) / 100, this.decimals = this.parent._countDecimals(this.step);
|
|
32
|
+
let o = null;
|
|
33
|
+
this.isObject ? o = this.propReferences.push(this.obj[this.prop]) - 1 : a === null && (a = (this.max - this.min) / 2);
|
|
34
|
+
const n = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? s : null, l = document.createElement("div");
|
|
35
|
+
l.className = "p-gui__slider", n && l.setAttribute("title", n), this.parent.wrapper.append(l);
|
|
36
|
+
const u = document.createElement("div");
|
|
37
|
+
u.className = "p-gui__slider-name", u.textContent = s, l.append(u), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", this.min), this.ctrlDiv.setAttribute("max", this.max), l.append(this.ctrlDiv);
|
|
33
38
|
const d = document.createElement("div");
|
|
34
|
-
d.className = "p-gui__slider-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
d.className = "p-gui__slider-bar", this.ctrlDiv.append(d), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", d.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : a, l.append(this.valueInput), setTimeout(() => {
|
|
40
|
+
const p = this.handle.offsetWidth;
|
|
41
|
+
this.handle.position = this._mapLinear(
|
|
42
|
+
this.valueInput.value,
|
|
43
|
+
this.min,
|
|
44
|
+
this.max,
|
|
45
|
+
p / 2,
|
|
46
|
+
88 - p / 2
|
|
47
|
+
), this.handle.position = Math.min(
|
|
48
|
+
this.handle.position,
|
|
49
|
+
88 - p / 2
|
|
50
|
+
), this.handle.position = Math.max(
|
|
51
|
+
this.handle.position,
|
|
52
|
+
p / 2
|
|
53
|
+
), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
|
|
39
54
|
}, 0), this.valueInput.addEventListener("change", () => {
|
|
40
55
|
this._updateHandlePositionFromValue(), this._triggerCallbacks();
|
|
41
|
-
}), this.ctrlDiv.addEventListener("pointerdown", (
|
|
42
|
-
this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition =
|
|
43
|
-
}), window.addEventListener("pointerup", (
|
|
56
|
+
}), this.ctrlDiv.addEventListener("pointerdown", (p) => {
|
|
57
|
+
this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = p.clientX, this._updateHandlePositionFromPointer(p, !0);
|
|
58
|
+
}), window.addEventListener("pointerup", (p) => {
|
|
44
59
|
this.ctrlDiv.pointerDown = !1;
|
|
45
|
-
}), window.addEventListener("pointermove", (
|
|
46
|
-
this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta =
|
|
60
|
+
}), window.addEventListener("pointermove", (p) => {
|
|
61
|
+
this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = p.clientX - this.ctrlDiv.prevPosition, this._updateHandlePositionFromPointer(p));
|
|
47
62
|
}), this.isObject && Object.defineProperty(this.obj, this.prop, {
|
|
48
|
-
set: (
|
|
49
|
-
this.propReferences[
|
|
63
|
+
set: (p) => {
|
|
64
|
+
this.propReferences[o] = p, this.valueInput.value = p, this._updateHandlePositionFromValue(), this.callback && this.callback(parseFloat(this.valueInput.value));
|
|
50
65
|
},
|
|
51
|
-
get: () => this.propReferences[
|
|
52
|
-
})
|
|
66
|
+
get: () => this.propReferences[o]
|
|
67
|
+
});
|
|
53
68
|
}
|
|
54
69
|
_updateHandlePositionFromPointer(t, e = !1) {
|
|
55
|
-
const
|
|
56
|
-
let
|
|
57
|
-
e ?
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
const r = this.ctrlDiv.offsetWidth, c = this.handle.offsetWidth, i = t.clientX - this.ctrlDiv.prevPosition, a = parseFloat(this.valueInput.value);
|
|
71
|
+
let s;
|
|
72
|
+
e ? s = t.offsetX : s = this.handle.position + i, s = Math.max(
|
|
73
|
+
c / 2,
|
|
74
|
+
Math.min(s, r - c / 2)
|
|
75
|
+
);
|
|
76
|
+
let o = this.min + (this.max - this.min) * (s - c / 2) / (r - c);
|
|
77
|
+
o > a ? o = this._quantizeFloor(o, this.step) : o = this._quantizeCeil(o, this.step), o = parseFloat(o.toFixed(9));
|
|
78
|
+
const n = parseFloat((a + this.step).toFixed(9)), l = parseFloat((a - this.step).toFixed(9));
|
|
79
|
+
(o >= n || o <= l) && (o = o.toFixed(this.decimals), this.valueInput.value = o, this.ctrlDiv.prevPosition = t.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${s}px)`, this.handle.position = s, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
|
|
62
80
|
}
|
|
63
81
|
_updateHandlePositionFromValue() {
|
|
64
82
|
const t = this.ctrlDiv.offsetWidth, e = this.handle.offsetWidth;
|
|
65
|
-
let
|
|
66
|
-
|
|
83
|
+
let r = this._mapLinear(
|
|
84
|
+
this.valueInput.value,
|
|
85
|
+
this.min,
|
|
86
|
+
this.max,
|
|
87
|
+
e / 2,
|
|
88
|
+
t - e / 2
|
|
89
|
+
);
|
|
90
|
+
r = Math.max(
|
|
91
|
+
e / 2,
|
|
92
|
+
Math.min(r, t - e / 2)
|
|
93
|
+
), this.handle.style.transform = `translate(-50%, -50%) translateX(${r}px)`, this.handle.position = r, this.filling.style.width = this.handle.position + "px";
|
|
67
94
|
}
|
|
68
95
|
_triggerCallbacks() {
|
|
69
96
|
this.isObject ? this.obj[this.prop] = parseFloat(this.valueInput.value) : this.callback && this.callback(parseFloat(this.valueInput.value)), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
70
97
|
}
|
|
71
|
-
_mapLinear(t, e,
|
|
72
|
-
return
|
|
98
|
+
_mapLinear(t, e, r, c, i) {
|
|
99
|
+
return c + (t - e) * (i - c) / (r - e);
|
|
73
100
|
}
|
|
74
101
|
_quantize(t, e) {
|
|
75
102
|
return e * Math.round(t / e);
|
|
@@ -80,193 +107,266 @@ class N {
|
|
|
80
107
|
_quantizeFloor(t, e) {
|
|
81
108
|
return e * Math.floor(t / e);
|
|
82
109
|
}
|
|
110
|
+
onChange(t) {
|
|
111
|
+
return this.callback = t, this;
|
|
112
|
+
}
|
|
83
113
|
}
|
|
84
|
-
class
|
|
85
|
-
constructor(t, e = {}
|
|
86
|
-
if (this.parent = t, typeof e != "object")
|
|
87
|
-
throw Error(
|
|
88
|
-
|
|
114
|
+
class z {
|
|
115
|
+
constructor(t, e = {}) {
|
|
116
|
+
if (this.parent = t, this.callback = null, typeof e != "object")
|
|
117
|
+
throw Error(
|
|
118
|
+
`[GUI] image() first parameter must be an object. Received: ${typeof e}.`
|
|
119
|
+
);
|
|
120
|
+
let r;
|
|
89
121
|
if (typeof e.path == "string")
|
|
90
|
-
|
|
122
|
+
r = e.path;
|
|
91
123
|
else
|
|
92
124
|
throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
|
|
93
|
-
let
|
|
94
|
-
e.label == null ?
|
|
95
|
-
const
|
|
96
|
-
let
|
|
97
|
-
e.width && (typeof e.width == "number" && (e.width += "px"),
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
let
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
125
|
+
let c = r.replace(/^.*[\\\/]/, ""), i;
|
|
126
|
+
e.label == null ? i = c : i = typeof e.label == "string" && e.label || " ";
|
|
127
|
+
const a = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? i : null, s = e.selected === !0, o = e.selectionBorder !== !1;
|
|
128
|
+
let n = "";
|
|
129
|
+
e.width && (typeof e.width == "number" && (e.width += "px"), n += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), n += `height: ${e.height}; `);
|
|
130
|
+
const l = document.createElement("div");
|
|
131
|
+
l.className = "p-gui__image", l.style = "background-image: url(" + r + "); " + n, a && l.setAttribute("title", a), this.parent.imageContainer.append(l), s && o && l.classList.add("p-gui__image--selected");
|
|
132
|
+
const u = document.createElement("div");
|
|
133
|
+
u.className = "p-gui__image-text", u.textContent = i, l.append(u), l.addEventListener("click", () => {
|
|
134
|
+
let d = l.parentElement.querySelectorAll(
|
|
135
|
+
".p-gui__image--selected"
|
|
136
|
+
);
|
|
137
|
+
for (let p = 0; p < d.length; p++)
|
|
138
|
+
d[p].classList.remove("p-gui__image--selected");
|
|
139
|
+
o && l.classList.add("p-gui__image--selected"), typeof this.callback == "function" && this.callback({ path: r, text: i }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
onClick(t) {
|
|
143
|
+
return this.callback = t, this;
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
|
-
class
|
|
110
|
-
constructor(t, e
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const u = h.target.childNodes[1];
|
|
127
|
-
let g = !0;
|
|
128
|
-
u.classList.contains("p-gui__toggle-checkbox--active") && (g = !1), u.classList.toggle("p-gui__toggle-checkbox--active"), l ? o[r] = g : typeof i == "function" && i(g), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
146
|
+
class B {
|
|
147
|
+
constructor(t, e, r, c) {
|
|
148
|
+
this.parent = t, this.callback = null;
|
|
149
|
+
let i = {}, a = null, s = !1, o, n;
|
|
150
|
+
if (e && typeof e == "object" && typeof r == "string")
|
|
151
|
+
o = e, n = r, s = !0, i = c || {};
|
|
152
|
+
else if (e && typeof e == "object")
|
|
153
|
+
s = !1, i = e, a = typeof i.value == "boolean" ? i.value : null;
|
|
154
|
+
else
|
|
155
|
+
throw Error("[GUI] toggle() invalid parameters.");
|
|
156
|
+
let l = typeof i.label == "string" && i.label || " ", u = null;
|
|
157
|
+
s && l == " " && (l = n), s && (u = this.parent.propReferences.push(o[n]) - 1);
|
|
158
|
+
const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null, p = document.createElement("div");
|
|
159
|
+
p.textContent = l, p.className = "p-gui__toggle", d && p.setAttribute("title", d), this.parent.wrapper.append(p), p.addEventListener("click", (b) => {
|
|
160
|
+
const h = b.target.childNodes[1];
|
|
161
|
+
let _ = !0;
|
|
162
|
+
h.classList.contains("p-gui__toggle-checkbox--active") && (_ = !1), h.classList.toggle("p-gui__toggle-checkbox--active"), s ? o[n] = _ : typeof this.callback == "function" && this.callback(_), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
129
163
|
});
|
|
130
|
-
let
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
set: (
|
|
134
|
-
this.parent.propReferences[
|
|
164
|
+
let g = s ? o[n] ? " p-gui__toggle-checkbox--active" : "" : a ? " p-gui__toggle-checkbox--active" : "";
|
|
165
|
+
const f = document.createElement("div");
|
|
166
|
+
f.className = "p-gui__toggle-checkbox" + g, p.append(f), s && Object.defineProperty(o, n, {
|
|
167
|
+
set: (b) => {
|
|
168
|
+
this.parent.propReferences[u] = b, b ? f.classList.add(
|
|
169
|
+
"p-gui__toggle-checkbox--active"
|
|
170
|
+
) : f.classList.remove(
|
|
171
|
+
"p-gui__toggle-checkbox--active"
|
|
172
|
+
), typeof this.callback == "function" && this.callback(b);
|
|
135
173
|
},
|
|
136
|
-
get: () => this.parent.propReferences[
|
|
137
|
-
})
|
|
174
|
+
get: () => this.parent.propReferences[u]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
onChange(t) {
|
|
178
|
+
return this.callback = t, this;
|
|
138
179
|
}
|
|
139
180
|
}
|
|
140
|
-
class
|
|
141
|
-
constructor(t, e
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
n ? (v = d.find((w) => w.value == u), b = v?.value || d[0].value, g = d.indexOf(v)) : (typeof u == "string" && (g = d.indexOf(u), b = u), typeof u == "number" && (g = u, b = d[u])), this.parent.propReferences[a] = n ? b : u;
|
|
183
|
-
const x = h.querySelector("[selected]");
|
|
184
|
-
x && x.removeAttribute("selected"), h.querySelectorAll("option")[g].setAttribute("selected", ""), typeof i == "function" && i(n ? v : b, g);
|
|
181
|
+
class V {
|
|
182
|
+
constructor(t, e, r, c) {
|
|
183
|
+
this.parent = t, this.callback = null;
|
|
184
|
+
let i = {}, a = null, s = !1, o, n;
|
|
185
|
+
if (e && typeof e == "object" && typeof r == "string")
|
|
186
|
+
o = e, n = r, s = !0, i = c || {};
|
|
187
|
+
else if (e && typeof e == "object")
|
|
188
|
+
s = !1, i = e;
|
|
189
|
+
else
|
|
190
|
+
throw Error("[GUI] list() invalid parameters.");
|
|
191
|
+
let l = typeof i.label == "string" ? i.label : " ", u = null, d = Array.isArray(i.values) ? i.values : null, p = d && d.length > 0 && typeof d[0] == "object";
|
|
192
|
+
const g = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null;
|
|
193
|
+
s ? (a = (() => {
|
|
194
|
+
if (!d)
|
|
195
|
+
return null;
|
|
196
|
+
if (typeof o[n] == "string")
|
|
197
|
+
return p ? d.find((h) => h.value === o[n]).value : d.indexOf(o[n]);
|
|
198
|
+
if (typeof o[n] == "number")
|
|
199
|
+
return p ? d.find((h) => h.value === o[n]).value : o[n];
|
|
200
|
+
})(), u = this.parent.propReferences.push(o[n]) - 1) : a = (() => {
|
|
201
|
+
if (!d)
|
|
202
|
+
return null;
|
|
203
|
+
if (typeof i.value == "string")
|
|
204
|
+
return d.indexOf(i.value);
|
|
205
|
+
if (typeof i.value == "number")
|
|
206
|
+
return i.value;
|
|
207
|
+
})();
|
|
208
|
+
let f = document.createElement("div");
|
|
209
|
+
f.className = "p-gui__list", f.textContent = l, g && f.setAttribute("title", g), this.parent.wrapper.append(f);
|
|
210
|
+
let b = document.createElement("select");
|
|
211
|
+
f.append(b), b.className = "p-gui__list-dropdown", b.addEventListener("change", (h) => {
|
|
212
|
+
s ? o[n] = h.target.value : this.callback && this.callback(h.target.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
213
|
+
}), d && d.forEach((h, _) => {
|
|
214
|
+
const y = p ? h.label : h, v = p ? h.value : h;
|
|
215
|
+
let w = document.createElement("option");
|
|
216
|
+
w.setAttribute("value", v), w.textContent = y, b.append(w), (!p && a == _ || p && a == v) && w.setAttribute("selected", "");
|
|
217
|
+
}), s && Object.defineProperty(o, n, {
|
|
218
|
+
set: (h) => {
|
|
219
|
+
let _, y, v;
|
|
220
|
+
p ? (v = d.find((C) => C.value == h), y = v?.value || d[0].value, _ = d.indexOf(v)) : (typeof h == "string" && (_ = d.indexOf(h), y = h), typeof h == "number" && (_ = h, y = d[h])), this.parent.propReferences[u] = p ? y : h;
|
|
221
|
+
const w = b.querySelector("[selected]");
|
|
222
|
+
w && w.removeAttribute("selected"), b.querySelectorAll("option")[_].setAttribute("selected", ""), typeof this.callback == "function" && (p ? this.callback(v, _) : this.callback(y, _));
|
|
185
223
|
},
|
|
186
|
-
get: () => this.parent.propReferences[
|
|
187
|
-
})
|
|
224
|
+
get: () => this.parent.propReferences[u]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
onChange(t) {
|
|
228
|
+
return this.callback = t, this;
|
|
188
229
|
}
|
|
189
230
|
}
|
|
190
|
-
class
|
|
191
|
-
constructor(t, e
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
else
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
this.parent.propReferences[a] = p, f.value = p, typeof i == "function" && i(p);
|
|
231
|
+
class G {
|
|
232
|
+
constructor(t, e, r, c) {
|
|
233
|
+
this.parent = t, this.callback = null;
|
|
234
|
+
let i = {}, a = null, s = !1, o, n;
|
|
235
|
+
if (e && typeof e == "object" && typeof r == "string")
|
|
236
|
+
o = e, n = r, s = !0, i = c || {};
|
|
237
|
+
else if (e && typeof e == "object")
|
|
238
|
+
s = !1, i = e;
|
|
239
|
+
else
|
|
240
|
+
throw Error("[GUI] color() invalid parameters.");
|
|
241
|
+
let l = typeof i.label == "string" && i.label || " ", u = null;
|
|
242
|
+
const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null;
|
|
243
|
+
s ? (l == " " && (l = n), u = this.parent.propReferences.push(o[n]) - 1, a = o[n] || "#000000") : (typeof i.value == "string" && (i.value.length != 7 || i.value[0] != "#" ? console.error(
|
|
244
|
+
`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${i.value}".`
|
|
245
|
+
) : a = i.value), a || (a = "#000000"));
|
|
246
|
+
const p = document.createElement("div");
|
|
247
|
+
p.className = "p-gui__color", p.textContent = l, d && p.setAttribute("title", d), this.parent.wrapper.append(p);
|
|
248
|
+
const g = document.createElement("input");
|
|
249
|
+
g.className = "p-gui__color-picker", g.setAttribute("type", "color"), g.value = a, p.append(g), g.addEventListener("input", () => {
|
|
250
|
+
s ? o[n] = g.value : typeof this.callback == "function" && this.callback(g.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
251
|
+
}), s && Object.defineProperty(o, n, {
|
|
252
|
+
set: (f) => {
|
|
253
|
+
this.parent.propReferences[u] = f, g.value = f, typeof this.callback == "function" && this.callback(f);
|
|
214
254
|
},
|
|
215
|
-
get: () => this.parent.propReferences[
|
|
216
|
-
})
|
|
255
|
+
get: () => this.parent.propReferences[u]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
onChange(t) {
|
|
259
|
+
return this.callback = t, this;
|
|
217
260
|
}
|
|
218
261
|
}
|
|
219
|
-
class
|
|
220
|
-
constructor(t, e
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
262
|
+
class T {
|
|
263
|
+
constructor(t, e, r, c, i) {
|
|
264
|
+
this.parent = t, this.callback = null;
|
|
265
|
+
let a = {}, s, o, n, l;
|
|
266
|
+
if (e && typeof e == "object" && typeof r == "string" && typeof c == "string")
|
|
267
|
+
s = e, o = e, n = r, l = c, a = i || {};
|
|
268
|
+
else if (e && typeof e == "object" && e.x && e.x.obj)
|
|
269
|
+
a = e, s = a.x.obj, n = a.x.prop, o = a.y.obj, l = a.y.prop;
|
|
270
|
+
else
|
|
271
|
+
throw Error(
|
|
272
|
+
"[GUI] vector2() invalid parameters. Use: gui.vector2(obj, 'propX', 'propY', params)"
|
|
273
|
+
);
|
|
274
|
+
let u = typeof a.label == "string" && a.label || " ";
|
|
275
|
+
u === " " && (u = n + " / " + l);
|
|
276
|
+
const d = a.x || {}, p = a.y || {}, g = d.min ?? a.min ?? 0, f = d.max ?? a.max ?? 1, b = p.min ?? a.min ?? 0, h = p.max ?? a.max ?? 1, _ = d.step || a.step || (f - g) / 100, y = p.step || a.step || (h - b) / 100, v = this.parent._countDecimals(_), w = this.parent._countDecimals(y), C = this.parent.propReferences.push(s[n]) - 1, D = this.parent.propReferences.push(o[l]) - 1, L = typeof a.tooltip == "string" ? a.tooltip : a.tooltip === !0 ? u : null, A = document.createElement("div");
|
|
277
|
+
A.className = "p-gui__vector2", A.textContent = u, L && A.setAttribute("title", L), this.parent.wrapper.append(A);
|
|
278
|
+
const E = document.createElement("div");
|
|
279
|
+
E.className = "p-gui__vector-value", E.textContent = s[n] + ", " + o[l], A.append(E);
|
|
280
|
+
const m = document.createElement("div");
|
|
281
|
+
m.className = "p-gui__vector2-area", A.append(m), m.addEventListener("click", (x) => {
|
|
282
|
+
const j = parseFloat(
|
|
283
|
+
this.parent._mapLinear(
|
|
284
|
+
x.offsetX,
|
|
285
|
+
0,
|
|
286
|
+
m.clientWidth,
|
|
287
|
+
g,
|
|
288
|
+
f
|
|
289
|
+
)
|
|
290
|
+
), R = parseFloat(
|
|
291
|
+
this.parent._mapLinear(
|
|
292
|
+
x.offsetY,
|
|
293
|
+
0,
|
|
294
|
+
m.clientHeight,
|
|
295
|
+
h,
|
|
296
|
+
b
|
|
297
|
+
)
|
|
298
|
+
);
|
|
299
|
+
s[n] = j.toFixed(v), o[l] = R.toFixed(w), this.callback && this.callback(s[n], s[l]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
234
300
|
});
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
|
|
301
|
+
const P = (x) => {
|
|
302
|
+
const j = m.getBoundingClientRect(), R = x.clientX - j.left, N = x.clientY - j.top, H = this.parent._mapLinear(
|
|
303
|
+
R,
|
|
304
|
+
0,
|
|
305
|
+
m.clientWidth,
|
|
306
|
+
g,
|
|
307
|
+
f
|
|
308
|
+
), X = this.parent._mapLinear(
|
|
309
|
+
N,
|
|
310
|
+
0,
|
|
311
|
+
m.clientHeight,
|
|
312
|
+
h,
|
|
313
|
+
b
|
|
314
|
+
), S = Math.max(g, Math.min(f, H)), W = Math.max(b, Math.min(h, X));
|
|
315
|
+
s[n] = parseFloat(S.toFixed(v)), o[l] = parseFloat(W.toFixed(w)), this.callback && this.callback(s[n], o[l]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
|
|
238
316
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
317
|
+
m.addEventListener("pointerdown", (x) => {
|
|
318
|
+
P(x), document.addEventListener("pointermove", P), document.addEventListener(
|
|
319
|
+
"pointerup",
|
|
320
|
+
() => {
|
|
321
|
+
document.removeEventListener(
|
|
322
|
+
"pointermove",
|
|
323
|
+
P
|
|
324
|
+
);
|
|
325
|
+
},
|
|
326
|
+
{ once: !0 }
|
|
327
|
+
);
|
|
243
328
|
});
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
|
|
329
|
+
const F = document.createElement("div");
|
|
330
|
+
F.className = "p-gui__vector2-line p-gui__vector2-line-x", m.append(F);
|
|
331
|
+
const M = document.createElement("div");
|
|
332
|
+
M.className = "p-gui__vector2-line p-gui__vector2-line-y", m.append(M);
|
|
333
|
+
const U = document.createElement("div");
|
|
334
|
+
U.className = "p-gui__vector2-dot", m.append(U);
|
|
335
|
+
const I = () => {
|
|
336
|
+
U.style.left = this.parent._mapLinear(
|
|
337
|
+
s[n],
|
|
338
|
+
g,
|
|
339
|
+
f,
|
|
340
|
+
0,
|
|
341
|
+
m.clientWidth
|
|
342
|
+
) + "px", U.style.top = this.parent._mapLinear(
|
|
343
|
+
o[l],
|
|
344
|
+
b,
|
|
345
|
+
h,
|
|
346
|
+
m.clientHeight,
|
|
347
|
+
0
|
|
348
|
+
) + "px";
|
|
252
349
|
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}).observe(
|
|
256
|
-
set: (
|
|
257
|
-
this.parent.propReferences[
|
|
350
|
+
I(), new ResizeObserver(() => {
|
|
351
|
+
I();
|
|
352
|
+
}).observe(m), Object.defineProperty(s, n, {
|
|
353
|
+
set: (x) => {
|
|
354
|
+
this.parent.propReferences[C] = x, I(), E.textContent = String(x) + ", " + o[l];
|
|
258
355
|
},
|
|
259
|
-
get: () => this.parent.propReferences[
|
|
260
|
-
}), Object.defineProperty(
|
|
261
|
-
set: (
|
|
262
|
-
this.parent.propReferences[
|
|
356
|
+
get: () => this.parent.propReferences[C]
|
|
357
|
+
}), Object.defineProperty(o, l, {
|
|
358
|
+
set: (x) => {
|
|
359
|
+
this.parent.propReferences[D] = x, I(), E.textContent = s[n] + ", " + String(x);
|
|
263
360
|
},
|
|
264
|
-
get: () => this.parent.propReferences[
|
|
265
|
-
})
|
|
361
|
+
get: () => this.parent.propReferences[D]
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
onChange(t) {
|
|
365
|
+
return this.callback = t, this;
|
|
266
366
|
}
|
|
267
367
|
}
|
|
268
|
-
const
|
|
269
|
-
function
|
|
368
|
+
const Q = ".p-gui__button{background:var(--color-accent);text-align:center;color:var(--color-bg);border:1px solid transparent;box-sizing:border-box;transition:var(--transition) background,var(--transition) border-color}.p-gui__button:hover{background:var(--color-accent-hover);border-color:#fff3}.p-gui__folder .p-gui__button{margin-inline:0}", q = ".p-gui__slider{position:relative;min-height:14px;display:flex;align-items:center;justify-content:space-between;gap:10px;color:var(--color-text-dark);transition:color var(--transition);padding:3px}.p-gui__slider:hover{color:var(--color-text-light)}.p-gui__slider-name{width:50%;text-overflow:ellipsis;overflow:hidden}.p-gui__slider-ctrl{-webkit-appearance:none;padding:0;font:inherit;outline:none;box-sizing:border-box;cursor:pointer;position:relative;right:0;height:14px;margin:0 0 0 auto;width:37%}.p-gui__slider-bar{position:absolute;top:50%;left:0;height:2px;background:#fff3;width:100%;transform:translateY(-50%)}.p-gui__slider-filling{position:absolute;top:-25%;left:0;height:100%;background:var(--color-accent);width:0}.p-gui__slider:hover .p-gui__slider-filling{background:var(--color-accent-hover)}.p-gui__slider-handle{width:9px;height:9px;position:absolute;top:50%;left:0;border-radius:2px;transform:translate(-50%,-50%);pointer-events:none;background:var(--color-text-dark);box-shadow:0 0 2px #00000080}.p-gui__slider:hover .p-gui__slider-handle{background:var(--color-text-light)}.p-gui__slider-value{display:inline-block;right:7px;width:13%;border:none;color:#fff;border-radius:2px;background:#ffffff1a;padding:2px 4px;color:inherit}.p-gui__slider-value:focus{outline:none}", J = ".p-gui__list{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__list:hover{color:var(--color-text-light)}.p-gui__list-dropdown{background:#ffffff0d;color:#fff;padding:0 12px 0 5px;top:0}.p-gui__list-dropdown{position:absolute;right:5px;top:0;bottom:0;margin:auto;height:calc(100% - 4px);cursor:pointer;border-radius:3px;border:1px solid var(--color-border-2);outline:none}.p-gui__list-dropdown option{background:#fff;color:#000}.p-gui__list-dropdown:hover{background:#ffffff1a}", Z = ".p-gui__toggle{color:var(--color-text-dark);transition:var(--transition) background,var(--transition) color}.p-gui__toggle:hover{background:#ffffff1a;color:var(--color-text-light)}.p-gui__folder .p-gui__toggle{margin-inline:0}.p-gui__toggle-checkbox{width:10px;height:10px;background-color:#ffffff1a;position:absolute;top:0;right:10px;bottom:0;margin:auto;border-radius:2px;pointer-events:none;transition:.5s all ease}.p-gui__toggle-checkbox--active{background-color:#ddd;box-shadow:0 0 5px #ddd}", K = ".p-gui__color{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__color:hover{color:var(--color-text-light)}.p-gui__color-picker{position:absolute;right:5px;top:0;bottom:0;margin:auto;height:calc(100% - 4px);cursor:pointer;border-radius:3px;border:1px solid var(--color-border-2);outline:none;-webkit-appearance:none;padding:0;background-color:transparent;border:1px solid #222222;overflow:hidden}.p-gui__color-picker::-webkit-color-swatch-wrapper{padding:0}.p-gui__color-picker::-webkit-color-swatch{border:none}", ee = ".p-gui__vector2{background:transparent;aspect-ratio:1;padding-bottom:0;color:var(--color-text-dark)}.p-gui__vector2:hover{color:var(--color-text-light)}.p-gui__vector2-area{position:relative;background:#0000004d;margin-top:8px;width:100%;height:calc(100% - 28px);touch-action:none}.p-gui__vector2-line{position:absolute;background:#fff;opacity:.3;pointer-events:none}.p-gui__vector2-line-x{width:100%;height:1px;left:0;top:50%;transform:translateY(-50%)}.p-gui__vector2-line-y{width:1px;height:100%;top:0;left:50%;transform:translate(-50%)}.p-gui__vector2-dot{position:absolute;top:0;left:0;width:8px;height:8px;border-radius:50%;background:#d5d5d5;border:2px solid #ff9999;transform:translate(-50%,-50%);pointer-events:none}.p-gui__vector-value{display:inline-block;right:7px;position:absolute}", te = '.p-gui__image-container{width:100%;padding:3px;display:flex;justify-content:flex-start;flex-wrap:wrap;box-sizing:border-box}.p-gui__image{background-size:cover;cursor:pointer;position:relative;margin:1px 2.5px 19px;border-radius:var(--main-border-radius);flex:0 0 calc(33.333% - 5px);height:90px;background-position:center;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__image:hover{color:var(--color-text-light)}.p-gui__image:after{position:absolute;top:0;left:0;width:100%;height:100%;content:"";border:1px solid transparent;box-sizing:border-box;border-radius:var(--main-border-radius);transition:var(--transition) border-color}.p-gui__image--selected:after{border-color:#06ff89}.p-gui__image-text{position:absolute;bottom:-15px;text-shadow:0 -1px 0 #111;white-space:nowrap;width:100%;overflow:hidden;text-overflow:ellipsis}', ie = ".p-gui__folder{width:100%;position:relative;background:var(--color-bg);margin-bottom:2px;display:flex;flex-wrap:wrap;border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbbbbb}.p-gui__folder--first{margin-top:0}.p-gui__folder-content{display:grid;grid-template-rows:1fr;transition:.25s grid-template-rows ease;width:100%}.p-gui__folder-inner{overflow:hidden;padding-left:3px;padding-right:2px}.p-gui__folder--closed .p-gui__folder-content{grid-template-rows:0fr}.p-gui__folder-header{padding:5px 3px;background-color:#00000080;color:#fff;cursor:pointer;width:100%;box-sizing:border-box;border-top-right-radius:var(--main-border-radius);border-bottom-right-radius:var(--main-border-radius)}.p-gui__folder-header:hover{background-color:#000000bf}.p-gui__folder-arrow{width:8px;height:8px;display:inline-block;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAHlBMVEUAAAD///////////////////////////////////8kfJuVAAAACXRSTlMA9Z1fCdMo1yxEJnA0AAAAK0lEQVQI12PABlRgjKkJUMZMYRhjpgqMAZSEMICSaIzpDWiKhdENhEhgAgATSg5jyWnYewAAAABJRU5ErkJggg==);background-size:contain;margin-right:5px;transform:rotate(90deg)}.p-gui__folder--closed .p-gui__folder-arrow{transform:rotate(0)}";
|
|
369
|
+
function re(k) {
|
|
270
370
|
return `
|
|
271
371
|
.p-gui {
|
|
272
372
|
--main-border-radius: 6px;
|
|
@@ -279,7 +379,7 @@ function Z(y) {
|
|
|
279
379
|
--color-accent-hover: #dddddd;
|
|
280
380
|
--transition: .1s linear;
|
|
281
381
|
|
|
282
|
-
position: ${
|
|
382
|
+
position: ${k};
|
|
283
383
|
top: 0;
|
|
284
384
|
left: 0;
|
|
285
385
|
transform: translate3d(0,0,0);
|
|
@@ -413,24 +513,24 @@ function Z(y) {
|
|
|
413
513
|
border-color: rgba(255,255,255,.2);
|
|
414
514
|
}
|
|
415
515
|
|
|
416
|
-
${
|
|
516
|
+
${Q}
|
|
417
517
|
|
|
418
|
-
${
|
|
518
|
+
${te}
|
|
419
519
|
|
|
420
|
-
${
|
|
520
|
+
${J}
|
|
421
521
|
|
|
422
|
-
${
|
|
522
|
+
${Z}
|
|
423
523
|
|
|
424
|
-
${
|
|
524
|
+
${q}
|
|
425
525
|
|
|
426
|
-
${
|
|
526
|
+
${K}
|
|
427
527
|
|
|
428
|
-
${
|
|
528
|
+
${ee}
|
|
429
529
|
|
|
430
|
-
${
|
|
530
|
+
${ie}
|
|
431
531
|
`;
|
|
432
532
|
}
|
|
433
|
-
class
|
|
533
|
+
class O {
|
|
434
534
|
constructor(t = {}) {
|
|
435
535
|
if (this.firstParent = this, t.container ? (this.container = typeof t.container == "string" ? document.querySelector(t.container) : t.container, this.position_type = "absolute") : (this.container = document.body, this.position_type = "fixed"), this.propReferences = [], this.folders = [], t.isFolder) {
|
|
436
536
|
this._folderConstructor(t.folderOptions);
|
|
@@ -439,14 +539,14 @@ class C {
|
|
|
439
539
|
typeof t.onUpdate == "function" && (this.onUpdate = t.onUpdate), this.label = t != null && typeof t.label == "string" ? t.label : "", this.backgroundColor = t.color || null, this.opacity = t.opacity || 1, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(
|
|
440
540
|
this.container.clientHeight,
|
|
441
541
|
window.innerHeight
|
|
442
|
-
), t.maxHeight && (this.initMaxHeight = t.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(t.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = t.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${
|
|
542
|
+
), t.maxHeight && (this.initMaxHeight = t.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(t.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = t.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${re(this.position_type)}`), this._styleInstance(), this._addWrapper(), this.domElement.setAttribute("data-corner-x", this.screenCorner.x), this.domElement.setAttribute("data-corner-y", this.screenCorner.y), t.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, t.draggable == !0 && this._makeDraggable(), this.closed = !1, t.closed && this.toggleClose();
|
|
443
543
|
}
|
|
444
544
|
_styleInstance() {
|
|
445
545
|
let t = this._getScrollbarWidth(this.container);
|
|
446
546
|
if (this.screenCorner.x == "left" ? this.xOffset = 0 : this.xOffset = this.container.clientWidth - this.wrapperWidth - t, this.instanceId > 0) {
|
|
447
547
|
let e = this.container.querySelectorAll(".p-gui");
|
|
448
|
-
for (let
|
|
449
|
-
this.screenCorner.y == e[
|
|
548
|
+
for (let r = 0; r < e.length; r++)
|
|
549
|
+
this.screenCorner.y == e[r].dataset.cornerY && (this.screenCorner.x == "left" && e[r].dataset.cornerX == "left" ? this.xOffset += e[r].offsetWidth : this.screenCorner.x == "right" && e[r].dataset.cornerX == "right" && (this.xOffset -= e[r].offsetWidth));
|
|
450
550
|
}
|
|
451
551
|
this.yOffset = 0, this.position = {
|
|
452
552
|
prevX: this.xOffset,
|
|
@@ -483,10 +583,10 @@ class C {
|
|
|
483
583
|
let e = this.container.querySelectorAll(
|
|
484
584
|
`.p-gui:not(#${this.domElement.id}):not([data-dragged])`
|
|
485
585
|
);
|
|
486
|
-
for (let
|
|
487
|
-
e[
|
|
488
|
-
) > this.instanceId);
|
|
489
|
-
this.screenCorner.y == e[
|
|
586
|
+
for (let r = 0; r < e.length && !(parseInt(
|
|
587
|
+
e[r].id.replace("p-gui-", "")
|
|
588
|
+
) > this.instanceId); r++)
|
|
589
|
+
this.screenCorner.y == e[r].dataset.cornerY && (this.screenCorner.x == "left" && e[r].dataset.cornerX == "left" ? this.xOffset += e[r].offsetWidth : this.screenCorner.x == "right" && e[r].dataset.cornerX == "right" && (this.xOffset -= e[r].offsetWidth));
|
|
490
590
|
}
|
|
491
591
|
this.position = {
|
|
492
592
|
prevX: this.xOffset,
|
|
@@ -505,68 +605,66 @@ class C {
|
|
|
505
605
|
const e = document.createElement("div");
|
|
506
606
|
e.className = "p-gui__content", this.domElement.append(e), this.wrapper = document.createElement("div"), this.wrapper.className = "p-gui__inner", e.append(this.wrapper);
|
|
507
607
|
}
|
|
508
|
-
button(t = {}
|
|
509
|
-
return this.imageContainer = null, new
|
|
608
|
+
button(t = {}) {
|
|
609
|
+
return this.imageContainer = null, new $(this, t);
|
|
510
610
|
}
|
|
511
|
-
image(t = {}
|
|
512
|
-
return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new
|
|
611
|
+
image(t = {}) {
|
|
612
|
+
return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new z(this, t);
|
|
513
613
|
}
|
|
514
|
-
slider(t
|
|
515
|
-
return this.imageContainer = null, new
|
|
614
|
+
slider(t, e, r) {
|
|
615
|
+
return this.imageContainer = null, new Y(this, t, e, r);
|
|
516
616
|
}
|
|
517
|
-
toggle(t
|
|
518
|
-
this.imageContainer = null;
|
|
519
|
-
const i = new S(this, t, e);
|
|
520
|
-
return this.wrapper.append(i), i;
|
|
617
|
+
toggle(t, e, r) {
|
|
618
|
+
return this.imageContainer = null, new B(this, t, e, r);
|
|
521
619
|
}
|
|
522
|
-
list(t
|
|
523
|
-
return this.imageContainer = null, new
|
|
620
|
+
list(t, e, r) {
|
|
621
|
+
return this.imageContainer = null, new V(this, t, e, r);
|
|
524
622
|
}
|
|
525
|
-
color(t
|
|
526
|
-
return this.imageContainer = null, new
|
|
623
|
+
color(t, e, r) {
|
|
624
|
+
return this.imageContainer = null, new G(this, t, e, r);
|
|
527
625
|
}
|
|
528
|
-
vector2(t
|
|
529
|
-
return this.imageContainer = null, new
|
|
626
|
+
vector2(t, e, r, c) {
|
|
627
|
+
return this.imageContainer = null, new T(this, t, e, r, c);
|
|
530
628
|
}
|
|
531
629
|
folder(t = {}) {
|
|
532
|
-
let e = typeof t.closed == "boolean" ? t.closed : !1,
|
|
630
|
+
let e = typeof t.closed == "boolean" ? t.closed : !1, r = t.label || "", c = t.color || null, i = t.maxHeight || null;
|
|
533
631
|
this.imageContainer = null;
|
|
534
632
|
let a = "p-gui__folder";
|
|
535
633
|
this.folders.length == 0 && (a += " p-gui__folder--first"), e && (a += " p-gui__folder--closed");
|
|
536
|
-
let
|
|
537
|
-
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
const d = document.createElement("div");
|
|
541
|
-
d.innerHTML = `<span class="p-gui__folder-arrow"></span>${i}`, d.className = "p-gui__folder-header", r.append(d);
|
|
542
|
-
const c = document.createElement("div");
|
|
543
|
-
c.className = "p-gui__folder-content", r.append(c);
|
|
634
|
+
let s = c ? `background-color: ${c};` : "";
|
|
635
|
+
s += i ? `max-height: ${i}px;` : "";
|
|
636
|
+
const o = document.createElement("div");
|
|
637
|
+
o.className = a, o.style = s, this.wrapper.append(o);
|
|
544
638
|
const n = document.createElement("div");
|
|
545
|
-
n.
|
|
546
|
-
|
|
639
|
+
n.innerHTML = `<span class="p-gui__folder-arrow"></span>${r}`, n.className = "p-gui__folder-header", o.append(n);
|
|
640
|
+
const l = document.createElement("div");
|
|
641
|
+
l.className = "p-gui__folder-content", o.append(l);
|
|
642
|
+
const u = document.createElement("div");
|
|
643
|
+
u.className = "p-gui__folder-inner", l.append(u), n.addEventListener("click", () => {
|
|
644
|
+
o.classList.toggle("p-gui__folder--closed");
|
|
547
645
|
});
|
|
548
|
-
let
|
|
646
|
+
let d = new O({
|
|
549
647
|
isFolder: !0,
|
|
550
648
|
folderOptions: {
|
|
551
|
-
wrapper:
|
|
552
|
-
inner:
|
|
649
|
+
wrapper: o,
|
|
650
|
+
inner: u,
|
|
553
651
|
parent: this,
|
|
554
652
|
firstParent: this.firstParent
|
|
555
653
|
}
|
|
556
654
|
});
|
|
557
|
-
return this.folders.push(
|
|
655
|
+
return this.folders.push(d), d;
|
|
558
656
|
}
|
|
559
657
|
_makeDraggable() {
|
|
560
658
|
var t = this;
|
|
561
|
-
this.header.addEventListener("pointerdown", e), this.header.addEventListener("pointerup",
|
|
562
|
-
function e(
|
|
563
|
-
|
|
659
|
+
this.header.addEventListener("pointerdown", e), this.header.addEventListener("pointerup", c);
|
|
660
|
+
function e(i) {
|
|
661
|
+
i.preventDefault(), t.position.initX = t.position.x, t.position.initY = t.position.y, t.position.prevX = i.clientX, t.position.prevY = i.clientY, document.addEventListener("pointermove", r);
|
|
564
662
|
}
|
|
565
|
-
function i
|
|
566
|
-
|
|
663
|
+
function r(i) {
|
|
664
|
+
i.preventDefault(), t.hasBeenDragged || (t.hasBeenDragged = !0, t.domElement.setAttribute("data-dragged", "true")), t.position.x = t.position.initX + i.clientX - t.position.prevX, t.position.y = t.position.initY + i.clientY - t.position.prevY, t.domElement.style.transform = "translate3d(" + t.position.x + "px," + t.position.y + "px,0)";
|
|
567
665
|
}
|
|
568
|
-
function
|
|
569
|
-
document.removeEventListener("pointermove",
|
|
666
|
+
function c(i) {
|
|
667
|
+
document.removeEventListener("pointermove", r);
|
|
570
668
|
}
|
|
571
669
|
}
|
|
572
670
|
toggleClose() {
|
|
@@ -575,18 +673,18 @@ class C {
|
|
|
575
673
|
kill() {
|
|
576
674
|
this.domElement.remove();
|
|
577
675
|
}
|
|
578
|
-
_mapLinear(t, e,
|
|
579
|
-
return
|
|
676
|
+
_mapLinear(t, e, r, c, i) {
|
|
677
|
+
return c + (t - e) * (i - c) / (r - e);
|
|
580
678
|
}
|
|
581
679
|
_countDecimals(t) {
|
|
582
|
-
const e = t.toString(),
|
|
583
|
-
return
|
|
680
|
+
const e = t.toString(), r = e.indexOf(".");
|
|
681
|
+
return r === -1 ? 0 : e.length - r - 1;
|
|
584
682
|
}
|
|
585
683
|
static registerPlugin(t) {
|
|
586
684
|
for (let e in t)
|
|
587
|
-
|
|
685
|
+
O.prototype[e] = t[e];
|
|
588
686
|
}
|
|
589
687
|
}
|
|
590
688
|
export {
|
|
591
|
-
|
|
689
|
+
O as default
|
|
592
690
|
};
|