Skip to content

Commit

Permalink
Merge pull request #1733 from xeokit/fix/storeyviewplugin-slicing
Browse files Browse the repository at this point in the history
Add ability to capture whole models::StoreyViewsPlugin
  • Loading branch information
xeolabs authored Nov 13, 2024
2 parents 1c0b63c + ccaf01d commit ffa9d0c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,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 @@ -520,6 +521,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 @@ -551,6 +553,9 @@ class StoreyViewsPlugin extends Plugin {
this.showStoreyObjects(storeyId, utils.apply(options, {
hideOthers: true
}));

if (captureSectionPlanes)
this._toggleSectionPlanes(false);

this._arrangeStoreyMapCamera(storey);

Expand All @@ -562,10 +567,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

0 comments on commit ffa9d0c

Please sign in to comment.