Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Nov 25, 2024
1 parent 2d83d3f commit b18fb36
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 75 deletions.
78 changes: 74 additions & 4 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9992,6 +9992,11 @@ class SceneModelEntity {
*/
this.model = model;

/**
* Identifies if it's a SceneModelEntity
*/
this.isSceneModelEntity = true;

/**
* The {@link SceneModelMesh}es belonging to this SceneModelEntity.
*
Expand Down Expand Up @@ -10924,7 +10929,7 @@ class Marker extends Component {
}
this._entity = entity;
if (this._entity) {
if (this._entity instanceof SceneModelEntity) {
if (this._entity.isSceneModelEntity) {
this._onEntityModelDestroyed = this._entity.model.on("destroyed", () => { // SceneModelEntity does not fire events, and cannot exist beyond its VBOSceneModel
this._entity = null; // Marker now may become visible, if it was synched to invisible Entity
this._onEntityModelDestroyed = null;
Expand Down Expand Up @@ -13098,7 +13103,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
mouseHovering = false;
if (pointerLens) {
pointerLens.visible = true;
pointerLens.pointerPos = event.canvasPos;
pointerLens.canvasPos = event.canvasPos;
pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
pointerLens.snapped = false;
}
Expand Down Expand Up @@ -97495,7 +97500,7 @@ class MousePanRotateDollyHandler {
}

function isPanning() {
return cameraControl._isKeyDownForAction(cameraControl.MOUSE_PAN, keyDown);
return configs.planView || cameraControl._isKeyDownForAction(cameraControl.MOUSE_PAN, keyDown);
}

function isRotating() {
Expand Down Expand Up @@ -98910,6 +98915,7 @@ class TouchPanRotateAndDollyHandler {
canvas.addEventListener("touchend", this._canvasTouchEndHandler = () => {
if (pivotController.getPivoting()) {
pivotController.endPivot();
pivotController.hidePivot();
}
});

Expand Down Expand Up @@ -110709,6 +110715,12 @@ class Viewer {
}
}

// Added to fix label's text offset in an html2canvas capture (See XEOK-151)
// based on https://github.com/niklasvh/html2canvas/issues/2775#issuecomment-1316356991
const style = document.createElement('style');
document.head.appendChild(style);
style.sheet?.insertRule('body > div:last-child img { display: inline-block; }');

for (let i = 0, len = pluginContainerElements.length; i < len; i++) {
const containerElement = pluginContainerElements[i];
await html2canvas(containerElement, {
Expand All @@ -110721,6 +110733,9 @@ class Viewer {
// (implemented to compensate XCD-153 issue)
snapshotCanvas.getContext("2d").resetTransform();
}

style.remove();

if (!params.includeGizmos) {
this.sendToPlugins("snapshotFinished");
}
Expand Down Expand Up @@ -123595,6 +123610,43 @@ class StoreyViewsPlugin extends Plugin {
this.modelStoreys[modelId][storeyId] = storey;
}
}
this._clipBoundingBoxes();
}

_clipBoundingBoxes() {
const storeysList = this.storeysList;
const metaScene = this.viewer.metaScene;
const camera = this.viewer.camera;
const worldUp = camera.worldUp;
const xUp = worldUp[0] > worldUp[1] && worldUp[0] > worldUp[2];
const yUp = !xUp && worldUp[1] > worldUp[0] && worldUp[1] > worldUp[2];
!xUp && !yUp && worldUp[2] > worldUp[0] && worldUp[2] > worldUp[1];

let bbIndex;

if(xUp) bbIndex = 0;
else if(yUp) bbIndex = 1;
else bbIndex = 2;

for (let i = 0, len = storeysList.length; i < len; i++) {

const storeyMetaObjectCur = metaScene.metaObjects[storeysList[i].storeyId];
const elevationCur = storeyMetaObjectCur.attributes.elevation;

if(isNaN(elevationCur)) return;

const bb = storeysList[i].storeyAABB;
bb[bbIndex] = Math.max(bb[1], parseFloat(elevationCur) / 1000);

if (i > 0) {
const storeyMetaObjectNext = metaScene.metaObjects[storeysList[i - 1].storeyId];
const elevationNext = storeyMetaObjectNext.attributes.elevation;
bb[4] = Math.min(bb[bbIndex + 3], parseFloat(elevationNext) / 1000);
}

this.storeys[storeysList[i].storeyId].storeyAABB = bb;
}

}

_deregisterModelStoreys(modelId) {
Expand Down Expand Up @@ -123791,6 +123843,7 @@ class StoreyViewsPlugin extends Plugin {
* @param {Number} [options.width=300] Image width in pixels. Height will be automatically determined from this, if not given.
* @param {Number} [options.height=300] Image height in pixels, as an alternative to width. Width will be automatically determined from this, if not given.
* @param {String} [options.format="png"] Image format. Accepted values are "png" and "jpeg".
* @param {Boolean} [options.captureSectionPlanes=false] Whether the storey map is sliced or not.
* @returns {StoreyMap} The StoreyMap.
*/
createStoreyMap(storeyId, options = {}) {
Expand All @@ -123807,6 +123860,7 @@ class StoreyViewsPlugin extends Plugin {
const aabb = (this._fitStoreyMaps) ? storey.storeyAABB : storey.modelAABB;
const aspect = Math.abs((aabb[5] - aabb[2]) / (aabb[3] - aabb[0]));
const padding = options.padding || 0;
const captureSectionPlanes = !!options.captureSectionPlanes;

let width;
let height;
Expand Down Expand Up @@ -123838,6 +123892,9 @@ class StoreyViewsPlugin extends Plugin {
this.showStoreyObjects(storeyId, utils.apply(options, {
hideOthers: true
}));

if (captureSectionPlanes)
this._toggleSectionPlanes(false);

this._arrangeStoreyMapCamera(storey);

Expand All @@ -123849,10 +123906,19 @@ class StoreyViewsPlugin extends Plugin {

this._objectsMemento.restoreObjects(scene, mask);
this._cameraMemento.restoreCamera(scene);
if (captureSectionPlanes)
this._toggleSectionPlanes(true);

return new StoreyMap(storeyId, src, format, width, height, padding);
}

_toggleSectionPlanes(visible) {
const planes = this.viewer.scene.sectionPlanes;
for (const key in planes) {
planes[key].active = visible;
}
}

_arrangeStoreyMapCamera(storey) {
const viewer = this.viewer;
const scene = viewer.scene;
Expand Down Expand Up @@ -133101,7 +133167,7 @@ parsers[ParserV11.version] = ParserV11;
*
* ````javascript
* const sceneModel = xktLoader.load({
* manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
* src: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
* id: "myModel",
* });
* ````
Expand Down Expand Up @@ -133839,6 +133905,10 @@ class XKTLoaderPlugin extends Plugin {
}

function getBaseDirectory(filePath) {
if (filePath.indexOf('?') > -1) {
filePath = filePath.split('?')[0];
}

const pathArray = filePath.split('/');
pathArray.pop(); // Remove the file name or the last segment of the path
return pathArray.join('/') + '/';
Expand Down
78 changes: 74 additions & 4 deletions dist/xeokit-sdk.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -9988,6 +9988,11 @@ class SceneModelEntity {
*/
this.model = model;

/**
* Identifies if it's a SceneModelEntity
*/
this.isSceneModelEntity = true;

/**
* The {@link SceneModelMesh}es belonging to this SceneModelEntity.
*
Expand Down Expand Up @@ -10920,7 +10925,7 @@ class Marker extends Component {
}
this._entity = entity;
if (this._entity) {
if (this._entity instanceof SceneModelEntity) {
if (this._entity.isSceneModelEntity) {
this._onEntityModelDestroyed = this._entity.model.on("destroyed", () => { // SceneModelEntity does not fire events, and cannot exist beyond its VBOSceneModel
this._entity = null; // Marker now may become visible, if it was synched to invisible Entity
this._onEntityModelDestroyed = null;
Expand Down Expand Up @@ -13094,7 +13099,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
mouseHovering = false;
if (pointerLens) {
pointerLens.visible = true;
pointerLens.pointerPos = event.canvasPos;
pointerLens.canvasPos = event.canvasPos;
pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
pointerLens.snapped = false;
}
Expand Down Expand Up @@ -97491,7 +97496,7 @@ class MousePanRotateDollyHandler {
}

function isPanning() {
return cameraControl._isKeyDownForAction(cameraControl.MOUSE_PAN, keyDown);
return configs.planView || cameraControl._isKeyDownForAction(cameraControl.MOUSE_PAN, keyDown);
}

function isRotating() {
Expand Down Expand Up @@ -98906,6 +98911,7 @@ class TouchPanRotateAndDollyHandler {
canvas.addEventListener("touchend", this._canvasTouchEndHandler = () => {
if (pivotController.getPivoting()) {
pivotController.endPivot();
pivotController.hidePivot();
}
});

Expand Down Expand Up @@ -110705,6 +110711,12 @@ class Viewer {
}
}

// Added to fix label's text offset in an html2canvas capture (See XEOK-151)
// based on https://github.com/niklasvh/html2canvas/issues/2775#issuecomment-1316356991
const style = document.createElement('style');
document.head.appendChild(style);
style.sheet?.insertRule('body > div:last-child img { display: inline-block; }');

for (let i = 0, len = pluginContainerElements.length; i < len; i++) {
const containerElement = pluginContainerElements[i];
await html2canvas(containerElement, {
Expand All @@ -110717,6 +110729,9 @@ class Viewer {
// (implemented to compensate XCD-153 issue)
snapshotCanvas.getContext("2d").resetTransform();
}

style.remove();

if (!params.includeGizmos) {
this.sendToPlugins("snapshotFinished");
}
Expand Down Expand Up @@ -123591,6 +123606,43 @@ class StoreyViewsPlugin extends Plugin {
this.modelStoreys[modelId][storeyId] = storey;
}
}
this._clipBoundingBoxes();
}

_clipBoundingBoxes() {
const storeysList = this.storeysList;
const metaScene = this.viewer.metaScene;
const camera = this.viewer.camera;
const worldUp = camera.worldUp;
const xUp = worldUp[0] > worldUp[1] && worldUp[0] > worldUp[2];
const yUp = !xUp && worldUp[1] > worldUp[0] && worldUp[1] > worldUp[2];
!xUp && !yUp && worldUp[2] > worldUp[0] && worldUp[2] > worldUp[1];

let bbIndex;

if(xUp) bbIndex = 0;
else if(yUp) bbIndex = 1;
else bbIndex = 2;

for (let i = 0, len = storeysList.length; i < len; i++) {

const storeyMetaObjectCur = metaScene.metaObjects[storeysList[i].storeyId];
const elevationCur = storeyMetaObjectCur.attributes.elevation;

if(isNaN(elevationCur)) return;

const bb = storeysList[i].storeyAABB;
bb[bbIndex] = Math.max(bb[1], parseFloat(elevationCur) / 1000);

if (i > 0) {
const storeyMetaObjectNext = metaScene.metaObjects[storeysList[i - 1].storeyId];
const elevationNext = storeyMetaObjectNext.attributes.elevation;
bb[4] = Math.min(bb[bbIndex + 3], parseFloat(elevationNext) / 1000);
}

this.storeys[storeysList[i].storeyId].storeyAABB = bb;
}

}

_deregisterModelStoreys(modelId) {
Expand Down Expand Up @@ -123787,6 +123839,7 @@ class StoreyViewsPlugin extends Plugin {
* @param {Number} [options.width=300] Image width in pixels. Height will be automatically determined from this, if not given.
* @param {Number} [options.height=300] Image height in pixels, as an alternative to width. Width will be automatically determined from this, if not given.
* @param {String} [options.format="png"] Image format. Accepted values are "png" and "jpeg".
* @param {Boolean} [options.captureSectionPlanes=false] Whether the storey map is sliced or not.
* @returns {StoreyMap} The StoreyMap.
*/
createStoreyMap(storeyId, options = {}) {
Expand All @@ -123803,6 +123856,7 @@ class StoreyViewsPlugin extends Plugin {
const aabb = (this._fitStoreyMaps) ? storey.storeyAABB : storey.modelAABB;
const aspect = Math.abs((aabb[5] - aabb[2]) / (aabb[3] - aabb[0]));
const padding = options.padding || 0;
const captureSectionPlanes = !!options.captureSectionPlanes;

let width;
let height;
Expand Down Expand Up @@ -123834,6 +123888,9 @@ class StoreyViewsPlugin extends Plugin {
this.showStoreyObjects(storeyId, utils.apply(options, {
hideOthers: true
}));

if (captureSectionPlanes)
this._toggleSectionPlanes(false);

this._arrangeStoreyMapCamera(storey);

Expand All @@ -123845,10 +123902,19 @@ class StoreyViewsPlugin extends Plugin {

this._objectsMemento.restoreObjects(scene, mask);
this._cameraMemento.restoreCamera(scene);
if (captureSectionPlanes)
this._toggleSectionPlanes(true);

return new StoreyMap(storeyId, src, format, width, height, padding);
}

_toggleSectionPlanes(visible) {
const planes = this.viewer.scene.sectionPlanes;
for (const key in planes) {
planes[key].active = visible;
}
}

_arrangeStoreyMapCamera(storey) {
const viewer = this.viewer;
const scene = viewer.scene;
Expand Down Expand Up @@ -133097,7 +133163,7 @@ parsers[ParserV11.version] = ParserV11;
*
* ````javascript
* const sceneModel = xktLoader.load({
* manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
* src: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
* id: "myModel",
* });
* ````
Expand Down Expand Up @@ -133835,6 +133901,10 @@ class XKTLoaderPlugin extends Plugin {
}

function getBaseDirectory(filePath) {
if (filePath.indexOf('?') > -1) {
filePath = filePath.split('?')[0];
}

const pathArray = filePath.split('/');
pathArray.pop(); // Remove the file name or the last segment of the path
return pathArray.join('/') + '/';
Expand Down
Loading

0 comments on commit b18fb36

Please sign in to comment.