@epigraph/solutions 0.19.0-canary.3 → 0.19.0-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4163,9 +4163,9 @@ ${l.join(`
|
|
|
4163
4163
|
}`};function $h(o,e,t){let i=t;const a=new se;return o.updateWorldMatrix(!0,!0),o.traverseVisible(l=>{const{geometry:u}=l;if(u!==void 0){const{position:d}=u.attributes;if(d!==void 0)for(let p=0,m=d.count;p<m;p++)l.isMesh?l.getVertexPosition(p,a):a.fromBufferAttribute(d,p),l.isSkinnedMesh||a.applyMatrix4(l.matrixWorld),i=e(i,a)}}),i}function _U(o){const e=new Map,t=new Map,i=o.clone();return sC(o,i,function(a,l){e.set(l,a),t.set(a,l)}),i.traverse(function(a){if(!a.isSkinnedMesh)return;const l=a,u=e.get(a),d=u.skeleton.bones;l.skeleton=u.skeleton.clone(),l.bindMatrix.copy(u.bindMatrix),l.skeleton.bones=d.map(function(p){return t.get(p)}),l.bind(l.skeleton,l.bindMatrix)}),i}function sC(o,e,t){t(o,e);for(let i=0;i<o.children.length;i++)sC(o.children[i],e.children[i],t)}class yU{constructor(e,t,i,a,l){this.xrLight=e,this.renderer=t,this.lightProbe=i,this.xrWebGLBinding=null,this.estimationStartCallback=l,this.frameCallback=this.onXRFrame.bind(this);const u=t.xr.getSession();if(a&&"XRWebGLBinding"in window){const d=new z0(16);e.environment=d.texture;const p=t.getContext();switch(u.preferredReflectionFormat){case"srgba8":p.getExtension("EXT_sRGB");break;case"rgba16f":p.getExtension("OES_texture_half_float");break}this.xrWebGLBinding=new XRWebGLBinding(u,p),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}u.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const a=t.getLightEstimate(this.lightProbe);if(a){this.xrLight.lightProbe.sh.fromArray(a.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const l=Math.max(1,Math.max(a.primaryLightIntensity.x,Math.max(a.primaryLightIntensity.y,a.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(a.primaryLightIntensity.x/l,a.primaryLightIntensity.y/l,a.primaryLightIntensity.z/l),this.xrLight.directionalLight.intensity=l,this.xrLight.directionalLight.position.copy(a.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class bU extends Ai{constructor(e,t=!0){super(),this.lightProbe=new DR,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new zS,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let i=null,a=!1;e.xr.addEventListener("sessionstart",()=>{const l=e.xr.getSession();"requestLightProbe"in l&&l.requestLightProbe({reflectionFormat:l.preferredReflectionFormat}).then(u=>{i=new yU(this,e,u,t,()=>{a=!0,this.dispatchEvent({type:"estimationstart"})})})}),e.xr.addEventListener("sessionend",()=>{i&&(i.dispose(),i=null),a&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{i&&(i.dispose(),i=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}class vU{constructor({scene:e,targetRenderer:t,contactShadowSettings:i}){this.__contactShadowSettings={},this.__shadowState={shadow:{blur:4,darkness:.6,opacity:1},plane:{color:"#ffffff",opacity:0},showWireframe:!1},this.__blurPlane={},this.__renderTarget={},this.__renderTargetBlur={},this.__shadowCamera={},this.__depthMaterial={},this.__horizontalBlurMaterial={},this.__verticalBlurMaterial={},this.__planeMaterial={},this.__scene=e,this.__targetRenderer=t,this.__contactShadowSettings=i,this.isEnabled()&&this.setupContactShadows()}isEnabled(){return this.__contactShadowSettings.enabled}enable(){this.__contactShadowSettings.enabled=!0}disable(){this.__contactShadowSettings.enabled=!1}updateShadowSoftness(e){this.__shadowState.shadow.blur=e}updateShadowIntensity(e){this.__shadowState.shadow.opacity=e,this.__planeMaterial.opacity=e,this.__planeMaterial.needsUpdate=!0}__blurShadow(e){this.__blurPlane.visible=!0,this.__blurPlane.material=this.__horizontalBlurMaterial,this.__blurPlane.material.uniforms.tDiffuse.value=this.__renderTarget.texture,this.__horizontalBlurMaterial.uniforms.h.value=e*1/256,this.__targetRenderer.setRenderTarget(this.__renderTargetBlur),this.__targetRenderer.render(this.__blurPlane,this.__shadowCamera),this.__blurPlane.material=this.__verticalBlurMaterial,this.__blurPlane.material.uniforms.tDiffuse.value=this.__renderTargetBlur.texture,this.__verticalBlurMaterial.uniforms.v.value=e*1/256,this.__targetRenderer.setRenderTarget(this.__renderTarget),this.__targetRenderer.render(this.__blurPlane,this.__shadowCamera),this.__blurPlane.visible=!1}setupContactShadows(){if(!this.__contactShadowSettings.enabled)return;const{planeLength:e,planeWidth:t,cameraHeight:i}=this.__contactShadowSettings,a=e,l=t,u=i,d=new Ai;d.position.y=0,this.__scene.add(d),this.__renderTarget=new dn(512,512),this.__renderTarget.texture.generateMipmaps=!1,this.__renderTargetBlur=new dn(512,512),this.__renderTargetBlur.texture.generateMipmaps=!1;const p=new Rs(l,a).rotateX(Math.PI/2);this.__planeMaterial=new wi({map:this.__renderTarget.texture,opacity:this.__shadowState.shadow.opacity,transparent:!0,depthWrite:!1});const m=new lt(p,this.__planeMaterial);m.renderOrder=1,d.add(m),m.scale.y=-1,this.__blurPlane=new lt(p),this.__blurPlane.visible=!1,d.add(this.__blurPlane);const A=new wi({color:this.__shadowState.plane.color,opacity:this.__shadowState.plane.opacity,transparent:!0,depthWrite:!1}),_=new lt(p,A);_.rotateX(Math.PI),d.add(_),this.__shadowCamera=new Zr(-l/2,l/2,a/2,-a/2,0,u),this.__shadowCamera.rotation.x=Math.PI/2,d.add(this.__shadowCamera),this.__depthMaterial=new j0,this.__depthMaterial.userData.darkness={value:this.__shadowState.shadow.darkness},this.__depthMaterial.onBeforeCompile=b=>{b.uniforms.darkness=this.__depthMaterial.userData.darkness,b.fragmentShader=`
|
|
4164
4164
|
uniform float darkness;
|
|
4165
4165
|
${b.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );")}
|
|
4166
|
-
`},this.__depthMaterial.depthTest=!1,this.__depthMaterial.depthWrite=!1,this.__horizontalBlurMaterial=new zi(iC),this.__horizontalBlurMaterial.depthTest=!1,this.__verticalBlurMaterial=new zi(nC),this.__verticalBlurMaterial.depthTest=!1}reCalculateContactShadows(){const e=this.__scene.background;this.__scene.background=null,this.__scene.overrideMaterial=this.__depthMaterial;const t=this.__targetRenderer.getClearAlpha();this.__targetRenderer.setClearAlpha(0),this.__targetRenderer.setRenderTarget(this.__renderTarget),this.__targetRenderer.render(this.__scene,this.__shadowCamera),this.__scene.overrideMaterial=null,this.__blurShadow(this.__shadowState.shadow.blur),this.__blurShadow(this.__shadowState.shadow.blur*.4),this.__targetRenderer.setRenderTarget(null),this.__targetRenderer.setClearAlpha(t),this.__scene.background=e}}class St{static isTouchDevice(){try{return document.createEvent("TouchEvent"),!0}catch{return!1}}static async wait(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}static generateStylesDomElem(e,t=""){const i=document.createElement("style");return i.setAttribute("id",e),i.innerHTML=t,i}static generateHtmlDivElem(e,t=""){const i=document.createElement("div");return i.setAttribute("id",e),i.innerHTML=t,i}static getRandomIntegerInRange(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}static getUrlParameterByName(e,t=window.location.search){const i=new URLSearchParams(t);return Object.fromEntries(i.entries())[e]}static getBaseUrl(){const e=St.getUrlParameterByName("parentUrl");return e||window.location.href}static normalizeRadian(e){return Math.atan2(Math.sin(e),Math.cos(e))}static isBetweenOnCircle(e,t,i){return e=St.normalizeRadian(e),t=St.normalizeRadian(t),i=St.normalizeRadian(i),t<=i?e>=t&&e<=i:e>=t||e<=i}static getPointInBetweenByPercentage(e,t,i){let a=t.clone().sub(e);const l=a.length();return a=a.normalize().multiplyScalar(l*i),e.clone().add(a)}static clampAzimuth(e,t,i){if(Math.abs(t)==1/0||i==1/0)return e;const a=St.normalizeRadian(e),l=St.normalizeRadian(t),u=St.normalizeRadian(i);if(St.isBetweenOnCircle(a,l,u))return a;const d=Math.abs(St.normalizeRadian(a-l)),p=Math.abs(St.normalizeRadian(a-u));return d<p?l:u}static resolveNexusEndpoint(e){let t=wd.PRODUCTION;return e=="local"?t=wd.LOCAL:e==="staging"&&(t=wd.STAGING),t}static parseUrlForEpigraphParams(e){const t=new Map,i=new qg(e);t.set(Ii.epigraphSessionId,i.getParameterInUrl(Ii.epigraphSessionId)),t.set(Ii.identifier,i.getParameterInUrl(Ii.identifier)),t.set(Ii.identifierType,i.getParameterInUrl(Ii.identifierType)),t.set(Ii.type,i.getParameterInUrl(Ii.type));const a=i.getParameterInUrl(Ii.action);return a&&t.set(au.AR,JSON.parse(a)[au.AR]),t}static generateShareableUrl({baseUrl:e,identifier:t,identifierType:i,sharedConfig:a,arCompatible:l=!1}){const u=new Map;return u.set(Ii.epigraphSessionId,window.epigraph.epigraphSessionId),u.set(Ii.identifier,t),u.set(Ii.identifierType,i),a&&u.set(Ii.sharedConfig,a),l&&u.set(Ii.action,`{"${au.AR}":true}`),new qg(e).generateQrCodeUrl(Object.fromEntries(u.entries()),!1)}static _dispose3(e){e instanceof lt&&e.geometry.dispose(),e instanceof lt&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose(),e.material?.map?.dispose())}static dispose3(e){e.traverse(t=>{t instanceof lt&&St._dispose3(t)}),(e instanceof lt||e instanceof jn)&&St._dispose3(e)}static animateValue(e,t,i,a){const l=performance.now();function u(d){const p=d-l,m=Math.min(p/i,1),A=e+(t-e)*m;a(A),m<1&&requestAnimationFrame(u)}requestAnimationFrame(u)}static getCustomStylesTemplate(){const t=document.querySelector("#epigraphCustomStyles")?.content?.cloneNode(!0);return t||$e}}class rC{constructor(e){this._success=e}get success(){return this._success}set success(e){this._success=e}get failed(){return!this._success}}class wU extends rC{constructor(e=!1,t=void 0){super(e),this.__payload=t}get payload(){return this.__payload}set payload(e){this.__payload=e}}var aC=(o=>(o.Empty="entity-empty",o.Gltf="entity-mesh",o.Render="entity-render",o.Proxy="entity-proxy",o.Collider="entity-collider",o.Asset="entity-asset",o))(aC||{});class EU extends Ai{constructor({epgId:e=""}){super(),this._entityType=aC.Empty,e||(e=crypto.randomUUID()),this._epgId=e}get epgId(){return this._epgId}get entityType(){return this._entityType}destroy(){let e;const t=new wU(!1,e);return e=void 0,t.success=!0,t.payload=e,t}}class gv{constructor(e,t){this.__name=e,this.__hotspotConfigs=t}getName(){return this.__name}getHotspotConfigs(){return this.__hotspotConfigs}}class Kr extends kt{constructor(e){super(),this.epgType="PLUG",this.__connectionId="",this.__isPrimary=!1,this.__receiver=null,this.__debugGeo=null,this.__config=e,this.name=e.name,this.__connectionId=e.connectionId,this.__isPrimary=e.isPrimary;const t=e.position;this.position.set(t.x,t.y,t.z);const i=e.rotation;this.rotation.set(i.x,i.y,i.z)}get config(){return this.__config}get connectionId(){return this.__connectionId}get isPrimary(){return this.__isPrimary}get isOpen(){return this.__receiver===null}get receiver(){return this.__receiver}connect(e){this.__receiver=e.receiver}disconnect(){this.__receiver=null}clone(e){return new Kr(this.__config).copy(this,e)}showDebug(){const e=new se().setFromEuler(this.rotation).normalize(),t=this.position,i=.2,a=16711680;this.__debugGeo=new VS(e,t,i,a,.06,.06);const l=document.createElement("div");l.textContent=this.name;const u=new p_(l);l.style.pointerEvents="none";const d=new se;this.getWorldDirection(d),d.normalize();const p=this.position.clone().addScaledVector(d,Math.random());u.position.set(p.x,p.y,p.z),this.__debugGeo.add(u),this.add(this.__debugGeo)}hideDebug(){this.__debugGeo&&(this.__debugGeo.clear(),this.__debugGeo?.removeFromParent(),St.dispose3(this.__debugGeo))}}class ur extends kt{constructor(e){super(),this.epgType="RECEIVER",this.__connectionId="",this.__plug=null,this.__debugGeo=null,this.__config=e,this.name=e.name,this.__connectionId=e.connectionId;const t=e.position;this.position.set(t.x,t.y,t.z);const i=e.rotation;this.rotation.set(i.x,i.y,i.z)}get config(){return this.__config}get connectionId(){return this.__connectionId}get isOpen(){return this.__plug===null}get plug(){return this.__plug}connect(e){this.__plug=e.plug}disconnect(){this.__plug=null}clone(e){return new ur(this.__config).copy(this,e)}showDebug(){const e=new se().setFromEuler(this.rotation.clone()).normalize(),t=this.position,i=.1,a=65280;this.__debugGeo=new VS(e,t,i,a,.01,.08);const l=document.createElement("div");l.textContent=this.name,l.style.color="green";const u=new p_(l);l.style.pointerEvents="none",this.__debugGeo.add(u),this.add(this.__debugGeo)}hideDebug(){this.__debugGeo&&(this.__debugGeo.clear(),this.__debugGeo?.removeFromParent(),St.dispose3(this.__debugGeo))}}var m_=(o=>(o.Gltf="media-asset-gltf",o.Proxy="media-asset-proxy",o.Render="media-asset-render",o))(m_||{}),WA=(o=>(o.Plug="plug",o.Receiver="receiver",o))(WA||{});class oC{constructor({id:e,uri:t,appWcRef:i}){this._type="media-asset-gltf",this._id=crypto.randomUUID(),this._loadingProgress=0,this._state="declared",this._resource=null,e&&(this._id=e),this._appWcRef=i,this._uri=t}get id(){return this._id}get uri(){return this._uri}get loadingProgress(){return this._loadingProgress}get state(){return this._state}get isLoaded(){return this._state==="loaded"}get type(){return this._type}get resource(){return this._resource}highlight(){}updateLoadingProgress(e){this._loadingProgress=e,this._appWcRef.eventsManager.assetLoadProgress.fire({progress:e})}async load(){if(this._state==="loaded"||this._state==="loading")return Promise.resolve(!0);this._state="loading";const e=await this._appWcRef.loaders.gltfLoader.loadAsync(this._uri,t=>{this.updateLoadingProgress(t.loaded/t.total*100)}).catch(t=>(window.epigraph.logger.groupCollapsed({title:""}),window.epigraph.logger.error({title:"An error occurred while trying to load an asset!",details:t}),this._state="failed",Promise.reject()));return e===void 0?Promise.reject(!1):(this._resource=e,await this._parseLoadedGltf(),this._state="loaded",Promise.resolve(!0))}async _parseLoadedGltf(){window.epigraph.logger.info({title:"Parsing GLTF data",details:this._resource})}unload(){return this._resource={},Promise.resolve(!0)}}class xU extends oC{constructor({id:e,uri:t,appWcRef:i}){super({id:e,uri:t,appWcRef:i}),this._type=m_.Proxy,this.__plugs=[],this.__receivers=[]}get plugs(){return this.__plugs}get receivers(){return this.__receivers}async _parseLoadedGltf(){if(!this._resource?.scene)return;const e=[];this._resource.scene.traverse(t=>{if(t.userData.epgType===WA.Receiver){const i=new ur({name:t.name,connectionId:t.userData.connectionId,position:t.position.clone(),rotation:t.rotation.clone()});this.__receivers.push(i),e.push(t)}else if(t.userData.epgType===WA.Plug){const i=new Kr({name:t.name,isPrimary:t.userData.isPrimary,connectionId:t.userData.connectionId,position:t.position.clone(),rotation:t.rotation.clone()});this.__plugs.push(i),e.push(t)}});for(const t of this.__receivers)this._resource.scene.add(t);for(const t of this.__plugs)this._resource.scene.add(t);for(const t of e)t.removeFromParent(),St.dispose3(t)}unload(){return this._resource={},this.__plugs=[],this.__receivers=[],Promise.resolve(!0)}}class SU extends oC{constructor({id:e,uri:t,appWcRef:i}){super({id:e,uri:t,appWcRef:i}),this._type=m_.Render,this.__variantsExtensionName="KHR_materials_variants",this.__variantNamesFromAsset=[]}get khrVariantsExtensionName(){return this.__variantsExtensionName}get khrVariantsExtension(){return this.__variantsExtension}get variantNamesFromAsset(){return this.__variantNamesFromAsset}async _parseLoadedGltf(){const e=this._resource?.userData?.gltfExtensions;if(e&&(this.__variantsExtension=e[this.__variantsExtensionName]),this.__variantsExtension?.variants)for(const t of this.__variantsExtension.variants)this.__variantNamesFromAsset.push(t.name)}unload(){return this._resource={},this.__variantsExtension={},this.__variantNamesFromAsset=[],Promise.resolve(!0)}}class lC{constructor(e,t){this._loggerContext="ASSET",this.__autoGenerateProxyEntity=!1,this.__finishes=new Map,this.__id=e.id,this.__name=e.name,this.__appWcRef=t,this.__proxyGltf=new xU({id:String(e.id),uri:e.proxyGeo,appWcRef:this.__appWcRef}),this.__autoGenerateProxyEntity=e.autoGenerateProxyEntity,this.__renderGltf=new SU({id:String(e.id),uri:e.renderGeo,appWcRef:this.__appWcRef});for(const i in e.finishes)this.__finishes.set(i,new gv(i,e.finishes[i].hotspots))}get id(){return this.__id}get name(){return this.__name}get proxyGltf(){return this.__proxyGltf}get autoGenerateProxyEntity(){return this.__autoGenerateProxyEntity}get renderGltf(){return this.__renderGltf}get finishes(){return this.__finishes}get allFinishIds(){const e=[];for(const t of this.__finishes.keys())e.push(t);return e}async loadProxyGltf(){return this.__proxyGltf?await this.__proxyGltf.load():Promise.resolve(!0)}pullFinishesFromRenderGltf(){this.__renderGltf.khrVariantsExtension?.variants.forEach(e=>{const t=e.name;this.__finishes.has(t)||this.__finishes.set(t,new gv(t,[]))})}async loadRenderGltf(e=!1){return await this.__renderGltf.load().catch(t=>(window.epigraph.logger.error({title:`Failed to load asset: ${this.__id}`,details:t,contextOverride:this._loggerContext}),Promise.reject(!1))),e&&this.pullFinishesFromRenderGltf(),Promise.resolve(!0)}async load(e=!1){return Promise.all([this.loadRenderGltf(e),this.loadProxyGltf()])}}var CU=Object.defineProperty,cC=(o,e,t,i)=>{for(var a=void 0,l=o.length-1,u;l>=0;l--)(u=o[l])&&(a=u(e,t,a)||a);return a&&CU(e,t,a),a};class uC{constructor({appWcRef:e}){this._loggerContext="SOLUTION MANAGER",this._appWcRef=e}initialize(){window.epigraph.logger.info({title:"Initializing...",contextOverride:this._loggerContext})}}const g_=class Rd extends ul{constructor(){super(),this._loggerContext="SOLUTION MANAGER",this.enabled=!1}static{this.webComponentName="solution-manager"}connectedCallback(){super.connectedCallback(),window.epigraph.logger.info({title:"Initializing...",contextOverride:this._loggerContext})}firstUpdated(e){super.firstUpdated(e)}static setupWebComponent(){window.customElements.get(Rd.webComponentName)||window.customElements.define(Rd.webComponentName,Rd)}render(){return Ee`
|
|
4166
|
+
`},this.__depthMaterial.depthTest=!1,this.__depthMaterial.depthWrite=!1,this.__horizontalBlurMaterial=new zi(iC),this.__horizontalBlurMaterial.depthTest=!1,this.__verticalBlurMaterial=new zi(nC),this.__verticalBlurMaterial.depthTest=!1}reCalculateContactShadows(){const e=this.__scene.background;this.__scene.background=null,this.__scene.overrideMaterial=this.__depthMaterial;const t=this.__targetRenderer.getClearAlpha();this.__targetRenderer.setClearAlpha(0),this.__targetRenderer.setRenderTarget(this.__renderTarget),this.__targetRenderer.render(this.__scene,this.__shadowCamera),this.__scene.overrideMaterial=null,this.__blurShadow(this.__shadowState.shadow.blur),this.__blurShadow(this.__shadowState.shadow.blur*.4),this.__targetRenderer.setRenderTarget(null),this.__targetRenderer.setClearAlpha(t),this.__scene.background=e}}class St{static isTouchDevice(){try{return document.createEvent("TouchEvent"),!0}catch{return!1}}static async wait(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}static generateStylesDomElem(e,t=""){const i=document.createElement("style");return i.setAttribute("id",e),i.innerHTML=t,i}static generateHtmlDivElem(e,t=""){const i=document.createElement("div");return i.setAttribute("id",e),i.innerHTML=t,i}static getRandomIntegerInRange(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}static getUrlParameterByName(e,t=window.location.search){const i=new URLSearchParams(t);return Object.fromEntries(i.entries())[e]}static getBaseUrl(){const e=St.getUrlParameterByName("parentUrl");return e||window.location.href}static normalizeRadian(e){return Math.atan2(Math.sin(e),Math.cos(e))}static isBetweenOnCircle(e,t,i){return e=St.normalizeRadian(e),t=St.normalizeRadian(t),i=St.normalizeRadian(i),t<=i?e>=t&&e<=i:e>=t||e<=i}static getPointInBetweenByPercentage(e,t,i){let a=t.clone().sub(e);const l=a.length();return a=a.normalize().multiplyScalar(l*i),e.clone().add(a)}static clampAzimuth(e,t,i){if(Math.abs(t)==1/0||i==1/0)return e;const a=St.normalizeRadian(e),l=St.normalizeRadian(t),u=St.normalizeRadian(i);if(St.isBetweenOnCircle(a,l,u))return a;const d=Math.abs(St.normalizeRadian(a-l)),p=Math.abs(St.normalizeRadian(a-u));return d<p?l:u}static resolveNexusEndpoint(e){let t=wd.PRODUCTION;return e=="local"?t=wd.LOCAL:e==="staging"&&(t=wd.STAGING),t}static parseUrlForEpigraphParams(e){const t=new Map,i=new qg(e);t.set(Ii.epigraphSessionId,i.getParameterInUrl(Ii.epigraphSessionId)),t.set(Ii.identifier,i.getParameterInUrl(Ii.identifier)),t.set(Ii.identifierType,i.getParameterInUrl(Ii.identifierType)),t.set(Ii.type,i.getParameterInUrl(Ii.type));const a=i.getParameterInUrl(Ii.action);return a&&t.set(au.AR,JSON.parse(a)[au.AR]),t}static generateShareableUrl({baseUrl:e,identifier:t,identifierType:i,sharedConfig:a,arCompatible:l=!1}){const u=new Map;return u.set(Ii.epigraphSessionId,window.epigraph.epigraphSessionId),u.set(Ii.identifier,t),u.set(Ii.identifierType,i),a&&u.set(Ii.sharedConfig,a),l&&u.set(Ii.action,`{"${au.AR}":true}`),new qg(e).generateQrCodeUrl(Object.fromEntries(u.entries()),!1)}static _dispose3(e){e instanceof lt&&e.geometry.dispose(),e instanceof lt&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose(),e.material?.map?.dispose())}static dispose3(e){e.traverse(t=>{t instanceof lt&&St._dispose3(t)}),(e instanceof lt||e instanceof jn)&&St._dispose3(e)}static animateValue(e,t,i,a){const l=performance.now();function u(d){const p=d-l,m=Math.min(p/i,1),A=e+(t-e)*m;a(A),m<1&&requestAnimationFrame(u)}requestAnimationFrame(u)}static getCustomStylesTemplate(){const t=document.querySelector("#epigraphCustomStyles")?.content?.cloneNode(!0);return t||$e}}class rC{constructor(e){this._success=e}get success(){return this._success}set success(e){this._success=e}get failed(){return!this._success}}class wU extends rC{constructor(e=!1,t=void 0){super(e),this.__payload=t}get payload(){return this.__payload}set payload(e){this.__payload=e}}var aC=(o=>(o.Empty="entity-empty",o.Gltf="entity-mesh",o.Render="entity-render",o.Proxy="entity-proxy",o.Collider="entity-collider",o.Asset="entity-asset",o))(aC||{});class EU extends Ai{constructor(){super(),this._entityType=aC.Empty}get entityType(){return this._entityType}destroy(){let e;const t=new wU(!1,e);return e=void 0,t.success=!0,t.payload=e,t}}class gv{constructor(e,t){this.__name=e,this.__hotspotConfigs=t}getName(){return this.__name}getHotspotConfigs(){return this.__hotspotConfigs}}class Kr extends kt{constructor(e){super(),this.epgType="PLUG",this.__connectionId="",this.__isPrimary=!1,this.__receiver=null,this.__debugGeo=null,this.__config=e,this.name=e.name,this.__connectionId=e.connectionId,this.__isPrimary=e.isPrimary;const t=e.position;this.position.set(t.x,t.y,t.z);const i=e.rotation;this.rotation.set(i.x,i.y,i.z)}get config(){return this.__config}get connectionId(){return this.__connectionId}get isPrimary(){return this.__isPrimary}get isOpen(){return this.__receiver===null}get receiver(){return this.__receiver}connect(e){this.__receiver=e.receiver}disconnect(){this.__receiver=null}clone(e){return new Kr(this.__config).copy(this,e)}showDebug(){const e=new se().setFromEuler(this.rotation).normalize(),t=this.position,i=.2,a=16711680;this.__debugGeo=new VS(e,t,i,a,.06,.06);const l=document.createElement("div");l.textContent=this.name;const u=new p_(l);l.style.pointerEvents="none";const d=new se;this.getWorldDirection(d),d.normalize();const p=this.position.clone().addScaledVector(d,Math.random());u.position.set(p.x,p.y,p.z),this.__debugGeo.add(u),this.add(this.__debugGeo)}hideDebug(){this.__debugGeo&&(this.__debugGeo.clear(),this.__debugGeo?.removeFromParent(),St.dispose3(this.__debugGeo))}}class ur extends kt{constructor(e){super(),this.epgType="RECEIVER",this.__connectionId="",this.__plug=null,this.__debugGeo=null,this.__config=e,this.name=e.name,this.__connectionId=e.connectionId;const t=e.position;this.position.set(t.x,t.y,t.z);const i=e.rotation;this.rotation.set(i.x,i.y,i.z)}get config(){return this.__config}get connectionId(){return this.__connectionId}get isOpen(){return this.__plug===null}get plug(){return this.__plug}connect(e){this.__plug=e.plug}disconnect(){this.__plug=null}clone(e){return new ur(this.__config).copy(this,e)}showDebug(){const e=new se().setFromEuler(this.rotation.clone()).normalize(),t=this.position,i=.1,a=65280;this.__debugGeo=new VS(e,t,i,a,.01,.08);const l=document.createElement("div");l.textContent=this.name,l.style.color="green";const u=new p_(l);l.style.pointerEvents="none",this.__debugGeo.add(u),this.add(this.__debugGeo)}hideDebug(){this.__debugGeo&&(this.__debugGeo.clear(),this.__debugGeo?.removeFromParent(),St.dispose3(this.__debugGeo))}}var m_=(o=>(o.Gltf="media-asset-gltf",o.Proxy="media-asset-proxy",o.Render="media-asset-render",o))(m_||{}),WA=(o=>(o.Plug="plug",o.Receiver="receiver",o))(WA||{});class oC{constructor({id:e,uri:t,appWcRef:i}){this._type="media-asset-gltf",this._id=crypto.randomUUID(),this._loadingProgress=0,this._state="declared",this._resource=null,e&&(this._id=e),this._appWcRef=i,this._uri=t}get id(){return this._id}get uri(){return this._uri}get loadingProgress(){return this._loadingProgress}get state(){return this._state}get isLoaded(){return this._state==="loaded"}get type(){return this._type}get resource(){return this._resource}highlight(){}updateLoadingProgress(e){this._loadingProgress=e,this._appWcRef.eventsManager.assetLoadProgress.fire({progress:e})}async load(){if(this._state==="loaded"||this._state==="loading")return Promise.resolve(!0);this._state="loading";const e=await this._appWcRef.loaders.gltfLoader.loadAsync(this._uri,t=>{this.updateLoadingProgress(t.loaded/t.total*100)}).catch(t=>(window.epigraph.logger.groupCollapsed({title:""}),window.epigraph.logger.error({title:"An error occurred while trying to load an asset!",details:t}),this._state="failed",Promise.reject()));return e===void 0?Promise.reject(!1):(this._resource=e,await this._parseLoadedGltf(),this._state="loaded",Promise.resolve(!0))}async _parseLoadedGltf(){window.epigraph.logger.info({title:"Parsing GLTF data",details:this._resource})}unload(){return this._resource={},Promise.resolve(!0)}}class xU extends oC{constructor({id:e,uri:t,appWcRef:i}){super({id:e,uri:t,appWcRef:i}),this._type=m_.Proxy,this.__plugs=[],this.__receivers=[]}get plugs(){return this.__plugs}get receivers(){return this.__receivers}async _parseLoadedGltf(){if(!this._resource?.scene)return;const e=[];this._resource.scene.traverse(t=>{if(t.userData.epgType===WA.Receiver){const i=new ur({name:t.name,connectionId:t.userData.connectionId,position:t.position.clone(),rotation:t.rotation.clone()});this.__receivers.push(i),e.push(t)}else if(t.userData.epgType===WA.Plug){const i=new Kr({name:t.name,isPrimary:t.userData.isPrimary,connectionId:t.userData.connectionId,position:t.position.clone(),rotation:t.rotation.clone()});this.__plugs.push(i),e.push(t)}});for(const t of this.__receivers)this._resource.scene.add(t);for(const t of this.__plugs)this._resource.scene.add(t);for(const t of e)t.removeFromParent(),St.dispose3(t)}unload(){return this._resource={},this.__plugs=[],this.__receivers=[],Promise.resolve(!0)}}class SU extends oC{constructor({id:e,uri:t,appWcRef:i}){super({id:e,uri:t,appWcRef:i}),this._type=m_.Render,this.__variantsExtensionName="KHR_materials_variants",this.__variantNamesFromAsset=[]}get khrVariantsExtensionName(){return this.__variantsExtensionName}get khrVariantsExtension(){return this.__variantsExtension}get variantNamesFromAsset(){return this.__variantNamesFromAsset}async _parseLoadedGltf(){const e=this._resource?.userData?.gltfExtensions;if(e&&(this.__variantsExtension=e[this.__variantsExtensionName]),this.__variantsExtension?.variants)for(const t of this.__variantsExtension.variants)this.__variantNamesFromAsset.push(t.name)}unload(){return this._resource={},this.__variantsExtension={},this.__variantNamesFromAsset=[],Promise.resolve(!0)}}class lC{constructor(e,t){this._loggerContext="ASSET",this.__autoGenerateProxyEntity=!1,this.__finishes=new Map,this.__id=e.id,this.__name=e.name,this.__appWcRef=t,this.__proxyGltf=new xU({id:String(e.id),uri:e.proxyGeo,appWcRef:this.__appWcRef}),this.__autoGenerateProxyEntity=e.autoGenerateProxyEntity,this.__renderGltf=new SU({id:String(e.id),uri:e.renderGeo,appWcRef:this.__appWcRef});for(const i in e.finishes)this.__finishes.set(i,new gv(i,e.finishes[i].hotspots))}get id(){return this.__id}get name(){return this.__name}get proxyGltf(){return this.__proxyGltf}get autoGenerateProxyEntity(){return this.__autoGenerateProxyEntity}get renderGltf(){return this.__renderGltf}get finishes(){return this.__finishes}get allFinishIds(){const e=[];for(const t of this.__finishes.keys())e.push(t);return e}async loadProxyGltf(){return this.__proxyGltf?await this.__proxyGltf.load():Promise.resolve(!0)}pullFinishesFromRenderGltf(){this.__renderGltf.khrVariantsExtension?.variants.forEach(e=>{const t=e.name;this.__finishes.has(t)||this.__finishes.set(t,new gv(t,[]))})}async loadRenderGltf(e=!1){return await this.__renderGltf.load().catch(t=>(window.epigraph.logger.error({title:`Failed to load asset: ${this.__id}`,details:t,contextOverride:this._loggerContext}),Promise.reject(!1))),e&&this.pullFinishesFromRenderGltf(),Promise.resolve(!0)}async load(e=!1){return Promise.all([this.loadRenderGltf(e),this.loadProxyGltf()])}}var CU=Object.defineProperty,cC=(o,e,t,i)=>{for(var a=void 0,l=o.length-1,u;l>=0;l--)(u=o[l])&&(a=u(e,t,a)||a);return a&&CU(e,t,a),a};class uC{constructor({appWcRef:e}){this._loggerContext="SOLUTION MANAGER",this._appWcRef=e}initialize(){window.epigraph.logger.info({title:"Initializing...",contextOverride:this._loggerContext})}}const g_=class Rd extends ul{constructor(){super(),this._loggerContext="SOLUTION MANAGER",this.enabled=!1}static{this.webComponentName="solution-manager"}connectedCallback(){super.connectedCallback(),window.epigraph.logger.info({title:"Initializing...",contextOverride:this._loggerContext})}firstUpdated(e){super.firstUpdated(e)}static setupWebComponent(){window.customElements.get(Rd.webComponentName)||window.customElements.define(Rd.webComponentName,Rd)}render(){return Ee`
|
|
4167
4167
|
${St.getCustomStylesTemplate()}
|
|
4168
|
-
`}};cC([he({type:Boolean,attribute:"enabled"})],g_.prototype,"enabled");cC([he({attribute:!1})],g_.prototype,"appWcRef");let Qf=g_;class TU{constructor({id:e,name:t,receiver:i,plug:a}){this.__name=t,this.__plug=a,this.__receiver=i,e?this.__id=e:this.__id=`${this.__receiver.uuid}-${this.__plug.uuid}`}get id(){return this.__id}get name(){return this.__name}get plug(){return this.__plug}isPrimary(){return this.__plug?.isPrimary}get receiver(){return this.__receiver}connect(){this.__receiver.connect(this),this.__plug.connect(this)}disconnect(){this.__plug&&this.__plug.disconnect(),this.__receiver&&this.__receiver.disconnect()}}class IU{constructor({id:e,receiver:t,plug:i}){this.__id=e,this.__plug=i,this.__receiver=t}get id(){return this.__id}get plug(){return this.__plug}set plug(e){this.__plug=e}get receiver(){return this.__receiver}set receiver(e){this.__receiver=e}disconnect(){this.__receiver.disconnect(),this.__plug.disconnect()}}class MU extends Ai{constructor(e){super(),this.name="ENTITIES",this._loggerContext="SCENE STRUCTURE",this.__appWcRef=e,this.__eventsManager=this.__appWcRef.eventsManager}async setupRootEntity(e,t){const i=await new lC({id:0,name:"Root",proxyGeo:e??"https://asset.myepigraph.com/configurator-assets/epigraph-solution-assets/staging-assets/pipeline-assets/3d-assets/proxies/root-proxy.glb",autoGenerateProxyEntity:!1,renderGeo:t??"https://asset.myepigraph.com/configurator-assets/epigraph-solution-assets/staging-assets/pipeline-assets/3d-assets/render/root-render.glb",finishes:{}},this.__appWcRef);await i.load().catch(()=>Promise.reject(!1));const a=new Ll(i);await a.initialize(),this.add(a),this.__rootEntity=a}get rootEntity(){return this.__rootEntity}isEmpty(){return this.__rootEntity===void 0||this.__rootEntity.children.length===0}isNotEmpty(){return!this.isEmpty()}addEntity(e){this.__rootEntity.add(e),this.__eventsManager.structureNodeAddedEvent.fire({node:e})}getFirstEntity(){return this.isEmpty()?null:this.getSceneEntities()[0]}getSceneEntities(e=!1){const t=[];return this.__rootEntity.traverse(i=>{!e&&i.uuid===this.__rootEntity.uuid||i instanceof Ll&&t.push(i)}),t}getPossibleConnectionsForAssetInScene(e){const t=[];window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e,contextOverride:this._loggerContext});for(const i of this.getSceneEntities(!0)){const a=i.findPossibleConnectionsForAsset(e);a.length>0&&t.push(...a)}return window.epigraph.logger.table({title:"Possible Connections",details:t}),t}getAllConnectionsInScene(){const e=new Map;return this.traverse(t=>{if(t instanceof ur||t instanceof Kr){if(t.connectionId===""||e.has(t.connectionId))return;let a=null,l=null;if(t instanceof ur?(a=t,l=t.plug):t instanceof Kr&&(a=t.receiver,l=t),a!==null&&l!==null){const u=new IU({id:t.connectionId,receiver:a,plug:l});e.set(t.connectionId,u)}}}),e}}class RU extends uC{constructor(e){super({appWcRef:e}),this._loggerContext="SCENE MANAGER",this.__currentSceneBounds=new vi,this.__sceneStructure=new MU(this._appWcRef)}get sceneStructure(){return this.__sceneStructure}get currentSceneBounds(){return this.__currentSceneBounds}recalculateSceneBounds(){this.currentSceneBounds.setFromPoints([new se]),this.__sceneStructure.isNotEmpty()&&this.__sceneStructure.rootEntity.traverse(e=>{e instanceof lt&&e.userData.isProxyMesh&&this.currentSceneBounds.expandByObject(e)}),this._appWcRef.eventsManager.sceneBoundsChanged.fire()}}class Ll extends EU{constructor(e){super({}),this.epgType="ENTITY_ASSET",this.__autoGeneratedProxy=new Ai,this.__proxyEntity=new Ai,this.__renderEntity=new Ai,this.__activeFinish="",this.__renderEntityBoundsBox=new vi,this.__renderEntityBoundsSize=new se,this.__animationMixer=null,this.__animations=[],this.__animationNames=[],this.name=e.name,this.__proxyEntity.name="PROXY",this.add(this.__proxyEntity),this.__renderEntity.name="RENDER",this.add(this.__renderEntity),this.__asset=e}get isRoot(){return this.name.toLowerCase()==="root"}get proxy(){return this.__proxyEntity}get render(){return this.__renderEntity}get activeAssetFinish(){return this.__activeFinish}get allAssetFinishes(){return this.__asset.finishes}get allFinishIds(){return this.__asset.allFinishIds}async selectAssetFinish(e,t=this.__renderEntity){window.epigraph.logger.info({title:`Switching to asset finish: ${e}`});const i=new rC(!1),a=this.__asset.renderGltf;if(!a)return Promise.reject(i);const l=a.khrVariantsExtension,u=a.khrVariantsExtensionName;if(!l?.variants||u===void 0)return window.epigraph.logger.warn({title:"No Variants found in asset. Using default material."}),i.success=!0,Promise.resolve(i);const d=l.variants.findIndex(p=>p.name===e);return t.traverse(async p=>{if(!(p instanceof lt)||!p.isMesh||!p.userData.gltfExtensions)return;const m=p.userData.gltfExtensions[u];if(!m)return window.epigraph.logger.error({title:"No Variants found in asset. Using default material."}),Promise.reject(i);p.userData.originalMaterial||(p.userData.originalMaterial=p.material);const A=m.mappings.find(_=>_.variants.includes(d));if(A&&a.resource){const _=a.resource.parser;p.material=await _.getDependency("material",A.material),_.assignFinalMaterial(p)}else window.epigraph.logger.warn({title:`Variant not found. Missing Variant ID: ${e}`,details:{message:"Available Variants",variants:l.variants}}),p.material=p.userData.originalMaterial;i.success=!0}),Promise.resolve(i)}findPossibleConnectionsForAsset(e){const t=[];return window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e}),this.__proxyEntity.traverse(i=>{if(!(i instanceof ur))return;const a=i;for(const l of e.proxyGltf?.plugs??[])l.connectionId===a.connectionId&&t.push(new TU({name:l.connectionId,receiver:a,plug:l}))}),t}getAnimationMixer(){return this.__animationMixer}getAllAnimations(){return this.__animations}getAllAnimationNames(){return this.__animationNames}async initialize(){this.__asset.autoGenerateProxyEntity?(await this.__initializeRenderEntity(),await this.__initializeProxyEntity()):(await this.__initializeProxyEntity(),await this.__initializeRenderEntity())}async __initializeRenderEntity(){const e=this.__asset?.renderGltf?.resource?.scene?.clone(!0);if(!e)return Promise.reject();this.__renderEntity.add(e),this.__renderEntityBoundsBox.setFromObject(e,!0),this.__renderEntityBoundsBox.getSize(this.__renderEntityBoundsSize);const t=new se;if(this.__renderEntityBoundsBox.getCenter(t),!this.__asset.proxyGltf){window.epigraph.logger.warn({title:"Attempted to place render geo at the grid for AssetEntity...",details:this});const i=new Ai;i.name="rendergeopivot";const a=new Wn(.01,.01,.01),l=new wi({color:65280,depthTest:!1}),u=new lt(a,l);i.add(u),this.__renderEntity.add(i),i.position.set(t.x,this.__renderEntityBoundsBox.min.y,t.z),i.attach(e),i.position.set(0,0,0),this.__renderEntity.attach(e),i.removeFromParent(),St.dispose3(i)}this.__updateAnimations()}async __initializeProxyEntity(){let e=this.__asset.proxyGltf.resource?.scene.clone();if((!e||this.__asset.autoGenerateProxyEntity)&&(this.__autoGenerateProxyScene(),e=this.__autoGeneratedProxy),!e)return window.epigraph.logger.error({title:"Failed to load OR auto generate proxy asset",details:this.__asset,contextOverride:"ASSET ENTITY"}),Promise.reject();this.__proxyEntity.add(e),this.__proxyEntity.traverse(t=>{t instanceof lt&&(t.userData.isProxyMesh=!0,t.visible=!1)})}__autoGenerateProxyScene(){window.epigraph.logger.info({title:"Attempting to auto generate proxy for asset...",details:this.__asset,contextOverride:"ASSET ENTITY"});const e=new Wn,t=new wi({color:65280,opacity:.5,transparent:!0}),i=new lt(e,t);i.name="AutoGeneratedProxyMesh",i.scale.set(this.__renderEntityBoundsSize.x,this.__renderEntityBoundsSize.y,this.__renderEntityBoundsSize.z);const a=new se;this.__renderEntityBoundsBox.getCenter(a);const l=new Ai;l.name="proxygeopivot";const u=new kf(.01,10,10),d=new wi({color:255,depthTest:!1}),p=new lt(u,d);l.add(p),this.__proxyEntity.add(l),l.translateY(-this.__renderEntityBoundsSize.y*.5),l.attach(i),l.position.set(0,0,0),this.__proxyEntity.add(i),l.removeFromParent(),St.dispose3(l),this.__autoGeneratedProxy.add(i)}__updateAnimations(){if(this.__animationMixer=null,this.__animations=[],this.__renderEntity.animations&&this.__asset.renderGltf.resource&&this.__asset.renderGltf.resource.animations.length>0){this.__animationMixer=new HS(this.__renderEntity.children[0]);for(const e of this.__asset.renderGltf.resource.animations)this.__animations.push(this.__animationMixer.clipAction(e)),this.__animationNames.push(e.name)}}}class BU extends EventTarget{constructor(e){super(),this._loggerContext="THREEJS ENGINE",this.__scene=new Wr,this.__tweenGroup=new i1,this.__clock=new GS,this.__effectsComposer={},this.__canvas={},this.__mainRenderer={},this.__textRenderer={},this.__screenshotRenderer={},this.__sceneHierarchy={baseSceneGrp:new Ai,lightsGrp:new Ai,sceneStructure:{},dimensionLinesGrp:new Ai,miscGrp:new Ai},this.__defaultEnvMap="https://asset.myepigraph.com/configurator-assets/epigraph-solution-assets/env-maps/neutral.hdr",this.__lengthLine={},this.__depthLine={},this.__heightLine={},this.__textureAnisotropyToUse=4,this.renderEngineSettings={hotspots:{enabled:!1},dimensions:{enabled:!1},contactShadows:{enabled:!0,planeLength:3,planeWidth:3,cameraHeight:1},postEffect:{ao:!1},camera:{clearColor:"#ffffff",focalLength:35,canPan:!0,canZoom:!0,minDistance:2,maxDistance:8,minPolarAngle:0,maxPolarAngle:1.5,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0},renderQuality:{antiAlias:!0},screenshots:{enabled:!1}},this.__appWcRef=e,this.__sceneHierarchy.sceneStructure=this.__appWcRef.sceneManager.sceneStructure}get canvas(){return this.__canvas}get scene(){return this.__scene}get mainRenderer(){return this.__mainRenderer}get textRenderer(){return this.__textRenderer}get effectsComposer(){return this.__effectsComposer}get screenshotRenderer(){return this.__screenshotRenderer}get sceneHierarchy(){return this.__sceneHierarchy}get contactShadows(){return this.__contactShadows}getClockDelta(){return this.__clock.getDelta()}get tweenGroup(){return this.__tweenGroup}updateAllTextureAnisotropy(){this.__scene.traverse(e=>{const i=e.material;i?.map&&(i.map.anisotropy=this.__textureAnisotropyToUse,i.needsUpdate=!0)})}printSceneHierarchy(e=!1){(function t(i){if(e===!0)console.group(`------ ${i.name} ------`),console.log(i);else{const a="epgType"in i?i.epgType:i.type;console.group(" <"+a+"> "+i.name)}i.children.forEach(t),console.groupEnd()})(this.__scene)}printSceneStructure(){let e="--";(function t(i){if(i instanceof Ll||i instanceof ur){const a=i.epgType;console.group(`${e} < ${a} > ${i.name} || ${i.uuid}`),e+="--|"}i.children.forEach(t),console.groupEnd()})(this.__sceneHierarchy.sceneStructure)}async emptyScene(){St.dispose3(this.scene),this.__sceneHierarchy.baseSceneGrp.clear(),this.__sceneHierarchy.lightsGrp.clear();const e=[];this.__sceneHierarchy.sceneStructure.rootEntity.traverse(t=>{t.uuid!==this.__sceneHierarchy.sceneStructure.rootEntity.uuid&&t instanceof Ll&&e.push(t)});for(const t of e)t.removeFromParent(),St.dispose3(t)}async _setupSceneHierarchy(){this.__sceneHierarchy.baseSceneGrp.name="GRP_BASE_SCENE",this.__scene.add(this.__sceneHierarchy.baseSceneGrp),this.__sceneHierarchy.lightsGrp.name="GRP_LIGHTS",this.__scene.add(this.__sceneHierarchy.lightsGrp),this.__scene.add(this.__sceneHierarchy.sceneStructure),this.__sceneHierarchy.dimensionLinesGrp.name="GRP_DIMENSIONS_LINES",this.__scene.add(this.__sceneHierarchy.dimensionLinesGrp),this.__sceneHierarchy.miscGrp.name="GRP_MISC",this.__scene.add(this.__sceneHierarchy.miscGrp)}async _setupLights({envMap:e=this.__defaultEnvMap}){this.__mainRenderer.outputColorSpace=Vt,this.__mainRenderer.toneMapping=M0,new Z1().load(e,i=>{i.mapping=xu,this.__scene.environment=i})}__setupEffectComposer(){this.__effectsComposer=new AU(this.__mainRenderer),window.epigraph.logger.info({title:"Effects to enable",details:this.renderEngineSettings.postEffect,contextOverride:this._loggerContext})}__constructLineSegment(e,t,i){const a=[e,t],l=new yi().setFromPoints(a),u=new Ya(l,i);return u.castShadow=!1,u}__setupDimensionLines(){const e={color:new Ye().setHex(11776947).convertSRGBToLinear(),scale:1,dashSize:.02,gapSize:.02},t=new Np(e),i=new Np(e),a=new Np(e),l=new se;this.__lengthLine=this.__constructLineSegment(l,l,t),this.__depthLine=this.__constructLineSegment(l,l,i),this.__heightLine=this.__constructLineSegment(l,l,a),this.__sceneHierarchy.dimensionLinesGrp.add(this.__lengthLine),this.__sceneHierarchy.dimensionLinesGrp.add(this.__depthLine),this.__sceneHierarchy.dimensionLinesGrp.add(this.__heightLine),this.setDimensionsVisibility(!1)}updateDimensionLines(e){this.__lengthLine.geometry?.setFromPoints([e.length.begin.worldPos,e.length.end.worldPos]),this.__depthLine.geometry?.setFromPoints([e.width.begin.worldPos,e.width.end.worldPos]),this.__heightLine.geometry?.setFromPoints([e.height.begin.worldPos,e.height.end.worldPos]),this.__lengthLine?.computeLineDistances(),this.__depthLine?.computeLineDistances(),this.__heightLine?.computeLineDistances()}frameUpdate(){this.__appWcRef.eventsManager.frameUpdated.fire()}repopulateHotspotIndicators(){this.__appWcRef.eventsManager.hotspotsUpdatedEvent.fire()}setDimensionsVisibility(e){this.__lengthLine.visible=e,this.__depthLine.visible=e,this.__heightLine.visible=e}async getSceneAsUsdzUrl(){const e=this.__sceneHierarchy.sceneStructure;this.printSceneHierarchy();const i=await new q1().parseAsync(e),a=new Blob([i],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(a)}async getSceneAsGlbUrl(){const e=new IN,t=new Nu,a=this.__sceneHierarchy.sceneStructure;this.printSceneHierarchy();const l={binary:!0,forceIndices:!0,trs:!1,onlyVisible:!0,embedImages:!0,maxTextureSize:1024},u=await t.parseAsync(a,l),d=await e.readBinary(new Uint8Array(u)),p=await this.optimizeGlb(d),m=await e.writeBinary(p);return await this.saveArrayBufferAsURL(m)}async optimizeGlb(e){const i=e.getRoot().listNodes();for(const a of i){a.setExtras({});const l=a.getName();(l==="GRP_ProxyMesh"||l==="GRP_LoadingPlaceholder")&&a.dispose()}return await e.transform(QN(),oO()),e}async saveArrayBufferAsURL(e){const t=new Blob([e],{type:"application/gltf-buffer"});return window.epigraph.logger.info({title:"Approx scene GLB size: "+t.size/1e6}),URL.createObjectURL(t)}__perFrameUpdate(){const e=this.__clock.getDelta();this.__contactShadows.isEnabled()&&this.__contactShadows.reCalculateContactShadows(),this.__appWcRef.postRenderFrameUpdateInEngine(e),this.__effectsComposer.render(),this.__tweenGroup.update(),requestAnimationFrame(this.__perFrameUpdate.bind(this))}__setupRenderers(){this.__mainRenderer=new af({antialias:this.renderEngineSettings.renderQuality.antiAlias,alpha:this.__appWcRef.transparentBackground}),this.__appWcRef.transparentBackground||this.__mainRenderer.setClearColor(this.renderEngineSettings.camera.clearColor),this.__mainRenderer.shadowMap.enabled=!0,this.__mainRenderer.shadowMap.type=I0,this.renderEngineSettings.screenshots.enabled&&(this.__screenshotRenderer=new af({antialias:this.renderEngineSettings.renderQuality.antiAlias,preserveDrawingBuffer:!0}),document.body.appendChild(this.__screenshotRenderer.domElement),this.__screenshotRenderer.domElement.style.display="none"),this.__textRenderer=new tC,this.__textRenderer.setSize(window.innerWidth,window.innerHeight),this.__textRenderer.domElement.style.position="absolute",this.__textRenderer.domElement.style.top="0px",this.__textRenderer.domElement.style.pointerEvents="none",document.body.appendChild(this.__textRenderer.domElement)}showTextRenderer(){this.__textRenderer.domElement.style.display="block"}hideTextRenderer(){this.__textRenderer.domElement.style.display="none"}async setup(e){e&&(this.renderEngineSettings=e),this.__setupRenderers(),this.__canvas=this.__mainRenderer.domElement,await this._setupSceneHierarchy(),await this._setupLights({envMap:this.__defaultEnvMap}),this.__contactShadows=new vU({scene:this.__scene,targetRenderer:this.__mainRenderer,contactShadowSettings:this.renderEngineSettings.contactShadows}),this.__setupDimensionLines(),this.__setupEffectComposer();const t=this.__mainRenderer.capabilities.getMaxAnisotropy();t<this.__textureAnisotropyToUse&&(this.__textureAnisotropyToUse=t),this.__perFrameUpdate(),requestAnimationFrame(this.__perFrameUpdate.bind(this));const i={canvasHtmlElem:this.__canvas,renderer:this.__mainRenderer,screenshotRenderer:this.__screenshotRenderer??void 0},a=1;return this.mainRenderer.setPixelRatio(a),this.effectsComposer.setPixelRatio(a),Promise.resolve(i)}}/*!
|
|
4168
|
+
`}};cC([he({type:Boolean,attribute:"enabled"})],g_.prototype,"enabled");cC([he({attribute:!1})],g_.prototype,"appWcRef");let Qf=g_;class TU{constructor({id:e,name:t,receiver:i,plug:a}){this.__name=t,this.__plug=a,this.__receiver=i,e?this.__id=e:this.__id=`${this.__receiver.uuid}-${this.__plug.uuid}`}get id(){return this.__id}get name(){return this.__name}get plug(){return this.__plug}isPrimary(){return this.__plug?.isPrimary}get receiver(){return this.__receiver}connect(){this.__receiver.connect(this),this.__plug.connect(this)}disconnect(){this.__plug&&this.__plug.disconnect(),this.__receiver&&this.__receiver.disconnect()}}class IU{constructor({id:e,receiver:t,plug:i}){this.__id=e,this.__plug=i,this.__receiver=t}get id(){return this.__id}get plug(){return this.__plug}set plug(e){this.__plug=e}get receiver(){return this.__receiver}set receiver(e){this.__receiver=e}disconnect(){this.__receiver.disconnect(),this.__plug.disconnect()}}class MU extends Ai{constructor(e){super(),this.name="ENTITIES",this._loggerContext="SCENE STRUCTURE",this.__appWcRef=e,this.__eventsManager=this.__appWcRef.eventsManager}async setupRootEntity(e,t){const i=await new lC({id:0,name:"Root",proxyGeo:e??"https://asset.myepigraph.com/configurator-assets/epigraph-solution-assets/staging-assets/pipeline-assets/3d-assets/proxies/root-proxy.glb",autoGenerateProxyEntity:!1,renderGeo:t??"https://asset.myepigraph.com/configurator-assets/epigraph-solution-assets/staging-assets/pipeline-assets/3d-assets/render/root-render.glb",finishes:{}},this.__appWcRef);await i.load().catch(()=>Promise.reject(!1));const a=new Ll(i);await a.initialize(),this.add(a),this.__rootEntity=a}get rootEntity(){return this.__rootEntity}isEmpty(){return this.__rootEntity===void 0||this.__rootEntity.children.length===0}isNotEmpty(){return!this.isEmpty()}addEntity(e){this.__rootEntity.add(e),this.__eventsManager.structureNodeAddedEvent.fire({node:e})}getFirstEntity(){return this.isEmpty()?null:this.getSceneEntities()[0]}getSceneEntities(e=!1){const t=[];return this.__rootEntity.traverse(i=>{!e&&i.uuid===this.__rootEntity.uuid||i instanceof Ll&&t.push(i)}),t}getPossibleConnectionsForAssetInScene(e){const t=[];window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e,contextOverride:this._loggerContext});for(const i of this.getSceneEntities(!0)){const a=i.findPossibleConnectionsForAsset(e);a.length>0&&t.push(...a)}return window.epigraph.logger.table({title:"Possible Connections",details:t}),t}getAllConnectionsInScene(){const e=new Map;return this.traverse(t=>{if(t instanceof ur||t instanceof Kr){if(t.connectionId===""||e.has(t.connectionId))return;let a=null,l=null;if(t instanceof ur?(a=t,l=t.plug):t instanceof Kr&&(a=t.receiver,l=t),a!==null&&l!==null){const u=new IU({id:t.connectionId,receiver:a,plug:l});e.set(t.connectionId,u)}}}),e}}class RU extends uC{constructor(e){super({appWcRef:e}),this._loggerContext="SCENE MANAGER",this.__currentSceneBounds=new vi,this.__sceneStructure=new MU(this._appWcRef)}get sceneStructure(){return this.__sceneStructure}get currentSceneBounds(){return this.__currentSceneBounds}recalculateSceneBounds(){this.currentSceneBounds.setFromPoints([new se]),this.__sceneStructure.isNotEmpty()&&this.__sceneStructure.rootEntity.traverse(e=>{e instanceof lt&&e.userData.isProxyMesh&&this.currentSceneBounds.expandByObject(e)}),this._appWcRef.eventsManager.sceneBoundsChanged.fire()}}class Ll extends EU{constructor(e){super(),this.epgType="ENTITY_ASSET",this.__autoGeneratedProxy=new Ai,this.__proxyEntity=new Ai,this.__renderEntity=new Ai,this.__activeFinish="",this.__renderEntityBoundsBox=new vi,this.__renderEntityBoundsSize=new se,this.__animationMixer=null,this.__animations=[],this.__animationNames=[],this.name=e.name,this.__proxyEntity.name="PROXY",this.add(this.__proxyEntity),this.__renderEntity.name="RENDER",this.add(this.__renderEntity),this.__asset=e}get asset(){return this.__asset}get isRoot(){return this.name.toLowerCase()==="root"}get proxy(){return this.__proxyEntity}get render(){return this.__renderEntity}get activeAssetFinish(){return this.__activeFinish}get allAssetFinishes(){return this.__asset.finishes}get allFinishIds(){return this.__asset.allFinishIds}async selectAssetFinish(e,t=this.__renderEntity){window.epigraph.logger.info({title:`Switching to asset finish: ${e}`});const i=new rC(!1),a=this.__asset.renderGltf;if(!a)return Promise.reject(i);const l=a.khrVariantsExtension,u=a.khrVariantsExtensionName;if(!l?.variants||u===void 0)return window.epigraph.logger.warn({title:"No Variants found in asset. Using default material."}),i.success=!0,Promise.resolve(i);const d=l.variants.findIndex(p=>p.name===e);return t.traverse(async p=>{if(!(p instanceof lt)||!p.isMesh||!p.userData.gltfExtensions)return;const m=p.userData.gltfExtensions[u];if(!m)return window.epigraph.logger.error({title:"No Variants found in asset. Using default material."}),Promise.reject(i);p.userData.originalMaterial||(p.userData.originalMaterial=p.material);const A=m.mappings.find(_=>_.variants.includes(d));if(A&&a.resource){const _=a.resource.parser;p.material=await _.getDependency("material",A.material),_.assignFinalMaterial(p)}else window.epigraph.logger.warn({title:`Variant not found. Missing Variant ID: ${e}`,details:{message:"Available Variants",variants:l.variants}}),p.material=p.userData.originalMaterial;i.success=!0}),Promise.resolve(i)}findPossibleConnectionsForAsset(e){const t=[];return window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e}),this.__proxyEntity.traverse(i=>{if(!(i instanceof ur))return;const a=i;for(const l of e.proxyGltf?.plugs??[])l.connectionId===a.connectionId&&t.push(new TU({name:l.connectionId,receiver:a,plug:l}))}),t}getAnimationMixer(){return this.__animationMixer}getAllAnimations(){return this.__animations}getAllAnimationNames(){return this.__animationNames}async initialize(){this.__asset.autoGenerateProxyEntity?(await this.__initializeRenderEntity(),await this.__initializeProxyEntity()):(await this.__initializeProxyEntity(),await this.__initializeRenderEntity())}async __initializeRenderEntity(){const e=this.__asset?.renderGltf?.resource?.scene?.clone(!0);if(!e)return Promise.reject();this.__renderEntity.add(e),this.__renderEntityBoundsBox.setFromObject(e,!0),this.__renderEntityBoundsBox.getSize(this.__renderEntityBoundsSize);const t=new se;if(this.__renderEntityBoundsBox.getCenter(t),!this.__asset.proxyGltf){window.epigraph.logger.warn({title:"Attempted to place render geo at the grid for AssetEntity...",details:this});const i=new Ai;i.name="rendergeopivot";const a=new Wn(.01,.01,.01),l=new wi({color:65280,depthTest:!1}),u=new lt(a,l);i.add(u),this.__renderEntity.add(i),i.position.set(t.x,this.__renderEntityBoundsBox.min.y,t.z),i.attach(e),i.position.set(0,0,0),this.__renderEntity.attach(e),i.removeFromParent(),St.dispose3(i)}this.__updateAnimations()}async __initializeProxyEntity(){let e=this.__asset.proxyGltf.resource?.scene.clone();if((!e||this.__asset.autoGenerateProxyEntity)&&(this.__autoGenerateProxyScene(),e=this.__autoGeneratedProxy),!e)return window.epigraph.logger.error({title:"Failed to load OR auto generate proxy asset",details:this.__asset,contextOverride:"ASSET ENTITY"}),Promise.reject();this.__proxyEntity.add(e),this.__proxyEntity.traverse(t=>{t instanceof lt&&(t.userData.isProxyMesh=!0,t.visible=!1)})}__autoGenerateProxyScene(){window.epigraph.logger.info({title:"Attempting to auto generate proxy for asset...",details:this.__asset,contextOverride:"ASSET ENTITY"});const e=new Wn,t=new wi({color:65280,opacity:.5,transparent:!0}),i=new lt(e,t);i.name="AutoGeneratedProxyMesh",i.scale.set(this.__renderEntityBoundsSize.x,this.__renderEntityBoundsSize.y,this.__renderEntityBoundsSize.z);const a=new se;this.__renderEntityBoundsBox.getCenter(a);const l=new Ai;l.name="proxygeopivot";const u=new kf(.01,10,10),d=new wi({color:255,depthTest:!1}),p=new lt(u,d);l.add(p),this.__proxyEntity.add(l),l.translateY(-this.__renderEntityBoundsSize.y*.5),l.attach(i),l.position.set(0,0,0),this.__proxyEntity.add(i),l.removeFromParent(),St.dispose3(l),this.__autoGeneratedProxy.add(i)}__updateAnimations(){if(this.__animationMixer=null,this.__animations=[],this.__renderEntity.animations&&this.__asset.renderGltf.resource&&this.__asset.renderGltf.resource.animations.length>0){this.__animationMixer=new HS(this.__renderEntity.children[0]);for(const e of this.__asset.renderGltf.resource.animations)this.__animations.push(this.__animationMixer.clipAction(e)),this.__animationNames.push(e.name)}}}class BU extends EventTarget{constructor(e){super(),this._loggerContext="THREEJS ENGINE",this.__scene=new Wr,this.__tweenGroup=new i1,this.__clock=new GS,this.__effectsComposer={},this.__canvas={},this.__mainRenderer={},this.__textRenderer={},this.__screenshotRenderer={},this.__sceneHierarchy={baseSceneGrp:new Ai,lightsGrp:new Ai,sceneStructure:{},dimensionLinesGrp:new Ai,miscGrp:new Ai},this.__defaultEnvMap="https://asset.myepigraph.com/configurator-assets/epigraph-solution-assets/env-maps/neutral.hdr",this.__lengthLine={},this.__depthLine={},this.__heightLine={},this.__textureAnisotropyToUse=4,this.renderEngineSettings={hotspots:{enabled:!1},dimensions:{enabled:!1},contactShadows:{enabled:!0,planeLength:3,planeWidth:3,cameraHeight:1},postEffect:{ao:!1},camera:{clearColor:"#ffffff",focalLength:35,canPan:!0,canZoom:!0,minDistance:2,maxDistance:8,minPolarAngle:0,maxPolarAngle:1.5,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0},renderQuality:{antiAlias:!0},screenshots:{enabled:!1}},this.__appWcRef=e,this.__sceneHierarchy.sceneStructure=this.__appWcRef.sceneManager.sceneStructure}get canvas(){return this.__canvas}get scene(){return this.__scene}get mainRenderer(){return this.__mainRenderer}get textRenderer(){return this.__textRenderer}get effectsComposer(){return this.__effectsComposer}get screenshotRenderer(){return this.__screenshotRenderer}get sceneHierarchy(){return this.__sceneHierarchy}get contactShadows(){return this.__contactShadows}getClockDelta(){return this.__clock.getDelta()}get tweenGroup(){return this.__tweenGroup}updateAllTextureAnisotropy(){this.__scene.traverse(e=>{const i=e.material;i?.map&&(i.map.anisotropy=this.__textureAnisotropyToUse,i.needsUpdate=!0)})}printSceneHierarchy(e=!1){(function t(i){if(e===!0)console.group(`------ ${i.name} ------`),console.log(i);else{const a="epgType"in i?i.epgType:i.type;console.group(" <"+a+"> "+i.name)}i.children.forEach(t),console.groupEnd()})(this.__scene)}printSceneStructure(){let e="--";(function t(i){if(i instanceof Ll||i instanceof ur){const a=i.epgType;console.group(`${e} < ${a} > ${i.name} || ${i.uuid}`),e+="--|"}i.children.forEach(t),console.groupEnd()})(this.__sceneHierarchy.sceneStructure)}async emptyScene(){St.dispose3(this.scene),this.__sceneHierarchy.baseSceneGrp.clear(),this.__sceneHierarchy.lightsGrp.clear();const e=[];this.__sceneHierarchy.sceneStructure.rootEntity.traverse(t=>{t.uuid!==this.__sceneHierarchy.sceneStructure.rootEntity.uuid&&t instanceof Ll&&e.push(t)});for(const t of e)t.removeFromParent(),St.dispose3(t)}async _setupSceneHierarchy(){this.__sceneHierarchy.baseSceneGrp.name="GRP_BASE_SCENE",this.__scene.add(this.__sceneHierarchy.baseSceneGrp),this.__sceneHierarchy.lightsGrp.name="GRP_LIGHTS",this.__scene.add(this.__sceneHierarchy.lightsGrp),this.__scene.add(this.__sceneHierarchy.sceneStructure),this.__sceneHierarchy.dimensionLinesGrp.name="GRP_DIMENSIONS_LINES",this.__scene.add(this.__sceneHierarchy.dimensionLinesGrp),this.__sceneHierarchy.miscGrp.name="GRP_MISC",this.__scene.add(this.__sceneHierarchy.miscGrp)}async _setupLights({envMap:e=this.__defaultEnvMap}){this.__mainRenderer.outputColorSpace=Vt,this.__mainRenderer.toneMapping=M0,new Z1().load(e,i=>{i.mapping=xu,this.__scene.environment=i})}__setupEffectComposer(){this.__effectsComposer=new AU(this.__mainRenderer),window.epigraph.logger.info({title:"Effects to enable",details:this.renderEngineSettings.postEffect,contextOverride:this._loggerContext})}__constructLineSegment(e,t,i){const a=[e,t],l=new yi().setFromPoints(a),u=new Ya(l,i);return u.castShadow=!1,u}__setupDimensionLines(){const e={color:new Ye().setHex(11776947).convertSRGBToLinear(),scale:1,dashSize:.02,gapSize:.02},t=new Np(e),i=new Np(e),a=new Np(e),l=new se;this.__lengthLine=this.__constructLineSegment(l,l,t),this.__depthLine=this.__constructLineSegment(l,l,i),this.__heightLine=this.__constructLineSegment(l,l,a),this.__sceneHierarchy.dimensionLinesGrp.add(this.__lengthLine),this.__sceneHierarchy.dimensionLinesGrp.add(this.__depthLine),this.__sceneHierarchy.dimensionLinesGrp.add(this.__heightLine),this.setDimensionsVisibility(!1)}updateDimensionLines(e){this.__lengthLine.geometry?.setFromPoints([e.length.begin.worldPos,e.length.end.worldPos]),this.__depthLine.geometry?.setFromPoints([e.width.begin.worldPos,e.width.end.worldPos]),this.__heightLine.geometry?.setFromPoints([e.height.begin.worldPos,e.height.end.worldPos]),this.__lengthLine?.computeLineDistances(),this.__depthLine?.computeLineDistances(),this.__heightLine?.computeLineDistances()}frameUpdate(){this.__appWcRef.eventsManager.frameUpdated.fire()}repopulateHotspotIndicators(){this.__appWcRef.eventsManager.hotspotsUpdatedEvent.fire()}setDimensionsVisibility(e){this.__lengthLine.visible=e,this.__depthLine.visible=e,this.__heightLine.visible=e}async getSceneAsUsdzUrl(){const e=this.__sceneHierarchy.sceneStructure;this.printSceneHierarchy();const i=await new q1().parseAsync(e),a=new Blob([i],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(a)}async getSceneAsGlbUrl(){const e=new IN,t=new Nu,a=this.__sceneHierarchy.sceneStructure;this.printSceneHierarchy();const l={binary:!0,forceIndices:!0,trs:!1,onlyVisible:!0,embedImages:!0,maxTextureSize:1024},u=await t.parseAsync(a,l),d=await e.readBinary(new Uint8Array(u)),p=await this.optimizeGlb(d),m=await e.writeBinary(p);return await this.saveArrayBufferAsURL(m)}async optimizeGlb(e){const i=e.getRoot().listNodes();for(const a of i){a.setExtras({});const l=a.getName();(l==="GRP_ProxyMesh"||l==="GRP_LoadingPlaceholder")&&a.dispose()}return await e.transform(QN(),oO()),e}async saveArrayBufferAsURL(e){const t=new Blob([e],{type:"application/gltf-buffer"});return window.epigraph.logger.info({title:"Approx scene GLB size: "+t.size/1e6}),URL.createObjectURL(t)}__perFrameUpdate(){const e=this.__clock.getDelta();this.__contactShadows.isEnabled()&&this.__contactShadows.reCalculateContactShadows(),this.__appWcRef.postRenderFrameUpdateInEngine(e),this.__effectsComposer.render(),this.__tweenGroup.update(),requestAnimationFrame(this.__perFrameUpdate.bind(this))}__setupRenderers(){this.__mainRenderer=new af({antialias:this.renderEngineSettings.renderQuality.antiAlias,alpha:this.__appWcRef.transparentBackground}),this.__appWcRef.transparentBackground||this.__mainRenderer.setClearColor(this.renderEngineSettings.camera.clearColor),this.__mainRenderer.shadowMap.enabled=!0,this.__mainRenderer.shadowMap.type=I0,this.renderEngineSettings.screenshots.enabled&&(this.__screenshotRenderer=new af({antialias:this.renderEngineSettings.renderQuality.antiAlias,preserveDrawingBuffer:!0}),document.body.appendChild(this.__screenshotRenderer.domElement),this.__screenshotRenderer.domElement.style.display="none"),this.__textRenderer=new tC,this.__textRenderer.setSize(window.innerWidth,window.innerHeight),this.__textRenderer.domElement.style.position="absolute",this.__textRenderer.domElement.style.top="0px",this.__textRenderer.domElement.style.pointerEvents="none",document.body.appendChild(this.__textRenderer.domElement)}showTextRenderer(){this.__textRenderer.domElement.style.display="block"}hideTextRenderer(){this.__textRenderer.domElement.style.display="none"}async setup(e){e&&(this.renderEngineSettings=e),this.__setupRenderers(),this.__canvas=this.__mainRenderer.domElement,await this._setupSceneHierarchy(),await this._setupLights({envMap:this.__defaultEnvMap}),this.__contactShadows=new vU({scene:this.__scene,targetRenderer:this.__mainRenderer,contactShadowSettings:this.renderEngineSettings.contactShadows}),this.__setupDimensionLines(),this.__setupEffectComposer();const t=this.__mainRenderer.capabilities.getMaxAnisotropy();t<this.__textureAnisotropyToUse&&(this.__textureAnisotropyToUse=t),this.__perFrameUpdate(),requestAnimationFrame(this.__perFrameUpdate.bind(this));const i={canvasHtmlElem:this.__canvas,renderer:this.__mainRenderer,screenshotRenderer:this.__screenshotRenderer??void 0},a=1;return this.mainRenderer.setPixelRatio(a),this.effectsComposer.setPixelRatio(a),Promise.resolve(i)}}/*!
|
|
4169
4169
|
* camera-controls
|
|
4170
4170
|
* https://github.com/yomotsu/camera-controls
|
|
4171
4171
|
* (c) 2017 @yomotsu
|
|
@@ -8499,7 +8499,7 @@ void main() {
|
|
|
8499
8499
|
opacity: 0;
|
|
8500
8500
|
pointer-events: none;
|
|
8501
8501
|
}
|
|
8502
|
-
`]}get timeElapsedSinceLoadBegin(){return parseFloat((performance.now()-this._loadTimeBegin).toFixed(2))}get epigraphAnalytics(){return this._epigraphAnalytics}get identifier(){return this._identifier}get identifierType(){return this._identifierType}get eventsManager(){return this._eventsManager}get canvasSize(){return this.__canvasSize}get loaders(){return this._loaders}get sceneManager(){return this._sceneManager}get cameraManager(){return this._cameraManager}get hasSceneChanged(){return this.__hasSceneChanged}set hasSceneChanged(e){this.__hasSceneChanged=e}get renderEngine(){return this._renderEngine}get isDevEnv(){return this._isDevEnv}enterPickerState(){this.pickerState=!0,this.style.cursor="crosshair"}exitPickerState(){this.pickerState=!1,this.style.cursor="grab"}renderScreenshotCanvasFrame(){this.renderEngine.screenshotRenderer.render(this.renderEngine.scene,this.cameraManager.getCameras().screenshot)}onLoadFailed(e,t){this._eventsManager.appFailedEvent.fire(t);const i=this.timeElapsedSinceLoadBegin,a=new V_(!0,i,e);this._epigraphAnalytics.sendEvent(a),this.showSplashScreen()}getFirstNonProxyFromIntersections(e){let t=null;for(const i of e)if(!(!i?.object||i.object.userData.isProxyMesh===!0)){t=i;break}return t}__getIntersectionsWithScene(e,t){const i=new J0,a=new Ve;return a.x=e/this.canvasSize.width*2-1,a.y=-(t/this.canvasSize.height)*2+1,i.setFromCamera(a,this.cameraManager.getCameras().main),i.intersectObjects(this.renderEngine.sceneHierarchy.sceneStructure.rootEntity.children,!0)}getPositionOnMeshFromPoint(e,t){const i=this.__getIntersectionsWithScene(e,t);if(i.length>0){const a=this.getFirstNonProxyFromIntersections(i);return a===null?null:a.point}else return null}getIntersectionOnProductFromPoint(e,t){const i=this.__getIntersectionsWithScene(e,t);let a=null;if(i.length>0){const l=this.getFirstNonProxyFromIntersections(i);if(!l?.object)return null;l.object.traverseAncestors(u=>{if(u instanceof Ll&&u.isRoot===!1){a={asset:{id:u.id,name:u.name},intersection:{point:l.point}};return}})}return a}getSceneSphericalBoundsForCameraFocus(){const e=this.sceneManager.currentSceneBounds;e.getCenter(this._boundingSphereCenter);const t=e.getBoundingSphere(new bn(this._boundingSphereCenter));if(this.dimensionsManager?.enabled){const i=this.canvasSize.height/this.canvasSize.width;t.radius+=i}return t}async getUsdzUrlForAr(){return this.__usdzBlobUrl=await this.renderEngine.getSceneAsUsdzUrl(),this.eventsManager.arModelReadyEvent.fire(this.__usdzBlobUrl),this.__usdzBlobUrl}async getGlbUrlForAr(){return this.__glbBlobUrl=await this.renderEngine.getSceneAsGlbUrl(),this.eventsManager.arModelReadyEvent.fire(this.__glbBlobUrl),this.__glbBlobUrl}async launchAR(){if(!this.isLoading)return await this.viewInYourSpaceManager.launchAR()}async spawnAssetInScene(e){const t=this.sceneManager.sceneStructure.getPossibleConnectionsForAssetInScene(e);if(t.length<=0)return Promise.resolve(void 0);const i=t[0];i.connect();const a=new Ll(e);await a.initialize();const l=i.receiver,u=i.plug.clone();this.sceneManager.sceneStructure.add(u);const d=new se;l.getWorldPosition(d),u.position.set(d.x,d.y,d.z),u.attach(a);const p=new $i;return l.getWorldQuaternion(p),u.setRotationFromQuaternion(p),l.attach(a),u.removeFromParent(),St.dispose3(u),Promise.resolve(a)}showDimensions(){this.dimensionsManager.enabled=!0,this.areDimensionsActive=!0,this.renderEngine.setDimensionsVisibility(this.dimensionsManager.enabled),this.cameraManager.fitCameraToSceneBounds()}hideDimensions(e=!1){this.dimensionsManager.enabled=!1,this.areDimensionsActive=!1,this.renderEngine.setDimensionsVisibility(this.dimensionsManager.enabled),e||this.cameraManager.fitCameraToSceneBounds()}getDimensions(){const e=this.dimensionsManager.getCurrentDimensionsState(),t=this.dimensionsManager.dimensionsUnit;return{length:e.length.distance,width:e.width.distance,height:e.height.distance,unit:t}}printSceneHierarchy(){this.renderEngine.printSceneHierarchy()}showCameraAim(){this.cameraAimElemRef.classList.remove("hide")}hideCameraAim(){this.cameraAimElemRef.classList.add("hide")}showHelp(){this.isHelpVisible=!0}hideHelp(){this.isHelpVisible=!1}toggleHelp(){this.isHelpVisible=!this.isHelpVisible}showHotspots(){window.epigraph.logger.info({title:"Showing Hotspots"}),this.areHotspotsActive=!0,this.eventsManager.hotspotsVisibilityChanged.fire({visible:!0})}hideHotspots(){window.epigraph.logger.info({title:"Hiding Hotspots"}),this.areHotspotsActive=!1,this.eventsManager.hotspotsVisibilityChanged.fire({visible:!1})}toggleHotspots(){this.hotspotsManager.enabled?this.hideHotspots():this.showHotspots()}updateHotspotsOrder(e){this.hotspotsManager.updateHotspotsOrder(e)}openHotspot({hotspotId:e,state:t,skipHotspotOpenEvent:i=!1}){this.hotspotsManager.openHotspot({hotspotId:e,state:t,skipHotspotOpenEvent:i})}closeActiveHotspot(){this.hotspotsManager.closeActiveHotspot()}setActiveHotspotState(e){this.hotspotsManager.setActiveHotspotState(e)}nextHotspot(){return this.hotspotsManager.nextHotspot()}previousHotspot(){return this.hotspotsManager.previousHotspot()}getActiveHotspot(){return this.hotspotsManager.activeHotspot}areHotspotsVisible(){return this.hotspotsManager.enabled}getAllHotspots(){return Array.from(this.hotspotsManager.hotspots.values())}getAllHotspotIds(){return Array.from(this.hotspotsManager.hotspots.keys())}getHotspotById(e){return this.hotspotsManager.hotspots.get(e)}createHotspots(e){this.hotspotsManager.createHotspots(e)}updateHotspots(e){this.hotspotsManager.updateHotspots(e)}removeHotspots(e){this.hotspotsManager.removeHotspots(e)}async __onPlayInteractionPrompt(e=2){this.showCameraInteractionPromptIndicator(),await St.wait(800);for(let t=0;t<e;t++)this.cameraInteractionPromptIndicatorElemRef.classList.add("play-wiggle-animation"),await this.cameraManager.wiggleCamera();this.cameraInteractionPromptIndicatorElemRef.classList.remove("play-wiggle-animation"),this.hideCameraInteractionPromptIndicator(),this._isSceneInteractedWith||setTimeout(()=>{this.__onPlayInteractionPrompt()},3e3)}getAllAnimations(){const e=this.sceneManager.sceneStructure.getFirstEntity();return e?e.getAllAnimations():[]}getAllAnimationNames(){const e=this.sceneManager.sceneStructure.getFirstEntity();return e?e.getAllAnimationNames():[]}playAnimationByName({animationName:e,clampWhenFinished:t=!1,loop:i=!1,repetitions:a=1/0,reverse:l=!1}){if(!e)return;const u=this.getAllAnimationNames();if(!u.includes(e)){window.epigraph.logger.warn({title:`Invalid animation name: ${e}. Expand for a list of valid names`,details:u});return}const d=u.indexOf(e),p=this.getAllAnimations()[d];return l?(p.timeScale=-1,p.fadeOut(this._animationFadeDurationInMiliseconds*.001)):(p.timeScale=1,p.fadeIn(this._animationFadeDurationInMiliseconds*.001)),p.setLoop(i?Fa:wl,a),p.clampWhenFinished=t,p.enabled=!0,p.play(),this._activeAnimations.set(e,p),{animationName:e,targetAnimationAction:p}}stopAnimationByName(e){if(!e)return;const t=this.getAllAnimationNames();if(!t.includes(e)){window.epigraph.logger.warn({title:`Invalid animation name: ${e}. Expand for a list of valid names`,details:t});return}const i=t.indexOf(e),a=this.getAllAnimations()[i];a.fadeOut(this._animationFadeDurationInMiliseconds*.001),setTimeout(()=>{a.stop()},this._animationFadeDurationInMiliseconds),this._activeAnimations.delete(e)}pauseActiveAnimations(e){for(const t of this._activeAnimations.values())t.paused=!0,e!==void 0&&(t.weight=e)}resumeActiveAnimations(){for(const e of this._activeAnimations.values())e.paused=!1,e.weight=1}stopAllAnimations(){for(const[e,t]of this._activeAnimations.entries())t.fadeOut(this._animationFadeDurationInMiliseconds*.001),setTimeout(()=>{t.stop(),this._activeAnimations.delete(e)},this._animationFadeDurationInMiliseconds)}postRenderFrameUpdateInEngine(e){try{this.cameraManager.mainCameraControls.update(e),this.renderEngine.mainRenderer.render(this.renderEngine.scene,this.cameraManager.getCameras().main),this.renderEngine.textRenderer.render(this.renderEngine.scene,this.cameraManager.getCameras().main)}catch(t){return t}}getScreenPositionFromWorld(e){const t=new Ve,i=this.cameraManager.getCameras().main,a=this.renderEngine.canvas.clientWidth*.5,l=this.renderEngine.canvas.clientHeight*.5,d=e.clone().project(i);return t.x=(d.x+1)*a,t.y=-(d.y-1)*l,t}_renderAppCanvasContainer(){return this.featuresToEnable.viewer?Ee`
|
|
8502
|
+
`]}get timeElapsedSinceLoadBegin(){return parseFloat((performance.now()-this._loadTimeBegin).toFixed(2))}get epigraphAnalytics(){return this._epigraphAnalytics}get identifier(){return this._identifier}get identifierType(){return this._identifierType}get eventsManager(){return this._eventsManager}get canvasSize(){return this.__canvasSize}get loaders(){return this._loaders}get sceneManager(){return this._sceneManager}get cameraManager(){return this._cameraManager}get hasSceneChanged(){return this.__hasSceneChanged}set hasSceneChanged(e){this.__hasSceneChanged=e}get renderEngine(){return this._renderEngine}get isDevEnv(){return this._isDevEnv}enterPickerState(){this.pickerState=!0,this.style.cursor="crosshair"}exitPickerState(){this.pickerState=!1,this.style.cursor="grab"}renderScreenshotCanvasFrame(){this.renderEngine.screenshotRenderer.render(this.renderEngine.scene,this.cameraManager.getCameras().screenshot)}onLoadFailed(e,t){this._eventsManager.appFailedEvent.fire(t);const i=this.timeElapsedSinceLoadBegin,a=new V_(!0,i,e);this._epigraphAnalytics.sendEvent(a),this.showSplashScreen()}getFirstNonProxyFromIntersections(e){let t=null;for(const i of e)if(!(!i?.object||i.object.userData.isProxyMesh===!0)){t=i;break}return t}__getIntersectionsWithScene(e,t){const i=new J0,a=new Ve;return a.x=e/this.canvasSize.width*2-1,a.y=-(t/this.canvasSize.height)*2+1,i.setFromCamera(a,this.cameraManager.getCameras().main),i.intersectObjects(this.renderEngine.sceneHierarchy.sceneStructure.rootEntity.children,!0)}getPositionOnMeshFromPoint(e,t){const i=this.__getIntersectionsWithScene(e,t);if(i.length>0){const a=this.getFirstNonProxyFromIntersections(i);return a===null?null:a.point}else return null}getIntersectionOnProductFromPoint(e,t){const i=this.__getIntersectionsWithScene(e,t);let a=null;if(i.length>0){const l=this.getFirstNonProxyFromIntersections(i);if(!l?.object)return null;l.object.traverseAncestors(u=>{if(u instanceof Ll&&u.isRoot===!1){a={asset:{id:u.asset.id,name:u.asset.name},intersection:{point:l.point}};return}})}return a}getSceneSphericalBoundsForCameraFocus(){const e=this.sceneManager.currentSceneBounds;e.getCenter(this._boundingSphereCenter);const t=e.getBoundingSphere(new bn(this._boundingSphereCenter));if(this.dimensionsManager?.enabled){const i=this.canvasSize.height/this.canvasSize.width;t.radius+=i}return t}async getUsdzUrlForAr(){return this.__usdzBlobUrl=await this.renderEngine.getSceneAsUsdzUrl(),this.eventsManager.arModelReadyEvent.fire(this.__usdzBlobUrl),this.__usdzBlobUrl}async getGlbUrlForAr(){return this.__glbBlobUrl=await this.renderEngine.getSceneAsGlbUrl(),this.eventsManager.arModelReadyEvent.fire(this.__glbBlobUrl),this.__glbBlobUrl}async launchAR(){if(!this.isLoading)return await this.viewInYourSpaceManager.launchAR()}async spawnAssetInScene(e){const t=this.sceneManager.sceneStructure.getPossibleConnectionsForAssetInScene(e);if(t.length<=0)return Promise.resolve(void 0);const i=t[0];i.connect();const a=new Ll(e);await a.initialize();const l=i.receiver,u=i.plug.clone();this.sceneManager.sceneStructure.add(u);const d=new se;l.getWorldPosition(d),u.position.set(d.x,d.y,d.z),u.attach(a);const p=new $i;return l.getWorldQuaternion(p),u.setRotationFromQuaternion(p),l.attach(a),u.removeFromParent(),St.dispose3(u),Promise.resolve(a)}showDimensions(){this.dimensionsManager.enabled=!0,this.areDimensionsActive=!0,this.renderEngine.setDimensionsVisibility(this.dimensionsManager.enabled),this.cameraManager.fitCameraToSceneBounds()}hideDimensions(e=!1){this.dimensionsManager.enabled=!1,this.areDimensionsActive=!1,this.renderEngine.setDimensionsVisibility(this.dimensionsManager.enabled),e||this.cameraManager.fitCameraToSceneBounds()}getDimensions(){const e=this.dimensionsManager.getCurrentDimensionsState(),t=this.dimensionsManager.dimensionsUnit;return{length:e.length.distance,width:e.width.distance,height:e.height.distance,unit:t}}printSceneHierarchy(){this.renderEngine.printSceneHierarchy()}showCameraAim(){this.cameraAimElemRef.classList.remove("hide")}hideCameraAim(){this.cameraAimElemRef.classList.add("hide")}showHelp(){this.isHelpVisible=!0}hideHelp(){this.isHelpVisible=!1}toggleHelp(){this.isHelpVisible=!this.isHelpVisible}showHotspots(){window.epigraph.logger.info({title:"Showing Hotspots"}),this.areHotspotsActive=!0,this.eventsManager.hotspotsVisibilityChanged.fire({visible:!0})}hideHotspots(){window.epigraph.logger.info({title:"Hiding Hotspots"}),this.areHotspotsActive=!1,this.eventsManager.hotspotsVisibilityChanged.fire({visible:!1})}toggleHotspots(){this.hotspotsManager.enabled?this.hideHotspots():this.showHotspots()}updateHotspotsOrder(e){this.hotspotsManager.updateHotspotsOrder(e)}openHotspot({hotspotId:e,state:t,skipHotspotOpenEvent:i=!1}){this.hotspotsManager.openHotspot({hotspotId:e,state:t,skipHotspotOpenEvent:i})}closeActiveHotspot(){this.hotspotsManager.closeActiveHotspot()}setActiveHotspotState(e){this.hotspotsManager.setActiveHotspotState(e)}nextHotspot(){return this.hotspotsManager.nextHotspot()}previousHotspot(){return this.hotspotsManager.previousHotspot()}getActiveHotspot(){return this.hotspotsManager.activeHotspot}areHotspotsVisible(){return this.hotspotsManager.enabled}getAllHotspots(){return Array.from(this.hotspotsManager.hotspots.values())}getAllHotspotIds(){return Array.from(this.hotspotsManager.hotspots.keys())}getHotspotById(e){return this.hotspotsManager.hotspots.get(e)}createHotspots(e){this.hotspotsManager.createHotspots(e)}updateHotspots(e){this.hotspotsManager.updateHotspots(e)}removeHotspots(e){this.hotspotsManager.removeHotspots(e)}async __onPlayInteractionPrompt(e=2){this.showCameraInteractionPromptIndicator(),await St.wait(800);for(let t=0;t<e;t++)this.cameraInteractionPromptIndicatorElemRef.classList.add("play-wiggle-animation"),await this.cameraManager.wiggleCamera();this.cameraInteractionPromptIndicatorElemRef.classList.remove("play-wiggle-animation"),this.hideCameraInteractionPromptIndicator(),this._isSceneInteractedWith||setTimeout(()=>{this.__onPlayInteractionPrompt()},3e3)}getAllAnimations(){const e=this.sceneManager.sceneStructure.getFirstEntity();return e?e.getAllAnimations():[]}getAllAnimationNames(){const e=this.sceneManager.sceneStructure.getFirstEntity();return e?e.getAllAnimationNames():[]}playAnimationByName({animationName:e,clampWhenFinished:t=!1,loop:i=!1,repetitions:a=1/0,reverse:l=!1}){if(!e)return;const u=this.getAllAnimationNames();if(!u.includes(e)){window.epigraph.logger.warn({title:`Invalid animation name: ${e}. Expand for a list of valid names`,details:u});return}const d=u.indexOf(e),p=this.getAllAnimations()[d];return l?(p.timeScale=-1,p.fadeOut(this._animationFadeDurationInMiliseconds*.001)):(p.timeScale=1,p.fadeIn(this._animationFadeDurationInMiliseconds*.001)),p.setLoop(i?Fa:wl,a),p.clampWhenFinished=t,p.enabled=!0,p.play(),this._activeAnimations.set(e,p),{animationName:e,targetAnimationAction:p}}stopAnimationByName(e){if(!e)return;const t=this.getAllAnimationNames();if(!t.includes(e)){window.epigraph.logger.warn({title:`Invalid animation name: ${e}. Expand for a list of valid names`,details:t});return}const i=t.indexOf(e),a=this.getAllAnimations()[i];a.fadeOut(this._animationFadeDurationInMiliseconds*.001),setTimeout(()=>{a.stop()},this._animationFadeDurationInMiliseconds),this._activeAnimations.delete(e)}pauseActiveAnimations(e){for(const t of this._activeAnimations.values())t.paused=!0,e!==void 0&&(t.weight=e)}resumeActiveAnimations(){for(const e of this._activeAnimations.values())e.paused=!1,e.weight=1}stopAllAnimations(){for(const[e,t]of this._activeAnimations.entries())t.fadeOut(this._animationFadeDurationInMiliseconds*.001),setTimeout(()=>{t.stop(),this._activeAnimations.delete(e)},this._animationFadeDurationInMiliseconds)}postRenderFrameUpdateInEngine(e){try{this.cameraManager.mainCameraControls.update(e),this.renderEngine.mainRenderer.render(this.renderEngine.scene,this.cameraManager.getCameras().main),this.renderEngine.textRenderer.render(this.renderEngine.scene,this.cameraManager.getCameras().main)}catch(t){return t}}getScreenPositionFromWorld(e){const t=new Ve,i=this.cameraManager.getCameras().main,a=this.renderEngine.canvas.clientWidth*.5,l=this.renderEngine.canvas.clientHeight*.5,d=e.clone().project(i);return t.x=(d.x+1)*a,t.y=-(d.y-1)*l,t}_renderAppCanvasContainer(){return this.featuresToEnable.viewer?Ee`
|
|
8503
8503
|
<div id="appCanvasContainer" class="app-canvas-container">
|
|
8504
8504
|
<span id="cameraAimIndicator" class="camera-aim-indicator hide"></span>
|
|
8505
8505
|
</div>
|