UNPKG

@xeokit/xeokit-sdk

Version:

3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision

42 lines (38 loc) 1.13 kB
import {utils} from "../../viewer/scene/utils.js"; /** * Default data access strategy for {@link DotBIMLoaderPlugin}. * * This just loads assets using XMLHttpRequest. */ export class DotBIMDefaultDataSource { constructor(cfg = {}) { this.cacheBuster = (cfg.cacheBuster !== false); } _cacheBusterURL(url) { if (!this.cacheBuster) { return url; } const timestamp = new Date().getTime(); if (url.indexOf('?') > -1) { return url + '&_=' + timestamp; } else { return url + '?_=' + timestamp; } } /** * Gets .BIM JSON. * * @param {String|Number} dotBIMSrc Identifies the .BIM JSON asset. * @param {Function} ok Fired on successful loading of the .BIM JSON asset. * @param {Function} error Fired on error while loading the .BIM JSON asset. */ getDotBIM(dotBIMSrc, ok, error) { utils.loadJSON(this._cacheBusterURL(dotBIMSrc), (json) => { ok(json); }, function (errMsg) { error(errMsg); }); } }