Class AxisGrid<UserData>

Create a 3D axis grid. This is represented as a box volume where each side of the box is itself a grid.

// Create a 200x200 meters extent
const extent = new Extent('EPSG:3857', -100, +100, -100, +100);

// Create an AxisGrid on this extent, with the grid floor at zero meters,
// and the grid ceiling at 2500 meters.
//
// Display a tick (grid line), every 10 meters on the horizontal axes,
// and every 50 meters on the vertical axis.
const grid = new AxisGrid('axis-grid', {
volume: {
extent,
floor: 0,
ceiling: 2500,
},
origin: TickOrigin.Relative,
ticks: {
x: 10,
y: 10,
z: 50,
},
});

Type Parameters

Hierarchy

Constructors

Properties

_arrowRoot: Group<Object3DEventMap>
_back: Side
_boundingBox: Box3
_boundingBoxCenter: Vector3
_boundingSphere: Sphere
_cameraForward: Vector3
_ceiling: Side
_dimensions: Vector2
_disposed: boolean = false
_distance: {
    max: number;
    min: number;
}

Type declaration

  • max: number
  • min: number
_floor: Side
_front: Side
_height: number
_instance: Instance
_labelElements: HTMLElement[]
_labelRoot: Group<Object3DEventMap>
_labels: CSS2DObject[]
_lastCamera: Camera
_left: Side
_material: LineBasicMaterial
_midHeight: number
_needsRebuild: boolean
_right: Side
_root: Group<Object3DEventMap>
_showCeilingGrid: boolean
_showFloorGrid: boolean
_showSideGrids: boolean
_unitSuffix: string
isAxisGrid: true = true

Read-only flag to check if a given object is of type AxisGrid.

isEntity: boolean = true

Read-only flag to check if a given object is of type Entity.

isEntity3D: boolean = true

Read-only flag to check if a given object is of type Entity3D.

isPickable: true = true
ready?: boolean
showHelpers: boolean
type: string

The name of the type of this object.

userData: UserData

An object that can be used to store custom data about the Entity.

whenReady?: Promise<AxisGrid<UserData>>

Accessors

  • get clippingPlanes(): Plane[]
  • Gets or sets the clipping planes set on this entity. Default is null (no clipping planes).

    Note: custom entities must ensure that the materials and shaders used do support the clipping plane feature of three.js. Refer to the three.js documentation for more information.

    Returns Plane[]

  • set clippingPlanes(planes): void
  • Parameters

    • planes: Plane[]

    Returns void

  • get color(): Color
  • Gets or sets the grid and label color.

    Returns Color

  • set color(color): void
  • Parameters

    • color: Color

    Returns void

  • get distance(): {
        max: number;
        min: number;
    }
  • Returns {
        max: number;
        min: number;
    }

    • max: number
    • min: number
  • get frozen(): boolean
  • Gets or sets the frozen status of this entity. A frozen entity is still visible but will not be updated automatically.

    Useful for debugging purposes.

    Returns boolean

  • set frozen(v): void
  • Parameters

    • v: boolean

    Returns void

  • get id(): string
  • Gets the unique identifier of this entity.

    Returns string

  • get loading(): boolean
  • Gets whether this entity is currently loading data.

    Returns boolean

  • get object3d(): Object3D<Object3DEventMap>
  • Returns the root object of this entity.

    Returns Object3D<Object3DEventMap>

  • get opacity(): number
  • Gets or sets the opacity of this entity.

    Returns number

  • set opacity(v): void
  • Parameters

    • v: number

    Returns void

  • get origin(): AxisGridOrigin
  • Gets or sets the tick origin. You will need to call refresh to recreate the grid.

    Returns AxisGridOrigin

  • set origin(v): void
  • Parameters

    Returns void

  • get progress(): number
  • Gets the current loading progress (between 0 and 1). Note: This property is only meaningful if loading is true.

    Returns number

  • get renderOrder(): number
  • Gets or sets the render order of this entity.

    Returns number

  • set renderOrder(v): void
  • Parameters

    • v: number

    Returns void

  • get showCeilingGrid(): boolean
  • Shows or hides the ceiling grid.

    Returns boolean

  • set showCeilingGrid(v): void
  • Parameters

    • v: boolean

    Returns void

  • get showFloorGrid(): boolean
  • Shows or hides the floor grid.

    Returns boolean

  • set showFloorGrid(v): void
  • Parameters

    • v: boolean

    Returns void

  • get showLabels(): boolean
  • Shows or hides labels.

    Returns boolean

  • set showLabels(v): void
  • Parameters

    • v: boolean

    Returns void

  • get showSideGrids(): boolean
  • Shows or hides the side grids.

    Returns boolean

  • set showSideGrids(v): void
  • Parameters

    • v: boolean

    Returns void

  • get style(): AxisGridStyle
  • Gets or sets the style. You will need to call refresh to recreate the grid.

    Returns AxisGridStyle

  • set style(v): void
  • Parameters

    Returns void

  • get ticks(): AxisGridTicks
  • Gets or sets the tick intervals. You will need to call refresh to recreate the grid.

    Returns AxisGridTicks

  • set ticks(v): void
  • Parameters

    Returns void

  • get visible(): boolean
  • Gets or sets the visibility of this entity. A non-visible entity will not be automatically updated.

    Returns boolean

  • set visible(v): void
  • Parameters

    • v: boolean

    Returns void

  • get volume(): AxisGridVolume
  • Gets or sets the volume. You will need to call refresh to recreate the grid.

    Returns AxisGridVolume

  • set volume(v): void
  • Parameters

    Returns void

