bravais 0.2.1 → 0.3.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/CHANGELOG.md +14 -0
- package/README.md +21 -0
- package/dist/bravais.js +800 -608
- package/dist/bravais.js.map +1 -1
- package/dist/types/cif/errors.d.ts +2 -1
- package/dist/types/cif/structure.d.ts +6 -8
- package/dist/types/index.d.ts +2 -0
- package/dist/types/structure/elements.d.ts +2 -0
- package/dist/types/structure/errors.d.ts +8 -0
- package/dist/types/structure/from-data.d.ts +57 -0
- package/dist/types/structure/sites.d.ts +19 -0
- package/dist/types/structure/types.d.ts +14 -3
- package/dist/types/symmetry/moyo.d.ts +4 -4
- package/dist/types/symmetry/resolve.d.ts +12 -9
- package/package.json +1 -1
package/dist/bravais.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import { ACESFilmicToneMapping as e, AlwaysStencilFunc as t, AmbientLight as n, Box3 as r, BoxGeometry as i, BufferGeometry as a, CanvasTexture as o, Color as s, ConeGeometry as c, Controls as l, CylinderGeometry as u, DataTexture as d, DirectionalLight as f, DoubleSide as p, EqualStencilFunc as m, Float32BufferAttribute as h, FloatType as g, Fog as ee, Group as _, InstancedMesh as v, LineBasicMaterial as y, LineSegments as
|
|
2
|
-
//#region src/
|
|
3
|
-
var
|
|
1
|
+
import { ACESFilmicToneMapping as e, AlwaysStencilFunc as t, AmbientLight as n, Box3 as r, BoxGeometry as i, BufferGeometry as a, CanvasTexture as o, Color as s, ConeGeometry as c, Controls as l, CylinderGeometry as u, DataTexture as d, DirectionalLight as f, DoubleSide as p, EqualStencilFunc as m, Float32BufferAttribute as h, FloatType as g, Fog as ee, Group as _, InstancedMesh as v, LineBasicMaterial as y, LineSegments as te, LinearFilter as ne, LinearMipmapLinearFilter as re, MOUSE as b, MathUtils as ie, Matrix4 as ae, Mesh as x, MeshStandardMaterial as S, NearestFilter as C, NotEqualStencilFunc as oe, Object3D as w, OrthographicCamera as T, PlaneGeometry as se, Quaternion as E, RGBAFormat as ce, ReplaceStencilOp as le, SRGBColorSpace as ue, Scene as de, SphereGeometry as fe, Sprite as pe, SpriteMaterial as me, Vector2 as D, Vector3 as O, WebGLRenderer as he } from "three";
|
|
2
|
+
//#region src/structure/errors.ts
|
|
3
|
+
var k = class extends Error {
|
|
4
|
+
constructor(e) {
|
|
5
|
+
super(e), this.name = "StructureError";
|
|
6
|
+
}
|
|
7
|
+
}, A = class extends k {
|
|
8
|
+
constructor(e) {
|
|
9
|
+
super(e), this.name = "StructureDataError";
|
|
10
|
+
}
|
|
11
|
+
}, j = class extends Error {
|
|
4
12
|
line;
|
|
5
13
|
constructor(e, t) {
|
|
6
14
|
super(`CIF line ${t}: ${e}`), this.name = "CifSyntaxError", this.line = t;
|
|
7
15
|
}
|
|
8
|
-
},
|
|
16
|
+
}, M = class extends k {
|
|
9
17
|
constructor(e) {
|
|
10
18
|
super(e), this.name = "CifStructureError";
|
|
11
19
|
}
|
|
12
20
|
};
|
|
13
21
|
//#endregion
|
|
14
22
|
//#region src/cif/tokenizer.ts
|
|
15
|
-
function
|
|
23
|
+
function ge(e) {
|
|
16
24
|
return e === " " || e === " " || e === "\r" || e === "\n";
|
|
17
25
|
}
|
|
18
|
-
function
|
|
26
|
+
function _e(e, t) {
|
|
19
27
|
let n = e.toLowerCase();
|
|
20
28
|
return e.startsWith("_") ? {
|
|
21
29
|
kind: "tag",
|
|
@@ -43,7 +51,7 @@ function pe(e, t) {
|
|
|
43
51
|
line: t
|
|
44
52
|
};
|
|
45
53
|
}
|
|
46
|
-
function
|
|
54
|
+
function ve(e) {
|
|
47
55
|
let t = [], n = e.split(/\r\n|\r|\n/), r = 0;
|
|
48
56
|
for (; r < n.length;) {
|
|
49
57
|
let e = n[r] ?? "", i = r + 1;
|
|
@@ -60,7 +68,7 @@ function me(e) {
|
|
|
60
68
|
}
|
|
61
69
|
a.push(e), r += 1;
|
|
62
70
|
}
|
|
63
|
-
if (!o) throw new
|
|
71
|
+
if (!o) throw new j("unterminated text field", i);
|
|
64
72
|
t.push({
|
|
65
73
|
kind: "value",
|
|
66
74
|
text: a.join("\n"),
|
|
@@ -71,7 +79,7 @@ function me(e) {
|
|
|
71
79
|
let a = 0;
|
|
72
80
|
for (; a < e.length;) {
|
|
73
81
|
let n = e.charAt(a);
|
|
74
|
-
if (
|
|
82
|
+
if (ge(n)) {
|
|
75
83
|
a += 1;
|
|
76
84
|
continue;
|
|
77
85
|
}
|
|
@@ -80,15 +88,15 @@ function me(e) {
|
|
|
80
88
|
let r = a + 1;
|
|
81
89
|
for (; r < e.length;) {
|
|
82
90
|
let t = e.indexOf(n, r);
|
|
83
|
-
if (t === -1) throw new
|
|
91
|
+
if (t === -1) throw new j("unterminated quoted string", i);
|
|
84
92
|
let a = e.charAt(t + 1);
|
|
85
|
-
if (t + 1 >= e.length ||
|
|
93
|
+
if (t + 1 >= e.length || ge(a)) {
|
|
86
94
|
r = t;
|
|
87
95
|
break;
|
|
88
96
|
}
|
|
89
97
|
r = t + 1;
|
|
90
98
|
}
|
|
91
|
-
if (r >= e.length) throw new
|
|
99
|
+
if (r >= e.length) throw new j("unterminated quoted string", i);
|
|
92
100
|
t.push({
|
|
93
101
|
kind: "value",
|
|
94
102
|
text: e.slice(a + 1, r),
|
|
@@ -97,8 +105,8 @@ function me(e) {
|
|
|
97
105
|
continue;
|
|
98
106
|
}
|
|
99
107
|
let r = a;
|
|
100
|
-
for (; r < e.length && !
|
|
101
|
-
t.push(
|
|
108
|
+
for (; r < e.length && !ge(e.charAt(r));) r += 1;
|
|
109
|
+
t.push(_e(e.slice(a, r), i)), a = r;
|
|
102
110
|
}
|
|
103
111
|
r += 1;
|
|
104
112
|
}
|
|
@@ -106,10 +114,10 @@ function me(e) {
|
|
|
106
114
|
}
|
|
107
115
|
//#endregion
|
|
108
116
|
//#region src/cif/parser.ts
|
|
109
|
-
function
|
|
117
|
+
function ye(e) {
|
|
110
118
|
return typeof e == "string" ? [e] : e;
|
|
111
119
|
}
|
|
112
|
-
var
|
|
120
|
+
var be = class {
|
|
113
121
|
name;
|
|
114
122
|
items = /* @__PURE__ */ new Map();
|
|
115
123
|
loops = [];
|
|
@@ -117,41 +125,41 @@ var ge = class {
|
|
|
117
125
|
this.name = e;
|
|
118
126
|
}
|
|
119
127
|
get(e) {
|
|
120
|
-
for (let t of
|
|
128
|
+
for (let t of ye(e)) {
|
|
121
129
|
let e = this.items.get(t.toLowerCase());
|
|
122
130
|
if (e !== void 0) return e;
|
|
123
131
|
}
|
|
124
132
|
return null;
|
|
125
133
|
}
|
|
126
134
|
findLoop(e) {
|
|
127
|
-
for (let t of
|
|
135
|
+
for (let t of ye(e)) {
|
|
128
136
|
let e = t.toLowerCase(), n = this.loops.find((t) => t.tags.includes(e));
|
|
129
137
|
if (n) return n;
|
|
130
138
|
}
|
|
131
139
|
return null;
|
|
132
140
|
}
|
|
133
141
|
};
|
|
134
|
-
function
|
|
135
|
-
for (let n of
|
|
142
|
+
function N(e, t) {
|
|
143
|
+
for (let n of ye(t)) {
|
|
136
144
|
let t = e.tags.indexOf(n.toLowerCase());
|
|
137
145
|
if (t !== -1) return e.rows.map((e) => e[t] ?? "?");
|
|
138
146
|
}
|
|
139
147
|
return null;
|
|
140
148
|
}
|
|
141
|
-
function
|
|
149
|
+
function P(e) {
|
|
142
150
|
return e === "?" || e === ".";
|
|
143
151
|
}
|
|
144
|
-
function
|
|
145
|
-
if (e == null ||
|
|
152
|
+
function F(e) {
|
|
153
|
+
if (e == null || P(e)) return null;
|
|
146
154
|
let t = e.replace(/\(\d+\)$/, "").trim();
|
|
147
155
|
return /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(t) ? Number(t) : null;
|
|
148
156
|
}
|
|
149
|
-
function
|
|
157
|
+
function xe(e) {
|
|
150
158
|
return e === void 0 || e.kind !== "value";
|
|
151
159
|
}
|
|
152
|
-
function
|
|
153
|
-
let t =
|
|
154
|
-
if (r || (r = new
|
|
160
|
+
function Se(e) {
|
|
161
|
+
let t = ve(e), n = [], r = null, i = 0, a = 0, o = (e) => {
|
|
162
|
+
if (r || (r = new be(""), n.push(r)), a > 0) throw new j(`unexpected ${e.kind} inside a save frame`, e.line);
|
|
155
163
|
return r;
|
|
156
164
|
};
|
|
157
165
|
for (; i < t.length;) {
|
|
@@ -159,7 +167,7 @@ function ve(e) {
|
|
|
159
167
|
if (!e) break;
|
|
160
168
|
switch (e.kind) {
|
|
161
169
|
case "data":
|
|
162
|
-
r = new
|
|
170
|
+
r = new be(e.text), n.push(r), a = 0, i += 1;
|
|
163
171
|
break;
|
|
164
172
|
case "save":
|
|
165
173
|
a = e.text === "" ? Math.max(0, a - 1) : a + 1, i += 1;
|
|
@@ -173,18 +181,18 @@ function ve(e) {
|
|
|
173
181
|
break;
|
|
174
182
|
}
|
|
175
183
|
let n = o(e), r = t[i + 1];
|
|
176
|
-
if (!r || r.kind !== "value") throw new
|
|
184
|
+
if (!r || r.kind !== "value") throw new j(`tag ${e.text} has no value`, e.line);
|
|
177
185
|
n.items.set(e.text.toLowerCase(), r.text), i += 2;
|
|
178
186
|
break;
|
|
179
187
|
}
|
|
180
188
|
case "loop": {
|
|
181
189
|
let n = [];
|
|
182
190
|
for (i += 1; t[i]?.kind === "tag";) n.push(t[i].text.toLowerCase()), i += 1;
|
|
183
|
-
if (n.length === 0) throw new
|
|
191
|
+
if (n.length === 0) throw new j("loop_ without tags", e.line);
|
|
184
192
|
let r = [];
|
|
185
|
-
for (; !
|
|
193
|
+
for (; !xe(t[i]);) r.push(t[i].text), i += 1;
|
|
186
194
|
if (a > 0) break;
|
|
187
|
-
if (r.length % n.length !== 0) throw new
|
|
195
|
+
if (r.length % n.length !== 0) throw new j(`loop with ${n.length} tags has ${r.length} values`, e.line);
|
|
188
196
|
let s = [];
|
|
189
197
|
for (let e = 0; e < r.length; e += n.length) s.push(r.slice(e, e + n.length));
|
|
190
198
|
o(e).loops.push({
|
|
@@ -193,60 +201,113 @@ function ve(e) {
|
|
|
193
201
|
});
|
|
194
202
|
break;
|
|
195
203
|
}
|
|
196
|
-
case "value": throw new
|
|
204
|
+
case "value": throw new j(`unexpected value ${JSON.stringify(e.text)}`, e.line);
|
|
197
205
|
}
|
|
198
206
|
}
|
|
199
207
|
return { blocks: n };
|
|
200
208
|
}
|
|
201
209
|
//#endregion
|
|
202
210
|
//#region src/structure/elements.ts
|
|
203
|
-
var
|
|
204
|
-
function
|
|
205
|
-
return
|
|
211
|
+
var Ce = /* @__PURE__ */ "H.He.Li.Be.B.C.N.O.F.Ne.Na.Mg.Al.Si.P.S.Cl.Ar.K.Ca.Sc.Ti.V.Cr.Mn.Fe.Co.Ni.Cu.Zn.Ga.Ge.As.Se.Br.Kr.Rb.Sr.Y.Zr.Nb.Mo.Tc.Ru.Rh.Pd.Ag.Cd.In.Sn.Sb.Te.I.Xe.Cs.Ba.La.Ce.Pr.Nd.Pm.Sm.Eu.Gd.Tb.Dy.Ho.Er.Tm.Yb.Lu.Hf.Ta.W.Re.Os.Ir.Pt.Au.Hg.Tl.Pb.Bi.Po.At.Rn.Fr.Ra.Ac.Th.Pa.U.Np.Pu.Am.Cm.Bk.Cf.Es.Fm.Md.No.Lr.Rf.Db.Sg.Bh.Hs.Mt.Ds.Rg.Cn.Nh.Fl.Mc.Lv.Ts.Og".split("."), we = new Set(Ce), Te = "D";
|
|
212
|
+
function Ee(e) {
|
|
213
|
+
return we.has(e) || e === Te;
|
|
206
214
|
}
|
|
207
|
-
function
|
|
215
|
+
function De(e) {
|
|
208
216
|
return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
209
217
|
}
|
|
210
|
-
function
|
|
218
|
+
function Oe(e) {
|
|
211
219
|
let t = e.match(/^[A-Za-z]{1,2}/)?.[0];
|
|
212
220
|
if (!t) return null;
|
|
213
|
-
let n =
|
|
214
|
-
if (t.length === 2 &&
|
|
221
|
+
let n = De(t);
|
|
222
|
+
if (t.length === 2 && Ee(n)) return n;
|
|
215
223
|
let r = t.charAt(0).toUpperCase();
|
|
216
|
-
return
|
|
224
|
+
return Ee(r) ? r : null;
|
|
217
225
|
}
|
|
218
|
-
function
|
|
219
|
-
return e ===
|
|
226
|
+
function ke(e) {
|
|
227
|
+
return e === Te ? "H" : e;
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/structure/lattice.ts
|
|
231
|
+
var Ae = Math.PI / 180;
|
|
232
|
+
function je(e, t, n) {
|
|
233
|
+
return Math.min(n, Math.max(t, e));
|
|
234
|
+
}
|
|
235
|
+
function Me(e) {
|
|
236
|
+
let { a: t, b: n, c: r } = e, i = e.alpha * Ae, a = e.beta * Ae, o = e.gamma * Ae, s = Math.cos(i), c = Math.cos(a), l = Math.cos(o), u = Math.sin(i), d = Math.sin(a), f = Math.acos(je((s * c - l) / (u * d), -1, 1)), p = [
|
|
237
|
+
t * d,
|
|
238
|
+
0,
|
|
239
|
+
t * c
|
|
240
|
+
], m = [
|
|
241
|
+
-n * u * Math.cos(f),
|
|
242
|
+
n * u * Math.sin(f),
|
|
243
|
+
n * s
|
|
244
|
+
], h = [
|
|
245
|
+
0,
|
|
246
|
+
0,
|
|
247
|
+
r
|
|
248
|
+
];
|
|
249
|
+
return {
|
|
250
|
+
...e,
|
|
251
|
+
vectors: [
|
|
252
|
+
p,
|
|
253
|
+
m,
|
|
254
|
+
h
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function Ne(e) {
|
|
259
|
+
let [t, n, r] = e, i = (e) => Math.hypot(e[0], e[1], e[2]), a = (e, t) => Math.acos(je((e[0] * t[0] + e[1] * t[1] + e[2] * t[2]) / (i(e) * i(t)), -1, 1)) / Ae;
|
|
260
|
+
return {
|
|
261
|
+
a: i(t),
|
|
262
|
+
b: i(n),
|
|
263
|
+
c: i(r),
|
|
264
|
+
alpha: a(n, r),
|
|
265
|
+
beta: a(t, r),
|
|
266
|
+
gamma: a(t, n),
|
|
267
|
+
vectors: e
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function Pe(e, t) {
|
|
271
|
+
let [n, r, i] = e.vectors, [a, o, s] = t;
|
|
272
|
+
return [
|
|
273
|
+
a * n[0] + o * r[0] + s * i[0],
|
|
274
|
+
a * n[1] + o * r[1] + s * i[1],
|
|
275
|
+
a * n[2] + o * r[2] + s * i[2]
|
|
276
|
+
];
|
|
277
|
+
}
|
|
278
|
+
function Fe(e, t) {
|
|
279
|
+
let n = e[0] - t[0], r = e[1] - t[1], i = e[2] - t[2];
|
|
280
|
+
return Math.sqrt(n * n + r * r + i * i);
|
|
220
281
|
}
|
|
221
282
|
//#endregion
|
|
222
283
|
//#region src/structure/fractional.ts
|
|
223
|
-
var
|
|
224
|
-
function
|
|
284
|
+
var Ie = .001, Le = 1e-9;
|
|
285
|
+
function I(e, t = Le) {
|
|
225
286
|
let n = e - Math.floor(e);
|
|
226
287
|
return n >= 1 - t ? 0 : n;
|
|
227
288
|
}
|
|
228
|
-
function
|
|
289
|
+
function Re(e) {
|
|
229
290
|
return [
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
291
|
+
I(e[0]),
|
|
292
|
+
I(e[1]),
|
|
293
|
+
I(e[2])
|
|
233
294
|
];
|
|
234
295
|
}
|
|
235
|
-
function
|
|
296
|
+
function ze(e, t, n) {
|
|
236
297
|
for (let r = 0; r < 3; r += 1) {
|
|
237
298
|
let i = Math.abs(e[r] - t[r]);
|
|
238
299
|
if (i -= Math.round(i), Math.abs(i) > n) return !1;
|
|
239
300
|
}
|
|
240
301
|
return !0;
|
|
241
302
|
}
|
|
242
|
-
var
|
|
243
|
-
function
|
|
244
|
-
return Math.floor(
|
|
303
|
+
var L = 100;
|
|
304
|
+
function Be(e) {
|
|
305
|
+
return Math.floor(I(e) * L) % L;
|
|
245
306
|
}
|
|
246
|
-
function
|
|
247
|
-
return (e *
|
|
307
|
+
function Ve(e, t, n) {
|
|
308
|
+
return (e * L + t) * L + n;
|
|
248
309
|
}
|
|
249
|
-
var
|
|
310
|
+
var He = class {
|
|
250
311
|
tolerance;
|
|
251
312
|
buckets = /* @__PURE__ */ new Map();
|
|
252
313
|
positions = [];
|
|
@@ -256,25 +317,25 @@ var je = class {
|
|
|
256
317
|
add(e) {
|
|
257
318
|
let t = this.positions.length;
|
|
258
319
|
this.positions.push(e);
|
|
259
|
-
let n =
|
|
320
|
+
let n = Ve(Be(e[0]), Be(e[1]), Be(e[2])), r = this.buckets.get(n);
|
|
260
321
|
return r ? r.push(t) : this.buckets.set(n, [t]), t;
|
|
261
322
|
}
|
|
262
323
|
near(e) {
|
|
263
|
-
let t =
|
|
324
|
+
let t = Re(e), [n, r, i] = t.map(Be), a = [];
|
|
264
325
|
for (let e = -1; e <= 1; e += 1) {
|
|
265
|
-
let o = (n + e +
|
|
326
|
+
let o = (n + e + L) % L;
|
|
266
327
|
for (let e = -1; e <= 1; e += 1) {
|
|
267
|
-
let n = (r + e +
|
|
328
|
+
let n = (r + e + L) % L;
|
|
268
329
|
for (let e = -1; e <= 1; e += 1) {
|
|
269
|
-
let r = (i + e +
|
|
270
|
-
for (let e of this.buckets.get(
|
|
330
|
+
let r = (i + e + L) % L;
|
|
331
|
+
for (let e of this.buckets.get(Ve(o, n, r)) ?? []) ze(this.positions[e], t, this.tolerance) && a.push(e);
|
|
271
332
|
}
|
|
272
333
|
}
|
|
273
334
|
}
|
|
274
335
|
return a.sort((e, t) => e - t);
|
|
275
336
|
}
|
|
276
337
|
};
|
|
277
|
-
function
|
|
338
|
+
function Ue(e, t) {
|
|
278
339
|
let n = e.rotation, [r, i, a] = t, o = e.translation;
|
|
279
340
|
return [
|
|
280
341
|
(n[0] ?? 0) * r + (n[1] ?? 0) * i + (n[2] ?? 0) * a + o[0],
|
|
@@ -283,93 +344,75 @@ function Me(e, t) {
|
|
|
283
344
|
];
|
|
284
345
|
}
|
|
285
346
|
//#endregion
|
|
286
|
-
//#region src/structure/
|
|
287
|
-
var
|
|
288
|
-
function
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
0,
|
|
295
|
-
t * c
|
|
296
|
-
], m = [
|
|
297
|
-
-n * u * Math.cos(f),
|
|
298
|
-
n * u * Math.sin(f),
|
|
299
|
-
n * s
|
|
300
|
-
], h = [
|
|
301
|
-
0,
|
|
302
|
-
0,
|
|
303
|
-
r
|
|
304
|
-
];
|
|
305
|
-
return {
|
|
306
|
-
...e,
|
|
307
|
-
vectors: [
|
|
308
|
-
p,
|
|
309
|
-
m,
|
|
310
|
-
h
|
|
311
|
-
]
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
function Fe(e) {
|
|
315
|
-
let [t, n, r] = e, i = (e) => Math.hypot(e[0], e[1], e[2]), a = (e, t) => Math.acos(Ne((e[0] * t[0] + e[1] * t[1] + e[2] * t[2]) / (i(e) * i(t)), -1, 1)) / V;
|
|
316
|
-
return {
|
|
317
|
-
a: i(t),
|
|
318
|
-
b: i(n),
|
|
319
|
-
c: i(r),
|
|
320
|
-
alpha: a(n, r),
|
|
321
|
-
beta: a(t, r),
|
|
322
|
-
gamma: a(t, n),
|
|
323
|
-
vectors: e
|
|
324
|
-
};
|
|
347
|
+
//#region src/structure/sites.ts
|
|
348
|
+
var We = 1e-4;
|
|
349
|
+
function Ge(e, t, n) {
|
|
350
|
+
let r = e.find((e) => e.element === t);
|
|
351
|
+
r ? r.occupancy += n : e.push({
|
|
352
|
+
element: t,
|
|
353
|
+
occupancy: n
|
|
354
|
+
}), e.sort((e, t) => t.occupancy - e.occupancy);
|
|
325
355
|
}
|
|
326
|
-
function
|
|
327
|
-
let
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
a * n[2] + o * r[2] + s * i[2]
|
|
332
|
-
];
|
|
356
|
+
function Ke(e) {
|
|
357
|
+
for (let t of e) {
|
|
358
|
+
let e = t.species.reduce((e, t) => e + t.occupancy, 0);
|
|
359
|
+
if (e > 1.000001) for (let n of t.species) n.occupancy /= e;
|
|
360
|
+
}
|
|
333
361
|
}
|
|
334
|
-
function
|
|
335
|
-
let
|
|
336
|
-
|
|
362
|
+
function qe(e) {
|
|
363
|
+
let t = [], n = new He(We);
|
|
364
|
+
for (let r of e) {
|
|
365
|
+
let e = [
|
|
366
|
+
I(r.fractional[0]),
|
|
367
|
+
I(r.fractional[1]),
|
|
368
|
+
I(r.fractional[2])
|
|
369
|
+
], [i] = n.near(e);
|
|
370
|
+
i === void 0 ? (n.add(e), t.push({
|
|
371
|
+
label: r.label,
|
|
372
|
+
species: [{
|
|
373
|
+
element: r.element,
|
|
374
|
+
occupancy: r.occupancy
|
|
375
|
+
}],
|
|
376
|
+
fractional: e
|
|
377
|
+
})) : Ge(t[i].species, r.element, r.occupancy);
|
|
378
|
+
}
|
|
379
|
+
return Ke(t), t;
|
|
337
380
|
}
|
|
338
381
|
//#endregion
|
|
339
382
|
//#region src/cif/symmetry-operations.ts
|
|
340
|
-
var
|
|
383
|
+
var Je = [
|
|
341
384
|
"x",
|
|
342
385
|
"y",
|
|
343
386
|
"z"
|
|
344
387
|
];
|
|
345
|
-
function
|
|
388
|
+
function Ye(e) {
|
|
346
389
|
if (e === "" || e === "+") return 1;
|
|
347
390
|
if (e === "-") return -1;
|
|
348
391
|
let t = e.match(/^([+-]?\d+)\/(\d+)$/), n = t ? Number(t[1]) / Number(t[2]) : Number(e);
|
|
349
|
-
if (!Number.isFinite(n)) throw new
|
|
392
|
+
if (!Number.isFinite(n)) throw new M(`Cannot read the number ${JSON.stringify(e)} in a symmetry operation.`);
|
|
350
393
|
return n;
|
|
351
394
|
}
|
|
352
|
-
function
|
|
395
|
+
function Xe(e) {
|
|
353
396
|
let t = e.split(",").map((e) => e.toLowerCase().replace(/[^xyz0-9./+-]/g, ""));
|
|
354
|
-
if (t.length !== 3) throw new
|
|
397
|
+
if (t.length !== 3) throw new M(`A symmetry operation needs three components: ${JSON.stringify(e)}.`);
|
|
355
398
|
let n = [], r = [];
|
|
356
399
|
for (let i of t) {
|
|
357
400
|
let t = i.match(/[+-]?[^+-]+/g);
|
|
358
|
-
if (!t || t.join("") !== i) throw new
|
|
401
|
+
if (!t || t.join("") !== i) throw new M(`Cannot read the symmetry operation ${JSON.stringify(e)}.`);
|
|
359
402
|
let a = [
|
|
360
403
|
0,
|
|
361
404
|
0,
|
|
362
405
|
0
|
|
363
406
|
], o = 0;
|
|
364
407
|
for (let e of t) {
|
|
365
|
-
let t =
|
|
366
|
-
if (t === -1) o +=
|
|
408
|
+
let t = Je.findIndex((t) => e.includes(t));
|
|
409
|
+
if (t === -1) o += Ye(e);
|
|
367
410
|
else {
|
|
368
|
-
let n =
|
|
411
|
+
let n = Ye(e.replace(Je[t], "").replace(/\*$/, ""));
|
|
369
412
|
a[t] = (a[t] ?? 0) + n;
|
|
370
413
|
}
|
|
371
414
|
}
|
|
372
|
-
n.push(...a), r.push(
|
|
415
|
+
n.push(...a), r.push(I(o));
|
|
373
416
|
}
|
|
374
417
|
return {
|
|
375
418
|
rotation: n,
|
|
@@ -378,99 +421,85 @@ function Be(e) {
|
|
|
378
421
|
}
|
|
379
422
|
//#endregion
|
|
380
423
|
//#region src/cif/structure.ts
|
|
381
|
-
var
|
|
424
|
+
var Ze = ["_space_group_symop_operation_xyz", "_symmetry_equiv_pos_as_xyz"], Qe = ["_space_group_it_number", "_symmetry_int_tables_number"], $e = [
|
|
382
425
|
"_space_group_name_h-m_alt",
|
|
383
426
|
"_symmetry_space_group_name_h-m",
|
|
384
427
|
"_space_group_name_h-m_full"
|
|
385
|
-
],
|
|
386
|
-
function
|
|
387
|
-
let n =
|
|
388
|
-
if (n === null) throw new
|
|
428
|
+
], et = ["_space_group_name_hall", "_symmetry_space_group_name_hall"];
|
|
429
|
+
function R(e, t) {
|
|
430
|
+
let n = F(e.get(t));
|
|
431
|
+
if (n === null) throw new M(`${e.name || "The CIF"} has no usable ${t}.`);
|
|
389
432
|
return n;
|
|
390
433
|
}
|
|
391
|
-
function
|
|
392
|
-
let r = e.find((e) => e.element === t);
|
|
393
|
-
r ? r.occupancy += n : e.push({
|
|
394
|
-
element: t,
|
|
395
|
-
occupancy: n
|
|
396
|
-
}), e.sort((e, t) => t.occupancy - e.occupancy);
|
|
397
|
-
}
|
|
398
|
-
function qe(e) {
|
|
399
|
-
for (let t of e) {
|
|
400
|
-
let e = t.species.reduce((e, t) => e + t.occupancy, 0);
|
|
401
|
-
if (e > 1.000001) for (let n of t.species) n.occupancy /= e;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
function Je(e) {
|
|
434
|
+
function tt(e) {
|
|
405
435
|
let t = e.findLoop("_atom_site_fract_x");
|
|
406
|
-
if (!t) throw new
|
|
407
|
-
let n =
|
|
436
|
+
if (!t) throw new M(`${e.name || "The CIF"} has no atom sites.`);
|
|
437
|
+
let n = N(t, "_atom_site_fract_x") ?? [], r = N(t, "_atom_site_fract_y") ?? [], i = N(t, "_atom_site_fract_z") ?? [], a = N(t, "_atom_site_label"), o = N(t, "_atom_site_type_symbol"), s = N(t, "_atom_site_occupancy"), c = [];
|
|
408
438
|
for (let e = 0; e < t.rows.length; e += 1) {
|
|
409
|
-
let t =
|
|
410
|
-
if (t === null ||
|
|
411
|
-
let
|
|
412
|
-
if (!
|
|
413
|
-
let
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
fractional: g
|
|
425
|
-
})) : Ke(c[ee].species, m, h);
|
|
439
|
+
let t = F(n[e]), l = F(r[e]), u = F(i[e]);
|
|
440
|
+
if (t === null || l === null || u === null) continue;
|
|
441
|
+
let d = a?.[e] ?? o?.[e] ?? `site${e + 1}`, f = o?.[e], p = (f && !P(f) ? Oe(f) : null) ?? Oe(d);
|
|
442
|
+
if (!p) throw new M(`Atom site ${JSON.stringify(d)} names no element (type symbol ${JSON.stringify(f ?? "")}).`);
|
|
443
|
+
let m = F(s?.[e]) ?? 1;
|
|
444
|
+
c.push({
|
|
445
|
+
label: d,
|
|
446
|
+
element: p,
|
|
447
|
+
occupancy: m,
|
|
448
|
+
fractional: [
|
|
449
|
+
t,
|
|
450
|
+
l,
|
|
451
|
+
u
|
|
452
|
+
]
|
|
453
|
+
});
|
|
426
454
|
}
|
|
427
|
-
|
|
428
|
-
|
|
455
|
+
let l = qe(c);
|
|
456
|
+
if (l.length === 0) throw new M(`${e.name || "The CIF"} has no atom sites with coordinates.`);
|
|
457
|
+
return l;
|
|
429
458
|
}
|
|
430
|
-
function
|
|
431
|
-
let t = e.findLoop(
|
|
459
|
+
function nt(e) {
|
|
460
|
+
let t = e.findLoop(Ze);
|
|
432
461
|
if (!t) {
|
|
433
|
-
let t = e.get(
|
|
434
|
-
return t === null ? null : [
|
|
462
|
+
let t = e.get(Ze);
|
|
463
|
+
return t === null ? null : [Xe(t)];
|
|
435
464
|
}
|
|
436
|
-
let n = (
|
|
465
|
+
let n = (N(t, Ze) ?? []).filter((e) => !P(e)).map(Xe);
|
|
437
466
|
return n.length > 0 ? n : null;
|
|
438
467
|
}
|
|
439
|
-
function
|
|
440
|
-
let t =
|
|
468
|
+
function rt(e) {
|
|
469
|
+
let t = F(e.get(Qe)), n = e.get($e), r = e.get(et);
|
|
441
470
|
return {
|
|
442
471
|
number: t !== null && Number.isInteger(t) && t >= 1 && t <= 230 ? t : null,
|
|
443
|
-
symbol: n !== null && !
|
|
444
|
-
hallSymbol: r !== null && !
|
|
472
|
+
symbol: n !== null && !P(n) ? n.trim() : null,
|
|
473
|
+
hallSymbol: r !== null && !P(r) ? r.trim() : null
|
|
445
474
|
};
|
|
446
475
|
}
|
|
447
|
-
function
|
|
476
|
+
function it(e) {
|
|
448
477
|
return e.findLoop("_atom_site_fract_x") !== null;
|
|
449
478
|
}
|
|
450
|
-
function
|
|
479
|
+
function at(e) {
|
|
451
480
|
return {
|
|
452
|
-
lattice:
|
|
453
|
-
a:
|
|
454
|
-
b:
|
|
455
|
-
c:
|
|
456
|
-
alpha:
|
|
457
|
-
beta:
|
|
458
|
-
gamma:
|
|
481
|
+
lattice: Me({
|
|
482
|
+
a: R(e, "_cell_length_a"),
|
|
483
|
+
b: R(e, "_cell_length_b"),
|
|
484
|
+
c: R(e, "_cell_length_c"),
|
|
485
|
+
alpha: R(e, "_cell_angle_alpha"),
|
|
486
|
+
beta: R(e, "_cell_angle_beta"),
|
|
487
|
+
gamma: R(e, "_cell_angle_gamma")
|
|
459
488
|
}),
|
|
460
|
-
sites:
|
|
461
|
-
operations:
|
|
462
|
-
spaceGroup:
|
|
489
|
+
sites: tt(e),
|
|
490
|
+
operations: nt(e),
|
|
491
|
+
spaceGroup: rt(e)
|
|
463
492
|
};
|
|
464
493
|
}
|
|
465
494
|
//#endregion
|
|
466
495
|
//#region src/structure/closure.ts
|
|
467
|
-
function
|
|
468
|
-
let n = new
|
|
496
|
+
function ot(e, t) {
|
|
497
|
+
let n = new He(Ie);
|
|
469
498
|
for (let t of e) n.add(t.fractional);
|
|
470
499
|
let r = !1, i = !0;
|
|
471
500
|
return e.forEach((e, a) => {
|
|
472
501
|
for (let o of t) {
|
|
473
|
-
let t = n.near(
|
|
502
|
+
let t = n.near(Ue(o, e.fractional));
|
|
474
503
|
t.some((e) => e !== a) && (r = !0), t.length === 0 && (i = !1);
|
|
475
504
|
}
|
|
476
505
|
}), {
|
|
@@ -480,7 +509,7 @@ function $e(e, t) {
|
|
|
480
509
|
}
|
|
481
510
|
//#endregion
|
|
482
511
|
//#region src/structure/types.ts
|
|
483
|
-
var
|
|
512
|
+
var st = {
|
|
484
513
|
rotation: [
|
|
485
514
|
1,
|
|
486
515
|
0,
|
|
@@ -497,29 +526,29 @@ var et = {
|
|
|
497
526
|
0,
|
|
498
527
|
0
|
|
499
528
|
]
|
|
500
|
-
},
|
|
501
|
-
function
|
|
502
|
-
return
|
|
503
|
-
await e.instantiate(),
|
|
529
|
+
}, ct = null, lt = null;
|
|
530
|
+
function ut() {
|
|
531
|
+
return lt ||= import("./moyo-wasm.js").then(async (e) => {
|
|
532
|
+
await e.instantiate(), ct = e;
|
|
504
533
|
}).catch((e) => {
|
|
505
|
-
throw
|
|
506
|
-
}),
|
|
534
|
+
throw lt = null, e;
|
|
535
|
+
}), lt;
|
|
507
536
|
}
|
|
508
|
-
function
|
|
509
|
-
if (!
|
|
510
|
-
return
|
|
537
|
+
function dt() {
|
|
538
|
+
if (!ct) throw Error("moyo is not loaded yet; await ensureMoyo() first.");
|
|
539
|
+
return ct;
|
|
511
540
|
}
|
|
512
541
|
//#endregion
|
|
513
542
|
//#region src/symmetry/moyo.ts
|
|
514
|
-
var
|
|
543
|
+
var ft = class extends Error {
|
|
515
544
|
constructor(e) {
|
|
516
545
|
super(e), this.name = "SpaceGroupLookupError";
|
|
517
546
|
}
|
|
518
|
-
},
|
|
519
|
-
function
|
|
520
|
-
return
|
|
547
|
+
}, z = null;
|
|
548
|
+
function pt() {
|
|
549
|
+
return ut();
|
|
521
550
|
}
|
|
522
|
-
function
|
|
551
|
+
function mt(e) {
|
|
523
552
|
let t = e.rotation;
|
|
524
553
|
return {
|
|
525
554
|
rotation: [
|
|
@@ -540,119 +569,282 @@ function ot(e) {
|
|
|
540
569
|
]
|
|
541
570
|
};
|
|
542
571
|
}
|
|
543
|
-
function
|
|
544
|
-
if (!
|
|
545
|
-
|
|
546
|
-
for (let e = 1; e <= 230; e += 1)
|
|
572
|
+
function ht() {
|
|
573
|
+
if (!z) {
|
|
574
|
+
z = [];
|
|
575
|
+
for (let e = 1; e <= 230; e += 1) z.push(...dt().hall_symbol_entries_from_number(e));
|
|
547
576
|
}
|
|
548
|
-
return
|
|
577
|
+
return z;
|
|
549
578
|
}
|
|
550
|
-
function
|
|
579
|
+
function B(e) {
|
|
551
580
|
return e.replace(/[\s_]/g, "").toLowerCase();
|
|
552
581
|
}
|
|
553
|
-
function
|
|
582
|
+
function gt(e) {
|
|
554
583
|
let t = e.trim(), n = t.match(/^(.*?)\s*:\s*(\S+)$/);
|
|
555
584
|
if (n && n[1] && n[2]) return {
|
|
556
|
-
base:
|
|
585
|
+
base: B(n[1]),
|
|
557
586
|
setting: n[2].toLowerCase()
|
|
558
587
|
};
|
|
559
588
|
let r = t.match(/^(.*\S)\s+([HRhr])$/);
|
|
560
589
|
return r && r[1] && r[2] ? {
|
|
561
|
-
base:
|
|
590
|
+
base: B(r[1]),
|
|
562
591
|
setting: r[2].toLowerCase()
|
|
563
592
|
} : {
|
|
564
|
-
base:
|
|
593
|
+
base: B(t),
|
|
565
594
|
setting: null
|
|
566
595
|
};
|
|
567
596
|
}
|
|
568
|
-
function
|
|
597
|
+
function _t(e) {
|
|
569
598
|
let t = e[0];
|
|
570
599
|
if (!t) return e;
|
|
571
|
-
let n =
|
|
600
|
+
let n = dt().space_group_type(t.number).hall_number;
|
|
572
601
|
return [...e].sort((e, t) => Number(t.hall_number === n) - Number(e.hall_number === n));
|
|
573
602
|
}
|
|
574
|
-
function
|
|
575
|
-
let t =
|
|
603
|
+
function vt(e) {
|
|
604
|
+
let t = ht().filter((t) => e.number === null || t.number === e.number);
|
|
576
605
|
if (e.hallSymbol) {
|
|
577
|
-
let n =
|
|
606
|
+
let n = B(e.hallSymbol), r = t.filter((e) => B(e.hall_symbol) === n);
|
|
578
607
|
if (r.length > 0) return r;
|
|
579
608
|
}
|
|
580
609
|
if (e.symbol) {
|
|
581
|
-
let { base: n, setting: r } =
|
|
610
|
+
let { base: n, setting: r } = gt(e.symbol), i = t.filter((e) => B(e.hm_short) === n || B(e.hm_full) === n);
|
|
582
611
|
if (r) {
|
|
583
612
|
let e = i.filter((e) => e.setting.toLowerCase() === r);
|
|
584
613
|
if (e.length > 0) return e;
|
|
585
614
|
}
|
|
586
|
-
return
|
|
615
|
+
return _t(i);
|
|
587
616
|
}
|
|
588
617
|
return [];
|
|
589
618
|
}
|
|
590
|
-
function
|
|
619
|
+
function yt(e) {
|
|
591
620
|
return [
|
|
592
621
|
e.hallSymbol,
|
|
593
622
|
e.symbol,
|
|
594
623
|
e.number
|
|
595
624
|
].filter((e) => e !== null).join(" / ");
|
|
596
625
|
}
|
|
597
|
-
async function
|
|
598
|
-
await
|
|
599
|
-
let { operations_from_number: t } =
|
|
626
|
+
async function bt(e) {
|
|
627
|
+
await pt();
|
|
628
|
+
let { operations_from_number: t } = dt();
|
|
600
629
|
if (e.hallSymbol || e.symbol) {
|
|
601
|
-
let n =
|
|
602
|
-
if (n.length === 0) throw new
|
|
630
|
+
let n = vt(e);
|
|
631
|
+
if (n.length === 0) throw new ft(`Space group ${yt(e)} is not in the symmetry table.`);
|
|
603
632
|
return n.map((e) => ({
|
|
604
633
|
setting: e.setting,
|
|
605
634
|
operations: t(e.number, {
|
|
606
635
|
type: "HallNumber",
|
|
607
636
|
value: e.hall_number
|
|
608
|
-
}, !1).map(
|
|
637
|
+
}, !1).map(mt)
|
|
609
638
|
}));
|
|
610
639
|
}
|
|
611
|
-
if (e.number === null) throw new
|
|
640
|
+
if (e.number === null) throw new ft("No space group is named.");
|
|
612
641
|
return [{
|
|
613
642
|
setting: "",
|
|
614
|
-
operations: t(e.number, { type: "Spglib" }, !1).map(
|
|
643
|
+
operations: t(e.number, { type: "Spglib" }, !1).map(mt)
|
|
615
644
|
}];
|
|
616
645
|
}
|
|
617
|
-
async function
|
|
618
|
-
let [t] = await
|
|
646
|
+
async function xt(e) {
|
|
647
|
+
let [t] = await bt(e);
|
|
619
648
|
return t.operations;
|
|
620
649
|
}
|
|
621
650
|
//#endregion
|
|
622
651
|
//#region src/symmetry/resolve.ts
|
|
623
|
-
var
|
|
624
|
-
function
|
|
625
|
-
return new
|
|
652
|
+
var St = .001, Ct = .01;
|
|
653
|
+
function wt(e) {
|
|
654
|
+
return new e("The symmetry does not fit the listed atoms: they are already expanded, yet the operations generate positions that are not listed.");
|
|
626
655
|
}
|
|
627
|
-
function
|
|
628
|
-
let
|
|
629
|
-
if (
|
|
656
|
+
function Tt(e, t, n) {
|
|
657
|
+
let r = ot(e, t);
|
|
658
|
+
if (r.preExpanded && !r.closed) throw wt(n);
|
|
630
659
|
}
|
|
631
|
-
function
|
|
632
|
-
let o = (e, t) => Math.abs(e - t) <=
|
|
660
|
+
function Et({ a: e, b: t, c: n, alpha: r, beta: i, gamma: a }) {
|
|
661
|
+
let o = (e, t) => Math.abs(e - t) <= St * Math.max(e, t), s = (e, t) => Math.abs(e - t) <= Ct;
|
|
633
662
|
return o(e, t) && o(t, n) && s(r, i) && s(i, a) && !s(r, 90) ? "R" : o(e, t) && s(r, 90) && s(i, 90) && s(a, 120) ? "H" : null;
|
|
634
663
|
}
|
|
635
|
-
async function
|
|
636
|
-
if (e.operations) return
|
|
637
|
-
let { spaceGroup:
|
|
638
|
-
if (
|
|
639
|
-
let
|
|
640
|
-
if (
|
|
641
|
-
let [
|
|
642
|
-
return
|
|
643
|
-
}
|
|
644
|
-
let
|
|
645
|
-
if (
|
|
646
|
-
if (
|
|
647
|
-
let
|
|
648
|
-
return ((
|
|
664
|
+
async function Dt(e, t) {
|
|
665
|
+
if (e.operations) return Tt(e.sites, e.operations, t), e.operations;
|
|
666
|
+
let { spaceGroup: n } = e;
|
|
667
|
+
if (n.hallSymbol === null && n.symbol === null && n.number === null) return [st];
|
|
668
|
+
let r = await bt(n);
|
|
669
|
+
if (r.length === 1) {
|
|
670
|
+
let [n] = r;
|
|
671
|
+
return Tt(e.sites, n.operations, t), n.operations;
|
|
672
|
+
}
|
|
673
|
+
let i = r.map((t) => ot(e.sites, t.operations)), a = r.find((e, t) => i[t].preExpanded && i[t].closed);
|
|
674
|
+
if (a) return a.operations;
|
|
675
|
+
if (i.some((e) => e.preExpanded)) throw wt(t);
|
|
676
|
+
let o = Et(e.lattice);
|
|
677
|
+
return ((o === null ? void 0 : r.find((e) => e.setting.toUpperCase() === o)) ?? r[0]).operations;
|
|
678
|
+
}
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/structure/from-data.ts
|
|
681
|
+
var Ot = 1e-9, kt = 1e-6;
|
|
682
|
+
function V(e) {
|
|
683
|
+
throw new A(e);
|
|
684
|
+
}
|
|
685
|
+
function H(e) {
|
|
686
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
687
|
+
}
|
|
688
|
+
function U(e) {
|
|
689
|
+
return e === void 0 ? "undefined" : typeof e == "object" && e ? Array.isArray(e) ? "an array" : "an object" : JSON.stringify(e) ?? String(e);
|
|
690
|
+
}
|
|
691
|
+
function W(e, t) {
|
|
692
|
+
return (typeof e != "number" || !Number.isFinite(e)) && V(`${t} must be a finite number, not ${U(e)}.`), e;
|
|
693
|
+
}
|
|
694
|
+
function G(e, t) {
|
|
695
|
+
let n = W(e, t);
|
|
696
|
+
return n <= 0 && V(`${t} must be positive, not ${n}.`), n;
|
|
697
|
+
}
|
|
698
|
+
function K(e, t) {
|
|
699
|
+
let n = Array.isArray(e) || ArrayBuffer.isView(e) ? Array.from(e) : null;
|
|
700
|
+
return (n === null || n.length !== 3) && V(`${t} must hold three numbers, not ${U(e)}.`), [
|
|
701
|
+
W(n[0], `${t}[0]`),
|
|
702
|
+
W(n[1], `${t}[1]`),
|
|
703
|
+
W(n[2], `${t}[2]`)
|
|
704
|
+
];
|
|
705
|
+
}
|
|
706
|
+
function At([e, t, n]) {
|
|
707
|
+
return e[0] * (t[1] * n[2] - t[2] * n[1]) - e[1] * (t[0] * n[2] - t[2] * n[0]) + e[2] * (t[0] * n[1] - t[1] * n[0]);
|
|
708
|
+
}
|
|
709
|
+
function jt(e) {
|
|
710
|
+
if (H(e) || V("lattice must be an object with a, b, c, alpha, beta and gamma, or with vectors."), e.vectors !== void 0 && e.vectors !== null) {
|
|
711
|
+
let t = e.vectors;
|
|
712
|
+
(!Array.isArray(t) || t.length !== 3) && V(`lattice.vectors must be three vectors, not ${U(t)}.`);
|
|
713
|
+
let n = [
|
|
714
|
+
K(t[0], "lattice.vectors[0]"),
|
|
715
|
+
K(t[1], "lattice.vectors[1]"),
|
|
716
|
+
K(t[2], "lattice.vectors[2]")
|
|
717
|
+
];
|
|
718
|
+
return Math.abs(At(n)) < kt && V("lattice.vectors lie in one plane: the cell has no volume."), Ne(n);
|
|
719
|
+
}
|
|
720
|
+
let t = {
|
|
721
|
+
a: G(e.a, "lattice.a"),
|
|
722
|
+
b: G(e.b, "lattice.b"),
|
|
723
|
+
c: G(e.c, "lattice.c"),
|
|
724
|
+
alpha: G(e.alpha, "lattice.alpha"),
|
|
725
|
+
beta: G(e.beta, "lattice.beta"),
|
|
726
|
+
gamma: G(e.gamma, "lattice.gamma")
|
|
727
|
+
}, n = Me(t);
|
|
728
|
+
return Math.abs(At(n.vectors)) >= kt || V(`lattice angles ${t.alpha}, ${t.beta} and ${t.gamma} degrees do not form a cell.`), n;
|
|
729
|
+
}
|
|
730
|
+
function Mt(e) {
|
|
731
|
+
(!Array.isArray(e) || e.length === 0) && V(`sites must be a non-empty array, not ${U(e)}.`);
|
|
732
|
+
let t = [];
|
|
733
|
+
return e.forEach((e, n) => {
|
|
734
|
+
let r = `sites[${n}]`;
|
|
735
|
+
H(e) || V(`${r} must be an object, not ${U(e)}.`);
|
|
736
|
+
let i = e.label;
|
|
737
|
+
i != null && typeof i != "string" && V(`${r}.label must be a string, not ${U(i)}.`);
|
|
738
|
+
let a = i ?? `site${n + 1}`, o = K(e.fractional, `${r}.fractional`), s = e.species;
|
|
739
|
+
(!Array.isArray(s) || s.length === 0) && V(`${r}.species must be a non-empty array, not ${U(s)}.`), s.forEach((e, n) => {
|
|
740
|
+
let i = `${r}.species[${n}]`;
|
|
741
|
+
H(e) || V(`${i} must be an object, not ${U(e)}.`);
|
|
742
|
+
let s = e.element;
|
|
743
|
+
(typeof s != "string" || !Ee(s)) && V(`${i}.element must be an element symbol such as "Fe", or "D", not ${U(s)}.`);
|
|
744
|
+
let c = e.occupancy, l = c == null ? 1 : W(c, `${i}.occupancy`);
|
|
745
|
+
l < 0 && V(`${i}.occupancy must not be negative, not ${l}.`), t.push({
|
|
746
|
+
label: a,
|
|
747
|
+
element: s,
|
|
748
|
+
occupancy: l,
|
|
749
|
+
fractional: o
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
}), t;
|
|
753
|
+
}
|
|
754
|
+
function Nt(e) {
|
|
755
|
+
return Math.abs(e - Math.round(e)) <= Ot;
|
|
756
|
+
}
|
|
757
|
+
function Pt(e) {
|
|
758
|
+
return e.rotation.every((e, t) => Math.abs(e - +(t % 4 == 0)) <= Ot) && e.translation.every((e) => Nt(e));
|
|
759
|
+
}
|
|
760
|
+
function Ft(e, t) {
|
|
761
|
+
let n = Array.isArray(e) || ArrayBuffer.isView(e) ? Array.from(e) : null;
|
|
762
|
+
(n === null || n.length !== 9) && V(`${t} must hold nine numbers, row by row, not ${U(e)}.`);
|
|
763
|
+
let r = n.map((e, n) => W(e, `${t}[${n}]`));
|
|
764
|
+
r.every(Nt) || V(`${t} must hold whole numbers.`);
|
|
765
|
+
let i = [
|
|
766
|
+
[
|
|
767
|
+
r[0],
|
|
768
|
+
r[1],
|
|
769
|
+
r[2]
|
|
770
|
+
],
|
|
771
|
+
[
|
|
772
|
+
r[3],
|
|
773
|
+
r[4],
|
|
774
|
+
r[5]
|
|
775
|
+
],
|
|
776
|
+
[
|
|
777
|
+
r[6],
|
|
778
|
+
r[7],
|
|
779
|
+
r[8]
|
|
780
|
+
]
|
|
781
|
+
];
|
|
782
|
+
return Math.abs(Math.abs(At(i)) - 1) > Ot && V(`${t} must have determinant 1 or -1.`), r.map(Math.round);
|
|
783
|
+
}
|
|
784
|
+
function It(e, t) {
|
|
785
|
+
if (typeof e == "string") {
|
|
786
|
+
let n;
|
|
787
|
+
try {
|
|
788
|
+
n = Xe(e);
|
|
789
|
+
} catch (e) {
|
|
790
|
+
V(`${t}: ${e instanceof Error ? e.message : String(e)}`);
|
|
791
|
+
}
|
|
792
|
+
return {
|
|
793
|
+
rotation: Ft(n.rotation, `${t} (${e})`),
|
|
794
|
+
translation: n.translation
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
return H(e) || V(`${t} must be a string such as "x, y, z" or an object with rotation and translation, not ${U(e)}.`), {
|
|
798
|
+
rotation: Ft(e.rotation, `${t}.rotation`),
|
|
799
|
+
translation: Re(K(e.translation, `${t}.translation`))
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function Lt(e) {
|
|
803
|
+
if (e == null) return null;
|
|
804
|
+
(!Array.isArray(e) || e.length === 0) && V(`operations must be a non-empty array, or absent, not ${U(e)}.`);
|
|
805
|
+
let t = e.map((e, t) => It(e, `operations[${t}]`));
|
|
806
|
+
return t.some(Pt) || V("operations must include the identity, x, y, z."), t;
|
|
807
|
+
}
|
|
808
|
+
function Rt(e) {
|
|
809
|
+
if (e == null) return {
|
|
810
|
+
number: null,
|
|
811
|
+
symbol: null,
|
|
812
|
+
hallSymbol: null
|
|
813
|
+
};
|
|
814
|
+
H(e) || V(`spaceGroup must be an object with number, symbol or hallSymbol, not ${U(e)}.`);
|
|
815
|
+
let t = e.number;
|
|
816
|
+
t != null && !(typeof t == "number" && Number.isInteger(t) && t >= 1 && t <= 230) && V(`spaceGroup.number must be a whole number from 1 to 230, not ${U(t)}.`);
|
|
817
|
+
let n = (t) => {
|
|
818
|
+
let n = e[t];
|
|
819
|
+
return n == null ? null : ((typeof n != "string" || n.trim() === "") && V(`spaceGroup.${t} must be a non-empty string, not ${U(n)}.`), n.trim());
|
|
820
|
+
};
|
|
821
|
+
return {
|
|
822
|
+
number: t ?? null,
|
|
823
|
+
symbol: n("symbol"),
|
|
824
|
+
hallSymbol: n("hallSymbol")
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
async function zt(e) {
|
|
828
|
+
H(e) || V(`Structure data must be an object, not ${U(e)}.`);
|
|
829
|
+
let t = jt(e.lattice), n = qe(Mt(e.sites)), r = Rt(e.spaceGroup);
|
|
830
|
+
return {
|
|
831
|
+
lattice: t,
|
|
832
|
+
sites: n,
|
|
833
|
+
operations: await Dt({
|
|
834
|
+
lattice: t,
|
|
835
|
+
sites: n,
|
|
836
|
+
operations: Lt(e.operations),
|
|
837
|
+
spaceGroup: r
|
|
838
|
+
}, A),
|
|
839
|
+
spaceGroup: r
|
|
840
|
+
};
|
|
649
841
|
}
|
|
650
842
|
//#endregion
|
|
651
843
|
//#region src/structure/expand.ts
|
|
652
|
-
function
|
|
653
|
-
let t = [], n = new
|
|
844
|
+
function Bt(e) {
|
|
845
|
+
let t = [], n = new He(Ie);
|
|
654
846
|
for (let r of e.sites) for (let i of e.operations) {
|
|
655
|
-
let e =
|
|
847
|
+
let e = Re(Ue(i, r.fractional));
|
|
656
848
|
n.near(e).length === 0 && (n.add(e), t.push({
|
|
657
849
|
label: r.label,
|
|
658
850
|
species: r.species,
|
|
@@ -662,17 +854,17 @@ function bt(e) {
|
|
|
662
854
|
return {
|
|
663
855
|
...e,
|
|
664
856
|
sites: t,
|
|
665
|
-
operations: [
|
|
857
|
+
operations: [st]
|
|
666
858
|
};
|
|
667
859
|
}
|
|
668
860
|
//#endregion
|
|
669
861
|
//#region src/symmetry/dataset.ts
|
|
670
|
-
var
|
|
862
|
+
var Vt = .01, Ht = class extends Error {
|
|
671
863
|
constructor(e) {
|
|
672
864
|
super(e), this.name = "SymmetryAnalysisError";
|
|
673
865
|
}
|
|
674
866
|
};
|
|
675
|
-
function
|
|
867
|
+
function Ut(e) {
|
|
676
868
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
677
869
|
return {
|
|
678
870
|
numbers: e.map((e) => {
|
|
@@ -682,7 +874,7 @@ function Ct(e) {
|
|
|
682
874
|
speciesByLabel: n
|
|
683
875
|
};
|
|
684
876
|
}
|
|
685
|
-
function
|
|
877
|
+
function Wt(e, t, n) {
|
|
686
878
|
let r = e.std_cell.lattice.basis, i = [
|
|
687
879
|
[
|
|
688
880
|
r[0],
|
|
@@ -704,13 +896,13 @@ function wt(e, t, n) {
|
|
|
704
896
|
return a.set(s, c), {
|
|
705
897
|
label: `${s}${c}`,
|
|
706
898
|
species: o,
|
|
707
|
-
fractional:
|
|
899
|
+
fractional: Re(n)
|
|
708
900
|
};
|
|
709
901
|
});
|
|
710
902
|
return {
|
|
711
|
-
lattice:
|
|
903
|
+
lattice: Ne(i),
|
|
712
904
|
sites: o,
|
|
713
|
-
operations: [
|
|
905
|
+
operations: [st],
|
|
714
906
|
spaceGroup: {
|
|
715
907
|
number: e.number,
|
|
716
908
|
symbol: e.hm_symbol,
|
|
@@ -718,9 +910,9 @@ function wt(e, t, n) {
|
|
|
718
910
|
}
|
|
719
911
|
};
|
|
720
912
|
}
|
|
721
|
-
async function
|
|
722
|
-
await
|
|
723
|
-
let { analyze_cell: n, hall_symbol_entry: r, space_group_type: i } =
|
|
913
|
+
async function Gt(e, t = {}) {
|
|
914
|
+
await pt();
|
|
915
|
+
let { analyze_cell: n, hall_symbol_entry: r, space_group_type: i } = dt(), a = Bt(e), { numbers: o, speciesByLabel: s } = Ut(a.sites), [c, l, u] = a.lattice.vectors, d = {
|
|
724
916
|
lattice: { basis: [
|
|
725
917
|
...c,
|
|
726
918
|
...l,
|
|
@@ -730,11 +922,11 @@ async function Tt(e, t = {}) {
|
|
|
730
922
|
numbers: o
|
|
731
923
|
}, f;
|
|
732
924
|
try {
|
|
733
|
-
f = n(JSON.stringify(d), t.symprec ??
|
|
925
|
+
f = n(JSON.stringify(d), t.symprec ?? Vt, "Standard");
|
|
734
926
|
} catch (e) {
|
|
735
|
-
throw new
|
|
927
|
+
throw new Ht(`moyo could not analyse the structure: ${e instanceof Error ? e.message : String(e)}`);
|
|
736
928
|
}
|
|
737
|
-
let p = r(f.hall_number), m = i(f.number), h =
|
|
929
|
+
let p = r(f.hall_number), m = i(f.number), h = Wt(f, s, p);
|
|
738
930
|
return {
|
|
739
931
|
number: f.number,
|
|
740
932
|
symbol: f.hm_symbol,
|
|
@@ -743,7 +935,7 @@ async function Tt(e, t = {}) {
|
|
|
743
935
|
hallNumber: f.hall_number,
|
|
744
936
|
setting: p.setting,
|
|
745
937
|
crystalSystem: m.crystal_system,
|
|
746
|
-
operations: f.operations.map(
|
|
938
|
+
operations: f.operations.map(mt),
|
|
747
939
|
wyckoffs: f.wyckoffs,
|
|
748
940
|
siteSymmetries: f.site_symmetry_symbols,
|
|
749
941
|
structure: a,
|
|
@@ -752,34 +944,34 @@ async function Tt(e, t = {}) {
|
|
|
752
944
|
}
|
|
753
945
|
//#endregion
|
|
754
946
|
//#region src/symmetry/symbol.ts
|
|
755
|
-
var
|
|
756
|
-
function
|
|
757
|
-
return
|
|
947
|
+
var Kt = "₀₁₂₃₄₅₆₇₈₉", qt = "̅";
|
|
948
|
+
function Jt(e) {
|
|
949
|
+
return Kt[Number(e)] ?? e;
|
|
758
950
|
}
|
|
759
|
-
function
|
|
951
|
+
function Yt(e) {
|
|
760
952
|
let t = e.trim(), n = t.indexOf(":"), r = n === -1 ? t : t.slice(0, n).trim(), i = n === -1 ? "" : ` ${t.slice(n)}`, a = r.split(/\s+/);
|
|
761
|
-
return a.map((e) => a.length > 1 ? e.replace(/^([2346])([1-5])(?=$|\/)/, (e, t, n) => Number(n) < Number(t) ? t +
|
|
953
|
+
return a.map((e) => a.length > 1 ? e.replace(/^([2346])([1-5])(?=$|\/)/, (e, t, n) => Number(n) < Number(t) ? t + Jt(n) : e) : e).join("").replace(/(\d)_(\d)/g, (e, t, n) => t + Jt(n)).replace(/-(\d)/g, (e, t) => t + qt) + i;
|
|
762
954
|
}
|
|
763
955
|
//#endregion
|
|
764
956
|
//#region src/structure/bonds.ts
|
|
765
|
-
var
|
|
957
|
+
var Xt = {
|
|
766
958
|
source: "VESTA bond-search cutoffs (K. Momma and F. Izumi), as distributed in pymatgen's vesta_cutoffs.yaml (MIT). Where VESTA lists a pair twice (H-O, D-O), the shorter cutoff is kept.",
|
|
767
959
|
pairs: /* @__PURE__ */ JSON.parse("{\"Ac-Br\":3.22726,\"Ac-Cl\":3.08646,\"Ac-F\":2.58646,\"Ac-O\":2.7326,\"Ag-As\":2.45642,\"Ag-Br\":2.37642,\"Ag-Cl\":3.05939,\"Ag-F\":2.76939,\"Ag-H\":1.65642,\"Ag-I\":2.53642,\"Ag-N\":2.00642,\"Ag-O\":2.81139,\"Ag-P\":2.37642,\"Ag-S\":3.08839,\"Ag-Se\":2.41642,\"Ag-Te\":2.66642,\"Al-As\":2.75646,\"Al-Br\":2.65646,\"Al-Cl\":2.48846,\"Al-F\":2.00146,\"Al-H\":1.90646,\"Al-I\":2.86646,\"Al-N\":2.24646,\"Al-O\":2.1074,\"Al-P\":2.69646,\"Al-S\":2.66646,\"Al-Se\":2.72646,\"Al-Te\":2.93646,\"Am-Br\":3.22944,\"Am-Cl\":3.08945,\"Am-F\":2.61945,\"Am-O\":2.71649,\"As-Au\":2.26998,\"As-B\":2.42646,\"As-Ba\":3.69,\"As-Be\":2.60649,\"As-Bi\":2.87642,\"As-Br\":2.80646,\"As-C\":2.38646,\"As-Ca\":3.48295,\"As-Cd\":3.29295,\"As-Ce\":3.08644,\"As-Cl\":2.61646,\"As-Co\":2.43642,\"As-Cr\":2.49642,\"As-Cs\":4.15942,\"As-Cu\":2.71895,\"As-Dy\":3.14,\"As-Er\":3.18,\"As-Eu\":2.93898,\"As-F\":2.15646,\"As-Fe\":2.50642,\"As-Ga\":2.38998,\"As-Gd\":3.18,\"As-Ge\":2.47998,\"As-Hf\":2.71642,\"As-Hg\":2.65642,\"As-Ho\":2.87898,\"As-I\":3.03646,\"As-In\":2.66642,\"As-Ir\":2.58998,\"As-K\":3.94942,\"As-La\":3.51293,\"As-Lu\":3.19649,\"As-Mg\":3.09293,\"As-Mn\":2.51642,\"As-Mo\":2.62701,\"As-Na\":3.64942,\"As-Nb\":2.69642,\"As-Ni\":2.28998,\"As-O\":2.24546,\"As-P\":2.29998,\"As-Pb\":3.02644,\"As-Pd\":2.34998,\"As-Pr\":3.35649,\"As-Pt\":2.30998,\"As-Rb\":4.04645,\"As-Re\":2.61998,\"As-Rh\":2.41998,\"As-Ru\":2.40998,\"As-S\":2.84649,\"As-Sb\":2.64998,\"As-Sc\":3.04291,\"As-Se\":2.98649,\"As-Si\":2.66002,\"As-Sm\":3.30649,\"As-Sn\":2.77642,\"As-Sr\":3.62295,\"As-Ta\":2.70642,\"As-Tb\":3.26649,\"As-Te\":3.10646,\"As-Th\":3.40649,\"As-Ti\":2.87642,\"As-Tl\":3.09644,\"As-Tm\":3.22649,\"As-U\":3.02644,\"As-V\":2.54642,\"As-W\":2.58998,\"As-Y\":3.24649,\"As-Yb\":3.19649,\"As-Zn\":2.95293,\"As-Zr\":3.07004,\"Au-Br\":2.77646,\"Au-Cl\":2.88295,\"Au-F\":2.34646,\"Au-H\":1.41998,\"Au-I\":3.21295,\"Au-N\":2.3826,\"Au-O\":2.34646,\"Au-P\":2.18998,\"Au-S\":2.8326,\"Au-Se\":2.22998,\"Au-Te\":2.45998,\"B-B\":1.85846,\"B-Br\":2.33646,\"B-Cl\":2.19646,\"B-F\":1.76646,\"B-H\":1.59646,\"B-I\":2.55646,\"B-N\":1.93846,\"B-O\":1.82746,\"B-P\":2.37646,\"B-S\":2.27646,\"B-Se\":2.40646,\"B-Te\":2.65646,\"Ba-Br\":3.74295,\"Ba-Cl\":3.55295,\"Ba-F\":3.05095,\"Ba-H\":3.08295,\"Ba-I\":3.99295,\"Ba-N\":3.33295,\"Ba-O\":3.14795,\"Ba-P\":3.48295,\"Ba-S\":3.66195,\"Ba-Se\":3.74295,\"Ba-Te\":3.94295,\"Be-Br\":2.50649,\"Be-Cl\":2.36649,\"Be-F\":1.88749,\"Be-H\":1.71649,\"Be-I\":2.70649,\"Be-N\":2.10649,\"Be-O\":1.98749,\"Be-P\":2.55649,\"Be-S\":2.43649,\"Be-Se\":2.57649,\"Be-Te\":2.81649,\"Bi-Br\":3.17993,\"Bi-Cl\":3.04291,\"Bi-F\":2.55291,\"Bi-H\":2.12642,\"Bi-I\":3.38291,\"Bi-N\":2.56329,\"Bi-O\":2.6608,\"Bi-P\":2.78642,\"Bi-S\":3.13291,\"Bi-Se\":3.24329,\"Bi-Te\":3.02642,\"Bk-Br\":3.15233,\"Bk-Cl\":3.02291,\"Bk-F\":2.54233,\"Bk-O\":2.64329,\"Br-C\":2.26002,\"Br-Ca\":3.36995,\"Br-Cd\":3.21295,\"Br-Ce\":3.40452,\"Br-Cf\":3.14233,\"Br-Cl\":2.33296,\"Br-Co\":2.33642,\"Br-Cr\":2.97293,\"Br-Cs\":4.06942,\"Br-Cu\":2.89295,\"Br-Dy\":3.16945,\"Br-Er\":3.14945,\"Br-Eu\":3.46549,\"Br-F\":2.20646,\"Br-Fe\":2.8952,\"Br-Ga\":2.6426,\"Br-Gd\":3.19945,\"Br-Ge\":2.34998,\"Br-Hf\":2.62642,\"Br-Hg\":3.09293,\"Br-Ho\":3.20159,\"Br-In\":3.05329,\"Br-Ir\":2.49998,\"Br-K\":3.8513,\"Br-La\":3.43293,\"Br-Li\":3.11654,\"Br-Lu\":3.11945,\"Br-Mg\":2.99293,\"Br-Mn\":3.05293,\"Br-Mo\":2.8535,\"Br-Na\":3.57715,\"Br-Nb\":3.07646,\"Br-Nd\":3.37293,\"Br-Ni\":2.80649,\"Br-Np\":3.21233,\"Br-O\":2.35646,\"Br-Os\":2.72002,\"Br-P\":2.44293,\"Br-Pa\":3.18437,\"Br-Pb\":3.62451,\"Br-Pd\":2.80649,\"Br-Pm\":3.18233,\"Br-Pr\":3.27649,\"Br-Pt\":2.94191,\"Br-Pu\":3.19233,\"Br-Rb\":4.05498,\"Br-Re\":2.70002,\"Br-Rh\":2.7126,\"Br-Ru\":2.30998,\"Br-S\":2.21998,\"Br-Sb\":2.96646,\"Br-Sc\":2.94291,\"Br-Se\":2.78002,\"Br-Si\":2.55002,\"Br-Sm\":3.26649,\"Br-Sn\":3.2152,\"Br-Sr\":3.54295,\"Br-Ta\":2.60642,\"Br-Tb\":3.18649,\"Br-Te\":2.90002,\"Br-Th\":3.31945,\"Br-Ti\":3.20293,\"Br-Tl\":3.80942,\"Br-Tm\":3.13945,\"Br-U\":3.39452,\"Br-V\":2.87329,\"Br-W\":2.49998,\"Br-Y\":3.15649,\"Br-Yb\":3.12945,\"Br-Zn\":2.86293,\"Br-Zr\":2.98004,\"C-C\":1.89002,\"C-Cl\":2.11002,\"C-Co\":2.19691,\"C-Cu\":2.32649,\"C-F\":1.76002,\"C-Fe\":2.25191,\"C-H\":1.2,\"C-I\":2.16998,\"C-N\":1.79202,\"C-O\":1.97249,\"C-P\":1.93998,\"C-Pd\":2.33649,\"C-Pt\":2.36649,\"C-S\":2.15002,\"C-Se\":2.01998,\"C-Si\":2.23302,\"C-Te\":2.25998,\"Ca-Cl\":3.23295,\"Ca-F\":2.70495,\"Ca-H\":2.69295,\"Ca-I\":3.58295,\"Ca-N\":3.00295,\"Ca-O\":2.83062,\"Ca-P\":3.41295,\"Ca-S\":3.31295,\"Ca-Se\":3.42295,\"Ca-Te\":3.62295,\"Cd-Cl\":3.09295,\"Cd-F\":2.67395,\"Cd-H\":2.52295,\"Cd-I\":3.46295,\"Cd-N\":2.82295,\"Cd-O\":2.76695,\"Cd-P\":3.20295,\"Cd-S\":3.16695,\"Cd-Se\":3.26295,\"Cd-Te\":3.45295,\"Ce-Cl\":3.25293,\"Ce-F\":2.75452,\"Ce-H\":2.34644,\"Ce-I\":3.62452,\"Ce-N\":2.78549,\"Ce-O\":2.86393,\"Ce-P\":3.00644,\"Ce-S\":3.36293,\"Ce-Se\":3.04644,\"Ce-Te\":3.22644,\"Cf-Cl\":3.01291,\"Cf-F\":2.53233,\"Cf-O\":2.63291,\"Cl-Cl\":2.14296,\"Cl-Cm\":3.18291,\"Cl-Co\":2.74593,\"Cl-Cr\":2.80293,\"Cl-Cs\":3.91042,\"Cl-Cu\":2.75295,\"Cl-D\":1.5,\"Cl-Dy\":3.01945,\"Cl-Er\":2.99944,\"Cl-Eu\":3.32549,\"Cl-F\":2.14646,\"Cl-Fe\":2.86293,\"Cl-Ga\":2.52646,\"Cl-Gd\":3.06349,\"Cl-Ge\":2.49002,\"Cl-H\":1.5,\"Cl-Hf\":2.75646,\"Cl-Hg\":3.24939,\"Cl-Ho\":3.05159,\"Cl-I\":3.33295,\"Cl-In\":3.52939,\"Cl-Ir\":2.56746,\"Cl-K\":3.65976,\"Cl-La\":3.33452,\"Cl-Li\":2.91814,\"Cl-Lu\":2.96944,\"Cl-Mg\":2.79293,\"Cl-Mn\":2.84593,\"Cl-Mo\":2.80447,\"Cl-N\":2.20646,\"Cl-NH\":3.48195,\"Cl-Na\":3.39412,\"Cl-Nb\":2.76291,\"Cl-Nd\":3.22493,\"Cl-Ni\":2.62649,\"Cl-Np\":3.07233,\"Cl-O\":2.16646,\"Cl-Os\":2.54002,\"Cl-P\":2.28746,\"Cl-Pa\":3.01437,\"Cl-Pb\":3.39295,\"Cl-Pd\":2.65649,\"Cl-Pm\":3.41233,\"Cl-Pr\":3.12749,\"Cl-Pt\":2.75646,\"Cl-Pu\":3.05233,\"Cl-Rb\":3.86664,\"Cl-Re\":3.44712,\"Cl-Rh\":2.62646,\"Cl-Ru\":2.70646,\"Cl-S\":2.37002,\"Cl-Sb\":2.80646,\"Cl-Sc\":2.92291,\"Cl-Se\":2.57002,\"Cl-Si\":2.38002,\"Cl-Sm\":3.08749,\"Cl-Sn\":3.13111,\"Cl-Sr\":3.37295,\"Cl-Ta\":2.6739,\"Cl-Tb\":3.04349,\"Cl-Tc\":2.56002,\"Cl-Te\":2.73906,\"Cl-Th\":3.15945,\"Cl-Ti\":3.02293,\"Cl-Tl\":3.72942,\"Cl-Tm\":2.98944,\"Cl-U\":3.24452,\"Cl-V\":3.15293,\"Cl-W\":2.47,\"Cl-Y\":3.00649,\"Cl-Yb\":2.98249,\"Cl-Zn\":2.72293,\"Cl-Zr\":3.33651,\"Cm-F\":2.68291,\"Cm-O\":2.79291,\"Co-F\":2.35293,\"Co-H\":1.9278,\"Co-I\":2.52878,\"Co-In\":3.13629,\"Co-N\":2.36293,\"Co-O\":2.40493,\"Co-P\":2.36642,\"Co-S\":2.65293,\"Co-Se\":2.39642,\"Co-Te\":2.61642,\"Cr-F\":2.45293,\"Cr-H\":1.67642,\"Cr-I\":3.19293,\"Cr-N\":2.5152,\"Cr-O\":2.44293,\"Cr-P\":2.42642,\"Cr-S\":2.72491,\"Cr-Se\":2.44642,\"Cr-Te\":2.67642,\"Cs-F\":3.49942,\"Cs-H\":3.55942,\"Cs-I\":4.40942,\"Cs-N\":3.94942,\"Cs-O\":3.53642,\"Cs-P\":3.64194,\"Cs-S\":4.24942,\"Cs-Se\":4.21655,\"Cs-Te\":4.4631,\"Cu-F\":2.46295,\"Cu-H\":1.81649,\"Cu-I\":3.01795,\"Cu-N\":2.49295,\"Cu-O\":2.47295,\"Cu-P\":2.65649,\"Cu-S\":2.76095,\"Cu-Se\":2.76295,\"Cu-Te\":2.87649,\"D-F\":1.1,\"D-N\":1.2,\"D-O\":1.2,\"Dy-F\":2.52944,\"Dy-H\":2.09,\"Dy-I\":3.39945,\"Dy-N\":2.38,\"Dy-O\":2.65651,\"Dy-P\":2.77,\"Dy-S\":2.823,\"Dy-Se\":2.81,\"Dy-Te\":3.22,\"Er-F\":2.51049,\"Er-H\":2.06,\"Er-I\":3.38945,\"Er-N\":2.36,\"Er-O\":2.63651,\"Er-P\":2.75,\"Er-S\":3.27651,\"Er-Se\":3.18649,\"Er-Te\":3.22,\"Es-O\":2.70139,\"Eu-F\":2.83549,\"Eu-H\":2.18898,\"Eu-I\":3.69549,\"Eu-N\":2.95549,\"Eu-O\":2.94249,\"Eu-P\":2.85898,\"Eu-S\":3.37949,\"Eu-Se\":2.89898,\"Eu-Te\":3.08898,\"F-Fe\":2.36293,\"F-Ga\":2.14646,\"F-Gd\":3.15651,\"F-Ge\":2.01002,\"F-H\":1.1,\"F-Hf\":3.18291,\"F-Hg\":2.88293,\"F-Ho\":2.56159,\"F-I\":3.18295,\"F-In\":2.35491,\"F-Ir\":2.15002,\"F-K\":3.11142,\"F-Kr\":2.67549,\"F-La\":2.79293,\"F-Li\":2.34276,\"F-Lu\":2.48249,\"F-Mg\":2.29093,\"F-Mn\":2.41093,\"F-Mo\":2.2998,\"F-N\":1.82646,\"F-NH\":2.99195,\"F-Na\":2.80398,\"F-Nb\":2.35646,\"F-Nd\":2.73452,\"F-Ni\":2.20249,\"F-Np\":2.59233,\"F-Os\":2.07746,\"F-P\":2.01002,\"F-Pa\":2.54437,\"F-Pb\":2.92045,\"F-Pd\":2.34649,\"F-Pm\":2.55233,\"F-Po\":2.83646,\"F-Pr\":2.62945,\"F-Pt\":2.54002,\"F-Pu\":2.58233,\"F-Rb\":3.37645,\"F-Re\":2.16002,\"F-Rh\":2.16646,\"F-Ru\":2.57646,\"F-S\":1.95002,\"F-Sb\":2.35646,\"F-Sc\":2.32291,\"F-Se\":2.08002,\"F-Si\":1.93002,\"F-Sm\":2.60649,\"F-Sn\":2.63793,\"F-Sr\":2.88195,\"F-Ta\":2.2539,\"F-Tb\":2.54249,\"F-Tc\":2.24219,\"F-Te\":2.22002,\"F-Th\":2.68945,\"F-Ti\":2.86293,\"F-Tl\":3.26942,\"F-Tm\":2.51649,\"F-U\":2.80293,\"F-V\":2.87293,\"F-W\":2.03,\"F-Xe\":2.62649,\"F-Y\":2.51049,\"F-Yb\":2.50649,\"F-Zn\":2.38293,\"F-Zr\":2.99651,\"Fe-H\":1.68642,\"Fe-I\":3.1552,\"Fe-N\":2.48193,\"Fe-O\":2.44693,\"Fe-P\":2.42642,\"Fe-S\":2.83793,\"Fe-Se\":2.43642,\"Fe-Te\":2.68642,\"Ga-H\":1.55998,\"Ga-I\":2.91646,\"Ga-N\":1.96,\"Ga-O\":2.18646,\"Ga-P\":2.46998,\"Ga-S\":2.61946,\"Ga-Se\":3.41295,\"Ga-Te\":2.58998,\"Gd-H\":2.13,\"Gd-I\":3.41945,\"Gd-N\":2.42,\"Gd-O\":2.76651,\"Gd-P\":2.81,\"Gd-S\":3.13649,\"Gd-Se\":2.85,\"Gd-Te\":3.24,\"Ge-Ge\":2.6,\"Ge-H\":1.59998,\"Ge-I\":2.54998,\"Ge-N\":1.92998,\"Ge-O\":2.09802,\"Ge-P\":2.36998,\"Ge-S\":2.56702,\"Ge-Se\":2.70002,\"Ge-Te\":2.60998,\"H-Hf\":1.93642,\"H-Hg\":1.86642,\"H-Ho\":2.11898,\"H-In\":1.87642,\"H-Ir\":1.80998,\"H-K\":3.21942,\"H-La\":2.77293,\"H-Lu\":2.42649,\"H-Mg\":2.24293,\"H-Mn\":1.70642,\"H-Mo\":1.83701,\"H-N\":1.2,\"H-Na\":2.79942,\"H-Nb\":1.90642,\"H-Ni\":1.44998,\"H-O\":1.2,\"H-P\":1.45998,\"H-Pb\":2.27644,\"H-Pd\":1.51998,\"H-Pr\":2.62649,\"H-Pt\":1.44998,\"H-Rb\":3.43645,\"H-Re\":1.79998,\"H-Rh\":1.59998,\"H-Ru\":1.65998,\"H-S\":1.42998,\"H-Sb\":2.81998,\"H-Sc\":2.24291,\"H-Se\":1.58998,\"H-Si\":1.82002,\"H-Sm\":2.56649,\"H-Sn\":2.00642,\"H-Sr\":2.87295,\"H-Ta\":1.91642,\"H-Tb\":2.51649,\"H-Te\":1.87998,\"H-Th\":2.67649,\"H-Ti\":1.76642,\"H-Tl\":2.35644,\"H-Tm\":2.45649,\"H-U\":2.27644,\"H-V\":1.73642,\"H-W\":1.80998,\"H-Y\":2.46649,\"H-Yb\":2.42649,\"H-Zn\":2.13293,\"H-Zr\":2.29004,\"Hf-I\":2.83642,\"Hf-N\":2.24642,\"Hf-O\":2.37946,\"Hf-P\":2.63642,\"Hf-S\":2.64642,\"Hf-Se\":2.67642,\"Hf-Te\":2.87642,\"Hg-Hg\":3.1952,\"Hg-I\":3.33293,\"Hg-N\":2.17642,\"Hg-O\":2.86939,\"Hg-P\":2.57642,\"Hg-S\":3.42093,\"Hg-Se\":2.82642,\"Hg-Te\":2.76642,\"Ho-I\":3.44159,\"Ho-N\":2.41898,\"Ho-O\":2.67047,\"Ho-P\":2.79898,\"Ho-S\":3.13547,\"Ho-Se\":2.84898,\"Ho-Te\":3.03898,\"I-I\":2.4,\"I-In\":3.19291,\"I-Ir\":2.70998,\"I-K\":4.11717,\"I-La\":3.64293,\"I-Li\":3.37676,\"I-Lu\":3.36945,\"I-Mg\":3.17293,\"I-Mn\":3.23293,\"I-Mo\":2.74701,\"I-Na\":3.88251,\"I-Nb\":3.1439,\"I-Nd\":3.59452,\"I-Ni\":3.00649,\"I-Np\":3.44233,\"I-O\":2.47646,\"I-P\":2.44998,\"I-Pb\":3.69562,\"I-Pd\":2.96649,\"I-Pr\":3.49649,\"I-Pt\":2.41998,\"I-Pu\":3.43233,\"I-Rb\":4.33462,\"I-Re\":2.65998,\"I-Rh\":2.52998,\"I-Ru\":2.52998,\"I-S\":2.40998,\"I-Sb\":3.21646,\"I-Sc\":3.15291,\"I-Se\":2.58998,\"I-Si\":2.76002,\"I-Sm\":3.44649,\"I-Sn\":3.52293,\"I-Sr\":3.74295,\"I-Ta\":2.81642,\"I-Tb\":3.40945,\"I-Te\":3.13702,\"I-Th\":3.56649,\"I-Ti\":3.08291,\"I-Tl\":3.94142,\"I-Tm\":3.37945,\"I-U\":3.62452,\"I-V\":2.66642,\"I-W\":2.70998,\"I-Y\":3.37649,\"I-Yb\":3.37945,\"I-Zn\":3.07293,\"I-Zr\":3.19004,\"In-Mn\":3.14729,\"In-N\":2.18642,\"In-O\":2.46491,\"In-P\":2.68642,\"In-S\":2.93291,\"In-Se\":2.62642,\"In-Te\":2.84642,\"Ir-N\":2.10998,\"Ir-O\":2.27746,\"Ir-P\":2.50998,\"Ir-S\":2.42998,\"Ir-Se\":2.55998,\"Ir-Te\":2.75998,\"K-N\":3.41942,\"K-O\":3.25142,\"K-P\":3.44942,\"K-S\":3.79285,\"K-Se\":4.00186,\"K-Te\":4.23284,\"La-N\":3.05293,\"La-O\":2.90983,\"La-P\":3.32293,\"La-S\":3.35593,\"La-Se\":3.45293,\"La-Te\":3.65293,\"Li-N\":2.66213,\"Li-O\":2.60087,\"Li-S\":3.02481,\"Li-Se\":3.2433,\"Li-Te\":3.42496,\"Lu-N\":2.71649,\"Lu-O\":2.57749,\"Lu-P\":3.11649,\"Lu-S\":3.03649,\"Lu-Se\":3.16649,\"Lu-Te\":3.35649,\"Mg-N\":2.56293,\"Mg-O\":2.41824,\"Mg-P\":3.00293,\"Mg-S\":2.89293,\"Mg-Se\":3.03293,\"Mg-Te\":3.24293,\"Mn-N\":2.56193,\"Mn-O\":2.51652,\"Mn-P\":2.39642,\"Mn-S\":2.93293,\"Mn-Se\":2.47642,\"Mn-Te\":2.70642,\"Mo-N\":2.4735,\"Mo-O\":2.3475,\"Mo-P\":2.54701,\"Mo-S\":2.80067,\"Mo-Se\":2.59701,\"Mo-Te\":2.79701,\"N-N\":1.8826,\"N-Na\":3.12942,\"N-Nb\":2.46046,\"N-Nd\":3.01293,\"N-Ni\":2.30649,\"N-O\":1.81746,\"N-P\":1.97146,\"N-Pb\":3.0967,\"N-Pd\":2.40451,\"N-Pr\":2.90649,\"N-Pt\":2.41649,\"N-Rb\":3.79645,\"N-Re\":2.10998,\"N-Rh\":2.2626,\"N-Ru\":2.2626,\"N-S\":2.28849,\"N-Sb\":2.56446,\"N-Sc\":2.54291,\"N-Se\":2.1,\"N-Si\":2.12002,\"N-Sm\":3.02351,\"N-Sn\":2.7152,\"N-Sr\":3.09295,\"N-Ta\":2.16642,\"N-Tb\":2.80649,\"N-Te\":2.16998,\"N-Th\":2.94649,\"N-Ti\":2.08642,\"N-Tl\":2.59644,\"N-Tm\":2.74649,\"N-U\":2.78649,\"N-V\":2.38329,\"N-W\":2.10998,\"N-Y\":2.77649,\"N-Yb\":2.84851,\"N-Zn\":2.43293,\"N-Zr\":2.65004,\"NH-O\":3.08895,\"Na-O\":2.95693,\"Na-P\":3.47942,\"Na-S\":3.57685,\"Na-Se\":3.71593,\"Na-Te\":3.95459,\"Nb-O\":2.45329,\"Nb-P\":2.61642,\"Nb-S\":2.74,\"Nb-Se\":2.66642,\"Nb-Te\":2.85642,\"Nd-O\":2.8587,\"Nd-S\":3.42712,\"Nd-Se\":3.42293,\"Nd-Te\":3.60293,\"Ni-O\":2.28149,\"Ni-P\":2.31998,\"Ni-S\":2.58649,\"Ni-Se\":2.18998,\"Ni-Te\":2.47998,\"Np-O\":2.63646,\"Np-S\":3.2,\"O-O\":1.7,\"O-Os\":2.23,\"O-P\":2.08646,\"O-Pa\":2.63383,\"O-Pb\":3.04096,\"O-Pd\":2.39849,\"O-Po\":2.64646,\"O-Pr\":2.74449,\"O-Pt\":2.40649,\"O-Pu\":2.68329,\"O-Rb\":3.43945,\"O-Re\":2.3426,\"O-Rh\":2.24946,\"O-Ru\":2.22646,\"O-S\":1.8,\"O-Sb\":2.45237,\"O-Sc\":2.42029,\"O-Se\":2.16102,\"O-Si\":1.99002,\"O-Sm\":2.88251,\"O-Sn\":2.82146,\"O-Sr\":2.98095,\"O-Ta\":2.74646,\"O-Tb\":2.65549,\"O-Tc\":2.22446,\"O-Te\":2.3334,\"O-Th\":2.77349,\"O-Ti\":2.35391,\"O-Tl\":3.36945,\"O-Tm\":2.60649,\"O-U\":2.94295,\"O-V\":2.84939,\"O-W\":2.20102,\"O-Xe\":2.63451,\"O-Y\":2.62549,\"O-Yb\":2.74551,\"O-Zn\":2.41693,\"O-Zr\":3.09651,\"Os-S\":2.56002,\"P-P\":2.48381,\"P-Pb\":2.94644,\"P-Pd\":2.46998,\"P-Pr\":3.28649,\"P-Pt\":2.23998,\"P-Rb\":3.50645,\"P-Re\":2.50998,\"P-Rh\":2.43998,\"P-Ru\":2.33998,\"P-S\":2.57646,\"P-Sb\":2.56998,\"P-Sc\":2.96291,\"P-Se\":2.69646,\"P-Si\":2.58002,\"P-Sm\":3.23649,\"P-Sn\":2.60642,\"P-Sr\":3.43295,\"P-Ta\":2.62642,\"P-Tb\":3.19649,\"P-Te\":2.56998,\"P-Th\":3.33649,\"P-Ti\":2.51642,\"P-Tl\":3.01644,\"P-Tm\":3.13649,\"P-U\":2.94644,\"P-V\":2.46642,\"P-W\":2.50998,\"P-Y\":3.17649,\"P-Yb\":3.13649,\"P-Zn\":2.86293,\"P-Zr\":3.02004,\"Pb-S\":3.40395,\"Pb-Se\":3.55295,\"Pb-Te\":3.14644,\"Pd-S\":2.69649,\"Pd-Se\":2.26998,\"Pd-Te\":2.52998,\"Pr-S\":3.20649,\"Pr-Se\":3.32649,\"Pr-Te\":3.50649,\"Pt-S\":2.76649,\"Pt-Se\":2.23998,\"Pt-Te\":2.49998,\"Pu-S\":3.3,\"Rb-S\":3.97645,\"Rb-Se\":4.13773,\"Rb-Te\":4.28802,\"Re-S\":2.61998,\"Re-Se\":2.54998,\"Re-Te\":2.74998,\"Rh-S\":2.19998,\"Rh-Se\":2.37998,\"Rh-Te\":2.59998,\"Ru-S\":2.6426,\"Ru-Se\":2.69451,\"Ru-Te\":2.58998,\"S-S\":2.2,\"S-Sb\":3.05,\"S-Sc\":2.88391,\"S-Se\":2.81649,\"S-Si\":2.47602,\"S-Sm\":3.15649,\"S-Sn\":3.15293,\"S-Sr\":3.51295,\"S-Ta\":2.8439,\"S-Tb\":3.11649,\"S-Te\":2.79002,\"S-Th\":3.24649,\"S-Ti\":2.74646,\"S-Tl\":3.66442,\"S-Tm\":3.05649,\"S-U\":3.25293,\"S-V\":2.82293,\"S-W\":2.43998,\"S-Y\":3.08649,\"S-Yb\":3.03649,\"S-Zn\":2.80293,\"S-Zr\":2.91004,\"Sb-Se\":3.05646,\"Sb-Te\":2.82998,\"Sc-Se\":3.00291,\"Sc-Te\":3.20291,\"Se-Se\":2.93649,\"Se-Si\":2.61002,\"Se-Sm\":3.27649,\"Se-Sn\":2.96646,\"Se-Sr\":3.58295,\"Se-Ta\":2.66642,\"Se-Tb\":3.23649,\"Se-Te\":2.57998,\"Se-Th\":3.36649,\"Se-Ti\":2.53642,\"Se-Tl\":3.00644,\"Se-Tm\":3.18649,\"Se-U\":3.00644,\"Se-V\":2.48642,\"Se-W\":2.55998,\"Se-Y\":3.21649,\"Se-Yb\":3.16649,\"Se-Zn\":2.93293,\"Se-Zr\":3.03004,\"Si-Si\":2.6,\"Si-Te\":2.84002,\"Sm-Te\":3.46649,\"Sn-Te\":2.91642,\"Sr-Te\":3.73295,\"Ta-Te\":2.85642,\"Tb-Te\":3.42649,\"Te-Te\":2.80998,\"Te-Th\":3.54649,\"Te-Ti\":2.95642,\"Te-Tl\":3.23644,\"Te-Tm\":3.37649,\"Te-U\":3.16644,\"Te-V\":2.72642,\"Te-W\":2.75998,\"Te-Y\":3.40649,\"Te-Yb\":3.36649,\"Te-Zn\":3.16293,\"Te-Zr\":3.17004}")
|
|
768
|
-
}.pairs,
|
|
769
|
-
function
|
|
770
|
-
return
|
|
960
|
+
}.pairs, Zt = .4;
|
|
961
|
+
function Qt(e, t) {
|
|
962
|
+
return Xt[e < t ? `${e}-${t}` : `${t}-${e}`] ?? null;
|
|
771
963
|
}
|
|
772
|
-
function
|
|
964
|
+
function $t(e) {
|
|
773
965
|
let t = /* @__PURE__ */ new Map(), n = e.map((e) => {
|
|
774
966
|
let n = t.get(e.element);
|
|
775
967
|
return n === void 0 && (n = t.size, t.set(e.element, n)), n;
|
|
776
968
|
}), r = [...t.keys()], i = new Float64Array(r.length * r.length), a = 0;
|
|
777
969
|
if (r.forEach((e, t) => {
|
|
778
970
|
r.forEach((n, o) => {
|
|
779
|
-
let s =
|
|
971
|
+
let s = Qt(e, n) ?? 0;
|
|
780
972
|
i[t * r.length + o] = s, a = Math.max(a, s);
|
|
781
973
|
});
|
|
782
|
-
}), a <
|
|
974
|
+
}), a < Zt) return [];
|
|
783
975
|
let o = e.map((e) => e.position.map((e) => Math.floor(e / a) | 0)), s = [
|
|
784
976
|
Infinity,
|
|
785
977
|
Infinity,
|
|
@@ -801,9 +993,9 @@ function Nt(e) {
|
|
|
801
993
|
m.length = 0;
|
|
802
994
|
for (let r = -1; r <= 1; r += 1) for (let o = -1; o <= 1; o += 1) for (let p = -1; p <= 1; p += 1) for (let h of f.get(d(s + r, c + o, l + p)) ?? []) {
|
|
803
995
|
let r = i[u + n[h]];
|
|
804
|
-
if (h <= a || r <
|
|
805
|
-
let o =
|
|
806
|
-
o >=
|
|
996
|
+
if (h <= a || r < Zt) continue;
|
|
997
|
+
let o = Fe(t.position, e[h].position);
|
|
998
|
+
o >= Zt && o <= r && m.push({
|
|
807
999
|
start: a,
|
|
808
1000
|
end: h,
|
|
809
1001
|
length: o
|
|
@@ -814,11 +1006,11 @@ function Nt(e) {
|
|
|
814
1006
|
}
|
|
815
1007
|
//#endregion
|
|
816
1008
|
//#region src/structure/images.ts
|
|
817
|
-
var
|
|
818
|
-
function
|
|
1009
|
+
var en = 1e-4;
|
|
1010
|
+
function tn(e, t) {
|
|
819
1011
|
let n = [];
|
|
820
1012
|
return e.forEach((e, r) => {
|
|
821
|
-
let i = e.fractional.map((e) =>
|
|
1013
|
+
let i = e.fractional.map((e) => I(e, en));
|
|
822
1014
|
if (n.push({
|
|
823
1015
|
siteIndex: r,
|
|
824
1016
|
fractional: i,
|
|
@@ -828,7 +1020,7 @@ function Ft(e, t) {
|
|
|
828
1020
|
0,
|
|
829
1021
|
1,
|
|
830
1022
|
2
|
|
831
|
-
].filter((e) => i[e] <
|
|
1023
|
+
].filter((e) => i[e] < en), o = 1 << a.length;
|
|
832
1024
|
for (let e = 1; e < o; e += 1) {
|
|
833
1025
|
let t = [
|
|
834
1026
|
i[0],
|
|
@@ -847,23 +1039,23 @@ function Ft(e, t) {
|
|
|
847
1039
|
}
|
|
848
1040
|
//#endregion
|
|
849
1041
|
//#region src/scene/build.ts
|
|
850
|
-
function
|
|
1042
|
+
function nn(e) {
|
|
851
1043
|
let t = [];
|
|
852
1044
|
for (let n of e.sites) for (let e of n.species) {
|
|
853
|
-
let n =
|
|
1045
|
+
let n = ke(e.element);
|
|
854
1046
|
t.includes(n) || t.push(n);
|
|
855
1047
|
}
|
|
856
1048
|
return t;
|
|
857
1049
|
}
|
|
858
|
-
function
|
|
859
|
-
let n =
|
|
1050
|
+
function rn(e, t = {}) {
|
|
1051
|
+
let n = tn(e.sites, t.imageAtoms ?? !0).map((t) => {
|
|
860
1052
|
let n = e.sites[t.siteIndex], r = n.species[0];
|
|
861
1053
|
if (!r) throw Error(`Site ${n.label} has no species.`);
|
|
862
1054
|
return {
|
|
863
1055
|
siteIndex: t.siteIndex,
|
|
864
1056
|
element: r.element,
|
|
865
1057
|
species: n.species,
|
|
866
|
-
position:
|
|
1058
|
+
position: Pe(e.lattice, t.fractional),
|
|
867
1059
|
fractional: t.fractional,
|
|
868
1060
|
isImage: t.isImage
|
|
869
1061
|
};
|
|
@@ -871,20 +1063,20 @@ function Lt(e, t = {}) {
|
|
|
871
1063
|
return {
|
|
872
1064
|
cell: e.lattice.vectors,
|
|
873
1065
|
atoms: n,
|
|
874
|
-
bonds:
|
|
875
|
-
elements:
|
|
1066
|
+
bonds: $t(n),
|
|
1067
|
+
elements: nn(e)
|
|
876
1068
|
};
|
|
877
1069
|
}
|
|
878
1070
|
//#endregion
|
|
879
1071
|
//#region node_modules/three/examples/jsm/controls/TrackballControls.js
|
|
880
|
-
var
|
|
1072
|
+
var an = { type: "change" }, on = { type: "start" }, sn = { type: "end" }, cn = 1e-6, q = {
|
|
881
1073
|
NONE: -1,
|
|
882
1074
|
ROTATE: 0,
|
|
883
1075
|
ZOOM: 1,
|
|
884
1076
|
PAN: 2,
|
|
885
1077
|
TOUCH_ROTATE: 3,
|
|
886
1078
|
TOUCH_ZOOM_PAN: 4
|
|
887
|
-
},
|
|
1079
|
+
}, ln = new D(), J = new D(), un = new O(), dn = new O(), fn = new O(), Y = new E(), pn = new O(), mn = new O(), hn = new O(), X = new O(), gn = class extends l {
|
|
888
1080
|
constructor(e, t = null) {
|
|
889
1081
|
super(e, t), this.screen = {
|
|
890
1082
|
left: 0,
|
|
@@ -896,10 +1088,10 @@ var Rt = { type: "change" }, zt = { type: "start" }, Bt = { type: "end" }, K = 1
|
|
|
896
1088
|
"KeyS",
|
|
897
1089
|
"KeyD"
|
|
898
1090
|
], this.mouseButtons = {
|
|
899
|
-
LEFT:
|
|
900
|
-
MIDDLE:
|
|
901
|
-
RIGHT:
|
|
902
|
-
}, this.target = new
|
|
1091
|
+
LEFT: b.ROTATE,
|
|
1092
|
+
MIDDLE: b.DOLLY,
|
|
1093
|
+
RIGHT: b.PAN
|
|
1094
|
+
}, this.target = new O(), this.state = q.NONE, this.keyState = q.NONE, this._lastPosition = new O(), this._lastUp = new O(), this._lastZoom = 1, this._touchZoomDistanceStart = 0, this._touchZoomDistanceEnd = 0, this._touchRollAngle = 0, this._touchRollPointerIds = "", this._lastAngle = 0, this._lastRollAngle = 0, this._eye = new O(), this._movePrev = new D(), this._moveCurr = new D(), this._lastAxis = new O(), this._zoomStart = new D(), this._zoomEnd = new D(), this._panStart = new D(), this._panEnd = new D(), this._pointers = [], this._pointerPositions = {}, this._onPointerMove = vn.bind(this), this._onPointerDown = _n.bind(this), this._onPointerUp = yn.bind(this), this._onPointerCancel = bn.bind(this), this._onContextMenu = Dn.bind(this), this._onMouseWheel = En.bind(this), this._onKeyDown = Sn.bind(this), this._onKeyUp = xn.bind(this), this._onTouchStart = On.bind(this), this._onTouchMove = kn.bind(this), this._onTouchEnd = An.bind(this), this._onMouseDown = Cn.bind(this), this._onMouseMove = wn.bind(this), this._onMouseUp = Tn.bind(this), this._target0 = this.target.clone(), this._position0 = this.object.position.clone(), this._up0 = this.object.up.clone(), this._zoom0 = this.object.zoom, t !== null && (this.connect(t), this.handleResize()), this.update();
|
|
903
1095
|
}
|
|
904
1096
|
connect(e) {
|
|
905
1097
|
super.connect(e), window.addEventListener("keydown", this._onKeyDown), window.addEventListener("keyup", this._onKeyUp), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerCancel), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "none";
|
|
@@ -917,16 +1109,16 @@ var Rt = { type: "change" }, zt = { type: "start" }, Bt = { type: "end" }, K = 1
|
|
|
917
1109
|
update() {
|
|
918
1110
|
if (this._eye.subVectors(this.object.position, this.target), this.noRotate || (this._rotateCamera(), this.multiTouchRoll === !0 && this._rollCamera()), this.noZoom || this._zoomCamera(), this.noPan || this._panCamera(), this.object.position.addVectors(this.target, this._eye), this.object.isPerspectiveCamera) {
|
|
919
1111
|
this._checkDistances(), this.object.lookAt(this.target);
|
|
920
|
-
let e = this._lastPosition.distanceToSquared(this.object.position) >
|
|
921
|
-
(e || t) && (this.dispatchEvent(
|
|
1112
|
+
let e = this._lastPosition.distanceToSquared(this.object.position) > cn, t = this._lastUp.distanceToSquared(this.object.up) > cn;
|
|
1113
|
+
(e || t) && (this.dispatchEvent(an), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up));
|
|
922
1114
|
} else if (this.object.isOrthographicCamera) {
|
|
923
1115
|
this.object.lookAt(this.target);
|
|
924
|
-
let e = this._lastPosition.distanceToSquared(this.object.position) >
|
|
925
|
-
(e || t || n) && (this.dispatchEvent(
|
|
1116
|
+
let e = this._lastPosition.distanceToSquared(this.object.position) > cn, t = this._lastUp.distanceToSquared(this.object.up) > cn, n = this._lastZoom !== this.object.zoom;
|
|
1117
|
+
(e || t || n) && (this.dispatchEvent(an), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up), this._lastZoom = this.object.zoom);
|
|
926
1118
|
} else console.warn("THREE.TrackballControls: Unsupported camera type.");
|
|
927
1119
|
}
|
|
928
1120
|
reset() {
|
|
929
|
-
this.state = q.NONE, this.keyState = q.NONE, this.target.copy(this._target0), this.object.position.copy(this._position0), this.object.up.copy(this._up0), this.object.zoom = this._zoom0, this.object.updateProjectionMatrix(), this._eye.subVectors(this.object.position, this.target), this.object.lookAt(this.target), this.dispatchEvent(
|
|
1121
|
+
this.state = q.NONE, this.keyState = q.NONE, this.target.copy(this._target0), this.object.position.copy(this._position0), this.object.up.copy(this._up0), this.object.zoom = this._zoom0, this.object.updateProjectionMatrix(), this._eye.subVectors(this.object.position, this.target), this.object.lookAt(this.target), this.dispatchEvent(an), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up), this._lastZoom = this.object.zoom;
|
|
930
1122
|
}
|
|
931
1123
|
_panCamera() {
|
|
932
1124
|
if (J.copy(this._panEnd).sub(this._panStart), J.lengthSq()) {
|
|
@@ -934,20 +1126,20 @@ var Rt = { type: "change" }, zt = { type: "start" }, Bt = { type: "end" }, K = 1
|
|
|
934
1126
|
let e = (this.object.right - this.object.left) / this.object.zoom / this.domElement.clientWidth, t = (this.object.top - this.object.bottom) / this.object.zoom / this.domElement.clientWidth;
|
|
935
1127
|
J.x *= e, J.y *= t;
|
|
936
1128
|
}
|
|
937
|
-
J.multiplyScalar(this._eye.length() * this.panSpeed),
|
|
1129
|
+
J.multiplyScalar(this._eye.length() * this.panSpeed), dn.copy(this._eye).cross(this.object.up).setLength(J.x), dn.add(un.copy(this.object.up).setLength(J.y)), this.object.position.add(dn), this.target.add(dn), this.staticMoving ? this._panStart.copy(this._panEnd) : this._panStart.add(J.subVectors(this._panEnd, this._panStart).multiplyScalar(this.dynamicDampingFactor));
|
|
938
1130
|
}
|
|
939
1131
|
}
|
|
940
1132
|
_rotateCamera() {
|
|
941
|
-
|
|
942
|
-
let e =
|
|
943
|
-
e ? (this._eye.copy(this.object.position).sub(this.target),
|
|
1133
|
+
X.set(this._moveCurr.x - this._movePrev.x, this._moveCurr.y - this._movePrev.y, 0);
|
|
1134
|
+
let e = X.length();
|
|
1135
|
+
e ? (this._eye.copy(this.object.position).sub(this.target), pn.copy(this._eye).normalize(), mn.copy(this.object.up).normalize(), hn.crossVectors(mn, pn).normalize(), mn.setLength(this._moveCurr.y - this._movePrev.y), hn.setLength(this._moveCurr.x - this._movePrev.x), X.copy(mn.add(hn)), fn.crossVectors(X, this._eye).normalize(), e *= this.rotateSpeed, Y.setFromAxisAngle(fn, e), this._eye.applyQuaternion(Y), this.object.up.applyQuaternion(Y), this._lastAxis.copy(fn), this._lastAngle = e) : !this.staticMoving && this._lastAngle && (this._lastAngle *= Math.sqrt(1 - this.dynamicDampingFactor), this._eye.copy(this.object.position).sub(this.target), Y.setFromAxisAngle(this._lastAxis, this._lastAngle), this._eye.applyQuaternion(Y), this.object.up.applyQuaternion(Y)), this._movePrev.copy(this._moveCurr);
|
|
944
1136
|
}
|
|
945
1137
|
_rollCamera() {
|
|
946
1138
|
let e = this._getTouchRollAngle();
|
|
947
1139
|
if (e) this._lastRollAngle = e * this.rollSpeed;
|
|
948
1140
|
else if (!this.staticMoving && this._lastRollAngle) this._lastRollAngle *= Math.sqrt(1 - this.dynamicDampingFactor);
|
|
949
1141
|
else return;
|
|
950
|
-
|
|
1142
|
+
pn.copy(this._eye).normalize(), Y.setFromAxisAngle(pn, this._lastRollAngle), this.object.up.applyQuaternion(Y);
|
|
951
1143
|
}
|
|
952
1144
|
_getTouchRollAngle() {
|
|
953
1145
|
let e = this._pointers[0], t = this._pointers[1];
|
|
@@ -959,13 +1151,13 @@ var Rt = { type: "change" }, zt = { type: "start" }, Bt = { type: "end" }, K = 1
|
|
|
959
1151
|
}
|
|
960
1152
|
_zoomCamera() {
|
|
961
1153
|
let e;
|
|
962
|
-
this.state === q.TOUCH_ZOOM_PAN ? (e = this._touchZoomDistanceStart / this._touchZoomDistanceEnd, this._touchZoomDistanceStart = this._touchZoomDistanceEnd, this.object.isPerspectiveCamera ? this._eye.multiplyScalar(e) : this.object.isOrthographicCamera ? (this.object.zoom =
|
|
1154
|
+
this.state === q.TOUCH_ZOOM_PAN ? (e = this._touchZoomDistanceStart / this._touchZoomDistanceEnd, this._touchZoomDistanceStart = this._touchZoomDistanceEnd, this.object.isPerspectiveCamera ? this._eye.multiplyScalar(e) : this.object.isOrthographicCamera ? (this.object.zoom = ie.clamp(this.object.zoom / e, this.minZoom, this.maxZoom), this._lastZoom !== this.object.zoom && this.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")) : (e = 1 + (this._zoomEnd.y - this._zoomStart.y) * this.zoomSpeed, e !== 1 && e > 0 && (this.object.isPerspectiveCamera ? this._eye.multiplyScalar(e) : this.object.isOrthographicCamera ? (this.object.zoom = ie.clamp(this.object.zoom / e, this.minZoom, this.maxZoom), this._lastZoom !== this.object.zoom && this.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")), this.staticMoving ? this._zoomStart.copy(this._zoomEnd) : this._zoomStart.y += (this._zoomEnd.y - this._zoomStart.y) * this.dynamicDampingFactor);
|
|
963
1155
|
}
|
|
964
1156
|
_getMouseOnScreen(e, t) {
|
|
965
|
-
return
|
|
1157
|
+
return ln.set((e - this.screen.left) / this.screen.width, (t - this.screen.top) / this.screen.height), ln;
|
|
966
1158
|
}
|
|
967
1159
|
_getMouseOnCircle(e, t) {
|
|
968
|
-
return
|
|
1160
|
+
return ln.set((e - this.screen.width * .5 - this.screen.left) / (this.screen.width * .5), (this.screen.height + 2 * (this.screen.top - t)) / this.screen.width), ln;
|
|
969
1161
|
}
|
|
970
1162
|
_addPointer(e) {
|
|
971
1163
|
this._pointers.push(e);
|
|
@@ -979,7 +1171,7 @@ var Rt = { type: "change" }, zt = { type: "start" }, Bt = { type: "end" }, K = 1
|
|
|
979
1171
|
}
|
|
980
1172
|
_trackPointer(e) {
|
|
981
1173
|
let t = this._pointerPositions[e.pointerId];
|
|
982
|
-
t === void 0 && (t = new
|
|
1174
|
+
t === void 0 && (t = new D(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
|
|
983
1175
|
}
|
|
984
1176
|
_getSecondPointerPosition(e) {
|
|
985
1177
|
let t = e.pointerId === this._pointers[0].pointerId ? this._pointers[1] : this._pointers[0];
|
|
@@ -989,25 +1181,25 @@ var Rt = { type: "change" }, zt = { type: "start" }, Bt = { type: "end" }, K = 1
|
|
|
989
1181
|
(!this.noZoom || !this.noPan) && (this._eye.lengthSq() > this.maxDistance * this.maxDistance && (this.object.position.addVectors(this.target, this._eye.setLength(this.maxDistance)), this._zoomStart.copy(this._zoomEnd)), this._eye.lengthSq() < this.minDistance * this.minDistance && (this.object.position.addVectors(this.target, this._eye.setLength(this.minDistance)), this._zoomStart.copy(this._zoomEnd)));
|
|
990
1182
|
}
|
|
991
1183
|
};
|
|
992
|
-
function
|
|
1184
|
+
function _n(e) {
|
|
993
1185
|
this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(e.pointerId), this.domElement.ownerDocument.addEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.addEventListener("pointerup", this._onPointerUp)), this._addPointer(e), e.pointerType === "touch" ? this._onTouchStart(e) : this._onMouseDown(e));
|
|
994
1186
|
}
|
|
995
|
-
function
|
|
1187
|
+
function vn(e) {
|
|
996
1188
|
this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchMove(e) : this._onMouseMove(e));
|
|
997
1189
|
}
|
|
998
|
-
function
|
|
1190
|
+
function yn(e) {
|
|
999
1191
|
this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchEnd(e) : this._onMouseUp(), this._removePointer(e), this._pointers.length === 0 && (this.domElement.releasePointerCapture(e.pointerId), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp)));
|
|
1000
1192
|
}
|
|
1001
|
-
function
|
|
1193
|
+
function bn(e) {
|
|
1002
1194
|
this._removePointer(e);
|
|
1003
1195
|
}
|
|
1004
|
-
function
|
|
1196
|
+
function xn() {
|
|
1005
1197
|
this.enabled !== !1 && (this.keyState = q.NONE, window.addEventListener("keydown", this._onKeyDown));
|
|
1006
1198
|
}
|
|
1007
|
-
function
|
|
1199
|
+
function Sn(e) {
|
|
1008
1200
|
this.enabled !== !1 && (window.removeEventListener("keydown", this._onKeyDown), this.keyState === q.NONE && (e.code === this.keys[q.ROTATE] && !this.noRotate ? this.keyState = q.ROTATE : e.code === this.keys[q.ZOOM] && !this.noZoom ? this.keyState = q.ZOOM : e.code === this.keys[q.PAN] && !this.noPan && (this.keyState = q.PAN)));
|
|
1009
1201
|
}
|
|
1010
|
-
function
|
|
1202
|
+
function Cn(e) {
|
|
1011
1203
|
let t;
|
|
1012
1204
|
switch (e.button) {
|
|
1013
1205
|
case 0:
|
|
@@ -1022,28 +1214,28 @@ function nn(e) {
|
|
|
1022
1214
|
default: t = -1;
|
|
1023
1215
|
}
|
|
1024
1216
|
switch (t) {
|
|
1025
|
-
case
|
|
1217
|
+
case b.DOLLY:
|
|
1026
1218
|
this.state = q.ZOOM;
|
|
1027
1219
|
break;
|
|
1028
|
-
case
|
|
1220
|
+
case b.ROTATE:
|
|
1029
1221
|
this.state = q.ROTATE;
|
|
1030
1222
|
break;
|
|
1031
|
-
case
|
|
1223
|
+
case b.PAN:
|
|
1032
1224
|
this.state = q.PAN;
|
|
1033
1225
|
break;
|
|
1034
1226
|
default: this.state = q.NONE;
|
|
1035
1227
|
}
|
|
1036
1228
|
let n = this.keyState === q.NONE ? this.state : this.keyState;
|
|
1037
|
-
n === q.ROTATE && !this.noRotate ? (this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY)), this._movePrev.copy(this._moveCurr)) : n === q.ZOOM && !this.noZoom ? (this._zoomStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._zoomEnd.copy(this._zoomStart)) : n === q.PAN && !this.noPan && (this._panStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._panEnd.copy(this._panStart)), this.dispatchEvent(
|
|
1229
|
+
n === q.ROTATE && !this.noRotate ? (this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY)), this._movePrev.copy(this._moveCurr)) : n === q.ZOOM && !this.noZoom ? (this._zoomStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._zoomEnd.copy(this._zoomStart)) : n === q.PAN && !this.noPan && (this._panStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._panEnd.copy(this._panStart)), this.dispatchEvent(on);
|
|
1038
1230
|
}
|
|
1039
|
-
function
|
|
1231
|
+
function wn(e) {
|
|
1040
1232
|
let t = this.keyState === q.NONE ? this.state : this.keyState;
|
|
1041
1233
|
t === q.ROTATE && !this.noRotate ? this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY)) : t === q.ZOOM && !this.noZoom ? this._zoomEnd.copy(this._getMouseOnScreen(e.pageX, e.pageY)) : t === q.PAN && !this.noPan && this._panEnd.copy(this._getMouseOnScreen(e.pageX, e.pageY));
|
|
1042
1234
|
}
|
|
1043
|
-
function
|
|
1044
|
-
this.state = q.NONE, this.dispatchEvent(
|
|
1235
|
+
function Tn() {
|
|
1236
|
+
this.state = q.NONE, this.dispatchEvent(sn);
|
|
1045
1237
|
}
|
|
1046
|
-
function
|
|
1238
|
+
function En(e) {
|
|
1047
1239
|
if (this.enabled !== !1 && this.noZoom !== !0) {
|
|
1048
1240
|
switch (e.preventDefault(), e.deltaMode) {
|
|
1049
1241
|
case 2:
|
|
@@ -1054,13 +1246,13 @@ function on(e) {
|
|
|
1054
1246
|
break;
|
|
1055
1247
|
default: this._zoomStart.y -= e.deltaY * 25e-5;
|
|
1056
1248
|
}
|
|
1057
|
-
this.dispatchEvent(
|
|
1249
|
+
this.dispatchEvent(on), this.dispatchEvent(sn);
|
|
1058
1250
|
}
|
|
1059
1251
|
}
|
|
1060
|
-
function
|
|
1252
|
+
function Dn(e) {
|
|
1061
1253
|
this.enabled !== !1 && e.preventDefault();
|
|
1062
1254
|
}
|
|
1063
|
-
function
|
|
1255
|
+
function On(e) {
|
|
1064
1256
|
switch (this._trackPointer(e), this._pointers.length) {
|
|
1065
1257
|
case 1:
|
|
1066
1258
|
this.state = q.TOUCH_ROTATE, this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX, this._pointers[0].pageY)), this._movePrev.copy(this._moveCurr);
|
|
@@ -1072,9 +1264,9 @@ function cn(e) {
|
|
|
1072
1264
|
let n = (this._pointers[0].pageX + this._pointers[1].pageX) / 2, r = (this._pointers[0].pageY + this._pointers[1].pageY) / 2;
|
|
1073
1265
|
this._panStart.copy(this._getMouseOnScreen(n, r)), this._panEnd.copy(this._panStart);
|
|
1074
1266
|
}
|
|
1075
|
-
this.dispatchEvent(
|
|
1267
|
+
this.dispatchEvent(on);
|
|
1076
1268
|
}
|
|
1077
|
-
function
|
|
1269
|
+
function kn(e) {
|
|
1078
1270
|
switch (this._trackPointer(e), this._pointers.length) {
|
|
1079
1271
|
case 1:
|
|
1080
1272
|
this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY));
|
|
@@ -1086,7 +1278,7 @@ function ln(e) {
|
|
|
1086
1278
|
this._panEnd.copy(this._getMouseOnScreen(i, a));
|
|
1087
1279
|
}
|
|
1088
1280
|
}
|
|
1089
|
-
function
|
|
1281
|
+
function An(e) {
|
|
1090
1282
|
switch (this._pointers.length) {
|
|
1091
1283
|
case 0:
|
|
1092
1284
|
this.state = q.NONE;
|
|
@@ -1102,43 +1294,43 @@ function un(e) {
|
|
|
1102
1294
|
break;
|
|
1103
1295
|
}
|
|
1104
1296
|
}
|
|
1105
|
-
this.dispatchEvent(
|
|
1297
|
+
this.dispatchEvent(sn);
|
|
1106
1298
|
}
|
|
1107
1299
|
//#endregion
|
|
1108
1300
|
//#region src/render/camera.ts
|
|
1109
|
-
var
|
|
1110
|
-
function
|
|
1301
|
+
var jn = 1 / 3, Mn = 1 / 6, Nn = 2, Pn = 1e-12, Fn = new O(0, 0, -1), In = new O(0, 1, 0);
|
|
1302
|
+
function Ln(e, t) {
|
|
1111
1303
|
let n = e.clone().sub(t.clone().multiplyScalar(e.dot(t)));
|
|
1112
|
-
return n.lengthSq() <
|
|
1304
|
+
return n.lengthSq() < Pn ? null : n.normalize();
|
|
1113
1305
|
}
|
|
1114
|
-
function
|
|
1306
|
+
function Rn(e) {
|
|
1115
1307
|
for (let t of [
|
|
1116
|
-
new
|
|
1117
|
-
new
|
|
1118
|
-
new
|
|
1308
|
+
new O(0, 0, 1),
|
|
1309
|
+
new O(0, 1, 0),
|
|
1310
|
+
new O(1, 0, 0)
|
|
1119
1311
|
]) {
|
|
1120
|
-
let n =
|
|
1312
|
+
let n = Ln(t, e);
|
|
1121
1313
|
if (n) return n;
|
|
1122
1314
|
}
|
|
1123
|
-
return new
|
|
1315
|
+
return new O(0, 1, 0);
|
|
1124
1316
|
}
|
|
1125
|
-
function
|
|
1126
|
-
let t = new
|
|
1317
|
+
function zn(e) {
|
|
1318
|
+
let t = new O(...e[0]), n = new O(...e[1]), r = new O(...e[2]).normalize(), i = Ln(t, r) ?? Ln(n, r) ?? Rn(r), a = r.clone().cross(i).normalize(), o = i.clone().add(a.multiplyScalar(jn)).add(r.clone().multiplyScalar(Mn)).normalize();
|
|
1127
1319
|
return {
|
|
1128
1320
|
outward: o,
|
|
1129
|
-
up:
|
|
1321
|
+
up: Ln(r, o) ?? Rn(o)
|
|
1130
1322
|
};
|
|
1131
1323
|
}
|
|
1132
|
-
function
|
|
1324
|
+
function Bn(e) {
|
|
1133
1325
|
return Math.max(4, e * 4);
|
|
1134
1326
|
}
|
|
1135
|
-
function
|
|
1136
|
-
let { outward: t, up: n } =
|
|
1137
|
-
return new
|
|
1327
|
+
function Vn(e) {
|
|
1328
|
+
let { outward: t, up: n } = zn(e), r = n.clone().cross(t).normalize(), i = t.clone().cross(r).normalize(), a = new ae().makeBasis(r, i, t);
|
|
1329
|
+
return new E().setFromRotationMatrix(a).normalize();
|
|
1138
1330
|
}
|
|
1139
|
-
function
|
|
1331
|
+
function Hn(e) {
|
|
1140
1332
|
return {
|
|
1141
|
-
quaternion:
|
|
1333
|
+
quaternion: Wn(Vn(e)),
|
|
1142
1334
|
target: [
|
|
1143
1335
|
0,
|
|
1144
1336
|
0,
|
|
@@ -1147,11 +1339,11 @@ function Sn(e) {
|
|
|
1147
1339
|
scale: 1
|
|
1148
1340
|
};
|
|
1149
1341
|
}
|
|
1150
|
-
function
|
|
1151
|
-
let i = new
|
|
1152
|
-
e.position.copy(a).sub(o.multiplyScalar(n)), e.up.copy(
|
|
1342
|
+
function Un(e, t, n, r) {
|
|
1343
|
+
let i = new E(...t.quaternion).normalize(), a = new O(...t.target), o = Fn.clone().applyQuaternion(i);
|
|
1344
|
+
e.position.copy(a).sub(o.multiplyScalar(n)), e.up.copy(In.clone().applyQuaternion(i)), e.quaternion.copy(i), e.near = .01, e.far = Math.max(1e3, n + r * 8), e.updateProjectionMatrix();
|
|
1153
1345
|
}
|
|
1154
|
-
function
|
|
1346
|
+
function Wn(e) {
|
|
1155
1347
|
return [
|
|
1156
1348
|
e.x,
|
|
1157
1349
|
e.y,
|
|
@@ -1159,10 +1351,10 @@ function wn(e) {
|
|
|
1159
1351
|
e.w
|
|
1160
1352
|
];
|
|
1161
1353
|
}
|
|
1162
|
-
function
|
|
1163
|
-
let n = new
|
|
1354
|
+
function Gn(e, t) {
|
|
1355
|
+
let n = new O(1, 0, 0).applyQuaternion(t), r = new O(0, 1, 0).applyQuaternion(t), i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
1164
1356
|
for (let t of [e.min.x, e.max.x]) for (let c of [e.min.y, e.max.y]) for (let l of [e.min.z, e.max.z]) {
|
|
1165
|
-
let e = new
|
|
1357
|
+
let e = new O(t, c, l), u = e.dot(n), d = e.dot(r);
|
|
1166
1358
|
i = Math.min(i, u), a = Math.max(a, u), o = Math.min(o, d), s = Math.max(s, d);
|
|
1167
1359
|
}
|
|
1168
1360
|
return {
|
|
@@ -1170,31 +1362,31 @@ function Tn(e, t) {
|
|
|
1170
1362
|
height: Math.max(1, s - o)
|
|
1171
1363
|
};
|
|
1172
1364
|
}
|
|
1173
|
-
function
|
|
1174
|
-
let i =
|
|
1175
|
-
return Math.max(.01, a / (o *
|
|
1365
|
+
function Kn(e, t, n, r) {
|
|
1366
|
+
let i = Gn(e, t), a = Math.sqrt(Math.max(1, n) * Math.max(1, r)), o = Math.sqrt(i.width * i.height);
|
|
1367
|
+
return Math.max(.01, a / (o * Nn));
|
|
1176
1368
|
}
|
|
1177
|
-
function
|
|
1369
|
+
function qn(e, t, n) {
|
|
1178
1370
|
e.left = -t / 2, e.right = t / 2, e.top = n / 2, e.bottom = -n / 2, e.updateProjectionMatrix();
|
|
1179
1371
|
}
|
|
1180
1372
|
//#endregion
|
|
1181
1373
|
//#region src/render/materials.ts
|
|
1182
|
-
var
|
|
1374
|
+
var Jn = .1, Yn = .6, Xn = .8, Zn = 2.2, Qn = [
|
|
1183
1375
|
.3,
|
|
1184
1376
|
.2,
|
|
1185
1377
|
0
|
|
1186
|
-
],
|
|
1187
|
-
function
|
|
1378
|
+
], $n = "#fafafa", er = "#444444", tr = "#f2f2f2", nr = .3, rr = "6.28318530718";
|
|
1379
|
+
function ir(e, t) {
|
|
1188
1380
|
return t.reduce((e, [t, n]) => {
|
|
1189
1381
|
if (!e.includes(t)) throw Error(`bravais cannot draw with this three.js: its shader has no ${t}.`);
|
|
1190
1382
|
return e.replace(t, n);
|
|
1191
1383
|
}, e);
|
|
1192
1384
|
}
|
|
1193
|
-
function
|
|
1194
|
-
return
|
|
1385
|
+
function ar(e) {
|
|
1386
|
+
return ir(e, [["#include <common>", "#include <common>\nflat varying int vSectorSite;\nflat varying vec3 vSphereCenter;\nflat varying float vSphereRadius;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vSpherePoint;"], ["#include <project_vertex>", "mat4 sphereMatrix = modelViewMatrix * instanceMatrix;\nvSphereCenter = sphereMatrix[3].xyz;\nvSphereRadius = length(sphereMatrix[0].xyz);\nvSpherePoint = vSphereCenter + vec3(position.xy * vSphereRadius, 0.0);\nvDepthCoefficients = vec2(projectionMatrix[2][2], projectionMatrix[3][2]);\nvSectorSite = gl_InstanceID;\nvec4 mvPosition = vec4(vSpherePoint, 1.0);\ngl_Position = projectionMatrix * mvPosition;"]]);
|
|
1195
1387
|
}
|
|
1196
|
-
function
|
|
1197
|
-
return
|
|
1388
|
+
function or(e) {
|
|
1389
|
+
return ir(e, [
|
|
1198
1390
|
["#include <common>", "#include <common>\nuniform sampler2D sectorTexture;\nuniform float vacancyOpacity;\nflat varying int vSectorSite;\nflat varying vec3 vSphereCenter;\nflat varying float vSphereRadius;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vSpherePoint;"],
|
|
1199
1391
|
["#include <clipping_planes_fragment>", "// Where the view ray meets the sphere. The outline is smoothed over one\n// pixel through the alpha: sample coverage, or blending in a see-through layer.\nvec2 sphereOffset = vSpherePoint.xy - vSphereCenter.xy;\nfloat sphereDistance = length(sphereOffset);\nfloat sphereCoverage = clamp(\n (vSphereRadius - sphereDistance) / max(fwidth(sphereDistance), 1e-6) + 0.5,\n 0.0,\n 1.0\n);\nif (sphereCoverage <= 0.0) {\n discard;\n}\nfloat sphereHeight = sqrt(\n max(0.0, vSphereRadius * vSphereRadius - dot(sphereOffset, sphereOffset))\n);\nvec3 sphereNormal = vec3(sphereOffset, sphereHeight) / vSphereRadius;\nfloat sphereZ = vSphereCenter.z + sphereHeight;\ngl_FragDepth = (vDepthCoefficients.x * sphereZ + vDepthCoefficients.y) * 0.5 + 0.5;\n#include <clipping_planes_fragment>"],
|
|
1200
1392
|
["#include <color_fragment>", `#include <color_fragment>
|
|
@@ -1202,7 +1394,7 @@ function Bn(e) {
|
|
|
1202
1394
|
// A pie chart facing the viewer, like VESTA's occupancy pies: the instance
|
|
1203
1395
|
// colour fills the first sector from 12 o'clock clockwise, then each
|
|
1204
1396
|
// texel's colour from its stop on.
|
|
1205
|
-
float sectorAngle = fract(atan(sphereOffset.x, sphereOffset.y) / ${
|
|
1397
|
+
float sectorAngle = fract(atan(sphereOffset.x, sphereOffset.y) / ${rr});
|
|
1206
1398
|
vec3 sectorColor = vColor.rgb;
|
|
1207
1399
|
float sectorOpacity = 1.0;
|
|
1208
1400
|
int sectorRow = vSectorSite / 256;
|
|
@@ -1222,53 +1414,53 @@ function Bn(e) {
|
|
|
1222
1414
|
["#include <normal_fragment_begin>", "#include <normal_fragment_begin>\nnormal = sphereNormal;\nnonPerturbedNormal = normal;"]
|
|
1223
1415
|
]);
|
|
1224
1416
|
}
|
|
1225
|
-
function
|
|
1226
|
-
let r = e < 1 || n, i = new
|
|
1417
|
+
function sr(e, t, n) {
|
|
1418
|
+
let r = e < 1 || n, i = new S({
|
|
1227
1419
|
color: "#ffffff",
|
|
1228
|
-
metalness:
|
|
1229
|
-
roughness:
|
|
1420
|
+
metalness: Jn,
|
|
1421
|
+
roughness: Yn,
|
|
1230
1422
|
opacity: e,
|
|
1231
1423
|
transparent: r,
|
|
1232
1424
|
alphaToCoverage: !r
|
|
1233
1425
|
});
|
|
1234
1426
|
return i.onBeforeCompile = (e) => {
|
|
1235
|
-
e.uniforms.sectorTexture = { value: t }, e.uniforms.vacancyOpacity = { value:
|
|
1427
|
+
e.uniforms.sectorTexture = { value: t }, e.uniforms.vacancyOpacity = { value: nr }, e.vertexShader = ar(e.vertexShader), e.fragmentShader = or(e.fragmentShader);
|
|
1236
1428
|
}, i.customProgramCacheKey = () => "bravais-atom-spheres", i;
|
|
1237
1429
|
}
|
|
1238
|
-
function
|
|
1239
|
-
return
|
|
1430
|
+
function cr(e) {
|
|
1431
|
+
return ir(e, [["#include <common>", "#include <common>\nuniform float capRadius;\nflat varying vec3 vTubeCenter;\nflat varying vec3 vTubeAxis;\nflat varying vec3 vAtomCenter;\nflat varying float vTubeRadius;\nflat varying float vTubeHalfLength;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vBoxPoint;"], ["#include <project_vertex>", "mat4 tubeMatrix = modelViewMatrix * instanceMatrix;\nfloat tubeLength = max(length(tubeMatrix[1].xyz), 1e-6);\nvTubeRadius = length(tubeMatrix[0].xyz);\nvTubeHalfLength = tubeLength * 0.5;\nvTubeCenter = tubeMatrix[3].xyz;\nvTubeAxis = tubeMatrix[1].xyz / tubeLength;\nfloat rim = sqrt(max(0.0, capRadius * capRadius - vTubeRadius * vTubeRadius));\nvAtomCenter = vTubeCenter - vTubeAxis * (rim + vTubeHalfLength);\nvDepthCoefficients = vec2(projectionMatrix[2][2], projectionMatrix[3][2]);\nvec4 mvPosition = tubeMatrix * vec4(position, 1.0);\nvBoxPoint = mvPosition.xyz;\ngl_Position = projectionMatrix * mvPosition;"]]);
|
|
1240
1432
|
}
|
|
1241
|
-
function
|
|
1242
|
-
return
|
|
1433
|
+
function lr(e) {
|
|
1434
|
+
return ir(e, [
|
|
1243
1435
|
["#include <common>", "#include <common>\nuniform float capRadius;\nflat varying vec3 vTubeCenter;\nflat varying vec3 vTubeAxis;\nflat varying vec3 vAtomCenter;\nflat varying float vTubeRadius;\nflat varying float vTubeHalfLength;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vBoxPoint;"],
|
|
1244
1436
|
["#include <clipping_planes_fragment>", "// The view ray through this pixel runs down view z. The tube's surface is\n// the nearest of: the wall outside the atom's sphere, the sphere's far side\n// inside the tube (the cut face) and the midpoint disc. Along the ray,\n// q(z) = p(z) - centre has q.a = k + (z - cz) a.z and |q|^2 = u + (z - cz)^2.\nvec2 tubePixel = vBoxPoint.xy;\nvec2 tubeOffset = tubePixel - vTubeCenter.xy;\nfloat tubeK = dot(tubeOffset, vTubeAxis.xy);\nfloat tubeU = dot(tubeOffset, tubeOffset);\nfloat axisZ = vTubeAxis.z;\nfloat quadA = 1.0 - axisZ * axisZ;\nfloat quadB = -2.0 * tubeK * axisZ;\nfloat quadC = tubeU - tubeK * tubeK - vTubeRadius * vTubeRadius;\nfloat tubeRadius2 = vTubeRadius * vTubeRadius;\n// The ray's closest approach to the axis, for the outline's coverage.\nfloat axisDistance2 = tubeU - tubeK * tubeK;\nif (quadA > 1e-6) {\n axisDistance2 -= quadB * quadB / (4.0 * quadA);\n}\nfloat axisDistance = sqrt(max(0.0, axisDistance2));\nfloat tubeCoverage = clamp(\n (vTubeRadius - axisDistance) / max(fwidth(axisDistance), 1e-6) + 0.5,\n 0.0,\n 1.0\n);\nif (tubeCoverage <= 0.0) {\n discard;\n}\nfloat tubeHitZ = -1e30;\nvec3 tubeNormal = vec3(0.0, 0.0, 1.0);\nif (quadA > 1e-6) {\n float discriminant = quadB * quadB - 4.0 * quadA * quadC;\n if (discriminant >= 0.0) {\n float z = vTubeCenter.z + (-quadB + sqrt(discriminant)) / (2.0 * quadA);\n vec3 d = vec3(tubePixel, z) - vTubeCenter;\n float s = dot(d, vTubeAxis);\n if (abs(s) <= vTubeHalfLength && distance(vec3(tubePixel, z), vAtomCenter) >= capRadius) {\n tubeHitZ = z;\n tubeNormal = (d - s * vTubeAxis) / vTubeRadius;\n }\n }\n}\nif (axisZ > 1e-6) {\n float z = vTubeCenter.z + (vTubeHalfLength - tubeK) / axisZ;\n vec3 d = vec3(tubePixel, z) - vTubeCenter;\n if (dot(d, d) - vTubeHalfLength * vTubeHalfLength <= tubeRadius2 && z > tubeHitZ &&\n distance(vec3(tubePixel, z), vAtomCenter) >= capRadius) {\n tubeHitZ = z;\n tubeNormal = vTubeAxis;\n }\n}\n{\n vec2 m = tubePixel - vAtomCenter.xy;\n float inside = capRadius * capRadius - dot(m, m);\n if (inside >= 0.0) {\n float z = vAtomCenter.z - sqrt(inside);\n vec3 d = vec3(tubePixel, z) - vTubeCenter;\n float s = dot(d, vTubeAxis);\n if (abs(s) <= vTubeHalfLength && dot(d, d) - s * s <= tubeRadius2 && z > tubeHitZ) {\n tubeHitZ = z;\n tubeNormal = (vAtomCenter - vec3(tubePixel, z)) / capRadius;\n }\n }\n}\nif (tubeHitZ < -1e29) {\n discard;\n}\ngl_FragDepth = (vDepthCoefficients.x * tubeHitZ + vDepthCoefficients.y) * 0.5 + 0.5;\n#include <clipping_planes_fragment>"],
|
|
1245
1437
|
["#include <color_fragment>", "#include <color_fragment>\ndiffuseColor.a *= tubeCoverage;"],
|
|
1246
1438
|
["#include <normal_fragment_begin>", "#include <normal_fragment_begin>\nnormal = tubeNormal;\nnonPerturbedNormal = normal;"]
|
|
1247
1439
|
]);
|
|
1248
1440
|
}
|
|
1249
|
-
function
|
|
1250
|
-
let n = e < 1, r = new
|
|
1441
|
+
function ur(e, t) {
|
|
1442
|
+
let n = e < 1, r = new S({
|
|
1251
1443
|
color: "#ffffff",
|
|
1252
|
-
metalness:
|
|
1253
|
-
roughness:
|
|
1444
|
+
metalness: Jn,
|
|
1445
|
+
roughness: Yn,
|
|
1254
1446
|
opacity: e,
|
|
1255
1447
|
transparent: n,
|
|
1256
1448
|
alphaToCoverage: !n
|
|
1257
1449
|
});
|
|
1258
1450
|
return r.onBeforeCompile = (e) => {
|
|
1259
|
-
e.uniforms.capRadius = { value: t }, e.vertexShader =
|
|
1451
|
+
e.uniforms.capRadius = { value: t }, e.vertexShader = cr(e.vertexShader), e.fragmentShader = lr(e.fragmentShader);
|
|
1260
1452
|
}, r.customProgramCacheKey = () => "bravais-bond-tubes", r;
|
|
1261
1453
|
}
|
|
1262
|
-
function
|
|
1454
|
+
function dr(e) {
|
|
1263
1455
|
return new y({
|
|
1264
|
-
color:
|
|
1456
|
+
color: er,
|
|
1265
1457
|
opacity: e,
|
|
1266
1458
|
transparent: !0,
|
|
1267
1459
|
fog: !1
|
|
1268
1460
|
});
|
|
1269
1461
|
}
|
|
1270
|
-
function
|
|
1271
|
-
return new
|
|
1462
|
+
function fr(e, n) {
|
|
1463
|
+
return new S({
|
|
1272
1464
|
color: e,
|
|
1273
1465
|
metalness: 0,
|
|
1274
1466
|
roughness: .8,
|
|
@@ -1276,32 +1468,32 @@ function Kn(e, n) {
|
|
|
1276
1468
|
stencilWrite: !0,
|
|
1277
1469
|
stencilRef: n,
|
|
1278
1470
|
stencilFunc: t,
|
|
1279
|
-
stencilZPass:
|
|
1471
|
+
stencilZPass: le
|
|
1280
1472
|
});
|
|
1281
1473
|
}
|
|
1282
1474
|
//#endregion
|
|
1283
1475
|
//#region src/render/gizmo.ts
|
|
1284
|
-
var
|
|
1476
|
+
var pr = {
|
|
1285
1477
|
a: "#d27686",
|
|
1286
1478
|
b: "#80c393",
|
|
1287
1479
|
c: "#75a4dd"
|
|
1288
|
-
},
|
|
1289
|
-
function
|
|
1480
|
+
}, mr = .82, hr = .055, gr = .24, _r = .13, vr = .13, yr = 1.3, br = .5, xr = 128, Sr = "#2a2a2a", Cr = "#ffffff", wr = 3.2, Tr = new O(0, 1, 0);
|
|
1481
|
+
function Er(e, t) {
|
|
1290
1482
|
let n = document.createElement("canvas");
|
|
1291
|
-
n.width =
|
|
1483
|
+
n.width = xr, n.height = xr;
|
|
1292
1484
|
let r = n.getContext("2d");
|
|
1293
|
-
r && (r.font = `italic 600 ${
|
|
1485
|
+
r && (r.font = `italic 600 ${xr * .68}px ${t}`, r.textAlign = "center", r.textBaseline = "middle", r.fillStyle = "#ffffff", r.fillText(e, n.width / 2, n.height / 2));
|
|
1294
1486
|
let i = new o(n);
|
|
1295
|
-
return i.colorSpace =
|
|
1487
|
+
return i.colorSpace = ue, i.premultiplyAlpha = !0, i.magFilter = ne, i.minFilter = re, i;
|
|
1296
1488
|
}
|
|
1297
|
-
function
|
|
1298
|
-
let r = new _(), i =
|
|
1299
|
-
a.position.y =
|
|
1300
|
-
let o = new
|
|
1489
|
+
function Dr(e, t, n) {
|
|
1490
|
+
let r = new _(), i = fr(e, 1), a = new x(new u(hr, hr, mr, 24), i);
|
|
1491
|
+
a.position.y = mr / 2;
|
|
1492
|
+
let o = new x(new c(_r, gr, 32), i);
|
|
1301
1493
|
o.position.y = .94, r.add(a, o);
|
|
1302
|
-
let s =
|
|
1494
|
+
let s = Er(t, n), l = [[Sr, oe], [Cr, m]];
|
|
1303
1495
|
for (let [e, t] of l) {
|
|
1304
|
-
let n = new
|
|
1496
|
+
let n = new pe(new me({
|
|
1305
1497
|
map: s,
|
|
1306
1498
|
color: e,
|
|
1307
1499
|
depthTest: !1,
|
|
@@ -1311,29 +1503,29 @@ function sr(e, t, n) {
|
|
|
1311
1503
|
stencilRef: 1,
|
|
1312
1504
|
stencilFunc: t
|
|
1313
1505
|
}));
|
|
1314
|
-
n.scale.set(
|
|
1506
|
+
n.scale.set(br, br, 1), n.position.y = yr, n.renderOrder = 10, r.add(n);
|
|
1315
1507
|
}
|
|
1316
1508
|
return r;
|
|
1317
1509
|
}
|
|
1318
|
-
var
|
|
1319
|
-
scene = new
|
|
1320
|
-
camera = new
|
|
1510
|
+
var Or = class {
|
|
1511
|
+
scene = new de();
|
|
1512
|
+
camera = new T(-3.2 / 2, wr / 2, wr / 2, -3.2 / 2, .1, 20);
|
|
1321
1513
|
axes = new _();
|
|
1322
1514
|
arrows;
|
|
1323
1515
|
headlight = new f("#ffffff", 1.78);
|
|
1324
|
-
direction = new
|
|
1516
|
+
direction = new O();
|
|
1325
1517
|
constructor(e) {
|
|
1326
1518
|
this.camera.position.set(0, 0, 5), this.camera.lookAt(0, 0, 0), this.scene.add(new n("#ffffff", .68)), this.headlight.position.set(1.6, 1.1, 5), this.scene.add(this.headlight), this.arrows = [
|
|
1327
1519
|
"a",
|
|
1328
1520
|
"b",
|
|
1329
1521
|
"c"
|
|
1330
|
-
].map((t) =>
|
|
1331
|
-
let t = new
|
|
1522
|
+
].map((t) => Dr(pr[t], t, e));
|
|
1523
|
+
let t = new x(new fe(vr, 32, 16), fr("#f3f2ee", 0));
|
|
1332
1524
|
this.axes.add(...this.arrows, t), this.scene.add(this.axes);
|
|
1333
1525
|
}
|
|
1334
1526
|
setCell(e) {
|
|
1335
1527
|
this.arrows.forEach((t, n) => {
|
|
1336
|
-
t.quaternion.setFromUnitVectors(
|
|
1528
|
+
t.quaternion.setFromUnitVectors(Tr, this.direction.set(...e[n]).normalize());
|
|
1337
1529
|
});
|
|
1338
1530
|
}
|
|
1339
1531
|
render(e, t, n) {
|
|
@@ -1343,14 +1535,14 @@ var cr = class {
|
|
|
1343
1535
|
}
|
|
1344
1536
|
dispose() {
|
|
1345
1537
|
this.axes.traverse((e) => {
|
|
1346
|
-
if (e instanceof
|
|
1538
|
+
if (e instanceof x || e instanceof pe) {
|
|
1347
1539
|
e.geometry.dispose();
|
|
1348
1540
|
let t = e.material;
|
|
1349
1541
|
"map" in t && t.map && t.map.dispose(), t.dispose();
|
|
1350
1542
|
}
|
|
1351
1543
|
}), this.axes.clear();
|
|
1352
1544
|
}
|
|
1353
|
-
},
|
|
1545
|
+
}, kr = {
|
|
1354
1546
|
source: "VESTA's element colours, softened.",
|
|
1355
1547
|
elements: {
|
|
1356
1548
|
H: "#f2c0c0",
|
|
@@ -1454,21 +1646,21 @@ var cr = class {
|
|
|
1454
1646
|
};
|
|
1455
1647
|
//#endregion
|
|
1456
1648
|
//#region src/render/oklab.ts
|
|
1457
|
-
function
|
|
1649
|
+
function Ar(e) {
|
|
1458
1650
|
return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
1459
1651
|
}
|
|
1460
|
-
function
|
|
1652
|
+
function jr(e) {
|
|
1461
1653
|
return e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
|
|
1462
1654
|
}
|
|
1463
|
-
function
|
|
1464
|
-
let t = Number.parseInt(e.slice(1), 16), n =
|
|
1655
|
+
function Mr(e) {
|
|
1656
|
+
let t = Number.parseInt(e.slice(1), 16), n = Ar((t >> 16 & 255) / 255), r = Ar((t >> 8 & 255) / 255), i = Ar((t & 255) / 255), a = Math.cbrt(.4122214708 * n + .5363325363 * r + .0514459929 * i), o = Math.cbrt(.2119034982 * n + .6806995451 * r + .1073969566 * i), s = Math.cbrt(.0883024619 * n + .2817188376 * r + .6299787005 * i);
|
|
1465
1657
|
return {
|
|
1466
1658
|
L: .2104542553 * a + .793617785 * o - .0040720468 * s,
|
|
1467
1659
|
a: 1.9779984951 * a - 2.428592205 * o + .4505937099 * s,
|
|
1468
1660
|
b: .0259040371 * a + .7827717662 * o - .808675766 * s
|
|
1469
1661
|
};
|
|
1470
1662
|
}
|
|
1471
|
-
function
|
|
1663
|
+
function Nr(e) {
|
|
1472
1664
|
let t = (e.L + .3963377774 * e.a + .2158037573 * e.b) ** 3, n = (e.L - .1055613458 * e.a - .0638541728 * e.b) ** 3, r = (e.L - .0894841775 * e.a - 1.291485548 * e.b) ** 3;
|
|
1473
1665
|
return [
|
|
1474
1666
|
4.0767416621 * t - 3.3077115913 * n + .2309699292 * r,
|
|
@@ -1476,16 +1668,16 @@ function pr(e) {
|
|
|
1476
1668
|
-.0041960863 * t - .7034186147 * n + 1.707614701 * r
|
|
1477
1669
|
];
|
|
1478
1670
|
}
|
|
1479
|
-
function
|
|
1480
|
-
return
|
|
1671
|
+
function Pr(e) {
|
|
1672
|
+
return Nr(e).every((e) => e >= -1e-4 && e <= 1.0001);
|
|
1481
1673
|
}
|
|
1482
|
-
function
|
|
1483
|
-
return `#${
|
|
1484
|
-
let t =
|
|
1674
|
+
function Fr(e) {
|
|
1675
|
+
return `#${Nr(e).map((e) => {
|
|
1676
|
+
let t = jr(Math.min(1, Math.max(0, e)));
|
|
1485
1677
|
return Math.round(t * 255).toString(16).padStart(2, "0");
|
|
1486
1678
|
}).join("")}`;
|
|
1487
1679
|
}
|
|
1488
|
-
function
|
|
1680
|
+
function Ir(e) {
|
|
1489
1681
|
let t = Math.hypot(e.a, e.b), n = (Math.atan2(e.b, e.a) * 180 / Math.PI + 360) % 360;
|
|
1490
1682
|
return {
|
|
1491
1683
|
L: e.L,
|
|
@@ -1493,7 +1685,7 @@ function gr(e) {
|
|
|
1493
1685
|
h: n
|
|
1494
1686
|
};
|
|
1495
1687
|
}
|
|
1496
|
-
function
|
|
1688
|
+
function Lr(e) {
|
|
1497
1689
|
let t = e.h * Math.PI / 180;
|
|
1498
1690
|
return {
|
|
1499
1691
|
L: e.L,
|
|
@@ -1501,12 +1693,12 @@ function X(e) {
|
|
|
1501
1693
|
b: e.C * Math.sin(t)
|
|
1502
1694
|
};
|
|
1503
1695
|
}
|
|
1504
|
-
function
|
|
1505
|
-
if (
|
|
1696
|
+
function Rr(e) {
|
|
1697
|
+
if (Pr(Lr(e))) return e;
|
|
1506
1698
|
let t = 0, n = e.C;
|
|
1507
1699
|
for (let r = 0; r < 24; r += 1) {
|
|
1508
1700
|
let r = (t + n) / 2;
|
|
1509
|
-
|
|
1701
|
+
Pr(Lr({
|
|
1510
1702
|
...e,
|
|
1511
1703
|
C: r
|
|
1512
1704
|
})) ? t = r : n = r;
|
|
@@ -1518,15 +1710,15 @@ function _r(e) {
|
|
|
1518
1710
|
}
|
|
1519
1711
|
//#endregion
|
|
1520
1712
|
//#region src/render/palette.ts
|
|
1521
|
-
var
|
|
1713
|
+
var zr = kr.elements, Br = {
|
|
1522
1714
|
Cr: "#6d87c9",
|
|
1523
1715
|
V: "#bf4b62",
|
|
1524
1716
|
F: "#9bd7d0"
|
|
1525
|
-
},
|
|
1717
|
+
}, Vr = /* @__PURE__ */ "O.Li.Na.K.Mg.Ca.Sr.Ba.Al.Si.Ti.Mn.Fe.Co.Ni.Cu.Zn.V.Cr.Ga.Ge.Y.Zr.Nb.Mo.Ru.Ag.Cd.In.Sn.Sb.La.Ce.Nd.Sm.Gd.Ta.W.Pt.Au.Pb.Bi.H.C.N.F.P.S.Cl.Se.Te.I.Br.B.Sc.Rb.Cs.Hf.Re.Ir.Pd.Rh.Os.Pr.Eu.Tb.Dy.Ho.Er.Tm.Yb.Lu.Th.U".split("."), Hr = new Map(Vr.map((e, t) => [e, t])), Ur = .1, Wr = .7, Z = {
|
|
1526
1718
|
minL: .45,
|
|
1527
1719
|
maxL: .88,
|
|
1528
1720
|
maxC: .2
|
|
1529
|
-
},
|
|
1721
|
+
}, Gr = .025, Kr = .09, qr = .1, Jr = [
|
|
1530
1722
|
0,
|
|
1531
1723
|
10,
|
|
1532
1724
|
-10,
|
|
@@ -1547,7 +1739,7 @@ var vr = lr.elements, yr = {
|
|
|
1547
1739
|
150,
|
|
1548
1740
|
-150,
|
|
1549
1741
|
180
|
|
1550
|
-
],
|
|
1742
|
+
], Yr = [
|
|
1551
1743
|
0,
|
|
1552
1744
|
-.05,
|
|
1553
1745
|
.05,
|
|
@@ -1557,12 +1749,12 @@ var vr = lr.elements, yr = {
|
|
|
1557
1749
|
.15,
|
|
1558
1750
|
-.2,
|
|
1559
1751
|
.2
|
|
1560
|
-
],
|
|
1752
|
+
], Xr = [
|
|
1561
1753
|
0,
|
|
1562
1754
|
.15,
|
|
1563
1755
|
-.15,
|
|
1564
1756
|
.3
|
|
1565
|
-
],
|
|
1757
|
+
], Zr = [
|
|
1566
1758
|
0,
|
|
1567
1759
|
30,
|
|
1568
1760
|
60,
|
|
@@ -1575,76 +1767,76 @@ var vr = lr.elements, yr = {
|
|
|
1575
1767
|
270,
|
|
1576
1768
|
300,
|
|
1577
1769
|
330
|
|
1578
|
-
],
|
|
1579
|
-
function
|
|
1580
|
-
let n = (e.L - t.L) *
|
|
1770
|
+
], Qr = 30, $r = .08, ei = .15, ti = 1.5, ni = 2;
|
|
1771
|
+
function ri(e, t) {
|
|
1772
|
+
let n = (e.L - t.L) * Wr;
|
|
1581
1773
|
return Math.hypot(n, e.a - t.a, e.b - t.b);
|
|
1582
1774
|
}
|
|
1583
|
-
function
|
|
1775
|
+
function ii(e) {
|
|
1584
1776
|
let t = 2166136261;
|
|
1585
1777
|
for (let n = 0; n < e.length; n += 1) t = Math.imul(t ^ e.charCodeAt(n), 16777619) >>> 0;
|
|
1586
1778
|
return t;
|
|
1587
1779
|
}
|
|
1588
|
-
function
|
|
1589
|
-
return
|
|
1780
|
+
function ai(e) {
|
|
1781
|
+
return Br[e] ?? zr[e] ?? null;
|
|
1590
1782
|
}
|
|
1591
|
-
function
|
|
1592
|
-
let t =
|
|
1593
|
-
if (t) return
|
|
1594
|
-
let n =
|
|
1783
|
+
function oi(e) {
|
|
1784
|
+
let t = ai(e);
|
|
1785
|
+
if (t) return Ir(Mr(t));
|
|
1786
|
+
let n = Ce.indexOf(e) + 1;
|
|
1595
1787
|
return {
|
|
1596
1788
|
L: .68,
|
|
1597
1789
|
C: .12,
|
|
1598
|
-
h: (n > 0 ? n :
|
|
1790
|
+
h: (n > 0 ? n : ii(e)) * 137.508 % 360
|
|
1599
1791
|
};
|
|
1600
1792
|
}
|
|
1601
|
-
function
|
|
1602
|
-
let t =
|
|
1793
|
+
function si(e) {
|
|
1794
|
+
let t = Hr.get(e);
|
|
1603
1795
|
if (t !== void 0) return t;
|
|
1604
|
-
let n =
|
|
1605
|
-
return
|
|
1796
|
+
let n = Ce.indexOf(e);
|
|
1797
|
+
return Vr.length + (n >= 0 ? n : Ce.length);
|
|
1606
1798
|
}
|
|
1607
|
-
function
|
|
1608
|
-
return
|
|
1799
|
+
function ci(e) {
|
|
1800
|
+
return Rr({
|
|
1609
1801
|
L: Math.min(Z.maxL, Math.max(Z.minL, e.L)),
|
|
1610
1802
|
C: Math.min(Z.maxC, Math.max(0, e.C)),
|
|
1611
1803
|
h: (e.h % 360 + 360) % 360
|
|
1612
1804
|
});
|
|
1613
1805
|
}
|
|
1614
|
-
function
|
|
1615
|
-
return
|
|
1806
|
+
function li(e, t) {
|
|
1807
|
+
return Rr({
|
|
1616
1808
|
L: e,
|
|
1617
1809
|
C: .5,
|
|
1618
1810
|
h: t
|
|
1619
1811
|
}).C;
|
|
1620
1812
|
}
|
|
1621
|
-
function
|
|
1813
|
+
function ui(e, t) {
|
|
1622
1814
|
return {
|
|
1623
|
-
lab:
|
|
1815
|
+
lab: Lr(ci(e)),
|
|
1624
1816
|
cost: t
|
|
1625
1817
|
};
|
|
1626
1818
|
}
|
|
1627
|
-
function
|
|
1819
|
+
function di(e) {
|
|
1628
1820
|
let t = [];
|
|
1629
|
-
if (e.C <
|
|
1630
|
-
for (let n of
|
|
1631
|
-
let r = Math.abs(n) /
|
|
1632
|
-
t.push(
|
|
1821
|
+
if (e.C < Gr) {
|
|
1822
|
+
for (let n of Yr) {
|
|
1823
|
+
let r = Math.abs(n) / $r * (n > 0 ? ti : 1);
|
|
1824
|
+
t.push(ui({
|
|
1633
1825
|
...e,
|
|
1634
1826
|
L: e.L + n
|
|
1635
1827
|
}, r));
|
|
1636
|
-
for (let i of
|
|
1637
|
-
L: e.L -
|
|
1638
|
-
C:
|
|
1828
|
+
for (let i of Zr) t.push(ui({
|
|
1829
|
+
L: e.L - qr + n,
|
|
1830
|
+
C: Kr,
|
|
1639
1831
|
h: i
|
|
1640
|
-
},
|
|
1832
|
+
}, ni + r + i / 3600));
|
|
1641
1833
|
}
|
|
1642
1834
|
return t.sort((e, t) => e.cost - t.cost);
|
|
1643
1835
|
}
|
|
1644
|
-
let n = e.C / Math.max(1e-6,
|
|
1645
|
-
for (let r of
|
|
1646
|
-
let o = Math.min(Z.maxL, Math.max(Z.minL, e.L + i)), s = e.h + r, c = Math.min(1, Math.max(.1, n + a)) *
|
|
1647
|
-
t.push(
|
|
1836
|
+
let n = e.C / Math.max(1e-6, li(e.L, e.h));
|
|
1837
|
+
for (let r of Jr) for (let i of Yr) for (let a of Xr) {
|
|
1838
|
+
let o = Math.min(Z.maxL, Math.max(Z.minL, e.L + i)), s = e.h + r, c = Math.min(1, Math.max(.1, n + a)) * li(o, s), l = Math.abs(r) / Qr + Math.abs(i) / $r + Math.abs(a) / ei;
|
|
1839
|
+
t.push(ui({
|
|
1648
1840
|
L: o,
|
|
1649
1841
|
C: c,
|
|
1650
1842
|
h: s
|
|
@@ -1653,16 +1845,16 @@ function Wr(e) {
|
|
|
1653
1845
|
return t.sort((e, t) => e.cost - t.cost);
|
|
1654
1846
|
}
|
|
1655
1847
|
var Q = /* @__PURE__ */ new Map();
|
|
1656
|
-
function
|
|
1657
|
-
let n = [...Q.values()].map((e) => e.lab), r = (e) => n.reduce((t, n) => Math.min(t,
|
|
1658
|
-
if (r(i) >=
|
|
1659
|
-
hex: e ??
|
|
1848
|
+
function fi(e, t) {
|
|
1849
|
+
let n = [...Q.values()].map((e) => e.lab), r = (e) => n.reduce((t, n) => Math.min(t, ri(e, n)), Infinity), i = Lr(t);
|
|
1850
|
+
if (r(i) >= Ur) return {
|
|
1851
|
+
hex: e ?? Fr(i),
|
|
1660
1852
|
lab: i
|
|
1661
1853
|
};
|
|
1662
1854
|
let a = null, o = -Infinity, s = Infinity, c = null, l = -Infinity;
|
|
1663
|
-
for (let e of
|
|
1855
|
+
for (let e of di(t)) {
|
|
1664
1856
|
let t = r(e.lab);
|
|
1665
|
-
if (t >=
|
|
1857
|
+
if (t >= Ur) {
|
|
1666
1858
|
if ((e.cost < s - 1e-9 || Math.abs(e.cost - s) <= 1e-9 && t > o) && (a = e, s = e.cost, o = t), e.cost > s + 1e-9) break;
|
|
1667
1859
|
} else t > l && (c = e, l = t);
|
|
1668
1860
|
}
|
|
@@ -1671,36 +1863,36 @@ function Gr(e, t) {
|
|
|
1671
1863
|
cost: 0
|
|
1672
1864
|
};
|
|
1673
1865
|
return {
|
|
1674
|
-
hex:
|
|
1866
|
+
hex: Fr(u.lab),
|
|
1675
1867
|
lab: u.lab
|
|
1676
1868
|
};
|
|
1677
1869
|
}
|
|
1678
|
-
function
|
|
1679
|
-
let t = [...new Set(e)].filter((e) => !Q.has(e)).sort((e, t) =>
|
|
1680
|
-
for (let e of t) Q.set(e,
|
|
1870
|
+
function pi(e) {
|
|
1871
|
+
let t = [...new Set(e)].filter((e) => !Q.has(e)).sort((e, t) => si(e) - si(t));
|
|
1872
|
+
for (let e of t) Q.set(e, fi(ai(e), oi(e)));
|
|
1681
1873
|
}
|
|
1682
|
-
function
|
|
1874
|
+
function mi(e) {
|
|
1683
1875
|
let t = Q.get(e);
|
|
1684
|
-
return t ? t.hex : (
|
|
1876
|
+
return t ? t.hex : (pi([e]), Q.get(e).hex);
|
|
1685
1877
|
}
|
|
1686
|
-
function
|
|
1878
|
+
function hi() {
|
|
1687
1879
|
return [...Q].map(([e, t]) => [e, t.hex]);
|
|
1688
1880
|
}
|
|
1689
|
-
function
|
|
1881
|
+
function gi() {
|
|
1690
1882
|
Q.clear();
|
|
1691
1883
|
}
|
|
1692
1884
|
//#endregion
|
|
1693
1885
|
//#region src/render/legend.ts
|
|
1694
|
-
var
|
|
1695
|
-
function
|
|
1696
|
-
if (e.getElementById(
|
|
1886
|
+
var _i = "bravais-styles", vi = "\n.bravais-viewer {\n position: relative;\n overflow: hidden;\n}\n.bravais-canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n touch-action: none;\n}\n.bravais-legend {\n position: absolute;\n left: 50%;\n bottom: 20px;\n transform: translateX(-50%);\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 8px 16px;\n max-width: calc(100% - 32px);\n padding: 8px 16px;\n border: 1px solid rgba(40, 40, 40, 0.1);\n border-radius: 999px;\n background: rgba(255, 255, 255, 0.72);\n backdrop-filter: blur(24px) saturate(150%);\n box-shadow: 0 10px 15px -3px rgba(40, 40, 40, 0.1);\n font-family: inherit;\n font-size: 0.95rem;\n line-height: 1;\n color: #282828;\n pointer-events: none;\n}\n.bravais-legend[hidden] {\n display: none;\n}\n.bravais-legend-item {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.bravais-legend-swatch {\n width: 18px;\n height: 18px;\n border-radius: 50%;\n border: 1px solid rgba(40, 40, 40, 0.1);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);\n}\n";
|
|
1887
|
+
function yi(e) {
|
|
1888
|
+
if (e.getElementById(_i)) return;
|
|
1697
1889
|
let t = e.createElement("style");
|
|
1698
|
-
t.id =
|
|
1890
|
+
t.id = _i, t.textContent = vi, e.head.appendChild(t);
|
|
1699
1891
|
}
|
|
1700
|
-
function
|
|
1892
|
+
function bi(e) {
|
|
1701
1893
|
return `linear-gradient(135deg, rgba(255, 255, 255, 0.38) 0 14%, rgba(255, 255, 255, 0) 42%), ${e}`;
|
|
1702
1894
|
}
|
|
1703
|
-
var
|
|
1895
|
+
var xi = class {
|
|
1704
1896
|
element;
|
|
1705
1897
|
constructor(e) {
|
|
1706
1898
|
this.element = e.createElement("div"), this.element.className = "bravais-legend", this.element.hidden = !0;
|
|
@@ -1711,17 +1903,17 @@ var ei = class {
|
|
|
1711
1903
|
let e = this.element.ownerDocument.createElement("span");
|
|
1712
1904
|
e.className = "bravais-legend-item";
|
|
1713
1905
|
let n = this.element.ownerDocument.createElement("span");
|
|
1714
|
-
n.className = "bravais-legend-swatch", n.style.background =
|
|
1906
|
+
n.className = "bravais-legend-swatch", n.style.background = bi(mi(t));
|
|
1715
1907
|
let r = this.element.ownerDocument.createElement("span");
|
|
1716
1908
|
r.textContent = t, e.append(n, r), this.element.appendChild(e);
|
|
1717
1909
|
}
|
|
1718
1910
|
this.element.hidden = e.length === 0;
|
|
1719
1911
|
}
|
|
1720
|
-
}, $ = .4,
|
|
1721
|
-
function
|
|
1722
|
-
let [t, n, r] = e.map((e) => new
|
|
1912
|
+
}, $ = .4, Si = .1, Ci = .398, wi = Math.sqrt(Ci * Ci - Si * Si), Ti = new O(0, 1, 0);
|
|
1913
|
+
function Ei(e) {
|
|
1914
|
+
let [t, n, r] = e.map((e) => new O(...e));
|
|
1723
1915
|
return [
|
|
1724
|
-
new
|
|
1916
|
+
new O(),
|
|
1725
1917
|
t.clone(),
|
|
1726
1918
|
n.clone(),
|
|
1727
1919
|
r.clone(),
|
|
@@ -1731,7 +1923,7 @@ function ai(e) {
|
|
|
1731
1923
|
t.clone().add(n).add(r)
|
|
1732
1924
|
];
|
|
1733
1925
|
}
|
|
1734
|
-
function
|
|
1926
|
+
function Di(e) {
|
|
1735
1927
|
let [t, n, r] = e;
|
|
1736
1928
|
return [
|
|
1737
1929
|
(t[0] + n[0] + r[0]) / 2,
|
|
@@ -1739,7 +1931,7 @@ function oi(e) {
|
|
|
1739
1931
|
(t[2] + n[2] + r[2]) / 2
|
|
1740
1932
|
];
|
|
1741
1933
|
}
|
|
1742
|
-
var
|
|
1934
|
+
var Oi = [
|
|
1743
1935
|
[0, 1],
|
|
1744
1936
|
[0, 2],
|
|
1745
1937
|
[0, 3],
|
|
@@ -1753,84 +1945,84 @@ var si = [
|
|
|
1753
1945
|
[5, 7],
|
|
1754
1946
|
[6, 7]
|
|
1755
1947
|
];
|
|
1756
|
-
function
|
|
1757
|
-
let n =
|
|
1758
|
-
for (let [e, t] of
|
|
1948
|
+
function ki(e, t) {
|
|
1949
|
+
let n = Ei(e), r = [];
|
|
1950
|
+
for (let [e, t] of Oi) {
|
|
1759
1951
|
let i = n[e], a = n[t];
|
|
1760
1952
|
r.push(i.x, i.y, i.z, a.x, a.y, a.z);
|
|
1761
1953
|
}
|
|
1762
1954
|
let i = new a();
|
|
1763
|
-
return i.setAttribute("position", new h(r, 3)), new
|
|
1955
|
+
return i.setAttribute("position", new h(r, 3)), new te(i, dr(t));
|
|
1764
1956
|
}
|
|
1765
|
-
function
|
|
1766
|
-
let t = 2048, n = Math.max(1, Math.ceil(e.length / 256)), r = new Float32Array(t * n * 4).fill(1), i = new s(
|
|
1957
|
+
function Ai(e) {
|
|
1958
|
+
let t = 2048, n = Math.max(1, Math.ceil(e.length / 256)), r = new Float32Array(t * n * 4).fill(1), i = new s(tr), a = new s(), o = !1;
|
|
1767
1959
|
e.forEach((e, n) => {
|
|
1768
1960
|
let s = Math.floor(n / 256), c = n % 256 * 8, l = (s * t + c) * 4, u = 0, d = Math.min(1, e.species[0]?.occupancy ?? 1);
|
|
1769
|
-
for (let t of e.species.slice(1)) u < 7 && (a.set(
|
|
1961
|
+
for (let t of e.species.slice(1)) u < 7 && (a.set(mi(t.element)).toArray(r, l), r[l + 3] = d, l += 4, u += 1), d = Math.min(1, d + t.occupancy);
|
|
1770
1962
|
d < 1 - 1e-6 && (i.toArray(r, l), r[l + 3] = d + 2, o = !0);
|
|
1771
1963
|
});
|
|
1772
|
-
let c = new d(r, t, n,
|
|
1773
|
-
return c.magFilter =
|
|
1964
|
+
let c = new d(r, t, n, ce, g);
|
|
1965
|
+
return c.magFilter = C, c.minFilter = C, c.generateMipmaps = !1, c.needsUpdate = !0, {
|
|
1774
1966
|
texture: c,
|
|
1775
1967
|
hasVacancies: o
|
|
1776
1968
|
};
|
|
1777
1969
|
}
|
|
1778
|
-
function
|
|
1970
|
+
function ji() {
|
|
1779
1971
|
let e = /* @__PURE__ */ new Map();
|
|
1780
1972
|
return (t) => {
|
|
1781
1973
|
let n = e.get(t);
|
|
1782
|
-
return n || (n = new s(
|
|
1974
|
+
return n || (n = new s(mi(t)), e.set(t, n)), n;
|
|
1783
1975
|
};
|
|
1784
1976
|
}
|
|
1785
|
-
function
|
|
1786
|
-
let r = new
|
|
1977
|
+
function Mi(e, t, n = ji()) {
|
|
1978
|
+
let r = new se(2, 2), i = Ai(e), a = new v(r, sr(t, i.texture, i.hasVacancies), e.length), o = new ae();
|
|
1787
1979
|
return e.forEach((e, t) => {
|
|
1788
1980
|
o.makeScale($, $, $), o.setPosition(e.position[0], e.position[1], e.position[2]), a.setMatrixAt(t, o), a.setColorAt(t, n(e.element));
|
|
1789
1981
|
}), a.instanceMatrix.needsUpdate = !0, a.instanceColor && (a.instanceColor.needsUpdate = !0), a.userData.sectorTexture = i.texture, a;
|
|
1790
1982
|
}
|
|
1791
|
-
function
|
|
1983
|
+
function Ni(e, t, n = ji()) {
|
|
1792
1984
|
if (e.bonds.length === 0) return null;
|
|
1793
|
-
let r = new i(2, 1, 2), a = new v(r,
|
|
1985
|
+
let r = new i(2, 1, 2), a = new v(r, ur(t, Ci), e.bonds.length * 2), o = new w(), s = new O(), c = new O(), l = new O(), u = new E();
|
|
1794
1986
|
return e.bonds.forEach((t, r) => {
|
|
1795
1987
|
let i = e.atoms[t.start], d = e.atoms[t.end];
|
|
1796
1988
|
s.set(...i.position), c.set(...d.position), l.subVectors(c, s);
|
|
1797
1989
|
let f = l.length() / 2;
|
|
1798
|
-
l.normalize(), u.setFromUnitVectors(
|
|
1990
|
+
l.normalize(), u.setFromUnitVectors(Ti, l);
|
|
1799
1991
|
let p = [[
|
|
1800
1992
|
0,
|
|
1801
1993
|
i,
|
|
1802
|
-
|
|
1994
|
+
wi,
|
|
1803
1995
|
f
|
|
1804
1996
|
], [
|
|
1805
1997
|
1,
|
|
1806
1998
|
d,
|
|
1807
1999
|
f,
|
|
1808
|
-
2 * f -
|
|
2000
|
+
2 * f - wi
|
|
1809
2001
|
]];
|
|
1810
2002
|
for (let [e, t, i, c] of p) {
|
|
1811
2003
|
let d = Math.max(0, c - i);
|
|
1812
|
-
o.position.copy(s).addScaledVector(l, i + d / 2), o.quaternion.copy(u), o.scale.set(
|
|
2004
|
+
o.position.copy(s).addScaledVector(l, i + d / 2), o.quaternion.copy(u), o.scale.set(Si, d, Si), o.updateMatrix(), a.setMatrixAt(r * 2 + e, o.matrix), a.setColorAt(r * 2 + e, n(t.element));
|
|
1813
2005
|
}
|
|
1814
2006
|
}), a.instanceMatrix.needsUpdate = !0, a.instanceColor && (a.instanceColor.needsUpdate = !0), a;
|
|
1815
2007
|
}
|
|
1816
|
-
function
|
|
2008
|
+
function Pi(e) {
|
|
1817
2009
|
let t = e[0];
|
|
1818
2010
|
if (!t) throw Error("A scene model needs at least one layer.");
|
|
1819
|
-
|
|
1820
|
-
let n =
|
|
2011
|
+
pi(e.flatMap((e) => [...e.scene.elements, ...e.scene.atoms.map((e) => e.element)]));
|
|
2012
|
+
let n = Di(t.scene.cell), i = new _();
|
|
1821
2013
|
i.position.set(-n[0], -n[1], -n[2]);
|
|
1822
|
-
let a = new r(), o = [], s = 1, c = [], l = new
|
|
2014
|
+
let a = new r(), o = [], s = 1, c = [], l = new O(...n), u = new O(), d = new O();
|
|
1823
2015
|
for (let t of e) {
|
|
1824
|
-
for (let e of
|
|
2016
|
+
for (let e of Ei(t.scene.cell)) a.expandByPoint(e.sub(l));
|
|
1825
2017
|
for (let e of t.scene.atoms) u.set(...e.position).sub(l), a.expandByPoint(d.copy(u).addScalar($)), a.expandByPoint(d.copy(u).subScalar($));
|
|
1826
2018
|
for (let e of t.scene.cell) s = Math.max(s, Math.hypot(...e));
|
|
1827
2019
|
let e = t.opacity ?? 1;
|
|
1828
2020
|
if (e <= 0) continue;
|
|
1829
|
-
let n =
|
|
2021
|
+
let n = Mi(t.scene.atoms, e);
|
|
1830
2022
|
i.add(n), c.push(n);
|
|
1831
|
-
let r =
|
|
2023
|
+
let r = Ni(t.scene, e);
|
|
1832
2024
|
r && (i.add(r), c.push(r));
|
|
1833
|
-
let f =
|
|
2025
|
+
let f = ki(t.scene.cell, e);
|
|
1834
2026
|
i.add(f), c.push(f);
|
|
1835
2027
|
for (let e of t.scene.elements) o.includes(e) || o.push(e);
|
|
1836
2028
|
}
|
|
@@ -1841,18 +2033,18 @@ function pi(e) {
|
|
|
1841
2033
|
span: s,
|
|
1842
2034
|
elements: o,
|
|
1843
2035
|
dispose() {
|
|
1844
|
-
|
|
2036
|
+
Fi(c), i.clear();
|
|
1845
2037
|
}
|
|
1846
2038
|
};
|
|
1847
2039
|
}
|
|
1848
|
-
function
|
|
2040
|
+
function Fi(e) {
|
|
1849
2041
|
for (let t of e) {
|
|
1850
2042
|
t.geometry.dispose();
|
|
1851
2043
|
let e = t.userData.sectorTexture;
|
|
1852
2044
|
e instanceof d && e.dispose();
|
|
1853
2045
|
}
|
|
1854
2046
|
}
|
|
1855
|
-
var
|
|
2047
|
+
var Ii = {
|
|
1856
2048
|
cell: [
|
|
1857
2049
|
[
|
|
1858
2050
|
1,
|
|
@@ -1896,124 +2088,124 @@ var hi = {
|
|
|
1896
2088
|
}],
|
|
1897
2089
|
elements: []
|
|
1898
2090
|
};
|
|
1899
|
-
function
|
|
2091
|
+
function Li() {
|
|
1900
2092
|
let e = new s("#ffffff"), t = [];
|
|
1901
|
-
for (let n of [1, .5]) t.push(
|
|
1902
|
-
t.push(
|
|
2093
|
+
for (let n of [1, .5]) t.push(Mi(Ii.atoms, n, () => e), Ni(Ii, n, () => e));
|
|
2094
|
+
t.push(ki(Ii.cell, 1));
|
|
1903
2095
|
let n = new _();
|
|
1904
2096
|
return n.add(...t), {
|
|
1905
2097
|
group: n,
|
|
1906
|
-
dispose: () =>
|
|
2098
|
+
dispose: () => Fi(t)
|
|
1907
2099
|
};
|
|
1908
2100
|
}
|
|
1909
2101
|
//#endregion
|
|
1910
2102
|
//#region src/render/stage.ts
|
|
1911
|
-
function
|
|
1912
|
-
let r = new
|
|
2103
|
+
function Ri(t = {}) {
|
|
2104
|
+
let r = new he({
|
|
1913
2105
|
antialias: !0,
|
|
1914
2106
|
alpha: !0,
|
|
1915
2107
|
stencil: t.stencil ?? !1
|
|
1916
2108
|
});
|
|
1917
|
-
r.setClearColor(
|
|
1918
|
-
let i = new
|
|
1919
|
-
i.add(new n("#ffffff",
|
|
1920
|
-
let s = new
|
|
2109
|
+
r.setClearColor($n, 1), r.toneMapping = e;
|
|
2110
|
+
let i = new de(), a = new T(-1, 1, 1, -1, .01, 1e3), o = new f("#ffffff", Zn);
|
|
2111
|
+
i.add(new n("#ffffff", Xn), o, o.target);
|
|
2112
|
+
let s = new O();
|
|
1921
2113
|
return {
|
|
1922
2114
|
renderer: r,
|
|
1923
2115
|
scene: i,
|
|
1924
2116
|
camera: a,
|
|
1925
2117
|
updateHeadlight() {
|
|
1926
2118
|
let e = Math.max(a.position.length(), 4);
|
|
1927
|
-
s.set(...
|
|
2119
|
+
s.set(...Qn).multiplyScalar(e).applyQuaternion(a.quaternion), o.position.copy(a.position).add(s);
|
|
1928
2120
|
}
|
|
1929
2121
|
};
|
|
1930
2122
|
}
|
|
1931
2123
|
//#endregion
|
|
1932
2124
|
//#region src/render/viewer.ts
|
|
1933
|
-
var
|
|
1934
|
-
function
|
|
1935
|
-
let r = new
|
|
2125
|
+
var zi = .4, Bi = .4, Vi = .4, Hi = 2, Ui = 1.2, Wi = .2, Gi = 1500, Ki = .2, qi = 5, Ji = 3, Yi = 1e-5, Xi = 4, Zi = .35, Qi = 110, $i = 180;
|
|
2126
|
+
function ea(e, t, n) {
|
|
2127
|
+
let r = new O(0, 0, 1).applyQuaternion(n), i = 0, a = 0, o = new O();
|
|
1936
2128
|
for (let t of [e.bounds.min.x, e.bounds.max.x]) for (let n of [e.bounds.min.y, e.bounds.max.y]) for (let s of [e.bounds.min.z, e.bounds.max.z]) {
|
|
1937
2129
|
let e = o.set(t, n, s).dot(r);
|
|
1938
2130
|
i = Math.max(i, e), a = Math.min(a, e);
|
|
1939
2131
|
}
|
|
1940
|
-
let s = Math.max(1, e.span), c = Math.max(.01 * s, -a), l = Math.min(c, -i), u = s *
|
|
1941
|
-
return new ee(
|
|
2132
|
+
let s = Math.max(1, e.span), c = Math.max(.01 * s, -a), l = Math.min(c, -i), u = s * Vi, d = l - u, f = t + (d + (Math.max(d, c - u) - d) * Bi), p = f + (t + c - f) / zi;
|
|
2133
|
+
return new ee($n, f, p);
|
|
1942
2134
|
}
|
|
1943
|
-
function
|
|
2135
|
+
function ta(e, t = {}) {
|
|
1944
2136
|
let n = e.ownerDocument;
|
|
1945
|
-
|
|
1946
|
-
let { renderer: r, scene: i, camera: a, updateHeadlight: o } =
|
|
2137
|
+
yi(n), e.classList.add("bravais-viewer");
|
|
2138
|
+
let { renderer: r, scene: i, camera: a, updateHeadlight: o } = Ri({ stencil: !0 });
|
|
1947
2139
|
r.setPixelRatio(n.defaultView?.devicePixelRatio ?? 1), r.domElement.className = "bravais-canvas", e.appendChild(r.domElement);
|
|
1948
|
-
let s = t.legend === !1 ? null : new
|
|
2140
|
+
let s = t.legend === !1 ? null : new xi(n);
|
|
1949
2141
|
s && e.appendChild(s.element);
|
|
1950
|
-
let c = n.defaultView?.getComputedStyle(e).fontFamily ?? "sans-serif", l = t.gizmo === !1 ? null : new
|
|
1951
|
-
u.rotateSpeed =
|
|
1952
|
-
let d = null, f = null, p = 4, m = 1, h = 1, g = 1, _ = null, v = !1, y = 0,
|
|
1953
|
-
function
|
|
1954
|
-
|
|
1955
|
-
for (let e of
|
|
1956
|
-
}
|
|
1957
|
-
function
|
|
2142
|
+
let c = n.defaultView?.getComputedStyle(e).fontFamily ?? "sans-serif", l = t.gizmo === !1 ? null : new Or(c), u = new gn(a, r.domElement);
|
|
2143
|
+
u.rotateSpeed = Hi, u.zoomSpeed = Ui, u.dynamicDampingFactor = Wi, u.staticMoving = !1, u.noPan = !0, u.mouseButtons.LEFT = b.ROTATE, u.mouseButtons.MIDDLE = b.DOLLY, u.mouseButtons.RIGHT = null;
|
|
2144
|
+
let d = null, f = null, p = 4, m = 1, h = 1, g = 1, _ = null, v = !1, y = 0, te = !1, ne = 0, re = !1, ie = new D(), ae = new E(), x = 0, S = new O(), C = /* @__PURE__ */ new Set();
|
|
2145
|
+
function oe() {
|
|
2146
|
+
ne = 0, re = !1;
|
|
2147
|
+
for (let e of C) e();
|
|
2148
|
+
}
|
|
2149
|
+
function w() {
|
|
1958
2150
|
if (!f && (o(), r.setViewport(0, 0, h, g), r.render(i, a), l && d)) {
|
|
1959
|
-
let e = Math.round(Math.min(
|
|
2151
|
+
let e = Math.round(Math.min($i, Math.max(Qi, Math.min(h, g) * Zi)));
|
|
1960
2152
|
l.render(r, a.quaternion, e);
|
|
1961
2153
|
}
|
|
1962
2154
|
}
|
|
1963
|
-
function
|
|
2155
|
+
function T() {
|
|
1964
2156
|
let t = e.getBoundingClientRect();
|
|
1965
2157
|
h = Math.max(1, Math.round(t.width)), g = Math.max(1, Math.round(t.height));
|
|
1966
|
-
let n = r.getSize(
|
|
1967
|
-
(n.x !== h || n.y !== g) && r.setSize(h, g, !1),
|
|
2158
|
+
let n = r.getSize(ie);
|
|
2159
|
+
(n.x !== h || n.y !== g) && r.setSize(h, g, !1), qn(a, h, g), u.handleResize(), u.rotateSpeed = h / Gi * Hi;
|
|
1968
2160
|
}
|
|
1969
|
-
function
|
|
1970
|
-
d && (m =
|
|
1971
|
-
}
|
|
1972
|
-
function oe() {
|
|
1973
|
-
let e = re.angleTo(a.quaternion) > Oi || Math.abs(C - a.zoom) > Oi * m || w.distanceToSquared(u.target) > Oi;
|
|
1974
|
-
return re.copy(a.quaternion), C = a.zoom, w.copy(u.target), e;
|
|
1975
|
-
}
|
|
1976
|
-
function se() {
|
|
1977
|
-
_ = null, u.update(), oe() ? (y = 0, E(), x += 1, te = !0, x >= ki && ie()) : y += 1, b || y < Di ? _ = requestAnimationFrame(se) : (v = !1, te && ie());
|
|
2161
|
+
function se(e) {
|
|
2162
|
+
d && (m = Kn(d.bounds, e, h, g), u.minZoom = m * Ki, u.maxZoom = m * qi);
|
|
1978
2163
|
}
|
|
1979
2164
|
function ce() {
|
|
1980
|
-
|
|
2165
|
+
let e = ae.angleTo(a.quaternion) > Yi || Math.abs(x - a.zoom) > Yi * m || S.distanceToSquared(u.target) > Yi;
|
|
2166
|
+
return ae.copy(a.quaternion), x = a.zoom, S.copy(u.target), e;
|
|
1981
2167
|
}
|
|
1982
2168
|
function le() {
|
|
2169
|
+
_ = null, u.update(), ce() ? (y = 0, w(), ne += 1, re = !0, ne >= Xi && oe()) : y += 1, te || y < Ji ? _ = requestAnimationFrame(le) : (v = !1, re && oe());
|
|
2170
|
+
}
|
|
2171
|
+
function ue() {
|
|
2172
|
+
y = 0, v || (v = !0, _ = requestAnimationFrame(le));
|
|
2173
|
+
}
|
|
2174
|
+
function de() {
|
|
1983
2175
|
_ !== null && (cancelAnimationFrame(_), _ = null), v = !1;
|
|
1984
2176
|
}
|
|
1985
2177
|
u.addEventListener("start", () => {
|
|
1986
|
-
|
|
2178
|
+
te = !0, ue();
|
|
1987
2179
|
}), u.addEventListener("end", () => {
|
|
1988
|
-
|
|
1989
|
-
}), u.addEventListener("change",
|
|
1990
|
-
function
|
|
2180
|
+
te = !1, ue();
|
|
2181
|
+
}), u.addEventListener("change", ue);
|
|
2182
|
+
function fe() {
|
|
1991
2183
|
let e = m > 0 ? a.zoom / m : 1;
|
|
1992
|
-
|
|
1993
|
-
}
|
|
1994
|
-
let
|
|
1995
|
-
|
|
1996
|
-
let
|
|
1997
|
-
i.add(
|
|
1998
|
-
let
|
|
1999
|
-
i.remove(
|
|
2000
|
-
let
|
|
2001
|
-
f ===
|
|
2184
|
+
T(), se(a.quaternion), a.zoom = m * e, a.updateProjectionMatrix(), w();
|
|
2185
|
+
}
|
|
2186
|
+
let pe = typeof ResizeObserver > "u" ? null : new ResizeObserver(fe);
|
|
2187
|
+
pe?.observe(e), T();
|
|
2188
|
+
let me = Li();
|
|
2189
|
+
i.add(me.group), i.fog = new ee($n, 1, 2);
|
|
2190
|
+
let he = Promise.all([r.compileAsync(i, a), l && r.compileAsync(l.scene, l.camera)]);
|
|
2191
|
+
i.remove(me.group), i.fog = null, me.dispose(), f = he;
|
|
2192
|
+
let k = () => {
|
|
2193
|
+
f === he && (f = null, w());
|
|
2002
2194
|
};
|
|
2003
|
-
|
|
2004
|
-
function
|
|
2005
|
-
d && (
|
|
2195
|
+
he.then(k, k);
|
|
2196
|
+
function A(e) {
|
|
2197
|
+
d && (Un(a, e, p, d.span), u.target.set(...e.target), se(a.quaternion), a.zoom = m * e.scale, a.updateProjectionMatrix(), u.update(), ce());
|
|
2006
2198
|
}
|
|
2007
|
-
let
|
|
2199
|
+
let j = {
|
|
2008
2200
|
setLayers(e, t = null) {
|
|
2009
|
-
|
|
2201
|
+
j.clear(), e.length !== 0 && (d = Pi(e), i.add(d.group), p = Bn(d.span), i.fog = ea(d, p, Vn(d.cell)), s?.setElements(d.elements), l?.setCell(d.cell), T(), A(t ?? Hn(d.cell)), w());
|
|
2010
2202
|
},
|
|
2011
2203
|
clear() {
|
|
2012
|
-
|
|
2204
|
+
de(), d &&= (i.remove(d.group), d.dispose(), null), i.fog = null, s?.setElements([]), r.setViewport(0, 0, h, g), r.clear();
|
|
2013
2205
|
},
|
|
2014
2206
|
getView() {
|
|
2015
2207
|
return d ? {
|
|
2016
|
-
quaternion:
|
|
2208
|
+
quaternion: Wn(a.quaternion),
|
|
2017
2209
|
target: [
|
|
2018
2210
|
u.target.x,
|
|
2019
2211
|
u.target.y,
|
|
@@ -2023,32 +2215,32 @@ function Pi(e, t = {}) {
|
|
|
2023
2215
|
} : null;
|
|
2024
2216
|
},
|
|
2025
2217
|
setView(e) {
|
|
2026
|
-
|
|
2218
|
+
A(e), w();
|
|
2027
2219
|
},
|
|
2028
2220
|
resetView() {
|
|
2029
|
-
d &&
|
|
2221
|
+
d && A(Hn(d.cell)), w(), oe();
|
|
2030
2222
|
},
|
|
2031
|
-
resize:
|
|
2032
|
-
render:
|
|
2223
|
+
resize: fe,
|
|
2224
|
+
render: w,
|
|
2033
2225
|
onInteraction(e) {
|
|
2034
|
-
return
|
|
2226
|
+
return C.add(e), () => C.delete(e);
|
|
2035
2227
|
},
|
|
2036
2228
|
dispose() {
|
|
2037
|
-
|
|
2229
|
+
j.clear(), f = null, pe?.disconnect(), u.dispose(), l?.dispose(), r.dispose(), r.domElement.remove(), s?.element.remove(), e.classList.remove("bravais-viewer");
|
|
2038
2230
|
}
|
|
2039
2231
|
};
|
|
2040
|
-
return
|
|
2232
|
+
return j;
|
|
2041
2233
|
}
|
|
2042
2234
|
//#endregion
|
|
2043
2235
|
//#region src/render/thumbnails.ts
|
|
2044
|
-
function
|
|
2045
|
-
let { renderer: e, scene: t, camera: n, updateHeadlight: r } =
|
|
2236
|
+
function na() {
|
|
2237
|
+
let { renderer: e, scene: t, camera: n, updateHeadlight: r } = Ri(), i = /* @__PURE__ */ new Map(), a = Li();
|
|
2046
2238
|
t.add(a.group), e.compile(t, n), t.remove(a.group), a.dispose();
|
|
2047
2239
|
function o(e, t) {
|
|
2048
2240
|
let n = i.get(e);
|
|
2049
2241
|
if (n && n.layers === t) return n.model;
|
|
2050
2242
|
n?.model.dispose();
|
|
2051
|
-
let r =
|
|
2243
|
+
let r = Pi(t);
|
|
2052
2244
|
return i.set(e, {
|
|
2053
2245
|
layers: t,
|
|
2054
2246
|
model: r
|
|
@@ -2059,9 +2251,9 @@ function Fi() {
|
|
|
2059
2251
|
let l = c.getContext("2d");
|
|
2060
2252
|
if (!l || a.length === 0) return;
|
|
2061
2253
|
let u = o(i, a), d = Math.max(1, c.width), f = Math.max(1, c.height);
|
|
2062
|
-
(e.domElement.width !== d || e.domElement.height !== f) && e.setSize(d, f, !1),
|
|
2063
|
-
let p =
|
|
2064
|
-
|
|
2254
|
+
(e.domElement.width !== d || e.domElement.height !== f) && e.setSize(d, f, !1), qn(n, d, f);
|
|
2255
|
+
let p = Bn(u.span), m = s ?? Hn(u.cell);
|
|
2256
|
+
Un(n, m, p, u.span), n.zoom = Kn(u.bounds, new E(...m.quaternion), d, f) * m.scale, n.updateProjectionMatrix(), r(), t.add(u.group), e.render(t, n), t.remove(u.group), l.clearRect(0, 0, d, f), l.drawImage(e.domElement, 0, 0, d, f);
|
|
2065
2257
|
},
|
|
2066
2258
|
release(e) {
|
|
2067
2259
|
i.get(e)?.model.dispose(), i.delete(e);
|
|
@@ -2074,18 +2266,18 @@ function Fi() {
|
|
|
2074
2266
|
}
|
|
2075
2267
|
//#endregion
|
|
2076
2268
|
//#region src/index.ts
|
|
2077
|
-
async function
|
|
2078
|
-
let t =
|
|
2079
|
-
if (!n) throw new
|
|
2080
|
-
let r =
|
|
2269
|
+
async function ra(e) {
|
|
2270
|
+
let t = Se(e), n = t.blocks.find(it) ?? t.blocks[0];
|
|
2271
|
+
if (!n) throw new M("The CIF has no data block.");
|
|
2272
|
+
let r = at(n);
|
|
2081
2273
|
return {
|
|
2082
2274
|
lattice: r.lattice,
|
|
2083
2275
|
sites: r.sites,
|
|
2084
|
-
operations: await
|
|
2276
|
+
operations: await Dt(r, M),
|
|
2085
2277
|
spaceGroup: r.spaceGroup
|
|
2086
2278
|
};
|
|
2087
2279
|
}
|
|
2088
2280
|
//#endregion
|
|
2089
|
-
export {
|
|
2281
|
+
export { M as CifStructureError, j as CifSyntaxError, ft as SpaceGroupLookupError, A as StructureDataError, k as StructureError, Ht as SymmetryAnalysisError, rn as buildScene, na as createThumbnailRenderer, ta as createViewer, mi as elementColor, hi as elementColorAssignments, pi as ensureElementColors, pt as ensureMoyo, Bt as expandStructure, Me as latticeFromParameters, Ne as latticeFromVectors, xt as operationsForSpaceGroup, Se as parseCif, at as parseCifStructure, Xe as parseSymmetryOperation, ra as readCif, zt as readStructure, gi as resetElementColors, nn as structureElements, Gt as symmetryDataset, Yt as typesetSymbol };
|
|
2090
2282
|
|
|
2091
2283
|
//# sourceMappingURL=bravais.js.map
|