1import BaseMedia from 'element.base-media' 2import{loadProduct}from 'util.product-loader' 3export class ModelMedia extends BaseMedia{getPlayerTarget(){return new Promise((resolve)=>{this.setAttribute('loaded','') 4const initWhenReady=()=>{window.Shopify.loadFeatures([{name:'shopify-xr',version:'1.0',onLoad:this.setupShopifyXr.bind(this)},{name:'model-viewer-ui',version:'1.0',onLoad:()=>{const modelViewerUi=this.setupModelViewerUi() 5resolve(modelViewerUi)}}])};if(typeof customElements!=='undefined'&&customElements.whenDefined){customElements.whenDefined('model-viewer').then(initWhenReady)}else{initWhenReady()}})} 6playerHandler(target,prop){target[prop]()} 7async setupShopifyXr(){if(!window.ShopifyXR){document.addEventListener('shopify_xr_initialized',this.setupShopifyXr.bind(this))}else{const productJSON=await loadProduct(this.getAttribute('handle')) 8const productModels=productJSON.media.filter((media)=>media.media_type==='model') 9window.ShopifyXR.addModels(productModels) 10window.ShopifyXR.setupXRElements()}} 11setupModelViewerUi(){const modelViewer=this.querySelector('model-viewer') 12if(!modelViewer)return null 13modelViewer.addEventListener('shopify_model_viewer_ui_toggle_play',()=>{this.setAttribute('playing','')}) 14modelViewer.addEventListener('shopify_model_viewer_ui_toggle_pause',()=>{this.removeAttribute('playing')}) 15return new window.Shopify.ModelViewerUI(modelViewer,{focusOnPlay:!1})}} 16customElements.define('model-media',ModelMedia)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.