You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
17 KiB
1 line
17 KiB
|
1 year ago
|
!function(){"use strict";var e=window.hostConfig||{APIHost:"https://api.bimface.com",resourceHost:"https://m.bimface.com",staticHost:"https://static.bimface.com",dataEnvType:"BIMFACE",securityApi:!0};void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),o=1;o<arguments.length;o++){var n=arguments[o];if(null!=n)for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t});let t=Object.freeze({Release:"Release",Debug:"Debug"}),o=Object.freeze({Normal:"Normal",DrawingView:"drawingView"}),n=Object.freeze({BIMFACE:"BIMFACE",Local:"Local"}),r=Object.freeze({zh_CN:"zh_CN",en_GB:"en_GB",sv_SE:"sv_SE",zh_TW:"zh_TW"}),a=Object.freeze({Normal:"Normal",Bake:"Bake"});window.BimfaceSDKLoaderConfig=function(){if(window.hostConfig){for(let t in window.hostConfig)e[t]=window.hostConfig[t];e.securityApi=window.hostConfig.securityApi}return{staticHost:`${e.staticHost}/api`,APIHost:e.APIHost,language:"zh_CN",viewToken:null,configuration:t.Release,dataEnvType:e.dataEnvType||"BIMFACE",viewType:o.Normal,visualStyle:a.Bake,version:"",securityApi:e.securityApi}},window.BimfaceEnvOption=n,window.BimfaceLanguageOption=r,window.BimfaceConfigrationOption=t,window.BimfaceViewTypeOption=o;let i=function(e){let t=e.split("/");return t.pop(),t.join("/")+"/"};var s=function(e,t){for(var o=0;o<t.length;o++)t[o]=e+t[o]},c=function(e){var t=e.sdkVersion,n=e.options,r=n.configuration,a=[],i=[`/${t}/${n.language}.js`,`/${t}/Application${r}.js`];return a=function(e,t){return"drawingView"==e.renderType||t.viewType==o.DrawingView}(e.metadata,e.options)?[...a,...i,`/${t}/Drawing.css`,`/${t}/bimface.bufferfly.js`,`/${t}/Drawing${r}.js`]:[...a,...i,`/${t}/Bimface.css`,`/${t}/thirdparty.js`,`/${t}/lib/loaders/BimTilesLoader.js`,`/${t}/Bimface${r}.js`],a};window.postProcessing=function(e){var o=e.metadata,n=e.options,r=e.successCb,a=c(e);s(n.staticHost,a),o.databagId=`${o.databagId}`,n.path?(o.path=n.path,o.dataPath="./"):n.resourcePath&&(o.path=n.resourcePath.replace("viewToken","")),o.sdkPath=n.sdkPath,0==a.length?r(o):d(a,(function(){if(n.build===t.Debug&&n.dataPath){let e=n.dataPath.split("/");r({databagId:e.pop(),path:e.join("/")})}r(o)}))};var d=function(e,o,n){var r=e.length,a=0,i=function(l){if(l&&"error"==l.message&&l.element.indexOf("bimface.index")>-1){a=0;var f=n.options;f.build,t.Release;var h=c(n);return s(f.staticHost,h),void d(h,o)}++a==r?o():u(e[a],i)};u(e[a],i)},l=[],u=function(e,t){if(!(l.indexOf(e.split("/").pop())>-1)){var o,n=document.getElementsByTagName("head")[0];return e.indexOf(".css")>-1?((o=document.createElement("link")).setAttribute("href",e),o.setAttribute("rel","stylesheet")):(o=document.createElement("script")).setAttribute("src",e),o.url=e,n.appendChild(o),o.addEventListener("load",(function(){l.push(this.url.split("/").pop()),t&&t({message:"success"})})),o.addEventListener("error",(function(){t&&t({element:e,message:"error"})})),o}t()};window.loadResource=d;class f extends class{constructor(e){this.indexedDB=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.msIndexedDB,this.indexedDB||console.log("IndexedDB not supported"),this._db=null,this._opt=e}open(e,t){const o=e||this._opt.name,n=t||this._opt.version||1,r=this.indexedDB.open(o,n);return new Promise(((e,t)=>{r.onsuccess=t=>{this._db=r.result,e(this._db)},r.onupgradeneeded=e=>{let t=this._db=e.target.result;(this._opt.storeList||[]).forEach((e=>!t.objectStoreNames.contains(e)&&t.createObjectStore(e)))},r.onerror=e=>{t(e)}}))}getDB(){return new Promise(((e,t)=>{this._db?e(this._db):this.open().then(e).catch(t)}))}addObject(e,t,o){return new Promise(((n,r)=>{this.getDB().then((a=>{const i=a.transaction(e,"readwrite");i.objectStore(e).put(t,o).onsuccess=e=>{n(e.target.result)},i.onerror=e=>{r(e)}})).catch(r)}))}getObject(e,t){return new Promise(((o,n)=>{this.getDB().then((r=>{const a=r.transaction(e,"readonly");a.objectStore(e).get(t).onsuccess=e=>{let t=e.target.result;t?o(t):n(e)},a.onerror=e=>{n(e)}})).catch(n)}))}deleteObject(e,t){return new Pro
|