@epigraph/solutions 1.0.17-alpha.3 → 1.0.17

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.
@@ -12924,7 +12924,7 @@ void main() {
12924
12924
  }
12925
12925
  `);new In(new Q(-1,-1,-1),new Q(1,1,1)),new Q(-1,-3,1).normalize(),new Me(1,1,1),new Me(.5,.5,1),new Q(1,1,1);new In(new Q(-2,-1,-2),new Q(2,5,2)),new Q(0,-1,0),new Me(1,1,1),new Me(.25,.25,.5),new Q(.1,1,.1);const K1=class J_{static createButton(e,t={}){const n=navigator.xr;if(!n)return null;const i=n,r=document.createElement("button");e.xr.enabled=!0,e.xr.setReferenceSpaceType("local");function a(){let u=null;async function d(g){console.log("onSessionStarted"),g.addEventListener("end",A),await e.xr.setSession(g),r.textContent="EXIT VR",u=g}function A(){console.log("onSessionEnded"),u?.removeEventListener("end",A),r.textContent="ENTER VR",u=null}r.style.display="",r.style.cursor="pointer",r.style.left="calc(50% - 100px)",r.style.width="200px",r.style.height="100px",r.textContent="ENTER VR";const p={...t,optionalFeatures:[...t.optionalFeatures||[]]};r.onmouseenter=()=>{r.style.opacity="1.0"},r.onmouseleave=()=>{r.style.opacity="0.5"},r.onclick=()=>{u===null?(console.log("requesting session"),i.requestSession("immersive-vr",p).then(d)):(console.log("ending session"),u.end())}}function o(){r.style.display="none",r.style.cursor="auto",r.style.left="calc(50% - 75px)",r.style.width="150px",r.onmouseenter=null,r.onmouseleave=null,r.onclick=null}function l(){o(),r.textContent="VR NOT SUPPORTED"}function c(u){o(),console.warn("Exception when trying to call xr.isSessionSupported",u),r.textContent="VR NOT ALLOWED"}function h(u){u.style.position="absolute",u.style.bottom="20px",u.style.padding="12px 6px",u.style.border="1px solid #fff",u.style.borderRadius="4px",u.style.background="rgba(0,0,0,0.1)",u.style.color="#fff",u.style.font="normal 13px sans-serif",u.style.textAlign="center",u.style.opacity="0.5",u.style.outline="none",u.style.zIndex="999"}return r.id="VRButton",r.style.display="none",h(r),i.isSessionSupported("immersive-vr").then(u=>{u?a():l(),u&&J_.xrSessionIsGranted&&r.click()}).catch(c),r}static registerSessionGrantedListener(){const e=navigator.xr;if(!e)return null;const t=e;/WebXRViewer\//i.test(navigator.userAgent)||t.addEventListener("sessiongranted",()=>{J_.xrSessionIsGranted=!0})}};K1.xrSessionIsGranted=!1;let wV=K1;wV.registerSessionGrantedListener();var Z1=(s=>(s.w="wrist",s.t0="thumb-metacarpal",s.t1="thumb-phalanx-proximal",s.t2="thumb-phalanx-distal",s.t3="thumb-tip",s.i0="index-finger-metacarpal",s.i1="index-finger-phalanx-proximal",s.i2="index-finger-phalanx-intermediate",s.i3="index-finger-phalanx-distal",s.i4="index-finger-tip",s.m0="middle-finger-metacarpal",s.m1="middle-finger-phalanx-proximal",s.m2="middle-finger-phalanx-intermediate",s.m3="middle-finger-phalanx-distal",s.m4="middle-finger-tip",s.r0="ring-finger-metacarpal",s.r1="ring-finger-phalanx-proximal",s.r2="ring-finger-phalanx-intermediate",s.r3="ring-finger-phalanx-distal",s.r4="ring-finger-tip",s.p0="pinky-finger-metacarpal",s.p1="pinky-finger-phalanx-proximal",s.p2="pinky-finger-phalanx-intermediate",s.p3="pinky-finger-phalanx-distal",s.p4="pinky-finger-tip",s))(Z1||{});const SV=Object.keys(Z1);SV.length;new Q(0,0,-1),new Q(0,0,1),new Q(-1,0,0),new Q(1,0,0),new Q(0,1,0),new Q(0,-1,0);new Q(0,0,-1),new Q(0,0,1),new Q(-1,0,0),new Q(1,0,0),new Q(0,1,0),new Q(0,-1,0);new Q(0,0,1),new Q(0,0,-1);new Q(0,-1,0),new Q(0,1,0),new Q(-1,0,0),new Q(1,0,0);class It{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 n=document.createElement("style");return n.setAttribute("id",e),n.innerHTML=t,n}static generateHtmlDivElem(e,t=""){const n=document.createElement("div");return n.setAttribute("id",e),n.innerHTML=t,n}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 n=new URLSearchParams(t);return Object.fromEntries(n.entries())[e]}static getBaseUrl(){const e=It.getUrlParameterByName("parentUrl");return e||window.location.href}static normalizeRadian(e){return Math.atan2(Math.sin(e),Math.cos(e))}static isBetweenOnCircle(e,t,n){return e=It.normalizeRadian(e),t=It.normalizeRadian(t),n=It.normalizeRadian(n),t<=n?e>=t&&e<=n:e>=t||e<=n}static getPointInBetweenByPercentage(e,t,n){let i=t.clone().sub(e);const r=i.length();return i=i.normalize().multiplyScalar(r*n),e.clone().add(i)}static clampAzimuth(e,t,n){if(Math.abs(t)==1/0||n==1/0)return e;const i=It.normalizeRadian(e),r=It.normalizeRadian(t),a=It.normalizeRadian(n);if(It.isBetweenOnCircle(i,r,a))return i;const o=Math.abs(It.normalizeRadian(i-r)),l=Math.abs(It.normalizeRadian(i-a));return o<l?r:a}static resolveNexusEndpoint(e){let t=Fp.PRODUCTION;return e=="local"?t=Fp.LOCAL:e==="staging"&&(t=Fp.STAGING),t}static parseUrlForEpigraphParams(e){const t=new Map,n=new Py(e);t.set(Vn.epigraphSessionId,n.getParameterInUrl(Vn.epigraphSessionId)),t.set(Vn.identifier,n.getParameterInUrl(Vn.identifier)),t.set(Vn.identifierType,n.getParameterInUrl(Vn.identifierType)),t.set(Vn.type,n.getParameterInUrl(Vn.type));const i=n.getParameterInUrl(Vn.action);return i&&t.set(ed.AR,JSON.parse(i)[ed.AR]),t}static generateShareableUrl({baseUrl:e,identifier:t,identifierType:n,sharedConfig:i,arCompatible:r=!1}){const a=new Map;return a.set(Vn.epigraphSessionId,window.epigraph.epigraphSessionId),a.set(Vn.identifier,t),a.set(Vn.identifierType,n),i&&a.set(Vn.sharedConfig,i),r&&a.set(Vn.action,`{"${ed.AR}":true}`),new Py(e).generateQrCodeUrl(Object.fromEntries(a.entries()),!1)}static _dispose3(e){e instanceof je&&e.geometry.dispose(),e instanceof je&&(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 je||t instanceof mh)&&It._dispose3(t)}),(e instanceof je||e instanceof mh||e instanceof ss)&&It._dispose3(e)}static animateValue(e,t,n,i){const r=performance.now();function a(o){const l=o-r,c=Math.min(l/n,1),h=e+(t-e)*c;i(h),c<1&&requestAnimationFrame(a)}requestAnimationFrame(a)}static getCustomStylesTemplate(){const t=document.querySelector("#epigraphCustomStyles")?.content?.cloneNode(!0);return t||me}}class gd{constructor(e){this._success=e}get success(){return this._success}set success(e){this._success=e}get failed(){return!this._success}}class BV extends gd{constructor(e=!1,t=void 0){super(e),this.__payload=t}get payload(){return this.__payload}set payload(e){this.__payload=e}}var eR=(s=>(s.Empty="entity-empty",s.Gltf="entity-mesh",s.Render="entity-render",s.Proxy="entity-proxy",s.Collider="entity-collider",s.Asset="entity-asset",s))(eR||{});class TV extends yn{constructor(){super(),this._entityType=eR.Empty}get entityType(){return this._entityType}destroy(){let e;const t=new BV(!1,e);return e=void 0,t.success=!0,t.payload=e,t}}var ga=(s=>(s.GEO="geo",s.SPLAT="splat",s))(ga||{});class ep{constructor(e){this.__name=e}getName(){return this.__name}}var ks=(s=>(s.declared="declared",s.Loading="loading",s.Loaded="loaded",s.Unloaded="unloaded",s.Failed="failed",s))(ks||{}),oo=(s=>(s.None="epg-resource-none",s.Gltf="epg-resource-gltf",s.Proxy="epg-resource-gltf-proxy",s.Render="epg-resource-gltf-render",s.Splat="epg-resource-splat",s))(oo||{});class tR{constructor({id:e,uri:t,appWcRef:n}){this._loggerContext="EPG RESOURCE",this._type="epg-resource-none",this._id=crypto.randomUUID(),this._loadingProgress=0,this._state="declared",this._resource=null,e&&(this._id=e),this._appWcRef=n,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(){return window.epigraph.logger.info({title:"Loading EPG Resource. Override to define how a resource should be loaded."}),Promise.resolve(!0)}unload(){return this._resource={},Promise.resolve(!0)}}class Ao extends St{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 n=e.rotation;this.rotation.set(n.x,n.y,n.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 Ao(this.__config).copy(this,e)}showDebug(){const e=new Q().setFromEuler(this.rotation).normalize(),t=this.position,n=.2,i=16711680;this.__debugGeo=new ST(e,t,n,i,.06,.06);const r=document.createElement("div");r.textContent=this.name;const a=new _b(r);r.style.pointerEvents="none";const o=new Q;this.getWorldDirection(o),o.normalize();const l=this.position.clone().addScaledVector(o,Math.random());a.position.set(l.x,l.y,l.z),this.__debugGeo.add(a),this.add(this.__debugGeo)}hideDebug(){this.__debugGeo&&(this.__debugGeo.clear(),this.__debugGeo?.removeFromParent(),It.dispose3(this.__debugGeo))}}class _a extends St{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 n=e.rotation;this.rotation.set(n.x,n.y,n.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 _a(this.__config).copy(this,e)}showDebug(){const e=new Q().setFromEuler(this.rotation.clone()).normalize(),t=this.position,n=.1,i=65280;this.__debugGeo=new ST(e,t,n,i,.01,.08);const r=document.createElement("div");r.textContent=this.name,r.style.color="green";const a=new _b(r);r.style.pointerEvents="none",this.__debugGeo.add(a),this.add(this.__debugGeo)}hideDebug(){this.__debugGeo&&(this.__debugGeo.clear(),this.__debugGeo?.removeFromParent(),It.dispose3(this.__debugGeo))}}var K_=(s=>(s.Plug="plug",s.Receiver="receiver",s))(K_||{});class nR extends tR{constructor({id:e,uri:t,appWcRef:n}){super({id:e,uri:t,appWcRef:n}),this._loggerContext="EPG RESOURCE GLTF",this._type=oo.Gltf,this._resource=null}get resource(){return this._resource}highlight(){}updateLoadingProgress(e){this._loadingProgress=e,this._appWcRef.eventsManager.assetLoadProgress.fire({progress:e})}async load(){if(this._state===ks.Loaded||this._state===ks.Loading)return Promise.resolve(!0);this._state=ks.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=ks.Failed,Promise.reject()));return e===void 0?Promise.reject(!1):(this._resource=e,await this._parseLoadedGltf(),this._state=ks.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 MV extends nR{constructor({id:e,uri:t,appWcRef:n}){super({id:e,uri:t,appWcRef:n}),this._loggerContext="EPG RESOURCE PROXY",this._type=oo.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===K_.Receiver){const n=new _a({name:t.name,connectionId:t.userData.connectionId,position:t.position.clone(),rotation:t.rotation.clone()});this.__receivers.push(n),e.push(t)}else if(t.userData.epgType===K_.Plug){const n=new Ao({name:t.name,isPrimary:t.userData.isPrimary,connectionId:t.userData.connectionId,position:t.position.clone(),rotation:t.rotation.clone()});this.__plugs.push(n),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(),It.dispose3(t)}unload(){return this._resource={},this.__plugs=[],this.__receivers=[],Promise.resolve(!0)}}class iR extends nR{constructor({id:e,uri:t,appWcRef:n}){super({id:e,uri:t,appWcRef:n}),this._loggerContext="EPG RESOURCE RENDER",this._type=oo.Render,this.__variantsExtensionName="KHR_materials_variants",this.__finishNamesFromAsset=[]}get khrVariantsExtensionName(){return this.__variantsExtensionName}get khrVariantsExtension(){return this.__variantsExtension}get finishNamesFromAsset(){return this.__finishNamesFromAsset}async _parseLoadedGltf(){this._resource?.scene.traverse(t=>{t instanceof je&&(t.castShadow=!0)});const e=this._resource?.userData?.gltfExtensions;if(!e){this.__variantsExtension=null,this.__finishNamesFromAsset=["default"];return}if(this.__variantsExtension=e[this.__variantsExtensionName],this.__variantsExtension?.variants)for(const t of this.__variantsExtension.variants)this.__finishNamesFromAsset.push(t.name)}unload(){return this._resource={},this.__variantsExtension={},this.__finishNamesFromAsset=[],Promise.resolve(!0)}}class RV extends tR{constructor({id:e,uri:t,appWcRef:n}){super({id:e,uri:t,appWcRef:n}),this._loggerContext="EPG RESOURCE SPLAT",this._type=oo.Splat,this._resource=null,this.__splatMesh=null,this._appWcRef.renderEngine.setupSparkRendererIfNotExists()}get resource(){return this._resource}get splatMesh(){return this.__splatMesh}__parseLoadedSplat(){this._resource&&(this.__splatMesh=new mh({packedSplats:this._resource}),this.__splatMesh.quaternion.set(1,0,0,0))}async load(){if(this._state===ks.Loaded||this._state===ks.Loading)return Promise.resolve(!0);this._state=ks.Loading;const e=await this._appWcRef.loaders.splatLoader.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 a render splat resource!",details:t}),this._state=ks.Failed,Promise.reject()));return e===void 0?Promise.reject(!1):(this._resource=e,this.__parseLoadedSplat(),this._state=ks.Loaded,Promise.resolve(!0))}}class sR{constructor(e,t){this._loggerContext="ASSET",this.__autoGenerateProxyEntity=!1,this.__finishes=new Map,this.__brandMaterialLibraries=new Map,this.__hotspots=[],this.__assetOverrides=null,this.__id=e.id,this.__name=e.name,this.__config=e,this.__appWcRef=t,this.__proxyGltf=new MV({id:`${String(e.id)}-${oo.Proxy}`,uri:e.proxyGeo,appWcRef:this.__appWcRef}),this.__autoGenerateProxyEntity=e.autoGenerateProxyEntity,!this.isRootAsset&&this.__appWcRef.experienceData.currentAssetVersion<=0&&(this.__autoGenerateProxyEntity=!0),this.__appWcRef.productSettings.render.mode===ga.SPLAT?this.__renderSplat=new RV({id:`${String(e.id)}-${oo.Splat}`,uri:e.renderSplat,appWcRef:this.__appWcRef}):this.__renderGltf=new iR({id:`${String(e.id)}-${oo.Render}`,uri:e.renderGeo,appWcRef:this.__appWcRef});for(const n in e.finishes)this.__finishes.set(n,new ep(n));e.brandMaterialLibraries||(e.brandMaterialLibraries=[]),e.hotspots&&(this.__hotspots=e.hotspots)}get isRootAsset(){return this.__id===0}get id(){return this.__id}get name(){return this.__name}get assetRootDir(){const e=this.__appWcRef.productSettings.render.mode===ga.SPLAT?this.__renderSplat?.uri:this.__renderGltf?.uri;return new URL(e+"/../../").href}get assetOverrides(){return this.__assetOverrides}get proxyGltf(){return this.__proxyGltf}get autoGenerateProxyEntity(){return this.__autoGenerateProxyEntity}get renderSplat(){return this.__renderSplat}get renderGltf(){return this.__renderGltf}get finishes(){return this.__finishes}get hotspots(){return this.__hotspots}get brandMaterialLibraries(){return this.__brandMaterialLibraries}get allFinishIds(){const e=[];for(const t of this.__finishes.keys())e.push(t);return e}async loadRenderSplat(){await this.__renderSplat?.load(),this.__finishes.set("default",new ep("default"))}async loadProxyGltf(){return!this.__proxyGltf||this.__proxyGltf.isLoaded?Promise.resolve(!0):await this.__proxyGltf.load()}pullFinishesFromRenderGltf(){this.__finishes.clear(),this.__renderGltf&&this.__renderGltf.finishNamesFromAsset.forEach(e=>{this.__finishes.has(e)||this.__finishes.set(e,new ep(e))})}async parseAssetOverrideJson(){if(!this.__renderGltf)return null;let e=this.__renderGltf.resource?.asset.extras?.epgOverrides;if(!e)return null;e=e.replace("./","");const t=new URL(e,this.assetRootDir),n=await fetch(t).catch(i=>{window.epigraph.logger.error({title:`Failed to load asset override file: ${t}`,details:i})});n&&(this.__assetOverrides=await n.json())}async loadRenderGltf(e=!1){if(this.__renderGltf===void 0||this.__renderGltf.uri==="")return Promise.resolve(!0);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)));for(const t of this.__config.brandMaterialLibraries){const n=this.__appWcRef.experienceData.materialLibraryCollection.materialLibraries.get(t);if(await n?.load(),!n){window.epigraph.logger.warn({title:`Material library ${t} not found in brand material libraries.`,contextOverride:this._loggerContext});continue}this.__brandMaterialLibraries.set(n.id,n);for(const i of n.finishNamesFromAsset)this.finishes.has(i)||this.__finishes.set(i,new ep(i))}return e&&this.pullFinishesFromRenderGltf(),await this.parseAssetOverrideJson(),Promise.resolve(!0)}async load(e=!1){return Promise.all([this.loadRenderSplat(),this.loadRenderGltf(e),this.loadProxyGltf()])}}var DV=Object.defineProperty,rR=(s,e,t,n)=>{for(var i=void 0,r=s.length-1,a;r>=0;r--)(a=s[r])&&(i=a(e,t,i)||i);return i&&DV(e,t,i),i};class aR{constructor({appWcRef:e}){this._loggerContext="SOLUTION MANAGER",this._appWcRef=e}initialize(){window.epigraph.logger.info({title:"Initializing...",contextOverride:this._loggerContext})}}const Bb=class Wp extends $c{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(Wp.webComponentName)||window.customElements.define(Wp.webComponentName,Wp)}render(){return ae`
