Documentation - v19.16.0-dev
    Preparing search index...

    Entry point of the mesh engine. addMeshes() takes InputMeshes and returns a MeshProxy per object. For each part of an object:

    • the geometry is copied once per id into the GeometryStore: later parts with the same id reuse it (instances), without looking at their buffers;
    • its world matrix and material go to an instance of the InstanceTable;
    • its world box goes to the boxTree, the scene's BVH (shared with the sprites) for the culling and the picking, written by a worker.

    The controller is the only writer of its objects. They are added and removed many at once (addMeshes, removeMeshes: one subtree built, one removal); each is changed through its proxy (mesh.visible = false), which calls the controller: it updates its instances, and queues the changes of its leaves for the tree's worker, those of a task sent in one command (applied a message later, see BoxTree.whenApplied). The controller keeps no uuid and does not look for duplicates: each input added is a new object (the application filters them, e.g. in its ObjectImportController), and the application links its own object to the proxy (MeshProxy.owner).

    It tells nobody: whoever needs the changes reads them when it uses them, comparing with what it stored (the renderers, once per frame: version, the InstanceTable's allocationVersion and changed range, the geometries' changed range). Nothing is mirrored: a part is its instance index.

    The data is the same for every backend: a Renderer of either draws it, and changing the backend copies no geometry.

    Index

    Constructors

    Properties

    boxTree: BoxTree

    The scene's BoxTree, shared with the sprites (see LeafIds), in a SharedArrayBuffer read by the culling workers: a leaf per part, which stores its part's instance index (objectId), whether it is shown and the bit of the layer it is drawn in (flags, see PartFlags; the top one for a selected object with the selectionOverlay), for its ancestors: the culling skips the subtrees without a part shown. Not the objects' state, which it follows a message later: at a leaf, the culling reads it in the instances. Its part leaves are kept up to date by the controller, written by a worker that rebuilds the tree by itself once degraded: read it, do not change it.

    group: Group<Object3DEventMap> = ...

    The three.js objects that draw the meshes, in the scene's three.js scene: filled by the mesh renderer of the backend drawing the scene (its own meshes and materials), emptied when it is freed.

    settings: EngineSettings

    The scene's: its sizes read now, its selection, x-ray and edge colour followed.

    Accessors

    • get byteLength(): number

      Memory of the stored data, in bytes: the Containers' arrays, empty space included, and the InstanceTable (the scene's BoxTree apart). A backend uploads most of it to the GPU.

      Returns number

    • get geometryCount(): number

      Unique geometries stored.

      Returns number

    • get meshCount(): number

      Objects in the controller.

      Returns number

    • get partCount(): number

      Parts of all the objects: instances in the InstanceTable.

      Returns number

    • get selectionOverlay(): boolean

      Whether the selected objects are drawn in the top layer (MeshLayer.Layer4), over the other objects, seen through them; else in their own layer, kept either way (MeshProxy.layer): the scene's settings.meshes.selectionOverlay.

      Returns boolean

    • get version(): number

      Changes with every change of what is drawn or culled: objects added, removed, moved, shown, hidden, moved to another layer, (de)selected or x-rayed, the selectionOverlay switched, the boxTree changed by its worker. Not the materials: they are read in the InstanceTable's changed range. Compare it with the value read last to know whether something changed since.

      Returns number

    • get xRayOpacity(): number

      The opacity of the x-ray objects (MeshProxy.xRay) is multiplied by this, 0 to 1, their edges' too: the scene's settings.meshes.xRayOpacity.

      Returns number

    Methods

    • Adds objects, each a new object whatever its uuid: stores them, their new geometries together in a Container of their exact size when they are larger than a default one (the scene's settings.meshes.container*), then inserts their parts into the boxTree as one subtree (built by its worker): many at once are much faster than one by one, e.g. a group of a model being loaded. An object is drawn in the layer of its input (MeshLayer.Layer1 by default), shown. Throws an AddMeshesError at an object that has no parts or a layer that is not one, a geometry without vertices or not stored (named by id) or a part it cannot store, the ones before it added (error.added); throws without adding any when the BoxTree cannot hold them (the scene's settings.scene.boxTreeMaxNodes).

      Parameters

      Returns MeshProxy[]

      Their proxies, in the order of inputs.

    • Removes every object (see removeMeshes): the BoxTree emptied at once when it holds only their parts (a reset, against a rebuild of the rest: 0.2 ms against 430 ms in its worker for a million parts), else the sprites' leaves kept.

      Returns void

    • Stops following the scene's settings, which outlive it: the controller is not used after.

      Returns void

    • The objects in the controller.

      Returns MeshProxy[]

    • Whether the proxy is of an object of this controller (not removed).

      Parameters

      Returns boolean

    • Removes objects: their parts from the boxTree at once (the rest rebuilt by its worker when they are many, e.g. a model unloaded), then their instances; a geometry goes with its last instance. Their proxies are invalidated. The proxies removed already are skipped; throws, removing none, at a proxy of another controller.

      Parameters

      Returns void