@epigraph/solutions 1.1.1 → 1.1.2
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 Cn(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 Cn(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 Z1=class Z_{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&&Z_.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",()=>{Z_.xrSessionIsGranted=!0})}};Z1.xrSessionIsGranted=!1;let BV=Z1;BV.registerSessionGrantedListener();var eR=(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))(eR||{});const TV=Object.keys(eR);TV.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=kp.PRODUCTION;return e=="local"?t=kp.LOCAL:e==="staging"&&(t=kp.STAGING),t}static parseUrlForEpigraphParams(e){const t=new Map,n=new ky(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(nd.AR,JSON.parse(i)[nd.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,`{"${nd.AR}":true}`),new ky(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 _h)&&It._dispose3(t)}),(e instanceof je||e instanceof _h||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 Ed{constructor(e){this._success=e}get success(){return this._success}set success(e){this._success=e}get failed(){return!this._success}}class MV extends Ed{constructor(e=!1,t=void 0){super(e),this.__payload=t}get payload(){return this.__payload}set payload(e){this.__payload=e}}var tR=(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))(tR||{});class RV extends _n{constructor(){super(),this._entityType=tR.Empty}get entityType(){return this._entityType}destroy(){let e;const t=new MV(!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 tp{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 nR{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 BT(e,t,n,i,.06,.06);const r=document.createElement("div");r.textContent=this.name;const a=new bb(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 BT(e,t,n,i,.01,.08);const r=document.createElement("div");r.textContent=this.name,r.style.color="green";const a=new bb(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 e0=(s=>(s.Plug="plug",s.Receiver="receiver",s))(e0||{});class iR extends nR{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 DV extends iR{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===e0.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===e0.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 sR extends iR{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 QV extends nR{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 _h({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 rR{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 DV({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 QV({id:`${String(e.id)}-${oo.Splat}`,uri:e.renderSplat,appWcRef:this.__appWcRef}):this.__renderGltf=new sR({id:`${String(e.id)}-${oo.Render}`,uri:e.renderGeo,appWcRef:this.__appWcRef});for(const n in e.finishes)this.__finishes.set(n,new tp(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 tp("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 tp(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 tp(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 LV=Object.defineProperty,aR=(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&&LV(e,t,i),i};class oR{constructor({appWcRef:e}){this._loggerContext="SOLUTION MANAGER",this._appWcRef=e}initialize(){window.epigraph.logger.info({title:"Initializing...",contextOverride:this._loggerContext})}}const Tb=class jp extends qc{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(jp.webComponentName)||window.customElements.define(jp.webComponentName,jp)}render(){return ae`
|
|
12926
12926
|
${It.getCustomStylesTemplate()}
|
|
12927
|
-
`}};aR([q({type:Boolean,attribute:"enabled"})],Tb.prototype,"enabled");aR([q({attribute:!1})],Tb.prototype,"appWcRef");let Tl=Tb;class NV{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 PV{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 FV extends _n{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 rR({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 Al(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 Al&&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 PV({id:t.connectionId,receiver:i,plug:r});e.set(t.connectionId,a)}}}),e}}class kV extends oR{constructor(e){super({appWcRef:e}),this._loggerContext="SCENE MANAGER",this.__currentSceneBounds=new Cn,this.__sceneStructure=new FV(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 UV extends _n{constructor(e,t){super(),this.__autoGeneratedBoundsBox=new Cn,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 _n;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 _n;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 Ed(!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);let a=!0;if(await this.__selectFinishByKHRMaterialsVariantsExtension(i,r,e,n).catch(()=>{a=!1}),!a){const o=await this.__selectFinishByMaterialLibrary(i,r,e);t.success=o.success}return this.__activeFinish=e,Promise.resolve(t)}async __switchMaterial(e,t,n,i,r){const a=new Ed(!1);if(!(e instanceof je)||!e.isMesh||!e.userData.gltfExtensions)return Promise.reject(a);const o=e.userData.gltfExtensions[t];if(!o)return window.epigraph.logger.error({title:"No variants extension found in mesh.",details:o}),Promise.reject(a);e.userData.originalMaterial||(e.userData.originalMaterial=e.material);const l=o.mappings.find(c=>c.variants.includes(i));if(l&&n.resource){const c=n.resource.parser;e.material=await c.getDependency("material",l.material),c.assignFinalMaterial(e),a.success=!0}else window.epigraph.logger.info({title:"Variant has no effect on this Object.",details:{object:e,finishId:r}}),e.material=e.userData.originalMaterial,a.success=!0;return Promise.resolve(a)}__selectFinishByKHRMaterialsVariantsExtension(e,t,n,i){window.epigraph.logger.info({title:"Attempting to load finish by KHR Materials Variants",details:n});const r=e.variants.findIndex(o=>o.name===n),a=[];return this.traverse(async o=>{a.push(this.__switchMaterial(o,t,i,r,n))}),Promise.all(a)}async __selectFinishByMaterialLibrary(e,t,n){const i=new Ed(!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 OV extends _n{constructor(e){super(),this.name="PROXY",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class GV extends _n{constructor(e){super(),this.name="HOTSPOTS",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class Al extends RV{constructor(e,t){super(),this.epgType="ENTITY_ASSET",this.__autoGeneratedProxy=new _n,this.__animationMixer=null,this.__animations=new Map,this.name=e.name,this.__appWcRef=t,this.__proxyEntity=new OV(this),this.add(this.__proxyEntity),this.__renderEntity=new UV(this,this.__appWcRef.loaders.textureLoader),this.add(this.__renderEntity),this.__hotspotsEntity=new GV(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 NV({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 _n;r.name="proxygeopivot";const a=new hg(.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 wT(this.__renderEntity.children[0]);for(const e of this.__asset.renderGltf.resource.animations)this.__animations.set(e.name,this.__animationMixer.clipAction(e))}}}function lR(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=j0.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 zV=lR({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");function HV(s){return s.isLight}function $V(s){return!!s.geometry}const VV=lR({color:new Me(0),blend:2,alphaTest:.75,opacity:0,map:null},`varying vec2 vUv;
|
|
12927
|
+
`}};aR([q({type:Boolean,attribute:"enabled"})],Tb.prototype,"enabled");aR([q({attribute:!1})],Tb.prototype,"appWcRef");let Tl=Tb;class NV{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 PV{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 FV extends _n{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 rR({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 Al(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 Al&&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 PV({id:t.connectionId,receiver:i,plug:r});e.set(t.connectionId,a)}}}),e}}class kV extends oR{constructor(e){super({appWcRef:e}),this._loggerContext="SCENE MANAGER",this.__currentSceneBounds=new Cn,this.__sceneStructure=new FV(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 UV extends _n{constructor(e,t){super(),this.__autoGeneratedBoundsBox=new Cn,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 _n;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 _n;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 Ed(!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);let a=!0;if(await this.__selectFinishByKHRMaterialsVariantsExtension(i,r,e,n).catch(()=>{a=!1}),!a){const o=await this.__selectFinishByMaterialLibrary(i,r,e);t.success=o.success}return this.__activeFinish=e,Promise.resolve(t)}async __switchMaterial(e,t,n,i,r){const a=new Ed(!1);if(!(e instanceof je)||!e.isMesh)return Promise.resolve(a);if(!e.userData.gltfExtensions)return Promise.reject(a);const o=e.userData.gltfExtensions[t];if(!o)return window.epigraph.logger.error({title:"No variants extension found in mesh.",details:o}),Promise.reject(a);e.userData.originalMaterial||(e.userData.originalMaterial=e.material);const l=o.mappings.find(c=>c.variants.includes(i));if(l&&n.resource){const c=n.resource.parser;e.material=await c.getDependency("material",l.material),c.assignFinalMaterial(e),a.success=!0}else window.epigraph.logger.info({title:"Variant has no effect on this Object.",details:{object:e,finishId:r}}),e.material=e.userData.originalMaterial,a.success=!0;return e.material.needsUpdate=!0,Promise.resolve(a)}__selectFinishByKHRMaterialsVariantsExtension(e,t,n,i){window.epigraph.logger.info({title:"Attempting to load finish by KHR Materials Variants",details:n});const r=e.variants.findIndex(o=>o.name===n),a=[];return this.traverse(o=>{a.push(this.__switchMaterial(o,t,i,r,n))}),Promise.all(a)}async __selectFinishByMaterialLibrary(e,t,n){const i=new Ed(!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);if(a===null)continue;const o=[];this.traverse(l=>{l instanceof je&&o.push((async()=>{l.material=a,await this.__processAnyOverridesForAsset(n,l),l.material.needsUpdate=!0})())}),await Promise.all(o)}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 OV extends _n{constructor(e){super(),this.name="PROXY",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class GV extends _n{constructor(e){super(),this.name="HOTSPOTS",this.__assetEntity=e}get asset(){return this.__assetEntity.asset}}class Al extends RV{constructor(e,t){super(),this.epgType="ENTITY_ASSET",this.__autoGeneratedProxy=new _n,this.__animationMixer=null,this.__animations=new Map,this.name=e.name,this.__appWcRef=t,this.__proxyEntity=new OV(this),this.add(this.__proxyEntity),this.__renderEntity=new UV(this,this.__appWcRef.loaders.textureLoader),this.add(this.__renderEntity),this.__hotspotsEntity=new GV(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 NV({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 _n;r.name="proxygeopivot";const a=new hg(.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 wT(this.__renderEntity.children[0]);for(const e of this.__asset.renderGltf.resource.animations)this.__animations.set(e.name,this.__animationMixer.clipAction(e))}}}function lR(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=j0.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 zV=lR({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");function HV(s){return s.isLight}function $V(s){return!!s.geometry}const VV=lR({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;
|