12926
12926
  ${It.getCustomStylesTemplate()}
12927
- `}};rR([q({type:Boolean,attribute:"enabled"})],Bb.prototype,"enabled");rR([q({attribute:!1})],Bb.prototype,"appWcRef");let Bl=Bb;class QV{constructor({id:e,name:t,receiver:n,plug:i}){this.__name=t,this.__plug=i,this.__receiver=n,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 LV{constructor({id:e,receiver:t,plug:n}){this.__id=e,this.__plug=n,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 NV extends yn{constructor(e){super(),this.name="ENTITIES",this._loggerContext="SCENE STRUCTURE",this.__appWcRef=e,this.__eventsManager=this.__appWcRef.eventsManager}async setupRootEntity(e,t){const n=await new sR({id:0,name:"Root",proxyGeo:e??"https://asset.myepigraph.com/solutions-assets/__PIPELINE__/assets/3d-assets/proxyGeo/root-proxy.glb",autoGenerateProxyEntity:!1,renderGeo:t??"https://asset.myepigraph.com/solutions-assets/__PIPELINE__/assets/3d-assets/renderGeo/root-render.glb",renderSplat:"",finishes:{},hotspots:[],brandMaterialLibraries:[]},this.__appWcRef);await n.load().catch(()=>Promise.reject(!1));const i=new dl(n,this.__appWcRef);await i.initialize(),this.add(i),this.__rootEntity=i}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]}getEntityForAssetName(e){const t=this.getSceneEntities();let n;for(const i of t)if(i.asset.name===e){n=i;break}return n}getEntityForAssetId(e){const t=this.getSceneEntities();let n;for(const i of t)if(i.asset.id===e){n=i;break}return n}getSceneEntities(e=!1){const t=[];return this.__rootEntity.traverse(n=>{!e&&n.uuid===this.__rootEntity.uuid||n instanceof dl&&t.push(n)}),t}getPossibleConnectionsForAssetInScene(e){const t=[];window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e,contextOverride:this._loggerContext});for(const n of this.getSceneEntities(!0)){const i=n.findPossibleConnectionsForAsset(e);i.length>0&&t.push(...i)}return window.epigraph.logger.table({title:"Possible Connections",details:t}),t}getAllConnectionsInScene(){const e=new Map;return this.traverse(t=>{if(t instanceof _a||t instanceof Ao){if(t.connectionId===""||e.has(t.connectionId))return;let i=null,r=null;if(t instanceof _a?(i=t,r=t.plug):t instanceof Ao&&(i=t.receiver,r=t),i!==null&&r!==null){const a=new LV({id:t.connectionId,receiver:i,plug:r});e.set(t.connectionId,a)}}}),e}}class PV extends aR{constructor(e){super({appWcRef:e}),this._loggerContext="SCENE MANAGER",this.__currentSceneBounds=new In,this.__sceneStructure=new NV(this._appWcRef)}get sceneStructure(){return this.__sceneStructure}get currentSceneBounds(){return this.__currentSceneBounds}get currentSceneCenter(){const e=new Q;return this.currentSceneBounds.getCenter(e),e}recalculateSceneBounds(){this.currentSceneBounds.setFromPoints([new Q]),this.__sceneStructure.isNotEmpty()&&this.__sceneStructure.rootEntity.traverse(e=>{e instanceof je&&e.userData.isProxyMesh&&this.currentSceneBounds.expandByObject(e)}),this._appWcRef.eventsManager.sceneBoundsChanged.fire()}}class FV extends yn{constructor(e,t){super(),this.__autoGeneratedBoundsBox=new In,this.__autoGeneratedBoundsSize=new Q,this.__activeFinish="",this.name="RENDER",this.__assetEntity=e,this.__textureLoader=t}get asset(){return this.__assetEntity.asset}get activeFinish(){return this.__activeFinish}get allAssetFinishes(){return this.asset.finishes}get allFinishIds(){return this.asset.allFinishIds}get autoGeneratedBoundsBox(){return this.__autoGeneratedBoundsBox}get autoGeneratedBoundsSize(){return this.__autoGeneratedBoundsSize}async initializeRenderGeoEntity(){const e=this.asset?.renderGltf?.resource?.scene?.clone(!0);if(!e)return Promise.reject();this.add(e),this.__autoGeneratedBoundsBox.setFromObject(e,!0),this.__autoGeneratedBoundsBox.getSize(this.__autoGeneratedBoundsSize);const t=new Q;if(this.__autoGeneratedBoundsBox.getCenter(t),this.asset.autoGenerateProxyEntity){window.epigraph.logger.group({title:""}),window.epigraph.logger.info({title:"Attempting to place render geo at the grid for AssetEntity...",details:this.asset,contextOverride:"ASSET ENTITY"});const n=new yn;n.name="rendergeopivot";const i=new xs(.01,.01,.01),r=new Un({color:65280,depthTest:!1}),a=new je(i,r);n.add(a),this.add(n),n.position.set(t.x,this.__autoGeneratedBoundsBox.min.y,t.z),n.attach(e),n.position.set(0,0,0),this.attach(e),n.removeFromParent(),It.dispose3(n),window.epigraph.logger.info({title:"Done!!"}),window.epigraph.logger.groupEnd()}}async initializeSplatEntity(){const e=this.asset.renderSplat?.splatMesh;if(!e)return;this.add(e),this.__autoGeneratedBoundsBox.copy(e.getBoundingBox(!1)),this.__autoGeneratedBoundsBox.getSize(this.__autoGeneratedBoundsSize);const t=new Q;if(this.__autoGeneratedBoundsBox.getCenter(t),this.asset.autoGenerateProxyEntity){window.epigraph.logger.group({title:""}),window.epigraph.logger.info({title:"Attempting to place render geo at the grid for AssetEntity...",details:this.asset,contextOverride:"ASSET ENTITY"});const n=new yn;n.name="splatmeshpivot",this.attach(n),n.position.set(t.x,this.__autoGeneratedBoundsBox.max.y,t.z),e.position.set(-t.x,this.__autoGeneratedBoundsBox.max.y,-t.z),n.add(e),n.position.set(0,0,0),this.add(e),n.removeFromParent(),It.dispose3(n),window.epigraph.logger.info({title:"Done!!"}),window.epigraph.logger.groupEnd()}}async selectAssetFinish(e){window.epigraph.logger.info({title:`Switching to asset finish: ${e}`});const t=new gd(!1);if(this.__assetEntity.isRenderingSplats())return t.success=!0,Promise.resolve(t);const n=this.asset.renderGltf;if(!n)return Promise.reject(t);const i=n.khrVariantsExtension,r=n.khrVariantsExtensionName;if(!i?.variants)return window.epigraph.logger.warn({title:"No KHR_Materials_Variants found in asset. Using default material."}),this.allFinishIds.length===1&&this.allFinishIds.includes(e)&&(this.__activeFinish=e),t.success=!0,Promise.resolve(t);const a=await this.__selectFinishByKHRMaterialsVariantsExtension(i,r,e,n);if(t.success=a.success,t.failed===!0){const o=await this.__selectFinishByMaterialLibrary(i,r,e);t.success=o.success}return this.__activeFinish=e,Promise.resolve(t)}__selectFinishByKHRMaterialsVariantsExtension(e,t,n,i){const r=new gd(!1);window.epigraph.logger.info({title:"Attempting to load finish by KHR Materials Variants",details:n});const a=e.variants.findIndex(o=>o.name===n);return this.traverse(async o=>{if(!(o instanceof je)||!o.isMesh||!o.userData.gltfExtensions)return;const l=o.userData.gltfExtensions[t];if(!l)return window.epigraph.logger.error({title:"No variants extension found in mesh.",details:l}),Promise.reject(r);o.userData.originalMaterial||(o.userData.originalMaterial=o.material);const c=l.mappings.find(h=>h.variants.includes(a));if(c&&i.resource){const h=i.resource.parser;o.material=await h.getDependency("material",c.material),h.assignFinalMaterial(o),r.success=!0}else window.epigraph.logger.info({title:"Variant has no effect on this Object.",details:{object:o,finishId:n}}),o.material=o.userData.originalMaterial,r.success=!1}),r}async __selectFinishByMaterialLibrary(e,t,n){const i=new gd(!1);window.epigraph.logger.info({title:"Attempting to load finish by material library",details:n});for(const r of this.asset.brandMaterialLibraries.values()){const a=await r.getMaterialForFinishId(n);a!==null&&this.traverse(async o=>{o instanceof je&&(o.material=a,await this.__processAnyOverridesForAsset(n,o),o.material.needsUpdate=!0)})}return i.success=!1,i}async __processAnyOverridesForAsset(e,t){const n=this.asset.assetOverrides;if(!n)return;const i=n.brandMaterialLibrary;if(i){const r=i[e];if(r){r.sort((a,o)=>{const l=a.name.includes("."),c=o.name.includes(".");return l&&!c?1:!l&&c?-1:0});for(const a of r){const o=a.name,l=a.value,c=a.type,h=t.material;switch(window.epigraph.logger.info({title:`Override Property on asset: ${this.asset.id} MLIB: ${o} -> overrides[override]`}),c){case"image":await this.__processImageOverride(o,l,h);break;case"color":await this.__processColorOverride(o,l,h);break;case"number":await this.__processNumberOverride(o,l,h);break}}}}}__applyFinalPropertyValue(e,t,n){let i=n;const r=e.split(".");r.length===2&&(i=i[r[0]],e=r[1]),!(!i||!(e in i))&&(i[e]=t)}async __processImageOverride(e,t,n){const i=new URL(t,`${this.asset.assetRootDir}overrides/`).href,r=await this.__textureLoader.loadAsync(i).catch(a=>{window.epigraph.logger.error({title:`Couldn't load texture: ${i}`,details:a,contextOverride:"ASSET ENTITY"})});r&&(r.flipY=!1,this.__applyFinalPropertyValue(e,r,n))}__processColorOverride(e,t,n){const i=JSON.parse(t),r=new Me(i[0],i[1],i[2]);this.__applyFinalPropertyValue(e,r,n)}__processNumberOverride(e,t,n){this.__applyFinalPropertyValue(e,parseFloat(t),n)}highlight(){this.traverseVisible(e=>{const t=e;if(t.isMesh){const n=t.material;if(!n.emissive)return;(n.emissive.r>0||n.emissive.g>0||n.emissive.b>0)&&(n.userData.epgData={orignalEmissive:n.emissive.clone(),originalEmissiveIntensity:n.emissiveIntensity}),n.emissive.r=1,n.emissive.g=1,n.emissive.b=1,n.emissiveIntensity=1}})}unhighlight(){this.traverseVisible(e=>{const t=e;if(t.isMesh){const n=t.material;if(!n.emissive)return;const i=n?.userData?.epgData?.orignalEmissive;i?(n.emissive.r=i.r,n.emissive.g=i.g,n.emissive.b=i.b):(n.emissive.r=0,n.emissive.g=0,n.emissive.b=0);const r=n?.userData?.epgData?.orignalEmissiveIntensity;n.emissiveIntensity=r!==void 0?r:0}})}}class kV extends yn{constructor(e){super(),this.name="PROXY",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class UV extends yn{constructor(e){super(),this.name="HOTSPOTS",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class dl extends TV{constructor(e,t){super(),this.epgType="ENTITY_ASSET",this.__autoGeneratedProxy=new yn,this.__animationMixer=null,this.__animations=new Map,this.name=e.name,this.__appWcRef=t,this.__proxyEntity=new kV(this),this.add(this.__proxyEntity),this.__renderEntity=new FV(this,this.__appWcRef.loaders.textureLoader),this.add(this.__renderEntity),this.__hotspotsEntity=new UV(this),this.add(this.__hotspotsEntity),this.__asset=e}get asset(){return this.__asset}get isRoot(){return this.name.toLowerCase()==="root"}get proxyEntity(){return this.__proxyEntity}get renderEntity(){return this.__renderEntity}get activeFinish(){return this.__renderEntity.activeFinish}get allAssetFinishes(){return this.__renderEntity.allAssetFinishes}get allFinishIds(){return this.__renderEntity.allFinishIds}highlight(){this.__renderEntity.highlight()}unhighlight(){this.__renderEntity.unhighlight()}addHotspot(e){e.entity.name=`HOTSPOT-${this.asset.name}-${crypto.randomUUID()}`,e.entity.userData.epgId=e.hotspotId,e.entity.position.set(e.config.position.x,e.config.position.y,e.config.position.z),this.__hotspotsEntity.add(e.entity)}removeHotspot(e){let t;this.__hotspotsEntity.traverse(n=>{n.userData.epgId===e&&(t=n)}),t&&(t.removeFromParent(),It.dispose3(t))}isRenderingMesh(){return this.__appWcRef.productSettings.render.mode===ga.GEO}isRenderingSplats(){return this.__appWcRef.productSettings.render.mode===ga.SPLAT}async selectAssetFinish(e){return this.__renderEntity.selectAssetFinish(e)}findPossibleConnectionsForAsset(e){const t=[];return window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e}),this.__proxyEntity.traverse(n=>{if(!(n instanceof _a))return;const i=n,r=e.proxyGltf?.plugs??[];for(const a of r)a.connectionId===i.connectionId&&t.push(new QV({name:a.connectionId,receiver:i,plug:a}))}),t}getAnimationMixer(){return this.__animationMixer}getAllAnimations(){return this.__animations}async initialize(){this.__asset.autoGenerateProxyEntity?(await this.__initializeRenderEntity(),await this.__initializeProxyEntity()):(await this.__initializeProxyEntity(),await this.__initializeRenderEntity())}async __initializeRenderEntity(){this.__appWcRef.productSettings.render.mode===ga.GEO?(await this.__renderEntity.initializeRenderGeoEntity(),this.__updateAnimations()):await this.__renderEntity.initializeSplatEntity()}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 je&&(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 xs,t=new Un({color:65280,opacity:.5,transparent:!0}),n=new je(e,t);n.name="AutoGeneratedProxyMesh",n.scale.set(this.__renderEntity.autoGeneratedBoundsSize.x,this.__renderEntity.autoGeneratedBoundsSize.y,this.__renderEntity.autoGeneratedBoundsSize.z);const i=new Q;this.__renderEntity.autoGeneratedBoundsBox.getCenter(i);const r=new yn;r.name="proxygeopivot";const a=new lg(.01,10,10),o=new Un({color:255,depthTest:!1}),l=new je(a,o);r.add(l),this.__proxyEntity.add(r),r.translateY(-this.__renderEntity.autoGeneratedBoundsSize.y*.5),r.attach(n),r.position.set(0,0,0),this.__proxyEntity.add(n),r.removeFromParent(),It.dispose3(r),this.__autoGeneratedProxy.add(n)}__updateAnimations(){if(this.__asset.renderGltf&&(this.__animationMixer=null,this.__animations.clear(),this.__renderEntity.animations&&this.__asset.renderGltf.resource&&this.__asset.renderGltf.resource.animations.length>0)){this.__animationMixer=new xT(this.__renderEntity.children[0]);for(const e of this.__asset.renderGltf.resource.animations)this.__animations.set(e.name,this.__animationMixer.clipAction(e))}}}function oR(s,e,t,n){const i=Object.entries(s);class r extends Tn{static key=hr.generateUUID();constructor(o){super({uniforms:i.reduce((l,[c,h])=>{const u=W0.clone({[c]:{value:h}});return{...l,...u}},{}),vertexShader:e,fragmentShader:t});for(const[l]of i)Object.defineProperty(this,l,{get:()=>this.uniforms[l].value,set:c=>this.uniforms[l].value=c});Object.assign(this,o)}}return r}const OV=oR({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");function GV(s){return s.isLight}function zV(s){return!!s.geometry}const HV=oR({color:new Me(0),blend:2,alphaTest:.75,opacity:0,map:null},`varying vec2 vUv;
12927
+ `}};rR([q({type:Boolean,attribute:"enabled"})],Bb.prototype,"enabled");rR([q({attribute:!1})],Bb.prototype,"appWcRef");let Bl=Bb;class QV{constructor({id:e,name:t,receiver:n,plug:i}){this.__name=t,this.__plug=i,this.__receiver=n,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 LV{constructor({id:e,receiver:t,plug:n}){this.__id=e,this.__plug=n,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 NV extends yn{constructor(e){super(),this.name="ENTITIES",this._loggerContext="SCENE STRUCTURE",this.__appWcRef=e,this.__eventsManager=this.__appWcRef.eventsManager}async setupRootEntity(e,t){const n=await new sR({id:0,name:"Root",proxyGeo:e??"https://asset.myepigraph.com/solutions-assets/__PIPELINE__/assets/3d-assets/proxyGeo/root-proxy.glb",autoGenerateProxyEntity:!1,renderGeo:t??"https://asset.myepigraph.com/solutions-assets/__PIPELINE__/assets/3d-assets/renderGeo/root-render.glb",renderSplat:"",finishes:{},hotspots:[],brandMaterialLibraries:[]},this.__appWcRef);await n.load().catch(()=>Promise.reject(!1));const i=new dl(n,this.__appWcRef);await i.initialize(),this.add(i),this.__rootEntity=i}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]}getEntityForAssetName(e){const t=this.getSceneEntities();let n;for(const i of t)if(i.asset.name===e){n=i;break}return n}getEntityForAssetId(e){const t=this.getSceneEntities();let n;for(const i of t)if(i.asset.id===e){n=i;break}return n}getSceneEntities(e=!1){const t=[];return this.__rootEntity.traverse(n=>{!e&&n.uuid===this.__rootEntity.uuid||n instanceof dl&&t.push(n)}),t}getPossibleConnectionsForAssetInScene(e){const t=[];window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e,contextOverride:this._loggerContext});for(const n of this.getSceneEntities(!0)){const i=n.findPossibleConnectionsForAsset(e);i.length>0&&t.push(...i)}return window.epigraph.logger.table({title:"Possible Connections",details:t}),t}getAllConnectionsInScene(){const e=new Map;return this.traverse(t=>{if(t instanceof _a||t instanceof Ao){if(t.connectionId===""||e.has(t.connectionId))return;let i=null,r=null;if(t instanceof _a?(i=t,r=t.plug):t instanceof Ao&&(i=t.receiver,r=t),i!==null&&r!==null){const a=new LV({id:t.connectionId,receiver:i,plug:r});e.set(t.connectionId,a)}}}),e}}class PV extends aR{constructor(e){super({appWcRef:e}),this._loggerContext="SCENE MANAGER",this.__currentSceneBounds=new In,this.__sceneStructure=new NV(this._appWcRef)}get sceneStructure(){return this.__sceneStructure}get currentSceneBounds(){return this.__currentSceneBounds}get currentSceneCenter(){const e=new Q;return this.__currentSceneBounds.getCenter(e),e}recalculateSceneBounds(){this.__currentSceneBounds.setFromPoints([new Q]),this.__sceneStructure.isNotEmpty()&&this.__sceneStructure.rootEntity.traverse(e=>{e instanceof je&&e.userData.isProxyMesh&&this.__currentSceneBounds.expandByObject(e)}),this._appWcRef.eventsManager.sceneBoundsChanged.fire()}}class FV extends yn{constructor(e,t){super(),this.__autoGeneratedBoundsBox=new In,this.__autoGeneratedBoundsSize=new Q,this.__activeFinish="",this.name="RENDER",this.__assetEntity=e,this.__textureLoader=t}get asset(){return this.__assetEntity.asset}get activeFinish(){return this.__activeFinish}get allAssetFinishes(){return this.asset.finishes}get allFinishIds(){return this.asset.allFinishIds}get autoGeneratedBoundsBox(){return this.__autoGeneratedBoundsBox}get autoGeneratedBoundsSize(){return this.__autoGeneratedBoundsSize}async initializeRenderGeoEntity(){const e=this.asset?.renderGltf?.resource?.scene?.clone(!0);if(!e)return Promise.reject();this.add(e),this.__autoGeneratedBoundsBox.setFromObject(e,!0),this.__autoGeneratedBoundsBox.getSize(this.__autoGeneratedBoundsSize);const t=new Q;if(this.__autoGeneratedBoundsBox.getCenter(t),this.asset.autoGenerateProxyEntity){window.epigraph.logger.group({title:""}),window.epigraph.logger.info({title:"Attempting to place render geo at the grid for AssetEntity...",details:this.asset,contextOverride:"ASSET ENTITY"});const n=new yn;n.name="rendergeopivot";const i=new xs(.01,.01,.01),r=new Un({color:65280,depthTest:!1}),a=new je(i,r);n.add(a),this.add(n),n.position.set(t.x,this.__autoGeneratedBoundsBox.min.y,t.z),n.attach(e),n.position.set(0,0,0),this.attach(e),n.removeFromParent(),It.dispose3(n),window.epigraph.logger.info({title:"Done!!"}),window.epigraph.logger.groupEnd()}}async initializeSplatEntity(){const e=this.asset.renderSplat?.splatMesh;if(!e)return;this.add(e),this.__autoGeneratedBoundsBox.copy(e.getBoundingBox(!1)),this.__autoGeneratedBoundsBox.getSize(this.__autoGeneratedBoundsSize);const t=new Q;if(this.__autoGeneratedBoundsBox.getCenter(t),this.asset.autoGenerateProxyEntity){window.epigraph.logger.group({title:""}),window.epigraph.logger.info({title:"Attempting to place render geo at the grid for AssetEntity...",details:this.asset,contextOverride:"ASSET ENTITY"});const n=new yn;n.name="splatmeshpivot",this.attach(n),n.position.set(t.x,this.__autoGeneratedBoundsBox.max.y,t.z),e.position.set(-t.x,this.__autoGeneratedBoundsBox.max.y,-t.z),n.add(e),n.position.set(0,0,0),this.add(e),n.removeFromParent(),It.dispose3(n),window.epigraph.logger.info({title:"Done!!"}),window.epigraph.logger.groupEnd()}}async selectAssetFinish(e){window.epigraph.logger.info({title:`Switching to asset finish: ${e}`});const t=new gd(!1);if(this.__assetEntity.isRenderingSplats())return t.success=!0,Promise.resolve(t);const n=this.asset.renderGltf;if(!n)return Promise.reject(t);const i=n.khrVariantsExtension,r=n.khrVariantsExtensionName;if(!i?.variants)return window.epigraph.logger.warn({title:"No KHR_Materials_Variants found in asset. Using default material."}),this.allFinishIds.length===1&&this.allFinishIds.includes(e)&&(this.__activeFinish=e),t.success=!0,Promise.resolve(t);const a=await this.__selectFinishByKHRMaterialsVariantsExtension(i,r,e,n);if(t.success=a.success,t.failed===!0){const o=await this.__selectFinishByMaterialLibrary(i,r,e);t.success=o.success}return this.__activeFinish=e,Promise.resolve(t)}__selectFinishByKHRMaterialsVariantsExtension(e,t,n,i){const r=new gd(!1);window.epigraph.logger.info({title:"Attempting to load finish by KHR Materials Variants",details:n});const a=e.variants.findIndex(o=>o.name===n);return this.traverse(async o=>{if(!(o instanceof je)||!o.isMesh||!o.userData.gltfExtensions)return;const l=o.userData.gltfExtensions[t];if(!l)return window.epigraph.logger.error({title:"No variants extension found in mesh.",details:l}),Promise.reject(r);o.userData.originalMaterial||(o.userData.originalMaterial=o.material);const c=l.mappings.find(h=>h.variants.includes(a));if(c&&i.resource){const h=i.resource.parser;o.material=await h.getDependency("material",c.material),h.assignFinalMaterial(o),r.success=!0}else window.epigraph.logger.info({title:"Variant has no effect on this Object.",details:{object:o,finishId:n}}),o.material=o.userData.originalMaterial,r.success=!1}),r}async __selectFinishByMaterialLibrary(e,t,n){const i=new gd(!1);window.epigraph.logger.info({title:"Attempting to load finish by material library",details:n});for(const r of this.asset.brandMaterialLibraries.values()){const a=await r.getMaterialForFinishId(n);a!==null&&this.traverse(async o=>{o instanceof je&&(o.material=a,await this.__processAnyOverridesForAsset(n,o),o.material.needsUpdate=!0)})}return i.success=!1,i}async __processAnyOverridesForAsset(e,t){const n=this.asset.assetOverrides;if(!n)return;const i=n.brandMaterialLibrary;if(i){const r=i[e];if(r){r.sort((a,o)=>{const l=a.name.includes("."),c=o.name.includes(".");return l&&!c?1:!l&&c?-1:0});for(const a of r){const o=a.name,l=a.value,c=a.type,h=t.material;switch(window.epigraph.logger.info({title:`Override Property on asset: ${this.asset.id} MLIB: ${o} -> overrides[override]`}),c){case"image":await this.__processImageOverride(o,l,h);break;case"color":await this.__processColorOverride(o,l,h);break;case"number":await this.__processNumberOverride(o,l,h);break}}}}}__applyFinalPropertyValue(e,t,n){let i=n;const r=e.split(".");r.length===2&&(i=i[r[0]],e=r[1]),!(!i||!(e in i))&&(i[e]=t)}async __processImageOverride(e,t,n){const i=new URL(t,`${this.asset.assetRootDir}overrides/`).href,r=await this.__textureLoader.loadAsync(i).catch(a=>{window.epigraph.logger.error({title:`Couldn't load texture: ${i}`,details:a,contextOverride:"ASSET ENTITY"})});r&&(r.flipY=!1,this.__applyFinalPropertyValue(e,r,n))}__processColorOverride(e,t,n){const i=JSON.parse(t),r=new Me(i[0],i[1],i[2]);this.__applyFinalPropertyValue(e,r,n)}__processNumberOverride(e,t,n){this.__applyFinalPropertyValue(e,parseFloat(t),n)}highlight(){this.traverseVisible(e=>{const t=e;if(t.isMesh){const n=t.material;if(!n.emissive)return;(n.emissive.r>0||n.emissive.g>0||n.emissive.b>0)&&(n.userData.epgData={orignalEmissive:n.emissive.clone(),originalEmissiveIntensity:n.emissiveIntensity}),n.emissive.r=1,n.emissive.g=1,n.emissive.b=1,n.emissiveIntensity=1}})}unhighlight(){this.traverseVisible(e=>{const t=e;if(t.isMesh){const n=t.material;if(!n.emissive)return;const i=n?.userData?.epgData?.orignalEmissive;i?(n.emissive.r=i.r,n.emissive.g=i.g,n.emissive.b=i.b):(n.emissive.r=0,n.emissive.g=0,n.emissive.b=0);const r=n?.userData?.epgData?.orignalEmissiveIntensity;n.emissiveIntensity=r!==void 0?r:0}})}}class kV extends yn{constructor(e){super(),this.name="PROXY",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class UV extends yn{constructor(e){super(),this.name="HOTSPOTS",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class dl extends TV{constructor(e,t){super(),this.epgType="ENTITY_ASSET",this.__autoGeneratedProxy=new yn,this.__animationMixer=null,this.__animations=new Map,this.name=e.name,this.__appWcRef=t,this.__proxyEntity=new kV(this),this.add(this.__proxyEntity),this.__renderEntity=new FV(this,this.__appWcRef.loaders.textureLoader),this.add(this.__renderEntity),this.__hotspotsEntity=new UV(this),this.add(this.__hotspotsEntity),this.__asset=e}get asset(){return this.__asset}get isRoot(){return this.name.toLowerCase()==="root"}get proxyEntity(){return this.__proxyEntity}get renderEntity(){return this.__renderEntity}get activeFinish(){return this.__renderEntity.activeFinish}get allAssetFinishes(){return this.__renderEntity.allAssetFinishes}get allFinishIds(){return this.__renderEntity.allFinishIds}highlight(){this.__renderEntity.highlight()}unhighlight(){this.__renderEntity.unhighlight()}addHotspot(e){e.entity.name=`HOTSPOT-${this.asset.name}-${crypto.randomUUID()}`,e.entity.userData.epgId=e.hotspotId,e.entity.position.set(e.config.position.x,e.config.position.y,e.config.position.z),this.__hotspotsEntity.add(e.entity)}removeHotspot(e){let t;this.__hotspotsEntity.traverse(n=>{n.userData.epgId===e&&(t=n)}),t&&(t.removeFromParent(),It.dispose3(t))}isRenderingMesh(){return this.__appWcRef.productSettings.render.mode===ga.GEO}isRenderingSplats(){return this.__appWcRef.productSettings.render.mode===ga.SPLAT}async selectAssetFinish(e){return this.__renderEntity.selectAssetFinish(e)}findPossibleConnectionsForAsset(e){const t=[];return window.epigraph.logger.info({title:"Getting connections for asset in scene:",details:e}),this.__proxyEntity.traverse(n=>{if(!(n instanceof _a))return;const i=n,r=e.proxyGltf?.plugs??[];for(const a of r)a.connectionId===i.connectionId&&t.push(new QV({name:a.connectionId,receiver:i,plug:a}))}),t}getAnimationMixer(){return this.__animationMixer}getAllAnimations(){return this.__animations}async initialize(){this.__asset.autoGenerateProxyEntity?(await this.__initializeRenderEntity(),await this.__initializeProxyEntity()):(await this.__initializeProxyEntity(),await this.__initializeRenderEntity())}async __initializeRenderEntity(){this.__appWcRef.productSettings.render.mode===ga.GEO?(await this.__renderEntity.initializeRenderGeoEntity(),this.__updateAnimations()):await this.__renderEntity.initializeSplatEntity()}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 je&&(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 xs,t=new Un({color:65280,opacity:.5,transparent:!0}),n=new je(e,t);n.name="AutoGeneratedProxyMesh",n.scale.set(this.__renderEntity.autoGeneratedBoundsSize.x,this.__renderEntity.autoGeneratedBoundsSize.y,this.__renderEntity.autoGeneratedBoundsSize.z);const i=new Q;this.__renderEntity.autoGeneratedBoundsBox.getCenter(i);const r=new yn;r.name="proxygeopivot";const a=new lg(.01,10,10),o=new Un({color:255,depthTest:!1}),l=new je(a,o);r.add(l),this.__proxyEntity.add(r),r.translateY(-this.__renderEntity.autoGeneratedBoundsSize.y*.5),r.attach(n),r.position.set(0,0,0),this.__proxyEntity.add(n),r.removeFromParent(),It.dispose3(r),this.__autoGeneratedProxy.add(n)}__updateAnimations(){if(this.__asset.renderGltf&&(this.__animationMixer=null,this.__animations.clear(),this.__renderEntity.animations&&this.__asset.renderGltf.resource&&this.__asset.renderGltf.resource.animations.length>0)){this.__animationMixer=new xT(this.__renderEntity.children[0]);for(const e of this.__asset.renderGltf.resource.animations)this.__animations.set(e.name,this.__animationMixer.clipAction(e))}}}function oR(s,e,t,n){const i=Object.entries(s);class r extends Tn{static key=hr.generateUUID();constructor(o){super({uniforms:i.reduce((l,[c,h])=>{const u=W0.clone({[c]:{value:h}});return{...l,...u}},{}),vertexShader:e,fragmentShader:t});for(const[l]of i)Object.defineProperty(this,l,{get:()=>this.uniforms[l].value,set:c=>this.uniforms[l].value=c});Object.assign(this,o)}}return r}const OV=oR({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");function GV(s){return s.isLight}function zV(s){return!!s.geometry}const HV=oR({color:new Me(0),blend:2,alphaTest:.75,opacity:0,map:null},`varying vec2 vUv;
12928
12928
  void main() {
12929
12929
  gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
12930
12930
  vUv = uv;
@@ -16074,7 +16074,7 @@ ${r.join(`
16074
16074
  height: 100%;
16075
16075
  pointer-events: none;
16076
16076
  }
16077
- `]}static setupWebComponent(){window.customElements.get(sf.webComponentName)||window.customElements.define(sf.webComponentName,sf)}firstUpdated(e){super.firstUpdated(e),this.__setupEventListeners()}addHotspot(e,t=!0){const n=new dx({config:e,appWcRef:this.appWcRef,hotspotManagerRef:this});if(n.hidden)return;this.hotspots.set(n.hotspotId,n);const i=this.appWcRef.sceneManager.sceneStructure.getEntityForAssetId(e.assetId);i&&i.addHotspot(n),t&&this.updateHotspotsOrder(Array.from(this.hotspots.keys()))}updateHotspot(e,t){const n=this.hotspots.get(e);if(!n){window.epigraph.logger.error({title:`Invalid hotspot ID: ${e}`});return}n.updateConfig(t),this.__resolveHotspotCardContents()}removeHotspot(e,t=!0){this.hotspots.delete(e),t&&this.updateHotspotsOrder(Array.from(this.hotspots.keys()))}stepHotspots(e){const t=this.activeHotspotIndex;if(t===null)return;const n=this.hotspotsOrder.length;let i=t;e==="next"?(i=t+1,i>=n&&(i=0)):e==="prev"&&(i=t-1,i<0&&(i=n-1));const r=this.hotspotsOrder[i];this.setActiveHotspot({hotspotId:r})}nextHotspot(){return this.stepHotspots("next"),this.appWcRef.eventsManager.hotspotNextEvent.fire({hotspot:this.activeHotspot}),this.activeHotspot}previousHotspot(){return this.stepHotspots("prev"),this.appWcRef.eventsManager.hotspotPreviousEvent.fire({hotspot:this.activeHotspot}),this.activeHotspot}openHotspot({hotspotId:e,state:t,skipHotspotOpenEvent:n=!1}){this.appWcRef.playInteractionPrompt=!1,this.setActiveHotspot({hotspotId:e,state:t}),n||this.appWcRef.eventsManager.hotspotOpenEvent.fire({hotspot:this.activeHotspot});const i=new Hr(!0,Hr.PANEL_TYPE.HOTSPOT_PANEL,Hr.TRIGGER_SOURCE.HOTSPOT,[]);this.appWcRef.epigraphAnalytics.sendEvent(i)}closeActiveHotspot(){const e=this.activeHotspot?.hotspotId;this.setActiveHotspot({hotspotId:null}),this.appWcRef.eventsManager.hotspotClosedEvent.fire({hotspotId:e});const t=new $r(!0,$r.PANEL_TYPE.HOTSPOT_PANEL,$r.TRIGGER_SOURCE.BUTTON,[]);this.appWcRef.epigraphAnalytics.sendEvent(t)}updateHotspotsOrder(e){this.hotspotsOrder=e}removeAllHotspots(){for(const e of this.hotspots.keys())this.removeHotspot(e)}setActiveHotspotByIndex(e){const t=this.hotspotsOrder[e];this.setActiveHotspot({hotspotId:t})}updateActiveHotspotIndex(){this.activeHotspot?this.activeHotspotIndex=this.hotspotsOrder.indexOf(this.activeHotspot?.hotspotId):this.activeHotspotIndex=-1}setActiveHotspotState(e){this.__mobileHotspotCardsManager.setAttribute("cards-state",e)}setActiveHotspot({hotspotId:e,state:t=this.__mobileHotspotCardsManager.cardsState??$n.collapsed}){if(this.activeHotspot?.hotspotId===e)return;const{x:n,y:i,z:r}=this.__cameraOffsetApplied;if((n!==0||i!==0||r!==0)&&(this.appWcRef.cameraManager.mainCameraControls.setFocalOffset(0,0,0,!0),this.__cameraOffsetApplied.x=0,this.__cameraOffsetApplied.y=0,this.__cameraOffsetApplied.z=0),e===null){const o=!!this.activeHotspot;this.activeHotspot=void 0,this.updateActiveHotspotIndex(),o&&this.appWcRef.cameraManager.resetCurrentCameraTransformsToLastSavedState(),this.appWcRef.isPortraitOrientation&&this.appWcRef.cameraManager.mainCameraControls.setFocalOffset(0,0,0,!0);return}this.enabled===!1&&(this.enabled=!0);const a=!this.activeHotspot;if(this.activeHotspot=this.hotspots.get(e),this.updateActiveHotspotIndex(),this.setActiveHotspotState(t),this.__resolveHotspotCardContents(),this.activeHotspot?.camera.target.x===9999.9999&&(this.activeHotspot.camera.target=this.appWcRef.sceneManager.currentSceneCenter,this.appWcRef.cameraManager.mainCameraControls.setFocalOffset(-.5,0,0,!0),this.__cameraOffsetApplied.x=-.5),this.appWcRef.eventsManager.cameraMoveToTransform.fire({cameraTransforms:this.activeHotspot?.camera,saveFirst:a,ignoreCameraLimits:!0}),this.appWcRef.isPortraitOrientation){const o=this.appWcRef.cameraManager.mainCameraControls,l=new Q;o.getTarget(l,!0);const c=new Q;o.getPosition(c,!0),o.setLookAt(c.x-l.x,c.y,c.z-l.z,0,l.y,0,!0),o.setFocalOffset(0,.1,0,!0),this.__cameraOffsetApplied.y=.1}window.addEventListener("keydown",o=>{o.key==="Escape"&&this.closeActiveHotspot()},{once:!0})}__resolveHotspotCardContents(){this.__allCards=[];let e=0;const t=this.hotspots.size-1,n=this.hotspots.size>1,i=this.appWcRef.productSettings.hotspots.showNavigationButtons;for(const r of this.hotspots.values()){const a=e===0,o=e===t,l=ae`
16077
+ `]}static setupWebComponent(){window.customElements.get(sf.webComponentName)||window.customElements.define(sf.webComponentName,sf)}firstUpdated(e){super.firstUpdated(e),this.__setupEventListeners()}addHotspot(e,t=!0){const n=new dx({config:e,appWcRef:this.appWcRef,hotspotManagerRef:this});if(n.hidden)return;this.hotspots.set(n.hotspotId,n);const i=this.appWcRef.sceneManager.sceneStructure.getEntityForAssetId(e.assetId);i&&i.addHotspot(n),t&&this.updateHotspotsOrder(Array.from(this.hotspots.keys()))}updateHotspot(e,t){const n=this.hotspots.get(e);if(!n){window.epigraph.logger.error({title:`Invalid hotspot ID: ${e}`});return}n.updateConfig(t),this.__resolveHotspotCardContents()}removeHotspot(e,t=!0){this.hotspots.delete(e),t&&this.updateHotspotsOrder(Array.from(this.hotspots.keys()))}stepHotspots(e){const t=this.activeHotspotIndex;if(t===null)return;const n=this.hotspotsOrder.length;let i=t;e==="next"?(i=t+1,i>=n&&(i=0)):e==="prev"&&(i=t-1,i<0&&(i=n-1));const r=this.hotspotsOrder[i];this.setActiveHotspot({hotspotId:r})}nextHotspot(){return this.stepHotspots("next"),this.appWcRef.eventsManager.hotspotNextEvent.fire({hotspot:this.activeHotspot}),this.activeHotspot}previousHotspot(){return this.stepHotspots("prev"),this.appWcRef.eventsManager.hotspotPreviousEvent.fire({hotspot:this.activeHotspot}),this.activeHotspot}openHotspot({hotspotId:e,state:t,skipHotspotOpenEvent:n=!1}){this.appWcRef.playInteractionPrompt=!1,this.setActiveHotspot({hotspotId:e,state:t}),n||this.appWcRef.eventsManager.hotspotOpenEvent.fire({hotspot:this.activeHotspot});const i=new Hr(!0,Hr.PANEL_TYPE.HOTSPOT_PANEL,Hr.TRIGGER_SOURCE.HOTSPOT,[]);this.appWcRef.epigraphAnalytics.sendEvent(i)}closeActiveHotspot(){const e=this.activeHotspot?.hotspotId;this.setActiveHotspot({hotspotId:null}),this.appWcRef.eventsManager.hotspotClosedEvent.fire({hotspotId:e});const t=new $r(!0,$r.PANEL_TYPE.HOTSPOT_PANEL,$r.TRIGGER_SOURCE.BUTTON,[]);this.appWcRef.epigraphAnalytics.sendEvent(t)}updateHotspotsOrder(e){this.hotspotsOrder=e}removeAllHotspots(){for(const e of this.hotspots.keys())this.removeHotspot(e)}setActiveHotspotByIndex(e){const t=this.hotspotsOrder[e];this.setActiveHotspot({hotspotId:t})}updateActiveHotspotIndex(){this.activeHotspot?this.activeHotspotIndex=this.hotspotsOrder.indexOf(this.activeHotspot?.hotspotId):this.activeHotspotIndex=-1}setActiveHotspotState(e){this.__mobileHotspotCardsManager.setAttribute("cards-state",e)}setActiveHotspot({hotspotId:e,state:t=this.__mobileHotspotCardsManager.cardsState??$n.collapsed}){if(this.activeHotspot?.hotspotId===e)return;const{x:n,y:i,z:r}=this.__cameraOffsetApplied;if((n!==0||i!==0||r!==0)&&(this.appWcRef.cameraManager.mainCameraControls.setFocalOffset(0,0,0,!0),this.__cameraOffsetApplied.x=0,this.__cameraOffsetApplied.y=0,this.__cameraOffsetApplied.z=0),e===null){const l=!!this.activeHotspot;this.activeHotspot=void 0,this.updateActiveHotspotIndex(),l&&this.appWcRef.cameraManager.resetCurrentCameraTransformsToLastSavedState();return}this.enabled===!1&&(this.enabled=!0);const a=!this.activeHotspot;if(this.activeHotspot=this.hotspots.get(e),this.activeHotspot===void 0)return;this.updateActiveHotspotIndex(),this.setActiveHotspotState(t),this.__resolveHotspotCardContents();let o=this.activeHotspot.camera;if(this.activeHotspot?.camera.target.x===9999.9999&&(o=JSON.parse(JSON.stringify(o)),o.target=this.appWcRef.sceneManager.currentSceneCenter,this.appWcRef.cameraManager.mainCameraControls.setFocalOffset(-.5,0,0,!0),this.__cameraOffsetApplied.x=-.5),this.appWcRef.eventsManager.cameraMoveToTransform.fire({cameraTransforms:o,saveFirst:a,ignoreCameraLimits:!0}),this.appWcRef.isPortraitOrientation){const l=this.appWcRef.cameraManager.mainCameraControls,c=new Q;l.getTarget(c,!0);const h=new Q;l.getPosition(h,!0),l.setLookAt(h.x-c.x,h.y,h.z-c.z,0,c.y,0,!0),l.setFocalOffset(0,.1,0,!0),this.__cameraOffsetApplied.y=.1}window.addEventListener("keydown",l=>{l.key==="Escape"&&this.closeActiveHotspot()},{once:!0})}__resolveHotspotCardContents(){this.__allCards=[];let e=0;const t=this.hotspots.size-1,n=this.hotspots.size>1,i=this.appWcRef.productSettings.hotspots.showNavigationButtons;for(const r of this.hotspots.values()){const a=e===0,o=e===t,l=ae`
16078
16078
  <swiper-slide part="swiper-slide">
16079
16079
  <style>
16080
16080
  .expand-button {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epigraph/solutions",
3
- "version": "1.0.17-alpha.3",
3
+ "version": "1.0.17",
4
4
  "type": "module",
5
5
  "main": "./dist/epigraph-solutions.js",
6
6
  "files": [