diff --git a/dist/xeokit-sdk.cjs.js b/dist/xeokit-sdk.cjs.js index 5c8a0bb80a..f211d36d71 100644 --- a/dist/xeokit-sdk.cjs.js +++ b/dist/xeokit-sdk.cjs.js @@ -12644,7 +12644,7 @@ function buildBoxGeometry(cfg = {}) { * xSize: 1, // Half-size on each axis * ySize: 1, * zSize: 1 - * }), + * })), * material: new PhongMaterial(viewer.scene, { * emissive: [0,1,0] * }) @@ -67078,6 +67078,85 @@ const getCanvasPosFromEvent$5 = function (event, canvasPos) { * * angleMeasurements.control.activate(); // <------------ Activate the AngleMeasurementsControl * ```` + * + * ## Example 4: Attaching Mouse Handlers + * + * In our fourth example, we'll attach even handlers to our plugin, to catch when the user + * hovers or right-clicks over our measurements. + * + * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_angle_modelWithMeasurements)] + * + * ````javascript + * import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin} from "xeokit-sdk.es.js"; + * + * const viewer = new Viewer({ + * canvasId: "myCanvas", + * transparent: true + * }); + * + * viewer.scene.camera.eye = [-2.37, 18.97, -26.12]; + * viewer.scene.camera.look = [10.97, 5.82, -11.22]; + * viewer.scene.camera.up = [0.36, 0.83, 0.40]; + * + * const xktLoader = new XKTLoaderPlugin(viewer); + * + * const angleMeasurements = new AngleMeasurementsPlugin(viewer); + * + * angleMeasurements.on("mouseOver", (e) => { + * e.measurement.setHighlighted(true); + * }); + * + * angleMeasurements.on("mouseLeave", (e) => { + * e.measurement.setHighlighted(false); + * }); + * + * angleMeasurements.on("contextMenu", (e) => { + * // Show context menu + * e.event.preventDefault(); + * }); + * + * const model = xktLoader.load({ + * src: "./models/xkt/duplex/duplex.xkt" + * }); + * + * model.on("loaded", () => { + * + * angleMeasurementsPlugin.createMeasurement({ + * id: "angleMeasurement1", + * origin: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.4158603637281142, 2.5193106917110457, 17.79972838299403] + * }, + * corner: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.41857741956197625,0.0987169929481646,17.799763071093395] + * }, + * target: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [5.235526066859247, 0.11580773869801986, 17.824891550941565] + * }, + * visible: true + * }); + * + * angleMeasurementsPlugin.createMeasurement({ + * id: "angleMeasurement2", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"], + * worldPos: [-0.00003814187850181838, 5.9996748076205115,17.79996871551525] + * }, + * corner: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNqI"], + * worldPos: [-0.0005214119318139865, 3.1010044228517595, 17.787656604483363] + * + * }, + * target: { + * entity: viewer.scene.objects["1s1jVhK8z0pgKYcr9jt7AB"], + * worldPos: [ 8.380657312957396, 3.1055697628459553, 17.799220108187185] + * }, + * visible: true + * }); + * }); + * ```` */ class AngleMeasurementsPlugin extends Plugin { @@ -87851,7 +87930,7 @@ const getCanvasPosFromEvent = function (event, canvasPos) { * * * [[Example 1: Model with distance measurements](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)] * * [[Example 2: Create distance measurements with mouse](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_createWithMouse)] - * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale)] + * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale) * * ## Overview * @@ -87974,6 +88053,78 @@ const getCanvasPosFromEvent = function (event, canvasPos) { * metrics.units = "meters"; * metrics.scale = 10.0; * ```` + * + * ## Example 4: Attaching Mouse Handlers + * + * In our fourth example, we'll attach even handlers to our plugin, to catch when the user + * hovers or right-clicks over our measurements. + * + * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)] + * + * ````javascript + * import {Viewer, XKTLoaderPlugin, DistanceMeasurementsPlugin} from "xeokit-sdk.es.js"; + * + * const viewer = new Viewer({ + * canvasId: "myCanvas", + * transparent: true + * }); + * + * viewer.scene.camera.eye = [-2.37, 18.97, -26.12]; + * viewer.scene.camera.look = [10.97, 5.82, -11.22]; + * viewer.scene.camera.up = [0.36, 0.83, 0.40]; + * + * const xktLoader = new XKTLoaderPlugin(viewer); + * + * const distanceMeasurements = new DistanceMeasurementsPlugin(viewer); + * + * distanceMeasurements.on("mouseOver", (e) => { + * e.measurement.setHighlighted(true); + * }); + * + * distanceMeasurements.on("mouseLeave", (e) => { + * e.measurement.setHighlighted(false); + * }); + * + * distanceMeasurements.on("contextMenu", (e) => { + * // Show context menu + * e.event.preventDefault(); + * }); + * + * const model = xktLoader.load({ + * src: "./models/xkt/duplex/duplex.xkt" + * }); + * + * model.on("loaded", () => { + * + * const myMeasurement1 = distanceMeasurements.createMeasurement({ + * id: "distanceMeasurement1", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"], + * worldPos: [0.044, 5.998, 17.767] + * }, + * target: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"], + * worldPos: [4.738, 3.172, 17.768] + * }, + * visible: true, + * wireVisible: true + * }); + * + * const myMeasurement2 = distanceMeasurements.createMeasurement({ + * id: "distanceMeasurement2", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"], + * worldPos: [0.457, 2.532, 17.766] + * }, + * target: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.436, 0.001, 22.135] + * }, + * visible: true, + * wireVisible: true + * }); + * }); + * ```` */ class DistanceMeasurementsPlugin extends Plugin { diff --git a/dist/xeokit-sdk.es.js b/dist/xeokit-sdk.es.js index 91f749d6ea..07ca0c5adb 100644 --- a/dist/xeokit-sdk.es.js +++ b/dist/xeokit-sdk.es.js @@ -12640,7 +12640,7 @@ function buildBoxGeometry(cfg = {}) { * xSize: 1, // Half-size on each axis * ySize: 1, * zSize: 1 - * }), + * })), * material: new PhongMaterial(viewer.scene, { * emissive: [0,1,0] * }) @@ -67074,6 +67074,85 @@ const getCanvasPosFromEvent$5 = function (event, canvasPos) { * * angleMeasurements.control.activate(); // <------------ Activate the AngleMeasurementsControl * ```` + * + * ## Example 4: Attaching Mouse Handlers + * + * In our fourth example, we'll attach even handlers to our plugin, to catch when the user + * hovers or right-clicks over our measurements. + * + * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_angle_modelWithMeasurements)] + * + * ````javascript + * import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin} from "xeokit-sdk.es.js"; + * + * const viewer = new Viewer({ + * canvasId: "myCanvas", + * transparent: true + * }); + * + * viewer.scene.camera.eye = [-2.37, 18.97, -26.12]; + * viewer.scene.camera.look = [10.97, 5.82, -11.22]; + * viewer.scene.camera.up = [0.36, 0.83, 0.40]; + * + * const xktLoader = new XKTLoaderPlugin(viewer); + * + * const angleMeasurements = new AngleMeasurementsPlugin(viewer); + * + * angleMeasurements.on("mouseOver", (e) => { + * e.measurement.setHighlighted(true); + * }); + * + * angleMeasurements.on("mouseLeave", (e) => { + * e.measurement.setHighlighted(false); + * }); + * + * angleMeasurements.on("contextMenu", (e) => { + * // Show context menu + * e.event.preventDefault(); + * }); + * + * const model = xktLoader.load({ + * src: "./models/xkt/duplex/duplex.xkt" + * }); + * + * model.on("loaded", () => { + * + * angleMeasurementsPlugin.createMeasurement({ + * id: "angleMeasurement1", + * origin: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.4158603637281142, 2.5193106917110457, 17.79972838299403] + * }, + * corner: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.41857741956197625,0.0987169929481646,17.799763071093395] + * }, + * target: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [5.235526066859247, 0.11580773869801986, 17.824891550941565] + * }, + * visible: true + * }); + * + * angleMeasurementsPlugin.createMeasurement({ + * id: "angleMeasurement2", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"], + * worldPos: [-0.00003814187850181838, 5.9996748076205115,17.79996871551525] + * }, + * corner: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNqI"], + * worldPos: [-0.0005214119318139865, 3.1010044228517595, 17.787656604483363] + * + * }, + * target: { + * entity: viewer.scene.objects["1s1jVhK8z0pgKYcr9jt7AB"], + * worldPos: [ 8.380657312957396, 3.1055697628459553, 17.799220108187185] + * }, + * visible: true + * }); + * }); + * ```` */ class AngleMeasurementsPlugin extends Plugin { @@ -87847,7 +87926,7 @@ const getCanvasPosFromEvent = function (event, canvasPos) { * * * [[Example 1: Model with distance measurements](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)] * * [[Example 2: Create distance measurements with mouse](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_createWithMouse)] - * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale)] + * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale) * * ## Overview * @@ -87970,6 +88049,78 @@ const getCanvasPosFromEvent = function (event, canvasPos) { * metrics.units = "meters"; * metrics.scale = 10.0; * ```` + * + * ## Example 4: Attaching Mouse Handlers + * + * In our fourth example, we'll attach even handlers to our plugin, to catch when the user + * hovers or right-clicks over our measurements. + * + * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)] + * + * ````javascript + * import {Viewer, XKTLoaderPlugin, DistanceMeasurementsPlugin} from "xeokit-sdk.es.js"; + * + * const viewer = new Viewer({ + * canvasId: "myCanvas", + * transparent: true + * }); + * + * viewer.scene.camera.eye = [-2.37, 18.97, -26.12]; + * viewer.scene.camera.look = [10.97, 5.82, -11.22]; + * viewer.scene.camera.up = [0.36, 0.83, 0.40]; + * + * const xktLoader = new XKTLoaderPlugin(viewer); + * + * const distanceMeasurements = new DistanceMeasurementsPlugin(viewer); + * + * distanceMeasurements.on("mouseOver", (e) => { + * e.measurement.setHighlighted(true); + * }); + * + * distanceMeasurements.on("mouseLeave", (e) => { + * e.measurement.setHighlighted(false); + * }); + * + * distanceMeasurements.on("contextMenu", (e) => { + * // Show context menu + * e.event.preventDefault(); + * }); + * + * const model = xktLoader.load({ + * src: "./models/xkt/duplex/duplex.xkt" + * }); + * + * model.on("loaded", () => { + * + * const myMeasurement1 = distanceMeasurements.createMeasurement({ + * id: "distanceMeasurement1", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"], + * worldPos: [0.044, 5.998, 17.767] + * }, + * target: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"], + * worldPos: [4.738, 3.172, 17.768] + * }, + * visible: true, + * wireVisible: true + * }); + * + * const myMeasurement2 = distanceMeasurements.createMeasurement({ + * id: "distanceMeasurement2", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"], + * worldPos: [0.457, 2.532, 17.766] + * }, + * target: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.436, 0.001, 22.135] + * }, + * visible: true, + * wireVisible: true + * }); + * }); + * ```` */ class DistanceMeasurementsPlugin extends Plugin { diff --git a/dist/xeokit-sdk.es5.js b/dist/xeokit-sdk.es5.js index 69f4be6d0b..33bccbcbca 100644 --- a/dist/xeokit-sdk.es5.js +++ b/dist/xeokit-sdk.es5.js @@ -2966,7 +2966,7 @@ indices:[0,1,2,0,2,3,// front * xSize: 1, // Half-size on each axis * ySize: 1, * zSize: 1 - * }), + * })), * material: new PhongMaterial(viewer.scene, { * emissive: [0,1,0] * }) @@ -13753,6 +13753,85 @@ _this56._currentAngleMeasurement.targetVisible=true;_this56._currentAngleMeasure * * angleMeasurements.control.activate(); // <------------ Activate the AngleMeasurementsControl * ```` + * + * ## Example 4: Attaching Mouse Handlers + * + * In our fourth example, we'll attach even handlers to our plugin, to catch when the user + * hovers or right-clicks over our measurements. + * + * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_angle_modelWithMeasurements)] + * + * ````javascript + * import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin} from "xeokit-sdk.es.js"; + * + * const viewer = new Viewer({ + * canvasId: "myCanvas", + * transparent: true + * }); + * + * viewer.scene.camera.eye = [-2.37, 18.97, -26.12]; + * viewer.scene.camera.look = [10.97, 5.82, -11.22]; + * viewer.scene.camera.up = [0.36, 0.83, 0.40]; + * + * const xktLoader = new XKTLoaderPlugin(viewer); + * + * const angleMeasurements = new AngleMeasurementsPlugin(viewer); + * + * angleMeasurements.on("mouseOver", (e) => { + * e.measurement.setHighlighted(true); + * }); + * + * angleMeasurements.on("mouseLeave", (e) => { + * e.measurement.setHighlighted(false); + * }); + * + * angleMeasurements.on("contextMenu", (e) => { + * // Show context menu + * e.event.preventDefault(); + * }); + * + * const model = xktLoader.load({ + * src: "./models/xkt/duplex/duplex.xkt" + * }); + * + * model.on("loaded", () => { + * + * angleMeasurementsPlugin.createMeasurement({ + * id: "angleMeasurement1", + * origin: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.4158603637281142, 2.5193106917110457, 17.79972838299403] + * }, + * corner: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.41857741956197625,0.0987169929481646,17.799763071093395] + * }, + * target: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [5.235526066859247, 0.11580773869801986, 17.824891550941565] + * }, + * visible: true + * }); + * + * angleMeasurementsPlugin.createMeasurement({ + * id: "angleMeasurement2", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"], + * worldPos: [-0.00003814187850181838, 5.9996748076205115,17.79996871551525] + * }, + * corner: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNqI"], + * worldPos: [-0.0005214119318139865, 3.1010044228517595, 17.787656604483363] + * + * }, + * target: { + * entity: viewer.scene.objects["1s1jVhK8z0pgKYcr9jt7AB"], + * worldPos: [ 8.380657312957396, 3.1055697628459553, 17.799220108187185] + * }, + * visible: true + * }); + * }); + * ```` */var AngleMeasurementsPlugin=/*#__PURE__*/function(_Plugin){_inherits(AngleMeasurementsPlugin,_Plugin);var _super42=_createSuper(AngleMeasurementsPlugin);/** * @constructor * @param {Viewer} viewer The Viewer. @@ -21163,7 +21242,7 @@ mouseHoverEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseCanvasPos.s * * * [[Example 1: Model with distance measurements](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)] * * [[Example 2: Create distance measurements with mouse](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_createWithMouse)] - * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale)] + * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale) * * ## Overview * @@ -21286,6 +21365,78 @@ mouseHoverEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseCanvasPos.s * metrics.units = "meters"; * metrics.scale = 10.0; * ```` + * + * ## Example 4: Attaching Mouse Handlers + * + * In our fourth example, we'll attach even handlers to our plugin, to catch when the user + * hovers or right-clicks over our measurements. + * + * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)] + * + * ````javascript + * import {Viewer, XKTLoaderPlugin, DistanceMeasurementsPlugin} from "xeokit-sdk.es.js"; + * + * const viewer = new Viewer({ + * canvasId: "myCanvas", + * transparent: true + * }); + * + * viewer.scene.camera.eye = [-2.37, 18.97, -26.12]; + * viewer.scene.camera.look = [10.97, 5.82, -11.22]; + * viewer.scene.camera.up = [0.36, 0.83, 0.40]; + * + * const xktLoader = new XKTLoaderPlugin(viewer); + * + * const distanceMeasurements = new DistanceMeasurementsPlugin(viewer); + * + * distanceMeasurements.on("mouseOver", (e) => { + * e.measurement.setHighlighted(true); + * }); + * + * distanceMeasurements.on("mouseLeave", (e) => { + * e.measurement.setHighlighted(false); + * }); + * + * distanceMeasurements.on("contextMenu", (e) => { + * // Show context menu + * e.event.preventDefault(); + * }); + * + * const model = xktLoader.load({ + * src: "./models/xkt/duplex/duplex.xkt" + * }); + * + * model.on("loaded", () => { + * + * const myMeasurement1 = distanceMeasurements.createMeasurement({ + * id: "distanceMeasurement1", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"], + * worldPos: [0.044, 5.998, 17.767] + * }, + * target: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"], + * worldPos: [4.738, 3.172, 17.768] + * }, + * visible: true, + * wireVisible: true + * }); + * + * const myMeasurement2 = distanceMeasurements.createMeasurement({ + * id: "distanceMeasurement2", + * origin: { + * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"], + * worldPos: [0.457, 2.532, 17.766] + * }, + * target: { + * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"], + * worldPos: [0.436, 0.001, 22.135] + * }, + * visible: true, + * wireVisible: true + * }); + * }); + * ```` */var DistanceMeasurementsPlugin=/*#__PURE__*/function(_Plugin5){_inherits(DistanceMeasurementsPlugin,_Plugin5);var _super64=_createSuper(DistanceMeasurementsPlugin);/** * @constructor * @param {Viewer} viewer The Viewer.