Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lumiscaphe/viewer

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lumiscaphe/viewer - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

LICENSE.md

2

dist/index.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lodash.clonedeep"),require("debounce-promise"),require("twgl.js"),require("axios")):"function"==typeof define&&define.amd?define(["lodash.clonedeep","debounce-promise","twgl.js","axios"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).LumiscapheViewer=e(t.cloneDeep,t.debounce,t.twgl,t.axios)}(this,(function(t,e,i,n){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=o(t),a=o(e),s=o(i),h=o(n),c=function(){};c.fit=function(t,e,i,n){var o=t.width/t.height,r=e/i,a=0,s=0;switch(n){case"contain":a=r<o?e:i*o,s=r<o?e/o:i;break;case"cover":default:a=r<o?i*o:e,s=r<o?i:e/o;break;case"fill":a=e,s=i}return{width:Math.round(a),height:Math.round(s),top:Math.round((i-s)/2),left:Math.round((e-a)/2)}},c.getStandardAspectRatio=function(t,e){if(0===t||0===e)return 0;var i=t/e;return t<e?Math.abs(3/4-i)<Math.abs(9/16-i)?3/4:9/16:Math.abs(4/3-i)<Math.abs(16/9-i)?4/3:16/9},c.getStandardQuality=function(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080},c.getStandardResolution=function(t,e){if(0===t||0===e)return{width:0,height:0};var i=c.getStandardAspectRatio(t,e);if(t<e){var n=c.getStandardQuality(e*i);return{width:Math.round(n),height:Math.round(n/i)}}var o=c.getStandardQuality(t/i);return{width:Math.round(o*i),height:Math.round(o)}};var d=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=this.element.getContext("2d"),this.backCanvas=document.createElement("canvas"),this.backContext=this.backCanvas.getContext("2d"),this.requestAnimationId=null};d.prototype.show=function(t){t?this.element.style.display="block":this.element.style.opacity=1},d.prototype.hide=function(t){t?this.element.style.display="none":this.element.style.opacity=0},d.prototype.resize=function(t,e,i){var n=c.fit(i,t,e,"cover");this.element.style.width=n.width+"px",this.element.style.height=n.height+"px",this.element.style.top=n.top+"px",this.element.style.left=n.left+"px",i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height,this.backCanvas.width=i.width,this.backCanvas.height=i.height)},d.prototype.load=function(t){var e=this,i=new Image;i.onload=function(){e.draw(i,!1)},i.src=t},d.prototype.draw=function(t,e,i){t&&(this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=null),e?(this.backContext.drawImage(this.element,0,0,this.element.width,this.element.height),this.context.globalAlpha=0,this.fadeLoop(t,i)):(this.context.globalAlpha=1,this.context.drawImage(t,0,0,this.element.width,this.element.height)))},d.prototype.fadeLoop=function(t,e){var i=this;if(this.context.globalAlpha>=1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=null);var n=Math.min(this.context.globalAlpha+e,1);this.context.clearRect(0,0,this.element.width,this.element.height),this.context.globalAlpha=1,this.context.drawImage(this.backCanvas,0,0,this.element.width,this.element.height),this.context.globalAlpha=n,this.context.drawImage(t,0,0,this.element.width,this.element.height),this.requestAnimationId=requestAnimationFrame((function(){i.fadeLoop(t,e)}))};var u=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=s.default.getContext(this.element,{preserveDrawingBuffer:!0}),s.default.setDefaultTextureColor([1,1,1,1]),this.requestAnimationId=null};u.prototype.show=function(){this.element.style.opacity=1},u.prototype.hide=function(){this.element.style.opacity=0},u.prototype.resize=function(){this.element.style.width="100%",this.element.style.height="100%",this.element.style.top=0,this.element.style.left=0};var l=function(){};l.accelerate=function(t,e){var i=e||1.5;return Math.pow(Math.abs(t),i)*(t>0?1:-1)},l.degreesToRadians=function(t){return t*(Math.PI/180)},l.radiansToDegrees=function(t){return t*(180/Math.PI)},l.mod=function(t,e){return t-e*Math.floor(t/e)};var p=/directUrl="([^"]*)"/g,m=function(t){this.server=t};m.buildQuery=function(t){return Object.keys(t).filter((function(e){return void 0!==t[e]})).map((function(e){return e+"="+t[e]})).join("&")},m.sceneParameters=function(t){var e=t.scene,i=e.length>1?e.find((function(t){return t.accessory})):null,n=e.length>1?e.find((function(t){return t.decor})):null,o=e.find((function(t){return t!==i&&t!==n})),r={databaseId:o.database};return o.configuration&&(r.configuration=o.configuration),o.animations&&o.animations.length&&(r.animations=o.animations.join("/")),i&&(r.accessoryDatabaseId=i.database),n&&(r.decorDatabaseId=n.database,r.decorDeltaAltitude=n.translation.y),r},m.renderParameters=function(t){var e=t.parameters;return{width:e.width,height:e.height,softwareAntialiasing:e.antialiasing,superSampling:e.superSampling}},m.encoderParameters=function(t){var e=t.encoder;return{imageFormat:e.format,imageQuality:e.quality}},m.fetch=function(t){return h.default.get(t).then((function(t){var e=t.data.replace(/&amp;/g,"&").match(p);return e?e.map((function(t){return t.replace(p,"$1")})):Promise.reject()}))},m.prototype.animation=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],frames:t.view.frames,loop:!!t.view.loop,background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return m.fetch(this.server+"/ImagesFromAnimation?"+i)},m.prototype.image=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return Promise.resolve(this.server+"/ImageFromBookmark?"+i)},m.prototype.video=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],duration:t.view.duration,frames:t.view.frames,loop:!!t.view.loop,reverse:!!t.view.reverse,background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return Promise.resolve(this.server+"/ImagesFromAnimation?"+i)},m.prototype.vrCube=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t)),e.width=Math.max(e.width,e.height),e.height=Math.max(e.width,e.height);var i=m.buildQuery(e);return m.fetch(this.server+"/CubeFromBookmark?"+i)},m.prototype.vrObject=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera,background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return m.fetch(this.server+"/ImagesFromBookmarkSet?"+i)};var v=function(t){this.server=t};v.snapshotBody=function(t){var e={};return e.scene=t.scene.map((function(t){t.accessory,t.decor;return function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(i[n]=t[n]);return i}(t,["accessory","decor"])})),e.mode={},e.renderParameters=Object.assign({},t.parameters),e.renderParameters.superSampling=e.renderParameters.superSampling.toString(),e.encoder={},e.encoder[t.encoder.format]={quality:t.encoder.quality,compression:t.encoder.compression},e},v.fetch=function(t,e){return h.default.post(t,e).then((function(t){return Array.isArray(t.data)?t.data.map((function(t){return t.url})):t.data.url}))},v.prototype.image=function(t){var e=v.snapshotBody(t);return e.mode.image={camera:t.view.camera},v.fetch(this.server+"/Snapshot",e)},v.prototype.vrCube=function(t){var e=v.snapshotBody(t);e.mode.vrCube={camera:t.view.camera};var i=e.renderParameters;return e.renderParameters.width=Math.max(i.width,i.height),e.renderParameters.height=Math.max(i.width,i.height),v.fetch(this.server+"/Snapshot",e)},v.prototype.vrObject=function(t){var e=v.snapshotBody(t);return t.view.camera?e.mode.vrObject={camera:t.view.camera,frames:t.view.frames}:t.view.cameraGroup&&(e.mode.images={cameraGroup:t.view.cameraGroup}),v.fetch(this.server+"/Snapshot",e)},v.prototype.animation=function(t){var e=v.snapshotBody(t);return e.mode.animation={id:t.view.animation,camera:t.view.camera,fps:t.view.fps},v.fetch(this.server+"/Snapshot",e)};var f=function(t,e,i){switch(e){case"v1":this.webrender=new m(t);break;case"v2":this.webrender=new v(t);break;default:this.webrender=new m(t)}this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i&&i.onLoadStart?i.onLoadStart:function(){},this.onLoadProgress=i&&i.onLoadProgress?i.onLoadProgress:function(){},this.onLoadEnd=i&&i.onLoadEnd?i.onLoadEnd:function(){}},g={progress:{configurable:!0}};g.progress.get=function(){return this.total?this.loaded/this.total:0},f.prototype.loadImage=function(t,e){var i=this,n=new Image;n.crossOrigin="anonymous";var o=new Promise((function(t,o){n.addEventListener("load",(function(){e===i.loadingId&&(i.loaded+=1,i.onLoadProgress(i.progress),t(n))}),{once:!0}),n.addEventListener("error",(function(t){e===i.loadingId&&o(t)}),{once:!0})}));return n.src=t,o},f.prototype.loadImageFrames=function(t,e,i,n){var o=this;this.total=t.length;for(var r=new Array(t.length),a=i||0,s=0,h=t.length;s<h;s+=1){var c=Math.ceil(s/2)*(s%2==0?1:-1),d=e?l.mod(a+c,h):s;r[d]=this.loadImage(t[d],n)}return Promise.all(r).then((function(){return o.onLoadEnd(o.progress)})),r},f.prototype.loadVideo=function(t,e,i,n){var o=this;t.loop=i;var r=new Promise((function(e,i){t.addEventListener("canplaythrough",(function(){n===o.loadingId&&(o.loaded+=1,o.onLoadProgress(o.progress),e())}),{once:!0}),t.addEventListener("error",(function(t){n===o.loadingId&&i(t)}),{once:!0})}));return t.src=e,t.load(),r},f.prototype.loadVideoFrame=function(t,e,i,n,o){var r=this,a=0;return new Promise((function(s,h){var c=function(){if(o===r.loadingId)if(a===n){t.removeEventListener("seeked",c);var h=document.createElement("canvas");h.width=t.videoWidth,h.height=t.videoHeight,h.getContext("2d").drawImage(t,0,0),s(h),r.loaded+=1,r.onLoadProgress(r.progress),n!==i-1&&(t.currentTime+=1/e)}else a+=1};t.addEventListener("seeked",c),t.addEventListener("error",(function(t){o===r.loadingId&&h(t)}),{once:!0})}))},f.prototype.loadVideoFrames=function(t,e,i,n){var o=this;this.total=e;for(var r=new Array(e),a=document.createElement("video"),s=0,h=e;s<h;s+=1)r[s]=this.loadVideoFrame(a,i,e,s,n);return a.addEventListener("canplaythrough",(function(){n===o.loadingId&&(a.currentTime=1/i/2)}),{once:!0}),a.src=t,a.load(),Promise.all(r).then((function(){return o.onLoadEnd(o.progress)})),r},f.prototype.loadImageSnapshot=function(t){var e=this;this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);var i=this.loadingId;return this.webrender.image(t).then((function(t){return e.loadImage(t,i)})).then((function(t){return e.onLoadEnd(e.progress),t}))},f.prototype.loadVideoSnapshot=function(t,e){var i=this;this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);var n=this.loadingId;return this.webrender.video(e).then((function(o){return i.loadVideo(t,o,e.view.loop,n)})).then((function(){return i.onLoadEnd(i.progress),t}))},f.prototype.loadVRCubeSnapshot=function(t){var e=this;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);var i=this.loadingId;return this.webrender.vrCube(t).then((function(t){e.total=t.length;var n=t.map((function(t){return e.loadImage(t,i)}));return Promise.all(n)})).then((function(t){return e.onLoadEnd(e.progress),t}))},f.prototype.loadVRObjectSnapshot=function(t,e){var i=this;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);var n,o=this.loadingId;return n=t.view.animation?"mp4"===t.encoder.format?"video":"animation":"vrObject",this.webrender[n](t).then((function(n){return Array.isArray(n)?i.loadImageFrames(n,t.view.loop,e,o):i.loadVideoFrames(n,t.view.frames,30,o)}))},Object.defineProperties(f.prototype,g);var y=function(){this.element=document.createElement("video"),this.element.classList.add("ls-viewer-video"),this.element.style.opacity=0,this.element.setAttribute("muted",""),this.element.setAttribute("playsinline",""),this.element.setAttribute("preload","auto")};y.prototype.show=function(){this.element.style.opacity=1},y.prototype.hide=function(){this.element.style.opacity=0},y.prototype.resize=function(t,e,i){var n=c.fit(i,t,e,"cover");this.element.style.width=n.width+"px",this.element.style.height=n.height+"px",this.element.style.top=n.top+"px",this.element.style.left=n.left+"px",i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height)};var w=function(t,e,i,n){this.container=t,this.canvas=e,this.loader=i,this.options=Object.assign({},n),this.image=null,this.goto=function(){},this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};w.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-image")},w.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-image")},w.prototype.load=function(t,e,i){var n=this,o=JSON.stringify(t);return o===this.hash?(this.canvas.draw(this.image,i,.05),Promise.resolve()):(this.hash=o,this.loader.loadImageSnapshot(t).then((function(t){n.image=t,n.canvas.draw(n.image,i,.05)})))};var b=function(t,e,i,n){this.container=t,this.loader=i,this.options=Object.assign({},n),this.video=e,this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};b.prototype.show=function(){this.video.show(),this.container.classList.add("ls-viewer-container-video")},b.prototype.hide=function(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")},b.prototype.load=function(t){var e=JSON.stringify(t);return e===this.hash?(this.video.load(),Promise.resolve()):(this.hash=e,this.loader.loadVideoSnapshot(this.video.element,t))},b.prototype.play=function(){var t=this;return new Promise((function(e,i){t.video.element.addEventListener("ended",(function(){e()}),{once:!0});var n=t.video.element.play();n&&n.catch((function(){i()})),t.show()}))};var E=function(){};E.point=function(t){if("touchmove"===t.type||"touchstart"===t.type||"touchend"===t.type){var e=t.targetTouches[0]||t.changedTouches[0];return{x:e.screenX,y:e.screenY}}return{x:t.screenX,y:t.screenY}};var P=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];3===e.length?(t=e,this.u=t[0],this.v=t[1],this.o=t[2],this.w=i.v3.cross(this.u,this.v)):(this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0])},L={localToGlobalMatrix:{configurable:!0},globalToLocalMatrix:{configurable:!0}};L.localToGlobalMatrix.get=function(){var t=[this.u[0],this.u[1],this.u[2],0],e=[this.v[0],this.v[1],this.v[2],0],i=[this.w[0],this.w[1],this.w[2],0],n=[this.o[0],this.o[1],this.o[2],1];return[].concat.apply([],[t,e,i,n])},L.globalToLocalMatrix.get=function(){return i.m4.inverse(this.localToGlobalMatrix)},Object.defineProperties(P.prototype,L);var x=function(t){this.animationFrameId=null,this.points=[],this.onMotion=t,this.loop=this.loop.bind(this)};x.prototype.track=function(t){var e=Date.now();this.points=this.points.filter((function(t){return e-t.time<=100})),this.points.push({x:t.x,y:t.y,time:e}),this.lastPoint=t},x.prototype.start=function(){if(0!==this.points.length){var t=this.points[0],e=this.points[this.points.length-1],i=e.x-t.x,n=e.y-t.y,o=e.time-t.time;this.velocity={x:0===o?0:i/(o/15),y:0===o?0:n/(o/15)},this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.animationFrameId=requestAnimationFrame(this.loop)}},x.prototype.stop=function(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.points=[]},x.prototype.loop=function(){if(Math.abs(this.velocity.x)<1&&Math.abs(this.velocity.y)<1)return this.animationFrameId=null,void(this.points=[]);this.lastPoint.x+=this.velocity.x,this.lastPoint.y+=this.velocity.y,this.velocity.x*=.9,this.velocity.y*=.9,this.onMotion(this.lastPoint),this.animationFrameId=requestAnimationFrame(this.loop)};var I=function(t,e,n){this.isStarted=!1,this.inertia=new x(this.motion.bind(this)),this.pov=t,this.fov=l.degreesToRadians(e),this.orientationMatrix=i.m4.identity(),this.initPov=this.pov,this.initFov=this.fov,this.initOrientation=l.degreesToRadians(window.orientation)||0,this.onMotion=n},S={orientedPov:{configurable:!0}};S.orientedPov.get=function(){var t=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),e=new P(t,[0,1,0],this.pov.eye),n=i.m4.identity();return i.m4.multiply(n,e.localToGlobalMatrix,n),i.m4.multiply(n,this.orientationMatrix,n),i.m4.multiply(n,e.globalToLocalMatrix,n),{eye:Array.from(this.pov.eye),target:Array.from(i.m4.transformDirection(n,this.pov.target)),up:Array.from(i.m4.transformDirection(n,this.pov.up))}},I.prototype.reset=function(){this.pov={eye:Array.from(this.initPov.eye),target:Array.from(this.initPov.target),up:Array.from(this.initPov.up)},this.fov=this.initFov},I.prototype.start=function(t,e){this.isStarted=!0,this.startPov=this.pov,this.startPoint=t,this.startSize=e,this.previousPoint=t,this.inertia.stop()},I.prototype.motion=function(t){this.isStarted&&this.inertia.track(t);var e={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},n=l.accelerate(e.x,1.3)/this.startSize.width*.2*Math.PI*1.5,o=l.accelerate(e.y,1.3)/this.startSize.height*.2*Math.PI,r=i.m4.multiply(i.m4.rotationY(-n),i.m4.rotationX(-o)),a=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),s=new P(a,[0,1,0],this.pov.eye),h=i.m4.identity();i.m4.multiply(h,s.localToGlobalMatrix,h),i.m4.multiply(h,r,h),i.m4.multiply(h,s.globalToLocalMatrix,h);var c=i.m4.transformPoint(h,this.pov.target),d=i.m4.transformDirection(h,this.pov.up);i.v3.cross(d,[0,0,1])[0]>=0&&(this.pov.target=Array.from(c),this.pov.up=Array.from(d)),this.previousPoint={x:t.x,y:t.y},this.onMotion()},I.prototype.end=function(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())},I.prototype.orientation=function(t){if(null!==t.alpha&&null!==t.beta&&null!==t.gamma){var e=l.degreesToRadians(window.orientation)||0,n=l.degreesToRadians(t.alpha),o=l.degreesToRadians(-t.beta),r=l.degreesToRadians(-t.gamma),a=i.m4.rotationX(l.degreesToRadians(90));i.m4.rotateZ(a,this.initOrientation,a),i.m4.rotateZ(a,n,a),i.m4.rotateX(a,o,a),i.m4.rotateY(a,r,a),i.m4.rotateZ(a,-e,a),this.orientationMatrix=a,this.onMotion()}},Object.defineProperties(I.prototype,S);var A=function(t,e,i,n,o){var r=this;this.container=t,this.canvas=e,this.loader=i,this.options=Object.assign({},n);var a={eye:[0,0,0],target:[0,0,1],up:[0,1,0]},h=s.default.m4.rotationX(l.degreesToRadians(15));s.default.m4.transformDirection(h,a.target,a.target),s.default.m4.transformDirection(h,a.up,a.up),this.interaction=new I(a,60,(function(){requestAnimationFrame(r.render),r.onInteraction({pov:{eye:[].concat(r.interaction.pov.eye),target:[].concat(r.interaction.pov.target),up:[].concat(r.interaction.pov.up)},fov:r.interaction.fov})})),this.onInteraction=o,this.gl=this.canvas.context,this.programInfo=s.default.createProgramInfo(this.gl,["attribute vec4 position;uniform mat4 u_matrix;varying vec3 direction;void main(){direction=(u_matrix*position).xyz;gl_Position=position*vec4(-1,1,1,1);}\n","precision mediump float;uniform float u_mix;uniform samplerCube u_texture;uniform samplerCube u_texture_back;varying vec3 direction;void main(){vec4 backColor=textureCube(u_texture_back,direction);vec4 color=textureCube(u_texture,direction);gl_FragColor=mix(backColor,color,u_mix);}\n"]),this.quad=s.default.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:s.default.m4.identity(),u_mix:0,u_texture_back:s.default.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:s.default.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1})},this.render=this.render.bind(this),this.goto=function(){}},k={pov:{configurable:!0},fov:{configurable:!0}};A.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")},A.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")},k.pov.get=function(){return this.interaction.pov},k.pov.set=function(t){this.interaction.pov.eye.every((function(e,i){return e===t.eye[i]}))&&this.interaction.pov.target.every((function(e,i){return e===t.target[i]}))&&this.interaction.pov.up.every((function(e,i){return e===t.up[i]}))||(this.interaction.pov={eye:[].concat(t.eye),target:[].concat(t.target),up:[].concat(t.up)},requestAnimationFrame(this.render))},k.fov.get=function(){return l.radiansToDegrees(this.interaction.fov)},k.fov.set=function(t){this.interaction.fov!==t&&(this.interaction.fov=l.degreesToRadians(t),requestAnimationFrame(this.render))},A.prototype.load=function(t,e,i){var n=this,o=JSON.stringify(t);return o===this.hash?(requestAnimationFrame(this.render),Promise.resolve()):(this.hash=o,this.images=[],requestAnimationFrame(this.render),this.loader.loadVRCubeSnapshot(t).then((function(t){n.images=t,s.default.createTexture(n.gl,{target:n.gl.TEXTURE_CUBE_MAP,minMag:n.gl.LINEAR,auto:!1,cubeFaceOrder:[n.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,n.gl.TEXTURE_CUBE_MAP_POSITIVE_X,n.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,n.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,n.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,n.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y],src:t},(function(t,o){t||(e&&n.interaction.reset(),n.uniforms.u_mix=i?0:1,n.uniforms.u_texture_back=n.uniforms.u_texture,n.uniforms.u_texture=o,requestAnimationFrame(n.render))}))})))},A.prototype.render=function(){s.default.resizeCanvasToDisplaySize(this.gl.canvas,window.devicePixelRatio),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var t=this.gl.canvas.clientWidth,e=this.gl.canvas.clientHeight,i=c.getStandardAspectRatio(t,e),n=t/e,o=this.interaction.fov*(i/n),r=s.default.m4.inverse(s.default.m4.perspective(o,n,.5,100)),a=this.interaction.orientedPov,h=s.default.m4.lookAt(a.eye,a.target,a.up);this.uniforms.u_matrix=s.default.m4.multiply(h,r),this.gl.useProgram(this.programInfo.program),s.default.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),s.default.setUniforms(this.programInfo,this.uniforms),s.default.drawBufferInfo(this.gl,this.quad),this.uniforms.u_mix<1&&(this.uniforms.u_mix=Math.min(this.uniforms.u_mix+.05,1),requestAnimationFrame(this.render))},A.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(E.point(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})},A.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(E.point(t),!1))},A.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(E.point(t)),t.preventDefault())},A.prototype.onEnd=function(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(E.point(t),!0))},A.prototype.onDeviceOrientation=function(t){this.interaction.orientation({alpha:t.alpha,beta:t.beta,gamma:t.gamma})},Object.defineProperties(A.prototype,k);var M=function(t,e,i,n){this.isStarted=!1,this.inertia=new x(this.motion.bind(this)),this.position=t,this.count=e,this.loop=i,this.onMotion=n,this.initPosition=this.position};M.prototype.reset=function(){this.position=this.initPosition},M.prototype.start=function(t,e){this.isStarted=!0,this.startPosition=this.position,this.startPoint=t,this.startSize=e,this.inertia.stop()},M.prototype.motion=function(t){this.isStarted&&this.inertia.track(t);var e={x:t.x-this.startPoint.x,y:t.y-this.startPoint.y},i=l.accelerate(e.x,1.3)/this.startSize.width*(this.count/4),n=this.startPosition-Math.round(i);(n=this.loop?l.mod(n,this.count):Math.max(0,Math.min(n,this.count-1)))!==this.position&&(this.position=n,this.onMotion())},M.prototype.end=function(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())};var j=function(t,e,i,n,o){var r=this;this.container=t,this.canvas=e,this.loader=i,this.options=Object.assign({},{loop:!0},n),this.images=[],this.interaction=new M(0,1,!1,(function(){r.canvas.draw(r.image,!0,.5),r.onInteraction({position:r.interaction.position})})),this.onDeviceOrientation=function(){},this.onInteraction=o},O={position:{configurable:!0},image:{configurable:!0}};j.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrobject")},j.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrobject")},O.position.get=function(){return this.interaction.position},O.position.set=function(t){this.interaction.position!==t&&(this.interaction.loop?this.interaction.position=l.mod(t,this.interaction.count):this.interaction.position=Math.max(0,Math.min(t,this.interaction.count-1)),this.canvas.draw(this.image,!0,.5))},j.prototype.goto=function(t){var e=this;return new Promise((function(i){var n=e.interaction.position,o=function(){if(e.interaction.position===t)i();else{var r=n>t?-1:1;e.interaction.loop&&e.interaction.count-n+t<Math.abs(t-n)&&(r*=-1),n+=.5*r,e.position=Math.floor(n),requestAnimationFrame(o)}};requestAnimationFrame(o)}))},O.image.get=function(){return this.images[this.interaction.position]},j.prototype.load=function(t,e,i){var n=this,o=JSON.stringify(t);if(o===this.hash)return this.canvas.draw(this.image,i,.05),Promise.resolve();this.hash=o,this.images=[],e&&this.interaction.reset();var r=this.interaction.position;return this.loader.loadVRObjectSnapshot(t,r).then((function(e){var o=e.length;return n.images=new Array(o),n.interaction.count=o,n.interaction.loop=!!t.view.loop,e.forEach((function(t,e){t.then((function(t){n.images[e]=t,t===n.image&&n.canvas.draw(n.image,i,.05)}))})),e[n.interaction.position]}))},j.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(E.point(t),{width:this.canvas.element.width,height:this.canvas.element.height})},j.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(E.point(t),!1))},j.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(E.point(t)),t.preventDefault())},j.prototype.onEnd=function(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(E.point(t),!0))},Object.defineProperties(j.prototype,O);!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".ls-viewer-container{display:block;position:relative;overflow:hidden;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%;height:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{position:absolute;opacity:0;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");var T=function(t,e){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onResize=this.onResize.bind(this),this.onStart=this.onStart.bind(this),this.onEnter=this.onEnter.bind(this),this.onMove=this.onMove.bind(this),this.onEnd=this.onEnd.bind(this),this.onLoadStart=this.onLoadStart.bind(this),this.onLoadProgress=this.onLoadProgress.bind(this),this.onLoadEnd=this.onLoadEnd.bind(this),this.onLoadError=this.onLoadError.bind(this),this.onVrcubeInteraction=this.onVrcubeInteraction.bind(this),this.onVrobjectInteraction=this.onVrobjectInteraction.bind(this),this.options=Object.assign({},{server:"localhost",api:"v1",image:{},video:{},vrcube:{},vrobject:{}},e),this.options.events=Object.assign({},{onLoadStart:function(){},onLoadProgress:function(){},onLoadEnd:function(){},onLoadError:function(){},onInteraction:function(){},onVrcubeInteraction:function(){},onVrobjectInteraction:function(){}},e.events),this.options.events.onLoadError=a.default(this.options.events.onLoadError,10),this.container=t,this.container.classList.add("ls-viewer-container"),this.canvas2D=new d,this.container.appendChild(this.canvas2D.element),this.canvas3D=new u,this.container.appendChild(this.canvas3D.element),this.video=new y,this.container.appendChild(this.video.element),this.loader=new f(e.server,e.api,this),this.resolution={width:0,height:0},this.scene=null,this.view=null,this.parameters={antialiasing:!1,superSampling:2},this.encoder={format:"jpeg",quality:80},this.widgets={image:new w(t,this.canvas2D,this.loader,this.options.image),video:new b(t,this.video,this.loader,this.options.video),vrcube:new A(t,this.canvas3D,this.loader,this.options.vrcube,this.onVrcubeInteraction),vrobject:new j(t,this.canvas2D,this.loader,this.options.vrobject,this.onVrobjectInteraction)},this.widget=this.widgets.image,this.container.addEventListener("mousedown",this.onStart,{passive:!1}),this.container.addEventListener("mouseenter",this.onEnter,{passive:!1}),this.container.addEventListener("touchstart",this.onStart,{passive:!1}),document.addEventListener("mousemove",this.onMove),document.addEventListener("mouseup",this.onEnd),document.addEventListener("touchmove",this.onMove),document.addEventListener("touchend",this.onEnd),this.checkResize(),this.loadWidget=a.default(this.loadWidget,10),this.onResize=a.default(this.onResize,250)};return T.prototype.destroy=function(){this.container.removeEventListener("mousedown",this.onStart),this.container.removeEventListener("mouseenter",this.onEnter),this.container.removeEventListener("touchstart",this.onStart),document.removeEventListener("mousemove",this.onMove),document.removeEventListener("mouseup",this.onEnd),document.removeEventListener("touchmove",this.onMove),document.removeEventListener("touchend",this.onEnd),window.removeEventListener("deviceorientation",this.onDeviceOrientation),this.isDestroyed=!0},T.prototype.load=function(t,e){var i=this,n=Promise.resolve();e&&void 0!==e.animation&&(n=n.then((function(){return i.loadAnimation(e.animation)}))),this.view&&e&&void 0!==e.position&&(n=n.then((function(){return i.widgets[i.view.mode].goto(e.position)}))),e&&void 0!==e.animation&&(n=n.then((function(){return i.widgets.video.play()}))),(n=n.then((function(){return i.scene=Array.isArray(t)?r.default(t):[r.default(t)],i.loadWidget(!1,!(e&&e.animation))}))).catch((function(t){i.onLoadError(t)}))},T.prototype.setEncoder=function(t){var e=this;this.encoder=r.default(t);var i=Promise.resolve();(i=i.then((function(){return e.loadWidget(!1,!0)}))).catch((function(t){e.onLoadError(t)}))},T.prototype.setParameters=function(t){var e=this;this.parameters=r.default(t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;var i=Promise.resolve();(i=i.then((function(){return e.loadWidget(!1,!0)}))).catch((function(t){e.onLoadError(t)}))},T.prototype.setView=function(t,e){var i=this,n=Promise.resolve();e&&void 0!==e.animation&&(n=n.then((function(){return i.loadAnimation(e.animation)}))),this.view&&e&&void 0!==e.fromPosition&&(n=n.then((function(){return i.widgets[i.view.mode].goto(e.fromPosition)}))),e&&void 0!==e.animation&&(n=n.then((function(){return i.widgets.video.play()}))),(n=n.then((function(){var n=!0;return i.view=r.default(t),i.view&&e&&void 0!==e.toPosition&&(n=!1,i.widgets[i.view.mode].position=e.toPosition),i.loadWidget(n,!(e&&e.animation))}))).catch((function(t){i.onLoadError(t)}))},T.prototype.setVrcube=function(t){Object.assign(this.widgets.vrcube,t)},T.prototype.setVrobject=function(t){Object.assign(this.widgets.vrobject,t)},T.prototype.loadAnimation=function(t){var e=this,i={scene:this.scene,view:{animation:t.name,camera:t.camera,duration:t.duration,loop:t.loop,reverse:t.reverse},parameters:this.parameters,encoder:{format:"mp4"}};return i.view.background||(i.view.background="product"),this.widgets.video.load(i).catch((function(t){e.onLoadError(t)}))},T.prototype.playAnimation=function(t){var e=this;return this.loadAnimation(t).then((function(){return e.widgets.video.play()}))},T.prototype.stopAnimation=function(){this.widgets.video.hide()},T.prototype.snapshot=function(t,e){return this.widgets[this.view.mode].canvas.element.toDataURL(t,e)},T.prototype.loadWidget=function(t,e){var i=this;if(!this.scene||!this.view)return Promise.resolve();if(!this.parameters.width||!this.parameters.height)return Promise.resolve();var n=this.widgets[this.view.mode];if(!n)return Promise.reject(new Error("Unknown view mode"));var o={scene:this.scene,view:this.view,parameters:this.parameters,encoder:this.encoder};return o.view.background||(o.view.background="product"),n.load(o,t,e).then((function(){i.widget.hide(),i.widget=n,i.widget.show(),i.widgets.video.hide()}))},T.prototype.checkResize=function(){if(!this.isDestroyed){var t=this.container.offsetWidth,e=this.container.offsetHeight;t===this.containerWidth&&e===this.containerHeight||(this.containerWidth=t,this.containerHeight=e,this.onResize()),this.isDestroyed||requestAnimationFrame(this.checkResize)}},T.prototype.onStart=function(t){this.widget.onStart(t),t.preventDefault()},T.prototype.onEnter=function(t){this.widget.onEnter(t),t.preventDefault()},T.prototype.onMove=function(t){this.widget.onMove(t)},T.prototype.onEnd=function(t){this.widget.onEnd(t)},T.prototype.onDeviceOrientation=function(t){this.widget.onDeviceOrientation(t)},T.prototype.onResize=function(){var t=this,e=window.devicePixelRatio,i=this.container.offsetWidth*e,n=this.container.offsetHeight*e;this.resolution=c.getStandardResolution(i,n),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(i/e,n/e,this.resolution),this.canvas3D.resize(i/e,n/e,this.resolution),this.video.resize(i/e,n/e,this.resolution),this.loadWidget(!1,!1).catch((function(e){t.onLoadError(e)}))},T.prototype.onVrcubeInteraction=function(){for(var t,e,i=[],n=arguments.length;n--;)i[n]=arguments[n];(t=this.options.events).onInteraction.apply(t,i),(e=this.options.events).onVrcubeInteraction.apply(e,i)},T.prototype.onVrobjectInteraction=function(){for(var t,e,i=[],n=arguments.length;n--;)i[n]=arguments[n];(t=this.options.events).onInteraction.apply(t,i),(e=this.options.events).onVrobjectInteraction.apply(e,i)},T.prototype.onLoadStart=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];this.container.classList.add("ls-viewer-container-loading"),(t=this.options.events).onLoadStart.apply(t,e)},T.prototype.onLoadProgress=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this.options.events).onLoadProgress.apply(t,e)},T.prototype.onLoadEnd=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];this.container.classList.remove("ls-viewer-container-loading"),(t=this.options.events).onLoadEnd.apply(t,e)},T.prototype.onLoadError=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];this.container.classList.remove("ls-viewer-container-loading"),(t=this.options.events).onLoadError.apply(t,e)},T}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lodash.clonedeep"),require("debounce-promise"),require("twgl.js"),require("axios")):"function"==typeof define&&define.amd?define(["lodash.clonedeep","debounce-promise","twgl.js","axios"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).LumiscapheViewer=e(t.cloneDeep,t.debounce,t.twgl,t.axios)}(this,(function(t,e,i,n){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=o(t),a=o(e),s=o(i),h=o(n),c=function(){};c.fit=function(t,e,i,n){var o=t.width/t.height,r=e/i,a=0,s=0;switch(n){case"contain":a=r<o?e:i*o,s=r<o?e/o:i;break;case"cover":default:a=r<o?i*o:e,s=r<o?i:e/o;break;case"fill":a=e,s=i}return{width:Math.round(a),height:Math.round(s),top:Math.round((i-s)/2),left:Math.round((e-a)/2)}},c.getStandardAspectRatio=function(t,e){if(0===t||0===e)return 0;var i=t/e;return t<e?Math.abs(3/4-i)<Math.abs(9/16-i)?3/4:9/16:Math.abs(4/3-i)<Math.abs(16/9-i)?4/3:16/9},c.getStandardQuality=function(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080},c.getStandardResolution=function(t,e){if(0===t||0===e)return{width:0,height:0};var i=c.getStandardAspectRatio(t,e);if(t<e){var n=c.getStandardQuality(e*i);return{width:Math.round(n),height:Math.round(n/i)}}var o=c.getStandardQuality(t/i);return{width:Math.round(o*i),height:Math.round(o)}};var d=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=this.element.getContext("2d"),this.backCanvas=document.createElement("canvas"),this.backContext=this.backCanvas.getContext("2d"),this.requestAnimationId=null};d.prototype.show=function(t){t?this.element.style.display="block":this.element.style.opacity=1},d.prototype.hide=function(t){t?this.element.style.display="none":this.element.style.opacity=0},d.prototype.resize=function(t,e,i){var n=c.fit(i,t,e,"cover");this.element.style.width=n.width+"px",this.element.style.height=n.height+"px",this.element.style.top=n.top+"px",this.element.style.left=n.left+"px",i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height,this.backCanvas.width=i.width,this.backCanvas.height=i.height)},d.prototype.load=function(t){var e=this,i=new Image;i.onload=function(){e.draw(i,!1)},i.src=t},d.prototype.draw=function(t,e,i){t&&(this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=null),e?(this.backContext.drawImage(this.element,0,0,this.element.width,this.element.height),this.context.globalAlpha=0,this.fadeLoop(t,i)):(this.context.globalAlpha=1,this.context.drawImage(t,0,0,this.element.width,this.element.height)))},d.prototype.fadeLoop=function(t,e){var i=this;if(this.context.globalAlpha>=1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=null);var n=Math.min(this.context.globalAlpha+e,1);this.context.clearRect(0,0,this.element.width,this.element.height),this.context.globalAlpha=1,this.context.drawImage(this.backCanvas,0,0,this.element.width,this.element.height),this.context.globalAlpha=n,this.context.drawImage(t,0,0,this.element.width,this.element.height),this.requestAnimationId=requestAnimationFrame((function(){i.fadeLoop(t,e)}))};var u=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=s.default.getContext(this.element,{preserveDrawingBuffer:!0}),s.default.setDefaultTextureColor([1,1,1,1]),this.requestAnimationId=null};u.prototype.show=function(){this.element.style.opacity=1},u.prototype.hide=function(){this.element.style.opacity=0},u.prototype.resize=function(){this.element.style.width="100%",this.element.style.height="100%",this.element.style.top=0,this.element.style.left=0};var l=function(){};l.accelerate=function(t,e){var i=e||1.5;return Math.pow(Math.abs(t),i)*(t>0?1:-1)},l.degreesToRadians=function(t){return t*(Math.PI/180)},l.radiansToDegrees=function(t){return t*(180/Math.PI)},l.mod=function(t,e){return t-e*Math.floor(t/e)};var p=/directUrl="([^"]*)"/g,m=function(t){this.server=t};m.buildQuery=function(t){return Object.keys(t).filter((function(e){return void 0!==t[e]})).map((function(e){return e+"="+t[e]})).join("&")},m.sceneParameters=function(t){var e=t.scene,i=e.length>1?e.find((function(t){return t.accessory})):null,n=e.length>1?e.find((function(t){return t.decor})):null,o=e.find((function(t){return t!==i&&t!==n})),r={databaseId:o.database};return o.configuration&&(r.configuration=o.configuration),o.animations&&o.animations.length&&(r.animations=o.animations.join("/")),i&&(r.accessoryDatabaseId=i.database),n&&(r.decorDatabaseId=n.database,r.decorDeltaAltitude=n.translation.y),r},m.renderParameters=function(t){var e=t.parameters;return{width:e.width,height:e.height,softwareAntialiasing:e.antialiasing,superSampling:e.superSampling}},m.encoderParameters=function(t){var e=t.encoder;return{imageFormat:e.format,imageQuality:e.quality}},m.fetch=function(t){return h.default.get(t).then((function(t){var e=t.data.replace(/&amp;/g,"&").match(p);return e?e.map((function(t){return t.replace(p,"$1")})):Promise.reject()}))},m.prototype.animation=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],frames:t.view.frames,loop:!!t.view.loop,background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return m.fetch(this.server+"/ImagesFromAnimation?"+i)},m.prototype.image=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return Promise.resolve(this.server+"/ImageFromBookmark?"+i)},m.prototype.video=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],duration:t.view.duration,frames:t.view.frames,loop:!!t.view.loop,reverse:!!t.view.reverse,background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return Promise.resolve(this.server+"/ImagesFromAnimation?"+i)},m.prototype.vrCube=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t)),e.width=Math.max(e.width,e.height),e.height=Math.max(e.width,e.height);var i=m.buildQuery(e);return m.fetch(this.server+"/CubeFromBookmark?"+i)},m.prototype.vrObject=function(t){var e={};Object.assign(e,m.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera,background:t.view.background}),Object.assign(e,m.renderParameters(t)),Object.assign(e,m.encoderParameters(t));var i=m.buildQuery(e);return m.fetch(this.server+"/ImagesFromBookmarkSet?"+i)};var v=function(t){this.server=t};v.snapshotBody=function(t){var e={};return e.scene=t.scene.map((function(t){return t.accessory,t.decor,function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(i[n]=t[n]);return i}(t,["accessory","decor"])})),e.mode={},e.renderParameters=Object.assign({},t.parameters),e.renderParameters.superSampling=e.renderParameters.superSampling.toString(),e.encoder={},e.encoder[t.encoder.format]={quality:t.encoder.quality,compression:t.encoder.compression},e},v.fetch=function(t,e){return h.default.post(t,e).then((function(t){return Array.isArray(t.data)?t.data.map((function(t){return t.url})):t.data.url}))},v.prototype.image=function(t){var e=v.snapshotBody(t);return e.mode.image={camera:t.view.camera},v.fetch(this.server+"/Snapshot",e)},v.prototype.vrCube=function(t){var e=v.snapshotBody(t);e.mode.vrCube={camera:t.view.camera};var i=e.renderParameters;return e.renderParameters.width=Math.max(i.width,i.height),e.renderParameters.height=Math.max(i.width,i.height),v.fetch(this.server+"/Snapshot",e)},v.prototype.vrObject=function(t){var e=v.snapshotBody(t);return t.view.camera?e.mode.vrObject={camera:t.view.camera,frames:t.view.frames}:t.view.cameraGroup&&(e.mode.images={cameraGroup:t.view.cameraGroup}),v.fetch(this.server+"/Snapshot",e)},v.prototype.animation=function(t){var e=v.snapshotBody(t);return e.mode.animation={id:t.view.animation,camera:t.view.camera,fps:t.view.fps},v.fetch(this.server+"/Snapshot",e)};var f=function(t,e,i){switch(e){case"v1":this.webrender=new m(t);break;case"v2":this.webrender=new v(t);break;default:this.webrender=new m(t)}this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i&&i.onLoadStart?i.onLoadStart:function(){},this.onLoadProgress=i&&i.onLoadProgress?i.onLoadProgress:function(){},this.onLoadEnd=i&&i.onLoadEnd?i.onLoadEnd:function(){}},g={progress:{configurable:!0}};g.progress.get=function(){return this.total?this.loaded/this.total:0},f.prototype.loadImage=function(t,e){var i=this,n=new Image;n.crossOrigin="anonymous";var o=new Promise((function(t,o){n.addEventListener("load",(function(){e===i.loadingId&&(i.loaded+=1,i.onLoadProgress(i.progress),t(n))}),{once:!0}),n.addEventListener("error",(function(t){e===i.loadingId&&o(t)}),{once:!0})}));return n.src=t,o},f.prototype.loadImageFrames=function(t,e,i,n){var o=this;this.total=t.length;for(var r=new Array(t.length),a=i||0,s=0,h=t.length;s<h;s+=1){var c=Math.ceil(s/2)*(s%2==0?1:-1),d=e?l.mod(a+c,h):s;r[d]=this.loadImage(t[d],n)}return Promise.all(r).then((function(){return o.onLoadEnd(o.progress)})),r},f.prototype.loadVideo=function(t,e,i,n){var o=this;t.loop=i;var r=new Promise((function(e,i){t.addEventListener("canplaythrough",(function(){n===o.loadingId&&(o.loaded+=1,o.onLoadProgress(o.progress),e())}),{once:!0}),t.addEventListener("error",(function(t){n===o.loadingId&&i(t)}),{once:!0})}));return t.src=e,t.load(),r},f.prototype.loadVideoFrame=function(t,e,i,n,o){var r=this,a=0;return new Promise((function(s,h){var c=function(){if(o===r.loadingId)if(a===n){t.removeEventListener("seeked",c);var h=document.createElement("canvas");h.width=t.videoWidth,h.height=t.videoHeight,h.getContext("2d").drawImage(t,0,0),s(h),r.loaded+=1,r.onLoadProgress(r.progress),n!==i-1&&(t.currentTime+=1/e)}else a+=1};t.addEventListener("seeked",c),t.addEventListener("error",(function(t){o===r.loadingId&&h(t)}),{once:!0})}))},f.prototype.loadVideoFrames=function(t,e,i,n){var o=this;this.total=e;for(var r=new Array(e),a=document.createElement("video"),s=0,h=e;s<h;s+=1)r[s]=this.loadVideoFrame(a,i,e,s,n);return a.addEventListener("canplaythrough",(function(){n===o.loadingId&&(a.currentTime=1/i/2)}),{once:!0}),a.src=t,a.load(),Promise.all(r).then((function(){return o.onLoadEnd(o.progress)})),r},f.prototype.loadImageSnapshot=function(t){var e=this;this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);var i=this.loadingId;return this.webrender.image(t).then((function(t){return e.loadImage(t,i)})).then((function(t){return e.onLoadEnd(e.progress),t}))},f.prototype.loadVideoSnapshot=function(t,e){var i=this;this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);var n=this.loadingId;return this.webrender.video(e).then((function(o){return i.loadVideo(t,o,e.view.loop,n)})).then((function(){return i.onLoadEnd(i.progress),t}))},f.prototype.loadVRCubeSnapshot=function(t){var e=this;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);var i=this.loadingId;return this.webrender.vrCube(t).then((function(t){e.total=t.length;var n=t.map((function(t){return e.loadImage(t,i)}));return Promise.all(n)})).then((function(t){return e.onLoadEnd(e.progress),t}))},f.prototype.loadVRObjectSnapshot=function(t,e){var i=this;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);var n,o=this.loadingId;return n=t.view.animation?"mp4"===t.encoder.format?"video":"animation":"vrObject",this.webrender[n](t).then((function(n){return Array.isArray(n)?i.loadImageFrames(n,t.view.loop,e,o):i.loadVideoFrames(n,t.view.frames,30,o)}))},Object.defineProperties(f.prototype,g);var y=function(){this.element=document.createElement("video"),this.element.classList.add("ls-viewer-video"),this.element.style.opacity=0,this.element.setAttribute("muted",""),this.element.setAttribute("playsinline",""),this.element.setAttribute("preload","auto")};y.prototype.show=function(){this.element.style.opacity=1},y.prototype.hide=function(){this.element.style.opacity=0},y.prototype.resize=function(t,e,i){var n=c.fit(i,t,e,"cover");this.element.style.width=n.width+"px",this.element.style.height=n.height+"px",this.element.style.top=n.top+"px",this.element.style.left=n.left+"px",i.width===this.element.width&&i.height===this.element.height||(this.element.width=i.width,this.element.height=i.height)};var w=function(t,e,i,n){this.container=t,this.canvas=e,this.loader=i,this.options=Object.assign({},n),this.image=null,this.goto=function(){},this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};w.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-image")},w.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-image")},w.prototype.load=function(t,e,i){var n=this,o=JSON.stringify(t);return o===this.hash?(this.canvas.draw(this.image,i,.05),Promise.resolve()):(this.hash=o,this.loader.loadImageSnapshot(t).then((function(t){n.image=t,n.canvas.draw(n.image,i,.05)})))};var b=function(t,e,i,n){this.container=t,this.loader=i,this.options=Object.assign({},n),this.video=e,this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};b.prototype.show=function(){this.video.show(),this.container.classList.add("ls-viewer-container-video")},b.prototype.hide=function(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")},b.prototype.load=function(t){var e=JSON.stringify(t);return e===this.hash?(this.video.load(),Promise.resolve()):(this.hash=e,this.loader.loadVideoSnapshot(this.video.element,t))},b.prototype.play=function(){var t=this;return new Promise((function(e,i){t.video.element.addEventListener("ended",(function(){e()}),{once:!0});var n=t.video.element.play();n&&n.catch((function(){i()})),t.show()}))};var E=function(){};E.point=function(t){if("touchmove"===t.type||"touchstart"===t.type||"touchend"===t.type){var e=t.targetTouches[0]||t.changedTouches[0];return{x:e.screenX,y:e.screenY}}return{x:t.screenX,y:t.screenY}};var P=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];3===e.length?(t=e,this.u=t[0],this.v=t[1],this.o=t[2],this.w=i.v3.cross(this.u,this.v)):(this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0])},x={localToGlobalMatrix:{configurable:!0},globalToLocalMatrix:{configurable:!0}};x.localToGlobalMatrix.get=function(){var t=[this.u[0],this.u[1],this.u[2],0],e=[this.v[0],this.v[1],this.v[2],0],i=[this.w[0],this.w[1],this.w[2],0],n=[this.o[0],this.o[1],this.o[2],1];return[].concat.apply([],[t,e,i,n])},x.globalToLocalMatrix.get=function(){return i.m4.inverse(this.localToGlobalMatrix)},Object.defineProperties(P.prototype,x);var L=function(t){this.animationFrameId=null,this.points=[],this.onMotion=t,this.loop=this.loop.bind(this)};L.prototype.track=function(t){var e=Date.now();this.points=this.points.filter((function(t){return e-t.time<=100})),this.points.push({x:t.x,y:t.y,time:e}),this.lastPoint=t},L.prototype.start=function(){if(0!==this.points.length){var t=this.points[0],e=this.points[this.points.length-1],i=e.x-t.x,n=e.y-t.y,o=e.time-t.time;this.velocity={x:0===o?0:i/(o/15),y:0===o?0:n/(o/15)},this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.animationFrameId=requestAnimationFrame(this.loop)}},L.prototype.stop=function(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.points=[]},L.prototype.loop=function(){if(Math.abs(this.velocity.x)<1&&Math.abs(this.velocity.y)<1)return this.animationFrameId=null,void(this.points=[]);this.lastPoint.x+=this.velocity.x,this.lastPoint.y+=this.velocity.y,this.velocity.x*=.9,this.velocity.y*=.9,this.onMotion(this.lastPoint),this.animationFrameId=requestAnimationFrame(this.loop)};var I=function(t,e,n){this.isStarted=!1,this.inertia=new L(this.motion.bind(this)),this.pov=t,this.fov=l.degreesToRadians(e),this.orientationMatrix=i.m4.identity(),this.initPov=this.pov,this.initFov=this.fov,this.initOrientation=l.degreesToRadians(window.orientation)||0,this.onMotion=n},S={orientedPov:{configurable:!0}};S.orientedPov.get=function(){var t=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),e=new P(t,[0,1,0],this.pov.eye),n=i.m4.identity();return i.m4.multiply(n,e.localToGlobalMatrix,n),i.m4.multiply(n,this.orientationMatrix,n),i.m4.multiply(n,e.globalToLocalMatrix,n),{eye:Array.from(this.pov.eye),target:Array.from(i.m4.transformDirection(n,this.pov.target)),up:Array.from(i.m4.transformDirection(n,this.pov.up))}},I.prototype.reset=function(){this.pov={eye:Array.from(this.initPov.eye),target:Array.from(this.initPov.target),up:Array.from(this.initPov.up)},this.fov=this.initFov},I.prototype.start=function(t,e){this.isStarted=!0,this.startPov=this.pov,this.startPoint=t,this.startSize=e,this.previousPoint=t,this.inertia.stop()},I.prototype.motion=function(t){this.isStarted&&this.inertia.track(t);var e={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},n=l.accelerate(e.x,1.3)/this.startSize.width*.2*Math.PI*1.5,o=l.accelerate(e.y,1.3)/this.startSize.height*.2*Math.PI,r=i.m4.multiply(i.m4.rotationY(-n),i.m4.rotationX(-o)),a=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),s=new P(a,[0,1,0],this.pov.eye),h=i.m4.identity();i.m4.multiply(h,s.localToGlobalMatrix,h),i.m4.multiply(h,r,h),i.m4.multiply(h,s.globalToLocalMatrix,h);var c=i.m4.transformPoint(h,this.pov.target),d=i.m4.transformDirection(h,this.pov.up);i.v3.cross(d,[0,0,1])[0]>=0&&(this.pov.target=Array.from(c),this.pov.up=Array.from(d)),this.previousPoint={x:t.x,y:t.y},this.onMotion()},I.prototype.end=function(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())},I.prototype.orientation=function(t){if(null!==t.alpha&&null!==t.beta&&null!==t.gamma){var e=l.degreesToRadians(window.orientation)||0,n=l.degreesToRadians(t.alpha),o=l.degreesToRadians(-t.beta),r=l.degreesToRadians(-t.gamma),a=i.m4.rotationX(l.degreesToRadians(90));i.m4.rotateZ(a,this.initOrientation,a),i.m4.rotateZ(a,n,a),i.m4.rotateX(a,o,a),i.m4.rotateY(a,r,a),i.m4.rotateZ(a,-e,a),this.orientationMatrix=a,this.onMotion()}},Object.defineProperties(I.prototype,S);var A=function(t,e,i,n,o){var r=this;this.container=t,this.canvas=e,this.loader=i,this.options=Object.assign({},n);var a={eye:[0,0,0],target:[0,0,1],up:[0,1,0]},h=s.default.m4.rotationX(l.degreesToRadians(15));s.default.m4.transformDirection(h,a.target,a.target),s.default.m4.transformDirection(h,a.up,a.up),this.interaction=new I(a,60,(function(){requestAnimationFrame(r.render),r.onInteraction({pov:{eye:[].concat(r.interaction.pov.eye),target:[].concat(r.interaction.pov.target),up:[].concat(r.interaction.pov.up)},fov:r.interaction.fov})})),this.onInteraction=o,this.gl=this.canvas.context,this.programInfo=s.default.createProgramInfo(this.gl,["attribute vec4 position;uniform mat4 u_matrix;varying vec3 direction;void main(){direction=(u_matrix*position).xyz;gl_Position=position*vec4(-1,1,1,1);}\n","precision mediump float;uniform float u_mix;uniform samplerCube u_texture;uniform samplerCube u_texture_back;varying vec3 direction;void main(){vec4 backColor=textureCube(u_texture_back,direction);vec4 color=textureCube(u_texture,direction);gl_FragColor=mix(backColor,color,u_mix);}\n"]),this.quad=s.default.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:s.default.m4.identity(),u_mix:0,u_texture_back:s.default.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:s.default.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1})},this.render=this.render.bind(this),this.goto=function(){}},k={pov:{configurable:!0},fov:{configurable:!0}};A.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")},A.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")},k.pov.get=function(){return this.interaction.pov},k.pov.set=function(t){this.interaction.pov.eye.every((function(e,i){return e===t.eye[i]}))&&this.interaction.pov.target.every((function(e,i){return e===t.target[i]}))&&this.interaction.pov.up.every((function(e,i){return e===t.up[i]}))||(this.interaction.pov={eye:[].concat(t.eye),target:[].concat(t.target),up:[].concat(t.up)},requestAnimationFrame(this.render))},k.fov.get=function(){return l.radiansToDegrees(this.interaction.fov)},k.fov.set=function(t){this.interaction.fov!==t&&(this.interaction.fov=l.degreesToRadians(t),requestAnimationFrame(this.render))},A.prototype.load=function(t,e,i){var n=this,o=JSON.stringify(t);return o===this.hash?(requestAnimationFrame(this.render),Promise.resolve()):(this.hash=o,this.images=[],requestAnimationFrame(this.render),this.loader.loadVRCubeSnapshot(t).then((function(t){n.images=t,s.default.createTexture(n.gl,{target:n.gl.TEXTURE_CUBE_MAP,minMag:n.gl.LINEAR,auto:!1,cubeFaceOrder:[n.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,n.gl.TEXTURE_CUBE_MAP_POSITIVE_X,n.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,n.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,n.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,n.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y],src:t},(function(t,o){t||(e&&n.interaction.reset(),n.uniforms.u_mix=i?0:1,n.uniforms.u_texture_back=n.uniforms.u_texture,n.uniforms.u_texture=o,requestAnimationFrame(n.render))}))})))},A.prototype.render=function(){s.default.resizeCanvasToDisplaySize(this.gl.canvas,window.devicePixelRatio),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var t=this.gl.canvas.clientWidth,e=this.gl.canvas.clientHeight,i=c.getStandardAspectRatio(t,e),n=t/e,o=this.interaction.fov*(i/n),r=s.default.m4.inverse(s.default.m4.perspective(o,n,.5,100)),a=this.interaction.orientedPov,h=s.default.m4.lookAt(a.eye,a.target,a.up);this.uniforms.u_matrix=s.default.m4.multiply(h,r),this.gl.useProgram(this.programInfo.program),s.default.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),s.default.setUniforms(this.programInfo,this.uniforms),s.default.drawBufferInfo(this.gl,this.quad),this.uniforms.u_mix<1&&(this.uniforms.u_mix=Math.min(this.uniforms.u_mix+.05,1),requestAnimationFrame(this.render))},A.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(E.point(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})},A.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(E.point(t),!1))},A.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(E.point(t)),t.preventDefault())},A.prototype.onEnd=function(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(E.point(t),!0))},A.prototype.onDeviceOrientation=function(t){this.interaction.orientation({alpha:t.alpha,beta:t.beta,gamma:t.gamma})},Object.defineProperties(A.prototype,k);var M=function(t,e,i,n){this.isStarted=!1,this.inertia=new L(this.motion.bind(this)),this.position=t,this.count=e,this.loop=i,this.onMotion=n,this.initPosition=this.position};M.prototype.reset=function(){this.position=this.initPosition},M.prototype.start=function(t,e){this.isStarted=!0,this.startPosition=this.position,this.startPoint=t,this.startSize=e,this.inertia.stop()},M.prototype.motion=function(t){this.isStarted&&this.inertia.track(t);var e={x:t.x-this.startPoint.x,y:t.y-this.startPoint.y},i=l.accelerate(e.x,1.3)/this.startSize.width*(this.count/4),n=this.startPosition-Math.round(i);(n=this.loop?l.mod(n,this.count):Math.max(0,Math.min(n,this.count-1)))!==this.position&&(this.position=n,this.onMotion())},M.prototype.end=function(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())};var j=function(t,e,i,n,o){var r=this;this.container=t,this.canvas=e,this.loader=i,this.options=Object.assign({},{loop:!0},n),this.images=[],this.interaction=new M(0,1,!1,(function(){r.canvas.draw(r.image,!0,.5),r.onInteraction({position:r.interaction.position})})),this.onDeviceOrientation=function(){},this.onInteraction=o},O={position:{configurable:!0},image:{configurable:!0}};j.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrobject")},j.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrobject")},O.position.get=function(){return this.interaction.position},O.position.set=function(t){this.interaction.position!==t&&(this.interaction.loop?this.interaction.position=l.mod(t,this.interaction.count):this.interaction.position=Math.max(0,Math.min(t,this.interaction.count-1)),this.canvas.draw(this.image,!0,.5))},j.prototype.goto=function(t){var e=this;return new Promise((function(i){var n=e.interaction.position,o=function(){if(e.interaction.position===t)i();else{var r=n>t?-1:1;e.interaction.loop&&e.interaction.count-n+t<Math.abs(t-n)&&(r*=-1),n+=.5*r,e.position=Math.floor(n),requestAnimationFrame(o)}};requestAnimationFrame(o)}))},O.image.get=function(){return this.images[this.interaction.position]},j.prototype.load=function(t,e,i){var n=this,o=JSON.stringify(t);if(o===this.hash)return this.canvas.draw(this.image,i,.05),Promise.resolve();this.hash=o,this.images=[],e&&this.interaction.reset();var r=this.interaction.position;return this.loader.loadVRObjectSnapshot(t,r).then((function(e){var o=e.length;return n.images=new Array(o),n.interaction.count=o,n.interaction.loop=!!t.view.loop,e.forEach((function(t,e){t.then((function(t){n.images[e]=t,t===n.image&&n.canvas.draw(n.image,i,.05)}))})),e[n.interaction.position]}))},j.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(E.point(t),{width:this.canvas.element.width,height:this.canvas.element.height})},j.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(E.point(t),!1))},j.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(E.point(t)),t.preventDefault())},j.prototype.onEnd=function(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(E.point(t),!0))},Object.defineProperties(j.prototype,O);!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".ls-viewer-container{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-ms-flex:1 0 auto;flex:1 0 auto;position:relative;overflow:hidden;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{position:absolute;opacity:0;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");var T=function(t,e){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onResize=this.onResize.bind(this),this.onStart=this.onStart.bind(this),this.onEnter=this.onEnter.bind(this),this.onMove=this.onMove.bind(this),this.onEnd=this.onEnd.bind(this),this.onLoadStart=this.onLoadStart.bind(this),this.onLoadProgress=this.onLoadProgress.bind(this),this.onLoadEnd=this.onLoadEnd.bind(this),this.onLoadError=this.onLoadError.bind(this),this.onVrcubeInteraction=this.onVrcubeInteraction.bind(this),this.onVrobjectInteraction=this.onVrobjectInteraction.bind(this),this.options=Object.assign({},{server:"localhost",api:"v1",image:{},video:{},vrcube:{},vrobject:{}},e),this.options.events=Object.assign({},{onLoadStart:function(){},onLoadProgress:function(){},onLoadEnd:function(){},onLoadError:function(){},onInteraction:function(){},onVrcubeInteraction:function(){},onVrobjectInteraction:function(){}},e.events),this.options.events.onLoadError=a.default(this.options.events.onLoadError,10),this.container=t,this.container.classList.add("ls-viewer-container"),this.canvas2D=new d,this.container.appendChild(this.canvas2D.element),this.canvas3D=new u,this.container.appendChild(this.canvas3D.element),this.video=new y,this.container.appendChild(this.video.element),this.loader=new f(e.server,e.api,this),this.resolution={width:0,height:0},this.scene=null,this.view=null,this.parameters={antialiasing:!1,superSampling:2},this.encoder={format:"jpeg",quality:80},this.widgets={image:new w(t,this.canvas2D,this.loader,this.options.image),video:new b(t,this.video,this.loader,this.options.video),vrcube:new A(t,this.canvas3D,this.loader,this.options.vrcube,this.onVrcubeInteraction),vrobject:new j(t,this.canvas2D,this.loader,this.options.vrobject,this.onVrobjectInteraction)},this.widget=this.widgets.image,this.container.addEventListener("mousedown",this.onStart,{passive:!1}),this.container.addEventListener("mouseenter",this.onEnter,{passive:!1}),this.container.addEventListener("touchstart",this.onStart,{passive:!1}),document.addEventListener("mousemove",this.onMove),document.addEventListener("mouseup",this.onEnd),document.addEventListener("touchmove",this.onMove),document.addEventListener("touchend",this.onEnd),this.checkResize(),this.loadWidget=a.default(this.loadWidget,10),this.onResize=a.default(this.onResize,250)};return T.prototype.destroy=function(){this.container.removeEventListener("mousedown",this.onStart),this.container.removeEventListener("mouseenter",this.onEnter),this.container.removeEventListener("touchstart",this.onStart),document.removeEventListener("mousemove",this.onMove),document.removeEventListener("mouseup",this.onEnd),document.removeEventListener("touchmove",this.onMove),document.removeEventListener("touchend",this.onEnd),window.removeEventListener("deviceorientation",this.onDeviceOrientation),this.isDestroyed=!0},T.prototype.load=function(t,e){var i=this,n=Promise.resolve();e&&void 0!==e.animation&&(n=n.then((function(){return i.loadAnimation(e.animation)}))),this.view&&e&&void 0!==e.position&&(n=n.then((function(){return i.widgets[i.view.mode].goto(e.position)}))),e&&void 0!==e.animation&&(n=n.then((function(){return i.widgets.video.play()}))),(n=n.then((function(){return i.scene=Array.isArray(t)?r.default(t):[r.default(t)],i.loadWidget(!1,!(e&&e.animation))}))).catch((function(t){i.onLoadError(t)}))},T.prototype.setEncoder=function(t){var e=this;this.encoder=r.default(t);var i=Promise.resolve();(i=i.then((function(){return e.loadWidget(!1,!0)}))).catch((function(t){e.onLoadError(t)}))},T.prototype.setParameters=function(t){var e=this;this.parameters=r.default(t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;var i=Promise.resolve();(i=i.then((function(){return e.loadWidget(!1,!0)}))).catch((function(t){e.onLoadError(t)}))},T.prototype.setView=function(t,e){var i=this,n=Promise.resolve();e&&void 0!==e.animation&&(n=n.then((function(){return i.loadAnimation(e.animation)}))),this.view&&e&&void 0!==e.fromPosition&&(n=n.then((function(){return i.widgets[i.view.mode].goto(e.fromPosition)}))),e&&void 0!==e.animation&&(n=n.then((function(){return i.widgets.video.play()}))),(n=n.then((function(){var n=!0;return i.view=r.default(t),i.view&&e&&void 0!==e.toPosition&&(n=!1,i.widgets[i.view.mode].position=e.toPosition),i.loadWidget(n,!(e&&e.animation))}))).catch((function(t){i.onLoadError(t)}))},T.prototype.setVrcube=function(t){Object.assign(this.widgets.vrcube,t)},T.prototype.setVrobject=function(t){Object.assign(this.widgets.vrobject,t)},T.prototype.loadAnimation=function(t){var e=this,i={scene:this.scene,view:{animation:t.name,camera:t.camera,duration:t.duration,loop:t.loop,reverse:t.reverse},parameters:this.parameters,encoder:{format:"mp4"}};return i.view.background||(i.view.background="product"),this.widgets.video.load(i).catch((function(t){e.onLoadError(t)}))},T.prototype.playAnimation=function(t){var e=this;return this.loadAnimation(t).then((function(){return e.widgets.video.play()}))},T.prototype.stopAnimation=function(){this.widgets.video.hide()},T.prototype.snapshot=function(t,e){return this.widgets[this.view.mode].canvas.element.toDataURL(t,e)},T.prototype.loadWidget=function(t,e){var i=this;if(!this.scene||!this.view)return Promise.resolve();if(!this.parameters.width||!this.parameters.height)return Promise.resolve();var n=this.widgets[this.view.mode];if(!n)return Promise.reject(new Error("Unknown view mode"));var o={scene:this.scene,view:this.view,parameters:this.parameters,encoder:this.encoder};return o.view.background||(o.view.background="product"),n.load(o,t,e).then((function(){i.widget.hide(),i.widget=n,i.widget.show(),i.widgets.video.hide()}))},T.prototype.checkResize=function(){if(!this.isDestroyed){var t=this.container.offsetWidth,e=this.container.offsetHeight;t===this.containerWidth&&e===this.containerHeight||(this.containerWidth=t,this.containerHeight=e,this.onResize()),this.isDestroyed||requestAnimationFrame(this.checkResize)}},T.prototype.onStart=function(t){this.widget.onStart(t),t.preventDefault()},T.prototype.onEnter=function(t){this.widget.onEnter(t),t.preventDefault()},T.prototype.onMove=function(t){this.widget.onMove(t)},T.prototype.onEnd=function(t){this.widget.onEnd(t)},T.prototype.onDeviceOrientation=function(t){this.widget.onDeviceOrientation(t)},T.prototype.onResize=function(){var t=this,e=window.devicePixelRatio,i=this.container.offsetWidth*e,n=this.container.offsetHeight*e;this.resolution=c.getStandardResolution(i,n),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(i/e,n/e,this.resolution),this.canvas3D.resize(i/e,n/e,this.resolution),this.video.resize(i/e,n/e,this.resolution),this.loadWidget(!1,!1).catch((function(e){t.onLoadError(e)}))},T.prototype.onVrcubeInteraction=function(){for(var t,e,i=[],n=arguments.length;n--;)i[n]=arguments[n];(t=this.options.events).onInteraction.apply(t,i),(e=this.options.events).onVrcubeInteraction.apply(e,i)},T.prototype.onVrobjectInteraction=function(){for(var t,e,i=[],n=arguments.length;n--;)i[n]=arguments[n];(t=this.options.events).onInteraction.apply(t,i),(e=this.options.events).onVrobjectInteraction.apply(e,i)},T.prototype.onLoadStart=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];this.container.classList.add("ls-viewer-container-loading"),(t=this.options.events).onLoadStart.apply(t,e)},T.prototype.onLoadProgress=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];(t=this.options.events).onLoadProgress.apply(t,e)},T.prototype.onLoadEnd=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];this.container.classList.remove("ls-viewer-container-loading"),(t=this.options.events).onLoadEnd.apply(t,e)},T.prototype.onLoadError=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];this.container.classList.remove("ls-viewer-container-loading"),(t=this.options.events).onLoadError.apply(t,e)},T}));
{
"name": "@lumiscaphe/viewer",
"version": "2.2.3",
"version": "2.3.0",
"description": "Lumiscaphe 3D Viewer",

@@ -12,10 +12,10 @@ "main": "dist/index.js",

"dependencies": {
"axios": "~0.20.0",
"axios": "~0.21.0",
"debounce-promise": "~3.1.0",
"lodash.clonedeep": "~4.5.0",
"twgl.js": "~4.16.0"
"twgl.js": "~4.18.0"
},
"devDependencies": {
"cross-env": "~7.0.0",
"eslint": "~7.11.0",
"eslint": "~7.19.0",
"eslint-config-airbnb-base": "~14.2.0",

@@ -25,3 +25,4 @@ "eslint-plugin-import": "~2.22.0",

"postcss-cssnext": "~3.1.0",
"rollup": "~2.32.0",
"postcss-reporter": "~7.0.0",
"rollup": "~2.38.0",
"rollup-plugin-buble": "~0.19.0",

@@ -32,8 +33,8 @@ "rollup-plugin-commonjs": "~10.1.0",

"rollup-plugin-node-resolve": "~5.2.0",
"rollup-plugin-postcss": "~3.1.0",
"rollup-plugin-postcss": "~4.0.0",
"rollup-plugin-replace": "~2.2.0",
"rollup-plugin-terser": "~7.0.0",
"stylelint": "~13.7.0",
"stylelint": "~13.9.0",
"stylelint-config-standard": "~20.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc