@woosh/meep-engine 3.0.2 → 3.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/LICENSE +188 -188
- package/README.md +152 -145
- package/editor/Editor.js +598 -598
- package/editor/EditorCameraNavigation.js +205 -205
- package/editor/EditorKeyMap.js +182 -182
- package/editor/SelectionVisualizer.js +127 -127
- package/editor/actions/concrete/ActionInvalidateSampler.js +27 -27
- package/editor/actions/concrete/PatchTerrainHeightAction.js +85 -85
- package/editor/camera/camera_framing.js +104 -104
- package/editor/clipboard.js +184 -184
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +22 -22
- package/editor/ecs/component/editors/ObservedStringEditor.js +34 -34
- package/editor/ecs/component/editors/common/two_way_sync.js +50 -50
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +19 -19
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +35 -35
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -17
- package/editor/ecs/component/editors/ecs/SGMeshEditor.js +24 -24
- package/editor/ecs/component/editors/ecs/ShadedGeometryEditor.js +33 -33
- package/editor/ecs/component/editors/ecs/Trail3DEditor.js +45 -45
- package/editor/ecs/component/editors/ecs/buildGridObstaclePreview.js +19 -19
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +72 -72
- package/editor/ecs/component/editors/shade/MeshletGeometryEditor.js +30 -30
- package/editor/ecs/component/editors/shade/ShadeImageEditor.js +70 -70
- package/editor/ecs/component/editors/shade/ShadeMaterialEditor.js +34 -34
- package/editor/ecs/component/editors/shade/ShadeTextureEditor.js +46 -46
- package/editor/ecs/component/editors/shade/StandardShadeMaterialEditor.js +24 -24
- package/editor/ecs/component/prototypeObjectEditor.js +265 -265
- package/editor/ecs/component/registerBasicTypeEditors.js +100 -100
- package/editor/ecs/component/registerEngineComponentEditors.js +95 -95
- package/editor/entity_world_bounds.js +27 -27
- package/editor/particles/lut_ops.js +148 -148
- package/editor/particles/particleEditEvents.js +12 -12
- package/editor/particles/rebuildParticleEmitter.js +31 -31
- package/editor/persistence/EditorLayoutStore.js +71 -71
- package/editor/persistence/SceneMetadata.js +52 -52
- package/editor/persistence/SceneSlotManager.js +144 -144
- package/editor/persistence/buildNewSceneDataset.js +67 -67
- package/editor/persistence/files.js +68 -68
- package/editor/persistence/scene_import.js +143 -143
- package/editor/persistence/scene_serialization.js +79 -79
- package/editor/persistence/string_buffer_codec.js +41 -41
- package/editor/process/GridDisplayProcess.js +125 -125
- package/editor/process/SymbolicDisplayProcess.js +106 -108
- package/editor/process/symbolic/CameraSymbolicDisplay.js +146 -146
- package/editor/process/symbolic/LightSymbolicDisplay.js +172 -172
- package/editor/process/symbolic/PathSymbolicDisplay.js +118 -118
- package/editor/process/symbolic/PositionedMarkerSymbolicDisplay.js +79 -79
- package/editor/process/symbolic/SoundEmitterSymbolicDisplay.js +57 -57
- package/editor/process/symbolic/SymbolicDisplay.js +62 -62
- package/editor/process/symbolic/gizmo_draw_wire_box_oriented.js +85 -85
- package/editor/process/symbolic/gizmo_draw_wire_circle.js +53 -53
- package/editor/prototypeEditorShell.js +156 -156
- package/editor/selection/editor_pick.js +130 -130
- package/editor/selection/screen_rect_frustum.js +119 -119
- package/editor/style/controls.scss +168 -168
- package/editor/style/inspector.scss +223 -223
- package/editor/templates/entity_templates.js +167 -167
- package/editor/tools/GridPaintTool.js +273 -273
- package/editor/tools/SelectionTool.js +307 -307
- package/editor/tools/TransformToolV2.js +378 -378
- package/editor/tools/engine/ToolEngine.js +188 -188
- package/editor/tools/paint/TerrainTexturePaintTool.js +250 -250
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +501 -501
- package/editor/tools/v2/TransformControls.js +971 -971
- package/editor/tools/v2/handle/gizmo_drag_plane.js +141 -141
- package/editor/tools/v2/handle/gizmo_draw.js +399 -399
- package/editor/tools/v2/handle/gizmo_handles.js +364 -364
- package/editor/tools/v2/handle/gizmo_ray_shapes.js +239 -239
- package/editor/view/ecs/HierarchicalEntityListView.js +339 -339
- package/editor/view/ecs/components/DatGuiController.js +2 -2
- package/editor/view/ecs/components/common/AutoCanvasView.js +100 -100
- package/editor/view/ecs/components/common/TextController.js +59 -59
- package/editor/view/library/MeshLibraryView.js +175 -175
- package/editor/view/library/mesh_library_drag.js +63 -63
- package/editor/view/library/model_thumbnail_source.js +86 -86
- package/editor/view/makeEntityDecorators.js +125 -125
- package/editor/view/node-graph/NodeGraphSelection.js +89 -89
- package/editor/view/node-graph/NodeView.js +211 -211
- package/editor/view/node-graph/actions/ConnectionDeleteAction.js +36 -36
- package/editor/view/node-graph/actions/NodesMoveAction.js +41 -41
- package/editor/view/node-graph/connection_wire_geometry.js +107 -107
- package/editor/view/particles/ColorLutGradientView.js +291 -291
- package/editor/view/particles/ScalarLutCurveView.js +279 -279
- package/editor/view/prepareMeshLibrary.js +188 -188
- package/editor/view/shell/SceneTreePanelView.js +119 -119
- package/editor/view/v2/SplitView.js +2 -2
- package/package.json +94 -94
- package/samples/generation/generators/interactive/mir_generator_place_buff_objects.js +362 -362
- package/src/DUPLICATION_AUDIT_2026_08_07/00_core_reuse_surface.md +738 -738
- package/src/DUPLICATION_AUDIT_2026_08_07/A_core_math_geom.md +79 -79
- package/src/DUPLICATION_AUDIT_2026_08_07/B_core_data.md +93 -93
- package/src/DUPLICATION_AUDIT_2026_08_07/C_gfx_render.md +80 -80
- package/src/DUPLICATION_AUDIT_2026_08_07/D_gfx_features.md +164 -164
- package/src/DUPLICATION_AUDIT_2026_08_07/E_physics.md +69 -69
- package/src/DUPLICATION_AUDIT_2026_08_07/F_sound.md +102 -102
- package/src/DUPLICATION_AUDIT_2026_08_07/G_net_save.md +129 -129
- package/src/DUPLICATION_AUDIT_2026_08_07/H_engine_misc.md +72 -72
- package/src/DUPLICATION_AUDIT_2026_08_07/I_generation_view.md +74 -74
- package/src/DUPLICATION_AUDIT_2026_08_07/K_crosscutting.md +169 -169
- package/src/DUPLICATION_AUDIT_2026_08_07.md +254 -254
- package/src/DUPLICATION_AUDIT_REMEDIATION.md +250 -250
- package/src/REVIEW_2026_08_06/adv-core.md +511 -511
- package/src/REVIEW_2026_08_06/adv-gfx.md +480 -480
- package/src/REVIEW_2026_08_06/adv-view.md +446 -446
- package/src/REVIEW_2026_08_06/api-core.md +296 -296
- package/src/REVIEW_2026_08_06/api-engine.md +195 -195
- package/src/REVIEW_2026_08_06/bvh-phys-sound-net.md +507 -507
- package/src/REVIEW_2026_08_06/core-binary.md +348 -348
- package/src/REVIEW_2026_08_06/core-collection.md +376 -376
- package/src/REVIEW_2026_08_06/core-math.md +221 -221
- package/src/REVIEW_2026_08_06/core-process.md +266 -266
- package/src/REVIEW_2026_08_06/core-science.md +223 -223
- package/src/REVIEW_2026_08_06/engine-ai-nav.md +279 -279
- package/src/REVIEW_2026_08_06/engine-animation.md +167 -167
- package/src/REVIEW_2026_08_06/engine-asset.md +166 -166
- package/src/REVIEW_2026_08_06/engine-ecs.md +920 -920
- package/src/REVIEW_2026_08_06/engine-input.md +197 -197
- package/src/REVIEW_2026_08_06/engine-misc.md +248 -248
- package/src/REVIEW_2026_08_06/engine-terrain.md +52 -52
- package/src/REVIEW_2026_08_06/generation.md +176 -176
- package/src/REVIEW_2026_08_06/geom-2d.md +434 -434
- package/src/REVIEW_2026_08_06/geom-3d.md +117 -117
- package/src/REVIEW_2026_08_06/gfx-gi.md +143 -143
- package/src/REVIEW_2026_08_06/gfx-render.md +740 -740
- package/src/REVIEW_2026_08_06/gfx-texture.md +690 -690
- package/src/REVIEW_2026_08_06/prior-criticals.md +49 -49
- package/src/REVIEW_2026_08_06/prior-highs.md +138 -138
- package/src/REVIEW_2026_08_06/test-gaps.md +364 -364
- package/src/REVIEW_2026_08_06/view.md +667 -667
- package/src/REVIEW_2026_08_06.md +610 -610
- package/src/avif/codec/dec/avif_dec.cpp +233 -233
- package/src/avif/codec/dec/avif_dec.js +16 -16
- package/src/core/binary/BitImage2.js +246 -246
- package/src/core/binary/align_32.js +21 -21
- package/src/core/binary/data_view/DataType2DataViewReaders.js +23 -23
- package/src/core/binary/data_view/DataType2DataViewWriters.js +25 -25
- package/src/core/binary/hash/XXH128Hash.js +55 -55
- package/src/core/binary/hash/XXH3_SECRET.js +25 -25
- package/src/core/binary/hash/xxh3_128.js +341 -341
- package/src/core/binary/hash/xxh3_64.js +241 -241
- package/src/core/binary/hash/xxh3_common.js +476 -476
- package/src/core/binary/lz4/LZ4_MAX_INPUT_SIZE.js +9 -9
- package/src/core/binary/lz4/lz4_compress_block.js +385 -385
- package/src/core/binary/lz4/lz4_compress_bound.js +25 -25
- package/src/core/binary/lz4/lz4_decompress_block.js +139 -139
- package/src/core/binary/lz4/lz4_decompress_bound.js +30 -30
- package/src/core/binary/meshopt/MESHOPT_GROUP_SIZE.js +18 -18
- package/src/core/binary/meshopt/MeshoptCompressionFilter.js +30 -30
- package/src/core/binary/meshopt/MeshoptCompressionMode.js +21 -21
- package/src/core/binary/meshopt/__meshopt_test_streams.js +237 -237
- package/src/core/binary/meshopt/meshopt_decode.js +73 -73
- package/src/core/binary/meshopt/meshopt_decode_byte_group.js +67 -67
- package/src/core/binary/meshopt/meshopt_decode_data_block.js +59 -59
- package/src/core/binary/meshopt/meshopt_decode_filter_color.js +69 -69
- package/src/core/binary/meshopt/meshopt_decode_filter_exponential.js +43 -43
- package/src/core/binary/meshopt/meshopt_decode_filter_octahedral.js +60 -60
- package/src/core/binary/meshopt/meshopt_decode_filter_quaternion.js +71 -71
- package/src/core/binary/meshopt/meshopt_decode_index_buffer.js +294 -294
- package/src/core/binary/meshopt/meshopt_decode_index_sequence.js +115 -115
- package/src/core/binary/meshopt/meshopt_decode_vertex_buffer.js +381 -381
- package/src/core/binary/meshopt/meshopt_read_uint_var.js +59 -59
- package/src/core/binary/reinterpret_float32_as_uint32.js +13 -13
- package/src/core/binary/reinterpret_uint32_as_float32.js +14 -14
- package/src/core/binary/type/DataType2TypedArrayConstructorMapping.js +35 -35
- package/src/core/bvh2/bvh3/ebvh_geometry_query_any_triangle_ray.js +149 -149
- package/src/core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js +96 -96
- package/src/core/bvh2/bvh3/query/bvh_query_depth_range_in_frustum.js +101 -101
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +77 -77
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +90 -90
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray_segment.js +94 -94
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +86 -86
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_intersects_capsule.js +101 -101
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_intersects_sphere.js +92 -92
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +96 -96
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.js +100 -100
- package/src/core/bvh2/visual/BVHGeometry.js +131 -131
- package/src/core/bvh8/BVH8.js +436 -436
- package/src/core/bvh8/aabb3_round_to_float32.js +22 -22
- package/src/core/bvh8/build/BVH8Converter.js +588 -588
- package/src/core/bvh8/build/TriangleCluster.js +122 -122
- package/src/core/bvh8/build/aabb3_compute_merge_cost.js +28 -28
- package/src/core/bvh8/build/aabb3_from_triangle_by_index.js +17 -17
- package/src/core/bvh8/build/bvh8_build_for_geometry.js +303 -303
- package/src/core/bvh8/build/bvh8_from_proxy.js +256 -256
- package/src/core/bvh8/build/byte.js +9 -9
- package/src/core/bvh8/build/encode_bounds_e.js +11 -11
- package/src/core/bvh8/bvh8_convert_to_dot.js +132 -132
- package/src/core/bvh8/bvh8_count_primitives.js +98 -98
- package/src/core/bvh8/bvh8_geometry_validate.js +138 -138
- package/src/core/bvh8/bvh8_geometry_validate_indirect.js +166 -166
- package/src/core/bvh8/bvh8_get_node_bounds.js +34 -34
- package/src/core/bvh8/bvh8_get_node_child_bounds.js +52 -52
- package/src/core/bvh8/bvh8_node_child_surface_area.js +18 -18
- package/src/core/bvh8/bvh8_node_count_triangles.js +27 -27
- package/src/core/bvh8/bvh8_quality.js +72 -72
- package/src/core/bvh8/bvh8_validate_structure.js +87 -87
- package/src/core/clipboard/obtainClipBoard.js +29 -29
- package/src/core/clipboard/safeClipboardReadText.js +55 -55
- package/src/core/clipboard/safeClipboardWriteText.js +23 -23
- package/src/core/collection/array/typed/typed_array_value_denormalize.js +52 -52
- package/src/core/collection/array/typed/typed_array_value_normalize.js +51 -51
- package/src/core/collection/union-find/union_find.js +79 -79
- package/src/core/color/YCoCg/rgb_to_ycocg.js +20 -20
- package/src/core/color/YCoCg/ycocg_to_rgb.js +17 -17
- package/src/core/color/colormap/MAGMA_LUT.js +26 -26
- package/src/core/color/illuminant/D65_TRISTIMULUS_XYZ.js +19 -19
- package/src/core/color/lab/lab_apply_hunt_adjustment.js +27 -27
- package/src/core/color/lab/lab_distance_hyab.js +23 -23
- package/src/core/color/lab/xyz_to_lab.js +62 -62
- package/src/core/color/operations/color_darken.js +24 -24
- package/src/core/color/operations/color_desaturate.js +24 -24
- package/src/core/color/operations/color_lighten.js +24 -24
- package/src/core/color/operations/color_saturate.js +24 -24
- package/src/core/color/operations/color_scale_okhsv_channel.js +45 -45
- package/src/core/color/tonemap/tonemap_aces.js +41 -41
- package/src/core/color/ycxcz/xyz_to_ycxcz.js +28 -28
- package/src/core/color/ycxcz/ycxcz_to_xyz.js +19 -19
- package/src/core/dom/isImageBitmap.js +12 -12
- package/src/core/function/frameThrottle.js +23 -23
- package/src/core/geom/2d/aabb/aabb2_array_combine.js +7 -7
- package/src/core/geom/2d/aabb/aabb2_compute_area.js +7 -7
- package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.js +7 -7
- package/src/core/geom/2d/aabb/aabb2_compute_overlap.js +7 -7
- package/src/core/geom/2d/aabb/aabb2_from_v2_array.js +7 -7
- package/src/core/geom/2d/aabb/aabb2_intersects_point.js +7 -7
- package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +7 -7
- package/src/core/geom/2d/circle/circle_compute_circle_intersection.js +7 -7
- package/src/core/geom/2d/circle/circle_compute_circle_penetration.js +7 -7
- package/src/core/geom/2d/circle/circle_intersects_point.js +7 -7
- package/src/core/geom/2d/compute_polygon_area_2d.js +7 -7
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +7 -7
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +7 -7
- package/src/core/geom/2d/convex-hull/orientation3_array.js +7 -7
- package/src/core/geom/2d/intersect_ray_2d.js +7 -7
- package/src/core/geom/2d/line/line2_distance_to_point_sqr.js +7 -7
- package/src/core/geom/2d/line/line2_segment_intersection_fraction_2d.js +44 -44
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +7 -7
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js +7 -7
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_2d.js +7 -7
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js +7 -7
- package/src/core/geom/2d/line/line_segment_intersection_fraction_2d.js +7 -7
- package/src/core/geom/2d/line/line_segment_line_segment_intersection_exists_2d.js +7 -7
- package/src/core/geom/2d/line/segment2_intersects_segment2_2d.js +25 -25
- package/src/core/geom/2d/line/segment2_segment_compute_intersection_array_2d.js +46 -46
- package/src/core/geom/2d/line/segment2_segment_intersection_fractions.js +52 -52
- package/src/core/geom/2d/oriented-box/min_area_rect_2d.js +69 -69
- package/src/core/geom/2d/polygon/TRIANGULATION_DESIGN.md +433 -433
- package/src/core/geom/2d/polygon/polygon2_clip_axis_halfplane.js +51 -51
- package/src/core/geom/2d/polygon/polygon2_clip_halfplane.js +50 -50
- package/src/core/geom/2d/polygon/polygon2_is_counter_clockwise.js +84 -84
- package/src/core/geom/2d/polygon/polygon2_signed_area.js +52 -52
- package/src/core/geom/2d/polygon/polygon2_triangulate.corpus.js +86 -86
- package/src/core/geom/2d/polygon/polygon2_triangulate.js +1280 -1280
- package/src/core/geom/2d/polygon/polygon2_triangulation_deviation.js +77 -77
- package/src/core/geom/2d/quad-tree/qt_collect_by_circle.js +39 -39
- package/src/core/geom/2d/quad-tree/qt_match_data_by_circle.js +101 -101
- package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +7 -7
- package/src/core/geom/2d/rectangle_to_aabb.js +7 -7
- package/src/core/geom/2d/spline_bezier2_2d.js +7 -7
- package/src/core/geom/2d/triangle/tri2_rasterize_conservative.js +99 -99
- package/src/core/geom/2d/triangle/tri2_signed_area.js +35 -35
- package/src/core/geom/2d/triangle2d_compute_area.js +7 -7
- package/src/core/geom/2d/triangle2d_contains_point.js +7 -7
- package/src/core/geom/2d/triangle2d_get_barycentric.js +7 -7
- package/src/core/geom/2d/v2_morton_encode.js +23 -23
- package/src/core/geom/3d/aabb/aabb3_array_intersects_frustum_degree.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_box_surface_area_2.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_build_frustum.js +5 -5
- package/src/core/geom/3d/aabb/aabb3_closest_point_on_surface.js +57 -57
- package/src/core/geom/3d/aabb/aabb3_combined_surface_area.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_compute_half_surface_area.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_compute_projected_area.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_compute_surface_area.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_from_triangle_group.js +46 -46
- package/src/core/geom/3d/aabb/aabb3_intersects_frustum_degree.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_intersects_line_segment.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_nearest_point_on_surface.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_ray_segment_entry_distance.js +95 -95
- package/src/core/geom/3d/aabb/aabb3_raycast.js +7 -7
- package/src/core/geom/3d/aabb/aabb3_transform_oriented.js +93 -93
- package/src/core/geom/3d/aabb/aabb3_transform_oriented_inverse.js +82 -82
- package/src/core/geom/3d/aabb/compute_aabb_from_points.js +7 -7
- package/src/core/geom/3d/aabb/compute_triangle_group_aabb3.js +7 -7
- package/src/core/geom/3d/atlas/ATLAS_PORT_PLAN.md +486 -486
- package/src/core/geom/3d/atlas/BFF_PLAN.md +174 -174
- package/src/core/geom/3d/atlas/Chart.js +77 -77
- package/src/core/geom/3d/atlas/REVIEW_02.md +392 -392
- package/src/core/geom/3d/atlas/atlas_bench_lib.js +315 -315
- package/src/core/geom/3d/atlas/atlas_chart_type.js +16 -16
- package/src/core/geom/3d/atlas/atlas_compute_charts.js +188 -188
- package/src/core/geom/3d/atlas/atlas_extract_chart.js +107 -107
- package/src/core/geom/3d/atlas/atlas_generate.js +50 -50
- package/src/core/geom/3d/atlas/atlas_test_fixtures.js +266 -266
- package/src/core/geom/3d/atlas/atlas_write_chart_uvs.js +36 -36
- package/src/core/geom/3d/atlas/data/atlas_build_edge_dihedrals.js +62 -62
- package/src/core/geom/3d/atlas/data/atlas_build_edge_lengths.js +33 -33
- package/src/core/geom/3d/atlas/data/atlas_build_face_areas.js +50 -50
- package/src/core/geom/3d/atlas/io/atlas_mesh_weld_colocals.js +39 -39
- package/src/core/geom/3d/atlas/io/bt_loop_uv.js +35 -35
- package/src/core/geom/3d/atlas/pack/ChartPlacement.js +46 -46
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_bff.js +269 -269
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_lscm.js +209 -209
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_ortho.js +38 -38
- package/src/core/geom/3d/atlas/param/atlas_chart_stretch_metric.js +86 -86
- package/src/core/geom/3d/atlas/param/atlas_piecewise_resegment.js +183 -183
- package/src/core/geom/3d/atlas/param/fit_plane_basis.js +66 -66
- package/src/core/geom/3d/atlas/segment/RegionGraph.js +40 -40
- package/src/core/geom/3d/atlas/segment/atlas_build_region_graph.js +136 -136
- package/src/core/geom/3d/atlas/segment/atlas_chart_roundness_delta.js +30 -30
- package/src/core/geom/3d/atlas/segment/atlas_compute_planar_regions.js +77 -77
- package/src/core/geom/3d/atlas/segment/atlas_merge_charts.js +116 -116
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts.js +271 -271
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.js +191 -191
- package/src/core/geom/3d/box/box3_projected_half_extent.js +35 -35
- package/src/core/geom/3d/capsule/capsule_intersects_aabb3_closed.js +67 -67
- package/src/core/geom/3d/capsule/capsule_intersects_aabb3_iterative.js +137 -137
- package/src/core/geom/3d/compute_circle_bounding_box.js +7 -7
- package/src/core/geom/3d/cone/computeConeBoundingBox.js +7 -7
- package/src/core/geom/3d/cone/computeConePlaneSide.js +7 -7
- package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.js +7 -7
- package/src/core/geom/3d/cylinder/cylinder3_raycast.d.ts +38 -0
- package/src/core/geom/3d/cylinder/cylinder3_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/cylinder/cylinder3_raycast.js +105 -0
- package/src/core/geom/3d/equirectangular/equirectangular_direction_to_uv.js +18 -18
- package/src/core/geom/3d/equirectangular/equirectangular_uv_to_direction.js +24 -24
- package/src/core/geom/3d/frustum/clipping_volume_matrix4_project.js +7 -7
- package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +7 -7
- package/src/core/geom/3d/frustum/frustum3_compute_closest_point.js +117 -117
- package/src/core/geom/3d/frustum/frustum_matrix4_project.js +7 -7
- package/src/core/geom/3d/frustum/hexahedron_from_aabb.js +7 -7
- package/src/core/geom/3d/frustum/read_frustum_corner.js +17 -17
- package/src/core/geom/3d/frustum/read_three_planes_to_array.js +7 -7
- package/src/core/geom/3d/frustum/slice_frustum_linear_to_points.js +7 -7
- package/src/core/geom/3d/gjk/GJK_REVIEW_NOTES.md +146 -146
- package/src/core/geom/3d/gjk/gjk.js +430 -430
- package/src/core/geom/3d/gjk/gjk_epa_penetration.js +520 -520
- package/src/core/geom/3d/gjk/minkowski_support.js +71 -71
- package/src/core/geom/3d/gjk/mpr.js +368 -368
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.js +7 -7
- package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.js +7 -7
- package/src/core/geom/3d/line/line3_compute_point_segment_point_distance_unfolded.js +64 -64
- package/src/core/geom/3d/line/line3_compute_segment_closest_point_to_aabb3_t.js +153 -153
- package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_aabb3_t.js +7 -7
- package/src/core/geom/3d/line/line3_compute_segment_nearest_point_to_point_t.js +7 -7
- package/src/core/geom/3d/line/line3_compute_segment_segment_closest_points.js +88 -88
- package/src/core/geom/3d/line/line3_segment_segment_closest_point_pair.js +71 -71
- package/src/core/geom/3d/line/segment3_point_distance_to_segments.js +25 -25
- package/src/core/geom/3d/mat4/allocate_m4.js +7 -7
- package/src/core/geom/3d/mat4/apply_mat4_transform_to_direction_v3_array.js +7 -7
- package/src/core/geom/3d/mat4/apply_mat4_transform_to_v3_array.js +7 -7
- package/src/core/geom/3d/mat4/compose_matrix4_array.js +7 -7
- package/src/core/geom/3d/mat4/decompose_matrix_4_array.js +7 -7
- package/src/core/geom/3d/mat4/eulerAnglesFromMatrix.js +7 -7
- package/src/core/geom/3d/mat4/m4_compose.js +22 -22
- package/src/core/geom/3d/mat4/m4_compute_normal_matrix3.js +7 -7
- package/src/core/geom/3d/mat4/m4_decompose.js +64 -64
- package/src/core/geom/3d/mat4/m4_decompose_array.js +157 -157
- package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.js +32 -32
- package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale_scalar.js +67 -67
- package/src/core/geom/3d/mat4/m4_linear_matrix3.js +29 -29
- package/src/core/geom/3d/mat4/m4_look_at.js +96 -96
- package/src/core/geom/3d/mat4/m4_make_rotation_x.js +47 -47
- package/src/core/geom/3d/mat4/m4_make_rotation_y.js +47 -47
- package/src/core/geom/3d/mat4/m4_make_rotation_z.js +47 -47
- package/src/core/geom/3d/mat4/m4_normal_matrix3.js +39 -39
- package/src/core/geom/3d/mat4/m4_perspective.js +66 -66
- package/src/core/geom/3d/mat4/m4_transpose.js +48 -48
- package/src/core/geom/3d/morton/mortonEncode_LUT.js +7 -7
- package/src/core/geom/3d/morton/mortonEncode_magicbits.js +7 -7
- package/src/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +5 -5
- package/src/core/geom/3d/normal/hemioct/encode_unit_to_hemioct.js +28 -28
- package/src/core/geom/3d/normal/lambert_azimuth/decode_azimuth_to_unit.js +30 -30
- package/src/core/geom/3d/normal/lambert_azimuth/encode_unit_to_azimuth.js +19 -19
- package/src/core/geom/3d/normal/spherical/decode_spheremap_to_unit.js +38 -38
- package/src/core/geom/3d/normal/spherical/encode_unit_to_spheremap.js +30 -30
- package/src/core/geom/3d/plane/is_point_within_planes.js +7 -7
- package/src/core/geom/3d/plane/orient3d_fast_point.js +47 -47
- package/src/core/geom/3d/plane/plane3_compute_convex_3_plane_intersection.js +7 -7
- package/src/core/geom/3d/plane/plane3_compute_plane_intersection.js +7 -7
- package/src/core/geom/3d/plane/plane3_intersect_plane.js +7 -7
- package/src/core/geom/3d/plane/plane3_three_compute_convex_3_plane_intersection.js +7 -7
- package/src/core/geom/3d/point/point3_raycast.d.ts +33 -0
- package/src/core/geom/3d/point/point3_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/point/point3_raycast.js +47 -0
- package/src/core/geom/3d/polygon/polygon3_compute_normal.js +60 -60
- package/src/core/geom/3d/polygon/polygon3_triangulate.js +94 -94
- package/src/core/geom/3d/polyhedron/convex_polyhedron3_raycast.d.ts +40 -0
- package/src/core/geom/3d/polyhedron/convex_polyhedron3_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/polyhedron/convex_polyhedron3_raycast.js +94 -0
- package/src/core/geom/3d/quadric/QUADRIC3_SIZE.js +14 -14
- package/src/core/geom/3d/quadric/Quadric3.js +282 -282
- package/src/core/geom/3d/quadric/quadric3_add.js +33 -33
- package/src/core/geom/3d/quadric/quadric3_clear.js +25 -25
- package/src/core/geom/3d/quadric/quadric3_copy.js +27 -27
- package/src/core/geom/3d/quadric/quadric3_distance.js +36 -36
- package/src/core/geom/3d/quadric/quadric3_evaluate.js +25 -25
- package/src/core/geom/3d/quadric/quadric3_optimize.js +45 -45
- package/src/core/geom/3d/quadric/quadric3_scale.js +32 -32
- package/src/core/geom/3d/quadric/quadric3_set_from_plane_through_point.js +30 -30
- package/src/core/geom/3d/quadric/quadric3_set_from_vector4.js +35 -35
- package/src/core/geom/3d/quadric/quadric3_sub.js +36 -36
- package/src/core/geom/3d/quadric/quadric3_to_tensor_m3.js +28 -28
- package/src/core/geom/3d/quadric/quadric3_to_tensor_m3_inverse.js +56 -56
- package/src/core/geom/3d/quadric/quadric3_to_vector3.js +19 -19
- package/src/core/geom/3d/quaternion/quat3_createFromAxisAngle.js +7 -7
- package/src/core/geom/3d/quaternion/quat3_integrate.js +62 -62
- package/src/core/geom/3d/quaternion/quat3_multiply.js +31 -31
- package/src/core/geom/3d/quaternion/quat3_nlerp.js +72 -72
- package/src/core/geom/3d/quaternion/quat3_to_matrix3.js +69 -69
- package/src/core/geom/3d/quaternion/quat_decode_from_uint32.js +7 -7
- package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +7 -7
- package/src/core/geom/3d/ray/ray3_array_compose.js +7 -7
- package/src/core/geom/3d/ray/ray3_compute_nearest_point_to_point.js +7 -7
- package/src/core/geom/3d/ray/ray3_distance_to_point.js +7 -7
- package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.js +7 -7
- package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts +17 -0
- package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/ConvexHullShape3D.js +43 -0
- package/src/core/geom/3d/shape/CylinderShape3D.d.ts +1 -0
- package/src/core/geom/3d/shape/CylinderShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/CylinderShape3D.js +21 -0
- package/src/core/geom/3d/shape/PointShape3D.d.ts +7 -0
- package/src/core/geom/3d/shape/PointShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/PointShape3D.js +88 -63
- package/src/core/geom/3d/shape/PosedShape3D.d.ts +6 -0
- package/src/core/geom/3d/shape/PosedShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/PosedShape3D.js +27 -0
- package/src/core/geom/3d/shape/TransformedShape3D.d.ts +10 -0
- package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/TransformedShape3D.js +13 -0
- package/src/core/geom/3d/shape/Triangle3D.d.ts +1 -0
- package/src/core/geom/3d/shape/Triangle3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/Triangle3D.js +26 -0
- package/src/core/geom/3d/shape/UnionShape3D.d.ts +6 -0
- package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnionShape3D.js +7 -0
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +45 -45
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +44 -44
- package/src/core/geom/3d/shape/shape3_mesh_from_geometry.js +64 -64
- package/src/core/geom/3d/shape/shape_mesh_from_geometry.js +7 -7
- package/src/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +51 -51
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +7 -7
- package/src/core/geom/3d/sphere/compute_bounding_sphere_of_2_spheres.js +7 -7
- package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_zh.js +53 -53
- package/src/core/geom/3d/sphere/harmonics/sh3_ggx_zh.js +30 -30
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +7 -7
- package/src/core/geom/3d/sphere/harmonics/sh_compute_K.js +7 -7
- package/src/core/geom/3d/sphere/sphere_array_intersects_point.js +7 -7
- package/src/core/geom/3d/sphere/sphere_array_intersects_ray.js +7 -7
- package/src/core/geom/3d/sphere/sphere_intersects_point.js +7 -7
- package/src/core/geom/3d/sphere/sphere_matrix4_transform.js +5 -5
- package/src/core/geom/3d/sphere/sphere_projected_sphere_radius_sqr.js +7 -7
- package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +7 -7
- package/src/core/geom/3d/sphere/spherical_from_cartesian.js +7 -7
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js +174 -174
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js +7 -7
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_volume.js +7 -7
- package/src/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +7 -7
- package/src/core/geom/3d/tetrahedra/graphics/build_tetrahedral_mesh_geometry.js +39 -39
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.js +48 -48
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.js +173 -173
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_compute_tet_quality.js +22 -22
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.js +146 -146
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +232 -232
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +255 -255
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +387 -387
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +140 -140
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_tet_get_neighbours.js +7 -7
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +97 -97
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js +66 -66
- package/src/core/geom/3d/tetrahedra/triangle/triangle_decode_depth.js +59 -59
- package/src/core/geom/3d/tetrahedra/triangle/triangle_rasterized_depth_sample_index.js +54 -54
- package/src/core/geom/3d/tetrahedra/validate_neighbour.js +70 -70
- package/src/core/geom/3d/topology/struct/binary/BinaryDataBlock.js +314 -314
- package/src/core/geom/3d/topology/struct/binary/BinaryDataLayer.js +364 -364
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +567 -567
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +1085 -1085
- package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.js +73 -73
- package/src/core/geom/3d/topology/struct/binary/io/bt_loop_kill.js +35 -35
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_append.js +119 -119
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +84 -84
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.js +172 -172
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_face_normals.js +56 -56
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadratics.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadrics.js +227 -227
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +161 -161
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_island_erode.js +490 -490
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.js +120 -120
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_from_indexed_geometry.js +120 -120
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_collapse.js +52 -52
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.js +115 -115
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_flip.js +142 -142
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.js +21 -21
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +92 -92
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_split.js +179 -179
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_swap_vertex_slots.js +28 -28
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_kill_only_edge.js +8 -8
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.js +83 -83
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js +89 -89
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_kill.js +25 -25
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_poke.js +127 -127
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.js +268 -268
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_kill_only_face.js +8 -8
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_mesh_kill_degenerate_faces.js +72 -72
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_kill_only_vert.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_merge_verts_by_distance.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_mesh_relative_merge_distance.js +48 -48
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_mesh_split_pinched_vertices.js +256 -256
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_mesh_vertex_merge_distance.js +77 -77
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_kill.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_fuse_duplicate_edges.js +148 -148
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_kill_only.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/query/bt_collect_boundary_segments.js +29 -29
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_collapse_breaks_link_condition.js +107 -107
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_flip_is_legal.js +41 -41
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_flip_would_fold.js +120 -120
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +42 -42
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_is_boundary.js +20 -20
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_read_diamond.js +96 -96
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_compute_newell_normal.js +72 -72
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_attached_faces.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_edge_adjacent_faces.js +39 -39
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_edge_adjacent_faces_weighted.js +93 -93
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_neighbour_faces.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_shared_loop.js +48 -48
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_island_flood_fill.js +45 -45
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_read_triangle.js +66 -66
- package/src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.js +7 -7
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_assert_valid.js +44 -44
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_build_boundary_euclidean_distance_field.js +32 -32
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_face_islands.js +53 -53
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path.js +703 -703
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js +181 -181
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_segment_penetrates_surface.js +133 -133
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_surface_ray_parity.js +82 -82
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_validate.js +599 -599
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js +108 -108
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js +7 -7
- package/src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.js +7 -7
- package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +7 -7
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +7 -7
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +7 -7
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js +7 -7
- package/src/core/geom/3d/triangle/compute_triangle_area_3d.js +7 -7
- package/src/core/geom/3d/triangle/compute_triangle_normal.js +7 -7
- package/src/core/geom/3d/triangle/rayTriangleIntersection.js +7 -7
- package/src/core/geom/3d/triangle/tri3_closest_point.js +65 -65
- package/src/core/geom/3d/triangle/tri3_closest_point_barycentric.js +171 -171
- package/src/core/geom/3d/triangle/tri3_flatten_isometric.js +79 -79
- package/src/core/geom/3d/triangle/tri3_ray_intersection.js +160 -160
- package/src/core/geom/3d/triangle/tri3_ray_intersection_barycentric.js +96 -96
- package/src/core/geom/3d/triangle/tri3_raycast.d.ts +42 -0
- package/src/core/geom/3d/triangle/tri3_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/tri3_raycast.js +94 -0
- package/src/core/geom/3d/triangle/triangle3_incenter.js +7 -7
- package/src/core/geom/3d/triangle/triangle_compute_plane_side.js +7 -7
- package/src/core/geom/3d/triangle/triangle_compute_signed_volume.js +7 -7
- package/src/core/geom/3d/triangle/triangle_intersects_clipping_volume.js +7 -7
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js +7 -7
- package/src/core/geom/3d/triangle/v3_compute_triangle_normal.js +7 -7
- package/src/core/geom/3d/util/make_justified_point_grid.js +7 -7
- package/src/core/geom/GEOMETRY_REVIEW_002_API_ISSUES.md +381 -381
- package/src/core/geom/GEOMETRY_REVIEW_002_NAMING.md +684 -684
- package/src/core/geom/MANIFOLD_COMPARISON_2026_08_01.md +554 -554
- package/src/core/geom/mat3/m3_cm_from_translation.js +7 -7
- package/src/core/geom/mat3/m3_cm_invert.js +7 -7
- package/src/core/geom/mat3/m3_make_rotation.js +5 -5
- package/src/core/geom/mat3/m3_make_rotation_TBN.js +31 -31
- package/src/core/geom/mat3/m3_multiply_vec3.js +7 -7
- package/src/core/geom/packing/computeBoundingSphereOfSpheres.js +7 -7
- package/src/core/geom/packing/max-rect/cost/costByBestShortSide.js +7 -7
- package/src/core/geom/packing/max-rect/cost/costByRemainingArea.js +7 -7
- package/src/core/geom/packing/max-rect/cutArea.js +7 -7
- package/src/core/geom/packing/max-rect/findBestContainer.js +7 -7
- package/src/core/geom/packing/max-rect/packMaxRectangles.js +7 -7
- package/src/core/geom/packing/max-rect/packOneBox.js +7 -7
- package/src/core/geom/packing/max-rect/removeRedundantBoxes.js +7 -7
- package/src/core/geom/packing/max-rect/removeRedundantBoxesArray.js +7 -7
- package/src/core/geom/random/randomPointInBox.js +7 -7
- package/src/core/geom/random/randomPointInCircle.js +7 -7
- package/src/core/geom/random/randomPointInPoint.js +7 -7
- package/src/core/geom/random/randomPointInSphere.js +7 -7
- package/src/core/geom/random/randomPointOnBox.js +7 -7
- package/src/core/geom/random/randomPointOnSphere.js +7 -7
- package/src/core/geom/random/random_orthonormal_basis.js +31 -31
- package/src/core/geom/vec/vector_axpy.js +15 -15
- package/src/core/geom/vec/vector_axpy_offset.js +20 -20
- package/src/core/geom/vec/vector_copy.js +7 -7
- package/src/core/geom/vec/vector_dot_offset.js +25 -25
- package/src/core/geom/vec/vector_scale_array.js +7 -7
- package/src/core/geom/vec2/v2_rotate.js +21 -21
- package/src/core/geom/vec2/v2_rotate_cos_sin.js +21 -21
- package/src/core/geom/vec3/v3_angle_atan2_between.js +7 -7
- package/src/core/geom/vec3/v3_angle_between.js +7 -7
- package/src/core/geom/vec3/v3_angle_cos_between.js +7 -7
- package/src/core/geom/vec3/v3_array_add_in_place.js +7 -7
- package/src/core/geom/vec3/v3_array_centroid.js +7 -7
- package/src/core/geom/vec3/v3_array_copy.js +7 -7
- package/src/core/geom/vec3/v3_array_displace_in_direction.js +7 -7
- package/src/core/geom/vec3/v3_array_equals.js +7 -7
- package/src/core/geom/vec3/v3_array_immediate_add.js +7 -7
- package/src/core/geom/vec3/v3_array_matrix4_rotate.js +7 -7
- package/src/core/geom/vec3/v3_array_normalize.js +7 -7
- package/src/core/geom/vec3/v3_array_scale.js +7 -7
- package/src/core/geom/vec3/v3_compute_interior_angle.js +7 -7
- package/src/core/geom/vec3/v3_cotangent.js +33 -33
- package/src/core/geom/vec3/v3_dot_array_array.js +7 -7
- package/src/core/geom/vec3/v3_matrix3_multiply.js +30 -30
- package/src/core/geom/vec3/v3_matrix3_rotate.js +49 -49
- package/src/core/geom/vec3/v3_matrix4_rotate.js +7 -7
- package/src/core/geom/vec3/v3_multiply.js +23 -23
- package/src/core/geom/vec3/v3_multiply_scalar.js +7 -7
- package/src/core/geom/vec3/v3_orthonormal_matrix_from_normal.js +49 -49
- package/src/core/geom/vec3/v3_quat3_apply.js +7 -7
- package/src/core/geom/vec3/v3_quat3_apply_inverse.js +7 -7
- package/src/core/geom/vec3/v3_quaternion_apply.js +39 -39
- package/src/core/geom/vec3/v3_quaternion_apply_inverse.js +41 -41
- package/src/core/geom/vec3/v3_reflect.js +24 -24
- package/src/core/geom/vec3/v3_scale_array.js +18 -18
- package/src/core/geom/vec3/v3_triple_cross.js +45 -45
- package/src/core/geom/vec3/v3_triple_cross_product.js +7 -7
- package/src/core/geom/vec3/v3_uniform_sample_cone.js +21 -21
- package/src/core/geom/vec4/v4_multiply_mat4.js +7 -7
- package/src/core/graph/csr/csr_graph_build_distance_field.js +112 -112
- package/src/core/graph/csr/csr_graph_find_edge.js +25 -25
- package/src/core/graph/csr/csr_graph_find_shortest_path.js +105 -105
- package/src/core/graph/csr/csr_graph_from_undirected_edge_list.js +94 -94
- package/src/core/graph/graph_k_means_cluster.js +250 -250
- package/src/core/graph/layout/CircleLayout.js +1 -1
- package/src/core/graph/layout/box/BoxLayouter.js +1 -1
- package/src/core/graph/layout/graph_peel_topological_layer.js +45 -45
- package/src/core/graph/metis/BinaryTopologyFaceGraph.js +49 -49
- package/src/core/graph/metis/bt_mesh_build_face_graph.js +111 -111
- package/src/core/graph/metis/cluster_mesh_metis.js +137 -137
- package/src/core/graph/metis/native/bisection/bisect_graph.js +100 -100
- package/src/core/graph/metis/native/bisection/compute_2way_params.js +86 -86
- package/src/core/graph/metis/native/bisection/fm_2way.js +297 -297
- package/src/core/graph/metis/native/bisection/grow_bisection.js +137 -137
- package/src/core/graph/metis/native/bisection/split_graph_two_way.js +119 -119
- package/src/core/graph/metis/native/coarsen/coarsen_graph.js +94 -94
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.js +158 -158
- package/src/core/graph/metis/native/coarsen/match_shem.js +175 -175
- package/src/core/graph/metis/native/initial/initial_kway_bfs.js +122 -122
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.js +170 -170
- package/src/core/graph/metis/native/metis_partition_kway.js +126 -126
- package/src/core/graph/metis/native/refine/RefinementScratch.js +53 -53
- package/src/core/graph/metis/native/refine/fm_kway.js +487 -487
- package/src/core/graph/metis/native/refine/project_kway.js +43 -43
- package/src/core/graph/metis/native/refine/refine_kway.js +43 -43
- package/src/core/lang/reactive/pegjs/parser.js +3458 -3458
- package/src/core/math/complex/complex_horner_eval.js +31 -31
- package/src/core/math/computeWholeDivisorLow.js +33 -33
- package/src/core/math/f32_next_down.js +24 -24
- package/src/core/math/f32_next_up.js +27 -27
- package/src/core/math/hash/hash_mix2.js +22 -22
- package/src/core/math/hash/hash_mix3.js +19 -19
- package/src/core/math/linalg/cg/cg_solve.js +106 -106
- package/src/core/math/linalg/cg/cg_solve_normal_equations.js +59 -59
- package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.js +43 -43
- package/src/core/math/linalg/eigen/matrix_householder_in_place.js +122 -122
- package/src/core/math/linalg/eigen/matrix_qr_in_place.js +190 -190
- package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.js +117 -117
- package/src/core/math/linalg/givens/givens_apply_rows.js +28 -28
- package/src/core/math/linalg/givens/givens_apply_rows_offset.js +30 -30
- package/src/core/math/linalg/givens/givens_rotation_coefficients.js +39 -39
- package/src/core/math/linalg/lu_factor_linear_system.js +108 -108
- package/src/core/math/linalg/lu_solve_linear_system.js +53 -53
- package/src/core/math/linalg/polynomial_add_into.js +29 -29
- package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js +159 -159
- package/src/core/math/linalg/polynomial_cubic_derivative_eval.js +16 -16
- package/src/core/math/linalg/polynomial_cubic_horner_eval.js +19 -19
- package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.js +14 -14
- package/src/core/math/linalg/polynomial_multiply.js +41 -41
- package/src/core/math/linalg/polynomial_real_roots_in_interval.js +211 -211
- package/src/core/math/linalg/polynomial_root_bound_cauchy.js +30 -30
- package/src/core/math/linalg/polynomial_scale_into.js +17 -17
- package/src/core/math/linalg/polynomial_sub_into.js +29 -29
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +96 -96
- package/src/core/math/linalg/sor_optimal_omega.js +42 -42
- package/src/core/math/linalg/sparse/SparseMatrixCSR.js +88 -88
- package/src/core/math/linalg/sparse/spm_matvec.js +22 -22
- package/src/core/math/linalg/sparse/spm_matvec_transpose.js +29 -29
- package/src/core/math/lookup/LUT_HEATMAP.js +30 -30
- package/src/core/math/lookup/ParameterLookupTable.js +495 -495
- package/src/core/math/lookup/ParameterLookupTableFlags.js +6 -6
- package/src/core/math/noise/curl_noise_3d.js +18 -18
- package/src/core/math/physics/brdf/cone_cosine_from_roughness.js +28 -28
- package/src/core/math/physics/brdf/reflection_sample_weight.js +48 -48
- package/src/core/math/physics/kinematics/computeInterceptPoint.js +79 -79
- package/src/core/math/random/randomSeed.js +16 -16
- package/src/core/math/random/random_pick_weighted_index.js +26 -26
- package/src/core/math/round_half_away_from_zero.js +13 -13
- package/src/core/math/spline/spline3_hermite_apply_transform.js +107 -107
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.js +125 -125
- package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.js +50 -50
- package/src/core/math/spline/spline3_hermite_reverse.js +49 -49
- package/src/core/math/spline/spline3_hermite_to_monomial.js +37 -37
- package/src/core/math/statistics/hammersley_sequence.js +53 -53
- package/src/core/model/reactive/model/util/createRandomReactiveExpression.js +185 -185
- package/src/core/path/convertPathToURL.js +107 -107
- package/src/core/process/delay.js +16 -16
- package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.js +87 -87
- package/src/core/science/units/MEASUREMENT_UNITS_SI.js +17 -17
- package/src/core/science/units/NamedUnit.js +48 -48
- package/src/core/science/units/UNIT_DIMENSION_MAPPING.js +29 -29
- package/src/core/science/units/UnitDimension.js +28 -28
- package/src/core/science/units/format_quantity.js +74 -74
- package/src/core/science/units/magnitude_prefix.js +127 -127
- package/src/core/science/units/si/AMPERE.js +13 -13
- package/src/core/science/units/si/CANDELA.js +13 -13
- package/src/core/science/units/si/DIMENSIONLESS.js +14 -14
- package/src/core/science/units/si/KELVIN.js +13 -13
- package/src/core/science/units/si/KILOGRAM.js +13 -13
- package/src/core/science/units/si/METER.js +13 -13
- package/src/core/science/units/si/MOLE.js +13 -13
- package/src/core/science/units/si/SECOND.js +13 -13
- package/src/core/science/units/si/derived/BECQUEREL.js +16 -16
- package/src/core/science/units/si/derived/COULOMB.js +13 -13
- package/src/core/science/units/si/derived/FARAD.js +13 -13
- package/src/core/science/units/si/derived/GRAY.js +16 -16
- package/src/core/science/units/si/derived/HENRY.js +13 -13
- package/src/core/science/units/si/derived/HERTZ.js +16 -16
- package/src/core/science/units/si/derived/JOULE.js +13 -13
- package/src/core/science/units/si/derived/KATAL.js +13 -13
- package/src/core/science/units/si/derived/LUMEN.js +14 -14
- package/src/core/science/units/si/derived/LUX.js +13 -13
- package/src/core/science/units/si/derived/NEWTON.js +13 -13
- package/src/core/science/units/si/derived/OHM.js +13 -13
- package/src/core/science/units/si/derived/PASCAL.js +13 -13
- package/src/core/science/units/si/derived/SIEMENS.js +13 -13
- package/src/core/science/units/si/derived/SIEVERT.js +16 -16
- package/src/core/science/units/si/derived/TESLA.js +13 -13
- package/src/core/science/units/si/derived/VOLT.js +13 -13
- package/src/core/science/units/si/derived/WATT.js +13 -13
- package/src/core/science/units/si/derived/WEBER.js +13 -13
- package/src/core/science/units/unit_matrix_to_string.js +403 -403
- package/src/engine/Engine.js +726 -726
- package/src/engine/EngineHarness.js +590 -590
- package/src/engine/REVIEW_2026_07_03.md +211 -211
- package/src/engine/animation/AnimatedActions.js +81 -81
- package/src/engine/animation/AnimationUtils.js +252 -252
- package/src/engine/animation/async/TimeSeries.js +300 -300
- package/src/engine/animation/curve/animation_curve_binary_codec.js +60 -60
- package/src/engine/animation/curve/draw/canvas_point_to_curve.js +22 -22
- package/src/engine/animation/curve/draw/curve_point_to_canvas.js +38 -38
- package/src/engine/animation/curve/draw/position_canvas_to_curve.js +22 -22
- package/src/engine/animation/curve/draw/position_curve_to_canvas.js +22 -22
- package/src/engine/asset/GameAssetType.d.ts +0 -1
- package/src/engine/asset/GameAssetType.js +0 -1
- package/src/engine/asset/load_model_scene_bundle.js +27 -27
- package/src/engine/asset/loaders/font/FontAsset.js +21 -21
- package/src/engine/asset/loaders/font/FontAssetLoader.js +20 -20
- package/src/engine/asset/loaders/gltf_test_fixtures.js +358 -358
- package/src/engine/asset/loaders/image/ImageBitmapAssetLoader.js +52 -52
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +94 -94
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterAverage.js +59 -59
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +55 -55
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterPaeth.js +74 -74
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js +34 -34
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js +46 -46
- package/src/engine/control/first-person/DESIGN.md +640 -640
- package/src/engine/control/first-person/DESIGN_EXTENSIONS.md +563 -563
- package/src/engine/control/first-person/FirstPersonMotionPhase.js +134 -134
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +2045 -2045
- package/src/engine/control/first-person/mastery/DecisionPoint.js +30 -30
- package/src/engine/control/first-person/math/Spring.js +71 -71
- package/src/engine/control/first-person/math/computeJumpFromApex.js +23 -23
- package/src/engine/control/first-person/math/computeLRCBreathRate.js +41 -41
- package/src/engine/control/first-person/math/computeMassRatios.js +44 -44
- package/src/engine/control/first-person/math/criticallyDampedSpring.js +34 -34
- package/src/engine/control/first-person/math/dampedSpringStep.js +72 -72
- package/src/engine/control/first-person/math/jumpDynamics.js +108 -108
- package/src/engine/control/first-person/math/stepTowards.js +20 -20
- package/src/engine/control/first-person/pose/FirstPersonPose.js +137 -137
- package/src/engine/control/first-person/pose/FirstPersonPosture.js +27 -27
- package/src/engine/control/first-person/test/buildTestPlayer.js +36 -36
- package/src/engine/ecs/ASYNC_SYSTEMS_PROPOSAL.md +531 -531
- package/src/engine/ecs/EntityManager.d.ts +7 -3
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +10 -5
- package/src/engine/ecs/HIERARCHY_REVIEW.md +717 -717
- package/src/engine/ecs/async/SystemWorkerHost.js +329 -329
- package/src/engine/ecs/async/SystemWorkerLoopback.js +143 -143
- package/src/engine/ecs/async/WORKER_SYSTEM_PLAN.md +246 -246
- package/src/engine/ecs/async/WorkerSystem.js +702 -702
- package/src/engine/ecs/async/WorkerSystemProtocol.js +150 -150
- package/src/engine/ecs/fow/FogOfWar.js +707 -707
- package/src/engine/ecs/fow/FogOfWarEdgeMode.js +40 -40
- package/src/engine/ecs/fow/fog_of_war_mask_world_bounds.js +24 -24
- package/src/engine/ecs/fow/fog_of_war_uv_transform.js +30 -30
- package/src/engine/ecs/gui/hud/testHudEdgeStick.js +132 -134
- package/src/engine/ecs/hierarchy/EntityChildIndex.js +140 -140
- package/src/engine/ecs/ik/IKProblem.js +42 -42
- package/src/engine/ecs/ik/InverseKinematicsSystem.js +193 -193
- package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +134 -134
- package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +97 -97
- package/src/engine/ecs/ik/ik_bone_chain.js +85 -85
- package/src/engine/ecs/ik/ik_probe_terrain_contact.js +119 -119
- package/src/engine/ecs/parent/EntityNode.d.ts +1 -1
- package/src/engine/ecs/parent/EntityNode.js +2 -2
- package/src/engine/ecs/parent/ParentEntitySystem.js +255 -255
- package/src/engine/ecs/speaker/VoiceSystem.d.ts +2 -2
- package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
- package/src/engine/ecs/speaker/VoiceSystem.js +13 -7
- package/src/engine/ecs/storage/binary/SERIALIZATION_COVERAGE.md +269 -269
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectDeSerializer.js +315 -315
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectSerializer.js +331 -331
- package/src/engine/ecs/storage/binary/object-v2/DESIGN.md +199 -199
- package/src/engine/ecs/storage/binary/object-v2/ObjectBinaryFormat.js +57 -57
- package/src/engine/ecs/storage/binary/object-v2/ObjectSerializationAdapter.js +56 -56
- package/src/engine/ecs/storage/binary/object-v2/README.md +110 -110
- package/src/engine/ecs/storage/binary/object-v2/objectStringCodec.js +48 -48
- package/src/engine/ecs/storage/binary/object-v2/serializerTestHarness.js +44 -44
- package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +265 -265
- package/src/engine/ecs/terrain/TerrainClouds.js +97 -97
- package/src/engine/ecs/terrain/ecs/StubTerrainBuildWorker.js +65 -65
- package/src/engine/ecs/terrain/ecs/Terrain.d.ts +4 -0
- package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/Terrain.js +790 -790
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +209 -209
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +316 -316
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +416 -416
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +525 -525
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +302 -302
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +561 -561
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +896 -896
- package/src/engine/ecs/terrain/tiles/tile_geometry_to_meshlets.js +36 -36
- package/src/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +129 -129
- package/src/engine/ecs/transform/Transform64.js +814 -814
- package/src/engine/ecs/transform/t64_copy_from_transform.js +35 -35
- package/src/engine/ecs/transform/t64_equals_transform.js +55 -55
- package/src/engine/ecs/transform/t64_look_rotation.js +36 -36
- package/src/engine/ecs/transform/t64_transform_direction.js +25 -25
- package/src/engine/ecs/transform/transform_copy_from_t64.js +28 -28
- package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.js +345 -345
- package/src/engine/ecs/transform-attachment/transform_attachment_find_descendant_by_name.js +65 -65
- package/src/engine/ecs/transform-attachment/transform_attachment_parent_of.js +24 -24
- package/src/engine/ecs/util/hideEntityGracefully.js +208 -208
- package/src/engine/graphics/CONTEXT_LOSS_RECOVERY_PLAN.md +446 -446
- package/src/engine/graphics/FULL_SCREEN_QUAD_VERTEX_SHADER.js +14 -14
- package/src/engine/graphics/FrameThrottle.js +2 -2
- package/src/engine/graphics/ecs/animation/animator/graph/AnimationState.js +207 -207
- package/src/engine/graphics/ecs/animation/animator/graph/AnimationTransition.js +151 -151
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionAssetLoader.js +22 -22
- package/src/engine/graphics/ecs/camera/Camera.js +165 -165
- package/src/engine/graphics/ecs/camera/camera_active_frustum.js +25 -25
- package/src/engine/graphics/ecs/camera/camera_find_active.js +28 -28
- package/src/engine/graphics/ecs/camera/camera_traverse_active.js +18 -18
- package/src/engine/graphics/ecs/camera/pp/PerfectPanner.js +170 -170
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +68 -68
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +296 -296
- package/src/engine/graphics/ecs/decal/v2/Decal.js +220 -220
- package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +56 -56
- package/src/engine/graphics/ecs/decal/v2/DecalSerializationUpgrader_0_1.js +38 -38
- package/src/engine/graphics/ecs/light/shadow/compute_view_frustum_aabb_in_space.js +62 -62
- package/src/engine/graphics/ecs/light/shadow/extend_shadow_camera_near_for_casters.js +77 -77
- package/src/engine/graphics/ecs/make_bvh_depth_range_computer.js +33 -33
- package/src/engine/graphics/ecs/mesh-v2/DeferredBoundsQueue.js +88 -88
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +428 -428
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +303 -303
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.d.ts +1 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/serialization/SGMeshSerializationAdapter.js +39 -39
- package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.js +36 -36
- package/src/engine/graphics/ecs/path/tube/build/GeometryStream.js +94 -94
- package/src/engine/graphics/ecs/path/tube/build/build_stream_catmullrom.js +310 -310
- package/src/engine/graphics/ecs/path/tube/build/build_stream_linear.js +73 -73
- package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +199 -199
- package/src/engine/graphics/ecs/path/tube/build/makeTubeStream.js +217 -217
- package/src/engine/graphics/ecs/path/tube/build/make_cap.js +340 -340
- package/src/engine/graphics/ecs/path/tube/build/make_ring_faces.js +40 -40
- package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.js +153 -153
- package/src/engine/graphics/ecs/render_layers_compute_depth_range.js +64 -64
- package/src/engine/graphics/ecs/trail3d/Trail3D.js +483 -483
- package/src/engine/graphics/ecs/trail3d/Trail3DFlags.js +26 -26
- package/src/engine/graphics/ecs/trail3d/advance_trail.js +42 -42
- package/src/engine/graphics/ecs/trail3d/make_gradient_stroke.js +58 -58
- package/src/engine/graphics/ecs/trail3d/seed_trail_stroke.js +90 -90
- package/src/engine/graphics/ecs/trail3d/seed_trail_tube.js +75 -75
- package/src/engine/graphics/ecs/trail3d/trail_head_position.js +19 -19
- package/src/engine/graphics/ecs/water/Water.js +104 -104
- package/src/engine/graphics/geometry/AttributeData.js +84 -84
- package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_indexed.js +49 -49
- package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +288 -288
- package/src/engine/graphics/geometry/buffered/query/nearest_point_on_triangle_record.js +87 -87
- package/src/engine/graphics/geometry/buffered/read_triangle_vertices.js +102 -102
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_buffered_geometry.js +52 -52
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js +20 -20
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_unindexed_geometry.js +19 -19
- package/src/engine/graphics/geometry/optimization/geometry_optimize_uv_tension.js +135 -135
- package/src/engine/graphics/impostors/voxel/README.md +149 -149
- package/src/engine/graphics/impostors/voxel/VoxelImpostorDescription.js +141 -141
- package/src/engine/graphics/particles/node-based/codegen/glsl/getTypeByteSize.js +20 -20
- package/src/engine/graphics/particles/node-based/nodes/FloatConstant.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/FloatConstant.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/ReadFloatUniform.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/ReadFloatUniform.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/ReadVelocity.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/ReadVelocity.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/ShaderNode.d.ts +1 -2
- package/src/engine/graphics/particles/node-based/nodes/ShaderNode.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/Vector3Constant.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/Vector3Constant.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/Vector3Merge.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/Vector3Merge.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/Vector3Split.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/Vector3Split.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/WriteVelocity.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/WriteVelocity.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/attribute/ReadVector3Attribute.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/attribute/ReadVector3Attribute.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/attribute/WriteVector3Attribute.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/attribute/WriteVector3Attribute.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/math/AddFloatNode.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/math/AddFloatNode.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Add.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Add.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Divide.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Divide.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Multiply.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Multiply.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Subtract.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/math/Vector3Subtract.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/noise/CurlNoiseNode.d.ts +2 -0
- package/src/engine/graphics/particles/node-based/nodes/noise/CurlNoiseNode.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/nodes/particle_data_type_component_count.js +45 -45
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +229 -229
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +2 -10
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1149 -1149
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +472 -472
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -2
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTableFlags.js +2 -2
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterSet.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterSet.js +3 -5
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +135 -135
- package/src/engine/graphics/particles/particular/engine/utils/distribute_points_on_indexed_triangles.js +168 -168
- package/src/engine/graphics/render/forward_plus/plugin/forwardPlusMaterialMarker.js +18 -18
- package/src/engine/graphics/render/forward_plus/read_frustum_corner.js +2 -2
- package/src/engine/graphics/render/frame_graph/FRAME_GRAPH_RECOMMENDATIONS.md +219 -219
- package/src/engine/graphics/render/frame_graph/FrameGraph.js +900 -900
- package/src/engine/graphics/render/frame_graph/FrameGraphScope.js +72 -72
- package/src/engine/graphics/render/frame_graph/FrameGraphState.js +39 -39
- package/src/engine/graphics/render/frame_graph/ResourceEntry.js +96 -96
- package/src/engine/graphics/render/gizmo/GizmoShapeBuffer.js +105 -105
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +162 -162
- package/src/engine/graphics/render/layers/RenderLayer.js +95 -95
- package/src/engine/graphics/sh3/build_injected_shader.js +56 -56
- package/src/engine/graphics/sh3/grid_dilate_average.js +175 -175
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +506 -506
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +161 -161
- package/src/engine/graphics/sh3/path_tracer/PathTracedRenderer.js +205 -205
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +698 -698
- package/src/engine/graphics/sh3/path_tracer/REVIEW_001_ACTION_PLAN.md +490 -490
- package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +45 -45
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +73 -73
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +32 -32
- package/src/engine/graphics/sh3/path_tracer/texture/apply_texture_clamping_to_coordinate.js +28 -28
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +142 -142
- package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.js +70 -70
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +388 -388
- package/src/engine/graphics/shaders/chunks/glsl_octahedral_impostor.js +277 -277
- package/src/engine/graphics/shaders/chunks/glsl_voxel_impostor_splat.js +57 -57
- package/src/engine/graphics/shadows/vsm.glsl.js +43 -43
- package/src/engine/graphics/texture/3d/scs3d_sample_linear3.js +81 -81
- package/src/engine/graphics/texture/EnvironmentTextureProjection.js +15 -15
- package/src/engine/graphics/texture/channel_count_to_format_prefix.js +26 -26
- package/src/engine/graphics/texture/isImageBitmap.js +2 -2
- package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.js +189 -189
- package/src/engine/graphics/texture/reflection/equirectangular_reflection_roughness.js +51 -51
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.js +145 -145
- package/src/engine/graphics/texture/sampler/Sampler2DArray.js +172 -172
- package/src/engine/graphics/texture/sampler/compare/FLIP_IMPLEMENTATION_PLAN.md +466 -466
- package/src/engine/graphics/texture/sampler/compare/flip/FlipParameters.js +18 -18
- package/src/engine/graphics/texture/sampler/compare/flip/FlipPooling.js +33 -33
- package/src/engine/graphics/texture/sampler/compare/flip/flip_build_feature_kernel.js +147 -147
- package/src/engine/graphics/texture/sampler/compare/flip/flip_build_spatial_kernel.js +177 -177
- package/src/engine/graphics/texture/sampler/compare/flip/flip_compute_color_difference.js +104 -104
- package/src/engine/graphics/texture/sampler/compare/flip/flip_compute_feature_difference.js +76 -76
- package/src/engine/graphics/texture/sampler/compare/flip/flip_compute_pixels_per_degree.js +34 -34
- package/src/engine/graphics/texture/sampler/compare/flip/flip_constants.js +77 -77
- package/src/engine/graphics/texture/sampler/compare/flip/flip_filter_feature.js +48 -48
- package/src/engine/graphics/texture/sampler/compare/flip/flip_filter_spatial.js +86 -86
- package/src/engine/graphics/texture/sampler/compare/flip/flip_pool.js +71 -71
- package/src/engine/graphics/texture/sampler/compare/flip/flip_srgb_to_ycxcz.js +55 -55
- package/src/engine/graphics/texture/sampler/compare/flip/sampler2d_flip_ldr.js +80 -80
- package/src/engine/graphics/texture/sampler/filter/SeparableKernel.js +82 -82
- package/src/engine/graphics/texture/sampler/filter/sampler2d_convolve_separable.js +122 -122
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.js +148 -148
- package/src/engine/graphics/texture/sampler/sampler2d_channel_apply_lut.js +82 -82
- package/src/engine/graphics/texture/sampler/sampler2d_combine.js +67 -67
- package/src/engine/graphics/texture/sampler/sampler2d_linear_f16_to_srgb_u8.js +54 -54
- package/src/engine/graphics/texture/sampler/sampler2d_sample_equirectangular_direction.js +63 -63
- package/src/engine/graphics/texture/sampler/sampler2d_srgb_to_linear.js +33 -33
- package/src/engine/graphics/texture/sampler/sampler2d_srgb_u8_to_linear_f16.js +68 -68
- package/src/engine/graphics/texture/shade_image_preview.js +103 -103
- package/src/engine/graphics/trail/TrailSpawnMode.js +20 -20
- package/src/engine/graphics/trail/tube/TubeX.js +573 -573
- package/src/engine/graphics/trail/tube/TubeXMaterialSpec.js +58 -58
- package/src/engine/graphics/trail/tube/simulator/TubeXFixedPhysicsSimulator.js +34 -34
- package/src/engine/graphics/trail/tube/tube_attributes_spec.js +69 -69
- package/src/engine/graphics/trail/tube/tube_frame.js +83 -83
- package/src/engine/graphics3/AnimationGraphSystem3.js +329 -329
- package/src/engine/graphics3/AnimationSystem3.js +352 -352
- package/src/engine/graphics3/CameraSystem3.js +170 -170
- package/src/engine/graphics3/DecalSystem3.js +441 -441
- package/src/engine/graphics3/FogOfWarSystem3.js +265 -265
- package/src/engine/graphics3/GraphicsEngine3.js +776 -776
- package/src/engine/graphics3/HighlightSystem3.js +241 -241
- package/src/engine/graphics3/LightSystem3.js +211 -211
- package/src/engine/graphics3/MeshSystem3.js +646 -646
- package/src/engine/graphics3/ParticleEmitterSystem3.js +289 -289
- package/src/engine/graphics3/PathDisplaySystem3.js +309 -309
- package/src/engine/graphics3/PickingQuery.js +48 -48
- package/src/engine/graphics3/PickingResult.js +47 -47
- package/src/engine/graphics3/PickingSystem3.js +273 -273
- package/src/engine/graphics3/ShadeCameraAdapter.js +55 -55
- package/src/engine/graphics3/ShadedGeometrySystem3.js +169 -169
- package/src/engine/graphics3/TerrainSystem3.js +566 -566
- package/src/engine/graphics3/TooltipComponentSystem3.js +328 -328
- package/src/engine/graphics3/Trail3DSystem3.js +221 -221
- package/src/engine/graphics3/WaterSystem3.js +293 -293
- package/src/engine/graphics3/animation/ClipPlayback.js +84 -84
- package/src/engine/graphics3/animation/wrap_clip_time.js +23 -23
- package/src/engine/graphics3/animation/write_graph_playback.js +48 -48
- package/src/engine/graphics3/camera_sync_from_transform.js +29 -29
- package/src/engine/graphics3/debug/gizmo_view_from_camera.js +48 -48
- package/src/engine/graphics3/decal/DECAL_CLUSTER.js +61 -61
- package/src/engine/graphics3/decal/DECAL_GPU_RECORD.js +117 -117
- package/src/engine/graphics3/decal/DecalAtlas.js +194 -194
- package/src/engine/graphics3/decal/DecalAtlasFill.js +32 -32
- package/src/engine/graphics3/decal/GPUDecalRenderer.js +360 -360
- package/src/engine/graphics3/decal/chunk_decal_intersects_frustum.js +59 -59
- package/src/engine/graphics3/decal/chunk_decal_sampling_info.js +57 -57
- package/src/engine/graphics3/decal/chunk_decal_surface_frame.js +54 -54
- package/src/engine/graphics3/decal/decal_atlas_border.js +69 -69
- package/src/engine/graphics3/decal/decal_gpu_records.js +120 -120
- package/src/engine/graphics3/decal/decal_material_samplers.js +109 -109
- package/src/engine/graphics3/decal/graph_build_decal_clusters.js +212 -212
- package/src/engine/graphics3/decal/shader_cluster_assign_decals.js +207 -207
- package/src/engine/graphics3/decal/shader_cull_decals_frustum.js +108 -108
- package/src/engine/graphics3/highlight/GPUHighlightRenderer.js +151 -151
- package/src/engine/graphics3/highlight/HIGHLIGHT_OUTLINE.js +23 -23
- package/src/engine/graphics3/highlight/chunk_highlight_lookup.js +53 -53
- package/src/engine/graphics3/highlight/pack_highlight_color.js +44 -44
- package/src/engine/graphics3/highlight/pack_highlight_table.js +74 -74
- package/src/engine/graphics3/highlight/shader_highlight_outline.js +150 -150
- package/src/engine/graphics3/load_cube_environment.js +68 -68
- package/src/engine/graphics3/make_default_environment.js +107 -107
- package/src/engine/graphics3/particles/particle_gpu_records.js +221 -221
- package/src/engine/graphics3/path/build_tube_path_streams.js +98 -98
- package/src/engine/graphics3/path/tube_stream_write_geometry.js +90 -90
- package/src/engine/graphics3/preview/ModelPreviewFraming.js +35 -35
- package/src/engine/graphics3/preview/make_model_preview_scene.js +154 -154
- package/src/engine/graphics3/preview/make_model_thumbnail.js +48 -48
- package/src/engine/graphics3/preview/model_preview_framing.js +70 -70
- package/src/engine/graphics3/shade_bundle_bounds.js +55 -55
- package/src/engine/graphics3/shade_camera_projection_ray.js +77 -77
- package/src/engine/graphics3/shade_node_to_entity_composition.js +84 -84
- package/src/engine/graphics3/terrain/GPUTerrainSplatRenderer.js +481 -481
- package/src/engine/graphics3/terrain/chunk_terrain_grid_overlay.js +61 -61
- package/src/engine/graphics3/terrain/chunk_terrain_splat_mix.js +66 -66
- package/src/engine/graphics3/terrain/pack_terrain_row_table.js +53 -53
- package/src/engine/graphics3/terrain/shader_terrain_splat.js +215 -215
- package/src/engine/graphics3/trail/trail_tube_write_geometry.js +158 -158
- package/src/engine/grid/grid2transform/GridPosition2TransformSystem.d.ts +2 -2
- package/src/engine/grid/grid2transform/GridPosition2TransformSystem.d.ts.map +1 -1
- package/src/engine/input/GAMEPAD_API_PROPOSAL.md +717 -717
- package/src/engine/input/analog/apply_radial_dead_zone.js +38 -38
- package/src/engine/input/devices/GamepadDevice.js +466 -466
- package/src/engine/input/devices/ManualInputDevice.js +152 -152
- package/src/engine/input/devices/PointerCoordinates.js +26 -26
- package/src/engine/input/devices/events/GamepadEvents.js +10 -10
- package/src/engine/input/devices/gamepad/GamepadAxes.js +19 -19
- package/src/engine/input/devices/gamepad/GamepadButtons.js +29 -29
- package/src/engine/input/devices/gamepad/GamepadCoordinates.js +17 -17
- package/src/engine/input/devices/gamepad/GamepadDeviceLayout.js +323 -323
- package/src/engine/input/devices/gamepad/GamepadHandle.js +286 -286
- package/src/engine/input/devices/gamepad/GamepadLayout.js +160 -160
- package/src/engine/input/devices/gamepad/GamepadStandardMapping.js +31 -31
- package/src/engine/input/devices/gamepad/GamepadStick.js +169 -169
- package/src/engine/input/devices/gamepad/GamepadStickCalibration.js +119 -119
- package/src/engine/input/devices/gamepad/GamepadStickCalibrator.js +250 -250
- package/src/engine/input/devices/gamepad/gamepad_layout_database.js +144 -144
- package/src/engine/input/devices/gamepad/gamepad_read_hat_axis.js +61 -61
- package/src/engine/input/devices/gamepad/gamepad_write_dpad_vector.js +30 -30
- package/src/engine/input/devices/gamepad/prototypeGamepadTester.js +2124 -2124
- package/src/engine/input/devices/mouse/MouseButtons.js +22 -22
- package/src/engine/input/ecs/components/Input.js +118 -118
- package/src/engine/input/ecs/components/InputController.js +78 -78
- package/src/engine/input/ecs/ism/ISM_DESIGN.md +1523 -1523
- package/src/engine/input/ecs/ism/ISM_IMPLEMENTATION_PLAN.md +627 -627
- package/src/engine/input/ecs/ism/InputActionEvent.js +40 -40
- package/src/engine/input/ecs/ism/InputBinding.js +71 -71
- package/src/engine/input/ecs/ism/InputCoordinateKind.js +25 -25
- package/src/engine/input/ecs/ism/InputCoordinateSource.js +86 -86
- package/src/engine/input/ecs/ism/InputDirection.js +33 -33
- package/src/engine/input/ecs/ism/InputMapProgram.js +236 -236
- package/src/engine/input/ecs/ism/InputMapSystem.js +976 -976
- package/src/engine/input/ecs/ism/InputOcclusion.js +31 -31
- package/src/engine/input/ecs/ism/InputSource.js +67 -67
- package/src/engine/input/ecs/ism/InputSourceTable.js +107 -107
- package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.js +93 -93
- package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannelType.js +11 -11
- package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js +153 -153
- package/src/engine/input/ecs/ism/coordinate/InputCoordinateSwitches.js +160 -160
- package/src/engine/input/ecs/ism/device/GAMEPAD_INPUT_DEVICE_ID.js +9 -9
- package/src/engine/input/ecs/ism/device/GamepadInputDeviceAdapter.js +88 -88
- package/src/engine/input/ecs/ism/device/InputDeviceAdapter.js +72 -72
- package/src/engine/input/ecs/ism/device/KEYBOARD_INPUT_DEVICE_ID.js +9 -9
- package/src/engine/input/ecs/ism/device/KeyboardInputDeviceAdapter.js +63 -63
- package/src/engine/input/ecs/ism/device/ManualInputDeviceAdapter.js +55 -55
- package/src/engine/input/ecs/ism/device/POINTER_INPUT_DEVICE_ID.js +9 -9
- package/src/engine/input/ecs/ism/device/PointerInputDeviceAdapter.js +160 -160
- package/src/engine/input/ecs/ism/map/InputBinding.js +88 -88
- package/src/engine/input/ecs/ism/map/InputCoordinateBinding.js +102 -102
- package/src/engine/input/ecs/ism/map/InputLayer.js +220 -220
- package/src/engine/input/ecs/ism/map/InputMap.js +331 -331
- package/src/engine/input/ecs/ism/prototypeInputMap.js +309 -309
- package/src/engine/input/ecs/ism/trigger/InputTrigger.js +148 -148
- package/src/engine/input/ecs/ism/trigger/InputTriggerChord.js +173 -173
- package/src/engine/input/ecs/ism/trigger/InputTriggerGamepadButton.js +37 -37
- package/src/engine/input/ecs/ism/trigger/InputTriggerHold.js +176 -176
- package/src/engine/input/ecs/ism/trigger/InputTriggerKey.js +39 -39
- package/src/engine/input/ecs/ism/trigger/InputTriggerMouseButton.js +38 -38
- package/src/engine/input/ecs/ism/trigger/InputTriggerRelease.js +120 -120
- package/src/engine/input/ecs/ism/trigger/InputTriggerSequence.js +315 -315
- package/src/engine/input/ecs/ism/trigger/InputTriggerSwitch.js +105 -105
- package/src/engine/input/ecs/ism/trigger/InputTriggerType.js +17 -17
- package/src/engine/input/ecs/systems/InputControllerSystem.js +253 -253
- package/src/engine/input/ecs/systems/InputSystem.js +162 -162
- package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +25 -25
- package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.js +26 -26
- package/src/engine/intelligence/behavior/util/AsynchronousDelayAction.js +55 -55
- package/src/engine/interpolation/BinaryInterpolationAdapter.js +56 -56
- package/src/engine/interpolation/Interpoland.js +49 -49
- package/src/engine/interpolation/Interpolated.js +149 -149
- package/src/engine/interpolation/PoseInterpolationAdapter.js +61 -61
- package/src/engine/interpolation/TransformPoseSerializationAdapter.js +57 -57
- package/src/engine/interpolation/pose_interpoland.js +27 -27
- package/src/engine/navigation/ecs/path_following/PathFollower.js +222 -222
- package/src/engine/navigation/mesh/NavigationMesh.js +145 -145
- package/src/engine/navigation/mesh/OVERLAPPING_SURFACES_2026_08_25.md +661 -0
- package/src/engine/navigation/mesh/PATHFINDING_PLAN.md +229 -229
- package/src/engine/navigation/mesh/build/clip_soup_against_overhangs.d.ts.map +1 -1
- package/src/engine/navigation/mesh/build/clip_soup_against_overhangs.js +628 -520
- package/src/engine/network/CONGESTION_CONTROL.md +87 -87
- package/src/engine/network/README.md +52 -52
- package/src/engine/network/adapters/QuaternionInterpolationAdapter.js +43 -43
- package/src/engine/network/adapters/TransformInterpolationAdapter.js +84 -84
- package/src/engine/network/adapters/TransformReplicationAdapter.js +87 -87
- package/src/engine/network/adapters/Vector3InterpolationAdapter.js +46 -46
- package/src/engine/network/convertPathToURL.js +2 -2
- package/src/engine/network/core/MalformedPacketError.js +26 -26
- package/src/engine/network/core/quantize/quantize_float.js +73 -73
- package/src/engine/network/core/quantize/quantize_position.js +65 -65
- package/src/engine/network/core/sequence/ack_bitfield.js +77 -77
- package/src/engine/network/core/sequence/seq16.js +69 -69
- package/src/engine/network/core/sequence/seq32.js +73 -73
- package/src/engine/network/ecs/NetworkSystem.js +84 -84
- package/src/engine/network/ecs/components/NetworkIdentity.js +73 -73
- package/src/engine/network/ecs/owner_authorization.js +55 -55
- package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.js +64 -64
- package/src/engine/network/replication/ScopeFilter.js +71 -71
- package/src/engine/network/sim/ActionLog.js +152 -152
- package/src/engine/network/sim/SimAction.js +273 -273
- package/src/engine/network/sim/Snapshotter.js +222 -222
- package/src/engine/network/state/FrameBufferRing.js +168 -168
- package/src/engine/network/state/InputRing.js +134 -134
- package/src/engine/network/state/PriorityAccumulator.js +180 -180
- package/src/engine/network/time/TimeDilation.js +62 -62
- package/src/engine/network/transport/Channel.js +336 -336
- package/src/engine/network/transport/Transport.js +203 -203
- package/src/engine/network/transport/adapters/NodeUDPTransport.js +186 -186
- package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.js +105 -105
- package/src/engine/network/transport/fragments/fragment_send.js +147 -147
- package/src/engine/network/transport/fragments/packet_size.js +101 -101
- package/src/engine/network/xhr.js +23 -23
- package/src/engine/physics/BULLET_REVIEW.md +945 -945
- package/src/engine/physics/CANNON_REVIEW.md +1300 -1300
- package/src/engine/physics/CONSTRAINT_SOLVER_BENCH_LOG.md +208 -208
- package/src/engine/physics/CONSTRAINT_SOLVER_IMPROVEMENTS_PLAN.md +364 -364
- package/src/engine/physics/INTEPOLATION_SYSTEM_PLAN.md +287 -287
- package/src/engine/physics/JOLT_REVIEW.md +913 -913
- package/src/engine/physics/PLAN.md +1120 -1094
- package/src/engine/physics/RAPIER_REVIEW.md +934 -934
- package/src/engine/physics/REVIEW_001_ACTION_PLAN.md +642 -642
- package/src/engine/physics/REVIEW_002.md +151 -151
- package/src/engine/physics/REVIEW_003.md +166 -166
- package/src/engine/physics/broadphase/compute_fat_world_aabb.js +97 -97
- package/src/engine/physics/constraint/DofMode.js +35 -35
- package/src/engine/physics/constraint/solve_constraints.js +1 -1
- package/src/engine/physics/contact/combine_material.js +35 -35
- package/src/engine/physics/ecs/BodyKind.js +29 -29
- package/src/engine/physics/ecs/Collider.js +177 -177
- package/src/engine/physics/ecs/ColliderFlags.js +15 -15
- package/src/engine/physics/ecs/ColliderSerializationAdapter.js +37 -37
- package/src/engine/physics/ecs/Joint.js +475 -475
- package/src/engine/physics/ecs/JointSerializationAdapter.js +72 -72
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +3 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +7 -2
- package/src/engine/physics/ecs/RigidBodySerializationUpgrader_0_1.js +37 -37
- package/src/engine/physics/ecs/SleepState.js +12 -12
- package/src/engine/physics/ecs/find_non_finite_physics_state.js +76 -76
- package/src/engine/physics/fluid/FluidField.js +867 -867
- package/src/engine/physics/fluid/FluidSimulator.js +832 -832
- package/src/engine/physics/fluid/REVIEW_02_PLAN.md +243 -243
- package/src/engine/physics/fluid/SliceVisualiser.js +190 -190
- package/src/engine/physics/fluid/ecs/FluidComponent.js +239 -239
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js +89 -89
- package/src/engine/physics/fluid/ecs/FluidObstacle.js +97 -97
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.js +348 -348
- package/src/engine/physics/fluid/ecs/FluidSystem.js +142 -142
- package/src/engine/physics/fluid/ecs/FluidWorkerCore.js +123 -123
- package/src/engine/physics/fluid/ecs/WorkerFluidSystem.js +395 -395
- package/src/engine/physics/fluid/ecs/fluid.worker.js +12 -12
- package/src/engine/physics/fluid/ecs/fluid_build_world_to_grid.js +32 -32
- package/src/engine/physics/fluid/ecs/fluid_gather_visible_effectors.js +47 -47
- package/src/engine/physics/fluid/ecs/fluid_reanchor_field.js +85 -85
- package/src/engine/physics/fluid/ecs/fluid_sync_effectors_from_transform.js +16 -16
- package/src/engine/physics/fluid/ecs/fluid_worker_protocol.js +111 -111
- package/src/engine/physics/fluid/ecs/makeFluidWorker.js +18 -18
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +81 -81
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +202 -202
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +257 -257
- package/src/engine/physics/fluid/effector/WakeFluidEffector.js +405 -405
- package/src/engine/physics/fluid/prototype.js +126 -126
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_scalar.js +143 -143
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_velocity.js +162 -162
- package/src/engine/physics/fluid/solver/v3_grid_advect_sl_velocity.js +107 -107
- package/src/engine/physics/fluid/solver/v3_grid_apply_vorticity_confinement.js +131 -131
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +90 -90
- package/src/engine/physics/fluid/solver/v3_grid_limit8_at_indices.js +38 -38
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_constant.js +77 -77
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js +113 -113
- package/src/engine/physics/fluid/solver/v3_grid_sample_scalar_masked.js +92 -92
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.js +107 -107
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +135 -135
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +511 -511
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +108 -108
- package/src/engine/physics/fluid/solver/v3_mac_advect_maccormack_velocity.js +317 -317
- package/src/engine/physics/fluid/solver/v3_mac_advect_scalar.js +236 -236
- package/src/engine/physics/fluid/solver/v3_mac_advect_sl_velocity.js +217 -217
- package/src/engine/physics/fluid/solver/v3_mac_apply_vorticity_confinement.js +174 -174
- package/src/engine/physics/fluid/solver/v3_mac_clip_trace.js +95 -95
- package/src/engine/physics/fluid/solver/v3_mac_compute_divergence.js +77 -77
- package/src/engine/physics/fluid/solver/v3_mac_compute_face_solid.js +131 -131
- package/src/engine/physics/fluid/solver/v3_mac_subtract_pressure_gradient.js +104 -104
- package/src/engine/physics/inertia/world_inverse_inertia.js +160 -160
- package/src/engine/physics/integration/integrate_position.js +97 -97
- package/src/engine/physics/narrowphase/box_box_manifold.js +681 -681
- package/src/engine/physics/narrowphase/box_triangle_contact.js +906 -906
- package/src/engine/physics/narrowphase/capsule_triangle_contact.js +395 -395
- package/src/engine/physics/narrowphase/compute_penetration.js +369 -369
- package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.js +55 -55
- package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.js +37 -37
- package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.js +117 -117
- package/src/engine/physics/narrowphase/narrowphase_step.js +1738 -1738
- package/src/engine/physics/narrowphase/reduce_manifold_contacts.js +74 -74
- package/src/engine/physics/narrowphase/refine_ray_hit.d.ts +12 -11
- package/src/engine/physics/narrowphase/refine_ray_hit.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_hit.js +228 -36
- package/src/engine/physics/narrowphase/sphere_sphere_contact.js +52 -52
- package/src/engine/physics/narrowphase/sphere_triangle_contact.js +138 -138
- package/src/engine/physics/persistence/solver_caches.js +309 -309
- package/src/engine/physics/queries/overlap_shape.js +187 -187
- package/src/engine/physics/queries/raycast.d.ts +7 -4
- package/src/engine/physics/queries/raycast.d.ts.map +1 -1
- package/src/engine/physics/queries/raycast.js +11 -5
- package/src/engine/physics/queries/shape_cast.js +417 -417
- package/src/engine/physics/solver/apply_impulse_to_body.js +86 -86
- package/src/engine/physics/solver/friction_cone.js +37 -37
- package/src/engine/physics/solver/solve_contacts.js +1 -1
- package/src/engine/platform/WebEnginePlatform.d.ts.map +1 -1
- package/src/engine/platform/WebEnginePlatform.js +1 -2
- package/src/engine/scene/SerializedScene.d.ts +2 -2
- package/src/engine/scene/SerializedScene.d.ts.map +1 -1
- package/src/engine/scene/transitionToScene.js +121 -121
- package/src/engine/simulation/Ticker.d.ts.map +1 -1
- package/src/engine/simulation/Ticker.js +33 -0
- package/src/engine/sound/ecs/audio/LiveEmitterSet.js +345 -345
- package/src/engine/sound/ecs/audio/SpatialAudioIndex.js +140 -140
- package/src/engine/sound/simulation/AcousticSimulator.js +646 -646
- package/src/engine/sound/simulation/IMPLEMENTATION_PLAN.md +432 -432
- package/src/engine/sound/simulation/PROBE_PLACEMENT.md +250 -250
- package/src/engine/sound/simulation/PROBE_TRANSFER_RESEARCH.md +322 -322
- package/src/engine/sound/simulation/README.md +277 -277
- package/src/engine/sound/simulation/REFLECTION_IR_PLAN.md +261 -261
- package/src/engine/sound/simulation/VISIBILITY_GRAPH_PLAN.md +121 -121
- package/src/engine/sound/simulation/configureAcousticSimulation.js +48 -48
- package/src/engine/sound/simulation/core/AcousticMedium.js +113 -113
- package/src/engine/sound/simulation/core/AcousticMediumSerializationAdapter.js +27 -27
- package/src/engine/sound/simulation/core/AcousticOccluderIndex.js +312 -312
- package/src/engine/sound/simulation/core/AcousticRegionIndex.js +159 -159
- package/src/engine/sound/simulation/core/AcousticSolution.js +90 -90
- package/src/engine/sound/simulation/core/AcousticSourceState.js +109 -109
- package/src/engine/sound/simulation/core/AcousticVolumeRegion.js +73 -73
- package/src/engine/sound/simulation/core/OcclusionSolver.js +112 -112
- package/src/engine/sound/simulation/core/RayHit.js +50 -50
- package/src/engine/sound/simulation/core/VolumeField.js +149 -149
- package/src/engine/sound/simulation/definition/AcousticDirectivity.js +114 -114
- package/src/engine/sound/simulation/definition/AcousticDirectivitySerializationAdapter.js +30 -30
- package/src/engine/sound/simulation/definition/AcousticMaterial.js +122 -122
- package/src/engine/sound/simulation/definition/AcousticMaterialSerializationAdapter.js +32 -32
- package/src/engine/sound/simulation/ecs/AcousticBody.js +48 -48
- package/src/engine/sound/simulation/ecs/AcousticBodySerializationAdapter.js +34 -34
- package/src/engine/sound/simulation/ecs/AcousticProbeFieldSystem.js +64 -64
- package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.js +75 -75
- package/src/engine/sound/simulation/ecs/AcousticVolume.js +74 -74
- package/src/engine/sound/simulation/ecs/AcousticVolumeSerializationAdapter.js +37 -37
- package/src/engine/sound/simulation/ecs/AcousticVolumeSystem.js +66 -66
- package/src/engine/sound/simulation/probe/AcousticProbeField.js +578 -578
- package/src/engine/sound/simulation/probe/AcousticProbeFieldSerializationAdapter.js +60 -60
- package/src/engine/sound/simulation/probe/ProbeFieldPathingSolution.js +64 -64
- package/src/engine/sound/simulation/probe/ProbeVisibilityRecheck.js +132 -132
- package/src/engine/sound/simulation/probe/acoustic_probe_transfer.js +103 -103
- package/src/engine/sound/simulation/probe/acoustic_trace_energy.js +136 -136
- package/src/engine/sound/simulation/probe/bakeProbeField.js +169 -169
- package/src/engine/sound/simulation/probe/bakeProbeReflectors.js +110 -110
- package/src/engine/sound/simulation/probe/bakeReverbBands.js +110 -110
- package/src/engine/sound/simulation/probe/bakeVisibility.js +148 -148
- package/src/engine/sound/simulation/probe/echogram_band_rt60.js +83 -83
- package/src/engine/sound/simulation/probe/probe_delaunay_edges.js +215 -215
- package/src/engine/sound/simulation/probe/probe_densify_portals.js +140 -140
- package/src/engine/sound/simulation/probe/probe_detect_portals.js +196 -196
- package/src/engine/sound/simulation/probe/probe_edge_key.js +38 -38
- package/src/engine/sound/simulation/probe/probe_edge_visible.js +41 -41
- package/src/engine/sound/simulation/probe/probe_place_sdf_cover.js +82 -82
- package/src/engine/sound/simulation/probe/probe_refine_connectivity.js +181 -181
- package/src/engine/sound/simulation/probe/probe_sdf_grid.js +171 -171
- package/src/engine/sound/simulation/probe/probe_visibility_augment.js +146 -146
- package/src/engine/sound/simulation/probe/probe_visibility_bridge_components.js +167 -167
- package/src/engine/sound/simulation/render/FoaProbeReverbRenderer.js +354 -354
- package/src/engine/sound/simulation/render/ProbeReverbRenderer.js +231 -231
- package/src/engine/sound/simulation/render/foaReverbImpulseResponse.js +105 -105
- package/src/engine/sound/simulation/render/reverbImpulseResponse.js +66 -66
- package/src/engine/sound/simulation/render/reverb_band_tails.js +93 -93
- package/src/engine/sound/simulation/serialization/populateAcousticSerializationRegistry.js +25 -25
- package/src/engine/sound/sopra/README.md +643 -643
- package/src/engine/sound/sopra/SopraEngine.js +432 -432
- package/src/engine/sound/sopra/asset/AssetManagerBufferProvider.js +71 -71
- package/src/engine/sound/sopra/asset/BufferProvider.js +29 -29
- package/src/engine/sound/sopra/asset/StubBufferProvider.js +58 -58
- package/src/engine/sound/sopra/definition/BusDefinition.js +142 -142
- package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.js +54 -54
- package/src/engine/sound/sopra/definition/DuckingRule.js +106 -106
- package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.js +31 -31
- package/src/engine/sound/sopra/definition/EventDescription.js +262 -262
- package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.js +55 -55
- package/src/engine/sound/sopra/definition/MixerSnapshot.js +83 -83
- package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.js +39 -39
- package/src/engine/sound/sopra/definition/ParameterDefinition.js +117 -117
- package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.js +31 -31
- package/src/engine/sound/sopra/definition/VoiceStealMode.js +18 -18
- package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +109 -109
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.js +185 -185
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.js +59 -59
- package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.js +128 -128
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.js +226 -226
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.js +54 -54
- package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +191 -191
- package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.js +39 -39
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.js +79 -79
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.js +42 -42
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.js +77 -77
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.js +27 -27
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +5 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -1
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.js +125 -125
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.js +41 -41
- package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.js +24 -24
- package/src/engine/sound/sopra/definition/effect/CompressorEffect.js +120 -120
- package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.js +31 -31
- package/src/engine/sound/sopra/definition/effect/EqEffect.js +128 -128
- package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.js +29 -29
- package/src/engine/sound/sopra/definition/effect/ReverbEffect.js +113 -113
- package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.js +25 -25
- package/src/engine/sound/sopra/runtime/BusGraph.js +231 -231
- package/src/engine/sound/sopra/runtime/ParameterStore.js +98 -98
- package/src/engine/sound/sopra/runtime/SopraPlaybackContext.js +68 -68
- package/src/engine/sound/sopra/runtime/Voice.js +145 -145
- package/src/engine/sound/sopra/runtime/VoiceManager.js +136 -136
- package/src/engine/sound/sopra/runtime/VoicePool.js +17 -17
- package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.js +42 -42
- package/src/engine/sound/sopra/serialization/sopraJSON.js +99 -99
- package/src/engine/sound/sopra/serialization/sopraSerializationHarness.js +49 -49
- package/src/engine/sound/sopra/util/MockAudioContext.js +224 -224
- package/src/engine/sound/sopra/util/fadeOutAndStop.js +60 -60
- package/src/engine/ui/DraggableAspect.js +115 -115
- package/src/engine/ui/apply_pointer_tilt_3d.js +50 -50
- package/src/generation/COORDINATES.md +54 -54
- package/src/generation/GridGenerationResource.js +24 -24
- package/src/generation/GridTaskGroup.js +214 -214
- package/src/generation/REVIEW_01_ACTION_PLAN.md +628 -628
- package/src/generation/automata/CaveGeneratorCellularAutomata.js +79 -79
- package/src/generation/automata/CellularAutomata.js +22 -22
- package/src/generation/compute_writes_union.js +25 -25
- package/src/generation/filtering/CellFilter.js +117 -117
- package/src/generation/filtering/core/CellFilterBinaryOperation.js +37 -37
- package/src/generation/filtering/core/CellFilterOperationTertiary.js +43 -43
- package/src/generation/filtering/core/CellFilterUnaryOperation.js +29 -29
- package/src/generation/filtering/numeric/process/computeCellFilterSobel.js +36 -36
- package/src/generation/filtering/numeric/process/computeFilterSurfaceNormal.js +42 -42
- package/src/generation/filtering/numeric/util/populateSampler2DFromCellFilter.js +18 -18
- package/src/generation/filtering/numeric/util/write_cell_filter_to_sampler2d.js +47 -47
- package/src/generation/filtering/util/cell_filter_weights_pick.js +54 -54
- package/src/generation/grid/GridData.js +233 -233
- package/src/generation/grid/coords/grid_to_texel.js +10 -10
- package/src/generation/grid/coords/texel_to_grid.js +10 -10
- package/src/generation/grid/generation/GridTaskApplyActionToCells.js +90 -90
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +388 -388
- package/src/generation/grid/generation/GridTaskExecuteRuleTimes.js +127 -127
- package/src/generation/grid/generation/GridTaskSequence.js +58 -58
- package/src/generation/grid/generation/NoopGridTaskGenerator.js +12 -12
- package/src/generation/grid/generation/discrete/GridTaskActionRuleSet.js +48 -48
- package/src/generation/grid/generation/discrete/GridTaskCellularAutomata.js +146 -146
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +540 -540
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +222 -222
- package/src/generation/grid/generation/grid/GridTaskAddNodesFixed.js +44 -44
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +614 -614
- package/src/generation/markers/GridCellActionPlaceMarker.js +244 -244
- package/src/generation/markers/GridCellActionPlaceMarkerGroup.js +86 -86
- package/src/generation/markers/actions/terrain/MarkerNodeActionPaintTerrain.js +266 -266
- package/src/generation/markers/emitter/MarkerNodeEmitterGridCellAction.js +49 -49
- package/src/generation/placement/GridCellActionTransformNearbyMarkers.js +120 -120
- package/src/generation/placement/action/GridCellAction.js +45 -45
- package/src/generation/placement/action/GridCellActionPlaceTags.js +140 -140
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +89 -89
- package/src/generation/placement/action/random/CellActionSelectRandom.js +69 -69
- package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +91 -91
- package/src/generation/placement/action/util/GridCellActionSequence.js +61 -61
- package/src/generation/placement/action/util/GridCellDisplacedAction.js +61 -61
- package/src/generation/rules/cell/CellMatcherRemovalPreservesConnectivity.js +183 -183
- package/src/generation/theme/ThemeEngine.js +666 -666
- package/src/shade/RENDERER_CONTRACT.md +568 -0
- package/src/shade/descriptor/texture/format/gpu_texture_format_info.js +267 -267
- package/src/shade/device/ShadeDeviceFailure.js +104 -104
- package/src/shade/device/ShadeDeviceFailureReason.js +41 -41
- package/src/shade/device/mock/IMPLEMENTATION_PLAN.md +255 -255
- package/src/shade/device/mock/REVIEW_2026_08_22.md +527 -527
- package/src/shade/device/mock/SoftwareGPUBindGroup.js +23 -23
- package/src/shade/device/mock/SoftwareGPUBindGroupLayout.js +22 -22
- package/src/shade/device/mock/SoftwareGPUError.js +63 -63
- package/src/shade/device/mock/SoftwareGPUPipeline.js +75 -75
- package/src/shade/device/mock/SoftwareGPUQuerySet.js +113 -113
- package/src/shade/device/mock/SoftwareGPUSampler.js +30 -30
- package/src/shade/device/mock/SoftwareGPUShaderModule.js +32 -32
- package/src/shade/device/mock/SoftwareGPUTextureView.js +22 -22
- package/src/shade/device/mock/SoftwareGPUUncapturedErrorEvent.js +23 -23
- package/src/shade/device/mock/normalize_dynamic_offsets.js +26 -26
- package/src/shade/device/mock/texture_copy.js +287 -287
- package/src/shade/device/timing/GPUTimer.js +285 -285
- package/src/shade/device/timing/GPUTimerArray.js +205 -205
- package/src/shade/playground/add_random_lights.js +49 -49
- package/src/shade/playground/add_random_meshes.js +83 -83
- package/src/shade/playground/animation_prototype.js +508 -508
- package/src/shade/playground/animation_prototype_skinning.js +647 -647
- package/src/shade/playground/animation_prototype_stress.js +765 -765
- package/src/shade/playground/enable_picker.js +59 -59
- package/src/shade/playground/gltf_skinned_prototype.js +560 -560
- package/src/shade/playground/gltf_skinned_stress_prototype.js +387 -387
- package/src/shade/playground/gltf_viewer.js +282 -282
- package/src/shade/playground/load_default_environment.js +19 -19
- package/src/shade/playground/main.js +2727 -2727
- package/src/shade/playground/make_animated_instances.js +117 -117
- package/src/shade/playground/prototype_virtual_texture.js +274 -274
- package/src/shade/playground/prototype_volumetrics_01.js +206 -206
- package/src/shade/playground/sample.js +234 -234
- package/src/shade/playground/sample_load_gltf.js +102 -102
- package/src/shade/playground/spread_node3d_grid.js +19 -19
- package/src/shade/renderer/Renderer.js +2436 -2436
- package/src/shade/renderer/ShadeIndirectLightingMode.js +14 -14
- package/src/shade/renderer/animation/ShadeAnimationChannel.js +414 -414
- package/src/shade/renderer/animation/compute_skinned_mesh_clip_bounding_sphere.js +531 -531
- package/src/shade/renderer/animation/pose/PosePlayback.js +55 -55
- package/src/shade/renderer/animation/pose/pose_evaluate_local.js +179 -179
- package/src/shade/renderer/animation/pose/pose_evaluate_world.js +76 -76
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +1024 -1024
- package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.js +79 -79
- package/src/shade/renderer/animation/skinning/chunk_skin_blend_mesh_local.js +56 -56
- package/src/shade/renderer/binding/BindGroupManager.js +282 -282
- package/src/shade/renderer/binding/adapt_cache_capacity.js +25 -25
- package/src/shade/renderer/buffer/GPUBufferAllocator.js +116 -116
- package/src/shade/renderer/buffer/buffer_pool_ops.js +123 -123
- package/src/shade/renderer/buffer/table/GPU_DATABASE_PAGE_SIZE.js +9 -9
- package/src/shade/renderer/buffer/table/GPU_DATABASE_UPLOAD_BUFFER_LIMIT.js +8 -8
- package/src/shade/renderer/buffer/table/PageBufferPool.js +71 -71
- package/src/shade/renderer/buffer/table/PageSlotAllocator.js +95 -95
- package/src/shade/renderer/camera/Camera.js +281 -281
- package/src/shade/renderer/camera/GPUCameraContext.js +233 -233
- package/src/shade/renderer/camera/orbital/README.md +84 -84
- package/src/shade/renderer/deferred/shader_composite_volumetrics.js +75 -75
- package/src/shade/renderer/dynamic/DYNAMIC_MESH_VERTEX.js +25 -25
- package/src/shade/renderer/dynamic/GPUDynamicMeshRenderer.js +342 -342
- package/src/shade/renderer/dynamic/GPUDynamicMeshResidency.js +167 -167
- package/src/shade/renderer/dynamic/shader_dynamic_mesh.js +170 -170
- package/src/shade/renderer/extension/FrameContext.js +263 -263
- package/src/shade/renderer/extension/FramePhase.js +104 -104
- package/src/shade/renderer/extension/FrameRecord.js +126 -126
- package/src/shade/renderer/extension/GBufferTextures.js +83 -83
- package/src/shade/renderer/extension/PresentTarget.js +34 -34
- package/src/shade/renderer/extension/RENDER_EXTENSION_DESIGN.md +918 -918
- package/src/shade/renderer/extension/RenderExtension.js +69 -69
- package/src/shade/renderer/extension/RenderExtensionRegistry.js +319 -319
- package/src/shade/renderer/extension/SceneColor.js +40 -40
- package/src/shade/renderer/extension/ViewTextures.js +78 -78
- package/src/shade/renderer/fow/GPUFogOfWarRenderer.js +182 -182
- package/src/shade/renderer/geometry/Geometry.js +608 -608
- package/src/shade/renderer/geometry/geometry_build_from_meshlet_geometry.js +342 -342
- package/src/shade/renderer/geometry/meshlet_geometry_transfer.js +41 -41
- package/src/shade/renderer/geometry/primitives/make_box_geometry.js +153 -153
- package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.js +240 -240
- package/src/shade/renderer/geometry/primitives/make_plane_geometry.js +145 -145
- package/src/shade/renderer/geometry/primitives/make_polyhedron_geometry.js +327 -327
- package/src/shade/renderer/geometry/primitives/make_torus_geometry.js +107 -107
- package/src/shade/renderer/geometry/primitives/make_torus_knot_geometry.js +165 -165
- package/src/shade/renderer/geometry/virtual/VGEO_FORMAT.md +607 -607
- package/src/shade/renderer/geometry/virtual/build/VGeoBuildOptions.js +66 -66
- package/src/shade/renderer/geometry/virtual/build/VGeoBuildResult.js +32 -32
- package/src/shade/renderer/geometry/virtual/build/VGeoFaceGraph.js +103 -103
- package/src/shade/renderer/geometry/virtual/build/VGeoGatheredFaces.js +25 -25
- package/src/shade/renderer/geometry/virtual/build/VGeoLevel.js +33 -33
- package/src/shade/renderer/geometry/virtual/build/VGeoLevelOptions.js +62 -62
- package/src/shade/renderer/geometry/virtual/build/VGeoLevelSummary.js +49 -49
- package/src/shade/renderer/geometry/virtual/build/VGeoSubmesh.js +20 -20
- package/src/shade/renderer/geometry/virtual/build/VirtualGeometryMesh.js +214 -214
- package/src/shade/renderer/geometry/virtual/build/gltf/GltfByteSource.js +122 -122
- package/src/shade/renderer/geometry/virtual/build/gltf/GltfCollectReport.js +29 -29
- package/src/shade/renderer/geometry/virtual/build/gltf/GltfDocument.js +210 -210
- package/src/shade/renderer/geometry/virtual/build/gltf/GltfGeometry.js +48 -48
- package/src/shade/renderer/geometry/virtual/build/gltf/GltfGeometryInstance.js +25 -25
- package/src/shade/renderer/geometry/virtual/build/gltf/GltfGeometrySelection.js +28 -28
- package/src/shade/renderer/geometry/virtual/build/gltf/gltf_collect_geometries.js +296 -296
- package/src/shade/renderer/geometry/virtual/build/gltf/gltf_open_document.js +166 -166
- package/src/shade/renderer/geometry/virtual/build/gltf/gltf_read_geometry.js +199 -199
- package/src/shade/renderer/geometry/virtual/build/vgeo_assemble_pages.js +173 -173
- package/src/shade/renderer/geometry/virtual/build/vgeo_bounding_sphere.js +28 -28
- package/src/shade/renderer/geometry/virtual/build/vgeo_build.js +200 -200
- package/src/shade/renderer/geometry/virtual/build/vgeo_build_levels.js +1786 -1786
- package/src/shade/renderer/geometry/virtual/build/vgeo_build_page_nodes.js +157 -157
- package/src/shade/renderer/geometry/virtual/build/vgeo_build_root_group.js +26 -26
- package/src/shade/renderer/geometry/virtual/build/vgeo_compute_vertex_normals.js +75 -75
- package/src/shade/renderer/geometry/virtual/build/vgeo_compute_vertex_tangents.js +143 -143
- package/src/shade/renderer/geometry/virtual/build/vgeo_containing_sphere.js +44 -44
- package/src/shade/renderer/geometry/virtual/build/vgeo_extract_submesh.js +41 -41
- package/src/shade/renderer/geometry/virtual/build/vgeo_gather_faces.js +71 -71
- package/src/shade/renderer/geometry/virtual/build/vgeo_graph_components.js +123 -123
- package/src/shade/renderer/geometry/virtual/build/vgeo_narrow_indices.js +26 -26
- package/src/shade/renderer/geometry/virtual/build/vgeo_normalize_source.js +112 -112
- package/src/shade/renderer/geometry/virtual/build/vgeo_partition_graph.js +56 -56
- package/src/shade/renderer/geometry/virtual/build/vgeo_sphere_inflate_to_contain.js +70 -70
- package/src/shade/renderer/geometry/virtual/build/vgeo_split_face_set.js +187 -187
- package/src/shade/renderer/geometry/virtual/build/vgeo_split_face_set_packed.js +207 -207
- package/src/shade/renderer/geometry/virtual/format/VGEO_DEFECT.js +18 -18
- package/src/shade/renderer/geometry/virtual/format/VGeoDefect.js +38 -38
- package/src/shade/renderer/geometry/virtual/format/VGeoWriteOptions.js +64 -64
- package/src/shade/renderer/geometry/virtual/format/attribute/VGEO_ATTRIBUTE.js +13 -13
- package/src/shade/renderer/geometry/virtual/format/attribute/VGEO_ATTRIBUTES.js +50 -50
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_attribute_allocate.js +28 -28
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_attribute_mask.js +23 -23
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_attributes_read.js +31 -31
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_layers_copy_vertex.js +32 -32
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_layers_declare.js +46 -46
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_layers_like.js +19 -19
- package/src/shade/renderer/geometry/virtual/format/attribute/vgeo_layers_test_fixtures.js +27 -27
- package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_asset_id_preimage.js +62 -62
- package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_asset_id.js +13 -13
- package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_directory_block_checksum.js +41 -41
- package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_frame_checksum.js +41 -41
- package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_header_checksum.js +25 -25
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_CLUSTER_OFFSET.js +20 -20
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_CLUSTER_RECORD_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_MAX_CHILD_REF.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_MAX_CLUSTER_TRIANGLE_COUNT.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_MAX_CLUSTER_VERTEX_COUNT.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_NO_CHILD.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_NO_GROUP.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/cluster/VGEO_SAME_PAGE.js +6 -6
- package/src/shade/renderer/geometry/virtual/format/dag/VirtualGeometryCluster.js +81 -81
- package/src/shade/renderer/geometry/virtual/format/dag/VirtualGeometryGroup.js +37 -37
- package/src/shade/renderer/geometry/virtual/format/dag/VirtualGeometryPageNode.js +55 -55
- package/src/shade/renderer/geometry/virtual/format/directory/VGEO_DIRECTORY_BLOCK_RECORDS.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/directory/VGEO_DIRECTORY_FLAG_ROOT_PAGE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/directory/VGEO_DIRECTORY_RECORD_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/directory/vgeo_directory_block_count.js +12 -12
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_CHILD_OFFSET.js +11 -11
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_CHILD_TABLE_ENTRY_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_CODEC_LZ4.js +11 -11
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_CODEC_RAW.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_FRAME_ALIGNMENT.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_FRAME_HEADER_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_FRAME_OFFSET.js +13 -13
- package/src/shade/renderer/geometry/virtual/format/frame/VGEO_PAGE_MAGIC.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/frame/VGeoFrameBlob.js +21 -21
- package/src/shade/renderer/geometry/virtual/format/frame/VGeoFrameExtent.js +59 -59
- package/src/shade/renderer/geometry/virtual/format/frame/vgeo_codec_name.js +27 -27
- package/src/shade/renderer/geometry/virtual/format/frame/vgeo_decode_frame_blob.js +84 -84
- package/src/shade/renderer/geometry/virtual/format/frame/vgeo_encode_frame_blob.js +56 -56
- package/src/shade/renderer/geometry/virtual/format/frame/vgeo_frame_decode_bound.js +35 -35
- package/src/shade/renderer/geometry/virtual/format/frame/vgeo_scan_frames.js +74 -74
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_FORMAT_VERSION.js +6 -6
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_HASH_ALGO_XXH3.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_HEADER_OFFSET.js +31 -31
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_HEADER_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_LEVEL_OFFSET.js +20 -20
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_LEVEL_RECORD_SIZE.js +9 -9
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_MAGIC.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_MIN_READER_VERSION.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/header/VGEO_PAYLOAD_ENCODING_SHADE_MESHLET_V1.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/header/VGeoLevelRecord.js +41 -41
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_GROUP_RECORD_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_MAX_GROUP_CLUSTER_COUNT.js +6 -6
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_METRIC_OFFSET.js +21 -21
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_METRIC_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_NODE_FANOUT.js +9 -9
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_NODE_FLAG_LEAF.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_NODE_OFFSET.js +10 -10
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_NODE_RECORD_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_PAGE_HEADER_SIZE.js +5 -5
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_PAGE_OFFSET.js +16 -16
- package/src/shade/renderer/geometry/virtual/format/payload/VGEO_ENCODING_FLAGS_MASK.js +6 -6
- package/src/shade/renderer/geometry/virtual/format/payload/VGeoEncodedPayload.js +18 -18
- package/src/shade/renderer/geometry/virtual/format/payload/vgeo_encode_cluster_payload.js +200 -200
- package/src/shade/renderer/geometry/virtual/format/payload/vgeo_payload_attribute_offset.js +39 -39
- package/src/shade/renderer/geometry/virtual/format/payload/vgeo_payload_size.js +20 -20
- package/src/shade/renderer/geometry/virtual/format/prototypeVGEOFormatViewer.js +2063 -2063
- package/src/shade/renderer/geometry/virtual/format/vgeo_validate_container.js +1622 -1622
- package/src/shade/renderer/geometry/virtual/format/vgeo_write_container.js +485 -485
- package/src/shade/renderer/gpu_primitive/sort/ffx/graph_radix_sort.js +115 -115
- package/src/shade/renderer/gpu_primitive/sort/one_sweep/verify_radix_sort_one_sweep.js +110 -110
- package/src/shade/renderer/light/environment/octahedral_resample_kernel.js +50 -50
- package/src/shade/renderer/light/environment/octahedral_uv_to_direction.js +30 -30
- package/src/shade/renderer/light/environment/resample_cube_to_octahedral.js +157 -157
- package/src/shade/renderer/light/make_sunlight.js +35 -35
- package/src/shade/renderer/light/model/io/light_record_point.js +39 -39
- package/src/shade/renderer/loader/gltf/GLTF_PRIMITIVE_MODE.js +23 -23
- package/src/shade/renderer/loader/gltf/MESHOPT_COMPRESSION_PLAN.md +793 -793
- package/src/shade/renderer/loader/gltf/ext/GltfBufferViewExtension.js +54 -54
- package/src/shade/renderer/loader/gltf/ext/GltfBufferViewExtensionSet.js +109 -109
- package/src/shade/renderer/loader/gltf/ext/gltf_apply_buffer_view_extensions.js +69 -69
- package/src/shade/renderer/loader/gltf/ext/gltf_buffer_view_extensions.js +22 -22
- package/src/shade/renderer/loader/gltf/ext/gltf_geometry_extensions.js +39 -39
- package/src/shade/renderer/loader/gltf/ext/meshopt/MeshoptBufferViewExtension.js +301 -301
- package/src/shade/renderer/loader/gltf/gltf_component_type.js +223 -223
- package/src/shade/renderer/loader/gltf/gltf_node_world_matrices.js +137 -137
- package/src/shade/renderer/loader/gltf/gltf_parse_container.js +241 -241
- package/src/shade/renderer/loader/gltf/gltf_read_accessor.js +294 -294
- package/src/shade/renderer/loader/gltf/gltf_used_image_indices.js +49 -49
- package/src/shade/renderer/loader/gltf/load_gltf.js +1253 -1253
- package/src/shade/renderer/loader/gltf/tiny-gltf.js +646 -646
- package/src/shade/renderer/loader/usd/UsdError.js +33 -33
- package/src/shade/renderer/loader/usd/UsdExtensionRegistry.js +69 -69
- package/src/shade/renderer/loader/usd/load_usd.js +226 -226
- package/src/shade/renderer/loader/usd/parse_usda.js +931 -931
- package/src/shade/renderer/loader/usd/unpack_usdz.js +106 -106
- package/src/shade/renderer/loader/usd/usd_build_scene.js +658 -658
- package/src/shade/renderer/loader/usd/usd_compose_transform.js +258 -258
- package/src/shade/renderer/loader/usd/usd_decode_image.js +384 -384
- package/src/shade/renderer/loader/usd/usd_lz4.js +182 -182
- package/src/shade/renderer/loader/usd/usd_triangulate.js +159 -159
- package/src/shade/renderer/material/ShadeMaterial.d.ts +2 -2
- package/src/shade/renderer/material/ShadeMaterial.js +2 -2
- package/src/shade/renderer/material/standard/fragment_gbuffer.js +334 -334
- package/src/shade/renderer/material/standard/fragment_gbuffer_vt.js +169 -169
- package/src/shade/renderer/material/standard/material_gbuffer_vertex.js +45 -45
- package/src/shade/renderer/material/standard_material_to_struct.js +23 -23
- package/src/shade/renderer/particles/prototypeParticleSystem.js +450 -450
- package/src/shade/renderer/particles/runtime/spawn_request_encoding.js +52 -52
- package/src/shade/renderer/pool/TransientResourcePool.js +392 -392
- package/src/shade/renderer/postprocess/bloom/bloom_chain_resolution.js +29 -29
- package/src/shade/renderer/postprocess/bloom/graph_bloom_downsample.js +109 -109
- package/src/shade/renderer/postprocess/bloom/graph_postprocess_bloom.js +155 -155
- package/src/shade/renderer/postprocess/cas/shader_ffx_rcas.js +114 -114
- package/src/shade/renderer/postprocess/dof/DOF_AUTOFOCUS_PARAMS_STRUCT.js +25 -25
- package/src/shade/renderer/postprocess/dof/DOF_FOCUS_STATE_STRUCT.js +23 -23
- package/src/shade/renderer/postprocess/dof/DOF_PRESETS.js +27 -27
- package/src/shade/renderer/postprocess/dof/chunk_dof_coc_band_diameter.js +41 -41
- package/src/shade/renderer/postprocess/dof/chunk_dof_coc_band_radius.js +32 -32
- package/src/shade/renderer/postprocess/dof/chunk_dof_coc_coefficient.js +26 -26
- package/src/shade/renderer/postprocess/dof/compute_dof_autofocus_params.js +64 -64
- package/src/shade/renderer/postprocess/dof/compute_dof_uniform.js +54 -54
- package/src/shade/renderer/postprocess/dof/gather/DOF2_CONFIG.js +91 -91
- package/src/shade/renderer/postprocess/dof/gather/DOF2_PRESETS.js +9 -9
- package/src/shade/renderer/postprocess/dof/gather/DOF2_SETTINGS_STRUCT.js +66 -66
- package/src/shade/renderer/postprocess/dof/gather/DOF2_TEXTURE_FORMAT.js +22 -22
- package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.js +292 -292
- package/src/shade/renderer/postprocess/dof/gather/chunk_dof2_coc_to_near_far.js +25 -25
- package/src/shade/renderer/postprocess/dof/gather/chunk_dof2_gather_weight.js +30 -30
- package/src/shade/renderer/postprocess/dof/gather/compute_dof2_uniform.js +54 -54
- package/src/shade/renderer/postprocess/dof/gather/graph_postprocess_dof2.js +194 -194
- package/src/shade/renderer/postprocess/dof/gather/shader_dof2_fill.js +68 -68
- package/src/shade/renderer/postprocess/dof/gather/shader_dof2_gather_far.js +140 -140
- package/src/shade/renderer/postprocess/dof/gather/shader_dof2_gather_near.js +142 -142
- package/src/shade/renderer/postprocess/dof/gather/shader_dof2_recombine.js +99 -99
- package/src/shade/renderer/postprocess/dof/gather/shader_dof2_setup.js +102 -102
- package/src/shade/renderer/postprocess/dof/gather/shader_dof2_tile_dilate.js +75 -75
- package/src/shade/renderer/postprocess/dof/gather/shader_dof2_tile_max.js +73 -73
- package/src/shade/renderer/postprocess/dof/raymarch/DOF_SETTINGS_STRUCT.js +49 -49
- package/src/shade/renderer/postprocess/dof/raymarch/DepthOfField.js +298 -298
- package/src/shade/renderer/postprocess/dof/raymarch/graph_postprocess_dof.js +244 -244
- package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_composite.js +91 -91
- package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_firefly_cleanup.js +61 -61
- package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_prefilter.js +90 -90
- package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.js +267 -267
- package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.js +271 -271
- package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_tile_dilate.js +70 -70
- package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_tile_max.js +72 -72
- package/src/shade/renderer/postprocess/dof/shader_dof_autofocus.js +99 -99
- package/src/shade/renderer/postprocess/gtao/generate_magic_square_noise.js +51 -51
- package/src/shade/renderer/postprocess/motion_blur/MotionBlur.js +56 -56
- package/src/shade/renderer/postprocess/upscale-dither/NOTES.md +78 -78
- package/src/shade/renderer/postprocess/upscale-dither/UpscaleDither.js +95 -95
- package/src/shade/renderer/postprocess/upscale-dither/fragment_shader_upscale_dither.js +204 -204
- package/src/shade/renderer/rasterize/bucket/construct_primitive_state.js +58 -58
- package/src/shade/renderer/rasterize/fast/graph_rasterize_scene_fast.js +230 -230
- package/src/shade/renderer/rasterize/native/graph_rasterize_meshes_alpha_tested.js +278 -278
- package/src/shade/renderer/rasterize/native/oit/chunk_material_side_should_draw.js +26 -26
- package/src/shade/renderer/rasterize/native/oit/shader_oit_resolve_moments_ibl.js +178 -178
- package/src/shade/renderer/rasterize/standard/graph_rasterize_partial_opaque.js +235 -235
- package/src/shade/renderer/rasterize/standard/graph_rasterize_remaining_opaque.js +208 -208
- package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.js +206 -206
- package/src/shade/renderer/scene/DynamicMesh.js +70 -70
- package/src/shade/renderer/scene/DynamicMeshBatch.js +90 -90
- package/src/shade/renderer/scene/GPUSceneContext.js +901 -901
- package/src/shade/renderer/scene/SceneNodeBinding.js +56 -56
- package/src/shade/renderer/scene/SkinnedMesh.js +55 -55
- package/src/shade/renderer/scene/TransformAuthority.js +33 -33
- package/src/shade/renderer/scene/optimization/deduplicate_geometries.js +38 -38
- package/src/shade/renderer/scene/optimization/deduplicate_images.js +93 -93
- package/src/shade/renderer/scene/optimization/geometry/internal/match_refit_validate.js +127 -127
- package/src/shade/renderer/scene/optimization/geometry/internal/match_solve_transform.js +492 -492
- package/src/shade/renderer/scene/optimization/optimize_texture_set.js +81 -81
- package/src/shade/renderer/scene/optimization/source_to_sampler2d.js +21 -21
- package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.js +12 -12
- package/src/shade/renderer/shader/chunk/geometry/quaternion/dual/chunk_dual_quat_transform_point.js +26 -26
- package/src/shade/renderer/shader/chunk/noise/chunk_interleaved_gradient_noise.js +20 -20
- package/src/shade/renderer/shader/chunk/spherical_harmonics/dering/chunk_sh2_dering_optimize_positive.js +61 -61
- package/src/shade/renderer/shader/chunk/texture/chunk_texture_filter_fxaa_lite.js +225 -225
- package/src/shade/renderer/shader/chunk/texture/dither/chunk_dither_color_8bit_gradient_noise.js +25 -25
- package/src/shade/renderer/shadow/map/DirectionalLightShadowmap.js +384 -384
- package/src/shade/renderer/shadow/map/PointLightShadowmap.js +105 -105
- package/src/shade/renderer/shadow/map/SpotLightShadowmap.js +63 -63
- package/src/shade/renderer/shadow/map/TetrahedronPointLightShadowmap.js +89 -89
- package/src/shade/renderer/shadow/map/shadowmap_update_score.js +232 -232
- package/src/shade/renderer/texture/GPUTextureAllocator.js +85 -85
- package/src/shade/renderer/texture/texture_pool_ops.js +171 -171
- package/src/shade/renderer/texture/virtual/PageTableQuadAllocator.js +253 -253
- package/src/shade/renderer/texture/virtual/README.md +276 -276
- package/src/shade/renderer/texture/virtual/VTPageTable.js +330 -330
- package/src/shade/renderer/texture/virtual/VTPhysicalCache.js +349 -349
- package/src/shade/renderer/texture/virtual/VT_CONSTANTS.js +154 -154
- package/src/shade/renderer/texture/virtual/VT_STACK_INFO_STRUCT.js +20 -20
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.js +1276 -1276
- package/src/shade/renderer/texture/virtual/VirtualTextureStack.js +106 -106
- package/src/shade/renderer/texture/virtual/build_chunk_vt_lookup.js +150 -150
- package/src/shade/renderer/texture/virtual/build_shader_vt_feedback.js +232 -232
- package/src/shade/renderer/texture/virtual/chunk_vt_request_key.js +28 -28
- package/src/shade/renderer/texture/virtual/source/VTSourceImage.js +207 -207
- package/src/shade/renderer/texture/virtual/source/VTSourceProcedural.js +135 -135
- package/src/shade/renderer/texture/virtual/source/VTSourceTiled.js +132 -132
- package/src/shade/renderer/water/GPUWaterRenderer.js +167 -167
- package/src/shade/renderer/water/shader_water.js +246 -246
- package/src/shade/renderer/water/water_height_texture_from_sampler.js +56 -56
- package/src/shade/vitest.setup.mjs +89 -89
- package/src/shade/wgsl/validate_wgsl_source.js +316 -316
- package/src/view/controller/controls/NumericIntervalControl.js +90 -90
- package/src/view/controller/controls/Vector2Control.js +83 -83
- package/src/view/controller/controls/Vector3Control.js +90 -90
- package/src/view/elements/Group.js +56 -56
- package/src/view/elements/drawCheckers.js +33 -33
- package/src/view/elements/windrose/WindRoseDiagram.js +369 -369
- package/src/view/graphics/WebGLContextFailureView.js +76 -76
- package/src/view/layout/DockPanel.js +51 -51
- package/src/view/layout/SplitView.js +365 -365
- package/src/view/layout/show_popup_menu.js +81 -81
- package/src/view/minimap/MinimapCanvasView.js +411 -411
- package/src/view/minimap/MinimapImageCache.js +88 -88
- package/src/view/minimap/MinimapMarkerCollection.d.ts +0 -1
- package/src/view/minimap/MinimapMarkerCollection.d.ts.map +1 -1
- package/src/view/minimap/MinimapMarkerCollection.js +180 -180
- package/src/view/minimap/dom/MinimapCameraView.js +206 -206
- package/src/view/minimap/minimap_focus_area.js +97 -97
- package/editor/process/symbolic/SocketsSymbolicDisplay.js +0 -192
- package/src/core/geom/3d/topology/struct/binary/io/moved_tests.txt +0 -37
- package/src/engine/ecs/attachment/Attachment.d.ts +0 -40
- package/src/engine/ecs/attachment/Attachment.d.ts.map +0 -1
- package/src/engine/ecs/attachment/Attachment.js +0 -57
- package/src/engine/ecs/attachment/AttachmentBinding.d.ts +0 -28
- package/src/engine/ecs/attachment/AttachmentBinding.d.ts.map +0 -1
- package/src/engine/ecs/attachment/AttachmentBinding.js +0 -41
- package/src/engine/ecs/attachment/AttachmentSystem.d.ts +0 -61
- package/src/engine/ecs/attachment/AttachmentSystem.d.ts.map +0 -1
- package/src/engine/ecs/attachment/AttachmentSystem.js +0 -307
- package/src/engine/ecs/attachment/BoneAttachmentBinding.d.ts +0 -27
- package/src/engine/ecs/attachment/BoneAttachmentBinding.d.ts.map +0 -1
- package/src/engine/ecs/attachment/BoneAttachmentBinding.js +0 -69
- package/src/engine/ecs/attachment/TransformAttachmentBinding.d.ts +0 -4
- package/src/engine/ecs/attachment/TransformAttachmentBinding.d.ts.map +0 -1
- package/src/engine/ecs/attachment/TransformAttachmentBinding.js +0 -51
- package/src/engine/ecs/sockets/AttachmentSocket.d.ts +0 -32
- package/src/engine/ecs/sockets/AttachmentSocket.d.ts.map +0 -1
- package/src/engine/ecs/sockets/AttachmentSocket.js +0 -60
- package/src/engine/ecs/sockets/AttachmentSocketType.d.ts +0 -6
- package/src/engine/ecs/sockets/AttachmentSocketType.d.ts.map +0 -1
- package/src/engine/ecs/sockets/AttachmentSocketType.js +0 -8
- package/src/engine/ecs/sockets/AttachmentSockets.d.ts +0 -57
- package/src/engine/ecs/sockets/AttachmentSockets.d.ts.map +0 -1
- package/src/engine/ecs/sockets/AttachmentSockets.js +0 -130
- package/src/engine/ecs/sockets/BoneAttachmentSocket.d.ts +0 -29
- package/src/engine/ecs/sockets/BoneAttachmentSocket.d.ts.map +0 -1
- package/src/engine/ecs/sockets/BoneAttachmentSocket.js +0 -56
- package/src/engine/ecs/sockets/serialization/AttachmentSocketsAssetLoader.d.ts +0 -6
- package/src/engine/ecs/sockets/serialization/AttachmentSocketsAssetLoader.d.ts.map +0 -1
- package/src/engine/ecs/sockets/serialization/AttachmentSocketsAssetLoader.js +0 -19
- package/src/shade/renderer/animation/_dump_resolve.d.mts +0 -2
- package/src/shade/renderer/animation/_dump_resolve.d.mts.map +0 -1
- package/src/shade/renderer/animation/_dump_resolve.mjs +0 -5
|
@@ -1,2063 +1,2063 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A debug viewer for the `.vgeo` container.
|
|
3
|
-
*
|
|
4
|
-
* Drop a file onto the page and it is validated, decoded, and drawn — not as an asset, but as the
|
|
5
|
-
* *cut* the container's own metric selects: the clusters a runtime would draw, coloured so the
|
|
6
|
-
* seams between them are visible, with the cluster count on screen.
|
|
7
|
-
*
|
|
8
|
-
* npm run dev
|
|
9
|
-
* http://localhost:9000/index.html?entry=/src/mir-engine/meep/src/shade/renderer/geometry/virtual/format/prototypeVGEOFormatViewer.js
|
|
10
|
-
*
|
|
11
|
-
* `?file=/data/models/stanford/vgeo/bunny/<asset-id>.vgeo` loads one straight away, which is what
|
|
12
|
-
* makes a particular view of a particular asset a bookmark.
|
|
13
|
-
*
|
|
14
|
-
* **The cut is frozen until you ask for a new one.** "Adapt to view" re-runs the traversal at
|
|
15
|
-
* wherever the camera is standing now; everything after that is you flying around a decision taken
|
|
16
|
-
* from somewhere else, which is the only way to see what a cut actually selected. Turn `auto` on to
|
|
17
|
-
* watch it chase the camera instead.
|
|
18
|
-
*
|
|
19
|
-
* Drawing goes through Shade's **direct geometry path** — a {@link DynamicMesh} drawn straight from
|
|
20
|
-
* its attributes, no meshlet encode — because a cut is rebuilt from scratch every time it is
|
|
21
|
-
* adapted, and a meshlet build per adapt would price the tool out of being interactive. It is drawn
|
|
22
|
-
* *opaque* on that path ({@link GPUDynamicMeshRenderer.opaque}), so the depth buffer orders the
|
|
23
|
-
* cut's own triangles: a cut is a solid surface and nothing on the CPU can order one correctly.
|
|
24
|
-
*
|
|
25
|
-
* THROWAWAY, and deliberately self-contained. The container reader below is a *debug* reader: whole
|
|
26
|
-
* file, eager, everything resident. The runtime's is streaming and partial and belongs to M1;
|
|
27
|
-
* nothing here should be mistaken for its shape.
|
|
28
|
-
*
|
|
29
|
-
* @author Alex Goldring
|
|
30
|
-
* @copyright Company Named Limited (c) 2026
|
|
31
|
-
*/
|
|
32
|
-
import { assert } from "../../../../../core/assert.js";
|
|
33
|
-
import { BinaryBuffer } from "../../../../../core/binary/BinaryBuffer.js";
|
|
34
|
-
import { UINT16_MAX } from "../../../../../core/binary/UINT16_MAX.js";
|
|
35
|
-
import {
|
|
36
|
-
decode_octahedron_to_unit
|
|
37
|
-
} from "../../../../../core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js";
|
|
38
|
-
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
39
|
-
import { DEG_TO_RAD } from "../../../../../core/math/DEG_TO_RAD.js";
|
|
40
|
-
import { OrbitalCameraController } from "../../../camera/orbital/index.js";
|
|
41
|
-
import { PerspectiveCamera } from "../../../camera/PerspectiveCamera.js";
|
|
42
|
-
import { create_frame_loop } from "../../../create_frame_loop.js";
|
|
43
|
-
import { DEFAULT_DEPTH_TEXTURE_VIEW } from "../../../depth/DEFAULT_DEPTH_TEXTURE_VIEW.js";
|
|
44
|
-
import { DEPTH_BACKGROUND_VALUE } from "../../../depth/DEPTH_BACKGROUND_VALUE.js";
|
|
45
|
-
import { GPUDynamicMeshRenderer } from "../../../dynamic/GPUDynamicMeshRenderer.js";
|
|
46
|
-
import { make_sunlight } from "../../../light/make_sunlight.js";
|
|
47
|
-
import { FramePhase } from "../../../extension/FramePhase.js";
|
|
48
|
-
import { RenderExtension } from "../../../extension/RenderExtension.js";
|
|
49
|
-
import { SceneColor } from "../../../extension/SceneColor.js";
|
|
50
|
-
import { ViewTextures } from "../../../extension/ViewTextures.js";
|
|
51
|
-
import { Renderer } from "../../../Renderer.js";
|
|
52
|
-
import { DynamicMesh } from "../../../scene/DynamicMesh.js";
|
|
53
|
-
import { DynamicMeshBatch } from "../../../scene/DynamicMeshBatch.js";
|
|
54
|
-
import { Scene } from "../../../scene/Scene.js";
|
|
55
|
-
import { Attribute } from "../../Attribute.js";
|
|
56
|
-
import { Geometry } from "../../Geometry.js";
|
|
57
|
-
import { StandardAttributes } from "../../StandardAttributes.js";
|
|
58
|
-
import { VGEO_ATTRIBUTE } from "./attribute/VGEO_ATTRIBUTE.js";
|
|
59
|
-
import { VGEO_ATTRIBUTES } from "./attribute/VGEO_ATTRIBUTES.js";
|
|
60
|
-
import { VGEO_CHILD_OFFSET } from "./frame/VGEO_CHILD_OFFSET.js";
|
|
61
|
-
import { VGEO_CHILD_TABLE_ENTRY_SIZE } from "./frame/VGEO_CHILD_TABLE_ENTRY_SIZE.js";
|
|
62
|
-
import { VGEO_CLUSTER_OFFSET } from "./cluster/VGEO_CLUSTER_OFFSET.js";
|
|
63
|
-
import { VGEO_CLUSTER_RECORD_SIZE } from "./cluster/VGEO_CLUSTER_RECORD_SIZE.js";
|
|
64
|
-
import { vgeo_codec_name } from "./frame/vgeo_codec_name.js";
|
|
65
|
-
import { VGEO_CODEC_LZ4 } from "./frame/VGEO_CODEC_LZ4.js";
|
|
66
|
-
import { VGEO_CODEC_RAW } from "./frame/VGEO_CODEC_RAW.js";
|
|
67
|
-
import { vgeo_decode_frame_blob } from "./frame/vgeo_decode_frame_blob.js";
|
|
68
|
-
import { VGEO_FRAME_HEADER_SIZE } from "./frame/VGEO_FRAME_HEADER_SIZE.js";
|
|
69
|
-
import { vgeo_frame_decode_bound } from "./frame/vgeo_frame_decode_bound.js";
|
|
70
|
-
import { VGEO_GROUP_RECORD_SIZE } from "./page/VGEO_GROUP_RECORD_SIZE.js";
|
|
71
|
-
import { VGEO_HEADER_OFFSET } from "./header/VGEO_HEADER_OFFSET.js";
|
|
72
|
-
import { VGEO_HEADER_SIZE } from "./header/VGEO_HEADER_SIZE.js";
|
|
73
|
-
import { VGEO_LEVEL_OFFSET } from "./header/VGEO_LEVEL_OFFSET.js";
|
|
74
|
-
import { VGEO_LEVEL_RECORD_SIZE } from "./header/VGEO_LEVEL_RECORD_SIZE.js";
|
|
75
|
-
import { VGEO_MAGIC } from "./header/VGEO_MAGIC.js";
|
|
76
|
-
import { VGEO_MAX_CLUSTER_VERTEX_COUNT } from "./cluster/VGEO_MAX_CLUSTER_VERTEX_COUNT.js";
|
|
77
|
-
import { VGEO_NO_CHILD } from "./cluster/VGEO_NO_CHILD.js";
|
|
78
|
-
import { VGEO_PAGE_HEADER_SIZE } from "./page/VGEO_PAGE_HEADER_SIZE.js";
|
|
79
|
-
import { VGEO_PAGE_OFFSET } from "./page/VGEO_PAGE_OFFSET.js";
|
|
80
|
-
import { VGEO_SAME_PAGE } from "./cluster/VGEO_SAME_PAGE.js";
|
|
81
|
-
import { vgeo_scan_frames } from "./frame/vgeo_scan_frames.js";
|
|
82
|
-
import { vgeo_payload_attribute_offset } from "./payload/vgeo_payload_attribute_offset.js";
|
|
83
|
-
import { vgeo_validate_container } from "./vgeo_validate_container.js";
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Everything in the container is little-endian (`VGEO_FORMAT.md` §2).
|
|
87
|
-
* @type {boolean}
|
|
88
|
-
*/
|
|
89
|
-
const LE = true;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The `encoding_flags` bit that says a cluster's normal section holds one constant-compressed word
|
|
93
|
-
* for the whole cluster instead of one per vertex.
|
|
94
|
-
* @type {number}
|
|
95
|
-
*/
|
|
96
|
-
const NORMAL_COMPRESSION_FLAG = VGEO_ATTRIBUTES[VGEO_ATTRIBUTE.NORMAL].compression_flag;
|
|
97
|
-
|
|
98
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
99
|
-
// Reading
|
|
100
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* One page, decoded far enough to traverse.
|
|
104
|
-
*/
|
|
105
|
-
export class VGeoPageView {
|
|
106
|
-
/**
|
|
107
|
-
* Page index, which is also the frame ordinal.
|
|
108
|
-
* @type {number}
|
|
109
|
-
*/
|
|
110
|
-
index = 0;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Byte offset of the decoded page's first byte in {@link VGeoContainer.page_bytes}.
|
|
114
|
-
* @type {number}
|
|
115
|
-
*/
|
|
116
|
-
base = 0;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* The codec its frame stored it under. Informational here — the page is decoded before anything
|
|
120
|
-
* reads it — and worth showing, because it is per page and a file can carry both.
|
|
121
|
-
* @type {number}
|
|
122
|
-
*/
|
|
123
|
-
codec = 0;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Bytes the frame stores, before decoding.
|
|
127
|
-
* @type {number}
|
|
128
|
-
*/
|
|
129
|
-
stored_size = 0;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Bytes the page occupies decoded.
|
|
133
|
-
* @type {number}
|
|
134
|
-
*/
|
|
135
|
-
decoded_size = 0;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @type {number}
|
|
139
|
-
*/
|
|
140
|
-
min_level = 0;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @type {number}
|
|
144
|
-
*/
|
|
145
|
-
max_level = 0;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Absolute byte offset of this page's payload section.
|
|
149
|
-
* @type {number}
|
|
150
|
-
*/
|
|
151
|
-
payload_base = 0;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Id of this page's first cluster in the reader's own flat numbering, which is page order and
|
|
155
|
-
* then cluster-table order. The format has no global cluster id; this exists so the arrays on
|
|
156
|
-
* {@link VGeoContainer} can be indexed by one.
|
|
157
|
-
* @type {number}
|
|
158
|
-
*/
|
|
159
|
-
cluster_base = 0;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @type {number}
|
|
163
|
-
*/
|
|
164
|
-
cluster_count = 0;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* `child_ref -> page index`, read out of the frame's child table.
|
|
168
|
-
* @type {Uint32Array}
|
|
169
|
-
*/
|
|
170
|
-
child_pages = new Uint32Array(0);
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Per group: index of its first cluster within this page.
|
|
174
|
-
* @type {Uint16Array}
|
|
175
|
-
*/
|
|
176
|
-
group_cluster_first = new Uint16Array(0);
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @type {Uint16Array}
|
|
180
|
-
*/
|
|
181
|
-
group_cluster_count = new Uint16Array(0);
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* How many clusters name this group as their child. Zero is what makes a group selectable with
|
|
185
|
-
* nothing above it — the root page's topmost groups, and only those.
|
|
186
|
-
* @type {Uint16Array}
|
|
187
|
-
*/
|
|
188
|
-
group_parent_count = new Uint16Array(0);
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* @type {number}
|
|
192
|
-
*/
|
|
193
|
-
node_count = 0;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* A whole `.vgeo` file, read into the flat form the traversal wants.
|
|
198
|
-
*
|
|
199
|
-
* Clusters are a structure of arrays rather than objects: an asset of any size has hundreds of
|
|
200
|
-
* thousands of them, a cut reads a handful of fields from the ones it visits and nothing at all
|
|
201
|
-
* from the ones it skips, and an object per cluster would cost more than the file does.
|
|
202
|
-
*/
|
|
203
|
-
export class VGeoContainer {
|
|
204
|
-
/**
|
|
205
|
-
* Every page decoded, back to back in page order. Each page's {@link VGeoPageView.base} is an
|
|
206
|
-
* offset into this, and so — through it — is every payload offset a cluster record carries.
|
|
207
|
-
*
|
|
208
|
-
* It is not the file. Under a compressing codec the file does not hold a page's bytes at all,
|
|
209
|
-
* and even under the raw codec the two differ by the frame headers and child tables the decoded
|
|
210
|
-
* image leaves out.
|
|
211
|
-
*
|
|
212
|
-
* @type {Uint8Array}
|
|
213
|
-
*/
|
|
214
|
-
page_bytes = new Uint8Array(0);
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* What the frames store between them, before decoding — the part of the file that is pages.
|
|
218
|
-
* @type {number}
|
|
219
|
-
*/
|
|
220
|
-
stored_page_bytes = 0;
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* `page_bytes.length`, named so a caller does not have to know that.
|
|
224
|
-
* @type {number}
|
|
225
|
-
*/
|
|
226
|
-
decoded_page_bytes = 0;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* @type {number}
|
|
230
|
-
*/
|
|
231
|
-
format_version = 0;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* @type {number}
|
|
235
|
-
*/
|
|
236
|
-
payload_encoding = 0;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Hex, as the 16 asset-id bytes stand in the file.
|
|
240
|
-
* @type {string}
|
|
241
|
-
*/
|
|
242
|
-
asset_id = '';
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* @type {number}
|
|
246
|
-
*/
|
|
247
|
-
source_vertex_count = 0;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* @type {number}
|
|
251
|
-
*/
|
|
252
|
-
source_face_count = 0;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Object-space bounding sphere of the whole geometry: centre xyz then radius.
|
|
256
|
-
* @type {Float32Array}
|
|
257
|
-
*/
|
|
258
|
-
object_sphere = new Float32Array(4);
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* @type {Float32Array}
|
|
262
|
-
*/
|
|
263
|
-
object_bounds = new Float32Array(6);
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* @type {VGeoPageView[]}
|
|
267
|
-
*/
|
|
268
|
-
pages = [];
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* @type {{min_error:number, max_error:number, clusters:number, groups:number, triangles:number}[]}
|
|
272
|
-
*/
|
|
273
|
-
levels = [];
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* @type {number}
|
|
277
|
-
*/
|
|
278
|
-
cluster_count = 0;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* `4 * cluster_count` — the LOD-metric sphere of the step that created each cluster.
|
|
282
|
-
* @type {Float32Array}
|
|
283
|
-
*/
|
|
284
|
-
self_sphere = new Float32Array(0);
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* @type {Float32Array}
|
|
288
|
-
*/
|
|
289
|
-
self_error = new Float32Array(0);
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* @type {Float32Array}
|
|
293
|
-
*/
|
|
294
|
-
parent_error = new Float32Array(0);
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* `4 * cluster_count` — each cluster's own tight sphere, for culling and never for the cut test.
|
|
298
|
-
* @type {Float32Array}
|
|
299
|
-
*/
|
|
300
|
-
bounds_sphere = new Float32Array(0);
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* @type {Uint16Array}
|
|
304
|
-
*/
|
|
305
|
-
child_ref = new Uint16Array(0);
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* @type {Uint16Array}
|
|
309
|
-
*/
|
|
310
|
-
child_group = new Uint16Array(0);
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* @type {Uint32Array}
|
|
314
|
-
*/
|
|
315
|
-
encoding_flags = new Uint32Array(0);
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Offset into the owning page's payload section.
|
|
319
|
-
* @type {Uint32Array}
|
|
320
|
-
*/
|
|
321
|
-
payload_offset = new Uint32Array(0);
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* @type {Uint8Array}
|
|
325
|
-
*/
|
|
326
|
-
vertex_count = new Uint8Array(0);
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* @type {Uint8Array}
|
|
330
|
-
*/
|
|
331
|
-
triangle_count = new Uint8Array(0);
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* @type {Uint32Array}
|
|
335
|
-
*/
|
|
336
|
-
page_of_cluster = new Uint32Array(0);
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Group index within that page, so a colour can be keyed on the residency unit.
|
|
340
|
-
* @type {Uint16Array}
|
|
341
|
-
*/
|
|
342
|
-
group_of_cluster = new Uint16Array(0);
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* How many clusters store a normal per vertex rather than one constant-compressed word for the
|
|
346
|
-
* whole cluster.
|
|
347
|
-
*
|
|
348
|
-
* A source carrying no normals encodes the engine default everywhere, and then `colour by
|
|
349
|
-
* stored normal` comes out one flat colour across the whole model. That is the file's truth and
|
|
350
|
-
* it reads exactly like a broken viewer, so the panel says the number outright.
|
|
351
|
-
*
|
|
352
|
-
* It is not a count of clusters that *have* normals: a cluster whose vertices genuinely all
|
|
353
|
-
* face the same way compresses to one word as well, and a flat surface is not a missing one.
|
|
354
|
-
*
|
|
355
|
-
* @type {number}
|
|
356
|
-
*/
|
|
357
|
-
per_vertex_normal_cluster_count = 0;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* What {@link vgeo_validate_container} made of the file. Empty is the only good answer, and a
|
|
361
|
-
* non-empty one is the most interesting thing this tool can tell you.
|
|
362
|
-
* @type {VGeoDefect[]}
|
|
363
|
-
*/
|
|
364
|
-
defects = [];
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* @param {DataView} view
|
|
369
|
-
* @param {number} offset
|
|
370
|
-
* @returns {string} 16 bytes as hex
|
|
371
|
-
*/
|
|
372
|
-
function read_asset_id(view, offset) {
|
|
373
|
-
let out = '';
|
|
374
|
-
|
|
375
|
-
for (let i = 0; i < 16; i++) {
|
|
376
|
-
out += view.getUint8(offset + i).toString(16).padStart(2, '0');
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return out;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Read a whole `.vgeo` file.
|
|
384
|
-
*
|
|
385
|
-
* Eager and complete, which is the opposite of what the runtime will do and exactly right for a
|
|
386
|
-
* tool whose job is to look at every part of it.
|
|
387
|
-
*
|
|
388
|
-
* @param {ArrayBuffer} array_buffer the complete file
|
|
389
|
-
* @returns {VGeoContainer}
|
|
390
|
-
* @throws {Error} when the bytes are not a `.vgeo` at all, or a page uses a codec this reader has no
|
|
391
|
-
* decoder for — everything softer than that lands in {@link VGeoContainer.defects}
|
|
392
|
-
*/
|
|
393
|
-
export function vgeo_read_container(array_buffer) {
|
|
394
|
-
assert.defined(array_buffer, 'array_buffer');
|
|
395
|
-
|
|
396
|
-
if (array_buffer.byteLength < VGEO_HEADER_SIZE) {
|
|
397
|
-
throw new Error(`file is ${array_buffer.byteLength} bytes, shorter than the header`);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
const view = new DataView(array_buffer);
|
|
401
|
-
|
|
402
|
-
const magic = view.getUint32(VGEO_HEADER_OFFSET.MAGIC, LE);
|
|
403
|
-
|
|
404
|
-
if (magic !== VGEO_MAGIC) {
|
|
405
|
-
throw new Error(
|
|
406
|
-
`not a .vgeo file: magic is 0x${magic.toString(16)}, expected 0x${VGEO_MAGIC.toString(16)}`
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
const result = new VGeoContainer();
|
|
411
|
-
|
|
412
|
-
const file_bytes = new Uint8Array(array_buffer);
|
|
413
|
-
|
|
414
|
-
result.format_version = view.getUint16(VGEO_HEADER_OFFSET.FORMAT_VERSION, LE);
|
|
415
|
-
result.payload_encoding = view.getUint32(VGEO_HEADER_OFFSET.PAYLOAD_ENCODING, LE);
|
|
416
|
-
result.asset_id = read_asset_id(view, VGEO_HEADER_OFFSET.ASSET_ID);
|
|
417
|
-
result.source_vertex_count = Number(view.getBigUint64(VGEO_HEADER_OFFSET.SOURCE_VERTEX_COUNT, LE));
|
|
418
|
-
result.source_face_count = Number(view.getBigUint64(VGEO_HEADER_OFFSET.SOURCE_FACE_COUNT, LE));
|
|
419
|
-
|
|
420
|
-
for (let i = 0; i < 4; i++) {
|
|
421
|
-
result.object_sphere[i] = view.getFloat32(VGEO_HEADER_OFFSET.OBJECT_SPHERE + i * 4, LE);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
for (let i = 0; i < 6; i++) {
|
|
425
|
-
result.object_bounds[i] = view.getFloat32(VGEO_HEADER_OFFSET.OBJECT_BOUNDS + i * 4, LE);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
const level_count = view.getUint8(VGEO_HEADER_OFFSET.LEVEL_COUNT);
|
|
429
|
-
|
|
430
|
-
for (let i = 0; i < level_count; i++) {
|
|
431
|
-
const at = VGEO_HEADER_SIZE + i * VGEO_LEVEL_RECORD_SIZE;
|
|
432
|
-
|
|
433
|
-
result.levels.push({
|
|
434
|
-
min_error: view.getFloat32(at + VGEO_LEVEL_OFFSET.MIN_ERROR, LE),
|
|
435
|
-
max_error: view.getFloat32(at + VGEO_LEVEL_OFFSET.MAX_ERROR, LE),
|
|
436
|
-
clusters: view.getUint32(at + VGEO_LEVEL_OFFSET.CLUSTER_COUNT, LE),
|
|
437
|
-
groups: view.getUint32(at + VGEO_LEVEL_OFFSET.GROUP_COUNT, LE),
|
|
438
|
-
triangles: view.getUint32(at + VGEO_LEVEL_OFFSET.TRIANGLE_COUNT, LE),
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// The frame walk is the format's own, shared with the writer and the validator — a file either
|
|
443
|
-
// of those can scan is a file this can scan.
|
|
444
|
-
const frames = vgeo_scan_frames(BinaryBuffer.fromArrayBuffer(array_buffer));
|
|
445
|
-
|
|
446
|
-
/*
|
|
447
|
-
Every page is decoded up front into one image laid out in page order, and everything below
|
|
448
|
-
addresses that image rather than the file. The runtime does the opposite — one page at a time,
|
|
449
|
-
wherever it has room — but this tool wants all of them at once and wants one address space to
|
|
450
|
-
read them through, and under a compressing codec the file simply does not hold a page's bytes.
|
|
451
|
-
|
|
452
|
-
Both refusals below happen before a byte is allocated. The second matters more than it looks:
|
|
453
|
-
`decoded_size` is four bytes of untrusted file, and honouring one that no block of that length
|
|
454
|
-
could produce turns corruption into an out-of-memory throw.
|
|
455
|
-
*/
|
|
456
|
-
let decoded_total = 0;
|
|
457
|
-
|
|
458
|
-
for (const frame of frames) {
|
|
459
|
-
if (frame.codec !== VGEO_CODEC_RAW && frame.codec !== VGEO_CODEC_LZ4) {
|
|
460
|
-
throw new Error(
|
|
461
|
-
`page ${frame.page_index} uses codec ${frame.codec};`
|
|
462
|
-
+ ` this reader decodes ${VGEO_CODEC_RAW} (raw) and ${VGEO_CODEC_LZ4} (lz4)`
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
if (frame.decoded_size > vgeo_frame_decode_bound(frame.codec, frame.stored_size)) {
|
|
467
|
-
throw new Error(
|
|
468
|
-
`page ${frame.page_index} claims ${frame.decoded_size} decoded bytes,`
|
|
469
|
-
+ ` more than codec ${frame.codec} could produce from ${frame.stored_size} stored`
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
result.stored_page_bytes += frame.stored_size;
|
|
474
|
-
|
|
475
|
-
decoded_total += frame.decoded_size;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
const page_bytes = new Uint8Array(decoded_total);
|
|
479
|
-
|
|
480
|
-
result.page_bytes = page_bytes;
|
|
481
|
-
result.decoded_page_bytes = decoded_total;
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* The decoded pages, addressed a word at a time. A `DataView` has no alignment requirement,
|
|
485
|
-
* which is what a page's fields need: their offsets are the format's, not the browser's.
|
|
486
|
-
* @type {DataView}
|
|
487
|
-
*/
|
|
488
|
-
const page_data = new DataView(page_bytes.buffer, page_bytes.byteOffset, page_bytes.byteLength);
|
|
489
|
-
|
|
490
|
-
let page_cursor = 0;
|
|
491
|
-
let cluster_total = 0;
|
|
492
|
-
|
|
493
|
-
for (const frame of frames) {
|
|
494
|
-
const page = new VGeoPageView();
|
|
495
|
-
|
|
496
|
-
page.index = frame.page_index;
|
|
497
|
-
page.base = page_cursor;
|
|
498
|
-
page.codec = frame.codec;
|
|
499
|
-
page.stored_size = frame.stored_size;
|
|
500
|
-
page.decoded_size = frame.decoded_size;
|
|
501
|
-
|
|
502
|
-
page_cursor = vgeo_decode_frame_blob(page_bytes, page_cursor, file_bytes, frame);
|
|
503
|
-
|
|
504
|
-
// The child table is plaintext inside the frame, never compressed — which is what lets a
|
|
505
|
-
// runtime read fetch ranges without decoding anything. So it is read from the file.
|
|
506
|
-
page.child_pages = new Uint32Array(frame.child_page_count);
|
|
507
|
-
|
|
508
|
-
for (let i = 0; i < frame.child_page_count; i++) {
|
|
509
|
-
const entry = frame.frame_offset
|
|
510
|
-
+ VGEO_FRAME_HEADER_SIZE
|
|
511
|
-
+ i * VGEO_CHILD_TABLE_ENTRY_SIZE;
|
|
512
|
-
|
|
513
|
-
page.child_pages[i] = view.getUint32(entry + VGEO_CHILD_OFFSET.PAGE_INDEX, LE);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
const group_count = page_data.getUint16(page.base + VGEO_PAGE_OFFSET.GROUP_COUNT, LE);
|
|
517
|
-
|
|
518
|
-
page.cluster_count = page_data.getUint16(page.base + VGEO_PAGE_OFFSET.CLUSTER_COUNT, LE);
|
|
519
|
-
page.min_level = page_data.getUint8(page.base + VGEO_PAGE_OFFSET.MIN_LEVEL);
|
|
520
|
-
page.max_level = page_data.getUint8(page.base + VGEO_PAGE_OFFSET.MAX_LEVEL);
|
|
521
|
-
page.node_count = page_data.getUint16(page.base + VGEO_PAGE_OFFSET.NODE_COUNT, LE);
|
|
522
|
-
page.payload_base = page.base
|
|
523
|
-
+ page_data.getUint32(page.base + VGEO_PAGE_OFFSET.PAYLOAD_OFFSET, LE);
|
|
524
|
-
page.cluster_base = cluster_total;
|
|
525
|
-
|
|
526
|
-
page.group_cluster_first = new Uint16Array(group_count);
|
|
527
|
-
page.group_cluster_count = new Uint16Array(group_count);
|
|
528
|
-
page.group_parent_count = new Uint16Array(group_count);
|
|
529
|
-
|
|
530
|
-
for (let i = 0; i < group_count; i++) {
|
|
531
|
-
const record = page.base + VGEO_PAGE_HEADER_SIZE + i * VGEO_GROUP_RECORD_SIZE;
|
|
532
|
-
|
|
533
|
-
page.group_cluster_first[i] = page_data.getUint16(record, LE);
|
|
534
|
-
page.group_cluster_count[i] = page_data.getUint16(record + 2, LE);
|
|
535
|
-
page.group_parent_count[i] = page_data.getUint16(record + 4, LE);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
result.pages.push(page);
|
|
539
|
-
|
|
540
|
-
cluster_total += page.cluster_count;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
result.cluster_count = cluster_total;
|
|
544
|
-
result.self_sphere = new Float32Array(cluster_total * 4);
|
|
545
|
-
result.self_error = new Float32Array(cluster_total);
|
|
546
|
-
result.parent_error = new Float32Array(cluster_total);
|
|
547
|
-
result.bounds_sphere = new Float32Array(cluster_total * 4);
|
|
548
|
-
result.child_ref = new Uint16Array(cluster_total);
|
|
549
|
-
result.child_group = new Uint16Array(cluster_total);
|
|
550
|
-
result.encoding_flags = new Uint32Array(cluster_total);
|
|
551
|
-
result.payload_offset = new Uint32Array(cluster_total);
|
|
552
|
-
result.vertex_count = new Uint8Array(cluster_total);
|
|
553
|
-
result.triangle_count = new Uint8Array(cluster_total);
|
|
554
|
-
result.page_of_cluster = new Uint32Array(cluster_total);
|
|
555
|
-
result.group_of_cluster = new Uint16Array(cluster_total);
|
|
556
|
-
|
|
557
|
-
for (const page of result.pages) {
|
|
558
|
-
const table = page.base
|
|
559
|
-
+ page_data.getUint32(page.base + VGEO_PAGE_OFFSET.CLUSTER_TABLE_OFFSET, LE);
|
|
560
|
-
|
|
561
|
-
for (let i = 0; i < page.cluster_count; i++) {
|
|
562
|
-
const record = table + i * VGEO_CLUSTER_RECORD_SIZE;
|
|
563
|
-
const id = page.cluster_base + i;
|
|
564
|
-
|
|
565
|
-
for (let c = 0; c < 4; c++) {
|
|
566
|
-
result.self_sphere[id * 4 + c] =
|
|
567
|
-
page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.SELF_SPHERE + c * 4, LE);
|
|
568
|
-
result.bounds_sphere[id * 4 + c] =
|
|
569
|
-
page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.BOUNDS_SPHERE + c * 4, LE);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
result.self_error[id] = page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.SELF_ERROR, LE);
|
|
573
|
-
result.parent_error[id] = page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.PARENT_ERROR, LE);
|
|
574
|
-
result.child_ref[id] = page_data.getUint16(record + VGEO_CLUSTER_OFFSET.CHILD_REF, LE);
|
|
575
|
-
result.child_group[id] = page_data.getUint16(record + VGEO_CLUSTER_OFFSET.CHILD_GROUP, LE);
|
|
576
|
-
result.encoding_flags[id] =
|
|
577
|
-
page_data.getUint32(record + VGEO_CLUSTER_OFFSET.ENCODING_FLAGS, LE);
|
|
578
|
-
result.payload_offset[id] =
|
|
579
|
-
page_data.getUint32(record + VGEO_CLUSTER_OFFSET.PAYLOAD_OFFSET, LE);
|
|
580
|
-
result.vertex_count[id] = page_data.getUint8(record + VGEO_CLUSTER_OFFSET.VERTEX_COUNT);
|
|
581
|
-
result.triangle_count[id] = page_data.getUint8(record + VGEO_CLUSTER_OFFSET.TRIANGLE_COUNT);
|
|
582
|
-
result.page_of_cluster[id] = page.index;
|
|
583
|
-
|
|
584
|
-
if ((result.encoding_flags[id] & NORMAL_COMPRESSION_FLAG) === 0) {
|
|
585
|
-
result.per_vertex_normal_cluster_count++;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
for (let group = 0; group < page.group_cluster_first.length; group++) {
|
|
590
|
-
const first = page.group_cluster_first[group];
|
|
591
|
-
const count = page.group_cluster_count[group];
|
|
592
|
-
|
|
593
|
-
for (let i = 0; i < count; i++) {
|
|
594
|
-
result.group_of_cluster[page.cluster_base + first + i] = group;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
result.defects = vgeo_validate_container(BinaryBuffer.fromArrayBuffer(array_buffer));
|
|
600
|
-
|
|
601
|
-
return result;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
605
|
-
// The cut
|
|
606
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* The view a cut is selected for. `VIRTUAL_GEOMETRY_DESIGN.md` §4: a cut is selected at one
|
|
610
|
-
* camera's distances and pixel budget, and is the wrong cut for any other.
|
|
611
|
-
*/
|
|
612
|
-
export class VGeoCutView {
|
|
613
|
-
/**
|
|
614
|
-
* Camera position, object space — the viewer draws at identity, so world and object agree.
|
|
615
|
-
* @type {Float32Array}
|
|
616
|
-
*/
|
|
617
|
-
eye = new Float32Array(3);
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* Pixels of permitted error. The one quality dial.
|
|
621
|
-
* @type {number}
|
|
622
|
-
*/
|
|
623
|
-
tau = 1;
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Height of the render target, in pixels — the projection's numerator.
|
|
627
|
-
* @type {number}
|
|
628
|
-
*/
|
|
629
|
-
screen_height = 1080;
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* @type {number}
|
|
633
|
-
*/
|
|
634
|
-
fov_y = 60 * DEG_TO_RAD;
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* @type {boolean}
|
|
638
|
-
*/
|
|
639
|
-
cull_enabled = false;
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* Six normalized world-space planes, as {@link Camera.frustum} holds them.
|
|
643
|
-
* @type {Float32Array}
|
|
644
|
-
*/
|
|
645
|
-
frustum = new Float32Array(24);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* What one traversal came to, including what it had to look at to get there.
|
|
650
|
-
*/
|
|
651
|
-
export class VGeoCut {
|
|
652
|
-
/**
|
|
653
|
-
* Selected clusters, by reader id.
|
|
654
|
-
* @type {number[]}
|
|
655
|
-
*/
|
|
656
|
-
clusters = [];
|
|
657
|
-
|
|
658
|
-
/**
|
|
659
|
-
* @type {number}
|
|
660
|
-
*/
|
|
661
|
-
triangle_count = 0;
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* @type {number}
|
|
665
|
-
*/
|
|
666
|
-
vertex_count = 0;
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* @type {number}
|
|
670
|
-
*/
|
|
671
|
-
groups_visited = 0;
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* @type {number}
|
|
675
|
-
*/
|
|
676
|
-
clusters_tested = 0;
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
* Clusters whose subtree the frustum threw away, which is a whole region rather than one
|
|
680
|
-
* cluster — the reason culling belongs in the traversal and not after it.
|
|
681
|
-
* @type {number}
|
|
682
|
-
*/
|
|
683
|
-
culled = 0;
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Distinct pages the traversal had to have resident.
|
|
687
|
-
* @type {number}
|
|
688
|
-
*/
|
|
689
|
-
pages_touched = 0;
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* @type {number}
|
|
693
|
-
*/
|
|
694
|
-
duration_ms = 0;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* `VIRTUAL_GEOMETRY_DESIGN.md` §4: `err_px = r_e · screen_height / (2 · tan(fov_y / 2) · d)`, with
|
|
699
|
-
* `d` the distance to the *closest point* of the sphere.
|
|
700
|
-
*
|
|
701
|
-
* A zero error projects to zero unconditionally — otherwise a leaf, whose error is exactly zero,
|
|
702
|
-
* would become undrawable the moment the camera entered its sphere.
|
|
703
|
-
*
|
|
704
|
-
* @param {number} error object-space `r_e`; `+Infinity` for a root's parent
|
|
705
|
-
* @param {Float32Array} spheres
|
|
706
|
-
* @param {number} base index of the sphere's first component
|
|
707
|
-
* @param {Float32Array} eye
|
|
708
|
-
* @param {number} k `screen_height / (2 · tan(fov_y / 2))`, hoisted out of the loop
|
|
709
|
-
* @returns {number} pixels
|
|
710
|
-
*/
|
|
711
|
-
function project_error(error, spheres, base, eye, k) {
|
|
712
|
-
if (error === 0) {
|
|
713
|
-
return 0;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
const dx = eye[0] - spheres[base];
|
|
717
|
-
const dy = eye[1] - spheres[base + 1];
|
|
718
|
-
const dz = eye[2] - spheres[base + 2];
|
|
719
|
-
|
|
720
|
-
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz) - spheres[base + 3];
|
|
721
|
-
|
|
722
|
-
if (distance <= 0) {
|
|
723
|
-
// camera inside the sphere; the projection is unbounded and the cluster must refine
|
|
724
|
-
return Number.POSITIVE_INFINITY;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
return (error * k) / distance;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* Whether a sphere is entirely outside the frustum.
|
|
732
|
-
*
|
|
733
|
-
* Only the five finite planes are tested. The projection is infinite reverse-Z, so the far plane's
|
|
734
|
-
* row is degenerate and normalizing it produces nothing a test can use.
|
|
735
|
-
*
|
|
736
|
-
* @param {Float32Array} frustum
|
|
737
|
-
* @param {Float32Array} spheres
|
|
738
|
-
* @param {number} base
|
|
739
|
-
* @returns {boolean}
|
|
740
|
-
*/
|
|
741
|
-
function sphere_outside_frustum(frustum, spheres, base) {
|
|
742
|
-
const x = spheres[base];
|
|
743
|
-
const y = spheres[base + 1];
|
|
744
|
-
const z = spheres[base + 2];
|
|
745
|
-
const radius = spheres[base + 3];
|
|
746
|
-
|
|
747
|
-
for (let plane = 0; plane < 5; plane++) {
|
|
748
|
-
const o = plane * 4;
|
|
749
|
-
|
|
750
|
-
const distance = frustum[o] * x + frustum[o + 1] * y + frustum[o + 2] * z + frustum[o + 3];
|
|
751
|
-
|
|
752
|
-
if (distance < -radius) {
|
|
753
|
-
return true;
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
return false;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
/**
|
|
761
|
-
* Select the cut for a view, by descending the page graph.
|
|
762
|
-
*
|
|
763
|
-
* A traversal rather than a flat pass over every cluster, per design §4 — and it gets the cut rule's
|
|
764
|
-
* first half for free. The rule is `project(parent) > τ AND project(self) ≤ τ`; a group is only ever
|
|
765
|
-
* reached by descending *through* the cluster whose step consumed it, and that descent happened
|
|
766
|
-
* precisely because the step projected above τ. Every cluster of a group shares that step's sphere
|
|
767
|
-
* and error, so the parent test is satisfied by the act of arriving.
|
|
768
|
-
*
|
|
769
|
-
* The residency clamp degenerates here: the whole file is in memory, so nothing is ever
|
|
770
|
-
* non-selectable and a leaf is the only reason to stop early.
|
|
771
|
-
*
|
|
772
|
-
* @param {VGeoContainer} container
|
|
773
|
-
* @param {VGeoCutView} view
|
|
774
|
-
* @returns {VGeoCut}
|
|
775
|
-
*/
|
|
776
|
-
export function vgeo_select_cut(container, view) {
|
|
777
|
-
assert.greaterThan(container.pages.length, 0, 'container.pages.length');
|
|
778
|
-
|
|
779
|
-
const started = performance.now();
|
|
780
|
-
|
|
781
|
-
const cut = new VGeoCut();
|
|
782
|
-
|
|
783
|
-
const k = view.screen_height / (2 * Math.tan(view.fov_y * 0.5));
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* Groups already queued, keyed `page · 65536 + group`. A group is referenced by every sibling
|
|
787
|
-
* cluster of the step that consumed it, so without this the traversal would expand it once per
|
|
788
|
-
* parent and the cut would carry duplicates.
|
|
789
|
-
*
|
|
790
|
-
* @type {Set<number>}
|
|
791
|
-
*/
|
|
792
|
-
const queued = new Set();
|
|
793
|
-
|
|
794
|
-
/**
|
|
795
|
-
* @type {Set<number>}
|
|
796
|
-
*/
|
|
797
|
-
const pages = new Set();
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* Page index and group index, interleaved.
|
|
801
|
-
* @type {number[]}
|
|
802
|
-
*/
|
|
803
|
-
const stack = [];
|
|
804
|
-
|
|
805
|
-
const root = container.pages[0];
|
|
806
|
-
|
|
807
|
-
for (let group = 0; group < root.group_parent_count.length; group++) {
|
|
808
|
-
// no cluster anywhere refines into this group, so it is the top of the DAG and selectable
|
|
809
|
-
// with nothing above it
|
|
810
|
-
if (root.group_parent_count[group] === 0) {
|
|
811
|
-
queued.add(group);
|
|
812
|
-
stack.push(0, group);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
while (stack.length > 0) {
|
|
817
|
-
const group = stack.pop();
|
|
818
|
-
const page_index = stack.pop();
|
|
819
|
-
|
|
820
|
-
const page = container.pages[page_index];
|
|
821
|
-
|
|
822
|
-
cut.groups_visited++;
|
|
823
|
-
pages.add(page_index);
|
|
824
|
-
|
|
825
|
-
const first = page.group_cluster_first[group];
|
|
826
|
-
const count = page.group_cluster_count[group];
|
|
827
|
-
|
|
828
|
-
for (let i = 0; i < count; i++) {
|
|
829
|
-
const id = page.cluster_base + first + i;
|
|
830
|
-
|
|
831
|
-
cut.clusters_tested++;
|
|
832
|
-
|
|
833
|
-
/*
|
|
834
|
-
Culling on `self_sphere` rather than on the tight `bounds_sphere`, because this decides
|
|
835
|
-
the subtree as well as the cluster: monotonicity makes a cluster's self sphere contain
|
|
836
|
-
every descendant's geometry, so a self sphere outside the frustum means nothing under
|
|
837
|
-
it can be on screen either.
|
|
838
|
-
*/
|
|
839
|
-
if (view.cull_enabled
|
|
840
|
-
&& sphere_outside_frustum(view.frustum, container.self_sphere, id * 4)) {
|
|
841
|
-
cut.culled++;
|
|
842
|
-
continue;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
const child_ref = container.child_ref[id];
|
|
846
|
-
|
|
847
|
-
const self_px = project_error(
|
|
848
|
-
container.self_error[id], container.self_sphere, id * 4, view.eye, k
|
|
849
|
-
);
|
|
850
|
-
|
|
851
|
-
if (self_px <= view.tau || child_ref === VGEO_NO_CHILD) {
|
|
852
|
-
cut.clusters.push(id);
|
|
853
|
-
cut.triangle_count += container.triangle_count[id];
|
|
854
|
-
cut.vertex_count += container.vertex_count[id];
|
|
855
|
-
continue;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
const child_page = child_ref === VGEO_SAME_PAGE ? page_index : page.child_pages[child_ref];
|
|
859
|
-
const child_group = container.child_group[id];
|
|
860
|
-
|
|
861
|
-
const key = child_page * 65536 + child_group;
|
|
862
|
-
|
|
863
|
-
if (!queued.has(key)) {
|
|
864
|
-
queued.add(key);
|
|
865
|
-
stack.push(child_page, child_group);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
cut.pages_touched = pages.size;
|
|
871
|
-
cut.duration_ms = performance.now() - started;
|
|
872
|
-
|
|
873
|
-
return cut;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
877
|
-
// Turning a cut into drawable geometry
|
|
878
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
879
|
-
|
|
880
|
-
/**
|
|
881
|
-
* What a cluster's colour is keyed on.
|
|
882
|
-
*
|
|
883
|
-
* The two normal modes are not keyed on the cluster at all: they paint every vertex with its own
|
|
884
|
-
* direction, and the cluster boundaries go with it. `stored normal` is the container's own
|
|
885
|
-
* {@link VGEO_ATTRIBUTE.NORMAL}, decoded out of the payload — the only mode that shows an attribute
|
|
886
|
-
* the file carries rather than something derived from it. `geometric normal` is the area-weighted
|
|
887
|
-
* normal of the decoded triangles, which is what every other mode shades with. The pair is the
|
|
888
|
-
* point: they agree where the builder's normals still describe the geometry it shipped, and a
|
|
889
|
-
* source with no normals at all makes the first one flat.
|
|
890
|
-
*
|
|
891
|
-
* @enum {string}
|
|
892
|
-
*/
|
|
893
|
-
export const VGEO_COLOR_MODE = {
|
|
894
|
-
Cluster: 'cluster',
|
|
895
|
-
Group: 'group',
|
|
896
|
-
Page: 'page',
|
|
897
|
-
Error: 'error',
|
|
898
|
-
StoredNormal: 'stored normal',
|
|
899
|
-
GeometricNormal: 'geometric normal',
|
|
900
|
-
};
|
|
901
|
-
|
|
902
|
-
/**
|
|
903
|
-
* Key colours are spread by the golden ratio so that adjacent ids never land on adjacent hues —
|
|
904
|
-
* neighbouring clusters are exactly what has to be told apart.
|
|
905
|
-
* @type {number}
|
|
906
|
-
*/
|
|
907
|
-
const HUE_STEP = 0.6180339887498949;
|
|
908
|
-
|
|
909
|
-
/**
|
|
910
|
-
* @param {number} hue in `[0, 1)`
|
|
911
|
-
* @param {number} saturation
|
|
912
|
-
* @param {number} value
|
|
913
|
-
* @param {Float32Array} out
|
|
914
|
-
* @param {number} offset
|
|
915
|
-
*/
|
|
916
|
-
function hsv_to_rgb(hue, saturation, value, out, offset) {
|
|
917
|
-
const sector = hue * 6;
|
|
918
|
-
const i = Math.floor(sector);
|
|
919
|
-
const f = sector - i;
|
|
920
|
-
|
|
921
|
-
const p = value * (1 - saturation);
|
|
922
|
-
const q = value * (1 - saturation * f);
|
|
923
|
-
const t = value * (1 - saturation * (1 - f));
|
|
924
|
-
|
|
925
|
-
switch (i % 6) {
|
|
926
|
-
case 0:
|
|
927
|
-
out[offset] = value; out[offset + 1] = t; out[offset + 2] = p;
|
|
928
|
-
break;
|
|
929
|
-
case 1:
|
|
930
|
-
out[offset] = q; out[offset + 1] = value; out[offset + 2] = p;
|
|
931
|
-
break;
|
|
932
|
-
case 2:
|
|
933
|
-
out[offset] = p; out[offset + 1] = value; out[offset + 2] = t;
|
|
934
|
-
break;
|
|
935
|
-
case 3:
|
|
936
|
-
out[offset] = p; out[offset + 1] = q; out[offset + 2] = value;
|
|
937
|
-
break;
|
|
938
|
-
case 4:
|
|
939
|
-
out[offset] = t; out[offset + 1] = p; out[offset + 2] = value;
|
|
940
|
-
break;
|
|
941
|
-
default:
|
|
942
|
-
out[offset] = value; out[offset + 1] = p; out[offset + 2] = q;
|
|
943
|
-
break;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
/**
|
|
948
|
-
* Key lights, baked into vertex colour.
|
|
949
|
-
*
|
|
950
|
-
* The direct path carries position and colour per vertex and nothing else — no normal reaches the
|
|
951
|
-
* shader — so shading happens here, once per cut, against normals derived from the decoded
|
|
952
|
-
* triangles. Two opposed lights and a generous ambient, so that no part of the surface is black and
|
|
953
|
-
* every cluster's colour stays readable wherever it faces.
|
|
954
|
-
*
|
|
955
|
-
* @type {number[]}
|
|
956
|
-
*/
|
|
957
|
-
const KEY_LIGHT = [0.35, 0.78, 0.52];
|
|
958
|
-
|
|
959
|
-
/**
|
|
960
|
-
* @type {number[]}
|
|
961
|
-
*/
|
|
962
|
-
const FILL_LIGHT = [-0.55, -0.25, -0.79];
|
|
963
|
-
|
|
964
|
-
/**
|
|
965
|
-
* Ceiling on a baked colour's brightest channel.
|
|
966
|
-
*
|
|
967
|
-
* The pass draws at `AfterTransparency`, so everything it writes still goes through the tonemapper,
|
|
968
|
-
* and the tonemapper desaturates as it approaches white. Pushed to 1.0 the clusters come out pastel
|
|
969
|
-
* and stop being tellable apart, which defeats the only thing the colour is for — so the shading
|
|
970
|
-
* range is deliberately kept below it.
|
|
971
|
-
*
|
|
972
|
-
* @type {number}
|
|
973
|
-
*/
|
|
974
|
-
const COLOR_CEILING = 0.9;
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* One cluster's worth of decoded stored normals, reused across clusters.
|
|
978
|
-
*
|
|
979
|
-
* {@link VGEO_MAX_CLUSTER_VERTEX_COUNT} is the format's ceiling on a cluster and
|
|
980
|
-
* {@link vgeo_validate_container} holds every file to it, so this is never short.
|
|
981
|
-
*
|
|
982
|
-
* @type {Float32Array}
|
|
983
|
-
*/
|
|
984
|
-
const stored_normals = new Float32Array(VGEO_MAX_CLUSTER_VERTEX_COUNT * 3);
|
|
985
|
-
|
|
986
|
-
/**
|
|
987
|
-
* One decoded direction, on its way from the octahedral codec into a caller's array.
|
|
988
|
-
* @type {Float32Array}
|
|
989
|
-
*/
|
|
990
|
-
const scratch_direction = new Float32Array(3);
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* Decode one cluster's stored normal section into unit vectors.
|
|
994
|
-
*
|
|
995
|
-
* The section is one octahedral `u32` per vertex, or a single word for the whole cluster when the
|
|
996
|
-
* encoder found every vertex agreeing — which is also what a source lacking normals encodes to, so
|
|
997
|
-
* the constant case is the ordinary one and not an exception. A stride of zero is what reads it:
|
|
998
|
-
* every vertex fetches the same word, and the loop does not have to know which case it is in.
|
|
999
|
-
*
|
|
1000
|
-
* @param {VGeoContainer} container
|
|
1001
|
-
* @param {DataView} data over the whole file
|
|
1002
|
-
* @param {number} id reader cluster id
|
|
1003
|
-
* @param {Float32Array} out at least `3 * container.vertex_count[id]` long
|
|
1004
|
-
*/
|
|
1005
|
-
function vgeo_read_cluster_normals(container, data, id, out) {
|
|
1006
|
-
const vertex_count = container.vertex_count[id];
|
|
1007
|
-
|
|
1008
|
-
// out is sized for the format's ceiling, so this fires only on a file that already broke it —
|
|
1009
|
-
// and a short write would come out as a handful of quietly wrong colours instead
|
|
1010
|
-
assert.greaterThanOrEqual(out.length, vertex_count * 3, 'out must hold three components per cluster vertex');
|
|
1011
|
-
|
|
1012
|
-
const encoding_flags = container.encoding_flags[id];
|
|
1013
|
-
|
|
1014
|
-
const page = container.pages[container.page_of_cluster[id]];
|
|
1015
|
-
|
|
1016
|
-
const at = page.payload_base
|
|
1017
|
-
+ container.payload_offset[id]
|
|
1018
|
-
+ vgeo_payload_attribute_offset(
|
|
1019
|
-
VGEO_ATTRIBUTE.NORMAL, vertex_count, container.triangle_count[id], encoding_flags
|
|
1020
|
-
);
|
|
1021
|
-
|
|
1022
|
-
const stride = (encoding_flags & NORMAL_COMPRESSION_FLAG) === 0 ? 4 : 0;
|
|
1023
|
-
|
|
1024
|
-
for (let i = 0; i < vertex_count; i++) {
|
|
1025
|
-
const word = data.getUint32(at + i * stride, LE);
|
|
1026
|
-
|
|
1027
|
-
const u = ((word & 0xFFFF) / UINT16_MAX) * 2 - 1;
|
|
1028
|
-
const v = (((word >>> 16) & 0xFFFF) / UINT16_MAX) * 2 - 1;
|
|
1029
|
-
|
|
1030
|
-
decode_octahedron_to_unit(scratch_direction, 0, u, v);
|
|
1031
|
-
|
|
1032
|
-
/*
|
|
1033
|
-
The encoder hands the octahedral codec `(nx, nz, ny)` — Shade's own convention, matched so
|
|
1034
|
-
that a `.vgeo` payload is byte for byte a `MeshletBatch` one — so the decode comes back in
|
|
1035
|
-
that order and has to be put back.
|
|
1036
|
-
*/
|
|
1037
|
-
out[i * 3] = scratch_direction[0];
|
|
1038
|
-
out[i * 3 + 1] = scratch_direction[2];
|
|
1039
|
-
out[i * 3 + 2] = scratch_direction[1];
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
/**
|
|
1044
|
-
* Paint a run of vertices with their own directions and no shading: `rgb = n · 0.5 + 0.5`, scaled
|
|
1045
|
-
* by {@link COLOR_CEILING} for the same reason every other mode is.
|
|
1046
|
-
*
|
|
1047
|
-
* Unlit on purpose. A direction multiplied by how much light it happens to catch is unreadable
|
|
1048
|
-
* exactly where reading it matters — a normal facing away from both lights would come out black,
|
|
1049
|
-
* and black is not a direction.
|
|
1050
|
-
*
|
|
1051
|
-
* The tonemapper still has the last word on what reaches the screen, so this is a direction to be
|
|
1052
|
-
* read and not a value to be measured.
|
|
1053
|
-
*
|
|
1054
|
-
* @param {Float32Array} colors four per vertex
|
|
1055
|
-
* @param {number} first index of the run's first vertex
|
|
1056
|
-
* @param {number} count vertices in the run
|
|
1057
|
-
* @param {Float32Array} directions unit vectors, three components apiece
|
|
1058
|
-
* @param {number} directions_offset index of the run's first component within `directions`
|
|
1059
|
-
*/
|
|
1060
|
-
function paint_directions(colors, first, count, directions, directions_offset) {
|
|
1061
|
-
for (let i = 0; i < count; i++) {
|
|
1062
|
-
const d = directions_offset + i * 3;
|
|
1063
|
-
const o = (first + i) * 4;
|
|
1064
|
-
|
|
1065
|
-
colors[o] = COLOR_CEILING * (directions[d] * 0.5 + 0.5);
|
|
1066
|
-
colors[o + 1] = COLOR_CEILING * (directions[d + 1] * 0.5 + 0.5);
|
|
1067
|
-
colors[o + 2] = COLOR_CEILING * (directions[d + 2] * 0.5 + 0.5);
|
|
1068
|
-
colors[o + 3] = 1;
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
/**
|
|
1073
|
-
* A cut, decoded into one geometry.
|
|
1074
|
-
*
|
|
1075
|
-
* Nothing about it depends on where the camera is: the mesh is drawn solid and the depth buffer
|
|
1076
|
-
* orders it, so the triangle list is uploaded once when the cut is taken and never touched again.
|
|
1077
|
-
*/
|
|
1078
|
-
export class VGeoCutGeometry {
|
|
1079
|
-
/**
|
|
1080
|
-
* Position and colour, indexed by {@link triangles}.
|
|
1081
|
-
* @type {Geometry}
|
|
1082
|
-
*/
|
|
1083
|
-
geometry = new Geometry();
|
|
1084
|
-
|
|
1085
|
-
/**
|
|
1086
|
-
* `3 * triangle_count` — the full triangle list, in cluster order, and the geometry's index.
|
|
1087
|
-
* @type {Uint32Array}
|
|
1088
|
-
*/
|
|
1089
|
-
triangles = new Uint32Array(0);
|
|
1090
|
-
|
|
1091
|
-
/**
|
|
1092
|
-
* @type {number}
|
|
1093
|
-
*/
|
|
1094
|
-
triangle_count = 0;
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
* @type {number}
|
|
1098
|
-
*/
|
|
1099
|
-
vertex_count = 0;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
/**
|
|
1103
|
-
* Decode the selected clusters into one geometry.
|
|
1104
|
-
*
|
|
1105
|
-
* Payloads are `SHADE_MESHLET_V1`'s (format §8): the index section first, three 8-bit local indices
|
|
1106
|
-
* per triangle, then the attribute sections. Position is always read — it is raw float32, never
|
|
1107
|
-
* constant-compressed — and the stored normal section only when a normal display asks for it,
|
|
1108
|
-
* because the direct path carries position and colour per vertex and nowhere to put the rest.
|
|
1109
|
-
*
|
|
1110
|
-
* @param {VGeoContainer} container
|
|
1111
|
-
* @param {VGeoCut} cut
|
|
1112
|
-
* @param {VGEO_COLOR_MODE} color_mode
|
|
1113
|
-
* @returns {VGeoCutGeometry}
|
|
1114
|
-
*/
|
|
1115
|
-
export function vgeo_build_cut_geometry(container, cut, color_mode) {
|
|
1116
|
-
const vertex_count = cut.vertex_count;
|
|
1117
|
-
const triangle_count = cut.triangle_count;
|
|
1118
|
-
|
|
1119
|
-
const positions = new Float32Array(vertex_count * 3);
|
|
1120
|
-
const colors = new Float32Array(vertex_count * 4);
|
|
1121
|
-
const normals = new Float32Array(vertex_count * 3);
|
|
1122
|
-
|
|
1123
|
-
const result = new VGeoCutGeometry();
|
|
1124
|
-
|
|
1125
|
-
result.triangles = new Uint32Array(triangle_count * 3);
|
|
1126
|
-
result.triangle_count = triangle_count;
|
|
1127
|
-
result.vertex_count = vertex_count;
|
|
1128
|
-
|
|
1129
|
-
const bytes = container.page_bytes;
|
|
1130
|
-
const triangles = result.triangles;
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
* The decoded pages, addressed a word at a time. A `DataView` has no alignment requirement,
|
|
1134
|
-
* which is what an encoded attribute word needs: its offset is the format's, not the browser's.
|
|
1135
|
-
* @type {DataView}
|
|
1136
|
-
*/
|
|
1137
|
-
const data = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1138
|
-
|
|
1139
|
-
/*
|
|
1140
|
-
The error ramp spans the *cut's* own errors, not the file's. Normalizing against the coarsest
|
|
1141
|
-
error in the container would be defensible and useless: a fine cut's clusters all sit orders of
|
|
1142
|
-
magnitude below it and the whole model comes out one flat colour. What the question actually is
|
|
1143
|
-
— which parts of this cut settled for more error than the rest — is a question about this cut.
|
|
1144
|
-
*/
|
|
1145
|
-
let error_low = Number.POSITIVE_INFINITY;
|
|
1146
|
-
let error_high = 0;
|
|
1147
|
-
|
|
1148
|
-
for (const id of cut.clusters) {
|
|
1149
|
-
error_low = Math.min(error_low, container.self_error[id]);
|
|
1150
|
-
error_high = Math.max(error_high, container.self_error[id]);
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
const error_span = error_high - error_low;
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
* `[first vertex, first triangle]` of each selected cluster, so colour can be applied per
|
|
1157
|
-
* cluster after the normals are known.
|
|
1158
|
-
* @type {Uint32Array}
|
|
1159
|
-
*/
|
|
1160
|
-
const cluster_vertex_first = new Uint32Array(cut.clusters.length);
|
|
1161
|
-
|
|
1162
|
-
let vertex_cursor = 0;
|
|
1163
|
-
let triangle_cursor = 0;
|
|
1164
|
-
|
|
1165
|
-
for (let c = 0; c < cut.clusters.length; c++) {
|
|
1166
|
-
const id = cut.clusters[c];
|
|
1167
|
-
|
|
1168
|
-
const cluster_vertices = container.vertex_count[id];
|
|
1169
|
-
const cluster_triangles = container.triangle_count[id];
|
|
1170
|
-
|
|
1171
|
-
const page = container.pages[container.page_of_cluster[id]];
|
|
1172
|
-
const payload = page.payload_base + container.payload_offset[id];
|
|
1173
|
-
|
|
1174
|
-
cluster_vertex_first[c] = vertex_cursor;
|
|
1175
|
-
|
|
1176
|
-
const position_at = payload + vgeo_payload_attribute_offset(
|
|
1177
|
-
VGEO_ATTRIBUTE.POSITION,
|
|
1178
|
-
cluster_vertices,
|
|
1179
|
-
cluster_triangles,
|
|
1180
|
-
container.encoding_flags[id]
|
|
1181
|
-
);
|
|
1182
|
-
|
|
1183
|
-
/*
|
|
1184
|
-
Copied out rather than viewed in place: a Float32Array view demands 4-byte alignment
|
|
1185
|
-
against the *file's* buffer, which is a property of where the browser happened to put it
|
|
1186
|
-
and not something the format promises.
|
|
1187
|
-
*/
|
|
1188
|
-
const coordinates = new Float32Array(
|
|
1189
|
-
bytes.slice(position_at, position_at + cluster_vertices * 12).buffer
|
|
1190
|
-
);
|
|
1191
|
-
|
|
1192
|
-
positions.set(coordinates, vertex_cursor * 3);
|
|
1193
|
-
|
|
1194
|
-
for (let i = 0; i < cluster_triangles * 3; i++) {
|
|
1195
|
-
triangles[triangle_cursor * 3 + i] = vertex_cursor + bytes[payload + i];
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
vertex_cursor += cluster_vertices;
|
|
1199
|
-
triangle_cursor += cluster_triangles;
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
assert.equal(vertex_cursor, vertex_count, 'decoded vertices must match the cut');
|
|
1203
|
-
assert.equal(triangle_cursor, triangle_count, 'decoded triangles must match the cut');
|
|
1204
|
-
|
|
1205
|
-
// Area-weighted vertex normals, which is all shading reads. Clusters share no vertices, so
|
|
1206
|
-
// accumulating over the whole list still gives each cluster its own smoothing — the crease that
|
|
1207
|
-
// leaves at a cluster seam is a feature here, not an artefact.
|
|
1208
|
-
for (let t = 0; t < triangle_count; t++) {
|
|
1209
|
-
const a = triangles[t * 3] * 3;
|
|
1210
|
-
const b = triangles[t * 3 + 1] * 3;
|
|
1211
|
-
const c = triangles[t * 3 + 2] * 3;
|
|
1212
|
-
|
|
1213
|
-
const abx = positions[b] - positions[a];
|
|
1214
|
-
const aby = positions[b + 1] - positions[a + 1];
|
|
1215
|
-
const abz = positions[b + 2] - positions[a + 2];
|
|
1216
|
-
|
|
1217
|
-
const acx = positions[c] - positions[a];
|
|
1218
|
-
const acy = positions[c + 1] - positions[a + 1];
|
|
1219
|
-
const acz = positions[c + 2] - positions[a + 2];
|
|
1220
|
-
|
|
1221
|
-
const nx = aby * acz - abz * acy;
|
|
1222
|
-
const ny = abz * acx - abx * acz;
|
|
1223
|
-
const nz = abx * acy - aby * acx;
|
|
1224
|
-
|
|
1225
|
-
normals[a] += nx; normals[a + 1] += ny; normals[a + 2] += nz;
|
|
1226
|
-
normals[b] += nx; normals[b + 1] += ny; normals[b + 2] += nz;
|
|
1227
|
-
normals[c] += nx; normals[c + 1] += ny; normals[c + 2] += nz;
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
// Normalized here rather than where they are read, because two things read them now — the
|
|
1231
|
-
// shading, and `geometric normal` — and a direction is the same direction for both.
|
|
1232
|
-
for (let v = 0; v < vertex_count; v++) {
|
|
1233
|
-
const n = v * 3;
|
|
1234
|
-
|
|
1235
|
-
const length = Math.hypot(normals[n], normals[n + 1], normals[n + 2]);
|
|
1236
|
-
|
|
1237
|
-
// A vertex left with no area around it has no direction to give. Zero shades as ambient and
|
|
1238
|
-
// displays as mid grey, and both say "nothing here" rather than inventing an answer.
|
|
1239
|
-
const scale = length > 0 ? 1 / length : 0;
|
|
1240
|
-
|
|
1241
|
-
normals[n] *= scale;
|
|
1242
|
-
normals[n + 1] *= scale;
|
|
1243
|
-
normals[n + 2] *= scale;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
const tint = new Float32Array(3);
|
|
1247
|
-
|
|
1248
|
-
for (let c = 0; c < cut.clusters.length; c++) {
|
|
1249
|
-
const id = cut.clusters[c];
|
|
1250
|
-
|
|
1251
|
-
const first = cluster_vertex_first[c];
|
|
1252
|
-
const count = container.vertex_count[id];
|
|
1253
|
-
|
|
1254
|
-
if (color_mode === VGEO_COLOR_MODE.StoredNormal) {
|
|
1255
|
-
vgeo_read_cluster_normals(container, data, id, stored_normals);
|
|
1256
|
-
|
|
1257
|
-
paint_directions(colors, first, count, stored_normals, 0);
|
|
1258
|
-
|
|
1259
|
-
continue;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
if (color_mode === VGEO_COLOR_MODE.GeometricNormal) {
|
|
1263
|
-
paint_directions(colors, first, count, normals, first * 3);
|
|
1264
|
-
|
|
1265
|
-
continue;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
let key;
|
|
1269
|
-
|
|
1270
|
-
switch (color_mode) {
|
|
1271
|
-
case VGEO_COLOR_MODE.Group:
|
|
1272
|
-
key = container.page_of_cluster[id] * 65536 + container.group_of_cluster[id];
|
|
1273
|
-
break;
|
|
1274
|
-
case VGEO_COLOR_MODE.Page:
|
|
1275
|
-
key = container.page_of_cluster[id];
|
|
1276
|
-
break;
|
|
1277
|
-
default:
|
|
1278
|
-
key = id;
|
|
1279
|
-
break;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
if (color_mode === VGEO_COLOR_MODE.Error) {
|
|
1283
|
-
// cool where the cut is refined, hot where it settled for the most error
|
|
1284
|
-
const t = error_span > 0 ? (container.self_error[id] - error_low) / error_span : 0;
|
|
1285
|
-
|
|
1286
|
-
hsv_to_rgb(0.68 * (1 - t), 0.9, 1, tint, 0);
|
|
1287
|
-
} else {
|
|
1288
|
-
hsv_to_rgb((key * HUE_STEP) % 1, 0.85, 1, tint, 0);
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
const end = first + count;
|
|
1292
|
-
|
|
1293
|
-
for (let v = first; v < end; v++) {
|
|
1294
|
-
const n = v * 3;
|
|
1295
|
-
|
|
1296
|
-
const nx = normals[n];
|
|
1297
|
-
const ny = normals[n + 1];
|
|
1298
|
-
const nz = normals[n + 2];
|
|
1299
|
-
|
|
1300
|
-
const key_term = Math.max(
|
|
1301
|
-
0, nx * KEY_LIGHT[0] + ny * KEY_LIGHT[1] + nz * KEY_LIGHT[2]
|
|
1302
|
-
);
|
|
1303
|
-
|
|
1304
|
-
const fill_term = Math.max(
|
|
1305
|
-
0, nx * FILL_LIGHT[0] + ny * FILL_LIGHT[1] + nz * FILL_LIGHT[2]
|
|
1306
|
-
);
|
|
1307
|
-
|
|
1308
|
-
const shade = COLOR_CEILING * (0.22 + 0.60 * key_term + 0.18 * fill_term);
|
|
1309
|
-
|
|
1310
|
-
colors[v * 4] = tint[0] * shade;
|
|
1311
|
-
colors[v * 4 + 1] = tint[1] * shade;
|
|
1312
|
-
colors[v * 4 + 2] = tint[2] * shade;
|
|
1313
|
-
colors[v * 4 + 3] = 1;
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
result.geometry.addAttribute(Attribute.from(positions, 3, StandardAttributes.Position));
|
|
1318
|
-
result.geometry.addAttribute(Attribute.from(colors, 4, StandardAttributes.Color));
|
|
1319
|
-
result.geometry.index = Attribute.from(result.triangles, 1, StandardAttributes.Index);
|
|
1320
|
-
|
|
1321
|
-
return result;
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
/**
|
|
1325
|
-
* Clear the frame's depth, so that the cut is the only thing in it.
|
|
1326
|
-
*
|
|
1327
|
-
* **The renderer does not do this when there is nothing to rasterize.** Depth is cleared as a side
|
|
1328
|
-
* effect of drawing the first opaque bucket, and this viewer's `Scene` holds a light and no meshes,
|
|
1329
|
-
* so that draw never happens. The renderer also ping-pongs two depth textures frame to frame — so
|
|
1330
|
-
* left alone, the cut is depth-tested against *its own depth from two frames ago*, and dissolves
|
|
1331
|
-
* into holes wherever the camera has moved since. It reads as missing geometry and it is not.
|
|
1332
|
-
*
|
|
1333
|
-
* A real scene needs none of this and must not have it: the cut has to be occluded by whatever the
|
|
1334
|
-
* scene put in the depth buffer, which is why the draw itself loads rather than clears.
|
|
1335
|
-
*
|
|
1336
|
-
* It runs immediately before the draw rather than at the top of the frame, so everything earlier
|
|
1337
|
-
* that reads depth still sees the previous frame's. With nothing in the scene there is nothing for
|
|
1338
|
-
* those passes to occlude, and the alternative is a second registration on another phase to save a
|
|
1339
|
-
* result that is empty either way.
|
|
1340
|
-
*
|
|
1341
|
-
* @param {FrameGraph} graph
|
|
1342
|
-
* @param {number} depth
|
|
1343
|
-
* @returns {number} the depth handle to draw against
|
|
1344
|
-
*/
|
|
1345
|
-
function vgeo_graph_clear_depth(graph, depth) {
|
|
1346
|
-
const data = {};
|
|
1347
|
-
|
|
1348
|
-
const pass = graph.add('vgeo/clear depth', data, (data, resources, context) => {
|
|
1349
|
-
const texture = resources.get(data.depth);
|
|
1350
|
-
|
|
1351
|
-
// no draws — the clear is the load op, and ending the pass immediately is what performs it
|
|
1352
|
-
context.encoder.beginRenderPass({
|
|
1353
|
-
label: "vgeo/clear depth",
|
|
1354
|
-
colorAttachments: [],
|
|
1355
|
-
depthStencilAttachment: {
|
|
1356
|
-
view: texture.obtainView(DEFAULT_DEPTH_TEXTURE_VIEW),
|
|
1357
|
-
depthLoadOp: "clear",
|
|
1358
|
-
depthStoreOp: "store",
|
|
1359
|
-
depthClearValue: DEPTH_BACKGROUND_VALUE,
|
|
1360
|
-
},
|
|
1361
|
-
}).end();
|
|
1362
|
-
});
|
|
1363
|
-
|
|
1364
|
-
data.depth = pass.write(depth);
|
|
1365
|
-
|
|
1366
|
-
return data.depth;
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
1370
|
-
// Harness
|
|
1371
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
1372
|
-
|
|
1373
|
-
/**
|
|
1374
|
-
* @param {number} value
|
|
1375
|
-
* @returns {string}
|
|
1376
|
-
*/
|
|
1377
|
-
function thousands(value) {
|
|
1378
|
-
return value.toLocaleString('en-US');
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
/**
|
|
1382
|
-
* @param {[string, string][]} entries
|
|
1383
|
-
* @returns {string} one label/value row apiece
|
|
1384
|
-
*/
|
|
1385
|
-
function panel_table(entries) {
|
|
1386
|
-
return entries
|
|
1387
|
-
.map(([key, value]) => `<div class="row"><span class="muted">${key}</span><span>${value}</span></div>`)
|
|
1388
|
-
.join('');
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
/**
|
|
1392
|
-
* @param {number} bytes
|
|
1393
|
-
* @returns {string}
|
|
1394
|
-
*/
|
|
1395
|
-
function human_bytes(bytes) {
|
|
1396
|
-
if (bytes < 1024) {
|
|
1397
|
-
return `${bytes} B`;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
if (bytes < 1024 * 1024) {
|
|
1401
|
-
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
if (bytes < 1024 * 1024 * 1024) {
|
|
1405
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
/**
|
|
1412
|
-
* What the pages cost stored against what they cost decoded, and under which codec.
|
|
1413
|
-
*
|
|
1414
|
-
* Stored is the number that gets fetched and the number that sits on disk; decoded is the number a
|
|
1415
|
-
* resident page costs in RAM. The codec is per frame, so a file can genuinely be a mixture — the
|
|
1416
|
-
* encoder stores a page raw whenever compressing it would not have shrunk it — and naming all of
|
|
1417
|
-
* them is more honest than naming whichever one happened to come first.
|
|
1418
|
-
*
|
|
1419
|
-
* @param {VGeoContainer} container
|
|
1420
|
-
* @returns {string}
|
|
1421
|
-
*/
|
|
1422
|
-
function page_storage(container) {
|
|
1423
|
-
const codec = Array.from(new Set(container.pages.map((page) => page.codec)))
|
|
1424
|
-
.map(vgeo_codec_name)
|
|
1425
|
-
.join(' + ');
|
|
1426
|
-
|
|
1427
|
-
const ratio = container.decoded_page_bytes / Math.max(container.stored_page_bytes, 1);
|
|
1428
|
-
|
|
1429
|
-
return `${human_bytes(container.stored_page_bytes)} stored`
|
|
1430
|
-
+ ` · ${human_bytes(container.decoded_page_bytes)} decoded`
|
|
1431
|
-
+ ` · ${codec} ${ratio.toFixed(2)}x`;
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
const PANEL_CSS = `
|
|
1435
|
-
#vgeo-panel {
|
|
1436
|
-
position: absolute; top: 0; right: 0; width: 340px; max-height: 100vh; overflow-y: auto;
|
|
1437
|
-
padding: 12px 14px; box-sizing: border-box;
|
|
1438
|
-
font: 12px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
1439
|
-
color: #dfe6ee; background: rgba(12, 16, 22, 0.88);
|
|
1440
|
-
border-left: 1px solid #2b3947;
|
|
1441
|
-
}
|
|
1442
|
-
#vgeo-panel h1 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.06em; color: #7fd2ff; }
|
|
1443
|
-
#vgeo-panel h2 {
|
|
1444
|
-
margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
|
|
1445
|
-
color: #6b7c8d; border-bottom: 1px solid #24313d; padding-bottom: 3px;
|
|
1446
|
-
}
|
|
1447
|
-
#vgeo-panel .row { display: flex; justify-content: space-between; gap: 8px; }
|
|
1448
|
-
#vgeo-panel .row span:last-child { color: #f2f6fa; }
|
|
1449
|
-
#vgeo-panel .count { font-size: 30px; line-height: 1.1; color: #8fe388; }
|
|
1450
|
-
#vgeo-panel .muted { color: #6b7c8d; }
|
|
1451
|
-
#vgeo-panel .bad { color: #ff8a7a; }
|
|
1452
|
-
#vgeo-panel .good { color: #8fe388; }
|
|
1453
|
-
#vgeo-panel button {
|
|
1454
|
-
width: 100%; margin: 8px 0 2px; padding: 7px; cursor: pointer;
|
|
1455
|
-
font: inherit; color: #061018; background: #7fd2ff; border: 0; border-radius: 3px;
|
|
1456
|
-
}
|
|
1457
|
-
#vgeo-panel button:hover { background: #a5e0ff; }
|
|
1458
|
-
#vgeo-panel label { display: flex; align-items: center; gap: 6px; margin: 3px 0; cursor: pointer; }
|
|
1459
|
-
#vgeo-panel input[type=range] { width: 100%; }
|
|
1460
|
-
#vgeo-panel select { width: 100%; font: inherit; background: #16202b; color: #dfe6ee; border: 1px solid #2b3947; padding: 3px; }
|
|
1461
|
-
#vgeo-panel ol { margin: 4px 0; padding-left: 18px; }
|
|
1462
|
-
#vgeo-drop {
|
|
1463
|
-
position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
|
|
1464
|
-
font: 20px ui-monospace, monospace; color: #7fd2ff;
|
|
1465
|
-
background: rgba(6, 12, 20, 0.82); border: 3px dashed #7fd2ff; box-sizing: border-box;
|
|
1466
|
-
}
|
|
1467
|
-
#vgeo-drop.active { display: flex; }
|
|
1468
|
-
`;
|
|
1469
|
-
|
|
1470
|
-
/**
|
|
1471
|
-
* The viewer draws its clusters into the scene, at the phase a full-screen effect that should be
|
|
1472
|
-
* tonemapped with the rest of the frame belongs at.
|
|
1473
|
-
*/
|
|
1474
|
-
class VGEOViewerExtension extends RenderExtension {
|
|
1475
|
-
name = "vgeo viewer";
|
|
1476
|
-
|
|
1477
|
-
phase = FramePhase.AfterTransparency;
|
|
1478
|
-
|
|
1479
|
-
/**
|
|
1480
|
-
* @type {VGeoViewer}
|
|
1481
|
-
*/
|
|
1482
|
-
#viewer;
|
|
1483
|
-
|
|
1484
|
-
/**
|
|
1485
|
-
* @param {VGeoViewer} viewer
|
|
1486
|
-
*/
|
|
1487
|
-
constructor(viewer) {
|
|
1488
|
-
super();
|
|
1489
|
-
|
|
1490
|
-
this.#viewer = viewer;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
record(frame) {
|
|
1494
|
-
this.#viewer.record(frame);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
/**
|
|
1499
|
-
* The viewer. One container at a time, one cut at a time, and the cut only changes when asked.
|
|
1500
|
-
*/
|
|
1501
|
-
class VGeoViewer {
|
|
1502
|
-
/**
|
|
1503
|
-
* @type {VGeoContainer|undefined}
|
|
1504
|
-
*/
|
|
1505
|
-
#container = undefined;
|
|
1506
|
-
|
|
1507
|
-
/**
|
|
1508
|
-
* @type {VGeoCutGeometry|undefined}
|
|
1509
|
-
*/
|
|
1510
|
-
#cut_geometry = undefined;
|
|
1511
|
-
|
|
1512
|
-
/**
|
|
1513
|
-
* @type {VGeoCut}
|
|
1514
|
-
*/
|
|
1515
|
-
#cut = new VGeoCut();
|
|
1516
|
-
|
|
1517
|
-
/**
|
|
1518
|
-
* @type {VGeoCutView}
|
|
1519
|
-
*/
|
|
1520
|
-
#view = new VGeoCutView();
|
|
1521
|
-
|
|
1522
|
-
/**
|
|
1523
|
-
* @type {DynamicMeshBatch}
|
|
1524
|
-
*/
|
|
1525
|
-
#batch = new DynamicMeshBatch();
|
|
1526
|
-
|
|
1527
|
-
/**
|
|
1528
|
-
* @type {DynamicMesh|undefined}
|
|
1529
|
-
*/
|
|
1530
|
-
#mesh = undefined;
|
|
1531
|
-
|
|
1532
|
-
/**
|
|
1533
|
-
* A cut is a solid surface, so it is drawn as one: opaque, writing depth, and ordered by the
|
|
1534
|
-
* depth buffer rather than by anything this file does.
|
|
1535
|
-
*
|
|
1536
|
-
* @type {GPUDynamicMeshRenderer}
|
|
1537
|
-
*/
|
|
1538
|
-
#dynamic = new GPUDynamicMeshRenderer();
|
|
1539
|
-
|
|
1540
|
-
/**
|
|
1541
|
-
* Where the camera stood when the current cut was taken, so the panel can say how far you have
|
|
1542
|
-
* wandered from the decision you are looking at.
|
|
1543
|
-
* @type {Float32Array}
|
|
1544
|
-
*/
|
|
1545
|
-
#cut_eye = new Float32Array(3);
|
|
1546
|
-
|
|
1547
|
-
/**
|
|
1548
|
-
* @type {Float32Array}
|
|
1549
|
-
*/
|
|
1550
|
-
#eye = new Float32Array(3);
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
* @type {boolean}
|
|
1554
|
-
*/
|
|
1555
|
-
#auto_adapt = false;
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
* @type {VGEO_COLOR_MODE}
|
|
1559
|
-
*/
|
|
1560
|
-
#color_mode = VGEO_COLOR_MODE.Cluster;
|
|
1561
|
-
|
|
1562
|
-
/**
|
|
1563
|
-
* @type {string}
|
|
1564
|
-
*/
|
|
1565
|
-
#status = 'drop a .vgeo file anywhere on the page';
|
|
1566
|
-
|
|
1567
|
-
/**
|
|
1568
|
-
* @type {string}
|
|
1569
|
-
*/
|
|
1570
|
-
#file_label = '';
|
|
1571
|
-
|
|
1572
|
-
/**
|
|
1573
|
-
* @type {number}
|
|
1574
|
-
*/
|
|
1575
|
-
#file_bytes = 0;
|
|
1576
|
-
|
|
1577
|
-
/**
|
|
1578
|
-
* @type {number}
|
|
1579
|
-
*/
|
|
1580
|
-
#read_ms = 0;
|
|
1581
|
-
|
|
1582
|
-
/**
|
|
1583
|
-
* @type {number}
|
|
1584
|
-
*/
|
|
1585
|
-
#build_ms = 0;
|
|
1586
|
-
|
|
1587
|
-
constructor() {
|
|
1588
|
-
this.canvas = document.createElement('canvas');
|
|
1589
|
-
this.renderer = new Renderer();
|
|
1590
|
-
this.camera = new PerspectiveCamera();
|
|
1591
|
-
this.scene = new Scene();
|
|
1592
|
-
|
|
1593
|
-
this.#dynamic.opaque = true;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
/**
|
|
1597
|
-
* @returns {Promise<void>}
|
|
1598
|
-
*/
|
|
1599
|
-
async start() {
|
|
1600
|
-
document.body.style.margin = '0';
|
|
1601
|
-
document.body.style.overflow = 'hidden';
|
|
1602
|
-
document.body.style.background = '#070b10';
|
|
1603
|
-
|
|
1604
|
-
this.canvas.style.position = 'absolute';
|
|
1605
|
-
this.canvas.style.inset = '0';
|
|
1606
|
-
this.canvas.style.outline = 'none';
|
|
1607
|
-
|
|
1608
|
-
// the orbital controller attaches a KeyboardDevice, and a canvas cannot receive key events
|
|
1609
|
-
// without being focusable
|
|
1610
|
-
this.canvas.tabIndex = 0;
|
|
1611
|
-
|
|
1612
|
-
document.body.appendChild(this.canvas);
|
|
1613
|
-
|
|
1614
|
-
this.canvas.focus();
|
|
1615
|
-
|
|
1616
|
-
await this.renderer.initialize({ context: this.canvas.getContext('webgpu') });
|
|
1617
|
-
|
|
1618
|
-
/*
|
|
1619
|
-
Everything that would move the image for reasons unrelated to the cut is off. Automatic
|
|
1620
|
-
exposure in particular: it adapts to whatever is on screen, so the same cluster would read
|
|
1621
|
-
a different colour depending on how much of the model is in frame, which is exactly the
|
|
1622
|
-
signal this tool is trying to show.
|
|
1623
|
-
*/
|
|
1624
|
-
this.renderer.feature_automatic_exposure_enabled = false;
|
|
1625
|
-
this.renderer.feature_taa_enabled = true;
|
|
1626
|
-
this.renderer.feature_bloom_enabled = false;
|
|
1627
|
-
this.renderer.feature_ssr_enabled = false;
|
|
1628
|
-
this.renderer.feature_ssao_enabled = true;
|
|
1629
|
-
this.renderer.feature_shadows_enabled = false;
|
|
1630
|
-
this.renderer.feature_lpv_enabled = false;
|
|
1631
|
-
this.renderer.pixel_ratio = 1;
|
|
1632
|
-
|
|
1633
|
-
this.scene.lights.add(make_sunlight({ intensity: 3 }));
|
|
1634
|
-
|
|
1635
|
-
this.camera.near = 0.05;
|
|
1636
|
-
this.camera.far = 500;
|
|
1637
|
-
this.camera.fov = 55 * DEG_TO_RAD;
|
|
1638
|
-
this.camera.transform.position.set(0, 0.5, 2);
|
|
1639
|
-
this.camera.transform.lookAt(Vector3.zero);
|
|
1640
|
-
|
|
1641
|
-
this.controller = new OrbitalCameraController(this.camera, this.canvas);
|
|
1642
|
-
this.controller.distanceLimits.min = 1e-4;
|
|
1643
|
-
this.controller.distanceLimits.max = 1e5;
|
|
1644
|
-
|
|
1645
|
-
this.#build_interface();
|
|
1646
|
-
this.#fit_to_window();
|
|
1647
|
-
|
|
1648
|
-
window.addEventListener('resize', () => this.#fit_to_window());
|
|
1649
|
-
|
|
1650
|
-
this.renderer.add_extension(new VGEOViewerExtension(this));
|
|
1651
|
-
|
|
1652
|
-
create_frame_loop((dt) => this.#frame(dt));
|
|
1653
|
-
|
|
1654
|
-
const requested = new URL(window.location.href).searchParams.get('file');
|
|
1655
|
-
|
|
1656
|
-
if (requested !== null) {
|
|
1657
|
-
await this.load_url(requested);
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
|
-
/**
|
|
1662
|
-
* @param {FrameContext} frame
|
|
1663
|
-
*/
|
|
1664
|
-
record(frame) {
|
|
1665
|
-
const graph = frame.graph;
|
|
1666
|
-
const scene = frame.get(SceneColor);
|
|
1667
|
-
|
|
1668
|
-
scene.color = this.#dynamic.graph_draw({
|
|
1669
|
-
graph,
|
|
1670
|
-
batch: this.#batch,
|
|
1671
|
-
color: scene.color,
|
|
1672
|
-
depth: vgeo_graph_clear_depth(graph, frame.get(ViewTextures).depth),
|
|
1673
|
-
camera: frame.view.camera.buffer,
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
#fit_to_window() {
|
|
1678
|
-
const width = window.innerWidth;
|
|
1679
|
-
const height = window.innerHeight;
|
|
1680
|
-
|
|
1681
|
-
this.canvas.width = width;
|
|
1682
|
-
this.canvas.height = height;
|
|
1683
|
-
|
|
1684
|
-
this.renderer.resize(width, height);
|
|
1685
|
-
|
|
1686
|
-
this.camera.aspect = this.renderer.aspect_ratio;
|
|
1687
|
-
|
|
1688
|
-
this.#view.screen_height = height;
|
|
1689
|
-
this.#view.fov_y = this.camera.fov;
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
/**
|
|
1693
|
-
* @param {number} dt seconds
|
|
1694
|
-
*/
|
|
1695
|
-
#frame(dt) {
|
|
1696
|
-
this.controller.update(dt);
|
|
1697
|
-
|
|
1698
|
-
const position = this.camera.transform.position;
|
|
1699
|
-
|
|
1700
|
-
const moved = position.x !== this.#eye[0]
|
|
1701
|
-
|| position.y !== this.#eye[1]
|
|
1702
|
-
|| position.z !== this.#eye[2];
|
|
1703
|
-
|
|
1704
|
-
this.#eye[0] = position.x;
|
|
1705
|
-
this.#eye[1] = position.y;
|
|
1706
|
-
this.#eye[2] = position.z;
|
|
1707
|
-
|
|
1708
|
-
if (moved && this.#auto_adapt) {
|
|
1709
|
-
this.adapt();
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
this.renderer.render(this.camera, this.scene, dt);
|
|
1713
|
-
|
|
1714
|
-
if (moved) {
|
|
1715
|
-
this.#refresh_cut();
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
/**
|
|
1720
|
-
* Re-render the cut readout alone.
|
|
1721
|
-
*
|
|
1722
|
-
* Every number under it moves as the camera does — the drift on every frame, and the whole lot
|
|
1723
|
-
* on every adapt when `follow the camera` is on. Rebuilding the *whole* panel at that rate would
|
|
1724
|
-
* also rebuild the controls, which is how a slider stops being draggable mid-drag; this section
|
|
1725
|
-
* holds no controls, so replacing it is free of that.
|
|
1726
|
-
*/
|
|
1727
|
-
#refresh_cut() {
|
|
1728
|
-
const host = this.panel.querySelector('#vgeo-cut');
|
|
1729
|
-
|
|
1730
|
-
if (host === null) {
|
|
1731
|
-
return;
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
host.innerHTML = this.#cut_html();
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
/**
|
|
1738
|
-
* The cut readout — the cluster count first, because it is the number the tool exists to show.
|
|
1739
|
-
*
|
|
1740
|
-
* @returns {string}
|
|
1741
|
-
*/
|
|
1742
|
-
#cut_html() {
|
|
1743
|
-
const cut = this.#cut;
|
|
1744
|
-
|
|
1745
|
-
return `<div class="count">${thousands(cut.clusters.length)}</div>`
|
|
1746
|
-
+ `<div class="muted" style="margin-bottom:6px">clusters in the current cut</div>`
|
|
1747
|
-
+ panel_table([
|
|
1748
|
-
['triangles', thousands(cut.triangle_count)],
|
|
1749
|
-
['groups', thousands(cut.groups_visited)],
|
|
1750
|
-
['pages resident', thousands(cut.pages_touched)],
|
|
1751
|
-
['clusters tested', thousands(cut.clusters_tested)],
|
|
1752
|
-
['culled subtrees', thousands(cut.culled)],
|
|
1753
|
-
['select / build', `${cut.duration_ms.toFixed(1)} / ${this.#build_ms.toFixed(1)} ms`],
|
|
1754
|
-
['camera drift', `${this.#drift().toExponential(2)} u`],
|
|
1755
|
-
]);
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
/**
|
|
1759
|
-
* How far the camera has moved since the cut on screen was selected.
|
|
1760
|
-
* @returns {number}
|
|
1761
|
-
*/
|
|
1762
|
-
#drift() {
|
|
1763
|
-
return Math.hypot(
|
|
1764
|
-
this.#eye[0] - this.#cut_eye[0],
|
|
1765
|
-
this.#eye[1] - this.#cut_eye[1],
|
|
1766
|
-
this.#eye[2] - this.#cut_eye[2]
|
|
1767
|
-
);
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
/**
|
|
1771
|
-
* Take a fresh cut at wherever the camera is standing, and build the geometry for it.
|
|
1772
|
-
*/
|
|
1773
|
-
adapt() {
|
|
1774
|
-
if (this.#container === undefined) {
|
|
1775
|
-
return;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
// the frustum is derived from matrices the renderer refreshes during its own frame, and an
|
|
1779
|
-
// adapt can land before one has run — a cut culled against last frame's planes would be a
|
|
1780
|
-
// silent, hard-to-see wrong answer
|
|
1781
|
-
this.camera.update();
|
|
1782
|
-
|
|
1783
|
-
this.#view.eye.set(this.#eye);
|
|
1784
|
-
this.#view.screen_height = this.canvas.height;
|
|
1785
|
-
this.#view.fov_y = this.camera.fov;
|
|
1786
|
-
this.#view.frustum.set(this.camera.frustum);
|
|
1787
|
-
|
|
1788
|
-
this.#cut = vgeo_select_cut(this.#container, this.#view);
|
|
1789
|
-
|
|
1790
|
-
const started = performance.now();
|
|
1791
|
-
|
|
1792
|
-
const previous = this.#cut_geometry;
|
|
1793
|
-
|
|
1794
|
-
this.#cut_geometry = vgeo_build_cut_geometry(this.#container, this.#cut, this.#color_mode);
|
|
1795
|
-
|
|
1796
|
-
this.#build_ms = performance.now() - started;
|
|
1797
|
-
|
|
1798
|
-
this.#batch.clear();
|
|
1799
|
-
|
|
1800
|
-
// Residency is keyed on the geometry and deliberately survives leaving the batch, so the
|
|
1801
|
-
// cut that was just replaced would hold its buffers forever otherwise — and this tool
|
|
1802
|
-
// replaces one on every drag of the tau slider.
|
|
1803
|
-
if (previous !== undefined) {
|
|
1804
|
-
this.#dynamic.release(previous.geometry);
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
this.#mesh = DynamicMesh.from(this.#cut_geometry.geometry);
|
|
1808
|
-
this.#mesh.updateMatrices();
|
|
1809
|
-
|
|
1810
|
-
this.#batch.add(this.#mesh);
|
|
1811
|
-
|
|
1812
|
-
this.#cut_eye.set(this.#eye);
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
/**
|
|
1816
|
-
* @param {ArrayBuffer} array_buffer
|
|
1817
|
-
* @param {string} label
|
|
1818
|
-
*/
|
|
1819
|
-
load(array_buffer, label) {
|
|
1820
|
-
this.#file_label = label;
|
|
1821
|
-
this.#file_bytes = array_buffer.byteLength;
|
|
1822
|
-
|
|
1823
|
-
const started = performance.now();
|
|
1824
|
-
|
|
1825
|
-
try {
|
|
1826
|
-
this.#container = vgeo_read_container(array_buffer);
|
|
1827
|
-
} catch (e) {
|
|
1828
|
-
this.#container = undefined;
|
|
1829
|
-
this.#cut_geometry = undefined;
|
|
1830
|
-
this.#batch.clear();
|
|
1831
|
-
this.#status = String(e.message ?? e);
|
|
1832
|
-
this.#refresh_panel();
|
|
1833
|
-
|
|
1834
|
-
throw e;
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
this.#read_ms = performance.now() - started;
|
|
1838
|
-
this.#status = '';
|
|
1839
|
-
|
|
1840
|
-
this.#frame_camera();
|
|
1841
|
-
this.adapt();
|
|
1842
|
-
this.#refresh_panel();
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
/**
|
|
1846
|
-
* @param {string} url
|
|
1847
|
-
* @returns {Promise<void>}
|
|
1848
|
-
*/
|
|
1849
|
-
async load_url(url) {
|
|
1850
|
-
this.#status = `fetching ${url}`;
|
|
1851
|
-
this.#refresh_panel();
|
|
1852
|
-
|
|
1853
|
-
const response = await fetch(url);
|
|
1854
|
-
|
|
1855
|
-
if (!response.ok) {
|
|
1856
|
-
this.#status = `${url} — HTTP ${response.status}`;
|
|
1857
|
-
this.#refresh_panel();
|
|
1858
|
-
|
|
1859
|
-
return;
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
this.load(await response.arrayBuffer(), url.split('/').pop());
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
/**
|
|
1866
|
-
* Put the camera where the whole asset is on screen, and scale the clip range to it — vgeo
|
|
1867
|
-
* assets are authored at whatever scale the source used, and the Stanford models are a tenth of
|
|
1868
|
-
* a unit across.
|
|
1869
|
-
*/
|
|
1870
|
-
#frame_camera() {
|
|
1871
|
-
const sphere = this.#container.object_sphere;
|
|
1872
|
-
|
|
1873
|
-
const radius = Math.max(sphere[3], 1e-6);
|
|
1874
|
-
const center = new Vector3(sphere[0], sphere[1], sphere[2]);
|
|
1875
|
-
|
|
1876
|
-
const distance = radius / Math.tan(this.camera.fov * 0.5) * 1.15;
|
|
1877
|
-
|
|
1878
|
-
const eye = new Vector3(0.55, 0.42, 0.72);
|
|
1879
|
-
|
|
1880
|
-
eye.normalize();
|
|
1881
|
-
eye.multiplyScalar(distance);
|
|
1882
|
-
eye.add(center);
|
|
1883
|
-
|
|
1884
|
-
this.camera.near = radius * 0.005;
|
|
1885
|
-
this.camera.far = radius * 200;
|
|
1886
|
-
|
|
1887
|
-
this.controller.distanceLimits.min = radius * 0.02;
|
|
1888
|
-
this.controller.distanceLimits.max = radius * 200;
|
|
1889
|
-
this.controller.movement_speed_scale = radius;
|
|
1890
|
-
|
|
1891
|
-
this.controller.look(eye, center);
|
|
1892
|
-
|
|
1893
|
-
this.#eye[0] = eye.x;
|
|
1894
|
-
this.#eye[1] = eye.y;
|
|
1895
|
-
this.#eye[2] = eye.z;
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
#build_interface() {
|
|
1899
|
-
const style = document.createElement('style');
|
|
1900
|
-
|
|
1901
|
-
style.textContent = PANEL_CSS;
|
|
1902
|
-
document.head.appendChild(style);
|
|
1903
|
-
|
|
1904
|
-
const drop = document.createElement('div');
|
|
1905
|
-
|
|
1906
|
-
drop.id = 'vgeo-drop';
|
|
1907
|
-
drop.textContent = 'drop a .vgeo file';
|
|
1908
|
-
document.body.appendChild(drop);
|
|
1909
|
-
|
|
1910
|
-
let drag_depth = 0;
|
|
1911
|
-
|
|
1912
|
-
window.addEventListener('dragenter', (event) => {
|
|
1913
|
-
event.preventDefault();
|
|
1914
|
-
drag_depth++;
|
|
1915
|
-
drop.classList.add('active');
|
|
1916
|
-
});
|
|
1917
|
-
|
|
1918
|
-
window.addEventListener('dragover', (event) => event.preventDefault());
|
|
1919
|
-
|
|
1920
|
-
window.addEventListener('dragleave', () => {
|
|
1921
|
-
drag_depth = Math.max(0, drag_depth - 1);
|
|
1922
|
-
|
|
1923
|
-
if (drag_depth === 0) {
|
|
1924
|
-
drop.classList.remove('active');
|
|
1925
|
-
}
|
|
1926
|
-
});
|
|
1927
|
-
|
|
1928
|
-
window.addEventListener('drop', async (event) => {
|
|
1929
|
-
event.preventDefault();
|
|
1930
|
-
|
|
1931
|
-
drag_depth = 0;
|
|
1932
|
-
drop.classList.remove('active');
|
|
1933
|
-
|
|
1934
|
-
const file = event.dataTransfer.files[0];
|
|
1935
|
-
|
|
1936
|
-
if (file === undefined) {
|
|
1937
|
-
return;
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
|
-
this.#status = `reading ${file.name}`;
|
|
1941
|
-
this.#refresh_panel();
|
|
1942
|
-
|
|
1943
|
-
this.load(await file.arrayBuffer(), file.name);
|
|
1944
|
-
});
|
|
1945
|
-
|
|
1946
|
-
this.panel = document.createElement('div');
|
|
1947
|
-
this.panel.id = 'vgeo-panel';
|
|
1948
|
-
document.body.appendChild(this.panel);
|
|
1949
|
-
|
|
1950
|
-
this.#refresh_panel();
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
/**
|
|
1954
|
-
* @param {string} id
|
|
1955
|
-
* @param {function(HTMLElement): void} bind
|
|
1956
|
-
*/
|
|
1957
|
-
#wire(id, bind) {
|
|
1958
|
-
const element = this.panel.querySelector(`#${id}`);
|
|
1959
|
-
|
|
1960
|
-
if (element !== null) {
|
|
1961
|
-
bind(element);
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
#refresh_panel() {
|
|
1966
|
-
const container = this.#container;
|
|
1967
|
-
|
|
1968
|
-
const header = [`<h1>.vgeo format viewer</h1>`];
|
|
1969
|
-
|
|
1970
|
-
if (this.#status !== '') {
|
|
1971
|
-
header.push(`<div class="muted">${this.#status}</div>`);
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
if (container === undefined) {
|
|
1975
|
-
this.panel.innerHTML = header.join('');
|
|
1976
|
-
|
|
1977
|
-
return;
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
const defects = container.defects;
|
|
1981
|
-
|
|
1982
|
-
const validation = defects.length === 0
|
|
1983
|
-
? `<div class="good">container valid — every invariant holds</div>`
|
|
1984
|
-
: `<div class="bad">${defects.length} defect(s)</div><ol class="bad">${
|
|
1985
|
-
defects.slice(0, 12).map((d) => `<li>${d.toString()}</li>`).join('')
|
|
1986
|
-
}</ol>`;
|
|
1987
|
-
|
|
1988
|
-
const rows = [
|
|
1989
|
-
['file', `${this.#file_label} · ${human_bytes(this.#file_bytes)}`],
|
|
1990
|
-
['pages', page_storage(container)],
|
|
1991
|
-
['format', `v${container.format_version} · encoding ${container.payload_encoding}`],
|
|
1992
|
-
['asset id', container.asset_id.slice(0, 16)],
|
|
1993
|
-
['source', `${thousands(container.source_face_count)} tris / ${thousands(container.source_vertex_count)} verts`],
|
|
1994
|
-
['contents', `${thousands(container.cluster_count)} clusters · ${thousands(container.pages.length)} pages · ${container.levels.length} levels`],
|
|
1995
|
-
['per-vertex normals', `${thousands(container.per_vertex_normal_cluster_count)} / ${thousands(container.cluster_count)} clusters`],
|
|
1996
|
-
['read', `${this.#read_ms.toFixed(1)} ms`],
|
|
1997
|
-
];
|
|
1998
|
-
|
|
1999
|
-
this.panel.innerHTML = header.join('')
|
|
2000
|
-
+ `<h2>container</h2>${panel_table(rows)}`
|
|
2001
|
-
+ `<h2>validation</h2>${validation}`
|
|
2002
|
-
+ `<h2>cut</h2>`
|
|
2003
|
-
+ `<div id="vgeo-cut">${this.#cut_html()}</div>`
|
|
2004
|
-
+ `<h2>selection</h2>`
|
|
2005
|
-
+ `<div class="row"><span class="muted">tau</span><span id="vgeo-tau-value">${this.#view.tau.toFixed(2)} px</span></div>`
|
|
2006
|
-
+ `<input id="vgeo-tau" type="range" min="-1.3" max="1.7" step="0.01" value="${Math.log10(this.#view.tau)}">`
|
|
2007
|
-
+ `<button id="vgeo-adapt">adapt to view</button>`
|
|
2008
|
-
+ `<label><input id="vgeo-auto" type="checkbox" ${this.#auto_adapt ? 'checked' : ''}> follow the camera</label>`
|
|
2009
|
-
+ `<label><input id="vgeo-cull" type="checkbox" ${this.#view.cull_enabled ? 'checked' : ''}> frustum cull while selecting</label>`
|
|
2010
|
-
+ `<h2>display</h2>`
|
|
2011
|
-
+ `<select id="vgeo-color">`
|
|
2012
|
-
+ Object.values(VGEO_COLOR_MODE).map((mode) =>
|
|
2013
|
-
`<option value="${mode}" ${mode === this.#color_mode ? 'selected' : ''}>colour by ${mode}</option>`
|
|
2014
|
-
).join('')
|
|
2015
|
-
+ `</select>`;
|
|
2016
|
-
|
|
2017
|
-
this.#wire('vgeo-adapt', (element) => {
|
|
2018
|
-
element.onclick = () => {
|
|
2019
|
-
this.adapt();
|
|
2020
|
-
this.#refresh_panel();
|
|
2021
|
-
};
|
|
2022
|
-
});
|
|
2023
|
-
|
|
2024
|
-
this.#wire('vgeo-tau', (element) => {
|
|
2025
|
-
element.oninput = () => {
|
|
2026
|
-
this.#view.tau = Math.pow(10, Number(element.value));
|
|
2027
|
-
|
|
2028
|
-
this.adapt();
|
|
2029
|
-
this.#refresh_panel();
|
|
2030
|
-
};
|
|
2031
|
-
});
|
|
2032
|
-
|
|
2033
|
-
this.#wire('vgeo-auto', (element) => {
|
|
2034
|
-
element.onchange = () => {
|
|
2035
|
-
this.#auto_adapt = element.checked;
|
|
2036
|
-
};
|
|
2037
|
-
});
|
|
2038
|
-
|
|
2039
|
-
this.#wire('vgeo-cull', (element) => {
|
|
2040
|
-
element.onchange = () => {
|
|
2041
|
-
this.#view.cull_enabled = element.checked;
|
|
2042
|
-
|
|
2043
|
-
this.adapt();
|
|
2044
|
-
this.#refresh_panel();
|
|
2045
|
-
};
|
|
2046
|
-
});
|
|
2047
|
-
|
|
2048
|
-
this.#wire('vgeo-color', (element) => {
|
|
2049
|
-
element.onchange = () => {
|
|
2050
|
-
this.#color_mode = element.value;
|
|
2051
|
-
|
|
2052
|
-
this.adapt();
|
|
2053
|
-
this.#refresh_panel();
|
|
2054
|
-
};
|
|
2055
|
-
});
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
const viewer = new VGeoViewer();
|
|
2060
|
-
|
|
2061
|
-
window.__vgeo = viewer;
|
|
2062
|
-
|
|
2063
|
-
viewer.start();
|
|
1
|
+
/**
|
|
2
|
+
* A debug viewer for the `.vgeo` container.
|
|
3
|
+
*
|
|
4
|
+
* Drop a file onto the page and it is validated, decoded, and drawn — not as an asset, but as the
|
|
5
|
+
* *cut* the container's own metric selects: the clusters a runtime would draw, coloured so the
|
|
6
|
+
* seams between them are visible, with the cluster count on screen.
|
|
7
|
+
*
|
|
8
|
+
* npm run dev
|
|
9
|
+
* http://localhost:9000/index.html?entry=/src/mir-engine/meep/src/shade/renderer/geometry/virtual/format/prototypeVGEOFormatViewer.js
|
|
10
|
+
*
|
|
11
|
+
* `?file=/data/models/stanford/vgeo/bunny/<asset-id>.vgeo` loads one straight away, which is what
|
|
12
|
+
* makes a particular view of a particular asset a bookmark.
|
|
13
|
+
*
|
|
14
|
+
* **The cut is frozen until you ask for a new one.** "Adapt to view" re-runs the traversal at
|
|
15
|
+
* wherever the camera is standing now; everything after that is you flying around a decision taken
|
|
16
|
+
* from somewhere else, which is the only way to see what a cut actually selected. Turn `auto` on to
|
|
17
|
+
* watch it chase the camera instead.
|
|
18
|
+
*
|
|
19
|
+
* Drawing goes through Shade's **direct geometry path** — a {@link DynamicMesh} drawn straight from
|
|
20
|
+
* its attributes, no meshlet encode — because a cut is rebuilt from scratch every time it is
|
|
21
|
+
* adapted, and a meshlet build per adapt would price the tool out of being interactive. It is drawn
|
|
22
|
+
* *opaque* on that path ({@link GPUDynamicMeshRenderer.opaque}), so the depth buffer orders the
|
|
23
|
+
* cut's own triangles: a cut is a solid surface and nothing on the CPU can order one correctly.
|
|
24
|
+
*
|
|
25
|
+
* THROWAWAY, and deliberately self-contained. The container reader below is a *debug* reader: whole
|
|
26
|
+
* file, eager, everything resident. The runtime's is streaming and partial and belongs to M1;
|
|
27
|
+
* nothing here should be mistaken for its shape.
|
|
28
|
+
*
|
|
29
|
+
* @author Alex Goldring
|
|
30
|
+
* @copyright Company Named Limited (c) 2026
|
|
31
|
+
*/
|
|
32
|
+
import { assert } from "../../../../../core/assert.js";
|
|
33
|
+
import { BinaryBuffer } from "../../../../../core/binary/BinaryBuffer.js";
|
|
34
|
+
import { UINT16_MAX } from "../../../../../core/binary/UINT16_MAX.js";
|
|
35
|
+
import {
|
|
36
|
+
decode_octahedron_to_unit
|
|
37
|
+
} from "../../../../../core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js";
|
|
38
|
+
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
39
|
+
import { DEG_TO_RAD } from "../../../../../core/math/DEG_TO_RAD.js";
|
|
40
|
+
import { OrbitalCameraController } from "../../../camera/orbital/index.js";
|
|
41
|
+
import { PerspectiveCamera } from "../../../camera/PerspectiveCamera.js";
|
|
42
|
+
import { create_frame_loop } from "../../../create_frame_loop.js";
|
|
43
|
+
import { DEFAULT_DEPTH_TEXTURE_VIEW } from "../../../depth/DEFAULT_DEPTH_TEXTURE_VIEW.js";
|
|
44
|
+
import { DEPTH_BACKGROUND_VALUE } from "../../../depth/DEPTH_BACKGROUND_VALUE.js";
|
|
45
|
+
import { GPUDynamicMeshRenderer } from "../../../dynamic/GPUDynamicMeshRenderer.js";
|
|
46
|
+
import { make_sunlight } from "../../../light/make_sunlight.js";
|
|
47
|
+
import { FramePhase } from "../../../extension/FramePhase.js";
|
|
48
|
+
import { RenderExtension } from "../../../extension/RenderExtension.js";
|
|
49
|
+
import { SceneColor } from "../../../extension/SceneColor.js";
|
|
50
|
+
import { ViewTextures } from "../../../extension/ViewTextures.js";
|
|
51
|
+
import { Renderer } from "../../../Renderer.js";
|
|
52
|
+
import { DynamicMesh } from "../../../scene/DynamicMesh.js";
|
|
53
|
+
import { DynamicMeshBatch } from "../../../scene/DynamicMeshBatch.js";
|
|
54
|
+
import { Scene } from "../../../scene/Scene.js";
|
|
55
|
+
import { Attribute } from "../../Attribute.js";
|
|
56
|
+
import { Geometry } from "../../Geometry.js";
|
|
57
|
+
import { StandardAttributes } from "../../StandardAttributes.js";
|
|
58
|
+
import { VGEO_ATTRIBUTE } from "./attribute/VGEO_ATTRIBUTE.js";
|
|
59
|
+
import { VGEO_ATTRIBUTES } from "./attribute/VGEO_ATTRIBUTES.js";
|
|
60
|
+
import { VGEO_CHILD_OFFSET } from "./frame/VGEO_CHILD_OFFSET.js";
|
|
61
|
+
import { VGEO_CHILD_TABLE_ENTRY_SIZE } from "./frame/VGEO_CHILD_TABLE_ENTRY_SIZE.js";
|
|
62
|
+
import { VGEO_CLUSTER_OFFSET } from "./cluster/VGEO_CLUSTER_OFFSET.js";
|
|
63
|
+
import { VGEO_CLUSTER_RECORD_SIZE } from "./cluster/VGEO_CLUSTER_RECORD_SIZE.js";
|
|
64
|
+
import { vgeo_codec_name } from "./frame/vgeo_codec_name.js";
|
|
65
|
+
import { VGEO_CODEC_LZ4 } from "./frame/VGEO_CODEC_LZ4.js";
|
|
66
|
+
import { VGEO_CODEC_RAW } from "./frame/VGEO_CODEC_RAW.js";
|
|
67
|
+
import { vgeo_decode_frame_blob } from "./frame/vgeo_decode_frame_blob.js";
|
|
68
|
+
import { VGEO_FRAME_HEADER_SIZE } from "./frame/VGEO_FRAME_HEADER_SIZE.js";
|
|
69
|
+
import { vgeo_frame_decode_bound } from "./frame/vgeo_frame_decode_bound.js";
|
|
70
|
+
import { VGEO_GROUP_RECORD_SIZE } from "./page/VGEO_GROUP_RECORD_SIZE.js";
|
|
71
|
+
import { VGEO_HEADER_OFFSET } from "./header/VGEO_HEADER_OFFSET.js";
|
|
72
|
+
import { VGEO_HEADER_SIZE } from "./header/VGEO_HEADER_SIZE.js";
|
|
73
|
+
import { VGEO_LEVEL_OFFSET } from "./header/VGEO_LEVEL_OFFSET.js";
|
|
74
|
+
import { VGEO_LEVEL_RECORD_SIZE } from "./header/VGEO_LEVEL_RECORD_SIZE.js";
|
|
75
|
+
import { VGEO_MAGIC } from "./header/VGEO_MAGIC.js";
|
|
76
|
+
import { VGEO_MAX_CLUSTER_VERTEX_COUNT } from "./cluster/VGEO_MAX_CLUSTER_VERTEX_COUNT.js";
|
|
77
|
+
import { VGEO_NO_CHILD } from "./cluster/VGEO_NO_CHILD.js";
|
|
78
|
+
import { VGEO_PAGE_HEADER_SIZE } from "./page/VGEO_PAGE_HEADER_SIZE.js";
|
|
79
|
+
import { VGEO_PAGE_OFFSET } from "./page/VGEO_PAGE_OFFSET.js";
|
|
80
|
+
import { VGEO_SAME_PAGE } from "./cluster/VGEO_SAME_PAGE.js";
|
|
81
|
+
import { vgeo_scan_frames } from "./frame/vgeo_scan_frames.js";
|
|
82
|
+
import { vgeo_payload_attribute_offset } from "./payload/vgeo_payload_attribute_offset.js";
|
|
83
|
+
import { vgeo_validate_container } from "./vgeo_validate_container.js";
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Everything in the container is little-endian (`VGEO_FORMAT.md` §2).
|
|
87
|
+
* @type {boolean}
|
|
88
|
+
*/
|
|
89
|
+
const LE = true;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The `encoding_flags` bit that says a cluster's normal section holds one constant-compressed word
|
|
93
|
+
* for the whole cluster instead of one per vertex.
|
|
94
|
+
* @type {number}
|
|
95
|
+
*/
|
|
96
|
+
const NORMAL_COMPRESSION_FLAG = VGEO_ATTRIBUTES[VGEO_ATTRIBUTE.NORMAL].compression_flag;
|
|
97
|
+
|
|
98
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
99
|
+
// Reading
|
|
100
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* One page, decoded far enough to traverse.
|
|
104
|
+
*/
|
|
105
|
+
export class VGeoPageView {
|
|
106
|
+
/**
|
|
107
|
+
* Page index, which is also the frame ordinal.
|
|
108
|
+
* @type {number}
|
|
109
|
+
*/
|
|
110
|
+
index = 0;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Byte offset of the decoded page's first byte in {@link VGeoContainer.page_bytes}.
|
|
114
|
+
* @type {number}
|
|
115
|
+
*/
|
|
116
|
+
base = 0;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The codec its frame stored it under. Informational here — the page is decoded before anything
|
|
120
|
+
* reads it — and worth showing, because it is per page and a file can carry both.
|
|
121
|
+
* @type {number}
|
|
122
|
+
*/
|
|
123
|
+
codec = 0;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Bytes the frame stores, before decoding.
|
|
127
|
+
* @type {number}
|
|
128
|
+
*/
|
|
129
|
+
stored_size = 0;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Bytes the page occupies decoded.
|
|
133
|
+
* @type {number}
|
|
134
|
+
*/
|
|
135
|
+
decoded_size = 0;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @type {number}
|
|
139
|
+
*/
|
|
140
|
+
min_level = 0;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @type {number}
|
|
144
|
+
*/
|
|
145
|
+
max_level = 0;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Absolute byte offset of this page's payload section.
|
|
149
|
+
* @type {number}
|
|
150
|
+
*/
|
|
151
|
+
payload_base = 0;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Id of this page's first cluster in the reader's own flat numbering, which is page order and
|
|
155
|
+
* then cluster-table order. The format has no global cluster id; this exists so the arrays on
|
|
156
|
+
* {@link VGeoContainer} can be indexed by one.
|
|
157
|
+
* @type {number}
|
|
158
|
+
*/
|
|
159
|
+
cluster_base = 0;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @type {number}
|
|
163
|
+
*/
|
|
164
|
+
cluster_count = 0;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* `child_ref -> page index`, read out of the frame's child table.
|
|
168
|
+
* @type {Uint32Array}
|
|
169
|
+
*/
|
|
170
|
+
child_pages = new Uint32Array(0);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Per group: index of its first cluster within this page.
|
|
174
|
+
* @type {Uint16Array}
|
|
175
|
+
*/
|
|
176
|
+
group_cluster_first = new Uint16Array(0);
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @type {Uint16Array}
|
|
180
|
+
*/
|
|
181
|
+
group_cluster_count = new Uint16Array(0);
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* How many clusters name this group as their child. Zero is what makes a group selectable with
|
|
185
|
+
* nothing above it — the root page's topmost groups, and only those.
|
|
186
|
+
* @type {Uint16Array}
|
|
187
|
+
*/
|
|
188
|
+
group_parent_count = new Uint16Array(0);
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @type {number}
|
|
192
|
+
*/
|
|
193
|
+
node_count = 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A whole `.vgeo` file, read into the flat form the traversal wants.
|
|
198
|
+
*
|
|
199
|
+
* Clusters are a structure of arrays rather than objects: an asset of any size has hundreds of
|
|
200
|
+
* thousands of them, a cut reads a handful of fields from the ones it visits and nothing at all
|
|
201
|
+
* from the ones it skips, and an object per cluster would cost more than the file does.
|
|
202
|
+
*/
|
|
203
|
+
export class VGeoContainer {
|
|
204
|
+
/**
|
|
205
|
+
* Every page decoded, back to back in page order. Each page's {@link VGeoPageView.base} is an
|
|
206
|
+
* offset into this, and so — through it — is every payload offset a cluster record carries.
|
|
207
|
+
*
|
|
208
|
+
* It is not the file. Under a compressing codec the file does not hold a page's bytes at all,
|
|
209
|
+
* and even under the raw codec the two differ by the frame headers and child tables the decoded
|
|
210
|
+
* image leaves out.
|
|
211
|
+
*
|
|
212
|
+
* @type {Uint8Array}
|
|
213
|
+
*/
|
|
214
|
+
page_bytes = new Uint8Array(0);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* What the frames store between them, before decoding — the part of the file that is pages.
|
|
218
|
+
* @type {number}
|
|
219
|
+
*/
|
|
220
|
+
stored_page_bytes = 0;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* `page_bytes.length`, named so a caller does not have to know that.
|
|
224
|
+
* @type {number}
|
|
225
|
+
*/
|
|
226
|
+
decoded_page_bytes = 0;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @type {number}
|
|
230
|
+
*/
|
|
231
|
+
format_version = 0;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @type {number}
|
|
235
|
+
*/
|
|
236
|
+
payload_encoding = 0;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Hex, as the 16 asset-id bytes stand in the file.
|
|
240
|
+
* @type {string}
|
|
241
|
+
*/
|
|
242
|
+
asset_id = '';
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @type {number}
|
|
246
|
+
*/
|
|
247
|
+
source_vertex_count = 0;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @type {number}
|
|
251
|
+
*/
|
|
252
|
+
source_face_count = 0;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Object-space bounding sphere of the whole geometry: centre xyz then radius.
|
|
256
|
+
* @type {Float32Array}
|
|
257
|
+
*/
|
|
258
|
+
object_sphere = new Float32Array(4);
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @type {Float32Array}
|
|
262
|
+
*/
|
|
263
|
+
object_bounds = new Float32Array(6);
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @type {VGeoPageView[]}
|
|
267
|
+
*/
|
|
268
|
+
pages = [];
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @type {{min_error:number, max_error:number, clusters:number, groups:number, triangles:number}[]}
|
|
272
|
+
*/
|
|
273
|
+
levels = [];
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @type {number}
|
|
277
|
+
*/
|
|
278
|
+
cluster_count = 0;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* `4 * cluster_count` — the LOD-metric sphere of the step that created each cluster.
|
|
282
|
+
* @type {Float32Array}
|
|
283
|
+
*/
|
|
284
|
+
self_sphere = new Float32Array(0);
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @type {Float32Array}
|
|
288
|
+
*/
|
|
289
|
+
self_error = new Float32Array(0);
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @type {Float32Array}
|
|
293
|
+
*/
|
|
294
|
+
parent_error = new Float32Array(0);
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* `4 * cluster_count` — each cluster's own tight sphere, for culling and never for the cut test.
|
|
298
|
+
* @type {Float32Array}
|
|
299
|
+
*/
|
|
300
|
+
bounds_sphere = new Float32Array(0);
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @type {Uint16Array}
|
|
304
|
+
*/
|
|
305
|
+
child_ref = new Uint16Array(0);
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @type {Uint16Array}
|
|
309
|
+
*/
|
|
310
|
+
child_group = new Uint16Array(0);
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @type {Uint32Array}
|
|
314
|
+
*/
|
|
315
|
+
encoding_flags = new Uint32Array(0);
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Offset into the owning page's payload section.
|
|
319
|
+
* @type {Uint32Array}
|
|
320
|
+
*/
|
|
321
|
+
payload_offset = new Uint32Array(0);
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* @type {Uint8Array}
|
|
325
|
+
*/
|
|
326
|
+
vertex_count = new Uint8Array(0);
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @type {Uint8Array}
|
|
330
|
+
*/
|
|
331
|
+
triangle_count = new Uint8Array(0);
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @type {Uint32Array}
|
|
335
|
+
*/
|
|
336
|
+
page_of_cluster = new Uint32Array(0);
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Group index within that page, so a colour can be keyed on the residency unit.
|
|
340
|
+
* @type {Uint16Array}
|
|
341
|
+
*/
|
|
342
|
+
group_of_cluster = new Uint16Array(0);
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* How many clusters store a normal per vertex rather than one constant-compressed word for the
|
|
346
|
+
* whole cluster.
|
|
347
|
+
*
|
|
348
|
+
* A source carrying no normals encodes the engine default everywhere, and then `colour by
|
|
349
|
+
* stored normal` comes out one flat colour across the whole model. That is the file's truth and
|
|
350
|
+
* it reads exactly like a broken viewer, so the panel says the number outright.
|
|
351
|
+
*
|
|
352
|
+
* It is not a count of clusters that *have* normals: a cluster whose vertices genuinely all
|
|
353
|
+
* face the same way compresses to one word as well, and a flat surface is not a missing one.
|
|
354
|
+
*
|
|
355
|
+
* @type {number}
|
|
356
|
+
*/
|
|
357
|
+
per_vertex_normal_cluster_count = 0;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* What {@link vgeo_validate_container} made of the file. Empty is the only good answer, and a
|
|
361
|
+
* non-empty one is the most interesting thing this tool can tell you.
|
|
362
|
+
* @type {VGeoDefect[]}
|
|
363
|
+
*/
|
|
364
|
+
defects = [];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* @param {DataView} view
|
|
369
|
+
* @param {number} offset
|
|
370
|
+
* @returns {string} 16 bytes as hex
|
|
371
|
+
*/
|
|
372
|
+
function read_asset_id(view, offset) {
|
|
373
|
+
let out = '';
|
|
374
|
+
|
|
375
|
+
for (let i = 0; i < 16; i++) {
|
|
376
|
+
out += view.getUint8(offset + i).toString(16).padStart(2, '0');
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return out;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Read a whole `.vgeo` file.
|
|
384
|
+
*
|
|
385
|
+
* Eager and complete, which is the opposite of what the runtime will do and exactly right for a
|
|
386
|
+
* tool whose job is to look at every part of it.
|
|
387
|
+
*
|
|
388
|
+
* @param {ArrayBuffer} array_buffer the complete file
|
|
389
|
+
* @returns {VGeoContainer}
|
|
390
|
+
* @throws {Error} when the bytes are not a `.vgeo` at all, or a page uses a codec this reader has no
|
|
391
|
+
* decoder for — everything softer than that lands in {@link VGeoContainer.defects}
|
|
392
|
+
*/
|
|
393
|
+
export function vgeo_read_container(array_buffer) {
|
|
394
|
+
assert.defined(array_buffer, 'array_buffer');
|
|
395
|
+
|
|
396
|
+
if (array_buffer.byteLength < VGEO_HEADER_SIZE) {
|
|
397
|
+
throw new Error(`file is ${array_buffer.byteLength} bytes, shorter than the header`);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const view = new DataView(array_buffer);
|
|
401
|
+
|
|
402
|
+
const magic = view.getUint32(VGEO_HEADER_OFFSET.MAGIC, LE);
|
|
403
|
+
|
|
404
|
+
if (magic !== VGEO_MAGIC) {
|
|
405
|
+
throw new Error(
|
|
406
|
+
`not a .vgeo file: magic is 0x${magic.toString(16)}, expected 0x${VGEO_MAGIC.toString(16)}`
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const result = new VGeoContainer();
|
|
411
|
+
|
|
412
|
+
const file_bytes = new Uint8Array(array_buffer);
|
|
413
|
+
|
|
414
|
+
result.format_version = view.getUint16(VGEO_HEADER_OFFSET.FORMAT_VERSION, LE);
|
|
415
|
+
result.payload_encoding = view.getUint32(VGEO_HEADER_OFFSET.PAYLOAD_ENCODING, LE);
|
|
416
|
+
result.asset_id = read_asset_id(view, VGEO_HEADER_OFFSET.ASSET_ID);
|
|
417
|
+
result.source_vertex_count = Number(view.getBigUint64(VGEO_HEADER_OFFSET.SOURCE_VERTEX_COUNT, LE));
|
|
418
|
+
result.source_face_count = Number(view.getBigUint64(VGEO_HEADER_OFFSET.SOURCE_FACE_COUNT, LE));
|
|
419
|
+
|
|
420
|
+
for (let i = 0; i < 4; i++) {
|
|
421
|
+
result.object_sphere[i] = view.getFloat32(VGEO_HEADER_OFFSET.OBJECT_SPHERE + i * 4, LE);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
for (let i = 0; i < 6; i++) {
|
|
425
|
+
result.object_bounds[i] = view.getFloat32(VGEO_HEADER_OFFSET.OBJECT_BOUNDS + i * 4, LE);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const level_count = view.getUint8(VGEO_HEADER_OFFSET.LEVEL_COUNT);
|
|
429
|
+
|
|
430
|
+
for (let i = 0; i < level_count; i++) {
|
|
431
|
+
const at = VGEO_HEADER_SIZE + i * VGEO_LEVEL_RECORD_SIZE;
|
|
432
|
+
|
|
433
|
+
result.levels.push({
|
|
434
|
+
min_error: view.getFloat32(at + VGEO_LEVEL_OFFSET.MIN_ERROR, LE),
|
|
435
|
+
max_error: view.getFloat32(at + VGEO_LEVEL_OFFSET.MAX_ERROR, LE),
|
|
436
|
+
clusters: view.getUint32(at + VGEO_LEVEL_OFFSET.CLUSTER_COUNT, LE),
|
|
437
|
+
groups: view.getUint32(at + VGEO_LEVEL_OFFSET.GROUP_COUNT, LE),
|
|
438
|
+
triangles: view.getUint32(at + VGEO_LEVEL_OFFSET.TRIANGLE_COUNT, LE),
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// The frame walk is the format's own, shared with the writer and the validator — a file either
|
|
443
|
+
// of those can scan is a file this can scan.
|
|
444
|
+
const frames = vgeo_scan_frames(BinaryBuffer.fromArrayBuffer(array_buffer));
|
|
445
|
+
|
|
446
|
+
/*
|
|
447
|
+
Every page is decoded up front into one image laid out in page order, and everything below
|
|
448
|
+
addresses that image rather than the file. The runtime does the opposite — one page at a time,
|
|
449
|
+
wherever it has room — but this tool wants all of them at once and wants one address space to
|
|
450
|
+
read them through, and under a compressing codec the file simply does not hold a page's bytes.
|
|
451
|
+
|
|
452
|
+
Both refusals below happen before a byte is allocated. The second matters more than it looks:
|
|
453
|
+
`decoded_size` is four bytes of untrusted file, and honouring one that no block of that length
|
|
454
|
+
could produce turns corruption into an out-of-memory throw.
|
|
455
|
+
*/
|
|
456
|
+
let decoded_total = 0;
|
|
457
|
+
|
|
458
|
+
for (const frame of frames) {
|
|
459
|
+
if (frame.codec !== VGEO_CODEC_RAW && frame.codec !== VGEO_CODEC_LZ4) {
|
|
460
|
+
throw new Error(
|
|
461
|
+
`page ${frame.page_index} uses codec ${frame.codec};`
|
|
462
|
+
+ ` this reader decodes ${VGEO_CODEC_RAW} (raw) and ${VGEO_CODEC_LZ4} (lz4)`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (frame.decoded_size > vgeo_frame_decode_bound(frame.codec, frame.stored_size)) {
|
|
467
|
+
throw new Error(
|
|
468
|
+
`page ${frame.page_index} claims ${frame.decoded_size} decoded bytes,`
|
|
469
|
+
+ ` more than codec ${frame.codec} could produce from ${frame.stored_size} stored`
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
result.stored_page_bytes += frame.stored_size;
|
|
474
|
+
|
|
475
|
+
decoded_total += frame.decoded_size;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const page_bytes = new Uint8Array(decoded_total);
|
|
479
|
+
|
|
480
|
+
result.page_bytes = page_bytes;
|
|
481
|
+
result.decoded_page_bytes = decoded_total;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* The decoded pages, addressed a word at a time. A `DataView` has no alignment requirement,
|
|
485
|
+
* which is what a page's fields need: their offsets are the format's, not the browser's.
|
|
486
|
+
* @type {DataView}
|
|
487
|
+
*/
|
|
488
|
+
const page_data = new DataView(page_bytes.buffer, page_bytes.byteOffset, page_bytes.byteLength);
|
|
489
|
+
|
|
490
|
+
let page_cursor = 0;
|
|
491
|
+
let cluster_total = 0;
|
|
492
|
+
|
|
493
|
+
for (const frame of frames) {
|
|
494
|
+
const page = new VGeoPageView();
|
|
495
|
+
|
|
496
|
+
page.index = frame.page_index;
|
|
497
|
+
page.base = page_cursor;
|
|
498
|
+
page.codec = frame.codec;
|
|
499
|
+
page.stored_size = frame.stored_size;
|
|
500
|
+
page.decoded_size = frame.decoded_size;
|
|
501
|
+
|
|
502
|
+
page_cursor = vgeo_decode_frame_blob(page_bytes, page_cursor, file_bytes, frame);
|
|
503
|
+
|
|
504
|
+
// The child table is plaintext inside the frame, never compressed — which is what lets a
|
|
505
|
+
// runtime read fetch ranges without decoding anything. So it is read from the file.
|
|
506
|
+
page.child_pages = new Uint32Array(frame.child_page_count);
|
|
507
|
+
|
|
508
|
+
for (let i = 0; i < frame.child_page_count; i++) {
|
|
509
|
+
const entry = frame.frame_offset
|
|
510
|
+
+ VGEO_FRAME_HEADER_SIZE
|
|
511
|
+
+ i * VGEO_CHILD_TABLE_ENTRY_SIZE;
|
|
512
|
+
|
|
513
|
+
page.child_pages[i] = view.getUint32(entry + VGEO_CHILD_OFFSET.PAGE_INDEX, LE);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const group_count = page_data.getUint16(page.base + VGEO_PAGE_OFFSET.GROUP_COUNT, LE);
|
|
517
|
+
|
|
518
|
+
page.cluster_count = page_data.getUint16(page.base + VGEO_PAGE_OFFSET.CLUSTER_COUNT, LE);
|
|
519
|
+
page.min_level = page_data.getUint8(page.base + VGEO_PAGE_OFFSET.MIN_LEVEL);
|
|
520
|
+
page.max_level = page_data.getUint8(page.base + VGEO_PAGE_OFFSET.MAX_LEVEL);
|
|
521
|
+
page.node_count = page_data.getUint16(page.base + VGEO_PAGE_OFFSET.NODE_COUNT, LE);
|
|
522
|
+
page.payload_base = page.base
|
|
523
|
+
+ page_data.getUint32(page.base + VGEO_PAGE_OFFSET.PAYLOAD_OFFSET, LE);
|
|
524
|
+
page.cluster_base = cluster_total;
|
|
525
|
+
|
|
526
|
+
page.group_cluster_first = new Uint16Array(group_count);
|
|
527
|
+
page.group_cluster_count = new Uint16Array(group_count);
|
|
528
|
+
page.group_parent_count = new Uint16Array(group_count);
|
|
529
|
+
|
|
530
|
+
for (let i = 0; i < group_count; i++) {
|
|
531
|
+
const record = page.base + VGEO_PAGE_HEADER_SIZE + i * VGEO_GROUP_RECORD_SIZE;
|
|
532
|
+
|
|
533
|
+
page.group_cluster_first[i] = page_data.getUint16(record, LE);
|
|
534
|
+
page.group_cluster_count[i] = page_data.getUint16(record + 2, LE);
|
|
535
|
+
page.group_parent_count[i] = page_data.getUint16(record + 4, LE);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
result.pages.push(page);
|
|
539
|
+
|
|
540
|
+
cluster_total += page.cluster_count;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
result.cluster_count = cluster_total;
|
|
544
|
+
result.self_sphere = new Float32Array(cluster_total * 4);
|
|
545
|
+
result.self_error = new Float32Array(cluster_total);
|
|
546
|
+
result.parent_error = new Float32Array(cluster_total);
|
|
547
|
+
result.bounds_sphere = new Float32Array(cluster_total * 4);
|
|
548
|
+
result.child_ref = new Uint16Array(cluster_total);
|
|
549
|
+
result.child_group = new Uint16Array(cluster_total);
|
|
550
|
+
result.encoding_flags = new Uint32Array(cluster_total);
|
|
551
|
+
result.payload_offset = new Uint32Array(cluster_total);
|
|
552
|
+
result.vertex_count = new Uint8Array(cluster_total);
|
|
553
|
+
result.triangle_count = new Uint8Array(cluster_total);
|
|
554
|
+
result.page_of_cluster = new Uint32Array(cluster_total);
|
|
555
|
+
result.group_of_cluster = new Uint16Array(cluster_total);
|
|
556
|
+
|
|
557
|
+
for (const page of result.pages) {
|
|
558
|
+
const table = page.base
|
|
559
|
+
+ page_data.getUint32(page.base + VGEO_PAGE_OFFSET.CLUSTER_TABLE_OFFSET, LE);
|
|
560
|
+
|
|
561
|
+
for (let i = 0; i < page.cluster_count; i++) {
|
|
562
|
+
const record = table + i * VGEO_CLUSTER_RECORD_SIZE;
|
|
563
|
+
const id = page.cluster_base + i;
|
|
564
|
+
|
|
565
|
+
for (let c = 0; c < 4; c++) {
|
|
566
|
+
result.self_sphere[id * 4 + c] =
|
|
567
|
+
page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.SELF_SPHERE + c * 4, LE);
|
|
568
|
+
result.bounds_sphere[id * 4 + c] =
|
|
569
|
+
page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.BOUNDS_SPHERE + c * 4, LE);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
result.self_error[id] = page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.SELF_ERROR, LE);
|
|
573
|
+
result.parent_error[id] = page_data.getFloat32(record + VGEO_CLUSTER_OFFSET.PARENT_ERROR, LE);
|
|
574
|
+
result.child_ref[id] = page_data.getUint16(record + VGEO_CLUSTER_OFFSET.CHILD_REF, LE);
|
|
575
|
+
result.child_group[id] = page_data.getUint16(record + VGEO_CLUSTER_OFFSET.CHILD_GROUP, LE);
|
|
576
|
+
result.encoding_flags[id] =
|
|
577
|
+
page_data.getUint32(record + VGEO_CLUSTER_OFFSET.ENCODING_FLAGS, LE);
|
|
578
|
+
result.payload_offset[id] =
|
|
579
|
+
page_data.getUint32(record + VGEO_CLUSTER_OFFSET.PAYLOAD_OFFSET, LE);
|
|
580
|
+
result.vertex_count[id] = page_data.getUint8(record + VGEO_CLUSTER_OFFSET.VERTEX_COUNT);
|
|
581
|
+
result.triangle_count[id] = page_data.getUint8(record + VGEO_CLUSTER_OFFSET.TRIANGLE_COUNT);
|
|
582
|
+
result.page_of_cluster[id] = page.index;
|
|
583
|
+
|
|
584
|
+
if ((result.encoding_flags[id] & NORMAL_COMPRESSION_FLAG) === 0) {
|
|
585
|
+
result.per_vertex_normal_cluster_count++;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
for (let group = 0; group < page.group_cluster_first.length; group++) {
|
|
590
|
+
const first = page.group_cluster_first[group];
|
|
591
|
+
const count = page.group_cluster_count[group];
|
|
592
|
+
|
|
593
|
+
for (let i = 0; i < count; i++) {
|
|
594
|
+
result.group_of_cluster[page.cluster_base + first + i] = group;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
result.defects = vgeo_validate_container(BinaryBuffer.fromArrayBuffer(array_buffer));
|
|
600
|
+
|
|
601
|
+
return result;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
605
|
+
// The cut
|
|
606
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* The view a cut is selected for. `VIRTUAL_GEOMETRY_DESIGN.md` §4: a cut is selected at one
|
|
610
|
+
* camera's distances and pixel budget, and is the wrong cut for any other.
|
|
611
|
+
*/
|
|
612
|
+
export class VGeoCutView {
|
|
613
|
+
/**
|
|
614
|
+
* Camera position, object space — the viewer draws at identity, so world and object agree.
|
|
615
|
+
* @type {Float32Array}
|
|
616
|
+
*/
|
|
617
|
+
eye = new Float32Array(3);
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Pixels of permitted error. The one quality dial.
|
|
621
|
+
* @type {number}
|
|
622
|
+
*/
|
|
623
|
+
tau = 1;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Height of the render target, in pixels — the projection's numerator.
|
|
627
|
+
* @type {number}
|
|
628
|
+
*/
|
|
629
|
+
screen_height = 1080;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* @type {number}
|
|
633
|
+
*/
|
|
634
|
+
fov_y = 60 * DEG_TO_RAD;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* @type {boolean}
|
|
638
|
+
*/
|
|
639
|
+
cull_enabled = false;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Six normalized world-space planes, as {@link Camera.frustum} holds them.
|
|
643
|
+
* @type {Float32Array}
|
|
644
|
+
*/
|
|
645
|
+
frustum = new Float32Array(24);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* What one traversal came to, including what it had to look at to get there.
|
|
650
|
+
*/
|
|
651
|
+
export class VGeoCut {
|
|
652
|
+
/**
|
|
653
|
+
* Selected clusters, by reader id.
|
|
654
|
+
* @type {number[]}
|
|
655
|
+
*/
|
|
656
|
+
clusters = [];
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* @type {number}
|
|
660
|
+
*/
|
|
661
|
+
triangle_count = 0;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* @type {number}
|
|
665
|
+
*/
|
|
666
|
+
vertex_count = 0;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* @type {number}
|
|
670
|
+
*/
|
|
671
|
+
groups_visited = 0;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* @type {number}
|
|
675
|
+
*/
|
|
676
|
+
clusters_tested = 0;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Clusters whose subtree the frustum threw away, which is a whole region rather than one
|
|
680
|
+
* cluster — the reason culling belongs in the traversal and not after it.
|
|
681
|
+
* @type {number}
|
|
682
|
+
*/
|
|
683
|
+
culled = 0;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Distinct pages the traversal had to have resident.
|
|
687
|
+
* @type {number}
|
|
688
|
+
*/
|
|
689
|
+
pages_touched = 0;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* @type {number}
|
|
693
|
+
*/
|
|
694
|
+
duration_ms = 0;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* `VIRTUAL_GEOMETRY_DESIGN.md` §4: `err_px = r_e · screen_height / (2 · tan(fov_y / 2) · d)`, with
|
|
699
|
+
* `d` the distance to the *closest point* of the sphere.
|
|
700
|
+
*
|
|
701
|
+
* A zero error projects to zero unconditionally — otherwise a leaf, whose error is exactly zero,
|
|
702
|
+
* would become undrawable the moment the camera entered its sphere.
|
|
703
|
+
*
|
|
704
|
+
* @param {number} error object-space `r_e`; `+Infinity` for a root's parent
|
|
705
|
+
* @param {Float32Array} spheres
|
|
706
|
+
* @param {number} base index of the sphere's first component
|
|
707
|
+
* @param {Float32Array} eye
|
|
708
|
+
* @param {number} k `screen_height / (2 · tan(fov_y / 2))`, hoisted out of the loop
|
|
709
|
+
* @returns {number} pixels
|
|
710
|
+
*/
|
|
711
|
+
function project_error(error, spheres, base, eye, k) {
|
|
712
|
+
if (error === 0) {
|
|
713
|
+
return 0;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const dx = eye[0] - spheres[base];
|
|
717
|
+
const dy = eye[1] - spheres[base + 1];
|
|
718
|
+
const dz = eye[2] - spheres[base + 2];
|
|
719
|
+
|
|
720
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz) - spheres[base + 3];
|
|
721
|
+
|
|
722
|
+
if (distance <= 0) {
|
|
723
|
+
// camera inside the sphere; the projection is unbounded and the cluster must refine
|
|
724
|
+
return Number.POSITIVE_INFINITY;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
return (error * k) / distance;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Whether a sphere is entirely outside the frustum.
|
|
732
|
+
*
|
|
733
|
+
* Only the five finite planes are tested. The projection is infinite reverse-Z, so the far plane's
|
|
734
|
+
* row is degenerate and normalizing it produces nothing a test can use.
|
|
735
|
+
*
|
|
736
|
+
* @param {Float32Array} frustum
|
|
737
|
+
* @param {Float32Array} spheres
|
|
738
|
+
* @param {number} base
|
|
739
|
+
* @returns {boolean}
|
|
740
|
+
*/
|
|
741
|
+
function sphere_outside_frustum(frustum, spheres, base) {
|
|
742
|
+
const x = spheres[base];
|
|
743
|
+
const y = spheres[base + 1];
|
|
744
|
+
const z = spheres[base + 2];
|
|
745
|
+
const radius = spheres[base + 3];
|
|
746
|
+
|
|
747
|
+
for (let plane = 0; plane < 5; plane++) {
|
|
748
|
+
const o = plane * 4;
|
|
749
|
+
|
|
750
|
+
const distance = frustum[o] * x + frustum[o + 1] * y + frustum[o + 2] * z + frustum[o + 3];
|
|
751
|
+
|
|
752
|
+
if (distance < -radius) {
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Select the cut for a view, by descending the page graph.
|
|
762
|
+
*
|
|
763
|
+
* A traversal rather than a flat pass over every cluster, per design §4 — and it gets the cut rule's
|
|
764
|
+
* first half for free. The rule is `project(parent) > τ AND project(self) ≤ τ`; a group is only ever
|
|
765
|
+
* reached by descending *through* the cluster whose step consumed it, and that descent happened
|
|
766
|
+
* precisely because the step projected above τ. Every cluster of a group shares that step's sphere
|
|
767
|
+
* and error, so the parent test is satisfied by the act of arriving.
|
|
768
|
+
*
|
|
769
|
+
* The residency clamp degenerates here: the whole file is in memory, so nothing is ever
|
|
770
|
+
* non-selectable and a leaf is the only reason to stop early.
|
|
771
|
+
*
|
|
772
|
+
* @param {VGeoContainer} container
|
|
773
|
+
* @param {VGeoCutView} view
|
|
774
|
+
* @returns {VGeoCut}
|
|
775
|
+
*/
|
|
776
|
+
export function vgeo_select_cut(container, view) {
|
|
777
|
+
assert.greaterThan(container.pages.length, 0, 'container.pages.length');
|
|
778
|
+
|
|
779
|
+
const started = performance.now();
|
|
780
|
+
|
|
781
|
+
const cut = new VGeoCut();
|
|
782
|
+
|
|
783
|
+
const k = view.screen_height / (2 * Math.tan(view.fov_y * 0.5));
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Groups already queued, keyed `page · 65536 + group`. A group is referenced by every sibling
|
|
787
|
+
* cluster of the step that consumed it, so without this the traversal would expand it once per
|
|
788
|
+
* parent and the cut would carry duplicates.
|
|
789
|
+
*
|
|
790
|
+
* @type {Set<number>}
|
|
791
|
+
*/
|
|
792
|
+
const queued = new Set();
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* @type {Set<number>}
|
|
796
|
+
*/
|
|
797
|
+
const pages = new Set();
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Page index and group index, interleaved.
|
|
801
|
+
* @type {number[]}
|
|
802
|
+
*/
|
|
803
|
+
const stack = [];
|
|
804
|
+
|
|
805
|
+
const root = container.pages[0];
|
|
806
|
+
|
|
807
|
+
for (let group = 0; group < root.group_parent_count.length; group++) {
|
|
808
|
+
// no cluster anywhere refines into this group, so it is the top of the DAG and selectable
|
|
809
|
+
// with nothing above it
|
|
810
|
+
if (root.group_parent_count[group] === 0) {
|
|
811
|
+
queued.add(group);
|
|
812
|
+
stack.push(0, group);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
while (stack.length > 0) {
|
|
817
|
+
const group = stack.pop();
|
|
818
|
+
const page_index = stack.pop();
|
|
819
|
+
|
|
820
|
+
const page = container.pages[page_index];
|
|
821
|
+
|
|
822
|
+
cut.groups_visited++;
|
|
823
|
+
pages.add(page_index);
|
|
824
|
+
|
|
825
|
+
const first = page.group_cluster_first[group];
|
|
826
|
+
const count = page.group_cluster_count[group];
|
|
827
|
+
|
|
828
|
+
for (let i = 0; i < count; i++) {
|
|
829
|
+
const id = page.cluster_base + first + i;
|
|
830
|
+
|
|
831
|
+
cut.clusters_tested++;
|
|
832
|
+
|
|
833
|
+
/*
|
|
834
|
+
Culling on `self_sphere` rather than on the tight `bounds_sphere`, because this decides
|
|
835
|
+
the subtree as well as the cluster: monotonicity makes a cluster's self sphere contain
|
|
836
|
+
every descendant's geometry, so a self sphere outside the frustum means nothing under
|
|
837
|
+
it can be on screen either.
|
|
838
|
+
*/
|
|
839
|
+
if (view.cull_enabled
|
|
840
|
+
&& sphere_outside_frustum(view.frustum, container.self_sphere, id * 4)) {
|
|
841
|
+
cut.culled++;
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
const child_ref = container.child_ref[id];
|
|
846
|
+
|
|
847
|
+
const self_px = project_error(
|
|
848
|
+
container.self_error[id], container.self_sphere, id * 4, view.eye, k
|
|
849
|
+
);
|
|
850
|
+
|
|
851
|
+
if (self_px <= view.tau || child_ref === VGEO_NO_CHILD) {
|
|
852
|
+
cut.clusters.push(id);
|
|
853
|
+
cut.triangle_count += container.triangle_count[id];
|
|
854
|
+
cut.vertex_count += container.vertex_count[id];
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
const child_page = child_ref === VGEO_SAME_PAGE ? page_index : page.child_pages[child_ref];
|
|
859
|
+
const child_group = container.child_group[id];
|
|
860
|
+
|
|
861
|
+
const key = child_page * 65536 + child_group;
|
|
862
|
+
|
|
863
|
+
if (!queued.has(key)) {
|
|
864
|
+
queued.add(key);
|
|
865
|
+
stack.push(child_page, child_group);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
cut.pages_touched = pages.size;
|
|
871
|
+
cut.duration_ms = performance.now() - started;
|
|
872
|
+
|
|
873
|
+
return cut;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
877
|
+
// Turning a cut into drawable geometry
|
|
878
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* What a cluster's colour is keyed on.
|
|
882
|
+
*
|
|
883
|
+
* The two normal modes are not keyed on the cluster at all: they paint every vertex with its own
|
|
884
|
+
* direction, and the cluster boundaries go with it. `stored normal` is the container's own
|
|
885
|
+
* {@link VGEO_ATTRIBUTE.NORMAL}, decoded out of the payload — the only mode that shows an attribute
|
|
886
|
+
* the file carries rather than something derived from it. `geometric normal` is the area-weighted
|
|
887
|
+
* normal of the decoded triangles, which is what every other mode shades with. The pair is the
|
|
888
|
+
* point: they agree where the builder's normals still describe the geometry it shipped, and a
|
|
889
|
+
* source with no normals at all makes the first one flat.
|
|
890
|
+
*
|
|
891
|
+
* @enum {string}
|
|
892
|
+
*/
|
|
893
|
+
export const VGEO_COLOR_MODE = {
|
|
894
|
+
Cluster: 'cluster',
|
|
895
|
+
Group: 'group',
|
|
896
|
+
Page: 'page',
|
|
897
|
+
Error: 'error',
|
|
898
|
+
StoredNormal: 'stored normal',
|
|
899
|
+
GeometricNormal: 'geometric normal',
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Key colours are spread by the golden ratio so that adjacent ids never land on adjacent hues —
|
|
904
|
+
* neighbouring clusters are exactly what has to be told apart.
|
|
905
|
+
* @type {number}
|
|
906
|
+
*/
|
|
907
|
+
const HUE_STEP = 0.6180339887498949;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* @param {number} hue in `[0, 1)`
|
|
911
|
+
* @param {number} saturation
|
|
912
|
+
* @param {number} value
|
|
913
|
+
* @param {Float32Array} out
|
|
914
|
+
* @param {number} offset
|
|
915
|
+
*/
|
|
916
|
+
function hsv_to_rgb(hue, saturation, value, out, offset) {
|
|
917
|
+
const sector = hue * 6;
|
|
918
|
+
const i = Math.floor(sector);
|
|
919
|
+
const f = sector - i;
|
|
920
|
+
|
|
921
|
+
const p = value * (1 - saturation);
|
|
922
|
+
const q = value * (1 - saturation * f);
|
|
923
|
+
const t = value * (1 - saturation * (1 - f));
|
|
924
|
+
|
|
925
|
+
switch (i % 6) {
|
|
926
|
+
case 0:
|
|
927
|
+
out[offset] = value; out[offset + 1] = t; out[offset + 2] = p;
|
|
928
|
+
break;
|
|
929
|
+
case 1:
|
|
930
|
+
out[offset] = q; out[offset + 1] = value; out[offset + 2] = p;
|
|
931
|
+
break;
|
|
932
|
+
case 2:
|
|
933
|
+
out[offset] = p; out[offset + 1] = value; out[offset + 2] = t;
|
|
934
|
+
break;
|
|
935
|
+
case 3:
|
|
936
|
+
out[offset] = p; out[offset + 1] = q; out[offset + 2] = value;
|
|
937
|
+
break;
|
|
938
|
+
case 4:
|
|
939
|
+
out[offset] = t; out[offset + 1] = p; out[offset + 2] = value;
|
|
940
|
+
break;
|
|
941
|
+
default:
|
|
942
|
+
out[offset] = value; out[offset + 1] = p; out[offset + 2] = q;
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Key lights, baked into vertex colour.
|
|
949
|
+
*
|
|
950
|
+
* The direct path carries position and colour per vertex and nothing else — no normal reaches the
|
|
951
|
+
* shader — so shading happens here, once per cut, against normals derived from the decoded
|
|
952
|
+
* triangles. Two opposed lights and a generous ambient, so that no part of the surface is black and
|
|
953
|
+
* every cluster's colour stays readable wherever it faces.
|
|
954
|
+
*
|
|
955
|
+
* @type {number[]}
|
|
956
|
+
*/
|
|
957
|
+
const KEY_LIGHT = [0.35, 0.78, 0.52];
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* @type {number[]}
|
|
961
|
+
*/
|
|
962
|
+
const FILL_LIGHT = [-0.55, -0.25, -0.79];
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Ceiling on a baked colour's brightest channel.
|
|
966
|
+
*
|
|
967
|
+
* The pass draws at `AfterTransparency`, so everything it writes still goes through the tonemapper,
|
|
968
|
+
* and the tonemapper desaturates as it approaches white. Pushed to 1.0 the clusters come out pastel
|
|
969
|
+
* and stop being tellable apart, which defeats the only thing the colour is for — so the shading
|
|
970
|
+
* range is deliberately kept below it.
|
|
971
|
+
*
|
|
972
|
+
* @type {number}
|
|
973
|
+
*/
|
|
974
|
+
const COLOR_CEILING = 0.9;
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* One cluster's worth of decoded stored normals, reused across clusters.
|
|
978
|
+
*
|
|
979
|
+
* {@link VGEO_MAX_CLUSTER_VERTEX_COUNT} is the format's ceiling on a cluster and
|
|
980
|
+
* {@link vgeo_validate_container} holds every file to it, so this is never short.
|
|
981
|
+
*
|
|
982
|
+
* @type {Float32Array}
|
|
983
|
+
*/
|
|
984
|
+
const stored_normals = new Float32Array(VGEO_MAX_CLUSTER_VERTEX_COUNT * 3);
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* One decoded direction, on its way from the octahedral codec into a caller's array.
|
|
988
|
+
* @type {Float32Array}
|
|
989
|
+
*/
|
|
990
|
+
const scratch_direction = new Float32Array(3);
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* Decode one cluster's stored normal section into unit vectors.
|
|
994
|
+
*
|
|
995
|
+
* The section is one octahedral `u32` per vertex, or a single word for the whole cluster when the
|
|
996
|
+
* encoder found every vertex agreeing — which is also what a source lacking normals encodes to, so
|
|
997
|
+
* the constant case is the ordinary one and not an exception. A stride of zero is what reads it:
|
|
998
|
+
* every vertex fetches the same word, and the loop does not have to know which case it is in.
|
|
999
|
+
*
|
|
1000
|
+
* @param {VGeoContainer} container
|
|
1001
|
+
* @param {DataView} data over the whole file
|
|
1002
|
+
* @param {number} id reader cluster id
|
|
1003
|
+
* @param {Float32Array} out at least `3 * container.vertex_count[id]` long
|
|
1004
|
+
*/
|
|
1005
|
+
function vgeo_read_cluster_normals(container, data, id, out) {
|
|
1006
|
+
const vertex_count = container.vertex_count[id];
|
|
1007
|
+
|
|
1008
|
+
// out is sized for the format's ceiling, so this fires only on a file that already broke it —
|
|
1009
|
+
// and a short write would come out as a handful of quietly wrong colours instead
|
|
1010
|
+
assert.greaterThanOrEqual(out.length, vertex_count * 3, 'out must hold three components per cluster vertex');
|
|
1011
|
+
|
|
1012
|
+
const encoding_flags = container.encoding_flags[id];
|
|
1013
|
+
|
|
1014
|
+
const page = container.pages[container.page_of_cluster[id]];
|
|
1015
|
+
|
|
1016
|
+
const at = page.payload_base
|
|
1017
|
+
+ container.payload_offset[id]
|
|
1018
|
+
+ vgeo_payload_attribute_offset(
|
|
1019
|
+
VGEO_ATTRIBUTE.NORMAL, vertex_count, container.triangle_count[id], encoding_flags
|
|
1020
|
+
);
|
|
1021
|
+
|
|
1022
|
+
const stride = (encoding_flags & NORMAL_COMPRESSION_FLAG) === 0 ? 4 : 0;
|
|
1023
|
+
|
|
1024
|
+
for (let i = 0; i < vertex_count; i++) {
|
|
1025
|
+
const word = data.getUint32(at + i * stride, LE);
|
|
1026
|
+
|
|
1027
|
+
const u = ((word & 0xFFFF) / UINT16_MAX) * 2 - 1;
|
|
1028
|
+
const v = (((word >>> 16) & 0xFFFF) / UINT16_MAX) * 2 - 1;
|
|
1029
|
+
|
|
1030
|
+
decode_octahedron_to_unit(scratch_direction, 0, u, v);
|
|
1031
|
+
|
|
1032
|
+
/*
|
|
1033
|
+
The encoder hands the octahedral codec `(nx, nz, ny)` — Shade's own convention, matched so
|
|
1034
|
+
that a `.vgeo` payload is byte for byte a `MeshletBatch` one — so the decode comes back in
|
|
1035
|
+
that order and has to be put back.
|
|
1036
|
+
*/
|
|
1037
|
+
out[i * 3] = scratch_direction[0];
|
|
1038
|
+
out[i * 3 + 1] = scratch_direction[2];
|
|
1039
|
+
out[i * 3 + 2] = scratch_direction[1];
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* Paint a run of vertices with their own directions and no shading: `rgb = n · 0.5 + 0.5`, scaled
|
|
1045
|
+
* by {@link COLOR_CEILING} for the same reason every other mode is.
|
|
1046
|
+
*
|
|
1047
|
+
* Unlit on purpose. A direction multiplied by how much light it happens to catch is unreadable
|
|
1048
|
+
* exactly where reading it matters — a normal facing away from both lights would come out black,
|
|
1049
|
+
* and black is not a direction.
|
|
1050
|
+
*
|
|
1051
|
+
* The tonemapper still has the last word on what reaches the screen, so this is a direction to be
|
|
1052
|
+
* read and not a value to be measured.
|
|
1053
|
+
*
|
|
1054
|
+
* @param {Float32Array} colors four per vertex
|
|
1055
|
+
* @param {number} first index of the run's first vertex
|
|
1056
|
+
* @param {number} count vertices in the run
|
|
1057
|
+
* @param {Float32Array} directions unit vectors, three components apiece
|
|
1058
|
+
* @param {number} directions_offset index of the run's first component within `directions`
|
|
1059
|
+
*/
|
|
1060
|
+
function paint_directions(colors, first, count, directions, directions_offset) {
|
|
1061
|
+
for (let i = 0; i < count; i++) {
|
|
1062
|
+
const d = directions_offset + i * 3;
|
|
1063
|
+
const o = (first + i) * 4;
|
|
1064
|
+
|
|
1065
|
+
colors[o] = COLOR_CEILING * (directions[d] * 0.5 + 0.5);
|
|
1066
|
+
colors[o + 1] = COLOR_CEILING * (directions[d + 1] * 0.5 + 0.5);
|
|
1067
|
+
colors[o + 2] = COLOR_CEILING * (directions[d + 2] * 0.5 + 0.5);
|
|
1068
|
+
colors[o + 3] = 1;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* A cut, decoded into one geometry.
|
|
1074
|
+
*
|
|
1075
|
+
* Nothing about it depends on where the camera is: the mesh is drawn solid and the depth buffer
|
|
1076
|
+
* orders it, so the triangle list is uploaded once when the cut is taken and never touched again.
|
|
1077
|
+
*/
|
|
1078
|
+
export class VGeoCutGeometry {
|
|
1079
|
+
/**
|
|
1080
|
+
* Position and colour, indexed by {@link triangles}.
|
|
1081
|
+
* @type {Geometry}
|
|
1082
|
+
*/
|
|
1083
|
+
geometry = new Geometry();
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* `3 * triangle_count` — the full triangle list, in cluster order, and the geometry's index.
|
|
1087
|
+
* @type {Uint32Array}
|
|
1088
|
+
*/
|
|
1089
|
+
triangles = new Uint32Array(0);
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* @type {number}
|
|
1093
|
+
*/
|
|
1094
|
+
triangle_count = 0;
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* @type {number}
|
|
1098
|
+
*/
|
|
1099
|
+
vertex_count = 0;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Decode the selected clusters into one geometry.
|
|
1104
|
+
*
|
|
1105
|
+
* Payloads are `SHADE_MESHLET_V1`'s (format §8): the index section first, three 8-bit local indices
|
|
1106
|
+
* per triangle, then the attribute sections. Position is always read — it is raw float32, never
|
|
1107
|
+
* constant-compressed — and the stored normal section only when a normal display asks for it,
|
|
1108
|
+
* because the direct path carries position and colour per vertex and nowhere to put the rest.
|
|
1109
|
+
*
|
|
1110
|
+
* @param {VGeoContainer} container
|
|
1111
|
+
* @param {VGeoCut} cut
|
|
1112
|
+
* @param {VGEO_COLOR_MODE} color_mode
|
|
1113
|
+
* @returns {VGeoCutGeometry}
|
|
1114
|
+
*/
|
|
1115
|
+
export function vgeo_build_cut_geometry(container, cut, color_mode) {
|
|
1116
|
+
const vertex_count = cut.vertex_count;
|
|
1117
|
+
const triangle_count = cut.triangle_count;
|
|
1118
|
+
|
|
1119
|
+
const positions = new Float32Array(vertex_count * 3);
|
|
1120
|
+
const colors = new Float32Array(vertex_count * 4);
|
|
1121
|
+
const normals = new Float32Array(vertex_count * 3);
|
|
1122
|
+
|
|
1123
|
+
const result = new VGeoCutGeometry();
|
|
1124
|
+
|
|
1125
|
+
result.triangles = new Uint32Array(triangle_count * 3);
|
|
1126
|
+
result.triangle_count = triangle_count;
|
|
1127
|
+
result.vertex_count = vertex_count;
|
|
1128
|
+
|
|
1129
|
+
const bytes = container.page_bytes;
|
|
1130
|
+
const triangles = result.triangles;
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* The decoded pages, addressed a word at a time. A `DataView` has no alignment requirement,
|
|
1134
|
+
* which is what an encoded attribute word needs: its offset is the format's, not the browser's.
|
|
1135
|
+
* @type {DataView}
|
|
1136
|
+
*/
|
|
1137
|
+
const data = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1138
|
+
|
|
1139
|
+
/*
|
|
1140
|
+
The error ramp spans the *cut's* own errors, not the file's. Normalizing against the coarsest
|
|
1141
|
+
error in the container would be defensible and useless: a fine cut's clusters all sit orders of
|
|
1142
|
+
magnitude below it and the whole model comes out one flat colour. What the question actually is
|
|
1143
|
+
— which parts of this cut settled for more error than the rest — is a question about this cut.
|
|
1144
|
+
*/
|
|
1145
|
+
let error_low = Number.POSITIVE_INFINITY;
|
|
1146
|
+
let error_high = 0;
|
|
1147
|
+
|
|
1148
|
+
for (const id of cut.clusters) {
|
|
1149
|
+
error_low = Math.min(error_low, container.self_error[id]);
|
|
1150
|
+
error_high = Math.max(error_high, container.self_error[id]);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
const error_span = error_high - error_low;
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* `[first vertex, first triangle]` of each selected cluster, so colour can be applied per
|
|
1157
|
+
* cluster after the normals are known.
|
|
1158
|
+
* @type {Uint32Array}
|
|
1159
|
+
*/
|
|
1160
|
+
const cluster_vertex_first = new Uint32Array(cut.clusters.length);
|
|
1161
|
+
|
|
1162
|
+
let vertex_cursor = 0;
|
|
1163
|
+
let triangle_cursor = 0;
|
|
1164
|
+
|
|
1165
|
+
for (let c = 0; c < cut.clusters.length; c++) {
|
|
1166
|
+
const id = cut.clusters[c];
|
|
1167
|
+
|
|
1168
|
+
const cluster_vertices = container.vertex_count[id];
|
|
1169
|
+
const cluster_triangles = container.triangle_count[id];
|
|
1170
|
+
|
|
1171
|
+
const page = container.pages[container.page_of_cluster[id]];
|
|
1172
|
+
const payload = page.payload_base + container.payload_offset[id];
|
|
1173
|
+
|
|
1174
|
+
cluster_vertex_first[c] = vertex_cursor;
|
|
1175
|
+
|
|
1176
|
+
const position_at = payload + vgeo_payload_attribute_offset(
|
|
1177
|
+
VGEO_ATTRIBUTE.POSITION,
|
|
1178
|
+
cluster_vertices,
|
|
1179
|
+
cluster_triangles,
|
|
1180
|
+
container.encoding_flags[id]
|
|
1181
|
+
);
|
|
1182
|
+
|
|
1183
|
+
/*
|
|
1184
|
+
Copied out rather than viewed in place: a Float32Array view demands 4-byte alignment
|
|
1185
|
+
against the *file's* buffer, which is a property of where the browser happened to put it
|
|
1186
|
+
and not something the format promises.
|
|
1187
|
+
*/
|
|
1188
|
+
const coordinates = new Float32Array(
|
|
1189
|
+
bytes.slice(position_at, position_at + cluster_vertices * 12).buffer
|
|
1190
|
+
);
|
|
1191
|
+
|
|
1192
|
+
positions.set(coordinates, vertex_cursor * 3);
|
|
1193
|
+
|
|
1194
|
+
for (let i = 0; i < cluster_triangles * 3; i++) {
|
|
1195
|
+
triangles[triangle_cursor * 3 + i] = vertex_cursor + bytes[payload + i];
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
vertex_cursor += cluster_vertices;
|
|
1199
|
+
triangle_cursor += cluster_triangles;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
assert.equal(vertex_cursor, vertex_count, 'decoded vertices must match the cut');
|
|
1203
|
+
assert.equal(triangle_cursor, triangle_count, 'decoded triangles must match the cut');
|
|
1204
|
+
|
|
1205
|
+
// Area-weighted vertex normals, which is all shading reads. Clusters share no vertices, so
|
|
1206
|
+
// accumulating over the whole list still gives each cluster its own smoothing — the crease that
|
|
1207
|
+
// leaves at a cluster seam is a feature here, not an artefact.
|
|
1208
|
+
for (let t = 0; t < triangle_count; t++) {
|
|
1209
|
+
const a = triangles[t * 3] * 3;
|
|
1210
|
+
const b = triangles[t * 3 + 1] * 3;
|
|
1211
|
+
const c = triangles[t * 3 + 2] * 3;
|
|
1212
|
+
|
|
1213
|
+
const abx = positions[b] - positions[a];
|
|
1214
|
+
const aby = positions[b + 1] - positions[a + 1];
|
|
1215
|
+
const abz = positions[b + 2] - positions[a + 2];
|
|
1216
|
+
|
|
1217
|
+
const acx = positions[c] - positions[a];
|
|
1218
|
+
const acy = positions[c + 1] - positions[a + 1];
|
|
1219
|
+
const acz = positions[c + 2] - positions[a + 2];
|
|
1220
|
+
|
|
1221
|
+
const nx = aby * acz - abz * acy;
|
|
1222
|
+
const ny = abz * acx - abx * acz;
|
|
1223
|
+
const nz = abx * acy - aby * acx;
|
|
1224
|
+
|
|
1225
|
+
normals[a] += nx; normals[a + 1] += ny; normals[a + 2] += nz;
|
|
1226
|
+
normals[b] += nx; normals[b + 1] += ny; normals[b + 2] += nz;
|
|
1227
|
+
normals[c] += nx; normals[c + 1] += ny; normals[c + 2] += nz;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// Normalized here rather than where they are read, because two things read them now — the
|
|
1231
|
+
// shading, and `geometric normal` — and a direction is the same direction for both.
|
|
1232
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
1233
|
+
const n = v * 3;
|
|
1234
|
+
|
|
1235
|
+
const length = Math.hypot(normals[n], normals[n + 1], normals[n + 2]);
|
|
1236
|
+
|
|
1237
|
+
// A vertex left with no area around it has no direction to give. Zero shades as ambient and
|
|
1238
|
+
// displays as mid grey, and both say "nothing here" rather than inventing an answer.
|
|
1239
|
+
const scale = length > 0 ? 1 / length : 0;
|
|
1240
|
+
|
|
1241
|
+
normals[n] *= scale;
|
|
1242
|
+
normals[n + 1] *= scale;
|
|
1243
|
+
normals[n + 2] *= scale;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
const tint = new Float32Array(3);
|
|
1247
|
+
|
|
1248
|
+
for (let c = 0; c < cut.clusters.length; c++) {
|
|
1249
|
+
const id = cut.clusters[c];
|
|
1250
|
+
|
|
1251
|
+
const first = cluster_vertex_first[c];
|
|
1252
|
+
const count = container.vertex_count[id];
|
|
1253
|
+
|
|
1254
|
+
if (color_mode === VGEO_COLOR_MODE.StoredNormal) {
|
|
1255
|
+
vgeo_read_cluster_normals(container, data, id, stored_normals);
|
|
1256
|
+
|
|
1257
|
+
paint_directions(colors, first, count, stored_normals, 0);
|
|
1258
|
+
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
if (color_mode === VGEO_COLOR_MODE.GeometricNormal) {
|
|
1263
|
+
paint_directions(colors, first, count, normals, first * 3);
|
|
1264
|
+
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
let key;
|
|
1269
|
+
|
|
1270
|
+
switch (color_mode) {
|
|
1271
|
+
case VGEO_COLOR_MODE.Group:
|
|
1272
|
+
key = container.page_of_cluster[id] * 65536 + container.group_of_cluster[id];
|
|
1273
|
+
break;
|
|
1274
|
+
case VGEO_COLOR_MODE.Page:
|
|
1275
|
+
key = container.page_of_cluster[id];
|
|
1276
|
+
break;
|
|
1277
|
+
default:
|
|
1278
|
+
key = id;
|
|
1279
|
+
break;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
if (color_mode === VGEO_COLOR_MODE.Error) {
|
|
1283
|
+
// cool where the cut is refined, hot where it settled for the most error
|
|
1284
|
+
const t = error_span > 0 ? (container.self_error[id] - error_low) / error_span : 0;
|
|
1285
|
+
|
|
1286
|
+
hsv_to_rgb(0.68 * (1 - t), 0.9, 1, tint, 0);
|
|
1287
|
+
} else {
|
|
1288
|
+
hsv_to_rgb((key * HUE_STEP) % 1, 0.85, 1, tint, 0);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
const end = first + count;
|
|
1292
|
+
|
|
1293
|
+
for (let v = first; v < end; v++) {
|
|
1294
|
+
const n = v * 3;
|
|
1295
|
+
|
|
1296
|
+
const nx = normals[n];
|
|
1297
|
+
const ny = normals[n + 1];
|
|
1298
|
+
const nz = normals[n + 2];
|
|
1299
|
+
|
|
1300
|
+
const key_term = Math.max(
|
|
1301
|
+
0, nx * KEY_LIGHT[0] + ny * KEY_LIGHT[1] + nz * KEY_LIGHT[2]
|
|
1302
|
+
);
|
|
1303
|
+
|
|
1304
|
+
const fill_term = Math.max(
|
|
1305
|
+
0, nx * FILL_LIGHT[0] + ny * FILL_LIGHT[1] + nz * FILL_LIGHT[2]
|
|
1306
|
+
);
|
|
1307
|
+
|
|
1308
|
+
const shade = COLOR_CEILING * (0.22 + 0.60 * key_term + 0.18 * fill_term);
|
|
1309
|
+
|
|
1310
|
+
colors[v * 4] = tint[0] * shade;
|
|
1311
|
+
colors[v * 4 + 1] = tint[1] * shade;
|
|
1312
|
+
colors[v * 4 + 2] = tint[2] * shade;
|
|
1313
|
+
colors[v * 4 + 3] = 1;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
result.geometry.addAttribute(Attribute.from(positions, 3, StandardAttributes.Position));
|
|
1318
|
+
result.geometry.addAttribute(Attribute.from(colors, 4, StandardAttributes.Color));
|
|
1319
|
+
result.geometry.index = Attribute.from(result.triangles, 1, StandardAttributes.Index);
|
|
1320
|
+
|
|
1321
|
+
return result;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Clear the frame's depth, so that the cut is the only thing in it.
|
|
1326
|
+
*
|
|
1327
|
+
* **The renderer does not do this when there is nothing to rasterize.** Depth is cleared as a side
|
|
1328
|
+
* effect of drawing the first opaque bucket, and this viewer's `Scene` holds a light and no meshes,
|
|
1329
|
+
* so that draw never happens. The renderer also ping-pongs two depth textures frame to frame — so
|
|
1330
|
+
* left alone, the cut is depth-tested against *its own depth from two frames ago*, and dissolves
|
|
1331
|
+
* into holes wherever the camera has moved since. It reads as missing geometry and it is not.
|
|
1332
|
+
*
|
|
1333
|
+
* A real scene needs none of this and must not have it: the cut has to be occluded by whatever the
|
|
1334
|
+
* scene put in the depth buffer, which is why the draw itself loads rather than clears.
|
|
1335
|
+
*
|
|
1336
|
+
* It runs immediately before the draw rather than at the top of the frame, so everything earlier
|
|
1337
|
+
* that reads depth still sees the previous frame's. With nothing in the scene there is nothing for
|
|
1338
|
+
* those passes to occlude, and the alternative is a second registration on another phase to save a
|
|
1339
|
+
* result that is empty either way.
|
|
1340
|
+
*
|
|
1341
|
+
* @param {FrameGraph} graph
|
|
1342
|
+
* @param {number} depth
|
|
1343
|
+
* @returns {number} the depth handle to draw against
|
|
1344
|
+
*/
|
|
1345
|
+
function vgeo_graph_clear_depth(graph, depth) {
|
|
1346
|
+
const data = {};
|
|
1347
|
+
|
|
1348
|
+
const pass = graph.add('vgeo/clear depth', data, (data, resources, context) => {
|
|
1349
|
+
const texture = resources.get(data.depth);
|
|
1350
|
+
|
|
1351
|
+
// no draws — the clear is the load op, and ending the pass immediately is what performs it
|
|
1352
|
+
context.encoder.beginRenderPass({
|
|
1353
|
+
label: "vgeo/clear depth",
|
|
1354
|
+
colorAttachments: [],
|
|
1355
|
+
depthStencilAttachment: {
|
|
1356
|
+
view: texture.obtainView(DEFAULT_DEPTH_TEXTURE_VIEW),
|
|
1357
|
+
depthLoadOp: "clear",
|
|
1358
|
+
depthStoreOp: "store",
|
|
1359
|
+
depthClearValue: DEPTH_BACKGROUND_VALUE,
|
|
1360
|
+
},
|
|
1361
|
+
}).end();
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
data.depth = pass.write(depth);
|
|
1365
|
+
|
|
1366
|
+
return data.depth;
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1370
|
+
// Harness
|
|
1371
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* @param {number} value
|
|
1375
|
+
* @returns {string}
|
|
1376
|
+
*/
|
|
1377
|
+
function thousands(value) {
|
|
1378
|
+
return value.toLocaleString('en-US');
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* @param {[string, string][]} entries
|
|
1383
|
+
* @returns {string} one label/value row apiece
|
|
1384
|
+
*/
|
|
1385
|
+
function panel_table(entries) {
|
|
1386
|
+
return entries
|
|
1387
|
+
.map(([key, value]) => `<div class="row"><span class="muted">${key}</span><span>${value}</span></div>`)
|
|
1388
|
+
.join('');
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* @param {number} bytes
|
|
1393
|
+
* @returns {string}
|
|
1394
|
+
*/
|
|
1395
|
+
function human_bytes(bytes) {
|
|
1396
|
+
if (bytes < 1024) {
|
|
1397
|
+
return `${bytes} B`;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
if (bytes < 1024 * 1024) {
|
|
1401
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
if (bytes < 1024 * 1024 * 1024) {
|
|
1405
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* What the pages cost stored against what they cost decoded, and under which codec.
|
|
1413
|
+
*
|
|
1414
|
+
* Stored is the number that gets fetched and the number that sits on disk; decoded is the number a
|
|
1415
|
+
* resident page costs in RAM. The codec is per frame, so a file can genuinely be a mixture — the
|
|
1416
|
+
* encoder stores a page raw whenever compressing it would not have shrunk it — and naming all of
|
|
1417
|
+
* them is more honest than naming whichever one happened to come first.
|
|
1418
|
+
*
|
|
1419
|
+
* @param {VGeoContainer} container
|
|
1420
|
+
* @returns {string}
|
|
1421
|
+
*/
|
|
1422
|
+
function page_storage(container) {
|
|
1423
|
+
const codec = Array.from(new Set(container.pages.map((page) => page.codec)))
|
|
1424
|
+
.map(vgeo_codec_name)
|
|
1425
|
+
.join(' + ');
|
|
1426
|
+
|
|
1427
|
+
const ratio = container.decoded_page_bytes / Math.max(container.stored_page_bytes, 1);
|
|
1428
|
+
|
|
1429
|
+
return `${human_bytes(container.stored_page_bytes)} stored`
|
|
1430
|
+
+ ` · ${human_bytes(container.decoded_page_bytes)} decoded`
|
|
1431
|
+
+ ` · ${codec} ${ratio.toFixed(2)}x`;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
const PANEL_CSS = `
|
|
1435
|
+
#vgeo-panel {
|
|
1436
|
+
position: absolute; top: 0; right: 0; width: 340px; max-height: 100vh; overflow-y: auto;
|
|
1437
|
+
padding: 12px 14px; box-sizing: border-box;
|
|
1438
|
+
font: 12px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
1439
|
+
color: #dfe6ee; background: rgba(12, 16, 22, 0.88);
|
|
1440
|
+
border-left: 1px solid #2b3947;
|
|
1441
|
+
}
|
|
1442
|
+
#vgeo-panel h1 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.06em; color: #7fd2ff; }
|
|
1443
|
+
#vgeo-panel h2 {
|
|
1444
|
+
margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
|
|
1445
|
+
color: #6b7c8d; border-bottom: 1px solid #24313d; padding-bottom: 3px;
|
|
1446
|
+
}
|
|
1447
|
+
#vgeo-panel .row { display: flex; justify-content: space-between; gap: 8px; }
|
|
1448
|
+
#vgeo-panel .row span:last-child { color: #f2f6fa; }
|
|
1449
|
+
#vgeo-panel .count { font-size: 30px; line-height: 1.1; color: #8fe388; }
|
|
1450
|
+
#vgeo-panel .muted { color: #6b7c8d; }
|
|
1451
|
+
#vgeo-panel .bad { color: #ff8a7a; }
|
|
1452
|
+
#vgeo-panel .good { color: #8fe388; }
|
|
1453
|
+
#vgeo-panel button {
|
|
1454
|
+
width: 100%; margin: 8px 0 2px; padding: 7px; cursor: pointer;
|
|
1455
|
+
font: inherit; color: #061018; background: #7fd2ff; border: 0; border-radius: 3px;
|
|
1456
|
+
}
|
|
1457
|
+
#vgeo-panel button:hover { background: #a5e0ff; }
|
|
1458
|
+
#vgeo-panel label { display: flex; align-items: center; gap: 6px; margin: 3px 0; cursor: pointer; }
|
|
1459
|
+
#vgeo-panel input[type=range] { width: 100%; }
|
|
1460
|
+
#vgeo-panel select { width: 100%; font: inherit; background: #16202b; color: #dfe6ee; border: 1px solid #2b3947; padding: 3px; }
|
|
1461
|
+
#vgeo-panel ol { margin: 4px 0; padding-left: 18px; }
|
|
1462
|
+
#vgeo-drop {
|
|
1463
|
+
position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
|
|
1464
|
+
font: 20px ui-monospace, monospace; color: #7fd2ff;
|
|
1465
|
+
background: rgba(6, 12, 20, 0.82); border: 3px dashed #7fd2ff; box-sizing: border-box;
|
|
1466
|
+
}
|
|
1467
|
+
#vgeo-drop.active { display: flex; }
|
|
1468
|
+
`;
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* The viewer draws its clusters into the scene, at the phase a full-screen effect that should be
|
|
1472
|
+
* tonemapped with the rest of the frame belongs at.
|
|
1473
|
+
*/
|
|
1474
|
+
class VGEOViewerExtension extends RenderExtension {
|
|
1475
|
+
name = "vgeo viewer";
|
|
1476
|
+
|
|
1477
|
+
phase = FramePhase.AfterTransparency;
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* @type {VGeoViewer}
|
|
1481
|
+
*/
|
|
1482
|
+
#viewer;
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* @param {VGeoViewer} viewer
|
|
1486
|
+
*/
|
|
1487
|
+
constructor(viewer) {
|
|
1488
|
+
super();
|
|
1489
|
+
|
|
1490
|
+
this.#viewer = viewer;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
record(frame) {
|
|
1494
|
+
this.#viewer.record(frame);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* The viewer. One container at a time, one cut at a time, and the cut only changes when asked.
|
|
1500
|
+
*/
|
|
1501
|
+
class VGeoViewer {
|
|
1502
|
+
/**
|
|
1503
|
+
* @type {VGeoContainer|undefined}
|
|
1504
|
+
*/
|
|
1505
|
+
#container = undefined;
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* @type {VGeoCutGeometry|undefined}
|
|
1509
|
+
*/
|
|
1510
|
+
#cut_geometry = undefined;
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* @type {VGeoCut}
|
|
1514
|
+
*/
|
|
1515
|
+
#cut = new VGeoCut();
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* @type {VGeoCutView}
|
|
1519
|
+
*/
|
|
1520
|
+
#view = new VGeoCutView();
|
|
1521
|
+
|
|
1522
|
+
/**
|
|
1523
|
+
* @type {DynamicMeshBatch}
|
|
1524
|
+
*/
|
|
1525
|
+
#batch = new DynamicMeshBatch();
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* @type {DynamicMesh|undefined}
|
|
1529
|
+
*/
|
|
1530
|
+
#mesh = undefined;
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* A cut is a solid surface, so it is drawn as one: opaque, writing depth, and ordered by the
|
|
1534
|
+
* depth buffer rather than by anything this file does.
|
|
1535
|
+
*
|
|
1536
|
+
* @type {GPUDynamicMeshRenderer}
|
|
1537
|
+
*/
|
|
1538
|
+
#dynamic = new GPUDynamicMeshRenderer();
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Where the camera stood when the current cut was taken, so the panel can say how far you have
|
|
1542
|
+
* wandered from the decision you are looking at.
|
|
1543
|
+
* @type {Float32Array}
|
|
1544
|
+
*/
|
|
1545
|
+
#cut_eye = new Float32Array(3);
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* @type {Float32Array}
|
|
1549
|
+
*/
|
|
1550
|
+
#eye = new Float32Array(3);
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* @type {boolean}
|
|
1554
|
+
*/
|
|
1555
|
+
#auto_adapt = false;
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* @type {VGEO_COLOR_MODE}
|
|
1559
|
+
*/
|
|
1560
|
+
#color_mode = VGEO_COLOR_MODE.Cluster;
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* @type {string}
|
|
1564
|
+
*/
|
|
1565
|
+
#status = 'drop a .vgeo file anywhere on the page';
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* @type {string}
|
|
1569
|
+
*/
|
|
1570
|
+
#file_label = '';
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* @type {number}
|
|
1574
|
+
*/
|
|
1575
|
+
#file_bytes = 0;
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* @type {number}
|
|
1579
|
+
*/
|
|
1580
|
+
#read_ms = 0;
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
* @type {number}
|
|
1584
|
+
*/
|
|
1585
|
+
#build_ms = 0;
|
|
1586
|
+
|
|
1587
|
+
constructor() {
|
|
1588
|
+
this.canvas = document.createElement('canvas');
|
|
1589
|
+
this.renderer = new Renderer();
|
|
1590
|
+
this.camera = new PerspectiveCamera();
|
|
1591
|
+
this.scene = new Scene();
|
|
1592
|
+
|
|
1593
|
+
this.#dynamic.opaque = true;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* @returns {Promise<void>}
|
|
1598
|
+
*/
|
|
1599
|
+
async start() {
|
|
1600
|
+
document.body.style.margin = '0';
|
|
1601
|
+
document.body.style.overflow = 'hidden';
|
|
1602
|
+
document.body.style.background = '#070b10';
|
|
1603
|
+
|
|
1604
|
+
this.canvas.style.position = 'absolute';
|
|
1605
|
+
this.canvas.style.inset = '0';
|
|
1606
|
+
this.canvas.style.outline = 'none';
|
|
1607
|
+
|
|
1608
|
+
// the orbital controller attaches a KeyboardDevice, and a canvas cannot receive key events
|
|
1609
|
+
// without being focusable
|
|
1610
|
+
this.canvas.tabIndex = 0;
|
|
1611
|
+
|
|
1612
|
+
document.body.appendChild(this.canvas);
|
|
1613
|
+
|
|
1614
|
+
this.canvas.focus();
|
|
1615
|
+
|
|
1616
|
+
await this.renderer.initialize({ context: this.canvas.getContext('webgpu') });
|
|
1617
|
+
|
|
1618
|
+
/*
|
|
1619
|
+
Everything that would move the image for reasons unrelated to the cut is off. Automatic
|
|
1620
|
+
exposure in particular: it adapts to whatever is on screen, so the same cluster would read
|
|
1621
|
+
a different colour depending on how much of the model is in frame, which is exactly the
|
|
1622
|
+
signal this tool is trying to show.
|
|
1623
|
+
*/
|
|
1624
|
+
this.renderer.feature_automatic_exposure_enabled = false;
|
|
1625
|
+
this.renderer.feature_taa_enabled = true;
|
|
1626
|
+
this.renderer.feature_bloom_enabled = false;
|
|
1627
|
+
this.renderer.feature_ssr_enabled = false;
|
|
1628
|
+
this.renderer.feature_ssao_enabled = true;
|
|
1629
|
+
this.renderer.feature_shadows_enabled = false;
|
|
1630
|
+
this.renderer.feature_lpv_enabled = false;
|
|
1631
|
+
this.renderer.pixel_ratio = 1;
|
|
1632
|
+
|
|
1633
|
+
this.scene.lights.add(make_sunlight({ intensity: 3 }));
|
|
1634
|
+
|
|
1635
|
+
this.camera.near = 0.05;
|
|
1636
|
+
this.camera.far = 500;
|
|
1637
|
+
this.camera.fov = 55 * DEG_TO_RAD;
|
|
1638
|
+
this.camera.transform.position.set(0, 0.5, 2);
|
|
1639
|
+
this.camera.transform.lookAt(Vector3.zero);
|
|
1640
|
+
|
|
1641
|
+
this.controller = new OrbitalCameraController(this.camera, this.canvas);
|
|
1642
|
+
this.controller.distanceLimits.min = 1e-4;
|
|
1643
|
+
this.controller.distanceLimits.max = 1e5;
|
|
1644
|
+
|
|
1645
|
+
this.#build_interface();
|
|
1646
|
+
this.#fit_to_window();
|
|
1647
|
+
|
|
1648
|
+
window.addEventListener('resize', () => this.#fit_to_window());
|
|
1649
|
+
|
|
1650
|
+
this.renderer.add_extension(new VGEOViewerExtension(this));
|
|
1651
|
+
|
|
1652
|
+
create_frame_loop((dt) => this.#frame(dt));
|
|
1653
|
+
|
|
1654
|
+
const requested = new URL(window.location.href).searchParams.get('file');
|
|
1655
|
+
|
|
1656
|
+
if (requested !== null) {
|
|
1657
|
+
await this.load_url(requested);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* @param {FrameContext} frame
|
|
1663
|
+
*/
|
|
1664
|
+
record(frame) {
|
|
1665
|
+
const graph = frame.graph;
|
|
1666
|
+
const scene = frame.get(SceneColor);
|
|
1667
|
+
|
|
1668
|
+
scene.color = this.#dynamic.graph_draw({
|
|
1669
|
+
graph,
|
|
1670
|
+
batch: this.#batch,
|
|
1671
|
+
color: scene.color,
|
|
1672
|
+
depth: vgeo_graph_clear_depth(graph, frame.get(ViewTextures).depth),
|
|
1673
|
+
camera: frame.view.camera.buffer,
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
#fit_to_window() {
|
|
1678
|
+
const width = window.innerWidth;
|
|
1679
|
+
const height = window.innerHeight;
|
|
1680
|
+
|
|
1681
|
+
this.canvas.width = width;
|
|
1682
|
+
this.canvas.height = height;
|
|
1683
|
+
|
|
1684
|
+
this.renderer.resize(width, height);
|
|
1685
|
+
|
|
1686
|
+
this.camera.aspect = this.renderer.aspect_ratio;
|
|
1687
|
+
|
|
1688
|
+
this.#view.screen_height = height;
|
|
1689
|
+
this.#view.fov_y = this.camera.fov;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* @param {number} dt seconds
|
|
1694
|
+
*/
|
|
1695
|
+
#frame(dt) {
|
|
1696
|
+
this.controller.update(dt);
|
|
1697
|
+
|
|
1698
|
+
const position = this.camera.transform.position;
|
|
1699
|
+
|
|
1700
|
+
const moved = position.x !== this.#eye[0]
|
|
1701
|
+
|| position.y !== this.#eye[1]
|
|
1702
|
+
|| position.z !== this.#eye[2];
|
|
1703
|
+
|
|
1704
|
+
this.#eye[0] = position.x;
|
|
1705
|
+
this.#eye[1] = position.y;
|
|
1706
|
+
this.#eye[2] = position.z;
|
|
1707
|
+
|
|
1708
|
+
if (moved && this.#auto_adapt) {
|
|
1709
|
+
this.adapt();
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
this.renderer.render(this.camera, this.scene, dt);
|
|
1713
|
+
|
|
1714
|
+
if (moved) {
|
|
1715
|
+
this.#refresh_cut();
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* Re-render the cut readout alone.
|
|
1721
|
+
*
|
|
1722
|
+
* Every number under it moves as the camera does — the drift on every frame, and the whole lot
|
|
1723
|
+
* on every adapt when `follow the camera` is on. Rebuilding the *whole* panel at that rate would
|
|
1724
|
+
* also rebuild the controls, which is how a slider stops being draggable mid-drag; this section
|
|
1725
|
+
* holds no controls, so replacing it is free of that.
|
|
1726
|
+
*/
|
|
1727
|
+
#refresh_cut() {
|
|
1728
|
+
const host = this.panel.querySelector('#vgeo-cut');
|
|
1729
|
+
|
|
1730
|
+
if (host === null) {
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
host.innerHTML = this.#cut_html();
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* The cut readout — the cluster count first, because it is the number the tool exists to show.
|
|
1739
|
+
*
|
|
1740
|
+
* @returns {string}
|
|
1741
|
+
*/
|
|
1742
|
+
#cut_html() {
|
|
1743
|
+
const cut = this.#cut;
|
|
1744
|
+
|
|
1745
|
+
return `<div class="count">${thousands(cut.clusters.length)}</div>`
|
|
1746
|
+
+ `<div class="muted" style="margin-bottom:6px">clusters in the current cut</div>`
|
|
1747
|
+
+ panel_table([
|
|
1748
|
+
['triangles', thousands(cut.triangle_count)],
|
|
1749
|
+
['groups', thousands(cut.groups_visited)],
|
|
1750
|
+
['pages resident', thousands(cut.pages_touched)],
|
|
1751
|
+
['clusters tested', thousands(cut.clusters_tested)],
|
|
1752
|
+
['culled subtrees', thousands(cut.culled)],
|
|
1753
|
+
['select / build', `${cut.duration_ms.toFixed(1)} / ${this.#build_ms.toFixed(1)} ms`],
|
|
1754
|
+
['camera drift', `${this.#drift().toExponential(2)} u`],
|
|
1755
|
+
]);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* How far the camera has moved since the cut on screen was selected.
|
|
1760
|
+
* @returns {number}
|
|
1761
|
+
*/
|
|
1762
|
+
#drift() {
|
|
1763
|
+
return Math.hypot(
|
|
1764
|
+
this.#eye[0] - this.#cut_eye[0],
|
|
1765
|
+
this.#eye[1] - this.#cut_eye[1],
|
|
1766
|
+
this.#eye[2] - this.#cut_eye[2]
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* Take a fresh cut at wherever the camera is standing, and build the geometry for it.
|
|
1772
|
+
*/
|
|
1773
|
+
adapt() {
|
|
1774
|
+
if (this.#container === undefined) {
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
// the frustum is derived from matrices the renderer refreshes during its own frame, and an
|
|
1779
|
+
// adapt can land before one has run — a cut culled against last frame's planes would be a
|
|
1780
|
+
// silent, hard-to-see wrong answer
|
|
1781
|
+
this.camera.update();
|
|
1782
|
+
|
|
1783
|
+
this.#view.eye.set(this.#eye);
|
|
1784
|
+
this.#view.screen_height = this.canvas.height;
|
|
1785
|
+
this.#view.fov_y = this.camera.fov;
|
|
1786
|
+
this.#view.frustum.set(this.camera.frustum);
|
|
1787
|
+
|
|
1788
|
+
this.#cut = vgeo_select_cut(this.#container, this.#view);
|
|
1789
|
+
|
|
1790
|
+
const started = performance.now();
|
|
1791
|
+
|
|
1792
|
+
const previous = this.#cut_geometry;
|
|
1793
|
+
|
|
1794
|
+
this.#cut_geometry = vgeo_build_cut_geometry(this.#container, this.#cut, this.#color_mode);
|
|
1795
|
+
|
|
1796
|
+
this.#build_ms = performance.now() - started;
|
|
1797
|
+
|
|
1798
|
+
this.#batch.clear();
|
|
1799
|
+
|
|
1800
|
+
// Residency is keyed on the geometry and deliberately survives leaving the batch, so the
|
|
1801
|
+
// cut that was just replaced would hold its buffers forever otherwise — and this tool
|
|
1802
|
+
// replaces one on every drag of the tau slider.
|
|
1803
|
+
if (previous !== undefined) {
|
|
1804
|
+
this.#dynamic.release(previous.geometry);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
this.#mesh = DynamicMesh.from(this.#cut_geometry.geometry);
|
|
1808
|
+
this.#mesh.updateMatrices();
|
|
1809
|
+
|
|
1810
|
+
this.#batch.add(this.#mesh);
|
|
1811
|
+
|
|
1812
|
+
this.#cut_eye.set(this.#eye);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
/**
|
|
1816
|
+
* @param {ArrayBuffer} array_buffer
|
|
1817
|
+
* @param {string} label
|
|
1818
|
+
*/
|
|
1819
|
+
load(array_buffer, label) {
|
|
1820
|
+
this.#file_label = label;
|
|
1821
|
+
this.#file_bytes = array_buffer.byteLength;
|
|
1822
|
+
|
|
1823
|
+
const started = performance.now();
|
|
1824
|
+
|
|
1825
|
+
try {
|
|
1826
|
+
this.#container = vgeo_read_container(array_buffer);
|
|
1827
|
+
} catch (e) {
|
|
1828
|
+
this.#container = undefined;
|
|
1829
|
+
this.#cut_geometry = undefined;
|
|
1830
|
+
this.#batch.clear();
|
|
1831
|
+
this.#status = String(e.message ?? e);
|
|
1832
|
+
this.#refresh_panel();
|
|
1833
|
+
|
|
1834
|
+
throw e;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
this.#read_ms = performance.now() - started;
|
|
1838
|
+
this.#status = '';
|
|
1839
|
+
|
|
1840
|
+
this.#frame_camera();
|
|
1841
|
+
this.adapt();
|
|
1842
|
+
this.#refresh_panel();
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
/**
|
|
1846
|
+
* @param {string} url
|
|
1847
|
+
* @returns {Promise<void>}
|
|
1848
|
+
*/
|
|
1849
|
+
async load_url(url) {
|
|
1850
|
+
this.#status = `fetching ${url}`;
|
|
1851
|
+
this.#refresh_panel();
|
|
1852
|
+
|
|
1853
|
+
const response = await fetch(url);
|
|
1854
|
+
|
|
1855
|
+
if (!response.ok) {
|
|
1856
|
+
this.#status = `${url} — HTTP ${response.status}`;
|
|
1857
|
+
this.#refresh_panel();
|
|
1858
|
+
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
this.load(await response.arrayBuffer(), url.split('/').pop());
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* Put the camera where the whole asset is on screen, and scale the clip range to it — vgeo
|
|
1867
|
+
* assets are authored at whatever scale the source used, and the Stanford models are a tenth of
|
|
1868
|
+
* a unit across.
|
|
1869
|
+
*/
|
|
1870
|
+
#frame_camera() {
|
|
1871
|
+
const sphere = this.#container.object_sphere;
|
|
1872
|
+
|
|
1873
|
+
const radius = Math.max(sphere[3], 1e-6);
|
|
1874
|
+
const center = new Vector3(sphere[0], sphere[1], sphere[2]);
|
|
1875
|
+
|
|
1876
|
+
const distance = radius / Math.tan(this.camera.fov * 0.5) * 1.15;
|
|
1877
|
+
|
|
1878
|
+
const eye = new Vector3(0.55, 0.42, 0.72);
|
|
1879
|
+
|
|
1880
|
+
eye.normalize();
|
|
1881
|
+
eye.multiplyScalar(distance);
|
|
1882
|
+
eye.add(center);
|
|
1883
|
+
|
|
1884
|
+
this.camera.near = radius * 0.005;
|
|
1885
|
+
this.camera.far = radius * 200;
|
|
1886
|
+
|
|
1887
|
+
this.controller.distanceLimits.min = radius * 0.02;
|
|
1888
|
+
this.controller.distanceLimits.max = radius * 200;
|
|
1889
|
+
this.controller.movement_speed_scale = radius;
|
|
1890
|
+
|
|
1891
|
+
this.controller.look(eye, center);
|
|
1892
|
+
|
|
1893
|
+
this.#eye[0] = eye.x;
|
|
1894
|
+
this.#eye[1] = eye.y;
|
|
1895
|
+
this.#eye[2] = eye.z;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
#build_interface() {
|
|
1899
|
+
const style = document.createElement('style');
|
|
1900
|
+
|
|
1901
|
+
style.textContent = PANEL_CSS;
|
|
1902
|
+
document.head.appendChild(style);
|
|
1903
|
+
|
|
1904
|
+
const drop = document.createElement('div');
|
|
1905
|
+
|
|
1906
|
+
drop.id = 'vgeo-drop';
|
|
1907
|
+
drop.textContent = 'drop a .vgeo file';
|
|
1908
|
+
document.body.appendChild(drop);
|
|
1909
|
+
|
|
1910
|
+
let drag_depth = 0;
|
|
1911
|
+
|
|
1912
|
+
window.addEventListener('dragenter', (event) => {
|
|
1913
|
+
event.preventDefault();
|
|
1914
|
+
drag_depth++;
|
|
1915
|
+
drop.classList.add('active');
|
|
1916
|
+
});
|
|
1917
|
+
|
|
1918
|
+
window.addEventListener('dragover', (event) => event.preventDefault());
|
|
1919
|
+
|
|
1920
|
+
window.addEventListener('dragleave', () => {
|
|
1921
|
+
drag_depth = Math.max(0, drag_depth - 1);
|
|
1922
|
+
|
|
1923
|
+
if (drag_depth === 0) {
|
|
1924
|
+
drop.classList.remove('active');
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
|
|
1928
|
+
window.addEventListener('drop', async (event) => {
|
|
1929
|
+
event.preventDefault();
|
|
1930
|
+
|
|
1931
|
+
drag_depth = 0;
|
|
1932
|
+
drop.classList.remove('active');
|
|
1933
|
+
|
|
1934
|
+
const file = event.dataTransfer.files[0];
|
|
1935
|
+
|
|
1936
|
+
if (file === undefined) {
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
this.#status = `reading ${file.name}`;
|
|
1941
|
+
this.#refresh_panel();
|
|
1942
|
+
|
|
1943
|
+
this.load(await file.arrayBuffer(), file.name);
|
|
1944
|
+
});
|
|
1945
|
+
|
|
1946
|
+
this.panel = document.createElement('div');
|
|
1947
|
+
this.panel.id = 'vgeo-panel';
|
|
1948
|
+
document.body.appendChild(this.panel);
|
|
1949
|
+
|
|
1950
|
+
this.#refresh_panel();
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
/**
|
|
1954
|
+
* @param {string} id
|
|
1955
|
+
* @param {function(HTMLElement): void} bind
|
|
1956
|
+
*/
|
|
1957
|
+
#wire(id, bind) {
|
|
1958
|
+
const element = this.panel.querySelector(`#${id}`);
|
|
1959
|
+
|
|
1960
|
+
if (element !== null) {
|
|
1961
|
+
bind(element);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
#refresh_panel() {
|
|
1966
|
+
const container = this.#container;
|
|
1967
|
+
|
|
1968
|
+
const header = [`<h1>.vgeo format viewer</h1>`];
|
|
1969
|
+
|
|
1970
|
+
if (this.#status !== '') {
|
|
1971
|
+
header.push(`<div class="muted">${this.#status}</div>`);
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
if (container === undefined) {
|
|
1975
|
+
this.panel.innerHTML = header.join('');
|
|
1976
|
+
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
const defects = container.defects;
|
|
1981
|
+
|
|
1982
|
+
const validation = defects.length === 0
|
|
1983
|
+
? `<div class="good">container valid — every invariant holds</div>`
|
|
1984
|
+
: `<div class="bad">${defects.length} defect(s)</div><ol class="bad">${
|
|
1985
|
+
defects.slice(0, 12).map((d) => `<li>${d.toString()}</li>`).join('')
|
|
1986
|
+
}</ol>`;
|
|
1987
|
+
|
|
1988
|
+
const rows = [
|
|
1989
|
+
['file', `${this.#file_label} · ${human_bytes(this.#file_bytes)}`],
|
|
1990
|
+
['pages', page_storage(container)],
|
|
1991
|
+
['format', `v${container.format_version} · encoding ${container.payload_encoding}`],
|
|
1992
|
+
['asset id', container.asset_id.slice(0, 16)],
|
|
1993
|
+
['source', `${thousands(container.source_face_count)} tris / ${thousands(container.source_vertex_count)} verts`],
|
|
1994
|
+
['contents', `${thousands(container.cluster_count)} clusters · ${thousands(container.pages.length)} pages · ${container.levels.length} levels`],
|
|
1995
|
+
['per-vertex normals', `${thousands(container.per_vertex_normal_cluster_count)} / ${thousands(container.cluster_count)} clusters`],
|
|
1996
|
+
['read', `${this.#read_ms.toFixed(1)} ms`],
|
|
1997
|
+
];
|
|
1998
|
+
|
|
1999
|
+
this.panel.innerHTML = header.join('')
|
|
2000
|
+
+ `<h2>container</h2>${panel_table(rows)}`
|
|
2001
|
+
+ `<h2>validation</h2>${validation}`
|
|
2002
|
+
+ `<h2>cut</h2>`
|
|
2003
|
+
+ `<div id="vgeo-cut">${this.#cut_html()}</div>`
|
|
2004
|
+
+ `<h2>selection</h2>`
|
|
2005
|
+
+ `<div class="row"><span class="muted">tau</span><span id="vgeo-tau-value">${this.#view.tau.toFixed(2)} px</span></div>`
|
|
2006
|
+
+ `<input id="vgeo-tau" type="range" min="-1.3" max="1.7" step="0.01" value="${Math.log10(this.#view.tau)}">`
|
|
2007
|
+
+ `<button id="vgeo-adapt">adapt to view</button>`
|
|
2008
|
+
+ `<label><input id="vgeo-auto" type="checkbox" ${this.#auto_adapt ? 'checked' : ''}> follow the camera</label>`
|
|
2009
|
+
+ `<label><input id="vgeo-cull" type="checkbox" ${this.#view.cull_enabled ? 'checked' : ''}> frustum cull while selecting</label>`
|
|
2010
|
+
+ `<h2>display</h2>`
|
|
2011
|
+
+ `<select id="vgeo-color">`
|
|
2012
|
+
+ Object.values(VGEO_COLOR_MODE).map((mode) =>
|
|
2013
|
+
`<option value="${mode}" ${mode === this.#color_mode ? 'selected' : ''}>colour by ${mode}</option>`
|
|
2014
|
+
).join('')
|
|
2015
|
+
+ `</select>`;
|
|
2016
|
+
|
|
2017
|
+
this.#wire('vgeo-adapt', (element) => {
|
|
2018
|
+
element.onclick = () => {
|
|
2019
|
+
this.adapt();
|
|
2020
|
+
this.#refresh_panel();
|
|
2021
|
+
};
|
|
2022
|
+
});
|
|
2023
|
+
|
|
2024
|
+
this.#wire('vgeo-tau', (element) => {
|
|
2025
|
+
element.oninput = () => {
|
|
2026
|
+
this.#view.tau = Math.pow(10, Number(element.value));
|
|
2027
|
+
|
|
2028
|
+
this.adapt();
|
|
2029
|
+
this.#refresh_panel();
|
|
2030
|
+
};
|
|
2031
|
+
});
|
|
2032
|
+
|
|
2033
|
+
this.#wire('vgeo-auto', (element) => {
|
|
2034
|
+
element.onchange = () => {
|
|
2035
|
+
this.#auto_adapt = element.checked;
|
|
2036
|
+
};
|
|
2037
|
+
});
|
|
2038
|
+
|
|
2039
|
+
this.#wire('vgeo-cull', (element) => {
|
|
2040
|
+
element.onchange = () => {
|
|
2041
|
+
this.#view.cull_enabled = element.checked;
|
|
2042
|
+
|
|
2043
|
+
this.adapt();
|
|
2044
|
+
this.#refresh_panel();
|
|
2045
|
+
};
|
|
2046
|
+
});
|
|
2047
|
+
|
|
2048
|
+
this.#wire('vgeo-color', (element) => {
|
|
2049
|
+
element.onchange = () => {
|
|
2050
|
+
this.#color_mode = element.value;
|
|
2051
|
+
|
|
2052
|
+
this.adapt();
|
|
2053
|
+
this.#refresh_panel();
|
|
2054
|
+
};
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
const viewer = new VGeoViewer();
|
|
2060
|
+
|
|
2061
|
+
window.__vgeo = viewer;
|
|
2062
|
+
|
|
2063
|
+
viewer.start();
|