Methods

  • Adds a listener to an event type.

    Type Parameters

    Parameters

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    • type: T
    • listener: EventListener<{}, T, AxisGrid<UserData>>

    Returns void

  • Returns void

  • Parameters

    • name: string

      The name of the object.

    • width: number

      The width of the plane.

    • height: number

      The height of the plane.

    • xOffset: number

      The starting offset on the X axis.

    • xStep: number

      The distance between lines on the X axis.

    • yOffset: number

      The starting offset on the Y axis.

    • yStep: number

      The distance between lines on the Y axis.

    Returns Side

    the mesh object.

  • Returns void

  • Test whether this entity contains the given object.

    The object may be a component of the entity, or a 3D object.

    Parameters

    • obj: unknown

      The object to test.

    Returns boolean

    true if the entity contains the object.

  • Returns void

  • Returns void

  • Disposes this entity and all resources associated with it.

    The default implementation of this method does nothing. You should implement it in your custom entities to handle any special logic of disposal.

    For example: disposing materials, geometries, stopping HTTP requests, etc.

    Returns void

  • Filters what objects need to be updated, based on updatedSources. The returned objects are then passed to preUpdate and postUpdate.

    Inherited classes should override shouldFullUpdate and shouldUpdate if they need to change this behavior.

    Parameters

    • updateSources: Set<unknown>

      Sources that triggered an update

    Returns Set<unknown>

    Set of objects to update

  • Returns an approximated bounding box of this entity in the scene.

    Returns Box3

    the resulting bounding box, or null if it could not be computed.

  • Attached layers expect to receive the visual representation of a layer (= THREE object with a material). So if a layer's update function don't process this kind of object, the layer must provide a getObjectToUpdateForAttachedLayers function that returns the correct object to update for attached layer from the objects returned by preUpdate.

    Parameters

    • obj: any

      the Mesh or the object containing a Mesh. These are the objects returned by preUpdate or update.

    Returns ObjectToUpdate

    an object passed to the update function of attached layers.

  • Checks if listener is added to an event type.

    Type Parameters

    Parameters

    Returns boolean

  • Type Parameters

    • T extends string

    Parameters

    • type: T
    • listener: EventListener<{}, T, AxisGrid<UserData>>

    Returns boolean

  • Returns true if this object belongs to this entity.

    Parameters

    • obj: unknown

      The object to test.

    Returns boolean

  • Parameters

    • start: Vector3
    • end: Vector3

    Returns void

  • Applies entity-level setup on a new object.

    Note: this method should be called from the subclassed entity to notify the parent class that a new 3D object has just been created, so that it can be setup with entity-wide parameters.

    Parameters

    • obj: Object3D<Object3DEventMap>

      The object to prepare.

    Returns void

    Example

    // In the subclass
    const obj = new Object3D();

    // Notify the parent class
    this.onObjectCreated(obj);
  • Picks objects from this entity.

    Implementations must respect at least limit and filter options.

    Parameters

    • canvasCoords: Vector2

      Coordinates on the rendering canvas

    • Optional options: PickOptions

      Options

    Returns PickResult<unknown>[]

    Target

  • Method called after update.

    Parameters

    • context: Context

      the update context.

    • changeSources: Set<unknown>

      the objects that triggered an update step. This is useful to filter out unnecessary updates if no sources are relevant to this entity. For example, if one of the sources is a camera that moved during the previous frame, any entity that depends on the camera's field of view should be updated.

    Returns void

  • This method is called just before update() to filter and select which elements should be actually updated. For example, in the case of complex entities made of a hierarchy of elements, the entire hierarchy may not need to be updated.

    Use this method to optimize the update step by reducing the number of elements to process.

    Note: if this functions returns nothing, update() will not be called.

    Parameters

    • context: Context

      the update context.

    Returns object[]

    the elements to update during update().

  • Asynchronously preprocess the entity. This method may be overriden to perform any operation that must be done before the entity can be used in the scene, such as fetching metadata about a dataset, etc.

    Returns Promise<void>

    A promise that resolves when the entity is ready to be used.

  • Returns void

  • Rebuilds the grid. This is necessary after changing the ticks, volume or origin.

    Returns void

  • Removes a listener from an event type.

    Type Parameters

    Parameters

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    • type: T
    • listener: EventListener<{}, T, AxisGrid<UserData>>

    Returns void

  • Returns void

  • This method is called before update to check if the MainLoop should try to update this entity or not. For better performances, it should return false if the entity has no impact on the rendering (e.g. the element is not visible).

    The inherited child can completely ignore this value if it makes sense.

    Returns boolean

    true if should check for update

  • This method is called at the beginning of the update step to determine if we should do a full render of the object. This should be the case if, for instance, the source is the camera.

    You can override this depending on your needs. The inherited child should not ignore this value, it should do a boolean OR, e.g.: return super.shouldFullUpdate(updateSource) || this.contains(updateSource);

    Parameters

    • updateSource: unknown

      Source of change

    Returns boolean

    true if requires a full update of this object

  • This method is called at the beginning of the update step to determine if we should re-render updateSource. Not used when shouldFullUpdate returns true.

    You can override this depending on your needs. The inherited child should not ignore this value, it should do a boolean OR, e.g.: return super.shouldUpdate(updateSource) || this.contains(updateSource);

    Parameters

    • updateSource: unknown

      Source of change

    Returns boolean

    true if requires an update of updateSource

  • Traverses all objects in the hierarchy of this entity.

    Parameters

    • callback: ((arg0) => void)

      The callback.

        • (arg0): void
        • Parameters

          • arg0: Object3D<Object3DEventMap>

          Returns void

    • root: Object3D<Object3DEventMap> = undefined

      The traversal root. If undefined, the traversal starts at the root object of this entity.

    Returns void

  • Traverses all materials in the hierarchy of this entity.

    Parameters

    • callback: ((arg0) => void)

      The callback.

        • (arg0): void
        • Parameters

          • arg0: Material

          Returns void

    • root: Object3D<Object3DEventMap> = undefined

      The traversal root. If undefined, the traversal starts at the root object of this entity.

    Returns void

  • Traverses all meshes in the hierarchy of this entity.

    Parameters

    • callback: ((arg0) => void)

      The callback.

        • (arg0): void
        • Parameters

          • arg0: Mesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap>

          Returns void

    • root: Object3D<Object3DEventMap> = undefined

      The raversal root. If undefined, the traversal starts at the root object of this entity.

    Returns void

  • Performs an update on an element of the entity.

    Note: this method will be called for each element returned by preUpdate().

    Parameters

    • context: Context

      the update context. This is the same object that the entity whose update() is being called.

    • element: unknown

      the element to update. This is one of the elements returned by preUpdate.

    Returns unknown[]

    New elements to update

  • Updates the clipping planes of all objects under this entity.

    Returns void

  • Parameters

    • camera: Camera
    • edge: Edge

    Returns void

  • Parameters

    • camera: Camera

    Returns void

  • Parameters

    Returns void

  • Updates the opacity of the entity. Note: this method can be overriden for custom implementations.

    Returns void

  • Parameters

    • camera: Camera

    Returns void

  • Updates the visibility of the entity. Note: this method can be overriden for custom implementations.

    Returns void

Generated using TypeDoc