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