@limrun/ui 0.21.0 → 0.22.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 +36 -8
- package/dist/BufferGeometryUtils-B2-bJqFj.js +1 -0
- package/dist/BufferGeometryUtils-BcXIkYhS.mjs +64 -0
- package/dist/{GLTFLoader-D4AITfgZ.mjs → GLTFLoader-BQvr_TBF.mjs} +138 -137
- package/dist/GLTFLoader-CsxjkQ8a.js +1 -0
- package/dist/components/device-stage.d.ts +61 -0
- package/dist/components/device-view.d.ts +29 -0
- package/dist/components/duo-frame.d.ts +5 -1
- package/dist/components/duo-model.d.ts +2 -1
- package/dist/components/macbook-frame.d.ts +30 -0
- package/dist/components/macbook-geometry.d.ts +77 -0
- package/dist/components/model-source.d.ts +8 -0
- package/dist/components/remote-control.d.ts +40 -1
- package/dist/components/studio-environment.d.ts +6 -0
- package/dist/core/mac-pointer.d.ts +56 -0
- package/dist/{core-CRIachT9.mjs → core-nbvkIrvp.mjs} +24 -24
- package/dist/core.js +12 -12
- package/dist/duo-frame-B04_gIge.js +11 -0
- package/dist/duo-frame-CyoWZakh.mjs +748 -0
- package/dist/duo-model-BYgtCaCR.mjs +4 -0
- package/dist/duo-model-CDWgmLRF.js +1 -0
- package/dist/duo-model.d.ts +2 -0
- package/dist/duo-view-BHwnQmx_.js +1 -0
- package/dist/{duo-view-BeqYIqfQ.mjs → duo-view-DJEQ3Q74.mjs} +84 -86
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +32 -25
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +2 -2
- package/dist/macbook-frame-Be0dCliH.js +3 -0
- package/dist/macbook-frame-DzwIHHCA.mjs +344 -0
- package/dist/macbook-model-BiMxLpmf.mjs +4 -0
- package/dist/macbook-model-BpUdvtlU.js +1 -0
- package/dist/macbook-model.d.ts +2 -0
- package/dist/meshopt_decoder.module-C4Z_evpr.mjs +217 -0
- package/dist/meshopt_decoder.module-DxJdu6ez.js +1 -0
- package/dist/{duo-frame-D1JK_cRk.mjs → model-source-BAZAKTcr.mjs} +6184 -6894
- package/dist/model-source-DbYJQWkh.js +4049 -0
- package/dist/remote-control-Db6ssV0S.js +1 -0
- package/dist/remote-control-PGtDEDgm.mjs +1746 -0
- package/package.json +1 -1
- package/dist/GLTFLoader-C25N9Y4j.js +0 -1
- package/dist/duo-frame-B1NXSk6a.js +0 -4059
- package/dist/duo-view-PsR5b045.js +0 -1
- package/dist/remote-control-DNr0Pyrx.js +0 -1
- package/dist/remote-control-rdm3mDtI.mjs +0 -1299
|
@@ -0,0 +1,748 @@
|
|
|
1
|
+
import { jsxs as Rt, jsx as pt } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ut, useState as oe, useEffect as Zt } from "react";
|
|
3
|
+
import { ah as ae, d as K, G as Pt, f as Xt, M as jt, e as Yt, D as ce, ai as le, aj as _t, ak as qt, B as Jt, j as Ft, al as Qt, i as wt, l as ue, b as bt, T as de, g as $t, am as fe, an as pe, ao as ge, ap as he, h as ne, u as me, a4 as ye, c as be, V as te, S as ve, L as ee, R as xe } from "./model-source-BAZAKTcr.mjs";
|
|
4
|
+
import { a as we } from "./BufferGeometryUtils-BcXIkYhS.mjs";
|
|
5
|
+
import { D as Me, k as Se, l as Ut, m as De, p as Be } from "./core-nbvkIrvp.mjs";
|
|
6
|
+
import { h as ke, u as Ie, D as Ae, a as Ee, f as ze } from "./duo-view-DJEQ3Q74.mjs";
|
|
7
|
+
const zt = new K();
|
|
8
|
+
function et(h, b, g, i, w, n) {
|
|
9
|
+
const f = 2 * Math.PI * w / 4, k = Math.max(n - 2 * w, 0), B = Math.PI / 4;
|
|
10
|
+
zt.copy(b), zt[i] = 0, zt.normalize();
|
|
11
|
+
const r = 0.5 * f / (f + k), L = 1 - zt.angleTo(h) / B;
|
|
12
|
+
return Math.sign(zt[g]) === 1 ? L * r : k / (f + k) + r + r * (1 - L);
|
|
13
|
+
}
|
|
14
|
+
class Kt extends ae {
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new rounded box geometry.
|
|
17
|
+
*
|
|
18
|
+
* @param {number} [width=1] - The width. That is, the length of the edges parallel to the X axis.
|
|
19
|
+
* @param {number} [height=1] - The height. That is, the length of the edges parallel to the Y axis.
|
|
20
|
+
* @param {number} [depth=1] - The depth. That is, the length of the edges parallel to the Z axis.
|
|
21
|
+
* @param {number} [segments=2] - Number of segments that form the rounded corners.
|
|
22
|
+
* @param {number} [radius=0.1] - The radius of the rounded corners.
|
|
23
|
+
*/
|
|
24
|
+
constructor(b = 1, g = 1, i = 1, w = 2, n = 0.1) {
|
|
25
|
+
const f = w * 2 + 1;
|
|
26
|
+
if (n = Math.min(b / 2, g / 2, i / 2, n), super(1, 1, 1, f, f, f), this.type = "RoundedBoxGeometry", this.parameters = {
|
|
27
|
+
width: b,
|
|
28
|
+
height: g,
|
|
29
|
+
depth: i,
|
|
30
|
+
segments: w,
|
|
31
|
+
radius: n
|
|
32
|
+
}, f === 1) return;
|
|
33
|
+
const k = this.toNonIndexed();
|
|
34
|
+
this.index = null, this.attributes.position = k.attributes.position, this.attributes.normal = k.attributes.normal, this.attributes.uv = k.attributes.uv;
|
|
35
|
+
const B = new K(), r = new K(), L = new K(b, g, i).divideScalar(2).subScalar(n), A = this.attributes.position.array, U = this.attributes.normal.array, S = this.attributes.uv.array, X = A.length / 6, v = new K(), q = 0.5 / f;
|
|
36
|
+
for (let E = 0, z = 0; E < A.length; E += 3, z += 2)
|
|
37
|
+
switch (B.fromArray(A, E), r.copy(B), r.x -= Math.sign(r.x) * q, r.y -= Math.sign(r.y) * q, r.z -= Math.sign(r.z) * q, r.normalize(), A[E + 0] = L.x * Math.sign(B.x) + r.x * n, A[E + 1] = L.y * Math.sign(B.y) + r.y * n, A[E + 2] = L.z * Math.sign(B.z) + r.z * n, U[E + 0] = r.x, U[E + 1] = r.y, U[E + 2] = r.z, Math.floor(E / X)) {
|
|
38
|
+
case 0:
|
|
39
|
+
v.set(1, 0, 0), S[z + 0] = et(v, r, "z", "y", n, i), S[z + 1] = 1 - et(v, r, "y", "z", n, g);
|
|
40
|
+
break;
|
|
41
|
+
case 1:
|
|
42
|
+
v.set(-1, 0, 0), S[z + 0] = 1 - et(v, r, "z", "y", n, i), S[z + 1] = 1 - et(v, r, "y", "z", n, g);
|
|
43
|
+
break;
|
|
44
|
+
case 2:
|
|
45
|
+
v.set(0, 1, 0), S[z + 0] = 1 - et(v, r, "x", "z", n, b), S[z + 1] = et(v, r, "z", "x", n, i);
|
|
46
|
+
break;
|
|
47
|
+
case 3:
|
|
48
|
+
v.set(0, -1, 0), S[z + 0] = 1 - et(v, r, "x", "z", n, b), S[z + 1] = 1 - et(v, r, "z", "x", n, i);
|
|
49
|
+
break;
|
|
50
|
+
case 4:
|
|
51
|
+
v.set(0, 0, 1), S[z + 0] = 1 - et(v, r, "x", "y", n, b), S[z + 1] = 1 - et(v, r, "y", "x", n, g);
|
|
52
|
+
break;
|
|
53
|
+
case 5:
|
|
54
|
+
v.set(0, 0, -1), S[z + 0] = et(v, r, "x", "y", n, b), S[z + 1] = 1 - et(v, r, "y", "x", n, g);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Factory method for creating an instance of this class from the given
|
|
60
|
+
* JSON object.
|
|
61
|
+
*
|
|
62
|
+
* @param {Object} data - A JSON object representing the serialized geometry.
|
|
63
|
+
* @returns {RoundedBoxGeometry} A new instance.
|
|
64
|
+
*/
|
|
65
|
+
static fromJSON(b) {
|
|
66
|
+
return new Kt(
|
|
67
|
+
b.width,
|
|
68
|
+
b.height,
|
|
69
|
+
b.depth,
|
|
70
|
+
b.segments,
|
|
71
|
+
b.radius
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const { width: Pe, height: $, depth: P } = Me, Y = Pe / 2, vt = (11.3 - P * 2) / 2, xt = 157.5, Wt = 110.8, gt = 1.1, Gt = 0.14;
|
|
76
|
+
function Vt(h, b) {
|
|
77
|
+
h.envMap = b ?? null, h.envMapIntensity = 1, h.onBeforeCompile = (g) => {
|
|
78
|
+
g.vertexShader = `varying vec3 vDuoStudioPosition;
|
|
79
|
+
${g.vertexShader}`.replace(
|
|
80
|
+
"#include <worldpos_vertex>",
|
|
81
|
+
`#include <worldpos_vertex>
|
|
82
|
+
vDuoStudioPosition = (modelMatrix * vec4(transformed, 1.0)).xyz;`
|
|
83
|
+
), g.fragmentShader = `
|
|
84
|
+
varying vec3 vDuoStudioPosition;
|
|
85
|
+
vec3 duoStudioReflection(vec3 direction) {
|
|
86
|
+
float radius = 240.0;
|
|
87
|
+
float along = dot(vDuoStudioPosition, direction);
|
|
88
|
+
float distance = -along + sqrt(max(0.0, along * along + radius * radius - dot(vDuoStudioPosition, vDuoStudioPosition)));
|
|
89
|
+
return normalize(vDuoStudioPosition + direction * distance);
|
|
90
|
+
}
|
|
91
|
+
${g.fragmentShader}`.replace(
|
|
92
|
+
"#include <envmap_physical_pars_fragment>",
|
|
93
|
+
fe.envmap_physical_pars_fragment.replace(
|
|
94
|
+
"envMapRotation * reflectVec",
|
|
95
|
+
"envMapRotation * duoStudioReflection(reflectVec)"
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
}, h.customProgramCacheKey = () => "duo-polished-silver-v1";
|
|
99
|
+
}
|
|
100
|
+
function Ht(h, b, g, i) {
|
|
101
|
+
const w = new _t(), n = -h / 2, f = -b / 2;
|
|
102
|
+
return w.moveTo(n + g, f), w.lineTo(n + h - i, f), i && w.absarc(n + h - i, f + i, i, -Math.PI / 2, 0, !1), w.lineTo(n + h, f + b - i), i && w.absarc(n + h - i, f + b - i, i, 0, Math.PI / 2, !1), w.lineTo(n + g, f + b), g && w.absarc(n + g, f + b - g, g, Math.PI / 2, Math.PI, !1), w.lineTo(n, f + g), g && w.absarc(n + g, f + g, g, Math.PI, Math.PI * 1.5, !1), w;
|
|
103
|
+
}
|
|
104
|
+
function Le(h, b, g) {
|
|
105
|
+
const i = new Pt(), w = new Pt(), n = new Pt();
|
|
106
|
+
i.add(w, n);
|
|
107
|
+
const f = [], k = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
108
|
+
let L, A = !1, U = !1;
|
|
109
|
+
const S = [], X = [], v = new Xt({
|
|
110
|
+
color: 15264750,
|
|
111
|
+
metalness: 1,
|
|
112
|
+
roughness: 0.055,
|
|
113
|
+
clearcoat: 1,
|
|
114
|
+
clearcoatRoughness: 0.055,
|
|
115
|
+
envMapIntensity: 1.15
|
|
116
|
+
}), q = new Xt({
|
|
117
|
+
color: 15987179,
|
|
118
|
+
metalness: 0.04,
|
|
119
|
+
roughness: 0.2,
|
|
120
|
+
clearcoat: 1,
|
|
121
|
+
clearcoatRoughness: 0.08
|
|
122
|
+
}), E = v.clone();
|
|
123
|
+
E.roughness = 0.085, Vt(v, g), Vt(E, g);
|
|
124
|
+
const z = new jt({ color: 526860 }), rt = new Yt({ color: 10790304, roughness: 0.55 }), ht = new Xt({
|
|
125
|
+
color: 198157,
|
|
126
|
+
envMap: g ?? null,
|
|
127
|
+
envMapIntensity: 0.05,
|
|
128
|
+
metalness: 1,
|
|
129
|
+
roughness: 0.22
|
|
130
|
+
}), Mt = new Xt({
|
|
131
|
+
color: 1057079,
|
|
132
|
+
envMap: g ?? null,
|
|
133
|
+
envMapIntensity: 0.04,
|
|
134
|
+
metalness: 1,
|
|
135
|
+
roughness: 0.3
|
|
136
|
+
}), dt = new Yt({ color: 15723220, roughness: 0.35 }), l = new Yt({
|
|
137
|
+
color: 12632252,
|
|
138
|
+
metalness: 0.6,
|
|
139
|
+
roughness: 0.25,
|
|
140
|
+
side: ce
|
|
141
|
+
}), V = new jt({ map: h, toneMapped: !1 }), ft = new jt({ map: b, toneMapped: !1 });
|
|
142
|
+
X.push(
|
|
143
|
+
v,
|
|
144
|
+
q,
|
|
145
|
+
E,
|
|
146
|
+
z,
|
|
147
|
+
rt,
|
|
148
|
+
ht,
|
|
149
|
+
Mt,
|
|
150
|
+
dt,
|
|
151
|
+
l,
|
|
152
|
+
V,
|
|
153
|
+
ft
|
|
154
|
+
);
|
|
155
|
+
const T = (o, s) => {
|
|
156
|
+
X.push(o);
|
|
157
|
+
const e = new bt(o, s);
|
|
158
|
+
return f.push(e), e;
|
|
159
|
+
}, it = (o, s, e, u, y, p, D = 0.12) => T(
|
|
160
|
+
we(
|
|
161
|
+
new pe(Ht(o, s, u, y), {
|
|
162
|
+
depth: e,
|
|
163
|
+
bevelEnabled: D > 0,
|
|
164
|
+
bevelSize: D,
|
|
165
|
+
bevelThickness: D,
|
|
166
|
+
bevelSegments: 3,
|
|
167
|
+
steps: 1,
|
|
168
|
+
curveSegments: 20
|
|
169
|
+
}),
|
|
170
|
+
Math.PI / 3
|
|
171
|
+
),
|
|
172
|
+
p
|
|
173
|
+
), ot = (o, s, e, u, y) => T(new Kt(o, s, e, 3, u), y);
|
|
174
|
+
for (const [o, s] of [
|
|
175
|
+
[w, -1],
|
|
176
|
+
[n, 1]
|
|
177
|
+
]) {
|
|
178
|
+
const e = s === -1 ? 8.6 : 0.55, u = s === 1 ? 8.6 : 0.55, y = it(Y - 0.3, $ - 0.3, P - 0.8, e, u, v, 0.35);
|
|
179
|
+
y.position.set(s * Y / 2, 0, -P + 0.4), o.add(y);
|
|
180
|
+
const p = it(Y - 1.25, $ - 1.25, 0.2, e - 0.3, u - 0.3, q);
|
|
181
|
+
p.position.set(s * Y / 2, 0, -P - 0.02), o.add(p);
|
|
182
|
+
const D = it(Y - 0.8, $ - 0.8, 0.1, e - 0.2, u - 0.2, z, 0.05);
|
|
183
|
+
D.position.set(s * Y / 2, 0, -0.06), o.add(D);
|
|
184
|
+
for (const M of [-$ / 2 + 13, $ / 2 - 13]) {
|
|
185
|
+
const a = ot(0.22, 0.65, P - 0.8, 0.08, rt);
|
|
186
|
+
a.position.set(s * (Y + 0.04), M, -P / 2), o.add(a);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const lt = (o, s, e, u, y, p = 0) => {
|
|
190
|
+
const D = y === "outer" ? Ht(e, u, 0.8, 6.6) : Ht(e, u, p === 0 ? 5.3 : 0, p === 1 ? 5.3 : 0), M = new qt(D, 24), a = M.getAttribute("position"), m = M.getAttribute("uv");
|
|
191
|
+
for (let x = 0; x < a.count; x++) {
|
|
192
|
+
const F = (a.getX(x) + e / 2) / e, R = (a.getY(x) + u / 2) / u;
|
|
193
|
+
if (y === "inner") {
|
|
194
|
+
const W = a.getX(x) + s;
|
|
195
|
+
m.setXY(x, 1 - R, (W + xt / 2) / xt);
|
|
196
|
+
} else m.setXY(x, F, R);
|
|
197
|
+
}
|
|
198
|
+
const c = T(M, y === "inner" ? ft : V);
|
|
199
|
+
c.name = y === "outer" ? "cover-display" : `inner-display-${p}`, c.position.set(s, 0, y === "inner" ? Gt : -P - 0.25), y === "outer" && (c.rotation.y = Math.PI), c.userData.display = y, o.add(c);
|
|
200
|
+
}, St = xt / 2 - gt;
|
|
201
|
+
lt(w, -79.85 / 2, St, Wt, "inner", 0), lt(n, (xt / 2 + gt) / 2, St, Wt, "inner", 1);
|
|
202
|
+
const J = it(Y - 0.85, $ - 0.9, 0.08, 8.1, 0.3, z, 0.04);
|
|
203
|
+
J.position.set(-Y / 2, 0, -P - 0.15), w.add(J), lt(w, -Y / 2, 77.1, 112.2, "outer");
|
|
204
|
+
const N = $ / 2 - 15, mt = it(57, 20, 1.6, 10, 10, q, 0.28);
|
|
205
|
+
mt.position.set(Y / 2 + 2, N, -P - 1.8), n.add(mt);
|
|
206
|
+
const Q = (o, s, e, u, y) => {
|
|
207
|
+
const p = T(new ge(o, 48), s);
|
|
208
|
+
return p.rotation.y = Math.PI, p.position.set(e, u, y), n.add(p), p;
|
|
209
|
+
};
|
|
210
|
+
for (const o of [Y / 2 + 19, Y / 2 - 1]) {
|
|
211
|
+
const s = T(new le(8.05, 8.05, 1.7, 64), v);
|
|
212
|
+
s.rotation.x = Math.PI / 2, s.position.set(o, N, -P - 2.55), n.add(s), Q(7.35, z, o, N, -P - 3.43), Q(6.65, ht, o, N, -P - 3.46), Q(2.5, Mt, o, N, -P - 3.48), Q(1.9, ht, o, N, -P - 3.5);
|
|
213
|
+
const e = Q(0.7, Mt, o - 1.1, N + 1.15, -P - 3.52);
|
|
214
|
+
e.scale.y = 0.55;
|
|
215
|
+
}
|
|
216
|
+
Q(2.2, v, Y / 2 - 18, N - 3, -P - 2.11), Q(1.8, dt, Y / 2 - 18, N - 3, -P - 2.15), Q(0.65, z, Y / 2 - 18, N + 3.2, -P - 2.15);
|
|
217
|
+
const H = new _t();
|
|
218
|
+
H.moveTo(0, 3.2), H.bezierCurveTo(-1.5, 4.2, -3.5, 4.3, -4.8, 2.6), H.bezierCurveTo(-6.4, 0.3, -4.4, -4.6, -2.5, -5.4), H.bezierCurveTo(-1.4, -5.9, -0.8, -5, 0, -5), H.bezierCurveTo(1, -5, 1.7, -5.9, 2.8, -5.3), H.bezierCurveTo(3.8, -4.5, 4.6, -3.1, 4.9, -2.1), H.bezierCurveTo(2.3, -1.2, 2.1, 1.5, 4.1, 2.8), H.bezierCurveTo(3, 4.3, 1.5, 4, 0, 3.2);
|
|
219
|
+
const C = new _t();
|
|
220
|
+
C.moveTo(-0.2, 4), C.bezierCurveTo(-0.3, 5.7, 1, 6.9, 2.5, 7.1), C.bezierCurveTo(2.6, 5.6, 1.2, 4, -0.2, 4);
|
|
221
|
+
const yt = T(new qt([H, C], 20), l);
|
|
222
|
+
yt.rotation.y = Math.PI, yt.position.set(Y / 2, -3, -P - 0.16), n.add(yt);
|
|
223
|
+
const nt = (o, s, e, u, y) => {
|
|
224
|
+
const p = v.clone();
|
|
225
|
+
X.push(p);
|
|
226
|
+
const D = ot(s, e, 2.5, 0.27, p);
|
|
227
|
+
D.name = `button-${o}`, D.userData.button = o, D.position.set(u, y, -P / 2), n.add(D), k.set(o, D), B.set(o, D.position.clone());
|
|
228
|
+
const M = ot(s < e ? 4.5 : s, s < e ? e : 4.5, P, 0.1, p);
|
|
229
|
+
f.splice(f.indexOf(M), 1), M.position.set(u + (s < e ? 2 : 0), y + (s < e ? 0 : 2), -P / 2), M.userData.button = o, M.visible = !1, M.updateMatrix(), S.push(M);
|
|
230
|
+
};
|
|
231
|
+
nt("side", 0.7, 13, Y + 0.15, 21), nt("volumeUp", 9.5, 0.65, Y - 25, $ / 2 + 0.12), nt("volumeDown", 9.5, 0.65, Y - 37, $ / 2 + 0.12);
|
|
232
|
+
const Dt = ot(0.35, 12, 2.5, 0.15, rt);
|
|
233
|
+
Dt.position.set(Y - 0.08, -12, -P / 2), n.add(Dt);
|
|
234
|
+
const tt = 32, O = (o, s = !1) => {
|
|
235
|
+
const e = new Jt(), u = new Float32Array((tt + 1) * 2 * 3), y = new Float32Array((tt + 1) * 2 * 2), p = [];
|
|
236
|
+
for (let M = 0; M <= tt; M++) {
|
|
237
|
+
const a = (xt / 2 - gt + 2 * gt * M / tt) / xt;
|
|
238
|
+
if (y.set([1, a, 0, a], M * 4), M < tt) {
|
|
239
|
+
const m = M * 2;
|
|
240
|
+
p.push(m, m + 2, m + 1, m + 2, m + 3, m + 1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
e.setAttribute(
|
|
244
|
+
"position",
|
|
245
|
+
new Ft(u, 3).setUsage(Qt)
|
|
246
|
+
), e.setAttribute("uv", new Ft(y, 2)), e.setIndex(p);
|
|
247
|
+
const D = T(e, o);
|
|
248
|
+
return s && (D.userData.display = "inner"), i.add(D), e;
|
|
249
|
+
}, Z = O(z), Bt = O(ft, !0), at = O(E), kt = [-1, 1].map((o) => {
|
|
250
|
+
const s = new Jt();
|
|
251
|
+
s.setAttribute(
|
|
252
|
+
"position",
|
|
253
|
+
new Ft(new Float32Array((tt + 1) * 2 * 3), 3).setUsage(Qt)
|
|
254
|
+
);
|
|
255
|
+
const e = [];
|
|
256
|
+
for (let y = 0; y < tt; y++) {
|
|
257
|
+
const p = y * 2;
|
|
258
|
+
e.push(
|
|
259
|
+
...o === 1 ? [p, p + 1, p + 2, p + 1, p + 3, p + 2] : [p, p + 2, p + 1, p + 1, p + 2, p + 3]
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
s.setIndex(e);
|
|
263
|
+
const u = T(s, E);
|
|
264
|
+
return u.name = `hinge-cap-${o}`, i.add(u), { geometry: s, edge: o };
|
|
265
|
+
});
|
|
266
|
+
at.setIndex(Array.from(at.getIndex().array).reverse());
|
|
267
|
+
let It;
|
|
268
|
+
const ct = (o) => {
|
|
269
|
+
if (It === o) return;
|
|
270
|
+
It = o;
|
|
271
|
+
const s = wt.degToRad((180 - o) / 2), e = Math.sin(s), u = Math.cos(s);
|
|
272
|
+
for (const [c, x] of [
|
|
273
|
+
[w, 1],
|
|
274
|
+
[n, -1]
|
|
275
|
+
])
|
|
276
|
+
c.rotation.y = x * s, c.position.set(-x * vt * e, 0, vt * (1 - u));
|
|
277
|
+
const y = gt * u + (vt - Gt) * e, p = gt * e + Gt * u + vt * (1 - u), D = 2 * gt / 3, M = 0.45 * u + (P + vt) * e, a = 0.45 * e - P * u + vt * (1 - u), m = -P * (1 - e) - 0.8 * e;
|
|
278
|
+
for (let c = 0; c <= tt; c++) {
|
|
279
|
+
const x = c / tt, F = 1 - x, R = F * F * F * -y + 3 * F * F * x * (-y + u * D) + 3 * F * x * x * (y - u * D) + x * x * x * y, W = p - 3 * F * x * e * D, st = Math.PI * x;
|
|
280
|
+
for (let G = 0; G < 2; G++)
|
|
281
|
+
Bt.getAttribute("position").setXYZ(c * 2 + G, R, (G - 0.5) * Wt, W), Z.getAttribute("position").setXYZ(c * 2 + G, R, (G - 0.5) * ($ - 0.9), W - 0.07), at.getAttribute("position").setXYZ(
|
|
282
|
+
c * 2 + G,
|
|
283
|
+
-M * Math.cos(st),
|
|
284
|
+
(G - 0.5) * ($ - 0.9),
|
|
285
|
+
a + (m - a) * Math.sin(st)
|
|
286
|
+
);
|
|
287
|
+
for (const { geometry: G, edge: Lt } of kt) {
|
|
288
|
+
const t = G.getAttribute("position");
|
|
289
|
+
t.setXYZ(c * 2, R, Lt * ($ / 2 - 0.45), W - 0.07), t.setXYZ(
|
|
290
|
+
c * 2 + 1,
|
|
291
|
+
-M * Math.cos(st),
|
|
292
|
+
Lt * ($ / 2 - 0.45),
|
|
293
|
+
a + (m - a) * Math.sin(st)
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
for (const c of [Z, Bt, at, ...kt.map((x) => x.geometry)])
|
|
298
|
+
c.getAttribute("position").needsUpdate = !0, c.computeVertexNormals(), c.computeBoundingSphere(), c.computeBoundingBox();
|
|
299
|
+
i.updateMatrixWorld(!0);
|
|
300
|
+
};
|
|
301
|
+
return ct(180), {
|
|
302
|
+
device: i,
|
|
303
|
+
hitObjects: f,
|
|
304
|
+
setAngle: ct,
|
|
305
|
+
buttonAnchors: () => [...B].map(([o, s]) => ({
|
|
306
|
+
button: o,
|
|
307
|
+
point: s.clone().applyMatrix4(n.matrixWorld),
|
|
308
|
+
outward: s.clone().add(o === "side" ? new K(10, 0, 0) : new K(0, 10, 0)).applyMatrix4(n.matrixWorld)
|
|
309
|
+
})),
|
|
310
|
+
getBounds: (o) => {
|
|
311
|
+
o.makeEmpty();
|
|
312
|
+
const s = new $t();
|
|
313
|
+
for (const e of f)
|
|
314
|
+
!(e instanceof bt) || e.userData.button || (e.geometry.boundingBox || e.geometry.computeBoundingBox(), s.copy(e.geometry.boundingBox).applyMatrix4(e.matrixWorld), o.union(s));
|
|
315
|
+
return o;
|
|
316
|
+
},
|
|
317
|
+
pick: (o) => {
|
|
318
|
+
const s = o.intersectObjects(f, !1)[0];
|
|
319
|
+
if (s?.object.userData.display || s?.object.userData.button) return s;
|
|
320
|
+
for (const u of S)
|
|
321
|
+
u.matrixWorld.multiplyMatrices(n.matrixWorld, u.matrix);
|
|
322
|
+
const e = o.intersectObjects(S, !1)[0];
|
|
323
|
+
return e && (!s || e.distance <= s.distance) ? e : s;
|
|
324
|
+
},
|
|
325
|
+
// Imported appearances replace the rigid body while live screens and the hinge remain under our control.
|
|
326
|
+
loadAppearance: async (o) => {
|
|
327
|
+
const { GLTFLoader: s } = await import("./GLTFLoader-BQvr_TBF.mjs"), { scene: e } = await ue(new s(), o), u = /* @__PURE__ */ new Set();
|
|
328
|
+
if (e.traverse((a) => {
|
|
329
|
+
if (a instanceof bt) {
|
|
330
|
+
u.add(a.geometry);
|
|
331
|
+
for (const m of Array.isArray(a.material) ? a.material : [a.material]) {
|
|
332
|
+
u.add(m), m instanceof Yt && m.userData.finish === "polished-silver" && Vt(m, g);
|
|
333
|
+
for (const c of Object.values(m))
|
|
334
|
+
c instanceof de && c !== g && u.add(c);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}), U) {
|
|
338
|
+
u.forEach((a) => a.dispose());
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const y = e.getObjectByName("folding-half"), p = e.getObjectByName("stationary-half"), D = /* @__PURE__ */ new Set();
|
|
342
|
+
if (p?.traverse((a) => {
|
|
343
|
+
a instanceof bt && a.userData.button && D.add(a.userData.button);
|
|
344
|
+
}), !y || !p || !["side", "volumeUp", "volumeDown"].every((a) => D.has(a)))
|
|
345
|
+
throw u.forEach((a) => a.dispose()), new Error(
|
|
346
|
+
"Duo appearance requires both body halves and side, volumeUp, and volumeDown button meshes."
|
|
347
|
+
);
|
|
348
|
+
X.push(...u);
|
|
349
|
+
const M = y.children.find(
|
|
350
|
+
(a) => a instanceof bt && (a.userData.sourceDisplay === "outer" || a.material.name === "cover-screen")
|
|
351
|
+
);
|
|
352
|
+
if (M) {
|
|
353
|
+
const a = i.getObjectByName("cover-display"), m = M.geometry.clone().scale(10, 10, 10);
|
|
354
|
+
m.computeBoundingBox();
|
|
355
|
+
const c = m.boundingBox, x = m.getAttribute("position"), F = new Ft(new Float32Array(x.count * 2), 2);
|
|
356
|
+
for (let R = 0; R < x.count; R++)
|
|
357
|
+
F.setXY(
|
|
358
|
+
R,
|
|
359
|
+
(c.max.x - x.getX(R)) / (c.max.x - c.min.x),
|
|
360
|
+
(x.getY(R) - c.min.y) / (c.max.y - c.min.y)
|
|
361
|
+
);
|
|
362
|
+
m.setAttribute("uv", F), a.geometry = m, a.position.copy(M.position).multiplyScalar(10), a.rotation.copy(M.rotation), a.scale.copy(M.scale), X.push(m);
|
|
363
|
+
}
|
|
364
|
+
for (const a of [w, n])
|
|
365
|
+
for (const m of [...a.children]) {
|
|
366
|
+
if (m.userData.display) continue;
|
|
367
|
+
a.remove(m);
|
|
368
|
+
const c = f.indexOf(m);
|
|
369
|
+
c !== -1 && f.splice(c, 1);
|
|
370
|
+
}
|
|
371
|
+
k.clear(), S.length = 0, B.clear(), r.clear();
|
|
372
|
+
for (const a of ["side", "volumeUp", "volumeDown"]) {
|
|
373
|
+
const m = new Pt();
|
|
374
|
+
m.name = `button-${a}`, k.set(a, m), n.add(m);
|
|
375
|
+
}
|
|
376
|
+
for (const [a, m] of [
|
|
377
|
+
[y, w],
|
|
378
|
+
[p, n]
|
|
379
|
+
])
|
|
380
|
+
for (const c of [...a.children]) {
|
|
381
|
+
if (!(c instanceof bt) || c.userData.sourceDisplay || ["inner-screen", "cover-screen"].includes(c.material.name))
|
|
382
|
+
continue;
|
|
383
|
+
c.geometry.scale(10, 10, 10), c.position.multiplyScalar(10), c.geometry.computeBoundingBox();
|
|
384
|
+
const x = c.userData.button;
|
|
385
|
+
x && k.has(x) ? k.get(x).add(c) : m.add(c), f.push(c);
|
|
386
|
+
}
|
|
387
|
+
for (const [a, m] of k) {
|
|
388
|
+
const c = new $t();
|
|
389
|
+
for (const W of m.children) {
|
|
390
|
+
const st = W;
|
|
391
|
+
st.updateMatrix(), c.union(st.geometry.boundingBox.clone().applyMatrix4(st.matrix));
|
|
392
|
+
}
|
|
393
|
+
const x = c.getCenter(new K());
|
|
394
|
+
for (const W of m.children) W.position.sub(x);
|
|
395
|
+
m.position.copy(x), B.set(a, x);
|
|
396
|
+
const F = c.getSize(new K()), R = ot(a === "side" ? 5 : F.x, a === "side" ? F.y : 5, P, 0.1, v);
|
|
397
|
+
f.splice(f.indexOf(R), 1), R.position.copy(x).add(new K(a === "side" ? 2 : 0, a === "side" ? 0 : 2, 0)), R.userData.button = a, R.visible = !1, R.updateMatrix(), S.push(R);
|
|
398
|
+
}
|
|
399
|
+
i.updateMatrixWorld(!0);
|
|
400
|
+
},
|
|
401
|
+
highlightButton: (o, s = !1) => {
|
|
402
|
+
L = o, A = s;
|
|
403
|
+
},
|
|
404
|
+
animateButtons: (o) => {
|
|
405
|
+
let s = !1;
|
|
406
|
+
for (const [e, u] of k) {
|
|
407
|
+
const y = B.get(e), p = e === L ? A ? 0 : 0.5 : 0.16;
|
|
408
|
+
let D = wt.damp(r.get(e) ?? 0.16, p, 22, o);
|
|
409
|
+
Math.abs(D - p) < 1e-3 ? D = p : s = !0, r.set(e, D), u.position.copy(y), u.position[e === "side" ? "x" : "y"] += D;
|
|
410
|
+
}
|
|
411
|
+
return s;
|
|
412
|
+
},
|
|
413
|
+
dispose: () => {
|
|
414
|
+
U = !0, X.forEach((o) => o.dispose());
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function Nt(h, b, g) {
|
|
419
|
+
const i = Math.min(2.5, Math.max(0, g)), w = i <= 0.625 ? i * 0.8 : i <= 1.875 ? 0.5 + (i - 0.625) * 0.2 : 0.75 + (i - 1.875) * 0.4;
|
|
420
|
+
return h + (b - h) * w;
|
|
421
|
+
}
|
|
422
|
+
function Te(h, b, g, i, w) {
|
|
423
|
+
const n = (r) => {
|
|
424
|
+
const L = r.clone().project(g);
|
|
425
|
+
return new ne((L.x + 1) * i / 2, (1 - L.y) * w / 2);
|
|
426
|
+
}, f = new he();
|
|
427
|
+
for (const r of [b.min.x, b.max.x])
|
|
428
|
+
for (const L of [b.min.y, b.max.y])
|
|
429
|
+
for (const A of [b.min.z, b.max.z]) f.expandByPoint(n(new K(r, L, A)));
|
|
430
|
+
const k = h.map(({ button: r, point: L, outward: A }) => {
|
|
431
|
+
const U = n(L), S = n(A).sub(U), X = Math.abs(S.y) >= Math.abs(S.x), v = X ? S.y < 0 ? "top" : "bottom" : S.x < 0 ? "left" : "right";
|
|
432
|
+
return {
|
|
433
|
+
button: r,
|
|
434
|
+
edge: v,
|
|
435
|
+
x: X ? U.x : v === "left" ? f.min.x - 28 : f.max.x + 28,
|
|
436
|
+
y: X ? v === "top" ? f.min.y - 28 : f.max.y + 28 : U.y
|
|
437
|
+
};
|
|
438
|
+
}), B = k.filter((r) => r.button !== "side");
|
|
439
|
+
if (B.length === 2 && B[0].edge === B[1].edge) {
|
|
440
|
+
const r = B[0].edge === "top" || B[0].edge === "bottom" ? "x" : "y";
|
|
441
|
+
if (B.sort((L, A) => L[r] - A[r]), B[1][r] - B[0][r] < 48) {
|
|
442
|
+
const L = (B[0][r] + B[1][r]) / 2;
|
|
443
|
+
B[0][r] = L - 24, B[1][r] = L + 24;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return { guides: k, rect: f, iconSize: ke(f) };
|
|
447
|
+
}
|
|
448
|
+
function Oe(h, b, g) {
|
|
449
|
+
const i = ut(void 0), w = ut(0), [n, f] = oe(), k = Ie(h, b, (A) => {
|
|
450
|
+
A !== void 0 && r(), g(A);
|
|
451
|
+
}), B = ut(k);
|
|
452
|
+
B.current = k;
|
|
453
|
+
const r = () => {
|
|
454
|
+
i.current && (cancelAnimationFrame(w.current), i.current = void 0, k.interacting.current = !1, f(void 0));
|
|
455
|
+
}, L = () => {
|
|
456
|
+
const A = performance.now(), U = i.current, S = U ? Nt(U.from, U.target, (A - U.startedAt) / 1e3) : k.angle, X = (U?.target ?? k.angle) < 90 ? 180 : 0;
|
|
457
|
+
r();
|
|
458
|
+
const v = { from: S, target: X, startedAt: A };
|
|
459
|
+
i.current = v, k.interacting.current = !0, f(X);
|
|
460
|
+
let q = -1 / 0;
|
|
461
|
+
const E = (z) => {
|
|
462
|
+
if (i.current !== v) return;
|
|
463
|
+
const rt = Nt(S, X, (z - A) / 1e3);
|
|
464
|
+
(z - q >= 1e3 / 30 || rt === X) && (q = z, B.current.changeAngle(rt)), rt === X ? r() : w.current = requestAnimationFrame(E);
|
|
465
|
+
};
|
|
466
|
+
w.current = requestAnimationFrame(E);
|
|
467
|
+
};
|
|
468
|
+
return Zt(
|
|
469
|
+
() => () => {
|
|
470
|
+
cancelAnimationFrame(w.current), i.current = void 0, B.current.interacting.current = !1;
|
|
471
|
+
},
|
|
472
|
+
[]
|
|
473
|
+
), {
|
|
474
|
+
...k,
|
|
475
|
+
motion: i,
|
|
476
|
+
target: n,
|
|
477
|
+
fold: L,
|
|
478
|
+
cancelFold: r,
|
|
479
|
+
changeAngle: (A) => {
|
|
480
|
+
r(), k.changeAngle(A);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const Ce = {
|
|
485
|
+
environment: 0.4,
|
|
486
|
+
hemisphere: 1.1,
|
|
487
|
+
key: { intensity: 2.4, position: [-100, 180, 260] },
|
|
488
|
+
rim: { intensity: 0.8, position: [200, -40, -200] }
|
|
489
|
+
};
|
|
490
|
+
function je(h) {
|
|
491
|
+
const b = ut(null), g = ut(/* @__PURE__ */ new Map()), i = ut(h);
|
|
492
|
+
i.current = h;
|
|
493
|
+
const [w, n] = oe(), { angle: f, changeAngle: k, interacting: B, motion: r, target: L, fold: A, cancelFold: U } = Oe(
|
|
494
|
+
h.state.angleDegrees,
|
|
495
|
+
h.setAngle,
|
|
496
|
+
n
|
|
497
|
+
), S = ut(f);
|
|
498
|
+
S.current = f;
|
|
499
|
+
const {
|
|
500
|
+
view: X,
|
|
501
|
+
viewRef: v,
|
|
502
|
+
chooseView: q,
|
|
503
|
+
locked: E,
|
|
504
|
+
lockedRef: z,
|
|
505
|
+
setLocked: rt,
|
|
506
|
+
orbit: ht,
|
|
507
|
+
drag: Mt
|
|
508
|
+
} = me("front"), dt = ut(() => {
|
|
509
|
+
});
|
|
510
|
+
return Zt(() => {
|
|
511
|
+
dt.current();
|
|
512
|
+
}, [f, L, X, E, h.state.orientation]), Zt(() => {
|
|
513
|
+
const l = b.current, V = h.outer, ft = h.inner;
|
|
514
|
+
if (!l || !V || !ft) return;
|
|
515
|
+
const T = new ye(-150, 150, 150, -150, 1, 2e3);
|
|
516
|
+
let it = 1;
|
|
517
|
+
T.position.set(0, 0, 340);
|
|
518
|
+
const ot = be({
|
|
519
|
+
container: l,
|
|
520
|
+
videos: [V, ft],
|
|
521
|
+
maxPixelRatio: 1.5,
|
|
522
|
+
lighting: Ce,
|
|
523
|
+
resize: (t, d) => {
|
|
524
|
+
it = t / d, T.updateProjectionMatrix();
|
|
525
|
+
},
|
|
526
|
+
frame: (t, d) => Lt(t, d)
|
|
527
|
+
});
|
|
528
|
+
if (!ot) {
|
|
529
|
+
n("3D rendering is unavailable in this browser. Enable WebGL to use the folding frame."), i.current.onReady?.();
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
const { renderer: lt, scene: St, invalidate: J } = ot, N = new Pt(), mt = new te(V), Q = new te(ft);
|
|
533
|
+
for (const t of [mt, Q])
|
|
534
|
+
t.colorSpace = ve, t.minFilter = ee, t.magFilter = ee;
|
|
535
|
+
let H = !1;
|
|
536
|
+
const C = Le(mt, Q, ot.environment), { device: yt } = C;
|
|
537
|
+
h.model ? C.loadAppearance(h.model).then(() => J()).catch((t) => {
|
|
538
|
+
H || n(String(t));
|
|
539
|
+
}).finally(() => {
|
|
540
|
+
H || i.current.onReady?.();
|
|
541
|
+
}) : i.current.onReady?.();
|
|
542
|
+
const nt = new Se(
|
|
543
|
+
(t, d) => i.current.button(t, d),
|
|
544
|
+
(t) => n(String(t))
|
|
545
|
+
);
|
|
546
|
+
N.add(yt), St.add(N);
|
|
547
|
+
const Dt = new xe(), tt = new ne();
|
|
548
|
+
let O, Z = S.current, Bt = Z, at = Z, kt = 0, It = !1, ct = 0;
|
|
549
|
+
dt.current = J;
|
|
550
|
+
let o, s;
|
|
551
|
+
const e = (t) => t instanceof Element ? t.closest("[data-duo-button]") : null, u = (t) => {
|
|
552
|
+
s = t;
|
|
553
|
+
for (const d of o?.guides ?? []) {
|
|
554
|
+
const I = g.current.get(d.button);
|
|
555
|
+
I && (I.dataset.visible = String(d.edge === t));
|
|
556
|
+
}
|
|
557
|
+
}, y = (t) => {
|
|
558
|
+
if (i.current.watchOnly) return;
|
|
559
|
+
const d = e(t.target);
|
|
560
|
+
if (d) return { button: d.dataset.duoButton };
|
|
561
|
+
const I = lt.domElement.getBoundingClientRect();
|
|
562
|
+
tt.set(
|
|
563
|
+
(t.clientX - I.left) / I.width * 2 - 1,
|
|
564
|
+
1 - (t.clientY - I.top) / I.height * 2
|
|
565
|
+
), Dt.setFromCamera(tt, T);
|
|
566
|
+
const _ = C.pick(Dt), j = _?.object.userData.button;
|
|
567
|
+
if (j) return { button: j };
|
|
568
|
+
if (!_?.object.userData.display || !_.uv) return;
|
|
569
|
+
const At = i.current.state.displays.find(
|
|
570
|
+
(Tt) => Tt.id === _.object.userData.display
|
|
571
|
+
);
|
|
572
|
+
if (At)
|
|
573
|
+
return { screenId: At.screenId, ...Be(_.uv.x, _.uv.y) };
|
|
574
|
+
}, p = (t) => {
|
|
575
|
+
if (J(), O || t.button !== 0) return;
|
|
576
|
+
e(t.target) || l.focus({ preventScroll: !0 });
|
|
577
|
+
const d = y(t), I = d && "button" in d ? d.button : void 0, _ = De(z.current, !!d && !I, t.altKey);
|
|
578
|
+
if (_ === "ignore" && !I) return;
|
|
579
|
+
const j = _ === "touch" && d && "screenId" in d ? d : void 0;
|
|
580
|
+
O = {
|
|
581
|
+
pointer: t.pointerId,
|
|
582
|
+
button: I,
|
|
583
|
+
...j,
|
|
584
|
+
x: j?.x ?? 0,
|
|
585
|
+
y: j?.y ?? 0,
|
|
586
|
+
clientX: t.clientX,
|
|
587
|
+
clientY: t.clientY
|
|
588
|
+
}, l.setPointerCapture(t.pointerId), I ? (n(void 0), nt.press(I), C.highlightButton(I, !0)) : j && i.current.touch(0, j.screenId, j.x, j.y);
|
|
589
|
+
}, D = (t) => {
|
|
590
|
+
if (J(), !O) {
|
|
591
|
+
const d = y(t), I = d && "button" in d ? d.button : void 0, _ = l.getBoundingClientRect();
|
|
592
|
+
u(
|
|
593
|
+
I ? o?.guides.find((j) => j.button === I)?.edge : o && ze(t.clientX - _.left, t.clientY - _.top, o.rect)
|
|
594
|
+
), lt.domElement.style.cursor = I ? "pointer" : "", lt.domElement.title = I ? Ut[I] : "", C.highlightButton(I);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
if (!(O.pointer !== t.pointerId || O.button)) {
|
|
598
|
+
if (O.screenId) {
|
|
599
|
+
const d = y(t);
|
|
600
|
+
d && "screenId" in d && d.screenId === O.screenId && (O.x = d.x, O.y = d.y, i.current.touch(2, d.screenId, d.x, d.y));
|
|
601
|
+
} else z.current || Mt(t.clientX - O.clientX, t.clientY - O.clientY, 1.4);
|
|
602
|
+
O.clientX = t.clientX, O.clientY = t.clientY;
|
|
603
|
+
}
|
|
604
|
+
}, M = (t) => {
|
|
605
|
+
J(), !(!O || t && O.pointer !== t.pointerId) && (O.button ? (nt.release(), C.highlightButton()) : O.screenId && i.current.touch(1, O.screenId, O.x, O.y), O = void 0, t && D(t));
|
|
606
|
+
}, a = () => {
|
|
607
|
+
J(), O || (C.highlightButton(), u(void 0));
|
|
608
|
+
}, m = (t) => {
|
|
609
|
+
J();
|
|
610
|
+
const d = e(t.target);
|
|
611
|
+
if (!d || i.current.watchOnly || (t.stopPropagation(), t.code !== "Space" && t.code !== "Enter") || (t.preventDefault(), t.repeat)) return;
|
|
612
|
+
const I = d.dataset.duoButton;
|
|
613
|
+
nt.press(I), C.highlightButton(I, !0), d.dataset.pressed = "true";
|
|
614
|
+
}, c = (t) => {
|
|
615
|
+
J();
|
|
616
|
+
const d = e(t.target);
|
|
617
|
+
!d || i.current.watchOnly || (t.stopPropagation(), !(t.code !== "Space" && t.code !== "Enter") && (t.preventDefault(), nt.release(), C.highlightButton(d.dataset.duoButton), d.dataset.pressed = "false"));
|
|
618
|
+
}, x = (t) => {
|
|
619
|
+
const d = e(t.target);
|
|
620
|
+
d && u(o?.guides.find((I) => I.button === d.dataset.duoButton)?.edge);
|
|
621
|
+
}, F = () => {
|
|
622
|
+
J(), M(), nt.release(), C.highlightButton(), u(void 0), g.current.forEach((t) => {
|
|
623
|
+
t.dataset.pressed = "false";
|
|
624
|
+
});
|
|
625
|
+
}, R = (t) => {
|
|
626
|
+
l.contains(t.relatedTarget) ? e(t.target) && (nt.release(), C.highlightButton()) : F();
|
|
627
|
+
};
|
|
628
|
+
l.addEventListener("pointerleave", a), l.addEventListener("pointerdown", p), l.addEventListener("pointermove", D), l.addEventListener("pointerup", M), l.addEventListener("pointercancel", M), l.addEventListener("lostpointercapture", M), l.addEventListener("keydown", m), l.addEventListener("keyup", c), l.addEventListener("focusin", x), l.addEventListener("focusout", R), window.addEventListener("blur", F);
|
|
629
|
+
const W = new $t(), st = new K(), G = new K(), Lt = (t, d) => {
|
|
630
|
+
at !== S.current && (Bt = Z, at = S.current, kt = t, It = B.current);
|
|
631
|
+
const I = r.current;
|
|
632
|
+
Z = I ? Nt(I.from, I.target, (t - I.startedAt) / 1e3) : It ? wt.damp(Z, at, 18, d) : Nt(Bt, at, (t - kt) / 1e3), Math.abs(Z - S.current) < 1e-3 && (Z = S.current), C.setAngle(Z);
|
|
633
|
+
const j = (1 - wt.smoothstep(Z, 15, 110)) * Math.PI / 2 + (v.current === "back" ? Math.PI : 0);
|
|
634
|
+
ct = wt.damp(ct, j, 12, d), Math.abs(ct - j) < 1e-3 && (ct = j), N.rotation.set(
|
|
635
|
+
ht.pitch + (v.current === "table" ? -0.35 : v.current === "book" ? 0.2 : 0),
|
|
636
|
+
ht.yaw + (v.current === "book" ? -0.2 : 0),
|
|
637
|
+
0
|
|
638
|
+
), yt.rotation.set(
|
|
639
|
+
0,
|
|
640
|
+
ct,
|
|
641
|
+
{ portrait: 0, pud: Math.PI, "landscape-left": Math.PI / 2, "landscape-right": -Math.PI / 2 }[i.current.state.orientation] ?? 0,
|
|
642
|
+
"ZYX"
|
|
643
|
+
), N.position.set(0, 0, 0), N.updateMatrixWorld(!0), C.getBounds(W).getCenter(st), W.getSize(G), N.position.copy(st).negate();
|
|
644
|
+
const At = l.clientWidth, Tt = l.clientHeight, se = Math.max(0.4, 1 - 108 / At), re = Math.min(0.8, Math.max(0.35, 1 - 108 / Tt)), Ot = Math.max(G.y / (2 * re), G.x / (2 * it * se));
|
|
645
|
+
T.top = wt.damp(T.top, Ot, 14, d), Math.abs(T.top - Ot) < 1e-3 && (T.top = Ot), T.bottom = -T.top, T.left = -T.top * it, T.right = T.top * it, T.updateProjectionMatrix();
|
|
646
|
+
const ie = C.animateButtons(d);
|
|
647
|
+
lt.render(St, T), C.getBounds(W), o = Te(C.buttonAnchors(), W, T, At, Tt);
|
|
648
|
+
for (const Ct of o.guides) {
|
|
649
|
+
const Et = g.current.get(Ct.button);
|
|
650
|
+
Et && (Et.style.left = `${Ct.x}px`, Et.style.top = `${Ct.y}px`, Et.style.setProperty("--duo-hardware-icon-size", `${o.iconSize}px`), Et.dataset.visible = String(Ct.edge === s));
|
|
651
|
+
}
|
|
652
|
+
return !!r.current || Z !== S.current || ct !== j || T.top !== Ot || ie;
|
|
653
|
+
};
|
|
654
|
+
return ot.start(), () => {
|
|
655
|
+
H = !0, dt.current = () => {
|
|
656
|
+
}, M(), nt.release(), window.removeEventListener("blur", F), l.removeEventListener("pointerleave", a), l.removeEventListener("pointerdown", p), l.removeEventListener("pointermove", D), l.removeEventListener("pointerup", M), l.removeEventListener("pointercancel", M), l.removeEventListener("lostpointercapture", M), l.removeEventListener("keydown", m), l.removeEventListener("keyup", c), l.removeEventListener("focusin", x), l.removeEventListener("focusout", R), C.dispose(), mt.dispose(), Q.dispose(), ot.dispose();
|
|
657
|
+
};
|
|
658
|
+
}, [h.outer, h.inner, h.model]), /* @__PURE__ */ Rt("div", { className: "rc-duo", children: [
|
|
659
|
+
/* @__PURE__ */ pt(
|
|
660
|
+
"div",
|
|
661
|
+
{
|
|
662
|
+
ref: b,
|
|
663
|
+
className: "rc-duo-stage",
|
|
664
|
+
"data-position-locked": E,
|
|
665
|
+
tabIndex: 0,
|
|
666
|
+
role: "application",
|
|
667
|
+
"aria-label": "iPhone Duo simulator. Touch the screen to control iOS. Drag the frame or background to rotate when position is unlocked.",
|
|
668
|
+
onKeyDown: h.onKeyDown,
|
|
669
|
+
onKeyUp: h.onKeyUp,
|
|
670
|
+
children: Object.keys(Ut).map((l) => /* @__PURE__ */ pt(
|
|
671
|
+
"button",
|
|
672
|
+
{
|
|
673
|
+
disabled: h.watchOnly,
|
|
674
|
+
ref: (V) => {
|
|
675
|
+
V ? g.current.set(l, V) : g.current.delete(l);
|
|
676
|
+
},
|
|
677
|
+
type: "button",
|
|
678
|
+
className: "rc-duo-hardware",
|
|
679
|
+
"data-duo-button": l,
|
|
680
|
+
"data-visible": "false",
|
|
681
|
+
"aria-label": Ut[l],
|
|
682
|
+
title: Ut[l],
|
|
683
|
+
children: /* @__PURE__ */ pt(Ae, { button: l })
|
|
684
|
+
},
|
|
685
|
+
l
|
|
686
|
+
))
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
/* @__PURE__ */ Rt(
|
|
690
|
+
Ee,
|
|
691
|
+
{
|
|
692
|
+
watchOnly: h.watchOnly,
|
|
693
|
+
angle: f,
|
|
694
|
+
onFold: A,
|
|
695
|
+
foldTarget: L,
|
|
696
|
+
onHingeDrag: U,
|
|
697
|
+
changeAngle: k,
|
|
698
|
+
interacting: B,
|
|
699
|
+
rotate: () => {
|
|
700
|
+
h.setOrientation(h.state.orientation === "portrait" ? "landscape-left" : "portrait").catch((l) => n(String(l)));
|
|
701
|
+
},
|
|
702
|
+
children: [
|
|
703
|
+
["front", "book", "table", "back"].map((l) => /* @__PURE__ */ pt(
|
|
704
|
+
"button",
|
|
705
|
+
{
|
|
706
|
+
disabled: h.watchOnly && (l === "book" || l === "table"),
|
|
707
|
+
"aria-pressed": X === l,
|
|
708
|
+
onClick: () => {
|
|
709
|
+
q(l), dt.current(), l === "book" && h.setOrientation("portrait").then(() => k(110)).catch((V) => n(String(V))), l === "table" && h.setOrientation("landscape-left").then(() => k(110)).catch((V) => n(String(V)));
|
|
710
|
+
},
|
|
711
|
+
children: l === "table" ? "Laptop view" : l[0].toUpperCase() + l.slice(1)
|
|
712
|
+
},
|
|
713
|
+
l
|
|
714
|
+
)),
|
|
715
|
+
/* @__PURE__ */ Rt(
|
|
716
|
+
"button",
|
|
717
|
+
{
|
|
718
|
+
className: "rc-duo-lock",
|
|
719
|
+
"aria-label": "Lock position",
|
|
720
|
+
"aria-pressed": E,
|
|
721
|
+
title: E ? "Position is locked. Screen touches still control iOS." : "Drag the frame or background to rotate. Alt-drag rotates from the screen.",
|
|
722
|
+
onClick: () => rt(!E),
|
|
723
|
+
children: [
|
|
724
|
+
/* @__PURE__ */ Rt("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
|
|
725
|
+
/* @__PURE__ */ pt("rect", { x: "4", y: "9", width: "12", height: "9", rx: "2", stroke: "currentColor", strokeWidth: "1.6" }),
|
|
726
|
+
/* @__PURE__ */ pt(
|
|
727
|
+
"path",
|
|
728
|
+
{
|
|
729
|
+
d: E ? "M6 9V6a4 4 0 0 1 8 0v3" : "M6 9V6a4 4 0 0 1 8 0",
|
|
730
|
+
stroke: "currentColor",
|
|
731
|
+
strokeWidth: "1.6",
|
|
732
|
+
strokeLinecap: "round"
|
|
733
|
+
}
|
|
734
|
+
)
|
|
735
|
+
] }),
|
|
736
|
+
E ? "Position locked" : "Lock position"
|
|
737
|
+
]
|
|
738
|
+
}
|
|
739
|
+
)
|
|
740
|
+
]
|
|
741
|
+
}
|
|
742
|
+
),
|
|
743
|
+
w && /* @__PURE__ */ pt("div", { role: "alert", className: "rc-duo-error", children: w })
|
|
744
|
+
] });
|
|
745
|
+
}
|
|
746
|
+
export {
|
|
747
|
+
je as default
|
|
748
|
+
};
|