Skip to content

TrailView: fixed models as files, and the model spec #3785

Closed

Description

@timohueser

Status: approved

Part of epic #3782 (parts 1 and 2). The epic holds the facts, the measurements and the full design.

TL;DR

Goal: TrailView fetches every fixed-shape instance model (trees, plants, rocks, animals, small objects of the kinds) as a file that the web build makes; the device builds no model, and no pixel changes.
Decision: a Vite plugin runs today's generators and mesh code in Node and emits packed model files (16-byte vertices, meshopt coded) with a manifest module; the engine fetches them per region and keeps them in the device cache entry models (8 MiB). specs/trailview-models.md holds the file format and the model budget.
Systems: trailview, web-planner
Contracts: new specs/trailview-models.md
Size: M (2 systems, a new contract, more than 500 changed lines)

Plan

  1. models/pack.ts: the file codec; quantize and the derived values (largest, radius, spread, proxy, outlines, sinks) move here from instances/instances.ts. Trees and plants are packed from float32, the others from float64, as today.
  2. models/bake.ts and vite/model-files.ts: build the files and the manifest virtual:models (file URLs, model ids, keepsHeading, phase colour matrices and own-crown flags, plant ground rules and sized, breed heights and coats, objects in POINT_MODELS order after the rocks). The dev server rebuilds on a change of any module in the entry's module graph. The build fails on a model over the budget of the spec.
  3. instances/instances.ts: take packed meshes with their derived values.
  4. vegetation/tree-models.ts, plants.ts, forest.ts, rows.ts, dressing/dressing.ts, structures/kind-points.ts: fetch the files in today's order; a 404 is not asked again in the session and warns once.
  5. Delete model-worker.ts, model-entry.ts, plant-worker.ts, the tree entry of vite/bundle-version.ts, virtual:tree-version; terrain/device-cache.ts: models (8 MiB) replaces trees.
  6. specs/trailview-models.md: the format and the budget table of the epic's part 2. docs/design/trailview.md: own vite/model-files.ts.

The epic's ## Files lists every file.

Done when

  • models/pack.test.ts: each file decodes to a fresh pack of the generator output, bit for bit.
  • In the pull request, once: the pools' bytes and model records of develop and the branch are equal for every model, phase, season and seed; a pixel diff of three still views (forest summer, forest winter, pasture with herds) shows 0 changed pixels.
  • Cold first open of the Alps, develop against the branch, alternated, 3 runs each, on the M1 Pro and once on the iPhone 13 (app host of prototype #3765: TrailView in the iOS app's web view on the iPhone 13 #3768): the time to the near trees and to the first complete view are not longer on the branch.
  • An open with no network after a first open draws trees, plants and herds from the device cache.
  • The web suites that obc test affected --base origin/develop selects pass, and npm run check passes in builder/web.

The phone plan #3656 lists the model workers in its budget table; whichever lands second adapts those rows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions