@margoengine/ui 0.1.0 → 1.0.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/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +1225 -708
- package/dist/dom-CWJhpotq.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/dist/{renderer-Bdhc_0Cu.js → renderer-Vs-YtiWv.js} +101 -13
- package/dist/renderer.d.ts +46 -0
- package/dist/world-gl.js +3 -3
- package/dist/world.js +3 -3
- package/package.json +119 -119
package/dist/dom-CWJhpotq.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
3
|
|
|
4
4
|
import { SDF_DEFAULTS as e, glyphAtlases as t } from "@margoengine/text";
|
|
@@ -20,7 +20,7 @@ var n = "\nstruct Frame { size: vec2f, linear: f32, pad: f32, sdf: vec2f, pad2:
|
|
|
20
20
|
}, a = { primitive: {
|
|
21
21
|
topology: "triangle-list",
|
|
22
22
|
cullMode: "none"
|
|
23
|
-
} }, o = class {coreRequirement=__margoCoreRequirement("
|
|
23
|
+
} }, o = class {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
24
24
|
constructor(e, t) {
|
|
25
25
|
this.options = e, this.stats = t, this.groupKey = "", this.rectCapacity = 0, this.glyphCapacity = 0, this.pipelines = /* @__PURE__ */ new Map(), this.frameData = /* @__PURE__ */ new Float32Array(8), this.batch = new s(), this.uploaded = -1, this.uploadedAtlas = "", this.fresh = !1;
|
|
26
26
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { uiActions, UI_ACTIONS } from './interaction.js';
|
|
|
11
11
|
export type { InputSource, PointerInfo, UiActionOptions } from './interaction.js';
|
|
12
12
|
export { moveFocus } from './focus.js';
|
|
13
13
|
export type { Direction } from './focus.js';
|
|
14
|
-
export type { UiRendererOptions } from './renderer.js';
|
|
14
|
+
export type { UiLayer, UiRendererOptions } from './renderer.js';
|
|
15
15
|
export { DrawList } from './draw.js';
|
|
16
16
|
export type { DrawCommand, ImageCommand, RectCommand, TextCommand, ClipCommand, UnclipCommand, RectStyle, } from './draw.js';
|
|
17
17
|
export { arrange, edges, translate, validateStyle } from './layout.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { C as e, S as t, _ as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, x as b, y as x } from "./meters-yaZRtwsX.js";
|
|
2
|
-
import { _ as S, a as C, c as w, d as T, f as E, g as D, h as O, i as k, l as A, m as j, n as M, o as N, p as P, r as F, s as I, t as L, u as R, v as z, y as B } from "./renderer-
|
|
2
|
+
import { _ as S, a as C, c as w, d as T, f as E, g as D, h as O, i as k, l as A, m as j, n as M, o as N, p as P, r as F, s as I, t as L, u as R, v as z, y as B } from "./renderer-Vs-YtiWv.js";
|
|
3
3
|
import { i as V, t as H } from "./dom-CWJhpotq.js";
|
|
4
4
|
export { g as Button, O as Dialog, B as DrawList, _ as HealthBar, h as Inventory, n as Label, l as List, p as Menu, y as Panel, f as ProgressBar, i as Slider, D as Toast, u as Toggle, S as Tooltip, P as UI_ACTIONS, N as Ui, L as UiRenderer, C as VirtualList, F as WIDGET_SKIP, x as Widget, r as arrange, H as attachInput, M as attachMirror, I as browserTextScale, v as colorDifference, a as contrastRatio, R as createTheme, k as describeWidget, b as edges, V as handleKeyDown, o as luminance, m as mixColors, z as moveFocus, d as parseRgba, w as readSafeArea, A as resolutionScale, c as simulateColorBlindness, T as themeForPreferences, E as themes, t as translate, j as uiActions, e as validateStyle, s as withAlpha };
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./errors-CDgOgzCd.js";
|
|
2
2
|
import { _ as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l, v as u } from "./meters-yaZRtwsX.js";
|
|
3
|
-
import { o as d, t as f } from "./renderer-
|
|
3
|
+
import { o as d, t as f } from "./renderer-Vs-YtiWv.js";
|
|
4
4
|
import { createContext as p, useContext as m, useEffect as h, useLayoutEffect as g, useRef as _, useState as v } from "react";
|
|
5
5
|
import { jsx as y } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react.tsx
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
3
|
|
|
4
4
|
import { n as e, r as t, t as n } from "./errors-CDgOgzCd.js";
|
|
@@ -1563,8 +1563,8 @@ function $(e, t, n = {}) {
|
|
|
1563
1563
|
}
|
|
1564
1564
|
//#endregion
|
|
1565
1565
|
//#region src/renderer.ts
|
|
1566
|
-
var ue = class n {coreRequirement=__margoCoreRequirement("
|
|
1567
|
-
static attach(e, t, r) {__margoAssertCore(e,__margoCoreRequirement("
|
|
1566
|
+
var ue = class n {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
1567
|
+
static attach(e, t, r) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
1568
1568
|
let i = new n(t, r);
|
|
1569
1569
|
return e.use(i), i;
|
|
1570
1570
|
}
|
|
@@ -1590,7 +1590,7 @@ var ue = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1590
1590
|
};
|
|
1591
1591
|
for (let t of Object.values(this.options)) if (!Number.isInteger(t) || t < 1) throw e("Atlas sizes and page limits must be positive integers", "ui");
|
|
1592
1592
|
if (this.options.atlasSize < 64 || this.options.colorAtlasSize < 64) throw e("Atlas pages must be at least 64 texels", "ui");
|
|
1593
|
-
this.painter = new v(this.options, this.stats);
|
|
1593
|
+
this.layer = r.layer === !0, this.painter = new v(this.options, this.stats);
|
|
1594
1594
|
}
|
|
1595
1595
|
setup(e) {
|
|
1596
1596
|
this.engine = e;
|
|
@@ -1615,24 +1615,112 @@ var ue = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1615
1615
|
onPreUpdate(e) {
|
|
1616
1616
|
this.advanceTime(e);
|
|
1617
1617
|
}
|
|
1618
|
+
layOut(e, t) {
|
|
1619
|
+
let n = this.pixelRatio(e);
|
|
1620
|
+
this.laidOut = [
|
|
1621
|
+
e / n,
|
|
1622
|
+
t / n,
|
|
1623
|
+
n
|
|
1624
|
+
], this.ui.resize(e / n, t / n, n);
|
|
1625
|
+
}
|
|
1618
1626
|
draw(e) {
|
|
1619
|
-
|
|
1620
|
-
if (t.resize(e.width / n, e.height / n, n), !this.painter.prepare(t.draw())) return;
|
|
1627
|
+
if (this.layOut(e.width, e.height), this.layer || !this.painter.prepare(this.ui.draw())) return;
|
|
1621
1628
|
this.descriptor.colorAttachments[0].view = e.color, this.descriptor.depthStencilAttachment.view = e.depth;
|
|
1622
|
-
let
|
|
1623
|
-
this.painter.encode(
|
|
1629
|
+
let t = e.encoder.beginRenderPass(this.descriptor);
|
|
1630
|
+
this.painter.encode(t, {
|
|
1624
1631
|
width: e.width,
|
|
1625
1632
|
height: e.height,
|
|
1626
1633
|
format: e.format,
|
|
1627
1634
|
depthFormat: e.descriptor.depthStencil.format,
|
|
1628
1635
|
samples: e.descriptor.multisample?.count ?? 1
|
|
1629
|
-
}),
|
|
1636
|
+
}), t.end();
|
|
1630
1637
|
}
|
|
1631
1638
|
drawGl(e) {
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1639
|
+
this.gl && this.engine && !e.gl.isContextLost() && (this.glPainter?.gl !== e.gl && (this.glPainter?.dispose(), this.glPainter = this.gl.glPainter(e.gl, this.options, this.stats)), this.layOut(e.width, e.height), this.layer || this.glPainter.draw(this.ui.draw(), e.width, e.height));
|
|
1640
|
+
}
|
|
1641
|
+
async renderLayer(t, n, r = {}) {
|
|
1642
|
+
let { signal: i } = r;
|
|
1643
|
+
if (i?.throwIfAborted(), !Number.isInteger(t) || !Number.isInteger(n) || t < 1 || n < 1) throw e(`A UI layer is a whole number of pixels a side, not ${t} x ${n}`, "ui");
|
|
1644
|
+
if (this.disposed) throw Error("renderLayer on a disposed UiRenderer");
|
|
1645
|
+
let a = this.laidOut, [o, s] = a ?? this.cssSize(t, n);
|
|
1646
|
+
this.ui.resize(o, s, t / o);
|
|
1647
|
+
let c = this.ui.draw(), l;
|
|
1648
|
+
try {
|
|
1649
|
+
if (this.device) l = this.layerGpu(this.device, c, t, n);
|
|
1650
|
+
else if (this.glPainter && !this.glPainter.gl.isContextLost()) l = this.layerGl(this.glPainter, c, t, n);
|
|
1651
|
+
else throw Error("renderLayer needs a drawn frame first: the renderer has no GPU device or WebGL2 painter yet");
|
|
1652
|
+
} finally {
|
|
1653
|
+
a && this.ui.resize(a[0], a[1], a[2]);
|
|
1654
|
+
}
|
|
1655
|
+
let u = await l;
|
|
1656
|
+
return i?.throwIfAborted(), u;
|
|
1657
|
+
}
|
|
1658
|
+
async layerGpu(t, n, r, i) {
|
|
1659
|
+
let a = t.limits.maxTextureDimension2D;
|
|
1660
|
+
if (r > a || i > a) throw e(`A UI layer of ${r} x ${i} pixels does not fit this GPU, whose limit is ${a} a side`, "ui");
|
|
1661
|
+
let o = t.createTexture({
|
|
1662
|
+
size: [r, i],
|
|
1663
|
+
format: "rgba8unorm",
|
|
1664
|
+
usage: 17
|
|
1665
|
+
}), s = Math.ceil(r * 4 / 256) * 256, c = t.createBuffer({
|
|
1666
|
+
size: s * i,
|
|
1667
|
+
usage: 9
|
|
1668
|
+
}), l = t.createCommandEncoder(), u = l.beginRenderPass({ colorAttachments: [{
|
|
1669
|
+
view: o.createView(),
|
|
1670
|
+
loadOp: "clear",
|
|
1671
|
+
storeOp: "store",
|
|
1672
|
+
clearValue: [
|
|
1673
|
+
0,
|
|
1674
|
+
0,
|
|
1675
|
+
0,
|
|
1676
|
+
0
|
|
1677
|
+
]
|
|
1678
|
+
}] });
|
|
1679
|
+
this.painter.prepare(n) && this.painter.encode(u, {
|
|
1680
|
+
width: r,
|
|
1681
|
+
height: i,
|
|
1682
|
+
format: "rgba8unorm",
|
|
1683
|
+
samples: 1
|
|
1684
|
+
}), u.end(), l.copyTextureToBuffer({ texture: o }, {
|
|
1685
|
+
buffer: c,
|
|
1686
|
+
bytesPerRow: s
|
|
1687
|
+
}, [r, i]), t.queue.submit([l.finish()]);
|
|
1688
|
+
try {
|
|
1689
|
+
await c.mapAsync(1);
|
|
1690
|
+
let e = new Uint8Array(c.getMappedRange()), t = new Uint8Array(r * i * 4);
|
|
1691
|
+
for (let n = 0; n < i; n++) t.set(e.subarray(n * s, n * s + r * 4), n * r * 4);
|
|
1692
|
+
return c.unmap(), {
|
|
1693
|
+
width: r,
|
|
1694
|
+
height: i,
|
|
1695
|
+
rgba: t
|
|
1696
|
+
};
|
|
1697
|
+
} finally {
|
|
1698
|
+
c.destroy(), o.destroy();
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
layerGl(t, n, r, i) {
|
|
1702
|
+
let a = t.gl, o = a.getParameter(a.MAX_TEXTURE_SIZE);
|
|
1703
|
+
if (r > o || i > o) throw e(`A UI layer of ${r} x ${i} pixels does not fit this GPU, whose limit is ${o} a side`, "ui");
|
|
1704
|
+
let s = a.createTexture(), c = a.createFramebuffer();
|
|
1705
|
+
try {
|
|
1706
|
+
a.bindTexture(a.TEXTURE_2D, s), a.texStorage2D(a.TEXTURE_2D, 1, a.RGBA8, r, i), a.bindFramebuffer(a.FRAMEBUFFER, c), a.framebufferTexture2D(a.FRAMEBUFFER, a.COLOR_ATTACHMENT0, a.TEXTURE_2D, s, 0), a.disable(a.SCISSOR_TEST), a.clearColor(0, 0, 0, 0), a.clear(a.COLOR_BUFFER_BIT), t.draw(n, r, i, c), a.bindFramebuffer(a.FRAMEBUFFER, c);
|
|
1707
|
+
let e = new Uint8Array(r * i * 4), o = new Uint8Array(r * i * 4);
|
|
1708
|
+
a.readPixels(0, 0, r, i, a.RGBA, a.UNSIGNED_BYTE, e);
|
|
1709
|
+
for (let t = 0; t < i; t++) o.set(e.subarray((i - 1 - t) * r * 4, (i - t) * r * 4), t * r * 4);
|
|
1710
|
+
return {
|
|
1711
|
+
width: r,
|
|
1712
|
+
height: i,
|
|
1713
|
+
rgba: o
|
|
1714
|
+
};
|
|
1715
|
+
} finally {
|
|
1716
|
+
a.bindFramebuffer(a.FRAMEBUFFER, null), a.deleteFramebuffer(c), a.deleteTexture(s);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
cssSize(e, t) {
|
|
1720
|
+
let n = this.engine.canvas;
|
|
1721
|
+
if (n?.clientWidth && n.clientHeight) return [n.clientWidth, n.clientHeight];
|
|
1722
|
+
let r = globalThis.devicePixelRatio ?? 1;
|
|
1723
|
+
return [e / r, t / r];
|
|
1636
1724
|
}
|
|
1637
1725
|
pixelRatio(e) {
|
|
1638
1726
|
let t = this.engine.canvas?.clientWidth || 0;
|
package/dist/renderer.d.ts
CHANGED
|
@@ -26,6 +26,24 @@ export interface UiRendererOptions {
|
|
|
26
26
|
* true: the interface is accessible with no setup.
|
|
27
27
|
*/
|
|
28
28
|
mirror?: boolean | MirrorOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Draw nothing over the frame and give the UI only through {@link UiRenderer.renderLayer}, for a tool that lays the UI
|
|
31
|
+
* over the finished picture itself, such as a supersampled render that takes its frame down to the output size first
|
|
32
|
+
* (text and panels drawn into the big frame would pass through that filter). Settable later as `renderer.layer`.
|
|
33
|
+
* Default false.
|
|
34
|
+
*/
|
|
35
|
+
layer?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The UI as its own picture ({@link UiRenderer.renderLayer}): `width` x `height` RGBA bytes, row 0 at the top, colour
|
|
39
|
+
* premultiplied by alpha and sRGB coded as an 8-bit canvas holds it. Over a frame `f` of the same size, also sRGB coded,
|
|
40
|
+
* the UI's picture is `rgb + (1 - a) * f` (Porter and Duff's over), which is what the renderer's own pass blends over an
|
|
41
|
+
* 8-bit canvas.
|
|
42
|
+
*/
|
|
43
|
+
export interface UiLayer {
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
rgba: Uint8Array;
|
|
29
47
|
}
|
|
30
48
|
/**
|
|
31
49
|
* Engine plugin that draws a {@link Ui} over the finished frame, in the engine's own render pass: rounded rectangles
|
|
@@ -61,6 +79,10 @@ export declare class UiRenderer implements EnginePlugin {
|
|
|
61
79
|
private detach?;
|
|
62
80
|
private detachMirror?;
|
|
63
81
|
private disposed;
|
|
82
|
+
/** Draw nothing over the frame: the UI is read with {@link UiRenderer.renderLayer} (`UiRendererOptions.layer`). */
|
|
83
|
+
layer: boolean;
|
|
84
|
+
/** The size in CSS pixels the last frame laid the UI out at, which {@link UiRenderer.renderLayer} keeps. */
|
|
85
|
+
private laidOut?;
|
|
64
86
|
/** Same as `engine.use(new UiRenderer(ui, options))`; returns the renderer. */
|
|
65
87
|
static attach(engine: EngineKernel, ui: Ui, options?: UiRendererOptions): UiRenderer;
|
|
66
88
|
/**
|
|
@@ -80,9 +102,33 @@ export declare class UiRenderer implements EnginePlugin {
|
|
|
80
102
|
onPreUpdate(delta: number): void;
|
|
81
103
|
private elapsed;
|
|
82
104
|
private readonly execute;
|
|
105
|
+
/** Lays the UI out for a frame of `width` x `height` device pixels: the canvas's CSS size times the pixel ratio. */
|
|
106
|
+
private layOut;
|
|
83
107
|
private draw;
|
|
84
108
|
/** The WebGL2 path: the same draw list over the finished frame in the default framebuffer. */
|
|
85
109
|
private drawGl;
|
|
110
|
+
/**
|
|
111
|
+
* The UI as its own picture of `width` x `height` device pixels ({@link UiLayer}), cleared to transparent: laid out at
|
|
112
|
+
* the CSS size of the last frame (the canvas's CSS size before the first), so a layer at the canvas's size is the
|
|
113
|
+
* canvas's UI and one at half its size is the same UI at half the pixels, not a UI laid out again for a smaller
|
|
114
|
+
* screen. Text is drawn from its signed distance fields at the layer's own size. With
|
|
115
|
+
* {@link UiRendererOptions.layer} the frame holds no UI and a tool lays this over it.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* const renderer = UiRenderer.attach(engine, ui, { layer: true });
|
|
119
|
+
* engine.render(1 / 60);
|
|
120
|
+
* const { rgba } = await renderer.renderLayer(1920, 1080);
|
|
121
|
+
* @throws RangeError for a size that is not a whole number of pixels from 1 to the GPU's texture limit.
|
|
122
|
+
* @throws Error before the first frame (no GPU device or WebGL2 painter yet) or after dispose.
|
|
123
|
+
* @throws DOMException `AbortError` when `signal` aborts.
|
|
124
|
+
*/
|
|
125
|
+
renderLayer(width: number, height: number, options?: {
|
|
126
|
+
signal?: AbortSignal;
|
|
127
|
+
}): Promise<UiLayer>;
|
|
128
|
+
private layerGpu;
|
|
129
|
+
private layerGl;
|
|
130
|
+
/** The canvas's CSS size, or a frame of `width` x `height` at the browser's pixel ratio when it has none. */
|
|
131
|
+
private cssSize;
|
|
86
132
|
/** Device pixels per CSS pixel: the drawing buffer's width over the canvas's CSS width. */
|
|
87
133
|
private pixelRatio;
|
|
88
134
|
onDeviceRestored(engine: Engine): void;
|
package/dist/world-gl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
3
|
|
|
4
4
|
import { n as e, t } from "./errors-CDgOgzCd.js";
|
|
@@ -7,11 +7,11 @@ import { t as a } from "./gl-bb768Mje.js";
|
|
|
7
7
|
import { WorldPanels as o, screenRay as s } from "@margoengine/ui/world";
|
|
8
8
|
export * from "@margoengine/ui/world";
|
|
9
9
|
//#region src/world-gl.ts
|
|
10
|
-
var c = "#version 300 es\nprecision highp float;\nuniform mat4 model; uniform mat4 viewProj; uniform vec2 size; uniform vec4 surface; uniform vec3 eye;\nout vec2 uv; out float facing;\nvoid main(){int v=gl_VertexID%6;int cell=gl_VertexID/6;int cols=int(surface.z);\nvec2 c=(vec2(float(cell%cols),float(cell/cols))+vec2(float((0x32>>v)&1),float((0x2c>>v)&1)))/surface.zw;\nvec3 p=vec3((c.x-.5)*size.x,(.5-c.y)*size.y,0.);vec3 n=vec3(0.,0.,1.);\nif(surface.y>.5){float r=surface.x;float a=p.x/r;float b=surface.y>1.5?p.y/r:0.;n=vec3(sin(a)*cos(b),sin(b),cos(a)*cos(b));p=vec3(r*n.x,surface.y>1.5?r*n.y:p.y,r*(n.z-1.));}\nvec4 world=model*vec4(p,1.);facing=dot(eye-world.xyz,(model*vec4(n,0.)).xyz);gl_Position=viewProj*world;uv=c;}", l = "#version 300 es\nprecision highp float;\nuniform sampler2D panel; uniform bool doubleSided;in vec2 uv;in float facing;out vec4 color;\nvoid main(){if(facing<0.&&!doubleSided)discard;color=texture(panel,vec2(facing<0.?1.-uv.x:uv.x,uv.y));}", u = class u extends o {coreRequirement=__margoCoreRequirement("
|
|
10
|
+
var c = "#version 300 es\nprecision highp float;\nuniform mat4 model; uniform mat4 viewProj; uniform vec2 size; uniform vec4 surface; uniform vec3 eye;\nout vec2 uv; out float facing;\nvoid main(){int v=gl_VertexID%6;int cell=gl_VertexID/6;int cols=int(surface.z);\nvec2 c=(vec2(float(cell%cols),float(cell/cols))+vec2(float((0x32>>v)&1),float((0x2c>>v)&1)))/surface.zw;\nvec3 p=vec3((c.x-.5)*size.x,(.5-c.y)*size.y,0.);vec3 n=vec3(0.,0.,1.);\nif(surface.y>.5){float r=surface.x;float a=p.x/r;float b=surface.y>1.5?p.y/r:0.;n=vec3(sin(a)*cos(b),sin(b),cos(a)*cos(b));p=vec3(r*n.x,surface.y>1.5?r*n.y:p.y,r*(n.z-1.));}\nvec4 world=model*vec4(p,1.);facing=dot(eye-world.xyz,(model*vec4(n,0.)).xyz);gl_Position=viewProj*world;uv=c;}", l = "#version 300 es\nprecision highp float;\nuniform sampler2D panel; uniform bool doubleSided;in vec2 uv;in float facing;out vec4 color;\nvoid main(){if(facing<0.&&!doubleSided)discard;color=texture(panel,vec2(facing<0.?1.-uv.x:uv.x,uv.y));}", u = class u extends o {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
11
11
|
onPreUpdate(e) {
|
|
12
12
|
super.onPreUpdate(e), this.glFrame++;
|
|
13
13
|
}
|
|
14
|
-
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("
|
|
14
|
+
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
15
15
|
let n = new u(t);
|
|
16
16
|
return e.use(n), n;
|
|
17
17
|
}
|
package/dist/world.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
3
|
|
|
4
4
|
import { n as e, r as t } from "./errors-CDgOgzCd.js";
|
|
@@ -256,8 +256,8 @@ function v(e, t) {
|
|
|
256
256
|
}
|
|
257
257
|
return n;
|
|
258
258
|
}
|
|
259
|
-
var y = "rgba8unorm-srgb", b = class c {coreRequirement=__margoCoreRequirement("
|
|
260
|
-
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("
|
|
259
|
+
var y = "rgba8unorm-srgb", b = class c {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
260
|
+
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
261
261
|
let n = new c(t);
|
|
262
262
|
return e.use(n), n;
|
|
263
263
|
}
|
package/package.json
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@margoengine/ui",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Game UI drawn in the engine: menus, HUDs, health bars, inventories, dialogs and toasts with flex layout, theming, keyboard, gamepad and touch navigation, screen reader support and React components.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"margoengine",
|
|
7
|
-
"webgpu",
|
|
8
|
-
"3d",
|
|
9
|
-
"ui",
|
|
10
|
-
"hud",
|
|
11
|
-
"game-ui",
|
|
12
|
-
"accessibility"
|
|
13
|
-
],
|
|
14
|
-
"homepage": "https://margoengine.com",
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
21
|
-
"directory": "packages/ui"
|
|
22
|
-
},
|
|
23
|
-
"license": "Apache-2.0",
|
|
24
|
-
"author": "Scott Campbell",
|
|
25
|
-
"type": "module",
|
|
26
|
-
"sideEffects": false,
|
|
27
|
-
"exports": {
|
|
28
|
-
".": {
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
30
|
-
"import": "./dist/index.js"
|
|
31
|
-
},
|
|
32
|
-
"./react": {
|
|
33
|
-
"types": "./dist/react.d.ts",
|
|
34
|
-
"react-server": "./dist/rsc/react.js",
|
|
35
|
-
"import": "./dist/react.js"
|
|
36
|
-
},
|
|
37
|
-
"./world": {
|
|
38
|
-
"types": "./dist/world.d.ts",
|
|
39
|
-
"import": "./dist/world.js"
|
|
40
|
-
},
|
|
41
|
-
"./input": {
|
|
42
|
-
"types": "./dist/input.d.ts",
|
|
43
|
-
"import": "./dist/input.js"
|
|
44
|
-
},
|
|
45
|
-
"./markup": {
|
|
46
|
-
"types": "./dist/markup.d.ts",
|
|
47
|
-
"import": "./dist/markup.js"
|
|
48
|
-
},
|
|
49
|
-
"./image": {
|
|
50
|
-
"types": "./dist/image.d.ts",
|
|
51
|
-
"import": "./dist/image.js"
|
|
52
|
-
},
|
|
53
|
-
"./forms": {
|
|
54
|
-
"types": "./dist/forms.d.ts",
|
|
55
|
-
"import": "./dist/forms.js"
|
|
56
|
-
},
|
|
57
|
-
"./world-gl": {
|
|
58
|
-
"types": "./dist/world-gl.d.ts",
|
|
59
|
-
"import": "./dist/world-gl.js"
|
|
60
|
-
},
|
|
61
|
-
"./curved": {
|
|
62
|
-
"types": "./dist/curved.d.ts",
|
|
63
|
-
"import": "./dist/curved.js"
|
|
64
|
-
},
|
|
65
|
-
"./keyboard": {
|
|
66
|
-
"types": "./dist/keyboard.d.ts",
|
|
67
|
-
"import": "./dist/keyboard.js"
|
|
68
|
-
},
|
|
69
|
-
"./i18n": {
|
|
70
|
-
"types": "./dist/i18n.d.ts",
|
|
71
|
-
"import": "./dist/i18n.js"
|
|
72
|
-
},
|
|
73
|
-
"./editor": {
|
|
74
|
-
"types": "./dist/editor.d.ts",
|
|
75
|
-
"import": "./dist/editor.js"
|
|
76
|
-
},
|
|
77
|
-
"./dom": {
|
|
78
|
-
"types": "./dist/dom-host.d.ts",
|
|
79
|
-
"import": "./dist/dom-host.js"
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
"files": [
|
|
83
|
-
"dist",
|
|
84
|
-
"LICENSE",
|
|
85
|
-
"NOTICE"
|
|
86
|
-
],
|
|
87
|
-
"publishConfig": {
|
|
88
|
-
"access": "public"
|
|
89
|
-
},
|
|
90
|
-
"peerDependencies": {
|
|
91
|
-
"@margoengine/core": "^
|
|
92
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
93
|
-
},
|
|
94
|
-
"peerDependenciesMeta": {
|
|
95
|
-
"react": {
|
|
96
|
-
"optional": true
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
"dependencies": {
|
|
100
|
-
"@margoengine/input": "^
|
|
101
|
-
"@margoengine/math": "^
|
|
102
|
-
"@margoengine/text": "^
|
|
103
|
-
},
|
|
104
|
-
"scripts": {
|
|
105
|
-
"build": "node ../../scripts/build-optional.js ui",
|
|
106
|
-
"test": "npm run build && node --test tests/*.test.js",
|
|
107
|
-
"test:browser": "npm run build && node tests/ui-browser.mjs",
|
|
108
|
-
"prepack": "npm run build",
|
|
109
|
-
"test:browser:world": "npm run build && node tests/world-browser.mjs",
|
|
110
|
-
"test:browser:input": "npm run build && node tests/text-input-browser.mjs",
|
|
111
|
-
"test:browser:image": "npm run build && node tests/image-browser.mjs",
|
|
112
|
-
"test:browser:forms": "npm run build && node tests/forms-browser.mjs",
|
|
113
|
-
"test:browser:world-gl": "npm run build && node tests/world-gl-browser.mjs",
|
|
114
|
-
"test:browser:keyboard": "npm run build && node tests/keyboard-browser.mjs",
|
|
115
|
-
"test:browser:i18n": "npm run build && node tests/i18n-browser.mjs",
|
|
116
|
-
"test:browser:editor": "npm run build && node tests/editor-browser.mjs",
|
|
117
|
-
"test:browser:dom": "npm run build && node tests/dom-host-browser.mjs"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@margoengine/ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Game UI drawn in the engine: menus, HUDs, health bars, inventories, dialogs and toasts with flex layout, theming, keyboard, gamepad and touch navigation, screen reader support and React components.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"margoengine",
|
|
7
|
+
"webgpu",
|
|
8
|
+
"3d",
|
|
9
|
+
"ui",
|
|
10
|
+
"hud",
|
|
11
|
+
"game-ui",
|
|
12
|
+
"accessibility"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://margoengine.com",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
21
|
+
"directory": "packages/ui"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"author": "Scott Campbell",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./react": {
|
|
33
|
+
"types": "./dist/react.d.ts",
|
|
34
|
+
"react-server": "./dist/rsc/react.js",
|
|
35
|
+
"import": "./dist/react.js"
|
|
36
|
+
},
|
|
37
|
+
"./world": {
|
|
38
|
+
"types": "./dist/world.d.ts",
|
|
39
|
+
"import": "./dist/world.js"
|
|
40
|
+
},
|
|
41
|
+
"./input": {
|
|
42
|
+
"types": "./dist/input.d.ts",
|
|
43
|
+
"import": "./dist/input.js"
|
|
44
|
+
},
|
|
45
|
+
"./markup": {
|
|
46
|
+
"types": "./dist/markup.d.ts",
|
|
47
|
+
"import": "./dist/markup.js"
|
|
48
|
+
},
|
|
49
|
+
"./image": {
|
|
50
|
+
"types": "./dist/image.d.ts",
|
|
51
|
+
"import": "./dist/image.js"
|
|
52
|
+
},
|
|
53
|
+
"./forms": {
|
|
54
|
+
"types": "./dist/forms.d.ts",
|
|
55
|
+
"import": "./dist/forms.js"
|
|
56
|
+
},
|
|
57
|
+
"./world-gl": {
|
|
58
|
+
"types": "./dist/world-gl.d.ts",
|
|
59
|
+
"import": "./dist/world-gl.js"
|
|
60
|
+
},
|
|
61
|
+
"./curved": {
|
|
62
|
+
"types": "./dist/curved.d.ts",
|
|
63
|
+
"import": "./dist/curved.js"
|
|
64
|
+
},
|
|
65
|
+
"./keyboard": {
|
|
66
|
+
"types": "./dist/keyboard.d.ts",
|
|
67
|
+
"import": "./dist/keyboard.js"
|
|
68
|
+
},
|
|
69
|
+
"./i18n": {
|
|
70
|
+
"types": "./dist/i18n.d.ts",
|
|
71
|
+
"import": "./dist/i18n.js"
|
|
72
|
+
},
|
|
73
|
+
"./editor": {
|
|
74
|
+
"types": "./dist/editor.d.ts",
|
|
75
|
+
"import": "./dist/editor.js"
|
|
76
|
+
},
|
|
77
|
+
"./dom": {
|
|
78
|
+
"types": "./dist/dom-host.d.ts",
|
|
79
|
+
"import": "./dist/dom-host.js"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"files": [
|
|
83
|
+
"dist",
|
|
84
|
+
"LICENSE",
|
|
85
|
+
"NOTICE"
|
|
86
|
+
],
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"@margoengine/core": "^1.0.0",
|
|
92
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
93
|
+
},
|
|
94
|
+
"peerDependenciesMeta": {
|
|
95
|
+
"react": {
|
|
96
|
+
"optional": true
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"dependencies": {
|
|
100
|
+
"@margoengine/input": "^1.0.0",
|
|
101
|
+
"@margoengine/math": "^1.0.0",
|
|
102
|
+
"@margoengine/text": "^1.0.0"
|
|
103
|
+
},
|
|
104
|
+
"scripts": {
|
|
105
|
+
"build": "node ../../scripts/build-optional.js ui",
|
|
106
|
+
"test": "npm run build && node --test tests/*.test.js",
|
|
107
|
+
"test:browser": "npm run build && node tests/ui-browser.mjs",
|
|
108
|
+
"prepack": "npm run build",
|
|
109
|
+
"test:browser:world": "npm run build && node tests/world-browser.mjs",
|
|
110
|
+
"test:browser:input": "npm run build && node tests/text-input-browser.mjs",
|
|
111
|
+
"test:browser:image": "npm run build && node tests/image-browser.mjs",
|
|
112
|
+
"test:browser:forms": "npm run build && node tests/forms-browser.mjs",
|
|
113
|
+
"test:browser:world-gl": "npm run build && node tests/world-gl-browser.mjs",
|
|
114
|
+
"test:browser:keyboard": "npm run build && node tests/keyboard-browser.mjs",
|
|
115
|
+
"test:browser:i18n": "npm run build && node tests/i18n-browser.mjs",
|
|
116
|
+
"test:browser:editor": "npm run build && node tests/editor-browser.mjs",
|
|
117
|
+
"test:browser:dom": "npm run build && node tests/dom-host-browser.mjs"
|
|
118
|
+
}
|
|
119
|
+
}
|