Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Apr 22, 2024
1 parent 8a47feb commit 191d73c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 20 deletions.
45 changes: 38 additions & 7 deletions dist/xeokit-bim-viewer.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -10083,6 +10083,7 @@ class Wire {
wireClickable.addEventListener('contextmenu', (event) => {
cfg.onContextMenu(event, this);
event.preventDefault();
event.stopPropagation();
});
}

Expand Down Expand Up @@ -10281,6 +10282,7 @@ class Dot {
dotClickable.addEventListener('contextmenu', (event) => {
cfg.onContextMenu(event, this);
event.preventDefault();
event.stopPropagation();
});
}

Expand Down Expand Up @@ -10422,12 +10424,14 @@ class Label {
if (cfg.onMouseDown) {
label.addEventListener('mousedown', (event) => {
cfg.onMouseDown(event, this);
event.stopPropagation();
});
}

if (cfg.onMouseUp) {
label.addEventListener('mouseup', (event) => {
cfg.onMouseUp(event, this);
event.stopPropagation();
});
}

Expand All @@ -10441,6 +10445,8 @@ class Label {
label.addEventListener('contextmenu', (event) => {
cfg.onContextMenu(event, this);
event.preventDefault();
event.stopPropagation();
console.log("Label context menu");
});
}
}
Expand Down Expand Up @@ -72746,7 +72752,7 @@ class SceneModelTransform {
_addChildTransform(childTransform) {
this._childTransforms.push(childTransform);
childTransform._parentTransform = this;
childTransform._setWorldMatrixDirty();
childTransform._transformDirty();
childTransform._setAABBDirty();
}

Expand Down Expand Up @@ -75722,7 +75728,7 @@ class SceneModel extends Component {
const transform = new SceneModelTransform({
id: cfg.id,
model: this,
parentTransform,
parent: parentTransform,
matrix: cfg.matrix,
position: cfg.position,
scale: cfg.scale,
Expand Down Expand Up @@ -113898,12 +113904,37 @@ class BIMViewer extends Controller {
enableMeasurements: this._enableMeasurements
});

this.viewer.cameraControl.on("rightClick", (e) => {
const getCanvasPosFromEvent = function (event) {
const canvasPos = [];
if (!event) {
event = window.event;
canvasPos[0] = event.x;
canvasPos[1] = event.y;
} else {
let element = event.target;
let totalOffsetLeft = 0;
let totalOffsetTop = 0;
let totalScrollX = 0;
let totalScrollY = 0;
while (element.offsetParent) {
totalOffsetLeft += element.offsetLeft;
totalOffsetTop += element.offsetTop;
totalScrollX += element.scrollLeft;
totalScrollY += element.scrollTop;
element = element.offsetParent;
}
canvasPos[0] = event.pageX + totalScrollX - totalOffsetLeft;
canvasPos[1] = event.pageY + totalScrollY - totalOffsetTop;
}
return canvasPos;
};

this.viewer.scene.canvas.canvas.addEventListener('contextmenu', (event) => {

e.event;
const canvasPos = getCanvasPosFromEvent(event);

const hit = this.viewer.scene.pick({
canvasPos: e.canvasPos
canvasPos
});

if (hit && hit.entity.isObject) {
Expand All @@ -113921,14 +113952,14 @@ class BIMViewer extends Controller {
},
entity: hit.entity
};
this._objectContextMenu.show(e.pagePos[0], e.pagePos[1]);
this._objectContextMenu.show(event.pageX, event.pageY);
} else {
this._objectContextMenu.hide();
this._canvasContextMenu.context = {
viewer: this.viewer,
bimViewer: this
};
this._canvasContextMenu.show(e.pagePos[0], e.pagePos[1]);
this._canvasContextMenu.show(event.pageX, event.pageY);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions dist/xeokit-bim-viewer.min.es.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/xeokit-bim-viewer.min.umd.js

Large diffs are not rendered by default.

45 changes: 38 additions & 7 deletions dist/xeokit-bim-viewer.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -10089,6 +10089,7 @@
wireClickable.addEventListener('contextmenu', (event) => {
cfg.onContextMenu(event, this);
event.preventDefault();
event.stopPropagation();
});
}

Expand Down Expand Up @@ -10287,6 +10288,7 @@
dotClickable.addEventListener('contextmenu', (event) => {
cfg.onContextMenu(event, this);
event.preventDefault();
event.stopPropagation();
});
}

Expand Down Expand Up @@ -10428,12 +10430,14 @@
if (cfg.onMouseDown) {
label.addEventListener('mousedown', (event) => {
cfg.onMouseDown(event, this);
event.stopPropagation();
});
}

if (cfg.onMouseUp) {
label.addEventListener('mouseup', (event) => {
cfg.onMouseUp(event, this);
event.stopPropagation();
});
}

Expand All @@ -10447,6 +10451,8 @@
label.addEventListener('contextmenu', (event) => {
cfg.onContextMenu(event, this);
event.preventDefault();
event.stopPropagation();
console.log("Label context menu");
});
}
}
Expand Down Expand Up @@ -72752,7 +72758,7 @@
_addChildTransform(childTransform) {
this._childTransforms.push(childTransform);
childTransform._parentTransform = this;
childTransform._setWorldMatrixDirty();
childTransform._transformDirty();
childTransform._setAABBDirty();
}

Expand Down Expand Up @@ -75728,7 +75734,7 @@
const transform = new SceneModelTransform({
id: cfg.id,
model: this,
parentTransform,
parent: parentTransform,
matrix: cfg.matrix,
position: cfg.position,
scale: cfg.scale,
Expand Down Expand Up @@ -113904,12 +113910,37 @@
enableMeasurements: this._enableMeasurements
});

this.viewer.cameraControl.on("rightClick", (e) => {
const getCanvasPosFromEvent = function (event) {
const canvasPos = [];
if (!event) {
event = window.event;
canvasPos[0] = event.x;
canvasPos[1] = event.y;
} else {
let element = event.target;
let totalOffsetLeft = 0;
let totalOffsetTop = 0;
let totalScrollX = 0;
let totalScrollY = 0;
while (element.offsetParent) {
totalOffsetLeft += element.offsetLeft;
totalOffsetTop += element.offsetTop;
totalScrollX += element.scrollLeft;
totalScrollY += element.scrollTop;
element = element.offsetParent;
}
canvasPos[0] = event.pageX + totalScrollX - totalOffsetLeft;
canvasPos[1] = event.pageY + totalScrollY - totalOffsetTop;
}
return canvasPos;
};

this.viewer.scene.canvas.canvas.addEventListener('contextmenu', (event) => {

e.event;
const canvasPos = getCanvasPosFromEvent(event);

const hit = this.viewer.scene.pick({
canvasPos: e.canvasPos
canvasPos
});

if (hit && hit.entity.isObject) {
Expand All @@ -113927,14 +113958,14 @@
},
entity: hit.entity
};
this._objectContextMenu.show(e.pagePos[0], e.pagePos[1]);
this._objectContextMenu.show(event.pageX, event.pageY);
} else {
this._objectContextMenu.hide();
this._canvasContextMenu.context = {
viewer: this.viewer,
bimViewer: this
};
this._canvasContextMenu.show(e.pagePos[0], e.pagePos[1]);
this._canvasContextMenu.show(event.pageX, event.pageY);
}
});
}
Expand Down

0 comments on commit 191d73c

Please sign in to comment.