@moku-labs/game 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -775
- package/bin/moku-game-assets.mjs +4 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +32 -12
- package/fonts/LICENSE.txt +105 -0
- package/fonts/font-body.fnt +372 -0
- package/fonts/font-body.png +0 -0
- package/llms.txt +536 -0
- package/package.json +9 -2
package/dist/index.d.mts
CHANGED
|
@@ -1148,7 +1148,9 @@ declare function music(key: string | null, options?: MusicOptions): Descriptor;
|
|
|
1148
1148
|
* wide, that follows the shape: rounded corners stay rounded. Its alpha is
|
|
1149
1149
|
* `strength × alpha ×` the share of the disc of radius `distance` around the pixel the view
|
|
1150
1150
|
* covers, so `strength: 2` is full next to a straight edge and fades to nothing at `distance`.
|
|
1151
|
-
*
|
|
1151
|
+
* It takes 64 to 256 probes, by radius in physical pixels: about 3.5 physical pixels apart up to
|
|
1152
|
+
* a radius of 32 physical pixels. The view is padded by its live `distance`. One render pass per
|
|
1153
|
+
* apply.
|
|
1152
1154
|
*
|
|
1153
1155
|
* @example
|
|
1154
1156
|
* ```ts
|
package/dist/index.mjs
CHANGED
|
@@ -18103,27 +18103,33 @@ function defineFilter(id, spec) {
|
|
|
18103
18103
|
//#region src/plugins/effects/filters/glow-glsl.ts
|
|
18104
18104
|
/**
|
|
18105
18105
|
* @file effects/filters — the GLSL twin of the `Glow` fragment, the same math as `glow-wgsl.ts`
|
|
18106
|
-
* for the WebGL fallback: 64
|
|
18107
|
-
* each weighted by `(1 − r / distance)²`, every probe
|
|
18108
|
-
*
|
|
18106
|
+
* for the WebGL fallback: 64 to 256 probes, by radius in physical pixels, on a golden-angle
|
|
18107
|
+
* spiral over the disc of radius `distance`, each weighted by `(1 − r / distance)²`, every probe
|
|
18108
|
+
* clamped to the input frame, and the source drawn over the premultiplied halo
|
|
18109
|
+
* `color × coverage × strength × alpha`. The loop bound stays the constant 256, as GLSL ES
|
|
18110
|
+
* wants, and a `break` leaves at the count.
|
|
18109
18111
|
*/
|
|
18110
18112
|
/**
|
|
18111
18113
|
* The GLSL ES 3.0 fragment body of `Glow`. Reads the uniforms `strength`, `distance`, `color` and
|
|
18112
18114
|
* `alpha` under their bare names.
|
|
18113
18115
|
*/
|
|
18114
|
-
const GLOW_GLSL = `const int
|
|
18116
|
+
const GLOW_GLSL = `const int GLOW_MAX_PROBES = 256;
|
|
18115
18117
|
const float GLOW_TURN_COS = -0.7373688780783197;
|
|
18116
18118
|
const float GLOW_TURN_SIN = 0.6754902942615238;
|
|
18117
18119
|
|
|
18118
18120
|
void main() {
|
|
18119
18121
|
vec4 source = texture(uTexture, vTextureCoord);
|
|
18120
18122
|
vec2 reach = uInputSize.zw * distance;
|
|
18123
|
+
float radiusPx = distance * uInputPixel.x * uInputSize.z;
|
|
18124
|
+
int probes = clamp(int(ceil(radiusPx * radiusPx * 0.25)), 64, GLOW_MAX_PROBES);
|
|
18121
18125
|
vec2 turn = vec2(1.0, 0.0);
|
|
18122
18126
|
float coverage = 0.0;
|
|
18123
18127
|
float weights = 0.0;
|
|
18124
18128
|
|
|
18125
|
-
for (int probeIndex = 0; probeIndex <
|
|
18126
|
-
|
|
18129
|
+
for (int probeIndex = 0; probeIndex < GLOW_MAX_PROBES; probeIndex++) {
|
|
18130
|
+
if (probeIndex >= probes) break;
|
|
18131
|
+
|
|
18132
|
+
float along = sqrt((float(probeIndex) + 0.5) / float(probes));
|
|
18127
18133
|
float weight = (1.0 - along) * (1.0 - along);
|
|
18128
18134
|
vec2 probe = clamp(vTextureCoord + turn * reach * along, uInputClamp.xy, uInputClamp.zw);
|
|
18129
18135
|
|
|
@@ -18145,8 +18151,8 @@ void main() {
|
|
|
18145
18151
|
//#endregion
|
|
18146
18152
|
//#region src/plugins/effects/filters/glow-wgsl.ts
|
|
18147
18153
|
/**
|
|
18148
|
-
* @file effects/filters — the fragment body of `Glow`: a soft halo that follows the shape.
|
|
18149
|
-
*
|
|
18154
|
+
* @file effects/filters — the fragment body of `Glow`: a soft halo that follows the shape.
|
|
18155
|
+
* Probes spread evenly over the disc of radius `distance` around the pixel (a golden-angle
|
|
18150
18156
|
* spiral, so no rings and no spokes show) measure how much of the disc the shape covers, each
|
|
18151
18157
|
* probe weighted by `(1 − r / distance)²`: the near probes count most and the rim counts nothing.
|
|
18152
18158
|
* Next to a straight edge that is about ½, and it falls off fast and then slowly to 0 at
|
|
@@ -18154,11 +18160,16 @@ void main() {
|
|
|
18154
18160
|
* unweighted mean falls almost linearly and reads as an outline). The halo is
|
|
18155
18161
|
* `color × coverage × strength × alpha`, premultiplied, under the source pixel, the source drawn
|
|
18156
18162
|
* over it. Every probe stays in the input frame, so the padding around the view stays clear.
|
|
18163
|
+
*
|
|
18164
|
+
* 64 to 256 probes, by radius in physical pixels: `clamp(ceil((distance × resolution)² × 0.25),
|
|
18165
|
+
* 64, 256)`, about 3.5 physical pixels apart up to a radius of 32 physical pixels, so a glow on a
|
|
18166
|
+
* dense screen does not band; past it the 256 spread wider. The count comes from uniforms only,
|
|
18167
|
+
* so the loop leaves at it in uniform control flow, under the constant bound 256.
|
|
18157
18168
|
*/
|
|
18158
18169
|
/**
|
|
18159
18170
|
* The WGSL fragment body of `Glow`. Reads `fu.strength`, `fu.distance`, `fu.color`, `fu.alpha`.
|
|
18160
18171
|
*/
|
|
18161
|
-
const GLOW_WGSL = `const
|
|
18172
|
+
const GLOW_WGSL = `const GLOW_MAX_PROBES: i32 = 256;
|
|
18162
18173
|
const GLOW_TURN_COS: f32 = -0.7373688780783197;
|
|
18163
18174
|
const GLOW_TURN_SIN: f32 = 0.6754902942615238;
|
|
18164
18175
|
|
|
@@ -18166,12 +18177,16 @@ const GLOW_TURN_SIN: f32 = 0.6754902942615238;
|
|
|
18166
18177
|
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
18167
18178
|
let source = textureSample(uTexture, uSampler, uv);
|
|
18168
18179
|
let reach = gfu.uInputSize.zw * fu.distance;
|
|
18180
|
+
let radiusPx = fu.distance * gfu.uInputPixel.x * gfu.uInputSize.z;
|
|
18181
|
+
let probes = clamp(i32(ceil(radiusPx * radiusPx * 0.25)), 64, GLOW_MAX_PROBES);
|
|
18169
18182
|
var turn = vec2<f32>(1.0, 0.0);
|
|
18170
18183
|
var coverage = 0.0;
|
|
18171
18184
|
var weights = 0.0;
|
|
18172
18185
|
|
|
18173
|
-
for (var probeIndex = 0; probeIndex <
|
|
18174
|
-
|
|
18186
|
+
for (var probeIndex = 0; probeIndex < GLOW_MAX_PROBES; probeIndex++) {
|
|
18187
|
+
if (probeIndex >= probes) { break; }
|
|
18188
|
+
|
|
18189
|
+
let along = sqrt((f32(probeIndex) + 0.5) / f32(probes));
|
|
18175
18190
|
let weight = (1.0 - along) * (1.0 - along);
|
|
18176
18191
|
let probe = clamp(uv + turn * reach * along, gfu.uInputClamp.xy, gfu.uInputClamp.zw);
|
|
18177
18192
|
|
|
@@ -18308,7 +18323,9 @@ const alphaDefaults = {
|
|
|
18308
18323
|
* wide, that follows the shape: rounded corners stay rounded. Its alpha is
|
|
18309
18324
|
* `strength × alpha ×` the share of the disc of radius `distance` around the pixel the view
|
|
18310
18325
|
* covers, so `strength: 2` is full next to a straight edge and fades to nothing at `distance`.
|
|
18311
|
-
*
|
|
18326
|
+
* It takes 64 to 256 probes, by radius in physical pixels: about 3.5 physical pixels apart up to
|
|
18327
|
+
* a radius of 32 physical pixels. The view is padded by its live `distance`. One render pass per
|
|
18328
|
+
* apply.
|
|
18312
18329
|
*
|
|
18313
18330
|
* @example
|
|
18314
18331
|
* ```ts
|
|
@@ -30942,6 +30959,9 @@ function defineMotion(spec) {
|
|
|
30942
30959
|
* | `@moku-labs/game/assets` | the build-time asset key scanner and the production packer (`packAssets`, `--pack <dir>`), node and bun only |
|
|
30943
30960
|
* | `@moku-labs/game/inspect` | the editor's read door: `read`, `watch`, `defineSource`, the `sources` catalogue |
|
|
30944
30961
|
* | `@moku-labs/game/control` | the editor's write door, dev builds only: `run`, `defineCommand`, the `commands` catalogue |
|
|
30962
|
+
* | `@moku-labs/game/jsx-runtime`, `/jsx-dev-runtime` | the JSX runtimes `jsxImportSource: "@moku-labs/game"` names |
|
|
30963
|
+
* | `@moku-labs/game/fonts/*` | the MSDF body font `font-body.fnt` + `.png` and its OFL licence; a game copies them into `features/ui/assets/` |
|
|
30964
|
+
* | bin `moku-game-assets` | the asset scanner CLI, bun only |
|
|
30945
30965
|
*
|
|
30946
30966
|
* @file The package root: the composed framework and its public exports.
|
|
30947
30967
|
* @example
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
The MSDF body font of this folder is built from a Google Font released under the SIL Open Font
|
|
2
|
+
License 1.1. The licence text follows.
|
|
3
|
+
|
|
4
|
+
- font-body.fnt, font-body.png: Pangolin Regular (Pangolin-Regular.ttf).
|
|
5
|
+
|
|
6
|
+
================================================================================
|
|
7
|
+
|
|
8
|
+
Pangolin
|
|
9
|
+
|
|
10
|
+
================================================================================
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Copyright 2016 The Pangolin Project Authors (https://github.com/googlefonts/pangolin)
|
|
14
|
+
|
|
15
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
16
|
+
This license is copied below, and is also available with a FAQ at:
|
|
17
|
+
http://scripts.sil.org/OFL
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
-----------------------------------------------------------
|
|
21
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
22
|
+
-----------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
PREAMBLE
|
|
25
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
26
|
+
development of collaborative font projects, to support the font creation
|
|
27
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
28
|
+
open framework in which fonts may be shared and improved in partnership
|
|
29
|
+
with others.
|
|
30
|
+
|
|
31
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
32
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
33
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
34
|
+
redistributed and/or sold with any software provided that any reserved
|
|
35
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
36
|
+
however, cannot be released under any other type of license. The
|
|
37
|
+
requirement for fonts to remain under this license does not apply
|
|
38
|
+
to any document created using the fonts or their derivatives.
|
|
39
|
+
|
|
40
|
+
DEFINITIONS
|
|
41
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
42
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
43
|
+
include source files, build scripts and documentation.
|
|
44
|
+
|
|
45
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
46
|
+
copyright statement(s).
|
|
47
|
+
|
|
48
|
+
"Original Version" refers to the collection of Font Software components as
|
|
49
|
+
distributed by the Copyright Holder(s).
|
|
50
|
+
|
|
51
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
52
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
53
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
54
|
+
new environment.
|
|
55
|
+
|
|
56
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
57
|
+
writer or other person who contributed to the Font Software.
|
|
58
|
+
|
|
59
|
+
PERMISSION & CONDITIONS
|
|
60
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
61
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
62
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
63
|
+
Software, subject to the following conditions:
|
|
64
|
+
|
|
65
|
+
1) Neither the Font Software nor any of its individual components,
|
|
66
|
+
in Original or Modified Versions, may be sold by itself.
|
|
67
|
+
|
|
68
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
69
|
+
redistributed and/or sold with any software, provided that each copy
|
|
70
|
+
contains the above copyright notice and this license. These can be
|
|
71
|
+
included either as stand-alone text files, human-readable headers or
|
|
72
|
+
in the appropriate machine-readable metadata fields within text or
|
|
73
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
74
|
+
|
|
75
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
76
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
77
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
78
|
+
presented to the users.
|
|
79
|
+
|
|
80
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
81
|
+
Software shall not be used to promote, endorse or advertise any
|
|
82
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
83
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
84
|
+
permission.
|
|
85
|
+
|
|
86
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
87
|
+
must be distributed entirely under this license, and must not be
|
|
88
|
+
distributed under any other license. The requirement for fonts to
|
|
89
|
+
remain under this license does not apply to any document created
|
|
90
|
+
using the Font Software.
|
|
91
|
+
|
|
92
|
+
TERMINATION
|
|
93
|
+
This license becomes null and void if any of the above conditions are
|
|
94
|
+
not met.
|
|
95
|
+
|
|
96
|
+
DISCLAIMER
|
|
97
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
98
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
99
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
100
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
101
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
102
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
103
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
104
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
105
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|