@woosh/meep-engine 3.68.0 → 3.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/editor/ecs/component/editors/ecs/Trail3DEditor.d.ts +2 -17
- package/editor/ecs/component/editors/ecs/Trail3DEditor.d.ts.map +1 -1
- package/editor/ecs/component/editors/ecs/Trail3DEditor.js +3 -18
- package/package.json +1 -1
- package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts +33 -65
- package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts.map +1 -1
- package/src/engine/graphics/ecs/trail3d/Trail3D.js +37 -245
- package/src/engine/graphics/ecs/trail3d/Trail3DFlags.d.ts +0 -4
- package/src/engine/graphics/ecs/trail3d/Trail3DFlags.js +4 -10
- package/src/engine/graphics/ecs/trail3d/seed_trail_stroke.d.ts +13 -10
- package/src/engine/graphics/ecs/trail3d/seed_trail_stroke.d.ts.map +1 -1
- package/src/engine/graphics/ecs/trail3d/seed_trail_stroke.js +28 -37
- package/src/engine/graphics/ecs/trail3d/trail_knot_count.d.ts +10 -0
- package/src/engine/graphics/ecs/trail3d/trail_knot_count.d.ts.map +1 -0
- package/src/engine/graphics/ecs/trail3d/trail_knot_count.js +27 -0
- package/src/engine/graphics/trail/TrailKnots.d.ts +62 -0
- package/src/engine/graphics/trail/TrailKnots.d.ts.map +1 -0
- package/src/engine/graphics/trail/TrailKnots.js +137 -0
- package/src/engine/graphics/trail/tube/TubeXMaterialSpec.d.ts +1 -1
- package/src/engine/graphics/trail/tube/TubeXMaterialSpec.js +1 -1
- package/src/engine/graphics3/EntityRowHold.d.ts +48 -0
- package/src/engine/graphics3/EntityRowHold.d.ts.map +1 -0
- package/src/engine/graphics3/EntityRowHold.js +128 -0
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +6 -2
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUParticleEmitterSystem.js +11 -44
- package/src/engine/graphics3/Trail3DSystem.d.ts +69 -35
- package/src/engine/graphics3/Trail3DSystem.d.ts.map +1 -1
- package/src/engine/graphics3/Trail3DSystem.js +380 -81
- package/src/engine/physics/fluid/ecs/FluidObstacle.d.ts +17 -0
- package/src/engine/physics/fluid/ecs/FluidObstacle.d.ts.map +1 -1
- package/src/engine/physics/fluid/ecs/FluidObstacle.js +22 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +6 -5
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts.map +1 -1
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.js +14 -3
- package/src/engine/physics/fluid/obstacle/FLUID_OBSTACLE_RECORD_STRUCT.d.ts +9 -1
- package/src/engine/physics/fluid/obstacle/FLUID_OBSTACLE_RECORD_STRUCT.d.ts.map +1 -1
- package/src/engine/physics/fluid/obstacle/FLUID_OBSTACLE_RECORD_STRUCT.js +11 -1
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_record_create.d.ts +5 -0
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_record_create.d.ts.map +1 -1
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_record_create.js +2 -0
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_write_gpu_record.d.ts +4 -3
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_write_gpu_record.d.ts.map +1 -1
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_write_gpu_record.js +11 -3
- package/src/shade/playground/trails/index.html +50 -0
- package/src/shade/playground/trails/main.d.ts +2 -0
- package/src/shade/playground/trails/main.d.ts.map +1 -0
- package/src/shade/playground/trails/main.js +258 -0
- package/src/shade/renderer/animation/animation_curve_write_keys.d.ts +18 -0
- package/src/shade/renderer/animation/animation_curve_write_keys.d.ts.map +1 -0
- package/src/shade/renderer/animation/animation_curve_write_keys.js +34 -0
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/ColorGrade.js +13 -36
- package/src/shade/renderer/dynamic/GPUDynamicMeshResidency.js +2 -2
- package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.d.ts +2 -13
- package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.js +6 -21
- package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.d.ts +17 -6
- package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.js +38 -178
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.d.ts +7 -9
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.js +17 -106
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.d.ts +7 -17
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.js +18 -118
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING.d.ts +14 -0
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING.js +18 -0
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING_APPLY_STRUCT.d.ts +3 -1
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING_APPLY_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING_APPLY_STRUCT.js +4 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +9 -0
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.js +20 -4
- package/src/shade/renderer/fluid/forcing/chunk_fluid_forcing_cell.d.ts +11 -2
- package/src/shade/renderer/fluid/forcing/chunk_fluid_forcing_cell.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/chunk_fluid_forcing_cell.js +59 -2
- package/src/shade/renderer/fluid/forcing/shader_fluid_forcing_apply.d.ts +4 -1
- package/src/shade/renderer/fluid/forcing/shader_fluid_forcing_apply.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/shader_fluid_forcing_apply.js +367 -341
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.d.ts +6 -2
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.d.ts.map +1 -1
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.js +339 -282
- package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts +3 -2
- package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts.map +1 -1
- package/src/shade/renderer/grass/press/shader_grass_press_mark.js +5 -3
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_draw.d.ts +49 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_draw.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_draw.js +144 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_splat.d.ts +71 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_splat.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_splat.js +152 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unlit_varyings.d.ts +21 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unlit_varyings.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unlit_varyings.js +30 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_avboit_unlit.d.ts +101 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_avboit_unlit.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_avboit_unlit.js +306 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +11 -4
- package/src/shade/renderer/trails/GPUTrailAVBOITChannel.d.ts +69 -0
- package/src/shade/renderer/trails/GPUTrailAVBOITChannel.d.ts.map +1 -0
- package/src/shade/renderer/trails/GPUTrailAVBOITChannel.js +129 -0
- package/src/shade/renderer/trails/GPUTrailSystem.d.ts +164 -0
- package/src/shade/renderer/trails/GPUTrailSystem.d.ts.map +1 -0
- package/src/shade/renderer/trails/GPUTrailSystem.js +725 -0
- package/src/shade/renderer/trails/data/TRAIL_DATABASE_SPEC.d.ts +14 -0
- package/src/shade/renderer/trails/data/TRAIL_DATABASE_SPEC.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_DATABASE_SPEC.js +38 -0
- package/src/shade/renderer/trails/data/TRAIL_KNOT.d.ts +66 -0
- package/src/shade/renderer/trails/data/TRAIL_KNOT.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_KNOT.js +154 -0
- package/src/shade/renderer/trails/data/TRAIL_RECORD.d.ts +19 -0
- package/src/shade/renderer/trails/data/TRAIL_RECORD.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_RECORD.js +68 -0
- package/src/shade/renderer/trails/data/TRAIL_STATE.d.ts +18 -0
- package/src/shade/renderer/trails/data/TRAIL_STATE.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_STATE.js +43 -0
- package/src/shade/renderer/trails/graph_trails.d.ts +58 -0
- package/src/shade/renderer/trails/graph_trails.d.ts.map +1 -0
- package/src/shade/renderer/trails/graph_trails.js +155 -0
- package/src/shade/renderer/trails/graph_trails_avboit.d.ts +126 -0
- package/src/shade/renderer/trails/graph_trails_avboit.d.ts.map +1 -0
- package/src/shade/renderer/trails/graph_trails_avboit.js +300 -0
- package/src/shade/renderer/trails/runtime/TrailFadeCurves.d.ts +56 -0
- package/src/shade/renderer/trails/runtime/TrailFadeCurves.d.ts.map +1 -0
- package/src/shade/renderer/trails/runtime/TrailFadeCurves.js +220 -0
- package/src/shade/renderer/trails/runtime/TrailKnotPool.d.ts +49 -0
- package/src/shade/renderer/trails/runtime/TrailKnotPool.d.ts.map +1 -0
- package/src/shade/renderer/trails/runtime/TrailKnotPool.js +162 -0
- package/src/shade/renderer/trails/runtime/TrailParameters.d.ts +52 -0
- package/src/shade/renderer/trails/runtime/TrailParameters.d.ts.map +1 -0
- package/src/shade/renderer/trails/runtime/TrailParameters.js +126 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_frame_transport.d.ts +23 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_frame_transport.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_frame_transport.js +57 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_knot_alpha.d.ts +14 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_knot_alpha.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_knot_alpha.js +40 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_seed.d.ts +18 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_seed.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_seed.js +64 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_segment.d.ts +14 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_segment.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_segment.js +51 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_update.d.ts +48 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_update.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_update.js +197 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_vertex.d.ts +34 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_vertex.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_vertex.js +111 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit.d.ts +24 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit.js +78 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit_segments.d.ts +23 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit_segments.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit_segments.js +130 -0
- package/src/shade/renderer/trails/shaders/shader_trail_draw_args.d.ts +29 -0
- package/src/shade/renderer/trails/shaders/shader_trail_draw_args.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_draw_args.js +78 -0
- package/src/shade/renderer/trails/shaders/shader_trail_seed.d.ts +18 -0
- package/src/shade/renderer/trails/shaders/shader_trail_seed.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_seed.js +79 -0
- package/src/shade/renderer/trails/shaders/shader_trail_update.d.ts +20 -0
- package/src/shade/renderer/trails/shaders/shader_trail_update.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_update.js +101 -0
- package/src/engine/graphics/ecs/trail3d/advance_trail.d.ts +0 -18
- package/src/engine/graphics/ecs/trail3d/advance_trail.d.ts.map +0 -1
- package/src/engine/graphics/ecs/trail3d/advance_trail.js +0 -42
- package/src/engine/graphics/ecs/trail3d/seed_trail_tube.d.ts +0 -14
- package/src/engine/graphics/ecs/trail3d/seed_trail_tube.d.ts.map +0 -1
- package/src/engine/graphics/ecs/trail3d/seed_trail_tube.js +0 -75
- package/src/engine/graphics/ecs/trail3d/trail_head_position.d.ts +0 -17
- package/src/engine/graphics/ecs/trail3d/trail_head_position.d.ts.map +0 -1
- package/src/engine/graphics/ecs/trail3d/trail_head_position.js +0 -19
- package/src/engine/graphics/trail/tube/TubeX.d.ts +0 -186
- package/src/engine/graphics/trail/tube/TubeX.d.ts.map +0 -1
- package/src/engine/graphics/trail/tube/TubeX.js +0 -575
- package/src/engine/graphics/trail/tube/simulator/TubeXFixedPhysicsSimulator.d.ts +0 -16
- package/src/engine/graphics/trail/tube/simulator/TubeXFixedPhysicsSimulator.d.ts.map +0 -1
- package/src/engine/graphics/trail/tube/simulator/TubeXFixedPhysicsSimulator.js +0 -34
- package/src/engine/graphics/trail/tube/tube_attributes_spec.d.ts +0 -27
- package/src/engine/graphics/trail/tube/tube_attributes_spec.d.ts.map +0 -1
- package/src/engine/graphics/trail/tube/tube_attributes_spec.js +0 -70
- package/src/engine/graphics3/trail/trail_tube_write_geometry.d.ts +0 -38
- package/src/engine/graphics3/trail/trail_tube_write_geometry.d.ts.map +0 -1
- package/src/engine/graphics3/trail/trail_tube_write_geometry.js +0 -119
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { EndianType } from "../../../../core/binary/EndianType.js";
|
|
2
|
-
import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
|
|
3
|
-
import { RowFirstTableSpec } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Per-vertex attribute layout for a {@link TubeX}.
|
|
7
|
-
*
|
|
8
|
-
* Unlike {@link RibbonX} (which extrudes in screen space and therefore stores
|
|
9
|
-
* the neighbouring positions to derive a 2D normal), the tube extrudes in WORLD
|
|
10
|
-
* space inside the vertex shader using a per-knot tangent frame. Every vertex of
|
|
11
|
-
* a knot's ring shares the same centre/frame/colour/etc and differs only by `off`
|
|
12
|
-
* (its angular position around the ring), so the heavy per-frame work is just
|
|
13
|
-
* writing the knot centre + frame to the ring's `radial+1` rows.
|
|
14
|
-
*
|
|
15
|
-
* Layout is floats-first then a float16 colour triple, padded to a 4-byte multiple
|
|
16
|
-
* so the interleaved Float32 view (stride = bytesPerRecord >> 2) stays aligned —
|
|
17
|
-
* the same trick {@link ribbon_attributes_spec} relies on. The colour is linear and
|
|
18
|
-
* not limited to 0..1, so a trail can be brighter than white.
|
|
19
|
-
*/
|
|
20
|
-
export const tube_attributes_spec = new RowFirstTableSpec([
|
|
21
|
-
// age (CPU-side bookkeeping for the simulator; NOT a GPU attribute)
|
|
22
|
-
BinaryDataType.Float32,
|
|
23
|
-
|
|
24
|
-
// position (ring centre, world space)
|
|
25
|
-
BinaryDataType.Float32,
|
|
26
|
-
BinaryDataType.Float32,
|
|
27
|
-
BinaryDataType.Float32,
|
|
28
|
-
|
|
29
|
-
// frame normal (ring basis axis 1, world space, unit)
|
|
30
|
-
BinaryDataType.Float32,
|
|
31
|
-
BinaryDataType.Float32,
|
|
32
|
-
BinaryDataType.Float32,
|
|
33
|
-
|
|
34
|
-
// frame binormal (ring basis axis 2, world space, unit)
|
|
35
|
-
BinaryDataType.Float32,
|
|
36
|
-
BinaryDataType.Float32,
|
|
37
|
-
BinaryDataType.Float32,
|
|
38
|
-
|
|
39
|
-
// off (angular position around the ring, 0..1; STATIC per radial index = uv.x)
|
|
40
|
-
BinaryDataType.Float32,
|
|
41
|
-
|
|
42
|
-
// uv_v (position along the tube; DYNAMIC = uv.y)
|
|
43
|
-
BinaryDataType.Float32,
|
|
44
|
-
|
|
45
|
-
// alpha
|
|
46
|
-
BinaryDataType.Float32,
|
|
47
|
-
|
|
48
|
-
// thickness (tube diameter; radius = thickness * 0.5)
|
|
49
|
-
BinaryDataType.Float32,
|
|
50
|
-
|
|
51
|
-
// color (linear, unbounded)
|
|
52
|
-
BinaryDataType.Float16,
|
|
53
|
-
BinaryDataType.Float16,
|
|
54
|
-
BinaryDataType.Float16,
|
|
55
|
-
|
|
56
|
-
// padding -> bytesPerRecord = 64 (divisible by 4, keeps the Float32 view aligned)
|
|
57
|
-
BinaryDataType.Uint16,
|
|
58
|
-
|
|
59
|
-
], EndianType.LittleEndian);
|
|
60
|
-
|
|
61
|
-
// Column indices into {@link tube_attributes_spec} for RowFirstTable read/write.
|
|
62
|
-
export const TUBE_ATTRIBUTE_ADDRESS_AGE = 0;
|
|
63
|
-
export const TUBE_ATTRIBUTE_ADDRESS_POSITION = 1;
|
|
64
|
-
export const TUBE_ATTRIBUTE_ADDRESS_NORMAL = 4;
|
|
65
|
-
export const TUBE_ATTRIBUTE_ADDRESS_BINORMAL = 7;
|
|
66
|
-
export const TUBE_ATTRIBUTE_ADDRESS_OFF = 10;
|
|
67
|
-
export const TUBE_ATTRIBUTE_ADDRESS_UV_V = 11;
|
|
68
|
-
export const TUBE_ATTRIBUTE_ADDRESS_ALPHA = 12;
|
|
69
|
-
export const TUBE_ATTRIBUTE_ADDRESS_THICKNESS = 13;
|
|
70
|
-
export const TUBE_ATTRIBUTE_ADDRESS_COLOR = 14;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extrude a {@link TubeX}'s knots into the geometry a {@link DynamicMesh} is already holding.
|
|
3
|
-
*
|
|
4
|
-
* **The ring is built here rather than in a shader, and that is what the path costs.** The legacy
|
|
5
|
-
* renderer draws a tube through a material of its own, so its vertex stage can hold the knot's
|
|
6
|
-
* frame and expand a ring from it; the dynamic path has one pipeline and one vertex layout —
|
|
7
|
-
* position and colour (D11) — so the same expansion happens on the CPU, once per knot ring per
|
|
8
|
-
* frame the trail moves. Widening the layout to carry a frame would mean a second pipeline for
|
|
9
|
-
* every dynamic mesh in the engine, which is the trade D5/D11 already refused.
|
|
10
|
-
*
|
|
11
|
-
* The arithmetic is `TubeMaterialX`'s, exactly: a ring vertex sits at its knot's centre displaced
|
|
12
|
-
* by `cos(angle) * normal + sin(angle) * binormal`, half a thickness out, at `angle = off * 2π`.
|
|
13
|
-
*
|
|
14
|
-
* **Written into rather than replaced.** GPU residency on the dynamic path is keyed on the geometry
|
|
15
|
-
* and survives leaving the batch, so a trail that produced a fresh geometry each frame would strand
|
|
16
|
-
* a vertex buffer per frame.
|
|
17
|
-
*
|
|
18
|
-
* Colour rides the vertices because that is what fades a trail along its length: the knot's own
|
|
19
|
-
* half-float colour as is, unclamped so HDR survives, with its alpha — the simulator's age fade, already scaled by the trail's
|
|
20
|
-
* base opacity — as the fourth channel. A knot that has aged out is written transparent rather than
|
|
21
|
-
* dropped, which is what the index buffer expects, and blending takes it out of the picture.
|
|
22
|
-
*
|
|
23
|
-
* **A knot's alpha is the opacity of the tube as seen, not of one face of it.** The tube is a closed
|
|
24
|
-
* hull drawn from both sides, so a line of sight through it crosses two faces, and the transparency
|
|
25
|
-
* pipeline composes their transmittances: written as is, an alpha of 0.5 would cover 0.75, and a
|
|
26
|
-
* linear fade would hold near solid for most of the trail's life and collapse at its tail. Each face
|
|
27
|
-
* therefore takes half the optical depth, `1 - √(1 - α)`, and the two together cover exactly `α`.
|
|
28
|
-
* This is the one place that knows the hull is crossed twice, so it is the one place that splits it;
|
|
29
|
-
* a ray through a bend crosses the tube twice over, and that overlap is real and reads denser. The
|
|
30
|
-
* alpha is clamped to `0..1` first, the range an opacity has — an authored fade curve may overshoot
|
|
31
|
-
* it, and the square root has no answer above one.
|
|
32
|
-
*
|
|
33
|
-
* @param {Geometry} geometry
|
|
34
|
-
* @param {TubeX} tube
|
|
35
|
-
* @returns {void}
|
|
36
|
-
*/
|
|
37
|
-
export function trail_tube_write_geometry(geometry: Geometry, tube: TubeX): void;
|
|
38
|
-
//# sourceMappingURL=trail_tube_write_geometry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trail_tube_write_geometry.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics3/trail/trail_tube_write_geometry.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,4EAFa,IAAI,CAiEhB"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { assert } from "../../../core/assert.js";
|
|
2
|
-
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
3
|
-
import {
|
|
4
|
-
geometry_obtain_attribute,
|
|
5
|
-
geometry_obtain_index
|
|
6
|
-
} from "../../../shade/renderer/geometry/geometry_obtain_attribute.js";
|
|
7
|
-
import { StandardAttributes } from "../../../shade/renderer/geometry/StandardAttributes.js";
|
|
8
|
-
import {
|
|
9
|
-
TUBE_ATTRIBUTE_ADDRESS_ALPHA,
|
|
10
|
-
TUBE_ATTRIBUTE_ADDRESS_BINORMAL,
|
|
11
|
-
TUBE_ATTRIBUTE_ADDRESS_COLOR,
|
|
12
|
-
TUBE_ATTRIBUTE_ADDRESS_NORMAL,
|
|
13
|
-
TUBE_ATTRIBUTE_ADDRESS_OFF,
|
|
14
|
-
TUBE_ATTRIBUTE_ADDRESS_POSITION,
|
|
15
|
-
TUBE_ATTRIBUTE_ADDRESS_THICKNESS
|
|
16
|
-
} from "../../graphics/trail/tube/tube_attributes_spec.js";
|
|
17
|
-
|
|
18
|
-
const TWO_PI = Math.PI * 2;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Extrude a {@link TubeX}'s knots into the geometry a {@link DynamicMesh} is already holding.
|
|
22
|
-
*
|
|
23
|
-
* **The ring is built here rather than in a shader, and that is what the path costs.** The legacy
|
|
24
|
-
* renderer draws a tube through a material of its own, so its vertex stage can hold the knot's
|
|
25
|
-
* frame and expand a ring from it; the dynamic path has one pipeline and one vertex layout —
|
|
26
|
-
* position and colour (D11) — so the same expansion happens on the CPU, once per knot ring per
|
|
27
|
-
* frame the trail moves. Widening the layout to carry a frame would mean a second pipeline for
|
|
28
|
-
* every dynamic mesh in the engine, which is the trade D5/D11 already refused.
|
|
29
|
-
*
|
|
30
|
-
* The arithmetic is `TubeMaterialX`'s, exactly: a ring vertex sits at its knot's centre displaced
|
|
31
|
-
* by `cos(angle) * normal + sin(angle) * binormal`, half a thickness out, at `angle = off * 2π`.
|
|
32
|
-
*
|
|
33
|
-
* **Written into rather than replaced.** GPU residency on the dynamic path is keyed on the geometry
|
|
34
|
-
* and survives leaving the batch, so a trail that produced a fresh geometry each frame would strand
|
|
35
|
-
* a vertex buffer per frame.
|
|
36
|
-
*
|
|
37
|
-
* Colour rides the vertices because that is what fades a trail along its length: the knot's own
|
|
38
|
-
* half-float colour as is, unclamped so HDR survives, with its alpha — the simulator's age fade, already scaled by the trail's
|
|
39
|
-
* base opacity — as the fourth channel. A knot that has aged out is written transparent rather than
|
|
40
|
-
* dropped, which is what the index buffer expects, and blending takes it out of the picture.
|
|
41
|
-
*
|
|
42
|
-
* **A knot's alpha is the opacity of the tube as seen, not of one face of it.** The tube is a closed
|
|
43
|
-
* hull drawn from both sides, so a line of sight through it crosses two faces, and the transparency
|
|
44
|
-
* pipeline composes their transmittances: written as is, an alpha of 0.5 would cover 0.75, and a
|
|
45
|
-
* linear fade would hold near solid for most of the trail's life and collapse at its tail. Each face
|
|
46
|
-
* therefore takes half the optical depth, `1 - √(1 - α)`, and the two together cover exactly `α`.
|
|
47
|
-
* This is the one place that knows the hull is crossed twice, so it is the one place that splits it;
|
|
48
|
-
* a ray through a bend crosses the tube twice over, and that overlap is real and reads denser. The
|
|
49
|
-
* alpha is clamped to `0..1` first, the range an opacity has — an authored fade curve may overshoot
|
|
50
|
-
* it, and the square root has no answer above one.
|
|
51
|
-
*
|
|
52
|
-
* @param {Geometry} geometry
|
|
53
|
-
* @param {TubeX} tube
|
|
54
|
-
* @returns {void}
|
|
55
|
-
*/
|
|
56
|
-
export function trail_tube_write_geometry(geometry, tube) {
|
|
57
|
-
assert.defined(geometry, 'geometry');
|
|
58
|
-
assert.defined(tube, 'tube');
|
|
59
|
-
|
|
60
|
-
const vertex_count = tube.vertex_count;
|
|
61
|
-
|
|
62
|
-
const positions = geometry_obtain_attribute(geometry, StandardAttributes.Position, 3, vertex_count);
|
|
63
|
-
const colors = geometry_obtain_attribute(geometry, StandardAttributes.Color, 4, vertex_count);
|
|
64
|
-
|
|
65
|
-
const table = tube.table;
|
|
66
|
-
|
|
67
|
-
// Views over the knot rows, not a copy of them. Every attribute up to the colour is a float, so
|
|
68
|
-
// a column index is also its offset in the float view; the colour is three half floats at the
|
|
69
|
-
// column that follows them.
|
|
70
|
-
const floats = new Float32Array(table.data);
|
|
71
|
-
const halves = new Float16Array(table.data);
|
|
72
|
-
|
|
73
|
-
const float_stride = tube.bytes_per_vertex >> 2;
|
|
74
|
-
const half_stride = tube.bytes_per_vertex >> 1;
|
|
75
|
-
|
|
76
|
-
const color_offset = TUBE_ATTRIBUTE_ADDRESS_COLOR * 2;
|
|
77
|
-
|
|
78
|
-
for (let i = 0; i < vertex_count; i++) {
|
|
79
|
-
const f = i * float_stride;
|
|
80
|
-
|
|
81
|
-
const angle = floats[f + TUBE_ATTRIBUTE_ADDRESS_OFF] * TWO_PI;
|
|
82
|
-
|
|
83
|
-
const c = Math.cos(angle);
|
|
84
|
-
const s = Math.sin(angle);
|
|
85
|
-
|
|
86
|
-
const radius = floats[f + TUBE_ATTRIBUTE_ADDRESS_THICKNESS] * 0.5;
|
|
87
|
-
|
|
88
|
-
const nx = floats[f + TUBE_ATTRIBUTE_ADDRESS_NORMAL];
|
|
89
|
-
const ny = floats[f + TUBE_ATTRIBUTE_ADDRESS_NORMAL + 1];
|
|
90
|
-
const nz = floats[f + TUBE_ATTRIBUTE_ADDRESS_NORMAL + 2];
|
|
91
|
-
|
|
92
|
-
const bx = floats[f + TUBE_ATTRIBUTE_ADDRESS_BINORMAL];
|
|
93
|
-
const by = floats[f + TUBE_ATTRIBUTE_ADDRESS_BINORMAL + 1];
|
|
94
|
-
const bz = floats[f + TUBE_ATTRIBUTE_ADDRESS_BINORMAL + 2];
|
|
95
|
-
|
|
96
|
-
const p = i * 3;
|
|
97
|
-
|
|
98
|
-
positions[p] = floats[f + TUBE_ATTRIBUTE_ADDRESS_POSITION] + (c * nx + s * bx) * radius;
|
|
99
|
-
positions[p + 1] = floats[f + TUBE_ATTRIBUTE_ADDRESS_POSITION + 1] + (c * ny + s * by) * radius;
|
|
100
|
-
positions[p + 2] = floats[f + TUBE_ATTRIBUTE_ADDRESS_POSITION + 2] + (c * nz + s * bz) * radius;
|
|
101
|
-
|
|
102
|
-
const h = i * half_stride + color_offset;
|
|
103
|
-
const o = i * 4;
|
|
104
|
-
|
|
105
|
-
colors[o] = halves[h];
|
|
106
|
-
colors[o + 1] = halves[h + 1];
|
|
107
|
-
colors[o + 2] = halves[h + 2];
|
|
108
|
-
// half the optical depth: the face behind this one carries the other half
|
|
109
|
-
colors[o + 3] = 1 - Math.sqrt(1 - clamp01(floats[f + TUBE_ATTRIBUTE_ADDRESS_ALPHA]));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const source_indices = tube.indices;
|
|
113
|
-
|
|
114
|
-
const indices = geometry_obtain_index(geometry, source_indices.length);
|
|
115
|
-
|
|
116
|
-
indices.set(source_indices);
|
|
117
|
-
|
|
118
|
-
geometry.needsUpdate = true;
|
|
119
|
-
}
|