xeokit-sdk-v0.4.0-beta
Pre-releaseOverview
This xeokit SDK v0.4.0 beta release contains two new plugins for interactively measuring models, along with the ability to configure units of measurement and the mapping of a "real-world" Cartesian coordinate system to xeokit's World-space coordinate system.
To be properly usable, the measurement tools need the addition of cursor snap-to-line and snap-to-vertex. Those are not in this release, but are planned for the next release. In the meantime, we'll release the measurement tools now in order to get user feedback early.
Distance Measurements
DistanceMeasurementPlugin is a new Viewer plugin for interactively measuring point-to-point distances.
const distanceMeasurements = new DistanceMeasurementsPlugin(viewer);
//--------------------------------------------------------------------
// Create a distance measurement programmatically
//--------------------------------------------------------------------
const myMeasurement1 = distanceMeasurements.createMeasurement({
id: "distanceMeasurement1",
origin: {
entity: viewer.scene.objects["0jf0rYHfX3RAB3bSIRjmoa"],
worldPos: [0.04815268516540527, 6.0054426193237305, 17.76587677001953]
},
target: {
entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"],
worldPos: [4.70150089263916, 3.09493088722229, 17.766956329345703]
},
visible: true
});
//--------------------------------------------------------------------
// To create distance measurements interactively
// with mouse or touch input, activate the plugin's
// DistanceMeasurementControl
//--------------------------------------------------------------------
distanceMeasurements.control.activate();
Angle Measurements
AngleMeasurementPlugin is a new Viewer plugin for interactively measuring angles.
const angleMeasurements = new AngleMeasurementsPlugin(viewer);
//--------------------------------------------------------------------
// Create an angle measurement programmatically
//--------------------------------------------------------------------
const myMeasurement1 = angleMeasurements.createMeasurement({
id: "angleMeasurement1",
origin: {
entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
worldPos: [0.41385602951049805,-0.030549049377441406,17.801637649536133]
},
corner: {
entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
worldPos: [0.4156308174133301, -0.03379631042480469, 22.138973236083984]
},
target: {
entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
worldPos: [6.181171894073486, -0.0305633544921875,22.141223907470703]
},
visible: true
});
//--------------------------------------------------------------------
// To create angle measurements interactively
// with mouse or touch input, activate the plugin's
// AngleMeasurementControl
//--------------------------------------------------------------------
angleMeasurements.control.activate();
Units of Measurement
A new Metrics component configures its Scene's measurement unit and mapping between the Real-space and World-space 3D Cartesian coordinate systems. The screen capture below shows how the DistanceMeasurementPlugin will dynamically update its measurements as we update those configurations. Note how the distances and units are changing within the labels.
import {Viewer} from "../src/viewer/Viewer.js";
import {XKTLoaderPlugin} from "../src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js";
const viewer = new Viewer({
canvasId: "myCanvas"
});
//...
const metrics = viewer.scene.metrics;
metrics.units = "meters";
metrics.scale = 10.0;
metrics.origin = [100.0, 0.0, 200.0];
Metrics#units
configures the Real-space unit type, which is"meters"
by default.Metrics#scale
configures the number of Real-space units represented by each unit within the World-space 3D coordinate system. This is1.0
by default.Metrics#origin
configures the 3D Real-space origin, in current Real-space units, at which thisScene
's World-space coordinate origin sits, This is[0,0,0]
by default.