@pdftron/webviewer-bim-client
Version:
Addon for WebViewer that allows you to view, annotate, and collaborate on 3D models.
1 lines • 26.4 kB
JavaScript
var $jscomp=$jscomp||{};$jscomp.scope={},$jscomp.arrayIteratorImpl=function(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}},$jscomp.arrayIterator=function(t){return{next:$jscomp.arrayIteratorImpl(t)}},$jscomp.makeIterator=function(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):$jscomp.arrayIterator(t)},$jscomp.arrayFromIterator=function(t){for(var e,o=[];!(e=t.next()).done;)o.push(e.value);return o},$jscomp.arrayFromIterable=function(t){return t instanceof Array?t:$jscomp.arrayFromIterator($jscomp.makeIterator(t))},$jscomp.ASSUME_ES5=!1,$jscomp.ASSUME_NO_NATIVE_MAP=!1,$jscomp.ASSUME_NO_NATIVE_SET=!1,$jscomp.SIMPLE_FROUND_POLYFILL=!1,$jscomp.ISOLATE_POLYFILLS=!1,$jscomp.objectCreate=$jscomp.ASSUME_ES5||"function"==typeof Object.create?Object.create:function(t){var e=function(){};return e.prototype=t,new e},$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,o){return t==Array.prototype||t==Object.prototype||(t[e]=o.value),t},$jscomp.getGlobal=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var o=t[e];if(o&&o.Math==Math)return o}throw Error("Cannot find global object")},$jscomp.global=$jscomp.getGlobal(this),$jscomp.IS_SYMBOL_NATIVE="function"==typeof Symbol&&"symbol"==typeof Symbol("x"),$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE,$jscomp.polyfills={},$jscomp.propertyToPolyfillSymbol={},$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(t,e){var o=$jscomp.propertyToPolyfillSymbol[e];return null==o?t[e]:void 0!==(o=t[o])?o:t[e]};$jscomp.polyfill=function(t,e,o,i){e&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(t,e,o,i):$jscomp.polyfillUnisolated(t,e,o,i))},$jscomp.polyfillUnisolated=function(t,e,o,i){for(o=$jscomp.global,t=t.split("."),i=0;i<t.length-1;i++){var r=t[i];r in o||(o[r]={}),o=o[r]}(e=e(i=o[t=t[t.length-1]]))!=i&&null!=e&&$jscomp.defineProperty(o,t,{configurable:!0,writable:!0,value:e})},$jscomp.polyfillIsolated=function(t,e,o,i){var r=t.split(".");t=1===r.length,i=r[0],i=!t&&i in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var n=0;n<r.length-1;n++){var s=r[n];s in i||(i[s]={}),i=i[s]}r=r[r.length-1],null!=(e=e(o=$jscomp.IS_SYMBOL_NATIVE&&"es6"===o?i[r]:null))&&(t?$jscomp.defineProperty($jscomp.polyfills,r,{configurable:!0,writable:!0,value:e}):e!==o&&($jscomp.propertyToPolyfillSymbol[r]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(r):$jscomp.POLYFILL_PREFIX+r,r=$jscomp.propertyToPolyfillSymbol[r],$jscomp.defineProperty(i,r,{configurable:!0,writable:!0,value:e})))},$jscomp.underscoreProtoCanBeSet=function(){var t={};try{return t.__proto__={a:!0},t.a}catch(t){}return!1},$jscomp.setPrototypeOf=$jscomp.TRUST_ES6_POLYFILLS&&"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null,$jscomp.inherits=function(t,e){if(t.prototype=$jscomp.objectCreate(e.prototype),t.prototype.constructor=t,$jscomp.setPrototypeOf){var o=$jscomp.setPrototypeOf;o(t,e)}else for(o in e)if("prototype"!=o)if(Object.defineProperties){var i=Object.getOwnPropertyDescriptor(e,o);i&&Object.defineProperty(t,o,i)}else t[o]=e[o];t.superClass_=e.prototype},$jscomp.polyfill("Math.sign",(function(t){return t||function(t){return 0===(t=Number(t))||isNaN(t)?t:0<t?1:-1}}),"es6","es3"),$jscomp.checkEs6ConformanceViaProxy=function(){try{var t={},e=Object.create(new $jscomp.global.Proxy(t,{get:function(o,i,r){return o==t&&"q"==i&&r==e}}));return!0===e.q}catch(t){return!1}},$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy(),$jscomp.initSymbol=function(){},$jscomp.polyfill("Symbol",(function(t){if(t)return t;var e=function(t,e){this.$jscomp$symbol$id_=t,$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:e})};e.prototype.toString=function(){return this.$jscomp$symbol$id_};var o=0,i=function(t){if(this instanceof i)throw new TypeError("Symbol is not a constructor");return new e("jscomp_symbol_"+(t||"")+"_"+o++,t)};return i}),"es6","es3"),$jscomp.initSymbolIterator=function(){},$jscomp.polyfill("Symbol.iterator",(function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var e="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),o=0;o<e.length;o++){var i=$jscomp.global[e[o]];"function"==typeof i&&"function"!=typeof i.prototype[t]&&$jscomp.defineProperty(i.prototype,t,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}})}return t}),"es6","es3"),$jscomp.initSymbolAsyncIterator=function(){},$jscomp.iteratorPrototype=function(t){return(t={next:t})[Symbol.iterator]=function(){return this},t},$jscomp.owns=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},$jscomp.polyfill("WeakMap",(function(t){function e(){}function o(t){var e=typeof t;return"object"===e&&null!==t||"function"===e}function i(t){if(!$jscomp.owns(t,n)){var o=new e;$jscomp.defineProperty(t,n,{value:o})}}function r(t){var o=Object[t];o&&(Object[t]=function(t){return t instanceof e?t:(i(t),o(t))})}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&$jscomp.ES6_CONFORMANCE)return t}else if(function(){if(!t||!Object.seal)return!1;try{var e=Object.seal({}),o=Object.seal({}),i=new t([[e,2],[o,3]]);return 2==i.get(e)&&3==i.get(o)&&(i.delete(e),i.set(o,4),!i.has(e)&&4==i.get(o))}catch(t){return!1}}())return t;var n="$jscomp_hidden_"+Math.random();r("freeze"),r("preventExtensions"),r("seal");var s=0,a=function(t){if(this.id_=(s+=Math.random()+1).toString(),t){t=$jscomp.makeIterator(t);for(var e;!(e=t.next()).done;)e=e.value,this.set(e[0],e[1])}};return a.prototype.set=function(t,e){if(!o(t))throw Error("Invalid WeakMap key");if(i(t),!$jscomp.owns(t,n))throw Error("WeakMap key fail: "+t);return t[n][this.id_]=e,this},a.prototype.get=function(t){return o(t)&&$jscomp.owns(t,n)?t[n][this.id_]:void 0},a.prototype.has=function(t){return o(t)&&$jscomp.owns(t,n)&&$jscomp.owns(t[n],this.id_)},a.prototype.delete=function(t){return!!(o(t)&&$jscomp.owns(t,n)&&$jscomp.owns(t[n],this.id_))&&delete t[n][this.id_]},a}),"es6","es3"),$jscomp.MapEntry=function(){},$jscomp.polyfill("Map",(function(t){if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&$jscomp.ES6_CONFORMANCE)return t}else if(function(){if($jscomp.ASSUME_NO_NATIVE_MAP||!t||"function"!=typeof t||!t.prototype.entries||"function"!=typeof Object.seal)return!1;try{var e=Object.seal({x:4}),o=new t($jscomp.makeIterator([[e,"s"]]));if("s"!=o.get(e)||1!=o.size||o.get({x:4})||o.set({x:4},"t")!=o||2!=o.size)return!1;var i=o.entries(),r=i.next();return!r.done&&r.value[0]==e&&"s"==r.value[1]&&!((r=i.next()).done||4!=r.value[0].x||"t"!=r.value[1]||!i.next().done)}catch(t){return!1}}())return t;var e=new WeakMap,o=function(t){if(this.data_={},this.head_=n(),this.size=0,t){t=$jscomp.makeIterator(t);for(var e;!(e=t.next()).done;)e=e.value,this.set(e[0],e[1])}};o.prototype.set=function(t,e){var o=i(this,t=0===t?0:t);return o.list||(o.list=this.data_[o.id]=[]),o.entry?o.entry.value=e:(o.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:t,value:e},o.list.push(o.entry),this.head_.previous.next=o.entry,this.head_.previous=o.entry,this.size++),this},o.prototype.delete=function(t){return!(!(t=i(this,t)).entry||!t.list||(t.list.splice(t.index,1),t.list.length||delete this.data_[t.id],t.entry.previous.next=t.entry.next,t.entry.next.previous=t.entry.previous,t.entry.head=null,this.size--,0))},o.prototype.clear=function(){this.data_={},this.head_=this.head_.previous=n(),this.size=0},o.prototype.has=function(t){return!!i(this,t).entry},o.prototype.get=function(t){return(t=i(this,t).entry)&&t.value},o.prototype.entries=function(){return r(this,(function(t){return[t.key,t.value]}))},o.prototype.keys=function(){return r(this,(function(t){return t.key}))},o.prototype.values=function(){return r(this,(function(t){return t.value}))},o.prototype.forEach=function(t,e){for(var o,i=this.entries();!(o=i.next()).done;)o=o.value,t.call(e,o[1],o[0],this)},o.prototype[Symbol.iterator]=o.prototype.entries;var i=function(t,o){var i=o&&typeof o;"object"==i||"function"==i?e.has(o)?i=e.get(o):(i=""+ ++s,e.set(o,i)):i="p_"+o;var r=t.data_[i];if(r&&$jscomp.owns(t.data_,i))for(t=0;t<r.length;t++){var n=r[t];if(o!=o&&n.key!=n.key||o===n.key)return{id:i,list:r,index:t,entry:n}}return{id:i,list:r,index:-1,entry:void 0}},r=function(t,e){var o=t.head_;return $jscomp.iteratorPrototype((function(){if(o){for(;o.head!=t.head_;)o=o.previous;for(;o.next!=o.head;)return o=o.next,{done:!1,value:e(o)};o=null}return{done:!0,value:void 0}}))},n=function(){var t={};return t.previous=t.next=t.head=t},s=0;return o}),"es6","es3"),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).OdaViewerPlugin=e()}(this,(function(){var t=function(t){this.m_module=t};t.prototype.copyPoint=function(t){var e=new this.m_module.Point3d;return e.set(t.x,t.y,t.z),e},t.prototype.createVector3d=function(){return new this.m_module.Vector3d},t.prototype.createPoint3d=function(){return new this.m_module.Point3d},t.prototype.createMatrix3d=function(){return new this.m_module.Matrix3d},t.prototype.createPlane=function(){return new this.m_module.OdTvPlane},t.prototype.toVector=function(t){return this.m_module.Vector3d.createFromArray(t)},t.prototype.toGeVector=function(t){return[t.x,t.y,t.z]},t.prototype.toGePoint=function(t){return[t.x,t.y,t.z]},t.prototype.toPoint=function(t){return this.m_module.Point3d.createFromArray(t)},t.prototype.screenToWorld=function(t,e){return this.toPoint(this.m_module.getViewer().screenToWorld(t,e))},t.prototype.toDoubleArray=function(t){for(var e=[],o=0;o<t.length;o++)e.push(t[o].x),e.push(t[o].y),e.push(t[o].z);return e},t.prototype.correctCameraTarget=function(){var t=this.getViewParams(),e=this.m_module.getViewer().getActiveExtents(),o=e.min,i=e.max,r=this.toGePoint(t.target);r.x>=o.x&&r.y>=o.y&&r.z>=o.z&&r.x<=i.x&&r.y<=i.y&&r.z<=i.z||(t.target=e.center(),this.setViewParams(t))},t.prototype.setViewParams=function(t){this.m_module.getViewer().getActiveTvExtendedView().setView(t.position,t.target,t.upVector,t.viewFieldWidth,t.viewFieldHeight,t.perspective)},t.prototype.getViewParams=function(){var t=this.m_module.getViewer().activeView;return{position:t.viewPosition,target:t.viewTarget,upVector:t.upVector,viewFieldWidth:t.viewFieldWidth,viewFieldHeight:t.viewFieldHeight,perspective:t.perspective}};var e=function(t){return this.m_module=t,this.needInputText=!1,this.touchEndPoints={x:0,y:0},this.mouseDownPosition={x:0,y:0},this.autoSelect=!1,this.onmessage=new Function,this};$jscomp.inherits(e,t),e.prototype.relativeCoords=function(t){var e=t.target.getBoundingClientRect();return t.touches&&t.touches[0]&&(t=t.touches[0]),{x:(t.clientX-e.left)*window.devicePixelRatio,y:(t.clientY-e.top)*window.devicePixelRatio}},e.prototype.init=function(){this.subInit(),this.onmessage({type:"update"})},e.prototype.getViewer=function(){return this.m_module.getViewer()},e.prototype.touchstart=function(t){t=this.relativeCoords(t),this.isDragging=!0,this.touchEndPoints.x=t.x,this.touchEndPoints.y=t.y,this.start(t.x,t.y),this.onmessage({type:"update"})},e.prototype.touchend=function(t){this.end(this.touchEndPoints.x,this.touchEndPoints.y),this.isDragging=!1,this.onmessage({type:"update"})},e.prototype.touchmove=function(t){var e=this.relativeCoords(t);t=t.touches[0],this.touchEndPoints.x=e.x,this.touchEndPoints.y=e.y,this.drag(e.x,e.y,t.movementX,t.movementY),this.regenerationPreview(),this.isDragging&&this.onmessage({type:"update"})},e.prototype.mousedown=function(t){t=this.relativeCoords(t),this.isDragging=!0,this.mouseDownPosition={x:t.x,y:t.y},this.start(this.mouseDownPosition.x,this.mouseDownPosition.y),this.onmessage({type:"update"})},e.prototype.mouseup=function(t){t=this.relativeCoords(t),this.end(t.x,t.y),this.isDragging=!1,this.onmessage({type:"update"})},e.prototype.mousemove=function(t){var e=this.relativeCoords(t);this.drag(e.x,e.y,t.movementX,t.movementY),this.regenerationPreview(),this.isDragging&&this.onmessage({type:"update"})},e.prototype.click=function(t){var e=this.relativeCoords(t);t=e.x;var o=e.y,i=5>Math.abs(t-this.mouseDownPosition.x)&&5>Math.abs(o-this.mouseDownPosition.y);(e=this.getViewer())&&this.autoSelect&&i&&(e.unselect(),e.select(t,o,t,o),(t=e.getSelected()).isNull()||0===t.numItems()||this.onmessage({type:"select",data:e.getSelected()}),this.onmessage({type:"update"}))},e.prototype.dblclick=function(t){var e=this.getViewer(),o=this.relativeCoords(t);t=o.x,o=o.y,(t=e.getActiveDevice().viewAt([t,o]))&&!t.active?(e.activeView=t,this.onmessage({type:"update"})):e&&this.autoSelect&&((t=e.getSelected()).isNull()||0===t.numItems()||(e.zoomToEntity(t.getIterator().getEntity()),this.onmessage({type:"zoomToEntity",data:t.getIterator().getEntity()}),this.onmessage({type:"update"})))},e.prototype.start=function(t,e){},e.prototype.drag=function(t,e){},e.prototype.end=function(t,e){},e.prototype.setText=function(t){},e.prototype.subInit=function(){},e.prototype.finalize=function(){},e.prototype.getModel=function(){return this.getViewer().getMarkupModel()},e.prototype.regenerationPreview=function(){},e.prototype.beginInteractivity=function(){var t=this.getViewer().activeView;t.beginInteractivity&&(t.beginInteractivity(24),this.onmessage({type:"update"}))},e.prototype.endInteractivity=function(){var t=this.getViewer().activeView;if(t.endInteractivity){t.endInteractivity(),t=this.getViewer().getActiveDevice();var e=this.m_module.canvas;t.invalidate([0,0,e.width,e.height]),this.onmessage({type:"update"})}},e.prototype.getActiveMarkupEntity=function(t){return(t=this.getViewer().getMarkupModel().appendEntity("$MarkupTempEntity_"+t)).openObject().setColor(255,0,0),t.openObject().setLineWeight(2),t};var o=function(t){for(var o=[],i=0;i<arguments.length;++i)o[i-0]=arguments[i];return(o=e.apply(this,[].concat($jscomp.arrayFromIterable(o)))||this).press=!1,o};$jscomp.inherits(o,e),o.prototype.subInit=function(){this.m_module.getViewer().setEnableAutoSelect(!0)},o.prototype.start=function(t,e){this.press=!0,this.m_start=this.screenToWorld(t,e),this.beginInteractivity()},o.prototype.drag=function(t,e,o,i){this.press&&(i=this.m_module.Vector3d,o=this.getViewParams(),t=this.screenToWorld(t,e),t=this.m_start.sub(t).asVector(),e=(e=i.createFromArray(o.target)).add(t),o.target=e.toArray(),i=(i=i.createFromArray(o.position)).add(t),o.position=i.toArray(),this.setViewParams(o))},o.prototype.end=function(t,e){this.press=!1,this.endInteractivity()},o.prototype.finalize=function(){};var i=function(t){for(var o=[],i=0;i<arguments.length;++i)o[i-0]=arguments[i];return(o=e.apply(this,[].concat($jscomp.arrayFromIterable(o)))||this).press=!1,o.maxPolarAngle=Math.PI/2,o.minPolarAngle=0,o};$jscomp.inherits(i,e),i.prototype.subInit=function(){this.getViewer().setEnableAutoSelect(!0)},i.prototype.start=function(t,e){this.press=!0,this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e},t=this.getViewer().activeView,this.startCameraParams=this.getViewParams(),t=t.vportRect,this.m_delta=Math.max(t[1]-t[0],t[2]-t[3]),this.beginInteractivity()},i.prototype.setDefaultViewParams=function(){this.setViewParams(this.startCameraParams)},i.prototype.drag=function(t,e,o,i){if(this.press){i=t-this.m_startPoint.x;var r=e-this.m_startPoint.y;i*=Math.PI/this.m_delta,r*=Math.PI/this.m_delta,this.setDefaultViewParams(),e=(t=this.m_module).Vector3d;var n=t.Matrix3d;t=e.createFromArray(this.startCameraParams.target);var s=(o=e.createFromArray(this.startCameraParams.position).sub(t)).normalize(),a=new n;a.setToIdentity(),(n=new n).setToIdentity();var c=e.createFromArray([s.x,s.y,s.z]),p=e.createFromArray(this.startCameraParams.upVector);p=c.crossProduct(p),1e-5>=(c=e.createFromArray([c.x,c.y,0])).length()?c.set(-p.y,p.x,0):c=c.normalize(),i-=c=Math.sign(c.dotProduct(e.createFromArray([-1,0,0])))*c.angleTo(e.createFromArray([0,1,0])),r-=s=1e-5>=(c=e.createFromArray([s.x,s.y,0])).length()?-s.z*Math.PI/2:-(c=c.normalize()).angleTo(s),a.setToRotation(-i,[0,0,1],[0,0,0]),n.setToRotation(Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,r)),[1,0,0],[0,0,0]),r=a.postMultBy(n),i=e.createFromArray([0,1,0]).transformBy(r),e=e.createFromArray([0,0,1]).transformBy(r),i.setLength(o.length()),i=t.add(i),(t=this.getViewParams()).position=i.toArray(),t.upVector=e.toArray(),this.setViewParams(t)}},i.prototype.end=function(t,e){this.press=!1,this.endInteractivity()},i.prototype.mouseleave=function(t){this.end()},i.prototype.getCenter=function(){var t=this.getViewer().getActiveExtents(),e=this.getViewer().getSelected();return e.isNull()||0===e.numItems()||(1===(e=e.getIterator().getEntity()).getType()?t=e.openObject().getExtents():2===e.getType()&&(t=e.openObjectAsInsert().getExtents())),t.center()};var r=function(t){for(var o=[],i=0;i<arguments.length;++i)o[i-0]=arguments[i];return(o=e.apply(this,[].concat($jscomp.arrayFromIterable(o)))||this).press=!1,o};$jscomp.inherits(r,e),r.prototype.subInit=function(){this.getViewer().setEnableAutoSelect(!0)},r.prototype.start=function(t,e){this.press=!0,this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e},console.log(this.getViewer()),t=this.getViewer().activeView,this.startCameraParams={position:t.viewPosition,target:t.viewTarget,upVector:t.upVector,viewFieldWidth:t.viewFieldWidth,viewFieldHeight:t.viewFieldHeight,perspective:t.perspective},t=t.vportRect,this.m_delta=Math.max(t[1]-t[0],t[2]-t[3]),this.beginInteractivity()},r.prototype.setDefaultViewParams=function(){this.getViewer().getActiveTvExtendedView().setView(this.startCameraParams.position,this.startCameraParams.target,this.startCameraParams.upVector,this.startCameraParams.viewFieldWidth,this.startCameraParams.viewFieldHeight,this.startCameraParams.perspective)},r.prototype.drag=function(t,e,o,i){this.press&&(t-=this.m_startPoint.x,e-=this.m_startPoint.y,t*=Math.PI/this.m_delta,e*=Math.PI/this.m_delta,this.setDefaultViewParams(),this.getViewer().getActiveTvExtendedView().orbitWithCenter(-e,-t,this.m_viewCenter))},r.prototype.end=function(t,e){this.press=!1,this.endInteractivity()},r.prototype.mouseleave=function(t){this.end()},r.prototype.getCenter=function(){var t=this.getViewer().getActiveExtents(),e=this.getViewer().getSelected();return e.isNull()||0===e.numItems()||(1===(e=e.getIterator().getEntity()).getType()?t=e.openObject().getExtents():2===e.getType()&&(t=e.openObjectAsInsert().getExtents().ext)),t.center()};var n=function(t){for(var o=[],i=0;i<arguments.length;++i)o[i-0]=arguments[i];return(o=e.apply(this,[].concat($jscomp.arrayFromIterable(o)))||this).press=!1,o};$jscomp.inherits(n,e),n.prototype.start=function(t,e){this.press=!0},n.prototype.drag=function(t,e,o,i){this.press&&((t=this.getViewParams()).viewFieldWidth=Math.max(1,t.viewFieldWidth*(1+.001*i)),t.viewFieldHeight=Math.max(1,t.viewFieldHeight*(1+.001*i)),this.setViewParams(t))},n.prototype.end=function(t,e){this.press=!1},n.prototype.mouseleave=function(t){this.end()},n.prototype.subInit=function(){this.getViewer().setEnableAutoSelect(!0)};var s=function(){this.m_start=[0,0,0],this.m_end=[0,0,0],this.m_model=null};s.prototype.createPoint3d=function(){return new this.m_module.Point3d},s.prototype.init=function(t,e){this.m_module=t,this.m_model=e},s.prototype.getViewer=function(){return this.m_module.getViewer()},s.prototype.setValue=function(t){this.m_end=t,this.draw()},s.prototype.setStartPoint=function(t){this.m_end=this.m_start=t,this.draw()},s.prototype.toDoubleArray=function(t){for(var e=[],o=0;o<t.length;o++)e.push(t[o].x),e.push(t[o].y),e.push(t[o].z);return e},s.prototype.draw=function(){var t=this.getViewer().activeView,e=t.viewingMatrix,o=[];o.push(this.m_start),o.push(this.createPoint3d()),o.push(this.m_end),o.push(this.createPoint3d());var i=this.createPoint3d();i.set(this.m_start.x,this.m_start.y,this.m_start.z);var r=this.createPoint3d();r.set(this.m_end.x,this.m_end.y,this.m_end.z),i.transformBy(e),r.transformBy(e),o[1].x=i.x,o[3].x=r.x,o[1].y=r.y,o[3].y=i.y,o[1].z=o[3].z=r.z,t=t.eyeToWorldMatrix,o[1].transformBy(t),o[3].transformBy(t),this.m_entity?this.m_frame.openAsPolygon().setPoints(this.toDoubleArray(o)):(this.m_entity=this.m_model.appendEntity(""),(t=this.m_entity.openObject()).setColor(112,112,112),t.setLineWeight(2),this.m_frame=t.appendPolygon(this.toDoubleArray(o)),t.delete())},s.prototype.clear=function(){this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.m_entity=null)};var a=function(t){for(var o=[],i=0;i<arguments.length;++i)o[i-0]=arguments[i];return(o=e.apply(this,[].concat($jscomp.arrayFromIterable(o)))||this).press=!1,o.needInputText=!1,o};$jscomp.inherits(a,e),a.prototype.start=function(t,e){this.press=!0,this.m_minX=t,this.m_minY=e,t=this.screenToWorld(t,e),this.m_frame.setStartPoint(t)},a.prototype.drag=function(t,e,o,i){this.press&&(this.m_maxX=t,this.m_maxY=e,t=this.screenToWorld(t,e),this.m_frame.setValue(t))},a.prototype.end=function(t,e){this.press=!1,this.m_maxX=t,this.m_maxY=e,this.m_minX!==this.m_maxX&&this.m_minY!==this.m_maxY&&(this.m_frame.clear(),this.getViewer().zoomWindow(this.m_minX,this.m_minY,this.m_maxX,this.m_maxY))},a.prototype.subInit=function(){this.m_frame=new s,this.getViewer().setEnableAutoSelect(!0),this.m_frame.init(this.m_module,this.getModel())};var c=function(t,e){this.m_module=t;var o=this;o.opt=e||{},o.draggerFactory=new Map,o.target=null,o.activeType=0,o.canvasListeners=[],o.enableSelect=!1,o._onmessage=new Function;var i=o.m_module.canvas;return o.canvasListeners="mousemove mousedown mouseup mouseleave click touchstart touchend touchcancel touchmove dblclick".split(" ").map((function(t){var e=function(e){o[t]&&o[t](e)};return i.addEventListener(t,e),{key:t,listener:e}})),o};return $jscomp.inherits(c,t),c.prototype.finalize=function(){this.target&&(this.target.endInteractivity(),this.target.finalize(),this.target=null)},c.prototype.setActive=function(t){this.finalize(),this.activeType=t,this.draggerFactory.has(t)?(this.target=new(this.draggerFactory.get(t))(this.m_module),this.target.onmessage=this._onmessage,this.target.autoSelect=this.enableSelect,this.target.controller=this,this.target.init()):this.target=null},c.prototype.getActive=function(){return this.activeType},c.prototype.mousemove=function(t){this.target&&this.target.mousemove&&this.target.mousemove(t)},c.prototype.mousedown=function(t){this.target&&this.target.mousedown&&this.target.mousedown(t)},c.prototype.mouseup=function(t){this.target&&this.target.mouseup&&this.target.mouseup(t)},c.prototype.mouseleave=function(t){this.target&&this.target.mouseleave&&this.target.mouseleave(t)},c.prototype.click=function(t){this.target&&this.target.click&&this.target.click(t)},c.prototype.wheel=function(t){var e=(t=t||window.event).deltaY||t.detail||t.wheelDelta;this.m_module.getViewer()&&(this.m_module.getViewer().zoomAt(0>e?1/.9:.9,t.offsetX*window.devicePixelRatio,t.offsetY*window.devicePixelRatio),this._onmessage({type:"update"}))},c.prototype.touchstart=function(t){this.target&&this.target.touchstart&&this.target.touchstart(t)},c.prototype.touchend=function(t){this.target&&this.target.touchend&&this.target.touchend(t)},c.prototype.touchcancel=function(t){this.target&&this.target.touchcancel&&this.target.touchcancel(t)},c.prototype.touchmove=function(t){this.target&&this.target.touchmove&&this.target.touchmove(t)},c.prototype.dblclick=function(t){this.target&&this.target.dblclick&&this.target.dblclick(t)},c.prototype.subDispose=function(){},c.prototype.dispose=function(){this.finalize();var t=this.m_module.canvas;this.canvasListeners.forEach((function(e){t.removeEventListener(e.key,e.listener)})),this.canvasListeners=[],this.subDispose()},c.prototype.syncOverlayView=function(){var t=this.m_module.getViewer(),e=t.getViewByName("$OVERLAY_VIEW_NAME"),o=t.activeView;if(!e){var i=t.getMarkupModel();(e=(t=t.getActiveDevice()).createView("$OVERLAY_VIEW_NAME",!1)).addModel(i),o.addSibling(e),t.addView(e)}return e.viewPosition=o.viewPosition,e.viewTarget=o.viewTarget,e.upVector=o.upVector,e.viewFieldWidth=o.viewFieldWidth,e.viewFieldHeight=o.viewFieldHeight,i=e.getViewport(),e.setViewport(i.lowerLeft,i.upperRight),e.vportRect=o.vportRect,e},$jscomp.global.Object.defineProperties(c.prototype,{onmessage:{configurable:!0,enumerable:!0,set:function(t){var e=this;this._onmessage=t,this.target&&(this.target.onmessage=function(t){return e._onmessage(t)})}}}),t=function(t,e){var s=c.call(this,t,e)||this;return s.type={None:0,Pan:1,Orbit:2,Zoom:3,ZoomWindow:4,OrbitAroundBuilding:5},s.draggerFactory=new Map,s.draggerFactory.set(s.type.Pan,o),s.draggerFactory.set(s.type.Orbit,r),s.draggerFactory.set(s.type.Zoom,n),s.draggerFactory.set(s.type.ZoomWindow,a),s.draggerFactory.set(s.type.OrbitAroundBuilding,i),s.m_enableSelect=!1,s._resizeEventHandler=function(){s.resize()},s._onwheelEventHandler=function(t){s.wheel(t)},window.addEventListener("resize",s._resizeEventHandler),s.m_module.canvas.addEventListener("wheel",s._onwheelEventHandler),s},$jscomp.inherits(t,c),t.prototype.resize=function(){var t=this.m_module.canvas;t.width=t.clientWidth*window.devicePixelRatio,t.height=t.clientHeight*window.devicePixelRatio,this.m_module.getViewer().resize(0,t.width,t.height,0),this._onmessage({type:"update"})},t.prototype.setAutoSelect=function(t){this.enableSelect=t,this.target&&(this.target.autoSelect=t)},t.prototype.subDispose=function(){window.removeEventListener("resize",this._resizeEventHandler),this.m_module.canvas.removeEventListener("wheel",this._onwheelEventHandler)},t.prototype.wheel=function(t){t=t||window.event;var e=Math.sign(t.deltaY),o=this.m_module.getViewer();if(o){e*=.075;var i=this.m_module.Vector3d,r=this.getViewParams(),n=i.createFromArray([.5*this.m_module.canvas.clientWidth,.5*this.m_module.canvas.clientHeight,0]);t=i.createFromArray([t.offsetX,t.offsetY,0]).sub(n),r.viewFieldWidth*=1+e,r.viewFieldHeight*=1+e,this.setViewParams(r),0>e&&o.pan(t.x*e,t.y*e),this._onmessage({type:"update"})}},t}));