PageSourceSearch

https://www.bodylab.dk/theme/b15f317276263b8cf3120f98b282bbbe/js/s…/spatial-ar-viewer-plugin.ts.c8ae87.js

js bodylab.dk collected 2026-09-24 17:50:27 UTC 13,318 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["spatial-ar-viewer-plugin.ts"],{682:(e,t,s)=>{s.r(t),s.d(t,{default:()=>v});var i=s(4161);async function r(e){let t=await o(e),s=document.createElement("a");s.innerHTML="<picture></picture>",s.setAttribute("rel","ar"),s.setAttribute("download","model.usdz"),s.setAttribute("href",t),s.style.display="none",document.body.appendChild(s),s.click(),s.remove()}async function o(e){let t=new window.threeJsAddons.USDZExporter,s=await t.parse(e),i=new Blob([s],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(i)}var n=s(9568);async function a(){return await l()||d()}function d(){return document.createElement("a").relList.supports("ar")}async function l(){return!!navigator.xr&&await navigator.xr.isSessionSupported("immersive-ar")}class h{initializeEventListeners(){this.xrLight.addEventListener("estimationstart",this.onEstimationStart.bind(this)),this.xrLight.addEventListener("estimationend",this.onEstimationEnd.bind(this))}onEstimationStart(){this.scene.add(this.xrLight),this.scene.remove(this.defaultLight),this.xrLight.environment&&(this.scene.environment=this.xrLight.environment)}onEstimationEnd(){this.scene.add(this.defaultLight),this.scene.remove(this.xrLight),this.scene.environment=null}dispose(){this.xrLight.removeEventListener("estimationstart",this.onEstimationStart.bind(this)),this.xrLight.removeEventListener("estimationend",this.onEstimationEnd.bind(this))}constructor(e,t){this.scene=e,this.renderer=t,this.defaultLight=new window.threeJs.HemisphereLight(16777215,12303359,1),this.defaultLight.position.set(.5,1,.25),this.scene.add(this.defaultLight),this.xrLight=new window.threeJsAddons.XREstimatedLight(this.renderer),this.initializeEventListeners()}}class c{update(e){return!!(e instanceof XRFrame)&&(this.updateHits(e),this.updateMarker(),this.hitTestSourceRequested||this.requestHitTestSource().then(),!!this.lastHitPose)}updateHits(e){if(!this.hitTestSource)return;let t=e.getHitTestResults(this.hitTestSource);if(t.length){let e=t[0].getPose(this.renderer.xr.getReferenceSpace());this.lastHitPose=e.transform.matrix}else this.lastHitPose=null}updateMarker(){null!==this.lastHitPose?(this.marker.visible=this.markerVisible,this.marker.matrix.fromArray(this.lastHitPose)):this.marker.visible=!1}getHitPose(){return new window.threeJs.Matrix4().fromArray(this.lastHitPose)}hideMarker(){this.markerVisible=!1}showMarker(){this.markerVisible=!0}dispose(){this.hitTestSourceRequested=!1,this.hitTestSource=null,this.marker.visible=!1,this.scene.remove(this.marker)}async requestHitTestSource(){let e=this.renderer.xr.getSession(),t=await e.requestReferenceSpace("viewer");this.hitTestSource=await e.requestHitTestSource({space:t,entityTypes:["plane"]}),this.hitTestSourceRequested=!0}constructor(e,t){this.renderer=e,this.scene=t;let s=new window.threeJs.RingGeometry(.18,.2,32).rotateX(-Math.PI/2),i=new window.threeJs.MeshBasicMaterial;this.marker=new window.threeJs.Mesh(s,i),this.marker.matrixAutoUpdate=!1,this.marker.visible=!1,this.scene.add(this.marker),this.lastHitPose=null,this.hitTestSource=null,this.hitTestSourceRequested=!1}}class m{update(e){return this.webXrHitTest.update(e)}placeObject(){let e=this.webXrHitTest.getHitPose();e&&(this.model.position.setFromMatrixPosition(e),this.model.visible=!0,this.placed=!0,this.webXrHitTest.hideMarker())}resetPlacement(){this.model.visible=!1,this.webXrHitTest.showMarker()}dispose(){this.webXrHitTest.dispose()}constructor(e,t,s){this.renderer=e,this.scene=t,this.model=s,this.model.visible=!1,this.placed=!1,this.selectedObject=null,this.webXrHitTest=new c(this.renderer,this.scene),this.raycaster=new window.threeJs.Raycaster}}class u{sessionStarted(){this.overlay.classList.remove(u.options.classes.loading),this.overlay.classList.add(u.options.classes.sessionRunning)}sessionEnded(){this.overlay.classList.remove(u.options.classes.sessionRunning),this.overlay.classList.remove(u.options.classes.visible),this.overlay.classList.remove(u.options.classes.loading),this.overlay.classList.remove(u.options.classes.placementHint),this.overlay.classList.remove(u.options.classes.tracking)}trackingStarted(){this.overlay.classList.add(u.options.classes.tracking)}
1get element(){return this.overlay}addExitListener(e){this.exitButton.addEventListener("click",e)}removeExitListener(e){this.exitButton.removeEventListener("click",e)}startProgress(){this.progress=0;let e=setInterval(()=>{this.progress+=1,this.progressBar.style.width="".concat(this.progress,"%"),this.progressBar.setAttribute("aria-valuenow","".concat(this.progress)),this.progress>=100&&(clearInterval(e),this.overlay.classList.remove(u.options.classes.placementHint))},u.options.placementHintTimeout/100)}constructor(e){this.progress=0,this.overlay=e,this.overlay.classList.add(u.options.classes.visible),this.overlay.classList.add(u.options.classes.loading),this.overlay.classList.add(u.options.classes.placementHint),this.exitButton=this.overlay.querySelector(u.options.exitButton),this.progressBar=this.overlay.querySelector(u.options.progressBar),this.startProgress()}}u.options={overlay:"[data-spatial-ar-overlay]",exitButton:"[data-spatial-ar-overlay-exit]",progressBar:"[data-spatial-ar-overlay-progress]",classes:{visible:"is--visible",loading:"is--loading",placementHint:"is--placement-hint",tracking:"is--tracking",sessionRunning:"is--session-running"},placementHintTimeout:3e3};class w{render(e,t){if(this.objectPlacement.update(t)){var s;(s=this.overlay)===null||void 0===s||s.trackingStarted()}this.renderer.render(this.scene,this.camera)}endSession(){this.session.end().then()}async onSessionStarted(e){var t;this.session=e,this.session.addEventListener("end",this.onSessionEnded.bind(this));let s=((t=this.session.enabledFeatures)===null||void 0===t?void 0:t.includes("local-floor"))?"local-floor":"local";this.renderer.xr.setReferenceSpaceType(s),await this.renderer.xr.setSession(this.session),this.renderer.xr.getReferenceSpace().addEventListener("reset",this.objectPlacement.resetPlacement.bind(this.objectPlacement)),this.renderer.setAnimationLoop(this.render.bind(this)),this.overlay.sessionStarted()}onSessionEnded(){this.renderer.setAnimationLoop(null),this.objectPlacement.dispose(),this.session.removeEventListener("end",this.onSessionEnded.bind(this)),this.session.end(),this.overlay.sessionEnded(),this.lighting.dispose()}constructor(e,t){var s,i;this.overlay=t?new u(t):null,this.camera=new window.threeJs.PerspectiveCamera(75,window.innerWidth/window.innerHeight,.1,1e3),this.camera.position.set(0,1.6,3),this.scene=new window.threeJs.Scene,this.model=e,this.model.visible=!1,this.scene.add(this.model),this.renderer=new window.threeJs.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.xr.enabled=!0,document.body.appendChild(this.renderer.domElement),(s=this.overlay)===null||void 0===s||s.removeExitListener(this.endSession.bind(this)),(i=this.overlay)===null||void 0===i||i.addExitListener(this.endSession.bind(this)),this.objectPlacement=new m(this.renderer,this.scene,this.model),this.lighting=new h(this.scene,this.renderer),this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",this.objectPlacement.placeObject.bind(this.objectPlacement)),navigator.xr.requestSession("immersive-ar",{requiredFeatures:["local","hit-test"],optionalFeatures:["light-estimation","local-floor","dom-overlay"],domOverlay:{root:this.overlay.element}}).then(this.onSessionStarted.bind(this))}}var p=s(6896);class v extends n.Z{async init(){await (0,p.n)(),this.modelUrl=this.options.modelUrl,this.supportsAr=await a(),this.modelUrl&&(this.objectLoader=new i.Z,this.objectLoader.loadSingleObjectByUrl(this.modelUrl,{center:!0,clampSize:!1}).then(e=>{this.model=e,this.onReady()}),this.el.addEventListener("click",()=>{this.startARView().then()}))}async startARView(){if(!this.model||!this.supportsAr){var e,t,s,i;let r;null==(r=((e=this.options)===null||void 0===e?void 0:e.spatialArId)?(s=document.querySelector(".ar-qr-modal [data-ar-model-id='".concat((i=this.options)===null||void 0===i?void 0:i.spatialArId,"']")))===null||void 0===s?void 0:s.closest(".ar-qr-modal"):document.querySelector(".ar-qr-modal"))||(t=r.closest("body"))===null||void 0===t||t.appendChild(r),r&&new bootstrap.Modal(r).show();return}if(await l()){this.startWebXRView();return}if(d()){this.startIOSQuickLook();return}}startIOSQuickLook(){r(this.model).then()}startWebXRView(){let e=this.el.parentElement.querySelector("[data-spatial-ar-overlay]");new w(this.model,e)}onReady(){var e,t,s,i,r,o,n;this.el.classList.add("spatial-ar-ready");let a=new URLSearchParams(window.location.search);if(a.has("autostartAr")&&((e=this.options)===null||void 0===e?void 0:e.spatialArId)&&null==window.autostartingARView&&a.get("autostartAr")==((t=this.options)===null||void 0===t?void 0:t.spatialArId)){if(window.autostartingARView=!0,!((s=this.options)===null||void 0===s?void 0:s.spatialArId))return;let e=(i=document.querySelector(".ar-qr-modal-open-session [data-modal-open-ar-session-autostart='".concat((r=this.options)===null||void 0===r?void 0:r.spatialArId,"']")))===null||void 0===i?void 0:i.closest(".ar-qr-modal-open-session");if(!e)return;(o=e.getElementsByClassName("ar-btn-open-session")[0])===null||void 0===o||o.addEventListener("click",()=>{this.startARView().then()}),null==e||(n=e.closest("body"))===null||void 0===n||n.appendChild(e),new bootstrap.Modal(e).show()}}}},4161:(e,t,s)=>{s.d(t,{Z:()=>r});var i=s(9138);class r{async loadSingleObjectByUrl(e,t){this.loadStatus.set(e,0),this.emitLoadingUpdate();let s=await new Promise((t,s)=>{this.gltfLoader.load(e,s=>{this.loadStatus.set(e,1),this.emitLoadingUpdate(),t(s.scene)},t=>{this.loadStatus.set(e,t.loaded/t.total),this.emitLoadingUpdate()},t=>{this.loadStatus.set(e,-1),this.emitLoadingUpdate(),s(t)})});return t.clampSize&&(s=this.clampSize(s,t.clampMaxSize)),t.center&&(s=this.centerObject(s)),s}centerObject(e){let t=new window.threeJs.Box3().setFromObject(e).getCenter(new window.threeJs.Vector3);e.position.copy(t),e.position.multiplyScalar(-1);let s=new window.threeJs.Group;return s.name="centered",s.add(e),s}clampSize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{x:1,y:1,z:1},s=new window.threeJs.Box3().setFromObject(e).getSize(new window.threeJs.Vector3),i=Math.max(s.x*(1/t.x),s.y*(1/t.y),s.z*(1/t.z));return e.scale.multiplyScalar(1/i),e}percentageLoaded(){let e=0,t=0;
1return this.loadStatus.forEach(s=>{t+=s,e++}),t/e}detailLoaded(){return this.loadStatus}emitLoadingUpdate(){this.$emitter&&this.$emitter.publish("ObjectLoaderUtil/loadingUpdate",{percentage:this.percentageLoaded(),detailed:this.detailLoaded()})}constructor(e){this.gltfLoader=new window.threeJsAddons.GLTFLoader;let t=new window.threeJsAddons.DRACOLoader;t.setDecoderPath("".concat(window.themeAssetsPublicPath,"draco/")),this.gltfLoader.setDRACOLoader(t),this.loadStatus=new Map,(null==e?void 0:e.$emitter)instanceof i.Z&&(this.$emitter=null==e?void 0:e.$emitter)}}},6896:(e,t,s)=>{s.d(t,{n:()=>i});async function i(){var e,t,i,r,o,n;if(window.loadThreeJsUtil||(window.loadThreeJsUtil={isLoaded:!1,promise:null,promiseResolve:null}),!window.loadThreeJsUtil.isLoaded){if(window.loadThreeJsUtil.promise){await window.loadThreeJsUtil.promise;return}if(window.loadThreeJsUtil.promise=new Promise(e=>{window.loadThreeJsUtil.promiseResolve=e}),window.threeJs||(window.threeJs=await s.e("vendors-node_modules_three_build_three_module_js").then(s.bind(s,6173))),window.threeJsAddons||(window.threeJsAddons={}),!((e=window.threeJsAddons)===null||void 0===e?void 0:e.OrbitControls)){let{OrbitControls:e}=await Promise.all([s.e("vendors-node_modules_three_build_three_module_js"),s.e("vendors-node_modules_three_examples_jsm_controls_OrbitControls_js")]).then(s.bind(s,6976));window.threeJsAddons.OrbitControls=e}if(!((t=window.threeJsAddons)===null||void 0===t?void 0:t.USDZExporter)){let{USDZExporter:e}=await Promise.all([s.e("vendors-node_modules_three_build_three_module_js"),s.e("vendors-node_modules_three_examples_jsm_exporters_USDZExporter_js")]).then(s.bind(s,3707));window.threeJsAddons.USDZExporter=e}if(!((i=window.threeJsAddons)===null||void 0===i?void 0:i.XREstimatedLight)){let{XREstimatedLight:e}=await Promise.all([s.e("vendors-node_modules_three_build_three_module_js"),s.e("node_modules_three_examples_jsm_webxr_XREstimatedLight_js")]).then(s.bind(s,6874));window.threeJsAddons.XREstimatedLight=e}if(!((r=window.threeJsAddons)===null||void 0===r?void 0:r.GLTFLoader)){let{GLTFLoader:e}=await Promise.all([s.e("vendors-node_modules_three_build_three_module_js"),s.e("vendors-node_modules_three_examples_jsm_loaders_GLTFLoader_js")]).then(s.bind(s,1990));window.threeJsAddons.GLTFLoader=e}if(!((o=window.threeJsAddons)===null||void 0===o?void 0:o.DRACOLoader)){let{DRACOLoader:e}=await Promise.all([s.e("vendors-node_modules_three_build_three_module_js"),s.e("node_modules_three_examples_jsm_loaders_DRACOLoader_js")]).then(s.bind(s,5157));window.threeJsAddons.DRACOLoader=e}((n=window.threeJsAddons)===null||void 0===n?void 0:n.DRACOLibPath)||(window.threeJsAddons.DRACOLibPath="three/examples/jsm/libs/draco/"),window.loadThreeJsUtil.promiseResolve(),window.loadThreeJsUtil.isLoaded=!0}}}}]);

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.