Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Apr 17, 2024
1 parent cd348ef commit 82990c5
Show file tree
Hide file tree
Showing 4 changed files with 316 additions and 26 deletions.
167 changes: 156 additions & 11 deletions dist/xeokit-bim-viewer.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -11381,13 +11381,16 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
*
* @param {AngleMeasurementsPlugin} angleMeasurementsPlugin The AngleMeasurementsPlugin to control.
* @param {*} [cfg] Configuration
* @param {function} [cfg.canvasToPagePos] Optional function to map canvas-space coordinates to page coordinates.
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
*/
constructor(angleMeasurementsPlugin, cfg = {}) {

super(angleMeasurementsPlugin.viewer.scene);

this._canvasToPagePos = cfg.canvasToPagePos;

this.pointerLens = cfg.pointerLens;

this._active = false;
Expand Down Expand Up @@ -11526,6 +11529,8 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
const getTop = el => el.offsetTop + (el.offsetParent && getTop(el.offsetParent));
const getLeft = el => el.offsetLeft + (el.offsetParent && getLeft(el.offsetParent));

const pagePos = math.vec2();

this._onMouseHoverSurface = cameraControl.on(
this._snapping
? "hoverSnapOrSurface"
Expand Down Expand Up @@ -11557,9 +11562,14 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
mouseHoverCanvasPos.set(canvasPos);
switch (this._mouseState) {
case MOUSE_FINDING_ORIGIN:
this.markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
this.markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;

if (this._canvasToPagePos) {
this._canvasToPagePos(canvas, canvasPos, pagePos);
this.markerDiv.style.left = `${pagePos[0] - 5}px`;
this.markerDiv.style.top = `${pagePos[1] - 5}px`;
} else {
this.markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
this.markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
}
break;
case MOUSE_FINDING_CORNER:
if (this._currentAngleMeasurement) {
Expand Down Expand Up @@ -11970,6 +11980,46 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
* });
* });
* ````
*
* ## Example 5: Creating AngleMeasurements with Touch Input
*
* In our fifth example, we'll show how to create angle measurements with touch input, with snapping
* to the nearest vertex or edge. While creating the measurements, a long-touch when setting the
* start, corner or end point will cause the point to snap to the nearest vertex or edge. A quick
* touch-release will immediately set the point at the tapped position on the object surface.
*
* [[Run example](/examples/measurement/#angle_createWithTouch_snapping)]
*
* ````javascript
* import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin, AngleMeasurementsTouchControl} 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);
*
* const model = xktLoader.load({
* src: "./models/xkt/duplex/duplex.xkt"
* });
*
* const angleMeasurements = new AngleMeasurementsPlugin(viewer);
*
* const angleMeasurementsTouchControl = new AngleMeasurementsTouchControl(angleMeasurements, {
* pointerLens : new PointerLens(viewer),
* snapToVertex: true,
* snapToEdge: true
* })
*
* angleMeasurementsTouchControl.activate();
* ````
*/
class AngleMeasurementsPlugin extends Plugin {

Expand Down Expand Up @@ -13668,6 +13718,14 @@ class PickResult {
}
}

/**
* True if snapped to edge or vertex.
* @returns {boolean}
*/
get snapped() {
return this.snappedToEdge || this.snappedToVertex;
}

