@woosh/meep-engine 3.78.4 → 3.79.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/CHANGELOG.md +34 -0
- package/package.json +1 -1
- package/src/engine/asset/GameAssetType.d.ts +2 -0
- package/src/engine/asset/GameAssetType.js +10 -0
- package/src/engine/asset/guessAssetType.d.ts.map +1 -1
- package/src/engine/asset/guessAssetType.js +4 -0
- package/src/engine/asset/load_model_scene_bundle.d.ts +1 -1
- package/src/engine/asset/load_model_scene_bundle.js +2 -2
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts +42 -0
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.js +83 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts +36 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.js +78 -0
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts +6 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts.map +1 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +8 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts +33 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.js +196 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts +25 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.js +85 -0
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
- package/src/shade/renderer/hair/GPUHairSystem.js +16 -7
- package/src/shade/renderer/hair/HAIR.d.ts +5 -3
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR.js +6 -4
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts +10 -10
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -1
- package/src/shade/renderer/hair/hair_shadow_draw.js +21 -17
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_cull.js +6 -2
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +5 -4
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_shadow_list.js +10 -12
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts +38 -0
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.js +198 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.d.ts +88 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.js +159 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts +30 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.js +136 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.js +6 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts +8 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.js +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.js +6 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.js +6 -0
- package/src/shade/renderer/loader/mtf/load_mtf.d.ts +41 -0
- package/src/shade/renderer/loader/mtf/load_mtf.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/load_mtf.js +73 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts +19 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.js +57 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +9 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +78 -0
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts +45 -0
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_export.js +161 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts +9 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.js +12 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts +24 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.js +37 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts +27 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.js +121 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts +18 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.js +51 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.d.ts +21 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.js +98 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts +25 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.js +51 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts +20 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.js +80 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts +24 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.js +42 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts +31 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.js +87 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts +36 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_write.js +161 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.d.ts +39 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.js +207 -0
- package/src/shade/renderer/scene/optimization/source_to_sampler2d.d.ts.map +1 -1
- package/src/shade/renderer/scene/optimization/source_to_sampler2d.js +3 -1
- package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.d.ts +5 -5
- package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.js +5 -5
- package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/deserialize_scene.js +491 -528
- package/src/shade/renderer/scene/serialization/serialize_scene.d.ts +0 -10
- package/src/shade/renderer/scene/serialization/serialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/serialize_scene.js +15 -71
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.d.ts +11 -0
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.js +14 -0
- package/src/shade/renderer/texture/texture_role_image_quality.d.ts +10 -0
- package/src/shade/renderer/texture/texture_role_image_quality.d.ts.map +1 -0
- package/src/shade/renderer/texture/texture_role_image_quality.js +29 -0
|
@@ -30,7 +30,8 @@ import { HAIR_SHADOW_VIEW_STRUCT } from "./HAIR_FRAME_STRUCTS.js";
|
|
|
30
30
|
*
|
|
31
31
|
* **A shadow view's list** is laid out as the frame's draw list is (`HAIR.js`): view `v`'s from entry
|
|
32
32
|
* `v × list capacity`, each class's region from the draw list's start of it, its strands from the region's start, as
|
|
33
|
-
* many as the view's count of the class (`hair_shadow_counts`, `v × HAIR_CLASS_COUNT + class`).
|
|
33
|
+
* many as the view's count of the class (`hair_shadow_counts`, `v × HAIR_CLASS_COUNT + class`). An entry is where the
|
|
34
|
+
* strand's entry is in the frame's draw list, which holds its slot, its class and its shadow words.
|
|
34
35
|
*/
|
|
35
36
|
|
|
36
37
|
export const HAIR_SHADOW_LIST_SETTINGS = WebGPUStruct.from({
|
|
@@ -112,11 +113,11 @@ list_resources.createGroup()
|
|
|
112
113
|
*
|
|
113
114
|
* - the ball about its root as wide as its reach (its shadow words) is inside the view's planes, the near one aside;
|
|
114
115
|
* - its widest point, at the finest the view's texels are within that ball, is drawn by the shadow draw: wider than
|
|
115
|
-
* its
|
|
116
|
+
* its share (its third shadow word) of half a texel, the test of `hair_shadow_draw.js`. Where the ball reaches
|
|
116
117
|
* the eye of a perspective view, its texels are not bounded, and the strand is drawn.
|
|
117
118
|
*
|
|
118
|
-
* A drawn strand is appended to its class's region of the view's list
|
|
119
|
-
* count of the class).
|
|
119
|
+
* A drawn strand is appended to its class's region of the view's list, as the place of its entry in the frame's draw
|
|
120
|
+
* list (`chunk_subgroup_keyed_append` on the view's count of the class).
|
|
120
121
|
*
|
|
121
122
|
* @type {ComputeShader}
|
|
122
123
|
*/
|
|
@@ -132,7 +133,7 @@ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocatio
|
|
|
132
133
|
let entries = hair_list_entries();
|
|
133
134
|
|
|
134
135
|
var key = ${SUBGROUP_KEYED_APPEND_NONE}u;
|
|
135
|
-
var
|
|
136
|
+
var listed_at = 0u;
|
|
136
137
|
var place_base = 0u;
|
|
137
138
|
|
|
138
139
|
if (entries > 0u && thread < entries * settings.view_count) {
|
|
@@ -156,14 +157,12 @@ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocatio
|
|
|
156
157
|
|| (offset >= viewed && offset < hair_counters[${HAIR_COUNTER_SHADOW_CURSORS}u + point_class] - base);
|
|
157
158
|
|
|
158
159
|
if (listed) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
let slot = entry & ${2 ** HAIR_CLASS_SHIFT - 1}u;
|
|
162
|
-
let segments = 1u << (entry >> ${HAIR_CLASS_SHIFT}u);
|
|
160
|
+
let slot = hair_list[at] & ${2 ** HAIR_CLASS_SHIFT - 1}u;
|
|
163
161
|
|
|
164
162
|
let shadow_at = settings.list_capacity + at * ${HAIR_LIST_SHADOW_WORDS}u;
|
|
165
163
|
let widest = bitcast<f32>(hair_list[shadow_at]);
|
|
166
164
|
let reach = bitcast<f32>(hair_list[shadow_at + 1u]);
|
|
165
|
+
let share = bitcast<f32>(hair_list[shadow_at + 2u]);
|
|
167
166
|
|
|
168
167
|
let root = bitcast<vec3<f32>>(hair_points[slot].xyz);
|
|
169
168
|
let view = hair_shadow_views[view_index];
|
|
@@ -178,12 +177,11 @@ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocatio
|
|
|
178
177
|
|
|
179
178
|
// the least clip w within the ball; drawn wherever it does not bound the texels
|
|
180
179
|
let w = dot(view.depth.xyz, root) + view.depth.w - reach * length(view.depth.xyz);
|
|
181
|
-
let strand = slot / (segments + 1u);
|
|
182
|
-
let share = fract(f32(strand) * 0.618034 + 0.5);
|
|
183
180
|
let drawn = w <= 0.0 || widest > share * 0.5 * view.texel * w;
|
|
184
181
|
|
|
185
182
|
if (inside && drawn) {
|
|
186
183
|
key = view_index * ${HAIR_CLASS_COUNT}u + point_class;
|
|
184
|
+
listed_at = at;
|
|
187
185
|
place_base = view_index * settings.list_capacity + base;
|
|
188
186
|
}
|
|
189
187
|
}
|
|
@@ -192,7 +190,7 @@ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocatio
|
|
|
192
190
|
let place = subgroup_keyed_append(&hair_shadow_counts, key);
|
|
193
191
|
|
|
194
192
|
if (key != ${SUBGROUP_KEYED_APPEND_NONE}u) {
|
|
195
|
-
hair_shadow_list[place_base + place] =
|
|
193
|
+
hair_shadow_list[place_base + place] = listed_at;
|
|
196
194
|
}
|
|
197
195
|
}
|
|
198
196
|
`, [chunk_hair_list_entries, chunk_folded_workgroup_index, chunk_subgroup_keyed_append]),
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A {@link SceneNode} on disk.
|
|
3
|
+
*
|
|
4
|
+
* <pre>
|
|
5
|
+
* UTF8 name
|
|
6
|
+
* i32 parent: a place in the nodes, or -1 for a root
|
|
7
|
+
* f64 x 10 local: translation xyz, rotation xyzw, scale xyz
|
|
8
|
+
* u32 geometry: a place in the geometries, or 0xFFFFFFFF for a node that only places others
|
|
9
|
+
* u32 material: a place in the materials, or 0xFFFFFFFF exactly when the geometry is
|
|
10
|
+
* </pre>
|
|
11
|
+
*
|
|
12
|
+
* The transform is written in full. {@link Transform64SerializationAdapter} packs a rotation into 32 bits, which
|
|
13
|
+
* a save can afford and a model cannot: the error is up to 0.14 degrees, 2.4 cm at the far end of a 10 m part.
|
|
14
|
+
*
|
|
15
|
+
* A node names its geometry and its material by their places in two lists, given before the first node is
|
|
16
|
+
* written or read ({@link initialize}).
|
|
17
|
+
*
|
|
18
|
+
* @extends BinaryClassSerializationAdapter<SceneNode>
|
|
19
|
+
*
|
|
20
|
+
* @author Alex Goldring
|
|
21
|
+
* @copyright Company Named Limited (c) 2026
|
|
22
|
+
*/
|
|
23
|
+
export class SceneNodeSerializationAdapter extends BinaryClassSerializationAdapter<SceneNode> {
|
|
24
|
+
constructor();
|
|
25
|
+
klass: typeof SceneNode;
|
|
26
|
+
/**
|
|
27
|
+
* @param {MeshletGeometry[]} geometries what a node's geometry index is a place in
|
|
28
|
+
* @param {ShadeMaterial[]} materials what a node's material index is a place in
|
|
29
|
+
*/
|
|
30
|
+
initialize(geometries: MeshletGeometry[], materials: ShadeMaterial[]): void;
|
|
31
|
+
#private;
|
|
32
|
+
}
|
|
33
|
+
export type BinaryBuffer = import("../../../core/binary/BinaryBuffer.js").BinaryBuffer;
|
|
34
|
+
export type MeshletGeometry = import("../geometry/MeshletGeometry.js").MeshletGeometry;
|
|
35
|
+
export type ShadeMaterial = import("../material/ShadeMaterial.js").ShadeMaterial;
|
|
36
|
+
import { SceneNode } from "./SceneNode.js";
|
|
37
|
+
import { BinaryClassSerializationAdapter } from "../../../engine/ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
38
|
+
//# sourceMappingURL=SceneNodeSerializationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneNodeSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/loader/SceneNodeSerializationAdapter.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;IACI,wBAAkB;IAuBlB;;;OAGG;IACH,uBAHW,eAAe,EAAE,aACjB,aAAa,EAAE,QAQzB;;CA8GJ;2BAjMY,OAAO,sCAAsC,EAAE,YAAY;8BAC3D,OAAO,gCAAgC,EAAE,eAAe;4BACxD,OAAO,8BAA8B,EAAE,aAAa;0BALvC,gBAAgB;gDADM,uEAAuE"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../engine/ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { SceneNode } from "./SceneNode.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} BinaryBuffer
|
|
6
|
+
* @typedef {import("../geometry/MeshletGeometry.js").MeshletGeometry} MeshletGeometry
|
|
7
|
+
* @typedef {import("../material/ShadeMaterial.js").ShadeMaterial} ShadeMaterial
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Written in place of an index, for a node that has no geometry and no material.
|
|
12
|
+
*
|
|
13
|
+
* @type {number}
|
|
14
|
+
*/
|
|
15
|
+
const NOTHING = 0xFFFFFFFF;
|
|
16
|
+
|
|
17
|
+
const EMPTY = [];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @template T
|
|
21
|
+
* @param {Map<T, number>} indices emptied, then filled with where each element of `list` is in it
|
|
22
|
+
* @param {T[]} list
|
|
23
|
+
*/
|
|
24
|
+
function index_list(indices, list) {
|
|
25
|
+
indices.clear();
|
|
26
|
+
|
|
27
|
+
for (let i = 0; i < list.length; i++) {
|
|
28
|
+
indices.set(list[i], i);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A {@link SceneNode} on disk.
|
|
34
|
+
*
|
|
35
|
+
* <pre>
|
|
36
|
+
* UTF8 name
|
|
37
|
+
* i32 parent: a place in the nodes, or -1 for a root
|
|
38
|
+
* f64 x 10 local: translation xyz, rotation xyzw, scale xyz
|
|
39
|
+
* u32 geometry: a place in the geometries, or 0xFFFFFFFF for a node that only places others
|
|
40
|
+
* u32 material: a place in the materials, or 0xFFFFFFFF exactly when the geometry is
|
|
41
|
+
* </pre>
|
|
42
|
+
*
|
|
43
|
+
* The transform is written in full. {@link Transform64SerializationAdapter} packs a rotation into 32 bits, which
|
|
44
|
+
* a save can afford and a model cannot: the error is up to 0.14 degrees, 2.4 cm at the far end of a 10 m part.
|
|
45
|
+
*
|
|
46
|
+
* A node names its geometry and its material by their places in two lists, given before the first node is
|
|
47
|
+
* written or read ({@link initialize}).
|
|
48
|
+
*
|
|
49
|
+
* @extends BinaryClassSerializationAdapter<SceneNode>
|
|
50
|
+
*
|
|
51
|
+
* @author Alex Goldring
|
|
52
|
+
* @copyright Company Named Limited (c) 2026
|
|
53
|
+
*/
|
|
54
|
+
export class SceneNodeSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
55
|
+
klass = SceneNode;
|
|
56
|
+
version = 0;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @type {MeshletGeometry[]}
|
|
60
|
+
*/
|
|
61
|
+
#geometries = EMPTY;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @type {ShadeMaterial[]}
|
|
65
|
+
*/
|
|
66
|
+
#materials = EMPTY;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @type {Map<MeshletGeometry, number>}
|
|
70
|
+
*/
|
|
71
|
+
#geometry_indices = new Map();
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @type {Map<ShadeMaterial, number>}
|
|
75
|
+
*/
|
|
76
|
+
#material_indices = new Map();
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {MeshletGeometry[]} geometries what a node's geometry index is a place in
|
|
80
|
+
* @param {ShadeMaterial[]} materials what a node's material index is a place in
|
|
81
|
+
*/
|
|
82
|
+
initialize(geometries, materials) {
|
|
83
|
+
this.#geometries = geometries;
|
|
84
|
+
this.#materials = materials;
|
|
85
|
+
|
|
86
|
+
index_list(this.#geometry_indices, geometries);
|
|
87
|
+
index_list(this.#material_indices, materials);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
finalize() {
|
|
91
|
+
this.#geometries = EMPTY;
|
|
92
|
+
this.#materials = EMPTY;
|
|
93
|
+
|
|
94
|
+
this.#geometry_indices.clear();
|
|
95
|
+
this.#material_indices.clear();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param {BinaryBuffer} buffer
|
|
100
|
+
* @param {SceneNode} value
|
|
101
|
+
*/
|
|
102
|
+
serialize(buffer, value) {
|
|
103
|
+
buffer.writeUTF8String(value.name);
|
|
104
|
+
buffer.writeInt32(value.parent);
|
|
105
|
+
|
|
106
|
+
const local = value.local;
|
|
107
|
+
|
|
108
|
+
buffer.writeFloat64(local.translation_x);
|
|
109
|
+
buffer.writeFloat64(local.translation_y);
|
|
110
|
+
buffer.writeFloat64(local.translation_z);
|
|
111
|
+
|
|
112
|
+
buffer.writeFloat64(local.rotation_x);
|
|
113
|
+
buffer.writeFloat64(local.rotation_y);
|
|
114
|
+
buffer.writeFloat64(local.rotation_z);
|
|
115
|
+
buffer.writeFloat64(local.rotation_w);
|
|
116
|
+
|
|
117
|
+
buffer.writeFloat64(local.scale_x);
|
|
118
|
+
buffer.writeFloat64(local.scale_y);
|
|
119
|
+
buffer.writeFloat64(local.scale_z);
|
|
120
|
+
|
|
121
|
+
if (value.geometry === null) {
|
|
122
|
+
buffer.writeUint32(NOTHING);
|
|
123
|
+
buffer.writeUint32(NOTHING);
|
|
124
|
+
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const geometry = this.#geometry_indices.get(value.geometry);
|
|
129
|
+
const material = this.#material_indices.get(value.material);
|
|
130
|
+
|
|
131
|
+
// not asserts: with asserts stripped these would write a node that draws nothing, without a word
|
|
132
|
+
if (geometry === undefined) {
|
|
133
|
+
throw new Error(`node '${value.name}' draws a geometry that is not in the list of geometries being written`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (material === undefined) {
|
|
137
|
+
throw new Error(`node '${value.name}' draws with a material that is not in the list of materials being written`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
buffer.writeUint32(geometry);
|
|
141
|
+
buffer.writeUint32(material);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {BinaryBuffer} buffer
|
|
146
|
+
* @param {SceneNode} value
|
|
147
|
+
*/
|
|
148
|
+
deserialize(buffer, value) {
|
|
149
|
+
value.name = buffer.readUTF8String();
|
|
150
|
+
value.parent = buffer.readInt32();
|
|
151
|
+
|
|
152
|
+
const local = value.local;
|
|
153
|
+
|
|
154
|
+
const translation_x = buffer.readFloat64();
|
|
155
|
+
const translation_y = buffer.readFloat64();
|
|
156
|
+
const translation_z = buffer.readFloat64();
|
|
157
|
+
|
|
158
|
+
const rotation_x = buffer.readFloat64();
|
|
159
|
+
const rotation_y = buffer.readFloat64();
|
|
160
|
+
const rotation_z = buffer.readFloat64();
|
|
161
|
+
const rotation_w = buffer.readFloat64();
|
|
162
|
+
|
|
163
|
+
const scale_x = buffer.readFloat64();
|
|
164
|
+
const scale_y = buffer.readFloat64();
|
|
165
|
+
const scale_z = buffer.readFloat64();
|
|
166
|
+
|
|
167
|
+
local.setTranslation(translation_x, translation_y, translation_z);
|
|
168
|
+
local.setRotation(rotation_x, rotation_y, rotation_z, rotation_w);
|
|
169
|
+
local.setScale(scale_x, scale_y, scale_z);
|
|
170
|
+
|
|
171
|
+
// a reader composes worlds from the matrix without asking
|
|
172
|
+
local.updateMatrix();
|
|
173
|
+
|
|
174
|
+
const geometry = buffer.readUint32();
|
|
175
|
+
const material = buffer.readUint32();
|
|
176
|
+
|
|
177
|
+
if (geometry === NOTHING && material === NOTHING) {
|
|
178
|
+
value.geometry = null;
|
|
179
|
+
value.material = null;
|
|
180
|
+
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const geometries = this.#geometries;
|
|
185
|
+
const materials = this.#materials;
|
|
186
|
+
|
|
187
|
+
if (geometry >= geometries.length) {
|
|
188
|
+
throw new Error(`node '${value.name}' names geometry ${geometry}, and there are ${geometries.length}`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (material >= materials.length) {
|
|
192
|
+
throw new Error(`node '${value.name}' names material ${material}, and there are ${materials.length}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
value.geometry = geometries[geometry];
|
|
196
|
+
value.material = materials[material];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A texture as an MTF package holds it: a {@link ShadeTexture} with its image replaced by where the image can be
|
|
3
|
+
* fetched from. The package holds no texels; a set of files outside it does, one per GPU format and a fallback
|
|
4
|
+
* every device can use, and any number of packages name the same files.
|
|
5
|
+
*
|
|
6
|
+
* @author Alex Goldring
|
|
7
|
+
* @copyright Company Named Limited (c) 2026
|
|
8
|
+
*/
|
|
9
|
+
export class MTFTexture {
|
|
10
|
+
/**
|
|
11
|
+
* The record of a texture: its label, sampler and colour space, with what its files were built for and where
|
|
12
|
+
* they are.
|
|
13
|
+
*
|
|
14
|
+
* @param {ShadeTexture} texture
|
|
15
|
+
* @param {TextureRole|number} role
|
|
16
|
+
* @param {TextureVariantSet} variants
|
|
17
|
+
* @returns {MTFTexture}
|
|
18
|
+
*/
|
|
19
|
+
static from(texture: ShadeTexture, role: TextureRole | number, variants: TextureVariantSet): MTFTexture;
|
|
20
|
+
/**
|
|
21
|
+
* The texture's label.
|
|
22
|
+
*
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* What the encodings were chosen for, which is what a device's choice among them goes by.
|
|
28
|
+
*
|
|
29
|
+
* @type {TextureRole|number}
|
|
30
|
+
*/
|
|
31
|
+
role: TextureRole | number;
|
|
32
|
+
/**
|
|
33
|
+
* How sampling decodes. A file names the non-sRGB format of its pair, and this picks which of the two the
|
|
34
|
+
* texture is created as.
|
|
35
|
+
*
|
|
36
|
+
* @type {ColorSpace|number}
|
|
37
|
+
*/
|
|
38
|
+
color_space: ColorSpace | number;
|
|
39
|
+
/**
|
|
40
|
+
* The texture's {@link ShadeTextureFlags}: whether a mip chain is generated for it when what was fetched is
|
|
41
|
+
* a single image. A texture file brings its own levels whatever this says.
|
|
42
|
+
*
|
|
43
|
+
* @type {number}
|
|
44
|
+
*/
|
|
45
|
+
flags: number;
|
|
46
|
+
/**
|
|
47
|
+
* The filter that chain is generated with.
|
|
48
|
+
*
|
|
49
|
+
* @type {TextureFilterType|number}
|
|
50
|
+
*/
|
|
51
|
+
mipmap_generation_filter: TextureFilterType | number;
|
|
52
|
+
/**
|
|
53
|
+
* Wrap and filter modes, as {@link sampler_descriptor_pack} packs them.
|
|
54
|
+
*
|
|
55
|
+
* @type {number}
|
|
56
|
+
*/
|
|
57
|
+
sampler: number;
|
|
58
|
+
/**
|
|
59
|
+
* Which encodings were built, and the URI of each: relative to the package, or absolute. Null until the
|
|
60
|
+
* record is read or made {@link from} a texture.
|
|
61
|
+
*
|
|
62
|
+
* @type {TextureVariantSet|null}
|
|
63
|
+
*/
|
|
64
|
+
variants: TextureVariantSet | null;
|
|
65
|
+
/**
|
|
66
|
+
* The texture this record describes, over an image fetched from one of its files.
|
|
67
|
+
*
|
|
68
|
+
* An image that brings its own mip levels — texels from a texture file — generates none: the file's chain is
|
|
69
|
+
* the texture's, and no block format can be rendered into to make another. A decoded image is one level, and
|
|
70
|
+
* has a chain generated for it if the texture was to have one ({@link flags}).
|
|
71
|
+
*
|
|
72
|
+
* @param {ShadeImage} image
|
|
73
|
+
* @returns {ShadeTexture}
|
|
74
|
+
*/
|
|
75
|
+
to_shade_texture(image: ShadeImage): ShadeTexture;
|
|
76
|
+
/**
|
|
77
|
+
* @readonly
|
|
78
|
+
* @type {boolean}
|
|
79
|
+
*/
|
|
80
|
+
readonly isMTFTexture: boolean;
|
|
81
|
+
}
|
|
82
|
+
export type ShadeImage = import("../../texture/source/ShadeImage.js").ShadeImage;
|
|
83
|
+
export type TextureVariantSet = import("../../texture/TextureVariantSet.js").TextureVariantSet;
|
|
84
|
+
import { TextureRole } from "../../texture/TextureRole.js";
|
|
85
|
+
import { ColorSpace } from "../../texture/ColorSpace.js";
|
|
86
|
+
import { TextureFilterType } from "../../texture/TextureFilterType.js";
|
|
87
|
+
import { ShadeTexture } from "../../texture/ShadeTexture.js";
|
|
88
|
+
//# sourceMappingURL=MTFTexture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MTFTexture.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/MTFTexture.js"],"names":[],"mappings":"AA4BA;;;;;;;GAOG;AACH;IAqDI;;;;;;;;OAQG;IACH,qBALW,YAAY,QACZ,WAAW,GAAC,MAAM,YAClB,iBAAiB,GACf,UAAU,CAkBtB;IA7ED;;;;OAIG;IACH,MAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,MAFU,WAAW,GAAC,MAAM,CAEF;IAE1B;;;;;OAKG;IACH,aAFU,UAAU,GAAC,MAAM,CAES;IAEpC;;;;;OAKG;IACH,OAFU,MAAM,CAE0B;IAE1C;;;;OAIG;IACH,0BAFU,iBAAiB,GAAC,MAAM,CAEkB;IAEpD;;;;OAIG;IACH,SAFU,MAAM,CAEU;IAE1B;;;;;OAKG;IACH,UAFU,iBAAiB,GAAC,IAAI,CAEhB;IA6BhB;;;;;;;;;OASG;IACH,wBAHW,UAAU,GACR,YAAY,CA2BxB;IAGL;;;OAGG;IACH,uBAFU,OAAO,CAEgB;CANhC;yBA9IY,OAAO,oCAAoC,EAAE,UAAU;gCACvD,OAAO,oCAAoC,EAAE,iBAAiB;4BAL/C,8BAA8B;2BAN/B,6BAA6B;kCAKtB,oCAAoC;6BAFzC,+BAA+B"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { ColorSpace } from "../../texture/ColorSpace.js";
|
|
2
|
+
import { sampler_descriptor_pack } from "../../texture/format/sampler_descriptor_pack.js";
|
|
3
|
+
import { sampler_descriptor_unpack } from "../../texture/format/sampler_descriptor_unpack.js";
|
|
4
|
+
import { ShadeTexture } from "../../texture/ShadeTexture.js";
|
|
5
|
+
import { ShadeTextureFlags } from "../../texture/ShadeTextureFlags.js";
|
|
6
|
+
import { TextureFilterType } from "../../texture/TextureFilterType.js";
|
|
7
|
+
import { TextureRole } from "../../texture/TextureRole.js";
|
|
8
|
+
import { TextureWrapType } from "../../texture/TextureWrapType.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import("../../texture/source/ShadeImage.js").ShadeImage} ShadeImage
|
|
12
|
+
* @typedef {import("../../texture/TextureVariantSet.js").TextureVariantSet} TextureVariantSet
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The sampler of a {@link ShadeTexture} nobody has set: repeat on every axis, linear in every filter.
|
|
17
|
+
*
|
|
18
|
+
* @type {number}
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_SAMPLER = sampler_descriptor_pack({
|
|
21
|
+
wrapS: TextureWrapType.Repeat,
|
|
22
|
+
wrapT: TextureWrapType.Repeat,
|
|
23
|
+
wrapR: TextureWrapType.Repeat,
|
|
24
|
+
magFilter: TextureFilterType.Linear,
|
|
25
|
+
minFilter: TextureFilterType.Linear,
|
|
26
|
+
mipmapFilter: TextureFilterType.Linear,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A texture as an MTF package holds it: a {@link ShadeTexture} with its image replaced by where the image can be
|
|
31
|
+
* fetched from. The package holds no texels; a set of files outside it does, one per GPU format and a fallback
|
|
32
|
+
* every device can use, and any number of packages name the same files.
|
|
33
|
+
*
|
|
34
|
+
* @author Alex Goldring
|
|
35
|
+
* @copyright Company Named Limited (c) 2026
|
|
36
|
+
*/
|
|
37
|
+
export class MTFTexture {
|
|
38
|
+
/**
|
|
39
|
+
* The texture's label.
|
|
40
|
+
*
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
name = "";
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* What the encodings were chosen for, which is what a device's choice among them goes by.
|
|
47
|
+
*
|
|
48
|
+
* @type {TextureRole|number}
|
|
49
|
+
*/
|
|
50
|
+
role = TextureRole.Albedo;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* How sampling decodes. A file names the non-sRGB format of its pair, and this picks which of the two the
|
|
54
|
+
* texture is created as.
|
|
55
|
+
*
|
|
56
|
+
* @type {ColorSpace|number}
|
|
57
|
+
*/
|
|
58
|
+
color_space = ColorSpace.LinearSRGB;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The texture's {@link ShadeTextureFlags}: whether a mip chain is generated for it when what was fetched is
|
|
62
|
+
* a single image. A texture file brings its own levels whatever this says.
|
|
63
|
+
*
|
|
64
|
+
* @type {number}
|
|
65
|
+
*/
|
|
66
|
+
flags = ShadeTextureFlags.GenerateMipMaps;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The filter that chain is generated with.
|
|
70
|
+
*
|
|
71
|
+
* @type {TextureFilterType|number}
|
|
72
|
+
*/
|
|
73
|
+
mipmap_generation_filter = TextureFilterType.Linear;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Wrap and filter modes, as {@link sampler_descriptor_pack} packs them.
|
|
77
|
+
*
|
|
78
|
+
* @type {number}
|
|
79
|
+
*/
|
|
80
|
+
sampler = DEFAULT_SAMPLER;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Which encodings were built, and the URI of each: relative to the package, or absolute. Null until the
|
|
84
|
+
* record is read or made {@link from} a texture.
|
|
85
|
+
*
|
|
86
|
+
* @type {TextureVariantSet|null}
|
|
87
|
+
*/
|
|
88
|
+
variants = null;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The record of a texture: its label, sampler and colour space, with what its files were built for and where
|
|
92
|
+
* they are.
|
|
93
|
+
*
|
|
94
|
+
* @param {ShadeTexture} texture
|
|
95
|
+
* @param {TextureRole|number} role
|
|
96
|
+
* @param {TextureVariantSet} variants
|
|
97
|
+
* @returns {MTFTexture}
|
|
98
|
+
*/
|
|
99
|
+
static from(texture, role, variants) {
|
|
100
|
+
const r = new MTFTexture();
|
|
101
|
+
|
|
102
|
+
r.name = texture.label;
|
|
103
|
+
r.role = role;
|
|
104
|
+
|
|
105
|
+
// a texture that says nothing decodes as its image does
|
|
106
|
+
r.color_space = texture.color_space !== null ? texture.color_space : texture.image.color_space;
|
|
107
|
+
|
|
108
|
+
r.flags = texture.flags;
|
|
109
|
+
r.mipmap_generation_filter = texture.mipmapGenerationFilter;
|
|
110
|
+
|
|
111
|
+
r.sampler = sampler_descriptor_pack(texture);
|
|
112
|
+
r.variants = variants;
|
|
113
|
+
|
|
114
|
+
return r;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The texture this record describes, over an image fetched from one of its files.
|
|
119
|
+
*
|
|
120
|
+
* An image that brings its own mip levels — texels from a texture file — generates none: the file's chain is
|
|
121
|
+
* the texture's, and no block format can be rendered into to make another. A decoded image is one level, and
|
|
122
|
+
* has a chain generated for it if the texture was to have one ({@link flags}).
|
|
123
|
+
*
|
|
124
|
+
* @param {ShadeImage} image
|
|
125
|
+
* @returns {ShadeTexture}
|
|
126
|
+
*/
|
|
127
|
+
to_shade_texture(image) {
|
|
128
|
+
const texture = ShadeTexture.from(image);
|
|
129
|
+
|
|
130
|
+
texture.label = this.name;
|
|
131
|
+
texture.color_space = this.color_space;
|
|
132
|
+
|
|
133
|
+
texture.flags = this.flags;
|
|
134
|
+
texture.mipmapGenerationFilter = this.mipmap_generation_filter;
|
|
135
|
+
|
|
136
|
+
const sampler = sampler_descriptor_unpack(this.sampler);
|
|
137
|
+
|
|
138
|
+
texture.wrapS = sampler.wrapS;
|
|
139
|
+
texture.wrapT = sampler.wrapT;
|
|
140
|
+
texture.wrapR = sampler.wrapR;
|
|
141
|
+
texture.magFilter = sampler.magFilter;
|
|
142
|
+
texture.minFilter = sampler.minFilter;
|
|
143
|
+
texture.mipmapFilter = sampler.mipmapFilter;
|
|
144
|
+
|
|
145
|
+
const source = image.source;
|
|
146
|
+
|
|
147
|
+
if (source !== undefined && source !== null && source.isShadeTexelData === true) {
|
|
148
|
+
texture.clearFlag(ShadeTextureFlags.GenerateMipMaps);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return texture;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @readonly
|
|
157
|
+
* @type {boolean}
|
|
158
|
+
*/
|
|
159
|
+
MTFTexture.prototype.isMTFTexture = true;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An {@link MTFTexture} on disk.
|
|
3
|
+
*
|
|
4
|
+
* <pre>
|
|
5
|
+
* UTF8 name
|
|
6
|
+
* u8 role {@link TextureRole}
|
|
7
|
+
* u8 color_space {@link ColorSpace}
|
|
8
|
+
* u8 flags {@link ShadeTextureFlags}
|
|
9
|
+
* u8 mipmap_generation_filter {@link TextureFilterType}
|
|
10
|
+
* u32 sampler as {@link sampler_descriptor_pack} packs one
|
|
11
|
+
* UTF8 fallback URI of an encoding every device can use
|
|
12
|
+
* UintVar format count, which may be 0
|
|
13
|
+
* formats each: UTF8 WebGPU format name, the non-sRGB one of its pair, then UTF8 URI of a texture file in it
|
|
14
|
+
* </pre>
|
|
15
|
+
*
|
|
16
|
+
* The last three fields are a {@link TextureVariantSet}. Formats are kept in the order written.
|
|
17
|
+
*
|
|
18
|
+
* @extends BinaryClassSerializationAdapter<MTFTexture>
|
|
19
|
+
*
|
|
20
|
+
* @author Alex Goldring
|
|
21
|
+
* @copyright Company Named Limited (c) 2026
|
|
22
|
+
*/
|
|
23
|
+
export class MTFTextureSerializationAdapter extends BinaryClassSerializationAdapter<MTFTexture> {
|
|
24
|
+
constructor();
|
|
25
|
+
klass: typeof MTFTexture;
|
|
26
|
+
}
|
|
27
|
+
export type BinaryBuffer = import("../../../../core/binary/BinaryBuffer.js").BinaryBuffer;
|
|
28
|
+
import { MTFTexture } from "./MTFTexture.js";
|
|
29
|
+
import { BinaryClassSerializationAdapter } from "../../../../engine/ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
30
|
+
//# sourceMappingURL=MTFTextureSerializationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MTFTextureSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.js"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;IACI,yBAAmB;CAsFtB;2BA/HY,OAAO,yCAAyC,EAAE,YAAY;2BAHhD,iBAAiB;gDALI,0EAA0E"}
|