bravais 0.1.3 → 0.1.4
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 +8 -0
- package/README.md +11 -17
- package/dist/bravais.js +210 -212
- package/dist/bravais.js.map +1 -1
- package/dist/types/cif/symmetry-operators.d.ts +2 -2
- package/dist/types/index.d.ts +7 -7
- package/dist/types/render/gizmo.d.ts +4 -1
- package/dist/types/render/materials.d.ts +1 -2
- package/dist/types/render/palette.d.ts +5 -6
- package/dist/types/render/thumbnails.d.ts +4 -3
- package/dist/types/render/view-state.d.ts +2 -2
- package/dist/types/render/viewer.d.ts +10 -12
- package/dist/types/scene/build.d.ts +7 -9
- package/dist/types/structure/expand.d.ts +3 -2
- package/dist/types/structure/lattice.d.ts +3 -3
- package/dist/types/symmetry/dataset.d.ts +2 -4
- package/dist/types/symmetry/moyo.d.ts +6 -8
- package/dist/types/symmetry/symbol.d.ts +5 -7
- package/package.json +2 -3
package/dist/bravais.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 _, Group as v, InstancedMesh as y, LineBasicMaterial as ee, LineSegments as
|
|
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 _, Group as v, InstancedMesh as y, LineBasicMaterial as ee, LineSegments as te, LinearFilter as ne, LinearMipmapLinearFilter as re, MOUSE as b, MathUtils as x, Matrix4 as ie, Mesh as S, MeshStandardMaterial as C, NearestFilter as w, NotEqualStencilFunc as ae, Object3D as oe, OrthographicCamera as T, PlaneGeometry as se, Quaternion as E, RGBAFormat as D, ReplaceStencilOp as ce, SRGBColorSpace as le, Scene as O, SphereGeometry as ue, Sprite as k, SpriteMaterial as de, Vector2 as A, Vector3 as j, WebGLRenderer as fe } from "three";
|
|
2
2
|
//#region src/cif/tokenizer.ts
|
|
3
3
|
var M = class extends Error {
|
|
4
4
|
line;
|
|
@@ -884,7 +884,7 @@ var Lt = { type: "change" }, Rt = { type: "start" }, zt = { type: "end" }, K = 1
|
|
|
884
884
|
PAN: 2,
|
|
885
885
|
TOUCH_ROTATE: 3,
|
|
886
886
|
TOUCH_ZOOM_PAN: 4
|
|
887
|
-
}, Bt = new A(), J = new A(), Vt = new j(), Ht = new j(), Ut = new j(), Y = new
|
|
887
|
+
}, Bt = new A(), J = new A(), Vt = new j(), Ht = new j(), Ut = new j(), Y = new E(), Wt = new j(), Gt = new j(), Kt = new j(), qt = new j(), Jt = class extends l {
|
|
888
888
|
constructor(e, t = null) {
|
|
889
889
|
super(e, t), this.screen = {
|
|
890
890
|
left: 0,
|
|
@@ -896,9 +896,9 @@ var Lt = { type: "change" }, Rt = { type: "start" }, zt = { type: "end" }, K = 1
|
|
|
896
896
|
"KeyS",
|
|
897
897
|
"KeyD"
|
|
898
898
|
], this.mouseButtons = {
|
|
899
|
-
LEFT:
|
|
900
|
-
MIDDLE:
|
|
901
|
-
RIGHT:
|
|
899
|
+
LEFT: b.ROTATE,
|
|
900
|
+
MIDDLE: b.DOLLY,
|
|
901
|
+
RIGHT: b.PAN
|
|
902
902
|
}, this.target = new j(), this.state = q.NONE, this.keyState = q.NONE, this._lastPosition = new j(), this._lastUp = new j(), this._lastZoom = 1, this._touchZoomDistanceStart = 0, this._touchZoomDistanceEnd = 0, this._touchRollAngle = 0, this._touchRollPointerIds = "", this._lastAngle = 0, this._lastRollAngle = 0, this._eye = new j(), this._movePrev = new A(), this._moveCurr = new A(), this._lastAxis = new j(), this._zoomStart = new A(), this._zoomEnd = new A(), this._panStart = new A(), this._panEnd = new A(), this._pointers = [], this._pointerPositions = {}, this._onPointerMove = Xt.bind(this), this._onPointerDown = Yt.bind(this), this._onPointerUp = Zt.bind(this), this._onPointerCancel = Qt.bind(this), this._onContextMenu = on.bind(this), this._onMouseWheel = an.bind(this), this._onKeyDown = en.bind(this), this._onKeyUp = $t.bind(this), this._onTouchStart = sn.bind(this), this._onTouchMove = cn.bind(this), this._onTouchEnd = ln.bind(this), this._onMouseDown = tn.bind(this), this._onMouseMove = nn.bind(this), this._onMouseUp = rn.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
903
|
}
|
|
904
904
|
connect(e) {
|
|
@@ -959,7 +959,7 @@ var Lt = { type: "change" }, Rt = { type: "start" }, zt = { type: "end" }, K = 1
|
|
|
959
959
|
}
|
|
960
960
|
_zoomCamera() {
|
|
961
961
|
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 =
|
|
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 = x.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 = x.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
963
|
}
|
|
964
964
|
_getMouseOnScreen(e, t) {
|
|
965
965
|
return Bt.set((e - this.screen.left) / this.screen.width, (t - this.screen.top) / this.screen.height), Bt;
|
|
@@ -1022,13 +1022,13 @@ function tn(e) {
|
|
|
1022
1022
|
default: t = -1;
|
|
1023
1023
|
}
|
|
1024
1024
|
switch (t) {
|
|
1025
|
-
case
|
|
1025
|
+
case b.DOLLY:
|
|
1026
1026
|
this.state = q.ZOOM;
|
|
1027
1027
|
break;
|
|
1028
|
-
case
|
|
1028
|
+
case b.ROTATE:
|
|
1029
1029
|
this.state = q.ROTATE;
|
|
1030
1030
|
break;
|
|
1031
|
-
case
|
|
1031
|
+
case b.PAN:
|
|
1032
1032
|
this.state = q.PAN;
|
|
1033
1033
|
break;
|
|
1034
1034
|
default: this.state = q.NONE;
|
|
@@ -1133,8 +1133,8 @@ function yn(e) {
|
|
|
1133
1133
|
return Math.max(4, e * 4);
|
|
1134
1134
|
}
|
|
1135
1135
|
function bn(e) {
|
|
1136
|
-
let { outward: t, up: n } = vn(e), r = n.clone().cross(t).normalize(), i = t.clone().cross(r).normalize(), a = new
|
|
1137
|
-
return new
|
|
1136
|
+
let { outward: t, up: n } = vn(e), r = n.clone().cross(t).normalize(), i = t.clone().cross(r).normalize(), a = new ie().makeBasis(r, i, t);
|
|
1137
|
+
return new E().setFromRotationMatrix(a).normalize();
|
|
1138
1138
|
}
|
|
1139
1139
|
function xn(e) {
|
|
1140
1140
|
return {
|
|
@@ -1148,7 +1148,7 @@ function xn(e) {
|
|
|
1148
1148
|
};
|
|
1149
1149
|
}
|
|
1150
1150
|
function Sn(e, t, n, r) {
|
|
1151
|
-
let i = new
|
|
1151
|
+
let i = new E(...t.quaternion).normalize(), a = new j(...t.target), o = mn.clone().applyQuaternion(i);
|
|
1152
1152
|
e.position.copy(a).sub(o.multiplyScalar(n)), e.up.copy(hn.clone().applyQuaternion(i)), e.quaternion.copy(i), e.near = .01, e.far = Math.max(1e3, n + r * 8), e.updateProjectionMatrix();
|
|
1153
1153
|
}
|
|
1154
1154
|
function Cn(e) {
|
|
@@ -1223,7 +1223,7 @@ function Rn(e) {
|
|
|
1223
1223
|
]);
|
|
1224
1224
|
}
|
|
1225
1225
|
function zn(e, t, n) {
|
|
1226
|
-
let r = e < 1 || n, i = new
|
|
1226
|
+
let r = e < 1 || n, i = new C({
|
|
1227
1227
|
color: "#ffffff",
|
|
1228
1228
|
metalness: Dn,
|
|
1229
1229
|
roughness: On,
|
|
@@ -1247,7 +1247,7 @@ function Vn(e) {
|
|
|
1247
1247
|
]);
|
|
1248
1248
|
}
|
|
1249
1249
|
function Hn(e, t) {
|
|
1250
|
-
let n = e < 1, r = new
|
|
1250
|
+
let n = e < 1, r = new C({
|
|
1251
1251
|
color: "#ffffff",
|
|
1252
1252
|
metalness: Dn,
|
|
1253
1253
|
roughness: On,
|
|
@@ -1268,7 +1268,7 @@ function Un(e) {
|
|
|
1268
1268
|
});
|
|
1269
1269
|
}
|
|
1270
1270
|
function Wn(e, n) {
|
|
1271
|
-
return new
|
|
1271
|
+
return new C({
|
|
1272
1272
|
color: e,
|
|
1273
1273
|
metalness: 0,
|
|
1274
1274
|
roughness: .8,
|
|
@@ -1276,41 +1276,36 @@ function Wn(e, n) {
|
|
|
1276
1276
|
stencilWrite: !0,
|
|
1277
1277
|
stencilRef: n,
|
|
1278
1278
|
stencilFunc: t,
|
|
1279
|
-
stencilZPass:
|
|
1279
|
+
stencilZPass: ce
|
|
1280
1280
|
});
|
|
1281
1281
|
}
|
|
1282
|
-
function Gn(e) {
|
|
1283
|
-
for (let t of Array.isArray(e) ? e : [e]) t.dispose();
|
|
1284
|
-
}
|
|
1285
1282
|
//#endregion
|
|
1286
1283
|
//#region src/render/gizmo.ts
|
|
1287
|
-
var
|
|
1284
|
+
var Gn = {
|
|
1288
1285
|
a: "#d27686",
|
|
1289
1286
|
b: "#80c393",
|
|
1290
1287
|
c: "#75a4dd"
|
|
1291
|
-
},
|
|
1292
|
-
function
|
|
1288
|
+
}, Kn = .82, qn = .055, Jn = .24, Yn = .13, Xn = .13, Zn = 1.3, Qn = .5, $n = 128, er = "#2a2a2a", tr = "#ffffff", nr = 3.2, rr = new j(0, 1, 0);
|
|
1289
|
+
function ir(e, t) {
|
|
1293
1290
|
let n = document.createElement("canvas");
|
|
1294
|
-
n.width =
|
|
1291
|
+
n.width = $n, n.height = $n;
|
|
1295
1292
|
let r = n.getContext("2d");
|
|
1296
1293
|
if (r) {
|
|
1297
|
-
let i =
|
|
1294
|
+
let i = $n * .68;
|
|
1298
1295
|
r.clearRect(0, 0, n.width, n.height), r.font = `italic 600 ${i}px ${t}`, r.textAlign = "center", r.textBaseline = "middle", r.fillStyle = "#ffffff", r.fillText(e, n.width / 2, n.height / 2);
|
|
1299
1296
|
}
|
|
1300
1297
|
let i = new o(n);
|
|
1301
|
-
return i.colorSpace =
|
|
1302
|
-
}
|
|
1303
|
-
function
|
|
1304
|
-
let
|
|
1305
|
-
|
|
1306
|
-
let
|
|
1307
|
-
o.position.y =
|
|
1308
|
-
let s =
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
let n = new ue(new de({
|
|
1313
|
-
map: l,
|
|
1298
|
+
return i.colorSpace = le, i.premultiplyAlpha = !0, i.magFilter = ne, i.minFilter = re, i;
|
|
1299
|
+
}
|
|
1300
|
+
function ar(e, t, n) {
|
|
1301
|
+
let r = new v(), i = Wn(e, 1), a = new S(new u(qn, qn, Kn, 24), i);
|
|
1302
|
+
a.position.y = Kn / 2;
|
|
1303
|
+
let o = new S(new c(Yn, Jn, 32), i);
|
|
1304
|
+
o.position.y = .94, r.add(a, o);
|
|
1305
|
+
let s = ir(t, n), l = [[er, ae], [tr, m]];
|
|
1306
|
+
for (let [e, t] of l) {
|
|
1307
|
+
let n = new k(new de({
|
|
1308
|
+
map: s,
|
|
1314
1309
|
color: e,
|
|
1315
1310
|
depthTest: !1,
|
|
1316
1311
|
depthWrite: !1,
|
|
@@ -1319,48 +1314,49 @@ function or(e, t, n, r) {
|
|
|
1319
1314
|
stencilRef: 1,
|
|
1320
1315
|
stencilFunc: t
|
|
1321
1316
|
}));
|
|
1322
|
-
n.scale.set(
|
|
1317
|
+
n.scale.set(Qn, Qn, 1), n.position.y = Zn, n.renderOrder = 10, r.add(n);
|
|
1323
1318
|
}
|
|
1324
|
-
return
|
|
1319
|
+
return r;
|
|
1325
1320
|
}
|
|
1326
|
-
var
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
camera = new ae(-1, 1, 1, -1, .1, 20);
|
|
1321
|
+
var or = class {
|
|
1322
|
+
scene = new O();
|
|
1323
|
+
camera = new T(-1, 1, 1, -1, .1, 20);
|
|
1330
1324
|
axes = new v();
|
|
1325
|
+
arrows;
|
|
1331
1326
|
headlight = new f("#ffffff", 1.78);
|
|
1332
|
-
inverse = new
|
|
1327
|
+
inverse = new E();
|
|
1328
|
+
direction = new j();
|
|
1333
1329
|
constructor(e) {
|
|
1334
|
-
this.
|
|
1330
|
+
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 = [
|
|
1331
|
+
"a",
|
|
1332
|
+
"b",
|
|
1333
|
+
"c"
|
|
1334
|
+
].map((t) => ar(Gn[t], t, e));
|
|
1335
|
+
let t = new S(new ue(Xn, 32, 16), Wn("#f3f2ee", 0));
|
|
1336
|
+
this.axes.add(...this.arrows, t), this.scene.add(this.axes);
|
|
1335
1337
|
}
|
|
1336
1338
|
setCell(e) {
|
|
1337
|
-
this.
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
["b", new j(...e[1])],
|
|
1341
|
-
["c", new j(...e[2])]
|
|
1342
|
-
];
|
|
1343
|
-
for (let [e, n] of t) this.axes.add(or(n, Kn[e], e, this.fontFamily));
|
|
1344
|
-
let n = new w(new le(Zn, 32, 16), Wn("#f3f2ee", 0));
|
|
1345
|
-
this.axes.add(n);
|
|
1339
|
+
this.arrows.forEach((t, n) => {
|
|
1340
|
+
t.quaternion.setFromUnitVectors(rr, this.direction.set(...e[n]).normalize());
|
|
1341
|
+
});
|
|
1346
1342
|
}
|
|
1347
1343
|
render(e, t, n) {
|
|
1348
1344
|
this.axes.quaternion.copy(this.inverse.copy(t).invert());
|
|
1349
|
-
let r =
|
|
1345
|
+
let r = nr / 2;
|
|
1350
1346
|
this.camera.left = -1.6, this.camera.right = r, this.camera.top = r, this.camera.bottom = -1.6, this.camera.updateProjectionMatrix();
|
|
1351
1347
|
let i = e.autoClear;
|
|
1352
1348
|
e.autoClear = !1, e.setViewport(0, 0, n, n), e.setScissor(0, 0, n, n), e.setScissorTest(!0), e.clear(!1, !0, !0), e.render(this.scene, this.camera), e.setScissorTest(!1), e.autoClear = i;
|
|
1353
1349
|
}
|
|
1354
1350
|
dispose() {
|
|
1355
1351
|
this.axes.traverse((e) => {
|
|
1356
|
-
if (e instanceof
|
|
1352
|
+
if (e instanceof S || e instanceof k) {
|
|
1357
1353
|
e.geometry.dispose();
|
|
1358
1354
|
let t = e.material;
|
|
1359
1355
|
"map" in t && t.map && t.map.dispose(), t.dispose();
|
|
1360
1356
|
}
|
|
1361
1357
|
}), this.axes.clear();
|
|
1362
1358
|
}
|
|
1363
|
-
},
|
|
1359
|
+
}, sr = {
|
|
1364
1360
|
source: "VESTA's element colours, softened.",
|
|
1365
1361
|
elements: {
|
|
1366
1362
|
H: "#f2c0c0",
|
|
@@ -1464,21 +1460,21 @@ var sr = class {
|
|
|
1464
1460
|
};
|
|
1465
1461
|
//#endregion
|
|
1466
1462
|
//#region src/render/oklab.ts
|
|
1467
|
-
function
|
|
1463
|
+
function cr(e) {
|
|
1468
1464
|
return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
1469
1465
|
}
|
|
1470
|
-
function
|
|
1466
|
+
function lr(e) {
|
|
1471
1467
|
return e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
|
|
1472
1468
|
}
|
|
1473
|
-
function
|
|
1474
|
-
let t = Number.parseInt(e.slice(1), 16), n =
|
|
1469
|
+
function ur(e) {
|
|
1470
|
+
let t = Number.parseInt(e.slice(1), 16), n = cr((t >> 16 & 255) / 255), r = cr((t >> 8 & 255) / 255), i = cr((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);
|
|
1475
1471
|
return {
|
|
1476
1472
|
L: .2104542553 * a + .793617785 * o - .0040720468 * s,
|
|
1477
1473
|
a: 1.9779984951 * a - 2.428592205 * o + .4505937099 * s,
|
|
1478
1474
|
b: .0259040371 * a + .7827717662 * o - .808675766 * s
|
|
1479
1475
|
};
|
|
1480
1476
|
}
|
|
1481
|
-
function
|
|
1477
|
+
function dr(e) {
|
|
1482
1478
|
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;
|
|
1483
1479
|
return [
|
|
1484
1480
|
4.0767416621 * t - 3.3077115913 * n + .2309699292 * r,
|
|
@@ -1486,16 +1482,16 @@ function fr(e) {
|
|
|
1486
1482
|
-.0041960863 * t - .7034186147 * n + 1.707614701 * r
|
|
1487
1483
|
];
|
|
1488
1484
|
}
|
|
1489
|
-
function
|
|
1490
|
-
return
|
|
1485
|
+
function fr(e) {
|
|
1486
|
+
return dr(e).every((e) => e >= -1e-4 && e <= 1.0001);
|
|
1491
1487
|
}
|
|
1492
|
-
function
|
|
1493
|
-
return `#${
|
|
1494
|
-
let t =
|
|
1488
|
+
function pr(e) {
|
|
1489
|
+
return `#${dr(e).map((e) => {
|
|
1490
|
+
let t = lr(Math.min(1, Math.max(0, e)));
|
|
1495
1491
|
return Math.round(t * 255).toString(16).padStart(2, "0");
|
|
1496
1492
|
}).join("")}`;
|
|
1497
1493
|
}
|
|
1498
|
-
function
|
|
1494
|
+
function mr(e) {
|
|
1499
1495
|
let t = Math.hypot(e.a, e.b), n = (Math.atan2(e.b, e.a) * 180 / Math.PI + 360) % 360;
|
|
1500
1496
|
return {
|
|
1501
1497
|
L: e.L,
|
|
@@ -1503,7 +1499,7 @@ function hr(e) {
|
|
|
1503
1499
|
h: n
|
|
1504
1500
|
};
|
|
1505
1501
|
}
|
|
1506
|
-
function
|
|
1502
|
+
function hr(e) {
|
|
1507
1503
|
let t = e.h * Math.PI / 180;
|
|
1508
1504
|
return {
|
|
1509
1505
|
L: e.L,
|
|
@@ -1511,12 +1507,12 @@ function gr(e) {
|
|
|
1511
1507
|
b: e.C * Math.sin(t)
|
|
1512
1508
|
};
|
|
1513
1509
|
}
|
|
1514
|
-
function
|
|
1515
|
-
if (
|
|
1510
|
+
function gr(e) {
|
|
1511
|
+
if (fr(hr(e))) return e;
|
|
1516
1512
|
let t = 0, n = e.C;
|
|
1517
1513
|
for (let r = 0; r < 24; r += 1) {
|
|
1518
1514
|
let r = (t + n) / 2;
|
|
1519
|
-
|
|
1515
|
+
fr(hr({
|
|
1520
1516
|
...e,
|
|
1521
1517
|
C: r
|
|
1522
1518
|
})) ? t = r : n = r;
|
|
@@ -1528,15 +1524,15 @@ function _r(e) {
|
|
|
1528
1524
|
}
|
|
1529
1525
|
//#endregion
|
|
1530
1526
|
//#region src/render/palette.ts
|
|
1531
|
-
var
|
|
1527
|
+
var _r = sr.elements, vr = {
|
|
1532
1528
|
Cr: "#6d87c9",
|
|
1533
1529
|
V: "#bf4b62",
|
|
1534
1530
|
F: "#9bd7d0"
|
|
1535
|
-
},
|
|
1531
|
+
}, yr = /* @__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("."), br = new Map(yr.map((e, t) => [e, t])), xr = .1, Sr = .7, Z = {
|
|
1536
1532
|
minL: .45,
|
|
1537
1533
|
maxL: .88,
|
|
1538
1534
|
maxC: .2
|
|
1539
|
-
},
|
|
1535
|
+
}, Cr = .025, wr = .09, Tr = .1, Er = [
|
|
1540
1536
|
0,
|
|
1541
1537
|
10,
|
|
1542
1538
|
-10,
|
|
@@ -1557,7 +1553,7 @@ var vr = cr.elements, yr = {
|
|
|
1557
1553
|
150,
|
|
1558
1554
|
-150,
|
|
1559
1555
|
180
|
|
1560
|
-
],
|
|
1556
|
+
], Dr = [
|
|
1561
1557
|
0,
|
|
1562
1558
|
-.05,
|
|
1563
1559
|
.05,
|
|
@@ -1567,12 +1563,12 @@ var vr = cr.elements, yr = {
|
|
|
1567
1563
|
.15,
|
|
1568
1564
|
-.2,
|
|
1569
1565
|
.2
|
|
1570
|
-
],
|
|
1566
|
+
], Or = [
|
|
1571
1567
|
0,
|
|
1572
1568
|
.15,
|
|
1573
1569
|
-.15,
|
|
1574
1570
|
.3
|
|
1575
|
-
],
|
|
1571
|
+
], kr = [
|
|
1576
1572
|
0,
|
|
1577
1573
|
30,
|
|
1578
1574
|
60,
|
|
@@ -1585,78 +1581,78 @@ var vr = cr.elements, yr = {
|
|
|
1585
1581
|
270,
|
|
1586
1582
|
300,
|
|
1587
1583
|
330
|
|
1588
|
-
],
|
|
1589
|
-
function
|
|
1590
|
-
let n = (e.L - t.L) *
|
|
1584
|
+
], Ar = 30, jr = .08, Mr = .15, Nr = 1.5, Pr = 2;
|
|
1585
|
+
function Fr(e, t) {
|
|
1586
|
+
let n = (e.L - t.L) * Sr;
|
|
1591
1587
|
return Math.hypot(n, e.a - t.a, e.b - t.b);
|
|
1592
1588
|
}
|
|
1593
|
-
function
|
|
1589
|
+
function Ir(e) {
|
|
1594
1590
|
let t = 2166136261;
|
|
1595
1591
|
for (let n = 0; n < e.length; n += 1) t = Math.imul(t ^ e.charCodeAt(n), 16777619) >>> 0;
|
|
1596
1592
|
return t;
|
|
1597
1593
|
}
|
|
1598
|
-
function
|
|
1599
|
-
return
|
|
1594
|
+
function Lr(e) {
|
|
1595
|
+
return vr[e] ?? _r[e] ?? null;
|
|
1600
1596
|
}
|
|
1601
|
-
function
|
|
1602
|
-
let t =
|
|
1603
|
-
if (t) return
|
|
1597
|
+
function Rr(e) {
|
|
1598
|
+
let t = Lr(e);
|
|
1599
|
+
if (t) return mr(ur(t));
|
|
1604
1600
|
let n = I.indexOf(e) + 1;
|
|
1605
1601
|
return {
|
|
1606
1602
|
L: .68,
|
|
1607
1603
|
C: .12,
|
|
1608
|
-
h: (n > 0 ? n :
|
|
1604
|
+
h: (n > 0 ? n : Ir(e)) * 137.508 % 360
|
|
1609
1605
|
};
|
|
1610
1606
|
}
|
|
1611
|
-
function
|
|
1612
|
-
let t =
|
|
1607
|
+
function zr(e) {
|
|
1608
|
+
let t = br.get(e);
|
|
1613
1609
|
if (t !== void 0) return t;
|
|
1614
1610
|
let n = I.indexOf(e);
|
|
1615
|
-
return
|
|
1611
|
+
return yr.length + (n >= 0 ? n : I.length);
|
|
1616
1612
|
}
|
|
1617
|
-
function
|
|
1618
|
-
return
|
|
1613
|
+
function Br(e) {
|
|
1614
|
+
return gr({
|
|
1619
1615
|
L: Math.min(Z.maxL, Math.max(Z.minL, e.L)),
|
|
1620
1616
|
C: Math.min(Z.maxC, Math.max(0, e.C)),
|
|
1621
1617
|
h: (e.h % 360 + 360) % 360
|
|
1622
1618
|
});
|
|
1623
1619
|
}
|
|
1624
|
-
function
|
|
1625
|
-
return
|
|
1620
|
+
function Vr(e, t) {
|
|
1621
|
+
return gr({
|
|
1626
1622
|
L: e,
|
|
1627
1623
|
C: .5,
|
|
1628
1624
|
h: t
|
|
1629
1625
|
}).C;
|
|
1630
1626
|
}
|
|
1631
|
-
function
|
|
1632
|
-
let n =
|
|
1627
|
+
function Hr(e, t) {
|
|
1628
|
+
let n = Br(e);
|
|
1633
1629
|
return {
|
|
1634
1630
|
lch: n,
|
|
1635
|
-
lab:
|
|
1631
|
+
lab: hr(n),
|
|
1636
1632
|
cost: t
|
|
1637
1633
|
};
|
|
1638
1634
|
}
|
|
1639
|
-
function
|
|
1635
|
+
function Ur(e) {
|
|
1640
1636
|
let t = [];
|
|
1641
|
-
if (e.C <
|
|
1642
|
-
for (let n of
|
|
1643
|
-
let r = Math.abs(n) /
|
|
1644
|
-
t.push(
|
|
1637
|
+
if (e.C < Cr) {
|
|
1638
|
+
for (let n of Dr) {
|
|
1639
|
+
let r = Math.abs(n) / jr * (n > 0 ? Nr : 1);
|
|
1640
|
+
t.push(Hr({
|
|
1645
1641
|
...e,
|
|
1646
1642
|
L: e.L + n
|
|
1647
1643
|
}, r));
|
|
1648
|
-
for (let i of
|
|
1649
|
-
L: e.L -
|
|
1650
|
-
C:
|
|
1644
|
+
for (let i of kr) t.push(Hr({
|
|
1645
|
+
L: e.L - Tr + n,
|
|
1646
|
+
C: wr,
|
|
1651
1647
|
h: i
|
|
1652
|
-
},
|
|
1648
|
+
}, Pr + r + i / 3600));
|
|
1653
1649
|
}
|
|
1654
1650
|
return t.sort((e, t) => e.cost - t.cost);
|
|
1655
1651
|
}
|
|
1656
|
-
let n = e.C / Math.max(1e-6,
|
|
1657
|
-
for (let r of
|
|
1658
|
-
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)) *
|
|
1659
|
-
t.push(
|
|
1652
|
+
let n = e.C / Math.max(1e-6, Vr(e.L, e.h));
|
|
1653
|
+
for (let r of Er) for (let i of Dr) for (let a of Or) {
|
|
1654
|
+
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)) * Vr(o, s), l = Math.abs(r) / Ar + Math.abs(i) / jr + Math.abs(a) / Mr;
|
|
1655
|
+
t.push(Hr({
|
|
1660
1656
|
L: o,
|
|
1661
1657
|
C: c,
|
|
1662
1658
|
h: s
|
|
@@ -1665,16 +1661,16 @@ function Wr(e) {
|
|
|
1665
1661
|
return t.sort((e, t) => e.cost - t.cost);
|
|
1666
1662
|
}
|
|
1667
1663
|
var Q = /* @__PURE__ */ new Map();
|
|
1668
|
-
function
|
|
1669
|
-
let n = [...Q.values()].map((e) => e.lab), r = (e) => n.reduce((t, n) => Math.min(t,
|
|
1670
|
-
if (r(i) >=
|
|
1671
|
-
hex: e ??
|
|
1664
|
+
function Wr(e, t) {
|
|
1665
|
+
let n = [...Q.values()].map((e) => e.lab), r = (e) => n.reduce((t, n) => Math.min(t, Fr(e, n)), Infinity), i = hr(t);
|
|
1666
|
+
if (r(i) >= xr) return {
|
|
1667
|
+
hex: e ?? pr(i),
|
|
1672
1668
|
lab: i
|
|
1673
1669
|
};
|
|
1674
1670
|
let a = null, o = -Infinity, s = Infinity, c = null, l = -Infinity;
|
|
1675
|
-
for (let e of
|
|
1671
|
+
for (let e of Ur(t)) {
|
|
1676
1672
|
let t = r(e.lab);
|
|
1677
|
-
if (t >=
|
|
1673
|
+
if (t >= xr) {
|
|
1678
1674
|
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;
|
|
1679
1675
|
} else t > l && (c = e, l = t);
|
|
1680
1676
|
}
|
|
@@ -1684,36 +1680,36 @@ function Gr(e, t) {
|
|
|
1684
1680
|
cost: 0
|
|
1685
1681
|
};
|
|
1686
1682
|
return {
|
|
1687
|
-
hex:
|
|
1683
|
+
hex: pr(u.lab),
|
|
1688
1684
|
lab: u.lab
|
|
1689
1685
|
};
|
|
1690
1686
|
}
|
|
1691
|
-
function
|
|
1692
|
-
let t = [...new Set(e)].filter((e) => !Q.has(e)).sort((e, t) =>
|
|
1693
|
-
for (let e of t) Q.set(e,
|
|
1687
|
+
function Gr(e) {
|
|
1688
|
+
let t = [...new Set(e)].filter((e) => !Q.has(e)).sort((e, t) => zr(e) - zr(t));
|
|
1689
|
+
for (let e of t) Q.set(e, Wr(Lr(e), Rr(e)));
|
|
1694
1690
|
}
|
|
1695
|
-
function
|
|
1691
|
+
function Kr(e) {
|
|
1696
1692
|
let t = Q.get(e);
|
|
1697
|
-
return t ? t.hex : (
|
|
1693
|
+
return t ? t.hex : (Gr([e]), Q.get(e).hex);
|
|
1698
1694
|
}
|
|
1699
|
-
function
|
|
1695
|
+
function qr() {
|
|
1700
1696
|
return [...Q].map(([e, t]) => [e, t.hex]);
|
|
1701
1697
|
}
|
|
1702
|
-
function
|
|
1698
|
+
function Jr() {
|
|
1703
1699
|
Q.clear();
|
|
1704
1700
|
}
|
|
1705
1701
|
//#endregion
|
|
1706
1702
|
//#region src/render/legend.ts
|
|
1707
|
-
var
|
|
1708
|
-
function
|
|
1709
|
-
if (e.getElementById(
|
|
1703
|
+
var Yr = "bravais-styles", Xr = "\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";
|
|
1704
|
+
function Zr(e) {
|
|
1705
|
+
if (e.getElementById(Yr)) return;
|
|
1710
1706
|
let t = e.createElement("style");
|
|
1711
|
-
t.id =
|
|
1707
|
+
t.id = Yr, t.textContent = Xr, e.head.appendChild(t);
|
|
1712
1708
|
}
|
|
1713
|
-
function
|
|
1709
|
+
function Qr(e) {
|
|
1714
1710
|
return `linear-gradient(135deg, rgba(255, 255, 255, 0.38) 0 14%, rgba(255, 255, 255, 0) 42%), ${e}`;
|
|
1715
1711
|
}
|
|
1716
|
-
var
|
|
1712
|
+
var $r = class {
|
|
1717
1713
|
element;
|
|
1718
1714
|
constructor(e) {
|
|
1719
1715
|
this.element = e.createElement("div"), this.element.className = "bravais-legend", this.element.hidden = !0;
|
|
@@ -1724,14 +1720,14 @@ var ei = class {
|
|
|
1724
1720
|
let e = this.element.ownerDocument.createElement("span");
|
|
1725
1721
|
e.className = "bravais-legend-item";
|
|
1726
1722
|
let n = this.element.ownerDocument.createElement("span");
|
|
1727
|
-
n.className = "bravais-legend-swatch", n.style.background =
|
|
1723
|
+
n.className = "bravais-legend-swatch", n.style.background = Qr(Kr(t));
|
|
1728
1724
|
let r = this.element.ownerDocument.createElement("span");
|
|
1729
1725
|
r.textContent = t, e.append(n, r), this.element.appendChild(e);
|
|
1730
1726
|
}
|
|
1731
1727
|
this.element.hidden = e.length === 0;
|
|
1732
1728
|
}
|
|
1733
|
-
}, $ = .4,
|
|
1734
|
-
function
|
|
1729
|
+
}, $ = .4, ei = .1, ti = .398, ni = Math.sqrt(ti * ti - ei * ei), ri = new j(0, 1, 0);
|
|
1730
|
+
function ii(e) {
|
|
1735
1731
|
let [t, n, r] = e.map((e) => new j(...e));
|
|
1736
1732
|
return [
|
|
1737
1733
|
new j(),
|
|
@@ -1744,7 +1740,7 @@ function ai(e) {
|
|
|
1744
1740
|
t.clone().add(n).add(r)
|
|
1745
1741
|
];
|
|
1746
1742
|
}
|
|
1747
|
-
function
|
|
1743
|
+
function ai(e) {
|
|
1748
1744
|
let [t, n, r] = e;
|
|
1749
1745
|
return [
|
|
1750
1746
|
(t[0] + n[0] + r[0]) / 2,
|
|
@@ -1752,7 +1748,7 @@ function oi(e) {
|
|
|
1752
1748
|
(t[2] + n[2] + r[2]) / 2
|
|
1753
1749
|
];
|
|
1754
1750
|
}
|
|
1755
|
-
var
|
|
1751
|
+
var oi = [
|
|
1756
1752
|
[0, 1],
|
|
1757
1753
|
[0, 2],
|
|
1758
1754
|
[0, 3],
|
|
@@ -1766,84 +1762,84 @@ var si = [
|
|
|
1766
1762
|
[5, 7],
|
|
1767
1763
|
[6, 7]
|
|
1768
1764
|
];
|
|
1769
|
-
function
|
|
1770
|
-
let n =
|
|
1771
|
-
for (let [e, t] of
|
|
1765
|
+
function si(e, t) {
|
|
1766
|
+
let n = ii(e), r = [];
|
|
1767
|
+
for (let [e, t] of oi) {
|
|
1772
1768
|
let i = n[e], a = n[t];
|
|
1773
1769
|
r.push(i.x, i.y, i.z, a.x, a.y, a.z);
|
|
1774
1770
|
}
|
|
1775
1771
|
let i = new a();
|
|
1776
|
-
return i.setAttribute("position", new h(r, 3)), new
|
|
1772
|
+
return i.setAttribute("position", new h(r, 3)), new te(i, Un(t));
|
|
1777
1773
|
}
|
|
1778
|
-
function
|
|
1774
|
+
function ci(e) {
|
|
1779
1775
|
let t = 2048, n = Math.max(1, Math.ceil(e.length / 256)), r = new Float32Array(t * n * 4).fill(1), i = new s(Pn), a = new s(), o = !1;
|
|
1780
1776
|
e.forEach((e, n) => {
|
|
1781
1777
|
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);
|
|
1782
|
-
for (let t of e.species.slice(1)) u < 7 && (a.set(
|
|
1778
|
+
for (let t of e.species.slice(1)) u < 7 && (a.set(Kr(t.element)).toArray(r, l), r[l + 3] = d, l += 4, u += 1), d = Math.min(1, d + t.occupancy);
|
|
1783
1779
|
d < 1 - 1e-6 && (i.toArray(r, l), r[l + 3] = d + 2, o = !0);
|
|
1784
1780
|
});
|
|
1785
|
-
let c = new d(r, t, n,
|
|
1786
|
-
return c.magFilter =
|
|
1781
|
+
let c = new d(r, t, n, D, g);
|
|
1782
|
+
return c.magFilter = w, c.minFilter = w, c.generateMipmaps = !1, c.needsUpdate = !0, {
|
|
1787
1783
|
texture: c,
|
|
1788
1784
|
hasVacancies: o
|
|
1789
1785
|
};
|
|
1790
1786
|
}
|
|
1791
|
-
function
|
|
1787
|
+
function li() {
|
|
1792
1788
|
let e = /* @__PURE__ */ new Map();
|
|
1793
1789
|
return (t) => {
|
|
1794
1790
|
let n = e.get(t);
|
|
1795
|
-
return n || (n = new s(
|
|
1791
|
+
return n || (n = new s(Kr(t)), e.set(t, n)), n;
|
|
1796
1792
|
};
|
|
1797
1793
|
}
|
|
1798
|
-
function
|
|
1799
|
-
let n = new
|
|
1794
|
+
function ui(e, t) {
|
|
1795
|
+
let n = new se(2, 2), r = ci(e), i = new y(n, zn(t, r.texture, r.hasVacancies), e.length), a = new ie(), o = li();
|
|
1800
1796
|
return e.forEach((e, t) => {
|
|
1801
1797
|
a.makeScale($, $, $), a.setPosition(e.position[0], e.position[1], e.position[2]), i.setMatrixAt(t, a), i.setColorAt(t, o(e.element));
|
|
1802
1798
|
}), i.instanceMatrix.needsUpdate = !0, i.instanceColor && (i.instanceColor.needsUpdate = !0), i.userData.sectorTexture = r.texture, i;
|
|
1803
1799
|
}
|
|
1804
|
-
function
|
|
1800
|
+
function di(e, t) {
|
|
1805
1801
|
if (e.bonds.length === 0) return null;
|
|
1806
|
-
let n = new i(2, 1, 2), r = new y(n, Hn(t,
|
|
1802
|
+
let n = new i(2, 1, 2), r = new y(n, Hn(t, ti), e.bonds.length * 2), a = new oe(), o = new j(), s = new j(), c = new j(), l = new E(), u = li();
|
|
1807
1803
|
return e.bonds.forEach((t, n) => {
|
|
1808
1804
|
let i = e.atoms[t.start], d = e.atoms[t.end];
|
|
1809
1805
|
o.set(...i.position), s.set(...d.position), c.subVectors(s, o);
|
|
1810
1806
|
let f = c.length() / 2;
|
|
1811
|
-
c.normalize(), l.setFromUnitVectors(
|
|
1807
|
+
c.normalize(), l.setFromUnitVectors(ri, c);
|
|
1812
1808
|
let p = [[
|
|
1813
1809
|
0,
|
|
1814
1810
|
i,
|
|
1815
|
-
|
|
1811
|
+
ni,
|
|
1816
1812
|
f
|
|
1817
1813
|
], [
|
|
1818
1814
|
1,
|
|
1819
1815
|
d,
|
|
1820
1816
|
f,
|
|
1821
|
-
2 * f -
|
|
1817
|
+
2 * f - ni
|
|
1822
1818
|
]];
|
|
1823
1819
|
for (let [e, t, i, s] of p) {
|
|
1824
1820
|
let d = Math.max(0, s - i);
|
|
1825
|
-
a.position.copy(o).addScaledVector(c, i + d / 2), a.quaternion.copy(l), a.scale.set(
|
|
1821
|
+
a.position.copy(o).addScaledVector(c, i + d / 2), a.quaternion.copy(l), a.scale.set(ei, d, ei), a.updateMatrix(), r.setMatrixAt(n * 2 + e, a.matrix), r.setColorAt(n * 2 + e, u(t.element));
|
|
1826
1822
|
}
|
|
1827
1823
|
}), r.instanceMatrix.needsUpdate = !0, r.instanceColor && (r.instanceColor.needsUpdate = !0), r;
|
|
1828
1824
|
}
|
|
1829
|
-
function
|
|
1825
|
+
function fi(e) {
|
|
1830
1826
|
let t = e[0];
|
|
1831
1827
|
if (!t) throw Error("A scene model needs at least one layer.");
|
|
1832
|
-
|
|
1833
|
-
let n =
|
|
1828
|
+
Gr(e.flatMap((e) => [...e.scene.elements, ...e.scene.atoms.map((e) => e.element)]));
|
|
1829
|
+
let n = ai(t.scene.cell), i = new v();
|
|
1834
1830
|
i.position.set(-n[0], -n[1], -n[2]);
|
|
1835
1831
|
let a = new r(), o = [], s = 1, c = [], l = new j(...n), u = new j(), f = new j();
|
|
1836
1832
|
for (let t of e) {
|
|
1837
|
-
for (let e of
|
|
1833
|
+
for (let e of ii(t.scene.cell)) a.expandByPoint(e.sub(l));
|
|
1838
1834
|
for (let e of t.scene.atoms) u.set(...e.position).sub(l), a.expandByPoint(f.copy(u).addScalar($)), a.expandByPoint(f.copy(u).subScalar($));
|
|
1839
1835
|
for (let e of t.scene.cell) s = Math.max(s, Math.hypot(...e));
|
|
1840
1836
|
let e = t.opacity ?? 1;
|
|
1841
1837
|
if (e <= 0) continue;
|
|
1842
|
-
let n =
|
|
1838
|
+
let n = ui(t.scene.atoms, e);
|
|
1843
1839
|
i.add(n), c.push(n);
|
|
1844
|
-
let r =
|
|
1840
|
+
let r = di(t.scene, e);
|
|
1845
1841
|
r && (i.add(r), c.push(r));
|
|
1846
|
-
let d =
|
|
1842
|
+
let d = si(t.scene.cell, e);
|
|
1847
1843
|
i.add(d), c.push(d);
|
|
1848
1844
|
for (let e of t.scene.elements) o.includes(e) || o.push(e);
|
|
1849
1845
|
}
|
|
@@ -1856,7 +1852,7 @@ function pi(e) {
|
|
|
1856
1852
|
elements: o,
|
|
1857
1853
|
dispose() {
|
|
1858
1854
|
for (let e of c) {
|
|
1859
|
-
e.geometry.dispose()
|
|
1855
|
+
e.geometry.dispose();
|
|
1860
1856
|
let t = e.userData.sectorTexture;
|
|
1861
1857
|
t instanceof d && t.dispose();
|
|
1862
1858
|
}
|
|
@@ -1866,14 +1862,14 @@ function pi(e) {
|
|
|
1866
1862
|
}
|
|
1867
1863
|
//#endregion
|
|
1868
1864
|
//#region src/render/stage.ts
|
|
1869
|
-
function
|
|
1865
|
+
function pi(t = {}) {
|
|
1870
1866
|
let r = new fe({
|
|
1871
1867
|
antialias: !0,
|
|
1872
1868
|
alpha: !0,
|
|
1873
1869
|
stencil: t.stencil ?? !1
|
|
1874
1870
|
});
|
|
1875
1871
|
r.setClearColor(Mn, 1), r.toneMapping = e;
|
|
1876
|
-
let i = new
|
|
1872
|
+
let i = new O(), a = new T(-1, 1, 1, -1, .01, 1e3), o = new f("#ffffff", An);
|
|
1877
1873
|
i.add(new n("#ffffff", kn), o, o.target);
|
|
1878
1874
|
let s = new j();
|
|
1879
1875
|
return {
|
|
@@ -1888,54 +1884,56 @@ function mi(t = {}) {
|
|
|
1888
1884
|
}
|
|
1889
1885
|
//#endregion
|
|
1890
1886
|
//#region src/render/viewer.ts
|
|
1891
|
-
var
|
|
1892
|
-
function
|
|
1887
|
+
var mi = .4, hi = .4, gi = .4, _i = 2, vi = 1.2, yi = .2, bi = 1500, xi = .2, Si = 5, Ci = 3, wi = 1e-5, Ti = 4, Ei = .35, Di = 110, Oi = 180;
|
|
1888
|
+
function ki(e, t, n) {
|
|
1893
1889
|
let r = new j(0, 0, 1).applyQuaternion(n), i = 0, a = 0, o = new j();
|
|
1894
1890
|
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]) {
|
|
1895
1891
|
let e = o.set(t, n, s).dot(r);
|
|
1896
1892
|
i = Math.max(i, e), a = Math.min(a, e);
|
|
1897
1893
|
}
|
|
1898
|
-
let s = Math.max(1, e.span), c = Math.max(.01 * s, -a), l = Math.min(c, -i), u = s *
|
|
1894
|
+
let s = Math.max(1, e.span), c = Math.max(.01 * s, -a), l = Math.min(c, -i), u = s * gi, d = l - u, f = t + (d + (Math.max(d, c - u) - d) * hi), p = f + (t + c - f) / mi;
|
|
1899
1895
|
return new _(Mn, f, p);
|
|
1900
1896
|
}
|
|
1901
|
-
function
|
|
1897
|
+
function Ai(e, t = {}) {
|
|
1902
1898
|
let n = e.ownerDocument;
|
|
1903
|
-
|
|
1904
|
-
let { renderer: r, scene: i, camera: a, updateHeadlight: o } =
|
|
1899
|
+
Zr(n), e.classList.add("bravais-viewer");
|
|
1900
|
+
let { renderer: r, scene: i, camera: a, updateHeadlight: o } = pi({ stencil: !0 });
|
|
1905
1901
|
r.setPixelRatio(n.defaultView?.devicePixelRatio ?? 1), r.domElement.className = "bravais-canvas", e.appendChild(r.domElement);
|
|
1906
|
-
let s = t.legend === !1 ? null : new
|
|
1902
|
+
let s = t.legend === !1 ? null : new $r(n);
|
|
1907
1903
|
s && e.appendChild(s.element);
|
|
1908
|
-
let c = n.defaultView?.getComputedStyle(e).fontFamily ?? "sans-serif", l = t.gizmo === !1 ? null : new
|
|
1909
|
-
u.rotateSpeed =
|
|
1910
|
-
let d = null, f = 4, p = 1, m = 1, h = 1, g = null, _ = !1, v = 0, y = !1, ee = 0,
|
|
1911
|
-
function
|
|
1912
|
-
ee = 0,
|
|
1913
|
-
for (let e of
|
|
1904
|
+
let c = n.defaultView?.getComputedStyle(e).fontFamily ?? "sans-serif", l = t.gizmo === !1 ? null : new or(c), u = new Jt(a, r.domElement);
|
|
1905
|
+
u.rotateSpeed = _i, u.zoomSpeed = vi, u.dynamicDampingFactor = yi, u.staticMoving = !1, u.noPan = !0, u.mouseButtons.LEFT = b.ROTATE, u.mouseButtons.MIDDLE = b.DOLLY, u.mouseButtons.RIGHT = null;
|
|
1906
|
+
let d = null, f = 4, p = 1, m = 1, h = 1, g = null, _ = !1, v = 0, y = !1, ee = 0, te = !1, ne = new A(), re = new E(), x = 0, ie = new j(), S = /* @__PURE__ */ new Set();
|
|
1907
|
+
function C() {
|
|
1908
|
+
ee = 0, te = !1;
|
|
1909
|
+
for (let e of S) e();
|
|
1914
1910
|
}
|
|
1915
|
-
function
|
|
1911
|
+
function w() {
|
|
1916
1912
|
if (o(), r.setViewport(0, 0, m, h), r.render(i, a), l && d) {
|
|
1917
|
-
let e = Math.round(Math.min(
|
|
1913
|
+
let e = Math.round(Math.min(Oi, Math.max(Di, Math.min(m, h) * Ei)));
|
|
1918
1914
|
l.render(r, a.quaternion, e);
|
|
1919
1915
|
}
|
|
1920
1916
|
}
|
|
1921
|
-
function
|
|
1917
|
+
function ae() {
|
|
1922
1918
|
let t = e.getBoundingClientRect();
|
|
1923
|
-
m = Math.max(1, Math.round(t.width)), h = Math.max(1, Math.round(t.height))
|
|
1919
|
+
m = Math.max(1, Math.round(t.width)), h = Math.max(1, Math.round(t.height));
|
|
1920
|
+
let n = r.getSize(ne);
|
|
1921
|
+
(n.x !== m || n.y !== h) && r.setSize(m, h, !1), En(a, m, h), u.handleResize(), u.rotateSpeed = m / bi * _i;
|
|
1924
1922
|
}
|
|
1925
|
-
function
|
|
1926
|
-
d && (p = Tn(d.bounds, e, m, h), u.minZoom = p *
|
|
1923
|
+
function oe(e) {
|
|
1924
|
+
d && (p = Tn(d.bounds, e, m, h), u.minZoom = p * xi, u.maxZoom = p * Si);
|
|
1927
1925
|
}
|
|
1928
|
-
function
|
|
1929
|
-
let e =
|
|
1930
|
-
return
|
|
1926
|
+
function T() {
|
|
1927
|
+
let e = re.angleTo(a.quaternion) > wi || Math.abs(x - a.zoom) > wi * p || ie.distanceToSquared(u.target) > wi;
|
|
1928
|
+
return re.copy(a.quaternion), x = a.zoom, ie.copy(u.target), e;
|
|
1931
1929
|
}
|
|
1932
|
-
function
|
|
1933
|
-
g = null, u.update(),
|
|
1930
|
+
function se() {
|
|
1931
|
+
g = null, u.update(), T() ? (v = 0, w(), ee += 1, te = !0, ee >= Ti && C()) : v += 1, y || v < Ci ? g = requestAnimationFrame(se) : (_ = !1, te && C());
|
|
1934
1932
|
}
|
|
1935
1933
|
function D() {
|
|
1936
|
-
v = 0, _ || (_ = !0, g = requestAnimationFrame(
|
|
1934
|
+
v = 0, _ || (_ = !0, g = requestAnimationFrame(se));
|
|
1937
1935
|
}
|
|
1938
|
-
function
|
|
1936
|
+
function ce() {
|
|
1939
1937
|
g !== null && (cancelAnimationFrame(g), g = null), _ = !1;
|
|
1940
1938
|
}
|
|
1941
1939
|
u.addEventListener("start", () => {
|
|
@@ -1943,21 +1941,21 @@ function ji(e, t = {}) {
|
|
|
1943
1941
|
}), u.addEventListener("end", () => {
|
|
1944
1942
|
y = !1, D();
|
|
1945
1943
|
}), u.addEventListener("change", D);
|
|
1946
|
-
function
|
|
1944
|
+
function le() {
|
|
1947
1945
|
let e = p > 0 ? a.zoom / p : 1;
|
|
1948
|
-
|
|
1946
|
+
ae(), oe(a.quaternion), a.zoom = p * e, a.updateProjectionMatrix(), w();
|
|
1949
1947
|
}
|
|
1950
|
-
let
|
|
1951
|
-
|
|
1952
|
-
function
|
|
1953
|
-
d && (Sn(a, e, f, d.span), u.target.set(...e.target),
|
|
1948
|
+
let O = typeof ResizeObserver > "u" ? null : new ResizeObserver(le);
|
|
1949
|
+
O?.observe(e), ae();
|
|
1950
|
+
function ue(e) {
|
|
1951
|
+
d && (Sn(a, e, f, d.span), u.target.set(...e.target), oe(a.quaternion), a.zoom = p * e.scale, a.updateProjectionMatrix(), u.update(), T());
|
|
1954
1952
|
}
|
|
1955
|
-
let
|
|
1953
|
+
let k = {
|
|
1956
1954
|
setLayers(e, t = null) {
|
|
1957
|
-
|
|
1955
|
+
k.clear(), e.length !== 0 && (d = fi(e), i.add(d.group), f = yn(d.span), i.fog = ki(d, f, bn(d.cell)), s?.setElements(d.elements), l?.setCell(d.cell), ae(), ue(t ?? xn(d.cell)), w());
|
|
1958
1956
|
},
|
|
1959
1957
|
clear() {
|
|
1960
|
-
|
|
1958
|
+
ce(), d &&= (i.remove(d.group), d.dispose(), null), i.fog = null, s?.setElements([]), r.setViewport(0, 0, m, h), r.clear();
|
|
1961
1959
|
},
|
|
1962
1960
|
getView() {
|
|
1963
1961
|
return d ? {
|
|
@@ -1971,31 +1969,31 @@ function ji(e, t = {}) {
|
|
|
1971
1969
|
} : null;
|
|
1972
1970
|
},
|
|
1973
1971
|
setView(e) {
|
|
1974
|
-
|
|
1972
|
+
ue(e), w();
|
|
1975
1973
|
},
|
|
1976
1974
|
resetView() {
|
|
1977
|
-
d &&
|
|
1975
|
+
d && ue(xn(d.cell)), w(), C();
|
|
1978
1976
|
},
|
|
1979
|
-
resize:
|
|
1980
|
-
render:
|
|
1977
|
+
resize: le,
|
|
1978
|
+
render: w,
|
|
1981
1979
|
onInteraction(e) {
|
|
1982
|
-
return
|
|
1980
|
+
return S.add(e), () => S.delete(e);
|
|
1983
1981
|
},
|
|
1984
1982
|
dispose() {
|
|
1985
|
-
|
|
1983
|
+
k.clear(), y = !1, O?.disconnect(), u.dispose(), l?.dispose(), r.dispose(), r.domElement.remove(), s?.element.remove(), e.classList.remove("bravais-viewer");
|
|
1986
1984
|
}
|
|
1987
1985
|
};
|
|
1988
|
-
return
|
|
1986
|
+
return k;
|
|
1989
1987
|
}
|
|
1990
1988
|
//#endregion
|
|
1991
1989
|
//#region src/render/thumbnails.ts
|
|
1992
|
-
function
|
|
1993
|
-
let { renderer: e, scene: t, camera: n, updateHeadlight: r } =
|
|
1990
|
+
function ji() {
|
|
1991
|
+
let { renderer: e, scene: t, camera: n, updateHeadlight: r } = pi(), i = /* @__PURE__ */ new Map();
|
|
1994
1992
|
function a(e, t) {
|
|
1995
1993
|
let n = i.get(e);
|
|
1996
1994
|
if (n && n.layers === t) return n.model;
|
|
1997
1995
|
n?.model.dispose();
|
|
1998
|
-
let r =
|
|
1996
|
+
let r = fi(t);
|
|
1999
1997
|
return i.set(e, {
|
|
2000
1998
|
layers: t,
|
|
2001
1999
|
model: r
|
|
@@ -2008,7 +2006,7 @@ function Mi() {
|
|
|
2008
2006
|
let u = a(i, o), d = Math.max(1, c.width), f = Math.max(1, c.height);
|
|
2009
2007
|
(e.domElement.width !== d || e.domElement.height !== f) && e.setSize(d, f, !1), En(n, d, f);
|
|
2010
2008
|
let p = yn(u.span), m = s ?? xn(u.cell);
|
|
2011
|
-
Sn(n, m, p, u.span), n.zoom = Tn(u.bounds, new
|
|
2009
|
+
Sn(n, m, p, u.span), n.zoom = Tn(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);
|
|
2012
2010
|
},
|
|
2013
2011
|
release(e) {
|
|
2014
2012
|
i.get(e)?.model.dispose(), i.delete(e);
|
|
@@ -2021,7 +2019,7 @@ function Mi() {
|
|
|
2021
2019
|
}
|
|
2022
2020
|
//#endregion
|
|
2023
2021
|
//#region src/index.ts
|
|
2024
|
-
async function
|
|
2022
|
+
async function Mi(e) {
|
|
2025
2023
|
let t = ye(e), n = t.blocks.find(Xe) ?? t.blocks[0];
|
|
2026
2024
|
if (!n) throw new V("The CIF has no data block.");
|
|
2027
2025
|
let r = Ze(n);
|
|
@@ -2033,6 +2031,6 @@ async function Ni(e) {
|
|
|
2033
2031
|
};
|
|
2034
2032
|
}
|
|
2035
2033
|
//#endregion
|
|
2036
|
-
export { V as CifStructureError, M as CifSyntaxError, rt as SpaceGroupLookupError, xt as SymmetryAnalysisError, It as buildScene,
|
|
2034
|
+
export { V as CifStructureError, M as CifSyntaxError, rt as SpaceGroupLookupError, xt as SymmetryAnalysisError, It as buildScene, ji as createThumbnailRenderer, Ai as createViewer, Kr as elementColor, qr as elementColorAssignments, Gr as ensureElementColors, it as ensureMoyo, yt as expandStructure, Ne as latticeFromParameters, Pe as latticeFromVectors, ft as operationsForSpaceGroup, ye as parseCif, Ze as parseCifStructure, ze as parseSymmetryOperator, Mi as readCif, Jr as resetElementColors, Ft as structureElements, wt as symmetryDataset, Ot as typesetSymbol };
|
|
2037
2035
|
|
|
2038
2036
|
//# sourceMappingURL=bravais.js.map
|