Configures its View's measurement unit and mapping between the Real-space and World-space 3D Cartesian coordinate systems.

  • Located at View.metrics.
  • Metrics.units configures the Real-space unit type, which is constants!MetersUnit by default.
  • Metrics.scale configures the number of Real-space units represented by each unit within the World-space 3D coordinate system. This is 1.0 by default.
  • Metrics.origin configures the 3D Real-space origin, in current Real-space units, at which this View's World-space coordinate origin sits, This is [0,0,0] by default.
import {Viewer, constants} from "xeokit-viewer.es.js";

const viewer = new Viewer();

const view1 = myViewer.createView({
id: "myView",
elementId: "myCanvas1"
});

const metrics = view1.metrics;

metrics.units = MetersUnit;
metrics.scale = 10.0;
metrics.origin = [100.0, 0.0, 200.0];

Hierarchy (View Summary)

Properties

destroyed: boolean

True once this Component has been destroyed.

Don't use this Component if this is true.

dirty: boolean
id: string

Unique ID of this Component.

Accessors

  • get unitsInfo(): {}
  • Gets info about the supported Real-space unit types.

    With constants indicating each unit type, the info will be:

    {
    [MetersUnit]: {
    abbrev: "m"
    },
    [CentimetersUnit]: {
    abbrev: "cm"
    },
    [MillimetersUnit]: {
    abbrev: "mm"
    },
    [YardsUnit]: {
    abbrev: "yd"
    },
    [FeetUnit]: {
    abbrev: "ft"
    },
    [InchesUnit]: {
    abbrev: "in"
    }
    }

    Returns {}

Methods

  • Protected

    Logs an error for this component to the JavaScript console.

    The console message will have this format: [ERROR] [<component type> =<component id>: <message>

    Parameters

    • message: string

      The error message to log

    Returns void

  • Protected

    Logs a message for this component.

    The message will have this format: [LOG] [<component type> <component id>: <message>

    Parameters

    • message: string

      The message to log

    Returns void

  • Protected

    Logs a warning for this component to the JavaScript console.

    The console message will have this format: [WARN] [<component type> =<component id>: <message>

    Parameters

    • message: string

      The warning message to log

    Returns void

Events

onDestroyed: EventEmitter<Component, null>

Emits an event when the Component has been destroyed.

Emits an event each time Metrics.origin changes.

onScale: EventEmitter<Metrics, number>

Emits an event each time Metrics.scale changes.

onUnits: EventEmitter<Metrics, number>

Emits an event each time Metrics.units changes.