feat(webui): SurfaceColumn automatically finds PERPENDICULAR attributes, if set
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
22747e2577
commit
c4f86824c9
|
@ -10,6 +10,8 @@
|
||||||
import SurfacePoint from "./display/SurfacePoint.svelte";
|
import SurfacePoint from "./display/SurfacePoint.svelte";
|
||||||
import { i18n } from "../i18n";
|
import { i18n } from "../i18n";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
import { Query } from "@upnd/upend";
|
||||||
|
import { Any } from "@upnd/upend/query";
|
||||||
const dbg = debug("kestrel:surface");
|
const dbg = debug("kestrel:surface");
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
@ -29,6 +31,42 @@
|
||||||
let viewHeight = 0;
|
let viewHeight = 0;
|
||||||
let viewWidth = 0;
|
let viewWidth = 0;
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if ((x && !y) || (!x && y)) findPerpendicular();
|
||||||
|
}
|
||||||
|
async function findPerpendicular() {
|
||||||
|
const presentAxis = x || y;
|
||||||
|
const presentAxisAddress = await api.componentsToAddress({
|
||||||
|
t: "Attribute",
|
||||||
|
c: presentAxis,
|
||||||
|
});
|
||||||
|
const result = await api.query(
|
||||||
|
Query.or(
|
||||||
|
Query.matches(`@${presentAxisAddress}`, "PERPENDICULAR", Any),
|
||||||
|
Query.matches(Any, "PERPENDICULAR", `@${presentAxisAddress}`),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const perpendicular = [
|
||||||
|
...result.entries.map((e) => e.entity),
|
||||||
|
...result.values
|
||||||
|
.filter((v) => v.t === "Address")
|
||||||
|
.map((v) => v.c as string),
|
||||||
|
].find((address) => address !== presentAxisAddress);
|
||||||
|
|
||||||
|
if (perpendicular) {
|
||||||
|
const perpendicularComponents =
|
||||||
|
await api.addressToComponents(perpendicular);
|
||||||
|
if (perpendicularComponents.t !== "Attribute") return;
|
||||||
|
const perpendicularName = perpendicularComponents.c;
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
y = perpendicularName;
|
||||||
|
} else {
|
||||||
|
x = perpendicularName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface IPoint {
|
interface IPoint {
|
||||||
address: string;
|
address: string;
|
||||||
x: number;
|
x: number;
|
||||||
|
|
Loading…
Reference in New Issue