fast-mesh-wasm
    Preparing search index...

    Class SceneStore

    An observable store over a scene. Read with getSnapshot and subscribe; change through its actions. Call commitFrame once per animation frame instead of the scene's.

    Index
    mode: "local" | "worker"

    "local" over a Scene, "worker" over a WorkerScene.

    scene: SceneLike

    The scene, for the renderer adapters (bindMesh, ...).

    • The targets of the store-owned field behind the mesh's colouring (the one last sent to the scene), in the field's order: the order its nearest-target indices (Scene.fieldNearest, WorkerScene.fetchFieldNearest) refer to. That is ascending scene id, not the order of distanceTo or of a contact group's members. A target removed since leaves the list, as it leaves the field. Frozen; null when the mesh has no colouring.

      Parameters

      Returns readonly MeshHandle[] | null

      UNKNOWN_MESH for a mesh not in the store; INVALID_ARGUMENT once the store is disposed.

    • Call once per animation frame (instead of the scene's commitFrame()): applies the frame's declarative changes, then commits the scene's frame and returns its change records. From the first call on, declarative changes wait for it instead of applying on a microtask.

      Returns MeshChange[]

    • Removes the distance fields the store owns (fast-mesh-store:<n>, and so the colourings by them) and stops listening to the scene. The rest of the scene is left as it is (it is the app's). On a Worker scene the removals are queued like any call, and sent with the scene's next commitFrame(); errors from a scene that can no longer take them (a poisoned Worker scene, for one) are ignored. Later actions throw INVALID_ARGUMENT; the last snapshot stays readable.

      Returns void

    • The values of the store-owned field behind the mesh's colouring (the one last sent to the scene), one per vertex slot, as of the field's last update: a copy the caller owns. null when the mesh has no colouring. On a Worker scene the request is ordered after the calls made before it, so it reads the colouring last flushed. Never a history step.

      Rejects with UNKNOWN_MESH for a mesh not in the store, and INVALID_ARGUMENT once the store is disposed.

      Parameters

      Returns Promise<Float32Array<ArrayBufferLike> | null>

    • Removes a mesh; it leaves the snapshot (and the selection) at once. The scene drops the fields measured to it alone, and the colourings by them: a mesh coloured by distance to it alone shows no colouring, keeps its rule in desired, and is in "error" (UNKNOWN_MESH) from the next flush until its colouring changes. A colouring measured to it and other meshes keeps the others (its distanceTo loses the mesh). It leaves its contact groups, whose members' partners follow. Sections stop cutting it.

      Parameters

      Returns void

    • Sets contact group id, or removes it with null. Every member is coloured by group.coloring with its partners (the members it is paired with) as distanceTo, through one field per member measured to all of its partners: each vertex shows the smallest signed distance over them (the nearest surface, or the deepest penetration). Moving a member then recomputes only its own field and those of its partners. A member without partners shows no colouring.

      Members are coloured through setDisplay, so desired and display show the colourings (groups themselves are not in the snapshot). Setting the group colours every member, overriding a colouring the app gave it. A member's later setDisplay colouring overrides the group's: the group then leaves that member alone when it shrinks, is removed, or loses a mesh, until it is set again. Members dropped from the group, or all of them when it is removed, stop being coloured, and their store-owned fields are removed (not kept for later, as setDisplay keeps them). A removed mesh leaves its groups (and their pairs); a member left without partners stops being coloured.

      Parameters

      Returns void

      UNKNOWN_MESH for a mesh not in the store; INVALID_ARGUMENT for a mesh listed twice, a mesh already in another group, a pair that is not two different members, or a bad colouring (maxDistance, range, map or sign; checked here rather than at the flush).

    • Changes how a mesh is shown. desired changes at once; display follows at the next commitFrame() (or a microtask without a frame loop). A patch equal to the current request changes nothing.

      A coloring colours the mesh by distance to distanceTo (one mesh or several) through a field the store owns (one per mesh, named fast-mesh-store:<n>, kept while colouring is off and replaced only when the set of meshes in distanceTo, maxDistance or sign changes). display.coloring is the colouring last applied: on a Worker scene, once its display: request is ready.

      Parameters

      Returns void

      UNKNOWN_MESH for a mesh not in the store, INVALID_ARGUMENT for a bad value.

    • Registers a listener called after each new snapshot; returns the function that removes it. A listener that throws does not stop the others nor the action that changed the state (which has taken effect): its error is reported with reportError (an async rethrow where there is none), as the Worker scene does with its listeners.

      Parameters

      • listener: () => void

      Returns () => void