@kuncat/avoidant 0.1.4 → 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 +26 -0
- package/dist/components/AvoidantGame.svelte +226 -137
- package/dist/components/IdleBillboard.svelte +27 -0
- package/dist/components/IdleBillboard.svelte.d.ts +8 -0
- package/dist/components/board.svelte +245 -99
- package/dist/components/board.svelte.d.ts +3 -0
- package/dist/components/fragment.glsl +29 -19
- package/dist/components/terrain-depth-sort.d.ts +17 -0
- package/dist/components/terrain-depth-sort.js +63 -0
- package/dist/components/vertex.glsl +12 -7
- package/dist/generated/shared-constants.d.ts +0 -3
- package/dist/generated/shared-constants.js +0 -3
- package/dist/paraglide/messages/_index.d.ts +14 -0
- package/dist/paraglide/messages/_index.js +15 -1
- package/dist/paraglide/messages/cells_per_face.d.ts +18 -0
- package/dist/paraglide/messages/cells_per_face.js +29 -0
- package/dist/paraglide/messages/faces_count.d.ts +18 -0
- package/dist/paraglide/messages/faces_count.js +29 -0
- package/dist/paraglide/messages/field_cell_density.d.ts +16 -0
- package/dist/paraglide/messages/field_cell_density.js +29 -0
- package/dist/paraglide/messages/field_map_shape.d.ts +16 -0
- package/dist/paraglide/messages/field_map_shape.js +29 -0
- package/dist/paraglide/messages/field_radius.d.ts +16 -0
- package/dist/paraglide/messages/field_radius.js +29 -0
- package/dist/paraglide/messages/field_radius_x.d.ts +16 -0
- package/dist/paraglide/messages/field_radius_x.js +29 -0
- package/dist/paraglide/messages/field_radius_y.d.ts +16 -0
- package/dist/paraglide/messages/field_radius_y.js +29 -0
- package/dist/paraglide/messages/field_radius_z.d.ts +16 -0
- package/dist/paraglide/messages/field_radius_z.js +29 -0
- package/dist/paraglide/messages/field_spikiness.d.ts +16 -0
- package/dist/paraglide/messages/field_spikiness.js +29 -0
- package/dist/paraglide/messages/field_subdivisions.d.ts +16 -0
- package/dist/paraglide/messages/field_subdivisions.js +29 -0
- package/dist/paraglide/messages/field_surface_detail.d.ts +16 -0
- package/dist/paraglide/messages/field_surface_detail.js +29 -0
- package/dist/paraglide/messages/shape_label.d.ts +26 -0
- package/dist/paraglide/messages/shape_label.js +55 -0
- package/dist/paraglide/messages/text_density_summary.d.ts +19 -0
- package/dist/paraglide/messages/text_density_summary.js +29 -0
- package/dist/paraglide/messages/text_invite_after_opening.d.ts +16 -0
- package/dist/paraglide/messages/text_invite_after_opening.js +29 -0
- package/dist/troika-webgl2-atlas.d.ts +33 -0
- package/dist/troika-webgl2-atlas.js +65 -0
- package/dist/wasm/avoidant_wasm.d.ts +77 -35
- package/dist/wasm/avoidant_wasm.js +236 -223
- package/dist/wasm/avoidant_wasm_bg.wasm +0 -0
- package/dist/wasm/avoidant_wasm_bg.wasm.d.ts +27 -27
- package/dist/workers/mapgen-client.js +2 -0
- package/dist/workers/mapgen.worker.d.ts +2 -0
- package/dist/workers/mapgen.worker.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{}} Field_SubdivisionsInputs */
|
|
7
|
+
|
|
8
|
+
const en_field_subdivisions = /** @type {(inputs: Field_SubdivisionsInputs) => LocalizedString} */ () => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`Subdivisions`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_field_subdivisions = /** @type {(inputs: Field_SubdivisionsInputs) => LocalizedString} */ () => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`উপবিভাজন`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "Subdivisions" |
|
|
20
|
+
*
|
|
21
|
+
* @param {Field_SubdivisionsInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const field_subdivisions = /** @type {((inputs?: Field_SubdivisionsInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Field_SubdivisionsInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs = {}, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_field_subdivisions(inputs)
|
|
28
|
+
return bn_field_subdivisions(inputs)
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | output |
|
|
3
|
+
* | --- |
|
|
4
|
+
* | "Polyhedron faces" |
|
|
5
|
+
*
|
|
6
|
+
* @param {Field_Surface_DetailInputs} inputs
|
|
7
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
8
|
+
* @returns {LocalizedString}
|
|
9
|
+
*/
|
|
10
|
+
export const field_surface_detail: ((inputs?: Field_Surface_DetailInputs, options?: {
|
|
11
|
+
locale?: "en" | "bn";
|
|
12
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Field_Surface_DetailInputs, {
|
|
13
|
+
locale?: "en" | "bn";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
16
|
+
export type Field_Surface_DetailInputs = {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{}} Field_Surface_DetailInputs */
|
|
7
|
+
|
|
8
|
+
const en_field_surface_detail = /** @type {(inputs: Field_Surface_DetailInputs) => LocalizedString} */ () => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`Polyhedron faces`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_field_surface_detail = /** @type {(inputs: Field_Surface_DetailInputs) => LocalizedString} */ () => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`বহুতলকের পৃষ্ঠ`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "Polyhedron faces" |
|
|
20
|
+
*
|
|
21
|
+
* @param {Field_Surface_DetailInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const field_surface_detail = /** @type {((inputs?: Field_Surface_DetailInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Field_Surface_DetailInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs = {}, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_field_surface_detail(inputs)
|
|
28
|
+
return bn_field_surface_detail(inputs)
|
|
29
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | kind | output |
|
|
3
|
+
* | --- | --- |
|
|
4
|
+
* | "flat" | "Flat" |
|
|
5
|
+
* | "tetrahedron" | "Tetrahedron (4 faces)" |
|
|
6
|
+
* | "cube" | "Cube (6 faces)" |
|
|
7
|
+
* | "octahedron" | "Octahedron (8 faces)" |
|
|
8
|
+
* | "dodecahedron" | "Dodecahedron (12 faces)" |
|
|
9
|
+
* | "icosahedron" | "Icosahedron (20 faces)" |
|
|
10
|
+
* | "geodesicIcosphere" | "Geodesic icosphere" |
|
|
11
|
+
* | "spheroid" | "Spheroid" |
|
|
12
|
+
* | * | "{kind}" |
|
|
13
|
+
*
|
|
14
|
+
* @param {Shape_LabelInputs} inputs
|
|
15
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
16
|
+
* @returns {LocalizedString}
|
|
17
|
+
*/
|
|
18
|
+
export const shape_label: ((inputs: Shape_LabelInputs, options?: {
|
|
19
|
+
locale?: "en" | "bn";
|
|
20
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Shape_LabelInputs, {
|
|
21
|
+
locale?: "en" | "bn";
|
|
22
|
+
}, {}>;
|
|
23
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
24
|
+
export type Shape_LabelInputs = {
|
|
25
|
+
kind: NonNullable<unknown>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{ kind: NonNullable<unknown> }} Shape_LabelInputs */
|
|
7
|
+
|
|
8
|
+
const en_shape_label = /** @type {(inputs: Shape_LabelInputs) => LocalizedString} */ (i) => {
|
|
9
|
+
if (i?.kind === "flat") return /** @type {LocalizedString} */ (`Flat`);
|
|
10
|
+
if (i?.kind === "tetrahedron") return /** @type {LocalizedString} */ (`Tetrahedron (4 faces)`);
|
|
11
|
+
if (i?.kind === "cube") return /** @type {LocalizedString} */ (`Cube (6 faces)`);
|
|
12
|
+
if (i?.kind === "octahedron") return /** @type {LocalizedString} */ (`Octahedron (8 faces)`);
|
|
13
|
+
if (i?.kind === "dodecahedron") return /** @type {LocalizedString} */ (`Dodecahedron (12 faces)`);
|
|
14
|
+
if (i?.kind === "icosahedron") return /** @type {LocalizedString} */ (`Icosahedron (20 faces)`);
|
|
15
|
+
if (i?.kind === "geodesicIcosphere") return /** @type {LocalizedString} */ (`Geodesic icosphere`);
|
|
16
|
+
if (i?.kind === "spheroid") return /** @type {LocalizedString} */ (`Spheroid`);
|
|
17
|
+
return /** @type {LocalizedString} */ (`${i?.kind}`)
|
|
18
|
+
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const bn_shape_label = /** @type {(inputs: Shape_LabelInputs) => LocalizedString} */ (i) => {
|
|
22
|
+
if (i?.kind === "flat") return /** @type {LocalizedString} */ (`সমতল`);
|
|
23
|
+
if (i?.kind === "tetrahedron") return /** @type {LocalizedString} */ (`টেট্রাহেড্রন (৪ মুখ)`);
|
|
24
|
+
if (i?.kind === "cube") return /** @type {LocalizedString} */ (`ঘনক (৬ মুখ)`);
|
|
25
|
+
if (i?.kind === "octahedron") return /** @type {LocalizedString} */ (`অষ্টভুজ (৮ মুখ)`);
|
|
26
|
+
if (i?.kind === "dodecahedron") return /** @type {LocalizedString} */ (`দ্বাদশভুজ (১২ মুখ)`);
|
|
27
|
+
if (i?.kind === "icosahedron") return /** @type {LocalizedString} */ (`বিংশভুজ (২০ মুখ)`);
|
|
28
|
+
if (i?.kind === "geodesicIcosphere") return /** @type {LocalizedString} */ (`জিওডেসিক গোলক`);
|
|
29
|
+
if (i?.kind === "spheroid") return /** @type {LocalizedString} */ (`গোলকাকার`);
|
|
30
|
+
return /** @type {LocalizedString} */ (`${i?.kind}`)
|
|
31
|
+
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* | kind | output |
|
|
36
|
+
* | --- | --- |
|
|
37
|
+
* | "flat" | "Flat" |
|
|
38
|
+
* | "tetrahedron" | "Tetrahedron (4 faces)" |
|
|
39
|
+
* | "cube" | "Cube (6 faces)" |
|
|
40
|
+
* | "octahedron" | "Octahedron (8 faces)" |
|
|
41
|
+
* | "dodecahedron" | "Dodecahedron (12 faces)" |
|
|
42
|
+
* | "icosahedron" | "Icosahedron (20 faces)" |
|
|
43
|
+
* | "geodesicIcosphere" | "Geodesic icosphere" |
|
|
44
|
+
* | "spheroid" | "Spheroid" |
|
|
45
|
+
* | * | "{kind}" |
|
|
46
|
+
*
|
|
47
|
+
* @param {Shape_LabelInputs} inputs
|
|
48
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
49
|
+
* @returns {LocalizedString}
|
|
50
|
+
*/
|
|
51
|
+
export const shape_label = /** @type {((inputs: Shape_LabelInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Shape_LabelInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs, options = {}) => {
|
|
52
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
53
|
+
if (locale === "en") return en_shape_label(inputs)
|
|
54
|
+
return bn_shape_label(inputs)
|
|
55
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | output |
|
|
3
|
+
* | --- |
|
|
4
|
+
* | "{faces} faces · {count} cells total" |
|
|
5
|
+
*
|
|
6
|
+
* @param {Text_Density_SummaryInputs} inputs
|
|
7
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
8
|
+
* @returns {LocalizedString}
|
|
9
|
+
*/
|
|
10
|
+
export const text_density_summary: ((inputs: Text_Density_SummaryInputs, options?: {
|
|
11
|
+
locale?: "en" | "bn";
|
|
12
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Text_Density_SummaryInputs, {
|
|
13
|
+
locale?: "en" | "bn";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
16
|
+
export type Text_Density_SummaryInputs = {
|
|
17
|
+
faces: NonNullable<unknown>;
|
|
18
|
+
count: NonNullable<unknown>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{ faces: NonNullable<unknown>, count: NonNullable<unknown> }} Text_Density_SummaryInputs */
|
|
7
|
+
|
|
8
|
+
const en_text_density_summary = /** @type {(inputs: Text_Density_SummaryInputs) => LocalizedString} */ (i) => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`${i?.faces} faces · ${i?.count} cells total`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_text_density_summary = /** @type {(inputs: Text_Density_SummaryInputs) => LocalizedString} */ (i) => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`${i?.faces}টি পৃষ্ঠ · মোট ${i?.count}টি ঘর`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "{faces} faces · {count} cells total" |
|
|
20
|
+
*
|
|
21
|
+
* @param {Text_Density_SummaryInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const text_density_summary = /** @type {((inputs: Text_Density_SummaryInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Text_Density_SummaryInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_text_density_summary(inputs)
|
|
28
|
+
return bn_text_density_summary(inputs)
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | output |
|
|
3
|
+
* | --- |
|
|
4
|
+
* | "Explore a cell before inviting players." |
|
|
5
|
+
*
|
|
6
|
+
* @param {Text_Invite_After_OpeningInputs} inputs
|
|
7
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
8
|
+
* @returns {LocalizedString}
|
|
9
|
+
*/
|
|
10
|
+
export const text_invite_after_opening: ((inputs?: Text_Invite_After_OpeningInputs, options?: {
|
|
11
|
+
locale?: "en" | "bn";
|
|
12
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Text_Invite_After_OpeningInputs, {
|
|
13
|
+
locale?: "en" | "bn";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
16
|
+
export type Text_Invite_After_OpeningInputs = {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{}} Text_Invite_After_OpeningInputs */
|
|
7
|
+
|
|
8
|
+
const en_text_invite_after_opening = /** @type {(inputs: Text_Invite_After_OpeningInputs) => LocalizedString} */ () => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`Explore a cell before inviting players.`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_text_invite_after_opening = /** @type {(inputs: Text_Invite_After_OpeningInputs) => LocalizedString} */ () => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`খেলোয়াড়দের আমন্ত্রণ জানানোর আগে একটি ঘর উন্মোচন করুন।`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "Explore a cell before inviting players." |
|
|
20
|
+
*
|
|
21
|
+
* @param {Text_Invite_After_OpeningInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const text_invite_after_opening = /** @type {((inputs?: Text_Invite_After_OpeningInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Text_Invite_After_OpeningInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs = {}, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_text_invite_after_opening(inputs)
|
|
28
|
+
return bn_text_invite_after_opening(inputs)
|
|
29
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workaround for troika-three-text failing to render in recent Brave versions.
|
|
3
|
+
*
|
|
4
|
+
* The `<Text>` labels (drawn via `@threlte/extras` → `troika-three-text` →
|
|
5
|
+
* `webgl-sdf-generator`) stopped rendering in Brave, throwing:
|
|
6
|
+
*
|
|
7
|
+
* Error: ANGLE_instanced_arrays not supported
|
|
8
|
+
*
|
|
9
|
+
* Root cause: `webgl-sdf-generator` renders its glyph SDF atlas into a canvas for
|
|
10
|
+
* which it hard-codes a **WebGL 1** context (`getContext('webgl', …)`). On WebGL 1
|
|
11
|
+
* it unconditionally requires the `ANGLE_instanced_arrays` extension — even in
|
|
12
|
+
* `renderImageData`, the plain (non-instanced) blit used by its pure-JS fallback
|
|
13
|
+
* path. Recent Brave builds refuse to hand out that extension (fingerprinting
|
|
14
|
+
* protection returns `null` from `getExtension`), so `getExtension(...)` throws.
|
|
15
|
+
* Because troika's JS fallback also routes its final atlas upload through that same
|
|
16
|
+
* WebGL 1 blit, there is no working fallback and the labels never appear. Firefox
|
|
17
|
+
* and Safari still expose the extension, which is why only Brave is affected.
|
|
18
|
+
*
|
|
19
|
+
* Fix: transparently upgrade troika's atlas canvas to a **WebGL 2** context. WebGL 2
|
|
20
|
+
* has instancing built in (`vertexAttribDivisor` / `drawArraysInstanced`), so
|
|
21
|
+
* `webgl-sdf-generator` never asks for `ANGLE_instanced_arrays` at all (see its
|
|
22
|
+
* `isWebGL2` branches) and the GPU path works normally. Brave already exposes a
|
|
23
|
+
* working WebGL 2 context here — the game's main three.js renderer uses one.
|
|
24
|
+
*
|
|
25
|
+
* We scope the patch as tightly as possible: it only fires for a `'webgl'` request
|
|
26
|
+
* carrying troika's exact context attributes (`preserveDrawingBuffer: true` with
|
|
27
|
+
* `depth: false`), which the game's own renderer (it asks for `'webgl2'` directly)
|
|
28
|
+
* never matches. WebGL 2 is a superset of WebGL 1, so returning it is safe.
|
|
29
|
+
*
|
|
30
|
+
* Import this module for its side effect once, before any `<Text>` mounts. No-op
|
|
31
|
+
* during SSR and on browsers where `'webgl'` is already the only option.
|
|
32
|
+
*/
|
|
33
|
+
export declare function installTroikaWebGL2AtlasFix(): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workaround for troika-three-text failing to render in recent Brave versions.
|
|
3
|
+
*
|
|
4
|
+
* The `<Text>` labels (drawn via `@threlte/extras` → `troika-three-text` →
|
|
5
|
+
* `webgl-sdf-generator`) stopped rendering in Brave, throwing:
|
|
6
|
+
*
|
|
7
|
+
* Error: ANGLE_instanced_arrays not supported
|
|
8
|
+
*
|
|
9
|
+
* Root cause: `webgl-sdf-generator` renders its glyph SDF atlas into a canvas for
|
|
10
|
+
* which it hard-codes a **WebGL 1** context (`getContext('webgl', …)`). On WebGL 1
|
|
11
|
+
* it unconditionally requires the `ANGLE_instanced_arrays` extension — even in
|
|
12
|
+
* `renderImageData`, the plain (non-instanced) blit used by its pure-JS fallback
|
|
13
|
+
* path. Recent Brave builds refuse to hand out that extension (fingerprinting
|
|
14
|
+
* protection returns `null` from `getExtension`), so `getExtension(...)` throws.
|
|
15
|
+
* Because troika's JS fallback also routes its final atlas upload through that same
|
|
16
|
+
* WebGL 1 blit, there is no working fallback and the labels never appear. Firefox
|
|
17
|
+
* and Safari still expose the extension, which is why only Brave is affected.
|
|
18
|
+
*
|
|
19
|
+
* Fix: transparently upgrade troika's atlas canvas to a **WebGL 2** context. WebGL 2
|
|
20
|
+
* has instancing built in (`vertexAttribDivisor` / `drawArraysInstanced`), so
|
|
21
|
+
* `webgl-sdf-generator` never asks for `ANGLE_instanced_arrays` at all (see its
|
|
22
|
+
* `isWebGL2` branches) and the GPU path works normally. Brave already exposes a
|
|
23
|
+
* working WebGL 2 context here — the game's main three.js renderer uses one.
|
|
24
|
+
*
|
|
25
|
+
* We scope the patch as tightly as possible: it only fires for a `'webgl'` request
|
|
26
|
+
* carrying troika's exact context attributes (`preserveDrawingBuffer: true` with
|
|
27
|
+
* `depth: false`), which the game's own renderer (it asks for `'webgl2'` directly)
|
|
28
|
+
* never matches. WebGL 2 is a superset of WebGL 1, so returning it is safe.
|
|
29
|
+
*
|
|
30
|
+
* Import this module for its side effect once, before any `<Text>` mounts. No-op
|
|
31
|
+
* during SSR and on browsers where `'webgl'` is already the only option.
|
|
32
|
+
*/
|
|
33
|
+
export function installTroikaWebGL2AtlasFix() {
|
|
34
|
+
if (typeof document === "undefined" || typeof HTMLCanvasElement === "undefined") {
|
|
35
|
+
return; // SSR / non-DOM environment
|
|
36
|
+
}
|
|
37
|
+
if (typeof WebGL2RenderingContext === "undefined") {
|
|
38
|
+
return; // Browser has no WebGL 2; nothing we can do, leave original behavior.
|
|
39
|
+
}
|
|
40
|
+
const proto = HTMLCanvasElement.prototype;
|
|
41
|
+
if (proto.__troikaWebGL2Patched) {
|
|
42
|
+
return; // Idempotent: already installed.
|
|
43
|
+
}
|
|
44
|
+
proto.__troikaWebGL2Patched = true;
|
|
45
|
+
const originalGetContext = proto.getContext;
|
|
46
|
+
// Recognizes the atlas-canvas request that webgl-sdf-generator makes.
|
|
47
|
+
function isTroikaAtlasRequest(contextType, attrs) {
|
|
48
|
+
if (contextType !== "webgl" && contextType !== "experimental-webgl") {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const a = attrs;
|
|
52
|
+
return !!a && a.preserveDrawingBuffer === true && a.depth === false;
|
|
53
|
+
}
|
|
54
|
+
proto.getContext = function patchedGetContext(contextType, options) {
|
|
55
|
+
if (isTroikaAtlasRequest(contextType, options)) {
|
|
56
|
+
const gl2 = originalGetContext.call(this, "webgl2", options);
|
|
57
|
+
if (gl2) {
|
|
58
|
+
return gl2;
|
|
59
|
+
}
|
|
60
|
+
// WebGL 2 unavailable on this canvas — fall through to the original request.
|
|
61
|
+
}
|
|
62
|
+
// eslint-disable-next-line prefer-rest-params
|
|
63
|
+
return originalGetContext.apply(this, arguments);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -14,20 +14,38 @@ import type { Readable } from "svelte/store";
|
|
|
14
14
|
/**
|
|
15
15
|
* Flat per-vertex terrain mesh, decoupled from cell corners.
|
|
16
16
|
*
|
|
17
|
-
* `positions` is a `[x, y, z]`-packed `f32` array (length is a multiple of 9 (3 verts per triangle, 3 floats per vert). `normals` is `[nx, ny, nz]`) packed and parallel to `positions`; each vertex carries a smooth normal derived analytically from the noise field so the shader can per-pixel-interpolate it and avoid faceted flat shading. `cell_indices` carries the owning cell index for each emitted vertex (length = `positions.len() / 3`). Built once per map by [`crate::mapgen::generate_terrain_triangles`].
|
|
17
|
+
* `positions` is a `[x, y, z]`-packed `f32` array (length is a multiple of 9 (3 verts per triangle, 3 floats per vert). `normals` is `[nx, ny, nz]`) packed and parallel to `positions`; each vertex carries a smooth normal derived analytically from the noise field so the shader can per-pixel-interpolate it and avoid faceted flat shading. `cell_indices` carries the owning cell index for each emitted vertex (length = `positions.len() / 3`). `heights` is the scalar elevation displacement per vertex (the raw value sampled from the noise field along the cell's outward normal); the shader uses it for the elevation color ramp. Built once per map by [`crate::mapgen::generate_terrain_triangles`].
|
|
18
18
|
*/
|
|
19
19
|
export interface TerrainTriangles {
|
|
20
20
|
positions: number[];
|
|
21
21
|
normals: number[];
|
|
22
22
|
cellIndices: number[];
|
|
23
|
+
heights: number[];
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Map surface shape. Serialized as a tagged JS union; on the TS side this
|
|
28
|
+
* becomes a discriminated union by `kind`.
|
|
29
|
+
*/
|
|
30
|
+
export type MapShape = { kind: "flat"; radius: number } | { kind: "tetrahedron"; radius: number } | { kind: "cube"; radius: number } | { kind: "octahedron"; radius: number } | { kind: "dodecahedron"; radius: number } | { kind: "icosahedron"; radius: number } | { kind: "geodesicIcosphere"; radius: number; subdivisions: number } | { kind: "spheroid"; radiusX: number; radiusY: number; radiusZ: number };
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
* Voronoi cell polygons paired with the subdivided terrain triangle mesh.
|
|
27
34
|
*/
|
|
28
35
|
export interface MapData {
|
|
29
36
|
cells: MapCell[];
|
|
30
37
|
terrain: TerrainTriangles;
|
|
38
|
+
/**
|
|
39
|
+
* Estimated surface area of the generated shape in world units²; used
|
|
40
|
+
* by the renderer to size per-cell visuals (labels, gap insets) from
|
|
41
|
+
* the per-cell average area.
|
|
42
|
+
*/
|
|
43
|
+
surfaceArea: number;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum radial extent of the un-displaced shape from the origin, in
|
|
46
|
+
* world units. Used for camera framing.
|
|
47
|
+
*/
|
|
48
|
+
boundsRadius: number;
|
|
31
49
|
}
|
|
32
50
|
|
|
33
51
|
export interface CellMetadataEntry {
|
|
@@ -47,18 +65,20 @@ export interface GameOptions {
|
|
|
47
65
|
* Iroh relay server URLs to use for peer discovery and transport.
|
|
48
66
|
*/
|
|
49
67
|
relayUrls?: string[];
|
|
50
|
-
|
|
51
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Map surface shape. Defaults to Icosahedron { radius: 50.0 }.
|
|
70
|
+
*/
|
|
71
|
+
shape?: MapShape;
|
|
52
72
|
/**
|
|
53
73
|
* 0.0 = smooth broad hills, 1.0 = tight spiky features. Default: 0.4
|
|
54
74
|
*/
|
|
55
75
|
spikiness?: number;
|
|
56
76
|
/**
|
|
57
|
-
* Minimum vertex
|
|
77
|
+
* Minimum vertex elevation displacement in world units. Default: -0.4
|
|
58
78
|
*/
|
|
59
79
|
elevationMin?: number;
|
|
60
80
|
/**
|
|
61
|
-
* Maximum vertex
|
|
81
|
+
* Maximum vertex elevation displacement in world units. Default: 0.4
|
|
62
82
|
*/
|
|
63
83
|
elevationMax?: number;
|
|
64
84
|
/**
|
|
@@ -66,11 +86,33 @@ export interface GameOptions {
|
|
|
66
86
|
*/
|
|
67
87
|
terrainSubdivisions?: number;
|
|
68
88
|
voidFraction?: number;
|
|
89
|
+
firstSafeCell?: number;
|
|
90
|
+
authority?: string;
|
|
91
|
+
syncVersion?: number;
|
|
69
92
|
}
|
|
70
93
|
|
|
71
94
|
export interface MapCell {
|
|
95
|
+
/**
|
|
96
|
+
* True 3D world-space polygon vertices on (or just above) the map
|
|
97
|
+
* surface, CCW around `normal`.
|
|
98
|
+
*/
|
|
72
99
|
vertices: [number, number, number][];
|
|
100
|
+
/**
|
|
101
|
+
* Global indices of adjacent cells, including cross-face neighbors that
|
|
102
|
+
* share an actual boundary edge on the surface.
|
|
103
|
+
*/
|
|
73
104
|
neighbors: number[];
|
|
105
|
+
/**
|
|
106
|
+
* 3D centroid of the cell on the surface (used for label anchoring, fan
|
|
107
|
+
* triangulation apex, and pulse origins).
|
|
108
|
+
*/
|
|
109
|
+
centroid: [number, number, number];
|
|
110
|
+
/**
|
|
111
|
+
* Outward unit normal at the cell's centroid. For polyhedra this is the
|
|
112
|
+
* face normal; for the spheroid it's the surface normal at the centroid.
|
|
113
|
+
* Used by the renderer to displace falling void cells outward.
|
|
114
|
+
*/
|
|
115
|
+
normal: [number, number, number];
|
|
74
116
|
}
|
|
75
117
|
|
|
76
118
|
export interface NetworkPeerStatus {
|
|
@@ -170,7 +212,7 @@ export class GameState {
|
|
|
170
212
|
*
|
|
171
213
|
* The caller is responsible for having populated the map cells (typically
|
|
172
214
|
* via [`GameState::apply_map_cells`]) before invoking this; the function
|
|
173
|
-
*
|
|
215
|
+
* waits for an authoritative snapshot before allowing gameplay.
|
|
174
216
|
*/
|
|
175
217
|
joinAsPeer(ticket: string, nickname: string): Promise<void>;
|
|
176
218
|
constructor(options: GameOptions);
|
|
@@ -188,7 +230,7 @@ export class GameState {
|
|
|
188
230
|
readonly networkPeers: NetworkPeerStatus[];
|
|
189
231
|
readonly networkSnapshot: Readable<NetworkSnapshot>;
|
|
190
232
|
/**
|
|
191
|
-
*
|
|
233
|
+
* Canonical score, synchronized from the host independently of reveal animations.
|
|
192
234
|
*/
|
|
193
235
|
readonly score: Readable<ScoreState>;
|
|
194
236
|
readonly topicId: string | undefined;
|
|
@@ -261,7 +303,7 @@ export class UiState {
|
|
|
261
303
|
}
|
|
262
304
|
|
|
263
305
|
/**
|
|
264
|
-
* Build map cells and
|
|
306
|
+
* Build map cells and the subdivided terrain triangle mesh.
|
|
265
307
|
*/
|
|
266
308
|
export function generateMapData(options: GameOptions): MapData;
|
|
267
309
|
|
|
@@ -274,6 +316,9 @@ export interface InitOutput {
|
|
|
274
316
|
readonly __wbg_channel_free: (a: number, b: number) => void;
|
|
275
317
|
readonly __wbg_channelsender_free: (a: number, b: number) => void;
|
|
276
318
|
readonly __wbg_gamestate_free: (a: number, b: number) => void;
|
|
319
|
+
readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
|
|
320
|
+
readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
|
|
321
|
+
readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
|
|
277
322
|
readonly __wbg_networknode_free: (a: number, b: number) => void;
|
|
278
323
|
readonly __wbg_pulse_free: (a: number, b: number) => void;
|
|
279
324
|
readonly __wbg_uistate_free: (a: number, b: number) => void;
|
|
@@ -287,6 +332,8 @@ export interface InitOutput {
|
|
|
287
332
|
readonly gamestate_applyMapCells: (a: number, b: any) => [number, number, number];
|
|
288
333
|
readonly gamestate_cellMetadata: (a: number) => any;
|
|
289
334
|
readonly gamestate_cells: (a: number) => any;
|
|
335
|
+
readonly gamestate_elevationMax: (a: number) => number;
|
|
336
|
+
readonly gamestate_elevationMin: (a: number) => number;
|
|
290
337
|
readonly gamestate_endpointId: (a: number) => [number, number];
|
|
291
338
|
readonly gamestate_exploreCell: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
292
339
|
readonly gamestate_hasNetworkNode: (a: number) => number;
|
|
@@ -304,46 +351,41 @@ export interface InitOutput {
|
|
|
304
351
|
readonly gamestate_topicId: (a: number) => [number, number];
|
|
305
352
|
readonly gamestate_uiState: (a: number) => number;
|
|
306
353
|
readonly generateMapData: (a: any) => [number, number, number];
|
|
354
|
+
readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
|
|
355
|
+
readonly intounderlyingbytesource_cancel: (a: number) => void;
|
|
356
|
+
readonly intounderlyingbytesource_pull: (a: number, b: any) => any;
|
|
357
|
+
readonly intounderlyingbytesource_start: (a: number, b: any) => void;
|
|
358
|
+
readonly intounderlyingbytesource_type: (a: number) => number;
|
|
359
|
+
readonly intounderlyingsink_abort: (a: number, b: any) => any;
|
|
360
|
+
readonly intounderlyingsink_close: (a: number) => any;
|
|
361
|
+
readonly intounderlyingsink_write: (a: number, b: any) => any;
|
|
362
|
+
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
363
|
+
readonly intounderlyingsource_pull: (a: number, b: any) => any;
|
|
307
364
|
readonly networknode_create: (a: number, b: number, c: number) => any;
|
|
308
365
|
readonly networknode_endpointId: (a: number) => [number, number];
|
|
309
366
|
readonly networknode_join: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
310
367
|
readonly networknode_spawn: () => any;
|
|
368
|
+
readonly pulse_createdAtMs: (a: number) => number;
|
|
311
369
|
readonly pulse_durationMs: (a: number) => number;
|
|
312
370
|
readonly pulse_id: (a: number) => number;
|
|
313
371
|
readonly pulse_isRemote: (a: number) => number;
|
|
372
|
+
readonly pulse_maxRadius: (a: number) => number;
|
|
314
373
|
readonly pulse_nullPulse: () => number;
|
|
315
374
|
readonly pulse_originCell: (a: number) => number;
|
|
316
375
|
readonly pulse_position: (a: number) => [number, number];
|
|
317
376
|
readonly start: () => void;
|
|
318
377
|
readonly uistate_pulses: (a: number) => any;
|
|
319
|
-
readonly gamestate_elevationMax: (a: number) => number;
|
|
320
|
-
readonly gamestate_elevationMin: (a: number) => number;
|
|
321
|
-
readonly pulse_createdAtMs: (a: number) => number;
|
|
322
|
-
readonly pulse_maxRadius: (a: number) => number;
|
|
323
|
-
readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
|
|
324
|
-
readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
|
|
325
|
-
readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
|
|
326
|
-
readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
|
|
327
|
-
readonly intounderlyingbytesource_cancel: (a: number) => void;
|
|
328
|
-
readonly intounderlyingbytesource_pull: (a: number, b: any) => any;
|
|
329
|
-
readonly intounderlyingbytesource_start: (a: number, b: any) => void;
|
|
330
|
-
readonly intounderlyingbytesource_type: (a: number) => number;
|
|
331
|
-
readonly intounderlyingsink_abort: (a: number, b: any) => any;
|
|
332
|
-
readonly intounderlyingsink_close: (a: number) => any;
|
|
333
|
-
readonly intounderlyingsink_write: (a: number, b: any) => any;
|
|
334
|
-
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
335
|
-
readonly intounderlyingsource_pull: (a: number, b: any) => any;
|
|
336
378
|
readonly ring_core_0_17_14__bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
337
|
-
readonly
|
|
338
|
-
readonly
|
|
339
|
-
readonly
|
|
340
|
-
readonly
|
|
341
|
-
readonly
|
|
342
|
-
readonly
|
|
343
|
-
readonly
|
|
344
|
-
readonly
|
|
345
|
-
readonly
|
|
346
|
-
readonly
|
|
379
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke___js_sys_2872832c11c194f9___Function_fn_wasm_bindgen_6ded4d2ca8032970___JsValue_____wasm_bindgen_6ded4d2ca8032970___sys__Undefined___js_sys_2872832c11c194f9___Function_fn_wasm_bindgen_6ded4d2ca8032970___JsValue_____wasm_bindgen_6ded4d2ca8032970___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
380
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke___wasm_bindgen_6ded4d2ca8032970___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_6ded4d2ca8032970___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
381
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke___wasm_bindgen_6ded4d2ca8032970___JsValue__wasm_bindgen_6ded4d2ca8032970___JsValue__true_: (a: number, b: number, c: any) => any;
|
|
382
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke___wasm_bindgen_6ded4d2ca8032970___JsValue______true_: (a: number, b: number, c: any) => void;
|
|
383
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke___web_sys_1a344eaec6f2c168___features__gen_CloseEvent__CloseEvent______true_: (a: number, b: number, c: any) => void;
|
|
384
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke___web_sys_1a344eaec6f2c168___features__gen_MessageEvent__MessageEvent______true_: (a: number, b: number, c: any) => void;
|
|
385
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke_______true_: (a: number, b: number) => void;
|
|
386
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke_______true__1_: (a: number, b: number) => void;
|
|
387
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke_______true__2_: (a: number, b: number) => void;
|
|
388
|
+
readonly wasm_bindgen_6ded4d2ca8032970___convert__closures_____invoke_______true__3_: (a: number, b: number) => void;
|
|
347
389
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
348
390
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
349
391
|
readonly __wbindgen_exn_store: (a: number) => void;
|