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 0.2.4 to 0.2.5

2

dist/index.js

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

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("lodash.debounce"),require("twgl.js")):"function"==typeof define&&define.amd?define(["lodash.debounce","twgl.js"],i):t.viewer=i(t.debounce,t.twgl)}(this,function(t,i){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="default"in i?i.default:i,n=function(){};n.fit=function(t,i,e,n){var o=t.width/t.height,s=i/e,r=0,a=0;switch(n){case"contain":r=s<o?i:e*o,a=s<o?i/o:e;break;case"cover":default:r=s<o?e*o:i,a=s<o?e:i/o;break;case"fill":r=i,a=e}return{width:Math.round(r),height:Math.round(a),top:Math.round((e-a)/2),left:Math.round((i-r)/2)}},n.getStandardQuality=function(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080},n.getStandardResolution=function(t,i){if(0===t||0===i)return{width:0,height:0};if(t<i){var e=t/i<.75?9/16:.75,o=n.getStandardQuality(i*e);return{width:Math.round(o),height:Math.round(o/e)}}var s=t/i>4/3?16/9:4/3,r=n.getStandardQuality(t/s);return{width:Math.round(r*s),height:Math.round(r)}};var o=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.requestAnimationId=null};o.prototype.show=function(){this.element.style.opacity=1},o.prototype.hide=function(){this.element.style.opacity=0},o.prototype.resize=function(t,i,e){var o=n.fit(e,t,i,"cover");this.element.style.width=o.width+"px",this.element.style.height=o.height+"px",this.element.style.top=o.top+"px",this.element.style.left=o.left+"px",e.width===this.element.width&&e.height===this.element.height||(this.element.width=e.width,this.element.height=e.height)},o.prototype.draw=function(t,i,e){t&&(this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=null),i?(this.context.globalAlpha=0,this.fadeInLoop(t,e)):(this.context.globalAlpha=1,this.context.drawImage(t,0,0,this.element.width,this.element.height)))},o.prototype.fadeInLoop=function(t,i){var e=this;if(this.context.globalAlpha>1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=null);this.context.globalAlpha+=i,this.context.drawImage(t,0,0,this.element.width,this.element.height),this.requestAnimationId=requestAnimationFrame(function(){e.fadeInLoop(t,i)})};var s=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=e.getContext(this.element),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,i,e){this.element.style.width="100%",this.element.style.height="100%",this.element.style.top=0,this.element.style.left=0,e.width===this.element.width&&e.height===this.element.height||(this.element.width=e.width,this.element.height=e.height)};var r=function(t){this.server=t};r.buildQuery=function(t){return Object.keys(t).map(function(i){return i+"="+t[i]}).join("&")},r.sceneParameters=function(t){var i=t.scene,e={},n=i.length>1?i.find(function(t){return t.master})||i[0]:null;if(n){var o=i.find(function(t){return t!==n});e.databaseId=o.database,e.configuration=o.configuration,e.decorDatabaseId=n.database,e.decorDeltaAltitude=n.translation.y}else{var s=i[0];e.databaseId=s.database,e.configuration=s.configuration}return e},r.renderParameters=function(t){var i=t.parameters;return{width:i.width,height:i.height,softwareAntialiasing:i.antialiasing,superSampling:i.superSampling}},r.encoderParameters=function(t){var i=t.encoder;return{imageFormat:i.format,imageQuality:i.quality}},r.fetch=function(t){return fetch(t).then(function(t){return t.text()}).then(function(t){var i=t.replace(/&amp;/g,"&").match(/directUrl="([^"]*)"/g);return i?i.map(function(t){return t.replace(/directUrl="([^"]*)"/g,"$1")}):Promise.reject()})},r.prototype.image=function(t){var i={};Object.assign(i,r.sceneParameters(t)),Object.assign(i,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(i,r.renderParameters(t)),Object.assign(i,r.encoderParameters(t));var e=r.buildQuery(i);return Promise.resolve(this.server+"/ImageFromBookmark?"+e)},r.prototype.vrCube=function(t){var i={};Object.assign(i,r.sceneParameters(t)),Object.assign(i,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(i,r.renderParameters(t)),Object.assign(i,r.encoderParameters(t)),i.width=Math.max(i.width,i.height),i.height=Math.max(i.width,i.height);var e=r.buildQuery(i);return r.fetch(this.server+"/CubeFromBookmark?"+e)},r.prototype.vrObject=function(t){var i={};Object.assign(i,r.sceneParameters(t)),Object.assign(i,{bookmarkSet:t.view.camera,background:t.view.background}),Object.assign(i,r.renderParameters(t)),Object.assign(i,r.encoderParameters(t));var e=r.buildQuery(i);return r.fetch(this.server+"/ImagesFromBookmarkSet?"+e)},r.prototype.animation=function(t){var i={};Object.assign(i,r.sceneParameters(t)),Object.assign(i,{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(i,r.renderParameters(t)),Object.assign(i,r.encoderParameters(t));var e=r.buildQuery(i);return r.fetch(this.server+"/ImagesFromAnimation?"+e)};var a=function(t,i){this.webrender=new r(t),this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i.onLoadStart||function(){},this.onLoadProgress=i.onLoadProgress||function(){},this.onLoadEnd=i.onLoadEnd||function(){}},h={progress:{configurable:!0}};h.progress.get=function(){return this.total?this.loaded/this.total:0},a.prototype.loadImage=function(t,i){var e=this,n=new Image;n.crossOrigin="anonymous";var o=new Promise(function(t,o){n.addEventListener("load",function(){i===e.loadingId&&(e.loaded+=1,e.onLoadProgress(e.progress),t(n))}),n.addEventListener("error",function(t){i===e.loadingId&&o(t)})});return n.src=t,o},a.prototype.loadVideoFrames=function(t,i,e,n){var o=this,s=1/e/2,r=[],a=document.createElement("video");a.autoplay=!0,a.muted=!0,a.playsinline=!0,a.preload="auto";var h=new Promise(function(t,h){a.addEventListener("loadeddata",function(){n===o.loadingId&&(a.currentTime=s)}),a.addEventListener("seeked",function(){if(n===o.loadingId){var h=document.createElement("canvas");h.width=a.videoWidth,h.height=a.videoHeight,h.getContext("2d").drawImage(a,0,0),r.push(h),o.loaded+=1,o.onLoadProgress(o.progress),(s+=1/e)<=i/e?a.currentTime=s:t(r)}}),a.addEventListener("error",function(t){n===o.loadingId&&h(t)})});return a.src=t,h},a.prototype.loadImageSnapshot=function(t){var i=this;this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);var e=this.loadingId;return this.webrender.image(t).then(function(t){return i.loadImage(t,e)}).then(function(t){return i.onLoadEnd(i.progress),t})},a.prototype.loadVRCubeSnapshot=function(t){var i=this;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);var e=this.loadingId;return this.webrender.vrCube(t).then(function(t){return i.total=t.length,Promise.all(t.map(function(t){return i.loadImage(t,e)}))}).then(function(t){return i.onLoadEnd(i.progress),t})},a.prototype.loadVRObjectSnapshot=function(t){var i=this;this.loaded=0,this.total=0,this.onLoadStart(this.progress);var e=this.loadingId,n=t.view.animation?"animation":"vrObject";return this.webrender[n](t).then(function(t){return i.total=t.length,Promise.all(t.map(function(t){return i.loadImage(t,e)}))}).then(function(t){return i.onLoadEnd(i.progress),t})},Object.defineProperties(a.prototype,h);var c=function(t,i,e){this.container=t,this.canvas=i,this.loader=e,this.image=null,this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};c.prototype.load=function(t,i,e){var n=this,o=JSON.stringify(t);return o===this.hash?(this.canvas.draw(this.image,e,.01),Promise.resolve()):(this.hash=o,this.loader.loadImageSnapshot(t).then(function(t){n.image=t,n.canvas.draw(n.image,e,.01)}))};var d=function(){};d.point=function(t){if("touchmove"===t.type||"touchstart"===t.type||"touchend"===t.type){var i=t.targetTouches[0]||t.changedTouches[0];return{x:i.screenX,y:i.screenY}}return{x:t.screenX,y:t.screenY}};var l=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(3===t.length){var n;n=t,this.u=n[0],this.v=n[1],this.o=n[2],this.w=i.v3.cross(this.u,this.v)}else this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0]},u={localToGlobalMatrix:{configurable:!0},globalToLocalMatrix:{configurable:!0}};u.localToGlobalMatrix.get=function(){var t=[this.u[0],this.u[1],this.u[2],0],i=[this.v[0],this.v[1],this.v[2],0],e=[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,i,e,n])},u.globalToLocalMatrix.get=function(){return i.m4.inverse(this.localToGlobalMatrix)},Object.defineProperties(l.prototype,u);var m=function(t){this.animationFrameId=null,this.points=[],this.onMotion=t,this.loop=this.loop.bind(this)};m.prototype.track=function(t){var i=Date.now();this.points=this.points.filter(function(t){return i-t.time<=100}),this.points.push({x:t.x,y:t.y,time:i}),this.lastPoint=t},m.prototype.start=function(){if(0!==this.points.length){var t=this.points[0],i=this.points[this.points.length-1],e=i.x-t.x,n=i.y-t.y,o=i.time-t.time;this.velocity={x:0===o?0:e/(o/15),y:0===o?0:n/(o/15)},this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.animationFrameId=requestAnimationFrame(this.loop)}},m.prototype.stop=function(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.points=[]},m.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 p=function(){};p.accelerate=function(t,i){var e=i||1.5;return Math.pow(Math.abs(t),e)*(t>0?1:-1)},p.degreesToRadians=function(t){return t*(Math.PI/180)},p.mod=function(t,i){return t-i*Math.floor(t/i)};var v=function(t,i,e){this.changed=!1,this.isStarted=!1,this.inertia=new m(this.motion.bind(this)),this.fov=p.degreesToRadians(t),this.pov=i,this.initFov=this.fov,this.initPov=this.pov,this.onMotion=e};v.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)}},v.prototype.start=function(t,i){this.changed=!1,this.isStarted=!0,this.startPov=this.pov,this.startPoint=t,this.startSize=i,this.previousPoint=t,this.inertia.stop()},v.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=p.accelerate(e.x,1.2)/this.startSize.width*.2*Math.PI*1.5,o=p.accelerate(e.y,1.2)/this.startSize.height*.2*Math.PI,s=i.m4.multiply(i.m4.rotationY(-n),i.m4.rotationX(-o)),r=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),a=new l(r,[0,1,0],this.pov.eye),h=i.m4.identity();i.m4.multiply(h,a.localToGlobalMatrix,h),i.m4.multiply(h,s,h),i.m4.multiply(h,a.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=c,this.pov.up=d),this.previousPoint={x:t.x,y:t.y},this.onMotion(),this.changed=!0},v.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()},v.prototype.orientation=function(t){var e=p.degreesToRadians(90-t.beta),n=p.degreesToRadians(-t.alpha),o=i.m4.identity();i.m4.multiply(o,i.m4.rotationZ(0),o),i.m4.multiply(o,i.m4.rotationY(n),o),i.m4.multiply(o,i.m4.rotationX(e),o),this.reset();var s=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),r=new l(s,[0,1,0],this.pov.eye),a=i.m4.identity();i.m4.multiply(a,r.localToGlobalMatrix,a),i.m4.multiply(a,o,a),i.m4.multiply(a,r.globalToLocalMatrix,a);var h=i.m4.transformPoint(a,this.pov.target),c=i.m4.transformDirection(a,this.pov.up);i.v3.cross(c,[0,0,1])[0]>=0&&(this.pov.target=h,this.pov.up=c),this.onMotion()};var g=function(t,i,n,o){var s=this;this.container=t,this.canvas=i,this.loader=n,this.onInteraction=o,this.images=[];var r={eye:[0,0,0],target:[0,0,1],up:[0,1,0]},a=e.m4.rotationX(p.degreesToRadians(15));e.m4.transformDirection(a,r.target,r.target),this.interaction=new v(60,r,function(){requestAnimationFrame(s.render)}),this.gl=this.canvas.context,this.programInfo=e.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 samplerCube u_texture;varying vec3 direction;void main(){gl_FragColor=textureCube(u_texture,direction);}\n"]),this.quad=e.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_texture:e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_matrix:e.m4.identity()},this.render=this.render.bind(this)};g.prototype.load=function(t,i){var n=this,o=JSON.stringify(t);return o===this.hash?(requestAnimationFrame(this.render),Promise.resolve()):(this.hash=o,i&&this.interaction.reset(),this.images=[],requestAnimationFrame(this.render),this.loader.loadVRCubeSnapshot(t).then(function(t){n.images=t;var i=t.map(function(t){return t.src});n.uniforms.u_texture=e.createTexture(n.gl,{target:n.gl.TEXTURE_CUBE_MAP,minMag:n.gl.LINEAR,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:i,crossOrigin:"anonymous"},function(){requestAnimationFrame(n.render)})}))},g.prototype.render=function(){e.resizeCanvasToDisplaySize(this.gl.canvas),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var t=this.interaction.fov,i=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,n=e.m4.inverse(e.m4.perspective(t,i,.5,100)),o=this.interaction.pov,s=e.m4.lookAt(o.eye,o.target,o.up);this.uniforms.u_matrix=e.m4.multiply(s,n),this.gl.useProgram(this.programInfo.program),e.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),e.setUniforms(this.programInfo,this.uniforms),e.drawBufferInfo(this.gl,this.quad)},g.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(d.point(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})},g.prototype.onEnter=function(t){this.interaction.isStarted||0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!1))},g.prototype.onMove=function(t){this.interaction.isStarted&&this.interaction.motion(d.point(t))},g.prototype.onEnd=function(){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!0),this.interaction.changed&&this.onInteraction())},g.prototype.onDeviceOrientation=function(t){!1!==this.interaction.isStarted&&this.interaction.orientation({alpha:t.alpha,beta:t.beta,gamma:t.gamma})};var f=function(t,i,e,n){this.changed=!1,this.isStarted=!1,this.inertia=new m(this.motion.bind(this)),this.position=t,this.count=i,this.loop=e,this.onMotion=n,this.initPosition=this.position};f.prototype.set=function(t){var i=this.position;this.loop?this.position=p.mod(t,this.count):this.position=Math.max(0,Math.min(t,this.count-1)),this.position!==i&&(this.onMotion(),this.changed=!0)},f.prototype.reset=function(){this.set(this.initPosition)},f.prototype.start=function(t,i){this.changed=!1,this.isStarted=!0,this.startPosition=this.position,this.startPoint=t,this.startSize=i,this.inertia.stop()},f.prototype.motion=function(t){this.isStarted&&this.inertia.track(t);var i={x:t.x-this.startPoint.x,y:t.y-this.startPoint.y},e=p.accelerate(i.x,1.2)/this.startSize.width*(this.count/4),n=this.startPosition-Math.round(e);this.set(n)},f.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()};var b=function(t,i,e,n){var o=this;this.container=t,this.canvas=i,this.loader=e,this.onInteraction=n,this.images=[],this.interaction=new f(0,1,!1,function(){o.canvas.draw(o.image,!0,.25)}),this.options={loop:!0},this.onDeviceOrientation=function(){}},y={image:{configurable:!0}};y.image.get=function(){return this.images[this.interaction.position]},b.prototype.load=function(t,i,e){var n=this,o=JSON.stringify(t);return o===this.hash?(this.canvas.draw(this.image,e,.01),Promise.resolve()):(this.hash=o,i&&this.interaction.reset(),this.images=[],this.loader.loadVRObjectSnapshot(t).then(function(i){n.images=i,n.interaction.count=i.length,n.interaction.loop=t.view.loop,n.canvas.draw(n.image,e,.01)}))},b.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(d.point(t),{width:this.canvas.element.width,height:this.canvas.element.height})},b.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(!1))},b.prototype.onMove=function(t){this.interaction.isStarted&&this.interaction.motion(d.point(t))},b.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(b.prototype,y),function(t,i){if("undefined"==typeof document)return i;t=t||"";var e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}(".ls-viewer-container{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{cursor:default}.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}",void 0);var w=function(i,e){this.container=i,this.container.classList.add("ls-viewer-container"),this.canvas2D=new o,this.container.appendChild(this.canvas2D.element),this.canvas3D=new s,this.container.appendChild(this.canvas3D.element),this.container.addEventListener("mousedown",this.onStart.bind(this)),this.container.addEventListener("mouseenter",this.onEnter.bind(this)),this.container.addEventListener("mousemove",this.onMove.bind(this)),this.container.addEventListener("mouseup",this.onEnd.bind(this)),this.container.addEventListener("touchstart",this.onStart.bind(this)),this.container.addEventListener("touchmove",this.onMove.bind(this)),this.container.addEventListener("touchend",this.onEnd.bind(this)),this.options=Object.assign({},{server:"localhost",events:{onInteraction:function(){},onLoadStart:function(){},onLoadProgress:function(){},onLoadEnd:function(){},onError:function(){}}},e),this.loader=new a(e.server,{onLoadStart:this.onLoadStart.bind(this),onLoadProgress:this.onLoadProgress.bind(this),onLoadEnd:this.onLoadEnd.bind(this),onError:this.onError.bind(this)}),this.params=null,this.resolution={};var n=this.onInteraction.bind(this);this.widgetImage=new c(i,this.canvas2D,this.loader,n),this.widgetVRCube=new g(i,this.canvas3D,this.loader,n),this.widgetVRObject=new b(i,this.canvas2D,this.loader,n),this.widget=this.widgetImage,window.addEventListener("resize",t(this.onResize.bind(this),250)),this.onResize()};return w.prototype.load=function(t,i,e){var n=this;if(t&&(this.snapshot=t,this.resolution.width&&this.resolution.height)){this.snapshot.parameters=Object.assign({},{antialiasing:!1,superSampling:2},this.snapshot.parameters,{width:this.resolution.width,height:this.resolution.height}),this.snapshot.encoder=Object.assign({},{format:"jpeg",quality:90},this.snapshot.encoder),this.snapshot.view.background||(this.snapshot.view.background="product");var o=null;switch(t.view.mode){case"image":o=this.widgetImage,this.container.classList.remove("ls-viewer-container-vrcube"),this.container.classList.remove("ls-viewer-container-vrobject"),this.container.classList.add("ls-viewer-container-image");break;case"vrcube":o=this.widgetVRCube,this.container.classList.remove("ls-viewer-container-image"),this.container.classList.remove("ls-viewer-container-vrobject"),this.container.classList.add("ls-viewer-container-vrcube");break;case"vrobject":o=this.widgetVRObject,this.container.classList.remove("ls-viewer-container-image"),this.container.classList.remove("ls-viewer-container-vrcube"),this.container.classList.add("ls-viewer-container-vrobject")}o&&o.load(t,i,e).then(function(){o.canvas!==n.widget.canvas&&n.widget.canvas.hide(),o.canvas.show(),n.widget=o},function(t){n.options.events.onError(t)})}},w.prototype.onDeviceOrientation=function(t){this.widget.onDeviceOrientation(t)},w.prototype.onStart=function(t){this.widget.onStart(t)},w.prototype.onEnter=function(t){this.widget.onEnter(t)},w.prototype.onMove=function(t){this.widget.onMove(t)},w.prototype.onEnd=function(t){this.widget.onEnd(t)},w.prototype.onResize=function(){var t=this.container.offsetWidth,i=this.container.offsetHeight;this.resolution=n.getStandardResolution(t,i),this.canvas2D.resize(t,i,this.resolution),this.canvas3D.resize(t,i,this.resolution),this.load(this.snapshot,!1,!1)},w.prototype.onInteraction=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.options.events.onInteraction(t)},w.prototype.onLoadStart=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(t)},w.prototype.onLoadProgress=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.options.events.onLoadProgress(t)},w.prototype.onLoadEnd=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(t)},w.prototype.onError=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.options.events.onError(t)},w});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("lodash.debounce"),require("twgl.js")):"function"==typeof define&&define.amd?define(["lodash.debounce","twgl.js"],i):t.viewer=i(t.debounce,t.twgl)}(this,function(t,i){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="default"in i?i.default:i,n=function(){};n.fit=function(t,i,e,n){var o=t.width/t.height,s=i/e,r=0,a=0;switch(n){case"contain":r=s<o?i:e*o,a=s<o?i/o:e;break;case"cover":default:r=s<o?e*o:i,a=s<o?e:i/o;break;case"fill":r=i,a=e}return{width:Math.round(r),height:Math.round(a),top:Math.round((e-a)/2),left:Math.round((i-r)/2)}},n.getStandardQuality=function(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080},n.getStandardResolution=function(t,i){if(0===t||0===i)return{width:0,height:0};if(t<i){var e=t/i<.75?9/16:.75,o=n.getStandardQuality(i*e);return{width:Math.round(o),height:Math.round(o/e)}}var s=t/i>4/3?16/9:4/3,r=n.getStandardQuality(t/s);return{width:Math.round(r*s),height:Math.round(r)}};var o=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.requestAnimationId=null};o.prototype.show=function(){this.element.style.opacity=1},o.prototype.hide=function(){this.element.style.opacity=0},o.prototype.resize=function(t,i,e){var o=n.fit(e,t,i,"cover");this.element.style.width=o.width+"px",this.element.style.height=o.height+"px",this.element.style.top=o.top+"px",this.element.style.left=o.left+"px",e.width===this.element.width&&e.height===this.element.height||(this.element.width=e.width,this.element.height=e.height)},o.prototype.draw=function(t,i,e){t&&(this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=null),i?(this.context.globalAlpha=0,this.fadeInLoop(t,e)):(this.context.globalAlpha=1,this.context.drawImage(t,0,0,this.element.width,this.element.height)))},o.prototype.fadeInLoop=function(t,i){var e=this;if(this.context.globalAlpha>1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=null);this.context.globalAlpha+=i,this.context.drawImage(t,0,0,this.element.width,this.element.height),this.requestAnimationId=requestAnimationFrame(function(){e.fadeInLoop(t,i)})};var s=function(){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity=0,this.context=e.getContext(this.element),e.setDefaultTextureColor([1,1,1,1]),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,i,e){this.element.style.width="100%",this.element.style.height="100%",this.element.style.top=0,this.element.style.left=0,e.width===this.element.width&&e.height===this.element.height||(this.element.width=e.width,this.element.height=e.height)};var r=function(){};r.accelerate=function(t,i){var e=i||1.5;return Math.pow(Math.abs(t),e)*(t>0?1:-1)},r.degreesToRadians=function(t){return t*(Math.PI/180)},r.mod=function(t,i){return t-i*Math.floor(t/i)};var a=function(t){this.server=t};a.buildQuery=function(t){return Object.keys(t).map(function(i){return i+"="+t[i]}).join("&")},a.sceneParameters=function(t){var i=t.scene,e={},n=i.length>1?i.find(function(t){return t.master})||i[0]:null;if(n){var o=i.find(function(t){return t!==n});e.databaseId=o.database,e.configuration=o.configuration,e.decorDatabaseId=n.database,e.decorDeltaAltitude=n.translation.y}else{var s=i[0];e.databaseId=s.database,e.configuration=s.configuration}return e},a.renderParameters=function(t){var i=t.parameters;return{width:i.width,height:i.height,softwareAntialiasing:i.antialiasing,superSampling:i.superSampling}},a.encoderParameters=function(t){var i=t.encoder;return{imageFormat:i.format,imageQuality:i.quality}},a.fetch=function(t){return fetch(t).then(function(t){return t.text()}).then(function(t){var i=t.replace(/&amp;/g,"&").match(/directUrl="([^"]*)"/g);return i?i.map(function(t){return t.replace(/directUrl="([^"]*)"/g,"$1")}):Promise.reject()})},a.prototype.image=function(t){var i={};Object.assign(i,a.sceneParameters(t)),Object.assign(i,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(i,a.renderParameters(t)),Object.assign(i,a.encoderParameters(t));var e=a.buildQuery(i);return Promise.resolve(this.server+"/ImageFromBookmark?"+e)},a.prototype.vrCube=function(t){var i={};Object.assign(i,a.sceneParameters(t)),Object.assign(i,{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],background:t.view.background}),Object.assign(i,a.renderParameters(t)),Object.assign(i,a.encoderParameters(t)),i.width=Math.max(i.width,i.height),i.height=Math.max(i.width,i.height);var e=a.buildQuery(i);return a.fetch(this.server+"/CubeFromBookmark?"+e)},a.prototype.vrObject=function(t){var i={};Object.assign(i,a.sceneParameters(t)),Object.assign(i,{bookmarkSet:t.view.camera,background:t.view.background}),Object.assign(i,a.renderParameters(t)),Object.assign(i,a.encoderParameters(t));var e=a.buildQuery(i);return a.fetch(this.server+"/ImagesFromBookmarkSet?"+e)},a.prototype.animation=function(t){var i={};Object.assign(i,a.sceneParameters(t)),Object.assign(i,{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(i,a.renderParameters(t)),Object.assign(i,a.encoderParameters(t));var e=a.buildQuery(i);return a.fetch(this.server+"/ImagesFromAnimation?"+e)};var h=function(t,i){this.webrender=new a(t),this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=i.onLoadStart||function(){},this.onLoadProgress=i.onLoadProgress||function(){},this.onLoadEnd=i.onLoadEnd||function(){}},c={progress:{configurable:!0}};c.progress.get=function(){return this.total?this.loaded/this.total:0},h.prototype.loadImage=function(t,i){var e=this,n=new Image;n.crossOrigin="anonymous";var o=new Promise(function(t,o){n.addEventListener("load",function(){i===e.loadingId&&(e.loaded+=1,e.onLoadProgress(e.progress),t(n))}),n.addEventListener("error",function(t){i===e.loadingId&&o(t)})});return n.src=t,o},h.prototype.loadVideoFrames=function(t,i,e,n){var o=this,s=1/e/2,r=[],a=document.createElement("video");a.autoplay=!0,a.muted=!0,a.playsinline=!0,a.preload="auto";var h=new Promise(function(t,h){a.addEventListener("loadeddata",function(){n===o.loadingId&&(a.currentTime=s)}),a.addEventListener("seeked",function(){if(n===o.loadingId){var h=document.createElement("canvas");h.width=a.videoWidth,h.height=a.videoHeight,h.getContext("2d").drawImage(a,0,0),r.push(h),o.loaded+=1,o.onLoadProgress(o.progress),(s+=1/e)<=i/e?a.currentTime=s:t(r)}}),a.addEventListener("error",function(t){n===o.loadingId&&h(t)})});return a.src=t,h},h.prototype.loadImageSnapshot=function(t){var i=this;this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);var e=this.loadingId;return this.webrender.image(t).then(function(t){return i.loadImage(t,e)}).then(function(t){return i.onLoadEnd(i.progress),t})},h.prototype.loadVRCubeSnapshot=function(t){var i=this;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);var e=this.loadingId;return this.webrender.vrCube(t).then(function(t){i.total=t.length;var n=t.map(function(t){return i.loadImage(t,e)});return Promise.all(n)}).then(function(t){return i.onLoadEnd(i.progress),t})},h.prototype.loadVRObjectSnapshot=function(t,i){var e=this;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);var n=this.loadingId,o=t.view.animation?"animation":"vrObject";return this.webrender[o](t).then(function(o){e.total=o.length;for(var s=new Array(o.length),a=i||0,h=0,c=o.length;h<c;h+=1){var d=Math.ceil(h/2)*(h%2==0?1:-1),l=t.view.loop?r.mod(a+d,c):h;s[l]=e.loadImage(o[l],n)}return Promise.all(s).then(function(){return e.onLoadEnd(e.progress)}),s})},Object.defineProperties(h.prototype,c);var d=function(t,i,e){this.container=t,this.canvas=i,this.loader=e,this.image=null,this.onStart=function(){},this.onEnter=function(){},this.onMove=function(){},this.onEnd=function(){},this.onDeviceOrientation=function(){}};d.prototype.load=function(t,i,e){var n=this,o=JSON.stringify(t);return o===this.hash?(this.canvas.draw(this.image,e,.01),Promise.resolve()):(this.hash=o,this.loader.loadImageSnapshot(t).then(function(t){n.image=t,n.canvas.draw(n.image,e,.01)}))};var l=function(){};l.point=function(t){if("touchmove"===t.type||"touchstart"===t.type||"touchend"===t.type){var i=t.targetTouches[0]||t.changedTouches[0];return{x:i.screenX,y:i.screenY}}return{x:t.screenX,y:t.screenY}};var u=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(3===t.length){var n;n=t,this.u=n[0],this.v=n[1],this.o=n[2],this.w=i.v3.cross(this.u,this.v)}else this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0]},m={localToGlobalMatrix:{configurable:!0},globalToLocalMatrix:{configurable:!0}};m.localToGlobalMatrix.get=function(){var t=[this.u[0],this.u[1],this.u[2],0],i=[this.v[0],this.v[1],this.v[2],0],e=[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,i,e,n])},m.globalToLocalMatrix.get=function(){return i.m4.inverse(this.localToGlobalMatrix)},Object.defineProperties(u.prototype,m);var p=function(t){this.animationFrameId=null,this.points=[],this.onMotion=t,this.loop=this.loop.bind(this)};p.prototype.track=function(t){var i=Date.now();this.points=this.points.filter(function(t){return i-t.time<=100}),this.points.push({x:t.x,y:t.y,time:i}),this.lastPoint=t},p.prototype.start=function(){if(0!==this.points.length){var t=this.points[0],i=this.points[this.points.length-1],e=i.x-t.x,n=i.y-t.y,o=i.time-t.time;this.velocity={x:0===o?0:e/(o/15),y:0===o?0:n/(o/15)},this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.animationFrameId=requestAnimationFrame(this.loop)}},p.prototype.stop=function(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.points=[]},p.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 v=function(t,i,e){this.changed=!1,this.isStarted=!1,this.inertia=new p(this.motion.bind(this)),this.fov=r.degreesToRadians(t),this.pov=i,this.initFov=this.fov,this.initPov=this.pov,this.onMotion=e};v.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)}},v.prototype.start=function(t,i){this.changed=!1,this.isStarted=!0,this.startPov=this.pov,this.startPoint=t,this.startSize=i,this.previousPoint=t,this.inertia.stop()},v.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=r.accelerate(e.x,1.2)/this.startSize.width*.2*Math.PI*1.5,o=r.accelerate(e.y,1.2)/this.startSize.height*.2*Math.PI,s=i.m4.multiply(i.m4.rotationY(-n),i.m4.rotationX(-o)),a=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),h=new u(a,[0,1,0],this.pov.eye),c=i.m4.identity();i.m4.multiply(c,h.localToGlobalMatrix,c),i.m4.multiply(c,s,c),i.m4.multiply(c,h.globalToLocalMatrix,c);var d=i.m4.transformPoint(c,this.pov.target),l=i.m4.transformDirection(c,this.pov.up);i.v3.cross(l,[0,0,1])[0]>=0&&(this.pov.target=d,this.pov.up=l),this.previousPoint={x:t.x,y:t.y},this.onMotion(),this.changed=!0},v.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()},v.prototype.orientation=function(t){var e=r.degreesToRadians(90-t.beta),n=r.degreesToRadians(-t.alpha),o=i.m4.identity();i.m4.multiply(o,i.m4.rotationZ(0),o),i.m4.multiply(o,i.m4.rotationY(n),o),i.m4.multiply(o,i.m4.rotationX(e),o),this.reset();var s=i.v3.normalize(i.v3.cross(this.pov.up,this.pov.target)),a=new u(s,[0,1,0],this.pov.eye),h=i.m4.identity();i.m4.multiply(h,a.localToGlobalMatrix,h),i.m4.multiply(h,o,h),i.m4.multiply(h,a.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=c,this.pov.up=d),this.onMotion()};var g=function(t,i,n,o){var s=this;this.container=t,this.canvas=i,this.loader=n,this.onInteraction=o;var a={eye:[0,0,0],target:[0,0,1],up:[0,1,0]},h=e.m4.rotationX(r.degreesToRadians(15));e.m4.transformDirection(h,a.target,a.target),this.interaction=new v(60,a,function(){requestAnimationFrame(s.render)}),this.gl=this.canvas.context,this.programInfo=e.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 samplerCube u_texture;varying vec3 direction;void main(){gl_FragColor=textureCube(u_texture,direction);}\n"]),this.quad=e.primitives.createXYQuadBufferInfo(this.gl),this.uniforms={u_texture:e.createTexture(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_matrix:e.m4.identity()},this.render=this.render.bind(this)};g.prototype.load=function(t,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){var o=t.map(function(t){return t.src});n.uniforms.u_texture=e.createTexture(n.gl,{target:n.gl.TEXTURE_CUBE_MAP,minMag:n.gl.LINEAR,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:o,crossOrigin:"anonymous"},function(){i&&n.interaction.reset(),requestAnimationFrame(n.render)})}))},g.prototype.render=function(){e.resizeCanvasToDisplaySize(this.gl.canvas),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height);var t=this.interaction.fov,i=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,n=e.m4.inverse(e.m4.perspective(t,i,.5,100)),o=this.interaction.pov,s=e.m4.lookAt(o.eye,o.target,o.up);this.uniforms.u_matrix=e.m4.multiply(s,n),this.gl.useProgram(this.programInfo.program),e.setBuffersAndAttributes(this.gl,this.programInfo,this.quad),e.setUniforms(this.programInfo,this.uniforms),e.drawBufferInfo(this.gl,this.quad)},g.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(l.point(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})},g.prototype.onEnter=function(t){this.interaction.isStarted||0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!1))},g.prototype.onMove=function(t){this.interaction.isStarted&&this.interaction.motion(l.point(t))},g.prototype.onEnd=function(){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(!0),this.interaction.changed&&this.onInteraction())},g.prototype.onDeviceOrientation=function(t){!1!==this.interaction.isStarted&&this.interaction.orientation({alpha:t.alpha,beta:t.beta,gamma:t.gamma})};var f=function(t,i,e,n){this.changed=!1,this.isStarted=!1,this.inertia=new p(this.motion.bind(this)),this.position=t,this.count=i,this.loop=e,this.onMotion=n,this.initPosition=this.position};f.prototype.set=function(t){var i=this.position;this.loop?this.position=r.mod(t,this.count):this.position=Math.max(0,Math.min(t,this.count-1)),this.position!==i&&(this.onMotion(),this.changed=!0)},f.prototype.reset=function(){this.position=this.initPosition},f.prototype.start=function(t,i){this.changed=!1,this.isStarted=!0,this.startPosition=this.position,this.startPoint=t,this.startSize=i,this.inertia.stop()},f.prototype.motion=function(t){this.isStarted&&this.inertia.track(t);var i={x:t.x-this.startPoint.x,y:t.y-this.startPoint.y},e=r.accelerate(i.x,1.2)/this.startSize.width*(this.count/4),n=this.startPosition-Math.round(e);this.set(n)},f.prototype.end=function(t){this.isStarted=!1,t&&this.inertia.start()};var b=function(t,i,e,n){var o=this;this.container=t,this.canvas=i,this.loader=e,this.onInteraction=n,this.images=[],this.interaction=new f(0,1,!1,function(){o.canvas.draw(o.image,!0,.25)}),this.options={loop:!0},this.onDeviceOrientation=function(){}},y={image:{configurable:!0}};y.image.get=function(){return this.images[this.interaction.position]},b.prototype.load=function(t,i,e){var n=this,o=JSON.stringify(t);if(o===this.hash)return this.canvas.draw(this.image,e,.01),Promise.resolve();this.hash=o,this.images=[],i&&this.interaction.reset();var s=this.interaction.position;return this.loader.loadVRObjectSnapshot(t,s).then(function(i){var o=i.length;return n.images=new Array(o),n.interaction.count=o,n.interaction.loop=t.view.loop,i.forEach(function(t,i){t.then(function(t){n.images[i]=t,n.canvas.draw(n.image,e,.01)})}),i[n.interaction.position]})},b.prototype.onStart=function(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(l.point(t),{width:this.canvas.element.width,height:this.canvas.element.height})},b.prototype.onEnter=function(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(!1))},b.prototype.onMove=function(t){this.interaction.isStarted&&this.interaction.motion(l.point(t))},b.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(b.prototype,y),function(t,i){if("undefined"==typeof document)return i;t=t||"";var e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}(".ls-viewer-container{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{cursor:default}.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}",void 0);var w=function(i,e){this.container=i,this.container.classList.add("ls-viewer-container"),this.canvas2D=new o,this.container.appendChild(this.canvas2D.element),this.canvas3D=new s,this.container.appendChild(this.canvas3D.element),this.container.addEventListener("mousedown",this.onStart.bind(this)),this.container.addEventListener("mouseenter",this.onEnter.bind(this)),this.container.addEventListener("mousemove",this.onMove.bind(this)),this.container.addEventListener("mouseup",this.onEnd.bind(this)),this.container.addEventListener("touchstart",this.onStart.bind(this)),this.container.addEventListener("touchmove",this.onMove.bind(this)),this.container.addEventListener("touchend",this.onEnd.bind(this)),this.options=Object.assign({},{server:"localhost",events:{onInteraction:function(){},onLoadStart:function(){},onLoadProgress:function(){},onLoadEnd:function(){},onError:function(){}}},e),this.loader=new h(e.server,{onLoadStart:this.onLoadStart.bind(this),onLoadProgress:this.onLoadProgress.bind(this),onLoadEnd:this.onLoadEnd.bind(this),onError:this.onError.bind(this)}),this.params=null,this.resolution={};var n=this.onInteraction.bind(this);this.widgetImage=new d(i,this.canvas2D,this.loader,n),this.widgetVRCube=new g(i,this.canvas3D,this.loader,n),this.widgetVRObject=new b(i,this.canvas2D,this.loader,n),this.widget=this.widgetImage,window.addEventListener("resize",t(this.onResize.bind(this),250)),this.onResize()};return w.prototype.load=function(t,i,e){var n=this;if(t&&(this.snapshot=t,this.resolution.width&&this.resolution.height)){this.snapshot.parameters=Object.assign({},{antialiasing:!1,superSampling:2},this.snapshot.parameters,{width:this.resolution.width,height:this.resolution.height}),this.snapshot.encoder=Object.assign({},{format:"jpeg",quality:90},this.snapshot.encoder),this.snapshot.view.background||(this.snapshot.view.background="product");var o=null;switch(t.view.mode){case"image":o=this.widgetImage,this.container.classList.remove("ls-viewer-container-vrcube"),this.container.classList.remove("ls-viewer-container-vrobject"),this.container.classList.add("ls-viewer-container-image");break;case"vrcube":o=this.widgetVRCube,this.container.classList.remove("ls-viewer-container-image"),this.container.classList.remove("ls-viewer-container-vrobject"),this.container.classList.add("ls-viewer-container-vrcube");break;case"vrobject":o=this.widgetVRObject,this.container.classList.remove("ls-viewer-container-image"),this.container.classList.remove("ls-viewer-container-vrcube"),this.container.classList.add("ls-viewer-container-vrobject")}o&&o.load(t,i,e).then(function(){o.canvas!==n.widget.canvas&&n.widget.canvas.hide(),o.canvas.show(),n.widget=o},function(t){n.options.events.onError(t)})}},w.prototype.onDeviceOrientation=function(t){this.widget.onDeviceOrientation(t)},w.prototype.onStart=function(t){this.widget.onStart(t)},w.prototype.onEnter=function(t){this.widget.onEnter(t)},w.prototype.onMove=function(t){this.widget.onMove(t)},w.prototype.onEnd=function(t){this.widget.onEnd(t)},w.prototype.onResize=function(){var t=this.container.offsetWidth,i=this.container.offsetHeight;this.resolution=n.getStandardResolution(t,i),this.canvas2D.resize(t,i,this.resolution),this.canvas3D.resize(t,i,this.resolution),this.load(this.snapshot,!1,!1)},w.prototype.onInteraction=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.options.events.onInteraction(t)},w.prototype.onLoadStart=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(t)},w.prototype.onLoadProgress=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.options.events.onLoadProgress(t)},w.prototype.onLoadEnd=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(t)},w.prototype.onError=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];this.options.events.onError(t)},w});
{
"name": "@lumiscaphe/viewer",
"version": "0.2.4",
"version": "0.2.5",
"description": "Lumiscaphe 3D Viewer",

@@ -19,3 +19,3 @@ "main": "dist/index.js",

"cssnano": "^3.10.0",
"eslint": "^4.13.1",
"eslint": "^4.14.0",
"eslint-config-airbnb-base": "^12.1.0",

@@ -26,3 +26,3 @@ "eslint-plugin-import": "^2.8.0",

"postcss-reporter": "^5.0.0",
"rollup": "^0.53.0",
"rollup": "^0.53.1",
"rollup-plugin-buble": "^0.18.0",

@@ -29,0 +29,0 @@ "rollup-plugin-eslint": "^4.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