API (v2.0.0) - Giro3D
    Preparing search index...

    Class FeatureCollection<UserData>

    An Entity3D that represent simple features as 3D meshes.

    Warning

    Arbitrary triangulated meshes (TINs) are not supported.

    Both 2D and 3D geometries are supported. In the case of 2D geometries (with only XY coordinates), you can specify an elevation (Z) to display the geometries at arbitrary heights, using the elevation option in the constructor.

    Supported geometries:

    At the moment, this entity accepts an OpenLayers VectorSource that returns features.

    Note

    If your source doesn't have a notion of level of detail, like a WFS server, you must choose one level where data will be downloaded. The level giving the best user experience depends on the data source. You must configure both minLevel and maxLevel to this level.

    For example, in the case of a WFS source:

    import VectorSource from 'ol/source/Vector.js';
    import FeatureCollection from '@giro3d/giro3d/entities/FeatureCollection';

    const vectorSource = new VectorSource({
    // ...
    });
    const featureCollection = new FeatureCollection('features', {
    source: vectorSource
    minLevel: 10,
    maxLevel: 10,
    elevation: (feature) => feat.getProperties().elevation,
    });

    instance.add(featureCollection);

    The FeatureCollection supports the reprojection of geometries if the source has a different CRS than the scene. Any custom CRS must be registered first with core.geographic.CoordinateSystem.register | CoordinateSystem.register().

    Related examples:

    Features can be styled using a FeatureStyle, either using the same style for the entire entity, or using a style function that will return a style for each feature.

    Warning

    All features that share the same style will internally use the same material. It is not advised to modify this material to avoid affecting all shared objects. Those materials are automatically disposed when the entity is removed from the instance.

    Textures used by point styles are also disposed if they were created internally by the entity (from a provided URL) rather than provided as a texture.

    By default, styles are converted to materials using default generator functions. It is possible to override those function to create custom materials. For example, to use custom line materials, you can pass the lineMaterialGenerator option to the constructor.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _distance: { max: number; min: number }
    dataProjection: CoordinateSystem | null

    The projection code of the data source.

    extent: Extent

    The extent of this entity.

    hasDefaultPointOfView: true = ...

    Readonly flag to check if a given object implements HasDefaultPointOfView.

    id: string

    The unique identifier of this entity.

    isEntity: boolean = ...

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

    isEntity3D: boolean = ...

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

    isFeatureCollection: true = ...

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

    isMemoryUsage: true = ...

    Readonly flag to indicate that his object implements MemoryUsage.

    isPickable: true
    maxLevel: number = 0

    The maximum LOD at which this entity is displayed.

    minLevel: number = 0

    The minimum LOD at which this entity is displayed.

    name: string | undefined

    The name of this entity.

    sseScale: number = 1

    The factor to drive the subdivision of feature nodes. The heigher, the bigger the nodes.

    type: "FeatureCollection" = ...

    The name of the type of this object.

    userData: UserData

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

    Accessors

    • get clippingPlanes(): Plane[] | null

      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[] | null

    • set clippingPlanes(planes: Plane[] | null): void

      Parameters

      • planes: Plane[] | null

      Returns void

    • get distance(): Readonly<{ max: number; min: number }>

      Returns Readonly<{ 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: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get object3d(): Object3D

      Returns the root object of this entity.

      Returns Object3D

    • get opacity(): number

      Gets or sets the opacity of this entity.

      Returns number

    • set opacity(v: number): void

      Parameters

      • v: number

      Returns void

    • get ready(): boolean

      Determine if this entity is ready to use.

      Returns boolean

    • 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: boolean): void

      Parameters

      • v: boolean

      Returns void

    Methods

    • 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.

    • 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 | null

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

    • Default implementation that computes a point of view from the bounding box of the entity, if any.

      Parameters

      • params: { camera: Camera }
        • camera: Camera

          The camera to compute the point of view.

      Returns Readonly<PointOfView> | null

    • Returns true if this object belongs to this entity.

      Parameters

      • obj: unknown

        The object to test.

      Returns boolean

    • Notifies the parent instance that a change occured in the scene.

      Parameters

      • Optionalsource: unknown

      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

        The object to prepare.

      Returns void

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

      // Notify the parent class
      this.onObjectCreated(obj);
    • Called when the rendering context has been lost.

      Parameters

      • options: { canvas: HTMLCanvasElement }

        The options.

      Returns void

    • 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

    • 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.

    • 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

        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 unknown[]

      the elements to update during update().

    • Applies entity-level setup on new object's material.

      Subclasses can override this to setup custom logic, for instance if the entity can produce objects that are naturally transparent.

      Parameters

      • material: Material

        the material of the newly created object

      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: Object3D) => void

        The callback.

      • root: Object3D<Object3DEventMap> | undefined = 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: Material) => void

        The callback.

      • root: Object3D<Object3DEventMap> | undefined = 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: Mesh) => void

        The callback.

      • root: Object3D<Object3DEventMap> | undefined = 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

      Returns FeatureTile[] | null | undefined

      New elements to update