@epigraph/solutions 1.0.20-alpha.1 → 1.0.21

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.
@@ -18080,7 +18080,7 @@ void main() {
18080
18080
  <div id="appCanvasContainer" class="app-canvas-container">
18081
18081
  <span id="cameraAimIndicator" class="camera-aim-indicator hide"></span>
18082
18082
  </div>
18083
- `:me}getWebComponentName(){return ed.webComponentName}async _resolveIdentifierAndType(){this.sku?(this._identifierType="sku",this._identifier=this.sku):this.shopify_variant_id?(this._identifierType="shopify_variant_id",this._identifier=this.shopify_variant_id):this.upc?(this._identifierType="upc",this._identifier=this.upc):this.asin?(this._identifierType="asin",this._identifier=this.asin):this.experience_id?(this._identifierType="experience_id",this._identifier=this.experience_id):this.product_variant_uuid&&(this._identifierType="product_variant_uuid",this._identifier=this.product_variant_uuid)}async _onAuthenticationFailed(e){window.epigraph.logger.error({title:"AUTHENTICATION FAILED: Expand for details...",details:e,contextOverride:this._loggerContext}),this.onLoadFailed(sv.MODULE_FAILED_ERRORS.AUTHENTICATION_FAILED,{errorCode:$3.AuthenticationFailedError,message:e}),await this.disconnectedCallback()}async setupRenderEngine(){window.epigraph.logger.info({title:"Initiliazing Render Engine"}),this._renderEngine=new d5(this);const{canvasHtmlElem:e,screenshotRenderer:t,textRendererElem:n}=await this._renderEngine.setup();this.appCanvasContainerElemRef.appendChild(e),this.appCanvasContainerElemRef.appendChild(n),t?.domElement&&this.appCanvasContainerElemRef.appendChild(t.domElement),new ResizeObserver(this.__onWebComponentResize.bind(this)).observe(this.appCanvasContainerElemRef)}_showCustomViewInYourSpaceButton(){this._getSlottedElements(this.customViewInYourSpaceButtonSlotElem).forEach(t=>{const n=t;n.style.visibility="visible",n.style.transition="opacity 0.5s ease-in-out",n.style.opacity="1"})}_hideCustomViewInYourSpaceButton(){this._getSlottedElements(this.customViewInYourSpaceButtonSlotElem).forEach(t=>{const n=t,i=500;n.style.transition=`opacity ${i/1e3}s ease-in-out`,n.style.opacity="0",setTimeout(()=>n.style.visibility="hidden",i)})}_sendAnalyticsEventsOnModuleLoadStart(){const e=new dD(!1);this._epigraphAnalytics.sendEvent(e)}_sendAnalyticsEventsOnModuleLoadFinish(){const e=this.timeElapsedSinceLoadBegin,t=new AD(!1,e);this._epigraphAnalytics.sendEvent(t);const n=window.epigraph.isSessionWebGL2Compatible();let i;this.viewInYourSpaceManager.canLaunchAr()?i=n?Kh.SUPPORT_TYPE.AR_WEBGL2:Kh.SUPPORT_TYPE.AR:i=n?Kh.SUPPORT_TYPE.QR_WEBGL2:Kh.SUPPORT_TYPE.QR;const r=new Kh(i);this._epigraphAnalytics.sendEvent(r)}_onNewExperienceLoadStart(){this.isLoading=!0,this._loadingProgress=0,this._hideCustomViewInYourSpaceButton(),this.showSplashScreen(),this.hotspotsManager?.activeHotspot&&this.hotspotsManager.closeActiveHotspot(),this._sendAnalyticsEventsOnModuleLoadStart()}_onNewExperienceLoadFinish(){this._onSceneHierarchyUpdate(),this.isLoading=!1,this._showCustomViewInYourSpaceButton(),this._eventsManager.experienceUpdatedEvent.fire(),this._eventsManager.appReadyEvent.fire(),this.productSettings.camera.initial?.recalculateCameraZoom===!0&&this.cameraManager.fitCameraToSceneBounds(),this.hideSplashScreen(),setTimeout(()=>{this._isSceneInteractedWith||(this.playInteractionPrompt=!0)},3e3),this._sendAnalyticsEventsOnModuleLoadFinish()}toggleDimensions(){this.dimensionsManager.enabled?this.hideDimensions():this.showDimensions()}_onDimensionsToolControlClick(e){e.stopPropagation(),e.preventDefault();const t=e.target;t.active?this.showDimensions():this.hideDimensions();const n=new xa(xa.BUTTON_TYPE.DIMENSION_TOGGLE,t.id);this._epigraphAnalytics.sendEvent(n)}_onViewInYourSpaceToolControlClick(e){e.stopPropagation(),e.preventDefault();const t=e.target;this.launchAR();const n=new xa(xa.BUTTON_TYPE.AR_VIEW,t.id);this._epigraphAnalytics.sendEvent(n)}async _onSceneHierarchyUpdate(e=!1){if(this.sceneManager.recalculateSceneBounds(),this.featuresToEnable.hotspots&&this._repopulateHotspots(),e)return Promise.resolve([]);await this._cameraManager.fitCameraToSceneBounds()}_renderAppManagers(){return ae`
18083
+ `:me}getWebComponentName(){return ed.webComponentName}async _resolveIdentifierAndType(){this.sku?(this._identifierType="sku",this._identifier=this.sku):this.shopify_variant_id?(this._identifierType="shopify_variant_id",this._identifier=this.shopify_variant_id):this.upc?(this._identifierType="upc",this._identifier=this.upc):this.asin?(this._identifierType="asin",this._identifier=this.asin):this.experience_id?(this._identifierType="experience_id",this._identifier=this.experience_id):this.product_variant_uuid&&(this._identifierType="product_variant_uuid",this._identifier=this.product_variant_uuid)}async _onAuthenticationFailed(e){window.epigraph.logger.error({title:"AUTHENTICATION FAILED: Expand for details...",details:e,contextOverride:this._loggerContext}),this.onLoadFailed(sv.MODULE_FAILED_ERRORS.AUTHENTICATION_FAILED,{errorCode:$3.AuthenticationFailedError,message:e}),await this.disconnectedCallback()}async setupRenderEngine(){window.epigraph.logger.info({title:"Initiliazing Render Engine"}),this._renderEngine=new d5(this);const{canvasHtmlElem:e,screenshotRenderer:t,textRendererElem:n}=await this._renderEngine.setup();this.appCanvasContainerElemRef.appendChild(e),this.appCanvasContainerElemRef.appendChild(n),t?.domElement&&this.appCanvasContainerElemRef.appendChild(t.domElement),new ResizeObserver(this.__onWebComponentResize.bind(this)).observe(this.appCanvasContainerElemRef)}_showCustomViewInYourSpaceButton(){this._getSlottedElements(this.customViewInYourSpaceButtonSlotElem).forEach(t=>{const n=t;n.style.visibility="visible",n.style.transition="opacity 0.5s ease-in-out",n.style.opacity="1"})}_hideCustomViewInYourSpaceButton(){this._getSlottedElements(this.customViewInYourSpaceButtonSlotElem).forEach(t=>{const n=t,i=500;n.style.transition=`opacity ${i/1e3}s ease-in-out`,n.style.opacity="0",setTimeout(()=>n.style.visibility="hidden",i)})}_sendAnalyticsEventsOnModuleLoadStart(){const e=new dD(!1);this._epigraphAnalytics.sendEvent(e)}_sendAnalyticsEventsOnModuleLoadFinish(){const e=this.timeElapsedSinceLoadBegin,t=new AD(!1,e);this._epigraphAnalytics.sendEvent(t);const n=window.epigraph.isSessionWebGL2Compatible();let i;this.viewInYourSpaceManager.canLaunchAr()?i=n?Kh.SUPPORT_TYPE.AR_WEBGL2:Kh.SUPPORT_TYPE.AR:i=n?Kh.SUPPORT_TYPE.QR_WEBGL2:Kh.SUPPORT_TYPE.QR;const r=new Kh(i);this._epigraphAnalytics.sendEvent(r)}_onNewExperienceLoadStart(){this.isLoading=!0,this._loadingProgress=0,this._hideCustomViewInYourSpaceButton(),this.showSplashScreen(),this.hotspotsManager?.activeHotspot&&this.hotspotsManager.closeActiveHotspot(),this._sendAnalyticsEventsOnModuleLoadStart()}_onNewExperienceLoadFinish(){this._onSceneHierarchyUpdate(),this.isLoading=!1,this._showCustomViewInYourSpaceButton(),this._eventsManager.experienceUpdatedEvent.fire(),this._eventsManager.appReadyEvent.fire(),this.productSettings.camera.initial?.skipCameraFit||this.cameraManager.fitCameraToSceneBounds(),this.hideSplashScreen(),setTimeout(()=>{this._isSceneInteractedWith||(this.playInteractionPrompt=!0)},3e3),this._sendAnalyticsEventsOnModuleLoadFinish()}toggleDimensions(){this.dimensionsManager.enabled?this.hideDimensions():this.showDimensions()}_onDimensionsToolControlClick(e){e.stopPropagation(),e.preventDefault();const t=e.target;t.active?this.showDimensions():this.hideDimensions();const n=new xa(xa.BUTTON_TYPE.DIMENSION_TOGGLE,t.id);this._epigraphAnalytics.sendEvent(n)}_onViewInYourSpaceToolControlClick(e){e.stopPropagation(),e.preventDefault();const t=e.target;this.launchAR();const n=new xa(xa.BUTTON_TYPE.AR_VIEW,t.id);this._epigraphAnalytics.sendEvent(n)}async _onSceneHierarchyUpdate(e=!1){if(this.sceneManager.recalculateSceneBounds(),this.featuresToEnable.hotspots&&this._repopulateHotspots(),e)return Promise.resolve([]);await this._cameraManager.fitCameraToSceneBounds()}_renderAppManagers(){return ae`
18084
18084
  <div id="appManagersContainer" class="app-managers-container">
18085
18085
  ${this._renderDimensionsManager()}
18086
18086
 
@@ -18205,7 +18205,7 @@ void main() {
18205
18205
  .loadingLogoSrc=${this.splashScreenLogo}
18206
18206
  .loadingLabel=${this.splashScreenText}
18207
18207
  ></epg-loader-scene>
18208
- `}async _resetSession(){this._autoGeneratedProxyMesh?.scale.set(1,1,1),this._autoGeneratedProxyMesh?.position.set(0,0,0),this._autoGeneratedProxyMesh?.updateMatrixWorld(),await this.renderEngine.emptyScene()}_setupEventListeners(){window.epigraph.logger.info({title:"Setting up event listeners for this app."}),this.addEventListener(this.eventsManager.sceneBoundsChanged.name,()=>{this.cameraManager.fitCameraToSceneBounds()}),this.addEventListener(this.eventsManager.structureNodeAddedEvent.name,()=>{this._onSceneHierarchyUpdate()}),this.addEventListener(this.eventsManager.experienceUpdatedEvent.name,()=>{this.renderEngine.accumulativeShadows&&!this.renderEngine.accumulativeShadows.camera&&(this.renderEngine.accumulativeShadows.camera=this.cameraManager.getCameras().main),this.renderEngine.accumulativeShadows?.reset(),this.renderEngine.contactShadows&&this.renderEngine.contactShadows.updateSettings(this.productSettings.shadows.contactShadows),this.cameraManager.updateCameraSettings(this.productSettings.camera),this.productSettings.camera.initial&&this.cameraManager.moveCameraToLocation({newCameraTransforms:this.productSettings.camera.initial,transition:!0})}),this.addEventListener(this.eventsManager.dimensionsPositionChanged.name,this.__onDimensionsPositionChanged),this.addEventListener(this.eventsManager.cameraControlsStart.name,(e=>{switch(e.detail.type){case"rotate":(this.sessionState==="default"||this.sessionState==="cameraUpdate")&&(this.style.cursor="grabbing");break;case"pan":(this.sessionState==="default"||this.sessionState==="cameraUpdate")&&(this.style.cursor="move"),this.showCameraAim();break}this.hotspotsManager&&this.hotspotsManager.activeHotspot&&this.sessionState==="default"&&this.hotspotsManager.closeActiveHotspot()})),this.addEventListener(this.eventsManager.inputEnd.name,()=>{(this.sessionState==="default"||this.sessionState==="cameraUpdate")&&(this.style.cursor="grab"),this.hideCameraAim()}),this.addEventListener(this.eventsManager.hotspotOpenEvent.name,()=>{this.hideDimensions(!0)}),this.addEventListener(this.eventsManager.assetLoadProgress.name,(e=>{this._loadingProgress=e.detail.progress})),this.addEventListener(this.eventsManager.hotspotOpenEvent.name,(e=>{this._hasActiveHotspot=!0,this._resolveAnimationsOnHotspotEntry(e.detail.hotspot)})),this.addEventListener(this.eventsManager.hotspotNextEvent.name,(e=>{this._resolveAnimationsOnHotspotEntry(e.detail.hotspot)})),this.addEventListener(this.eventsManager.hotspotPreviousEvent.name,(e=>{this._resolveAnimationsOnHotspotEntry(e.detail.hotspot)})),this.addEventListener(this.eventsManager.hotspotClosedEvent.name,(e=>{this._hasActiveHotspot=!1;const t=this.hotspotsManager.hotspots.get(e.detail.hotspotId),n=t?.animation,i=t?.assetId;if(!n||!i)return;const r=n.loop,a=n.exit;r&&this.stopAnimationByNameAndAssetId(r,i);let o;a?o=this.playAnimationByNameAndAssetId({animationName:a,assetId:i}):o=this.playAnimationByNameAndAssetId({animationName:n.entry,assetId:i,reverse:!0}),setTimeout(()=>{o?.targetAnimationAction.reset(),this._activeAnimations.delete(o?.animationName??"")},this._animationFadeDurationInMiliseconds)})),this.appCanvasContainerElemRef.onpointerdown=e=>{this._isSceneInteractedWith=!0,this.playInteractionPrompt=!1,this.hideHelp(),this.eventsManager.inputStart.fire({event:e})},this.appCanvasContainerElemRef.onpointermove=e=>{this.eventsManager.inputMove.fire({event:e})},this.appCanvasContainerElemRef.onpointerup=e=>{this.eventsManager.inputEnd.fire({event:e})},this.appCanvasContainerElemRef.onpointerout=e=>{this.eventsManager.inputEnd.fire({event:e})},this.cameraManager.mainCameraControls.addEventListener("update",this._onCameraPositionUpdate.bind(this)),this.hotspotsManager?.addEventListener("pointerdown",()=>{this._isSceneInteractedWith=!0,this.playInteractionPrompt=!1,this.hideHelp()})}_onCameraPositionUpdate(){this.hotspotsManager?.enabled&&this.hotspotsManager.recalculateHotspotPositions()}_setupAutoGeneratedProxyContainers(){const e=new xs,t=new Un({color:65280,opacity:.5,transparent:!0});this._autoGeneratedProxyMesh=new je(e,t)}get productSettings(){return this._productSettings}async _setup(){window.epigraph.logger.table({title:"Setting up..."}),this._eventsManager=new NW(this),this._sceneManager=new FV(this),this._sceneManager.initialize(),this._cameraManager=new zf({appWcRef:this}),this._cameraManager.initialize();const e=this._sceneManager.sceneStructure.setupRootEntity().catch(t=>{this.onLoadFailed(T0.SCENE_LOAD_ERROR,t)});await this.setupRenderEngine(),await e,await this._cameraManager.setup({mainRenderer:this.renderEngine.mainRenderer,screenshotRenderer:this.renderEngine.screenshotRenderer,cameraSettings:this.productSettings.camera}),this._setupAutoGeneratedProxyContainers(),this._setupEventListeners(),this._setupVisibilityObserver()}_resolveAnimationsOnHotspotEntry(e){this.stopAllAnimations();const t=e.animation,n=e.assetId;if(!t||!n)return;this._activeAnimations.get(t.entry)||this.playAnimationByNameAndAssetId({animationName:t.entry,assetId:n,clampWhenFinished:!0}),setTimeout(()=>{this._activeAnimations.delete(t.entry),this._activeAnimations.get(t.loop)?.loop||this.playAnimationByNameAndAssetId({animationName:t.loop,assetId:n,loop:!0})},this._animationFadeDurationInMiliseconds)}_renderDimensionsManager(){let e=me;return this.featuresToEnable.dimensions&&(I5.setupWebComponent(),e=ae`
18208
+ `}async _resetSession(){this._autoGeneratedProxyMesh?.scale.set(1,1,1),this._autoGeneratedProxyMesh?.position.set(0,0,0),this._autoGeneratedProxyMesh?.updateMatrixWorld(),await this.renderEngine.emptyScene()}_setupEventListeners(){window.epigraph.logger.info({title:"Setting up event listeners for this app."}),this.addEventListener(this.eventsManager.sceneBoundsChanged.name,()=>{this.cameraManager.fitCameraToSceneBounds()}),this.addEventListener(this.eventsManager.structureNodeAddedEvent.name,()=>{this._onSceneHierarchyUpdate()}),this.addEventListener(this.eventsManager.experienceUpdatedEvent.name,()=>{this.renderEngine.accumulativeShadows&&!this.renderEngine.accumulativeShadows.camera&&(this.renderEngine.accumulativeShadows.camera=this.cameraManager.getCameras().main),this.renderEngine.accumulativeShadows?.reset(),this.renderEngine.contactShadows&&this.renderEngine.contactShadows.updateSettings(this.productSettings.shadows.contactShadows),this.cameraManager.updateCameraSettings(this.productSettings.camera),this.productSettings.camera.initial&&this.cameraManager.moveCameraToLocation({newCameraTransforms:this.productSettings.camera.initial,transition:!0}).then(()=>{this.productSettings.camera.initial?.skipCameraFit||this.cameraManager.fitCameraToSceneBounds()})}),this.addEventListener(this.eventsManager.dimensionsPositionChanged.name,this.__onDimensionsPositionChanged),this.addEventListener(this.eventsManager.cameraControlsStart.name,(e=>{switch(e.detail.type){case"rotate":(this.sessionState==="default"||this.sessionState==="cameraUpdate")&&(this.style.cursor="grabbing");break;case"pan":(this.sessionState==="default"||this.sessionState==="cameraUpdate")&&(this.style.cursor="move"),this.showCameraAim();break}this.hotspotsManager&&this.hotspotsManager.activeHotspot&&this.sessionState==="default"&&this.hotspotsManager.closeActiveHotspot()})),this.addEventListener(this.eventsManager.inputEnd.name,()=>{(this.sessionState==="default"||this.sessionState==="cameraUpdate")&&(this.style.cursor="grab"),this.hideCameraAim()}),this.addEventListener(this.eventsManager.hotspotOpenEvent.name,()=>{this.hideDimensions(!0)}),this.addEventListener(this.eventsManager.assetLoadProgress.name,(e=>{this._loadingProgress=e.detail.progress})),this.addEventListener(this.eventsManager.hotspotOpenEvent.name,(e=>{this._hasActiveHotspot=!0,this._resolveAnimationsOnHotspotEntry(e.detail.hotspot)})),this.addEventListener(this.eventsManager.hotspotNextEvent.name,(e=>{this._resolveAnimationsOnHotspotEntry(e.detail.hotspot)})),this.addEventListener(this.eventsManager.hotspotPreviousEvent.name,(e=>{this._resolveAnimationsOnHotspotEntry(e.detail.hotspot)})),this.addEventListener(this.eventsManager.hotspotClosedEvent.name,(e=>{this._hasActiveHotspot=!1;const t=this.hotspotsManager.hotspots.get(e.detail.hotspotId),n=t?.animation,i=t?.assetId;if(!n||!i)return;const r=n.loop,a=n.exit;r&&this.stopAnimationByNameAndAssetId(r,i);let o;a?o=this.playAnimationByNameAndAssetId({animationName:a,assetId:i}):o=this.playAnimationByNameAndAssetId({animationName:n.entry,assetId:i,reverse:!0}),setTimeout(()=>{o?.targetAnimationAction.reset(),this._activeAnimations.delete(o?.animationName??"")},this._animationFadeDurationInMiliseconds)})),this.appCanvasContainerElemRef.onpointerdown=e=>{this._isSceneInteractedWith=!0,this.playInteractionPrompt=!1,this.hideHelp(),this.eventsManager.inputStart.fire({event:e})},this.appCanvasContainerElemRef.onpointermove=e=>{this.eventsManager.inputMove.fire({event:e})},this.appCanvasContainerElemRef.onpointerup=e=>{this.eventsManager.inputEnd.fire({event:e})},this.appCanvasContainerElemRef.onpointerout=e=>{this.eventsManager.inputEnd.fire({event:e})},this.cameraManager.mainCameraControls.addEventListener("update",this._onCameraPositionUpdate.bind(this)),this.hotspotsManager?.addEventListener("pointerdown",()=>{this._isSceneInteractedWith=!0,this.playInteractionPrompt=!1,this.hideHelp()})}_onCameraPositionUpdate(){this.hotspotsManager?.enabled&&this.hotspotsManager.recalculateHotspotPositions()}_setupAutoGeneratedProxyContainers(){const e=new xs,t=new Un({color:65280,opacity:.5,transparent:!0});this._autoGeneratedProxyMesh=new je(e,t)}get productSettings(){return this._productSettings}async _setup(){window.epigraph.logger.table({title:"Setting up..."}),this._eventsManager=new NW(this),this._sceneManager=new FV(this),this._sceneManager.initialize(),this._cameraManager=new zf({appWcRef:this}),this._cameraManager.initialize();const e=this._sceneManager.sceneStructure.setupRootEntity().catch(t=>{this.onLoadFailed(T0.SCENE_LOAD_ERROR,t)});await this.setupRenderEngine(),await e,await this._cameraManager.setup({mainRenderer:this.renderEngine.mainRenderer,screenshotRenderer:this.renderEngine.screenshotRenderer,cameraSettings:this.productSettings.camera}),this._setupAutoGeneratedProxyContainers(),this._setupEventListeners()}_resolveAnimationsOnHotspotEntry(e){this.stopAllAnimations();const t=e.animation,n=e.assetId;if(!t||!n)return;this._activeAnimations.get(t.entry)||this.playAnimationByNameAndAssetId({animationName:t.entry,assetId:n,clampWhenFinished:!0}),setTimeout(()=>{this._activeAnimations.delete(t.entry),this._activeAnimations.get(t.loop)?.loop||this.playAnimationByNameAndAssetId({animationName:t.loop,assetId:n,loop:!0})},this._animationFadeDurationInMiliseconds)}_renderDimensionsManager(){let e=me;return this.featuresToEnable.dimensions&&(I5.setupWebComponent(),e=ae`
18209
18209
  <dimensions-manager
18210
18210
  id="dimensionsManager"
18211
18211
  .appWcRef=${this}
@@ -18245,7 +18245,7 @@ void main() {
18245
18245
  <div class="view-in-your-space-button ${this._hasActiveHotspot?"hide":""}">
18246
18246
  <slot name=${af.slotCustomViewInYourSpaceButton.name} @click=${this.launchAR}></slot>
18247
18247
  </div>
18248
- `}getAllHotspotsFromScene(){const e=[];return this.sceneManager.sceneStructure.traverse(t=>{if(t instanceof Al)for(const n of t.asset.hotspots)this.hotspotsManager.addHotspot(n,!1)}),e}_repopulateHotspots(){window.epigraph.logger.info({title:"Override to repopulate hotspots in scene on identifier changes"}),this.featuresToEnable.hotspots===!0&&this.hotspotsManager&&(this.hotspotsManager.removeAllHotspots(),this.getAllHotspotsFromScene(),this.updateHotspotsOrder(Array.from(this.hotspotsManager.hotspots.keys())))}_setupAnalytics(){this._isDevEnv||this._isStagingEnv||(this._nexusAnalyticsPlugin=new cD({trackingID:this.gaMeasurementId,experienceID:this.experience_id,solution:this.getWebComponentName(),sessionId:window.epigraph.epigraphSessionId,xPath:this.xPath,verboseLogging:this._isDevEnv,sendToStaging:this._isStagingEnv}),this._epigraphAnalytics.addEventPlugin(this._nexusAnalyticsPlugin),this.gaMeasurementId&&(this._ga4AnalyticsPlugin=new lD({trackingID:this.gaMeasurementId,experienceID:this.experience_id,solution:this.getWebComponentName(),verboseLogging:this._isDevEnv}),this._epigraphAnalytics.addEventPlugin(this._ga4AnalyticsPlugin)))}__onWebComponentResize(){if(!this.appCanvasContainerElemRef)return;const{width:e,height:t}=this.appCanvasContainerElemRef.getBoundingClientRect();if(!(e===0||t===0)){if(this.__canvasSize.width=e,this.__canvasSize.height=t,this.renderEngine.mainRenderer.setSize(e,t),this.renderEngine.textRenderer.setSize(e,t),this.renderEngine.effectsComposer.setSize(e,t),this.cameraManager){const n=this.renderEngine.canvas.clientWidth/this.renderEngine.canvas.clientHeight;this.cameraManager.getCameras().main.aspect=n,this.cameraManager.getCameras().main.updateProjectionMatrix(),this.cameraManager.getCameras().screenshot.aspect=n,this.cameraManager.getCameras().screenshot.updateProjectionMatrix()}this.dimensionsManager&&!this.hotspotsManager?.activeHotspot&&this.cameraManager.fitCameraToSceneBounds(!1),this.isPortraitOrientation=e<700,this.postRenderFrameUpdateInEngine(this.renderEngine.getClockDelta()),this.eventsManager.webComponentResized.fire()}}__onDimensionsPositionChanged(){this.renderEngine.updateDimensionLines(this.dimensionsManager.getCurrentDimensionsIndicatorState())}showSplashScreen(){this.splashScreenElem?.show()}hideSplashScreen(){this.splashScreenElem?.hide()}_setupVisibilityObserver(){new IntersectionObserver(()=>{this.isAppReady&&(window.epigraph.logger.info({title:"Component became visible, re-calculating scene hierarchy.",contextOverride:this._loggerContext}),this._onSceneHierarchyUpdate(),this.productSettings.camera.initial&&this.cameraManager.moveCameraToLocation({newCameraTransforms:this.productSettings.camera.initial,transition:!0}))}).observe(this)}_setupResizeObservers(){new ResizeObserver(t=>{for(const n of t){const{width:i,height:r}=n.target.getBoundingClientRect(),a=i*.5,o=r*.5;if(a>230)this._isToolsetLargerThanTheLeftBottomQuadrant=!1;else{const l=this.toolsetElem?.getBoundingClientRect();if(!l)continue;const c=l.width>a,h=l.height>o;this._isToolsetLargerThanTheLeftBottomQuadrant=c||h}}}).observe(this)}async _postExperienceDataInitialization(){if(!this._identifier||!this._identifierType)return Promise.resolve(!0);if(this.productSettings.render.mode===ga.SPLAT&&this._renderEngine.sparkRenderer){const{preBlurAmount:i,blurAmount:r}=this.productSettings.render.splatMode;this._renderEngine.sparkRenderer.preBlurAmount=i,this._renderEngine.sparkRenderer.blurAmount=r}const e=this._experienceData.productVariantCollection.getProductVariantByIdentifierAndType(this._identifier,this._identifierType);if(!e)return Promise.reject(!1);const{envMap:t,envMapRotation:n}=this.productSettings.render;return await this.renderEngine.updateEnvMap(t,n),await this.spawnProductVariant(e)}async spawnProductVariant(e){if(!e.productParts)return Promise.reject(!1);for(const t of e.productParts)await this.spawnProductPart(t);return Promise.resolve(!0)}async spawnProductPart(e){let t=this.sceneManager.sceneStructure.getEntityForAssetId(e.assetId);if(!t){const i=this._experienceData.getAssetCollection().getAssetByName(e.asset);if(!i||(await i.load(),t=await this.spawnAssetInScene(i),!t))return Promise.reject(!1)}const n=e.finish;return n?(await t.selectAssetFinish(n),Promise.resolve(!0)):Promise.resolve(!1)}async _fetchExperienceDataConfig(){return null}async _buildExperienceData(){const e=await this._fetchExperienceDataConfig();if(e===null)return await this._onAuthenticationFailed("Unable to retrieve experience data config."),Promise.reject();if(!e.success)return await this._onAuthenticationFailed(e.message),Promise.reject();this._experienceData=new HW({nexusApiResultPayload:e.payload,appWcRef:this}),await this._experienceData.initialize();const t=this._experienceData.channelSettings.ga_measurement_id;!this.gaMeasurementId&&t&&(window.epigraph.logger.info({title:"GA Measurement ID set from experience data",details:t,contextOverride:this._loggerContext}),this.gaMeasurementId=t,this._setupAnalytics())}__checkIfCurrentExperienceHasIdentifier(e,t){let n=!1;switch(e){case"sku":this.experienceData?.productVariantCollection?.getProductVariantBySku(t)&&(n=!0);break;case"shopify_variant_id":this.experienceData?.productVariantCollection?.getProductVariantByShopifyVariantId(t)&&(n=!0);break;case"upc":this.experienceData?.productVariantCollection?.getProductVariantByUpc(t)&&(n=!0);break;case"asin":this.experienceData?.productVariantCollection?.getProductVariantByAsin(t)&&(n=!0);break;case"experience_id":break;case"product_variant_uuid":this.experienceData?.productVariantCollection?.getProductVariantByUuid(t)&&(n=!0);break}return n}__guessesWhyTheExperienceFailed(){const e=[];return this._experienceData.getAssetCollection().hasAnyAssetWithSplat()&&this.productSettings.render.mode!==ga.SPLAT&&e.push("Render Splat provided in one of the assets. Try switching the render mode to Splat in Render Settings."),e}async _clearAndLoadNewExperienceInScene(){this._onNewExperienceLoadStart(),this.__checkIfCurrentExperienceHasIdentifier(this.identifierType,this.identifier)===!1&&await this._buildExperienceData().catch(e=>(window.epigraph.logger.error({title:`Couldn't build experience data for "${this.identifierType}" - "${this.identifier}"`,details:e,contextOverride:this._loggerContext}),Promise.reject(e))),await this._resetSession(),await this._postExperienceDataInitialization().catch(e=>Promise.reject(e)),this.parsedUrlParams.get(td.AR)&&!this.didARAutoLaunch&&(await this.launchAR(),this.didARAutoLaunch=!0),this._onNewExperienceLoadFinish()}async _onIdentifierOrTypeChange(){this.isAppReady&&(await this._resolveIdentifierAndType(),!(!this._identifier||!this._identifierType)&&(window.epigraph.logger.info({title:"IDENTIFIER CHANGED",details:`${this._identifierType} = ${this._identifier}`}),this._nexusAnalyticsPlugin&&(this._nexusAnalyticsPlugin.experienceID=this._identifier),this._ga4AnalyticsPlugin&&(this._ga4AnalyticsPlugin.experienceID=this._identifier),await this._clearAndLoadNewExperienceInScene().catch(e=>(window.epigraph.logger.error({title:"Error while clearing the session and loading a new experience.",details:e}),window.epigraph.logger.warn({title:"BEST GUESSES FOR FAILURE BELOW:",details:this.__guessesWhyTheExperienceFailed(),contextOverride:this._loggerContext}),Promise.reject(e)))))}showCameraInteractionPromptIndicator(){this.cameraInteractionPromptIndicatorElemRef?.classList.add("show")}hideCameraInteractionPromptIndicator(){this.cameraInteractionPromptIndicatorElemRef?.classList.remove("show")}_onPlayInteractionPromptChange(){this.playInteractionPrompt?this.__onPlayInteractionPrompt():(this.hideCameraInteractionPromptIndicator(),this._cameraManager?.mainCameraControls?.stop&&this._cameraManager?.mainCameraControls?.stop())}connectedCallback(){super.connectedCallback(),this._loadTimeBegin=performance.now(),this.parsedUrlParams=It.parseUrlForEpigraphParams(this.baseUrlOverride),this._setupAnalytics()}firstUpdated(){this.modalView&&(this.hide=!0),this._setup().then(()=>{this.featuresToEnable.viewer===!0&&(this._setupResizeObservers(),this.hideSplashScreen()),window.epigraph.logger.info({title:"All Initializations Complete",contextOverride:this._loggerContext}),this.isAppReady=!0,this._onIdentifierOrTypeChange()}).catch(e=>{window.epigraph.logger.error({title:"Error while setup",details:e})})}updated(e){(e.has("sku")||e.has("shopify_variant_id")||e.has("upc")||e.has("asin")||e.has("experience_id")||e.has("product_variant_uuid")||e.has("customVersionId"))&&this._onIdentifierOrTypeChange(),e.has("playInteractionPrompt")&&this._onPlayInteractionPromptChange(),e.has("_isActiveHotspot")&&(this._hasActiveHotspot?this._hideCustomViewInYourSpaceButton():this._showCustomViewInYourSpaceButton()),e.has("debug")&&this.eventsManager.debugChanged.fire({value:this.debug}),e.has("showSettings")&&this.eventsManager.showSettingsChanged.fire({value:this.showSettings}),e.has("modalView")&&(this.hide=this.modalView)}_getSlottedElements(e){if(!this.customViewInYourSpaceButtonSlotElem)return[];const t=e.assignedElements();return[...t.length>0?t:e.children]}disconnectedCallback(){super.disconnectedCallback()}showFullScreenModal(){this.hide=!1}hideFullScreenModal(){this.hide=!0}render(){return ae`
18248
+ `}getAllHotspotsFromScene(){const e=[];return this.sceneManager.sceneStructure.traverse(t=>{if(t instanceof Al)for(const n of t.asset.hotspots)this.hotspotsManager.addHotspot(n,!1)}),e}_repopulateHotspots(){window.epigraph.logger.info({title:"Override to repopulate hotspots in scene on identifier changes"}),this.featuresToEnable.hotspots===!0&&this.hotspotsManager&&(this.hotspotsManager.removeAllHotspots(),this.getAllHotspotsFromScene(),this.updateHotspotsOrder(Array.from(this.hotspotsManager.hotspots.keys())))}_setupAnalytics(){this._isDevEnv||this._isStagingEnv||(this._nexusAnalyticsPlugin=new cD({trackingID:this.gaMeasurementId,experienceID:this.experience_id,solution:this.getWebComponentName(),sessionId:window.epigraph.epigraphSessionId,xPath:this.xPath,verboseLogging:this._isDevEnv,sendToStaging:this._isStagingEnv}),this._epigraphAnalytics.addEventPlugin(this._nexusAnalyticsPlugin),this.gaMeasurementId&&(this._ga4AnalyticsPlugin=new lD({trackingID:this.gaMeasurementId,experienceID:this.experience_id,solution:this.getWebComponentName(),verboseLogging:this._isDevEnv}),this._epigraphAnalytics.addEventPlugin(this._ga4AnalyticsPlugin)))}__onWebComponentResize(){if(!this.appCanvasContainerElemRef)return;const{width:e,height:t}=this.appCanvasContainerElemRef.getBoundingClientRect();if(!(e===0||t===0)){if(this.__canvasSize.width=e,this.__canvasSize.height=t,this.renderEngine.mainRenderer.setSize(e,t),this.renderEngine.textRenderer.setSize(e,t),this.renderEngine.effectsComposer.setSize(e,t),this.cameraManager){const n=this.renderEngine.canvas.clientWidth/this.renderEngine.canvas.clientHeight;this.cameraManager.getCameras().main.aspect=n,this.cameraManager.getCameras().main.updateProjectionMatrix(),this.cameraManager.getCameras().screenshot.aspect=n,this.cameraManager.getCameras().screenshot.updateProjectionMatrix()}this.dimensionsManager&&!this.hotspotsManager?.activeHotspot&&this.cameraManager.fitCameraToSceneBounds(!1),this.isPortraitOrientation=e<700,this.postRenderFrameUpdateInEngine(this.renderEngine.getClockDelta()),this.eventsManager.webComponentResized.fire()}}__onDimensionsPositionChanged(){this.renderEngine.updateDimensionLines(this.dimensionsManager.getCurrentDimensionsIndicatorState())}showSplashScreen(){this.splashScreenElem?.show()}hideSplashScreen(){this.splashScreenElem?.hide()}_setupVisibilityObserver(){new IntersectionObserver(()=>{this.isAppReady&&(window.epigraph.logger.info({title:"Component became visible, re-calculating scene hierarchy.",contextOverride:this._loggerContext}),this._onSceneHierarchyUpdate(),this.productSettings.camera.initial&&this.cameraManager.moveCameraToLocation({newCameraTransforms:this.productSettings.camera.initial,transition:!0}).then(()=>{this.productSettings.camera.initial?.skipCameraFit||this.cameraManager.fitCameraToSceneBounds()}))}).observe(this)}_setupResizeObservers(){new ResizeObserver(t=>{for(const n of t){const{width:i,height:r}=n.target.getBoundingClientRect(),a=i*.5,o=r*.5;if(a>230)this._isToolsetLargerThanTheLeftBottomQuadrant=!1;else{const l=this.toolsetElem?.getBoundingClientRect();if(!l)continue;const c=l.width>a,h=l.height>o;this._isToolsetLargerThanTheLeftBottomQuadrant=c||h}}}).observe(this)}async _postExperienceDataInitialization(){if(!this._identifier||!this._identifierType)return Promise.resolve(!0);if(this.productSettings.render.mode===ga.SPLAT&&this._renderEngine.sparkRenderer){const{preBlurAmount:i,blurAmount:r}=this.productSettings.render.splatMode;this._renderEngine.sparkRenderer.preBlurAmount=i,this._renderEngine.sparkRenderer.blurAmount=r}const e=this._experienceData.productVariantCollection.getProductVariantByIdentifierAndType(this._identifier,this._identifierType);if(!e)return Promise.reject(!1);const{envMap:t,envMapRotation:n}=this.productSettings.render;return await this.renderEngine.updateEnvMap(t,n),await this.spawnProductVariant(e)}async spawnProductVariant(e){if(!e.productParts)return Promise.reject(!1);for(const t of e.productParts)await this.spawnProductPart(t);return Promise.resolve(!0)}async spawnProductPart(e){let t=this.sceneManager.sceneStructure.getEntityForAssetId(e.assetId);if(!t){const i=this._experienceData.getAssetCollection().getAssetByName(e.asset);if(!i||(await i.load(),t=await this.spawnAssetInScene(i),!t))return Promise.reject(!1)}const n=e.finish;return n?(await t.selectAssetFinish(n),Promise.resolve(!0)):Promise.resolve(!1)}async _fetchExperienceDataConfig(){return null}async _buildExperienceData(){const e=await this._fetchExperienceDataConfig();if(e===null)return await this._onAuthenticationFailed("Unable to retrieve experience data config."),Promise.reject();if(!e.success)return await this._onAuthenticationFailed(e.message),Promise.reject();this._experienceData=new HW({nexusApiResultPayload:e.payload,appWcRef:this}),await this._experienceData.initialize();const t=this._experienceData.channelSettings.ga_measurement_id;!this.gaMeasurementId&&t&&(window.epigraph.logger.info({title:"GA Measurement ID set from experience data",details:t,contextOverride:this._loggerContext}),this.gaMeasurementId=t,this._setupAnalytics())}__checkIfCurrentExperienceHasIdentifier(e,t){let n=!1;switch(e){case"sku":this.experienceData?.productVariantCollection?.getProductVariantBySku(t)&&(n=!0);break;case"shopify_variant_id":this.experienceData?.productVariantCollection?.getProductVariantByShopifyVariantId(t)&&(n=!0);break;case"upc":this.experienceData?.productVariantCollection?.getProductVariantByUpc(t)&&(n=!0);break;case"asin":this.experienceData?.productVariantCollection?.getProductVariantByAsin(t)&&(n=!0);break;case"experience_id":break;case"product_variant_uuid":this.experienceData?.productVariantCollection?.getProductVariantByUuid(t)&&(n=!0);break}return n}__guessesWhyTheExperienceFailed(){const e=[];return this._experienceData.getAssetCollection().hasAnyAssetWithSplat()&&this.productSettings.render.mode!==ga.SPLAT&&e.push("Render Splat provided in one of the assets. Try switching the render mode to Splat in Render Settings."),e}async _clearAndLoadNewExperienceInScene(){this._onNewExperienceLoadStart(),this.__checkIfCurrentExperienceHasIdentifier(this.identifierType,this.identifier)===!1&&await this._buildExperienceData().catch(e=>(window.epigraph.logger.error({title:`Couldn't build experience data for "${this.identifierType}" - "${this.identifier}"`,details:e,contextOverride:this._loggerContext}),Promise.reject(e))),await this._resetSession(),await this._postExperienceDataInitialization().catch(e=>Promise.reject(e)),this.parsedUrlParams.get(td.AR)&&!this.didARAutoLaunch&&(await this.launchAR(),this.didARAutoLaunch=!0),this._onNewExperienceLoadFinish()}async _onIdentifierOrTypeChange(){this.isAppReady&&(await this._resolveIdentifierAndType(),!(!this._identifier||!this._identifierType)&&(window.epigraph.logger.info({title:"IDENTIFIER CHANGED",details:`${this._identifierType} = ${this._identifier}`}),this._nexusAnalyticsPlugin&&(this._nexusAnalyticsPlugin.experienceID=this._identifier),this._ga4AnalyticsPlugin&&(this._ga4AnalyticsPlugin.experienceID=this._identifier),await this._clearAndLoadNewExperienceInScene().catch(e=>(window.epigraph.logger.error({title:"Error while clearing the session and loading a new experience.",details:e}),window.epigraph.logger.warn({title:"BEST GUESSES FOR FAILURE BELOW:",details:this.__guessesWhyTheExperienceFailed(),contextOverride:this._loggerContext}),Promise.reject(e)))))}showCameraInteractionPromptIndicator(){this.cameraInteractionPromptIndicatorElemRef?.classList.add("show")}hideCameraInteractionPromptIndicator(){this.cameraInteractionPromptIndicatorElemRef?.classList.remove("show")}_onPlayInteractionPromptChange(){this.playInteractionPrompt?this.__onPlayInteractionPrompt():(this.hideCameraInteractionPromptIndicator(),this._cameraManager?.mainCameraControls?.stop&&this._cameraManager?.mainCameraControls?.stop())}connectedCallback(){super.connectedCallback(),this._loadTimeBegin=performance.now(),this.parsedUrlParams=It.parseUrlForEpigraphParams(this.baseUrlOverride),this._setupAnalytics()}firstUpdated(){this.modalView&&(this.hide=!0),this._setup().then(()=>{this.featuresToEnable.viewer===!0&&(this._setupResizeObservers(),this.hideSplashScreen()),window.epigraph.logger.info({title:"All Initializations Complete",contextOverride:this._loggerContext}),this.isAppReady=!0,this._onIdentifierOrTypeChange()}).catch(e=>{window.epigraph.logger.error({title:"Error while setup",details:e})})}updated(e){(e.has("sku")||e.has("shopify_variant_id")||e.has("upc")||e.has("asin")||e.has("experience_id")||e.has("product_variant_uuid")||e.has("customVersionId"))&&this._onIdentifierOrTypeChange(),e.has("playInteractionPrompt")&&this._onPlayInteractionPromptChange(),e.has("_isActiveHotspot")&&(this._hasActiveHotspot?this._hideCustomViewInYourSpaceButton():this._showCustomViewInYourSpaceButton()),e.has("debug")&&this.eventsManager.debugChanged.fire({value:this.debug}),e.has("showSettings")&&this.eventsManager.showSettingsChanged.fire({value:this.showSettings}),e.has("modalView")&&(this.hide=this.modalView)}_getSlottedElements(e){if(!this.customViewInYourSpaceButtonSlotElem)return[];const t=e.assignedElements();return[...t.length>0?t:e.children]}disconnectedCallback(){super.disconnectedCallback()}showFullScreenModal(){this.hide=!1}hideFullScreenModal(){this.hide=!0}render(){return ae`
18249
18249
  ${It.getCustomStylesTemplate()}
18250
18250
 
18251
18251
  <epg-button-icon
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epigraph/solutions",
3
- "version": "1.0.20-alpha.1",
3
+ "version": "1.0.21",
4
4
  "type": "module",
5
5
  "main": "./dist/epigraph-solutions.js",
6
6
  "files": [