@epigraph/solutions 1.0.20 → 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.
@@ -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",
3
+ "version": "1.0.21",
4
4
  "type": "module",
5
5
  "main": "./dist/epigraph-solutions.js",
6
6
  "files": [