zhgdlarge/public/bimface.js

1 line
11 KiB
JavaScript
Raw Permalink Normal View History

2023-07-12 09:56:31 +08:00
!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),n=1;n<arguments.length;n++){var o=arguments[n];if(null!=o)for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(t[a]=o[a])}return t});let t=Object.freeze({Release:"Release",Debug:"Debug"}),n=Object.freeze({Normal:"Normal",DrawingView:"drawingView"}),o=Object.freeze({BIMFACE:"BIMFACE",Local:"Local"}),a=Object.freeze({zh_CN:"zh_CN",en_GB:"en_GB",sv_SE:"sv_SE",zh_TW:"zh_TW"}),r=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:n.Normal,visualStyle:r.Bake,version:"",securityApi:e.securityApi}},window.BimfaceEnvOption=o,window.BimfaceLanguageOption=a,window.BimfaceConfigrationOption=t,window.BimfaceViewTypeOption=n;let i=function(e){let t=e.split("/");return t.pop(),t.join("/")+"/"};var s=function(e,t){for(var n=0;n<t.length;n++)t[n]=e+t[n]},d=function(e){var t=e.sdkVersion,o=e.options,a=o.configuration,r=[],i=[`/${t}/${o.language}.js`,`/${t}/Application${a}.js`];return r=function(e,t){return"drawingView"==e.renderType||t.viewType==n.DrawingView}(e.metadata,e.options)?[...r,...i,`/${t}/Drawing.css`,`/${t}/bimface.bufferfly.js`,`/${t}/Drawing${a}.js`]:[...r,...i,`/${t}/Bimface.css`,`/${t}/thirdparty.js`,`/${t}/lib/loaders/BimTilesLoader.js`,`/${t}/Bimface${a}.js`],r};window.postProcessing=function(e){var n=e.metadata,o=e.options,a=e.successCb,r=d(e);s(o.staticHost,r),n.databagId=`${n.databagId}`,o.path?(n.path=o.path,n.dataPath="./"):o.resourcePath&&(n.path=o.resourcePath.replace("viewToken","")),n.sdkPath=o.sdkPath,0==r.length?a(n):c(r,(function(){if(o.build===t.Debug&&o.dataPath){let e=o.dataPath.split("/");a({databagId:e.pop(),path:e.join("/")})}a(n)}))};var c=function(e,n,o){var a=e.length,r=0,i=function(l){if(l&&"error"==l.message&&l.element.indexOf("bimface.index")>-1){r=0;var h=o.options;h.build,t.Release;var g=d(o);return s(h.staticHost,g),void c(g,n)}++r==a?n():u(e[r],i)};u(e[r],i)},l=[],u=function(e,t){if(!(l.indexOf(e.split("/").pop())>-1)){var n,o=document.getElementsByTagName("head")[0];return e.indexOf(".css")>-1?((n=document.createElement("link")).setAttribute("href",e),n.setAttribute("rel","stylesheet")):(n=document.createElement("script")).setAttribute("src",e),n.url=e,o.appendChild(n),n.addEventListener("load",(function(){l.push(this.url.split("/").pop()),t&&t({message:"success"})})),n.addEventListener("error",(function(){t&&t({element:e,message:"error"})})),n}t()};window.loadResource=c;class h 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 n=e||this._opt.name,o=t||this._opt.version||1,a=this.indexedDB.open(n,o);return new Promise(((e,t)=>{a.onsuccess=t=>{this._db=a.result,e(this._db)},a.onupgradeneeded=e=>{let t=this._db=e.target.result;(this._opt.storeList||[]).forEach((e=>!t.objectStoreNames.contains(e)&&t.createObjectStore(e)))},a.onerror=e=>{t(e)}}))}getDB(){return new Promise(((e,t)=>{this._db?e(this._db):this.open().then(e).catch(t)}))}addObject(e,t,n){return new Promise(((o,a)=>{this.getDB().then((r=>{const i=r.transaction(e,"readwrite");i.objectStore(e).put(t,n).onsuccess=e=>{o(e.target.result)},i.onerror=e=>{a(e)}})).catch(a)}))}getObject(e,t){return new Promise(((n,o)=>{this.getDB().then((a=>{const r=a.transaction(e,"readonly");r.objectStore(e).get(t).onsuccess=e=>{let t=e.target.result;t?n(t):o(e)},r.onerror=e=>{o(e)}})).catch(o)}))}deleteObject(e,t){return new Pro