Socket
Socket
Sign inDemoInstall

@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 0.5.8 to 0.5.9

2

dist/index.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("twgl.js"),require("axios"),require("lodash.clonedeep"),require("lodash.debounce")):"function"==typeof define&&define.amd?define(["twgl.js","axios","lodash.clonedeep","lodash.debounce"],e):t.LumiscapheViewer=e(t.twgl,t.axios,t.cloneDeep,t.debounce)}(this,function(t,e,i,n){"use strict";var o="default"in t?t.default:t;e=e&&e.hasOwnProperty("default")?e.default:e,i=i&&i.hasOwnProperty("default")?i.default:i,n=n&&n.hasOwnProperty("default")?n.default:n;var r=function(){};r.fit=function(t,e,i,n){var o=t.width/t.height,r=e/i,s=0,a=0;switch(n){case"contain":s=r<o?e:i*o,a=r<o?e/o:i;break;case"cover":default:s=r<o?i*o:e,a=r<o?i:e/o;break;case"fill":s=e,a=i}return{width:Math.round(s),height:Math.round(a),top:Math.round((i-a)/2),left:Math.round((e-s)/2)}},r.getStandardQuality=function(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080},r.getStandardResolution=function(t,e){if(0===t||0===e)return{width:0,height:0};if(t<e){var i=t/e<.75?9/16:.75,n=r.getStandardQuality(e*i);return{width:Math.round(n),height:Math.round(n/i)}}var o=t/e>4/3?16/9:4/3,s=r.getStandardQuality(t/o);return{width:Math.round(s*o),height:Math.round(s)}};var s=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};s.prototype.show=function(){this.element.style.opacity=1},s.prototype.hide=function(){this.element.style.opacity=0},s.prototype.resize=function(t,e,i){var n=r.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)},s.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)))},s.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 a=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=o.getContext(this.element),o.setDefaultTextureColor([1,1,1,1]),this.requestAnimationId=null};a.prototype.show=function(){this.element.style.opacity=1},a.prototype.hide=function(){this.element.style.opacity=0},a.prototype.resize=function(){this.element.style.width="100%",this.element.style.height="100%",this.element.style.top=0,this.element.style.left=0};var h=function(){};h.accelerate=function(t,e){var i=e||1.5;return Math.pow(Math.abs(t),i)*(t>0?1:-1)},h.degreesToRadians=function(t){return t*(Math.PI/180)},h.mod=function(t,e){return t-e*Math.floor(t/e)};var c=function(t){this.server=t};c.buildQuery=function(t){return Object.keys(t).filter(function(e){return void 0!==t[e]}).map(function(e){return e+"="+t[e]}).join("&")},c.sceneParameters=function(t){var e=t.scene,i={},n=e.length>1?e.find(function(t){return t.master})||e[0]:null;if(n){var o=e.find(function(t){return t!==n});i.databaseId=o.database,i.configuration=o.configuration,i.decorDatabaseId=n.database,i.decorDeltaAltitude=n.translation.y}else{var r=e[0];i.databaseId=r.database,i.configuration=r.configuration,i.animations=r.animations&&r.animations.length?r.animations.join("/"):void 0}return i},c.renderParameters=function(t){var e=t.parameters;return{width:e.width,height:e.height,softwareAntialiasing:e.antialiasing,superSampling:e.superSampling}},c.encoderParameters=function(t){var e=t.encoder;return{imageFormat:e.format,imageQuality:e.quality}},c.fetch=function(t){return e.get(t).then(function(t){var e=t.data.replace(/&amp;/g,"&").match(/directUrl="([^"]*)"/g);return e?e.map(function(t){return t.replace(/directUrl="([^"]*)"/g,"$1")}):Promise.reject()})},c.prototype.animation=function(t){var e={};Object.assign(e,c.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,c.renderParameters(t)),Object.assign(e,c.encoderParameters(t));var i=c.buildQuery(e);return c.fetch(this.server+"/ImagesFromAnimation?"+i)},c.prototype.image=function(t){var e={};Object.assign(e,c.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,c.renderParameters(t)),Object.assign(e,c.encoderParameters(t));var i=c.buildQuery(e);return Promise.resolve(this.server+"/ImageFromBookmark?"+i)},c.prototype.video=function(t){var e={};Object.assign(e,c.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,c.renderParameters(t)),Object.assign(e,c.encoderParameters(t));var i=c.buildQuery(e);return Promise.resolve(this.server+"/ImagesFromAnimation?"+i)},c.prototype.vrCube=function(t){var e={};Object.assign(e,c.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,c.renderParameters(t)),Object.assign(e,c.encoderParameters(t)),e.width=Math.max(e.width,e.height),e.height=Math.max(e.width,e.height);var i=c.buildQuery(e);return c.fetch(this.server+"/CubeFromBookmark?"+i)},c.prototype.vrObject=function(t){var e={};Object.assign(e,c.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera,background:t.view.background}),Object.assign(e,c.renderParameters(t)),Object.assign(e,c.encoderParameters(t));var i=c.buildQuery(e);return c.fetch(this.server+"/ImagesFromBookmarkSet?"+i)};var d=function(t,e){this.webrender=new c(t),this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=e.onLoadStart||function(){},this.onLoadProgress=e.onLoadProgress||function(){},this.onLoadEnd=e.onLoadEnd||function(){}},u={progress:{configurable:!0}};u.progress.get=function(){return this.total?this.loaded/this.total:0},d.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},d.prototype.loadImageFrames=function(t,e,i,n){var o=this;this.total=t.length;for(var r=new Array(t.length),s=i||0,a=0,c=t.length;a<c;a+=1){var d=Math.ceil(a/2)*(a%2==0?1:-1),u=e?h.mod(s+d,c):a;r[u]=o.loadImage(t[u],n)}return Promise.all(r).then(function(){return o.onLoadEnd(o.progress)}),r},d.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},d.prototype.loadVideoFrame=function(t,e,i,n,o){var r=this,s=0;return new Promise(function(a,h){t.addEventListener("seeked",function(){if(o===r.loadingId){if(s!==n)return void(s+=1);var h=document.createElement("canvas");h.width=t.videoWidth,h.height=t.videoHeight,h.getContext("2d").drawImage(t,0,0),a(h),r.loaded+=1,r.onLoadProgress(r.progress),n!==i-1&&(t.currentTime+=1/e)}},{once:!0}),t.addEventListener("error",function(t){o===r.loadingId&&h(t)},{once:!0})})},d.prototype.loadVideoFrames=function(t,e,i,n){var o=this;this.total=e;for(var r=new Array(e),s=document.createElement("video"),a=0,h=e;a<h;a+=1)r[a]=o.loadVideoFrame(s,i,e,a,n);return s.addEventListener("canplaythrough",function(){n===o.loadingId&&(s.currentTime=1/i/2)},{once:!0}),s.src=t,s.load(),Promise.all(r).then(function(){return o.onLoadEnd(o.progress)}),r},d.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})},d.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})},d.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})},d.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(d.prototype,u);var l=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")};l.prototype.show=function(){this.element.style.opacity=1},l.prototype.hide=function(){this.element.style.opacity=0},l.prototype.resize=function(t,e,i){var n=r.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 m=function(t,e,i){this.container=t,this.canvas=e,this.loader=i,this.image=null,this.goto=function(){},this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};m.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-image")},m.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-image")},m.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 v=function(t,e,i){this.container=t,this.loader=i,this.video=e,this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};v.prototype.show=function(){this.video.show(),this.container.classList.add("ls-viewer-container-video")},v.prototype.hide=function(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")},v.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))},v.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 p=function(){};p.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 g=function(){for(var e,i=[],n=arguments.length;n--;)i[n]=arguments[n];3===i.length?(e=i,this.u=e[0],this.v=e[1],this.o=e[2],this.w=t.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])},f={localToGlobalMatrix:{configurable:!0},globalToLocalMatrix:{configurable:!0}};f.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])},f.globalToLocalMatrix.get=function(){return t.m4.inverse(this.localToGlobalMatrix)},Object.defineProperties(g.prototype,f);var w=function(t){this.animationFrameId=null,this.points=[],this.onMotion=t,this.loop=this.loop.bind(this)};w.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},w.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)}},w.prototype.stop=function(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.points=[]},w.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 y=function(e,i,n){this.changed=!1,this.isStarted=!1,this.inertia=new w(this.motion.bind(this)),this.fov=h.degreesToRadians(e),this.pov=i,this.orientationMatrix=t.m4.identity(),this.initFov=this.fov,this.initPov=this.pov,this.initOrientation=h.degreesToRadians(window.orientation)||0,this.onMotion=n},b={orientedPov:{configurable:!0}};b.orientedPov.get=function(){var e=t.v3.normalize(t.v3.cross(this.pov.up,this.pov.target)),i=new g(e,[0,1,0],this.pov.eye),n=t.m4.identity();return t.m4.multiply(n,i.localToGlobalMatrix,n),t.m4.multiply(n,this.orientationMatrix,n),t.m4.multiply(n,i.globalToLocalMatrix,n),{eye:this.pov.eye,target:t.m4.transformDirection(n,this.pov.target),up:t.m4.transformDirection(n,this.pov.up)}},y.prototype.reset=function(){this.fov=this.initFov,this.pov={eye:Array.from(this.initPov.eye),target:Array.from(this.initPov.target),up:Array.from(this.initPov.up)}},y.prototype.start=function(t,e){this.changed=!1,this.isStarted=!0,this.startPov=this.pov,this.startPoint=t,this.startSize=e,this.previousPoint=t,this.inertia.stop()},y.prototype.motion=function(e){this.isStarted&&this.inertia.track(e);var i={x:e.x-this.previousPoint.x,y:e.y-this.previousPoint.y},n=h.accelerate(i.x,1.3)/this.startSize.width*.2*Math.PI*1.5,o=h.accelerate(i.y,1.3)/this.startSize.height*.2*Math.PI,r=t.m4.multiply(t.m4.rotationY(-n),t.m4.rotationX(-o)),s=t.v3.normalize(t.v3.cross(this.pov.up,this.pov.target)),a=new g(s,[0,1,0],this.pov.eye),c=t.m4.identity();t.m4.multiply(c,a.localToGlobalMatrix,c),t.m4.multiply(c,r,c),t.m4.multiply(c,a.globalToLocalMatrix,c);var d=t.m4.transformPoint(c,this.pov.target),u=t.m4.transformDirection(c,this.pov.up);t.v3.cross(u,[0,0,1])[0]>=0&&(this.pov.target=d,this.pov.up=u),this.previousPoint={x:e.x,y:e.y},this.onMotion(),this.changed=!0},y.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()},y.prototype.orientation=function(e){if(null!==e.alpha&&null!==e.beta&&null!==e.gamma){var i=h.degreesToRadians(window.orientation)||0,n=h.degreesToRadians(e.alpha),o=h.degreesToRadians(-e.beta),r=h.degreesToRadians(-e.gamma),s=t.m4.rotationX(h.degreesToRadians(90));t.m4.rotateZ(s,this.initOrientation,s),t.m4.rotateZ(s,n,s),t.m4.rotateX(s,o,s),t.m4.rotateY(s,r,s),t.m4.rotateZ(s,-i,s),this.orientationMatrix=s,this.onMotion()}},Object.defineProperties(y.prototype,b);var E=function(t,e,i,n){var r=this;this.container=t,this.canvas=e,this.loader=i,this.onInteraction=n;var s={eye:[0,0,0],target:[0,0,1],up:[0,1,0]},a=o.m4.rotationX(h.degreesToRadians(15));o.m4.transformDirection(a,s.target,s.target),o.m4.transformDirection(a,s.up,s.up),this.interaction=new y(60,s,function(){requestAnimationFrame(r.render)}),this.gl=this.canvas.context,this.programInfo=o.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=o.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:o.m4.identity(),u_mix:0,u_texture_back:o.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:o.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(){}};E.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")},E.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")},E.prototype.load=function(t,e,i){var n=this,r=JSON.stringify(t);return r===this.hash?(requestAnimationFrame(this.render),Promise.resolve()):(this.hash=r,this.images=[],requestAnimationFrame(this.render),this.loader.loadVRCubeSnapshot(t).then(function(t){o.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))})}))},E.prototype.render=function(){o.resizeCanvasToDisplaySize(this.gl.canvas,window.devicePixelRatio),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var t=this.interaction.fov,e=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,i=o.m4.inverse(o.m4.perspective(t,e,.5,100)),n=this.interaction.orientedPov,r=o.m4.lookAt(n.eye,n.target,n.up);this.uniforms.u_matrix=o.m4.multiply(r,i),this.gl.useProgram(this.programInfo.program),o.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),o.setUniforms(this.programInfo,this.uniforms),o.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))},E.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(p.point(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})},E.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!1))},E.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(p.point(t)),t.preventDefault())},E.prototype.onEnd=function(){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!0),this.interaction.changed&&this.onInteraction())},E.prototype.onDeviceOrientation=function(t){this.interaction.orientation({alpha:t.alpha,beta:t.beta,gamma:t.gamma})};var P=function(t,e,i,n){this.changed=!1,this.isStarted=!1,this.inertia=new w(this.motion.bind(this)),this.position=t,this.count=e,this.loop=i,this.onMotion=n,this.initPosition=this.position};P.prototype.set=function(t){var e=this.position;this.loop?this.position=h.mod(t,this.count):this.position=Math.max(0,Math.min(t,this.count-1)),this.position!==e&&(this.onMotion(),this.changed=!0)},P.prototype.reset=function(){this.position=this.initPosition},P.prototype.start=function(t,e){this.changed=!1,this.isStarted=!0,this.startPosition=this.position,this.startPoint=t,this.startSize=e,this.inertia.stop()},P.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=h.accelerate(e.x,1.3)/this.startSize.width*(this.count/4),n=this.startPosition-Math.round(i);this.set(n)},P.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()};var L=function(t,e,i,n){var o=this;this.container=t,this.canvas=e,this.loader=i,this.onInteraction=n,this.images=[],this.interaction=new P(0,1,!1,function(){o.canvas.draw(o.image,!0,.5)}),this.options={loop:!0},this.onDeviceOrientation=function(){}},x={image:{configurable:!0}};L.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrobject")},L.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrobject")},L.prototype.set=function(t){this.interaction.position=t},L.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.interaction.set(Math.floor(n)),requestAnimationFrame(o)}};requestAnimationFrame(o)})},x.image.get=function(){return this.images[this.interaction.position]},L.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]})},L.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(p.point(t),{width:this.canvas.element.width,height:this.canvas.element.height})},L.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(!1))},L.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(p.point(t)),t.preventDefault())},L.prototype.onEnd=function(){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(!0),this.interaction.changed&&this.onInteraction())},Object.defineProperties(L.prototype,x);!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;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");var I=function(t,e){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onInteraction=this.onInteraction.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.container=t,this.container.classList.add("ls-viewer-container"),this.canvas2D=new s,this.container.appendChild(this.canvas2D.element),this.canvas3D=new a,this.container.appendChild(this.canvas3D.element),this.video=new l,this.container.appendChild(this.video.element),this.options=Object.assign({},{server:"localhost"},e),this.options.events=Object.assign({},{onInteraction:function(){},onLoadStart:function(){},onLoadProgress:function(){},onLoadEnd:function(){},onLoadError:function(){}},e.events),this.loader=new d(e.server,{onLoadStart:this.onLoadStart,onLoadProgress:this.onLoadProgress,onLoadEnd:this.onLoadEnd,onLoadError:this.onLoadError}),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 m(t,this.canvas2D,this.loader,this.onInteraction),video:new v(t,this.video,this.loader,this.onInteraction),vrcube:new E(t,this.canvas3D,this.loader,this.onInteraction),vrobject:new L(t,this.canvas2D,this.loader,this.onInteraction)},this.widget=this.widgets.image,this.container.addEventListener("mousedown",this.onStart),this.container.addEventListener("mouseenter",this.onEnter),this.container.addEventListener("mousemove",this.onMove),this.container.addEventListener("mouseup",this.onEnd),this.container.addEventListener("touchstart",this.onStart),this.container.addEventListener("touchmove",this.onMove),this.container.addEventListener("touchend",this.onEnd),window.addEventListener("deviceorientation",this.onDeviceOrientation),this.checkResize(),this.loadWidget=n(this.loadWidget,10),this.onResize=n(this.onResize,250)};return I.prototype.destroy=function(){this.container.removeEventListener("mousedown",this.onStart),this.container.removeEventListener("mouseenter",this.onEnter),this.container.removeEventListener("mousemove",this.onMove),this.container.removeEventListener("mouseup",this.onEnd),this.container.removeEventListener("touchstart",this.onStart),this.container.removeEventListener("touchmove",this.onMove),this.container.removeEventListener("touchend",this.onEnd),window.removeEventListener("deviceorientation",this.onDeviceOrientation),this.isDestroyed=!0},I.prototype.load=function(t,e){var n=this,o=Promise.resolve();e&&void 0!==e.animation&&(o=o.then(function(){return n.loadAnimation(e.animation)})),this.view&&e&&void 0!==e.position&&(o=o.then(function(){return n.widgets[n.view.mode].goto(e.position)})),e&&void 0!==e.animation&&(o=o.then(function(){return n.widgets.video.play()})),(o=o.then(function(){return n.scene=Array.isArray(t)?i(t):[i(t)],n.loadWidget(!1,!(e&&e.animation))})).catch(function(){})},I.prototype.setEncoder=function(t){var e=this;this.encoder=i(t);var n=Promise.resolve();(n=n.then(function(){return e.loadWidget(!1,!0)})).catch(function(){})},I.prototype.setParameters=function(t){var e=this;this.parameters=i(t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;var n=Promise.resolve();(n=n.then(function(){return e.loadWidget(!1,!0)})).catch(function(){})},I.prototype.setView=function(t,e){var n=this,o=Promise.resolve();e&&void 0!==e.animation&&(o=o.then(function(){return n.loadAnimation(e.animation)})),this.view&&e&&void 0!==e.fromPosition&&(o=o.then(function(){return n.widgets[n.view.mode].goto(e.fromPosition)})),e&&void 0!==e.animation&&(o=o.then(function(){return n.widgets.video.play()})),(o=o.then(function(){var o=!0;return n.view=i(t),n.view&&e&&void 0!==e.toPosition&&(o=!1,n.widgets[n.view.mode].set(e.toPosition)),n.loadWidget(o,!(e&&e.animation))})).catch(function(){})},I.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)})},I.prototype.playAnimation=function(t){var e=this;return this.loadAnimation(t).then(function(){return e.widgets.video.play()})},I.prototype.stopAnimation=function(){this.widgets.video.hide()},I.prototype.loadWidget=function(t,e){var i=this;if(!this.scene||!this.view)return Promise.reject();if(!this.parameters.width||!this.parameters.height)return Promise.reject();var n=this.widgets[this.view.mode];if(!n)return Promise.reject();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()},function(t){i.onLoadError(t)})},I.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)}},I.prototype.onStart=function(t){this.widget.onStart(t)},I.prototype.onEnter=function(t){this.widget.onEnter(t)},I.prototype.onMove=function(t){this.widget.onMove(t)},I.prototype.onEnd=function(t){this.widget.onEnd(t)},I.prototype.onDeviceOrientation=function(t){this.widget.onDeviceOrientation(t)},I.prototype.onResize=function(){var t=window.devicePixelRatio,e=this.container.offsetWidth*t,i=this.container.offsetHeight*t;this.resolution=r.getStandardResolution(e,i),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(e/t,i/t,this.resolution),this.canvas3D.resize(e/t,i/t,this.resolution),this.video.resize(e/t,i/t,this.resolution),this.loadWidget(!1,!1).catch(function(){})},I.prototype.onInteraction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.options.events.onInteraction(t)},I.prototype.onLoadStart=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(t)},I.prototype.onLoadProgress=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.options.events.onLoadProgress(t)},I.prototype.onLoadEnd=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(t)},I.prototype.onLoadError=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadError(t)},I});
function __$$styleInject(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))}}import twgl,{m4,v3}from"twgl.js";import axios from"axios";import cloneDeep from"lodash.clonedeep";import debounce from"debounce-promise";var Viewport=function(){};Viewport.fit=function(t,e,i,n){var o=t.width/t.height,r=e/i,s=0,a=0;switch(n){case"contain":s=r<o?e:i*o,a=r<o?e/o:i;break;case"cover":default:s=r<o?i*o:e,a=r<o?i:e/o;break;case"fill":s=e,a=i}return{width:Math.round(s),height:Math.round(a),top:Math.round((i-a)/2),left:Math.round((e-s)/2)}},Viewport.getStandardQuality=function(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080},Viewport.getStandardResolution=function(t,e){if(0===t||0===e)return{width:0,height:0};if(t<e){var i=t/e<.75?9/16:.75,n=Viewport.getStandardQuality(e*i);return{width:Math.round(n),height:Math.round(n/i)}}var o=t/e>4/3?16/9:4/3,r=Viewport.getStandardQuality(t/o);return{width:Math.round(r*o),height:Math.round(r)}};var Canvas2D=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};Canvas2D.prototype.show=function(){this.element.style.opacity=1},Canvas2D.prototype.hide=function(){this.element.style.opacity=0},Canvas2D.prototype.resize=function(t,e,i){var n=Viewport.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)},Canvas2D.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)))},Canvas2D.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 Canvas3D=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=twgl.getContext(this.element),twgl.setDefaultTextureColor([1,1,1,1]),this.requestAnimationId=null};Canvas3D.prototype.show=function(){this.element.style.opacity=1},Canvas3D.prototype.hide=function(){this.element.style.opacity=0},Canvas3D.prototype.resize=function(){this.element.style.width="100%",this.element.style.height="100%",this.element.style.top=0,this.element.style.left=0};var Maths=function(){};Maths.accelerate=function(t,e){var i=e||1.5;return Math.pow(Math.abs(t),i)*(t>0?1:-1)},Maths.degreesToRadians=function(t){return t*(Math.PI/180)},Maths.mod=function(t,e){return t-e*Math.floor(t/e)};var xmlRegex=/directUrl="([^"]*)"/g,WebRender=function(t){this.server=t};WebRender.buildQuery=function(t){return Object.keys(t).filter(function(e){return void 0!==t[e]}).map(function(e){return e+"="+t[e]}).join("&")},WebRender.sceneParameters=function(t){var e=t.scene,i={},n=e.length>1?e.find(function(t){return t.master})||e[0]:null;if(n){var o=e.find(function(t){return t!==n});i.databaseId=o.database,i.configuration=o.configuration,i.decorDatabaseId=n.database,i.decorDeltaAltitude=n.translation.y}else{var r=e[0];i.databaseId=r.database,i.configuration=r.configuration,i.animations=r.animations&&r.animations.length?r.animations.join("/"):void 0}return i},WebRender.renderParameters=function(t){var e=t.parameters;return{width:e.width,height:e.height,softwareAntialiasing:e.antialiasing,superSampling:e.superSampling}},WebRender.encoderParameters=function(t){var e=t.encoder;return{imageFormat:e.format,imageQuality:e.quality}},WebRender.fetch=function(t){return axios.get(t).then(function(t){var e=t.data.replace(/&amp;/g,"&").match(xmlRegex);return e?e.map(function(t){return t.replace(xmlRegex,"$1")}):Promise.reject()})},WebRender.prototype.animation=function(t){var e={};Object.assign(e,WebRender.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,WebRender.renderParameters(t)),Object.assign(e,WebRender.encoderParameters(t));var i=WebRender.buildQuery(e);return WebRender.fetch(this.server+"/ImagesFromAnimation?"+i)},WebRender.prototype.image=function(t){var e={};Object.assign(e,WebRender.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,WebRender.renderParameters(t)),Object.assign(e,WebRender.encoderParameters(t));var i=WebRender.buildQuery(e);return Promise.resolve(this.server+"/ImageFromBookmark?"+i)},WebRender.prototype.video=function(t){var e={};Object.assign(e,WebRender.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,WebRender.renderParameters(t)),Object.assign(e,WebRender.encoderParameters(t));var i=WebRender.buildQuery(e);return Promise.resolve(this.server+"/ImagesFromAnimation?"+i)},WebRender.prototype.vrCube=function(t){var e={};Object.assign(e,WebRender.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(e,WebRender.renderParameters(t)),Object.assign(e,WebRender.encoderParameters(t)),e.width=Math.max(e.width,e.height),e.height=Math.max(e.width,e.height);var i=WebRender.buildQuery(e);return WebRender.fetch(this.server+"/CubeFromBookmark?"+i)},WebRender.prototype.vrObject=function(t){var e={};Object.assign(e,WebRender.sceneParameters(t)),Object.assign(e,{bookmarkSet:t.view.camera,background:t.view.background}),Object.assign(e,WebRender.renderParameters(t)),Object.assign(e,WebRender.encoderParameters(t));var i=WebRender.buildQuery(e);return WebRender.fetch(this.server+"/ImagesFromBookmarkSet?"+i)};var Loader=function(t,e){this.webrender=new WebRender(t),this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=e.onLoadStart||function(){},this.onLoadProgress=e.onLoadProgress||function(){},this.onLoadEnd=e.onLoadEnd||function(){}},prototypeAccessors={progress:{configurable:!0}};prototypeAccessors.progress.get=function(){return this.total?this.loaded/this.total:0},Loader.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},Loader.prototype.loadImageFrames=function(t,e,i,n){var o=this;this.total=t.length;for(var r=new Array(t.length),s=i||0,a=0,h=t.length;a<h;a+=1){var c=Math.ceil(a/2)*(a%2==0?1:-1),d=e?Maths.mod(s+c,h):a;r[d]=o.loadImage(t[d],n)}return Promise.all(r).then(function(){return o.onLoadEnd(o.progress)}),r},Loader.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},Loader.prototype.loadVideoFrame=function(t,e,i,n,o){var r=this,s=0;return new Promise(function(a,h){var c=function(){if(o===r.loadingId){if(s!==n)return void(s+=1);t.removeEventListener("seeked",c);var h=document.createElement("canvas");h.width=t.videoWidth,h.height=t.videoHeight,h.getContext("2d").drawImage(t,0,0),a(h),r.loaded+=1,r.onLoadProgress(r.progress),n!==i-1&&(t.currentTime+=1/e)}};t.addEventListener("seeked",c),t.addEventListener("error",function(t){o===r.loadingId&&h(t)},{once:!0})})},Loader.prototype.loadVideoFrames=function(t,e,i,n){var o=this;this.total=e;for(var r=new Array(e),s=document.createElement("video"),a=0,h=e;a<h;a+=1)r[a]=o.loadVideoFrame(s,i,e,a,n);return s.addEventListener("canplaythrough",function(){n===o.loadingId&&(s.currentTime=1/i/2)},{once:!0}),s.src=t,s.load(),Promise.all(r).then(function(){return o.onLoadEnd(o.progress)}),r},Loader.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})},Loader.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})},Loader.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})},Loader.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(Loader.prototype,prototypeAccessors);var Video=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")};Video.prototype.show=function(){this.element.style.opacity=1},Video.prototype.hide=function(){this.element.style.opacity=0},Video.prototype.resize=function(t,e,i){var n=Viewport.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 WidgetImage=function(t,e,i){this.container=t,this.canvas=e,this.loader=i,this.image=null,this.goto=function(){},this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};WidgetImage.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-image")},WidgetImage.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-image")},WidgetImage.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 WidgetVideo=function(t,e,i){this.container=t,this.loader=i,this.video=e,this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};WidgetVideo.prototype.show=function(){this.video.show(),this.container.classList.add("ls-viewer-container-video")},WidgetVideo.prototype.hide=function(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")},WidgetVideo.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))},WidgetVideo.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 Event=function(){};Event.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 Basis3=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];3===e.length?(t=e,this.u=t[0],this.v=t[1],this.o=t[2],this.w=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])},prototypeAccessors$1={localToGlobalMatrix:{configurable:!0},globalToLocalMatrix:{configurable:!0}};prototypeAccessors$1.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])},prototypeAccessors$1.globalToLocalMatrix.get=function(){return m4.inverse(this.localToGlobalMatrix)},Object.defineProperties(Basis3.prototype,prototypeAccessors$1);var Inertia=function(t){this.animationFrameId=null,this.points=[],this.onMotion=t,this.loop=this.loop.bind(this)};Inertia.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},Inertia.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)}},Inertia.prototype.stop=function(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.points=[]},Inertia.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 InteractiveCamera=function(t,e,i){this.changed=!1,this.isStarted=!1,this.inertia=new Inertia(this.motion.bind(this)),this.fov=Maths.degreesToRadians(t),this.pov=e,this.orientationMatrix=m4.identity(),this.initFov=this.fov,this.initPov=this.pov,this.initOrientation=Maths.degreesToRadians(window.orientation)||0,this.onMotion=i},prototypeAccessors$2={orientedPov:{configurable:!0}};prototypeAccessors$2.orientedPov.get=function(){var t=v3.normalize(v3.cross(this.pov.up,this.pov.target)),e=new Basis3(t,[0,1,0],this.pov.eye),i=m4.identity();return m4.multiply(i,e.localToGlobalMatrix,i),m4.multiply(i,this.orientationMatrix,i),m4.multiply(i,e.globalToLocalMatrix,i),{eye:this.pov.eye,target:m4.transformDirection(i,this.pov.target),up:m4.transformDirection(i,this.pov.up)}},InteractiveCamera.prototype.reset=function(){this.fov=this.initFov,this.pov={eye:Array.from(this.initPov.eye),target:Array.from(this.initPov.target),up:Array.from(this.initPov.up)}},InteractiveCamera.prototype.start=function(t,e){this.changed=!1,this.isStarted=!0,this.startPov=this.pov,this.startPoint=t,this.startSize=e,this.previousPoint=t,this.inertia.stop()},InteractiveCamera.prototype.motion=function(t){this.isStarted&&this.inertia.track(t);var e={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},i=Maths.accelerate(e.x,1.3)/this.startSize.width*.2*Math.PI*1.5,n=Maths.accelerate(e.y,1.3)/this.startSize.height*.2*Math.PI,o=m4.multiply(m4.rotationY(-i),m4.rotationX(-n)),r=v3.normalize(v3.cross(this.pov.up,this.pov.target)),s=new Basis3(r,[0,1,0],this.pov.eye),a=m4.identity();m4.multiply(a,s.localToGlobalMatrix,a),m4.multiply(a,o,a),m4.multiply(a,s.globalToLocalMatrix,a);var h=m4.transformPoint(a,this.pov.target),c=m4.transformDirection(a,this.pov.up);v3.cross(c,[0,0,1])[0]>=0&&(this.pov.target=h,this.pov.up=c),this.previousPoint={x:t.x,y:t.y},this.onMotion(),this.changed=!0},InteractiveCamera.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()},InteractiveCamera.prototype.orientation=function(t){if(null!==t.alpha&&null!==t.beta&&null!==t.gamma){var e=Maths.degreesToRadians(window.orientation)||0,i=Maths.degreesToRadians(t.alpha),n=Maths.degreesToRadians(-t.beta),o=Maths.degreesToRadians(-t.gamma),r=m4.rotationX(Maths.degreesToRadians(90));m4.rotateZ(r,this.initOrientation,r),m4.rotateZ(r,i,r),m4.rotateX(r,n,r),m4.rotateY(r,o,r),m4.rotateZ(r,-e,r),this.orientationMatrix=r,this.onMotion()}},Object.defineProperties(InteractiveCamera.prototype,prototypeAccessors$2);var WidgetVRCubeFragmentShader="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);}",WidgetVRCubeVertexShader="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);}",WidgetVRCube=function(t,e,i,n){var o=this;this.container=t,this.canvas=e,this.loader=i,this.onInteraction=n;var r={eye:[0,0,0],target:[0,0,1],up:[0,1,0]},s=twgl.m4.rotationX(Maths.degreesToRadians(15));twgl.m4.transformDirection(s,r.target,r.target),twgl.m4.transformDirection(s,r.up,r.up),this.interaction=new InteractiveCamera(60,r,function(){requestAnimationFrame(o.render)}),this.gl=this.canvas.context,this.programInfo=twgl.createProgramInfo(this.gl,[WidgetVRCubeVertexShader+"\n",WidgetVRCubeFragmentShader+"\n"]),this.quad=twgl.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:twgl.m4.identity(),u_mix:0,u_texture_back:twgl.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:twgl.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(){}};WidgetVRCube.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")},WidgetVRCube.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")},WidgetVRCube.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){twgl.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))})}))},WidgetVRCube.prototype.render=function(){twgl.resizeCanvasToDisplaySize(this.gl.canvas,window.devicePixelRatio),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var t=this.interaction.fov,e=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,i=twgl.m4.inverse(twgl.m4.perspective(t,e,.5,100)),n=this.interaction.orientedPov,o=twgl.m4.lookAt(n.eye,n.target,n.up);this.uniforms.u_matrix=twgl.m4.multiply(o,i),this.gl.useProgram(this.programInfo.program),twgl.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),twgl.setUniforms(this.programInfo,this.uniforms),twgl.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))},WidgetVRCube.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(Event.point(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})},WidgetVRCube.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!1))},WidgetVRCube.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(Event.point(t)),t.preventDefault())},WidgetVRCube.prototype.onEnd=function(){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!0),this.interaction.changed&&this.onInteraction())},WidgetVRCube.prototype.onDeviceOrientation=function(t){this.interaction.orientation({alpha:t.alpha,beta:t.beta,gamma:t.gamma})};var InteractivePosition=function(t,e,i,n){this.changed=!1,this.isStarted=!1,this.inertia=new Inertia(this.motion.bind(this)),this.position=t,this.count=e,this.loop=i,this.onMotion=n,this.initPosition=this.position};InteractivePosition.prototype.set=function(t){var e=this.position;this.loop?this.position=Maths.mod(t,this.count):this.position=Math.max(0,Math.min(t,this.count-1)),this.position!==e&&(this.onMotion(),this.changed=!0)},InteractivePosition.prototype.reset=function(){this.position=this.initPosition},InteractivePosition.prototype.start=function(t,e){this.changed=!1,this.isStarted=!0,this.startPosition=this.position,this.startPoint=t,this.startSize=e,this.inertia.stop()},InteractivePosition.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=Maths.accelerate(e.x,1.3)/this.startSize.width*(this.count/4),n=this.startPosition-Math.round(i);this.set(n)},InteractivePosition.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()};var WidgetVRObject=function(t,e,i,n){var o=this;this.container=t,this.canvas=e,this.loader=i,this.onInteraction=n,this.images=[],this.interaction=new InteractivePosition(0,1,!1,function(){o.canvas.draw(o.image,!0,.5)}),this.options={loop:!0},this.onDeviceOrientation=function(){}},prototypeAccessors$3={image:{configurable:!0}};WidgetVRObject.prototype.show=function(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrobject")},WidgetVRObject.prototype.hide=function(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrobject")},WidgetVRObject.prototype.set=function(t){this.interaction.position=t},WidgetVRObject.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.interaction.set(Math.floor(n)),requestAnimationFrame(o)}};requestAnimationFrame(o)})},prototypeAccessors$3.image.get=function(){return this.images[this.interaction.position]},WidgetVRObject.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]})},WidgetVRObject.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(Event.point(t),{width:this.canvas.element.width,height:this.canvas.element.height})},WidgetVRObject.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(!1))},WidgetVRObject.prototype.onMove=function(t){this.interaction.isStarted&&(this.interaction.motion(Event.point(t)),t.preventDefault())},WidgetVRObject.prototype.onEnd=function(){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(!0),this.interaction.changed&&this.onInteraction())},Object.defineProperties(WidgetVRObject.prototype,prototypeAccessors$3);var css=".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;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}";__$$styleInject(css);var LSViewer=function(t,e){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onInteraction=this.onInteraction.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.container=t,this.container.classList.add("ls-viewer-container"),this.canvas2D=new Canvas2D,this.container.appendChild(this.canvas2D.element),this.canvas3D=new Canvas3D,this.container.appendChild(this.canvas3D.element),this.video=new Video,this.container.appendChild(this.video.element),this.options=Object.assign({},{server:"localhost"},e),this.options.events=Object.assign({},{onInteraction:function(){},onLoadStart:function(){},onLoadProgress:function(){},onLoadEnd:function(){},onLoadError:function(){}},e.events),this.loader=new Loader(e.server,{onLoadStart:this.onLoadStart,onLoadProgress:this.onLoadProgress,onLoadEnd:this.onLoadEnd,onLoadError:this.onLoadError}),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 WidgetImage(t,this.canvas2D,this.loader,this.onInteraction),video:new WidgetVideo(t,this.video,this.loader,this.onInteraction),vrcube:new WidgetVRCube(t,this.canvas3D,this.loader,this.onInteraction),vrobject:new WidgetVRObject(t,this.canvas2D,this.loader,this.onInteraction)},this.widget=this.widgets.image,this.container.addEventListener("mousedown",this.onStart),this.container.addEventListener("mouseenter",this.onEnter),this.container.addEventListener("mousemove",this.onMove),this.container.addEventListener("mouseup",this.onEnd),this.container.addEventListener("touchstart",this.onStart),this.container.addEventListener("touchmove",this.onMove),this.container.addEventListener("touchend",this.onEnd),window.addEventListener("deviceorientation",this.onDeviceOrientation),this.checkResize(),this.loadWidget=debounce(this.loadWidget,10),this.onResize=debounce(this.onResize,250)};LSViewer.prototype.destroy=function(){this.container.removeEventListener("mousedown",this.onStart),this.container.removeEventListener("mouseenter",this.onEnter),this.container.removeEventListener("mousemove",this.onMove),this.container.removeEventListener("mouseup",this.onEnd),this.container.removeEventListener("touchstart",this.onStart),this.container.removeEventListener("touchmove",this.onMove),this.container.removeEventListener("touchend",this.onEnd),window.removeEventListener("deviceorientation",this.onDeviceOrientation),this.isDestroyed=!0},LSViewer.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)?cloneDeep(t):[cloneDeep(t)],i.loadWidget(!1,!(e&&e.animation))})).catch(function(){})},LSViewer.prototype.setEncoder=function(t){var e=this;this.encoder=cloneDeep(t);var i=Promise.resolve();(i=i.then(function(){return e.loadWidget(!1,!0)})).catch(function(){})},LSViewer.prototype.setParameters=function(t){var e=this;this.parameters=cloneDeep(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(){})},LSViewer.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=cloneDeep(t),i.view&&e&&void 0!==e.toPosition&&(n=!1,i.widgets[i.view.mode].set(e.toPosition)),i.loadWidget(n,!(e&&e.animation))})).catch(function(){})},LSViewer.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)})},LSViewer.prototype.playAnimation=function(t){var e=this;return this.loadAnimation(t).then(function(){return e.widgets.video.play()})},LSViewer.prototype.stopAnimation=function(){this.widgets.video.hide()},LSViewer.prototype.loadWidget=function(t,e){var i=this;if(!this.scene||!this.view)return Promise.reject();if(!this.parameters.width||!this.parameters.height)return Promise.reject();var n=this.widgets[this.view.mode];if(!n)return Promise.reject();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()},function(t){i.onLoadError(t)})},LSViewer.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)}},LSViewer.prototype.onStart=function(t){this.widget.onStart(t)},LSViewer.prototype.onEnter=function(t){this.widget.onEnter(t)},LSViewer.prototype.onMove=function(t){this.widget.onMove(t)},LSViewer.prototype.onEnd=function(t){this.widget.onEnd(t)},LSViewer.prototype.onDeviceOrientation=function(t){this.widget.onDeviceOrientation(t)},LSViewer.prototype.onResize=function(){var t=window.devicePixelRatio,e=this.container.offsetWidth*t,i=this.container.offsetHeight*t;this.resolution=Viewport.getStandardResolution(e,i),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(e/t,i/t,this.resolution),this.canvas3D.resize(e/t,i/t,this.resolution),this.video.resize(e/t,i/t,this.resolution),this.loadWidget(!1,!1).catch(function(){})},LSViewer.prototype.onInteraction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.options.events.onInteraction(t)},LSViewer.prototype.onLoadStart=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(t)},LSViewer.prototype.onLoadProgress=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.options.events.onLoadProgress(t)},LSViewer.prototype.onLoadEnd=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(t)},LSViewer.prototype.onLoadError=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadError(t)};export default LSViewer;
{
"name": "@lumiscaphe/viewer",
"version": "0.5.8",
"version": "0.5.9",
"description": "Lumiscaphe 3D Viewer",

@@ -14,4 +14,4 @@ "main": "dist/index.js",

"axios": "^0.18.0",
"debounce-promise": "^3.1.0",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"twgl.js": "^4.4.0"

@@ -29,4 +29,6 @@ },

"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-eslint": "^4.0.0",
"rollup-plugin-glsl": "^1.1.0",
"rollup-plugin-node-resolve": "^3.2.0",
"rollup-plugin-postcss": "1.2.8",

@@ -33,0 +35,0 @@ "rollup-plugin-uglify-es": "^0.0.1",

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