/**
* @private
*/
Expand Down Expand Up @@ -70579,7 +70637,9 @@ class DTXTrianglesLayer {
// Color

let f0;
if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
if (!visible || culled || xrayed
|| (highlighted && !this.model.scene.highlightMaterial.glowThrough)
|| (selected && !this.model.scene.selectedMaterial.glowThrough)) {
f0 = RENDER_PASSES.NOT_RENDERED;
} else {
if (transparent) {
Expand Down Expand Up @@ -78466,7 +78526,7 @@ class DistanceMeasurement extends Component {

if (this._sectionPlanesDirty) {

if (this._isSliced(this._wp)) {
if (this._isSliced(this._originWorld) || this._isSliced(this._targetWorld)) {
this._xAxisLabel.setCulled(true);
this._yAxisLabel.setCulled(true);
this._zAxisLabel.setCulled(true);
Expand Down Expand Up @@ -79238,13 +79298,16 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
*
* @param {DistanceMeasurementsPlugin} distanceMeasurementsPlugin The AngleMeasurementsPlugin to control.
* @param [cfg] Configuration
* @param {function} [cfg.canvasToPagePos] Optional function to map canvas-space coordinates to page coordinates.
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
*/
constructor(distanceMeasurementsPlugin, cfg = {}) {

super(distanceMeasurementsPlugin.viewer.scene);

this._canvasToPagePos = cfg.canvasToPagePos;

this.pointerLens = cfg.pointerLens;

this._active = false;
Expand Down Expand Up @@ -79391,6 +79454,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
const getTop = el => el.offsetTop + (el.offsetParent && getTop(el.offsetParent));
const getLeft = el => el.offsetLeft + (el.offsetParent && getLeft(el.offsetParent));

const pagePos = math.vec2();

this._onCameraControlHoverSnapOrSurface = cameraControl.on(
this._snapping
? "hoverSnapOrSurface"
Expand All @@ -79401,8 +79466,14 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
pointerCanvasPos.set(event.canvasPos);
if (this._mouseState === MOUSE_FIRST_CLICK_EXPECTED) {

this._markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
this._markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
if (this._canvasToPagePos) {
this._canvasToPagePos(canvas, canvasPos, pagePos);
this._markerDiv.style.left = `${pagePos[0] - 5}px`;
this._markerDiv.style.top = `${pagePos[1] - 5}px`;
} else {
this._markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
this._markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
}

this._markerDiv.style.background = "pink";
if (event.snappedToVertex || event.snappedToEdge) {
Expand Down Expand Up @@ -79808,6 +79879,46 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
* });
* });
* ````
*
* ## Example 5: Creating DistanceMeasurements with Touch Input
*
* In our fifth example, we'll show how to create distance measurements with touch input, with snapping
* to the nearest vertex or edge. While creating the measurements, a long-touch when setting the
* start or end point will cause the point to snap to the nearest vertex or edge. A quick
* touch-release will immediately set the point at the tapped position on the object surface.
*
* [[Run example](/examples/measurement/#distance_createWithTouch_snapping)]
*
* ````javascript
* import {Viewer, XKTLoaderPlugin, DistanceMeasurementsPlugin, DistanceMeasurementsTouchControl} 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);
*
* const model = xktLoader.load({
* src: "./models/xkt/duplex/duplex.xkt"
* });
*
* const distanceMeasurements = new DistanceMeasurementsPlugin(viewer);
*
* const distanceMeasurementsTouchControl = new DistanceMeasurementsTouchControl(distanceMeasurements, {
* pointerLens : new PointerLens(viewer),
* snapToVertex: true,
* snapToEdge: true
* })
*
* distanceMeasurementsTouchControl.activate();
* ````
*/
class DistanceMeasurementsPlugin extends Plugin {

Expand Down Expand Up @@ -80041,7 +80152,7 @@ class DistanceMeasurementsPlugin extends Plugin {
}

/**
* Shows all or hides the angle label of each {@link DistanceMeasurement}.
* Shows all or hides the distance label of each {@link DistanceMeasurement}.
*
* @param {Boolean} labelsShown Whether or not to show the labels.
*/
Expand Down Expand Up @@ -80164,6 +80275,7 @@ class DistanceMeasurementsPlugin extends Plugin {
* hidePBR: true, // No physically-based rendering while we interact (default is true)
* hideTransparentObjects: true, // Hide transparent objects while we interact (default is false)
* scaleCanvasResolution: true, // Scale canvas resolution while we interact (default is false)
* defaultScaleCanvasResolutionFactor: 1.0, // Factor by which we scale canvas resolution when we stop interacting (default is 1.0)
* scaleCanvasResolutionFactor: 0.5, // Factor by which we scale canvas resolution when we interact (default is 0.6)
* delayBeforeRestore: true, // When we stop interacting, delay before restoring normal render (default is true)
* delayBeforeRestoreSeconds: 0.5 // The delay duration, in seconds (default is 0.5)
Expand Down Expand Up @@ -80196,6 +80308,7 @@ class FastNavPlugin extends Plugin {
* @param {Boolean} [cfg.hideEdges=true] Whether to temporarily hide edges whenever we interact with the Viewer.
* @param {Boolean} [cfg.hideTransparentObjects=false] Whether to temporarily hide transparent objects whenever we interact with the Viewer.
* @param {Number} [cfg.scaleCanvasResolution=false] Whether to temporarily down-scale the canvas resolution whenever we interact with the Viewer.
* @param {Number} [cfg.defaultScaleCanvasResolutionFactor=0.6] The factor by which we downscale the canvas resolution whenever we stop interacting with the Viewer.
* @param {Number} [cfg.scaleCanvasResolutionFactor=0.6] The factor by which we downscale the canvas resolution whenever we interact with the Viewer.
* @param {Boolean} [cfg.delayBeforeRestore=true] Whether to temporarily have a delay before restoring normal rendering after we stop interacting with the Viewer.
* @param {Number} [cfg.delayBeforeRestoreSeconds=0.5] Delay in seconds before restoring normal rendering after we stop interacting with the Viewer.
Expand All @@ -80210,6 +80323,7 @@ class FastNavPlugin extends Plugin {
this._hideEdges = cfg.hideEdges !== false;
this._hideTransparentObjects = !!cfg.hideTransparentObjects;
this._scaleCanvasResolution = !!cfg.scaleCanvasResolution;
this._defaultScaleCanvasResolutionFactor = cfg.defaultScaleCanvasResolutionFactor || 1.0;
this._scaleCanvasResolutionFactor = cfg.scaleCanvasResolutionFactor || 0.6;
this._delayBeforeRestore = (cfg.delayBeforeRestore !== false);
this._delayBeforeRestoreSeconds = cfg.delayBeforeRestoreSeconds || 0.5;
Expand All @@ -80228,14 +80342,14 @@ class FastNavPlugin extends Plugin {
if (this._scaleCanvasResolution) {
viewer.scene.canvas.resolutionScale = this._scaleCanvasResolutionFactor;
} else {
viewer.scene.canvas.resolutionScale = 1;
viewer.scene.canvas.resolutionScale = this._defaultScaleCanvasResolutionFactor;
}
fastMode = true;
}
};

const switchToHighQuality = () => {
viewer.scene.canvas.resolutionScale = 1;
viewer.scene.canvas.resolutionScale = this._defaultScaleCanvasResolutionFactor;
viewer.scene._renderer.setEdgesEnabled(true);
viewer.scene._renderer.setColorTextureEnabled(true);
viewer.scene._renderer.setPBREnabled(true);
Expand Down Expand Up @@ -80403,7 +80517,7 @@ class FastNavPlugin extends Plugin {
}

/**
* Sets whether to temporarily scale the canvas resolution whenever we interact with the Viewer.
* Sets the factor to which we restore the canvas resolution scale when we stop interacting with the viewer.
*
* Default is ````false````.
*
Expand All @@ -80415,6 +80529,34 @@ class FastNavPlugin extends Plugin {
this._scaleCanvasResolution = scaleCanvasResolution;
}

/**
* Gets the factor to which we restore the canvas resolution scale when we stop interacting with the viewer.
*
* Default is ````1.0````.
*
* Enable canvas resolution scaling by setting {@link FastNavPlugin#scaleCanvasResolution} ````true````.
*
* @return {Number} Factor by scale canvas resolution when we stop interacting with the viewer.
*/
get defaultScaleCanvasResolutionFactor() {
return this._defaultScaleCanvasResolutionFactor;
}

/**
* Sets the factor to which we restore the canvas resolution scale when we stop interacting with the viewer.
*
* Accepted range is ````[0.0 .. 1.0]````.
*
* Default is ````1.0````.
*
* Enable canvas resolution scaling by setting {@link FastNavPlugin#scaleCanvasResolution} ````true````.
*
* @param {Number} defaultScaleCanvasResolutionFactor Factor by scale canvas resolution when we stop interacting with the viewer.
*/
set defaultScaleCanvasResolutionFactor(defaultScaleCanvasResolutionFactor) {
this._defaultScaleCanvasResolutionFactor = defaultScaleCanvasResolutionFactor || 1.0;
}

/**
* Gets the factor by which we temporarily scale the canvas resolution when we interact with the viewer.
*
Expand Down Expand Up @@ -84081,6 +84223,9 @@ class CameraUpdater {
}
}
}
} else {
dollyDistFactor = 1;
followPointerWorldPos = null;
}

const dollyDeltaForDist = (updates.dollyDelta * dollyDistFactor);
Expand Down
4 changes: 2 additions & 2 deletions dist/xeokit-bim-viewer.min.es.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/xeokit-bim-viewer.min.umd.js

Large diffs are not rendered by default.

Loading

0 comments on commit 82990c5

Please sign in to comment.