Improve Cesium cruise smoothness

This commit is contained in:
2026-08-03 15:17:51 +08:00
parent a824bee69b
commit 0d2dc2228c
10 changed files with 224 additions and 13 deletions

View File

@@ -0,0 +1 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}

View File

@@ -0,0 +1 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}

View File

@@ -0,0 +1,67 @@
# Smooth Cesium preview vehicle cruise
## Goal
Improve perceived smoothness of vehicle cruise in the Cesium preview for
`nantaizi-lake-innovation-valley` while the scene model is visible, especially
when Follow passes through scrub-heavy areas.
The initial preview-layer optimization helped but did not solve the root cause:
closing `Scene` helps a lot, and the current nantaizi GLB contains about 707
scrub bush nodes. The root fix is allowed to reduce scrub bush instance density
while preserving the flat scrub ground cover and existing preview controls.
## Requirements
1. Optimize `scripts/lib/cesium-preview.js` so vehicle animation does less
per-frame work during cruise without reducing default visual clarity.
2. Preserve existing controls and behavior:
- Play/Pause still drives `viewer.clock.shouldAnimate`.
- Speed slider still maps m/s to clock multiplier.
- Vehicle selection still chooses the follow target.
- Scene/routes/vehicles/FPS/diagnostics toggles still work.
- Follow mode still tracks the selected vehicle.
3. Keep the preview layer dependency-free and browser-native; no build step,
npm dependency, module system, or hard-coded area filenames.
4. Reduce scrub edge bush instance density in `blender/generate_scene.py` to
lower Cesium render load in scrub-heavy Follow views. Preserve deterministic
sampling, scrub ground polygons, scrub tree sampling, and scene stats fields.
5. Regenerate or copy the updated preview JS into
`outputs/nantaizi-lake-innovation-valley/cesium-preview.js` only if needed
for local manual verification; do not commit generated outputs.
6. Rebuild `nantaizi-lake-innovation-valley` `blender,cesium,preview` outputs
for manual validation. This task intentionally changes generated GLB
structure, so full parity-identical output is not expected.
## Acceptance Criteria
- [ ] `scripts/lib/cesium-preview.js` has a small, reviewable optimization that
reduces per-frame allocations or render overhead for vehicle cruise.
- [ ] `blender/generate_scene.py` reduces nantaizi scrub bush node count by at
least 50% while keeping scrub polygons present.
- [ ] Vehicle controls listed in Requirements continue to work by inspection
and/or local smoke check.
- [ ] Blender/Cesium rebuild for `nantaizi-lake-innovation-valley` completes
and generated metadata still includes scrub counts.
- [ ] `node --check scripts/lib/cesium-preview.js` passes.
- [ ] `python3 -m py_compile blender/generate_scene.py` passes.
- [ ] If local output preview JS is updated for testing, it remains ignored and
is not committed.
## Out Of Scope
- Full scene geometry/material optimization beyond scrub edge bush density.
- Reducing tree count or changing road/building/water assets.
- Replacing Cesium or adding profiling libraries.
- Visual design changes to the preview UI.
## Technical Notes
- User confirmed closing `Scene` improves smoothness, so the scene render load
is a real contributor.
- Current route data is small: `nantaizi-lake-innovation-valley` has 9 route
segments and the preview uses at most 5 vehicles.
- Current nantaizi GLB has 1271 nodes; about 707 are scrub bush nodes. Lowering
scrub edge sampling from `0.82m / 180 per patch` to `1.8m / 60 per patch`
should reduce nantaizi bush samples to about 266 while leaving scrub ground
cover intact.

View File

@@ -0,0 +1,57 @@
# Smooth Cesium preview vehicle cruise report
## Root Cause
The first preview-only optimization helped but did not address the main load.
User testing showed Follow still stuttered in scrub-heavy areas, while disabling
`Scene` improved smoothness substantially.
Current nantaizi GLB before the scrub-density change:
- GLB nodes: `1271`
- Scrub bush nodes: `707`
- Scrub polygons: `5`
The route data is small (`9` route segments, preview uses at most `5` vehicles),
so route interpolation is not the primary bottleneck.
## Changes
- `scripts/lib/cesium-preview.js`
- Route helper polyline is now opaque instead of alpha blended.
- Route helper polyline uses `arcType: Cesium.ArcType.NONE`.
- Vehicle orientation and chase-follow camera callbacks reuse scratch
`JulianDate`, `HeadingPitchRoll`, `Quaternion`, and `Matrix4` objects.
- Default Cesium resolution and antialiasing are preserved; no blurry
performance mode is enabled by default.
- `blender/generate_scene.py`
- `SCRUB_BUSH_SPACING`: `0.82 -> 1.8`
- `SCRUB_BUSH_LIMIT_PER_PATCH`: `180 -> 60`
- Scrub ground cover remains unchanged.
## Validation
Commands run:
```bash
node --check scripts/lib/cesium-preview.js
python3 -m py_compile blender/generate_scene.py
python3 -m unittest blender/tests/test_pure.py
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender,cesium,preview
node scripts/glb-digest.js outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley.glb --out /tmp/nantaizi-after-scrub-glb-digest.json
```
Results after rebuild:
- `SCENE_DONE` reports `scrub_bushes: 266`.
- GLB nodes: `830`
- Scrub bush nodes: `266`
- Scrub polygons in metadata: `5`
- Route segments in preview route JSON: `9`
- GLB size: about `31.96 MB`
## Deferred
If Follow still stutters after this density reduction, the next root-level work
should target the bush asset itself: lower-poly bush mesh, explicit LOD, or a
proper instancing path supported by Cesium/glTF.

View File

@@ -0,0 +1,26 @@
{
"id": "smooth-cesium-preview-vehicle-cruise",
"name": "smooth-cesium-preview-vehicle-cruise",
"title": "Smooth Cesium preview vehicle cruise",
"description": "Optimize Cesium preview vehicle cruise smoothness without changing Blender or GLB output.",
"status": "in_progress",
"dev_type": null,
"scope": null,
"package": null,
"priority": "P2",
"creator": "dingkang",
"assignee": "dingkang",
"createdAt": "2026-08-03",
"completedAt": null,
"branch": null,
"base_branch": "main",
"worktree_path": null,
"commit": null,
"pr_url": null,
"subtasks": [],
"children": [],
"parent": null,
"relatedFiles": [],
"notes": "",
"meta": {}
}