| 1 |
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.NDSWebViewer=t():e.NDSWebViewer=t()}(window,function(){return n=[function(e,t){var n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,O,L){!function(e){var x=L(19),o=L(20),s=L(21);function n(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function l(e,t){if(n()<t)throw new RangeError("Invalid typed array length");return h.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=h.prototype:(e=null===e?new h(t):e).length=t,e}function h(e,t,n){if(!(h.TYPED_ARRAY_SUPPORT||this instanceof h))return new h(e,t,n);if("number"!=typeof e)return i(this,e,t,n);if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return a(this,e)}function i(e,t,n,i){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer){var r=e,o=t,a=n;if(o.byteLength,a<0||o.byteLength<a)throw new RangeError("'offset' is out of bounds");if(o.byteLength<a+(i||0))throw new RangeError("'length' is out of bounds");return o=void 0===a&&void 0===i?new Uint8Array(o):void 0===i?new Uint8Array(o,a):new Uint8Array(o,a,i),h.TYPED_ARRAY_SUPPORT?(r=o).__proto__=h.prototype:r=d(r,o),r}if("string"!=typeof t){a=e,i=t;if(h.isBuffer(i))return o=0|c(i.length),0!==(a=l(a,o)).length&&i.copy(a,0,0,o),a;if(i){if("undefined"!=typeof ArrayBuffer&&i.buffer instanceof ArrayBuffer||"length"in i)return"number"!=typeof i.length||function(e){return e!=e}(i.length)?l(a,0):d(a,i);if("Buffer"===i.type&&s(i.data))return d(a,i.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}r=e,i=t,e=n;if(h.isEncoding(e="string"==typeof e&&""!==e?e:"utf8"))return t=0|u(i,e),r=(i=(r=l(r,t)).write(i,e))!==t?r.slice(0,i):r;throw new TypeError('"encoding" must be a valid string encoding')}function r(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function a(e,t){if(r(t),e=l(e,t<0?0:0|c(t)),!h.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function d(e,t){var n=t.length<0?0:0|c(t.length);e=l(e,n);for(var i=0;i<n;i+=1)e[i]=255&t[i];return e}function c(e){if(e>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function u(e,t){if(h.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;var n=(e="string"!=typeof e?""+e:e).length;if(0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return P(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return C(e).length;default:if(i)return P(e).length;t=(""+t).toLowerCase(),i=!0}}function t(e,t,n){var i,r=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var o=this,a=t,s=n,l=o.length;(!s||s<0||l<s)&&(s=l);for(var d="",c=a=!a||a<0?0:a;c<s;++c)d+=function(e){return e<16?"0"+e.toString(16):e.toString(16)}(o[c]);return d;case"utf8":case"utf-8":return I(this,t,n);case"ascii":var h=this,l=t,u=n,p="";u=Math.min(h.length,u);for(var f=l;f<u;++f)p+=String.fromCharCode(127&h[f]);return p;case"latin1":case"binary":var m=this,a=t,g=n,v="";g=Math.min(m.length,g);for(var A=a;A<g;++A)v+=String.fromCharCode(m[A]);return v;case"base64":return y=this,i=n,0===(E=t)&&i===y.length?x.fromByteArray(y):x.fromByteArray(y.slice(E,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":for(var y=t,E=n,M=this.slice(y,E),w="",b=0;b<M.length;b+=2)w+=String.fromCharCode(M[b]+256*M[b+1]);return w;default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function p(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function f(e,t,n,i,r){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):2147483647<n?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,(n=(n=isNaN(n)?r?0:e.length-1:n)<0?e.length+n:n)>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=h.from(t,i)),h.isBuffer(t))return 0===t.length?-1:m(e,t,n,i,r);if("number"==typeof t)return t&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(r?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):m(e,[t],n,i,r);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,i,r){var o=1,a=e.length,s=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;a/=o=2,s/=2,n/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r)for(var d=-1,c=n;c<a;c++)if(l(e,c)===l(t,-1===d?0:c-d)){if(c-(d=-1===d?c:d)+1===s)return d*o}else-1!==d&&(c-=c-d),d=-1;else for(c=n=a<n+s?a-s:n;0<=c;c--){for(var h=!0,u=0;u<s;u++)if(l(e,c+u)!==l(t,u)){h=!1;break}if(h)return c}return-1}function g(e,t,n,i){return R(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,i)}function v(e,t,n,i){return R(function(e,t){for(var n,i,r=[],o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),i=n>>8,r.push(n%256),r.push(i);return r}(t,e.length-n),e,n,i)}function I(e,t,n){n=Math.min(e.length,n);for(var i=[],r=t;r<n;){var o,a,s,l,d=e[r],c=null,h=239<d?4:223<d?3:191<d?2:1;if(r+h<=n)switch(h){case 1:d<128&&(c=d);break;case 2:128==(192&(o=e[r+1]))&&127<(l=(31&d)<<6|63&o)&&(c=l);break;case 3:o=e[r+1],a=e[r+2],128==(192&o)&&128==(192&a)&&2047<(l=(15&d)<<12|(63&o)<<6|63&a)&&(l<55296||57343<l)&&(c=l);break;case 4:o=e[r+1],a=e[r+2],s=e[r+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&65535<(l=(15&d)<<18|(63&o)<<12|(63&a)<<6|63&s)&&l<1114112&&(c=l)}null===c?(c=65533,h=1):65535<c&&(i.push((c-=65536)>>>10&1023|55296),c=56320|1023&c),i.push(c),r+=h}var u=i,p=u.length;if(p<=A)return String.fromCharCode.apply(String,u);for(var f="",m=0;m<p;)f+=String.fromCharCode.apply(String,u.slice(m,m+=A));return f}O.Buffer=h,O.SlowBuffer=function(e){+e!=e&&(e=0);return h.alloc(+e)},O.INSPECT_MAX_BYTES=50,h.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),O.kMaxLength=n(),h.poolSize=8192,h._augment=function(e){return e.__proto__=h.prototype,e},h.from=function(e,t,n){return i(null,e,t,n)},h.TYPED_ARRAY_SUPPORT&&(h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array,"undefined"!=typeof Symbol)&&Symbol.species&&h[Symbol.species]===h&&Object.defineProperty(h,Symbol.species,{value:null,configurable:!0}),h.alloc=function(e,t,n){return i=null,t=t,n=n,r(e=e),!(e<=0)&&void 0!==t?"string"==typeof n?l(i,e).fill(t,n):l(i,e).fill(t):l(i,e);var i},h.allocUnsafe=function(e){return a(null,e)},h.allocUnsafeSlow=function(e){return a(null,e)},h.isBuffer=function(e){return!(null==e||!e._isBuffer)},h.compare=function(e,t){if(!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,i=t.length,r=0,o=Math.min(n,i);r<o;++r)if(e[r]!==t[r]){n=e[r],i=t[r];break}return n<i?-1:i<n?1:0},h.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return h.alloc(0);if(void 0===t)for(r=t=0;r<e.length;++r)t+=e[r].length;for(var n=h.allocUnsafe(t),i=0,r=0;r<e.length;++r){var o=e[r];if(!h.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},h.byteLength=u,h.prototype._isBuffer=!0,h.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)p(this,t,t+1);return this},h.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)p(this,t,t+3),p(this,t+1,t+2);return this},h.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)p(this,t,t+7),p(this,t+1,t+6),p(this,t+2,t+5),p(this,t+3,t+4);return this},h.prototype.toString=function(){var e=0|this.length;return 0==e?"":0===arguments.length?I(this,0,e):t.apply(this,arguments)},h.prototype.equals=function(e){if(h.isBuffer(e))return this===e||0===h.compare(this,e);throw new TypeError("Argument must be a Buffer")},h.prototype.inspect=function(){var e="",t=O.INSPECT_MAX_BYTES;return 0<this.length&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t)&&(e+=" ... "),"<Buffer "+e+">"},h.prototype.compare=function(e,t,n,i,r){if(!h.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),(t=void 0===t?0:t)<0||n>e.length||i<0||r>this.length)throw new RangeError("out of range index");if(r<=i&&n<=t)return 0;if(r<=i)return-1;if(n<=t)return 1;if(this===e)return 0;for(var o=(r>>>=0)-(i>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(o,a),l=this.slice(i,r),d=e.slice(t,n),c=0;c<s;++c)if(l[c]!==d[c]){o=l[c],a=d[c];break}return o<a?-1:a<o?1:0},h.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},h.prototype.indexOf=function(e,t,n){return f(this,e,t,n,!0)},h.prototype.lastIndexOf=function(e,t,n){return f(this,e,t,n,!1)},h.prototype.write=function(e,t,n,i){if(void 0===t)i="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)i=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}var r=this.length-t;if((void 0===n||r<n)&&(n=r),0<e.length&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i=i||"utf8";for(var o,a,s,l=!1;;)switch(i){case"hex":var d=this,c=e,h=t,u=n,p=(h=Number(h)||0,d.length-h);if((!u||p<(u=Number(u)))&&(u=p),(p=c.length)%2!=0)throw new TypeError("Invalid hex string");p/2<u&&(u=p/2);for(var f=0;f<u;++f){var m=parseInt(c.substr(2*f,2),16);if(isNaN(m))return f;d[h+f]=m}return f;case"utf8":case"utf-8":return p=t,s=n,R(P(e,(a=this).length-p),a,p,s);case"ascii":return g(this,e,t,n);case"latin1":case"binary":return g(this,e,t,n);case"base64":return a=this,s=t,o=n,R(C(e),a,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),l=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function y(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(n<e+t)throw new RangeError("Trying to access beyond buffer length")}function E(e,t,n,i,r,o){if(!h.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r<t||t<o)throw new RangeError('"value" argument is out of bounds');if(n+i>e.length)throw new RangeError("Index out of range")}function M(e,t,n,i){t<0&&(t=65535+t+1);for(var r=0,o=Math.min(e.length-n,2);r<o;++r)e[n+r]=(t&255<<8*(i?r:1-r))>>>8*(i?r:1-r)}function w(e,t,n,i){t<0&&(t=4294967295+t+1);for(var r=0,o=Math.min(e.length-n,4);r<o;++r)e[n+r]=t>>>8*(i?r:3-r)&255}function b(e,t,n,i){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function T(e,t,n,i,r){return r||b(e,0,n,4),o.write(e,t,n,i,23,4),n+4}function S(e,t,n,i,r){return r||b(e,0,n,8),o.write(e,t,n,i,52,8),n+8}h.prototype.slice=function(e,t){var n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):n<e&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):n<t&&(t=n),t<e&&(t=e),h.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=h.prototype;else for(var i=t-e,r=new h(i,void 0),o=0;o<i;++o)r[o]=this[o+e];return r},h.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||y(e,t,this.length);for(var i=this[e],r=1,o=0;++o<t&&(r*=256);)i+=this[e+o]*r;return i},h.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||y(e,t,this.length);for(var i=this[e+--t],r=1;0<t&&(r*=256);)i+=this[e+--t]*r;return i},h.prototype.readUInt8=function(e,t){return t||y(e,1,this.length),this[e]},h.prototype.readUInt16LE=function(e,t){return t||y(e,2,this.length),this[e]|this[e+1]<<8},h.prototype.readUInt16BE=function(e,t){return t||y(e,2,this.length),this[e]<<8|this[e+1]},h.prototype.readUInt32LE=function(e,t){return t||y(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},h.prototype.readUInt32BE=function(e,t){return t||y(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},h.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||y(e,t,this.length);for(var i=this[e],r=1,o=0;++o<t&&(r*=256);)i+=this[e+o]*r;return(r*=128)<=i&&(i-=Math.pow(2,8*t)),i},h.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||y(e,t,this.length);for(var i=t,r=1,o=this[e+--i];0<i&&(r*=256);)o+=this[e+--i]*r;return(r*=128)<=o&&(o-=Math.pow(2,8*t)),o},h.prototype.readInt8=function(e,t){return t||y(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},h.prototype.readInt16LE=function(e,t){t||y(e,2,this.length);t=this[e]|this[e+1]<<8;return 32768&t?4294901760|t:t},h.prototype.readInt16BE=function(e,t){t||y(e,2,this.length);t=this[e+1]|this[e]<<8;return 32768&t?4294901760|t:t},h.prototype.readInt32LE=function(e,t){return t||y(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},h.prototype.readInt32BE=function(e,t){return t||y(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},h.prototype.readFloatLE=function(e,t){return t||y(e,4,this.length),o.read(this,e,!0,23,4)},h.prototype.readFloatBE=function(e,t){return t||y(e,4,this.length),o.read(this,e,!1,23,4)},h.prototype.readDoubleLE=function(e,t){return t||y(e,8,this.length),o.read(this,e,!0,52,8)},h.prototype.readDoubleBE=function(e,t){return t||y(e,8,this.length),o.read(this,e,!1,52,8)},h.prototype.writeUIntLE=function(e,t,n,i){e=+e,t|=0,n|=0,i||E(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,o=0;for(this[t]=255&e;++o<n&&(r*=256);)this[t+o]=e/r&255;return t+n},h.prototype.writeUIntBE=function(e,t,n,i){e=+e,t|=0,n|=0,i||E(this,e,t,n,Math.pow(2,8*n)-1,0);var r=n-1,o=1;for(this[t+r]=255&e;0<=--r&&(o*=256);)this[t+r]=e/o&255;return t+n},h.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,1,255,0),h.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},h.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},h.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},h.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):w(this,e,t,!0),t+4},h.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):w(this,e,t,!1),t+4},h.prototype.writeIntLE=function(e,t,n,i){e=+e,t|=0,i||E(this,e,t,n,(i=Math.pow(2,8*n-1))-1,-i);var r=0,o=1,a=0;for(this[t]=255&e;++r<n&&(o*=256);)e<0&&0===a&&0!==this[t+r-1]&&(a=1),this[t+r]=(e/o>>0)-a&255;return t+n},h.prototype.writeIntBE=function(e,t,n,i){e=+e,t|=0,i||E(this,e,t,n,(i=Math.pow(2,8*n-1))-1,-i);var r=n-1,o=1,a=0;for(this[t+r]=255&e;0<=--r&&(o*=256);)e<0&&0===a&&0!==this[t+r+1]&&(a=1),this[t+r]=(e/o>>0)-a&255;return t+n},h.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,1,127,-128),h.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&(e=e<0?255+e+1:e),t+1},h.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},h.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},h.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):w(this,e,t,!0),t+4},h.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||E(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),h.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):w(this,e,t,!1),t+4},h.prototype.writeFloatLE=function(e,t,n){return T(this,e,t,!0,n)},h.prototype.writeFloatBE=function(e,t,n){return T(this,e,t,!1,n)},h.prototype.writeDoubleLE=function(e,t,n){return S(this,e,t,!0,n)},h.prototype.writeDoubleBE=function(e,t,n){return S(this,e,t,!1,n)},h.prototype.copy=function(e,t,n,i){if(n=n||0,i||0===i||(i=this.length),t>=e.length&&(t=e.length),(i=0<i&&i<n?n:i)===n)return 0;if(0===e.length||0===this.length)return 0;if((t=t||0)<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length);var r,o=(i=e.length-t<i-n?e.length-t+n:i)-n;if(this===e&&n<t&&t<i)for(r=o-1;0<=r;--r)e[r+t]=this[r+n];else if(o<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r<o;++r)e[r+t]=this[r+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},h.prototype.fill=function(e,t,n,i){if("string"==typeof e){var r;if("string"==typeof t?(i=t,t=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),1===e.length&&(r=e.charCodeAt(0))<256&&(e=r),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!h.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(!(n<=t))if(t>>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(s=t;s<n;++s)this[s]=e;else for(var o=h.isBuffer(e)?e:P(new h(e,i).toString()),a=o.length,s=0;s<n-t;++s)this[s+t]=o[s%a];return this};var B=/[^+\/0-9A-Za-z-_]/g;function P(e,t){t=t||1/0;for(var n,i=e.length,r=null,o=[],a=0;a<i;++a){if(55295<(n=e.charCodeAt(a))&&n<57344){if(!r){if(56319<n){-1<(t-=3)&&o.push(239,191,189);continue}if(a+1===i){-1<(t-=3)&&o.push(239,191,189);continue}r=n;continue}if(n<56320){-1<(t-=3)&&o.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&-1<(t-=3)&&o.push(239,191,189);if(r=null,n<128){if(--t<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function C(e){return x.toByteArray(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function R(e,t,n,i){for(var r=0;r<i&&!(r+n>=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}.call(this,L(0))},function(e,t){var n,i,e=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}try{n="function"==typeof setTimeout?setTimeout:r}catch(e){n=r}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===r||!n)&&setTimeout)return(n=setTimeout)(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}var s,l=[],d=!1,c=-1;function h(){d&&s&&(d=!1,s.length?l=s.concat(l):c=-1,l.length)&&u()}function u(){if(!d){for(var e=a(h),t=(d=!0,l.length);t;){for(s=l,l=[];++c<t;)s&&s[c].run();c=-1,t=l.length}s=null,d=!1,!function(t){if(i===clearTimeout)return clearTimeout(t);if((i===o||!i)&&clearTimeout)return(i=clearTimeout)(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}e.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new p(e,t)),1!==l.length||d||a(u)},p.prototype.run=function(){this.fun.apply(null,this.array)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=f,e.addListener=f,e.once=f,e.off=f,e.removeListener=f,e.removeAllListeners=f,e.emit=f,e.prependListener=f,e.prependOnceListener=f,e.listeners=function(e){return[]},e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},function(e,t,n){!function(h,p,i,f){e.exports=function i(r,o,a){function s(t,e){if(!o[t]){if(!r[t]){if(l)return l(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}n=o[t]={exports:{}};r[t][0].call(n.exports,function(e){return s(r[t][1][e]||e)},n,n.exports,i,r,o,a)}return o[t].exports}for(var l=!1,e=0;e<a.length;e++)s(a[e]);return s}({1:[function(e,t,n){var h=e("./utils"),c=e("./support"),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(e){for(var t,n,i,r,o,a,s=[],l=0,d=e.length,c="string"!==h.getTypeOf(e);l<e.length;)a=d-l,i=c?(t=e[l++],n=l<d?e[l++]:0,l<d?e[l++]:0):(t=e.charCodeAt(l++),n=l<d?e.charCodeAt(l++):0,l<d?e.charCodeAt(l++):0),r=(3&t)<<4|n>>4,o=1<a?(15&n)<<2|i>>6:64,a=2<a?63&i:64,s.push(u.charAt(t>>2)+u.charAt(r)+u.charAt(o)+u.charAt(a));return s.join("")},n.decode=function(e){var t,n,i,r,o,a=0,s=0;if("data:"===e.substr(0,"data:".length))throw new Error("Invalid base64 input, it looks like a data url.");var l,d=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===u.charAt(64)&&d--,e.charAt(e.length-2)===u.charAt(64)&&d--,d%1!=0)throw new Error("Invalid base64 input, bad content length.");for(l=new(c.uint8array?Uint8Array:Array)(0|d);a<e.length;)t=u.indexOf(e.charAt(a++))<<2|(r=u.indexOf(e.charAt(a++)))>>4,n=(15&r)<<4|(r=u.indexOf(e.charAt(a++)))>>2,i=(3&r)<<6|(o=u.indexOf(e.charAt(a++))),l[s++]=t,64!==r&&(l[s++]=n),64!==o&&(l[s++]=i);return l}},{"./support":30,"./utils":32}],2:[function(e,t,n){var i=e("./external"),r=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function s(e,t,n,i,r){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=i,this.compressedContent=r}s.prototype={getContentWorker:function(){var e=new r(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new r(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},s.createWorkerFrom=function(e,t,n){return e.pipe(new o).pipe(new a("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){var i=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){var i=e("./utils"),a=function(){for(var e=[],t=0;t<256;t++){for(var n=t,i=0;i<8;i++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e}();t.exports=function(e,t){return void 0!==e&&e.length?("string"!==i.getTypeOf(e)?function(e,t,n){var i=a,r=0+n;e^=-1;for(var o=0;o<r;o++)e=e>>>8^i[255&(e^t[o])];return-1^e}:function(e,t,n){var i=a,r=0+n;e^=-1;for(var o=0;o<r;o++)e=e>>>8^i[255&(e^t.charCodeAt(o))];return-1^e})(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){e="undefined"!=typeof Promise?Promise:e("lie");t.exports={Promise:e}},{lie:37}],7:[function(e,t,n){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,r=e("pako"),o=e("./utils"),a=e("./stream/GenericWorker"),s=i?"uint8array":"array";function l(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",o.inherits(l,a),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(s,e.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){function A(e,t){for(var n="",i=0;i<t;i++)n+=String.fromCharCode(255&e),e>>>=8;return n}function i(e,t,n,i,r,o){var a=e.file,s=e.compression,l=o!==E.utf8encode,d=y.transformTo("string",o(a.name)),c=y.transformTo("string",E.utf8encode(a.name)),h=a.comment,o=y.transformTo("string",o(h)),u=y.transformTo("string",E.utf8encode(h)),p=c.length!==a.name.length,h=u.length!==h.length,f="",m=a.dir,g=a.date,v={crc32:0,compressedSize:0,uncompressedSize:0},n=(t&&!n||(v.crc32=e.crc32,v.compressedSize=e.compressedSize,v.uncompressedSize=e.uncompressedSize),0),e=(t&&(n|=8),l||!p&&!h||(n|=2048),0),t=0,g=(m&&(e|=16),"UNIX"===r?(t=798,e|=(65535&((l=a.unixPermissions)?l:m?16893:33204))<<16):(t=20,e|=63&(a.dosPermissions||0)),r=g.getUTCHours(),r=(r=((r<<=6)|g.getUTCMinutes())<<5)|g.getUTCSeconds()/2,l=g.getUTCFullYear()-1980,l=(l=((l<<=4)|g.getUTCMonth()+1)<<5)|g.getUTCDate(),p&&(m=A(1,1)+A(M(d),4)+c,f+="up"+A(m.length,2)+m),h&&(a=A(1,1)+A(M(o),4)+u,f+="uc"+A(a.length,2)+a),""),g=(g=(g=(g=(g=(g=(g=(g=(g=(g+="\n\0")+A(n,2))+s.magic)+A(r,2))+A(l,2))+A(v.crc32,4))+A(v.compressedSize,4))+A(v.uncompressedSize,4))+A(d.length,2))+A(f.length,2);return{fileRecord:w.LOCAL_FILE_HEADER+g+d+f,dirRecord:w.CENTRAL_FILE_HEADER+A(t,2)+g+A(o.length,2)+"\0\0\0\0"+A(e,4)+A(i,4)+d+f+o}}var y=e("../utils"),r=e("../stream/GenericWorker"),E=e("../utf8"),M=e("../crc32"),w=e("../signature");function o(e,t,n,i){r.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}y.inherits(o,r),o.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,r.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-i-1))/n:100}}))},o.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;t?(e=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName),this.push({data:e.fileRecord,meta:{percent:0}})):this.accumulate=!0},o.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:(t=e,w.DATA_DESCRIPTOR+A(t.crc32,4)+A(t.compressedSize,4)+A(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},o.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var n=this.bytesWritten-e,n=function(e,t,n,i,r){r=y.transformTo("string",r(i));return w.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(e,2)+A(e,2)+A(t,4)+A(n,4)+A(r.length,2)+r}(this.dirRecords.length,n,e,this.zipComment,this.encodeFileName);this.push({data:n,meta:{percent:100}})},o.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},o.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},o.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},o.prototype.error=function(e){var t=this._sources;if(!r.prototype.error.call(this,e))return!1;for(var n=0;n<t.length;n++)try{t[n].error(e)}catch(e){}return!0},o.prototype.lock=function(){r.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=o},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,n){var d=e("../compressions"),i=e("./ZipFileWorker");n.generateWorker=function(e,a,t){var s=new i(a.streamFiles,t,a.platform,a.encodeFileName),l=0;try{e.forEach(function(e,t){l++;var n=function(e,t){e=e||t,t=d[e];if(t)return t;throw new Error(e+" is not a valid compression method !")}(t.options.compression,a.compression),i=t.options.compressionOptions||a.compressionOptions||{},r=t.dir,o=t.date;t._compressWorker(n,i).withStreamInfo("file",{name:e,dir:r,date:o,comment:t.comment||"",unixPermissions:t.unixPermissions,dosPermissions:t.dosPermissions}).pipe(s)}),s.entriesCount=l}catch(e){s.error(e)}return s}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,n){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e,t=new i;for(e in this)"function"!=typeof this[e]&&(t[e]=this[e]);return t}}(i.prototype=e("./object")).loadAsync=e("./load"),i.support=e("./support"),i.defaults=e("./defaults"),i.version="3.10.1",i.loadAsync=function(e,t){return(new i).loadAsync(e,t)},i.external=e("./external"),t.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,n){var l=e("./utils"),r=e("./external"),i=e("./utf8"),o=e("./zipEntries"),d=e("./stream/Crc32Probe"),c=e("./nodejsUtils");t.exports=function(e,a){var s=this;return a=l.extend(a||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),c.isNode&&c.isStream(e)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):l.prepareContent("the loaded zip file",e,!0,a.optimizedBinaryString,a.base64).then(function(e){var t=new o(a);return t.load(e),t}).then(function(e){var t=[r.Promise.resolve(e)],n=e.files;if(a.checkCRC32)for(var i=0;i<n.length;i++)t.push(function(i){return new r.Promise(function(e,t){var n=i.decompressed.getContentWorker().pipe(new d);n.on("error",function(e){t(e)}).on("end",function(){n.streamInfo.crc32!==i.decompressed.crc32?t(new Error("Corrupted zip : CRC32 mismatch")):e()}).resume()})}(n[i]));return r.Promise.all(t)}).then(function(e){for(var e=e.shift(),t=e.files,n=0;n<t.length;n++){var i=t[n],r=i.fileNameStr,o=l.resolve(i.fileNameStr);s.file(o,i.decompressed,{binary:!0,optimizedBinaryString:!0,date:i.date,dir:i.dir,comment:i.fileCommentStr.length?i.fileCommentStr:null,unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions,createFolders:a.createFolders}),i.dir||(s.file(o).unsafeOriginalName=r)}return e.zipComment.length&&(s.comment=e.zipComment),s})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,n){var i=e("../utils"),r=e("../stream/GenericWorker");function o(e,t){r.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}i.inherits(o,r),o.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},o.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,n){var r=e("readable-stream").Readable;function i(e,t,n){r.call(this,t),this._helper=e;var i=this;e.on("data",function(e,t){i.push(e)||i._helper.pause(),n&&n(t)}).on("error",function(e){i.emit("error",e)}).on("end",function(){i.push(null)})}e("../utils").inherits(i,r),i.prototype._read=function(){this._helper.resume()},t.exports=i},{"../utils":32,"readable-stream":16}],14:[function(e,t,n){t.exports={isNode:void 0!==h,newBufferFrom:function(e,t){if(h.from&&h.from!==Uint8Array.from)return h.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new h(e,t)},allocBuffer:function(e){return h.alloc?h.alloc(e):((e=new h(e)).fill(0),e)},isBuffer:function(e){return h.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,n){function r(e,t,n){var i=l.getTypeOf(t),r=l.extend(n||{},h),o=(r.date=r.date||new Date,null!==r.compression&&(r.compression=r.compression.toUpperCase()),"string"==typeof r.unixPermissions&&(r.unixPermissions=parseInt(r.unixPermissions,8)),r.unixPermissions&&16384&r.unixPermissions&&(r.dir=!0),r.dosPermissions&&16&r.dosPermissions&&(r.dir=!0),r.dir&&(e=v(e)),r.createFolders&&(o=a(e))&&s.call(this,o,!0),"string"===i&&!1===r.binary&&!1===r.base64),i=(n&&void 0!==n.binary||(r.binary=!o),(t instanceof u&&0===t.uncompressedSize||r.dir||!t||0===t.length)&&(r.base64=!1,r.binary=!0,t="",r.compression="STORE"),t instanceof u||t instanceof d?t:m.isNode&&m.isStream(t)?new g(e,t):l.prepareContent(e,t,r.binary,r.optimizedBinaryString,r.base64)),n=new p(e,i,r);this.files[e]=n}function a(e){var t=(e="/"===e.slice(-1)?e.substring(0,e.length-1):e).lastIndexOf("/");return 0<t?e.substring(0,t):""}function s(e,t){return t=void 0!==t?t:h.createFolders,e=v(e),this.files[e]||r.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]}var o=e("./utf8"),l=e("./utils"),d=e("./stream/GenericWorker"),c=e("./stream/StreamHelper"),h=e("./defaults"),u=e("./compressedObject"),p=e("./zipObject"),f=e("./generate"),m=e("./nodejsUtils"),g=e("./nodejs/NodejsStreamInputAdapter"),v=function(e){return"/"!==e.slice(-1)&&(e+="/"),e};function A(e){return"[object RegExp]"===Object.prototype.toString.call(e)}t.exports={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,n,i;for(t in this.files)i=this.files[t],(n=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(n,i)},filter:function(n){var i=[];return this.forEach(function(e,t){n(e,t)&&i.push(t)}),i},file:function(e,t,n){var i;return 1!==arguments.length?(e=this.root+e,r.call(this,e,t,n),this):A(e)?(i=e,this.filter(function(e,t){return!t.dir&&i.test(e)})):(t=this.files[this.root+e])&&!t.dir?t:null},folder:function(n){var e,t;return n?A(n)?this.filter(function(e,t){return t.dir&&n.test(e)}):(e=this.root+n,e=s.call(this,e),(t=this.clone()).root=e.name,t):this},remove:function(n){n=this.root+n;var e=this.files[n];if(e||("/"!==n.slice(-1)&&(n+="/"),e=this.files[n]),e&&!e.dir)delete this.files[n];else for(var t=this.filter(function(e,t){return t.name.slice(0,n.length)===n}),i=0;i<t.length;i++)delete this.files[t[i].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t={};try{if((t=l.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=t.type.toLowerCase(),t.compression=t.compression.toUpperCase(),"binarystring"===t.type&&(t.type="string"),!t.type)throw new Error("No output type specified.");l.checkSupport(t.type),"darwin"!==t.platform&&"freebsd"!==t.platform&&"linux"!==t.platform&&"sunos"!==t.platform||(t.platform="UNIX"),"win32"===t.platform&&(t.platform="DOS");var n=t.comment||this.comment||"",i=f.generateWorker(this,t,n)}catch(e){(i=new d("error")).error(e)}return new c(i,t.type||"string",t.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}}},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,n){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,n){var i=e("./DataReader");function r(e){i.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(r,i),r.prototype.byteAt=function(e){return this.data[this.zero+e]},r.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),r=e.charCodeAt(3),o=this.length-4;0<=o;--o)if(this.data[o]===t&&this.data[o+1]===n&&this.data[o+2]===i&&this.data[o+3]===r)return o-this.zero;return-1},r.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),e=e.charCodeAt(3),r=this.readData(4);return t===r[0]&&n===r[1]&&i===r[2]&&e===r[3]},r.prototype.readData=function(e){var t;return this.checkOffset(e),0===e?[]:(t=this.data.slice(this.zero+this.index,this.zero+this.index+e),this.index+=e,t)},t.exports=r},{"../utils":32,"./DataReader":18}],18:[function(e,t,n){var i=e("../utils");function r(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,n=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return i.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=r},{"../utils":32}],19:[function(e,t,n){var i=e("./Uint8ArrayReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){var i=e("./DataReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},r.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},r.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){var i=e("./ArrayReader");function r(e){i.call(this,e)}e("../utils").inherits(r,i),r.prototype.readData=function(e){var t;return this.checkOffset(e),0===e?new Uint8Array(0):(t=this.data.subarray(this.zero+this.index,this.zero+this.index+e),this.index+=e,t)},t.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){var i=e("../utils"),r=e("../support"),o=e("./ArrayReader"),a=e("./StringReader"),s=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=i.getTypeOf(e);return i.checkSupport(t),"string"!==t||r.uint8array?"nodebuffer"===t?new s(e):r.uint8array?new l(i.transformTo("uint8array",e)):new o(i.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){var i=e("./GenericWorker"),r=e("../utils");function o(e){i.call(this,"ConvertWorker to "+e),this.destType=e}r.inherits(o,i),o.prototype.processChunk=function(e){this.push({data:r.transformTo(this.destType,e.data),meta:e.meta})},t.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){var i=e("./GenericWorker"),r=e("../crc32");function o(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,i),o.prototype.processChunk=function(e){this.streamInfo.crc32=r(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){var i=e("../utils"),r=e("./GenericWorker");function o(e){r.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}i.inherits(o,r),o.prototype.processChunk=function(e){var t;e&&(t=this.streamInfo[this.propName]||0,this.streamInfo[this.propName]=t+e.data.length),r.prototype.processChunk.call(this,e)},t.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){var i=e("../utils"),r=e("./GenericWorker");function o(e){r.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=i.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}i.inherits(o,r),o.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished)||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0)},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){function i(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n<this._listeners[e].length;n++)this._listeners[e][n].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){var e;return!(!this.isPaused||this.isFinished||(e=this.isPaused=!1,this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),e))},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=i},{}],29:[function(e,t,n){var d=e("../utils"),r=e("./ConvertWorker"),o=e("./GenericWorker"),c=e("../base64"),i=e("../support"),a=e("../external"),s=null;if(i.nodestream)try{s=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function l(e,t,n){var i=t;switch(t){case"blob":case"arraybuffer":i="uint8array";break;case"base64":i="string"}try{this._internalType=i,this._outputType=t,this._mimeType=n,d.checkSupport(i),this._worker=e.pipe(new r(i)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}l.prototype={accumulate:function(e){return s=this,l=e,new a.Promise(function(t,n){var i=[],r=s._internalType,o=s._outputType,a=s._mimeType;s.on("data",function(e,t){i.push(e),l&&l(t)}).on("error",function(e){i=[],n(e)}).on("end",function(){try{var e=function(e,t,n){switch(e){case"blob":return d.newBlob(d.transformTo("arraybuffer",t),n);case"base64":return c.encode(t);default:return d.transformTo(e,t)}}(o,function(e,t){for(var n=0,i=null,r=0,o=0;o<t.length;o++)r+=t[o].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(r),o=0;o<t.length;o++)i.set(t[o],n),n+=t[o].length;return i;case"nodebuffer":return h.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(r,i),a);t(e)}catch(e){n(e)}i=[]}).resume()});var s,l},on:function(e,t){var n=this;return"data"===e?this._worker.on(e,function(e){t.call(n,e.data,e.meta)}):this._worker.on(e,function(){d.delay(t,arguments,n)}),this},resume:function(){return d.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(d.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new s(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=l},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,n.nodebuffer=void 0!==h,n.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)n.blob=!1;else{var i=new ArrayBuffer(0);try{n.blob=0===new Blob([i],{type:"application/zip"}).size}catch(e){try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(i),n.blob=0===r.getBlob("application/zip").size}catch(e){n.blob=!1}}}try{n.nodestream=!!e("readable-stream").Readable}catch(e){n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,r){for(var l=e("./utils"),d=e("./support"),c=e("./nodejsUtils"),n=e("./stream/GenericWorker"),h=new Array(256),i=0;i<256;i++)h[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;function o(){n.call(this,"utf-8 decode"),this.leftOver=null}function a(){n.call(this,"utf-8 encode")}h[254]=h[254]=1,r.utf8encode=function(e){if(d.nodebuffer)return c.newBufferFrom(e,"utf-8");for(var t,n,i,r,o=e,a=o.length,s=0,l=0;l<a;l++)55296==(64512&(n=o.charCodeAt(l)))&&l+1<a&&56320==(64512&(i=o.charCodeAt(l+1)))&&(n=65536+(n-55296<<10)+(i-56320),l++),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new(d.uint8array?Uint8Array:Array)(s),l=r=0;r<s;l++)55296==(64512&(n=o.charCodeAt(l)))&&l+1<a&&56320==(64512&(i=o.charCodeAt(l+1)))&&(n=65536+(n-55296<<10)+(i-56320),l++),n<128?t[r++]=n:(n<2048?t[r++]=192|n>>>6:(n<65536?t[r++]=224|n>>>12:(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63),t[r++]=128|n>>>6&63),t[r++]=128|63&n);return t},r.utf8decode=function(e){if(d.nodebuffer)return l.transformTo("nodebuffer",e).toString("utf-8");for(var t,n,i,r=e=l.transformTo(d.uint8array?"uint8array":"array",e),o=r.length,a=new Array(2*o),s=t=0;s<o;)if((n=r[s++])<128)a[t++]=n;else if(4<(i=h[n]))a[t++]=65533,s+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&s<o;)n=n<<6|63&r[s++],i--;1<i?a[t++]=65533:n<65536?a[t++]=n:(n-=65536,a[t++]=55296|n>>10&1023,a[t++]=56320|1023&n)}return a.length!==t&&(a.subarray?a=a.subarray(0,t):a.length=t),l.applyFromCharCode(a)},l.inherits(o,n),o.prototype.processChunk=function(e){var t=l.transformTo(d.uint8array?"uint8array":"array",e.data),n=(this.leftOver&&this.leftOver.length&&(d.uint8array?(n=t,(t=new Uint8Array(n.length+this.leftOver.length)).set(this.leftOver,0),t.set(n,this.leftOver.length)):t=this.leftOver.concat(t),this.leftOver=null),function(e,t){for(var n=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=n&&128==(192&e[n]);)n--;return!(n<0)&&0!==n&&n+h[e[n]]>t?n:t}(t)),i=t;n!==t.length&&(d.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:r.utf8decode(i),meta:e.meta})},o.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=o,l.inherits(a,n),a.prototype.processChunk=function(e){this.push({data:r.utf8encode(e.data),meta:e.meta})},r.Utf8EncodeWorker=a},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){var s=e("./support"),l=e("./base64"),n=e("./nodejsUtils"),d=e("./external");function i(e){return e}function c(e,t){for(var n=0;n<e.length;++n)t[n]=255&e.charCodeAt(n);return t}e("setimmediate"),a.newBlob=function(t,n){a.checkSupport("blob");try{return new Blob([t],{type:n})}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return i.append(t),i.getBlob(n)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var r={stringifyByChunk:function(e,t,n){var i=[],r=0,o=e.length;if(o<=n)return String.fromCharCode.apply(null,e);for(;r<o;)i.push("array"===t||"nodebuffer"===t?String.fromCharCode.apply(null,e.slice(r,Math.min(r+n,o))):String.fromCharCode.apply(null,e.subarray(r,Math.min(r+n,o)))),r+=n;return i.join("")},stringifyByChar:function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},applyCanBeUsed:{uint8array:function(){try{return s.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return s.nodebuffer&&1===String.fromCharCode.apply(null,n.allocBuffer(1)).length}catch(e){return!1}}()}};function o(e){var t=65536,n=a.getTypeOf(e),i=!0;if("uint8array"===n?i=r.applyCanBeUsed.uint8array:"nodebuffer"===n&&(i=r.applyCanBeUsed.nodebuffer),i)for(;1<t;)try{return r.stringifyByChunk(e,n,t)}catch(e){t=Math.floor(t/2)}return r.stringifyByChar(e)}function h(e,t){for(var n=0;n<e.length;n++)t[n]=e[n];return t}a.applyFromCharCode=o;var u={};u.string={string:i,array:function(e){return c(e,new Array(e.length))},arraybuffer:function(e){return u.string.uint8array(e).buffer},uint8array:function(e){return c(e,new Uint8Array(e.length))},nodebuffer:function(e){return c(e,n.allocBuffer(e.length))}},u.array={string:o,array:i,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(e)}},u.arraybuffer={string:function(e){return o(new Uint8Array(e))},array:function(e){return h(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:i,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(new Uint8Array(e))}},u.uint8array={string:o,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:i,nodebuffer:function(e){return n.newBufferFrom(e)}},u.nodebuffer={string:o,array:function(e){return h(e,new Array(e.length))},arraybuffer:function(e){return u.nodebuffer.uint8array(e).buffer},uint8array:function(e){return h(e,new Uint8Array(e.length))},nodebuffer:i},a.transformTo=function(e,t){if(t=t||"",!e)return t;a.checkSupport(e);var n=a.getTypeOf(t);return u[n][e](t)},a.resolve=function(e){for(var t=e.split("/"),n=[],i=0;i<t.length;i++){var r=t[i];"."===r||""===r&&0!==i&&i!==t.length-1||(".."===r?n.pop():n.push(r))}return n.join("/")},a.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":s.nodebuffer&&n.isBuffer(e)?"nodebuffer":s.uint8array&&e instanceof Uint8Array?"uint8array":s.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},a.checkSupport=function(e){if(!s[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},a.MAX_VALUE_16BITS=65535,a.MAX_VALUE_32BITS=-1,a.pretty=function(e){for(var t,n="",i=0;i<(e||"").length;i++)n+="\\x"+((t=e.charCodeAt(i))<16?"0":"")+t.toString(16).toUpperCase();return n},a.delay=function(e,t,n){p(function(){e.apply(n||null,t||[])})},a.inherits=function(e,t){function n(){}n.prototype=t.prototype,e.prototype=new n},a.extend=function(){for(var e,t={},n=0;n<arguments.length;n++)for(e in arguments[n])Object.prototype.hasOwnProperty.call(arguments[n],e)&&void 0===t[e]&&(t[e]=arguments[n][e]);return t},a.prepareContent=function(n,e,i,r,o){return d.Promise.resolve(e).then(function(i){return s.blob&&(i instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(i)))&&"undefined"!=typeof FileReader?new d.Promise(function(t,n){var e=new FileReader;e.onload=function(e){t(e.target.result)},e.onerror=function(e){n(e.target.error)},e.readAsArrayBuffer(i)}):i}).then(function(e){var t=a.getTypeOf(e);return t?("arraybuffer"===t?e=a.transformTo("uint8array",e):"string"===t&&(o?e=l.decode(e):i&&!0!==r&&(e=c(t=e,new(s.uint8array?Uint8Array:Array)(t.length)))),e):d.Promise.reject(new Error("Can't read the data of '"+n+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,n){var i=e("./reader/readerFor"),r=e("./utils"),o=e("./signature"),a=e("./zipEntry"),s=e("./support");function l(e){this.files=[],this.loadOptions=e}l.prototype={checkSignature:function(e){var t;if(!this.reader.readAndCheckSignature(e))throw this.reader.index-=4,t=this.reader.readString(4),new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(t)+", expected "+r.pretty(e)+")")},isSignature:function(e,t){var n=this.reader.index,e=(this.reader.setIndex(e),this.reader.readString(4)===t);return this.reader.setIndex(n),e},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=s.uint8array?"uint8array":"array",t=r.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(t)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,n,i=this.zip64EndOfCentralSize-44;0<i;)e=this.reader.readInt(2),t=this.reader.readInt(4),n=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:n}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){for(var e,t=0;t<this.files.length;t++)e=this.files[t],this.reader.setIndex(e.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),e.readLocalPart(this.reader),e.handleUTF8(),e.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(e=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(e);var t=e;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}e=this.centralDirOffset+this.centralDirSize,e=t-(e=this.zip64?e+20+(12+this.zip64EndOfCentralSize):e);if(0<e)this.isSignature(t,o.CENTRAL_FILE_HEADER)||(this.reader.zero=e);else if(e<0)throw new Error("Corrupted zip: missing "+Math.abs(e)+" bytes.")},prepareReader:function(e){this.reader=i(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=l},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,n){var i=e("./reader/readerFor"),r=e("./utils"),o=e("./compressedObject"),a=e("./crc32"),s=e("./utf8"),l=e("./compressions"),d=e("./support");function c(e,t){this.options=e,this.loadOptions=t}c.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t;if(e.skip(22),this.fileNameLength=e.readInt(2),t=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(t),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in l)if(Object.prototype.hasOwnProperty.call(l,t)&&l[t].magic===e)return l[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){var e;this.extraFields[1]&&(e=i(this.extraFields[1].value),this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS)&&(this.diskNumberStart=e.readInt(4))},readExtraFields:function(e){var t,n,i,r=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<r;)t=e.readInt(2),n=e.readInt(2),i=e.readData(n),this.extraFields[t]={id:t,length:n,value:i};e.setIndex(r)},handleUTF8:function(){var e,t=d.uint8array?"uint8array":"array";this.useUTF8()?(this.fileNameStr=s.utf8decode(this.fileName),this.fileCommentStr=s.utf8decode(this.fileComment)):(null!==(e=this.findExtraFieldUnicodePath())?this.fileNameStr=e:(e=r.transformTo(t,this.fileName),this.fileNameStr=this.loadOptions.decodeFileName(e)),null!==(e=this.findExtraFieldUnicodeComment())?this.fileCommentStr=e:(e=r.transformTo(t,this.fileComment),this.fileCommentStr=this.loadOptions.decodeFileName(e)))},findExtraFieldUnicodePath:function(){var e,t=this.extraFields[28789];return!t||1!==(e=i(t.value)).readInt(1)||a(this.fileName)!==e.readInt(4)?null:s.utf8decode(e.readData(t.length-5))},findExtraFieldUnicodeComment:function(){var e,t=this.extraFields[25461];return!t||1!==(e=i(t.value)).readInt(1)||a(this.fileComment)!==e.readInt(4)?null:s.utf8decode(e.readData(t.length-5))}},t.exports=c},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,n){function i(e,t,n){this.name=e,this.dir=n.dir,this.date=n.date,this.comment=n.comment,this.unixPermissions=n.unixPermissions,this.dosPermissions=n.dosPermissions,this._data=t,this._dataBinary=n.binary,this.options={compression:n.compression,compressionOptions:n.compressionOptions}}var o=e("./stream/StreamHelper"),r=e("./stream/DataWorker"),a=e("./utf8"),s=e("./compressedObject"),l=e("./stream/GenericWorker");i.prototype={internalStream:function(e){var t=null,n="string";try{if(!e)throw new Error("No output type specified.");var i="string"===(n=e.toLowerCase())||"text"===n,r=("binarystring"!==n&&"text"!==n||(n="string"),t=this._decompressWorker(),!this._dataBinary);r&&!i&&(t=t.pipe(new a.Utf8EncodeWorker)),!r&&i&&(t=t.pipe(new a.Utf8DecodeWorker))}catch(e){(t=new l("error")).error(e)}return new o(t,n,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){var n;return this._data instanceof s&&this._data.compression.magic===e.magic?this._data.getCompressedWorker():(n=this._decompressWorker(),this._dataBinary||(n=n.pipe(new a.Utf8EncodeWorker)),s.createWorkerFrom(n,e,t))},_decompressWorker:function(){return this._data instanceof s?this._data.getContentWorker():this._data instanceof l?this._data:new r(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],c=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)i.prototype[d[h]]=c;t.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,d,t){!function(t){var i,e,n,r,o=t.MutationObserver||t.WebKitMutationObserver,a=o?(e=0,o=new o(l),n=t.document.createTextNode(""),o.observe(n,{characterData:!0}),function(){n.data=e=++e%2}):t.setImmediate||void 0===t.MessageChannel?"document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){l(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(l,0)}:((r=new t.MessageChannel).port1.onmessage=l,function(){r.port2.postMessage(0)}),s=[];function l(){var e,t;i=!0;for(var n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}i=!1}d.exports=function(e){1!==s.push(e)||i||a()}}.call(this,void 0!==i?i:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,n){var r=e("immediate");function l(){}var d={},o=["REJECTED"],a=["FULFILLED"],i=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=i,this.queue=[],this.outcome=void 0,e!==l&&p(this,e)}function c(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function h(t,n,i){r(function(){var e;try{e=n(i)}catch(e){return d.reject(t,e)}e===t?d.reject(t,new TypeError("Cannot resolve promise with itself")):d.resolve(t,e)})}function u(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function p(t,e){var n=!1;function i(e){n||(n=!0,d.reject(t,e))}function r(e){n||(n=!0,d.resolve(t,e))}var o=f(function(){e(r,i)});"error"===o.status&&i(o.value)}function f(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}(t.exports=s).prototype.finally=function(t){var n;return"function"!=typeof t?this:(n=this.constructor,this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})}))},s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){var n;return"function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===o?this:(n=new this.constructor(l),this.state!==i?h(n,this.state===a?e:t,this.outcome):this.queue.push(new c(n,e,t)),n)},c.prototype.callFulfilled=function(e){d.resolve(this.promise,e)},c.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},c.prototype.callRejected=function(e){d.reject(this.promise,e)},c.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},d.resolve=function(e,t){var n=f(u,t);if("error"===n.status)return d.reject(e,n.value);n=n.value;if(n)p(e,n);else{e.state=a,e.outcome=t;for(var i=-1,r=e.queue.length;++i<r;)e.queue[i].callFulfilled(t)}return e},d.reject=function(e,t){e.state=o,e.outcome=t;for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e},s.resolve=function(e){return e instanceof this?e:d.resolve(new this(l),e)},s.reject=function(e){var t=new this(l);return d.reject(t,e)},s.all=function(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,r=!1;if(!i)return this.resolve([]);for(var o=new Array(i),a=0,t=-1,s=new this(l);++t<i;)!function(e,t){n.resolve(e).then(function(e){o[t]=e,++a!==i||r||(r=!0,d.resolve(s,o))},function(e){r||(r=!0,d.reject(s,e))})}(e[t],t);return s},s.race=function(e){if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var t=e.length,n=!1;if(!t)return this.resolve([]);for(var i,r=-1,o=new this(l);++r<t;)i=e[r],this.resolve(i).then(function(e){n||(n=!0,d.resolve(o,e))},function(e){n||(n=!0,d.reject(o,e))});return o}},{immediate:36}],38:[function(e,t,n){var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,n){var a=e("./zlib/deflate"),s=e("./utils/common"),l=e("./utils/strings"),i=e("./zlib/messages"),r=e("./zlib/zstream"),d=Object.prototype.toString;function o(e){if(!(this instanceof o))return new o(e);this.options=s.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var e=this.options,t=(e.raw&&0<e.windowBits?e.windowBits=-e.windowBits:e.gzip&&0<e.windowBits&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0,a.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy));if(0!==t)throw new Error(i[t]);if(e.header&&a.deflateSetHeader(this.strm,e.header),e.dictionary){e="string"==typeof e.dictionary?l.string2buf(e.dictionary):"[object ArrayBuffer]"===d.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary;if(0!==(t=a.deflateSetDictionary(this.strm,e)))throw new Error(i[t]);this._dict_set=!0}}function c(e,t){t=new o(t);if(t.push(e,!0),t.err)throw t.msg||i[t.err];return t.result}o.prototype.push=function(e,t){var n,i,r=this.strm,o=this.options.chunkSize;if(this.ended)return!1;i=t===~~t?t:!0===t?4:0,"string"==typeof e?r.input=l.string2buf(e):"[object ArrayBuffer]"===d.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(0===r.avail_out&&(r.output=new s.Buf8(o),r.next_out=0,r.avail_out=o),1!==(n=a.deflate(r,i))&&0!==n)return this.onEnd(n),!(this.ended=!0)}while(0!==r.avail_out&&(0!==r.avail_in||4!==i&&2!==i)||("string"===this.options.to?this.onData(l.buf2binstring(s.shrinkBuf(r.output,r.next_out))):this.onData(s.shrinkBuf(r.output,r.next_out))),(0<r.avail_in||0===r.avail_out)&&1!==n);return 4===i?(n=a.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==i||(this.onEnd(0),!(r.avail_out=0))},o.prototype.onData=function(e){this.chunks.push(e)},o.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=o,n.deflate=c,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,c(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,n){var h=e("./zlib/inflate"),u=e("./utils/common"),p=e("./utils/strings"),f=e("./zlib/constants"),i=e("./zlib/messages"),r=e("./zlib/zstream"),o=e("./zlib/gzheader"),m=Object.prototype.toString;function a(e){if(!(this instanceof a))return new a(e);this.options=u.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits)&&(t.windowBits=-15),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0,h.inflateInit2(this.strm,t.windowBits));if(e!==f.Z_OK)throw new Error(i[e]);this.header=new o,h.inflateGetHeader(this.strm,this.header)}function s(e,t){t=new a(t);if(t.push(e,!0),t.err)throw t.msg||i[t.err];return t.result}a.prototype.push=function(e,t){var n,i,r,o,a,s=this.strm,l=this.options.chunkSize,d=this.options.dictionary,c=!1;if(this.ended)return!1;i=t===~~t?t:!0===t?f.Z_FINISH:f.Z_NO_FLUSH,"string"==typeof e?s.input=p.binstring2buf(e):"[object ArrayBuffer]"===m.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new u.Buf8(l),s.next_out=0,s.avail_out=l),(n=h.inflate(s,f.Z_NO_FLUSH))===f.Z_NEED_DICT&&d&&(a="string"==typeof d?p.string2buf(d):"[object ArrayBuffer]"===m.call(d)?new Uint8Array(d):d,n=h.inflateSetDictionary(this.strm,a)),n===f.Z_BUF_ERROR&&!0===c&&(n=f.Z_OK,c=!1),n!==f.Z_STREAM_END&&n!==f.Z_OK)return this.onEnd(n),!(this.ended=!0)}while(!s.next_out||0!==s.avail_out&&n!==f.Z_STREAM_END&&(0!==s.avail_in||i!==f.Z_FINISH&&i!==f.Z_SYNC_FLUSH)||("string"===this.options.to?(a=p.utf8border(s.output,s.next_out),r=s.next_out-a,o=p.buf2string(s.output,a),s.next_out=r,s.avail_out=l-r,r&&u.arraySet(s.output,s.output,a,r,0),this.onData(o)):this.onData(u.shrinkBuf(s.output,s.next_out))),0===s.avail_in&&0===s.avail_out&&(c=!0),(0<s.avail_in||0===s.avail_out)&&n!==f.Z_STREAM_END);return(i=n===f.Z_STREAM_END?f.Z_FINISH:i)===f.Z_FINISH?(n=h.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===f.Z_OK):i!==f.Z_SYNC_FLUSH||(this.onEnd(f.Z_OK),!(s.avail_out=0))},a.prototype.onData=function(e){this.chunks.push(e)},a.prototype.onEnd=function(e){e===f.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=u.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=a,n.inflate=s,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,s(e,t)},n.ungzip=s},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,n){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array,r=(n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)},{arraySet:function(e,t,n,i,r){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+i),r);else for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){for(var t,n,i,r,o=t=0,a=e.length;o<a;o++)t+=e[o].length;for(r=new Uint8Array(t),o=n=0,a=e.length;o<a;o++)i=e[o],r.set(i,n),n+=i.length;return r}}),o={arraySet:function(e,t,n,i,r){for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,r)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,o))},n.setTyped(i)},{}],42:[function(e,t,n){var l=e("./common"),r=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var d=new l.Buf8(256),i=0;i<256;i++)d[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;function c(e,t){if(t<65537&&(e.subarray&&o||!e.subarray&&r))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n}d[254]=d[254]=1,n.string2buf=function(e){for(var t,n,i,r,o=e.length,a=0,s=0;s<o;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),a+=n<128?1:n<2048?2:n<65536?3:4;for(t=new l.Buf8(a),s=r=0;r<a;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),n<128?t[r++]=n:(n<2048?t[r++]=192|n>>>6:(n<65536?t[r++]=224|n>>>12:(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63),t[r++]=128|n>>>6&63),t[r++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new l.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){for(var n,i,r,o=t||e.length,a=new Array(2*o),s=n=0;s<o;)if((i=e[s++])<128)a[n++]=i;else if(4<(r=d[i]))a[n++]=65533,s+=r-1;else{for(i&=2===r?31:3===r?15:7;1<r&&s<o;)i=i<<6|63&e[s++],r--;1<r?a[n++]=65533:i<65536?a[n++]=i:(i-=65536,a[n++]=55296|i>>10&1023,a[n++]=56320|1023&i)}return c(a,n)},n.utf8border=function(e,t){for(var n=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=n&&128==(192&e[n]);)n--;return!(n<0)&&0!==n&&n+d[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){t.exports=function(e,t,n,i){for(var r=65535&e|0,o=e>>>16&65535|0,a=0;0!==n;){for(n-=a=2e3<n?2e3:n;o=o+(r=r+t[i++]|0)|0,--a;);r%=65521,o%=65521}return r|o<<16|0}},{}],44:[function(e,t,n){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,n){var s=function(){for(var e=[],t=0;t<256;t++){for(var n=t,i=0;i<8;i++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e}();t.exports=function(e,t,n,i){var r=s,o=i+n;e^=-1;for(var a=i;a<o;a++)e=e>>>8^r[255&(e^t[a])];return-1^e}},{}],46:[function(e,F,t){var s,h=e("../utils/common"),l=e("./trees"),u=e("./adler32"),p=e("./crc32"),n=e("./messages"),d=0,c=0,f=-2,i=2,m=8,r=286,o=30,a=19,N=2*r+1,j=15,g=3,v=258,A=v+g+1,y=42,E=113;function M(e,t){return e.msg=n[t],t}function w(e){return(e<<1)-(4<e?9:0)}function b(e){for(var t=e.length;0<=--t;)e[t]=0}function x(e){var t=e.state,n=t.pending;0!==(n=n>e.avail_out?e.avail_out:n)&&(h.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending)&&(t.pending_out=0)}function I(e,t){l._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,x(e.strm)}function T(e,t){e.pending_buf[e.pending++]=t}function S(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function B(e,t){var n,i,r=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-A?e.strstart-(e.w_size-A):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+v,p=d[o+a-1],f=d[o+a];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do{if(d[(n=t)+a]===f&&d[n+a-1]===p&&d[n]===d[o]&&d[++n]===d[o+1]){for(o+=2,n++;d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&o<u;);if(i=v-(u-o),o=u-v,a<i){if(e.match_start=t,s<=(a=i))break;p=d[o+a-1],f=d[o+a]}}}while((t=h[t&c])>l&&0!=--r);return a<=e.lookahead?a:e.lookahead}function P(e){var t,n,i,r,o,a,s,l,d,c=e.w_size;do{if(l=e.window_size-e.lookahead-e.strstart,e.strstart>=c+(c-A)){for(h.arraySet(e.window,e.window,c,c,0),e.match_start-=c,e.strstart-=c,e.block_start-=c,t=n=e.hash_size;i=e.head[--t],e.head[t]=c<=i?i-c:0,--n;);for(t=n=c;i=e.prev[--t],e.prev[t]=c<=i?i-c:0,--n;);l+=c}if(0===e.strm.avail_in)break;if(o=e.strm,a=e.window,s=e.strstart+e.lookahead,d=void 0,n=0===(d=(l=l)<(d=o.avail_in)?l:d)?0:(o.avail_in-=d,h.arraySet(a,o.input,o.next_in,d,s),1===o.state.wrap?o.adler=u(o.adler,a,d,s):2===o.state.wrap&&(o.adler=p(o.adler,a,d,s)),o.next_in+=d,o.total_in+=d,d),e.lookahead+=n,e.lookahead+e.insert>=g)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+g-1])&e.hash_mask,e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<g)););}while(e.lookahead<A&&0!==e.strm.avail_in)}function C(e,t){for(var n,i;;){if(e.lookahead<A){if(P(e),e.lookahead<A&&t===d)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=g&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-A&&(e.match_length=B(e,n)),e.match_length>=g)if(i=l._tr_tally(e,e.strstart-e.match_start,e.match_length-g),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=g){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=l._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(I(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<g-1?e.strstart:g-1,4===t?(I(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(I(e,!1),0===e.strm.avail_out)?1:2}function R(e,t){for(var n,i,r;;){if(e.lookahead<A){if(P(e),e.lookahead<A&&t===d)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=g&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=g-1,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-A&&(e.match_length=B(e,n),e.match_length<=5)&&(1===e.strategy||e.match_length===g&&4096<e.strstart-e.match_start)&&(e.match_length=g-1),e.prev_length>=g&&e.match_length<=e.prev_length){for(r=e.strstart+e.lookahead-g,i=l._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-g),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+g-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=g-1,e.strstart++,i&&(I(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((i=l._tr_tally(e,0,e.window[e.strstart-1]))&&I(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=l._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<g-1?e.strstart:g-1,4===t?(I(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(I(e,!1),0===e.strm.avail_out)?1:2}function O(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}function _(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=m,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new h.Buf16(2*N),this.dyn_dtree=new h.Buf16(2*(2*o+1)),this.bl_tree=new h.Buf16(2*(2*a+1)),b(this.dyn_ltree),b(this.dyn_dtree),b(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new h.Buf16(j+1),this.heap=new h.Buf16(2*r+1),b(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new h.Buf16(2*r+1),b(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function L(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=i,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?y:E,e.adler=2===t.wrap?0:1,t.last_flush=d,l._tr_init(t),c):M(e,f)}function D(e){var t=L(e);return t===c&&((e=e.state).window_size=2*e.w_size,b(e.head),e.max_lazy_match=s[e.level].max_lazy,e.good_match=s[e.level].good_length,e.nice_match=s[e.level].nice_length,e.max_chain_length=s[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=g-1,e.match_available=0,e.ins_h=0),t}function H(e,t,n,i,r,o){if(!e)return f;var a=1;if(-1===t&&(t=6),i<0?(a=0,i=-i):15<i&&(a=2,i-=16),r<1||9<r||n!==m||i<8||15<i||t<0||9<t||o<0||4<o)return M(e,f);8===i&&(i=9);var s=new _;return(e.state=s).strm=e,s.wrap=a,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=r+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+g-1)/g),s.window=new h.Buf8(2*s.w_size),s.head=new h.Buf16(s.hash_size),s.prev=new h.Buf16(s.w_size),s.lit_bufsize=1<<r+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new h.Buf8(s.pending_buf_size),s.d_buf=+s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=n,D(e)}s=[new O(0,0,0,0,function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(P(e),0===e.lookahead&&t===d)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,I(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-A&&(I(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(I(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(I(e,!1),e.strm.avail_out),1)}),new O(4,4,8,4,C),new O(4,5,16,8,C),new O(4,6,32,32,C),new O(4,4,16,16,R),new O(8,16,32,32,R),new O(8,16,128,128,R),new O(8,32,128,256,R),new O(32,128,258,1024,R),new O(32,258,258,4096,R)],t.deflateInit=function(e,t){return H(e,t,m,15,8,0)},t.deflateInit2=H,t.deflateReset=D,t.deflateResetKeep=L,t.deflateSetHeader=function(e,t){return!e||!e.state||2!==e.state.wrap?f:(e.state.gzhead=t,c)},t.deflate=function(e,t){var n,i,r,o;if(!e||!e.state||5<t||t<0)return e?M(e,f):f;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return M(e,0===e.avail_out?-5:f);if(i.strm=e,n=i.last_flush,i.last_flush=t,i.status===y&&(2===i.wrap?(e.adler=0,T(i,31),T(i,139),T(i,8),i.gzhead?(T(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),T(i,255&i.gzhead.time),T(i,i.gzhead.time>>8&255),T(i,i.gzhead.time>>16&255),T(i,i.gzhead.time>>24&255),T(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),T(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(T(i,255&i.gzhead.extra.length),T(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=p(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(T(i,0),T(i,0),T(i,0),T(i,0),T(i,0),T(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),T(i,3),i.status=E)):(a=m+(i.w_bits-8<<4)<<8,a|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(a|=32),a+=31-a%31,i.status=E,S(i,a),0!==i.strstart&&(S(i,e.adler>>>16),S(i,65535&e.adler)),e.adler=1)),69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),x(e),r=i.pending,i.pending!==i.pending_buf_size));)T(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),x(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}}while(o=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,T(i,o),0!==o);i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),0===o&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),x(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}}while(o=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,T(i,o),0!==o);i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),0===o&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&x(e),i.pending+2<=i.pending_buf_size&&(T(i,255&e.adler),T(i,e.adler>>8&255),e.adler=0,i.status=E)):i.status=E),0!==i.pending){if(x(e),0===e.avail_out)return i.last_flush=-1,c}else if(0===e.avail_in&&w(t)<=w(n)&&4!==t)return M(e,-5);if(666===i.status&&0!==e.avail_in)return M(e,-5);if(0!==e.avail_in||0!==i.lookahead||t!==d&&666!==i.status){var a=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(P(e),0===e.lookahead)){if(t===d)return 1;break}if(e.match_length=0,n=l._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(I(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(I(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(I(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,i,r,o,a=e.window;;){if(e.lookahead<=v){if(P(e),e.lookahead<=v&&t===d)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=g&&0<e.strstart&&(i=a[r=e.strstart-1])===a[++r]&&i===a[++r]&&i===a[++r]){for(o=e.strstart+v;i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&r<o;);e.match_length=v-(o-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=g?(n=l._tr_tally(e,1,e.match_length-g),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=l._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(I(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(I(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(I(e,!1),0===e.strm.avail_out)?1:2}(i,t):s[i.level].func(i,t);if(3!==a&&4!==a||(i.status=666),1===a||3===a)return 0===e.avail_out&&(i.last_flush=-1),c;if(2===a&&(1===t?l._tr_align(i):5!==t&&(l._tr_stored_block(i,0,0,!1),3===t)&&(b(i.head),0===i.lookahead)&&(i.strstart=0,i.block_start=0,i.insert=0),x(e),0===e.avail_out))return i.last_flush=-1,c}return 4!==t||!(i.wrap<=0)&&(2===i.wrap?(T(i,255&e.adler),T(i,e.adler>>8&255),T(i,e.adler>>16&255),T(i,e.adler>>24&255),T(i,255&e.total_in),T(i,e.total_in>>8&255),T(i,e.total_in>>16&255),T(i,e.total_in>>24&255)):(S(i,e.adler>>>16),S(i,65535&e.adler)),x(e),0<i.wrap&&(i.wrap=-i.wrap),0!==i.pending)?c:1},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==y&&69!==t&&73!==t&&91!==t&&103!==t&&t!==E&&666!==t?M(e,f):(e.state=null,t===E?M(e,-3):c):f},t.deflateSetDictionary=function(e,t){var n,i,r,o,a,s,l,d=t.length;if(!e||!e.state)return f;if(2===(o=(n=e.state).wrap)||1===o&&n.status!==y||n.lookahead)return f;for(1===o&&(e.adler=u(e.adler,t,d,0)),n.wrap=0,d>=n.w_size&&(0===o&&(b(n.head),n.strstart=0,n.block_start=0,n.insert=0),l=new h.Buf8(n.w_size),h.arraySet(l,t,d-n.w_size,n.w_size,0),t=l,d=n.w_size),l=e.avail_in,a=e.next_in,s=e.input,e.avail_in=d,e.next_in=0,e.input=t,P(n);n.lookahead>=g;){for(i=n.strstart,r=n.lookahead-(g-1);n.ins_h=(n.ins_h<<n.hash_shift^n.window[i+g-1])&n.hash_mask,n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,--r;);n.strstart=i,n.lookahead=g-1,P(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=g-1,n.match_available=0,e.next_in=a,e.input=s,e.avail_in=l,n.wrap=o,c},t.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,n){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,n){t.exports=function(e,t){var n,i,r,o,a,s,l=e.state,d=e.next_in,c=e.input,h=d+(e.avail_in-5),u=e.next_out,p=e.output,f=u-(t-e.avail_out),m=u+(e.avail_out-257),g=l.dmax,v=l.wsize,A=l.whave,y=l.wnext,E=l.window,M=l.hold,w=l.bits,b=l.lencode,x=l.distcode,I=(1<<l.lenbits)-1,T=(1<<l.distbits)-1;e:do{for(w<15&&(M+=c[d++]<<w,w+=8,M+=c[d++]<<w,w+=8),n=b[M&I];;){if(M>>>=i=n>>>24,w-=i,0==(i=n>>>16&255))p[u++]=65535&n;else{if(!(16&i)){if(0==(64&i)){n=b[(65535&n)+(M&(1<<i)-1)];continue}if(32&i){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(r=65535&n,(i&=15)&&(w<i&&(M+=c[d++]<<w,w+=8),r+=M&(1<<i)-1,M>>>=i,w-=i),w<15&&(M+=c[d++]<<w,w+=8,M+=c[d++]<<w,w+=8),n=x[M&T];;){if(M>>>=i=n>>>24,w-=i,!(16&(i=n>>>16&255))){if(0==(64&i)){n=x[(65535&n)+(M&(1<<i)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(o=65535&n,w<(i&=15)&&(M+=c[d++]<<w,(w+=8)<i)&&(M+=c[d++]<<w,w+=8),g<(o+=M&(1<<i)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(M>>>=i,w-=i,(i=u-f)<o){if(A<(i=o-i)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(s=E,(a=0)===y){if(a+=v-i,i<r){for(r-=i;p[u++]=E[a++],--i;);a=u-o,s=p}}else if(y<i){if(a+=v+y-i,(i-=y)<r){for(r-=i;p[u++]=E[a++],--i;);if(a=0,y<r){for(r-=i=y;p[u++]=E[a++],--i;);a=u-o,s=p}}}else if(a+=y-i,i<r){for(r-=i;p[u++]=E[a++],--i;);a=u-o,s=p}for(;2<r;)p[u++]=s[a++],p[u++]=s[a++],p[u++]=s[a++],r-=3;r&&(p[u++]=s[a++],1<r)&&(p[u++]=s[a++])}else{for(a=u-o;p[u++]=p[a++],p[u++]=p[a++],p[u++]=p[a++],2<(r-=3););r&&(p[u++]=p[a++],1<r)&&(p[u++]=p[a++])}break}}break}}while(d<h&&u<m);d-=r=w>>3,M&=(1<<(w-=r<<3))-1,e.next_in=d,e.next_out=u,e.avail_in=d<h?h-d+5:5-(d-h),e.avail_out=u<m?m-u+257:257-(u-m),l.hold=M,l.bits=w}},{}],49:[function(e,t,n){var R=e("../utils/common"),O=e("./adler32"),L=e("./crc32"),D=e("./inffast"),H=e("./inftrees"),F=0,N=-2,j=1,i=852,r=592;function _(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function o(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new R.Buf16(320),this.work=new R.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=j,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new R.Buf32(i),t.distcode=t.distdyn=new R.Buf32(r),t.sane=1,t.back=-1,F):N}function s(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):N}function l(e,t){var n,i;return!e||!e.state||(i=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?N:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,s(e))}function d(e,t){var n;return e?(n=new o,(e.state=n).window=null,(n=l(e,t))!==F&&(e.state=null),n):N}var V,k,U=!0;function G(e,t,n,i){var r,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new R.Buf8(e.wsize)),i>=e.wsize?(R.arraySet(e.window,t,n-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(i<(r=e.wsize-e.wnext)&&(r=i),R.arraySet(e.window,t,n-i,r,e.wnext),(i-=r)?(R.arraySet(e.window,t,n-i,i,0),e.wnext=i,e.whave=e.wsize):(e.wnext+=r,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=r))),0}n.inflateReset=s,n.inflateReset2=l,n.inflateResetKeep=a,n.inflateInit=function(e){return d(e,15)},n.inflateInit2=d,n.inflate=function(e,t){var n,i,r,o,a,s,l,d,c,h,u,p,f,m,g,v,A,y,E,M,w,b,x,I,T=0,S=new R.Buf8(4),B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return N;12===(n=e.state).mode&&(n.mode=13),a=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,d=n.hold,c=n.bits,h=s,u=l,b=F;e:for(;;)switch(n.mode){case j:if(0===n.wrap)n.mode=13;else{for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(2&n.wrap&&35615===d)S[n.check=0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0),c=d=0,n.mode=2;else if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&d)<<8)+(d>>8))%31)e.msg="incorrect header check",n.mode=30;else if(8!=(15&d))e.msg="unknown compression method",n.mode=30;else{if(c-=4,w=8+(15&(d>>>=4)),0===n.wbits)n.wbits=w;else if(w>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<w,e.adler=n.check=1,n.mode=512&d?10:12,c=d=0}}break;case 2:for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(n.flags=d,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=d>>8&1),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0)),c=d=0,n.mode=3;case 3:for(;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.head&&(n.head.time=d),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,S[2]=d>>>16&255,S[3]=d>>>24&255,n.check=L(n.check,S,4,0)),c=d=0,n.mode=4;case 4:for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.head&&(n.head.xflags=255&d,n.head.os=d>>8),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0)),c=d=0,n.mode=5;case 5:if(1024&n.flags){for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.length=d,n.head&&(n.head.extra_len=d),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0)),c=d=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((p=s<(p=n.length)?s:p)&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),R.arraySet(n.head.extra,i,o,p,w)),512&n.flags&&(n.check=L(n.check,i,p,o)),s-=p,o+=p,n.length-=p),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===s)break e;for(p=0;w=i[o+p++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w)),w&&p<s;);if(512&n.flags&&(n.check=L(n.check,i,p,o)),s-=p,o+=p,w)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===s)break e;for(p=0;w=i[o+p++],n.head&&w&&n.length<65536&&(n.head.comment+=String.fromCharCode(w)),w&&p<s;);if(512&n.flags&&(n.check=L(n.check,i,p,o)),s-=p,o+=p,w)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(d!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}c=d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}e.adler=n.check=_(d),c=d=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=a,e.avail_out=l,e.next_in=o,e.avail_in=s,n.hold=d,n.bits=c,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last)d>>>=7&c,c-=7&c,n.mode=27;else{for(;c<3;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}switch(n.last=1&d,--c,3&(d>>>=1)){case 0:n.mode=14;break;case 1:P=C=void 0;var P,C=n;if(U){for(V=new R.Buf32(512),k=new R.Buf32(32),P=0;P<144;)C.lens[P++]=8;for(;P<256;)C.lens[P++]=9;for(;P<280;)C.lens[P++]=7;for(;P<288;)C.lens[P++]=8;for(H(1,C.lens,0,288,V,0,C.work,{bits:9}),P=0;P<32;)C.lens[P++]=5;H(2,C.lens,0,32,k,0,C.work,{bits:5}),U=!1}if(C.lencode=V,C.lenbits=9,C.distcode=k,C.distbits=5,n.mode=20,6!==t)break;d>>>=2,c-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}d>>>=2,c-=2}break;case 14:for(d>>>=7&c,c-=7&c;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&d,c=d=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(p=n.length){if(0===(p=l<(p=s<p?s:p)?l:p))break e;R.arraySet(r,i,o,p,a),s-=p,o+=p,l-=p,a+=p,n.length-=p}else n.mode=12;break;case 17:for(;c<14;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(n.nlen=257+(31&d),d>>>=5,c-=5,n.ndist=1+(31&d),d>>>=5,c-=5,n.ncode=4+(15&d),d>>>=4,c-=4,286<n.nlen||30<n.ndist){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;c<3;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.lens[B[n.have++]]=7&d,d>>>=3,c-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,x={bits:n.lenbits},b=H(0,n.lens,0,19,n.lencode,0,n.work,x),n.lenbits=x.bits,b){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;v=(T=n.lencode[d&(1<<n.lenbits)-1])>>>16&255,A=65535&T,!((g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(A<16)d>>>=g,c-=g,n.lens[n.have++]=A;else{if(16===A){for(I=g+2;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(d>>>=g,c-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}w=n.lens[n.have-1],p=3+(3&d),d>>>=2,c-=2}else if(17===A){for(I=g+3;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}w=0,p=3+(7&(d>>>=g)),d>>>=3,c=c-g-3}else{for(I=g+7;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}w=0,p=11+(127&(d>>>=g)),d>>>=7,c=c-g-7}if(n.have+p>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;p--;)n.lens[n.have++]=w}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,x={bits:n.lenbits},b=H(1,n.lens,0,n.nlen,n.lencode,0,n.work,x),n.lenbits=x.bits,b){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,x={bits:n.distbits},b=H(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,x),n.distbits=x.bits,b){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=s&&258<=l){e.next_out=a,e.avail_out=l,e.next_in=o,e.avail_in=s,n.hold=d,n.bits=c,D(e,u),a=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,d=n.hold,c=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;v=(T=n.lencode[d&(1<<n.lenbits)-1])>>>16&255,A=65535&T,!((g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(v&&0==(240&v)){for(y=g,E=v,M=A;v=(T=n.lencode[M+((d&(1<<y+E)-1)>>y)])>>>16&255,A=65535&T,!(y+(g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}d>>>=y,c-=y,n.back+=y}if(d>>>=g,c-=g,n.back+=g,n.length=A,0===v){n.mode=26;break}if(32&v){n.back=-1,n.mode=12;break}if(64&v){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&v,n.mode=22;case 22:if(n.extra){for(I=n.extra;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.length+=d&(1<<n.extra)-1,d>>>=n.extra,c-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;v=(T=n.distcode[d&(1<<n.distbits)-1])>>>16&255,A=65535&T,!((g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(0==(240&v)){for(y=g,E=v,M=A;v=(T=n.distcode[M+((d&(1<<y+E)-1)>>y)])>>>16&255,A=65535&T,!(y+(g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}d>>>=y,c-=y,n.back+=y}if(d>>>=g,c-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=30;break}n.offset=A,n.extra=15&v,n.mode=24;case 24:if(n.extra){for(I=n.extra;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.offset+=d&(1<<n.extra)-1,d>>>=n.extra,c-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===l)break e;if(n.offset>(p=u-l)){if((p=n.offset-p)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}f=p>n.wnext?(p-=n.wnext,n.wsize-p):n.wnext-p,p>n.length&&(p=n.length),m=n.window}else m=r,f=a-n.offset,p=n.length;for(l-=p=l<p?l:p,n.length-=p;r[a++]=m[f++],--p;);0===n.length&&(n.mode=21);break;case 26:if(0===l)break e;r[a++]=n.length,l--,n.mode=21;break;case 27:if(n.wrap){for(;c<32;){if(0===s)break e;s--,d|=i[o++]<<c,c+=8}if(u-=l,e.total_out+=u,n.total+=u,u&&(e.adler=n.check=(n.flags?L:O)(n.check,r,u,a-u)),u=l,(n.flags?d:_(d))!==n.check){e.msg="incorrect data check",n.mode=30;break}c=d=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(d!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}c=d=0}n.mode=29;case 29:b=1;break e;case 30:b=-3;break e;case 31:return-4;default:return N}return e.next_out=a,e.avail_out=l,e.next_in=o,e.avail_in=s,n.hold=d,n.bits=c,(n.wsize||u!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&G(e,e.output,e.next_out,u-e.avail_out)?(n.mode=31,-4):(h-=e.avail_in,u-=e.avail_out,e.total_in+=h,e.total_out+=u,n.total+=u,n.wrap&&u&&(e.adler=n.check=(n.flags?L:O)(n.check,r,u,e.next_out-u)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),b=(0==h&&0===u||4===t)&&b===F?-5:b)},n.inflateEnd=function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,F):N},n.inflateGetHeader=function(e,t){return!e||!e.state||0==(2&(e=e.state).wrap)?N:((e.head=t).done=!1,F)},n.inflateSetDictionary=function(e,t){var n,i=t.length;return!e||!e.state||0!==(n=e.state).wrap&&11!==n.mode?N:11===n.mode&&O(1,t,i,0)!==n.check?-3:G(e,t,i,i)?(n.mode=31,-4):(n.havedict=1,F)},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,n){var D=e("../utils/common"),H=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],F=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],N=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],j=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,i,r,o,a,s){for(var l,d,c,h,u,p,f,m,g,v=s.bits,A=0,y=0,E=0,M=0,w=0,b=0,x=0,I=0,T=0,S=0,B=null,P=0,C=new D.Buf16(16),R=new D.Buf16(16),O=null,L=0,A=0;A<=15;A++)C[A]=0;for(y=0;y<i;y++)C[t[n+y]]++;for(w=v,M=15;1<=M&&0===C[M];M--);if(M<w&&(w=M),0===M)r[o++]=20971520,r[o++]=20971520,s.bits=1;else{for(E=1;E<M&&0===C[E];E++);for(w<E&&(w=E),A=I=1;A<=15;A++)if((I=(I<<1)-C[A])<0)return-1;if(0<I&&(0===e||1!==M))return-1;for(R[1]=0,A=1;A<15;A++)R[A+1]=R[A]+C[A];for(y=0;y<i;y++)0!==t[n+y]&&(a[R[t[n+y]]++]=y);if(p=0===e?(B=O=a,19):1===e?(B=H,P-=257,O=F,L-=257,256):(B=N,O=j,-1),A=E,u=o,x=y=S=0,c=-1,h=(T=1<<(b=w))-1,1===e&&852<T||2===e&&592<T)return 1;for(;;){for(g=a[y]<p?(m=0,a[y]):a[y]>p?(m=O[L+a[y]],B[P+a[y]]):(m=96,0),l=1<<(f=A-x),E=d=1<<b;r[u+(S>>x)+(d-=l)]=f<<24|m<<16|g|0,0!==d;);for(l=1<<A-1;S&l;)l>>=1;if(0!==l?S=(S&l-1)+l:S=0,y++,0==--C[A]){if(A===M)break;A=t[n+a[y]]}if(w<A&&(S&h)!==c){for(u+=E,I=1<<(b=A-(x=0===x?w:x));b+x<M&&!((I-=C[b+x])<=0);)b++,I<<=1;if(T+=1<<b,1===e&&852<T||2===e&&592<T)return 1;r[c=S&h]=w<<24|b<<16|u-o|0}}0!==S&&(r[u+S]=A-x<<24|64<<16|0),s.bits=w}return 0}},{"../utils/common":41}],51:[function(e,t,n){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,F,t){var r=e("../utils/common");function n(e){for(var t=e.length;0<=--t;)e[t]=0}var i=16,l=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],d=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],h=new Array(576),u=(n(h),new Array(60)),p=(n(u),new Array(512)),f=(n(p),new Array(256)),m=(n(f),new Array(29));n(m);var g,v,A,y=new Array(30);function E(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}function M(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function w(e){return e<256?p[e]:p[256+(e>>>7)]}function o(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function b(e,t,n){e.bi_valid>i-n?(e.bi_buf|=t<<e.bi_valid&65535,o(e,e.bi_buf),e.bi_buf=t>>i-e.bi_valid,e.bi_valid+=n-i):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function x(e,t,n){b(e,n[2*t],n[2*t+1])}function I(e,t){for(var n=0;n|=1&e,e>>>=1,n<<=1,0<--t;);return n>>>1}function T(e,t,n){for(var i,r=new Array(16),o=0,a=1;a<=15;a++)r[a]=o=o+n[a-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=I(r[s]++,s))}}function S(e){for(var t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function B(e){8<e.bi_valid?o(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function a(e,t,n,i){var r=2*t,o=2*n;return e[r]<e[o]||e[r]===e[o]&&i[t]<=i[n]}function P(e,t,n){for(var i=e.heap[n],r=n<<1;r<=e.heap_len&&(r<e.heap_len&&a(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!a(t,i,e.heap[r],e.depth));)e.heap[n]=e.heap[r],n=r,r<<=1;e.heap[n]=i}function C(e,t,n){var i,r,o,a,s=0;if(0!==e.last_lit)for(;i=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],r=e.pending_buf[e.l_buf+s],s++,0==i?x(e,r,t):(x(e,(o=f[r])+256+1,t),0!==(a=l[o])&&b(e,r-=m[o],a),x(e,o=w(--i),n),0!==(a=d[o])&&b(e,i-=y[o],a)),s<e.last_lit;);x(e,256,t)}function R(e,t){var n,i,r,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,l=t.stat_desc.elems,d=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<l;n++)0!==o[2*n]?(e.heap[++e.heap_len]=d=n,e.depth[n]=0):o[2*n+1]=0;for(;e.heap_len<2;)o[2*(r=e.heap[++e.heap_len]=d<2?++d:0)]=1,e.depth[r]=0,e.opt_len--,s&&(e.static_len-=a[2*r+1]);for(t.max_code=d,n=e.heap_len>>1;1<=n;n--)P(e,o,n);for(r=l;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],P(e,o,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,o[2*r]=o[2*n]+o[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,o[2*n+1]=o[2*i+1]=r,e.heap[1]=r++,P(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1];for(var c,h,u,p,f,m=e,g=t.dyn_tree,v=t.max_code,A=t.stat_desc.static_tree,y=t.stat_desc.has_stree,E=t.stat_desc.extra_bits,M=t.stat_desc.extra_base,w=t.stat_desc.max_length,b=0,x=0;x<=15;x++)m.bl_count[x]=0;for(g[2*m.heap[m.heap_max]+1]=0,c=m.heap_max+1;c<573;c++)w<(x=g[2*g[2*(h=m.heap[c])+1]+1]+1)&&(x=w,b++),g[2*h+1]=x,v<h||(m.bl_count[x]++,p=0,M<=h&&(p=E[h-M]),f=g[2*h],m.opt_len+=f*(x+p),y&&(m.static_len+=f*(A[2*h+1]+p)));if(0!==b){do{for(x=w-1;0===m.bl_count[x];)x--}while(m.bl_count[x]--,m.bl_count[x+1]+=2,m.bl_count[w]--,0<(b-=2));for(x=w;0!==x;x--)for(h=m.bl_count[x];0!==h;)v<(u=m.heap[--c])||(g[2*u+1]!==x&&(m.opt_len+=(x-g[2*u+1])*g[2*u],g[2*u+1]=x),h--)}T(o,d,e.bl_count)}function O(e,t,n){var i,r,o=-1,a=t[1],s=0,l=7,d=4;for(0===a&&(l=138,d=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=a,a=t[2*(i+1)+1],++s<l&&r===a||(s<d?e.bl_tree[2*r]+=s:0!==r?(r!==o&&e.bl_tree[2*r]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=r,d=(s=0)===a?(l=138,3):r===a?(l=6,3):(l=7,4))}function L(e,t,n){var i,r,o=-1,a=t[1],s=0,l=7,d=4;for(0===a&&(l=138,d=3),i=0;i<=n;i++)if(r=a,a=t[2*(i+1)+1],!(++s<l&&r===a)){if(s<d)for(;x(e,r,e.bl_tree),0!=--s;);else 0!==r?(r!==o&&(x(e,r,e.bl_tree),s--),x(e,16,e.bl_tree),b(e,s-3,2)):s<=10?(x(e,17,e.bl_tree),b(e,s-3,3)):(x(e,18,e.bl_tree),b(e,s-11,7));o=r,d=(s=0)===a?(l=138,3):r===a?(l=6,3):(l=7,4)}}n(y);var D=!1;function H(e,t,n,i){b(e,0+(i?1:0),3),i=t,t=n,B(n=e),o(n,t),o(n,~t),r.arraySet(n.pending_buf,n.window,i,t,n.pending),n.pending+=t}t._tr_init=function(e){if(!D){for(var t,n,i,r,o=new Array(16),a=i=0;a<28;a++)for(m[a]=i,t=0;t<1<<l[a];t++)f[i++]=a;for(f[i-1]=a,a=r=0;a<16;a++)for(y[a]=r,t=0;t<1<<d[a];t++)p[r++]=a;for(r>>=7;a<30;a++)for(y[a]=r<<7,t=0;t<1<<d[a]-7;t++)p[256+r++]=a;for(n=0;n<=15;n++)o[n]=0;for(t=0;t<=143;)h[2*t+1]=8,t++,o[8]++;for(;t<=255;)h[2*t+1]=9,t++,o[9]++;for(;t<=279;)h[2*t+1]=7,t++,o[7]++;for(;t<=287;)h[2*t+1]=8,t++,o[8]++;for(T(h,287,o),t=0;t<30;t++)u[2*t+1]=5,u[2*t]=I(t,5);g=new E(h,l,257,286,15),v=new E(u,d,0,30,15),A=new E(new Array(0),s,0,19,7),D=!0}e.l_desc=new M(e.dyn_ltree,g),e.d_desc=new M(e.dyn_dtree,v),e.bl_desc=new M(e.bl_tree,A),e.bi_buf=0,e.bi_valid=0,S(e)},t._tr_stored_block=H,t._tr_flush_block=function(e,t,n,i){var r,o,a,s=0;if(0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){for(var t=4093624447,n=0;n<=31;n++,t>>>=1)if(1&t&&0!==e.dyn_ltree[2*n])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(n=32;n<256;n++)if(0!==e.dyn_ltree[2*n])return 1;return 0}(e)),R(e,e.l_desc),R(e,e.d_desc),s=function(e){var t;for(O(e,e.dyn_ltree,e.l_desc.max_code),O(e,e.dyn_dtree,e.d_desc.max_code),R(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*c[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=r&&(r=o)):r=o=n+5,n+4<=r&&-1!==t)H(e,t,n,i);else if(4===e.strategy||o===r)b(e,2+(i?1:0),3),C(e,h,u);else{b(e,4+(i?1:0),3);var l=e,d=(t=e.l_desc.max_code+1,n=e.d_desc.max_code+1,s+1);for(b(l,t-257,5),b(l,n-1,5),b(l,d-4,4),a=0;a<d;a++)b(l,l.bl_tree[2*c[a]+1],3);L(l,l.dyn_ltree,t-1),L(l,l.dyn_dtree,n-1),C(e,e.dyn_ltree,e.dyn_dtree)}S(e),i&&B(e)},t._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(f[n]+256+1)]++,e.dyn_dtree[2*w(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){b(e,2,3),x(e,256,h),16===(e=e).bi_valid?(o(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){!function(e){function r(e){delete c[e]}function o(e){if(h)setTimeout(o,0,e);else{var t=c[e];if(t){h=!0;try{var n=t.callback,i=t.args;switch(i.length){case 0:n();break;case 1:n(i[0]);break;case 2:n(i[0],i[1]);break;case 3:n(i[0],i[1],i[2]);break;default:n.apply(a,i)}}finally{r(e),h=!1}}}}function t(e){e.source===n&&"string"==typeof e.data&&0===e.data.indexOf(l)&&o(+e.data.slice(l.length))}var n,a,i,s,l,d,c,h,u,p;(n="undefined"==typeof self?void 0===e?this:e:self).setImmediate||(d=1,h=!(c={}),u=n.document,e=(e=Object.getPrototypeOf&&Object.getPrototypeOf(n))&&e.setTimeout?e:n,p="[object process]"==={}.toString.call(n.process)?function(e){f.nextTick(function(){o(e)})}:function(){var e,t;if(n.postMessage&&!n.importScripts)return e=!0,t=n.onmessage,n.onmessage=function(){e=!1},n.postMessage("","*"),n.onmessage=t,e}()?(l="setImmediate$"+Math.random()+"$",n.addEventListener?n.addEventListener("message",t,!1):n.attachEvent("onmessage",t),function(e){n.postMessage(l+e,"*")}):n.MessageChannel?((s=new MessageChannel).port1.onmessage=function(e){o(e.data)},function(e){s.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(i=u.documentElement,function(e){var t=u.createElement("script");t.onreadystatechange=function(){o(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):function(e){setTimeout(o,0,e)},e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];return c[d]={callback:e,args:t},p(d),d++},e.clearImmediate=r)}.call(this,void 0!==i?i:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)}.call(this,n(1).Buffer,n(22).setImmediate,n(0),n(2))},function(e,t,n){!function(t,e){var n,i;n=window,i="function"==typeof(i=n.atob)?i:"function"==typeof t?function(e){return new t(e,"base64").toString("binary")}:"object"==typeof n.base64js?function(e){e=n.base64js.b64ToByteArray(e);return Array.prototype.map.call(e,function(e){return String.fromCharCode(e)}).join("")}:function(){throw new Error("You're probably in an old browser or an iOS webworker. It might help to include beatgammit's base64-js.")},n.atob=i,e&&e.exports&&(e.exports=i)}.call(this,n(1).Buffer,n(24)(e))},function(e,t,n){e.exports=function i(r,o,a){function s(n,e){if(!o[n]){if(!r[n]){if(l)return l(n,!0);var t=new Error("Cannot find module '"+n+"'");throw t.code="MODULE_NOT_FOUND",t}t=o[n]={exports:{}};r[n][0].call(t.exports,function(e){var t=r[n][1][e];return s(t||e)},t,t.exports,i,r,o,a)}return o[n].exports}for(var l=!1,e=0;e<a.length;e++)s(a[e]);return s}({1:[function(e,t,n){var a=e("./zlib/deflate"),s=e("./utils/common"),l=e("./utils/strings"),i=e("./zlib/messages"),r=e("./zlib/zstream"),d=Object.prototype.toString;function o(e){if(!(this instanceof o))return new o(e);this.options=s.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});e=this.options;if(e.raw&&0<e.windowBits?e.windowBits=-e.windowBits:e.gzip&&0<e.windowBits&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,(this.strm.avail_out=0)!==(t=a.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy)))throw new Error(i[t]);if(e.header&&a.deflateSetHeader(this.strm,e.header),e.dictionary){var t,e="string"==typeof e.dictionary?l.string2buf(e.dictionary):"[object ArrayBuffer]"===d.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary;if(0!==(t=a.deflateSetDictionary(this.strm,e)))throw new Error(i[t]);this._dict_set=!0}}function c(e,t){t=new o(t);if(t.push(e,!0),t.err)throw t.msg||i[t.err];return t.result}o.prototype.push=function(e,t){var n,i,r=this.strm,o=this.options.chunkSize;if(this.ended)return!1;i=t===~~t?t:!0===t?4:0,"string"==typeof e?r.input=l.string2buf(e):"[object ArrayBuffer]"===d.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(0===r.avail_out&&(r.output=new s.Buf8(o),r.next_out=0,r.avail_out=o),1!==(n=a.deflate(r,i))&&0!==n)return this.onEnd(n),!(this.ended=!0)}while(0!==r.avail_out&&(0!==r.avail_in||4!==i&&2!==i)||("string"===this.options.to?this.onData(l.buf2binstring(s.shrinkBuf(r.output,r.next_out))):this.onData(s.shrinkBuf(r.output,r.next_out))),(0<r.avail_in||0===r.avail_out)&&1!==n);return 4===i?(n=a.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==i||(this.onEnd(0),!(r.avail_out=0))},o.prototype.onData=function(e){this.chunks.push(e)},o.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=o,n.deflate=c,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,c(e,t)}},{"./utils/common":3,"./utils/strings":4,"./zlib/deflate":8,"./zlib/messages":13,"./zlib/zstream":15}],2:[function(e,t,n){var h=e("./zlib/inflate"),u=e("./utils/common"),p=e("./utils/strings"),f=e("./zlib/constants"),i=e("./zlib/messages"),r=e("./zlib/zstream"),o=e("./zlib/gzheader"),m=Object.prototype.toString;function a(e){if(!(this instanceof a))return new a(e);this.options=u.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits)&&(t.windowBits=-15),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0,h.inflateInit2(this.strm,t.windowBits));if(e!==f.Z_OK)throw new Error(i[e]);this.header=new o,h.inflateGetHeader(this.strm,this.header)}function s(e,t){t=new a(t);if(t.push(e,!0),t.err)throw t.msg||i[t.err];return t.result}a.prototype.push=function(e,t){var n,i,r,o,a,s=this.strm,l=this.options.chunkSize,d=this.options.dictionary,c=!1;if(this.ended)return!1;i=t===~~t?t:!0===t?f.Z_FINISH:f.Z_NO_FLUSH,"string"==typeof e?s.input=p.binstring2buf(e):"[object ArrayBuffer]"===m.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new u.Buf8(l),s.next_out=0,s.avail_out=l),(n=h.inflate(s,f.Z_NO_FLUSH))===f.Z_NEED_DICT&&d&&(a="string"==typeof d?p.string2buf(d):"[object ArrayBuffer]"===m.call(d)?new Uint8Array(d):d,n=h.inflateSetDictionary(this.strm,a)),n===f.Z_BUF_ERROR&&!0===c&&(n=f.Z_OK,c=!1),n!==f.Z_STREAM_END&&n!==f.Z_OK)return this.onEnd(n),!(this.ended=!0)}while(!s.next_out||0!==s.avail_out&&n!==f.Z_STREAM_END&&(0!==s.avail_in||i!==f.Z_FINISH&&i!==f.Z_SYNC_FLUSH)||("string"===this.options.to?(a=p.utf8border(s.output,s.next_out),r=s.next_out-a,o=p.buf2string(s.output,a),s.next_out=r,s.avail_out=l-r,r&&u.arraySet(s.output,s.output,a,r,0),this.onData(o)):this.onData(u.shrinkBuf(s.output,s.next_out))),0===s.avail_in&&0===s.avail_out&&(c=!0),(0<s.avail_in||0===s.avail_out)&&n!==f.Z_STREAM_END);return(i=n===f.Z_STREAM_END?f.Z_FINISH:i)===f.Z_FINISH?(n=h.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===f.Z_OK):i!==f.Z_SYNC_FLUSH||(this.onEnd(f.Z_OK),!(s.avail_out=0))},a.prototype.onData=function(e){this.chunks.push(e)},a.prototype.onEnd=function(e){e===f.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=u.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=a,n.inflate=s,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,s(e,t)},n.ungzip=s},{"./utils/common":3,"./utils/strings":4,"./zlib/constants":6,"./zlib/gzheader":9,"./zlib/inflate":11,"./zlib/messages":13,"./zlib/zstream":15}],3:[function(e,t,n){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;n.assign=function(e){for(var t,n,i=Array.prototype.slice.call(arguments,1);i.length;){var r=i.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var o in r)t=r,n=o,Object.prototype.hasOwnProperty.call(t,n)&&(e[o]=r[o])}}return e},n.shrinkBuf=function(e,t){if(e.length!==t){if(e.subarray)return e.subarray(0,t);e.length=t}return e};var r={arraySet:function(e,t,n,i,r){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+i),r);else for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){for(var t,n,i,r=0,o=0,a=e.length;o<a;o++)r+=e[o].length;for(i=new Uint8Array(r),o=t=0,a=e.length;o<a;o++)n=e[o],i.set(n,t),t+=n.length;return i}},o={arraySet:function(e,t,n,i,r){for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,r)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,o))},n.setTyped(i)},{}],4:[function(e,t,n){var l=e("./common"),r=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var d=new l.Buf8(256),i=0;i<256;i++)d[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;function c(e,t){if(t<65537&&(e.subarray&&o||!e.subarray&&r))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n}d[254]=d[254]=1,n.string2buf=function(e){for(var t,n,i,r,o=e.length,a=0,s=0;s<o;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),a+=n<128?1:n<2048?2:n<65536?3:4;for(t=new l.Buf8(a),s=r=0;r<a;s++)55296==(64512&(n=e.charCodeAt(s)))&&s+1<o&&56320==(64512&(i=e.charCodeAt(s+1)))&&(n=65536+(n-55296<<10)+(i-56320),s++),n<128?t[r++]=n:(n<2048?t[r++]=192|n>>>6:(n<65536?t[r++]=224|n>>>12:(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63),t[r++]=128|n>>>6&63),t[r++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new l.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){for(var n,i,r=t||e.length,o=new Array(2*r),a=0,s=0;s<r;)if((n=e[s++])<128)o[a++]=n;else if(4<(i=d[n]))o[a++]=65533,s+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&s<r;)n=n<<6|63&e[s++],i--;1<i?o[a++]=65533:n<65536?o[a++]=n:(n-=65536,o[a++]=55296|n>>10&1023,o[a++]=56320|1023&n)}return c(o,a)},n.utf8border=function(e,t){for(var n=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=n&&128==(192&e[n]);)n--;return!(n<0)&&0!==n&&n+d[e[n]]>t?n:t}},{"./common":3}],5:[function(e,t,n){t.exports=function(e,t,n,i){for(var r=65535&e|0,o=e>>>16&65535|0,a=0;0!==n;){for(n-=a=2e3<n?2e3:n;o=o+(r=r+t[i++]|0)|0,--a;);r%=65521,o%=65521}return r|o<<16|0}},{}],6:[function(e,t,n){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],7:[function(e,t,n){var s=function(){for(var e=[],t=0;t<256;t++){for(var n=t,i=0;i<8;i++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e}();t.exports=function(e,t,n,i){var r=s,o=i+n;e^=-1;for(var a=i;a<o;a++)e=e>>>8^r[255&(e^t[a])];return-1^e}},{}],8:[function(e,F,t){var s,h=e("../utils/common"),l=e("./trees"),u=e("./adler32"),p=e("./crc32"),N=e("./messages"),d=0,c=4,f=0,m=-2,j=-1,_=4,V=2,g=8,k=9,n=286,U=30,G=19,z=2*n+1,W=15,v=3,A=258,y=A+v+1,E=42,M=113,w=1,b=2,x=3,I=4;function T(e,t){return e.msg=N[t],t}function S(e){return(e<<1)-(4<e?9:0)}function B(e){for(var t=e.length;0<=--t;)e[t]=0}function P(e){var t=e.state,n=t.pending;0!==(n=n>e.avail_out?e.avail_out:n)&&(h.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending)&&(t.pending_out=0)}function C(e,t){l._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,P(e.strm)}function R(e,t){e.pending_buf[e.pending++]=t}function O(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function o(e,t){var n,i,r=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-y?e.strstart-(e.w_size-y):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+A,p=d[o+a-1],f=d[o+a];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do{if(d[(n=t)+a]===f&&d[n+a-1]===p&&d[n]===d[o]&&d[++n]===d[o+1]){for(o+=2,n++;d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&d[++o]===d[++n]&&o<u;);if(i=A-(u-o),o=u-A,a<i){if(e.match_start=t,s<=(a=i))break;p=d[o+a-1],f=d[o+a]}}}while((t=h[t&c])>l&&0!=--r);return a<=e.lookahead?a:e.lookahead}function L(e){var t,n,i,r,o,a,s,l,d,c=e.w_size;do{if(l=e.window_size-e.lookahead-e.strstart,e.strstart>=c+(c-y)){for(h.arraySet(e.window,e.window,c,c,0),e.match_start-=c,e.strstart-=c,e.block_start-=c,t=n=e.hash_size;i=e.head[--t],e.head[t]=c<=i?i-c:0,--n;);for(t=n=c;i=e.prev[--t],e.prev[t]=c<=i?i-c:0,--n;);l+=c}if(0===e.strm.avail_in)break;if(o=e.strm,a=e.window,s=e.strstart+e.lookahead,l=l,d=void 0,d=o.avail_in,n=0===(d=l<d?l:d)?0:(o.avail_in-=d,h.arraySet(a,o.input,o.next_in,d,s),1===o.state.wrap?o.adler=u(o.adler,a,d,s):2===o.state.wrap&&(o.adler=p(o.adler,a,d,s)),o.next_in+=d,o.total_in+=d,d),e.lookahead+=n,e.lookahead+e.insert>=v)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+v-1])&e.hash_mask,e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<v)););}while(e.lookahead<y&&0!==e.strm.avail_in)}function i(e,t){for(var n,i;;){if(e.lookahead<y){if(L(e),e.lookahead<y&&t===d)return w;if(0===e.lookahead)break}if(n=0,e.lookahead>=v&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+v-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-y&&(e.match_length=o(e,n)),e.match_length>=v)if(i=l._tr_tally(e,e.strstart-e.match_start,e.match_length-v),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=v){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+v-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=l._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(C(e,!1),0===e.strm.avail_out))return w}return e.insert=e.strstart<v-1?e.strstart:v-1,t===c?(C(e,!0),0===e.strm.avail_out?x:I):e.last_lit&&(C(e,!1),0===e.strm.avail_out)?w:b}function r(e,t){for(var n,i,r;;){if(e.lookahead<y){if(L(e),e.lookahead<y&&t===d)return w;if(0===e.lookahead)break}if(n=0,e.lookahead>=v&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+v-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=v-1,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-y&&(e.match_length=o(e,n),e.match_length<=5)&&(1===e.strategy||e.match_length===v&&4096<e.strstart-e.match_start)&&(e.match_length=v-1),e.prev_length>=v&&e.match_length<=e.prev_length){for(r=e.strstart+e.lookahead-v,i=l._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-v),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+v-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=v-1,e.strstart++,i&&(C(e,!1),0===e.strm.avail_out))return w}else if(e.match_available){if((i=l._tr_tally(e,0,e.window[e.strstart-1]))&&C(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return w}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=l._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<v-1?e.strstart:v-1,t===c?(C(e,!0),0===e.strm.avail_out?x:I):e.last_lit&&(C(e,!1),0===e.strm.avail_out)?w:b}function a(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}function Y(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=g,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new h.Buf16(2*z),this.dyn_dtree=new h.Buf16(2*(2*U+1)),this.bl_tree=new h.Buf16(2*(2*G+1)),B(this.dyn_ltree),B(this.dyn_dtree),B(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new h.Buf16(W+1),this.heap=new h.Buf16(2*n+1),B(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new h.Buf16(2*n+1),B(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function D(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=V,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?E:M,e.adler=2===t.wrap?0:1,t.last_flush=d,l._tr_init(t),f):T(e,m)}function H(e){var t=D(e);return t===f&&((e=e.state).window_size=2*e.w_size,B(e.head),e.max_lazy_match=s[e.level].max_lazy,e.good_match=s[e.level].good_length,e.nice_match=s[e.level].nice_length,e.max_chain_length=s[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=v-1,e.match_available=0,e.ins_h=0),t}function X(e,t,n,i,r,o){if(!e)return m;var a=1;if(t===j&&(t=6),i<0?(a=0,i=-i):15<i&&(a=2,i-=16),r<1||k<r||n!==g||i<8||15<i||t<0||9<t||o<0||_<o)return T(e,m);8===i&&(i=9);var s=new Y;return(e.state=s).strm=e,s.wrap=a,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=r+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+v-1)/v),s.window=new h.Buf8(2*s.w_size),s.head=new h.Buf16(s.hash_size),s.prev=new h.Buf16(s.w_size),s.lit_bufsize=1<<r+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new h.Buf8(s.pending_buf_size),s.d_buf=+s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=n,H(e)}s=[new a(0,0,0,0,function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(L(e),0===e.lookahead&&t===d)return w;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,C(e,!1),0===e.strm.avail_out))return w;if(e.strstart-e.block_start>=e.w_size-y&&(C(e,!1),0===e.strm.avail_out))return w}return e.insert=0,t===c?(C(e,!0),0===e.strm.avail_out?x:I):(e.strstart>e.block_start&&(C(e,!1),e.strm.avail_out),w)}),new a(4,4,8,4,i),new a(4,5,16,8,i),new a(4,6,32,32,i),new a(4,4,16,16,r),new a(8,16,32,32,r),new a(8,16,128,128,r),new a(8,32,128,256,r),new a(32,128,258,1024,r),new a(32,258,258,4096,r)],t.deflateInit=function(e,t){return X(e,t,g,15,8,0)},t.deflateInit2=X,t.deflateReset=H,t.deflateResetKeep=D,t.deflateSetHeader=function(e,t){return!e||!e.state||2!==e.state.wrap?m:(e.state.gzhead=t,f)},t.deflate=function(e,t){var n,i,r,o;if(!e||!e.state||5<t||t<0)return e?T(e,m):m;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==c)return T(e,0===e.avail_out?-5:m);if(i.strm=e,n=i.last_flush,i.last_flush=t,i.status===E&&(2===i.wrap?(e.adler=0,R(i,31),R(i,139),R(i,8),i.gzhead?(R(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),R(i,255&i.gzhead.time),R(i,i.gzhead.time>>8&255),R(i,i.gzhead.time>>16&255),R(i,i.gzhead.time>>24&255),R(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),R(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(R(i,255&i.gzhead.extra.length),R(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=p(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(R(i,0),R(i,0),R(i,0),R(i,0),R(i,0),R(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),R(i,3),i.status=M)):(a=g+(i.w_bits-8<<4)<<8,a|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(a|=32),a+=31-a%31,i.status=M,O(i,a),0!==i.strstart&&(O(i,e.adler>>>16),O(i,65535&e.adler)),e.adler=1)),69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),P(e),r=i.pending,i.pending!==i.pending_buf_size));)R(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),P(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}}while(o=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,R(i,o),0!==o);i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),0===o&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),P(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}}while(o=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,R(i,o),0!==o);i.gzhead.hcrc&&i.pending>r&&(e.adler=p(e.adler,i.pending_buf,i.pending-r,r)),0===o&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&P(e),i.pending+2<=i.pending_buf_size&&(R(i,255&e.adler),R(i,e.adler>>8&255),e.adler=0,i.status=M)):i.status=M),0!==i.pending){if(P(e),0===e.avail_out)return i.last_flush=-1,f}else if(0===e.avail_in&&S(t)<=S(n)&&t!==c)return T(e,-5);if(666===i.status&&0!==e.avail_in)return T(e,-5);if(0!==e.avail_in||0!==i.lookahead||t!==d&&666!==i.status){var a=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(L(e),0===e.lookahead)){if(t===d)return w;break}if(e.match_length=0,n=l._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(C(e,!1),0===e.strm.avail_out))return w}return e.insert=0,t===c?(C(e,!0),0===e.strm.avail_out?x:I):e.last_lit&&(C(e,!1),0===e.strm.avail_out)?w:b}(i,t):3===i.strategy?function(e,t){for(var n,i,r,o,a=e.window;;){if(e.lookahead<=A){if(L(e),e.lookahead<=A&&t===d)return w;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=v&&0<e.strstart&&(i=a[r=e.strstart-1])===a[++r]&&i===a[++r]&&i===a[++r]){for(o=e.strstart+A;i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&r<o;);e.match_length=A-(o-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=v?(n=l._tr_tally(e,1,e.match_length-v),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=l._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(C(e,!1),0===e.strm.avail_out))return w}return e.insert=0,t===c?(C(e,!0),0===e.strm.avail_out?x:I):e.last_lit&&(C(e,!1),0===e.strm.avail_out)?w:b}(i,t):s[i.level].func(i,t);if(a!==x&&a!==I||(i.status=666),a===w||a===x)return 0===e.avail_out&&(i.last_flush=-1),f;if(a===b&&(1===t?l._tr_align(i):5!==t&&(l._tr_stored_block(i,0,0,!1),3===t)&&(B(i.head),0===i.lookahead)&&(i.strstart=0,i.block_start=0,i.insert=0),P(e),0===e.avail_out))return i.last_flush=-1,f}return t!==c||!(i.wrap<=0)&&(2===i.wrap?(R(i,255&e.adler),R(i,e.adler>>8&255),R(i,e.adler>>16&255),R(i,e.adler>>24&255),R(i,255&e.total_in),R(i,e.total_in>>8&255),R(i,e.total_in>>16&255),R(i,e.total_in>>24&255)):(O(i,e.adler>>>16),O(i,65535&e.adler)),P(e),0<i.wrap&&(i.wrap=-i.wrap),0!==i.pending)?f:1},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==E&&69!==t&&73!==t&&91!==t&&103!==t&&t!==M&&666!==t?T(e,m):(e.state=null,t===M?T(e,-3):f):m},t.deflateSetDictionary=function(e,t){var n,i,r,o,a,s,l,d=t.length;if(!e||!e.state)return m;if(2===(o=(n=e.state).wrap)||1===o&&n.status!==E||n.lookahead)return m;for(1===o&&(e.adler=u(e.adler,t,d,0)),n.wrap=0,d>=n.w_size&&(0===o&&(B(n.head),n.strstart=0,n.block_start=0,n.insert=0),l=new h.Buf8(n.w_size),h.arraySet(l,t,d-n.w_size,n.w_size,0),t=l,d=n.w_size),l=e.avail_in,a=e.next_in,s=e.input,e.avail_in=d,e.next_in=0,e.input=t,L(n);n.lookahead>=v;){for(i=n.strstart,r=n.lookahead-(v-1);n.ins_h=(n.ins_h<<n.hash_shift^n.window[i+v-1])&n.hash_mask,n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,--r;);n.strstart=i,n.lookahead=v-1,L(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=v-1,n.match_available=0,e.next_in=a,e.input=s,e.avail_in=l,n.wrap=o,f},t.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":3,"./adler32":5,"./crc32":7,"./messages":13,"./trees":14}],9:[function(e,t,n){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],10:[function(e,t,n){t.exports=function(e,t){var n,i,r,o,a,s,l=e.state,d=e.next_in,c=e.input,h=d+(e.avail_in-5),u=e.next_out,p=e.output,f=u-(t-e.avail_out),m=u+(e.avail_out-257),g=l.dmax,v=l.wsize,A=l.whave,y=l.wnext,E=l.window,M=l.hold,w=l.bits,b=l.lencode,x=l.distcode,I=(1<<l.lenbits)-1,T=(1<<l.distbits)-1;e:do{for(w<15&&(M+=c[d++]<<w,w+=8,M+=c[d++]<<w,w+=8),n=b[M&I];;){if(M>>>=i=n>>>24,w-=i,0===(i=n>>>16&255))p[u++]=65535&n;else{if(!(16&i)){if(0==(64&i)){n=b[(65535&n)+(M&(1<<i)-1)];continue}if(32&i){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(r=65535&n,(i&=15)&&(w<i&&(M+=c[d++]<<w,w+=8),r+=M&(1<<i)-1,M>>>=i,w-=i),w<15&&(M+=c[d++]<<w,w+=8,M+=c[d++]<<w,w+=8),n=x[M&T];;){if(M>>>=i=n>>>24,w-=i,!(16&(i=n>>>16&255))){if(0==(64&i)){n=x[(65535&n)+(M&(1<<i)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(o=65535&n,w<(i&=15)&&(M+=c[d++]<<w,(w+=8)<i)&&(M+=c[d++]<<w,w+=8),g<(o+=M&(1<<i)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(M>>>=i,w-=i,(i=u-f)<o){if(A<(i=o-i)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(s=E,(a=0)===y){if(a+=v-i,i<r){for(r-=i;p[u++]=E[a++],--i;);a=u-o,s=p}}else if(y<i){if(a+=v+y-i,(i-=y)<r){for(r-=i;p[u++]=E[a++],--i;);if(a=0,y<r){for(r-=i=y;p[u++]=E[a++],--i;);a=u-o,s=p}}}else if(a+=y-i,i<r){for(r-=i;p[u++]=E[a++],--i;);a=u-o,s=p}for(;2<r;)p[u++]=s[a++],p[u++]=s[a++],p[u++]=s[a++],r-=3;r&&(p[u++]=s[a++],1<r)&&(p[u++]=s[a++])}else{for(a=u-o;p[u++]=p[a++],p[u++]=p[a++],p[u++]=p[a++],2<(r-=3););r&&(p[u++]=p[a++],1<r)&&(p[u++]=p[a++])}break}}break}}while(d<h&&u<m);M&=(1<<(w-=(r=w>>3)<<3))-1,e.next_in=d-=r,e.next_out=u,e.avail_in=d<h?h-d+5:5-(d-h),e.avail_out=u<m?m-u+257:257-(u-m),l.hold=M,l.bits=w}},{}],11:[function(e,t,n){var R=e("../utils/common"),O=e("./adler32"),L=e("./crc32"),D=e("./inffast"),H=e("./inftrees"),F=1,N=2,j=0,_=-2,V=1,i=852,r=592;function k(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function o(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new R.Buf16(320),this.work=new R.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=V,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new R.Buf32(i),t.distcode=t.distdyn=new R.Buf32(r),t.sane=1,t.back=-1,j):_}function s(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):_}function l(e,t){var n,i;return!e||!e.state||(i=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?_:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,s(e))}function d(e,t){var n;return e?(n=new o,(e.state=n).window=null,(n=l(e,t))!==j&&(e.state=null),n):_}var U,G,z=!0;function W(e,t,n,i){var r,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new R.Buf8(e.wsize)),i>=e.wsize?(R.arraySet(e.window,t,n-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(i<(r=e.wsize-e.wnext)&&(r=i),R.arraySet(e.window,t,n-i,r,e.wnext),(i-=r)?(R.arraySet(e.window,t,n-i,i,0),e.wnext=i,e.whave=e.wsize):(e.wnext+=r,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=r))),0}n.inflateReset=s,n.inflateReset2=l,n.inflateResetKeep=a,n.inflateInit=function(e){return d(e,15)},n.inflateInit2=d,n.inflate=function(e,t){var n,i,r,o,a,s,l,d,c,h,u,p,f,m,g,v,A,y,E,M,w,b,x,I,T=0,S=new R.Buf8(4),B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return _;12===(n=e.state).mode&&(n.mode=13),a=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,d=n.hold,c=n.bits,h=s,u=l,b=j;e:for(;;)switch(n.mode){case V:if(0===n.wrap)n.mode=13;else{for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(2&n.wrap&&35615===d)S[n.check=0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0),c=d=0,n.mode=2;else if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&d)<<8)+(d>>8))%31)e.msg="incorrect header check",n.mode=30;else if(8!=(15&d))e.msg="unknown compression method",n.mode=30;else{if(c-=4,w=8+(15&(d>>>=4)),0===n.wbits)n.wbits=w;else if(w>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<w,e.adler=n.check=1,n.mode=512&d?10:12,c=d=0}}break;case 2:for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(n.flags=d,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=d>>8&1),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0)),c=d=0,n.mode=3;case 3:for(;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.head&&(n.head.time=d),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,S[2]=d>>>16&255,S[3]=d>>>24&255,n.check=L(n.check,S,4,0)),c=d=0,n.mode=4;case 4:for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.head&&(n.head.xflags=255&d,n.head.os=d>>8),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0)),c=d=0,n.mode=5;case 5:if(1024&n.flags){for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.length=d,n.head&&(n.head.extra_len=d),512&n.flags&&(S[0]=255&d,S[1]=d>>>8&255,n.check=L(n.check,S,2,0)),c=d=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((p=s<(p=n.length)?s:p)&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),R.arraySet(n.head.extra,i,o,p,w)),512&n.flags&&(n.check=L(n.check,i,p,o)),s-=p,o+=p,n.length-=p),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===s)break e;for(p=0;w=i[o+p++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w)),w&&p<s;);if(512&n.flags&&(n.check=L(n.check,i,p,o)),s-=p,o+=p,w)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===s)break e;for(p=0;w=i[o+p++],n.head&&w&&n.length<65536&&(n.head.comment+=String.fromCharCode(w)),w&&p<s;);if(512&n.flags&&(n.check=L(n.check,i,p,o)),s-=p,o+=p,w)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;c<16;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(d!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}c=d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}e.adler=n.check=k(d),c=d=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=a,e.avail_out=l,e.next_in=o,e.avail_in=s,n.hold=d,n.bits=c,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last)d>>>=7&c,c-=7&c,n.mode=27;else{for(;c<3;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}switch(n.last=1&d,--c,3&(d>>>=1)){case 0:n.mode=14;break;case 1:P=C=void 0;var P,C=n;if(z){for(U=new R.Buf32(512),G=new R.Buf32(32),P=0;P<144;)C.lens[P++]=8;for(;P<256;)C.lens[P++]=9;for(;P<280;)C.lens[P++]=7;for(;P<288;)C.lens[P++]=8;for(H(F,C.lens,0,288,U,0,C.work,{bits:9}),P=0;P<32;)C.lens[P++]=5;H(N,C.lens,0,32,G,0,C.work,{bits:5}),z=!1}if(C.lencode=U,C.lenbits=9,C.distcode=G,C.distbits=5,n.mode=20,6!==t)break;d>>>=2,c-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}d>>>=2,c-=2}break;case 14:for(d>>>=7&c,c-=7&c;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&d,c=d=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(p=n.length){if(0===(p=l<(p=s<p?s:p)?l:p))break e;R.arraySet(r,i,o,p,a),s-=p,o+=p,l-=p,a+=p,n.length-=p}else n.mode=12;break;case 17:for(;c<14;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(n.nlen=257+(31&d),d>>>=5,c-=5,n.ndist=1+(31&d),d>>>=5,c-=5,n.ncode=4+(15&d),d>>>=4,c-=4,286<n.nlen||30<n.ndist){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;c<3;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.lens[B[n.have++]]=7&d,d>>>=3,c-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,x={bits:n.lenbits},b=H(0,n.lens,0,19,n.lencode,0,n.work,x),n.lenbits=x.bits,b){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;v=(T=n.lencode[d&(1<<n.lenbits)-1])>>>16&255,A=65535&T,!((g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(A<16)d>>>=g,c-=g,n.lens[n.have++]=A;else{if(16===A){for(I=g+2;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(d>>>=g,c-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}w=n.lens[n.have-1],p=3+(3&d),d>>>=2,c-=2}else if(17===A){for(I=g+3;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}w=0,p=3+(7&(d>>>=g)),d>>>=3,c=c-g-3}else{for(I=g+7;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}w=0,p=11+(127&(d>>>=g)),d>>>=7,c=c-g-7}if(n.have+p>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;p--;)n.lens[n.have++]=w}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,x={bits:n.lenbits},b=H(F,n.lens,0,n.nlen,n.lencode,0,n.work,x),n.lenbits=x.bits,b){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,x={bits:n.distbits},b=H(N,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,x),n.distbits=x.bits,b){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=s&&258<=l){e.next_out=a,e.avail_out=l,e.next_in=o,e.avail_in=s,n.hold=d,n.bits=c,D(e,u),a=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,d=n.hold,c=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;v=(T=n.lencode[d&(1<<n.lenbits)-1])>>>16&255,A=65535&T,!((g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(v&&0==(240&v)){for(y=g,E=v,M=A;v=(T=n.lencode[M+((d&(1<<y+E)-1)>>y)])>>>16&255,A=65535&T,!(y+(g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}d>>>=y,c-=y,n.back+=y}if(d>>>=g,c-=g,n.back+=g,n.length=A,0===v){n.mode=26;break}if(32&v){n.back=-1,n.mode=12;break}if(64&v){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&v,n.mode=22;case 22:if(n.extra){for(I=n.extra;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.length+=d&(1<<n.extra)-1,d>>>=n.extra,c-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;v=(T=n.distcode[d&(1<<n.distbits)-1])>>>16&255,A=65535&T,!((g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(0==(240&v)){for(y=g,E=v,M=A;v=(T=n.distcode[M+((d&(1<<y+E)-1)>>y)])>>>16&255,A=65535&T,!(y+(g=T>>>24)<=c);){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}d>>>=y,c-=y,n.back+=y}if(d>>>=g,c-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=30;break}n.offset=A,n.extra=15&v,n.mode=24;case 24:if(n.extra){for(I=n.extra;c<I;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}n.offset+=d&(1<<n.extra)-1,d>>>=n.extra,c-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===l)break e;if(n.offset>(p=u-l)){if((p=n.offset-p)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}f=p>n.wnext?(p-=n.wnext,n.wsize-p):n.wnext-p,p>n.length&&(p=n.length),m=n.window}else m=r,f=a-n.offset,p=n.length;for(l-=p=l<p?l:p,n.length-=p;r[a++]=m[f++],--p;);0===n.length&&(n.mode=21);break;case 26:if(0===l)break e;r[a++]=n.length,l--,n.mode=21;break;case 27:if(n.wrap){for(;c<32;){if(0===s)break e;s--,d|=i[o++]<<c,c+=8}if(u-=l,e.total_out+=u,n.total+=u,u&&(e.adler=n.check=(n.flags?L:O)(n.check,r,u,a-u)),u=l,(n.flags?d:k(d))!==n.check){e.msg="incorrect data check",n.mode=30;break}c=d=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;c<32;){if(0===s)break e;s--,d+=i[o++]<<c,c+=8}if(d!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}c=d=0}n.mode=29;case 29:b=1;break e;case 30:b=-3;break e;case 31:return-4;default:return _}return e.next_out=a,e.avail_out=l,e.next_in=o,e.avail_in=s,n.hold=d,n.bits=c,(n.wsize||u!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&W(e,e.output,e.next_out,u-e.avail_out)?(n.mode=31,-4):(h-=e.avail_in,u-=e.avail_out,e.total_in+=h,e.total_out+=u,n.total+=u,n.wrap&&u&&(e.adler=n.check=(n.flags?L:O)(n.check,r,u,e.next_out-u)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0==h&&0===u||4===t)&&b===j?-5:b)},n.inflateEnd=function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,j):_},n.inflateGetHeader=function(e,t){return!e||!e.state||0==(2&(e=e.state).wrap)?_:((e.head=t).done=!1,j)},n.inflateSetDictionary=function(e,t){var n,i=t.length;return!e||!e.state||0!==(n=e.state).wrap&&11!==n.mode?_:11===n.mode&&O(1,t,i,0)!==n.check?-3:W(e,t,i,i)?(n.mode=31,-4):(n.havedict=1,j)},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":3,"./adler32":5,"./crc32":7,"./inffast":10,"./inftrees":12}],12:[function(e,t,n){var D=e("../utils/common"),H=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],F=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],N=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],j=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,i,r,o,a,s){for(var l,d,c,h,u,p,f,m,g,v=s.bits,A=0,y=0,E=0,M=0,w=0,b=0,x=0,I=0,T=0,S=0,B=null,P=0,C=new D.Buf16(16),R=new D.Buf16(16),O=null,L=0,A=0;A<=15;A++)C[A]=0;for(y=0;y<i;y++)C[t[n+y]]++;for(w=v,M=15;1<=M&&0===C[M];M--);if(M<w&&(w=M),0===M)r[o++]=20971520,r[o++]=20971520,s.bits=1;else{for(E=1;E<M&&0===C[E];E++);for(w<E&&(w=E),A=I=1;A<=15;A++)if((I=(I<<=1)-C[A])<0)return-1;if(0<I&&(0===e||1!==M))return-1;for(R[1]=0,A=1;A<15;A++)R[A+1]=R[A]+C[A];for(y=0;y<i;y++)0!==t[n+y]&&(a[R[t[n+y]]++]=y);if(p=0===e?(B=O=a,19):1===e?(B=H,P-=257,O=F,L-=257,256):(B=N,O=j,-1),A=E,u=o,x=y=S=0,c=-1,h=(T=1<<(b=w))-1,1===e&&852<T||2===e&&592<T)return 1;for(;;){for(g=a[y]<p?(m=0,a[y]):a[y]>p?(m=O[L+a[y]],B[P+a[y]]):(m=96,0),l=1<<(f=A-x),E=d=1<<b;r[u+(S>>x)+(d-=l)]=f<<24|m<<16|g|0,0!==d;);for(l=1<<A-1;S&l;)l>>=1;if(S=0!==l?(S&l-1)+l:0,y++,0==--C[A]){if(A===M)break;A=t[n+a[y]]}if(w<A&&(S&h)!==c){for(u+=E,I=1<<(b=A-(x=0===x?w:x));b+x<M&&!((I-=C[b+x])<=0);)b++,I<<=1;if(T+=1<<b,1===e&&852<T||2===e&&592<T)return 1;r[c=S&h]=w<<24|b<<16|u-o|0}}0!==S&&(r[u+S]=A-x<<24|64<<16|0),s.bits=w}return 0}},{"../utils/common":3}],13:[function(e,t,n){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],14:[function(n,o,e){var a=n("../utils/common"),c=0,h=1;function t(e){for(var t=e.length;0<=--t;)e[t]=0}var s,l,d,u=29,p=256,f=p+1+u,m=30,g=19,I=2*f+1,T=15,i=16,_=7,v=256,A=16,y=17,E=18,M=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],w=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],V=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],b=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],x=new Array(2*(f+2)),S=(t(x),new Array(2*m)),B=(t(S),new Array(512)),P=(t(B),new Array(256)),C=(t(P),new Array(u)),R=(t(C),new Array(m));function O(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}function L(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function D(e){return e<256?B[e]:B[256+(e>>>7)]}function r(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function H(e,t,n){e.bi_valid>i-n?(e.bi_buf|=t<<e.bi_valid&65535,r(e,e.bi_buf),e.bi_buf=t>>i-e.bi_valid,e.bi_valid+=n-i):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function F(e,t,n){H(e,n[2*t],n[2*t+1])}function k(e,t){for(var n=0;n|=1&e,e>>>=1,n<<=1,0<--t;);return n>>>1}function U(e,t,n){for(var i,r=new Array(T+1),o=0,a=1;a<=T;a++)r[a]=o=o+n[a-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=k(r[s]++,s))}}function G(e){for(var t=0;t<f;t++)e.dyn_ltree[2*t]=0;for(t=0;t<m;t++)e.dyn_dtree[2*t]=0;for(t=0;t<g;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*v]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function z(e){8<e.bi_valid?r(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function W(e,t,n,i){var r=2*t,o=2*n;return e[r]<e[o]||e[r]===e[o]&&i[t]<=i[n]}function N(e,t,n){for(var i=e.heap[n],r=n<<1;r<=e.heap_len&&(r<e.heap_len&&W(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!W(t,i,e.heap[r],e.depth));)e.heap[n]=e.heap[r],n=r,r<<=1;e.heap[n]=i}function Y(e,t,n){var i,r,o,a,s=0;if(0!==e.last_lit)for(;i=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],r=e.pending_buf[e.l_buf+s],s++,0==i?F(e,r,t):(F(e,(o=P[r])+p+1,t),0!==(a=M[o])&&H(e,r-=C[o],a),F(e,o=D(--i),n),0!==(a=w[o])&&H(e,i-=R[o],a)),s<e.last_lit;);F(e,v,t)}function j(e,t){var n,i,r,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,l=t.stat_desc.elems,d=-1;for(e.heap_len=0,e.heap_max=I,n=0;n<l;n++)0!==o[2*n]?(e.heap[++e.heap_len]=d=n,e.depth[n]=0):o[2*n+1]=0;for(;e.heap_len<2;)o[2*(r=e.heap[++e.heap_len]=d<2?++d:0)]=1,e.depth[r]=0,e.opt_len--,s&&(e.static_len-=a[2*r+1]);for(t.max_code=d,n=e.heap_len>>1;1<=n;n--)N(e,o,n);for(r=l;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],N(e,o,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,o[2*r]=o[2*n]+o[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,o[2*n+1]=o[2*i+1]=r,e.heap[1]=r++,N(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1];for(var c,h,u,p,f,m=e,g=t.dyn_tree,v=t.max_code,A=t.stat_desc.static_tree,y=t.stat_desc.has_stree,E=t.stat_desc.extra_bits,M=t.stat_desc.extra_base,w=t.stat_desc.max_length,b=0,x=0;x<=T;x++)m.bl_count[x]=0;for(g[2*m.heap[m.heap_max]+1]=0,c=m.heap_max+1;c<I;c++)w<(x=g[2*g[2*(h=m.heap[c])+1]+1]+1)&&(x=w,b++),g[2*h+1]=x,v<h||(m.bl_count[x]++,p=0,M<=h&&(p=E[h-M]),f=g[2*h],m.opt_len+=f*(x+p),y&&(m.static_len+=f*(A[2*h+1]+p)));if(0!==b){do{for(x=w-1;0===m.bl_count[x];)x--}while(m.bl_count[x]--,m.bl_count[x+1]+=2,m.bl_count[w]--,0<(b-=2));for(x=w;0!==x;x--)for(h=m.bl_count[x];0!==h;)v<(u=m.heap[--c])||(g[2*u+1]!==x&&(m.opt_len+=(x-g[2*u+1])*g[2*u],g[2*u+1]=x),h--)}U(o,d,e.bl_count)}function X(e,t,n){var i,r,o=-1,a=t[1],s=0,l=7,d=4;for(0===a&&(l=138,d=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=a,a=t[2*(i+1)+1],++s<l&&r===a||(s<d?e.bl_tree[2*r]+=s:0!==r?(r!==o&&e.bl_tree[2*r]++,e.bl_tree[2*A]++):s<=10?e.bl_tree[2*y]++:e.bl_tree[2*E]++,o=r,d=(s=0)===a?(l=138,3):r===a?(l=6,3):(l=7,4))}function Q(e,t,n){var i,r,o=-1,a=t[1],s=0,l=7,d=4;for(0===a&&(l=138,d=3),i=0;i<=n;i++)if(r=a,a=t[2*(i+1)+1],!(++s<l&&r===a)){if(s<d)for(;F(e,r,e.bl_tree),0!=--s;);else 0!==r?(r!==o&&(F(e,r,e.bl_tree),s--),F(e,A,e.bl_tree),H(e,s-3,2)):s<=10?(F(e,y,e.bl_tree),H(e,s-3,3)):(F(e,E,e.bl_tree),H(e,s-11,7));o=r,d=(s=0)===a?(l=138,3):r===a?(l=6,3):(l=7,4)}}t(R);var Z=!1;function q(e,t,n,i){H(e,0+(i?1:0),3),i=t,t=n,n=!0,z(e=e),n&&(r(e,t),r(e,~t)),a.arraySet(e.pending_buf,e.window,i,t,e.pending),e.pending+=t}e._tr_init=function(e){if(!Z){for(var t,n,i,r=new Array(T+1),o=0,a=0;a<u-1;a++)for(C[a]=o,t=0;t<1<<M[a];t++)P[o++]=a;for(P[o-1]=a,a=i=0;a<16;a++)for(R[a]=i,t=0;t<1<<w[a];t++)B[i++]=a;for(i>>=7;a<m;a++)for(R[a]=i<<7,t=0;t<1<<w[a]-7;t++)B[256+i++]=a;for(n=0;n<=T;n++)r[n]=0;for(t=0;t<=143;)x[2*t+1]=8,t++,r[8]++;for(;t<=255;)x[2*t+1]=9,t++,r[9]++;for(;t<=279;)x[2*t+1]=7,t++,r[7]++;for(;t<=287;)x[2*t+1]=8,t++,r[8]++;for(U(x,f+1,r),t=0;t<m;t++)S[2*t+1]=5,S[2*t]=k(t,5);s=new O(x,M,p+1,f,T),l=new O(S,w,0,m,T),d=new O(new Array(0),V,0,g,_),Z=!0}e.l_desc=new L(e.dyn_ltree,s),e.d_desc=new L(e.dyn_dtree,l),e.bl_desc=new L(e.bl_tree,d),e.bi_buf=0,e.bi_valid=0,G(e)},e._tr_stored_block=q,e._tr_flush_block=function(e,t,n,i){var r,o,a=0;if(0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){for(var t=4093624447,n=0;n<=31;n++,t>>>=1)if(1&t&&0!==e.dyn_ltree[2*n])return c;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(n=32;n<p;n++)if(0!==e.dyn_ltree[2*n])return h;return c}(e)),j(e,e.l_desc),j(e,e.d_desc),a=function(e){var t;for(X(e,e.dyn_ltree,e.l_desc.max_code),X(e,e.dyn_dtree,e.d_desc.max_code),j(e,e.bl_desc),t=g-1;3<=t&&0===e.bl_tree[2*b[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=r&&(r=o)):r=o=n+5,n+4<=r&&-1!==t)q(e,t,n,i);else if(4===e.strategy||o===r)H(e,2+(i?1:0),3),Y(e,x,S);else{H(e,4+(i?1:0),3);var s,l=e,t=e.l_desc.max_code+1,n=e.d_desc.max_code+1,d=a+1;for(H(l,t-257,5),H(l,n-1,5),H(l,d-4,4),s=0;s<d;s++)H(l,l.bl_tree[2*b[s]+1],3);Q(l,l.dyn_ltree,t-1),Q(l,l.dyn_dtree,n-1),Y(e,e.dyn_ltree,e.dyn_dtree)}G(e),i&&z(e)},e._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(P[n]+p+1)]++,e.dyn_dtree[2*D(t)]++),e.last_lit===e.lit_bufsize-1},e._tr_align=function(e){H(e,2,3),F(e,v,x),16===(e=e).bi_valid?(r(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},{"../utils/common":3}],15:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/":[function(e,t,n){var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=i},{"./lib/deflate":1,"./lib/inflate":2,"./lib/utils/common":3,"./lib/zlib/constants":6}]},{},[])("/")},function(e,t,n){function d(){}function c(e,t,n,i,r,o,a,s,l,d){for(var c,h,u=0,p=r;p!==a;p+=o)for(h=s;h!==d;h+=l,u++)c=t[u],e[4*(h+i*p)+3]=255,e[4*(h+i*p)+2]=n[3*c+0],e[4*(h+i*p)+1]=n[3*c+1],e[4*(h+i*p)+0]=n[3*c+2];return e}function h(e,t,n,i,r,o,a,s,l,d){for(var c,h,u=0,p=r;p!==a;p+=o)for(h=s;h!==d;h+=l,u+=2)c=t[u+0]|t[u+1]<<8,e[4*(h+i*p)+0]=(31744&c)>>7,e[4*(h+i*p)+1]=(992&c)>>2,e[4*(h+i*p)+2]=(31&c)>>3,e[4*(h+i*p)+3]=32768&c?0:255;return e}function u(e,t,n,i,r,o,a,s,l,d){for(var c,h=0,u=r;u!==a;u+=o)for(c=s;c!==d;c+=l,h+=3)e[4*(c+i*u)+3]=255,e[4*(c+i*u)+2]=t[h+0],e[4*(c+i*u)+1]=t[h+1],e[4*(c+i*u)+0]=t[h+2];return e}function p(e,t,n,i,r,o,a,s,l,d){for(var c,h=0,u=r;u!==a;u+=o)for(c=s;c!==d;c+=l,h+=4)e[4*(c+i*u)+2]=t[h+0],e[4*(c+i*u)+1]=t[h+1],e[4*(c+i*u)+0]=t[h+2],e[4*(c+i*u)+3]=t[h+3];return e}function f(e,t,n,i,r,o,a,s,l,d){for(var c,h,u=0,p=r;p!==a;p+=o)for(h=s;h!==d;h+=l,u++)c=t[u],e[4*(h+i*p)+0]=c,e[4*(h+i*p)+1]=c,e[4*(h+i*p)+2]=c,e[4*(h+i*p)+3]=255;return e}function m(e,t,n,i,r,o,a,s,l,d){for(var c,h=0,u=r;u!==a;u+=o)for(c=s;c!==d;c+=l,h+=2)e[4*(c+i*u)+0]=t[h+0],e[4*(c+i*u)+1]=t[h+0],e[4*(c+i*u)+2]=t[h+0],e[4*(c+i*u)+3]=t[h+1];return e}var i;d.Type={NO_DATA:0,INDEXED:1,RGB:2,GREY:3,RLE_INDEXED:9,RLE_RGB:10,RLE_GREY:11},d.Origin={BOTTOM_LEFT:0,BOTTOM_RIGHT:1,TOP_LEFT:2,TOP_RIGHT:3,SHIFT:4,MASK:48},d.prototype.open=function(e,t){var n=this,i=new XMLHttpRequest;i.overrideMimeType("text/plain"),i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){200===this.status&&(n.load(new Uint8Array(i.response)),t)&&t.call(n)},i.send(null)},d.prototype.load=function(e){var t=0;if(e.length<18)throw new Error("Targa::load() - Not enough data to contain header");this.header={idLength:e[t++],colorMapType:e[t++],imageType:e[t++],colorMapIndex:e[t++]|e[t++]<<8,colorMapLength:e[t++]|e[t++]<<8,colorMapDepth:e[t++],offsetX:e[t++]|e[t++]<<8,offsetY:e[t++]|e[t++]<<8,width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixelDepth:e[t++],flags:e[t++]},this.header.hasEncoding=this.header.imageType===d.Type.RLE_INDEXED||this.header.imageType===d.Type.RLE_RGB||this.header.imageType===d.Type.RLE_GREY,this.header.hasColorMap=this.header.imageType===d.Type.RLE_INDEXED||this.header.imageType===d.Type.INDEXED,this.header.isGreyColor=this.header.imageType===d.Type.RLE_GREY||this.header.imageType===d.Type.GREY;var n=this.header;if(n.imageType===d.Type.NO_DATA)throw new Error("Targa::checkHeader() - No data");if(n.hasColorMap){if(256<n.colorMapLength||24!==n.colorMapSize||1!==n.colorMapType)throw new Error("Targa::checkHeader() - Invalid colormap for indexed type")}else if(n.colorMapType)throw new Error("Targa::checkHeader() - Why does the image contain a palette ?");if(n.width<=0||n.height<=0)throw new Error("Targa::checkHeader() - Invalid image size");if(8!==n.pixelDepth&&16!==n.pixelDepth&&24!==n.pixelDepth&&32!==n.pixelDepth)throw new Error('Targa::checkHeader() - Invalid pixel size "'+n.pixelDepth+'"');if((t+=this.header.idLength)>=e.length)throw new Error("Targa::load() - No data");this.header.hasColorMap&&(n=this.header.colorMapLength*(this.header.colorMapDepth>>3),this.palette=e.subarray(t,t+n),t+=n);var n=this.header.pixelDepth>>3,i=this.header.width*this.header.height,r=i*n;this.header.hasEncoding?this.imageData=function(e,t,n,i){for(var r,o,a,s=new Uint8Array(i),l=new Uint8Array(n),d=0;d<i;)if(o=1+(127&(r=e[t++])),128&r){for(a=0;a<n;++a)l[a]=e[t++];for(a=0;a<o;++a)s.set(l,d),d+=n}else for(o*=n,a=0;a<o;++a)s[d++]=e[t++];return s}(e,t,n,r):this.imageData=e.subarray(t,t+(this.header.hasColorMap?i:r))},d.prototype.getImageData=function(e){var t,n,i,r,o,a=this.header.width,s=this.header.height,l=(this.header.flags&d.Origin.MASK)>>d.Origin.SHIFT;switch(e=e||(document?document.createElement("canvas").getContext("2d").createImageData(a,s):{width:a,height:s,data:new Uint8ClampedArray(a*s*4)}),s=l===d.Origin.TOP_LEFT||l===d.Origin.TOP_RIGHT?(i=0,r=1,s):(i=s-1,r=-1),l=l===d.Origin.TOP_LEFT||l===d.Origin.BOTTOM_LEFT?(t=0,n=1,a):(t=a-1,n=-1),this.header.pixelDepth){case 8:o=this.header.isGreyColor?f:c;break;case 16:o=this.header.isGreyColor?m:h;break;case 24:o=u;break;case 32:o=p}return o(e.data,this.imageData,this.palette,a,i,r,s,t,n,l),e},d.prototype.getCanvas=function(){var e=document.createElement("canvas"),t=e.getContext("2d"),n=t.createImageData(this.header.width,this.header.height);return e.width=this.header.width,e.height=this.header.height,t.putImageData(this.getImageData(n),0,0),e},d.prototype.getDataURL=function(e){return this.getCanvas().toDataURL(e||"image/png")},(i={}).exports=t,i.exports&&(i.exports.TGA=d)},function(e,t){THREE.RGBFormat=THREE.RGBAFormat,THREE.RGBIntegerFormat=THREE.RGBAIntegerFormat},function(e,t){THREE.Geometry=THREE.CompatibleGeometry,THREE.Geometry.prototype.applyMatrix=THREE.Geometry.prototype.applyMatrix4;var n=0;THREE.GeometryIdCount=function(){return n++}},function(e,t){THREE.Matrix3.prototype.getInverse=function(e,t){e&&e.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var e=e.elements,n=this.elements,i=e[0],r=e[1],o=e[2],a=e[3],s=e[4],l=e[5],d=e[6],c=e[7],e=e[8],h=e*s-l*c,u=l*d-e*a,p=c*a-s*d,f=i*h+r*u+o*p;if(0==f){var m="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(!0===t)throw new Error(m);return console.warn(m),this.identity()}t=1/f;return n[0]=h*t,n[1]=(o*c-e*r)*t,n[2]=(l*r-o*s)*t,n[3]=u*t,n[4]=(e*i-o*d)*t,n[5]=(o*a-l*i)*t,n[6]=p*t,n[7]=(r*d-c*i)*t,n[8]=(s*i-r*a)*t,this}},function(e,t){THREE.Matrix4.prototype.getInverse=function(e,t){var n=this.elements,e=e.elements,i=e[0],r=e[1],o=e[2],a=e[3],s=e[4],l=e[5],d=e[6],c=e[7],h=e[8],u=e[9],p=e[10],f=e[11],m=e[12],g=e[13],v=e[14],e=e[15],A=u*v*c-g*p*c+g*d*f-l*v*f-u*d*e+l*p*e,y=m*p*c-h*v*c-m*d*f+s*v*f+h*d*e-s*p*e,E=h*g*c-m*u*c+m*l*f-s*g*f-h*l*e+s*u*e,M=m*u*d-h*g*d-m*l*p+s*g*p+h*l*v-s*u*v,w=i*A+r*y+o*E+a*M;if(0==w){var b="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(!0===t)throw new Error(b);return console.warn(b),this.identity()}t=1/w;return n[0]=A*t,n[1]=(g*p*a-u*v*a-g*o*f+r*v*f+u*o*e-r*p*e)*t,n[2]=(l*v*a-g*d*a+g*o*c-r*v*c-l*o*e+r*d*e)*t,n[3]=(u*d*a-l*p*a-u*o*c+r*p*c+l*o*f-r*d*f)*t,n[4]=y*t,n[5]=(h*v*a-m*p*a+m*o*f-i*v*f-h*o*e+i*p*e)*t,n[6]=(m*d*a-s*v*a-m*o*c+i*v*c+s*o*e-i*d*e)*t,n[7]=(s*p*a-h*d*a+h*o*c-i*p*c-s*o*f+i*d*f)*t,n[8]=E*t,n[9]=(m*u*a-h*g*a-m*r*f+i*g*f+h*r*e-i*u*e)*t,n[10]=(s*g*a-m*l*a+m*r*c-i*g*c-s*r*e+i*l*e)*t,n[11]=(h*l*a-s*u*a-h*r*c+i*u*c+s*r*f-i*l*f)*t,n[12]=M*t,n[13]=(h*g*o-m*u*o+m*r*p-i*g*p-h*r*v+i*u*v)*t,n[14]=(m*l*o-s*g*o-m*r*d+i*g*d+s*r*v-i*l*v)*t,n[15]=(s*u*o-h*l*o+h*r*d-i*u*d-s*r*p+i*l*p)*t,this}},function(e,t){THREE.Quaternion.prototype.inverse=function(){return this.conjugate().normalize()}},function(e,t){THREE.Object3D.prototype.applyMatrix=function(e){this.applyMatrix4(e)}},function(e,t){THREE.BufferGeometry.prototype.addAttribute=THREE.BufferGeometry.prototype.setAttribute,THREE.BufferGeometry.prototype.applyMatrix=THREE.BufferGeometry.prototype.applyMatrix4},function(e,t){THREE.Math=THREE.MathUtils},function(e,t){THREE.Triangle.normal=function(e,t,n){return THREE.Triangle.getNormal(e,t,n,new THREE.Vector3)}},function(e,t){THREE.Matrix4D=function(){THREE.Matrix4.call(this),this.elements=new Float64Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},THREE.Matrix4D.prototype=Object.create(THREE.Matrix4.prototype)},function(e,t){THREE.Plane.prototype.transformProvidingInverse=function(e){var t=new THREE.Vector4(this.normal.x,this.normal.y,this.normal.z,this.constant);t.applyMatrix4(e.clone().transpose()),this.setComponents(t.x,t.y,t.z,t.w),this.normalize()}},function(e,t){var o,n,r,i,E,M,w,a,s;THREE.Polytope=function(e){function i(e){for(var t=f.planes,n=e,i=[],r=0,o=t.length;r<o;r++){var i=[],a=t[r],s=n[0],l=a.distanceToPoint(s);Math.abs(l)<1e-6&&(l=0);for(var d=1,c=n.length;d<c;++d){var h,u=n[d],p=a.distanceToPoint(u);Math.abs(p)<1e-6&&(p=0),0<=l&&i.push(s),l*p<0&&(h=l/(l-p),h=s.clone().multiplyScalar(1-h).add(u.clone().multiplyScalar(h)),i.push(h)),l=p,s=u}if(0<=l&&i.push(s),i.length<=1)return!1;n=i}return!0}var f=this;this.planes=e||[];this.intersectsLineSegment=function(e,t){return i([e,t])},this.intersectsTriangle=function(e,t,n){return i([e,t,n,e])}},Object.assign(THREE.Polytope.prototype,{add:function(e){return this.planes.push(e.clone()),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=0,n=e.planes.length;t<n;t++)this.planes[t]=e.planes[t].clone();return this},setFromMatrix:function(e){var t=this.planes,e=e.elements,n=e[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],d=e[7],c=e[8],h=e[9],u=e[10],p=e[11],f=e[12],m=e[13],g=e[14],e=e[15];return t[0].setComponents(o-n,d-a,p-c,e-f).normalize(),t[1].setComponents(o+n,d+a,p+c,e+f).normalize(),t[2].setComponents(o+i,d+s,p+h,e+m).normalize(),t[3].setComponents(o-i,d-s,p-h,e-m).normalize(),t[4].setComponents(o-r,d-l,p-u,e-g).normalize(),t[5].setComponents(o+r,d+l,p+u,e+g).normalize(),this},intersectsObject:(i=new THREE.Sphere,function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),i.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(i)}),intersectsPMIObject:(r=new THREE.Box3,function(e){var n=this,i=[];return e.traverse(function(e){var t=e.geometry;t&&(null===t.boundingBox&&t.computeBoundingBox(),r.copy(t.boundingBox).applyMatrix4(e.matrixWorld),n.intersectsBox(r))&&i.push(e)}),i}),intersectsSprite:(n=new THREE.Sphere,function(e){return n.center.set(0,0,0),n.radius=.7071067811865476,n.applyMatrix4(e.matrixWorld),this.intersectsSphere(n)}),intersectsSphere:function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0,o=this.planes.length;r<o;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0},intersectsBox:(o=new THREE.Vector3,function(e){for(var t=this.planes,n=0,i=this.planes.length;n<i;n++){var r=t[n];if(o.x=(0<r.normal.x?e.max:e.min).x,o.y=(0<r.normal.y?e.max:e.min).y,o.z=(0<r.normal.z?e.max:e.min).z,r.distanceToPoint(o)<0)return!1}return!0}),containsPoint:function(e){for(var t=this.planes,n=0,i=t.length;n<i;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0},applyMatrix4:function(e){for(var t=this.planes,n=0,i=t.length;n<i;n++)t[n].applyMatrix4(e);return this},transformProvidingInverse:function(e){for(var t=this.planes,n=0,i=t.length;n<i;n++)t[n].transformProvidingInverse(e);return this},setToUnitFrustum:function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0),this.planes=[],this.planes.push(new THREE.Plane(new THREE.Vector3(1,0,0),1)),this.planes.push(new THREE.Plane(new THREE.Vector3(-1,0,0),1)),this.planes.push(new THREE.Plane(new THREE.Vector3(0,1,0),1)),this.planes.push(new THREE.Plane(new THREE.Vector3(0,-1,0),1)),e&&this.planes.push(new THREE.Plane(new THREE.Vector3(0,0,1),1)),t&&this.planes.push(new THREE.Plane(new THREE.Vector3(0,0,-1),1))},setToBoundingBox:function(e){this.planes=[],this.planes.push(new THREE.Plane(new THREE.Vector3(1,0,0),-e.min.x)),this.planes.push(new THREE.Plane(new THREE.Vector3(-1,0,0),e.max.x)),this.planes.push(new THREE.Plane(new THREE.Vector3(0,1,0),-e.min.y)),this.planes.push(new THREE.Plane(new THREE.Vector3(0,-1,0),e.max.y)),this.planes.push(new THREE.Plane(new THREE.Vector3(0,0,1),-e.min.z)),this.planes.push(new THREE.Plane(new THREE.Vector3(0,0,-1),e.max.z))}}),THREE.Line.prototype.raycast=(E=new THREE.Matrix4,M=new THREE.Ray,new THREE.Sphere,w=new THREE.Box3,function(e,t){var n=e.linePrecision,i=n*n,r=this.geometry,o=this.matrixWorld;if(null===r.boundingBox&&r.computeBoundingBox(),w.copy(r.boundingBox),w.applyMatrix4(o),w.max.x+=n,w.max.y+=n,w.max.z+=n,w.min.x-=n,w.min.y-=n,w.min.z-=n,!1!==e.ray.intersectsBox(w)&&r.attributes.position){E.getInverse(o),M.copy(e.ray).applyMatrix4(E);var a=new THREE.Vector3,s=new THREE.Vector3,l=new THREE.Vector3,d=new THREE.Vector3,c=this&&this.isLineSegments?2:1;if(r.isBufferGeometry){var n=r.index,h=r.attributes.position.array;if(null!==n)for(var u=n.array,p=0,f=u.length-1;p<f;p+=c){var m=u[p],g=u[p+1];a.fromArray(h,3*m),s.fromArray(h,3*g),i<M.distanceSqToSegment(a,s,d,l)||(d.applyMatrix4(this.matrixWorld),(v=e.ray.origin.distanceTo(d))<e.near)||v>e.far||t.push({distance:v,point:l.clone().applyMatrix4(this.matrixWorld),index:p,face:null,faceIndex:null,object:this})}else for(p=0,f=h.length/3-1;p<f;p+=c)a.fromArray(h,3*p),s.fromArray(h,3*p+3),i<M.distanceSqToSegment(a,s,d,l)||(d.applyMatrix4(this.matrixWorld),(v=e.ray.origin.distanceTo(d))<e.near)||v>e.far||t.push({distance:v,point:l.clone().applyMatrix4(this.matrixWorld),index:p,face:null,faceIndex:null,object:this})}else if(r.isGeometry)for(var v,A=r.vertices,y=A.length,p=0;p<y-1;p+=c)i<M.distanceSqToSegment(A[p],A[p+1],d,l)||(d.applyMatrix4(this.matrixWorld),(v=e.ray.origin.distanceTo(d))<e.near)||v>e.far||t.push({distance:v,point:l.clone().applyMatrix4(this.matrixWorld),index:p,face:null,faceIndex:null,object:this})}}),THREE.Box3.prototype.intersectsPlane=function(e){return s=0<e.normal.x?(a=e.normal.x*this.min.x,e.normal.x*this.max.x):(a=e.normal.x*this.max.x,e.normal.x*this.min.x),0<e.normal.y?(a+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(a+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),0<e.normal.z?(a+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(a+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),a<=-e.constant&&s>=-e.constant}},function(e,t,n){t.byteLength=function(e){var e=c(e),t=e[0],e=e[1];return 3*(t+e)/4-e},t.toByteArray=function(e){var t,n,i=c(e),r=i[0],i=i[1],o=new d(function(e,t){return 3*(e+t)/4-t}(r,i)),a=0,s=0<i?r-4:r;for(n=0;n<s;n+=4)t=l[e.charCodeAt(n)]<<18|l[e.charCodeAt(n+1)]<<12|l[e.charCodeAt(n+2)]<<6|l[e.charCodeAt(n+3)],o[a++]=t>>16&255,o[a++]=t>>8&255,o[a++]=255&t;2===i&&(t=l[e.charCodeAt(n)]<<2|l[e.charCodeAt(n+1)]>>4,o[a++]=255&t);1===i&&(t=l[e.charCodeAt(n)]<<10|l[e.charCodeAt(n+1)]<<4|l[e.charCodeAt(n+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t);return o},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,r=[],o=0,a=n-i;o<a;o+=16383)r.push(function(e,t,n){for(var i,r=[],o=t;o<n;o+=3)i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),r.push(function(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}(i));return r.join("")}(e,o,a<o+16383?a:o+16383));1==i?(t=e[n-1],r.push(s[t>>2]+s[t<<4&63]+"==")):2==i&&(t=(e[n-2]<<8)+e[n-1],r.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return r.join("")};for(var s=[],l=[],d="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,o=i.length;r<o;++r)s[r]=i[r],l[i.charCodeAt(r)]=r;function c(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");e=e.indexOf("="),t=(e=-1===e?t:e)===t?0:4-e%4;return[e,t]}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,i,r){var o,a,s=8*r-i-1,l=(1<<s)-1,d=l>>1,c=-7,h=n?r-1:0,u=n?-1:1,r=e[t+h];for(h+=u,o=r&(1<<-c)-1,r>>=-c,c+=s;0<c;o=256*o+e[t+h],h+=u,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=i;0<c;a=256*a+e[t+h],h+=u,c-=8);if(0===o)o=1-d;else{if(o===l)return a?NaN:1/0*(r?-1:1);a+=Math.pow(2,i),o-=d}return(r?-1:1)*a*Math.pow(2,o-i)},t.write=function(e,t,n,i,r,o){var a,s,l=8*o-r-1,d=(1<<l)-1,c=d>>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,u=i?0:o-1,p=i?1:-1,o=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=d):(a=Math.floor(Math.log(t)/Math.LN2),t*(i=Math.pow(2,-a))<1&&(a--,i*=2),2<=(t+=1<=a+c?h/i:h*Math.pow(2,1-c))*i&&(a++,i/=2),d<=a+c?(s=0,a=d):1<=a+c?(s=(t*i-1)*Math.pow(2,r),a+=c):(s=t*Math.pow(2,c-1)*Math.pow(2,r),a=0));8<=r;e[n+u]=255&s,u+=p,s/=256,r-=8);for(a=a<<r|s,l+=r;0<l;e[n+u]=255&a,u+=p,a/=256,l-=8);e[n+u-p]|=128*o}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,r,o){!function(e){var t=void 0!==e&&e||"undefined"!=typeof self&&self||window,n=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}r.setTimeout=function(){return new i(n.call(setTimeout,t,arguments),clearTimeout)},r.setInterval=function(){return new i(n.call(setInterval,t,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(t,this._id)},r.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},r.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},r._unrefActive=r.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},o(23),r.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,r.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}.call(this,o(0))},function(e,t,n){!function(e,t){function o(e){delete l[e]}function a(e){if(d)setTimeout(a,0,e);else{var t=l[e];if(t){d=!0;try{var n=t,i=n.callback,r=n.args;switch(r.length){case 0:i();break;case 1:i(r[0]);break;case 2:i(r[0],r[1]);break;case 3:i(r[0],r[1],r[2]);break;default:i.apply(s,r)}}finally{o(e),d=!1}}}}function n(){function e(e){e.source===i&&"string"==typeof e.data&&0===e.data.indexOf(t)&&a(+e.data.slice(t.length))}var t="setImmediate$"+Math.random()+"$";i.addEventListener?i.addEventListener("message",e,!1):i.attachEvent("onmessage",e),h=function(e){i.postMessage(t+e,"*")}}var i,s,r,l,d,c,h,u,p;(i="undefined"==typeof self?void 0===e?this:e:self).setImmediate||(r=1,d=!(l={}),c=i.document,e=(e=Object.getPrototypeOf&&Object.getPrototypeOf(i))&&e.setTimeout?e:i,"[object process]"==={}.toString.call(i.process)?h=function(e){t.nextTick(function(){a(e)})}:!function(){var e,t;if(i.postMessage&&!i.importScripts)return e=!0,t=i.onmessage,i.onmessage=function(){e=!1},i.postMessage("","*"),i.onmessage=t,e}()?h=i.MessageChannel?((p=new MessageChannel).port1.onmessage=function(e){a(e.data)},function(e){p.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(u=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){a(e),t.onreadystatechange=null,u.removeChild(t),t=null},u.appendChild(t)}):function(e){setTimeout(a,0,e)}:n(),e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];return l[r]={callback:e,args:t},h(r),r++},e.clearImmediate=o)}.call(this,n(0),n(2))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(i,e,t){t.r(e),t.d(e,"NDS",function(){return ve}),t.d(e,"Viewer",function(){return Ir}),t.d(e,"COMMON",function(){return Se}),t.d(e,"SETTING",function(){return _e}),t.d(e,"DecalGeometry",function(){return mt}),t.d(e,"NdsCoordSystem",function(){return Ne}),t.d(e,"LineTypeCreater",function(){return Et}),t.d(e,"BIMXHRLoader",function(){return oi}),t.d(e,"SDFCreater",function(){return le}),t.d(e,"BrepManager",function(){return Tt}),t.d(e,"MaterialsSetting",function(){return St}),t.d(e,"NdsMeshManager",function(){return ut}),t.d(e,"NdsGeometry",function(){return de}),t.d(e,"NdsBodyNode",function(){return Ae}),t.d(e,"NdsModel",function(){return zt}),t.d(e,"NdsModelSet",function(){return Xt}),t.d(e,"BVHCreater",function(){return fr}),t.d(e,"NdsModelBvh",function(){return Bt}),t.d(e,"NdsMeshSet",function(){return pt}),t.d(e,"NdsLeafBodyAttri",function(){return S}),t.d(e,"NdsCoordSystemAttri",function(){return C}),t.d(e,"PropertyManager",function(){return fi}),t.d(e,"MeasureBase",function(){return h}),t.d(e,"SelectionManager",function(){return mi}),t.d(e,"Extension",function(){return or}),t.d(e,"ExtensionManager",function(){return Te}),t.d(e,"CameraControl",function(){return De}),t.d(e,"OpBase",function(){return g}),t.d(e,"SnappingTool",function(){return An}),t.d(e,"SNAP_VERTEX",function(){return vn}),t.d(e,"LineMaterial",function(){return Q}),t.d(e,"LineMaterialOrigin",function(){return Ar}),t.d(e,"LineSegments2",function(){return qe}),t.d(e,"LineSegmentsGeometry",function(){return G});function Be(n){var l=this,i=null,r=(l.viewer=n,0),o=0,a=0,s=0,d=!1,c=(this.visible=!1,l.uiTreeRoot=null);function h(e){return document.getElementById(e)}function u(e){null!=e&&(e.style.left="1px",e.style.top="1px")}function p(e,t,n){var i=t.children.length,r=null,r=l.viewer.isLeaf(t)?document.createElement("leaf"):document.createElement("group");t.treeType&&"Root"==t.treeType&&(r.style.left="4px",l.uiTreeRoot=r),r.object3d=t,r.className="collapsed",n&&(r.className="expanded");(n=document.createElement("header")).className="headerunselected",r.appendChild(n);var o=document.createElement("icon");o.object3d=t,o.group=r,o.addEventListener("mouseup",A,!1),n.appendChild(o),(o=document.createElement("checkbox")).group=r,!(o.object3d=t).visible||l.viewer.isObjectOrSomeChildHidden(t)?(o.className="icon-checkbox-off",o.ischeckboxon=!1):(o.className="icon-checkbox-on",o.ischeckboxon=!0),o.addEventListener("mouseup",M,!1),n.appendChild(o),(o=document.createElement("label")).object3d=t,o.group=r,o.addEventListener("mouseup",v,!1),t.name?(o.textContent=t.name,r.name=t.name):(o.textContent="Object3D",r.name="Object3D"),n.appendChild(o),e.appendChild(r);for(var a=0;a<i;a++)l.viewer.isLeaf(t)||p(r,t.children[a])}function f(){var e=document.createElement("div"),t=(e.className="treeview",l.viewer.getModelTree());return t.treeType="Root",p(e,t,!0),n.addEventListener("selectObject",function(e){e=l.getUiNodeByObject3d(e.object,l.uiTreeRoot);l.setGroupClassName(e,"selected")}),n.addEventListener("clearSelection",function(e){l.setGroupClassName(l.uiTreeRoot,"unselected")}),n.addEventListener("isolateSelectedObjects",function(e){l.setGroupClassName(l.uiTreeRoot,"dim");for(var t=0;t<e.objects.length;t++){var n=l.getUiNodeByObject3d(e.objects[t],l.uiTreeRoot);l.setGroupClassName(n,"visible")}}),n.addEventListener("showAllModel",function(e){l.setGroupClassName(l.uiTreeRoot,"visible")}),n.addEventListener("exitIsolate",function(e){}),document.getElementById("modelbrowserdialog_serch").oninput=m,c=window.setInterval(function(){if(b!==w){if(l.viewer.showAllModel(),""!==w){var e=w,t=l.uiTreeRoot,s=[];(function e(t,n,i){var r=n.name.toLowerCase();if(!i&&0<=r.indexOf(t))s.push(n.object3d),i=n.parentNode,l.expandParent(i);else for(var o=0;o<n.children.length;o++){var a=n.children[o];"group"!=a.localName&&"leaf"!=a.localName||e(t,a,!1)}})(e,t,!0);for(var n=0;n<s.length;n++)l.viewer.selectionManager.selectObject(s[n]);l.viewer.isolateSelectedObjects()}else l.setGroupClassName(l.uiTreeRoot,"collapsed");b=w}},500),e}function m(e){e.preventDefault(),e.stopPropagation(),w=(w=e.target.value).toLowerCase()}window.onresize=function(){u(h("modelbrowserdialog"))},document.onmousemove=function(e){var t,n,i=(e=e||window.event).pageX,e=e.pageY;d&&(i=a+i-r,e=s+e-o,h("modelbrowserdialog").style.left=i+"px",h("modelbrowserdialog").style.top=e+"px",t=document.documentElement.clientWidth,n=document.documentElement.clientHeight,t=t-h("modelbrowserdialog").offsetWidth,n=n-h("modelbrowserdialog").offsetHeight,i=Math.min(Math.max(0,i),t),e=Math.min(Math.max(0,e),n),h("modelbrowserdialog").style.left=i+"px",h("modelbrowserdialog").style.top=e+"px")},this.onClose=function(e){0};var g=function(e,t){e=new THREE.Vector2(e.clientX,e.clientY);"js"===l.viewer.modelInfo[0].type&&_e.enableSelect&&l.viewer.enableInternalRMB&&(l.viewer.selectionManager.clearSelection(),l.viewer.selectionManager.selectObject(t.object3d),l.viewer.render(),l.viewer.showModelBroserMenu(!1),l.viewer.showModelBroserMenu(!0,e.x,e.y))},v=function(e){2===e.button?g(e,this):0===e.button&&"js"===l.viewer.modelInfo[0].type&&(l.viewer.selectionManager.clearSelection(),l.viewer.restoreOriginalMeshes(),l.viewer.selectionManager.selectObject(e.target.object3d),l.viewer.render())},A=function(e){var t;0===e.button?(0<=(t=this.group.className).indexOf("collapsed")?t=t.replace(/collapsed/g,"expanded"):0<=t.indexOf("expanded")&&(t=t.replace(/expanded/g,"collapsed")),this.group.className=t):2===e.button&&g(e,this)},y=(this.getUiNodeByObject3d=function(e,t){var n=null;if(t.object3d==e)n=t;else for(var i=0;i<t.children.length;i++)if("group"==t.children[i].localName||"leaf"==t.children[i].localName){var r=l.getUiNodeByObject3d(e,t.children[i]);if(r){n=r;break}}return n},this.setGroupClassName=function(e,t){var n=e.className;"dim"==t?0<=n.indexOf("visible")?n=n.replace(/visible/g,t):n.indexOf("dim")<0&&(n=n+" "+t):"visible"==t?0<=n.indexOf("dim")?n=n.replace(/dim/g,t):n.indexOf("visible")<0&&(n=n+" "+t):"selected"==t?n.indexOf("selected")<0&&(n=n+" "+t):"unselected"==t?0<=n.indexOf("selected")&&(n=n.replace(/selected/g,"")):"collapsed"==t?0<=n.indexOf("expanded")?n=n.replace(/expanded/,"collapsed"):n.indexOf("collapsed")<0&&(n+=" collapsed"):"expanded"==t&&(0<=n.indexOf("collapsed")?n=n.replace(/collapsed/,"expanded"):n.indexOf("expanded")<0&&(n+=" expanded")),e.className=n;for(var i=0;i<e.children.length;i++)"group"==e.children[i].localName?l.setGroupClassName(e.children[i],t):"leaf"==e.children[i].localName&&(n=e.children[i].className,"dim"==t?0<=n.indexOf("visible")?n=n.replace(/visible/g,t):n.indexOf("dim")<0&&(n=n+" "+t):"visible"==t?0<=n.indexOf("dim")?n=n.replace(/dim/g,t):n.indexOf("visible")<0&&(n=n+" "+t):"selected"==t?n.indexOf("selected")<0&&(n=n+" "+t):"unselected"==t&&0<=n.indexOf("selected")&&(n=n.replace(/selected/g,"")),e.children[i].className=n)},this.expandParent=function(e){e&&"group"==e.localName&&(0<=e.className.indexOf("collapsed")?e.className=e.className.replace(/collapsed/g,"expanded"):e.className.indexOf("expanded")<0&&(e.className=e.className+" expanded"),e.parentNode)&&l.expandParent(e.parentNode)},null),E=null,M=(this.getTreeNodeByClickModel=function(e){y&&(y.className="headerunselected");for(var t=$("label"),n=t.length-1;0<=n;n--)t[n].object3d.uuid==e.uuid&&(y=t[n].parentElement);if(y){for(var i=$("group"),n=i.length-1;0<=n;n--)0<=i[n].className.indexOf("expanded")&&(i[n].className=i[n].className.replace(/expanded/g,"collapsed"));for(var r=$(y).parents(),n=r.length-1;0<=n;n--)"group"==r[n].localName&&l.viewer.modelBrowserDlg.expandParent(r[n]);y.className="headerselected",E=y}},this.hideTreeNodeByObject=function(e){for(var t=$("label"),n=null,i=t.length-1;0<=i;i--)if(t[i].object3d.uuid==e.uuid){n=t[i];break}if(n){for(var r=n.parentNode.children[1],o=(r.ischeckboxon=!1,r.className="icon-checkbox-off",$(n).parents("group").children("header").find("checkbox")),i=o.length-1;0<=i;i--){var a=o[i].object3d;!a.visible||l.viewer.isObjectOrSomeChildHidden(a)?(o[i].className="icon-checkbox-off",o[i].ischeckboxon=!1):(o[i].className="icon-checkbox-on",o[i].ischeckboxon=!0)}var s=$(r.group).find("checkbox");if(r.ischeckboxon)for(i=s.length-1;0<=i;i--)s[i].className="icon-checkbox-on",s[i].ischeckboxon=!0;else for(i=s.length-1;0<=i;i--)s[i].className="icon-checkbox-off",s[i].ischeckboxon=!1}},this.showAllTreeNode=function(){for(var e=$("checkbox"),t=0;t<e.length;t++)e[t].className="icon-checkbox-on",e[t].ischeckboxon=!0},function(e){var e=e.target,t=(e.ischeckboxon=!e.ischeckboxon,l.viewer.showObjectAtObjectLevel(e.object3d,e.ischeckboxon),$(e).parents("group").children("header").find("checkbox"));if(e.ischeckboxon&&t)for(var n=t.length-1;0<=n;n--){var i=t[n].object3d;!i.visible||l.viewer.isObjectOrSomeChildHidden(i)?(t[n].className="icon-checkbox-off",t[n].ischeckboxon=!1):(t[n].className="icon-checkbox-on",t[n].ischeckboxon=!0)}var r=$(e.group).find("checkbox");if(e.ischeckboxon)for(n=r.length-1;0<=n;n--)r[n].className="icon-checkbox-on",r[n].ischeckboxon=!0;else for(n=r.length-1;0<=n;n--)r[n].className="icon-checkbox-off",r[n].ischeckboxon=!1;l.viewer.render()}),w="",b="",x=null;this.show=function(e){var t;x||((i=document.createElement("div")).onclick=function(){_e.enableSelect&&l.viewer.enableInternalRMB&&l.viewer.showModelBroserMenu(!1)},document.body.appendChild(i),i.innerHTML='<div class="modelbrowserdialog" id="modelbrowserdialog">'+('<div class="modelbrowserdialog_head" id="newdimmove_part">'+e+"</div>")+'<div class="newdimDlgBtnClose" id="modelbrowserclose">×</div>'+'<input class="modelbrowserdialog_serch" id="modelbrowserdialog_serch" type="search" placeholder="按名称过滤"></input>'+'<div class="modelbrowserdialog_content" id="nds-mbdlg-content">'+"</div>"+"</div>",e=document.getElementById("nds-mbdlg-content"),t=f(),x=t,e.appendChild(t),l.viewer.addEventListener("selectObject",function(e){l.getTreeNodeByClickModel(e.object)}),l.viewer.addEventListener("clearSelection",function(e){E&&(E.className="headerunselected")}),h("modelbrowserclose").onclick=function(){h("modelbrowserdialog").style.display="none",l.visible=!1,window.clearTimeout(c)},h("newdimmove_part").addEventListener("mousedown",function(e){e=e||window.event;r=e.pageX,o=e.pageY,a=h("modelbrowserdialog").offsetLeft,s=h("modelbrowserdialog").offsetTop,d=!0}),h("newdimmove_part").addEventListener("mouseup",function(){d=!1})),h("modelbrowserdialog").style.display="block",u(h("modelbrowserdialog")),l.visible=!0}}function ge(e,t,n){THREE.Camera.call(this),this.fov=45,this.near=.5,this.far=1e4,this.aspect=e/t,this.orthoNear=-200,this.perpNear=.5,this.viewer=n,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2,this.target=new THREE.Vector3(0,0,0),this.worldup=new THREE.Vector3(0,1,0),this.position.set(0,0,1),this.orthographicCamera=new THREE.OrthographicCamera(this.left,this.right,this.top,this.bottom,this.near,this.far),this.perspectiveCamera=new THREE.PerspectiveCamera(this.fov,this.aspect,this.near,this.far),this.updateMatrixWorld(!0),this.zoom=1,this.isPerspective=!0,this.zoomToFitRatio=5,this.orginalCameraInfo=void 0,this.toPerspective()}var ve={},_e=(t(5),t(6),t(7),t(8),t(9),t(10),t(11),t(12),t(13),t(14),t(15),t(16),{REVISION:"01",toolbarButtonClickedBkgColor:"",toolbarOpacity:.2,dialogOpacity:.2,bodyOpacity:.4,lineOpacity:.2,OES_element_index_uint:!1,avoidCaching:!0,lineSegAnnotationGridCount:200,enableBroadcast:!1,broadcastMajor:!1});_e.selectedMaterial=new THREE.MeshStandardMaterial({color:16763200,metalness:.2,roughness:1,side:THREE.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:2,skinning:!1}),_e.BIMselectedMaterial=new THREE.MeshBasicMaterial({opacity:.7,color:4168151,side:THREE.DoubleSide,depthTest:!1,depthWrite:!1,transparent:!0}),_e.selectedColor=new THREE.Color(16776960),_e.selectedLineMaterial=new THREE.LineBasicMaterial({color:16776960}),_e.selectedPointMaterial=new THREE.MeshBasicMaterial({color:16776960,side:THREE.DoubleSide}),_e.selectedFaceMaterial=new THREE.MeshBasicMaterial({opacity:.8,color:979390,side:THREE.DoubleSide,transparent:!0}),_e.selectedFace2DMaterial=new THREE.MeshBasicMaterial({opacity:.8,color:16763200,side:THREE.DoubleSide,transparent:!0}),_e.preSelectedFaceMaterial=new THREE.MeshBasicMaterial({opacity:.8,color:65535,side:THREE.DoubleSide,transparent:!0}),_e.selectedEdgeMaterial=new THREE.LineBasicMaterial({color:16744512,opacity:.9,transparent:!0,depthTest:!1,depthWrite:!1,linewidth:1}),_e.preSelectedEdgeMaterial=new THREE.LineBasicMaterial({color:65535,opacity:.9,transparent:!0,depthTest:!1,depthWrite:!1,linewidth:1}),_e.SelectedEdgeMaterial1=new THREE.LineBasicMaterial({color:16711680,depthTest:!0,depthWrite:!0,linewidth:1}),_e.selectedVertexMaterial=new THREE.MeshBasicMaterial({color:16711680,opacity:.8,transparent:!0,depthTest:!1,depthWrite:!1}),_e.preSelectedVertexMaterial=new THREE.MeshBasicMaterial({color:65535,opacity:.8,transparent:!0,depthTest:!1,depthWrite:!1}),_e.dashedMaterial=new THREE.ShaderMaterial({uniforms:{lineStyle:{value:-1},dashSize:{value:12},dashNum:{value:1},grapSize:{value:3},pointSize:{value:.5},pointNum:{value:1},opacity:{value:.8},diffuse:{value:new THREE.Color(16711680)}},linewidth:1,transparent:!0,fragmentShader:["uniform vec3 diffuse;","uniform float opacity;","uniform float dashSize;","uniform float dashNum;","uniform float pointNum;","uniform float grapSize;","uniform float pointSize;","varying float vLineDistance;","#include <common>","#include <color_pars_fragment>","#include <fog_pars_fragment>","#include <logdepthbuf_pars_fragment>","#include <clipping_planes_pars_fragment>","void main() {","#include <clipping_planes_fragment>","float totalSize = dashSize * dashNum + grapSize * (dashNum + pointNum) + pointSize * pointNum;","float modSize = mod( vLineDistance, totalSize );","bool grap = false;","for(float i = 1.0; i< 4.0; ++i){","if(i > dashNum){","break;","}","if(modSize < i * (grapSize + dashSize) && modSize > i * (grapSize + dashSize) - grapSize){","grap = true;","break;","}","}","if ( grap ) {","discard;","}","float dashlength = dashNum * (grapSize + dashSize);","for(float i = 1.0;i <4.0; ++i){","if(i > pointNum){","break;","}","if(modSize < i * (grapSize + pointSize) + dashlength && ","modSize > i * (grapSize + pointSize) - grapSize + dashlength){","grap = true;","break;","}","}","if ( grap ) {","discard;","}","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","#include <logdepthbuf_fragment>","#include <color_fragment>","outgoingLight = diffuseColor.rgb;","gl_FragColor = vec4( outgoingLight, diffuseColor.a );","#include <premultiplied_alpha_fragment>","#include <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>","}"].join("\n"),vertexShader:["attribute float lineDistance;","varying float vLineDistance;","#include <common>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>","void main() {","#include <color_vertex>","vLineDistance = lineDistance;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","gl_Position = projectionMatrix * mvPosition;","#include <logdepthbuf_vertex>","#include <clipping_planes_vertex>","#include <fog_vertex>","}"].join("\n")}),_e.enableSelect=!1,_e.autoSwitchFirstPersonView=!1,_e.tangentEdgeVisible=!0,_e.enableArrowKeyOp=!0,_e.dynamicRotateCenter=!0,_e.NdsLoadWorkerUrl="./coreviewer/NDSRequestWorker.min.js",_e.enableOutlineEffect=!1,_e.enableBodyVolumeMeasure=!1,_e.enablePreSelectBrep=!1,_e.selectObjectWithPropertyOnly=!1,_e.enableDirectMove=!1,_e.enableDirectRotate=!1,_e.inAssemblyContext=!1,_e.inBIMContext=!1,_e.ScenarioEditor=!1,_e.ScenarioEditorid=-1,_e.AnimationEdit=!1,_e.StopPMIOcclusion=!0,_e.singleHTML=!1,_e.HideLeafBody=!1,_e.New2DAPPMeasure=!1;function P(){P=function(){return a};var l,a={},e=Object.prototype,d=e.hasOwnProperty,c=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",r=t.toStringTag||"@@toStringTag";function o(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(l){o=function(e,t,n){return e[t]=n}}function s(e,t,n,i){var r,o,a,s,t=t&&t.prototype instanceof v?t:v,t=Object.create(t.prototype),i=new T(i||[]);return c(t,"_invoke",{value:(r=e,o=n,a=i,s=u,function(e,t){if(s===f)throw Error("Generator is already running");if(s===m){if("throw"===e)throw t;return{value:l,done:!0}}for(a.method=e,a.arg=t;;){var n=a.delegate;if(n){n=function e(t,n){var i=n.method,r=t.iterator[i];if(r===l)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=l,e(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;i=h(r,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,g;r=i.arg;return r?r.done?(n[t.resultName]=r.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=l),n.delegate=null,g):r:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}(n,a);if(n){if(n===g)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(s===u)throw s=m,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);s=f;n=h(r,o,a);if("normal"===n.type){if(s=a.done?m:p,n.arg===g)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(s=m,a.method="throw",a.arg=n.arg)}})}),t}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}a.wrap=s;var u="suspendedStart",p="suspendedYield",f="executing",m="completed",g={};function v(){}function A(){}function y(){}var t={},E=(o(t,i,function(){return this}),Object.getPrototypeOf),E=E&&E(E(S([]))),M=(E&&E!==e&&d.call(E,i)&&(t=E),y.prototype=v.prototype=Object.create(t));function w(e){["next","throw","return"].forEach(function(t){o(e,t,function(e){return this._invoke(t,e)})})}function b(a,s){var t;c(this,"_invoke",{value:function(n,i){function e(){return new s(function(e,t){!function t(e,n,i,r){var o,e=h(a[e],a,n);if("throw"!==e.type)return(n=(o=e.arg).value)&&"object"==typeof n&&d.call(n,"__await")?s.resolve(n.__await).then(function(e){t("next",e,i,r)},function(e){t("throw",e,i,r)}):s.resolve(n).then(function(e){o.value=e,i(o)},function(e){return t("throw",e,i,r)});r(e.arg)}(n,i,e,t)})}return t=t?t.then(e,e):e()}})}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(t){if(t||""===t){var n,e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(d.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=l,e.done=!0,e}).next=e}throw new TypeError(typeof t+" is not iterable")}return c(M,"constructor",{value:A.prototype=y,configurable:!0}),c(y,"constructor",{value:A,configurable:!0}),A.displayName=o(y,r,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===A||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,o(e,r,"GeneratorFunction")),e.prototype=Object.create(M),e},a.awrap=function(e){return{__await:e}},w(b.prototype),o(b.prototype,n,function(){return this}),a.AsyncIterator=b,a.async=function(e,t,n,i,r){void 0===r&&(r=Promise);var o=new b(s(e,t,n,i),r);return a.isGeneratorFunction(t)?o:o.next().then(function(e){return e.done?e.value:o.next()})},w(M),o(M,r,"Generator"),o(M,i,function(){return this}),o(M,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,n=Object(e),i=[];for(t in n)i.push(t);return i.reverse(),function e(){for(;i.length;){var t=i.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=S,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=l,this.done=!1,this.delegate=null,this.method="next",this.arg=l,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&d.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=l)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var i=this;function e(e,t){return o.type="throw",o.arg=n,i.next=e,t&&(i.method="next",i.arg=l),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t],o=r.completion;if("root"===r.tryLoc)return e("end");if(r.tryLoc<=this.prev){var a=d.call(r,"catchLoc"),s=d.call(r,"finallyLoc");if(a&&s){if(this.prev<r.catchLoc)return e(r.catchLoc,!0);if(this.prev<r.finallyLoc)return e(r.finallyLoc)}else if(a){if(this.prev<r.catchLoc)return e(r.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return e(r.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&d.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}var o=(r=r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc?null:r)?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),I(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,i,r=this.tryEntries[t];if(r.tryLoc===e)return"throw"===(n=r.completion).type&&(i=n.arg,I(r)),i}throw Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=l),g}},a}function l(e,t,n,i,r,o,a){try{var s=e[o](a),l=s.value}catch(e){return n(e)}s.done?t(l):Promise.resolve(l).then(i,r)}ge.ORTHO_FOV=2*Math.atan(.5)*180/Math.PI,(ge.prototype=Object.create(THREE.Camera.prototype)).clone=function(){var e=new ge(2*this.right,2*this.top);return THREE.Camera.prototype.clone.call(this,e),e.position.copy(this.position),e.up.copy(this.up),this.target&&(e.target=this.target.clone()),this.worldup&&(e.worldup=this.worldup.clone()),e.left=this.left,e.right=this.right,e.top=this.top,e.bottom=this.bottom,e.near=this.near,e.far=this.far,e.fov=this.fov,e.aspect=this.aspect,e.zoom=this.zoom,e.orthoNear=this.orthoNear,e.perpNear=this.perpNear,e.isPerspective=this.isPerspective,this.updateProjectionMatrix(),e},ge.prototype.IsPerspective=function(){return this.isPerspective},ge.prototype.__computeFovPosition=function(e){var t,n;return Math.abs(this.fov-e)<=1e-4?this.position.clone():(t=this.target.clone().sub(this.position),n=THREE.Math.degToRad(this.fov),e=THREE.Math.degToRad(e),n=t.length()*Math.tan(.5*n)/Math.tan(.5*e),e=t.normalize().multiplyScalar(-n),this.target.clone().add(e))},ge.prototype.toPerspective=function(){!this.isPerspective&&this.saveFov&&(this.viewer.cameraControl&&this.viewer.cameraControl.adjustNearAndFar(),this.fov=this.saveFov,this.near=this.perpNear,2e3<this.far/this.near)&&(this.near=this.far/2e3),this.perspectiveCamera.aspect=this.aspect,this.perspectiveCamera.near=this.near,this.perspectiveCamera.far=this.far,this.perspectiveCamera.fov=this.fov/this.zoom,this.perspectiveCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspectiveCamera.projectionMatrix,this.projectionMatrixInverse.copy(this.projectionMatrix).invert(),this.isPerspective=!0},ge.prototype.toOrthographic=function(){var e,t,n;this.isPerspective&&(this.saveFov=this.fov,e=this.fov,this.fov=e,this.near=this.orthoNear),this.orthoScale=this.target.clone().sub(this.position).length(),this.aspect<1?t=(n=.5*this.orthoScale)/this.aspect:n=(t=.5*this.orthoScale)*this.aspect,this.left=this.orthographicCamera.left=-n,this.right=this.orthographicCamera.right=n,this.top=this.orthographicCamera.top=t,this.bottom=this.orthographicCamera.bottom=-t,this.orthographicCamera.near=this.near,this.orthographicCamera.far=this.far,this.orthographicCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthographicCamera.projectionMatrix,this.projectionMatrixInverse.copy(this.projectionMatrix).invert(),this.isPerspective=!1},ge.prototype.updateProjectionMatrix=function(){this.isPerspective?this.toPerspective():this.toOrthographic()},ge.prototype.setSize=function(e,t){this.aspect=e/t,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2},ge.prototype.setFov=function(e){this.fov=e,this.updateProjectionMatrix()},ge.prototype.setLens=function(e,t){void 0===t&&(t=24);t=2*THREE.Math.radToDeg(Math.atan(t/(2*e)));return this.setFov(t),t},ge.prototype.setCameraTarget=function(e){this.lookAt(e),this.target=e},ge.prototype.getCameraTarget=function(){return this.target},ge.prototype.adjustNearFar=function(e,t){var n;this.isPerspective?(this.far=t,this.near=.5,(2e3<this.far/this.near||this.far<=this.near)&&(this.near=this.far/2e3),n=(n=new THREE.Vector3).subVectors(this.viewer.controls.getBoundingBox().max,this.viewer.controls.getBoundingBox().min),this.near>.25*n.length()&&(this.near=.25*n.length())):(this.near=-t,this.far=t),this.updateProjectionMatrix()},ge.prototype.setFarNear=function(e,t){this.far=e,this.near=t},ge.prototype.setOrthoNear=function(e){e=e.min.distanceTo(e.max);-e<this.orthoNear&&(this.orthoNear=-e,this.isPerspective||(this.near=30*this.orthoNear))},ge.prototype.setZoomToFitRatio=function(e){this.zoomToFitRatio=e},ge.prototype.getZoomToFitRatio=function(){return this.zoomToFitRatio},ge.prototype.setOrginalCameraInfo=function(e){this.orginalCameraInfo=e},ge.prototype.getOrginalCameraInfo=function(){return this.orginalCameraInfo},ge.prototype.setCastRay=function(e,t,n){var i;this.isPerspective?((i=new THREE.Vector3(t,n,.5)).unproject(this),e.ray.origin=this.position.clone(),e.ray.direction=i.sub(this.position).normalize().clone()):(e.ray.origin.set(t,n,-1).unproject(this),e.ray.direction.set(0,0,-1).transformDirection(this.matrixWorld))},ge.prototype.setCastPolytopes=function(e,t,n,i,r){var o=new THREE.Vector3(t.x,t.y,-1).unproject(this),t=new THREE.Vector3(t.x,t.y,1).unproject(this),a=new THREE.Vector3(n.x,n.y,-1).unproject(this),n=(new THREE.Vector3(n.x,n.y,1).unproject(this),new THREE.Vector3(i.x,i.y,-1).unproject(this)),i=new THREE.Vector3(i.x,i.y,1).unproject(this),s=new THREE.Vector3(r.x,r.y,-1).unproject(this),r=new THREE.Vector3(r.x,r.y,1).unproject(this);e.push((new THREE.Plane).setFromCoplanarPoints(o,n,s)),e.push((new THREE.Plane).setFromCoplanarPoints(t,r,i)),e.push((new THREE.Plane).setFromCoplanarPoints(o,t,a)),e.push((new THREE.Plane).setFromCoplanarPoints(s,n,r)),e.push((new THREE.Plane).setFromCoplanarPoints(o,s,t)),e.push((new THREE.Plane).setFromCoplanarPoints(a,i,n))};function y(e){THREE.MeshBasicMaterial.call(this),this.depthTest=!1,this.depthWrite=!1,this.side=THREE.DoubleSide,this.transparent=!0,this.setValues(e),this.oldColor=this.color.clone(),this.oldOpacity=this.opacity,this.highlight=function(e){e?(this.color.setRGB(1,1,0),this.opacity=1):(this.color.copy(this.oldColor),this.opacity=this.oldOpacity)}}function E(e){THREE.LineBasicMaterial.call(this),this.depthTest=!1,this.depthWrite=!1,this.transparent=!0,this.linewidth=1,this.setValues(e),this.oldColor=this.color.clone(),this.oldOpacity=this.opacity,this.highlight=function(e){e?(this.color.setRGB(1,1,0),this.opacity=1):(this.color.copy(this.oldColor),this.opacity=this.oldOpacity)}}function A(){this.init=function(){THREE.Object3D.call(this),this.handles=new THREE.Object3D,this.pickers=new THREE.Object3D,this.planes=new THREE.Object3D,this.add(this.handles),this.add(this.pickers),this.add(this.planes);var a,e=new THREE.PlaneGeometry(50,50,2,2),t=new THREE.MeshBasicMaterial({visible:!1,side:THREE.DoubleSide}),n={XY:new THREE.Mesh(e,t),YZ:new THREE.Mesh(e,t),XZ:new THREE.Mesh(e,t),XYZE:new THREE.Mesh(e,t)};for(a in this.activePlane=n.XYZE,n.YZ.rotation.set(0,Math.PI/2,0),n.XZ.rotation.set(-Math.PI/2,0,0),n)n[a].name=a,this.planes.add(n[a]),this.planes[a]=n[a];function i(e,t){for(var n in e)for(a=e[n].length;a--;){var i=e[n][a][0],r=e[n][a][1],o=e[n][a][2];i.name=n,r&&i.position.set(r[0],r[1],r[2]),o&&i.rotation.set(o[0],o[1],o[2]),t.add(i)}}i(this.handleGizmos,this.handles),i(this.pickerGizmos,this.pickers),this.traverse(function(e){var t;e instanceof THREE.Mesh&&(e.updateMatrix(),(t=e.geometry.clone()).applyMatrix(e.matrix),e.geometry=t,e.position.set(0,0,0),e.rotation.set(0,0,0),e.scale.set(1,1,1))})},this.highlight=function(t){this.traverse(function(e){e.material&&e.material.highlight&&(e.name===t?e.material.highlight(!0):e.material.highlight(!1))})}}function q(e,t){function n(e,t){var n=new Image,i=(n.crossOrigin="anonymous",new THREE.Texture(n));switch(e){case 0:n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGuSURBVDhPpZK/SwJxGMbPkwYVAg0CHcIlECPEU8iisS2i0Yi2hiiiKWpoiH6ttRQRDTk4RP9EtAQhJxYhRkNGQ9MRhIQEZp/3zs47bfOBh/e95/3h931flV7haVlF07QBj8ezhftpGMZutVr9sSJtkDNNzlSz2cwXi0VdNNWMAAQD0we3Q6HQuik6QHGM4kvcdL1eL1mqo0ELm7BC4l4qldIsiYp0OoC5gt9wvlwuN0QXuBrouv6FWYAyWp4mftF58jFNR3EXyXkT7Q/elrXxDiKRiMyfhYFwODxI8Q7+CcWHkuOEvUQn4vG41+fz3eCOwxp8aTQamVKpVJe4E/82ELC0YX65gqsyQoYl31kRNzqXaINiGcGM46+K/Q9dOxCw9UlMDl7DVzjLXp5YzyO+C10jJJPJoKqqcud++TRFRbmHcrpE5xW6RqD4HDMEl0muCtmBjBCEuWg06qpxjcDilph3A/eCwgNLNU/7wAgx3Bm/31/j+9aKOF5A8QjFR7jPnGzNUtvgZSsYef4+f7CEKQK7AcUTmDOem+XecnsXCoXCB7E53FM4Zoq9Q1F+AdSNjQGiWI24AAAAAElFTkSuQmCC";break;case 1:n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEnSURBVDhP3ZM9S8RAEIbz0ZhAsEgj+QF6pDjyYWFj5Q/wbyhiIYetCCeWtoKVxZWW9gaxECTR7mwFIVWw0c4Qn8ntrYa7RsXGB968k8nuzDJhjd9iKjfSNN3GlpumGRVFkU+yXeI4XrEsa4twnOf5meQseSju0a5pmqMoihYmqU/CMLTZfE64g3QDXYCKt9gJ6tm2fdgmv+A4zh62ho5YO1tAqOv6AHtEgyRJVtskcPQeNkR3rDlukwo9gynMQrrcoDFKqqqqfd+/lk8oprk00NjKNWVZPgdBsEi4id5c1+3jMrh9Nl/iHWZOIHAKF3tAS+hdYs/zNrIsa4g7zC0gUGQdy9Ar6tP9SfLfgkG+UOhKvc6l8xd+wn8vwL045XJdqNe/wDA+AM+DTooKvznTAAAAAElFTkSuQmCC";break;case 2:n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE0SURBVDhPpZI9S8RAEIbzQRCLA8FeFPsYErk6jf4HLbQQwfZK7fTA2sbeRixsxcreIiQgthbXWUXRFHbGZ3aXkGA2V9wDwzs7w8zObOIsimtUkSTJGNnTJysfeZ5Pjd9tEMfxPnKtT11c1/WRETajwYYKQqeBjTRN3aqqbnFlugkNrlQCPKODUHyKSPFdu1iY24B32UEusFfWOFbBFoMrULyG5JjsP+b2N4m3sU4QhuESco+tYgd9xYK1QRAEsqt81inFDyrYQ28DPuchcoI9lmV5roIW/r0BxVs81jPuu+d521mWfepMP/I4DVEUrVD0hDuq63qX0Wc6Y6dZQX4W3/dvcDexo6IoXlRiDs0KcjsNZNxfbv/W0X5YcZ3pvpSvIsDuyyQuzXEQLjhjwh9zXATH+QMUOlTdo/cuSQAAAABJRU5ErkJggg=="}n.onload=function(){i.needsUpdate=!0,p.parent.dispatchEvent({type:"change"})},e=new THREE.SpriteMaterial({map:i,depthTest:!1,depthWrite:!1,transparent:!0}),(e=new THREE.Sprite(e)).scale.set(.2,.2,1),e.material.needsUpdate=!0,t(e)}var i=this,r=(A.call(this),!0),o=!0,a=!0;e&&(r=0<=e.indexOf("translateX"),o=0<=e.indexOf("translateY"),a=0<=e.indexOf("translateZ"));var s=(e=Se.isMobileDevice())?new THREE.CylinderGeometry(0,.08,.17,14,1,!1):new THREE.CylinderGeometry(0,.05,.2,12,1,!1);(h=new THREE.Mesh(s)).position.y=.5,h.updateMatrix(),s.applyMatrix(h.matrix),(h=new THREE.BufferGeometry).addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,1,0,0],3));(u=new THREE.BufferGeometry).addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,1,0],3));var l=new THREE.BufferGeometry,d=(l.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,0,1],3)),new THREE.CylinderGeometry(.02,.02,1.4,3)),c=e?.9:.5,h=e?[new THREE.Mesh(d,new y({color:16711680})),[.7,0,0],[0,0,Math.PI/2]]:[new THREE.Line(h,new E({color:16711680}))],u=e?[new THREE.Mesh(d,new y({color:65280})),[0,.7,0],[0,Math.PI/2,0]]:[new THREE.Line(u,new E({color:65280}))],d=e?[new THREE.Mesh(d,new y({color:255})),[0,0,.7],[Math.PI/2,0,0]]:[new THREE.Line(l,new E({color:255}))],p=(this.handleGizmos={},r&&(this.handleGizmos.X=[[new THREE.Mesh(s,new y({color:16711680})),[c,0,0],[0,0,-Math.PI/2]],h]),o&&(this.handleGizmos.Y=[[new THREE.Mesh(s,new y({color:65280})),[0,c,0]],u]),a&&(this.handleGizmos.Z=[[new THREE.Mesh(s,new y({color:255})),[0,0,c],[Math.PI/2,0,0]],d]),this);Se.isMobileDevice()||0==t||(n(0,function(e){e.position.set(1.3,0,0),e.name="xSprite",i.handleGizmos.X&&i.handleGizmos.X[0][0].add(e)}),n(1,function(e){e.position.set(0,1.3,0),e.name="ySprite",i.handleGizmos.Y&&i.handleGizmos.Y[0][0].add(e)}),n(2,function(e){e.position.set(0,0,1.3),e.name="zSprite",i.handleGizmos.Z&&i.handleGizmos.X&&i.handleGizmos.Y&&i.handleGizmos.Z[0][0].add(e)})),r&&o&&a&&(this.handleGizmos.XY=[[new THREE.Mesh(new THREE.PlaneGeometry(.29,.29),new y({color:16776960,opacity:.25})),[.15,.15,0]]],this.handleGizmos.YZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.29,.29),new y({color:65535,opacity:.25})),[0,.15,.15],[0,Math.PI/2,0]]],this.handleGizmos.XZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.29,.29),new y({color:16711935,opacity:.25})),[.15,0,.15],[-Math.PI/2,0,0]]]),this.pickerGizmos={},r&&(this.pickerGizmos.X=e?[[new THREE.Mesh(new THREE.CylinderGeometry(.22,.05,1.4+.4,4,1,!1),f),[(1.4+.4)/2,0,0],[0,0,-Math.PI/2]]]:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),f),[.6,0,0],[0,0,-Math.PI/2]]]),o&&(this.pickerGizmos.Y=e?[[new THREE.Mesh(new THREE.CylinderGeometry(.22,.05,1.4+.4,4,1,!1),f),[0,(1.4+.4)/2,0]]]:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),f),[0,.6,0]]]),a&&(this.pickerGizmos.Z=e?[[new THREE.Mesh(new THREE.CylinderGeometry(.22,.05,1.4+.4,4,1,!1),f),[0,0,(1.4+.4)/2],[Math.PI/2,0,0]]]:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),f),[0,0,.6],[Math.PI/2,0,0]]]),r&&o&&a&&(this.pickerGizmos.XYZ=[[new THREE.Mesh(new THREE.OctahedronGeometry(.2,0),f)]],this.pickerGizmos.XY=[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),f),[.2,.2,0]]],this.pickerGizmos.YZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),f),[0,.2,.2],[0,Math.PI/2,0]]],this.pickerGizmos.XZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),f),[.2,0,.2],[-Math.PI/2,0,0]]]),this.setActivePlane=function(e,t){var n=new THREE.Matrix4;t.applyMatrix4(n.getInverse(n.extractRotation(this.planes.XY.matrixWorld))),"X"===e&&(this.activePlane=this.planes.XY,Math.abs(t.y)>Math.abs(t.z))&&(this.activePlane=this.planes.XZ),"Y"===e&&(this.activePlane=this.planes.XY,Math.abs(t.x)>Math.abs(t.z))&&(this.activePlane=this.planes.YZ),"Z"===e&&(this.activePlane=this.planes.XZ,Math.abs(t.x)>Math.abs(t.y))&&(this.activePlane=this.planes.YZ),"XYZ"===e&&(this.activePlane=this.planes.XYZE),"XY"===e&&(this.activePlane=this.planes.XY),"YZ"===e&&(this.activePlane=this.planes.YZ),"XZ"===e&&(this.activePlane=this.planes.XZ)},this.showAxis=function(e,t){if(void 0!==e&&""!==e)switch(e){case"x":for(var n=0;n<this.handleGizmos.X.length;n++)this.handleGizmos.X[n][0].visible=t;this.pickerGizmos.X[0][0].visible=t;break;case"y":for(n=0;n<this.handleGizmos.Y.length;n++)this.handleGizmos.Y[n][0].visible=t;this.pickerGizmos.Y[0][0].visible=t;break;case"z":for(n=0;n<this.handleGizmos.Z.length;n++)this.handleGizmos.Z[n][0].visible=t;this.pickerGizmos.Z[0][0].visible=t}},this.init()}function K(){function e(e,t,n){var i=new THREE.BufferGeometry,r=[];n=n||1;for(var o=0;o<=64*n;++o)"x"===t&&r.push(0,Math.cos(o/32*Math.PI)*e,Math.sin(o/32*Math.PI)*e),"y"===t&&r.push(Math.cos(o/32*Math.PI)*e,0,Math.sin(o/32*Math.PI)*e),"z"===t&&r.push(Math.sin(o/32*Math.PI)*e,Math.cos(o/32*Math.PI)*e,0);return i.addAttribute("position",new THREE.Float32BufferAttribute(r,3)),i}A.call(this);var t=Se.isMobileDevice()?1.2:.7,n=new THREE.BufferGeometry,i=new Float32Array([-.1,0,0,0,.3,0,0,0,-.1,0,0,-.1,0,.3,0,.1,0,0,.1,0,0,0,.3,0,0,0,.1,0,0,.1,0,.3,0,-.1,0,0,-.1,0,0,0,-.3,0,0,0,-.1,0,0,-.1,0,-.3,0,.1,0,0,.1,0,0,0,-.3,0,0,0,.1,0,0,.1,0,-.3,0,-.1,0,0]),r=(n.addAttribute("position",new THREE.BufferAttribute(i,3)),new THREE.MeshBasicMaterial({color:16711680}));new THREE.Mesh(n,r).position.set(t,0,0),new THREE.Line(new e(t,"x",.5),new E({color:16711680})),new THREE.Line(new e(t,"y",.5),new E({color:65280})),new THREE.Line(new e(t,"z",.5),new E({color:255})),n.addAttribute("position",new THREE.BufferAttribute(i,3)),(r=new THREE.Mesh(n,new y({color:16711680}))).scale.set(.5,.5,.5),r.position.set(0,0,t),(i=new THREE.Mesh(n,new y({color:65280}))).scale.set(.5,.5,.5),i.rotateZ(Math.PI/2),i.position.set(0,0,t),(n=new THREE.Mesh(n,new y({color:255}))).scale.set(.5,.5,.5),n.position.set(t,0,0),Se.isMobileDevice()?this.handleGizmos={X:[[new THREE.Mesh(new THREE.TorusGeometry(t,.01,10,40,Math.PI),new y({color:16711680})),[0,0,0],[0,-Math.PI/2,-Math.PI/2]],[r]],Y:[[new THREE.Mesh(new THREE.TorusGeometry(t,.01,10,40,Math.PI),new y({color:65280})),[0,0,0],[Math.PI/2,0,0]],[i]],Z:[[new THREE.Mesh(new THREE.TorusGeometry(t,.01,10,40,Math.PI),new y({color:255})),[0,0,0],[0,0,-Math.PI/2]],[n]],XYZE:[[new THREE.Line(new e(.7,"z",1),new E({color:7895160}))]]}:this.handleGizmos={X:[[new THREE.Line(new e(.7,"x",.5),new E({color:16711680}))]],Y:[[new THREE.Line(new e(.7,"y",.5),new E({color:65280}))]],Z:[[new THREE.Line(new e(.7,"z",.5),new E({color:255}))]],XYZE:[[new THREE.Line(new e(.7,"z",1),new E({color:7895160}))]]},Se.isMobileDevice()?this.pickerGizmos={X:[[new THREE.Mesh(new THREE.TorusGeometry(t,.1,10,40,Math.PI),f),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.TorusGeometry(t,.1,10,40,Math.PI),f),[0,0,0],[Math.PI/2,0,0]]],Z:[[new THREE.Mesh(new THREE.TorusGeometry(t,.1,10,40,Math.PI),f),[0,0,0],[0,0,-Math.PI/2]]],XYZE:[[new THREE.Mesh(new THREE.Geometry)]]}:this.pickerGizmos={X:[[new THREE.Mesh(new THREE.TorusGeometry(.7,.12,4,12,Math.PI),f),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.TorusGeometry(.7,.12,4,12,Math.PI),f),[0,0,0],[Math.PI/2,0,0]]],Z:[[new THREE.Mesh(new THREE.TorusGeometry(.7,.12,4,12,Math.PI),f),[0,0,0],[0,0,-Math.PI/2]]],XYZE:[[new THREE.Mesh(new THREE.Geometry)]]},this.showAxis=function(e,t){if(void 0!==e&&""!==e)switch(e){case"x":this.handleGizmos.X[0][0].visible=t,this.handleGizmos.X[1][0].visible=t,this.pickerGizmos.X[0][0].visible=t;break;case"y":this.handleGizmos.Y[0][0].visible=t,this.handleGizmos.Y[1][0].visible=t,this.pickerGizmos.Y[0][0].visible=t;break;case"z":this.handleGizmos.Z[0][0].visible=t,this.handleGizmos.Z[1][0].visible=t,this.pickerGizmos.Z[0][0].visible=t}},this.setActivePlane=function(e){"E"===e&&(this.activePlane=this.planes.XYZE),"X"===e&&(this.activePlane=this.planes.YZ),"Y"===e&&(this.activePlane=this.planes.XZ),"Z"===e&&(this.activePlane=this.planes.XY)},this.update=function(e,t){A.prototype.update.apply(this,arguments);this.handles,this.pickers;var n=new THREE.Matrix4,i=new THREE.Euler(0,0,1),r=new THREE.Quaternion,o=new THREE.Vector3(1,0,0),a=new THREE.Vector3(0,1,0),s=new THREE.Vector3(0,0,1),l=new THREE.Quaternion,d=new THREE.Quaternion,c=new THREE.Quaternion,h=t.clone();i.copy(this.planes.XY.rotation),r.setFromEuler(i),n.makeRotationFromQuaternion(r).getInverse(n),h.applyMatrix4(n),this.traverse(function(e){r.setFromEuler(i),"X"===e.name&&(l.setFromAxisAngle(o,Math.atan2(-h.y,h.z)),r.multiplyQuaternions(r,l),e.quaternion.copy(r)),"Y"===e.name&&(d.setFromAxisAngle(a,Math.atan2(h.x,h.z)),r.multiplyQuaternions(r,d),e.quaternion.copy(r)),"Z"===e.name&&(c.setFromAxisAngle(s,Math.atan2(h.y,h.x)),r.multiplyQuaternions(r,c),e.quaternion.copy(r))})},this.init()}function J(){var n=this;THREE.Object3D.call(this),this._gizmoTranslate=new q,this._gizmoRotate=new K,this.add(this._gizmoTranslate),this.add(this._gizmoRotate),this._translatePickers=this._gizmoTranslate.pickers,this._rotatePickers=this._gizmoRotate.pickers,this.activePlane=this._gizmoTranslate.activePlane,this.highlight=function(e,t){"translate"==t?(this._gizmoRotate.highlight(null),this._gizmoTranslate.highlight(e)):"rotate"==t&&(this._gizmoTranslate.highlight(null),this._gizmoRotate.highlight(e))},this.setActivePlane=function(e,t){"translate"==n.pickType?(this._gizmoTranslate.setActivePlane(e,t),this.activePlane=this._gizmoTranslate.activePlane):"rotate"==n.pickType&&(this._gizmoRotate.setActivePlane(e,t),this.activePlane=this._gizmoRotate.activePlane)},this.update=function(e,t){this._gizmoTranslate.update(e,t),this._gizmoRotate.update(e,t)}}function ee(){A.call(this);var e=new THREE.BoxGeometry(.125,.125,.125),t=new THREE.Mesh(e);t.position.y=.5,t.updateMatrix(),e.applyMatrix4(t.matrix);(t=new THREE.BufferGeometry).addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,1,0,0],3));var n=new THREE.BufferGeometry,i=(n.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,1,0],3)),new THREE.BufferGeometry);i.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,0,1],3)),this.handleGizmos={X:[[new THREE.Mesh(e,new y({color:16711680})),[.5,0,0],[0,0,-Math.PI/2]],[new THREE.Line(t,new E({color:16711680}))]],Y:[[new THREE.Mesh(e,new y({color:65280})),[0,.5,0]],[new THREE.Line(n,new E({color:65280}))]],Z:[[new THREE.Mesh(e,new y({color:255})),[0,0,.5],[Math.PI/2,0,0]],[new THREE.Line(i,new E({color:255}))]],XYZ:[[new THREE.Mesh(new THREE.BoxGeometry(.125,.125,.125),new y({color:16777215,opacity:.25}))]]},this.pickerGizmos={X:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),f),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),f),[0,.6,0]]],Z:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),f),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new THREE.Mesh(new THREE.BoxGeometry(.4,.4,.4),f)]]},this.setActivePlane=function(e,t){var n=new THREE.Matrix4;t.applyMatrix4(n.getInverse(n.extractRotation(this.planes.XY.matrixWorld))),"X"===e&&(this.activePlane=this.planes.XY,Math.abs(t.y)>Math.abs(t.z))&&(this.activePlane=this.planes.XZ),"Y"===e&&(this.activePlane=this.planes.XY,Math.abs(t.x)>Math.abs(t.z))&&(this.activePlane=this.planes.YZ),"Z"===e&&(this.activePlane=this.planes.XZ,Math.abs(t.x)>Math.abs(t.y))&&(this.activePlane=this.planes.YZ),"XYZ"===e&&(this.activePlane=this.planes.XYZE)},this.init()}function Pe(u){for(var l,e,h=u.lights,o=u.camera,t=u.scene,p=(this.viewer=u,new THREE.Group),a=(p.name="lightctrls",t.add(p),null),a=u.canvas2D||u.canvas3D,c=[],f=null,m=null,d=null,g=null,v=null,A=null,y=null,E=null,M=null,w=null,b=null,x=null,t=h.length,n=!1,i=.7,s=(a.width,a.height),I=new Array(t),r=null,T=2,S=.7,B=1e3,P=this,C=(this._scene=p,this._transformScene=new THREE.Scene,new THREE.TextureLoader(new THREE.LoadingManager)),R=0;R<h.length;R++)h[R]._enabled=!0,h[R]._visible=!0,h[R]._iconVisible=!1,p.add(h[R]),null!=h[R]._followCamera&&1==h[R]._followCamera&&(e=new L(R),h[R]._followCameraListener=e,h[R].oldDir=h[R].target.getWorldPosition(),h[R].oldDir.sub(h[R].getWorldPosition()),h[R].oldDir.normalize(),P.viewer.addFrameListener(e));function O(e){if(null!=e)for(var t=0;t<e.children.length;t++)if(e.children[t]instanceof THREE.Sprite)return t;return-1}function F(e){if(null!=e)for(var t=0;t<e.children.length;t++)if("spotframe"==e.children[t].name)return t;return-1}function N(){this.run=function(){new THREE.Vector3;a.width,s=a.height;for(var e,t=0;t<I.length;t++)h[t]&&h[t]._enabled&&h[t]._iconVisible&&0<=(e=O(I[t]))&&(e=I[t].children[e],r=I[t].position.distanceTo(o.position)/30,"hemilightctrl"==e.name&&(r*=1.6),r=r/(s/1e3)*S,e.scale.x=e.scale.y=r,e.updateMatrixWorld(!0));for(var n,i,r,t=0;t<I.length;t++)h[t]._enabled&&h[t]._iconVisible&&(n=-1,(i=null)!=I[t]&&"spotlightgroup"==I[t].name?n=F(I[t]):null!=I[t]&&"dirlightgroup"==I[t].name&&(n=function(e){if(null!=e)for(var t=0;t<e.children.length;t++)if("sundir"==e.children[t].name)return t;return-1}(I[t])),0<=n)&&(i=I[t].children[n],r=(r=I[t].position.distanceTo(o.position)/30)/(s/1e3)*S,i.scale.x=i.scale.y=i.scale.z=r,i.updateMatrixWorld(!0));null!=x&&x.update()}}function L(i){this.run=function(){var e,t,n;u.controls instanceof He&&"DirectionalLight"==h[i].type&&(u.renderer.isInARModel||(n=o.getWorldDirection(new THREE.Vector3),t=o.up.clone(),n.normalize(),t.normalize(),n.negate(),t.multiplyScalar(.9),(e=new THREE.Vector3).addVectors(n,t),e.normalize(),e.negate(),t=(n=h[i]).target,n=n.position,t.position.set(n.x+e.x,n.y+e.y,n.z+e.z),t.updateMatrixWorld(!0)))}}function j(){(x=new z(c,a,u,P)).setSize(i),r=new N,P.viewer.addFrameListener(r);var e=O(I[0]);0<e&&x.attachTo(I[0].children[e]),u.render()}function _(){var e=new THREE.MeshBasicMaterial({color:6710886,wireframe:!0}),t=new THREE.CylinderGeometry(.1,.6,.8,20,1,!0),t=new THREE.Mesh(t,e);return t.position.set(0,0,0),t.name="spotframe",t}function V(e){null==b&&(b=new THREE.SpriteMaterial({map:w,side:THREE.DoubleSide,transparent:!0}));var t=h[e],n=new THREE.Sprite(b),i=(n.name="spotlightctrl",c.push(n),_()),r=(I[e]=new THREE.Group,I[e].name="spotlightgroup",I[e].index=e,I[e].position.copy(t.position),t.position.x),o=t.position.y,a=t.position.z,s=t.target.position.x,l=t.target.position.y,d=t.target.position.z,s=new THREE.Vector3(s-r,l-o,d-a),r=(s.normalize(),new THREE.Quaternion),l=new THREE.Vector3(0,-1,0),o=s,d=(t.position.set(0,0,0),t.target.position.set(0,-1,0),I[e].add(n),I[e].add(i),I[e].add(t.target),I[e].add(t),r.setFromUnitVectors(l,o),I[e].quaternion);d.multiplyQuaternions(r,d),d.normalize(),I[e].setRotationFromQuaternion(d),p.add(I[e]),h[e]._iconVisible=!0,I[e].updateMatrixWorld(!0)}function k(e){null==g&&(g=new THREE.SpriteMaterial({map:v,side:THREE.DoubleSide,transparent:!0}));var t=h[e],n=new THREE.Sprite(g);n.name="pointlightctrl",c.push(n),I[e]=new THREE.Group,I[e].name="pointlightgroup",I[e].position.copy(t.position),t.position.set(0,0,0),I[e].add(n),I[e].add(t),p.add(I[e]),h[e]._iconVisible=!0,I[e].updateMatrixWorld(!0)}function U(e){null==y&&(y=new THREE.SpriteMaterial({map:E,side:THREE.DoubleSide,transparent:!0}));var t=h[e],n=new THREE.Sprite(y);n.name="hemilightctrl",c.push(n),I[e]=new THREE.Group,I[e].name="hemilightgroup",I[e].position.copy(t.position),t.position.set(0,0,0),I[e].add(n),I[e].add(t),p.add(I[e]),h[e]._iconVisible=!0,I[e].updateMatrixWorld(!0)}function G(e){null==f&&(f=new THREE.SpriteMaterial({map:m,side:THREE.DoubleSide,transparent:!0}));var t=h[e],n=new THREE.Sprite(f),i=(n.name="dirlightctrl",c.push(n),new THREE.Geometry),r=(i.vertices.push(new THREE.Vector3(0,0,0)),t.position.x),o=t.position.y,a=t.position.z,s=t.target.position.x,l=t.target.position.y,d=t.target.position.z,s=new THREE.Vector3(s-r,l-o,d-a),r=((s=s.normalize()).x*=T,s.y*=T,s.z*=T,i.vertices.push(new THREE.Vector3(s.x,s.y,s.z)),new THREE.LineBasicMaterial({linewidth:1,color:16776960})),l=new THREE.Line(i,r);l.name="sundir",t.target.position.copy(s),I[e]=new THREE.Group,I[e].name="dirlightgroup",I[e].index=e,I[e].position.copy(t.position),t.position.set(0,0,0),I[e].add(n),I[e].add(t.target),I[e].add(t),I[e].add(l),p.add(I[e]),h[e]._iconVisible=!0,I[e].updateMatrixWorld(!0)}function D(e){for(var t=0;t<c.length;t++)if(e==c[t]){c.splice(t,1);break}}function H(e){for(var t=0;t<h.length;t++)if(e==h[t])return t}this.loadTextures=function(e){var t=this.viewer.serverUrl||"./";m=C.load(t+"img/sun.png",function(){E=C.load(t+"img/hemi.png",function(){v=C.load(t+"img/lamp.png",function(){w=C.load(t+"img/spotlight.png",function(){null!=e&&e()})})})})},this.renderLight=function(){this._transformScene&&this.viewer.renderer.render(this._transformScene,this.viewer.camera)},this.resetPosition=function(){for(var e=u.controls.getBoundingBox(),t=e.min.x,n=e.min.y,i=e.min.z,r=e.max.x,o=e.max.y,a=e.max.z,s=new Array(3),l=(s[0]=o-n,s[1]=r-t,s[2]=a-i,s[0]),d=0;d<3;d++)s[d]>l&&(l=s[d]);B=4*l,l/=10,P.setDirLength(2);for(var c=0;c<h.length;c++)0==c?(h[0]._iconVisible?(I[0].position.set(t+(r-t)/2,o+l,i-l),I):(h[0].position.set(t+(r-t)/2,o+l,i-l),h))[0].updateMatrixWorld(!0):1==c?(h[1]._iconVisible?(I[1].position.set(r+l,o+l,i+(a-i)/2),I):(h[1].position.set(r+l,o+l,i+(a-i)/2),h))[1].updateMatrixWorld(!0):2==c&&((h[2]._iconVisible?(I[2].position.set(t-l,o+l,i+(a-i)/2),I):(h[2].position.set(t-l,o+l,i+(a-i)/2),h))[2].updateMatrixWorld(!0),h[2]._distance=50,h[2].distance=h[2]._distance/100*B);u.render()},this.computeMaxdistance=function(){for(var e=u.controls.getBoundingBox(),t=e.min.x,n=e.min.y,i=e.min.z,r=e.max.x,o=e.max.y,e=e.max.z,a=new Array(3),s=(a[0]=o-n,a[1]=r-t,a[2]=e-i,a[0]),l=0;l<3;l++)a[l]>s&&(s=a[l]);B=4*s;for(l=0;l<h.length;l++)"PointLight"==h[l].type?P.setPointLightParam(h[l]._distance):"SpotLight"==h[l].type&&P.setSpotLightParam(h[l]._distance)},this.getMaxdistance=function(){return B},this.setMaxdistance=function(e){B=e},this.setIconVisible=function(e,t){if(null==e||!e._enabled)return!1;null==x&&(j(),x.isActive()||x.activate());var n=H(e),i=e.type;if(e._iconVisible!=t&&"DirectionalLight"!=i){if(t)switch(i){case"DirectionalLight":G(n);break;case"SpotLight":V(n);break;case"HemisphereLight":U(n);break;case"PointLight":k(n)}else{p.remove(I[n]);var r=O(I[n]),o=I[n].children[r],a=x.getCurrAttachObj();I[n]==a&&x.detach(),D(o),e.position.copy(I[n].position),"DirectionalLight"!=i&&"SpotLight"!=i||(a=e.target.getWorldPosition(),e.target.position.copy(a),p.add(e.target),e.target.updateMatrixWorld(!0)),p.add(e),e.updateMatrixWorld(!0),e._iconVisible=t}h[n]._iconVisible&&(x.detach(),r=O(I[n]),x.attachTo(I[n].children[r])),u.render()}h[n]._iconVisible&&(x.detach(),r=O(I[n]),x.attachTo(I[n].children[r])),u.render()},this.setIconSize=function(e){S=e},this.setControlsSize=function(e){i=e,x.setSize(i)},this.setDirLength=function(e){T=e},this.getLightsCount=function(){return h.length},this.setVisible=function(e){if(e==n)return!1;for(var t=0;t<h.length;t++)h[t]._enabled&&this.setIconVisible(h[t],e);return x&&x.detach(),(n=e)?null==x||x.isActive()||x.activate():null!=x&&x.isActive()&&x.deactivate(),!0},this.getVisible=function(){for(var e=!1,t=0;t<h.length;t++)if(h[t]._iconVisible){e=!0;break}return e},this.dispose=function(){for(var e,t=0;t<h.length;t++)p.remove(I[t]),h[t].position.copy(I[t].position),"DirectionalLight"!=h[t].type&&"SpotLight"!=h[t].type||(e=h[t].target.getWorldPosition(),h[t].target.position.copy(e)),p.add(h[t]);c.splice(0,c.length),u.render()},this.switchLight=function(e,t){if(e<0||e>=h.length)return!1;if("None"==t)this.setIconVisible(h[e],!1),this.setLightEnabled(h[e],!1),h[e].type="None";else if(this.setLightEnabled(h[e],!0),h[e].type!=t){"DirectionalLight"==h[e].type&&h[e]._followCamera&&(P.viewer.removeFrameListener(h[e]._followCameraListener),h[e]._followCamera=null);var n,i=null,r=(h[e]._iconVisible?(i=I[e].position,p.remove(I[e]),n=O(I[e]),D(I[e].children[n])):(p.remove(h[e]),i=h[e].position),h[e]._iconVisible);switch(t){case"DirectionalLight":h[e]=new THREE.DirectionalLight(16777215,1),h[e]._enabled=!0,h[e]._visible=!0,h[e]._iconVisible=!1,h[e]._followCamera=!1,h[e].position.copy(i),p.add(h[e]),x.detach();break;case"PointLight":h[e]=new THREE.PointLight(16777215),h[e]._enabled=!0,h[e]._visible=!0,h[e]._iconVisible=!1,h[e]._distance=50,h[e].distance=.5*B,h[e].position.copy(i),r?k(e):p.add(h[e]);break;case"HemisphereLight":h[e]=new THREE.HemisphereLight(16777215,16777215,1),h[e]._enabled=!0,h[e]._visible=!0,h[e]._iconVisible=!1,h[e].position.copy(i),r?U(e):p.add(h[e]);break;case"SpotLight":h[e]=new THREE.SpotLight(16777215,1),h[e]._enabled=!0,h[e]._visible=!0,h[e]._iconVisible=!1,h[e]._distance=50,h[e].distance=.5*B,h[e].position.copy(i),h[e].target.position.set(i.x,i.y-1,i.z),r?V(e):p.add(h[e])}h[e]._iconVisible&&(x.detach(),n=O(I[e]),x.attachTo(I[e].children[n])),u.render()}return!0},this.addLight=function(e){for(var t=u.controls.getBoundingBox(),n=t.min.x,i=t.min.y,r=t.min.z,o=t.max.x,a=t.max.y,t=t.max.z,s=new Array(3),l=(s[0]=a-i,s[1]=o-n,s[2]=t-r,s[0]),d=0;d<3;d++)s[d]>l&&(l=s[d]);B=4*l,l/=10;var c=h.length;switch(e){case"DirectionalLight":h[c]=new THREE.DirectionalLight(16777215,1),h[c]._enabled=!0,h[c]._visible=!0,h[c]._iconVisible=!1,h[c]._followCamera=!1,h[c].position.set(1,2,0),p.add(h[c]);break;case"PointLight":h[c]=new THREE.PointLight(16777215),h[c]._enabled=!0,h[c]._visible=!0,h[c]._iconVisible=!1,h[c]._distance=50,h[c].distance=.5*B,h[c].position.set(0,0,0),p.add(h[c]);break;case"HemisphereLight":h[c]=new THREE.HemisphereLight(16777215,16777215,1),h[c]._enabled=!0,h[c]._visible=!0,h[c]._iconVisible=!1,h[c].position.set(0,5,0),p.add(h[c]);break;case"SpotLight":h[c]=new THREE.SpotLight(16777215,1),h[c]._enabled=!0,h[c]._visible=!0,h[c]._iconVisible=!1,h[c]._distance=50,h[c].distance=.5*B,h[c].position.set(10,10,10),h[c].target.position.set(10,9,10),p.add(h[c]);break;case"None":h[c]=new THREE.DirectionalLight(16777215,1),h[c]._enabled=!1,h[c]._visible=!1,h[c]._iconVisible=!1,h[c]._followCamera=!1,h[c].position.set(1,2,0),h[c].type="None"}h[c]&&(h[c].position.set(n+(o-n)/2+l*c,a+l,r-l+l*c),h[c].updateMatrixWorld(!0)),u.render()},this.removeLight=function(e){var t,e=H(e);"DirectionalLight"==h[e].type&&h[e]._followCamera&&(P.viewer.removeFrameListener(h[e]._followCameraListener),h[e]._followCamera=null),h[e]._iconVisible?(p.remove(I[e]),t=O(I[e]),D(I[e].children[t])):p.remove(h[e]),I.splice(e,1),h.splice(e,1);for(var n,i=0;i<h.length;i++)"DirectionalLight"==h[i].type&&h[i]._followCamera&&(P.viewer.removeFrameListener(h[i]._followCameraListener),n=new L(i),P.viewer.addFrameListener(n),h[i]._followCameraListener=n);x&&x.detach(),u.render()},this.getLightList=function(){return h},this.getLight=function(e){return e<0||e>=h.length?null:h[e]},this.showLightGizmo=function(e){var t,n;e._enabled&&e._iconVisible&&(n=H(e),t=O(I[n]),n=I[n].children[t],e._enabled?x.attachTo(n):x.detach())},this.getLightEnabled=function(e){if(null!=e)return e._enabled},this.setLightVisible=function(e,t){if(null==e)return!1;if(e._visible==t)return!0;if("DirectionalLight"==e.type)return!0;e._visible=t;var n=H(e),i=e.type;if(t){switch(i){case"DirectionalLight":null==f&&(f=new THREE.SpriteMaterial({map:m,side:THREE.DoubleSide,transparent:!0})),(a=new THREE.Sprite(f)).name="dirlightctrl";break;case"HemisphereLight":null==y&&(y=new THREE.SpriteMaterial({map:E,side:THREE.DoubleSide,transparent:!0})),(a=new THREE.Sprite(y)).name="hemilightctrl";break;case"PointLight":null==g&&(g=new THREE.SpriteMaterial({map:v,side:THREE.DoubleSide,transparent:!0})),(a=new THREE.Sprite(g)).name="pointlightctrl";break;case"SpotLight":null==b&&(b=new new THREE.SpriteMaterial({map:w,side:THREE.DoubleSide,transparent:!0})),(a=new THREE.Sprite(b)).name="spotlightctrl";var r=_();I[n].add(r)}o=O(I[n]);I[n].remove(I[n].children[o]),I[n].add(a),I[n].add(e),c.push(a)}else{I[n].remove(e);var o=O(I[n]),a=(D(I[n].children[o]),null);switch(i){case"DirectionalLight":null==d&&(d=new THREE.SpriteMaterial({map:null,side:THREE.DoubleSide,transparent:!0})),a=new THREE.Sprite(d);break;case"HemisphereLight":null==M&&(M=new THREE.SpriteMaterial({map:null,side:THREE.DoubleSide,transparent:!0})),a=new THREE.Sprite(M);break;case"PointLight":null==A&&(A=new THREE.SpriteMaterial({map:void 0,side:THREE.DoubleSide,transparent:!0})),a=new THREE.Sprite(A);break;case"SpotLight":null==l&&(l=new THREE.SpriteMaterial({map:void 0,side:THREE.DoubleSide,transparent:!0}));var a=new THREE.Sprite(l),s=F(I[n]);I[n].remove(I[n].children[s])}x.getCurrAttachObj()==I[n]&&x.detach();var o=O(I[n]);I[n].remove(I[n].children[o]),I[n].add(a)}},this.setLightEnabled=function(e,t){if(null==e)return!1;var n=H(e);if(e._enabled!=t){e._enabled=t;var i,r,o=e.type;switch(o){case"DirectionalLight":t?(e._iconVisible?p.add(I[n]):(p.add(e),p.add(e.target)),e._followCamera&&(i=new L(n),P.viewer.addFrameListener(i),e._followCameraListener=i)):(e._followCamera&&P.viewer.removeFrameListener(e._followCameraListener),e._iconVisible?p.remove(I[n]):(p.remove(e),p.remove(e.target)));break;case"PointLight":case"SpotLight":case"HemisphereLight":t?e._iconVisible?p.add(I[n]):(p.add(e),"SpotLight"==o&&p.add(e.target)):e._iconVisible?p.remove(I[n]):(p.remove(e),"SpotLight"==o&&p.remove(e.target))}t&&e._iconVisible?(r=O(I[n]),x.attachTo(I[n].children[r])):!t&&e._iconVisible&&null!=x&&x.getCurrAttachObj()==I[n]&&x.detach(),t&&P.setIconVisible(e,!0),u.render()}return!0},this.getLightParam=function(e){switch(e.type){case"PointLight":return this.getPointLightParam(e);case"DirectionalLight":return this.getDirLightParam(e);case"SpotLight":return this.getSpotLightParam(e);case"HemisphereLight":return this.getHemiLightParam(e);default:return null}},this.getPointLightParam=function(e){var t,n,i,r={};if(null!=e&&"PointLight"==e.type)return r.color=e.color.getHex(),r.intensity=e.intensity,r.distance=e._distance,t=new THREE.Vector3,n=new THREE.Quaternion,i=new THREE.Vector3,e.matrixWorld.decompose(t,n,i),r.position={},r.position.x=t.x,r.position.y=t.y,r.position.z=t.z,r.iconVisible=e._iconVisible,r},this.setPointLightParam=function(e,t){var n,i,r;return void 0!==t&&null!=e&&!!e._enabled&&"PointLight"==e.type&&(n=!1,i=H(e),e._visible&&(null!=t.color&&"null"!=t.color&&(r=parseInt(t.color),e.color=new THREE.Color(r),n=!0),null!=t.intensity&&"null"!=t.intensity&&(r=parseFloat(t.intensity),e.intensity=r,n=!0),null!=t.distance&&"null"!=t.distance&&(r=parseFloat(t.distance),e._distance=r,e.distance=r/100*B+.1,n=!0),null!=t.position)&&"null"!=t.position&&(r=null,r="[object String]"===Object.prototype.toString.call(t.position)?JSON.parse(t.position):t.position,(e._iconVisible?(I[i].position.set(r.x,r.y,r.z),I[i]):(e.position.set(r.x,r.y,r.z),e)).updateMatrixWorld(!0),n=!0),null!=t.visible&&"null"!=t.visible&&(i=null,"[object String]"===Object.prototype.toString.call(t.visible)?"true"==t.visible?i=!0:"false"==t.visible&&(i=!1):i=t.visible,this.setLightVisible(e,i),n=!0),null!=t.iconVisible&&"null"!=t.iconVisible&&(r=null,"[object String]"===Object.prototype.toString.call(t.iconVisible)?"true"==t.iconVisible?r=!0:"false"==t.iconVisible&&(r=!1):r=t.iconVisible,this.setIconVisible(e,r),n=!0),u.render(),n)},this.getDirLightParam=function(e){var t={};if(null!=e&&("DirectionalLight"==e.type||"None"==e.type))return t.color=e.color.getHex(),t.intensity=e.intensity,t.followCamera=e._followCamera,t.position={},t.position.x=e.position.x,t.position.y=e.position.y,t.position.z=e.position.z,t.target={},t.target.x=e.target.position.x,t.target.y=e.target.position.y,t.target.z=e.target.position.z,t.iconVisible=e._iconVisible,t.rotate=e.rotate,t.bias=e.bias,t},this.setDirLightParam=function(e,t){var n,i,r,o,a,s,l,d,c,h;return void 0!==t&&null!=e&&(n=H(e),!!e._enabled)&&"DirectionalLight"==e.type&&(i=!1,e._visible&&(null!=t.color&&"null"!=t.color&&(h=parseInt(t.color),e.color=new THREE.Color(h),i=!0),null!=t.intensity&&"null"!=t.intensity&&(h=parseFloat(t.intensity),e.intensity=h,i=!0),null!=t.followCamera&&"null"!=t.followCamera&&(h=null,"[object String]"===Object.prototype.toString.call(t.followCamera)?"true"==t.followCamera?h=!0:t.followCamera:h=t.followCamera,h?e._followCamera||(c=new L(n),e._followCameraListener=c,e.oldDir=e.target.getWorldPosition(),e.oldDir.sub(e.getWorldPosition()),e.oldDir.normalize(),P.viewer.addFrameListener(c),u.render()):e._followCamera&&(P.viewer.removeFrameListener(e._followCameraListener),c=new THREE.Vector3,void 0===e.oldDir&&(e.oldDir=e.target.getWorldPosition(),e.oldDir.sub(e.getWorldPosition()),e.oldDir.normalize()),c.addVectors(e.getWorldPosition(),e.oldDir),e.target.position.copy(c),e.target.updateMatrixWorld(!0),e._iconVisible)&&(c=x.getCurrAttachObj()==I[n],p.remove(I[n]),0<=(a=O(I[n]))&&D(I[n].children[a]),e.position.copy(I[n].position),G(n),c)&&0<=(a=O(I[n]))&&(c=I[n].children[a],x.attachTo(c)),e._followCamera=h,i=!0),null!=t.position&&"null"!=t.position&&(s=null,s="[object String]"===Object.prototype.toString.call(t.position)?JSON.parse(t.position):t.position,(e._iconVisible?(I[n].position.set(s.x,s.y,s.z),I[n]):(e.position.set(s.x,s.y,s.z),e)).updateMatrixWorld(!0),i=!0),null!=t.target&&"null"!=t.target&&t.position&&(l=null,l="[object String]"===Object.prototype.toString.call(t.target)?JSON.parse(t.target):t.target,e._iconVisible?(d=I[n].position,e.target.position.set(l.x-d.x,l.y-d.y,l.z-d.z)):e.target.position.set(l.x,l.y,l.z),e.target.updateMatrixWorld(!0),i=!0),null!=t.rotate&&"null"!=t.rotate&&((r=e.target.getWorldPosition()).sub(e.getWorldPosition()),r.normalize(),(o=new THREE.Vector3(-1,-1,0)).applyAxisAngle(new THREE.Vector3(0,1,0),t.rotate*Math.PI/180),o.normalize(),s=new THREE.Vector3,e._iconVisible?s.copy(I[n].position):s.copy(e.position),l=s.add(o),e._iconVisible?(d=I[n].position,e.target.position.set(l.x-d.x,l.y-d.y,l.z-d.z)):e.target.position.set(l.x,l.y,l.z),e.target.updateMatrixWorld(!0),e.rotate=t.rotate),null!=t.bias)&&"null"!=t.bias&&((r=e.target.getWorldPosition()).sub(e.getWorldPosition()),r.normalize(),o=new THREE.Vector3(r.x,0,r.z),a=(new THREE.Vector3).crossVectors(o,r),o.applyAxisAngle(a,t.bias*Math.PI/180),o.normalize(),s=new THREE.Vector3,e._iconVisible?s.copy(I[n].position):s.copy(e.position),l=s.add(o),e._iconVisible?(d=I[n].position,e.target.position.set(l.x-d.x,l.y-d.y,l.z-d.z)):e.target.position.set(l.x,l.y,l.z),e.target.updateMatrixWorld(!0),e.bias=t.bias),null!=t.visible&&"null"!=t.visible&&(c=null,"[object String]"===Object.prototype.toString.call(t.visible)?"true"==t.visible?c=!0:"false"==t.visible&&(c=!1):c=t.visible,this.setLightVisible(e,c),i=!0),null!=t.iconVisible&&"null"!=t.iconVisible&&(h=null,"[object String]"===Object.prototype.toString.call(t.iconVisible)?"true"==t.iconVisible?h=!0:"false"==t.iconVisible&&(h=!1):h=t.iconVisible,this.setIconVisible(e,h),i=!0),u.render(),i)},this.getSpotLightParam=function(e){var t,n,i,r={};if(null!=e&&"SpotLight"==e.type)return r.color=e.color.getHex(),r.intensity=e.intensity,r.distance=e._distance,r.angle=e.angle,r.penumbra=e.penumbra,t=new THREE.Vector3,n=new THREE.Quaternion,i=new THREE.Vector3,e.matrixWorld.decompose(t,n,i),r.position={},r.position.x=t.x,r.position.y=t.y,r.position.z=t.z,r.target={},e.target.matrixWorld.decompose(t,n,i),r.target.x=t.x,r.target.y=t.y,r.target.z=t.z,r.iconVisible=e._iconVisible,r},this.setSpotLightParam=function(e,t){var n,i,r;return void 0!==t&&null!=e&&!!e._enabled&&"SpotLight"==e.type&&(i=H(e),n=!1,e._visible&&(null!=t.color&&"null"!=t.color&&(r=parseInt(t.color),e.color=new THREE.Color(r),n=!0),null!=t.intensity&&"null"!=t.intensity&&(r=parseFloat(t.intensity),e.intensity=r,n=!0),null!=t.distance&&"null"!=t.distance&&(r=parseFloat(t.distance),e._distance=r,e.distance=r/100*B+.1,n=!0),null!=t.angle&&"null"!=t.angle&&(r=parseFloat(t.angle),e.angle=r,n=!0),null!=t.penumbra&&"null"!=t.penumbra&&(r=parseFloat(t.penumbra),e.penumbra=r,n=!0),null!=t.position&&"null"!=t.position&&(r=null,r="[object String]"===Object.prototype.toString.call(t.position)?JSON.parse(t.position):t.position,(e._iconVisible?(I[i].position.set(r.x,r.y,r.z),I[i]):(e.position.set(r.x,r.y,r.z),e)).updateMatrixWorld(!0),n=!0),null!=t.target)&&"null"!=t.target&&t.position&&(r=null,r="[object String]"===Object.prototype.toString.call(t.target)?JSON.parse(t.target):t.target,e._iconVisible?(i=I[i].position,e.target.position.set(r.x-i.x,r.y-i.y,r.z-i.z)):e.target.position.set(r.x,r.y,r.z),e.target.updateMatrixWorld(!0),n=!0),null!=t.visible&&"null"!=t.visible&&(i=null,"[object String]"===Object.prototype.toString.call(t.visible)?"true"==t.visible?i=!0:"false"==t.visible&&(i=!1):i=t.visible,this.setLightVisible(e,i),n=!0),null!=t.iconVisible&&"null"!=t.iconVisible&&(r=null,"[object String]"===Object.prototype.toString.call(t.iconVisible)?"true"==t.iconVisible?r=!0:"false"==t.iconVisible&&(r=!1):r=t.iconVisible,this.setIconVisible(e,r),n=!0),u.render(),n)},this.getHemiLightParam=function(e){var t,n,i,r={};if(null!=e&&"HemisphereLight"==e.type)return r.skyColor=e.color.getHex(),r.groundColor=e.groundColor.getHex(),r.intensity=e.intensity,t=new THREE.Vector3,n=new THREE.Quaternion,i=new THREE.Vector3,e.matrixWorld.decompose(t,n,i),r.position={},r.position.x=t.x,r.position.y=t.y,r.position.z=t.z,r.iconVisible=e._iconVisible,r},this.setHemiLightParam=function(e,t){var n,i,r;return void 0!==t&&null!=e&&!!e._enabled&&"HemisphereLight"==e.type&&(n=!1,i=H(e),e._visible&&(null!=t.skyColor&&"null"!=t.skyColor&&(r=parseInt(t.skyColor),e.color=new THREE.Color(r),n=!0),null!=t.groundColor&&"null"!=t.groundColor&&(r=parseInt(t.groundColor),e.groundColor=new THREE.Color(r),n=!0),null!=t.intensity&&"null"!=t.intensity&&(r=parseFloat(t.intensity),e.intensity=r,n=!0),null!=t.position)&&"null"!=t.position&&(r=null,r="[object String]"===Object.prototype.toString.call(t.position)?JSON.parse(t.position):t.position,(e._iconVisible?(I[i].position.set(r.x,r.y,r.z),I[i]):(e.position.set(r.x,r.y,r.z),e)).updateMatrixWorld(!0),n=!0),null!=t.visible&&"null"!=t.visible&&(i=null,"[object String]"===Object.prototype.toString.call(t.visible)?"true"==t.visible?i=!0:"false"==t.visible&&(i=!1):i=t.visible,this.setLightVisible(e,i),n=!0),null!=t.iconVisible&&"null"!=t.iconVisible&&(r=null,"[object String]"===Object.prototype.toString.call(t.iconVisible)?"true"==t.iconVisible?r=!0:"false"==t.iconVisible&&(r=!1):r=t.iconVisible,this.setIconVisible(e,r),n=!0),u.render(),n)},this.setLightParam=function(e,t){if(null==e||null==t)return!1;switch(e.type){case"DirectionalLight":return setDirLightParam(e,t);case"SpotLight":return setSpotLightParam(e,t);case"PointLight":return setPointLightParam(e,t);case"HemisphereLight":return setHemiLightParam(e,t)}},this.isLightEditControlSelected=function(){return!(null==x||!x.isActive())&&x.isSelected()}}function Ce(e,t){function F(){f.style.opacity="1.0",x=!1,requestAnimationFrame(A.render)}function N(e){var t;x||A.viewCubeMenuOpen||(t=Math.max(4*Math.abs((e.clientX-u.x)/u.w-.5)-1,0),e=Math.max(4*Math.abs((e.clientY-u.y)/u.h-.5)-1,0),t=Math.max(0,Math.min(Math.sqrt(t*t+e*e),1)),f.style.opacity=1-t*(1-A.inactiveOpacity))}function j(){f.style.opacity=A.inactiveOpacity,x=!0,A.render()}var _,V,r,k,n,c,U,G,o,z,h,a,s,l,u,A=this,p=(this.viewer=e).cameraControl,W=e.camera,f=e.viewBoxDiv,i=(this.viewCubeMenuOpen=!1,{}),Y=(this.boxSize=void 0===t?235:t,A.currentFace="front",["top,front","top,right","top,left","top,back","bottom,front","bottom,right","bottom,left","bottom,back","left,front","front,right","right,back","back,left"]),X=["front,top,right","back,top,right","front,top,left","back,top,left","front,bottom,right","back,bottom,right","front,bottom,left","back,bottom,left"],y=null,d=(f.getBoundingClientRect(),A.camera=new THREE.PerspectiveCamera(45,window.innerWidth/window.innerHeight,1,2e3),this.originCamInfo={},[]),m=[],g=[],v=[],E=[],Q=null,Z=null,M=null,w=0,q=0,K=!0,J=!1,$=!1,ee=!1,b=!1,x=!1,I=[],te=(this.width=0,this.height=0,this.animSpeed=500,this.animate=!0,this.compass=!1,this.viewScaleFactorCompass=1.5,this.viewScale=1,this.draggable=!1,this.wantHomeButton=!1,this.wantRollArrows=!0,this.wantContextMenu=!1,this.inactiveOpacity=.5,this.getPicSrc=function(e){e=e.split("/"),e=e[e.length-1];return"VCarrows.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAArwAAAK8AFCrDSYAAAAIGNIUk0AAHxpAAB8jwAA/qkAAICUAAB5PAAA8TsAADeRAAAmhApr+WQAAAa2SURBVHja7J1PaJNnHMd/T5Jp98bM+i7TGrBZtzTtDoMGqlawUvQileKEIXqwOYkXRTxZFKQMlN6c6EXKDomHjl6cBMt2UMQeLBhIwUubZWtSR4wue42LeVddkmeHJKNIq++bv++f7wdCIeR9S9/vp7/f8z7v+z5hnHMC5sWCQwABAAQAEABAAAABAAQAEACYBpve/wDGGBHRV4yxY7zEOGI1eAUoh16h12KxHIvH492I0wQCMMaoMn3NGOu1WCzH4/F4d7FYRJpGF2C98HE9wwQCIHwTC4DwG3hstX4QVYRfdLvdsXV2Ey//zJRfKSLKcM5TEEDDAqj8zy+uV9GSyeQzIqJYLPY6k8kUwuFw/tGjR5ZoNGory5Eq/4xzzlcggD7LfrGalpZMJp+Fw+FX4XA4HwqFrJIk/UlEC0S0YIYKoYcWoLTnVyXAWkLcu3fvZTAYpGg0+rosw7xRZdB6C1Az4KuLAKuRJCl99+7dF2UZ0kQ0V64MKxBAW+E3RIDVxGKxp8Fg8FUgECiWRZgzggiaFcBqtX6XSCQ8Kmb4GipAhVwul52cnFwOBAIWSZIeE9EDPYuAClAl+Xz+zczMzNKZM2fe6rkiaPosgEoXelo2BlBTEa5evVogop855/MQoDUStESA1QPGS5cupUKhULIsQgoCNFeClgpQ4eHDh7+ePXs2L0nSLOf8AQSoIfhVE0FKJNCEAJW2cP78+UQoFJKI6EfOeQYCNF6CNa8FCIJQ6OnpKTgcDu7z+T7q6+sTOjs7BY/H42xGNThx4sQ/nPMJCNBgCYrFInV1dUWJaPydXbS/8+ogog5BEBz9/f35/fv3tw0ODm5plBButzuq5dvUmB4uqSqR4D0CrEcbEX1efvU6nU778PAw8/v9W+slw9jY2NdTU1Pfcs4XIUCDJahCAFqjUvQSUZ/T6fz09OnTG44ePdppt9s3GjV8XQnwIQkKhUKtAqymg4gGiKj38OHD1osXL+7Ytm3bJ0YLX3cCvE+CpaWlbrfbXS8BVreJASIaUCqCnsLXpQDrScAYO85LbzZiwPW/CKOjo7axsbEv12oNegtf8/MAGqSNiIYEQdh55cqVjUeOHPlCz+FDgNrGCN/4fD7x5s2bnbt27UoR0ZTewocAtTMkCMKgLMvTegxft2MAUD/wdDAEABpqez2MsXHGWB8EMGH4RHQ8EomIRHSQMdYOAUwWfiKR8Iqi6Lx169bHRHQMApgs/Mp7+/bt6x4ZGREZY0M4CzBZ+BVyuVx27969f0iSNNnI28tQATQYPhGR3W53XLt2zUZEB9ECTBb+O63A1cizArQAjYZfQZKktM/nSxLR94147gAVoMns3r37B6XhExGJoug8d+6clUpXI9EC9M6TJ09+ef78+d9qtjl58mQnEQ0wxtoggM6RZXn21KlTy2q2sdvtjuvXr28goiEIoH8eRCIR6fbt27+r2Wh4eLhLFMWd9a4CEKA1/HThwoU3uVzujdINbDbbRr/fX6z3WAACtIaULMuPJyYmfmv1WAACtLAVBIPBvJoBod1ud/j9fguVbl+HADpnhYjmLl++/FTNRqOjo5vr2QYgQGuZu3PnTkFNFfB4PDu8Xq+TMdYBAcxbBYiI+iCAgaqAmjOCQ4cOba3XOAACaKMKLExPTyueHBJF0en1ejfVow1AAI1UgRs3brytog30QgCDzAuk0+m/YrFYWukGBw4c2AIBjMV8IBB4ofTDLpdruyiKn9U6KQQBtMPCzMyMqpszRkZGClRa4AICGIBMOp3OqWkD/f39NghgsCowOzv7UoUAm6n0oCoEMAjx+/fvK77ty+VybUcFMJgA4XBY1Zd5er3efC3zARBAW6zIspxVMw7Ys2dPkUoLXEEAo8wJLC8vyyoHgqgARhJgfn5esQDt7e1WVACDnQ5GIpF/lX7Y4/FsggAGEyCbzTZtfRwbjrf2BFhcXLSqPBXMogIYSABZlq3N+mUQwORAAJODMUCLeN9T2c1cIxECtBDG2Hij9/WhL6uAAC1GzaPiavdRXj0dYwANM6UkpGoo73cKAmh7HLDYCAkq4StZvxgCGEwCNeFDAINJoDZ8CGAgCaoJHwIYRIJqw4cABpCglvAhgM4lqDV8CKBjCeoRPgTQqQT1Ch8C6FCCeoZPhLWCm07lSp/a415ZY5jq/PV0EMDkoAVAAAABAAQAEABAAAABAAQAEABAAAABAAQAEABAAAABAAQAEABAAAABAAQAEABAAAABAAQAEABAAAABAAQAEABAAAABAAQAEABAAAABAAQA2uS/AQBz1tjC7H2raAAAAABJRU5ErkJggg==":"VCarrowsS0.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAArwAAAK8AFCrDSYAAAAIGNIUk0AAHxpAAB8jwAA/qkAAICUAAB5PAAA8TsAADeRAAAmhApr+WQAAAcVSURBVHja7J1dTFNnGMf/L1SEFASPsPChwwVW2BIjRjclI5WEZDEKysUuWGbEjBBvMZsX04sREyIJWYLRiyWuiR/JNNwA05gtWYzItmiGtojLwDH5cE5kla9CKRV6dmG7oKvY057COaf/X9KE0PbQ9P/jeZ73bU8rZFkGiV3i+BRQAEIBCAUgFIBQAEIBCAUgMYNJzw8+oaYDAASAfQJolQF4bTsFYzVwBfCHHkAA2CsEWi8f2co0jS5AQk0HvLadgZ8D4bddObIVPmZpbAGWCp8vZxhcAIYfwwIw/BheBYQTfkLNjWDXBCbHQf/FAWDQa7M6Yl0AodX3A4QRvk8G4oKtAadm57sBYMg5OzHpnpcdQ66k7iFXzuOJufV+ORwArgO47rVZJyiAtkQItez7wmlpU7Pz3XeHXeOOIVfST33jhdOehUEAbQDaYqFCaFoAhT0/LAGCCXGjd3yivWs07/HE3IJfhrNGlUHLLUDpwKeKAIvxPPPd//He08d+GZ4CaPZXhgkKEH0B9imc9lUXYDGjU95bLTdH8H23s9AvQrMRRNCsAIk1HbLCHb6oChBg3ic/uvTLyMAV++imac/CWQD1ehaBFSBMZBlTP98fv9P43cAWPVcELW8EfSfLqCxvug2hwdf3hMCakoK1pW2fbZmuKs4qAzCYUHPjICuAzlcBkQyMTVcG3Lf6JycB1Oll1RDz+wBq0/PQ1dHQ9qBo2rPQ7LVZ6ylA+MEr3gnUSkub98mPTrQ/+OdW/6QAUOm1WQcpQJQl8AHY23Q7WK+eSkk0DSSuivNYssyzRblrkjZmJKUVZpsLlqMafHHpjyKvzZpGAaIswSIBXh4ZcwFsXHQpAlAkBKSMlITf389L9ZS+uy4zWkKUN92B12YVFCDKEiwhwKtIBVDqv1Sa4sSqd3KS+6utOarJUN50BwD2em3WyxQgyhKEIQCCVIpKAAdNcSJj1+b0/v0lOUXJifGpRg1fVwK8ToIFOWIBFrMZQB2Ayo0ZSfeOVeZtzEpbvd5o4etOgKUkuPz5VpSrJ8DiNlEHoC5UEfQUvi4FeIUE/50XoLIA/xNh04aU7mOVeUFbg97C1/w+gAZJBVAvBD795IPsu1XFWSV6Dp8CRDYjnF2TZBJf7S9cV3vmt/V6DJ8CRM6XgKjXa/gUQEU2bUjBiSpL0Os+LEzW7OPm2cEq0fPQhY+a7Zj2LOjqcVMAFfE88+Hg13fR+/dMeOVYiAIhRL0QoogC6FiCI9/2KpZACFEA4GO73S4B2CWESKMAOkWWoUiCQPhDQ0MWSZLSL1y4kASgigLEgASLww/8zmq1vl1RUSEJIUq5CtA5QgBz3+wMOfwAMzMzrpKSkr/GxsbOyLI8wgqg40qgNHwAMJvNKSdPnjQB2MUWYDBeF/5LrSA7mqsCChBlAi9aKQ0/wPHjxzP9q4JECmAAtm/fbgs1fACQJCn98OHD8QB2UACd//cDQE9Pzw9PnjyZUnKc2traNwHsiEYVoADLjNvt7jx06NCwkvuYzeaUU6dOJeD5+xcpgF7/+/1ct9vtY62trQ+UHG/37t1vSZL0ntpVgAKsDG1Hjx6dm5mZmQv1DiaTaXV1dbVP7VmAAqwMI263+9fGxsY/V3oWoADLW/5faAXnz5+fVzIQms3mlOrq6jgAhRRA/3gA3GxoaHio5E4HDhxIVbMNUICV5WZ7e/uCkiqQn5+/wWKxpAshMimAfst/pFUAeH6OIwUwShVQsiLYs2fPG2rNARRAG7NAb0tLS8ibQ5IkpVsslmQ12gAFWLny/0IVOH36tDeMNlBIAQyyL+B0Op/29/c7Q71DWVnZWgpgLBznzp0bDfXG2dnZWZIkZUS6KUQBtEPv1atXFb0/r6KiYgHPP/WEAhiACafTOaOkDWzbts1EAfQ/AL5QBTo7O8cVCJAKIJMCGIfBa9eueZTMAawABhOgq6tL0df4WCyW+Uj2AyiAtvC43W6XkjmguLjYByCNAhhoT2B4eNitcBBkBTCSAA6HI2QB0tLS4lkBDLYctNvtz0K9cX5+fjIFMJgALpdr2T5a1sTnW3sC9PX1xStcCrpYAQwkgNvtjl+uP0YBYhwKoBJ6/TwDzgArxFIfzCGW8VuyKMAKIoSoj/axZFmupwAaRsmp4kqPkZube58zgLa5GEpI4eA/7kUKoO05oC8aEgTC9x+fAmh5JaC2BErCpwAGqwRKw6cABpIgnPApgEbaQKQShBs+BTBAJYgkfAqgcwkiDZ8CaLANhCqBGuFTAJ1WArXCpwAarwLBJFAzfAqgz0qgWviATr85lKgHKwAFIBSAUABCAQgFIBSAUABCAQgFIBSAUABCAQgFIBSAUABCAQgFIBSAUABCAQgFIBSAUABCAQgFIBSAUABCAQgFIBSAUABCAQgFIBSAUACiTf4dAFchuSsaUf6VAAAAAElFTkSuQmCC":"VCarrowsS1.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAArwAAAK8AFCrDSYAAAAIGNIUk0AAHxpAAB8jwAA/qkAAICUAAB5PAAA8TsAADeRAAAmhApr+WQAAAarSURBVHja7N1daFNnHMfx/zlJ03hqajpDbREb4/omqE1cp91LtcguhjhbYZQKUwu5VRSGGChIN9ANBrM3uxBxLMVRGbsoi4o3Qs0clS1jccLWZSlNpk3LqllqW1trcp5dNBlFGpeTl+a8/L5QCtKkmP/H53nO6YscY4yQduPxEgAAAgAEAAgAEAAgAEAAgDSTXul/AY7jiIi2chzXxZbqxVhVvgIkh56qkef5rlAoVIdxagAAx3GUun3NcVwjz/OHQ6FQnSiKmKbaAaQbPr6eoQEAGL6GAWD4BXxt5f4iShi+aLVag2meJpR8H0u+TRJRjDE2CQAyBiDxX76YbkWLRCITRETBYHA2FoslfD5ffHh4mA8EAvokjsnk+xBjbAEAlLnsi9lsaZFIZMLn8037fL64x+PRRaPRKSIaIaIRLawQStgCMt3zswKwEohbt27909/fT4FAYDaJwa9WDHLfAqQc+PICYHnRaPTR9evX/05ieEREd5MrwwIAyGv4BQGwvGAw+KC/v3/a7XaLSQh31QBBtgB0Ot3H4XC4VsIdvoICSDU3Nzdz6dKlv9xuNx+NRn8ioiElQ8AKkGXxePzZjRs3xk6cOLGo5BVB1lcBtPSFnqKdAaSsCBcuXEgQ0U3GmB8AioOgKACWHxjPnj076fF4IkkIkwCwugiKCiCV1+v98+TJk/FoNPo9Y2wIAHIY/LIbQZkgkAWA1LZw5syZsMfjiRLRVcZYDAAKj2DFrwUIgpBoaGhImEwm5nA4Sux2u1BTUyPU1tZaVmM1OHLkyDxj7FMAKDACURTJZrMFiKj3hacwv/BWRURVgiCYmpub4/v27TO2trZWFAqE1WoNyPnb1DglfEk1EwQvAZAuIxFtTr41WiyWsv3793PHjh2rzBcGl8u1fWBg4H3G2B8AUGAEWQCgFVaKRiKyWyyW9cePHzd0dnbWlJWVlap1+IoC8H8IEolErgCWV0VELUTU2N7eruvp6dm0YcOGcrUNX3EAXoZgbGyszmq15gvA8m2ihYhaMoWgpOErEkA6BBzHHWZLf1iIA9d/EI4ePap3uVyvrrQ1KG34sr8PIMOMRNQmCMLr58+fLz106NAWJQ8fAHI7I3Q4HI5XLl68WLNr165JIhpQ2vABIPfaBEFoffr06TdKHL5izwAof+GngwEAySWD0/uewellBqe3GwA0OHwi+u7bU/YAEfUZnN7NAKCx4V87vZOMJXz9J111fiIaBACNDT/V9k2mvbtr1zGD09uLqwCNDT9VXGTjH3zx69rZhUTb4uU9fqwAGho+EZGe5zb2dGzxE1EftgCNDf+FrWBdIa8KAECmw091+oBNSF4VmAFAHWU8fCIiYwlf3/VG9X0iOgUAKojj2JOJ2LOHUh7T9WaVjYhOFWIVAIBVjjH6/MMrI4+lPEbPcxtdB22/UAG+1wEAVr+PnszH2dXhiTtSHvRWfcXOtUZdd75XAQAoTt1f/xDZMbuQmM5866DyA47KvJ8FAKA43WOMvjw3OOov9lkAAIpX7/0HM01SDoR6ntv4bpNlhIg6AED5TRNR37nB0ZCUB3W2VFE+twEAKG59oan5bVJWgcpyw+5qc+l6g9NrBwCNrgLtzZWjRNQNACpaBaRcEbyzbX11vs4BACCPVWDwyp3xjK8IjCV8fbW5VJePbQAAZLIK3Lz3qDaLbaADAFRyXyAusqmRyFzGP1uwp7HCDADq6iu3dzzjXyxVvkbftNao25zrTSEAkE+Dv4/PStoG3m6oGCGiNgBQR+G4yJ5L2QbsVtM8AKhsFRj67XHG28COGlMFEdkBQD0N/Tg6bZRyDiCivQCgIgBTM4tbpTyg2lz6MJf7AQAgr6YZo6iUc0CT1TROS7/pDABUkj80NR+TeBDECqAmAP7wk/lMP3idoOewAqirUGBibk2mH2y1rDEDgMoALDwXjav1yfR4veUHYGYhbpN4KYjLQBUVZozKV+uTAYDGAwCNhzNAkVq8nP4OrsF5GwC0kMF5O0+/noWlfa7Fy3s5AJBx106/VrDnOPDZzzgDyLyDmQwpm5LPexAA5H0O8BQCQWr4yecHAC0hkDJ8AFAZAqnDBwAVIchm+ACgEgTZDh8AVIAgl+EDgMIR5Dp8AFAwgnwMHwAUiiBfwwcABSLI5/ABQJkI8jZ8Ivx/AZoPKwAAIABAAIAAAAEAAgAEAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIAAAAEAAgAEAAgAEAAgAEAAgOTZvwMATRi8gArAJm8AAAAASUVORK5CYII=":"VCcontext.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAAIGNIUk0AAH7FAACLdgAA9UcAAIsOAABxUAAA6BUAADlYAAAfBMec4XAAAAEBSURBVHja7JcxCsIwFIb/V3oFx04v4iB4A3ev4Ak9iOABOhQcageHDh7iuVSwpW1eYmIFEwiFQvN9SZP/ERIRLNkyLNySQBLIhy+I6AhgE5F5FZHTpACAbV3X61h0Zs5nVwBAJiL0rd+eNuHvnQIArTEmplhrE7gAWEUUePSO/Vg1jJgFvQyYWoFoWTDMgLlNWDFzIyIUqjNzA6DSCpwBlMaYW4iZd+OU3bh2ARG5h5J4h3fj6nIghIQNbg2iTyQ0cFUS+kho4eoodpFwgTvVAo2EK9y5GM1J+MC9quGYhC98shaoPiQqAOwB7Hzhrxn1umMrABy6pxeT0t3w7wWeAwD5qe4YizvzugAAAABJRU5ErkJggg==":"VCcontextS.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAAIGNIUk0AAH7FAACLdgAA9UcAAIsOAABxUAAA6BUAADlYAAAfBMec4XAAAAEVSURBVHja7JcxDoJAEEX/rvY2HMEb6AEsaTDxBngKIzfgDBR6AxJtiI0egN7Ght6GWBIYGzVKQHaQDYU7yYSwxb5HMvs3CCJCnyXRcxkBIzAsLwyWpx0ARyNzn29m81oBAE60mmqj237smBkwAl9PAfIssv3Y1kbMs+j9VZQvIyHEGMBI40enRHSpFdCcBR8ZUJcD2rKgnAH1Q5gmnu3HXcOBNPGUBIrQDbqUeMKL0A2UBIjo2pXEO5yIrso50IVEE7wxiH6RUIErJWEbCVW4chRzJDhw1l2gIsGFPzdmNQBLLrZr6R7pcL69WrpHkovtGoDF2o8rUCXRFt5aoCzRFl4pwCwLwOTxBGOeXi3Mv+HfC9wHAAIQ03ZDDGqmAAAAAElFTkSuQmCC":"VCedge1.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB90BEBUkDgOwdkQAAADtSURBVHja7ZsxDoQgEEU/FCbsAWmoOJmVjfdz3VjIFmpizOoB9r/XGBMk8GEmwzCGXGqT9NHGKilIavtT5/dx6JN+kEud9za6fHslSGrj0L9u+pkkBcUu6Y51mY/+H8Yz7W3O42insR1zSsqlvmVKLvUdH1bLgRBPW9eRhgCYAAJ4gwA4QXMBBAAAzuzJDNu5EwkSCT7l3/5++buECSAAAiAAAngLsF01ebIuMxkhAABwhgoRboe5G+QwhAAIgADWAlAm5x4H2JuA9Q7gMAQAYA01QoTChMKkxDgO4wPwAdY7wNkPRHsnGNx/n/8CGU1kteidCpYAAAAASUVORK5CYII=":"VChome.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAAIGNIUk0AAH8nAAB4zgABAecAAH1lAAB+pAAA60MAADfoAAAl6h9/B7IAAAFxSURBVHja7JfNTcNAEEbfjK0IhOgBKSZpAKWLdEABlEQB3DnQBaKBRI6UDjig8BNld7lMJCeQZNfxwiUj+eCf2fe8sr+1JYTAf1bZpklEBLgBxnboCXgJLe6mbAkfAePZbHYN0O/3FVAReU6VkJTrm/C6rgfeewFQ1VBV1dRmIkkiWmAb7pzT5vmiKHwbCe0CDuCc07quB/ZcjKzneIEY+DES2hW8rYR2CW8joV3DUyU0BzxFQnPBYyU0JzxGQnPDD0mIbVnh+xJTgeKv4L/MRFGawLyqqt56RiaTyVUO+HA4nAPBtvlaIACPwIUtz3cJA228RBHiHrgHVsACCKXtvAHvwJldRMRA2xUi+16BT8ABqzKE4IFl422IrR8zENn3FUL4MB7ZH7pOvgdOAieBk0DO2vgvEJFz4BYYRITQb0F0KIymwEMziLYbesClrQt6AL5LQPbE8MJif7krPtUWpCIhWlOi29na41v9G+ao7wEA29D8X0f9dpYAAAAASUVORK5CYII=":"VChomeS.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAAIGNIUk0AAH8nAAB4zgABAecAAH1lAAB+pAAA60MAADfoAAAl6h9/B7IAAAF8SURBVHja7JdNTsJAFIC/eW1QYzyFV+ACLgS27q1hJ3gCjsAJUHdGDuCWIgkX4ABsPIOLxh9+2uemNQURaGnLhpfMos30fd+bSV87RlXZZ9hpHjLGGLl5vUXsewCCeTN4vnzUNNWoaqIBGHHcptSHOhh7Ohh7KvWhiuM2AZM0nySu3HEbWKVOv1X+vd9vlcEqdcRxG8YYkySn7ArfVUKygO8iIVnB00pIlvA0EpI1PKmE5AFPIiF5wbeVkDzh20hI3vBNElIEfJ2ECXt77vB4VNoj8Kd3Qbf6IIBVJDy+EoBlAxb+rFdpj2oLE/KqPAp/1osENOhWroFTwJb68C1RouXKNkTwdHEOzIEPQO3wwgM+geMCduAd+AZ8YG6ragBMo7ehAIGJqn6FvGQ/JHnEQeAgcBDYu4CJn6aMMSfi9F6wjqq50PyJG3RrV/FGtNz5SsBZ+F34b3U0NhaKiY2Vn4Gw/3tR52XFZAkPrNaaRGlDo/4fyvzdgn3EzwAYdgRqNummZQAAAABJRU5ErkJggg==":"back.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAVISURBVHhe7dx/aFVlHMfx73GXud9brIyVc63EICiFQMJoCRFSGLT+yBn0A2L9EBwOXVkt0zb3j6NJYdAigoqFEGo1NKhIsqh/Eu2PsCjbWM0gw91t3K5390fPOc+j1+nUhc/V55zP5wXn+D3PFTfv3rv3nrt75+UUIVhzzJ8EigGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYAjgGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYAjgGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYALhIBfHU0JW1tbZI4NGhWaLYi8WvivMZHRIY+NEd5W566V3Lzl0suk5JkKiMty+pkyco15lLyhT6AzsG4bH2gxhz9f1erraO3TxITY3rBiE8mpK93nZqu0wsRFeoAsmor8q5S++lfvMtliapnVUevJBMTZkUkrT6pxlhcntzUZ1bcFuoABo9MyndvPy/Hq2+S/lfWm9Ur7za1HQ7J1RrpXxXbM3BAkj/tlaLYXDn1n6ypLJP2DdvUdFwvFMCymMi3UwwglDa090hFdVJN554gVZWXyvrOfpHUUbMyMwYAyLv5MZFf3g/mMAXAJ4JsOTlphnBhAOAYADgGAI4B2DK3wgzhEsqzAM9bqPa/6QMH8Syg0GLXmoEuVTgDSIfzlMtFobwLaH/1HalO/67yVbe1DgieXu56VyR+JDjmM4GAvIUt6mHJzmDmYwBEUyfNEC4MwJbqSjOECwOwpLgqH4AXomuVAViSPeOh1HjK3/uvV3IfA7Akk8l/wePBPv8yMZcxAEsa6683k4g+OXXjFPViInEauH3nfvnn8GdSVFxiVgonlRFZXDsmq9ZtNyvaggdflpGPu4O5SG3p3M9qvyg4dpofQNjVrtjoR3zZthW1515td64ZmPZ3ctmD5hK3ReIuoKKs8N/5Zyqb4Qd/5Wcv/vWHGdzGxwCWlJaUm0nLHhsyk9siF4B/W5DLTfi30VY3KblHf4DzWHTHLWbS/uYtwJWRDvbHgr1V6X/NMLP6unlm0r7/4gczuY13AZYsmDf9qhwdP2EmtzEAS5bO9/f++xS13R8dNJPbGIAldf6u5vZg9n0ePB34azC7jAFYVN+03Exa8sAuM7mLAVj0cGurmbS+1143k7sYgEXPrJx+JrBjz59qP6UPHMUALPJfrC5Lnw5mn//lH/5grT5wFAOw7MWNXWbSnnj8LTMV4LkJCyIXgP4hbPCY3K5YqRkubGvzNWp/oz5Q9mdFxj55SU0F+JwsiFwA/q928LxKtXlWN0l+qT/ALKx+c4+ZtLube8zkHt4FFMDAs7eqff5W4Ed1K/B17/3myC0MoEBadpx1K9CxT+TEp+bIHZF4RdAND22R4d2bg9kvelv3WhlPq/viXCZYuxTqxl9iVeXS2fGGSHYkWGtuENk1dPGrzfPuUvtv9IEyurdb6u7zHw84xA8g7BqaN59+JU5x8F8a1RdYJMVNpz+GCsCsXtjASPDNFWyH+h81q26JxF3AZMJ/6KcFr8guxC+OTOX/zcQs35u62v8BUVOXPKceEixufU8vOiZSLwr1ikskFp+UTX0vqNVafaElp96QmsrFZnxR6PkMT4k0zBkWKVL3Gw7im0PB8SwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAKCJ/AegxeeFlLjG0gAAAABJRU5ErkJggg==":"down.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAOiSURBVHhe7d1PSBRhGMfxZ7IS80/aBhpBh7Q8BIEGYUHaIVAr6SaL1k3z2nWLbhXe6mjZKdBYOmq1HoL0kIfQbhGbHmMTNjW1pUSc3pl5it3NSpaCfef3+8C+887jRfE7ji6rOq4hBGuHHgkUAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAWRmA0xAVx3GserSWOvreFxcrA9hZu0939th/QDdFhrcAcFYGsLGwqDt7pFO6KTL8n0F5HKfRrMngxHBXEyIV7XoWPrwFZFnx12/++lMqrZtwYgDgGAA4BgCOAfw3q3osbgwAHHwA47NL5ke/MpEXt2SXzv6NSj0WN9gAkpvmU3S0U7pOeE8rf5WqczfFZGCU+isKyAA6+0elscSRtfcJnQR37N5Lh8y62z9HARXA6GTSfLmvlMTDXp3kWt+sMOvH4AQERADL5lHe0CG9Z72nedf8WbY681iZGZMnY2/Nbq8/QxH6AKKD41LjOJKZn9BJrpG+Dkm5rlQ2X9Sngjf8FUVoA5iac82X+zqJx7p0kuuUuezdxRnpGX6uE0yhDOB0dFDajngf2kIwyPNypE9epVyRmmad4ApVAM/eLJurvlym4zGd5Gqv3yOuuyRtPcM6odAE0NBxQy4015hdJhjkmX16XRJzX8yuOhiQz/oAxl+n/Kt+fuKOTnL9uOqbzt/WCWWzOgDvB7quk8fMuvVVPznUzav+L6wOwHvaZsr99fWBh8vMd/junLQOxHVCv2P9LeCMeVx5MBucGEPdLTKf8V7mWB8M6I9C8U3go/4miTRGJT19Xwbi0zql7QhFAJ70u8cSabmqZ7RdoQmACsMAwDEAcAwAHAMAxwDAMQBwDKBAW7/SwD4MoEAf9Gg7BlCgg3q0HQMoUK0ebccAwDEAcAwgy6a/5v3iyMa6bsKJfyQqi/fXgWLX7klV9SezK5HPaxm5G7ssEjnuvz2MGAA43gLAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwCgiXwH+DSb2mLzUIsAAAAASUVORK5CYII=":"front.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAATSSURBVHhe7d1vaFV1HMfx77mt3f25s/mHSX8oAxVayxDBWSxScmxhj+rBDNTyiYotuUSKk1kbPcjK0AjF9aCejHGDwB44GyWRDHsQKP7LB0NhICauDLWlu2Pb8Zxzv3k7d7dzd+eg8zufzwt+1985h3vhet+enXP0Hi3bIQQrpr8SKAYAjgGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYAjgGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYAjgGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYADiqAs4eP6ez+HP9+Zl4nDCAC6Dk+IJZVJc+92qhrpm/F7j5Z2dQob6+Yr2sM594oMsqk8X33Rpj3xp7mct1SvPbvbvlea4EzTBf5AD4/cdP3oblj4tQXunXqem94d1T1jUvdW3WruSIfgKu+vdf3wZU7oxgTzhCp8b3Gx03xzEbDQQTgktpW3wfYWjv1t16xfKfvuU87IyqgbhZtWTXO4++ZBUfXxidk05eDupTfL8Mi9VWWLmXYl3tEHntdl8wGdRo4bg+JVC725ltW1zkf/mlvHmR5wvvjLvVrd3jLqU0LI/Phe9w9gGleSB717ZJNGecOteg7CA8j9wDzqp3DOAPFE3N0Fh5GBnB7ZExnZhkbvaOz8DDyIPDrnwblTN8BKS2r1DXhN3w7LW3rGmTukjW6Jhz4X8aAgzoLoMmM3wMMpkUOtCWlcla1/D0yKm81PysLVrboVirE+ACO3RBpnJ29UPPDziZZ/WGfLlEhxv8IKMl5ByVlFTrz6z17Xdp2vCsdHR2SfGe7SHryFcCu8+7VQmtGh5zv0lcPJ5hjgG9ODsmeTz6Vzs5O+WzfXpE7F3VLViKuk5kUT+gknGACKC8t0ZmK5SyD4llAAPvCfu/vAYoZfX+ZdUjFAALcuuYcYRbpj6s6MQQDAMcAwDGAALPmV+ts6uY9rBNDMIAAVm0y77l90GjO+ddDYccAwDEAcAwgAK8DgON1AIo8BgCOAQTgdQBwvA5AkccAwDGAALwOAI7XASLkz+G0ztRY+L6m9X+ACSC1uc63q5Y5L+sWbMYH4H6W/xaz+FOtGMb/bj1UpRM1Mjqis/sXi5l1Tj8dxgdQ4b2D7NtIfdurs+LZEzr5x/i4TqLL+AAyN3zJPLq++lWkq+V5XfLbdvCIvNe6zZkNZVbkqMz5UtGGN/fqLMKcAyLj1az5wD0SmNJ43Bm2nc48MccVZ4gkJj0n3/hx90uZJ+XoHvCOSu4Ne6Bbt4ST8XsAV+pwu84Ke3GJ+1jqzXM94j40bPXmhaxav05nZotEAKseFOm/6N42pvC9g5Y+tVBn+V3v/0gk/qQu5ed9hXBRNE4jI3eHkINHTsvVn1PyQGmZrsly7x+QfGWZPNrwmq75bz39v8mFo/ulJO4/MBhzDhQXld2UN3bt0zV+7jeMtzyTPXuwzx0SqdusS+HDW8SAi8SPAJo+BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYAjgGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYAjgGAYwDgGAA4BgCOAYBjAOAYADgGAI4BgGMA4BgAOAYAjgGAYwDgGAA4BgCOAYBjAOAYADSRuxux88tGkLE+AAAAAElFTkSuQmCC":"left.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAUbSURBVHhe7dxfaJV1HMfx75GDc8M17WZEDZtrBNofswu90KkX5bQIRtCUqJhdtLBWu5iNlUZ/tskML/qzQKoRgdhNWFAagS6tixiLaiVZy0gsyYu0NbfZDjv9fs/vi09nusOZO7Lf73w+L3iefX8TQc7ee54953lcIm0IwZqjHwkUAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAHLQ1NQt73Y06aqw8PcETmHQbNWJhFsYRWYbS/9h9tdF60LBI8AUbrK7hXdHs3XB7k73R3MhYQBZlC1fopNzur9Xp8LBALKoq2vQyenvHdCpcDCALJatvFUnp3egT6fCwQCy2Hhn/EOgdazvrE6FgwFkUW13N9RHs3Ug+vqfiOZCEeRlYCJhf0b/xS0CUF8lsm/Qz5c5zCNAslyHMFxbntTJP2EGkBrWIQyjwymd/BPkKaD5xbelLPWryffqf2ctKC2R5h17REbiU84bzz8mZ+ZUiEyM62emdiE1Iasqk3LPozv0M37hW8E5WHR/l5z84BldmS/q0Rdk7io/v6DTxauAHNTeW6eTs3v3WzqFj0eAHHxjtjv+d2PoerOdSo+YfXG0DhmPADlYZncV8VHgd7sbeCeaQ8cAcnTXA1t0cjq2d+gUNp4CctQzKLKlevJpYNTs50XrUPEIkKOG6AGBFdFs2dPA+JevusVlhfFeBQOYhhWNjTo5W5+OLw0vdV4/+o2ngGnoOWFOA1WZdwjTaXuNcLtbZDhutpvd6DEeAaahYbHZLc08Cux/tlmnyfz/4lvBHwFm+86gvWX8U8AvYfhHgFm+M/iz2b7t3uQWASqAI4A9/37nFrNkXVLk0HiYL2PwAVzJncHSknnyUs+n8veP8VO+rY+sleLq9TIxPqafuTx7yPxnQam80txqpvg2718ftsnC+9p1FRAbAKKq+p02/Itbum+n/kluFm/uzvj7NYkwX0rYq4DUv5nf6UPD2b/zJ9u/93GdnCMmg9/2PqWrcPAy8ArZB8YrN3e7hVr3YLZ3Bv3EAGbgcHQUiN8YMj+JyEdtq90iEAxgBhaZbUPXYbdQdZ1fmP0ptwgAA5ihT1rWmP1StzAmzPbc6gq3CAADyIM3f/heJ6fdHgSO7HILzzGAPGhcIlJc26Urp2TNNp38xgDyZORAi9nHzwjaR0V2bShxC48xgDzq+tw+KBrbdtBkcNTvUwEDyKOWGpGi9ZmngkSNPRX4e1XAAPJs7KA9FcRXBdbD5f5eFTCAq+Djc5lXBe+dEXn/ycwofAEbQHJu5tO818zP39O9G8tEHtrzta6cTa8fE+nr1JU/grwdPNP/HDqT28FTGTo/Jp1ba6XoxrX6GXMpuHK7jH71cjTve6JS6l/z8JdLRPcEAyNy28XbsD5tZz9r1X9hTKQ63bbc35c5zFNAcr4OfpmTvPQ0MnDyuLT3D+nKP2EGkPpTB7+kRs/pFLulwt4tLHULDwX/SBjNDC8DwTEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcA4Am8h8GanSzb0xHnAAAAABJRU5ErkJggg==":"right.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAATxSURBVHhe7dxvaFV1HMfx7xne/blbOrFwEHeSYSHRLIv+kA0iAjch6A9U6mARkwhmGsQabQ/KxaQ/kEFGIxbln54VFHUX9EDNB/qgMAsrJZJNkmrK3O7umgmn3++eb9zdcRfbumc7v/P5vOAcz/c8Uefb3znn7t55viEEq0x/JVAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDGAGaRPZGXbKy9LvefpmXjiTwotwvOuMfvhYDAuf90riQ0v6BQvXAGKeLD3Ez0KtO/s1KP44QpQxAWzXe0lzP5Kbrb8Pz82Jx/SKT64AhSxwmyrH9sTDOrdnR16FC9cAWbwvdkapt0A+v5Zs18VDDHBFWAGN5vt+pZ3gkF9+mKrHsWH0yvA5ycvyNH9vVKRrNEzpVOZKJMjv5VJem+3nhFZbrbON16S8VH7JZv7ly07eUW2brhOGjY9pWciwAbgqtb+U//+Sziz9bc26J8+Gpy+BFSVL9Ejd5RXlX61+j+cDuBiZlKP3JG5+LseRQOfAmbhjNlumPJEUGG2v/yM2VfnZpfxKWAW1pjt3q7PgsGw685rzXXB4DiuALNkXxNMePb6PZ6bLX/wgEhqs05u4gowS/Z2c/uBH4NBNa/dokfuYgBzsGdzylz2m3QSSZvF4NxHz+rkJl4C5ujgkMiW+ukvEQ+avYmjgL1JjNYjXzFcAebILgKrHi98ifj15rV6NFX+XiHKuALMg/2ClXlJs5/IzZZ/+FWRxud1sn42243BYYQxgHl676RI27r8pcDmMO6PmP2y3OyKWAVw1jygv925Q6qX1uqZcNh/9tq6Wtmx3VwK/j4dnDTabxJ56we3vpyxCuAr8x/wgeWFN2gL7du+Frm17UOdoi9WN4FLIvC3Wb9tn8ilL3SKPj4FhGBl7Sazd2NhjXUAAx332/c7hLa1vHlKf6dCf5it++7ovwZgxTqA4dH8Y1oYMiMzf2u351hWBrrv0im6eAkooSeffkaPAk09x2VsIP+WsihiACXUv/cRqW7crVNgaVOPWSoGdIoeBlBKv5yXzOEOkao79UTAu8p+A+m7YIgYBlBKeuN/LnssOJhipXeL2V8KhghhACG41mx9JwofA+2TwerqcF+hnA8GEJK2dSJd6TGdAr9mReqT9pVK+z2DaGAAIdq1sUbu6ErrFBgyT6ZDR/p1WnwMIGTHd22UFVv7dDK3CWNHJdX4nE6LjwEsgOF9bZJa3yH++YMiNffo2WhgAAtk8JvdInVP6BQdDABcrANIVoT72cHySje+4fNfYvWGkEOjIvcty78h5OHbU3Lbo+1yeaL0b9BMVibk/S/PyE+HPtAz5gbv9H6RNW59ViDWASw0FwPgPQA4BgAu1gEs1juCXBLrABbzHUGu4CUAXKwCmMj/YM+csH8cy/DItBVm0n4g1C38aBg4XgLAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcAwDHAMAxAHAMABwDAMcAwDEAcAwAHAMAxwDAMQBwDAAcA4Am8g9ejRDNEuk3tQAAAABJRU5ErkJggg==":"up.png"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAJpSURBVHhe7d3PShtBAIDx2RBxRS0pFIIHwYMnH6J47LuUgt7Se8FCD3rxAXwKFS/iQ3jpxZsUpAkRaYQQm5BB2MuSGGGz830/GGY2t+x+7OYvm72MBWE14iwoA4AzADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4A4AzADgDgDMAOAOAMwA4AyhxeP43ZFn2OnbHIzUGUKK11oyrqXZxMwkGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBzSO+DYAOYSzfOKTGAEq32h7ia+hjn2TzGebklF8Dq58PCN3iLjIO94kk/xVusJhfA1qdWXFVtM87LzUsAXHIB3D/04kqzSC6A55vjMLkh+nuMk9v0b6zuJaBE708/rtJlAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBlAi3yj+L6CZ4N7KXiY/fqux67vncHH6PeTrxYO1qHylES5//wvXZz/jIyFsjwP49utHeOoPx1tv3239p0E4+volrO7sx0cqNAmgzjpX3cmRqN3oXnXiM6hW7U9qeU3Py41mHlfVqn0Ag+EoruplNBzEVbV8DVCBZXoNUPsAtJgE39hoHgYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBoAWwn8GG/BweZN80wAAAABJRU5ErkJggg==":void 0},function(e){e=e.getBoundingClientRect();return{x:e.left,y:e.top,w:e.width,h:e.height}}),e=function(e){e.preventDefault(),e.stopPropagation(),$=document.pointerLockElement===f||document.mozPointerLockElement===f||document.webkitPointerLockElement===f},t=function(e){return e},T=(this.getView=function(){return A.center.clone().sub(A.camera.position)},function(){var e=new THREE.Vector3(1,1,1);e.normalize(),e.multiplyScalar(A.viewScale),A.camera.position.copy(e),A.center=new THREE.Vector3(0,0,0),A.camera.up.set(0,1,0),A.camera.lookAt(A.center),A.originCamInfo.position=e,A.originCamInfo.center=A.center.clone(),A.originCamInfo.up=new THREE.Vector3(0,1,0)}),S=function(e){var t=new Image,n=(t.crossOrigin="anonymous",new THREE.Texture(t));return t.onload=function(){n.needsUpdate=!0,11<=++q&&requestAnimationFrame(A.render)},_e.singleHTML?t.src=A.getPicSrc(e):t.src=e,n},ne=function(){var e,t,n=[],i=[];for(n[0]=P(0,0),n[1]=P(0,Math.PI/2),n[2]=P(0,-Math.PI/2),n[3]=P(0,Math.PI),n[4]=P(Math.PI/2,0),n[5]=P(Math.PI/2,Math.PI/2),n[6]=P(Math.PI/2,-Math.PI/2),n[7]=P(Math.PI/2,Math.PI),i[0]=B(0,0,0),i[1]=B(0,Math.PI/2,0),i[2]=B(0,-Math.PI/2,0),i[3]=B(0,Math.PI,0),i[4]=B(Math.PI/2,0,0),i[5]=B(Math.PI/2,Math.PI/2,0),i[6]=B(Math.PI/2,-Math.PI/2,0),i[7]=B(Math.PI/2,Math.PI,0),i[8]=B(0,0,Math.PI/2),i[9]=B(0,0,-Math.PI/2),i[10]=B(-Math.PI/2,0,-Math.PI/2),i[11]=B(-Math.PI,0,-Math.PI/2),d.push(ue(0,0)),d[0].name="front",g.push(d[0]),E.push(d[0]),r.add(d[0]),d.push(ue(0,Math.PI/2)),d[1].name="right",g.push(d[1]),E.push(d[1]),r.add(d[1]),d.push(ue(0,Math.PI)),d[2].name="back",g.push(d[2]),E.push(d[2]),r.add(d[2]),d.push(ue(0,-Math.PI/2)),d[3].name="left",g.push(d[3]),E.push(d[3]),r.add(d[3]),d.push(ue(Math.PI/2,0)),d[4].name="bottom",g.push(d[4]),E.push(d[4]),r.add(d[4]),d.push(ue(-Math.PI/2,0)),d[5].name="top",g.push(d[5]),E.push(d[5]),r.add(d[5]),e=d.length,t=0;t<n.length;t++)d.push(n[t]),d[e+t].name=X[t],r.add(d[e+t]),g.push(d[e+t]),E.push(d[e+t]);for(e=d.length,t=0;t<i.length;t++)d.push(i[t]),d[e+t].name=Y[t],r.add(d[e+t]),g.push(d[e+t]),E.push(d[e+t])},ie=function(e,t,n){var i=new THREE.Vector3;return i.copy(e),i=i.unproject(t),new THREE.Raycaster(t.position,i.sub(t.position).normalize()).intersectObjects(n)},re=function(e,t){var n=e.clientX-t.x,e=e.clientY-t.y,n=n/t.w*2-1,e=(t.h-e)/t.h*2-1;return new THREE.Vector3(n,e,.5)};function oe(e,t){var n={};return 0===e.type.indexOf("touch")?0<e.changedTouches.length?(n.clientX=e.changedTouches[0].clientX,n.clientY=e.changedTouches[0].clientY,n.pageX=e.changedTouches[0].pageX,n.pageY=e.changedTouches[0].pageY,n.screenX=e.changedTouches[0].screenX,n.screenY=e.changedTouches[0].screenY,n.movementX=n.screenX-t.prevX,n.movementY=n.screenY-t.prevY):n=t.prevCoords:(n.clientX=e.clientX,n.clientY=e.clientY,n.pageX=e.pageX,n.pageY=e.pageY,n.screenX=e.screenX,n.screenY=e.screenY,n.which=e.which,J?(n.movementX=e.movementX||e.mozMovementX||e.webkitMovementX||0,n.movementY=e.movementY||e.mozMovementY||e.webkitMovementY||0):(n.movementX=n.screenX-t.prevX,n.movementY=n.screenY-t.prevY)),t.prevX=n.screenX,t.prevY=n.screenY,t.prevCoords=n}function ae(){u=te(f),A.width=f.offsetWidth,A.height=f.offsetHeight,A.width,A.height,A.camera.aspect=A.width/A.height,A.camera.updateProjectionMatrix(),A.camera.topFov=A.camera.bottomFov=A.camera.fov/2,A.camera.leftFov=A.camera.rightFov=A.camera.aspect*A.camera.fov/2,A.renderer&&(A.renderer.setSize(A.width,A.height),A.render())}var se=function(e){Se.isMobileDevice()&&A.processMouseMove(e),e.preventDefault(),e.stopPropagation(),u=te(f),f.removeEventListener("mousemove",he,!1),f.addEventListener("mouseup",ce,!1),f.addEventListener("touchend",ce,!1)},le=function e(t){t.preventDefault(),t.stopPropagation(),A.animSpeed<=0?(document.removeEventListener("mousemove",e,!1),document.removeEventListener("touchmove",e,!1),avp.logger.error("animSpeed cannot be 0 or less")):p.currentlyAnimating||(t=oe(t,A),J&&ee&&(ee=!1,t.movementX=t.movementY=0),$&&(300<t.movementX||300<t.movementY)&&(t.movementX=0,t.movementY=0),t.movementX===t.movementY&&0===t.movementX?p.currentlyAnimating=!1:(b=!(K=!1),p.showPivot(!0),p.currentCursor=new THREE.Vector2(t.pageX,t.pageY),p.orbit(p.currentCursor,p.startCursor,new THREE.Vector3(-t.movementX,t.movementY,0),p.startState),A.camera.lookAt(A.center),requestAnimationFrame(A.render)))},de=function(e){e||(f.removeEventListener("mouseup",ce,!1),f.removeEventListener("touchend",ce,!1)),document.removeEventListener("mousemove",le,!1),document.removeEventListener("touchmove",le,!1),f.addEventListener("mousemove",he,!1),$&&document.exitPointerLock()},ce=(this.getDestByFace=function(e){var t,n,i,r,o=new THREE.Vector3(0,1,0),a=new THREE.Vector3(1,-0,0),s=new THREE.Vector3(0,0,-1),l=(null==y&&(l=new THREE.Vector3(0,-1,0),t=new THREE.Vector3(0,1,0),h=new THREE.Vector3(0,0,-1),n=new THREE.Vector3(0,0,1),i=new THREE.Vector3(1,0,0),c=new THREE.Vector3(-1,0,0),r=new THREE.Vector3,(y={}).top=l,y.bottom=t,y.front=h,y.back=n,y.left=i,y.right=c,y["top,front"]=r.addVectors(l,h).clone(),y["top,right"]=r.addVectors(l,c).clone(),y["top,left"]=r.addVectors(l,i).clone(),y["top,back"]=r.addVectors(l,n).clone(),y["bottom,front"]=r.addVectors(t,h).clone(),y["bottom,right"]=r.addVectors(t,c).clone(),y["bottom,left"]=r.addVectors(t,i).clone(),y["bottom,back"]=r.addVectors(t,n).clone(),y["left,front"]=r.addVectors(i,h).clone(),y["front,right"]=r.addVectors(h,c).clone(),y["right,back"]=r.addVectors(c,n).clone(),y["back,left"]=r.addVectors(n,i).clone(),y["front,top,right"]=r.addVectors(h,l).add(c).clone(),y["back,top,right"]=r.addVectors(n,l).add(c).clone(),y["front,top,left"]=r.addVectors(h,l).add(i).clone(),y["back,top,left"]=r.addVectors(n,l).add(i).clone(),y["front,bottom,right"]=r.addVectors(h,t).add(c).clone(),y["back,bottom,right"]=r.addVectors(n,t).add(c).clone(),y["front,bottom,left"]=r.addVectors(h,t).add(i).clone(),y["back,bottom,left"]=r.addVectors(n,t).add(i).clone()),y[e].clone().normalize()),d=o,c=l.clone().negate();if(1-Math.abs(c.dot(o))<1e-5)for(var h=this.getView().normalize(),u=[s.clone(),s.clone().negate(),a.clone(),a.clone().negate()],p=0<c.dot(o)?1:-1,f=h.clone().add(A.camera.up.clone().multiplyScalar(p)).normalize(),m=-2,g=0;g<4;g++){var v=f.dot(u[g]);m<v&&(m=v,d=u[g].multiplyScalar(p))}return{dir:l.clone(),up:d.clone()}},this.getOrientation=function(){var e=Se.round1(W.up.x),t=Se.round1(W.up.y),n=Se.round1(W.up.z),i=new THREE.Vector3(0,0,-1),r=new THREE.Vector3(0,1,0),o=i.clone().cross(r).normalize(),a=(i.x=Se.round1(i.x),i.y=Se.round1(i.y),i.z=Se.round1(i.z),r.x=Se.round1(r.x),r.y=Se.round1(r.y),r.z=Se.round1(r.z),o.x=Se.round1(o.x),o.y=Se.round1(o.y),o.z=Se.round1(o.z),o.clone().multiplyScalar(-1)),s=r.clone().multiplyScalar(-1),l=i.clone().multiplyScalar(-1);switch(A.currentFace){case"front":if(r.x==e&&r.y==t&&r.z==n)return"up";if(s.x==e&&s.y==t&&s.z==n)return"down";if(o.x==e&&o.y==t&&o.z==n)return"right";if(a.x==e&&a.y==t&&a.z==n)return"left";break;case"right":if(r.x==e&&r.y==t&&r.z==n)return"up";if(s.x==e&&s.y==t&&s.z==n)return"down";if(l.x==e&&l.y==t&&l.z==n)return"left";if(i.x==e&&i.y==t&&i.z==n)return"right";break;case"left":if(r.x==e&&r.y==t&&r.z==n)return"up";if(s.x==e&&s.y==t&&s.z==n)return"down";if(i.x==e&&i.y==t&&i.z==n)return"left";if(l.x==e&&l.y==t&&l.z==n)return"right";break;case"back":if(r.x==e&&r.y==t&&r.z==n)return"up";if(s.x==e&&s.y==t&&s.z==n)return"down";if(a.x==e&&a.y==t&&a.z==n)return"right";if(o.x==e&&o.y==t&&o.z==n)return"left";break;case"top":if(l.x==e&&l.y==t&&l.z==n)return"down";if(i.x==e&&i.y==t&&i.z==n)return"up";if(o.x==e&&o.y==t&&o.z==n)return"right";if(a.x==e&&a.y==t&&a.z==n)return"left";break;case"bottom":if(i.x==e&&i.y==t&&i.z==n)return"down";if(l.x==e&&l.y==t&&l.z==n)return"up";if(o.x==e&&o.y==t&&o.z==n)return"right";if(a.x==e&&a.y==t&&a.z==n)return"left"}},function(e){var t=Date.now();if(Se.isMobileDevice()&&A.processMouseMove({type:"noIntersect"}),e.preventDefault(),e.stopPropagation(),p.isSmoothTranslationDone()){var n,i=oe(e,A),i=(u=te(f),re(i,u)),r=ie(i,A.camera,E),o=ie(i,c,m),i=ie(i,c,v),a=A.isFaceView();if(0<r.length&&(r=r[0].object.name,s=A.viewer.getModelOperationMode(),d=A.viewer.getModelOperationVerticalRotationRange(),"FirstPerson"==s?"top"!=r&&"bottom"!=r&&(A.mouseMoveSave=e,A.cubeRotateTo(r)):("hall"!=s||(n=!0,"bottom"==r&&d.x<90&&(n=!1),("bottom,front"==r||"bottom,right"==r||"bottom,left"==r||"bottom,back"==r||"front,bottom,right"==r||"back,bottom,right"==r||"front,bottom,left"==r||"back,bottom,left"==r)&&d.x<45&&(n=!1),("top,front"==r||"top,right"==r||"top,left"==r||"top,back"==r||"front,top,right"==r||"back,top,right"==r||"front,top,left"==r||"back,top,left"==r)&&d.y<45&&(n=!1),n=!("top"==r&&d.y<90)&&n))&&(A.mouseMoveSave=e,A.cubeRotateTo(r))),0<o.length&&a){var s,l=A.getOrientation(),d=A.currentFace;switch(A.currentFace){case"front":switch(l){case"up":o[0].object===m[0]?A.currentFace="top":o[0].object===m[1]?A.currentFace="bottom":o[0].object===m[2]?A.currentFace="right":o[0].object===m[3]&&(A.currentFace="left");break;case"right":o[0].object===m[0]?A.currentFace="right":o[0].object===m[1]?A.currentFace="left":o[0].object===m[2]?A.currentFace="bottom":o[0].object===m[3]&&(A.currentFace="top");break;case"down":o[0].object===m[0]?A.currentFace="bottom":o[0].object===m[1]?A.currentFace="top":o[0].object===m[2]?A.currentFace="left":o[0].object===m[3]&&(A.currentFace="right");break;case"left":o[0].object===m[0]?A.currentFace="left":o[0].object===m[1]?A.currentFace="right":o[0].object===m[2]?A.currentFace="top":o[0].object===m[3]&&(A.currentFace="bottom")}break;case"right":switch(l){case"up":o[0].object===m[0]?A.currentFace="top":o[0].object===m[1]?A.currentFace="bottom":o[0].object===m[2]?A.currentFace="back":o[0].object===m[3]&&(A.currentFace="front");break;case"right":o[0].object===m[0]?A.currentFace="back":o[0].object===m[1]?A.currentFace="front":o[0].object===m[2]?A.currentFace="bottom":o[0].object===m[3]&&(A.currentFace="top");break;case"down":o[0].object===m[0]?A.currentFace="bottom":o[0].object===m[1]?A.currentFace="top":o[0].object===m[2]?A.currentFace="front":o[0].object===m[3]&&(A.currentFace="back");break;case"left":o[0].object===m[0]?A.currentFace="front":o[0].object===m[1]?A.currentFace="back":o[0].object===m[2]?A.currentFace="top":o[0].object===m[3]&&(A.currentFace="bottom")}break;case"left":switch(l){case"up":o[0].object===m[0]?A.currentFace="top":o[0].object===m[1]?A.currentFace="bottom":o[0].object===m[2]?A.currentFace="front":o[0].object===m[3]&&(A.currentFace="back");break;case"right":o[0].object===m[0]?A.currentFace="front":o[0].object===m[1]?A.currentFace="back":o[0].object===m[2]?A.currentFace="bottom":o[0].object===m[3]&&(A.currentFace="top");break;case"down":o[0].object===m[0]?A.currentFace="bottom":o[0].object===m[1]?A.currentFace="top":o[0].object===m[2]?A.currentFace="back":o[0].object===m[3]&&(A.currentFace="front");break;case"left":o[0].object===m[0]?A.currentFace="back":o[0].object===m[1]?A.currentFace="front":o[0].object===m[2]?A.currentFace="top":o[0].object===m[3]&&(A.currentFace="bottom")}break;case"back":switch(l){case"up":o[0].object===m[0]?A.currentFace="top":o[0].object===m[1]?A.currentFace="bottom":o[0].object===m[2]?A.currentFace="left":o[0].object===m[3]&&(A.currentFace="right");break;case"right":o[0].object===m[0]?A.currentFace="left":o[0].object===m[1]?A.currentFace="right":o[0].object===m[2]?A.currentFace="bottom":o[0].object===m[3]&&(A.currentFace="top");break;case"down":o[0].object===m[0]?A.currentFace="bottom":o[0].object===m[1]?A.currentFace="top":o[0].object===m[2]?A.currentFace="right":o[0].object===m[3]&&(A.currentFace="left");break;case"left":o[0].object===m[0]?A.currentFace="right":o[0].object===m[1]?A.currentFace="left":o[0].object===m[2]?A.currentFace="top":o[0].object===m[3]&&(A.currentFace="bottom")}break;case"top":switch(l){case"up":o[0].object===m[0]?A.currentFace="back":o[0].object===m[1]?A.currentFace="front":o[0].object===m[2]?A.currentFace="right":o[0].object===m[3]&&(A.currentFace="left");break;case"right":o[0].object===m[0]?A.currentFace="right":o[0].object===m[1]?A.currentFace="left":o[0].object===m[2]?A.currentFace="front":o[0].object===m[3]&&(A.currentFace="back");break;case"down":o[0].object===m[0]?A.currentFace="front":o[0].object===m[1]?A.currentFace="back":o[0].object===m[2]?A.currentFace="left":o[0].object===m[3]&&(A.currentFace="right");break;case"left":o[0].object===m[0]?A.currentFace="left":o[0].object===m[1]?A.currentFace="right":o[0].object===m[2]?A.currentFace="back":o[0].object===m[3]&&(A.currentFace="front")}break;case"bottom":switch(l){case"up":o[0].object===m[0]?A.currentFace="front":o[0].object===m[1]?A.currentFace="back":o[0].object===m[2]?A.currentFace="right":o[0].object===m[3]&&(A.currentFace="left");break;case"right":o[0].object===m[0]?A.currentFace="right":o[0].object===m[1]?A.currentFace="left":o[0].object===m[2]?A.currentFace="back":o[0].object===m[3]&&(A.currentFace="front");break;case"down":o[0].object===m[0]?A.currentFace="back":o[0].object===m[1]?A.currentFace="front":o[0].object===m[2]?A.currentFace="left":o[0].object===m[3]&&(A.currentFace="right");break;case"left":o[0].object===m[0]?A.currentFace="left":o[0].object===m[1]?A.currentFace="right":o[0].object===m[2]?A.currentFace="front":o[0].object===m[3]&&(A.currentFace="back")}}"hall"!=(s=A.viewer.getModelOperationMode())&&"FirstPerson"!=s||"top"!=A.currentFace&&"bottom"!=A.currentFace?A.cubeRotateTo(A.currentFace):A.currentFace=d}("normal"==(s=A.viewer.getModelOperationMode())||"bim"==s)&&0<i.length&&a&&(!A.wantRollArrows||i[0].object!==v[z]&&i[0].object!==v[h]||(n=i[0].object===v[h],e={center:A.center.clone(),position:A.camera.position.clone(),worldUp:new THREE.Vector3(0,1,0)},r=A.center.clone().sub(A.camera.position).normalize(),n?e.up=A.camera.up.clone().cross(r):(e.up=A.camera.up.clone().multiplyScalar(-1),e.up.cross(r)),e.up.normalize(),d={from:e.position.toArray(),to:e.center.toArray(),up:e.up.toArray(),animationSpeed:1e3},p.look(d))),de(!1),A.viewer.logOperatorTime&&A.viewer.logOperatorTimeShow("[视图盒操作]",t)}else de(!1)}),he=(this.cubeRotateTo=function(e){A.currentFace=e;var e=A.getDestByFace(e),t=A.center.clone().sub(e.dir),e=(t.normalize(),e.up.clone()),t={from:t.toArray(),to:A.center.toArray(),up:e.toArray(),callback:function(){var e=A.viewer.getCameraInfo(),e=new THREE.Vector3(e.position.x-e.target.x,e.position.y-e.target.y,e.position.z-e.target.z),e=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1).normalize(),e.normalize()),e=(new THREE.Euler).setFromQuaternion(e);A.viewer.ScenarioEditorInfo.EulerAngle.set(e.x,e.y,e.z),A.viewer.dispatchEvent({type:"Eulerchange",x:180*e.x/Math.PI,y:180*e.y/Math.PI,z:180*e.z/Math.PI}),A.viewer.dispatchEvent({type:"dischange",distance:20}),Se.isMobileDevice()||A.mouseMoveSave&&A.processMouseMove(A.mouseMoveSave),"OpDrawGeom"==A.viewer.controls.getOperator().type&&A.viewer.controls.getOperator().rotateViewBox(),p.adjustNearAndFar()},sphericalTransition:!0};p.look(t)},this.processMouseMove=function(e){var t,n;if(p.isSmoothTranslationDone()){if(A.mouseMoveSave=null,e=Se.isMobileDevice()&&"noIntersect"==e.type?(t=[],n=[],[]):(e=oe(e,A),e=re(e,u),t=ie(e,A.camera,g),n=ie(e,c,m),ie(e,c,v)),Q&&!b&&(Q.material.color.setHex(14540253),Q=null,requestAnimationFrame(A.render)),0<n.length&&!b){Q=n[0].object;for(var i=o.children.length;0<=--i;)if(Q===m[i]){(Q=o.children[i]).material.color.setHex(45055);break}requestAnimationFrame(A.render)}Z&&!b&&(Z.material.opacity=0,Z=null,requestAnimationFrame(A.render)),0<t.length&&!b&&((Z=t[0].object).material.opacity=.3,requestAnimationFrame(A.render)),0<e.length&&!b?M!==e[0].object&&(A.wantHomeButton&&e[0].object===v[s]?(M=e[0].object,v[s].material.map=I[0]):A.wantRollArrows&&e[0].object===v[z]?(M=e[0].object,v[a].material.map=I[1]):A.wantRollArrows&&e[0].object===v[h]?(M=e[0].object,v[a].material.map=I[2]):A.wantContextMenu&&e[0].object===v[l]?(M=e[0].object,v[l].material.map=I[6]):A.wantHomeButton&&M===v[s]?(M=null,v[s].material.map=I[3]):!A.wantRollArrows||M!==v[z]&&M!==v[h]&&M!==v[a]?A.wantContextMenu&&M===v[l]&&(M=null,v[l].material.map=I[5]):(M=null,v[a].material.map=I[4]),requestAnimationFrame(A.render)):null===M||b||(A.wantHomeButton&&M===v[s]?(M=null,v[s].material.map=I[3]):!A.wantRollArrows||M!==v[z]&&M!==v[h]&&M!==v[a]?A.wantContextMenu&&M===v[l]&&(M=null,v[l].material.map=I[5]):(M=null,v[a].material.map=I[4]),requestAnimationFrame(A.render))}},function(e){u=te(f),A.processMouseMove(e)}),ue=function(e,t){var n=.3*w,i=.225*w+n,r=new THREE.Geometry,o=new THREE.Vector3(0,0,0),a=new THREE.Vector3(n,-n,i),s=new THREE.Vector3(n,n,i),l=new THREE.Vector3(-n,n,i),n=new THREE.Vector3(-n,-n,i);return r.vertices.push(o),r.vertices.push(a),r.vertices.push(s),r.vertices.push(l),r.vertices.push(n),r.faces.push(new THREE.Face3(1,2,3)),r.faces.push(new THREE.Face3(1,3,4)),r.applyMatrix((new THREE.Matrix4).makeRotationX(e)),r.applyMatrix((new THREE.Matrix4).makeRotationY(t)),r.computeFaceNormals(),r.computeVertexNormals(),i=new THREE.MeshBasicMaterial({opacity:0,color:45055,transparent:!0}),new THREE.Mesh(r,i)},B=function(e,t,n){var i=.3*w,r=.225*w+i,o=new THREE.Geometry,a=new THREE.Vector3(i,r,r),s=new THREE.Vector3(-i,r,r),l=new THREE.Vector3(-i,i,r),d=new THREE.Vector3(i,i,r),c=new THREE.Vector3(i,r,i),h=new THREE.Vector3(-i,r,i),u=new THREE.Vector3(-i,r,r),i=new THREE.Vector3(i,r,r);return o.vertices.push(a),o.vertices.push(s),o.vertices.push(l),o.vertices.push(d),o.vertices.push(c),o.vertices.push(h),o.vertices.push(u),o.vertices.push(i),o.faces.push(new THREE.Face3(0,1,2)),o.faces.push(new THREE.Face3(0,2,3)),o.faces.push(new THREE.Face3(4,5,6)),o.faces.push(new THREE.Face3(4,6,7)),o.applyMatrix((new THREE.Matrix4).makeRotationX(e)),o.applyMatrix((new THREE.Matrix4).makeRotationY(t)),o.applyMatrix((new THREE.Matrix4).makeRotationZ(n)),o.computeFaceNormals(),o.computeVertexNormals(),r=new THREE.MeshBasicMaterial({opacity:0,color:45055,transparent:!0}),new THREE.Mesh(o,r)},P=function(e,t){var n=.3*w,i=.225*w+n,r=new THREE.Geometry,o=new THREE.Vector3(i,i,i),a=new THREE.Vector3(n,i,i),s=new THREE.Vector3(n,n,i),l=new THREE.Vector3(i,n,i),d=new THREE.Vector3(i,i,n),c=new THREE.Vector3(i,i,i),h=new THREE.Vector3(i,n,i),u=new THREE.Vector3(i,n,n),p=new THREE.Vector3(i,i,i),f=new THREE.Vector3(i,i,n),m=new THREE.Vector3(n,i,n),n=new THREE.Vector3(n,i,i);return r.vertices.push(o),r.vertices.push(a),r.vertices.push(s),r.vertices.push(l),r.vertices.push(d),r.vertices.push(c),r.vertices.push(h),r.vertices.push(u),r.vertices.push(p),r.vertices.push(f),r.vertices.push(m),r.vertices.push(n),r.faces.push(new THREE.Face3(0,1,2)),r.faces.push(new THREE.Face3(0,2,3)),r.faces.push(new THREE.Face3(4,5,6)),r.faces.push(new THREE.Face3(4,6,7)),r.faces.push(new THREE.Face3(8,9,10)),r.faces.push(new THREE.Face3(8,10,11)),r.applyMatrix((new THREE.Matrix4).makeRotationX(e)),r.applyMatrix((new THREE.Matrix4).makeRotationY(t)),r.computeFaceNormals(),r.computeVertexNormals(),i=new THREE.MeshBasicMaterial({opacity:0,color:45055,transparent:!0}),new THREE.Mesh(r,i)},pe=(this.render=function(){pe();var e=A.renderer;e&&(e.clear(),e.render(_,A.camera),e.render(V,A.camera),e.render(k,A.camera),e.render(r,A.camera),e.render(n,c))},this.isFaceView=function(){var e=!1,t=new THREE.Vector3(0,-1,0),n=new THREE.Vector3(0,1,0),i=new THREE.Vector3(0,0,-1),r=new THREE.Vector3(0,0,1),o=new THREE.Vector3(1,0,0),a=new THREE.Vector3(-1,0,0),s=new THREE.Vector3;return s.subVectors(A.center,A.camera.position),s.normalize(),e=s.equals(t)||s.equals(n)||s.equals(i)||s.equals(r)||s.equals(o)||s.equals(a)?!0:e},function(){K=A.isFaceView(),(Se.isMobileDevice()?K&&p.isSmoothTranslationDone()?me:fe:K&&!x&&p.isSmoothTranslationDone()?me:fe)(),(x?ge:ve)(),(x?Ae:ye)()}),fe=function(){n.remove(o),v[a].material.opacity=0,v[l].material.opacity=0},me=function(){n.add(o);var e=A.wantRollArrows?1:0,e=(v[a].material.opacity=e,v[l].material.opacity=e,A.viewer.getModelOperationMode());"hall"==e||"FirstPerson"==e?(v[a].material.opacity=0,i.up.visible=!1,i.down.visible=!1):(i.up.visible=!0,i.down.visible=!0)},ge=function(){G.material.opacity=0},ve=function(){G.material.opacity=A.wantContextMenu?1:0},Ae=function(){U.material.opacity=0},ye=function(){U.material.opacity=A.wantHomeButton?1:0},C=(this.refreshCube=function(){ae()},this.setSize=function(e,t){if(A.width=e,A.height=t,1<f.children.length)for(var n=1;n<f.children.length;n++)f.children[n].style.bottom=(A.height/5).toString()+"px";ae()},this.useTransparency=function(e){(x=e)?(f.onmouseover=F,f.onmousemove=N,f.onmouseout=j,j()):(f.onmouseover=null,f.onmouseout=null,f.onmousemove=null,f.style.opacity="1.0")},this.dtor=function(){this.renderer=null},this.updateCurrentFace=function(e){var t=new THREE.Vector3(0,-1,0),n=new THREE.Vector3(0,1,0),i=(new THREE.Vector3(0,0,-1),new THREE.Vector3(0,0,1)),r=new THREE.Vector3(1,0,0),o=new THREE.Vector3(-1,0,0);e||((e=new THREE.Vector3).subVectors(A.center,A.camera.position),e.normalize()),e.equals(t)?A.currentFace="top":e.equals(n)?A.currentFace="bottom":e.equals(r)?A.currentFace="left":e.equals(o)?A.currentFace="right":e.equals(i)?A.currentFace="back":A.currentFace="front"},this.enableViewBox=function(e){e?(f.addEventListener("touchstart",se,!1),f.addEventListener("mousedown",se,!1),f.addEventListener("mousemove",he,!1),f.onmouseover=F,f.onmousemove=N,f.onmouseout=j):(f.removeEventListener("touchstart",se,!1),f.removeEventListener("mousedown",se,!1),f.removeEventListener("mousemove",he,!1),f.onmouseover=null,f.onmousemove=null,f.onmouseout=null)},f.getBoundingClientRect()),C=(A.width=C.width,A.height=C.height,u=te(f),A.width,A.height,1),C=(0!=A.width&&0!=A.height&&(C=A.height/A.width),(c=new THREE.PerspectiveCamera(70,C,1,1e4)).position.set(0,0,500),_=new THREE.Scene,V=new THREE.Scene,r=new THREE.Scene,k=new THREE.Scene,n=new THREE.Scene,K=!0,w=A.boxSize,A.viewScale=700,T(),THREE.LinearFilter),T=(A.viewer.serverUrl||"./")+"img/viewbox/",Ee=[(O=T+(Se.getLanguage()+"/"))+"left"+(R=".png"),O+"right"+R,O+"up"+R,O+"down"+R,O+"front"+R,O+"back"+R];if(_e.singleHTML)for(var Me=0;Me<Ee.length;++Me)Ee[Me]=A.getPicSrc(Ee[Me]);(O=(new THREE.CubeTextureLoader).load(Ee)).format=THREE.RGBFormat,O.minFilter=O.maxFilter=C;var R=THREE.ShaderLib.cube,O=((R=new THREE.ShaderMaterial({fragmentShader:R.fragmentShader,vertexShader:R.vertexShader,uniforms:THREE.UniformsUtils.clone(R.uniforms),depthWrite:!1})).uniforms.tCube.value=O,new THREE.BoxGeometry(w,w,w,4,4,4)),L=new THREE.BoxGeometry(w+1,w+1,w+1,4,4,4),R=((D=new THREE.Mesh(O,R)).position.set(0,0,0),V.add(D),(O=S(t(T+"VCedge1.png"))).minFilter=O.maxFilter=C,(D=new THREE.Mesh(L,new THREE.MeshBasicMaterial({map:O,transparent:!0}))).position.set(0,0,0),k.add(D),w),C=new THREE.Geometry,L=new THREE.Vector3(-30,0,0),O=new THREE.Vector3(30,0,0),D=new THREE.Vector3(0,-30,0),L=(C.vertices.push(L),C.vertices.push(O),C.vertices.push(D),C.faces.push(new THREE.Face3(1,0,2)),C.computeFaceNormals(),new THREE.MeshBasicMaterial({color:14540253,transparent:!1,opacity:1})),O=new THREE.MeshBasicMaterial({color:14540253,transparent:!1,opacity:1}),D=new THREE.MeshBasicMaterial({color:14540253,transparent:!1,opacity:1}),H=new THREE.MeshBasicMaterial({color:14540253,transparent:!1,opacity:1}),we=new THREE.PlaneBufferGeometry(.5*w,.3*w,2,2),be=new THREE.MeshBasicMaterial({transparent:!0,opacity:0}),L=(i.up=L,new THREE.Mesh(C,L)),xe=new THREE.Mesh(we,be),O=(L.position.set(0,R,0),xe.position.set(0,.9*R,.1),i.down=O,new THREE.Mesh(C,O)),Ie=new THREE.Mesh(we,be),D=(O.position.set(0,-R,0),Ie.position.set(0,.9*-R,.1),O.rotation.z+=Math.PI,Ie.rotation.z+=Math.PI,i.right=D,new THREE.Mesh(C,D)),Te=new THREE.Mesh(we,be),C=(D.position.set(R,0,0),Te.position.set(.9*R,0,.1),D.rotation.z-=Math.PI/2,Te.rotation.z-=Math.PI/2,i.left=H,new THREE.Mesh(C,H)),H=new THREE.Mesh(we,be),we=(C.position.set(-R,0,0),H.position.set(.9*-R,0,.1),C.rotation.z+=Math.PI/2,H.rotation.z+=Math.PI/2,(o=new THREE.Object3D).position.set(0,0,0),o.add(L),o.add(O),o.add(D),o.add(C),n.add(xe),n.add(Ie),n.add(Te),n.add(H),n.add(o),m.push(xe),m.push(Ie),m.push(Te),m.push(H),new THREE.PlaneBufferGeometry(w/2,w/2,2,2)),be=new THREE.MeshBasicMaterial({map:S(t(T+"VChome.png")),transparent:!0,flatShading:!0}),R=((U=new THREE.Mesh(we,be)).position.set(1.4*-w,1.4*w,0),s=v.length,n.add(U),v.push(U),new THREE.PlaneBufferGeometry(1.5*w,1.5*w,2,2)),L=new THREE.MeshBasicMaterial({map:S(t(T+"VCarrows.png")),flatShading:!0,transparent:!0}),D=((O=new THREE.Mesh(R,L)).position.set(.5*w+20,.5*w+20,0),new THREE.PlaneBufferGeometry(.6*w,.45*w,2,2)),C=new THREE.MeshBasicMaterial({transparent:!0,opacity:0}),Ie=((xe=new THREE.Mesh(D,C)).position.set(.5*w+20,w+20,.1),new THREE.PlaneBufferGeometry(.45*w,.6*w,2,2)),Te=new THREE.MeshBasicMaterial({transparent:!0,opacity:0}),we=((H=new THREE.Mesh(Ie,Te)).position.set(w+20,.5*w+20,.1),n.add(O),n.add(xe),n.add(H),z=v.length,v.push(xe),h=v.length,v.push(H),a=v.length,v.push(O),new THREE.PlaneBufferGeometry(w/2.3,w/2.3,2,2)),be=new THREE.MeshBasicMaterial({map:S(t(T+"VCcontext.png")),transparent:!0,flatShading:!0});(G=new THREE.Mesh(we,be)).position.set(w,-w,0),l=v.length,n.add(G),v.push(G),(R=new THREE.Geometry).vertices.push(new THREE.Vector3(0,0,0)),R.vertices.push(new THREE.Vector3(-w/2,-w/2-20,-w/2)),R.vertices.push(new THREE.Vector3(w/2,-w/2-20,-w/2)),R.vertices.push(new THREE.Vector3(w/2,-w/2-20,w/2)),R.vertices.push(new THREE.Vector3(-w/2,-w/2-20,w/2)),R.faces.push(new THREE.Face3(4,3,2)),R.faces.push(new THREE.Face3(4,2,1)),L=new THREE.MeshBasicMaterial({color:0,transparent:!0,opacity:.5,depthWrite:!1}),D=new THREE.Mesh(R,L),_.add(D),ne(),A.renderer=new THREE.WebGLRenderer({alpha:!0,antialias:!1}),A.useTransparency(!0),A.setSize(A.width,A.height),A.camera.topFov=A.camera.bottomFov=A.camera.fov/2,A.camera.leftFov=A.camera.rightFov=A.camera.aspect*A.camera.fov/2,A.renderer.autoClear=!1,A.renderer.setSize(A.width,A.height),A.renderer.sortObjects=!1,f.appendChild(A.renderer.domElement),f.addEventListener("touchstart",se,!1),f.addEventListener("mousedown",se,!1),f.addEventListener("mousemove",he,!1),(J=!1)&&(document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,f.requestPointerLock=f.requestPointerLock||f.mozRequestPointerLock||f.webkitRequestPointerLock,document.addEventListener("pointerlockchange",e,!1),document.addEventListener("mozpointerlockchange",e,!1),document.addEventListener("webkitpointerlockchange",e,!1)),I.push(S(t(T+"VChomeS.png"))),I.push(S(t(T+"VCarrowsS0.png"))),I.push(S(t(T+"VCarrowsS1.png"))),I.push(S(t(T+"VChome.png"))),I.push(S(t(T+"VCarrows.png"))),I.push(S(t(T+"VCcontext.png"))),I.push(S(t(T+"VCcontextS.png")))}function c(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1,this.renderToColor=!1}function u(e,t){c.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}function w(){c.call(this),this.needsSwap=!1}function Re(e,t){c.call(this),this.textureID=void 0!==t?t:"tDiffuse",e instanceof THREE.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=THREE.UniformsUtils.clone(e.uniforms),this.material=new THREE.ShaderMaterial({defines:e.defines||{},uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),this.scene=new THREE.Scene,this.quad=new THREE.Mesh(new THREE.PlaneGeometry(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)}function Oe(e,t,n){var i;this.renderer=e,void 0===t&&(i={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1},e=e.getSize(),(t=new THREE.WebGLRenderTarget((n||e).width,(n||e).height,i)).texture.name="EffectComposer.rt1"),this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.colorTarget=n||null,this.passes=[],this.copyPass=new Re(je)}function b(e,t,n,i,r){c.call(this),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.oldClearColor=new THREE.Color,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1}function Le(e,t,n,i,r,o){c.call(this),this.scene=e,this.camera=t,this.viewer=n,this.overrideMaterial=i,this.overrideMaterial||(this.overrideMaterial=new THREE.MeshLambertMaterial({color:0,side:THREE.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1})),this.oldClearColor=new THREE.Color,this.clearColor=r,this.clearColor||(this.clearColor=new THREE.Color(16777215)),this.clearAlpha=void 0!==o?o:1,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.selectedMaterial=new THREE.MeshLambertMaterial({color:16711680,side:THREE.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1})}function x(){this.bodyFlag=ve.BODYFLAG.NONE_FLAG,this.bbox=new THREE.Box3,this.coords=[]}var I,Se={REVISION:"01",StringTable:void 0,SupportWebGL2:void 0},De=(Se.setLanguage=function(){s=P().mark(function e(t,n){var i,r,o,a;return P().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.language=t,Se.StringTable=new StringTable(t),_e.singleHTML?(Se.StringTable.tables=window.NdsLanguage,e.next=23):e.next=6;break;case 6:return o="coreViewer/language/en.js",r="coreViewer/language/",n&&(r=n+r),o="zh-CN"==t?r+"zh.js":""+r+t+".js",e.next=13,fetch(o);case 13:(i=e.sent).ok?e.next=18:(console.error("语言配置文件有丢失"),e.next=23);break;case 18:return e.next=20,i.text();case 20:r=e.sent,(o=r.match(/= ({[^}]*})/))?(a=o[1].trim(),Se.StringTable.tables=JSON.parse(a)):console.error("No JSON found in the string.");case 23:case"end":return e.stop()}},e,this)});var s,n=function(){var e=this,a=arguments;return new Promise(function(t,n){var i=s.apply(e,a);function r(e){l(i,t,n,r,o,"next",e)}function o(e){l(i,t,n,r,o,"throw",e)}r(void 0)})};return function(e,t){return n.apply(this,arguments)}}(),Se.getLanguage=function(){var e=this.language,t=(e=e||"en").split("-"),n=(e=1<t.length?t[0].toLowerCase()+"-"+t[1].toUpperCase():t[0].toLowerCase(),["en","zh-HANS","encn","japan","french","italy","german","spanish"]);return e=-1===n.indexOf(e)?-1<e.indexOf("zh-CN")||-1<e.indexOf("zh-TW")?"zh-HANS":1<t.length&&-1<n.indexOf(t[0])?t[0]:"en":e},Se.translateString=function(e){return Se.StringTable.translate(e)},Se.getStyle=function(e,t){return e.style[t]||(e.currentStyle?e.currentStyle[t]:document.defaultView&&document.defaultView.getComputedStyle?(t=(t=t.replace(/[A-Z]/g,"-$1")).toLowerCase(),(e=document.defaultView.getComputedStyle(e,""))&&e.getPropertyValue(t)):null)},Se.onAutoHide=function(e){function t(){clearTimeout(i)}var n=e.domElement,i=(n.addEventListener("mouseenter",t),setTimeout(function(){n.removeEventListener("mouseenter",t),e.setVisibility(!1)},300))},Se.onShowTooltip=function(e){var t=e.event.type,n=e.target.subElements.tooltip;switch(t){case"mouseenter":n.setVisibility(!0);break;case"mouseleave":n.setVisibility(!1);break;case"mouseover":n.setVisibility(!0);break;case"mouseout":n.setVisibility(!1)}},Se.map=function(e,t){this.key=e,this.value=t},Se.isSupportCanvas2=function(){var e;return null==Se.SupportWebGL2&&(e=document.createElement("canvas").getContext("webgl2"),Se.SupportWebGL2=!!e),Se.SupportWebGL2},Se.getExtName=function(e){var t=e.lastIndexOf("."),n=e.length;return e.substring(t+1,n)},Se.sleep=function(e){for(var t=new Date,n=t.getTime()+e;;)if((t=new Date).getTime()>n)return},Se.isEmptyObject=function(e){for(var t in e)return!1;return!0},Se.getObjectSize=function(e){var t,n=0;for(t in e)++n;return n},Se.disposeObject=function(e){if(0==e.children.length)e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose();else for(var t=0;t<e.children.length;t++)this.disposeObject(e.children[t])},Se.encodeURL=function(e){if(null==e)return null;if(Array.isArray(e))for(var t=0;t<e.length;++t)e[t]=e[t].replace(/&/g,"%26"),e[t]=e[t].replace(/#/g,"%23");else e=(e=e.replace(/&/g,"%26")).replace(/#/g,"%23");return e},Se.isIOSDevice=function(){var e=navigator.userAgent.toLowerCase();return/ip(ad|hone|od)/.test(e)||-1!==e.indexOf("macintosh")},Se.isAndroidDevice=function(){return-1!==navigator.userAgent.toLowerCase().indexOf("android")},Se.isIpadDevice=function(){return-1!==navigator.userAgent.toLowerCase().indexOf("ipad")},Se.isMobileDevice=function(){return this.platform?"mobile"==this.platform||"pc"!=this.platform&&(Se.isIOSDevice()||Se.isAndroidDevice()):Se.isIOSDevice()||Se.isAndroidDevice()},Se.setMobileDevice=function(e){this.platform=e},Se.easeClamp=function(e,t,n){return e<=t?0:n<=e?1:.5*(Math.sin(((e-t)/(n-t)-.5)*Math.PI)+1)},Se.linearClamp=function(e,t,n){return e<=t?0:n<=e?1:(e-t)/(n-t)},Se.linearInterp=function(e,t,n){return t*(1-e)+n*e},Se.round1=function(e){return Math.round(10*e)/10},Se.round2=function(e){return Math.round(100*e)/100},Se.getUniqueId=function(){var e=Date.now().toString(16);return e+=Math.random().toString(16).substr(3,4)},Se.extractUrlBase=function(e){e=e.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")},Se.getUUid32=function(e){return e=36===e.length?(e=e.slice(0,8)+e.slice(9,13)+e.slice(14,18)+e.slice(19,23)+e.slice(24,36)).toLowerCase():e},Se.addSceneID=function(e){return 0!=_e.ScenarioEditorid&&_e.ScenarioEditor?e+"_"+_e.ScenarioEditorid:e},function(p){var v=this,A=(this.viewer=p).viewBox,r=.5,o=!1,f=null,m=null,g=null,y=null,E=null,i=new THREE.Box3,a=null,M=1.5;function l(){v.resetOperationMode(),v.adjustNearAndFar(),v.viewer.dispatchEvent({type:"ZoomFitEvent"})}this.setCameraSize=function(e,t){p.camera.setSize(e,t),p.camera.updateProjectionMatrix()},this.center=function(){return this.viewer.camera.getCameraTarget()},this.setZoomSpeed=function(e){M=e},this.setRotateSpeed=function(e){0},this.StandardView={front:{from:[0,0,1],to:[0,0,0],up:[0,1,0]},back:{from:[0,0,-1],to:[0,0,0],up:[0,1,0]},left:{from:[-1,0,0],to:[0,0,0],up:[0,1,0]},right:{from:[1,0,0],to:[0,0,0],up:[0,1,0]},top:{from:[0,1,0],to:[0,0,0],up:[0,0,-1]},bottom:{from:[0,-1,0],to:[0,0,0],up:[0,0,1]},frontRight:{from:[1,0,1],to:[0,0,0],up:[0,1,0]},leftFront:{from:[-1,0,1],to:[0,0,0],up:[0,1,0]},backLeft:{from:[-1,0,-1],to:[0,0,0],up:[0,1,0]},rightBack:{from:[1,0,-1],to:[0,0,0],up:[0,1,0]},frontUpLeft:{from:[-.5773502691896258,.5773502691896258,.5773502691896258],to:[0,0,0],up:[0,1,0]},bottomRightFront:{from:[.5773502691896258,-.5773502691896258,.5773502691896258],to:[0,0,0],up:[0,1,0]},rightUpFront:{from:[.5773502691896258,.5773502691896258,.5773502691896258],to:[0,0,0],up:[0,1,0]},bottomFrontLeft:{from:[-.5773502691896258,-.5773502691896258,.5773502691896258],to:[0,0,0],up:[0,1,0]},backUpRight:{from:[.5773502691896258,.5773502691896258,-.5773502691896258],to:[0,0,0],up:[0,1,0]},leftUpBack:{from:[-.5773502691896258,.5773502691896258,-.5773502691896258],to:[0,0,0],up:[0,1,0]},bottomBackRight:{from:[.5773502691896258,-.5773502691896258,-.5773502691896258],to:[0,0,0],up:[0,1,0]},bottomLeftBack:{from:[-.5773502691896258,-.5773502691896258,-.5773502691896258],to:[0,0,0],up:[0,1,0]}},this.setViewBox=function(e){(A=e)&&this.updateViewBoxCamDir()},this.setRotateCenter=function(e){E=e},this.getRotateCenter=function(){return E},this.setCameraInfo=function(e,t){null!=e?p.camera.setOrginalCameraInfo({center:new THREE.Vector3(e.target.x,e.target.y,e.target.z),up:new THREE.Vector3(e.up.x,e.up.y,e.up.z),position:new THREE.Vector3(e.position.x,e.position.y,e.position.z),fov:e.fov,near:e.near,far:e.far,isPerspective:e.isPerspective,width:e.width,height:e.height,modelScreenBBox:e.modelScreenBBox}):(p.camera.setOrginalCameraInfo(void 0),p.controls.SetBoundingBoxUpdated(!1),p.camera.up.set(0,1,0),(e=new THREE.Matrix4).lookAt(new THREE.Vector3(1,1,1),new THREE.Vector3,p.camera.up),p.camera.quaternion.setFromRotationMatrix(e)),t&&p.resetCamera({useOrginal:!0})},this.getCameraInfo=function(){var e={},t=p.camera,t=(e.fov=t.fov,e.near=t.near,e.far=t.far,e.position={x:t.position.x,y:t.position.y,z:t.position.z},e.up={x:t.up.x,y:t.up.y,z:t.up.z},p.camera.getCameraTarget()),t=(e.target={x:t.x,y:t.y,z:t.z},e.isPerspective=p.camera.isPerspective,p.renderer.getPixelRatio());return e.width=p.renderer.domElement.width/t,e.height=p.renderer.domElement.height/t,e.modelScreenBBox=p.computeModelScreenBBox(),e},this.setAutoRotateSpeed=function(e){r=e},this.setAutoRotationEnabled=function(e){e?o||(o=!0,f=Date.now(),this.autoRotation()):o=!1},this.toggleAutoRotation=function(e){var t=o;o=!o,(o=void 0!==e?e:o)&&!t&&(f=Date.now(),this.autoRotation())},this.autoRotation=function(){var e,t,n,i;_e.enableBroadcast&&!_e.broadcastMajor||o&&(requestAnimationFrame(function(){v.autoRotation()}),1e3/30<=(t=(e=Date.now())-f))&&(f=e-t%(1e3/30),e=p.controls.getBoundingBox().getCenter(),(t=new THREE.Vector3).subVectors(p.camera.position,e),i=new THREE.Vector3(0,1,0),(n=new THREE.Quaternion).setFromAxisAngle(i,r*Math.PI/180),t.applyQuaternion(n),(i=new THREE.Vector3).subVectors(p.camera.getCameraTarget(),e),i.applyQuaternion(n),p.camera.getCameraTarget().addVectors(e,i),p.camera.up.applyQuaternion(n),p.camera.position.addVectors(e,t),p.camera.setCameraTarget(p.camera.getCameraTarget()),p.render(),A)&&v.updateViewBoxCamQuaternion(n)},this.look=function(e){var t=[1,1,1],n=[0,0,0],i=[0,1,0],r=("hall"==p.getModelOperationMode()&&(t=[0,0,1]),void 0!==e&&(void 0!==e.type&&void 0!==v.StandardView[e.type]?(t=v.StandardView[e.type].from,n=v.StandardView[e.type].to,i=v.StandardView[e.type].up):(void 0!==e.from&&(t=e.from),void 0!==e.to&&(n=e.to)),void 0!==e.up)&&(i=e.up),new THREE.Vector3),o=new THREE.Vector3,a=new THREE.Vector3,o=o.fromArray(n).sub(r.fromArray(t)),n=(o.normalize(),{dir:o,up:a.fromArray(i),callback:e.callback,sphericalTransition:e.sphericalTransition,animationSpeed:e.animationSpeed});void 0!==e&&void 0!==e.smoothTranslation?v.zoomExtents(e.smoothTranslation,e.useOrginal,n,!0):v.zoomExtents(void 0,e.useOrginal,n,!0)},this.zoomExtents=function(e,t,n,i){var r=new THREE.Vector3,o=new THREE.Vector3,a={flag:!0},s=p.controls.IsBoundingBoxUpdated();if(0<p.isolateMeshes.length&&(null==i||0==i))p.computeMeshesBoundingBox(p.isolateMeshes,r,o,a);else if(s)p.controls.getExplosionBoundingBox()?(r.copy(p.controls.getExplosionBoundingBox().min),o.copy(p.controls.getExplosionBoundingBox().max)):(r.copy(p.controls.getBoundingBox().min),o.copy(p.controls.getBoundingBox().max));else{if(p.computeBoundingBox(p.scene,r,o,a),r.x>o.x||r.y>o.y||r.z>o.z)return;p.controls.setBoundingBox(r,o)}i=new THREE.Vector3,i.x=.5*(o.x+r.x),i.y=.5*(o.y+r.y),i.z=.5*(o.z+r.z),a=new THREE.Vector3;(a=a.subVectors(o,r)).length()<1e-6&&a.set(1,1,1);var o=.5*a.length()/Math.sin(Math.PI/180*p.camera.fov*.5),r=(p.camera.IsPerspective()&&p.camera.aspect<1&&(o/=p.camera.aspect),0==o&&(o=1e-4),1!=Number(p.disratio)&&(o*=Number(p.disratio)),p.controls.getExplosionBoundingBox()||(p.camera.far=5*o,p.camera.setZoomToFitRatio(5),p.camera.far<1e3&&(p.camera.setZoomToFitRatio(1e3/o),p.camera.far=1e3),2e3<p.camera.far/p.camera.near&&(p.camera.near=p.camera.far/2e3),p.camera.near>.25*a.length()&&(p.camera.near=.25*a.length()),p.camera.perpNear>.25*a.length()&&(p.camera.perpNear=.25*a.length())),null),a=null;n?((r=n.dir.clone().normalize()).multiplyScalar(o),a=i.clone().sub(r)):((r=new THREE.Vector3(0,0,1).applyQuaternion(p.camera.quaternion)).multiplyScalar(o),(a=new THREE.Vector3).addVectors(i,r)),s||(p.groundShadow.updateGroundTransform(p.camera,p.controls.getBoundingBox()),p.is2DModel?p.camera.setOrthoNear(p.modelRootObject.boundingBox.clone()):p.camera.setOrthoNear(p.controls.getBoundingBox()),p.camera.getOrginalCameraInfo())||p.camera.setOrginalCameraInfo({center:i.clone(),up:n?n.up.clone():new THREE.Vector3(0,1,0),position:a}),!0===t&&p.camera.getOrginalCameraInfo()&&(i.copy(p.camera.getOrginalCameraInfo().center),a.copy(p.camera.getOrginalCameraInfo().position),p.camera.getOrginalCameraInfo().fov&&(p.camera.fov=p.camera.getOrginalCameraInfo().fov),p.camera.getOrginalCameraInfo().near&&p.camera.IsPerspective()==p.camera.getOrginalCameraInfo().isPerspective&&(p.camera.near=p.camera.getOrginalCameraInfo().near),p.camera.getOrginalCameraInfo().far)&&p.camera.IsPerspective()==p.camera.getOrginalCameraInfo().isPerspective&&(p.camera.far=p.camera.getOrginalCameraInfo().far),p.camera.updateProjectionMatrix(),p.camera.updateMatrixWorld(!0),void 0===e||e?(o={center:i,up:(n||p.camera).up.clone(),position:a},!0===t&&p.camera.getOrginalCameraInfo()&&p.camera.getOrginalCameraInfo().up&&(o.up=p.camera.getOrginalCameraInfo().up),n&&n.animationSpeed&&(o.animationSpeed=n.animationSpeed),n&&!0===n.sphericalTransition?v.sphericalTransition(o,n.callback):p.startSmoothTranslation(o,l)):(n&&n.up&&p.camera.up.copy(n.up.clone()),!0===t&&p.camera.getOrginalCameraInfo()&&p.camera.getOrginalCameraInfo().up&&p.camera.up.copy(p.camera.getOrginalCameraInfo().up),p.camera.position.copy(a),p.camera.setCameraTarget(i),p.camera.updateProjectionMatrix(),p.camera.updateMatrixWorld(!0),A&&v.updateViewBoxCamDir(),p.render(),l()),_e.autoSwitchFirstPersonView&&"FirstPerson"==p.getModelOperationMode()&&p.setModelOperationModeInternal(p.originalModelOperationMode)},this.sphericalTransition=function(e,a){var s,l,t,n,d,c,i,r,o,h,u;f=Date.now(),m=0,null==g&&(s=new THREE.Quaternion,l=new THREE.Quaternion,t=new THREE.Quaternion,n=new THREE.Quaternion,d=p.camera.getCameraTarget().clone().sub(p.camera.position).length(),c=e.center.clone().sub(e.position).length(),i=e.center.clone().sub(e.position).normalize(),h=(o=(r=p.camera.getCameraTarget().clone().sub(p.camera.position).normalize()).clone().cross(p.camera.up).normalize()).clone().cross(r).normalize(),(u=new THREE.Matrix4).set(r.x,h.x,o.x,0,r.y,h.y,o.y,0,r.z,h.z,o.z,0,0,0,0,1),s.setFromRotationMatrix(u),h=(o=(r=i).clone().cross(e.up).normalize()).clone().cross(r).normalize(),u.set(r.x,h.x,o.x,0,r.y,h.y,o.y,0,r.z,h.z,o.z,0,0,0,0,1),t.setFromAxisAngle(r,0),n.setFromAxisAngle(h,0),l.setFromRotationMatrix(u),l.multiply(t).multiply(n).normalize(),function e(t,n){var i,r,o;_e.enableBroadcast&&!_e.broadcastMajor||(r=p.camera.position.distanceToSquared(t.position),(i=new THREE.Vector3).subVectors(p.camera.up,t.up),r=r<1e-6&&Math.abs(i.x)<1e-5&&Math.abs(i.y)<1e-5&&Math.abs(i.z)<1e-5,!p.getEnableSmoothTranslation()||1<=m||r?(m=1,p.camera.position.copy(t.position),p.camera.up.copy(t.up),p.camera.setCameraTarget(t.center.clone()),p.camera.lookAt(v.center()),p.camera.updateMatrixWorld(!0),p.camera.updateProjectionMatrix(),p.render(),A&&(i=t.center.clone().sub(t.position),(r=A.center.clone().sub(i).normalize()).multiplyScalar(A.viewScale),A.camera.position.copy(r),A.camera.up.copy(t.up),A.camera.lookAt(A.center),A.render()),null!=g&&cancelAnimationFrame(g),g=null,A&&A.render(),void 0!==(i=p.getLoadingManager()).onSmoothTranslationDone&&i.onSmoothTranslationDone(),n&&n()):(i=1-(r=Se.linearClamp(m,0,1)),o=(n=Date.now())-f,f=n,t.animationSpeed?m+=o/t.animationSpeed:m+=o/500,n=new THREE.Matrix4,(o=s.clone()).slerp(l,r),n.makeRotationFromQuaternion(o),o=Se.linearInterp(r,d,c),n=n.elements,i=p.camera.getCameraTarget().clone().multiplyScalar(i).add(t.center.clone().multiplyScalar(r)),r=t.center.clone().sub(new THREE.Vector3(n[0],n[1],n[2]).multiplyScalar(o)),o=new THREE.Vector3(n[4],n[5],n[6]),p.camera.position.copy(r),p.camera.up.copy(o),p.camera.setCameraTarget(i),p.camera.updateProjectionMatrix(),p.render(),A&&(r=A.center.clone().sub(new THREE.Vector3(n[0],n[1],n[2]).multiplyScalar(A.viewScale)),A.camera.position.copy(r),A.camera.up.copy(o),A.camera.lookAt(A.center),A.render()),g=requestAnimationFrame(function(){e(t,a)})))}(e,a))},this.startSmoothTranslation=function(e,t){f=Date.now(),m=0,null!=g&&(cancelAnimationFrame(g),g=null),v.smoothTranslation(e,t)},this.isSmoothTranslationDone=function(){return null==g},this.smoothTranslation=function(e,t){var n,i,r,o,a,s;_e.enableBroadcast&&!_e.broadcastMajor||e&&(o=p.camera.position.distanceToSquared(e.position),(i=new THREE.Vector3).subVectors(p.camera.up,e.up),r=e.center.clone().sub(e.position),A&&(n=A.center.clone().sub(r).normalize()).multiplyScalar(A.viewScale),r=o<1e-6&&Math.abs(i.x)<1e-5&&Math.abs(i.y)<1e-5&&Math.abs(i.z)<1e-5,!p.getEnableSmoothTranslation()||1<=m||r?(m=1,p.camera.position.copy(e.position),p.camera.up.copy(e.up),p.camera.setCameraTarget(e.center.clone()),p.camera.lookAt(v.center()),p.camera.updateMatrixWorld(!0),p.camera.updateProjectionMatrix(),p.render(),A&&(A.camera.position.copy(n),A.camera.up.copy(e.up),A.camera.lookAt(A.center),v.updateViewBoxCamDir()),null!=g&&cancelAnimationFrame(g),g=null,A&&A.render(),void 0!==(o=p.getLoadingManager()).onSmoothTranslationDone&&o.onSmoothTranslationDone(),t&&t()):(r=1-(i=Se.linearClamp(m,0,1)),a=(o=Date.now())-f,f=o,e.animationSpeed?m+=a/e.animationSpeed:m+=a/1e3,o=p.camera.getCameraTarget().clone().multiplyScalar(r).add(e.center.clone().multiplyScalar(i)),a=p.camera.position.clone().multiplyScalar(r).add(e.position.clone().multiplyScalar(i)),s=p.camera.up.clone().multiplyScalar(r).add(e.up.clone().multiplyScalar(i)),p.camera.position.copy(a),p.camera.up.copy(s),p.camera.setCameraTarget(o),p.camera.updateProjectionMatrix(),p.camera.updateMatrixWorld(!0),p.render(),A&&((a=A.camera.position.clone().multiplyScalar(r).add(n.clone().multiplyScalar(i))).normalize(),a.multiplyScalar(A.viewScale),A.camera.position.copy(a),A.camera.up.copy(s),A.camera.lookAt(A.center),A.render()),g=requestAnimationFrame(function(){v.smoothTranslation(e,t)})))},this.resetOperationMode=function(){var e=p.getModelOperationMode();_e.autoSwitchFirstPersonView&&"FirstPerson"==e&&!p.controls.getBoundingBox().containsPoint(p.camera.position)&&p.setModelOperationModeInternal(p.originalModelOperationMode)},this.zoomToObject=function(e,t){var n=new THREE.Vector3,i=new THREE.Vector3,r=p.controls.IsBoundingBoxUpdated(),e=(p.computeBoundingBox(e,n,i,{flag:!0}),new THREE.Vector3),o=(e.x=.5*(i.x+n.x),e.y=.5*(i.y+n.y),e.z=.5*(i.z+n.z),new THREE.Vector3);(i=.5*(o=o.subVectors(i,n)).length())<1e-6||(n=i/Math.sin(Math.PI/180*p.camera.fov*.5),p.camera.IsPerspective()&&p.camera.aspect<1&&(n/=p.camera.aspect),0==n&&(n=1e-4),p.controls.getExplosionBoundingBox()||(p.camera.far<5*n&&(p.camera.far=5*n),p.camera.setZoomToFitRatio(5),p.camera.far<1e3&&(p.camera.setZoomToFitRatio(1e3/n),p.camera.far=1e3),2e3<p.camera.far/p.camera.near&&(p.camera.near=p.camera.far/2e3),p.camera.near>.5*o.length()&&(p.camera.near=.25*o.length())),(i=new THREE.Vector3(0,0,1).applyQuaternion(p.camera.quaternion)).multiplyScalar(n),(o=new THREE.Vector3).addVectors(e,i),r||(p.groundShadow.updateGroundTransform(p.camera,p.controls.getBoundingBox()),p.camera.setOrthoNear(p.controls.getBoundingBox()),p.camera.getOrginalCameraInfo())||p.camera.setOrginalCameraInfo({center:e.clone(),up:new THREE.Vector3(0,1,0),position:o}),p.camera.updateProjectionMatrix(),void 0===t||t?(n={center:e,up:p.camera.up,position:o},v.startSmoothTranslation(n,l)):(p.camera.position.copy(o),p.camera.setCameraTarget(e),p.render(),l()),i=p.controls.getBoundingBox().containsPoint(o),r=p.getModelOperationMode(),_e.autoSwitchFirstPersonView&&"hall"!=r&&(i?"FirstPerson"!=r&&p.setModelOperationModeInternal("FirstPerson"):"FirstPerson"==r&&p.setModelOperationModeInternal(p.originalModelOperationMode)))},this.setModelUpDirection=function(e,t){var n=-1;0<p.getExplodeFactor()&&(n=p.getExplodeFactor(),p.Optoolbar?p.Optoolbar.resetExplosion():p.explodeModel(0)),p.initModelUpDirection(e),p.scene.updateMatrixWorld(!0),p.controls.SetBoundingBoxUpdated(!1),p.scene.remove(p.lightControls._scene),p.scene.traverse(function(e){e.hasOwnProperty("geometry")&&(e.matrixWorldTransOrginal&&(e.matrixWorldTransOrginal=void 0),e.matrixWorldTransOrginalDrag)&&(e.matrixWorldTransOrginalDrag=void 0)}),p.scene.add(p.lightControls._scene),null!=p.modelSceneOrgin&&p.modelSceneOrgin!=p.scene&&(p.modelSceneOrgin.updateMatrixWorld(!0),p.modelSceneOrgin.traverse(function(e){e.hasOwnProperty("geometry")&&(e.matrixWorldTransOrginal&&(e.matrixWorldTransOrginal=void 0),e.matrixWorldTransOrginalDrag)&&(e.matrixWorldTransOrginalDrag=void 0)})),0!=t&&(e=p.camera.getOrginalCameraInfo(),p.camera.setOrginalCameraInfo(void 0),p.camera.up.set(0,1,0),(t=new THREE.Matrix4).lookAt(new THREE.Vector3(1,1,1),new THREE.Vector3,p.camera.up),p.camera.quaternion.setFromRotationMatrix(t),p.resetCamera({useOrginal:!0}),e)&&null!=e.fov&&p.camera.setOrginalCameraInfo(e),0<n&&p.explodeModel(n)},this.onOperationModeChange=function(e){p.camera.setOrginalCameraInfo(void 0),p.camera.up.set(0,1,0);var t=new THREE.Matrix4,n=(t.lookAt(new THREE.Vector3(1,1,1),new THREE.Vector3,p.camera.up),p.camera.quaternion.setFromRotationMatrix(t),.5*Math.PI-p.camera.up.angleTo(new THREE.Vector3(1,1,1).normalize())),i=p.getModelOperationVerticalRotationRange();null!=i&&Math.abs(i.y)*Math.PI/180<n&&(Math.abs(i.y)<4.5?t.lookAt(new THREE.Vector3(1,0,1),new THREE.Vector3,p.camera.up):t.lookAt(new THREE.Vector3(1,.1,1),new THREE.Vector3,p.camera.up),p.camera.quaternion.setFromRotationMatrix(t)),0!=e&&p.resetCamera({useOrginal:!0})},this.rotateToPlane=function(e){this.viewer.camera.updateMatrixWorld(!0);var t=new THREE.Vector3(0,0,1),n=(new THREE.Vector3,new THREE.Vector3),i=new THREE.Vector3,r=(i.copy(e.normal),new THREE.Vector3),o=new THREE.Vector3,a=new THREE.Vector3,a=(e.projectPoint(new THREE.Vector3(0,0,0),r),e.projectPoint(new THREE.Vector3(10,0,0),o),e.projectPoint(new THREE.Vector3(0,10,0),a),n.subVectors(a,r).normalize(),(new THREE.Vector3).crossVectors(n,i).length()<1e-4&&n.subVectors(o,r).normalize(),Math.abs(n.x<1e-5)&&Math.abs(n.y<1e-5)&&Math.abs(n.z<1e-5)&&(n=t),e=(new THREE.Vector3).crossVectors(n,i).normalize(),(new THREE.Matrix3).set(e.x,e.y,e.z,n.x,n.y,n.z,i.x,i.y,i.z).transpose()),o=(new THREE.Matrix3).copy(a).transpose(),t=this.viewer.controls.getBoundingBox().getCenter(),e=(new THREE.Vector3).copy(t);return e.addScaledVector(i,this.viewer.camera.position.distanceTo(t)),this.viewer.camera.up.set(n.x,n.y,n.z),this.viewer.camera.position.copy(e),this.center().copy(t),this.adjustNearAndFar(),this.viewer.camera.lookAt(this.center()),this.viewer.camera.updateMatrixWorld(!0),A&&v.updateViewBoxCamDir(),{origin:r,matrix:a,matrixInvert:o}},this.rotateByTrackBall=function(e,t,n){var i,r,o,a,s=this.viewer.renderer.getPixelRatio(),l=2*Math.PI*(e.pointer.x-e.pointerOld.x)*s/this.viewer.renderer.domElement.width,s=-2*Math.PI*(e.pointer.y-e.pointerOld.y)*s/this.viewer.renderer.domElement.height;this.viewer.camera.updateMatrixWorld(!0),t.length()&&(t=null,t=n?this.center().clone():this.viewer.controls.getBoundingBox().getCenter(new THREE.Vector3),null!=E&&(t=E),(o=new THREE.Vector3).subVectors(this.viewer.camera.position,t),(i=new THREE.Vector3(0,0,0)).unproject(this.viewer.camera),(a=new THREE.Vector3(10,0,0)).unproject(this.viewer.camera),a.sub(i).normalize(),(r=new THREE.Vector3(0,10,0)).unproject(this.viewer.camera),r.sub(i).normalize(),(i=new THREE.Quaternion).setFromAxisAngle(r,-l),(r=new THREE.Quaternion).setFromAxisAngle(a,s),o.applyQuaternion(i),o.applyQuaternion(r),(l=new THREE.Vector3).addVectors(t,o),(a=new THREE.Vector3).subVectors(this.center(),t),s=this.center().clone(),!0!==n&&(a.applyQuaternion(i),a.applyQuaternion(r),s.addVectors(t,a)),this.viewer.camera.up.applyQuaternion(i),this.viewer.camera.up.applyQuaternion(r),this.viewer.camera.position.copy(l),this.center().copy(s),this.adjustNearAndFar(),this.viewer.camera.lookAt(this.center()),this.viewer.camera.updateMatrixWorld(!0),o=this.viewer.getCameraInfo(),n=new THREE.Vector3(o.position.x-o.target.x,o.position.y-o.target.y,o.position.z-o.target.z),t=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1).normalize(),n.normalize()),a=(new THREE.Euler).setFromQuaternion(t),this.viewer.ScenarioEditorInfo.EulerAngle.set(a.x,a.y,a.z),this.viewer.dispatchEvent({type:"Eulerchange",x:180*a.x/Math.PI,y:180*a.y/Math.PI,z:180*a.z/Math.PI}),e.render(),A)&&v.updateViewBoxCamDir()},this.rotateByHall=function(e,t){var n=this.viewer.renderer.getPixelRatio(),i=2*Math.PI*(e.pointer.x-e.pointerOld.x)*n/this.viewer.renderer.domElement.width,n=-2*Math.PI*(e.pointer.y-e.pointerOld.y)*n/this.viewer.renderer.domElement.height,r=(this.viewer.camera.updateMatrixWorld(!0),new THREE.Vector3(0,0,1));if(r.unproject(this.viewer.camera),!isFinite(r.x)||!isFinite(r.y)||!isFinite(r.z))return!1;var o=new THREE.Vector3(.25,0,1);if(o.unproject(this.viewer.camera),!isFinite(o.x)||!isFinite(o.y)||!isFinite(o.z))return!1;o.sub(r).normalize();var r=null,r=t?this.center().clone():this.viewer.controls.getBoundingBox().getCenter(new THREE.Vector3),t=(0!=i&&(n*=.25),new THREE.Quaternion),i=(t.setFromAxisAngle(THREE.Object3D.DefaultUp,-i),new THREE.Quaternion),o=(i.setFromAxisAngle(o,n),new THREE.Vector3),n=(o.subVectors(this.viewer.camera.position,r),o.applyQuaternion(t),o.applyQuaternion(i),new THREE.Vector3),i=(n.subVectors(this.center(),r),n.applyQuaternion(t),n.applyQuaternion(i),(new THREE.Vector3).subVectors((new THREE.Vector3).addVectors(r,o),(new THREE.Vector3).addVectors(r,n))),i=(i.normalize(),i.angleTo(THREE.Object3D.DefaultUp)),a=this.viewer.getModelOperationVerticalRotationRange(),s=.06*Math.PI,l=(null!=a&&(s=Math.max(s,.5*Math.PI-Math.abs(a.y)*Math.PI/180)),.94*Math.PI);null!=a&&(l=Math.min(l,.5*Math.PI+Math.abs(a.x)*Math.PI/180)),(i<s||l<i)&&(n.subVectors(this.center(),r),n.applyQuaternion(t),o.subVectors(this.viewer.camera.position,r),o.applyQuaternion(t)),this.center().addVectors(r,n),this.viewer.camera.position.addVectors(r,o),this.adjustNearAndFar(),this.viewer.camera.lookAt(this.center()),e.render(),A&&v.updateViewBoxCamDir()},this.rotateByBim=function(e,t){var n=this.viewer.renderer.getPixelRatio(),i=2*Math.PI*(e.pointer.x-e.pointerOld.x)*n/this.viewer.renderer.domElement.width,n=-2*Math.PI*(e.pointer.y-e.pointerOld.y)*n/this.viewer.renderer.domElement.height,r=new THREE.Vector3(0,1,0),o=(this.viewer.camera.updateMatrixWorld(!0),new THREE.Vector3(0,0,0));if(o.unproject(this.viewer.camera),!isFinite(o.x)||!isFinite(o.y)||!isFinite(o.z))return!1;var a=new THREE.Vector3(10,0,0);if(a.unproject(this.viewer.camera),!isFinite(a.x)||!isFinite(a.y)||!isFinite(a.z))return!1;a.sub(o).normalize();var s,l=this.viewer.camera.position.clone(),d=this.center().clone(),c=this.viewer.camera.up.clone(),h=null,h=t?this.center().clone():this.viewer.controls.getBoundingBox().getCenter(new THREE.Vector3),u=(null!=E&&(h=E),new THREE.Vector3),p=(u.subVectors(this.viewer.camera.position,h),new THREE.Quaternion),i=(p.setFromAxisAngle(r,-i),new THREE.Quaternion),n=(i.setFromAxisAngle(a,n),u.applyQuaternion(i),u.applyQuaternion(p),new THREE.Vector3),f=(n.addVectors(h,u),new THREE.Vector3),m=(f.subVectors(this.center(),h),this.center().clone()),i=(!0!==t&&(f.applyQuaternion(i),f.applyQuaternion(p),m.addVectors(h,f)),this.viewer.camera.up.applyQuaternion(i),this.viewer.camera.up.applyQuaternion(p),this.viewer.camera.position.copy(n),this.center().copy(m),this.viewer.camera.lookAt(this.center()),this.viewer.camera.updateMatrixWorld(!0),o.set(0,0,0),o.unproject(this.viewer.camera),a.set(10,0,0),a.unproject(this.viewer.camera),a.sub(o).normalize(),new THREE.Vector3(0,10,0)),n=(i.unproject(this.viewer.camera),i.sub(o).normalize(),!0),m=this.viewer.getModelOperationVerticalRotationRange(),o=Math.min(Math.PI,Math.abs(m.x)*Math.PI/180),m=Math.min(Math.PI,Math.abs(m.y)*Math.PI/180),g=r.angleTo(i);1e-6<g&&((s=new THREE.Vector3).crossVectors(i,r),s.normalize(),s.dot(a)<0?o<g&&(n=!1):m<g&&(n=!1)),this.adjustNearAndFar(),n||(this.viewer.camera.up.copy(c),this.viewer.camera.up.applyQuaternion(p),u.subVectors(l,h),u.applyQuaternion(p),this.viewer.camera.position.addVectors(h,u),!0!==t&&(f.subVectors(d,h),f.applyQuaternion(p)),this.center().addVectors(h,f),this.viewer.camera.lookAt(this.center())),e.render(),A&&v.updateViewBoxCamDir()},this.rotateByFirstPerson=function(e,t){var n=this.viewer.renderer.getPixelRatio(),i=2*Math.PI*(e.pointer.x-e.pointerOld.x)*n/this.viewer.renderer.domElement.width,n=-.5*Math.PI*(e.pointer.y-e.pointerOld.y)*n/this.viewer.renderer.domElement.height,r=(this.viewer.camera.updateMatrixWorld(!0),this.viewer.camera.position),o=this.center(),a=this.viewer.camera.up,s=(1e-7<a.distanceTo(new THREE.Vector3(0,1,0))&&a.set(0,1,0),new THREE.Vector3),i=(s.subVectors(o,r),s.applyAxisAngle(a,-i),s.clone().normalize()),l=i.clone(),d=(i.negate(),new THREE.Vector3);i.equals(a)||l.equals(a)?d.set(1,0,0):(d.crossVectors(a,i),d.normalize()),e.latAngle-=n,e.latAngle>-.25*Math.PI&&e.latAngle<.25*Math.PI?s.applyAxisAngle(d,n):e.latAngle+=n,o.addVectors(r,s),this.adjustNearAndFar(),this.viewer.camera.lookAt(o),e.render(),A&&v.updateViewBoxCamDir()},this.calFarthestDistToCamera=function(){var e=this.viewer.controls.getExplosionBoundingBox(),t=(e=null==e?this.viewer.controls.getBoundingBox():e).getCenter(new THREE.Vector3),e=.5*(new THREE.Vector3).subVectors(e.max,e.min).length(),t=this.viewer.camera.position.distanceTo(t);return t+=e},this.pan=function(e,t,n){var i=[e.downModelPnt.x,e.downModelPnt.y,e.downModelPnt.z],i=this.viewer.modelCoordToClientCoord(i),t=[i[0]+t.x,i[1]-t.y,i[2]],i=this.viewer.clientCoordToModelCoord(t),t=new THREE.Vector3(i[0],i[1],i[2]).clone();t.sub(e.downModelPnt),this.viewer.camera.position.add(t),this.center().add(t),!1!==n&&e.render()},this.moveForwardBack=function(e,t,n){var i=this.center(),r=this.viewer.camera.position,o=(r.distanceTo(i),new THREE.Vector3),i=(o.subVectors(i,r),.03);this.viewer.controls.getBoundingBox().containsPoint(this.viewer.camera.position)&&(i=.01),o.multiplyScalar(i),0==t&&o.negate(),this.viewer.camera.position.add(o),this.center().add(o),!1!==n&&p.render()},this.setBoundingBox=function(e,t){i.set(e,t),a=i.getCenter()},this.setBoundingBoxCenter=function(e){a=e},this.adjustNearAndFar=function(){var e,t,n;this.viewer.is2DModel||(e=null,e=(this.viewer.controls.getExplosionBoundingBox()?this.viewer.controls.getExplosionBoundingBox():a?i:this.viewer.controls.getBoundingBox()).clone(),this.viewer.pmiObject&&(n=this.viewer.calculatePMIBoundingBox())&&!e.containsBox(n)&&e.union(n),n=new THREE.Vector3,e.getCenter(n),e=e.min.distanceTo(e.max),t=this.viewer.camera.position.clone(),n=Math.abs(n.distanceTo(t))+1.2*e,this.viewer.camera.adjustNearFar(n,n))},this.zoom=function(e,t,n,i){if(this.viewer.is2DViewer)(o=this.camDisTo2DViewer())<this.viewer.camera.near+.1&&t.z<0||(t.multiplyScalar(1e-4*o),t.length()>o)||(t.applyMatrix3(e.normalMatrix.getNormalMatrix(this.viewer.camera.matrix)),r=this.viewer.camera.IsPerspective(),this.viewer.camera.position.add(t),r&&this.center().add(t),this.adjustNearAndFar(),this.viewer.camera.updateProjectionMatrix(),!1!==i&&e.render());else{if(n){if(this.zoomByMouse(e,t,n,i))return}else if("hall"==this.viewer.getModelOperationMode())return void(0!=t.z&&(0<t.z?t.z=30:t.z=-30,this.zoomByMouse(e,t,{offsetX:0,offsetY:0},i)));var r=this.viewer.camera.IsPerspective(),o=this.viewer.camera.position.distanceTo(this.center());o*=M/1.5,t.multiplyScalar(1e-4*o),t.applyMatrix3(e.normalMatrix.getNormalMatrix(this.viewer.camera.matrix)),this.viewer.camera.position.add(t),r&&this.center().add(t),this.adjustNearAndFar(),this.viewer.camera.updateProjectionMatrix(),0<t.z&&(n=this.calFarthestDistToCamera())>this.viewer.camera.far&&(this.viewer.camera.far=n),!1!==i&&e.render()}},this.zoomByMouse=function(e,t,n,i){var r=this.viewer.renderer.domElement,o=this.viewer.renderer.getPixelRatio(),a=n.offsetX||n.clientX-this.viewer.container.getBoundingClientRect().left,s=n.offsetY||n.clientY-this.viewer.container.getBoundingClientRect().top,n=(n.srcElement&&n.srcElement!==this.viewer.renderer.domElement&&(a=n.clientX-this.viewer.container.getBoundingClientRect().left,s=n.clientY-this.viewer.container.getBoundingClientRect().top),null==n.srcElement&&n.target&&n.target!==this.viewer.renderer.domElement&&(a=n.clientX-this.viewer.container.getBoundingClientRect().left,s=n.clientY-this.viewer.container.getBoundingClientRect().top),this.viewer.camera.position.clone()),l=(n.sub(this.center()),n.length()),a=(n.multiplyScalar(.7),n.add(this.center()),n.project(this.viewer.camera),new THREE.Vector3(a*o/r.width*2-1,2*-(s*o/r.height)+1,n.z)),s=this.viewer.camera.IsPerspective(),o=this.viewer.getModelOperationMode();if("hall"==o&&((r=this.viewer.controls.getBoundingBox().getCenter()).project(this.viewer.camera),a.copy(r)),a.unproject(this.viewer.camera),!isFinite(a.x)||!isFinite(a.y)||!isFinite(a.z))return!1;var n=this.viewer.camera.position.clone(),r=(n.sub(this.center()),n.length(),this.center().clone()),a=(r.sub(a),M),t=t.z,d=this.viewer.controls.getBoundingBox(),c=d.containsPoint(this.viewer.camera.position),c=(c&&t<0&&(a*=.6),_e.autoSwitchFirstPersonView&&"hall"!=o&&(c?"FirstPerson"!=o&&(this.viewer.setModelOperationModeInternal("FirstPerson"),e.latAngle=0):"FirstPerson"==o&&this.viewer.setModelOperationModeInternal(this.viewer.originalModelOperationMode)),this.viewer.camera.position.clone()),o=this.center().clone(),h=new THREE.Vector3,u=(h.x=(n.x+r.x)*a/t,h.y=(n.y+r.y)*a/t,h.z=(n.z+r.z)*a/t,new THREE.Vector3);u.x=r.x*a/t,u.y=r.y*a/t,u.z=r.z*a/t,c.add(h),o.add(u);var p,f,m,r=.8*d.min.distanceTo(d.max),a=(l<r&&(l=r),new THREE.Vector3);return a.subVectors(o,c),a.normalize(),a.multiplyScalar(l),s&&(o.addVectors(c,a),p=this.viewer.camera.getOrginalCameraInfo(),f=new THREE.Vector3(p.position.x-p.center.x,p.position.y-p.center.y,p.position.z-p.center.z).length(),h=new THREE.Vector3(p.center.x,p.center.y,p.center.z),(m=100<(m=20/f*c.clone().sub(h).length())?100:m)<.1&&(m=.1),u=c.clone().sub(h),d=c.clone().sub(o),u.dot(d)<0&&(m=.1),this.viewer.dispatchEvent({type:"dischange",distance:m})),this.adjustNearAndFar(),(s||((r=c.clone()).sub(o),0<=r.dot(n)))&&(this.viewer.camera.position.copy(c),this.center().copy(o)),0<t&&(l=this.calFarthestDistToCamera())>this.viewer.camera.far&&(this.viewer.camera.far=l),this.viewer.camera.updateProjectionMatrix(),s||(p=this.viewer.camera.getOrginalCameraInfo(),m=20/(f=new THREE.Vector3(p.position.x-p.center.x,p.position.y-p.center.y,p.position.z-p.center.z).length())*this.viewer.camera.position.clone().sub(this.center()).length(),this.viewer.dispatchEvent({type:"dischange",distance:m=(m=100<m?100:m)<.1?.1:m})),!1!==i&&e.render(),!0},this.set2DViewerInfo=function(e){var t,n;null!=e.center&&p.viewer2DInfo.center.copy(e.center),null!=e.yDir&&(p.viewer2DInfo.yDir.copy(e.yDir),(n=new THREE.Vector3).copy(e.yDir),p.camera.up.copy(n)),null!=e.normal&&(e.normal.normalize(),p.viewer2DInfo.normal.copy(e.normal),(n=new THREE.Vector3).copy(e.normal),(t=new THREE.Vector3).copy(n),t.multiplyScalar(-1),null!=e.distance?(p.viewer2DInfo.distance=e.distance,n.multiplyScalar(e.distance)):n.multiplyScalar(100),(e=new THREE.Vector3(0,0,0)).copy(p.viewer2DInfo.center),e.add(n),p.camera.position.copy(e),(n=new THREE.Vector3).copy(p.camera.position),n.add(t),p.camera.lookAt(n)),p.camera.updateProjectionMatrix()},this.camDisTo2DViewer=function(){var e=p.viewer2DInfo.normal.x,t=p.viewer2DInfo.normal.y,n=p.viewer2DInfo.normal.z,i={a:0,b:0,c:0},i=(i.a=p.viewer2DInfo.center.x,i.b=p.viewer2DInfo.center.y,i.c=p.viewer2DInfo.center.z,-(e*i.a+t*i.b+n*i.c)),r={a:0,b:0,c:0};return r.a=p.camera.position.x,r.b=p.camera.position.y,r.c=p.camera.position.z,Math.abs(e*r.a+t*r.b+n*r.c+i)/Math.sqrt(e*e+t*t+n*n)},this.updateViewBoxCamQuaternion=function(e){A.camera.up.applyQuaternion(e),A.camera.position.applyQuaternion(e),A.camera.lookAt(A.center);e=new THREE.Vector3;e.subVectors(p.camera.getCameraTarget(),p.camera.position),e.normalize(),A.updateCurrentFace(e),requestAnimationFrame(A.render)},this.updateViewBoxCamDir=function(e){void 0===e&&((e=new THREE.Vector3).subVectors(p.camera.getCameraTarget(),p.camera.position),e.normalize(),_e.AnimationEdit)&&(e.x<-.999999&&e.setX(-1),e.y<-.999999&&e.setY(-1),e.z<-.999999&&e.setZ(-1),.999999<e.x&&e.setX(1),.999999<e.y&&e.setY(1),.999999<e.z)&&e.setZ(1),A.camera.position.subVectors(A.center,e),A.camera.position.multiplyScalar(A.viewScale),A.camera.up.copy(p.camera.up),A.camera.lookAt(A.center),A.updateCurrentFace(e),A.render()},this.lookByFace=function(e){var t=new THREE.Vector3(0,0,0),e=v.getDestByFace(e),n=t.clone().sub(e.dir),e=(n.normalize(),e.up.clone()),n={from:n.toArray(),to:t.toArray(),up:e.toArray(),sphericalTransition:!0};this.look(n)},this.getView=function(){return this.viewer.camera.getWorldDirection(new THREE.Vector3)},this.getDestByFace=function(e){var t,n,i,r,o=new THREE.Vector3(0,1,0),a=new THREE.Vector3(1,-0,0),s=new THREE.Vector3(0,0,-1),l=(null==y&&(l=new THREE.Vector3(0,-1,0),t=new THREE.Vector3(0,1,0),h=new THREE.Vector3(0,0,-1),n=new THREE.Vector3(0,0,1),i=new THREE.Vector3(1,0,0),c=new THREE.Vector3(-1,0,0),r=new THREE.Vector3,(y={}).top=l,y.bottom=t,y.front=h,y.back=n,y.left=i,y.right=c,y["top,front"]=r.addVectors(l,h).clone(),y["top,right"]=r.addVectors(l,c).clone(),y["top,left"]=r.addVectors(l,i).clone(),y["top,back"]=r.addVectors(l,n).clone(),y["bottom,front"]=r.addVectors(t,h).clone(),y["bottom,right"]=r.addVectors(t,c).clone(),y["bottom,left"]=r.addVectors(t,i).clone(),y["bottom,back"]=r.addVectors(t,n).clone(),y["left,front"]=r.addVectors(i,h).clone(),y["front,right"]=r.addVectors(h,c).clone(),y["right,back"]=r.addVectors(c,n).clone(),y["back,left"]=r.addVectors(n,i).clone(),y["front,top,right"]=r.addVectors(h,l).add(c).clone(),y["back,top,right"]=r.addVectors(n,l).add(c).clone(),y["front,top,left"]=r.addVectors(h,l).add(i).clone(),y["back,top,left"]=r.addVectors(n,l).add(i).clone(),y["front,bottom,right"]=r.addVectors(h,t).add(c).clone(),y["back,bottom,right"]=r.addVectors(n,t).add(c).clone(),y["front,bottom,left"]=r.addVectors(h,t).add(i).clone(),y["back,bottom,left"]=r.addVectors(n,t).add(i).clone()),y[e].clone().normalize()),d=o,c=l.clone().negate();if(1-Math.abs(c.dot(o))<1e-5)for(var h=this.getView().normalize(),u=[s.clone(),s.clone().negate(),a.clone(),a.clone().negate()],p=0<c.dot(o)?1:-1,f=h.clone().add(this.viewer.camera.up.clone().multiplyScalar(p)).normalize(),m=-2,g=0;g<4;g++){var v=f.dot(u[g]);m<v&&(m=v,d=u[g].multiplyScalar(p))}return{dir:l.clone(),up:d.clone()}}}),f=((y.prototype=Object.create(THREE.MeshBasicMaterial.prototype)).constructor=y,(E.prototype=Object.create(THREE.LineBasicMaterial.prototype)).constructor=E,new y({visible:!1,transparent:!1})),_=(((A.prototype=Object.create(THREE.Object3D.prototype)).constructor=A).prototype.update=function(t,n){var i=new THREE.Vector3(0,0,0),r=new THREE.Vector3(0,1,0),o=new THREE.Matrix4;this.traverse(function(e){-1!==e.name.search("E")?e.quaternion.setFromRotationMatrix(o.lookAt(n,i,r)):-1===e.name.search("X")&&-1===e.name.search("Y")&&-1===e.name.search("Z")||e.quaternion.setFromEuler(t)})},(q.prototype=Object.create(A.prototype)).constructor=q,THREE.Object3D.prototype.rotateAroundWorldAxis=(I=new THREE.Quaternion,function(e,t,n){return I.setFromAxisAngle(t,n),this.applyQuaternion(I),this.position.sub(e),this.position.applyQuaternion(I),this.position.add(e),this}),(K.prototype=Object.create(A.prototype)).constructor=K,(J.prototype=Object.create(THREE.Object3D.prototype)).constructor=J,(ee.prototype=Object.create(A.prototype)).constructor=ee,function(o,a,F,N){THREE.Object3D.call(this),a=void 0!==a?a:document,this.object=void 0,this.visible=!1,this.translationSnap=null,this.rotationSnap=null,this.space="world",this.size=1,this.axis=null,this.pickType=null,this.newPosition=new THREE.Vector3;var e,i=this,r="translate",s=!1,l={translate:new q(F,N),rotate:new K,both:new J,scale:new ee};for(e in l){var j=l[e];j.visible=e===r,this.add(j)}var _=1,d={type:"change"},V={type:"mouseDown"},k={type:"mouseUp",mode:r},U={type:"objectChange"},G=new THREE.Raycaster,z=new THREE.Vector2,n=new THREE.Vector3,c=new THREE.Vector3,h=new THREE.Vector3,u=new THREE.Vector3,p=1,W=new THREE.Matrix4,f=new THREE.Vector3,m=new THREE.Matrix4,g=new THREE.Vector3,v=new THREE.Quaternion,A=new THREE.Vector3(1,0,0),y=new THREE.Vector3(0,1,0),E=new THREE.Vector3(0,0,1),M=new THREE.Quaternion,w=new THREE.Quaternion,b=new THREE.Quaternion,x=new THREE.Quaternion,I=new THREE.Quaternion,T=new THREE.Vector3,S=new THREE.Vector3,Y=new THREE.Matrix4,B=new THREE.Matrix4,P=new THREE.Vector3,C=new THREE.Vector3,X=new THREE.Euler,R=new THREE.Matrix4,Q=new THREE.Vector3,Z=new THREE.Euler;function t(e){var t,n;!i.visible||_e.enableBroadcast&&!_e.broadcastMajor||void 0===i.object||!0===s||void 0!==e.button&&0!==e.button||(n=e.changedTouches?e.changedTouches[0]:e,t=null,"both"!=r?t=H(n,l[r].pickers.children):(t=H(n,l[r]._rotatePickers.children))?i.pickType="rotate":(t=H(n,l[r]._translatePickers.children))&&(i.pickType="translate"),n=null,t&&(n=t.object.name,e.preventDefault()),i.axis!==n&&(i.axis=n,i.update(),i.dispatchEvent(d)))}function O(e){if((!_e.enableBroadcast||_e.broadcastMajor)&&i.visible&&void 0!==i.object&&!0!==s&&(void 0===e.button||0===e.button)){var t=e.changedTouches?e.changedTouches[0]:e;if(0===t.button||void 0===t.button){var n=null;if("both"!=r?n=H(t,l[r].pickers.children):(n=H(t,l[r]._rotatePickers.children))?i.pickType="rotate":(n=H(t,l[r]._translatePickers.children))&&(i.pickType="translate"),n){if(e.preventDefault(),e.stopPropagation(),i.dispatchEvent(V),!i.visible)return;i.axis=n.object.name,i.update(),f.copy(Q).sub(C).normalize(),l[r].setActivePlane(i.axis,f);e=H(t,[l[r].activePlane]);e&&(T.copy(i.object.position),S.copy(i.object.scale),Y.extractRotation(i.object.matrix),R.extractRotation(i.object.matrixWorld),B.extractRotation(i.object.parent.matrixWorld),P.setFromMatrixScale(m.getInverse(i.object.parent.matrixWorld)),c.copy(e.point))}}s=!0}}function L(e){var t;_e.enableBroadcast&&!_e.broadcastMajor||void 0===i.object||null===i.axis||!1===s||void 0!==e.button&&0!==e.button||!1!==(t=H(e.changedTouches?e.changedTouches[0]:e,[l[r].activePlane]))&&(e.preventDefault(),e.stopPropagation(),i.visible)&&(n.copy(t.point),"translate"===r||"translate"==i.pickType?(n.sub(c),n.multiply(P),"local"===i.space&&(n.applyMatrix4(m.getInverse(R)),-1===i.axis.search("X")&&(n.x=0),-1===i.axis.search("Y")&&(n.y=0),-1===i.axis.search("Z")&&(n.z=0),n.applyMatrix4(Y),n.multiplyScalar(_),i.object.position.copy(T),i.object.position.add(n),i.newPosition=i.object.position.clone()),"world"!==i.space&&-1===i.axis.search("XYZ")||(-1===i.axis.search("X")&&(n.x=0),-1===i.axis.search("Y")&&(n.y=0),-1===i.axis.search("Z")&&(n.z=0),n.applyMatrix4(m.getInverse(B)),i.object.position.copy(T),i.object.position.add(n)),null!==i.translationSnap&&("local"===i.space&&i.object.position.applyMatrix4(m.getInverse(R)),-1!==i.axis.search("X")&&(i.object.position.x=Math.round(i.object.position.x/i.translationSnap)*i.translationSnap),-1!==i.axis.search("Y")&&(i.object.position.y=Math.round(i.object.position.y/i.translationSnap)*i.translationSnap),-1!==i.axis.search("Z")&&(i.object.position.z=Math.round(i.object.position.z/i.translationSnap)*i.translationSnap),"local"===i.space)&&i.object.position.applyMatrix4(R)):"scale"===r?(n.sub(c),n.multiply(P),"local"===i.space&&("XYZ"===i.axis?(p=1+n.y/Math.max(S.x,S.y,S.z),i.object.scale.x=S.x*p,i.object.scale.y=S.y*p,i.object.scale.z=S.z*p):(n.applyMatrix4(m.getInverse(R)),"X"===i.axis&&(i.object.scale.x=S.x*(1+n.x/S.x)),"Y"===i.axis&&(i.object.scale.y=S.y*(1+n.y/S.y)),"Z"===i.axis&&(i.object.scale.z=S.z*(1+n.z/S.z))))):"rotate"!==r&&"rotate"!=i.pickType||(n.sub(C),n.multiply(P),g.copy(c).sub(C),g.multiply(P),"E"===i.axis?(n.applyMatrix4(m.getInverse(W)),g.applyMatrix4(m.getInverse(W)),h.set(Math.atan2(n.z,n.y),Math.atan2(n.x,n.z),Math.atan2(n.y,n.x)),u.set(Math.atan2(g.z,g.y),Math.atan2(g.x,g.z),Math.atan2(g.y,g.x)),v.setFromRotationMatrix(m.getInverse(B)),I.setFromAxisAngle(f,h.z-u.z),M.setFromRotationMatrix(R),v.multiplyQuaternions(v,I),v.multiplyQuaternions(v,M),i.object.quaternion.copy(v)):"XYZE"===i.axis?(I.setFromEuler(n.clone().cross(g).normalize()),v.setFromRotationMatrix(m.getInverse(B)),w.setFromAxisAngle(I,-n.clone().angleTo(g)),M.setFromRotationMatrix(R),v.multiplyQuaternions(v,w),v.multiplyQuaternions(v,M),i.object.quaternion.copy(v)):"local"===i.space?(n.applyMatrix4(m.getInverse(R)),g.applyMatrix4(m.getInverse(R)),h.set(Math.atan2(n.z,n.y),Math.atan2(n.x,n.z),Math.atan2(n.y,n.x)),u.set(Math.atan2(g.z,g.y),Math.atan2(g.x,g.z),Math.atan2(g.y,g.x)),M.setFromRotationMatrix(Y),null!==i.rotationSnap?(w.setFromAxisAngle(A,Math.round((h.x-u.x)/i.rotationSnap)*i.rotationSnap),b.setFromAxisAngle(y,Math.round((h.y-u.y)/i.rotationSnap)*i.rotationSnap),x.setFromAxisAngle(E,Math.round((h.z-u.z)/i.rotationSnap)*i.rotationSnap)):(w.setFromAxisAngle(A,h.x-u.x),b.setFromAxisAngle(y,h.y-u.y),x.setFromAxisAngle(E,h.z-u.z)),"X"===i.axis&&M.multiplyQuaternions(M,w),"Y"===i.axis&&M.multiplyQuaternions(M,b),"Z"===i.axis&&M.multiplyQuaternions(M,x),i.object.quaternion.copy(M)):"world"===i.space&&(h.set(Math.atan2(n.z,n.y),Math.atan2(n.x,n.z),Math.atan2(n.y,n.x)),u.set(Math.atan2(g.z,g.y),Math.atan2(g.x,g.z),Math.atan2(g.y,g.x)),v.setFromRotationMatrix(m.getInverse(B)),null!==i.rotationSnap?(w.setFromAxisAngle(A,Math.round((h.x-u.x)/i.rotationSnap)*i.rotationSnap),b.setFromAxisAngle(y,Math.round((h.y-u.y)/i.rotationSnap)*i.rotationSnap),x.setFromAxisAngle(E,Math.round((h.z-u.z)/i.rotationSnap)*i.rotationSnap)):(w.setFromAxisAngle(A,h.x-u.x),b.setFromAxisAngle(y,h.y-u.y),x.setFromAxisAngle(E,h.z-u.z)),M.setFromRotationMatrix(R),"X"===i.axis&&v.multiplyQuaternions(v,w),"Y"===i.axis&&v.multiplyQuaternions(v,b),"Z"===i.axis&&v.multiplyQuaternions(v,x),v.multiplyQuaternions(v,M),i.object.quaternion.copy(v))),i.update(),i.dispatchEvent(d),i.dispatchEvent(U))}function D(e){_e.enableBroadcast&&!_e.broadcastMajor||(e.preventDefault(),!i.visible)||void 0!==e.button&&0!==e.button||(s&&null!==i.axis&&(k.mode=r,i.dispatchEvent(k),s=!1,i.dispatchEvent({type:"objectChange",mouseUp:!0})),s=!1,"TouchEvent"in window&&e instanceof TouchEvent?(i.axis=null,i.update(),i.dispatchEvent(d)):t(e))}function H(e,t){var n=a.getBoundingClientRect(),i=n.width,r=n.height,i=(null!=a.clientWidth&&null!=a.clientHeight&&(10<Math.abs(i-a.clientWidth)&&(i=a.clientWidth),10<Math.abs(r-a.clientHeight))&&(r=a.clientHeight),(e.clientX-n.left)/i),e=(e.clientY-n.top)/r,n=(z.set(2*i-1,-2*e+1),o.setCastRay(G,z.x,z.y),G.intersectObjects(t,!0));return n[0]||!1}Se.isMobileDevice()?(a.addEventListener("touchstart",O,!1),a.addEventListener("touchmove",t,!1),a.addEventListener("touchmove",L,!1),a.addEventListener("touchend",D,!1),a.addEventListener("touchcancel",D,!1)):(a.addEventListener("mousedown",O,!1),a.addEventListener("mousemove",t,!1),a.addEventListener("mousemove",L,!1),a.addEventListener("mouseup",D,!1)),this.setTranslateScale=function(e){_=e},this.isDragging=function(){return s},this.isSelected=function(){return null!=i.axis},this.setOldPosition=function(e){e&&T.copy(e)},this.getOldPosition=function(){return T},this.dispose=function(){Se.isMobileDevice()?(a.removeEventListener("touchstart",O),a.removeEventListener("touchmove",t),a.removeEventListener("touchmove",L),a.removeEventListener("touchend",D),a.removeEventListener("touchcancel",D),a.removeEventListener("touchleave",D)):(a.removeEventListener("mousedown",O),a.removeEventListener("mousemove",t),a.removeEventListener("mousemove",L),a.removeEventListener("mouseup",D),a.removeEventListener("mouseout",D))},this.attach=function(e){this.object=e,this.visible=!0,this.update()},this.detach=function(){this.object=void 0,this.visible=!1,this.axis=null},this.getMode=function(){return r},this.setMode=function(e){for(var t in"scale"===(r=e||r)&&(i.space="local"),l)l[t].visible=t===r;this.update(),i.dispatchEvent(d),i.pickType=null},this.setTranslationSnap=function(e){i.translationSnap=e},this.setRotationSnap=function(e){i.rotationSnap=e},this.setSize=function(e){i.size=e,this.update(),i.dispatchEvent(d)},this.setSpace=function(e){i.space=e,this.update(),i.dispatchEvent(d)},this.update=function(){var e,t,n;void 0!==i.object&&(i.object.updateMatrixWorld(),C.setFromMatrixPosition(i.object.matrixWorld),X.setFromRotationMatrix(m.extractRotation(i.object.matrixWorld)),o.updateMatrixWorld(),Q.setFromMatrixPosition(o.matrixWorld),Z.setFromRotationMatrix(m.extractRotation(o.matrixWorld)),o.updateMatrix(),e=o.getCameraTarget(),t=o.position,(n=new THREE.Vector3).subVectors(e,t),e=C.clone(),e=o.isPerspective?e.sub(t).dot(n.normalize()):1.2*n.length(),t=o.fov,n=120*(2*e*Math.tan(THREE.Math.degToRad(.5*t)))/a.height*i.size,Se.isMobileDevice()&&(n*=3),this.position.copy(C),this.scale.set(n,n,n),f.copy(Q).sub(C).normalize(),"local"===i.space?l[r].update(X,f):"world"===i.space&&l[r].update(new THREE.Euler,f),l[r].highlight(i.axis,i.pickType))}}),z=(_.prototype=Object.create(THREE.Object3D.prototype),_.prototype.constructor=_,function(t,n,i,e){var r=i.camera,o=e._transformScene,a=null,s=null,l=(new THREE.Plane,new THREE.Raycaster),d=new THREE.Vector2,c=(new THREE.Vector3,null),h=!1,u=!1,p=!1,f=!0,m=(this._enabled=!0,1),g=this,v=!1,A=null;function y(){n.addEventListener("mousemove",w,!1),n.addEventListener("mousedown",M,!1),n.addEventListener("mouseup",b,!1),null==a&&((a=new _(r,n)).setMode("translate"),a.setSpace("local"),a.setSize(m),o.add(a),a.addEventListener("change",function(){a.update(),s.update(),i.render()})),null==s&&((s=new _(r,n)).setMode("both"),s.setSpace("local"),s.setSize(m),o.add(s),s.addEventListener("change",function(){s.update(),a.update(),i.render()})),v=!0}function E(){null!=a&&a.detach(a.object),null!=s&&s.detach(s.object),n.removeEventListener("mousemove",w,!1),n.removeEventListener("mousedown",M,!1),n.removeEventListener("mouseup",b,!1),v=!1}function M(e){h=!(u=!0),A=n.style.cursor,e.preventDefault(),e.stopPropagation(),r instanceof ge?(r.setCastRay(l,d.x,d.y),l.camera=r):l.setFromCamera(d,r);e=l.intersectObjects(t);0<e.length&&(c=e[0].object,n.style.cursor="move",g.dispatchEvent({type:"mousedown",object:c}))}function w(e){e.preventDefault(),e.stopPropagation();var t=n.getBoundingClientRect();d.x=(e.clientX-t.left)/t.width*2-1,d.y=2*-((e.clientY-t.top)/t.height)+1,u&&(h=!0,s.update(),a.update(),i.render())}function b(e){null!=e&&e.preventDefault(),h?(g.dispatchEvent({type:"mouseup",object:c}),u=!1):(a.detach(a.object),s.detach(s.object),null!=c&&g.attachTo(c)),i.render(),c=null,n.style.cursor=A,u=!1}this.isActive=function(){return v},this.getCurrAttachObj=function(){return p?a.object:f?s.object:void 0},this.setSize=function(e){m=e,null!=a&&a.setSize(e),null!=s&&s.setSize(e),this.update(),i.render()},this.addEventListener=function(e,t,n){"rotate"==e?s.addEventListener(t,n):"transform"==e?a.addEventListener(t,n):"both"==e&&(s.addEventListener(t,n),a.addEventListener(t,n))},this.getRotateControls=function(){return s},this.getTransformControls=function(){return a},this.attachTo=function(e){a.detach(a.object),s.detach(s.object),null!=e&&e instanceof THREE.Sprite&&("pointlightctrl"==e.name||"hemilightctrl"==e.name?(f=!(p=!0),a.attach(e.parent)):"dirlightctrl"!=e.name&&"spotlightctrl"!=e.name||(f=!(p=!1),s.attach(e.parent))),i.render()},this.detach=function(){null!=a&&a.detach(a.object),null!=s&&s.detach(s.object)},this.update=function(){null!=a&&(a.update(),a.updateMatrixWorld(!0)),null!=s&&(s.update(),s.updateMatrixWorld(!0))},this.setTransformEnabled=function(e){p=e},this.setRotateEnabled=function(e){f=e},this.setEnabled=function(e){e?this._enabled||y():this._enabled&&E(),this._enabled=e},this.activate=y,this.deactivate=E,this.dispose=function(){E()},this.isSelected=function(){return null!=c||!(null==a||!a.isSelected())||!(null==s||!s.isSelected())}}),He=(z.prototype=Object.create(THREE.EventDispatcher.prototype),z.prototype.constructor=z,function(e){THREE.EventDispatcher.call(this);void 0===(t=e.renderer.domElement)&&document;var t,n=this,i=null,r=new THREE.Box3,o=void 0,a=!1;this.viewer=e,this.enabled=!0,this.staticmeasureOp=null,this.staticAnnotation=null,this.staticDrawGeomOp=null,this.render=function(e){n.dispatchEvent(e||{type:"render"})},this.update=function(){null!=i&&i.update()},this.onOpRender=function(e){n.render(e)},this.onOpEvent=function(e){n.dispatchEvent({type:"event",event:e})},this.setOperator=function(e){n.releaseOperator(),this.viewer.is2DModel&&!_e.New2DAPPMeasure&&null!=this.staticmeasureOp&&"OpMeasure"!=e.type&&this.viewer.OpMeasureRelease(),null!=this.staticmeasureOp&&"OpMeasure"==e.type?i=this.staticmeasureOp:null!=this.staticDrawGeomOp&&"OpDrawGeom"==e.type?(i=this.staticDrawGeomOp).init():null!=this.staticAnnotation&&"OpAnnotationNew"==e.type?i=this.staticAnnotation:(e.create(),"OpMeasure"==(i=e).type?this.staticmeasureOp=i:"OpDrawGeom"==e.type?(this.staticDrawGeomOp=i).init():"OpAnnotationNew"==e.type&&(this.staticAnnotation=i)),i.addEventListener("render",n.onOpRender),i.addEventListener("mouseEvent",n.onOpEvent),i.addEventListener("event",n.onOpEvent),this.viewer.clearCenterCross&&(this.viewer.clearCenterCross(),"OpOrbit"==e.type)&&"FirstPerson"==this.viewer.getModelOperationMode()&&this.viewer.drawCenterCross()},this.getOperator=function(){return i},this.releaseOperator=function(){var e=i;null!=e&&("OpMeasure"!=e.type&&"OpDrawGeom"!=e.type&&"OpAnnotationNew"!=e.type?e.release():e.clearFlag(),this.viewer.is2DModel&&Se.isMobileDevice()&&_e.New2DAPPMeasure&&"OpMeasure"==e.type||e.removeEventListener("render",n.onOpRender),e.removeEventListener("mouseEvent",n.onOpEvent),e.removeEventListener("event",n.onOpEvent))},this.setBoundingBox=function(e,t){r.set(e,t),a=!0,n.resetExplosionBoundingBox()},this.getBoundingBox=function(){return r},this.IsBoundingBoxUpdated=function(){return a},this.SetBoundingBoxUpdated=function(e){a=e},this.setExplosionBoundingBox=function(e,t){(o=void 0===o?new THREE.Box3:o).set(e,t)},this.getExplosionBoundingBox=function(){return o},this.resetExplosionBoundingBox=function(){o=void 0}}),Fe=(He.prototype=Object.create(THREE.EventDispatcher.prototype),function(e){THREE.EventDispatcher.call(this);var t=this,n=null;this.viewer=e,this.render=function(){t.dispatchEvent({type:"render"})},this.update=function(){null!=n&&n.update()},this.onOpRender=function(){t.render()},this.onOpEvent=function(e){t.dispatchEvent({type:"event",event:e})},this.setOperator=function(e){t.releaseOperator(),e.create(),e.addEventListener("render",t.onOpRender),e.addEventListener("mouseEvent",t.onOpEvent),e.addEventListener("event",t.onOpEvent),n=e},this.getOperator=function(){return n},this.releaseOperator=function(){var e=n;null!=e&&(e.release(),e.removeEventListener("render",t.onOpRender),e.removeEventListener("mouseEvent",t.onOpEvent),e.removeEventListener("event",t.onOpEvent))}}),Ne=(Fe.prototype=Object.create(THREE.EventDispatcher.prototype),function(o,a){THREE.Object3D.call(this);function e(e,t){for(var n in e)for(var i=e[n].length;i--;){var r=e[n][i][0],o=e[n][i][1],a=e[n][i][2];r.name=n,o&&r.position.set(o[0],o[1],o[2]),a&&r.rotation.set(a[0],a[1],a[2]),t.add(r)}}var t=new THREE.CylinderGeometry(0,.05,.2,12,1,!1),n=new THREE.Mesh(t),n=(n.position.y=.5,n.updateMatrix(),t.applyMatrix(n.matrix),new THREE.BufferGeometry),i=(n.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,1,0,0],3)),new THREE.BufferGeometry),r=(i.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,1,0],3)),new THREE.BufferGeometry),s=(r.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,0,1],3)),{}),n=(s.X=[[new THREE.Mesh(t,new y({color:16711680})),[.5,0,0],[0,0,-Math.PI/2]],[new THREE.Line(n,new E({color:16711680}))]],s.Y=[[new THREE.Mesh(t,new y({color:65280})),[0,.5,0]],[new THREE.Line(i,new E({color:65280}))]],s.Z=[[new THREE.Mesh(t,new y({color:255})),[0,0,.5],[Math.PI/2,0,0]],[new THREE.Line(r,new E({color:255}))]],new y({visible:!1,transparent:!1})),i={},l=(i.X=[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],i.Y=[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],i.Z=[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],this.axes=new THREE.Object3D,this.pickers=new THREE.Object3D,e(s,this.axes),e(i,this.pickers),this.add(this.axes),this.add(this.pickers),this),t=void 0!==a?a:document,d=(this.size=1,this.type="CoordSystem",this.pickedAxis=null,this.axis=null,this.parentNode=void 0,this.visible=!1,new THREE.Raycaster),c=new THREE.Vector2,h=new THREE.Vector3,u=new THREE.Quaternion,p=new THREE.Vector3;new THREE.Vector3;function f(e){var t,n;!l.visible||_e.enableBroadcast&&!_e.broadcastMajor||void 0===l.parentNode||void 0!==e.button&&0!==e.button||0!==(t=e.changedTouches?e.changedTouches[0]:e).button&&void 0!==t.button||(n=null,(n=A(t,l.pickers.children))?(e.preventDefault(),e.stopPropagation(),l.axis=n.object.name,l.update()):l.axis=null)}function m(e){}function g(e){}function v(e){var t,n;!l.visible||_e.enableBroadcast&&!_e.broadcastMajor||void 0===l.parentNode||void 0!==e.button&&0!==e.button||(n=t=null,(t=A(e.changedTouches?e.changedTouches[0]:e,l.pickers.children))&&(n=t.object.name,e.preventDefault()),l.pickedAxis!==n&&(l.pickedAxis=n,l.update()))}function A(e,t){var n=a.getBoundingClientRect(),i=n.width,r=n.height,i=(null!=a.clientWidth&&null!=a.clientHeight&&(10<Math.abs(i-a.clientWidth)&&(i=a.clientWidth),10<Math.abs(r-a.clientHeight))&&(r=a.clientHeight),(e.clientX-n.left)/i),e=(e.clientY-n.top)/r,n=(c.set(2*i-1,-2*e+1),o.setCastRay(d,c.x,c.y),d.intersectObjects(t,!0));return n[0]||!1}Se.isMobileDevice()?(t.addEventListener("touchstart",f,!1),t.addEventListener("touchmove",v,!1),t.addEventListener("touchmove",g,!0),t.addEventListener("touchend",m,!1),t.addEventListener("touchcancel",m,!1)):(t.addEventListener("mousedown",f,!1),t.addEventListener("mousemove",v,!1),t.addEventListener("mousemove",g,!0),t.addEventListener("mouseup",m,!1)),this.dispose=function(){Se.isMobileDevice()?(a.removeEventListener("touchstart",f),a.removeEventListener("touchmove",v),a.removeEventListener("touchmove",g),a.removeEventListener("touchend",m),a.removeEventListener("touchcancel",m)):(a.removeEventListener("mousedown",f),a.removeEventListener("mousemove",v),a.removeEventListener("mousemove",g),a.removeEventListener("mouseup",m))},this.isSelected=function(){return null!=this.axis},this.attach=function(e){this.parentNode=e,this.visible=!0,this.update()},this.detach=function(){this.parentNode=void 0,this.visible=!1,this.pickedAxis=null,this.axis=null},this.setSize=function(e){l.size=e,this.update()},this.highlight=function(t){this.traverse(function(e){e.material&&e.material.highlight&&(e.name===t?e.material.highlight(!0):e.material.highlight(!1))})},this.axisVisible=function(t,n){this.traverse(function(e){e.material&&e.material.highlight&&(e.name===n&&t?e.visible=!0:e.visible=!1)})},this.getAxisVisible=function(t){var n=!1;return this.traverse(function(e){e.material&&e.material.highlight&&e.name===t&&(n=e.visible)}),n},this.update=function(){if(void 0!==l.parentNode){l.visible=l.parentNode.visible;var e=l.parentNode.getModel();if("explodeObject"==l.name){var t=e.viewer.controls.getBoundingBox(),t=(t||renturn,t.getCenter(new THREE.Vector3));if(!t)return;h=t.clone()}else{if(!l.parentNode.worldMatrix)return;l.parentNode.worldMatrix.decompose(h,u,p)}o.updateMatrix();var t=o.getCameraTarget(),n=o.position,i=new THREE.Vector3,t=(i.subVectors(t,n),h.clone()),t=o.isPerspective?t.sub(n).dot(i.normalize()):1.2*i.length(),n=o.fov,i=2*t*Math.tan(THREE.Math.degToRad(.5*n)),t=e.viewer.renderer.domElement.height,n=70*i*e.viewer.renderer.getPixelRatio()/t;Se.isMobileDevice()&&(n*=3),n*=l.size,l.position.copy(h),l.quaternion.copy(u),l.scale.set(n,n,n),l.updateMatrixWorld(!0),this.highlight(l.axis)}}}),je=(Ne.prototype=Object.create(THREE.Object3D.prototype),Ne.prototype.constructor=Ne,{uniforms:{tDiffuse:{type:"t",value:null},opacity:{type:"f",value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","gl_FragColor = opacity * texel;","}"].join("\n")}),ke={uniforms:{tDiffuse:{type:"t",value:null}},defines:{},vertexShader:["varying vec2 vUv;","void main() {","vUv = vec2(uv.x, uv.y);","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","#ifdef HORIZONTAL","#define GET_UV(X) vec2(vUv.x + RESOLUTION*(X), vUv.y)","#else","#define GET_UV(Y) vec2(vUv.x, vUv.y + RESOLUTION*(Y))","#endif","#define BLUR_RADIUS (3.0 * SIGMA + 0.5)","#define SIGMASQ2 (2.0 * SIGMA * SIGMA)","#define GAUSS_EXP(X) ( exp(-(X)*(X)/SIGMASQ2) )","void main() {","vec4 sum = vec4( 0.0 );","float total = 0.0;","for (float x=-BLUR_RADIUS; x<=BLUR_RADIUS; x+=1.0) {","float ratio = GAUSS_EXP(x);","sum += texture2D(tDiffuse, GET_UV(x)) * ratio;","total += ratio;","}","sum /= total;","gl_FragColor = sum;","}"].join("\n")},Ue={uniforms:{tDiffuse:{type:"t",value:null}},defines:{},vertexShader:["varying vec2 vUv;","void main() {","vUv = vec2(uv.x, uv.y);","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","#ifdef HORIZONTAL","#define GET_UV(X) vec2(vUv.x + RESOLUTION*(X), vUv.y)","#else","#define GET_UV(Y) vec2(vUv.x, vUv.y + RESOLUTION*(Y))","#endif","void main() {","vec4 sum = texture2D(tDiffuse, GET_UV(0.0));","#if BLUR_LEVEL == 1","sum += texture2D(tDiffuse, GET_UV(-1.0)) * 0.882496903;","sum += texture2D(tDiffuse, GET_UV(1.0)) * 0.882496903;","sum += texture2D(tDiffuse, GET_UV(-2.0)) * 0.60653066;","sum += texture2D(tDiffuse, GET_UV(2.0)) * 0.60653066;","sum += texture2D(tDiffuse, GET_UV(-3.0)) * 0.324652467;","sum += texture2D(tDiffuse, GET_UV(3.0)) * 0.324652467;","sum += texture2D(tDiffuse, GET_UV(-4.0)) * 0.135335283;","sum += texture2D(tDiffuse, GET_UV(4.0)) * 0.135335283;","sum *= 0.204163689;","#elif BLUR_LEVEL == 2","sum += texture2D(tDiffuse, GET_UV(-1.0)) * 0.960005441;","sum += texture2D(tDiffuse, GET_UV(1.0)) * 0.960005441;","sum += texture2D(tDiffuse, GET_UV(-2.0)) * 0.849365817;","sum += texture2D(tDiffuse, GET_UV(2.0)) * 0.849365817;","sum += texture2D(tDiffuse, GET_UV(-3.0)) * 0.692569324;","sum += texture2D(tDiffuse, GET_UV(3.0)) * 0.692569324;","sum += texture2D(tDiffuse, GET_UV(-4.0)) * 0.520450121;","sum += texture2D(tDiffuse, GET_UV(4.0)) * 0.520450121;","sum += texture2D(tDiffuse, GET_UV(-5.0)) * 0.360447789;","sum += texture2D(tDiffuse, GET_UV(5.0)) * 0.360447789;","sum += texture2D(tDiffuse, GET_UV(-6.0)) * 0.230066299;","sum += texture2D(tDiffuse, GET_UV(6.0)) * 0.230066299;","sum += texture2D(tDiffuse, GET_UV(-7.0)) * 0.135335283;","sum += texture2D(tDiffuse, GET_UV(7.0)) * 0.135335283;","sum *= 0.117695797;","#elif BLUR_LEVEL == 3","sum += texture2D(tDiffuse, GET_UV(-1.0)) * 0.988235431;","sum += texture2D(tDiffuse, GET_UV(1.0)) * 0.988235431;","sum += texture2D(tDiffuse, GET_UV(-2.0)) * 0.953765659;","sum += texture2D(tDiffuse, GET_UV(2.0)) * 0.953765659;","sum += texture2D(tDiffuse, GET_UV(-3.0)) * 0.898967069;","sum += texture2D(tDiffuse, GET_UV(3.0)) * 0.898967069;","sum += texture2D(tDiffuse, GET_UV(-4.0)) * 0.827497567;","sum += texture2D(tDiffuse, GET_UV(4.0)) * 0.827497567;","sum += texture2D(tDiffuse, GET_UV(-5.0)) * 0.743893062;","sum += texture2D(tDiffuse, GET_UV(5.0)) * 0.743893062;","sum += texture2D(tDiffuse, GET_UV(-6.0)) * 0.653093155;","sum += texture2D(tDiffuse, GET_UV(6.0)) * 0.653093155;","sum += texture2D(tDiffuse, GET_UV(-7.0)) * 0.559964631;","sum += texture2D(tDiffuse, GET_UV(7.0)) * 0.559964631;","sum += texture2D(tDiffuse, GET_UV(-8.0)) * 0.468885606;","sum += texture2D(tDiffuse, GET_UV(8.0)) * 0.468885606;","sum += texture2D(tDiffuse, GET_UV(-9.0)) * 0.383437025;","sum += texture2D(tDiffuse, GET_UV(9.0)) * 0.383437025;","sum += texture2D(tDiffuse, GET_UV(-10.0)) * 0.30622598;","sum += texture2D(tDiffuse, GET_UV(10.0)) * 0.30622598;","sum += texture2D(tDiffuse, GET_UV(-11.0)) * 0.238842089;","sum += texture2D(tDiffuse, GET_UV(11.0)) * 0.238842089;","sum *= 0.06646455;","#endif","gl_FragColor = sum;","}"].join("\n")},Ge=(["varying vec2 vUv;","void main() {","vUv = vec2(uv.x, uv.y);","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),["uniform sampler2D tDiffuse;","varying vec2 vUv;","#define repeats 40.0","vec3 texture(vec2 uv) {","return texture2D(tDiffuse,uv).rgb;","}","float grid(float var, float size) {","return floor(var*size)/size;","}","float rand(vec2 co){","return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);","}","void main() {","vec3 blurred_image = vec3(0.0);","for(float i=0.0;i<repeats;i++){","vec2 q = vec2(cos(degrees((i/repeats)*360.0)),sin(degrees((i/repeats)*360.0))) * (rand(vec2(i,vUv.x+vUv.y))+BLUR_AMOUNT);","vec2 uv2 = vUv+(q*BLUR_AMOUNT);","blurred_image += texture(uv2)/2.0;","q = vec2(cos(degrees((i/repeats)*360.0)),sin(degrees((i/repeats)*360.0))) * (rand(vec2(i+2.,vUv.x+vUv.y+24.0))+BLUR_AMOUNT);","uv2 = vUv+(q*BLUR_AMOUNT);","blurred_image += texture(uv2)/2.0;","}","blurred_image /= repeats;","gl_FragColor = vec4(blurred_image,1.0);","}"].join("\n"),new THREE.Vector2(1/1024,1/512),["varying vec2 vUv;","void main() {"," vUv= uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),["uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","#define FXAA_SPAN_MAX 8.0","#define FXAA_EDGE_THRESHOLD_MIN (1.0/24.0)","#define FXAA_EDGE_THRESHOLD (1.0/8.0)","#define FXAA_SEARCH_THRESHOLD (1.0/4.0)","#define FXAA_SEARCH_STEPS 16","#define FXAA_SUBPIX_TRIM (1.0/4.0)","#define FXAA_SUBPIX_TRIM_SCALE (1.0/(1.0 - FXAA_SUBPIX_TRIM))","#define FXAA_SUBPIX_CAP (3.0/4.0)","float FxaaLuma(vec3 rgb){"," return rgb.y*(0.587/0.299) + rgb.x;","}","vec3 FxaaLerp3(vec3 a, vec3 b, float amountOfA) {"," return (vec3(-amountOfA) * b) +"," ((a * vec3(amountOfA)) + b); }","void main() {","vec3 rgbN = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 0.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 0.0 ) ) * resolution ).xyz;","vec3 rgbW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 0.0 ) ) * resolution ).xyz;","vec3 rgbS = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 0.0, 1.0 ) ) * resolution ).xyz;","vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );","vec3 rgbM = rgbaM.xyz;","float lumaN = FxaaLuma(rgbN);","float lumaE = FxaaLuma(rgbE);","float lumaW = FxaaLuma(rgbW);","float lumaS = FxaaLuma(rgbS);","float lumaM = FxaaLuma(rgbM);","float lumaMin = min( lumaM, min( min( lumaN, lumaW ), min( lumaS, lumaE ) ) );","float lumaMax = max( lumaM, max( max( lumaN, lumaW) , max( lumaS, lumaE ) ) );","float range = lumaMax -lumaMin;","if(range< max(FXAA_EDGE_THRESHOLD_MIN, lumaMax * FXAA_EDGE_THRESHOLD)) {"," gl_FragColor = rgbaM; return;","}","vec3 rgbL = rgbN + rgbW + rgbM + rgbE + rgbS;","float lumaL = (lumaN + lumaW + lumaE + lumaS) * 0.25;","float rangeL = abs(lumaL - lumaM);","float blendL = max(0.0, (rangeL / range) - FXAA_SUBPIX_TRIM) * FXAA_SUBPIX_TRIM_SCALE;","blendL = min(FXAA_SUBPIX_CAP, blendL);","vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;","vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;","float opacity = rgbaM.w;","rgbL += (rgbNW + rgbNE + rgbSW + rgbSE);","rgbL *= vec3(1.0/9.0);","float lumaNW = FxaaLuma( rgbNW);","float lumaNE = FxaaLuma( rgbNE);","float lumaSW = FxaaLuma( rgbSW);","float lumaSE = FxaaLuma( rgbSE);","float edgeVert = abs((0.25 * lumaNW) + (-0.5 * lumaN) + (0.25 * lumaNE)) +"," abs((0.50 * lumaW ) + (-1.0 * lumaM) + (0.50 * lumaE )) +"," abs((0.25 * lumaSW) + (-0.5 * lumaS) + (0.25 * lumaSE));","float edgeHorz = abs((0.25 * lumaNW) + (-0.5 * lumaW) + (0.25 * lumaSW)) +"," abs((0.50 * lumaN ) + (-1.0 * lumaM) + (0.50 * lumaS )) +"," abs((0.25 * lumaNE) + (-0.5 * lumaE) + (0.25 * lumaSE));","bool horzSpan = edgeHorz >= edgeVert;","float lengthSign = horzSpan ? -resolution.y : -resolution.x;","if(!horzSpan){"," lumaN = lumaW;"," lumaS = lumaE;","}","float gradientN = abs(lumaN - lumaM);","float gradientS = abs(lumaS - lumaM);","lumaN = (lumaN + lumaM) * 0.5;","lumaS = (lumaS + lumaM) * 0.5;","bool pairN = gradientN >= gradientS;","if(!pairN){"," lumaN = lumaS;"," gradientN = gradientS;"," lengthSign *= -1.0;","}","vec2 posN;","posN.x = vUv.x + (horzSpan ? 0.0 : lengthSign * 0.5);","posN.y = vUv.y + (horzSpan ? lengthSign * 0.5 : 0.0);","gradientN *= FXAA_SEARCH_THRESHOLD;","vec2 posP = posN;","vec2 offNP = horzSpan ? vec2(resolution.x, 0.0) : vec2(0.0, resolution.y);","float lumaEndN = lumaN;","float lumaEndP = lumaN;","bool doneN = false;","bool doneP = false;","posN += offNP * vec2(-1.0, -1.0);","posP += offNP * vec2( 1.0, 1.0);","for(int i = 0; i < FXAA_SEARCH_STEPS; i++) {"," if(!doneN) lumaEndN = FxaaLuma(texture2D( tDiffuse, posN.xy).xyz);"," if(!doneP) lumaEndP = FxaaLuma(texture2D( tDiffuse, posP.xy).xyz);"," doneN = doneN || (abs(lumaEndN - lumaN) >= gradientN);"," doneP = doneP || (abs(lumaEndP - lumaN) >= gradientN);"," if(doneN && doneP) break;"," if(!doneN) posN -= offNP;"," if(!doneP) posP += offNP;","}","float dstN = horzSpan ? vUv.x - posN.x : vUv.y - posN.y;","float dstP = horzSpan ? posP.x - vUv.x : posP.y - vUv.y;","bool directionN = dstN < dstP;","lumaEndN = directionN ? lumaEndN : lumaEndP;","if(((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))"," lengthSign = 0.0;","float spanLength = (dstP + dstN);","dstN = directionN ? dstN : dstP;","float subPixelOffset = (0.5 + (dstN * (-1.0/spanLength))) * lengthSign;","vec3 rgbF = texture2D(tDiffuse, vec2("," vUv.x + (horzSpan ? 0.0 : subPixelOffset),"," vUv.y + (horzSpan ? subPixelOffset : 0.0))).xyz;","gl_FragColor = vec4(FxaaLerp3(rgbL, rgbF, blendL), opacity);","}"].join("\n"),{uniforms:{tDiffuse:{type:"t",value:null},resolution:{type:"v2",value:new THREE.Vector2(1/1024,1/512)}},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","#define FXAA_REDUCE_MIN (1.0/128.0)","#define FXAA_REDUCE_MUL (1.0/8.0)","#define FXAA_SPAN_MAX 8.0","void main() {","vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;","vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;","vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );","vec3 rgbM = rgbaM.xyz;","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float lumaNW = dot( rgbNW, luma );","float lumaNE = dot( rgbNE, luma );","float lumaSW = dot( rgbSW, luma );","float lumaSE = dot( rgbSE, luma );","float lumaM = dot( rgbM, luma );","float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );","float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );","vec2 dir;","dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));","dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));","float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );","float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );","dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),","max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),","dir * rcpDirMin)) * resolution;","vec4 rgbA = (1.0/2.0) * (","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (1.0/3.0 - 0.5)) +","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (2.0/3.0 - 0.5)));","vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (0.0/3.0 - 0.5)) +","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (3.0/3.0 - 0.5)));","float lumaB = dot(rgbB, vec4(luma, 0.0));","if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {","gl_FragColor = rgbA;","} else {","gl_FragColor = rgbB;","}","}"].join("\n")}),ze={uniforms:{tDiffuse:{type:"t",value:null},resolution:{type:"v2",value:new THREE.Vector2(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vPos;","varying vec4 vPosPos;","void main() {","vPos = uv;","vPosPos.xy = uv + vec2(-0.5, -0.5) * resolution;","vPosPos.zw = uv + vec2( 0.5, 0.5) * resolution;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define FXAA_EDGE_SHARPNESS (8.0)","#define FXAA_EDGE_THRESHOLD (0.125)","#define FXAA_EDGE_THRESHOLD_MIN (0.05)","#define FXAA_RCP_FRAME_OPT (0.50)","#define FXAA_RCP_FRAME_OPT2 (2.0)","uniform sampler2D tDiffuse;","uniform highp vec2 resolution;","varying vec2 vPos;","varying vec4 vPosPos;","float FxaaLuma(vec3 rgb) {","return dot(rgb, vec3(0.299, 0.587, 0.114));","}","void main() {","float lumaNw = FxaaLuma(texture2D(tDiffuse, vPosPos.xy).rgb);","float lumaSw = FxaaLuma(texture2D(tDiffuse, vPosPos.xw).rgb);","float lumaNe = FxaaLuma(texture2D(tDiffuse, vPosPos.zy).rgb) + 1.0/384.0;","float lumaSe = FxaaLuma(texture2D(tDiffuse, vPosPos.zw).rgb);","vec3 rgbM = texture2D(tDiffuse, vPos.xy).rgb;","float lumaM = FxaaLuma(rgbM.rgb);","float lumaMax = max(max(lumaNe, lumaSe), max(lumaNw, lumaSw));","float lumaMin = min(min(lumaNe, lumaSe), min(lumaNw, lumaSw));","float lumaMaxSubMinM = max(lumaMax, lumaM) - min(lumaMin, lumaM);","float lumaMaxScaledClamped = max(FXAA_EDGE_THRESHOLD_MIN, lumaMax * FXAA_EDGE_THRESHOLD);","if (lumaMaxSubMinM < lumaMaxScaledClamped) {","gl_FragColor = vec4(rgbM, 1.0);","return;","}","float dirSwMinusNe = lumaSw - lumaNe;","float dirSeMinusNw = lumaSe - lumaNw;","vec2 dir1 = normalize(vec2(dirSwMinusNe + dirSeMinusNw, dirSwMinusNe - dirSeMinusNw));","vec3 rgbN1 = texture2D(tDiffuse, vPos.xy - dir1 * FXAA_RCP_FRAME_OPT*resolution).rgb;","vec3 rgbP1 = texture2D(tDiffuse, vPos.xy + dir1 * FXAA_RCP_FRAME_OPT*resolution).rgb;","float dirAbsMinTimesC = min(abs(dir1.x), abs(dir1.y)) * FXAA_EDGE_SHARPNESS;","vec2 dir2 = clamp(dir1.xy / dirAbsMinTimesC, -2.0, 2.0);","vec3 rgbN2 = texture2D(tDiffuse, vPos.xy - dir2 * FXAA_RCP_FRAME_OPT2*resolution).rgb;","vec3 rgbP2 = texture2D(tDiffuse, vPos.xy + dir2 * FXAA_RCP_FRAME_OPT2*resolution).rgb;","vec3 rgbA = rgbN1 + rgbP1;","vec3 rgbB = ((rgbN2 + rgbP2) * 0.25) + (rgbA * 0.25);","float lumaB = FxaaLuma(rgbB);","if ((lumaB < lumaMin) || (lumaB > lumaMax))","gl_FragColor = vec4(rgbA * 0.5, 1.0);","else","gl_FragColor = vec4(rgbB, 1.0);","}"].join("\n")},We=new THREE.ShaderMaterial({defines:{MAX_RADIUS:4},uniforms:{tDiffuse:{value:null},texSize:{value:new THREE.Vector2(.5,.5)},direction:{value:new THREE.Vector2(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"#include <common> varying vec2 vUv; uniform sampler2D tDiffuse; uniform vec2 texSize; uniform vec2 direction; uniform float kernelRadius; float gaussianPdf(in float x, in float sigma) { return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma; } void main() { vec2 invSize = 1.0 / texSize; float weightSum = gaussianPdf(0.0, kernelRadius); vec3 diffuseSum = texture2D( tDiffuse, vUv).rgb * weightSum; vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS) * 0.5; vec2 uvOffset = delta; for( int i = 1; i <= MAX_RADIUS; i ++ ) { float w = gaussianPdf(uvOffset.x, kernelRadius); vec3 sample1 = texture2D( tDiffuse, vUv + uvOffset).rgb; vec3 sample2 = texture2D( tDiffuse, vUv - uvOffset).rgb; diffuseSum += ((sample1 + sample2) * w); weightSum += (2.0 * w); uvOffset += delta; } float alpha = texture2D( tDiffuse, vUv).a; gl_FragColor = vec4(diffuseSum/weightSum, alpha); }"}),Ye={uniforms:{tDiffuse:{value:null},resolution:{value:new THREE.Vector2}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","bool IsSelected (vec3 color) {"," return (color.g<1e-8 && color.b < 1e-8 && color.r > 1e-3);","}","void main() {","float Alpha = 0.0;","vec2 texel = vec2( 0.5 / resolution.x, 0.5 / resolution.y );","texel = texel * vec2(2.0,2.0); ","bool Selected = false;","for( int i = -1; i <= 1;++i ) {","for (int j = -1; j <= 1; ++j){","Selected = IsSelected(texture2D( tDiffuse, vUv + texel * vec2( i,j ) ).rgb);","if (Selected) break;","}","if (Selected) break;","}","if(Selected)","Alpha = 1.0;","vec4 color = texture2D( tDiffuse, vUv);","float l = linearToRelativeLuminance( color.rgb );","gl_FragColor = vec4( l, l, l, Alpha );","}"].join("\n")},Xe=new THREE.ShaderMaterial({uniforms:{tDiffuse:{value:null},resolution:{value:new THREE.Vector2},selectColor:{value:new THREE.Color}},vertexShader:["varying vec2 vUv;","void main() { ","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","uniform vec3 selectColor;","varying vec2 vUv;","void main() {","vec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );","texel = texel * vec2(0.3,0.3); ","vec3 colorDest = vec3(0.0,0.0,0.0);","const mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 );","const mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 );","float tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;","float tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;","float tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;","float tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;","float tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;","float tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;","float tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;","float tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;","float tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;","float valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 + ","Gx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 + ","Gx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2; ","float valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 + ","Gy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 + ","Gy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2; ","float G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );","float Alpha = 1.0;","float select = texture2D( tDiffuse, vUv ).a;","if(G < 0.95) ","{","discard;","}","if( abs(select - 1.0) < 1e-6)","{","colorDest = selectColor;","}","gl_FragColor = vec4( colorDest, Alpha );","}"].join("\n"),blending:THREE.NormalBlending,depthTest:!1,depthWrite:!1,transparent:!0}),V={vertexShader:["void main() {\n","#ifdef USE_MODELMATRIXATTRIB\n\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\tgl_Position = projectionMatrix * ndsModelViewMatrix * vec4( position, 1.0 );\n#else\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n#endif\n","}"].join("\n"),fragmentShader:["const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)","const float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)","const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );","const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );","const float ShiftRight8 = 1. / 256.;","vec4 packDepthToRGBA( const in float v ) {","vec4 r = vec4( fract( v * PackFactors ), v );","r.yzw -= r.xyz * ShiftRight8; // tidy overflow","return r * PackUpscale;","}","float unpackRGBAToDepth( const in vec4 v ) {","return dot( v, UnpackFactors );","}","void main() {","gl_FragColor = packDepthToRGBA( gl_FragCoord.z);","}"].join("\n")},S=(["varying vec4 mvPosition;","void main() {","#ifdef USE_MODELMATRIXATTRIB\n\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\tmvPosition = ndsModelViewMatrix * vec4( position, 1.0 );\n#else\n\tmvPosition = modelViewMatrix * vec4( position, 1.0 );\n#endif\n","gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),["uniform float cameraNear;","uniform float cameraFar;","varying vec4 mvPosition;","void main() {","float depth = gl_FragCoord.z / gl_FragCoord.w;","depth =smoothstep( cameraNear, cameraFar, depth );","gl_FragColor = vec4( mvPosition.xyz, depth);","}"].join("\n"),["varying vec3 vNormal;","void main() {","#ifdef USE_MODELMATRIXATTRIB\n\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\tvNormal = normalize( mat3(ndsModelViewMatrix) * normal );\n\tgl_Position = projectionMatrix * ndsModelViewMatrix * vec4( position, 1.0 );\n#else\n\tvNormal = normalize( mat3(modelViewMatrix) * normal );\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n#endif\n","}"].join("\n"),["varying vec3 vNormal;","void main() {","gl_FragColor = vec4( normalize(vNormal).xyz, 1.0);","}"].join("\n"),new THREE.Vector2(512,512),new THREE.Vector3(1,0,1),["varying vec2 vUv;","varying vec2 vExtent; ","vec2 getExtent() {"," vec2 extent;"," float a = projectionMatrix[2][2];"," float b = projectionMatrix[3][2];"," float nearOrthographic = (b + 1.0) / a;"," float farOrthographic = (b - 1.0) / a;"," float nearPerspective = b / (a - 1.0);"," float farPerspective = b / (a + 1.0);"," extent[0] = projectionMatrix[3][3] * nearOrthographic - projectionMatrix[2][3] * nearPerspective;"," extent[1] = projectionMatrix[3][3] * farOrthographic - projectionMatrix[2][3] * farPerspective;"," extent[1] -= extent[0];"," return extent;"," }","void main() {","vUv = uv;","vExtent = getExtent();","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),["varying vec2 vUv;","varying vec2 vExtent; ","uniform sampler2D tDiffuse;","uniform sampler2D tPosition;","uniform sampler2D tNormal;","uniform vec2 vSize;","uniform float fOccluderBias;","uniform vec3 vAttenuation;","uniform float fDistScale;","uniform float fOnlyAo;","uniform float fLumInfluence;","uniform float fRadiusNear;","uniform float fRadiusFar;","uniform float fIntensity;","#define nRadial 5 ","#define nAngular 5 ","#define minResolution 2e-4 ","float SamplePixels (vec3 srcPosition, vec3 srcNormal, vec2 uv)","{"," vec3 dstPosition = texture2D(tPosition, uv).xyz;"," vec3 positionVec = dstPosition - srcPosition;"," float len = length(positionVec);"," float intensity = fIntensity * max((dot(positionVec, srcNormal)- minResolution* vExtent[1])/len- fOccluderBias, 0.0);"," float dist = fDistScale * len / vExtent[1];"," float attenuation = 1.0 / (vAttenuation.x + (vAttenuation.y * dist) + vAttenuation.z*dist*dist);"," return intensity * attenuation ;","}","vec2 rand( const vec2 coord ) {","vec2 noise;","float nx = dot ( coord, vec2( 12.9898, 78.233 ) );","float ny = dot ( coord, vec2( 12.9898, 78.233 ) * 2.0 );","noise = clamp( fract ( 43758.5453 * sin( vec2( nx, ny ) ) ), 0.0, 1.0 );","return ( noise * 2.0 - 1.0 );","}","float getRandomAngle(vec2 pos) {","vec2 rnd = rand(pos);","return atan(rnd.y, rnd.x);","}","void main ()","{"," vec3 srcPosition = texture2D(tPosition, vUv).xyz;"," float srcDepth = texture2D(tPosition, vUv).w;"," vec3 srcNormal = texture2D(tNormal, vUv).xyz;"," float ao = 0.0;"," float radiusMax = fRadiusNear + (fRadiusFar- fRadiusNear) * srcDepth;"," float radiusMin = radiusMax/float(nRadial);"," float angleStep = 6.2831853/float(nAngular);"," vec2 texelSize= 1.0/vSize;"," float angle = getRandomAngle(vUv);"," for (int i = 0; i < nRadial; ++i)"," {"," float radius = radiusMin*float(i+1);"," for(int j=0; j< nAngular; ++j){"," vec2 offset = radius * vec2(cos(angle),sin(angle));"," offset *= texelSize; "," ao += SamplePixels(srcPosition, srcNormal, vUv + offset);"," angle += angleStep;"," }"," angle -= angleStep/2.0;"," }"," ao /= float(nRadial * nAngular);","\tao *= float(srcDepth < 1.0);"," ao = clamp(ao, 0.0, 1.0);","\tgl_FragColor.r = ao;"," gl_FragColor.a = 1.0;","}"].join("\n"),new THREE.Vector2(512,512),["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),["varying vec2 vUv;","uniform sampler2D tDiffuse;","uniform sampler2D tDiffuseOrginal;","uniform sampler2D tSSAOMap;","uniform vec2 vSize;","uniform float fOnlyAo;","uniform float fLumInfluence;","#define uFilterRadius 3","void main ()","{"," float occlusion = 0.0;"," float count = 0.0;"," vec2 texelSize= 1.0/vSize;"," for(int x= -uFilterRadius; x<= uFilterRadius; ++ x){"," for(int y = -uFilterRadius; y<= uFilterRadius; ++y){"," vec2 offset = vec2(x,y);"," float occulusionSample = texture2D(tSSAOMap, vUv + offset*texelSize).r;"," float weight = 1.0 / (1.0 + dot(offset, offset));"," occlusion += weight * occulusionSample;"," count += weight;"," }","}","occlusion /= count;","occlusion = clamp(occlusion, 0.0, 1.0);","occlusion = 1.0 - occlusion;","vec4 texelValue = texture2D(tDiffuseOrginal,vUv).rgba;","vec3 color = texelValue.rgb;","vec3 lumcoeff = vec3( 0.299, 0.587, 0.114 );","float lum = dot( color.rgb, lumcoeff );","vec3 luminance = vec3( lum );","vec3 aoResult = vec3( mix( vec3( occlusion ), vec3( 1.0 ), luminance * fLumInfluence ) );","if ( fOnlyAo == 1.0 )","\tgl_FragColor.xyz= aoResult;","else if ( fOnlyAo == 2.0 )"," gl_FragColor.xyz = color;","else","{"," gl_FragColor.xyz = color * aoResult;","}","gl_FragColor.w = texelValue.a;","}"].join("\n"),c.prototype={constructor:c,setSize:function(e,t){},render:function(e,t,n,i,r){console.error("Pass: .render() must be implemented in derived pass.")}},u.prototype=Object.create(c.prototype),Object.assign(u.prototype,{render:function(e,t,n,i,r){var o,a,s=e.context,l=e.state;l.buffers.color.setMask(!1),l.buffers.depth.setMask(!1),l.buffers.color.setLocked(!0),l.buffers.depth.setLocked(!0),a=this.inverse?(o=0,1):(o=1,0),l.buffers.stencil.setTest(!0),l.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),l.buffers.stencil.setFunc(s.ALWAYS,o,4294967295),l.buffers.stencil.setClear(a),e.render(this.scene,this.camera,n,this.clear),e.render(this.scene,this.camera,t,this.clear),l.buffers.color.setLocked(!1),l.buffers.depth.setLocked(!1),l.buffers.stencil.setFunc(s.EQUAL,1,4294967295),l.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP)}}),w.prototype=Object.create(c.prototype),Object.assign(w.prototype,{render:function(e,t,n,i,r){e.state.buffers.stencil.setTest(!1)}}),Re.prototype=Object.assign(Object.create(c.prototype),{constructor:Re,render:function(e,t,n,i,r,o){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.quad.material=this.material,this.renderToColor&&i?e.render(this.scene,this.camera,i,this.clear):this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)}}),Object.assign(Oe.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e);var t=this.renderer.getSize();e.setSize(t.width,t.height)},insertPass:function(e,t){this.passes.splice(t,0,e)},render:function(e){this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2;for(var t,n,i=!1,r=this.passes.length,o=0;o<r;o++)!1!==(n=this.passes[o]).enabled&&(n.render(this.renderer,this.writeBuffer,this.readBuffer,this.colorTarget,e,i),n.needsSwap&&(i&&((t=this.renderer.context).stencilFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),t.stencilFunc(t.EQUAL,1,4294967295)),this.swapBuffers()),n instanceof u?i=!0:n instanceof w&&(i=!1))},reset:function(e){var t;void 0===e&&(t=this.renderer.getSize(),(e=this.renderTarget1.clone()).setSize(t.width,t.height)),this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(e,t){this.renderTarget1.setSize(e,t),this.renderTarget2.setSize(e,t);for(var n=0;n<this.passes.length;n++)this.passes[n].setSize(e,t)},setColorTarget:function(e){this.colorTarget&&this.colorTarget.dispose(),this.colorTarget=e,this.renderTarget1.setSize(e.width,e.height),this.renderTarget2.setSize(e.width,e.height);for(var t=0;t<this.passes.length;t++)this.passes[t].setSize(e.width,e.height)}}),b.prototype=Object.assign(Object.create(c.prototype),{constructor:b,render:function(e,t,n,i,r){var o,a,s=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial,this.clearColor&&(o=e.getClearColor(this.oldClearColor).getHex(),a=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.render(this.scene,this.camera,this.renderToScreen?null:n,this.clear),this.clearColor&&e.setClearColor(o,a),this.scene.overrideMaterial=null,e.autoClear=s}}),Le.prototype=Object.assign(Object.create(c.prototype),{constructor:b,render:function(e,t,n,i,r){var o,a,s,l=e.autoClear,d=(e.autoClear=!1,this.viewer.scene.overrideMaterial),c=(this.scene.overrideMaterial=this.overrideMaterial,(new this.overrideMaterial.constructor).copy(this.overrideMaterial));this.viewer.ndsModel.setOverrideMaterial(this.overrideMaterial,c,!1),this.clearColor&&(o=e.getClearColor(this.oldClearColor).getHex(),a=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),this.viewer.ndsModel.backupDirty(),this.viewer.ndsModel.backupAllBodyFlag(),this.viewer.ndsModel.setDirty(),this.viewer.ndsModel.setDrawMode(this.viewer.ndsModel.SHADED),this.scene.children.push(this.viewer.ndsModel),this.viewer.ndsModel.meshManager.selectedMaterial&&(s=this.viewer.ndsModel.meshManager.selectedMaterial.clone(),this.viewer.ndsModel.meshManager.selectedMaterial=this.selectedMaterial);for(var h=0;h<this.viewer.scene.children.length;++h)"Object3D"==this.viewer.scene.children[h].type&&(this.viewer.scene.children[h].oldVisible=this.viewer.scene.children[h].visible,this.viewer.scene.children[h].visible=!1);e.render(this.scene,this.camera,n,this.clear),this.clearColor&&e.setClearColor(o,a),this.viewer.ndsModel.setOverrideMaterial(null,null,!1),this.viewer.ndsModel.resetAllBodyFlag(),this.viewer.ndsModel.resetDirty(),this.viewer.ndsModel.meshManager.selectedMaterial&&(this.viewer.ndsModel.meshManager.selectedMaterial=s);for(var u=0;u<this.viewer.scene.children.length;++u)"Object3D"==this.viewer.scene.children[u].type&&(this.viewer.scene.children[u].visible=this.viewer.scene.children[u].oldVisible);this.scene.overrideMaterial=d,e.autoClear=l}}),ve.BODYFLAG={NONE_FLAG:0,SELECTED_FLAG:1,HIDDEN_FLAG:2,ISOLATED_FLAG:4,TRANSPARENT_FLAG:8,PRESELECTED_FLAG:16,DRAGGED_FLAG:32,ORIGINALTRANSPARENT_FLAG:64},function(e){this.bodyFlag=ve.BODYFLAG.NONE_FLAG,this._bodyMeshIds=[],this.bodyLineSegIds=[],this.bodyTextIds=[],this.Node=e,this._bodyBbox=[],this.bodyTranslate=[0,0,0],this.bodyDragTranslate=[0,0,0],this.bodyOpacity=1}),C=(Object.defineProperties(S.prototype,{bodyMeshIds:{get:function(){var t;return this.Node.getModel().NeedsMergeBodyNode&&!this.Node.IsMergedNode?this.totalMeshIds||(t=[],this.Node.parent.children.forEach(function(e){e.unload||(t=t.concat(e._leafBodyAttri._bodyMeshIds))}),this.totalMeshIds=t.concat(),t):this._bodyMeshIds},set:function(e){this._bodyMeshIds=e}},bodyBbox:{get:function(){var n;return this.Node.getModel().NeedsMergeBodyNode&&!this.Node.IsMergedNode?this.totalBbox||(n=[1/0,1/0,1/0,-1/0,-1/0,-1/0],this.Node.parent.children.forEach(function(e){if(!e.unload)for(var t=0;t<3;++t)n[t]>e._leafBodyAttri._bodyBbox[t]&&(n[t]=e._leafBodyAttri._bodyBbox[t]),n[3+t]<e._leafBodyAttri._bodyBbox[3+t]&&(n[3+t]=e._leafBodyAttri._bodyBbox[3+t])}),this.totalBbox=n.concat(),n):this._bodyBbox},set:function(e){this._bodyBbox=e}}}),function(){this.bodyFlag=ve.BODYFLAG.NONE_FLAG,this.renderObject=null}),Ae=(ve.COMPONENT_ELEMENT_FLAG={NONE_FLAG:0,COORDINATE_VISIBLE_FLAG:1,REFPLANE_VISIBLE_FLAG:2,REFAXIS_VISIBLE_FLAG:4,BODY_VISISBLE_FLAG:8},function n(){var i=arguments,r=this;this.uuid=null,this.name=null,this.type=null,this.visible=!0,this.fixed=!1,this.children=[],this.parent=null,this.area=void 0,this.volume=void 0,this.matrix=null,this.worldMatrix=null,this.objectid=null,this.id=-1,this._leafBodyAttri=null,this.componentElementFlag=ve.COMPONENT_ELEMENT_FLAG.BODY_VISISBLE_FLAG,this.useBodyNodeMaterial=!1,this.userMaterial=null,this.IsMergedNode=!1,this.add=function(e){if(1<i.length)for(var t=0;t<i.length;t++)r.add(i[t]);else r.children.indexOf(e)<0&&(e.parent&&e.parent.remove(e),e.lastParent&&delete e.lastParent,(e.parent=r).children.push(e));return r},this.remove=function(e){if(1<arguments.length)for(var t=0;t<arguments.length;t++)this.remove(arguments[t]);else{var n=this.children.indexOf(e);-1!==n&&(e.lastParent=this,e.parent=null,this.children.splice(n,1))}return this},this.clone=function(){var e=new n;e.uuid=this.uuid,e.name=this.name,e.type=this.type,e.visible=this.visible,e.fixed=this.fixed,e.matrix=this.matrix,e.worldMatrix=this.worldMatrix,e.objectid=this.objectid,e.id=this.id,e.fullpath=this.fullpath,e.propertyfile=this.propertyfile,e.unload=this.unload,e.volume=this.volume,e.area=this.area,e.referencename=this.referencename,this.ndsModel&&(e.ndsModel=this.ndsModel),e.pmiuuid=this.pmiuuid,this.refMatrix&&(e.refMatrix=this.refMatrix),this.propertyList&&(e.propertyList=this.propertyList),e.leafBodyAttri=this.leafBodyAttri,e.componentElementFlag=this.componentElementFlag,e.useBodyNodeMaterial=this.useBodyNodeMaterial;for(var t=0;t<this.children.length;t++)(!_e.HideLeafBody||this.children[t]&&"Body"!=this.children[t].type)&&e.add(this.children[t].clone());return e},this.cloneNew=function(){var e=new n;if(e.uuid=this.uuid+"_"+Math.random(),e.name=this.name,e.type=this.type,e.visible=this.visible,e.fixed=this.fixed,e.matrix=this.matrix,e.worldMatrix=this.worldMatrix,e.objectid=this.objectid,e.id=this.id,e.fullpath=this.fullpath,e.propertyfile=this.propertyfile,e.unload=this.unload,e.volume=this.volume,e.area=this.area,this.ndsModel&&(e.ndsModel=this.ndsModel),this.sketchRefModelUri&&(e.sketchRefModelUri=this.sketchRefModelUri),this.sketchModel&&(e.sketchModel=this.sketchModel),e.pmiuuid=this.pmiuuid,this.refMatrix&&(e.refMatrix=this.refMatrix),e.leafBodyAttri=this.leafBodyAttri,e.componentElementFlag=this.componentElementFlag,e.useBodyNodeMaterial=this.useBodyNodeMaterial,this.children[0]&&"Body"!=this.children[0].type)for(var t=0;t<this.children.length;t++)e.add(this.children[t].cloneNew());return e}});function T(e,t){return(T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}Ae.prototype={constructor:Ae,isFixed:function(){if(this.fixed)return!0;for(var e=this.parent;e;){if(e.fixed)return!0;e=e.parent}return!1},isSelected:function(){var e;return this.leafBodyAttri?0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.SELECTED_FLAG):!(!_e.HideLeafBody||(e=this.parent.FirstVisibleNode||0,this.uuid==this.parent.children[e].uuid)||!this.parent.children[e].isSelected())},isTransparent:function(){var e;return this.leafBodyAttri?0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.TRANSPARENT_FLAG):!(!_e.HideLeafBody||(e=this.parent.FirstVisibleNode||0,this.uuid==this.parent.children[e].uuid)||!this.parent.children[e].isTransparent())},isOriginalTransparent:function(){return!!this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.ORIGINALTRANSPARENT_FLAG)},isIsolated:function(){return!!this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.ISOLATED_FLAG)},isHidden:function(){var e;return!(!this.unload&&(this.leafBodyAttri?0==(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.HIDDEN_FLAG)&&("Body"!=this.type||"Assembly"!=this.parent.type&&"Part"!=this.parent.type?"RefAxis"!=this.type||"Assembly"!=this.parent.type&&"Part"!=this.parent.type?"RefPlane"!=this.type||"Assembly"!=this.parent.type&&"Part"!=this.parent.type?"CoordSystem"!=this.type||"Assembly"!=this.parent.type&&"Part"!=this.parent.type||0!=this.parent.isComponentCoordinateSysVisible():0!=this.parent.isComponentRefPlaneVisible():0!=this.parent.isComponentRefAxisVisible():0!=this.parent.isComponentBodyVisible()):!(_e.HideLeafBody&&this.parent&&"Body"==this.type&&(e=this.parent.FirstVisibleNode||0,this.parent.children[e].isHidden()||this.unload))))},isPreSelected:function(){return!!this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.PRESELECTED_FLAG)},isDragged:function(){return!!this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.DRAGGED_FLAG)},isReferenceEntity:function(){var e=this.type.toLowerCase();return"refplane"==e||"refaxis"==e||"refpoint"==e},isCoordinate:function(){return"coordsystem"==this.type.toLowerCase()},isOtherNode:function(){var e=this.type.toLowerCase();return"pmi"==e||"view"==e||"captures"==e||"views"==e||"capture"==e},isChildOfNode:function(e){for(var t=this.parent;t;){if(t==e)return!0;t=t.parent}return!1},select:function(){this.leafBodyAttri&&0==(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.SELECTED_FLAG)&&(this.leafBodyAttri.bodyFlag|=ve.BODYFLAG.SELECTED_FLAG,this.updateReferenceEntityDisplayFlag())},deSelect:function(){this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.SELECTED_FLAG)&&(this.leafBodyAttri.bodyFlag&=~ve.BODYFLAG.SELECTED_FLAG,this.updateReferenceEntityDisplayFlag())},preSelect:function(){this.leafBodyAttri&&0==(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.PRESELECTED_FLAG)&&(this.leafBodyAttri.bodyFlag|=ve.BODYFLAG.PRESELECTED_FLAG,this.updateReferenceEntityDisplayFlag())},dePreSelect:function(){this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.PRESELECTED_FLAG)&&(this.leafBodyAttri.bodyFlag&=~ve.BODYFLAG.PRESELECTED_FLAG,this.updateReferenceEntityDisplayFlag())},isEmptyNode:function(){return this.type.toLowerCase&&this.type.toLowerCase(),!this.leafBodyAttri&&0===this.children.length},hide:function(){this.leafBodyAttri?0==(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.HIDDEN_FLAG)&&(this.leafBodyAttri.bodyFlag|=ve.BODYFLAG.HIDDEN_FLAG,this.updateReferenceEntityDisplayFlag(),this.visible=!1,"CoordSystem"==this.type)&&this.leafBodyAttri.renderObject&&this.leafBodyAttri.renderObject.detach():this.isEmptyNode()&&(this.visible=!1)},show:function(){var e,t;this.leafBodyAttri?0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.HIDDEN_FLAG)&&(this.leafBodyAttri.bodyFlag&=~ve.BODYFLAG.HIDDEN_FLAG,this.updateReferenceEntityDisplayFlag(),this.visible=!0,"CoordSystem"==this.type)&&(this.leafBodyAttri.renderObject?this.leafBodyAttri.renderObject.attach(this):(t=null,t=(e=this.getModel()).viewer.canvas2D||e.viewer.canvas3D,(t=new Ne(e.viewer.camera,t)).attach(this),this.leafBodyAttri.renderObject=t,e.viewer.scene.add(t))):this.isEmptyNode()&&(this.visible=!0)},transparent:function(){this.leafBodyAttri&&0==(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.TRANSPARENT_FLAG)&&(this.leafBodyAttri.bodyFlag|=ve.BODYFLAG.TRANSPARENT_FLAG)},originalTransparent:function(){this.leafBodyAttri&&0==(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.ORIGINALTRANSPARENT_FLAG)&&(this.leafBodyAttri.bodyFlag|=ve.BODYFLAG.ORIGINALTRANSPARENT_FLAG)},opaque:function(){this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.TRANSPARENT_FLAG)&&(this.leafBodyAttri.bodyFlag&=~ve.BODYFLAG.TRANSPARENT_FLAG)},isolate:function(){this.leafBodyAttri&&0==(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.ISOLATED_FLAG)&&(this.leafBodyAttri.bodyFlag|=ve.BODYFLAG.ISOLATED_FLAG)},deIsolate:function(){this.leafBodyAttri&&0!=(this.leafBodyAttri.bodyFlag&ve.BODYFLAG.ISOLATED_FLAG)&&(this.leafBodyAttri.bodyFlag&=~ve.BODYFLAG.ISOLATED_FLAG)},setDragged:function(e){this.leafBodyAttri&&(e?this.leafBodyAttri.bodyFlag|=ve.BODYFLAG.DRAGGED_FLAG:this.leafBodyAttri.bodyFlag&=~ve.BODYFLAG.DRAGGED_FLAG)},getMaterialBodyNodeUUid:function(){for(var e=null,t=this;null!=t;)t.useBodyNodeMaterial&&(e=t.uuid),t=t.parent;return e},getUseBodyNodeMaterial:function(){return this.useBodyNodeMaterial},getAllMeshIds:function(){var e=this.getModel(),t=[];if(0<this.children.length)for(var n=e.getLeafBodies(this),i=n.length,r=0;r<i;++r)n[r].leafBodyAttri&&0!=n[r].leafBodyAttri.bodyMeshIds.length&&(t=t.concat(n[r].leafBodyAttri.bodyMeshIds));else if(this.leafBodyAttri)return this.leafBodyAttri.bodyMeshIds;return t},getAllbodyLineSegIds:function(){var e=this.getModel(),t=[];if(0<this.children.length)for(var n=e.getLeafBodies(this),i=n.length,r=0;r<i;++r)n[r].leafBodyAttri&&0!=n[r].leafBodyAttri.bodyLineSegIds.length&&(t=t.concat(n[r].leafBodyAttri.bodyLineSegIds));else if(this.leafBodyAttri)return this.leafBodyAttri.bodyLineSegIds;return t},getUserMaterial:function(){return this.leafBodyAttri||this.IsMergedNode?this.userMaterial:null},setUserMaterial:function(t){function n(e){e.userMaterial&&e.userMaterial.dispose(),e.userMaterial=t}this.leafBodyAttri&&(n(this),this.getModel().NeedsMergeBodyNode)&&this.parent.children.forEach(function(e){e.IsMergedNode&&n(e)})},getModel:function(){if(this.ndsModel)return this.ndsModel;for(var e=this.parent;e;){if(e.ndsModel)return e.ndsModel;e=e.parent}return null},getLevel:function(){for(var e=0,t=this;t;){if(e++,t.ndsModel&&!t.parent)return e;t=t.parent}return e},updateReferenceEntityDisplayFlag:function(){var e;"RefAxis"==this.type?(e=this.getModel())&&(e.referenceEntityDispManager.needUpdateRefAxisDispData=!0):"RefPlane"==this.type&&(e=this.getModel())&&(e.referenceEntityDispManager.needUpdateRefPlaneDispData=!0)},isComponentRefPlaneVisible:function(){return 0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.REFPLANE_VISIBLE_FLAG)},isComponentRefAxisVisible:function(){return 0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.REFAXIS_VISIBLE_FLAG)},isComponentCoordinateSysVisible:function(){return 0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.COORDINATE_VISIBLE_FLAG)},isComponentBodyVisible:function(){return 0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.BODY_VISISBLE_FLAG)},setComponentRefPlaneVisibility:function(e){if("Part"==this.type||"Assembly"==this.type)if(e){0==(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.REFPLANE_VISIBLE_FLAG)&&(this.componentElementFlag|=ve.COMPONENT_ELEMENT_FLAG.REFPLANE_VISIBLE_FLAG);for(var t=0;t<this.children.length;t++)"RefPlane"==(n=this.children[t]).type&&n.show()}else{0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.REFPLANE_VISIBLE_FLAG)&&(this.componentElementFlag&=~ve.COMPONENT_ELEMENT_FLAG.REFPLANE_VISIBLE_FLAG);for(var n,t=0;t<this.children.length;t++)"RefPlane"==(n=this.children[t]).type&&n.hide()}},setComponentRefAxisVisibility:function(e){if(e){0==(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.REFAXIS_VISIBLE_FLAG)&&(this.componentElementFlag|=ve.COMPONENT_ELEMENT_FLAG.REFAXIS_VISIBLE_FLAG);for(var t=0;t<this.children.length;t++)"RefAxis"==(n=this.children[t]).type&&n.show()}else{0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.REFAXIS_VISIBLE_FLAG)&&(this.componentElementFlag&=~ve.COMPONENT_ELEMENT_FLAG.REFAXIS_VISIBLE_FLAG);for(var n,t=0;t<this.children.length;t++)"RefAxis"==(n=this.children[t]).type&&n.hide()}},setComponentCoordinateSysVisibility:function(e){if("Part"==this.type||"Assembly"==this.type||"Model"==this.type){var t=this.getModel();if(e){0==(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.COORDINATE_VISIBLE_FLAG)&&(this.componentElementFlag|=ve.COMPONENT_ELEMENT_FLAG.COORDINATE_VISIBLE_FLAG);for(var n=0;n<this.children.length;n++)"CoordSystem"==(i=this.children[n]).type&&i.show()}else{0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.COORDINATE_VISIBLE_FLAG)&&(this.componentElementFlag&=~ve.COMPONENT_ELEMENT_FLAG.COORDINATE_VISIBLE_FLAG);for(var i,n=0;n<this.children.length;n++)"CoordSystem"==(i=this.children[n]).type&&i.hide()}t.viewer.render()}},setComponentBodyVisibility:function(e){var t;if("Part"==this.type||"Assembly"==this.type)if(e)0==(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.BODY_VISISBLE_FLAG)&&(this.componentElementFlag|=ve.COMPONENT_ELEMENT_FLAG.BODY_VISISBLE_FLAG),(t=this.getModel())&&t.meshManager.resetGeomSameMaterialFlags();else if(0!=(this.componentElementFlag&ve.COMPONENT_ELEMENT_FLAG.BODY_VISISBLE_FLAG)&&(this.componentElementFlag&=~ve.COMPONENT_ELEMENT_FLAG.BODY_VISISBLE_FLAG),t=this.getModel())for(var n=0;n<this.children.length;n++){var i=this.children[n];"Body"==i.type&&t.meshManager.setGeomSameMaterialFlag(i)}}},Object.defineProperties(Ae.prototype,{leafBodyAttri:{get:function(){return this.unload||this.getModel().NeedsMergeBodyNode&&this.IsMergedNode?null:this._leafBodyAttri},set:function(e){this._leafBodyAttri=e}}});function R(e){var n=this;this.geoms=[],this.uuidToIdMap={},this.usedGpuMemory=0,this.usedGpuMemoryInstanced=0,this.usedGpuMemoryLineSeg=0,this.usedMemory=0,this.viewer=e,this.pointGeomsMap={},this.maxGpuMemory=419430400,this.maxMemory=1.25*this.maxGpuMemory,this.loadedVertexAttributes=new Set,this.stopLoading=!1,this.allGeomInMemory=!0,this.ignorePendingBufferChunks=!1,this.ignorePendingLineSegBufferChunks=!1,this.maxBufferChunksInLoading=4,this.bufferChunksInLoading=0,this.bufferChunksToLoad=[],this.bufferChunk={},this.dispose=function(){for(var e=0,t=n.geoms.length;e<t;++e)n.geoms[e].dispose(),n.geoms[e]=null;n.geoms=[]}}function O(e){this.meshManager=e,this.dirty=!0}function L(e,t,n,i){this.meshId=e,this.materialId=t,this.programId=n,this.z=i}var de=function(n){function e(){var e=n.call(this)||this;return e.isNdsGeometry=!0,e.needsUpdate=!1,e.subGeomId=null,e.boundingBox=new THREE.Box3,e.boundingSphere=null,e.bufferLength=0,e.vertexColors=!1,e.loaded=!1,e.refMeshes=[],e.refMeshesSameMaterial=!0,e.refMeshesSameMaterialOriginal=!0,e.refLineSegs=[],e.refLineSegsSameMaterial=!0,e.refLineSegsSameMaterialOriginal=!0,e.dirty=!0,e.modelMatrixAttribute=null,e.isInstancedBufferGeometry=!1,e.instanceCount=0,e}t=n,(i=e).prototype=Object.create(t.prototype),T(i.prototype.constructor=i,t);var t,i=e.prototype;return i.setIndex=function(e){return this.needsUpdate=!0,n.prototype.setIndex.call(this,e)},i.setAttribute=function(e,t){return this.needsUpdate=!0,n.prototype.setAttribute.call(this,e,t)},i.deleteAttribute=function(e){return this.needsUpdate=!0,n.prototype.deleteAttribute.call(this,e)},i.applyMatrix4=function(e){return this.needsUpdate=!0,n.prototype.applyMatrix4.call(this,e)},e}(THREE.BufferGeometry);R.prototype={constructor:R,addGeom:function(e){var t=this.geoms.length;if(void 0===this.uuidToIdMap[e.uuid])this.uuidToIdMap[e.uuid]=[t],this.geoms.push(e);else{for(var n,i=0;i<this.uuidToIdMap[e.uuid].length;i++)if(n=this.uuidToIdMap[e.uuid][i],this.geoms[n].subGeomId==e.subGeomId)return t=n;this.geoms.push(e),this.uuidToIdMap[e.uuid].push(t)}return t},addPointGeom:function(e){void 0===this.pointGeomsMap[e.uuid]&&(this.pointGeomsMap[e.uuid]=e)},getPointGeomFromUuid:function(e){return this.pointGeomsMap[e]},getGeomFromId:function(e){if(!(e>=this.geoms.length||e<0))return this.geoms[e]},getGeomIdFromUuid:function(e,t){var n=this.uuidToIdMap[e];if(n=n||this.uuidToIdMap[e.toUpperCase()])for(var i=0,i=0;i<n.length;++i)if(this.geoms[n[i]].subGeomId===t)return n[i];return-1},getGeomFromUuid:function(e,t){e=this.getGeomIdFromUuid(e,t);return-1<e?this.geoms[e]:null},useSmallMemory:function(){this.maxGpuMemory=83886080,this.maxMemory=1.25*this.maxGpuMemory},useMediumMemory:function(){this.maxGpuMemory=314572800,this.maxMemory=1.25*this.maxGpuMemory},useLargeMemory:function(){this.maxGpuMemory=629145600,this.maxMemory=1.25*this.maxGpuMemory},usePCMemory:function(){this.maxGpuMemory=2147483648,this.maxMemory=3*this.maxGpuMemory},unloadGeometry:function(e){var t;e.index.array&&(t=e.index.array.byteLength,e.attributes.position.data?t+=e.attributes.position.data.array.byteLength:t+=e.attributes.position.array.byteLength,this.usedMemory-=t,e.index.array=null,e.attributes.position.data?e.attributes.position.data.array=null:e.attributes.position.array=null)},reloadGeometry:function(e){}},O.prototype={constructor:O,getNumLineSegments:function(){return this.meshManager.getNumLineSegments()},getLineSegmentsWithState:function(e,t,n){return this.meshManager.getLineSegmentsWithState(e,t,n=void 0===n?!1:n)},getLineSegments:function(e,t,n){e=this.meshManager.getLineSegmentsWithState(e,t,n=void 0===n?!1:n);return 1===e.state?e.lineSegments:null},isLineSegmentsLoaded:function(e){return this.meshManager.isLineSegmentsLoaded(e)},removeGeometry:function(){for(var e,t=0,n=this.getNumLineSegments();t<n;++t)this.meshManager.isLineSegmentsLoaded(t)&&(e=this.meshManager.geomManager.getGeomFromId(this.meshManager.lineSegGeomId[t])).index.indexBuffer&&e.index.array&&this.meshManager.geomManager.unloadGeometry(e)}};function D(e,t){return e.programId===t.programId?e.materialId===t.materialId?e.meshId-t.meshId:e.materialId-t.materialId:e.programId-t.programId}function H(e,t){return(H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var F=new THREE.Box3,U=new THREE.Vector3,G=function(t){function e(){var e=t.call(this)||this;e.isLineSegmentsGeometry=!0,e.type="LineSegmentsGeometry";return e.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),e.addAttribute("position",new THREE.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),e.addAttribute("uv",new THREE.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2)),e}n=t,(i=e).prototype=Object.create(n.prototype),H(i.prototype.constructor=i,n);var n,i=e.prototype;return i.applyMatrix4=function(e){var t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},i.setPositions=function(e){e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var t,e=new THREE.InstancedInterleavedBuffer(t,6,1);return this.addAttribute("instanceStart",new THREE.InterleavedBufferAttribute(e,3,0,!1)),this.addAttribute("instanceEnd",new THREE.InterleavedBufferAttribute(e,3,3,!1)),this.computeBoundingBox(),this.computeBoundingSphere(),this},i.setLineDistances=function(e){e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var t,e=new THREE.InstancedInterleavedBuffer(t,2,1);return this.addAttribute("instanceDistanceStart",new THREE.InterleavedBufferAttribute(e,1,0,!1)),this.addAttribute("instanceDistanceEnd",new THREE.InterleavedBufferAttribute(e,1,1,!1)),this},i.setLineWidth=function(e){e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var t,e=new THREE.InstancedInterleavedBuffer(t,2,1);return this.addAttribute("instanceWidthStart",new THREE.InterleavedBufferAttribute(e,1,0,!1)),this.addAttribute("instanceWidthEnd",new THREE.InterleavedBufferAttribute(e,1,1,!1)),this},i.setColors=function(e){e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new THREE.Float32Array(e));var t,e=new THREE.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new THREE.InterleavedBufferAttribute(e,3,0,!1)),this.setAttribute("instanceColorEnd",new THREE.InterleavedBufferAttribute(e,3,3,!1)),this},i.fromWireframeGeometry=function(e){return this.setPositions(e.attributes.position.array),this},i.fromEdgesGeometry=function(e){return this.setPositions(e.attributes.position.array),this},i.fromMesh=function(e){return this.fromWireframeGeometry(new THREE.WireframeGeometry(e.geometry)),this},i.fromLineSegments=function(e){e=e.geometry;return this.setPositions(e.attributes.position.array),this},i.computeBoundingBox=function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),F.setFromBufferAttribute(t),this.boundingBox.union(F))},i.computeBoundingSphere=function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){for(var n=this.boundingSphere.center,i=(this.boundingBox.getCenter(n),0),r=0,o=e.count;r<o;r++)U.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(U)),U.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(U));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}},i.toJSON=function(){},i.applyMatrix=function(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)},e}(THREE.InstancedBufferGeometry);function W(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function(e){e=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof e?e:e+""}(i.key),i)}}function X(e,t){return(X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}THREE.UniformsLib.line2={worldUnits:{value:1},mutiWidth:{value:0},linewidth:{value:1},linewidthScale:{value:1},resolution:{value:new THREE.Vector2(1,1)},lineScale:{value:1},lineTypeId:{value:0},uSampler:{value:null},patternLength:{value:1}},THREE.ShaderLib.line2={uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.line2]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform float linewidthScale;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying float vLineWidth;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t//#ifdef USE_DASH\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t//#endif\n\n\t\t#ifdef MUTI_WIDTH\n\t\t\tattribute float instanceWidthStart;\n\t\t\tattribute float instanceWidthEnd;\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef MUTI_WIDTH\n\t\t\t\tvLineWidth = ( position.y < 0.5 ) ? instanceWidthStart : instanceWidthEnd;\n\t\t\t#else\n\t\t\t\tvLineWidth = linewidth;\n\t\t\t#endif\n\n\t\t\tvLineWidth = vLineWidth * linewidthScale;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? instanceDistanceStart : instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t#ifdef USE_MODELMATRIXATTRIB\n\t\t\t\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\t\t\t\t// camera space\n\t\t\t\tvec4 start = ndsModelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\t\tvec4 end = ndsModelViewMatrix * vec4( instanceEnd, 1.0 );\n\t\t\t#else\n\t\t\t\t// camera space\n\t\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\tif(instanceDistanceStart > 0.0){\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * vLineWidth * 0.5;\n\t\t\t\t\t//end.xyz += worldDir * vLineWidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\t//offset.xy -= dir * forwardOffset;\n\t\t\t\t\t//offset.z += 0.5;\n\t\t\t\t\t}\t\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= vLineWidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= vLineWidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\t\tvarying float vLineWidth;\n\t\t\n\t\t#ifdef USE_DASH\n\t\t\tuniform float patternLength;\n\t\t\tuniform float lineScale;\n\t\t\tuniform sampler2D uSampler;\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n float newDistance = vLineDistance/lineScale;\n float modSize = mod( newDistance, patternLength);\n vec3 value = texture2D(uSampler,vec2(modSize/patternLength,0.0)).rgb;\n if(value.r > 0.9){\n \tdiscard;\n }\n\t\t\t\tif(value.r <=0.9 && value.r >=0.8){\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\t\t\t\t}\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / vLineWidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};var Q=function(n){function e(e){var t=n.call(this,{type:"LineMaterial",uniforms:THREE.UniformsUtils.clone(THREE.ShaderLib.line2.uniforms),vertexShader:THREE.ShaderLib.line2.vertexShader,fragmentShader:THREE.ShaderLib.line2.fragmentShader,clipping:!0})||this;return t.isLineMaterial=!0,t.setValues(e),t}var t,i,r;return i=n,(t=e).prototype=Object.create(i.prototype),X(t.prototype.constructor=t,i),t=e,(i=[{key:"color",get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},{key:"worldUnits",get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},{key:"linewidth",get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}},{key:"linewidthScale",get:function(){return this.uniforms.linewidthScale.value},set:function(e){this.uniforms.linewidthScale&&(this.uniforms.linewidthScale.value=e)}},{key:"dashed",get:function(){return"USE_DASH"in this.defines},set:function(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}},{key:"dashScale",get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},{key:"dashSize",get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},{key:"dashOffset",get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},{key:"gapSize",get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},{key:"opacity",get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms&&(this.uniforms.opacity.value=e)}},{key:"resolution",get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},{key:"alphaToCoverage",get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}},{key:"lineScale",get:function(){return this.uniforms.lineScale.value},set:function(e){this.uniforms.lineScale.value=e}},{key:"lineTypeId",get:function(){return this.uniforms.lineTypeId.value},set:function(e){this.uniforms.lineTypeId.value=e}},{key:"patternLength",get:function(){return this.uniforms.patternLength.value},set:function(e){this.uniforms.patternLength.value=e}},{key:"uSampler",get:function(){return this.uniforms.uSampler.value},set:function(e){this.uniforms.uSampler.value=e}},{key:"mutiWidth",get:function(){return"MUTI_WIDTH"in this.defines},set:function(e){!0===e?this.defines.MUTI_WIDTH="":delete this.defines.MUTI_WIDTH}}])&&W(t.prototype,i),r&&W(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(THREE.ShaderMaterial);function Z(e,t){return(Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var te,ne,ie=new THREE.Vector3,re=new THREE.Vector3,oe=new THREE.Vector4,ae=new THREE.Vector4,se=new THREE.Vector4,ce=new THREE.Vector3,he=new THREE.Matrix4,ue=new THREE.Line3,pe=new THREE.Vector3,fe=new THREE.Box3,me=new THREE.Sphere,Qe=new THREE.Vector4;function Ze(e,t,n){return Qe.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),Qe.multiplyScalar(1/Qe.w),Qe.x=ne/n.width,Qe.y=ne/n.height,Qe.applyMatrix4(e.projectionMatrixInverse),Qe.multiplyScalar(1/Qe.w),Math.abs(Math.max(Qe.x,Qe.y))}var qe=function(n){function e(e,t){return void 0===e&&(e=new G),void 0===t&&(t=new Q({color:16777215*Math.random()})),(e=n.call(this,e,t)||this).isLineSegments2=!0,e.type="LineSegments2",e}t=n,(i=e).prototype=Object.create(t.prototype),Z(i.prototype.constructor=i,t);var t,i=e.prototype;return i.computeLineDistances=function(){for(var e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,i=new Float32Array(2*t.count),r=0,o=0,a=t.count;r<a;r++,o+=2)ie.fromBufferAttribute(t,r),re.fromBufferAttribute(n,r),i[o]=0===o?0:i[o-1],i[o+1]=i[o]+ie.distanceTo(re);var s=new THREE.InstancedInterleavedBuffer(i,2,1);return e.addAttribute("instanceDistanceStart",new THREE.InterleavedBufferAttribute(s,1,0,!1)),e.addAttribute("instanceDistanceEnd",new THREE.InterleavedBufferAttribute(s,1,1,!1)),this},i.raycast=function(e,t){var n=this.material.worldUnits,i=e.camera,r=(null!==i||n||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),void 0!==e.params.Line2&&e.params.Line2.threshold||0),e=(te=e.ray,this.matrixWorld),o=this.geometry,a=this.material;if((ne=a.linewidth+r,null===o.boundingSphere&&o.computeBoundingSphere(),me.copy(o.boundingSphere).applyMatrix4(e),r=n?.5*ne:Ze(i,Math.max(i.near,me.distanceToPoint(te.origin)),a.resolution),me.radius+=r,!1!==te.intersectsSphere(me))&&(null===o.boundingBox&&o.computeBoundingBox(),fe.copy(o.boundingBox).applyMatrix4(e),r=n?.5*ne:Ze(i,Math.max(i.near,fe.distanceToPoint(te.origin)),a.resolution),fe.expandByScalar(r),!1!==te.intersectsBox(fe)))if(n)for(var s=this,l=t,d=s.matrixWorld,o=s.geometry,c=o.attributes.instanceStart,h=o.attributes.instanceEnd,u=0,p=Math.min(o.instanceCount,c.count);u<p;u++){ue.start.fromBufferAttribute(c,u),ue.end.fromBufferAttribute(h,u),ue.applyMatrix4(d);var f=new THREE.Vector3,m=new THREE.Vector3;te.distanceSqToSegment(ue.start,ue.end,m,f),m.distanceTo(f)<.5*ne&&l.push({point:m,pointOnLine:f,distance:te.origin.distanceTo(m),object:s,face:null,faceIndex:u,uv:null,uv1:null})}else{var g=this,e=i,v=t,A=e.projectionMatrix,y=g.material.resolution,E=g.matrixWorld,M=(a=g.geometry).attributes.instanceStart,w=a.attributes.instanceEnd,a=Math.min(a.instanceCount,M.count),b=-e.near;te.at(1,se),se.w=1,se.applyMatrix4(e.matrixWorldInverse),se.applyMatrix4(A),se.multiplyScalar(1/se.w),se.x*=y.x/2,se.y*=y.y/2,se.z=0,ce.copy(se),he.multiplyMatrices(e.matrixWorldInverse,E);for(var x,I,T,S,B=0,P=a;B<P;B++)oe.fromBufferAttribute(M,B),ae.fromBufferAttribute(w,B),oe.w=1,ae.w=1,oe.applyMatrix4(he),ae.applyMatrix4(he),oe.z>b&&ae.z>b||(oe.z>b?(x=oe.z-ae.z,x=(oe.z-b)/x,oe.lerp(ae,x)):ae.z>b&&(x=ae.z-oe.z,I=(ae.z-b)/x,ae.lerp(oe,I)),oe.applyMatrix4(A),ae.applyMatrix4(A),oe.multiplyScalar(1/oe.w),ae.multiplyScalar(1/ae.w),oe.x*=y.x/2,oe.y*=y.y/2,ae.x*=y.x/2,ae.y*=y.y/2,ue.start.copy(oe),ue.start.z=0,ue.end.copy(ae),ue.end.z=0,I=ue.closestPointToPointParameter(ce,!0),ue.at(I,pe),T=-1<=(T=THREE.Math.lerp(oe.z,ae.z,I))&&T<=1,S=ce.distanceTo(pe),T&&(ne<5?S<5:S<ne)&&(ue.start.fromBufferAttribute(M,B),ue.end.fromBufferAttribute(w,B),ue.start.applyMatrix4(E),ue.end.applyMatrix4(E),T=new THREE.Vector3,S=new THREE.Vector3,te.distanceSqToSegment(ue.start,ue.end,S,T),v.push({point:S,pointOnLine:T,distance:te.origin.distanceTo(S),object:g,face:null,faceIndex:B,uv:null,uv1:null})))}},e}(THREE.Mesh);function Ke(e,t){return(Ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}new THREE.Box3;var Je=new THREE.Vector3,$e=function(t){function e(){var e=t.call(this)||this;e.isPoint2Geometry=!0,e.type="Point2Geometry";return e.setIndex([0,1,2,0,2,3]),e.addAttribute("position",new THREE.Float32BufferAttribute([-1,-1,0,1,-1,0,1,1,0,-1,1,0],3)),e.addAttribute("uv",new THREE.Float32BufferAttribute([0,0,1,0,1,1,0,1],2)),e}n=t,(i=e).prototype=Object.create(n.prototype),Ke(i.prototype.constructor=i,n);var n,i=e.prototype;return i.setPositions=function(e){e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var t,e=new THREE.InstancedInterleavedBuffer(t,3,1);return this.addAttribute("instancePos",new THREE.InterleavedBufferAttribute(e,3,0,!1)),this.computeBoundingBox(),this.computeBoundingSphere(),this},i.computeBoundingBox=function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var e=this.attributes.instancePos;void 0!==e&&this.boundingBox.setFromBufferAttribute(e)},i.computeBoundingSphere=function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart;if(void 0!==e){for(var t=this.boundingSphere.center,n=(this.boundingBox.getCenter(t),0),i=0,r=e.count;i<r;i++)Je.fromBufferAttribute(e,i),n=Math.max(n,t.distanceToSquared(Je));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}},i.toJSON=function(){},i.applyMatrix=function(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)},e}(THREE.InstancedBufferGeometry);function et(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function(e){e=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof e?e:e+""}(i.key),i)}}function tt(e,t){return(tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var nt=function(n){function e(e){var t=n.call(this,{type:"Point2Material",uniforms:{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new THREE.Vector2(1,1)},diffuse:{value:new THREE.Color(16711680)}},vertexShader:"\n\t\t\t#include <common>\n\t\t\tuniform float linewidth;\n\t\t\tuniform vec2 resolution;\n\n\t\t\tattribute vec3 instancePos;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tvec4 modelPos;\n\n\t\t\t\t#ifdef USE_MODELMATRIXATTRIB\n\t\t\t\t\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\t\t\t\t\tmodelPos = ndsModelViewMatrix * vec4( instancePos, 1.0 );\n\t\t\t\t#else\n\t\t\t\t\tmodelPos = modelViewMatrix * vec4( instancePos, 1.0 );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef WORLD_UNITS\n\t\t\t\t modelPos += vec4(position * linewidth * 0.5, 0.0);\n\t\t\t\t\tmodelPos = projectionMatrix * modelPos;\n\t\t\t\t#else\n\t\t\t\t\tmodelPos = projectionMatrix * modelPos;\n\t\t\t\t\tfloat lenX = linewidth / resolution.x * modelPos.w;\n\t\t\t\t\tfloat lenY = linewidth / resolution.y * modelPos.w;\n\t\t\t\t\tmodelPos.xy += vec2(position.x * lenX, position.y * lenY);\n\t\t\t\t#endif\n\n\t\t\t\tgl_Position = modelPos;\n\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\tvarying vec2 vUv;\n\t\t\tuniform vec3 diffuse;\n\t\t\tvoid main(){\n\t\t\t\tif(length(vUv -0.5)>0.5) discard;\n\t\t\t\tgl_FragColor = vec4(diffuse, 1.0);\n\t\t\t}\n\t\t\t"})||this;return t.isPoint2Material=!0,t.setValues(e),t}var t,i,r;return i=n,(t=e).prototype=Object.create(i.prototype),tt(t.prototype.constructor=t,i),t=e,(i=[{key:"color",get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},{key:"worldUnits",get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},{key:"linewidth",get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}},{key:"resolution",get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}}])&&et(t.prototype,i),r&&et(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(THREE.ShaderMaterial);function it(e,t){return(it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var rt=function(n){function e(e,t){return void 0===e&&(e=new $e),void 0===t&&(t=new nt({color:16777215*Math.random()})),(e=n.call(this,e,t)||this).isPoint2=!0,e.type="Point2",e}var t,i;return i=n,(t=e).prototype=Object.create(i.prototype),it(t.prototype.constructor=t,i),e}(THREE.Mesh);function ot(e,t){return e-t}function at(e){var n=this;this.boundingBox=new THREE.Box3,this.boundingSphere=new THREE.Sphere,this.children=[],this.meshes=null,this.lines=null,this.texts=null,this.parent=null,this.addSubTree=function(e){((e=e.isSpatialIndex?e:new ft(e)).root.parent=n).children.push(e.root);for(var t=n;t;)t.boundingBox.expandByPoint(e.root.boundingBox.min),t.boundingBox.expandByPoint(e.root.boundingBox.max),t=t.parent;return e.root},this.queryByRayCast=function(){function o(e,t,n){if(t.intersectsBox(e.boundingBox)){0<=e.meshSetId&&(n[n.length]=e.meshSetId);for(var i=0,r=e.children.length;i<r;++i)o(e.children[i],t,n)}}new THREE.Vector3,new THREE.Quaternion,new THREE.Vector3;return function(e,t){o(this,e,t)}}()}function st(e){this.ndsModel=e,this.needUpdateRefPlaneVertexBuffer=!0,this.needUpdateRefPlaneDispData=!0,this.needUpdateRefAxisVertexBuffer=!0,this.needUpdateRefAxisDispData=!0;var b=this,x=(this.refPlanes=[],this.refAxises=[],null),I=null,E=null,M=null,w=null,T=null,S=new THREE.Mesh,B=new THREE.Mesh,P=new THREE.Mesh,C=new THREE.LineSegments,R=new THREE.LineSegments,O=new THREE.LineSegments,L=new de,D=new de,H=new de,F=new de,N=new de,j=new de,_=new THREE.LineSegments,V=new THREE.LineSegments,k=new THREE.LineSegments,U=new de,G=new de,z=new de;this.hasNormalPlane=!1,this.hasSelectedPlane=!1,this.hasPreselecedPlane=!1,this.hasNormalAxis=!1,this.hasSelectedAxis=!1,this.hasPreselectedAxis=!1,this.axisMaterial=new THREE.LineDashedMaterial({color:255,linewidth:2,dashSize:.003,gapSize:.002}),this.axisSelectedMaterial=new THREE.LineDashedMaterial({color:65280,linewidth:2,dashSize:.003,gapSize:.002}),this.axisPreSelectedMaterial=new THREE.LineDashedMaterial({color:65535,linewidth:2,dashSize:.003,gapSize:.002}),this.planeMaterial=new THREE.MeshBasicMaterial({color:15527167,side:THREE.DoubleSide,transparent:!0,opacity:.2,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),this.planeSelectedMaterial=new THREE.MeshBasicMaterial({color:16763200,side:THREE.DoubleSide,transparent:!0,opacity:.2,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),this.planePreSelectedMaterial=new THREE.MeshBasicMaterial({color:15527167,side:THREE.DoubleSide,transparent:!0,opacity:.2,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),this.planeEdgeMaterial=new THREE.LineBasicMaterial({color:5987327}),this.planeEdgeSelectedMaterial=new THREE.LineBasicMaterial({color:16776960}),this.planeEdgePreSelectedMaterial=new THREE.LineBasicMaterial({color:65535}),this.overrideMaterial=null,this.overrideMaterialCopy=null,this.useBodyIdMaterial=!1,this.getPlaneDispData=function(){var e={};if(b.needUpdateRefPlaneVertexBuffer){for(var t=b.refPlanes.length,n=4*t*3,i=(x&&x.length==n||(x=new Float32Array(n),I=new THREE.BufferAttribute(x,3)),new THREE.Vector3),r=0;r<t;r++)for(var o=b.refPlanes[r].worldMatrix,a=b.refPlanes[r].leafBodyAttri.coords,s=0;s<4;s++)i.fromArray(a,3*s),i.applyMatrix4(o),x[3*(4*r+s)+0]=i.x,x[3*(4*r+s)+1]=i.y,x[3*(4*r+s)+2]=i.z;I.needsUpdate=!0,b.needUpdateRefPlaneVertexBuffer=!1}if(this.needUpdateRefPlaneDispData){for(var l=this.refPlanes.length,n=4*l,d=0,c=0,h=0,u=0;u<l;u++)this.refPlanes[u].isHidden()||(this.refPlanes[u].isPreSelected()?h++:this.refPlanes[u].isSelected()?c++:d++);for(var p=null,f=null,m=null,g=null,v=null,A=null,y=(0<d?(this.hasNormalPlane=!0,p=new(n<=65535?Uint16Array:Uint32Array)(6*d),g=new(n<=65535?Uint16Array:Uint32Array)(8*d),S.geometry=L,S.material=this.planeMaterial,L.attributes.position=I,L.index=new THREE.BufferAttribute(p,1),C.geometry=F,C.material=this.planeEdgeMaterial,F.attributes.position=I,F.index=new THREE.BufferAttribute(g,1),e.normalPlaneMesh=S,e.normalPlaneEdge=C):(this.hasNormalPlane=!1,S.geometry=null,L.index=null,L.attributes.position=null,C.geometry=null,F.index=null,F.attributes.position=null),0<c?(this.hasSelectedPlane=!0,f=new(n<=65535?Uint16Array:Uint32Array)(6*c),v=new(n<=65535?Uint16Array:Uint32Array)(8*c),B.geometry=D,B.material=this.planeSelectedMaterial,D.attributes.position=I,D.index=new THREE.BufferAttribute(f,1),R.geometry=N,R.material=this.planeEdgeSelectedMaterial,N.attributes.position=I,N.index=new THREE.BufferAttribute(v,1),e.selectedPlaneMesh=B,e.selectedPlaneEdge=R):(this.hasSelectedPlane=!1,B.geometry=null,D.index=null,D.attributes.position=null,R.geometry=null,N.index=null,N.attributes.position=null),0<h?(this.hasPreselecedPlane=!0,m=new(n<=65535?Uint16Array:Uint32Array)(6*h),A=new(n<=65535?Uint16Array:Uint32Array)(8*h),P.geometry=H,P.material=this.planePreSelectedMaterial,H.attributes.position=I,H.index=new THREE.BufferAttribute(m,1),O.geometry=j,O.material=this.planeEdgePreSelectedMaterial,j.attributes.position=I,j.index=new THREE.BufferAttribute(A,1),e.preselectedPlaneMesh=P,e.preselectedPlaneEdge=O):(this.hasPreselecedPlane=!1,P.geometry=null,H.index=null,H.attributes.position=null,O.geometry=null,j.index=null,j.attributes.position=null),0),E=0,M=0,u=0;u<l;u++)if(!this.refPlanes[u].isHidden())if(this.refPlanes[u].isPreSelected()){m[6*y+0]=4*u+0,m[6*y+1]=4*u+1,m[6*y+2]=4*u+2,m[6*y+3]=4*u+2,m[6*y+4]=4*u+3,m[6*y+5]=4*u+0;for(var w=0;w<3;w++)A[8*y+2*w]=4*u+w,A[8*y+2*w+1]=4*u+w+1;A[8*y+6]=4*u+3,A[8*y+7]=4*u,y++}else if(this.refPlanes[u].isSelected()){f[6*E+0]=4*u+0,f[6*E+1]=4*u+1,f[6*E+2]=4*u+2,f[6*E+3]=4*u+2,f[6*E+4]=4*u+3,f[6*E+5]=4*u+0;for(w=0;w<3;w++)v[8*E+2*w]=4*u+w,v[8*E+2*w+1]=4*u+w+1;v[8*E+6]=4*u+3,v[8*E+7]=4*u,E++}else{p[6*M+0]=4*u+0,p[6*M+1]=4*u+1,p[6*M+2]=4*u+2,p[6*M+3]=4*u+2,p[6*M+4]=4*u+3,p[6*M+5]=4*u+0;for(w=0;w<3;w++)g[8*M+2*w]=4*u+w,g[8*M+2*w+1]=4*u+w+1;g[8*M+6]=4*u+3,g[8*M+7]=4*u,M++}this.needUpdateRefPlaneDispData=!1}else this.hasNormalPlane&&(e.normalPlaneMesh=S,e.normalPlaneEdge=C),this.hasSelectedPlane&&(e.selectedPlaneMesh=B,e.selectedPlaneEdge=R),this.hasPreselecedPlane&&(e.preselectedPlaneMesh=P,e.preselectedPlaneEdge=O);return e},this.getAxisDispData=function(){var e={};if(b.needUpdateRefAxisVertexBuffer){for(var t,n=b.refAxises.length,i=2*n*3,r=2*n,o=(E&&E.length==i||(E=new Float32Array(i),M=new THREE.BufferAttribute(E,3),w=new Float32Array(r),T=new THREE.BufferAttribute(w,1)),new THREE.Vector3),a=new THREE.Vector3,s=0;s<n;s++){t=b.refAxises[s].worldMatrix,l=b.refAxises[s].leafBodyAttri.coords,o.fromArray(l,0),a.fromArray(l,3);var l=o.distanceTo(a);o.applyMatrix4(t),a.applyMatrix4(t),E[2*s*3]=o.x,E[2*s*3+1]=o.y,E[2*s*3+2]=o.z,E[3*(2*s+1)]=a.x,E[3*(2*s+1)+1]=a.y,E[3*(2*s+1)+2]=a.z,w[2*s]=0,w[2*s+1]=l}M.needsUpdate=!0,T.needsUpdate=!0,b.needUpdateRefAxisVertexBuffer=!1}if(this.needUpdateRefAxisDispData){for(var d=this.refAxises.length,i=2*d,c=0,h=0,u=0,p=0;p<d;p++)this.refAxises[p].isHidden()||(this.refAxises[p].isPreSelected()?u++:this.refAxises[p].isSelected()?h++:c++);for(var f=null,m=null,g=null,v=(0<c?(this.hasNormalAxis=!0,f=new(i<=65535?Uint16Array:Uint32Array)(2*c),_.geometry=U,_.material=this.axisMaterial,U.attributes.position=M,U.attributes.lineDistance=T,U.index=new THREE.BufferAttribute(f,1),e.normalAxisLines=_):(this.hasNormalAxis=!1,_.geometry=null,U.index=null,U.attributes.position=null,U.attributes.lineDistance=null),0<h?(this.hasSelectedAxis=!0,m=new(i<=65535?Uint16Array:Uint32Array)(2*h),V.geometry=G,V.material=this.axisSelectedMaterial,G.attributes.position=M,G.attributes.lineDistance=T,G.index=new THREE.BufferAttribute(m,1),e.selectedAxisLines=V):(this.hasSelectedAxis=!1,V.geometry=null,G.index=null,G.attributes.position=null,G.attributes.lineDistance=null),0<u?(this.hasPreselectedAxis=!0,g=new(i<=65535?Uint16Array:Uint32Array)(2*u),k.geometry=z,k.material=this.axisPreSelectedMaterial,z.attributes.position=M,z.attributes.lineDistance=T,z.index=new THREE.BufferAttribute(g,1),e.preselectedAxisLines=k):(this.hasPreselectedAxis=!1,k.geometry=null,z.index=null,z.attributes.position=null,z.attributes.lineDistance=null),0),A=0,y=0,p=0;p<d;p++)this.refAxises[p].isHidden()||(this.refAxises[p].isPreSelected()?(g[2*v]=2*p,g[2*v+1]=2*p+1,v++):this.refAxises[p].isSelected()?(m[2*A]=2*p,m[2*A+1]=2*p+1,A++):(f[2*y]=2*p,f[2*y+1]=2*p+1,y++));this.needUpdateRefAxisDispData=!1}else this.hasNormalAxis&&(e.normalAxisLines=_),this.hasSelectedAxis&&(e.selectedAxisLines=V),this.hasPreselectedAxis&&(e.preselectedAxisLines=k);return e},this.addRefEntity=function(e){"RefAxis"==e.type?(this.refAxises.push(e),this.needUpdateRefAxisVertexBuffer=!0,this.needUpdateRefAxisDispData=!0):"RefPlane"==e.type&&(this.refPlanes.push(e),this.needUpdateRefPlaneVertexBuffer=!0,this.needUpdateRefPlaneDispData=!0)},this.removeRefEntity=function(e){var t;"RefAxis"==e.type?(-1<(t=this.refAxises.indexOf(e))&&this.refAxises.splice(t,1),this.needUpdateRefAxisVertexBuffer=!0,this.needUpdateRefAxisDispData=!0):"RefPlane"==e.type&&(-1<(t=this.refPlanes.indexOf(e))&&this.refPlanes.splice(t,1),this.needUpdateRefPlaneVertexBuffer=!0,this.needUpdateRefPlaneDispData=!0)}}var lt,dt,ct,ht,ut=function(e,t){var r=this;this.geomManager=e,this.ndsModel=t,this.nMeshes=0,this.matrixes=null,this.bboxes=[],this.geomId=[],this.matrixId=null,this.materialId=[],this.materialIdOriginal=[],this.materialUuids=[],this.bodyNodes=[],this.bodyUuids=[],this.meshObjectUuids=void 0,this.bodyUuid2IdMap={},this.materials={},this.mats=[],this.matsCopy=[],this.lineSegments2=new qe,this.lineSegments2_st=new qe,this.lineSegToLineSeg2Map=new Map,this.lineSegToLineSeg2MatMap=new Map,this.oriGeomUuid2MeshPosMap=new Map,this.lineStyleGeomUuid2MeshPosMap=new Map,this.geomUuid2MeshMtMap=new Map,this.geomUuid2MeshPosMap=new Map,this.spliceTextRow=[],this.spliceTextRowSelectArea=[],this.lineTypeUuid2ParamsMap=new Map,this.geomUuid2IndexMap=new Map,this.point2=new rt,this.lineSegToPoint2Map=new Map,this.lineSegToPoint2MatMap=new Map,this.nLineSegments=0,this.lineSegGeomId=[],this.lineSegMatrixId=null,this.lineSegMaterialId=[],this.lineSegBodyNodes=[],this.lineSegBodyUuids=[],this.lineSegObjectUuids=void 0,this.lineSegMaterial=null,this.lineSegMaterialCopy=null,this.lineSegMaterialHidden=null,this.lineSegSelectedMaterialHidden=null,this.LINESEG_LOADED_FLAG=1,this.lineSegFlag=[],this.nTexts=0,this.textGeomId=[],this.textMatrixId=null,this.textMaterialId=[],this.textBodyNodes=[],this.textBodyUuids=[],this.textObjectUuids=void 0,this.geomUuid=[],this.subgeomId=[],this.lineSegGeomUuid=[],this.textGeomUuid=[],this._matrix_copy_=new THREE.Matrix4,this.mesh=new THREE.Mesh,this.mesh.bbox=new THREE.Box3,this.lineSegments=new THREE.LineSegments,this.points=new THREE.Points,this.supportInstancedArrays=!1,this.supportInstancedArraysCopy=!1,this.instancedMeshIds=[],this.instancedLineSegInfos=[],this.instancedLineSegs=new Set,this.unInstancedLineSegIds=[],this.bNeedRecalculateInstanceMesh=!0,this.selectedMaterial=null,this.selectedLineSegMaterial=null,this.overrideMaterial=null,this.overrideMaterialCopy=null,this.useBodyIdMaterial=!1,this.meshMaterial=new THREE.MeshBasicMaterial({color:16711680,side:THREE.DoubleSide}),Array.prototype.extend=function(e){var t=this;e.forEach(function(e){t.push(e)},this)},Array.prototype.deletefromIds=function(e,t){var n=this;t&&e.sort(ot).reverse(),e.forEach(function(e){n.splice(e,1)},this)},this.dispose=function(){for(var e=0,t=r.mats.length;e<t;++e)r.mats[e]&&r.mats[e].dispose(),r.mats[e]=null;r.mats=[];for(var n=0,i=r.matsCopy.length;n<i;++n)r.matsCopy[n]&&r.matsCopy[n].dispose(),r.matsCopy[n]=null;r.matsCopy=[]}},pt=(ut.prototype={constructor:ut,setMatrixes:function(e){this.matrixes=e},expandMatrixes:function(e){var t,n;return this.matrixes?(t=this.matrixes.length/16,(n=new Array).extend(this.matrixes),n.extend(e),this.matrixes=new Float32Array(n),t):(this.setMatrixes(e),0)},setNumMeshes:function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1),this.nMeshes=e,this.bboxes=new Float32Array(6*e),this.geomId=new Int32Array(e),this.materialId=new Int32Array(e),this.materialIdOriginal=new Int32Array(e),this.bodyNodes=new Array(e),this.bodyUuids=new Array(e),t&&(this.meshObjectUuids=new Array(e)),n&&(this.matrixId=new Int32Array(e))},expandMeshes:function(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=!1),0===this.nMeshes)return this.setNumMeshes(e,t,n),0;var i=this.nMeshes;if(this.nMeshes+=e,this.nMeshes>this.geomId.length){for(var e=100<=e?e:100,r=new Float32Array(this.bboxes.length+6*e),o=0,a=this.bboxes.length;o<a;++o)r[o]=this.bboxes[o];this.bboxes=r;for(var s=new Int32Array(this.geomId.length+e),l=0,d=this.geomId.length;l<d;++l)s[l]=this.geomId[l];this.geomId=s;for(var c=new Int32Array(this.materialId.length+e),h=0,u=this.materialId.length;h<u;++h)c[h]=this.materialId[h];this.materialId=c;for(var p=new Int32Array(this.materialIdOriginal.length+e),f=0,m=this.materialIdOriginal.length;f<m;++f)p[f]=this.materialIdOriginal[f];if(this.materialIdOriginal=p,this.bodyNodes=this.bodyNodes.concat(new Array(e)),this.bodyUuids=this.bodyUuids.concat(new Array(e)),t&&(this.meshObjectUuids=this.meshObjectUuids.concat(new Array(e))),n){for(var g=new Int32Array(this.matrixId.length+e),v=0,A=this.matrixId.length;v<A;++v)g[v]=this.matrixId[v];this.materialId=g}}return this.instancedMeshIds.length=0,i},deleteMeshes:function(n){n.sort(ot).reverse(),this.nMeshes-=n.length;var e=new Array,e=(e.extend(this.bboxes),e=e.filter(function(e,t){if(-1==n.indexOf(Math.floor(t/6)))return!0}),this.bboxes=new Float32Array(e),new Array),e=(e.extend(this.geomId),e.deletefromIds(n),this.geomId=new Int32Array(e),new Array),e=(e.extend(this.geomUuid),e.deletefromIds(n),this.geomUuid=e,new Array),e=(e.extend(this.materialId),e.deletefromIds(n),this.materialId=new Int32Array(e),new Array),e=(e.extend(this.materialIdOriginal),e.deletefromIds(n),this.materialIdOriginal=new Int32Array(e),new Array),e=(e.extend(this.bodyNodes),e.deletefromIds(n),this.bodyNodes=e,new Array);e.extend(this.bodyUuids),e.deletefromIds(n),this.bodyUuids=e,this.bNeedRecalculateInstanceMesh=!0},setMeshFromGeomUuid:function(e,t,n,i,r,o,a,s){for(var l=0,l=0;l<6;++l)this.bboxes[6*e+l]=t[l];this.geomUuid[e]=n,this.subgeomId[e]=i,this.materialId[e]=r,this.materialIdOriginal[e]=r,this.bodyUuids[e]=o,this.meshObjectUuids&&(this.meshObjectUuids[e]=a),this.matrixId&&(this.matrixId[e]=s)},setMaterialUuids:function(e){this.materialUuids=e},expandMaterialUuids:function(e){if(!this.materialUuids)return this.setMaterialUuids(e),null;var t=[];if(e&&0<e.length)for(var n=0,i=e.length;n<i;++n){var r=this.materialUuids.indexOf(e[n]);-1===r&&(r=this.materialUuids.length,this.materialUuids[r]=e[n]),t[n]=r}return t},setMaterials:function(e){Object.assign(this.materials,e)},expandBodyUuids:function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0);for(var r,o=t=void 0===t?0:t;o<this.nMeshes;o++)r=this.bodyUuids[o],this.ndsModel.viewer.ndsModel.bodyuuidOld2New[e[r]]?this.bodyUuids[o]=this.ndsModel.viewer.ndsModel.bodyuuidOld2New[e[r]]:this.bodyUuids[o]=e[r],this.meshObjectUuids&&(r=this.meshObjectUuids[o],this.ndsModel.viewer.ndsModel.bodyuuidOld2New[e[r]]?this.meshObjectUuids[o]=this.ndsModel.viewer.ndsModel.bodyuuidOld2New[e[r]]:this.meshObjectUuids[o]=e[r]);for(var a,o=n;o<this.nLineSegments;o++)a=this.lineSegBodyUuids[o],this.ndsModel.viewer.ndsModel.bodyuuidOld2New[e[a]]?this.lineSegBodyUuids[o]=this.ndsModel.viewer.ndsModel.bodyuuidOld2New[e[a]]:this.lineSegBodyUuids[o]=e[a],this.lineSegObjectUuids&&(a=this.lineSegObjectUuids[o],this.lineSegObjectUuids[o]=e[a]);for(var s,l=i;l<this.nTexts;++l)s=this.textBodyUuids[l],this.textBodyUuids[l]=e[s],this.textObjectUuids&&(s=this.textObjectUuids[l],this.textObjectUuids[l]=e[s]);for(var d=this.bodyUuids.length,c=0;c<d;++c)this.bodyUuid2IdMap[this.bodyUuids[c]]=c},setBodyUuids:function(e){this.expandBodyUuids(e)},collectGeomRefEntities:function(){for(var n=this,e=0,t=this.geomManager.geoms.length;e<t;++e)this.geomManager.geoms[e].refMeshes.length=0,this.geomManager.geoms[e].refLineSegs.length=0;for(var i,e=0;e<this.nMeshes;++e)-1<(i=this.geomId[e])&&this.geomManager.geoms[i].refMeshes.push(e);if(this.ndsModel.viewer.is2DModel)for(e=0;e<this.nLineSegments;++e)-1<this.lineSegGeomId[e]&&this.geomManager.geoms[this.lineSegGeomId[e]].refLineSegs.push(e);for(e=0,t=this.geomManager.geoms.length;e<t;++e)this.geomManager.geoms[e].refMeshes.sort(function(e,t){return n.materialId[e]-n.materialId[t]}),1<this.geomManager.geoms[e].refLineSegs.length&&this.geomManager.geoms[e].refLineSegs.sort(function(e,t){return n.lineSegMaterialId[e]-n.lineSegMaterialId[t]})},setMaterialInfor:function(){var e=0,t=this.mats.length,n=(this.mats=[],this.materialUuids.length);for(e=0;e<n;++e){var i=(i=this.materials[this.materialUuids[e]])||this.materials[this.materialUuids[e].toUpperCase()];this.mats.push(i?i.mat:null)}var r,o,a,s={};for(e=0;e<this.nMeshes;++e)-1<this.geomId[e]&&(l=this.geomManager.getGeomFromId(this.geomId[e])).vertexColors&&((o=s[this.materialId[e]])||((r=(new(r=this.mats[this.materialId[e]]).constructor).copy(r)).vertexColors=!0,this.mats.push(r),++n,o=this.mats.length-1,s[this.materialId[e]]=o),this.materialId[e]=o,this.materialIdOriginal[e]=o);for(e=0;e<n;++e)this.mats[e]?(a=(new this.mats[e].constructor).copy(this.mats[e]),this.mats.push(a)):this.mats.push(null);if(this.supportInstancedArrays)for(var l,d=this.mats.length/2,e=0;e<this.nMeshes;++e)-1<this.geomId[e]&&(1<(l=this.geomManager.getGeomFromId(this.geomId[e])).refMeshes.length&&!l.useSharedGlBuffer?(this.materialId[e]=this.materialIdOriginal[e]+d,l.updateModelMatrix=!0):this.materialId[e]=this.materialIdOriginal[e]);if(0<this.matsCopy.length&&this.mats.length!=t){var c=this.matsCopy[0].opacity;for(e=0;e<this.matsCopy.length;++e)this.matsCopy[e].dispose();for(e=this.matsCopy.length=0;e<this.mats.length;++e)this.mats[e]&&(this.matsCopy[e]=this.mats[e].clone(),this.matsCopy[e].uuid=this.mats[e].uuid,this.matsCopy[e].program=this.mats[e].program,this.matsCopy[e].needsUpdate=this.mats[e].needsUpdate,this.matsCopy[e].opacity=c,this.matsCopy[e].transparent=!0)}},mapGeomUuidToGeomId:function(){for(var e=0,e=0;e<this.nMeshes;++e)this.geomId[e]=this.geomManager.getGeomIdFromUuid(this.geomUuid[e],this.subgeomId[e]);for(e=0;e<this.nLineSegments;++e)this.lineSegGeomId[e]=this.geomManager.getGeomIdFromUuid(this.lineSegGeomUuid[e],0);for(e=0;e<this.nTexts;++e)this.textGeomId[e]=this.geomManager.getGeomIdFromUuid(this.textGeomUuid[e],0);for(this.collectGeomRefEntities(),e=0;e<this.geomManager.geoms.length;++e){var t=this.geomManager.geoms[e];if(1<t.refMeshes.length){t.refMeshesSameMaterial=!0,t.refMeshesSameMaterialOriginal=!0;for(var n=0;n<t.refMeshes.length-1;++n){var i=t.refMeshes[n],r=t.refMeshes[n+1];if(this.materialId[i]!=this.materialId[r]){t.refMeshesSameMaterial=!1,t.refMeshesSameMaterialOriginal=!1;break}}}if(1<t.refLineSegs.length){t.refLineSegsSameMaterial=!0,t.refLineSegsSameMaterialOriginal=!0;for(n=0;n<t.refLineSegs.length-1;++n){i=t.refLineSegs[n],r=t.refLineSegs[n+1];if(this.lineSegMaterialId[i]!=this.lineSegMaterialId[r]||this.lineSegBodyUuids[i]!=this.lineSegBodyUuids[r]){t.refLineSegsSameMaterial=!1,t.refLineSegsSameMaterialOriginal=!1;break}}}}this.setMaterialInfor(),this.bNeedRecalculateInstanceMesh=!0},setMeshMaterialEnvMap:function(e,t){if(this.ndsModel.bodyNodeUUidToMaterial)for(var n in this.ndsModel.bodyNodeUUidToMaterial){n=this.ndsModel.bodyNodeUUidToMaterial[n];n.envMap=e,n.combine=t}for(var i=0,r=this.mats.length;i<r;++i)this.mats[i]&&void 0!==this.mats[i].envMap&&(this.mats[i].envMap=e,void 0!==this.mats[i].combine&&(this.mats[i].combine=t),this.mats[i].needsUpdate=!0)},getMeshBBox:function(){new THREE.Matrix4;return function(e,t){var n=this.bodyNodes[e],n=this.ndsModel.getBodyTranslate(n);t.min.fromArray(this.bboxes,6*e),t.max.fromArray(this.bboxes,6*e+3);(1e-7<Math.abs(n[0])||1e-7<Math.abs(n[1])||1e-7<Math.abs(n[2]))&&(t.min.x+=n[0],t.min.y+=n[1],t.min.z+=n[2],t.max.x+=n[0],t.max.y+=n[1],t.max.z+=n[2])}}(),updateMeshBBox:function(e){var t,n;this.geomId[e]<0||(t=this.bodyNodes[e],(n=this.geomManager.getGeomFromId(this.geomId[e]).boundingBox.clone()).applyMatrix4(t.worldMatrix),this.bboxes[6*e]=n.min.x,this.bboxes[6*e+1]=n.min.y,this.bboxes[6*e+2]=n.min.z,this.bboxes[6*e+3]=n.max.x,this.bboxes[6*e+4]=n.max.y,this.bboxes[6*e+5]=n.max.z)},getMeshInfor:function(e,t){var n=this.bodyNodes[e],i=this.ndsModel.getBodyTranslate(n),e=(-1<this.geomId[e]?t.geometry=this.geomManager.getGeomFromId(this.geomId[e]):t.geometry=null,this.materialId[e]),e=(e>=this.mats.length/2&&(t.geometry.refMeshesSameMaterial&&this.supportInstancedArrays&&!t.geometry.useSharedGlBuffer||(e-=this.mats.length/2)),t.material=this.mats[e],t.matrixWorld||(t.matrixWorld=new THREE.Matrix4),n.worldMatrix);t.matrixWorld.copy(e),t.matrixWorld.elements[12]+=i[0],t.matrixWorld.elements[13]+=i[1],t.matrixWorld.elements[14]+=i[2]},getSingleMesh:function(e){var t=this.supportInstancedArrays,e=(this.supportInstancedArrays=!1,this.getMesh(e));return this.supportInstancedArrays=t,e},getMeshMaterialByMeshId:function(t,e,n){var i,r,o,a,s=e;if(e||!(s=this.bodyNodes[t]).isHidden())return(e=n)||(e=this.geomManager.getGeomFromId(this.geomId[t])),n=s.getMaterialBodyNodeUUid(),(i=s.getUserMaterial())?(i.colors&&i.colors.forEach(function(e){e.meshId==t&&(i.color.copy(e.value),i.needsUpdate=!0,i.needsRefresh=!0)}),i.opacities&&i.opacities.forEach(function(e){e.meshId==t&&(i.opacity=e.value,i.opacity<1?i.transparent=!0:i.transparent=!1,i.needsUpdate=!0,i.needsRefresh=!0)}),(a=this.materialId[t])>=this.mats.length/2&&(e.refMeshesSameMaterial&&this.supportInstancedArrays&&!e.useSharedGlBuffer||(a-=this.mats.length/2)),o=this.mats[a],i.backMaterial||(i.backMaterial=i.clone(),i.backMaterial.transparent=!0,i.backMaterial.opacity=_e.bodyOpacity,i.backoriMaterial=i.clone(),i.backoriMaterial.transparent=o.transparent,i.backoriMaterial.opacity=o.opacity),o=i,e.refMeshesSameMaterial=!1,0<this.ndsModel.transparentizedBodies.length&&s.isTransparent()?o=i.backMaterial:s.isOriginalTransparent()&&(o=i.backoriMaterial)):(r=n&&(n=this.ndsModel.bodyNodeUUidToMaterial[n])?n:r)?(r.transparentMaterial||(r.transparentMaterial=r.clone(),r.transparentMaterial.transparent=!0,r.transparentMaterial.opacity=_e.bodyOpacity),o=r,e.refMeshesSameMaterial=!1,0<this.ndsModel.transparentizedBodies.length&&s.isTransparent()&&(o=r.transparentMaterial)):((a=this.materialId[t])>=this.mats.length/2&&(e.refMeshesSameMaterial&&this.supportInstancedArrays&&!e.useSharedGlBuffer||(a-=this.mats.length/2)),o=this.mats[a],0<this.ndsModel.transparentizedBodies.length&&s.isTransparent()&&(o=this.matsCopy[a])),o},getMesh:function(e){if(!(this.geomId[e]<0)){var t=this.bodyNodes[e];if(_e.HideLeafBody){var n=t.parent.FirstVisibleNode||0;if(t.parent.children[n].isHidden()||t.unload)return}else if(t.isHidden())return;if(this.mesh.meshId=e,this.mesh.hasSurface=t.hasSurface,this.mesh.geometry=this.geomManager.getGeomFromId(this.geomId[e]),this.mesh.geometry.aniMorphInfluences&&this.mesh.geometry.aniMorphDictionary?(this.mesh.morphTargetInfluences=this.mesh.geometry.aniMorphInfluences,this.mesh.morphTargetDictionary=this.mesh.geometry.aniMorphDictionary):this.mesh.morphTargetInfluences&&(delete this.mesh.morphTargetInfluences,delete this.mesh.morphTargetDictionary),this.mesh.geometry.isInstancedBufferGeometry=!1,this.mesh.material=this.getMeshMaterialByMeshId(e,t,this.mesh.geometry),this.mesh.material){var i=this.mesh.geometry.refMeshes.length;if(this.supportInstancedArrays&&1<i&&!this.mesh.geometry.useSharedGlBuffer){if(this.mesh.geometry.refMeshesSameMaterial){if(this.mesh.instancedCount=i,!this.mesh.geometry.dirty&&!this.mesh.geometry.updateModelMatrix&&this.mesh.geometry.modelMatrixAttribute)return;if(!this.mesh.geometry.modelMatrixAttribute||this.mesh.geometry.updateModelMatrix){for(var r=new Float32Array(16*i),o=0;o<i;++o){var a=this.mesh.geometry.refMeshes[o],s=16*o;if(this.matrixes)for(var l=0;l<16;++l)r[s+l]=this.matrixes[16*this.matrixId[a]+l];else this.bodyNodes[a].worldMatrix.toArray(r,s);var d=this.ndsModel.getBodyTranslate(this.bodyNodes[a]);r[12+s]+=d[0],r[13+s]+=d[1],r[14+s]+=d[2]}this.mesh.geometry.modelMatrixAttribute?(this.mesh.geometry.modelMatrixAttribute.array=r,this.mesh.geometry.modelMatrixAttribute.needsUpdate=!0,this.mesh.geometry.needsUpdate=!0):(this.mesh.geometry.modelMatrixAttribute=new THREE.InstancedBufferAttribute(r,16),this.mesh.geometry.modelMatrixAttribute.onUploadCallback=function(){this.array=null},this.mesh.geometry.setAttribute("modelMatrixAttrib",this.mesh.geometry.modelMatrixAttribute)),this.mesh.geometry.updateModelMatrix=!1}return this.mesh.geometry.dirty=!1,this.overrideMaterialCopy&&(this.mesh.material=this.overrideMaterialCopy),this.mesh.geometry.isInstancedBufferGeometry=!0,this.mesh.geometry.instanceCount=this.mesh.instancedCount,this.mesh}this.mesh.geometry.modelMatrixAttribute&&(this.mesh.geometry.modelMatrixAttribute.unUsed=!0)}if(this.mesh.geometry.modelMatrixAttribute&&(this.mesh.geometry.deleteAttribute("modelMatrixAttrib"),delete this.mesh.geometry.modelMatrixAttribute),this.mesh.instancedCount=0,this.mesh.geometry.instanceCount=0,this.matrixes&&!this.ndsModel.viewer.animationRun)for(l=0;l<16;++l)this.mesh.matrixWorld.elements[l]=this.matrixes[16*this.matrixId[e]+l];else this.mesh.matrixWorld.copy(t.worldMatrix);d=this.ndsModel.getBodyTranslate(t);return this.mesh.matrixWorld.elements[12]+=d[0],this.mesh.matrixWorld.elements[13]+=d[1],this.mesh.matrixWorld.elements[14]+=d[2],this.overrideMaterial&&(this.mesh.material=this.overrideMaterial,this.useBodyIdMaterial)&&(this.mesh.material=this.overrideMaterialCopy,this.mesh.material.color.setHex(10*t.id)),this.mesh}}},getMeshOriginalMaterial:function(e){var t,n,i,r=this.bodyNodes[e],o=r.getMaterialBodyNodeUUid(),a=r.getUserMaterial(),s=null;return a?((i=this.materialId[e])>=this.mats.length/2&&(this.mesh.geometry.refMeshesSameMaterial&&this.supportInstancedArrays&&!this.mesh.geometry.useSharedGlBuffer||(i-=this.mats.length/2)),n=this.mats[i],a.backMaterial||(a.backMaterial=a.clone(),a.backMaterial.transparent=!0,a.backMaterial.opacity=_e.bodyOpacity,a.backoriMaterial=a.clone(),a.backoriMaterial.transparent=n.transparent,a.backoriMaterial.opacity=n.opacity),s=a,0<this.ndsModel.transparentizedBodies.length&&r.isTransparent()?s=a.backMaterial:r.isOriginalTransparent()&&(s=a.backoriMaterial)):s=(t=o&&(n=this.ndsModel.bodyNodeUUidToMaterial[o])?n:t)||(i=this.materialId[e],this.mats[i]),s},getText:function(e){if(!(this.textGeomId[e]<0)){var t=this.textBodyNodes[e];if(!t.isHidden())return"shxLoad"==(t=this.geomManager.getGeomFromId(this.textGeomId[e])).textLoad?this.getLineText(e):"ttfLoad"==t.textLoad?this.getMeshText(e):void t.textLoad}},getLineText:function(e){var t=this.textBodyNodes[e];if(!t.isHidden()){this.lineSegments.geometry=this.geomManager.getGeomFromId(this.textGeomId[e]),this.lineSegments.geometry.isInstancedBufferGeometry=!1,this.lineSegments.material=this.materials["text:"+this.lineSegments.geometry.styleId].mat;var n=this.mats[this.textMaterialId[e]],i=(3<this.ndsModel.viewer.modelContentVersion&&(this.lineSegments.geometry.viewBox?(this.lineSegments.material.uniforms.min2.value.copy(this.lineSegments.geometry.viewBox.min2),this.lineSegments.material.uniforms.max2.value.copy(this.lineSegments.geometry.viewBox.max2)):(this.lineSegments.material.uniforms.min2.value.set(0,0),this.lineSegments.material.uniforms.max2.value.set(0,0))),this.lineSegments.material.uniforms.diffuse.value.copy(t.isSelected()?_e.selectedColor:n.color),this.lineSegments.material.uniformsNeedUpdate=!0,1<n.linewidth&&(this.lineSegments.material.linewidthCopy=n.linewidth),this.lineSegments.material.linewidth=1,this.lineSegments.geometry.refMeshes.length);if(this.supportInstancedArrays&&1<i&&!this.lineSegments.geometry.useSharedGlBuffer&&this.lineSegments.geometry.refMeshesSameMaterial){if(this.lineSegments.instancedCount=i,!this.lineSegments.geometry.dirty&&!this.lineSegments.geometry.updateModelMatrix&&this.lineSegments.geometry.modelMatrixBuffer)return void(this.lineSegments.matrixWorlds=null);if(!this.lineSegments.geometry.vao&&!this.lineSegments.geometry.modelMatrixBuffer||this.lineSegments.geometry.updateModelMatrix){this.lineSegments.matrixWorlds=new Float32Array(16*i);for(var r=0;r<i;++r){var o=this.lineSegments.geometry.refMeshes[r],a=16*r;if(this.matrixes)for(var s=0;s<16;++s)this.lineSegments.matrixWorlds[a+s]=this.matrixes[16*this.textMatrixId[o]+s];else this.bodyNodes[o].worldMatrix.toArray(this.lineSegments.matrixWorlds,a);var l=this.ndsModel.getBodyTranslate(this.bodyNodes[o]);this.lineSegments.matrixWorlds[12+a]+=l[0],this.lineSegments.matrixWorlds[13+a]+=l[1],this.lineSegments.matrixWorlds[14+a]+=l[2]}this.lineSegments.geometry.updateModelMatrix=!1}else this.lineSegments.matrixWorlds=null;this.lineSegments.geometry.dirty=!1,this.overrideMaterialCopy&&(this.lineSegments.material=this.overrideMaterialCopy)}else{if(this.lineSegments.position.copy(this.lineSegments.geometry.position),this.lineSegments.quaternion.copy(this.lineSegments.geometry.quaternion),this.lineSegments.updateMatrix(),this.lineSegments.matrixWorldNeedsUpdate=!1,this.lineSegments.geometry.modelMatrixAttribute&&(this.lineSegments.geometry.deleteAttribute("modelMatrixAttrib"),delete this.lineSegments.geometry.modelMatrixAttribute),this.lineSegments.instancedCount=0,this.lineSegments.geometry.instanceCount=0,this.matrixes)for(s=0;s<16;++s)this.lineSegments.matrixWorld.elements[s]=this.matrixes[16*this.textMatrixId[e]+s];else this.lineSegments.matrixWorld.copy(t.worldMatrix);this.ndsModel.viewer.modelContentVersion<4&&this.lineSegments.matrixWorld.multiply(this.lineSegments.matrix);l=this.ndsModel.getBodyTranslate(t);this.lineSegments.matrixWorld.elements[12]+=l[0],this.lineSegments.matrixWorld.elements[13]+=l[1],this.lineSegments.matrixWorld.elements[14]+=l[2],this.lineSegments.lineSegments2=this.lineSegmentToLineSegment2(this.lineSegments2,this.lineSegments.geometry,this.lineSegments.material,t.isSelected(),this.lineSegments.matrixWorld)}return this.lineSegments}},getMeshText:function(e){if(!(this.textGeomId[e]<0)){var t=this.textBodyNodes[e];if(!t.isHidden()){this.mesh.meshId=e,this.mesh.geometry=this.geomManager.getGeomFromId(this.textGeomId[e]),this.mesh.geometry.isInstancedBufferGeometry=!1,this.mesh.material=this.materials["text:"+this.mesh.geometry.styleId].mat;var n=this.mats[this.textMaterialId[e]],i=(3<this.ndsModel.viewer.modelContentVersion&&(this.mesh.geometry.viewBox?(this.mesh.material.uniforms.min2.value.copy(this.mesh.geometry.viewBox.min2),this.mesh.material.uniforms.max2.value.copy(this.mesh.geometry.viewBox.max2)):(this.mesh.material.uniforms.min2.value.set(0,0),this.mesh.material.uniforms.max2.value.set(0,0))),this.mesh.material.uniforms.diffuse.value.copy(t.isSelected()?_e.selectedColor:n.color),this.mesh.material.uniformsNeedUpdate=!0,this.mesh.geometry.refMeshes.length);if(this.supportInstancedArrays&&1<i&&!this.mesh.geometry.useSharedGlBuffer&&this.mesh.geometry.refMeshesSameMaterial){if(this.mesh.instancedCount=i,!this.mesh.geometry.dirty&&!this.mesh.geometry.updateModelMatrix&&this.mesh.geometry.modelMatrixBuffer)return void(this.mesh.matrixWorlds=null);if(!this.mesh.geometry.vao&&!this.mesh.geometry.modelMatrixBuffer||this.mesh.geometry.updateModelMatrix){this.mesh.matrixWorlds=new Float32Array(16*i);for(var r=0;r<i;++r){var o=this.mesh.geometry.refMeshes[r],a=16*r;if(this.matrixes)for(var s=0;s<16;++s)this.mesh.matrixWorlds[a+s]=this.matrixes[16*this.textMatrixId[o]+s];else this.bodyNodes[o].worldMatrix.toArray(this.mesh.matrixWorlds,a);var l=this.ndsModel.getBodyTranslate(this.bodyNodes[o]);this.mesh.matrixWorlds[12+a]+=l[0],this.mesh.matrixWorlds[13+a]+=l[1],this.mesh.matrixWorlds[14+a]+=l[2]}this.mesh.geometry.updateModelMatrix=!1}else this.mesh.matrixWorlds=null;this.mesh.geometry.dirty=!1,this.overrideMaterialCopy&&(this.mesh.material=this.overrideMaterialCopy)}else{if(this.mesh.position.copy(this.mesh.geometry.position),this.mesh.quaternion.copy(this.mesh.geometry.quaternion),this.mesh.updateMatrix(),this.mesh.matrixWorldNeedsUpdate=!1,this.mesh.geometry.modelMatrixAttribute&&(this.mesh.geometry.deleteAttribute("modelMatrixAttrib"),delete this.mesh.geometry.modelMatrixAttribute),this.mesh.instancedCount=0,this.mesh.geometry.instanceCount=0,this.matrixes)for(s=0;s<16;++s)this.mesh.matrixWorld.elements[s]=this.matrixes[16*this.textMatrixId[e]+s];else this.mesh.matrixWorld.copy(t.worldMatrix);this.ndsModel.viewer.modelContentVersion<4&&this.mesh.matrixWorld.multiply(this.mesh.matrix);l=this.ndsModel.getBodyTranslate(t);this.mesh.matrixWorld.elements[12]+=l[0],this.mesh.matrixWorld.elements[13]+=l[1],this.mesh.matrixWorld.elements[14]+=l[2],this.mesh.geometry.textWireFrame&&(this.lineSegments.geometry=this.mesh.geometry.textWireFrame,this.lineSegments.material=this.mesh.material,this.mesh.line=this.lineSegments)}return this.mesh}}},recalculateInstance:function(){var t=this;if(this.bNeedRecalculateInstanceMesh){this.instancedLineSegInfos.length=0;for(var e=this.unInstancedLineSegIds.length=0,n=this.geomManager.geoms.length;e<n;++e)if(1<this.geomManager.geoms[e].refMeshes.length&&this.instancedMeshIds.push(this.geomManager.geoms[e].refMeshes[0]),1<this.geomManager.geoms[e].refLineSegs.length){for(var i=this.geomManager.geoms[e],r=this.lineSegMaterialId[i.refLineSegs[0]],o=this.lineSegBodyUuids[i.refLineSegs[0]],a=[],s=this.instancedLineSegInfos.length,l=0,d=i.refLineSegs.length;l<d;++l)r===this.lineSegMaterialId[i.refLineSegs[l]]&&o===this.lineSegBodyUuids[i.refLineSegs[l]]||(r=this.lineSegMaterialId[i.refLineSegs[l]],o=this.lineSegBodyUuids[i.refLineSegs[l]],1<a.length?(this.instancedLineSegInfos.push({instanceId:s,lineSegIds:a}),a.forEach(function(e){return t.instancedLineSegs.add(e)})):this.unInstancedLineSegIds.push(a[0]),a=[]),a[a.length]=i.refLineSegs[l];1<a.length?(this.instancedLineSegInfos.push({instanceId:s,lineSegIds:a}),a.forEach(function(e){return t.instancedLineSegs.add(e)})):1===a.length&&this.unInstancedLineSegIds.push(a[0])}else 1===this.geomManager.geoms[e].refLineSegs.length&&this.unInstancedLineSegIds.push(this.geomManager.geoms[e].refLineSegs[0]);this.unInstancedLineSegIds.sort(function(e,t){return e-t});for(var c=[],e=0,n=this.instancedMeshIds.length;e<n;++e){var h=this.instancedMeshIds[e],u=this.materialId[h],p=this.mats[u],p=p.program?p.program.id:1e4;c.push(new L(h,u,p,0))}c.sort(D),this.instancedMeshDirtyFlags=[];for(e=0,n=this.instancedMeshIds.length;e<n;++e)this.instancedMeshIds[e]=c[e].meshId,this.instancedMeshDirtyFlags[e]=!0;this.instancedLineDirtyFlags=[];for(e=0,n=this.instancedLineSegs.size;e<n;++e)this.instancedLineDirtyFlags[e]=!0;this.bNeedRecalculateInstanceMesh=!1}},resetLineInstance:function(){for(var e=0,t=this.geomManager.geoms.length;e<t;++e)if(1<this.geomManager.geoms[e].refLineSegs.length){for(var n=this.geomManager.geoms[e],i=this.lineSegMaterialId[n.refLineSegs[0]],r=[],o=0,a=n.refLineSegs.length;o<a;++o)r[r.length]=n.refLineSegs[o],i!==this.lineSegMaterialId[n.refLineSegs[o]]&&(i=this.lineSegMaterialId[n.refLineSegs[o]],1<r.length&&(n.dirty=!0),r=[]);1<r.length&&(n.dirty=!0)}},getNumInstancedLineSegs:function(){return this.recalculateInstance(),this.instancedLineSegInfos.length},getNumUnInstancedLineSegs:function(){return this.recalculateInstance(),this.unInstancedLineSegIds.length},getNumInstancedMeshes:function(){return this.recalculateInstance(),this.instancedMeshIds.length},getInstancedMesh:function(e){e=this.instancedMeshIds[e],e=this.getMesh(e);if(e&&e.geometry.refMeshesSameMaterial)return e},getInstancedLineSegWithState:function(e,t){e=this.instancedLineSegInfos[e];return this.getLineSegmentsWithState(e,t)},getInstancedLineSeg:function(e,t){e=this.instancedLineSegInfos[e],e=this.getLineSegmentsWithState(e,t);return 1===e.state?e.lineSegments:null},getUnInstancedLineSegWithState:function(e,t){return this.getLineSegmentsWithState(this.unInstancedLineSegIds[e],t,!0)},getUnInstancedLineSeg:function(e,t){e=this.getLineSegmentsWithState(this.unInstancedLineSegIds[e],t,!0);return 1===e.state?e.lineSegments:null},getInstancedLineSegId:function(e){return this.instancedLineSegInfos[e].lineSegIds[0]},getUnInstancedLineSegId:function(e){return this.unInstancedLineSegIds[e]},getInstancedMeshId:function(e){return this.instancedMeshIds[e]},setNumLineSegments:function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1),this.nLineSegments=e,this.lineSegGeomId=new Int32Array(e),this.lineSegMaterialId=new Int32Array(e),this.lineSegFlag=new Uint8Array(e),this.lineSegBodyUuids=new Array(e),this.lineSegBodyNodes=new Array(e),t&&(this.lineSegObjectUuids=new Array(e)),n&&(this.lineSegMatrixId=new Int32Array(e))},expandLineSegments:function(e,t,n){var i,r;return void 0===t&&(t=!1),void 0===n&&(n=!1),0===this.nLineSegments?(this.setNumLineSegments(e,t,n),0):(i=this.nLineSegments,this.nLineSegments+=e,this.nLineSegments>this.lineSegGeomId.length&&(e=100<=e?e:100,(r=new Int32Array(this.lineSegGeomId.length+e)).set(this.lineSegGeomId),this.lineSegGeomId=r,(r=new Int32Array(this.lineSegMaterialId.length+e)).set(this.lineSegMaterialId),this.lineSegMaterialId=r,(r=new Uint8Array(this.lineSegFlag.length+e)).set(this.lineSegFlag),this.lineSegFlag=r,this.lineSegBodyNodes=this.lineSegBodyNodes.concat(new Array(e)),this.lineSegBodyUuids=this.lineSegBodyUuids.concat(new Array(e)),t&&(this.lineSegObjectUuids=this.lineSegObjectUuids.concat(new Array(e))),n)&&((r=new Int32Array(this.lineSegMatrixId.length+e)).set(this.lineSegMatrixId),this.lineSegMatrixId=r),i)},deleteLineSegments:function(e){e.sort(ot).reverse(),this.nLineSegments-=e.length;var t=new Array,t=(t.extend(this.lineSegGeomId),t.deletefromIds(e),this.lineSegGeomId=new Int32Array(t),new Array),t=(t.extend(this.lineSegGeomUuid),t.deletefromIds(e),this.lineSegGeomUuid=t,new Array),t=(t.extend(this.lineSegMaterialId),t.deletefromIds(e),this.lineSegMaterialId=new Int32Array(t),new Array),t=(t.extend(this.lineSegFlag),t.deletefromIds(e),this.lineSegFlag=new Uint8Array(t),new Array),t=(t.extend(this.lineSegBodyUuids),t.deletefromIds(e),this.lineSegBodyUuids=t,new Array);t.extend(this.lineSegBodyNodes),t.deletefromIds(e),this.lineSegBodyNodes=t},setLineSegmentsFromGeomUuid:function(e,t,n,i,r,o){this.lineSegGeomUuid[e]=t,this.lineSegBodyUuids[e]=n,this.lineSegMaterialId[e]=i||-1,this.lineSegObjectUuids&&(this.lineSegObjectUuids[e]=r),this.lineSegMatrixId&&(this.lineSegMatrixId[e]=o)},calcLineSegmentsBox:function(){for(var e=0;e<this.nLineSegments;++e){var t=this.lineSegBodyNodes[e];if(!(0<this.getNumBodyMeshs(t))){var n=this.geomManager.getGeomFromId(this.lineSegGeomId[e]);if(n&&n.boundingBox&&!n.boundingBox.isEmpty()){var i=n.boundingBox.clone();if(0==t.leafBodyAttri.bodyBbox.length)for(var r=0;r<3;++r)t.leafBodyAttri.bodyBbox[r]=i.min.getComponent(r),t.leafBodyAttri.bodyBbox[3+r]=i.max.getComponent(r)}}}},mergeLineSegments:function(){for(var e,t,n=0;n<this.nLineSegments;++n){var i,r=this.lineSegBodyNodes[n];if(!(0<this.getNumBodyMeshs(r))&&r.leafBodyAttri)if(i=this.geomManager.getGeomFromId(this.lineSegGeomId[n])){var o=i.boundingBox.clone();if(6==r.leafBodyAttri.bodyBbox.length)for(var a=0;a<3;++a)o.min.getComponent(a)<r.leafBodyAttri.bodyBbox[a]&&(r.leafBodyAttri.bodyBbox[a]=o.min.getComponent(a)),o.max.getComponent(a)>r.leafBodyAttri.bodyBbox[3+a]&&(r.leafBodyAttri.bodyBbox[3+a]=o.max.getComponent(a));else for(a=0;a<3;++a)r.leafBodyAttri.bodyBbox[a]=o.min.getComponent(a),r.leafBodyAttri.bodyBbox[3+a]=o.max.getComponent(a)}}for(n=0;n<this.nLineSegments-1;++n)this.lineSegBodyNodes[n]===this.lineSegBodyNodes[n+1]&&this.lineSegMaterialId[n]===this.lineSegMaterialId[n+1]&&(t=this.lineSegGeomId[n],e=this.lineSegGeomId[n+1],i=this.geomManager.getGeomFromId(t),t=this.geomManager.getGeomFromId(e),i&&t)&&(i.tangentEdgeObject&&!t.tangentEdgeObject||!i.tangentEdgeObject&&t.tangentEdgeObject||i.index===t.index&&i.drawRange.start+i.drawRange.count===t.drawRange.start&&(t.drawRange.start-=i.drawRange.count,t.drawRange.count+=i.drawRange.count,i.drawRange.count=0))},getNumLineSegments:function(){return this.nLineSegments},isLineSegmentsLoaded:function(e){if(0==(this.lineSegFlag[e]&this.LINESEG_LOADED_FLAG)){var t=this.geomManager,n=t.getGeomFromId(this.lineSegGeomId[e]);if(!n||!n.loaded||!n.index)return!1;t.loadedVertexAttributes.has(n.index.uuid)||(t.usedMemory+=n.index.array.byteLength,t.usedGpuMemory+=n.index.array.byteLength,t.loadedVertexAttributes.add(n.index.uuid)),t.loadedVertexAttributes.has(n.attributes.position.uuid)||(t.usedMemory+=(n.attributes.position.array?n.attributes.position:n.attributes.position.data).array.byteLength,t.usedGpuMemory+=(n.attributes.position.array?n.attributes.position:n.attributes.position.data).array.byteLength,t.loadedVertexAttributes.add(n.attributes.position.uuid)),this.lineSegFlag[e]|=this.LINESEG_LOADED_FLAG,t.usedMemory>=.9*t.maxMemory&&(t.stopLoading=!0,t.allGeomInMemory=!1)}return!0},getLineSegmentsWithState:function(e,t,n){i=e.lineSegIds?(r=e).lineSegIds[0]:e;var i,r,e={state:1,lineSegments:null,lineStyle:null};if((n=void 0===n?!1:n)&&this.instancedLineSegs.has(i))e.state=0;else if(this.isLineSegmentsLoaded(i)){this.instanceMats||(this.instanceMats=new Map);n=this.geomManager.getGeomFromId(this.lineSegGeomId[i]);if(0===n.drawRange.count)e.state=0;else if(!1===_e.tangentEdgeVisible&&n.tangentEdgeObject)e.state=0;else{var o=this.lineSegBodyNodes[i],a=void 0;if(o.isSelected()&&(a=o.isHidden(),o.show()),_e.HideLeafBody&&!o.sketchBody){var s=o.parent.FirstVisibleNode||0;if(o.parent.children[s].isHidden()||o.unload)return e.state=0,e}else if(o.isHidden())return e.state=0,e;this.lineSegments.geometry=n,this.lineSegments.geometry.isInstancedBufferGeometry=!1;var s=null,l=this.lineSegMaterialId[i];if(-1<l&&(1<(s=this.mats[l]).linewidth&&(s.linewidthCopy=s.linewidth),s.linewidth=1),!s||"LineBasicMaterial"!=s.type&&"ShaderMaterial"!=s.type&&!n.isPoints){if(!this.lineSegMaterial){for(var d in this.materials)if("LineBasicMaterial"===this.materials[d].mat.type){this.lineSegMaterial=this.materials[d].mat;break}this.lineSegMaterial||(this.lineSegMaterial=new THREE.LineBasicMaterial({color:0,linewidth:1}))}s=this.lineSegMaterial}if(r&&(this.instanceMats.has(s.uuid)||(l=s.clone(),s.linewidthCopy&&(l.linewidthCopy=s.linewidthCopy),l.needsUpdate=!0,l.needsRefresh=!0,this.instanceMats.set(s.uuid,l)),"ShaderMaterial"==(n=this.instanceMats.get(s.uuid)).type||n.color.equals(s.color)?"ShaderMaterial"!=n.type||n.uniforms.diffuse.value.equals(s.uniforms.diffuse.value)||(n.color&&n.color.copy(s.color),n.uniforms.diffuse.value.copy(s.color)):n.color.copy(s.color),o.isSelected()&&("ShaderMaterial"==n.type||n.color.equals(_e.selectedColor)?"ShaderMaterial"!=n.type||n.uniforms.diffuse.value.equals(_e.selectedColor)||(n.color&&n.color.copy(_e.selectedColor),n.uniforms.diffuse.value.copy(_e.selectedColor)):n.color.copy(_e.selectedColor)),n.isInstanceMaterial=!0,s=n),t?(void 0===s.oldOpacity&&(s.oldOpacity=s.opacity,s.oldTransparent=s.transparent,s.oldDepthFunc=s.depthFunc,s.needsUpdate=!0,s.needsRefresh=!0),s.opacity=.2,s.transparent=!0,s.depthFunc=THREE.GreaterDepth):null!=s.oldOpacity&&(s.opacity=s.oldOpacity,s.transparent=s.oldTransparent,s.depthFunc=s.oldDepthFunc,s.needsUpdate=!0,s.needsRefresh=!0,s.oldOpacity=void 0,s.oldTransparent=void 0,s.oldDepthFunc=void 0),this.lineSegments.material=s,o.isSelected()&&(this.selectedLineSegMaterial=s.clone(),this.ndsModel.viewer.selectionManager.shouldApplySelectedMaterial&&(this.selectedLineSegMaterial.color&&this.selectedLineSegMaterial.color.copy(_e.selectedColor),"ShaderMaterial"==this.selectedLineSegMaterial.type)&&this.selectedLineSegMaterial.uniforms.diffuse.value.copy(_e.selectedColor),this.ndsModel.viewer.selectionManager.overrideLineSelectionMaterialIn3DViewer(this.selectedLineSegMaterial),t&&!this.lineSegSelectedMaterialHidden&&(this.lineSegSelectedMaterialHidden=this.selectedLineSegMaterial.clone(),this.lineSegSelectedMaterialHidden.uuid=this.selectedLineSegMaterial.uuid,this.lineSegSelectedMaterialHidden.program=this.selectedLineSegMaterial.program,this.lineSegSelectedMaterialHidden.needsUpdate=!0,this.lineSegSelectedMaterialHidden.opacity=.2,this.lineSegSelectedMaterialHidden.transparent=!0,this.lineSegSelectedMaterialHidden.depthFunc=THREE.GreaterDepth),this.lineSegments.material=t?this.lineSegSelectedMaterialHidden:this.selectedLineSegMaterial),o.isTransparent()&&this.lineSegMaterialCopy&&!o.isSelected()&&(r?(this.instancedLineSegMaterialCopy||(this.instancedLineSegMaterialCopy=this.lineSegMaterialCopy.clone()),this.lineSegments.material=this.instancedLineSegMaterialCopy):this.lineSegments.material=this.lineSegMaterialCopy),r&&!o.isSelected()){var c=r.lineSegIds.length;if(this.supportInstancedArrays&&1<c&&!this.lineSegments.geometry.useSharedGlBuffer){if(this.lineSegments.geometry.refLineSegsSameMaterial){if(this.lineSegments.instancedCount=c,this.lineSegments.geometry.dirty||this.lineSegments.geometry.updateModelMatrix||!this.lineSegments.geometry.modelMatrixAttribute){if(!this.lineSegments.geometry.modelMatrixAttribute||this.lineSegments.geometry.updateModelMatrix){this.lineSegments.matrixWorlds=new Float32Array(16*c);for(var h=0;h<c;++h){var u=r.lineSegIds[h],p=16*h;if(this.matrixes)for(var f=0;f<16;++f)this.lineSegments.matrixWorlds[p+f]=this.matrixes[16*this.lineSegMatrixId[u]+f];else this.lineSegBodyNodes[u].worldMatrix.toArray(this.lineSegments.matrixWorlds,p);var m=this.ndsModel.getBodyTranslate(this.lineSegBodyNodes[u]);this.lineSegments.matrixWorlds[12+p]+=m[0],this.lineSegments.matrixWorlds[13+p]+=m[1],this.lineSegments.matrixWorlds[14+p]+=m[2]}this.lineSegments.geometry.modelMatrixAttribute?(this.lineSegments.geometry.modelMatrixAttribute.array=this.lineSegments.matrixWorlds,this.lineSegments.geometry.modelMatrixAttribute.needsUpdate=!0,this.lineSegments.geometry.needsUpdate=!0):(this.lineSegments.geometry.modelMatrixAttribute=new THREE.InstancedBufferAttribute(this.lineSegments.matrixWorlds,16),this.lineSegments.geometry.modelMatrixAttribute.onUploadCallback=function(){this.array=null},this.lineSegments.geometry.setAttribute("modelMatrixAttrib",this.lineSegments.geometry.modelMatrixAttribute)),this.lineSegments.geometry.updateModelMatrix=!1}this.lineSegments.geometry.isInstancedBufferGeometry=!0,this.lineSegments.geometry.instanceCount=this.lineSegments.instancedCount,this.lineSegments.geometry.dirty=!1,null!=s.uniforms&&null!=s.uniforms.lineTypeId&&this.ndsModel.viewer.lineTypes&&(e.lineStyle=this.ndsModel.viewer.lineTypes.getLineStyleInfo(this.lineSegments.geometry,s.uniforms.lineTypeId.value,s.uniforms.lineScale.value,s.color||s.uniforms.diffuse.value,s.linewidthCopy||1,o.isSelected())),this.lineSegments.geometry.isPoints?(this.points.geometry=this.lineSegments.geometry,this.points.material=this.lineSegments.material,e.state=1,e.lineSegments=this.lineSegments,e.lineSegments2=this.lineSegmentToPoint2(this.point2,this.lineSegments.geometry,s,o.isSelected()),e.points=this.points):(e.state=1,e.lineSegments=this.lineSegments,e.lineSegments2=this.lineSegmentToLineSegment2(this.lineSegments2,this.lineSegments.geometry,s,o.isSelected()))}else this.lineSegments.matrixWorlds=null,e.state=2;return e}this.lineSegments.geometry.modelMatrixAttribute&&(this.lineSegments.geometry.modelMatrixAttribute.unUsed=!0)}}if(this.lineSegments.geometry.modelMatrixAttribute&&(this.lineSegments.geometry.deleteAttribute("modelMatrixAttrib"),delete this.lineSegments.geometry.modelMatrixAttribute),this.lineSegments.instancedCount=0,this.lineSegments.geometry.instanceCount=0,this.matrixes)for(f=0;f<16;++f)this.lineSegments.matrixWorld.elements[f]=this.matrixes[16*this.lineSegMatrixId[i]+f];else this.lineSegments.matrixWorld.copy(o.worldMatrix);m=this.ndsModel.getBodyTranslate(o);this.lineSegments.matrixWorld.elements[12]+=m[0],this.lineSegments.matrixWorld.elements[13]+=m[1],this.lineSegments.matrixWorld.elements[14]+=m[2],null!=s.uniforms&&null!=s.uniforms.lineTypeId&&this.ndsModel.viewer.lineTypes&&(e.lineStyle=this.ndsModel.viewer.lineTypes.getLineStyleInfo(this.lineSegments.geometry,s.uniforms.lineTypeId.value,s.uniforms.lineScale.value,s.color||s.uniforms.diffuse.value,s.linewidthCopy||1,o.isSelected()),o.isSelected(),e.lineStyle)&&e.lineStyle.textMesh&&e.lineStyle.textMesh.isShx&&(e.lineStyle.lineSegments2=this.lineSegmentToLineSegment2(this.lineSegments2_st,e.lineStyle.textMesh.geometry,e.lineStyle.textMesh.material,o.isSelected(),this.lineSegments.matrixWorld)),this.lineSegments.geometry.isPoints?(this.points.geometry=this.lineSegments.geometry,this.points.material=this.lineSegments.material,e.state=1,e.lineSegments=this.lineSegments,e.lineSegments2=this.lineSegmentToPoint2(this.point2,this.lineSegments.geometry,s,o.isSelected()),e.points=this.points):(e.state=1,e.lineSegments=this.lineSegments,e.lineSegments2=this.lineSegmentToLineSegment2(this.lineSegments2,this.lineSegments.geometry,s,o.isSelected(),this.lineSegments.matrixWorld)),!0===a&&o.hide()}}else e.state=-1;return e},lineSegmentToPoint2:function(e,t,n,i){if(!this.ndsModel.viewer.showLineWidth||!n.linewidthCopy||!this.ndsModel.viewer.is2DModel)return null;var r=null,o=null;if(this.lineSegToPoint2Map.has(t.uuid))r=this.lineSegToPoint2Map.get(t.uuid);else{r=new $e,this.lineSegToPoint2Map.set(t.uuid,r);for(var a,s=[],l=new THREE.Vector3,d=t.getAttribute("position"),c=t.drawRange.start;c<t.drawRange.start+t.drawRange.count;c+=1)a=t.index.getX(c),l.fromBufferAttribute(d,a),s.push(l.x,l.y,l.z);r.needsUpdate=!0,r.setPositions(s)}this.lineSegToPoint2MatMap.has(n.uuid)?o=this.lineSegToPoint2MatMap.get(n.uuid):(o=new nt({linewidth:n.linewidthCopy,opacity:n.opacity,worldUnits:!this.ndsModel.viewer.isModelSpace}),this.lineSegToPoint2MatMap.set(n.uuid,o));var h=this.ndsModel.viewer.renderer.getPixelRatio(),u=this.ndsModel.viewer.renderer.domElement.width/h,h=this.ndsModel.viewer.renderer.domElement.height/h;return o.resolution.set(u,h),o.color.set(i?_e.selectedColor:n.color||n.uniforms.diffuse.value),o.uniformsNeedUpdate=!0,e.geometry=r,e.material=o,e},lineSegmentToLineSegment2:function(e,t,n,i,r){if(this.ndsModel.viewer.is2DModel&&(this.ndsModel.viewer.showLineWidth&&n.linewidthCopy||999===n.linewidthCopy)){var o,a=null,s=null;if(this.lineSegToLineSeg2Map.has(t.uuid))a=this.lineSegToLineSeg2Map.get(t.uuid);else{a=new G,this.lineSegToLineSeg2Map.set(t.uuid,a);for(var l,d,c,h=[],u=[],p=[],f=0,m=new THREE.Vector3,g=new THREE.Vector3,v=t.getAttribute("position"),A=t.getAttribute("uv"),y=t.drawRange.start;y<t.drawRange.start+t.drawRange.count;y+=2)l=t.index.getX(y),d=t.index.getX(y+1),m.fromBufferAttribute(v,l),g.fromBufferAttribute(v,d),h.push(m.x,m.y,m.z,g.x,g.y,g.z),c&&c.equals(m)?(u.push(f),f+=m.distanceTo(g)):(u.push(0),f=m.distanceTo(g)),u.push(f),(c=c||new THREE.Vector3).copy(g),A&&(p.push(A.array[2*l]),p.push(A.array[2*l+1]));a.needsUpdate=!0,a.setPositions(h),a.setLineDistances(u),A&&a.setLineWidth(p)}this.lineSegToLineSeg2MatMap.has(n.uuid)?s=this.lineSegToLineSeg2MatMap.get(n.uuid):(s=new Q({linewidthScale:1,linewidth:n.linewidthCopy,opacity:n.opacity,worldUnits:999===n.linewidthCopy||!this.ndsModel.viewer.isModelSpace,mutiWidth:999===n.linewidthCopy}),null!=n.uniforms&&null!=n.uniforms.lineTypeId&&this.ndsModel.viewer.lineTypes&&(s.dashed=!0,s.lineScale=n.uniforms.lineScale.value,s.lineTypeId=n.uniforms.lineTypeId.value,s.uSampler=n.uniforms.uSampler.value,s.patternLength=n.uniforms.patternLength.value),this.lineSegToLineSeg2MatMap.set(n.uuid,s)),r&&999===n.linewidthCopy?(E=new THREE.Vector3,M=new THREE.Quaternion,o=new THREE.Vector3(1,1,1),r.decompose(E,M,o),s.linewidthScale=o.x,e.isWorldUnit=!0):(s.linewidthScale=1,e.isWorldUnit=!1);var r=this.ndsModel.viewer.renderer.getPixelRatio(),E=this.ndsModel.viewer.renderer.domElement.width/r,M=this.ndsModel.viewer.renderer.domElement.height/r;return s.resolution.set(E,M),s.color.set(i?_e.selectedColor:n.color||n.uniforms.diffuse.value),s.uniformsNeedUpdate=!0,e.geometry=a,e.material=s,e}return null},getLineSegments:function(e,t,n){e=this.getLineSegmentsWithState(e,t,n=void 0===n?!1:n);return 1===e.state?e.lineSegments:null},setNumTexts:function(e,t,n){void 0===n&&(n=!1),this.nTexts=e,this.textGeomId=new Int32Array(e),this.textMaterialId=new Int32Array(e),this.textBodyUuids=new Array(e),this.textBodyNodes=new Array(e),t&&(this.textObjectUuids=new Array(e)),n&&(this.textMatrixId=new Int32Array(e))},expandTexts:function(e,t,n){var i,r;return void 0===n&&(n=!1),0===this.nTexts?(this.setNumTexts(e,t,n),0):(i=this.nTexts,this.nTexts+=e,(r=new Array).extend(this.textGeomId),r.extend(new Array(e).fill(0)),this.textGeomId=new Int32Array(r),(r=new Array).extend(this.textMaterialId),r.extend(new Array(e).fill(0)),this.textMaterialId=new Int32Array(r),(r=new Array).extend(this.textBodyNodes),r.extend(new Array(e)),this.textBodyNodes=r,(r=new Array).extend(this.textBodyUuids),r.extend(new Array(e)),this.textBodyUuids=r,t&&((r=new Array).extend(this.textObjectUuids),r.extend(new Array(e)),this.textObjectUuids=r),n&&((t=new Array).extend(this.textMatrixId),t.extend(new Array(e)),this.textMatrixId=new Int32Array(t)),i)},setTextFromGeomUuid:function(e,t,n,i,r,o){this.textGeomUuid[e]=t,this.textBodyUuids[e]=n,this.textMaterialId[e]=i||-1,this.textObjectUuids&&(this.textObjectUuids[e]=r),this.textMatrixId&&(this.textMatrixId[e]=o)},getNumTexts:function(){return this.nTexts},intersectPolytope:function(e,t){if(this.geomId[e]<0)return null;var n=this.geomManager.getGeomFromId(this.geomId[e]);this.mats[this.materialId[e]];if(!n||!n.loaded||n.index&&null==n.index.array)return null;var i=this.bodyNodes[e];if(i.isHidden())return null;if(this.matrixId)for(var r=0;r<16;++r)this._matrix_copy_.elements[r]=this.matrixes[16*this.matrixId[e]+r];else this._matrix_copy_.copy(i.worldMatrix);var o=this._matrix_copy_,a=this.ndsModel.getBodyTranslate(i),a=(o.elements[12]+=a[0],o.elements[13]+=a[1],o.elements[14]+=a[2],new THREE.Matrix4),s=(a.getInverse(o),new THREE.Polytope),l=(s.copy(t).applyMatrix4(a),{}),d=(l.distance=1/0,l.point=new THREE.Vector3,l.face=new THREE.Face3,l.faceIndex=-1,l.meshId=-1,l.lineSegId=-1,n.index);if(!d)return null;for(var c=n.attributes.position,h=new THREE.Vector3,u=new THREE.Vector3,p=new THREE.Vector3,f=(new THREE.Vector3,new THREE.Face3),m=n.drawRange.start,g=n.drawRange.start+n.drawRange.count;m<g;m+=3){var v=d.getX(m),A=d.getX(m+1),y=d.getX(m+2);if(h.fromBufferAttribute(c,v),u.fromBufferAttribute(c,A),p.fromBufferAttribute(c,y),s.intersectsTriangle(p,u,h)){l.face.copy(f),l.faceIndex=m/3,l.meshId=e,l.lineSegId=-1,l.geomId=this.geomId[e],l.geomUuid=this.geomUuid[e],l.bodyNode=i,l.bodyUuid=i.uuid;break}}return-1===l.meshId?null:l},intersect:function(e,t,n){if(this.geomId[e]<0)return null;var i=this.geomManager.getGeomFromId(this.geomId[e]),r=this.mats[this.materialId[e]];if(!i||!i.loaded||i.index&&null==i.index.array)return null;var o=this.bodyNodes[e];if(o.isHidden())return null;if(this.matrixId)for(var a=0;a<16;++a)this._matrix_copy_.elements[a]=this.matrixes[16*this.matrixId[e]+a];else this._matrix_copy_.copy(o.worldMatrix);var s=this._matrix_copy_,l=this.ndsModel.getBodyTranslate(o),l=(s.elements[12]+=l[0],s.elements[13]+=l[1],s.elements[14]+=l[2],new THREE.Matrix4),d=(l.getInverse(s),new THREE.Ray),c=(d.copy(t).applyMatrix4(l),{}),h=(c.distance=1/0,c.point=new THREE.Vector3,c.face=new THREE.Face3,c.faceIndex=-1,c.meshId=-1,c.lineSegId=-1,i.index);if(!h)return null;for(var u=i.attributes.position,p=new THREE.Vector3,f=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,v=new THREE.Face3,A=i.drawRange.start,y=i.drawRange.start+i.drawRange.count;A<y;A+=3){var E=h.getX(A),M=h.getX(A+1),w=h.getX(A+2);if(p.fromBufferAttribute(u,E),f.fromBufferAttribute(u,M),m.fromBufferAttribute(u,w),null!==(r.side===THREE.BackSide?d.intersectTriangle(m,f,p,!0,g):d.intersectTriangle(p,f,m,r.side!==THREE.DoubleSide,g))){g.applyMatrix4(s),v.a=E,v.b=M,v.c=w,v.normal=THREE.Triangle.normal(p,f,m);E=this.ndsModel.viewer.clipPlaneManager.getClipPlaneInfor();if(E)for(var b=E.clipGlobalPlaneObjects,x=E.clippingPlanes,I=!1,T=0;T<b.length;T++){var S=b[T].position,B=x[T].normal.clone();if(g.clone().sub(S).dot(B)<0){I=!0;break}}M=this.ndsModel.viewer.clipBoxManager.getBoxClipInfo();if(!(I=!M.clipBoxActive||M.clipbox.containsPoint(g)?I:!0)){w=t.origin.distanceTo(g);if(w<c.distance&&(c.distance=w,c.point.copy(g),c.face.copy(v),c.faceIndex=A/3,c.meshId=e,c.lineSegId=-1,c.geomId=this.geomId[e],c.geomUuid=this.geomUuid[e],c.bodyNode=o,c.bodyUuid=o.uuid,n))break}}}return-1===c.meshId?null:c},intersectall:function(e,t){if(this.geomId[e]<0)return null;var n=this.geomManager.getGeomFromId(this.geomId[e]),i=this.mats[this.materialId[e]];if(!n||!n.loaded||n.index&&null==n.index.array)return null;var r=this.bodyNodes[e];if(r.isHidden())return null;if(this.matrixId)for(var o=0;o<16;++o)this._matrix_copy_.elements[o]=this.matrixes[16*this.matrixId[e]+o];else this._matrix_copy_.copy(r.worldMatrix);var a=this._matrix_copy_,s=this.ndsModel.getBodyTranslate(r),s=(a.elements[12]+=s[0],a.elements[13]+=s[1],a.elements[14]+=s[2],new THREE.Matrix4),l=(s.getInverse(a),new THREE.Ray),d=(l.copy(t).applyMatrix4(s),[]),c=n.index;if(!c)return null;for(var h=n.attributes.position,u=new THREE.Vector3,p=new THREE.Vector3,f=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Face3,v=n.drawRange.start,A=n.drawRange.start+n.drawRange.count;v<A;v+=3){var y=c.getX(v),E=c.getX(v+1),M=c.getX(v+2);if(u.fromBufferAttribute(h,y),p.fromBufferAttribute(h,E),f.fromBufferAttribute(h,M),null!==(i.side===THREE.BackSide?l.intersectTriangle(f,p,u,!0,m):l.intersectTriangle(u,p,f,i.side!==THREE.DoubleSide,m))){m.applyMatrix4(a),g.a=y,g.b=E,g.c=M,g.normal=THREE.Triangle.normal(u,p,f);y=this.ndsModel.viewer.clipPlaneManager.getClipPlaneInfor();if(y)for(var w=y.clipGlobalPlaneObjects,b=y.clippingPlanes,x=!1,I=0;I<w.length;I++){var T=w[I].position,S=b[I].normal.clone();if(m.clone().sub(T).dot(S)<0){x=!0;break}}E=this.ndsModel.viewer.clipBoxManager.getBoxClipInfo();(x=!E.clipBoxActive||E.clipbox.containsPoint(m)?x:!0)||(M=t.origin.distanceTo(m),(y={}).point=new THREE.Vector3,y.face=new THREE.Face3,y.distance=M,y.point.copy(m),y.face.copy(g),y.faceIndex=v/3,y.meshId=e,y.lineSegId=-1,y.geomId=this.geomId[e],y.geomUuid=this.geomUuid[e],y.bodyNode=r,y.bodyUuid=r.uuid,-1!=y.meshId&&d.push(y))}}return d},intersectLineSegments:function(e,t,F,n,i){if(this.lineSegGeomId[e]<0)return null;var r=this.geomManager.getGeomFromId(this.lineSegGeomId[e]);if(0===r.drawRange.count||!r.loaded||r.index&&null==r.index.array)return null;var o=this.lineSegBodyNodes[e];if(o.isHidden())return null;if(this.lineSegMatrixId)for(var a=0;a<16;++a)this._matrix_copy_.elements[a]=this.matrixes[16*this.lineSegMatrixId[e]+a];else this._matrix_copy_.copy(o.worldMatrix);var s=this._matrix_copy_,l=this.ndsModel.getBodyTranslate(o),d=(s.elements[12]+=l[0],s.elements[13]+=l[1],s.elements[14]+=l[2],r.boundingBox.clone());if(d.applyMatrix4(s),Math.abs(d.min.x-d.max.x)<n&&(d.min.x-=n/2,d.max.x+=n/2),Math.abs(d.min.y-d.max.y)<n&&(d.min.y-=n/2,d.max.y+=n/2),(!i||!(t.origin.x<d.min.x-n||t.origin.x>d.max.x+n||t.origin.y<d.min.y-n||t.origin.y>d.max.y+n))&&(i||!1!==t.intersectsBox(d))){var d=new THREE.Vector3,c=new THREE.Quaternion,l=(s.decompose(l,c,d),new THREE.Matrix4),h=(l.getInverse(s),new THREE.Ray),u=(h.copy(t).applyMatrix4(l),{}),c=(u.distance=F,u.point=new THREE.Vector3,u.face=null,u.faceIndex=-1,u.meshId=-1,u.lineSegId=-1,n/((d.x+d.y+d.z)/3)),p=c*c,f=new THREE.Vector3,m=new THREE.Vector3,g=r.index,v=r.attributes.position;if(!g)return null;new THREE.Vector3;var A,y=new THREE.Vector3,E=new THREE.Vector3,l=new THREE.Plane(new THREE.Vector3(0,0,-1),0),M=new THREE.Vector3,w=(h.intersectPlane(l,M),new THREE.Vector3),b=new THREE.Vector3;if(r.isPoints)for(var x=r.drawRange.start,I=r.drawRange.start+r.drawRange.count;x<I;x++){A=g.getX(x),w.fromBufferAttribute(v,A);var N=M.distanceToSquared(w);if(N<p)return u.distance=N,u.point.copy(w),u.point.applyMatrix4(s),u.index=x,u.face=null,u.faceIndex=-1,u.meshId=-1,u.lineSegId=e,u.geomId=this.lineSegGeomId[e],u.geomUuid=this.lineSegGeomUuid[e],u.bodyNode=o,u.bodyUuid=o.uuid,u.isPointsGeom=!0,u}for(x=r.drawRange.start,I=r.drawRange.start+r.drawRange.count;x<I;x+=2)if(A=g.getX(x),S=g.getX(x+1),w.fromBufferAttribute(v,A),b.fromBufferAttribute(v,S),i){var j=new THREE.Line3(w.clone(),b.clone()),T=(w.z=0,b.z=0,y.subVectors(M,w),E.subVectors(b,w),E.dot(y)/E.dot(E));if(!(T<0||1<T||isNaN(T))){var S=M.distanceToSquared(E.clone().multiplyScalar(T).add(w));if(!(p<S)){if(R=this.ndsModel.viewer.clipPlaneManager.getClipPlaneInfor())for(var B=R.clipGlobalPlaneObjects,_=R.clippingPlanes,P=!1,C=0;C<B.length;C++){D=B[C].position,H=_[C].normal.clone().normalize();if(j.at(T).clone().applyMatrix4(s).sub(D).dot(H)<0){P=!0;break}}O=this.ndsModel.viewer.clipBoxManager.getBoxClipInfo();if(!(P=!O.clipBoxActive||O.clipbox.containsPoint(M)?P:!0))return f=j.at(T),u.distance=h.origin.distanceTo(f),u.point.copy(f),u.point.applyMatrix4(s),u.index=x,u.face=null,u.faceIndex=-1,u.meshId=-1,u.lineSegId=e,u.geomId=this.lineSegGeomId[e],u.geomUuid=this.lineSegGeomUuid[e],u.bodyNode=o,u.bodyUuid=o.uuid,u}}}else{var R,O,S=h.distanceSqToSegment(w,b,m,f);if(!(p<S)){if(R=this.ndsModel.viewer.clipPlaneManager.getClipPlaneInfor())for(var B=R.clipGlobalPlaneObjects,_=R.clippingPlanes,P=!1,L=0;L<B.length;L++){var D=B[L].position,H=_[L].normal.clone().normalize();if(f.clone().applyMatrix4(s).sub(D).dot(H)<0){P=!0;break}}(P=!(O=this.ndsModel.viewer.clipBoxManager.getBoxClipInfo()).clipBoxActive||O.clipbox.containsPoint(M)?P:!0)||(m.applyMatrix4(s),(S=t.origin.distanceTo(m))<u.distance&&(u.distance=S,u.point.copy(f),u.point.applyMatrix4(s),u.index=x,u.face=null,u.faceIndex=-1,u.meshId=-1,u.lineSegId=e,u.geomId=this.lineSegGeomId[e],u.geomUuid=this.lineSegGeomUuid[e],u.bodyNode=o,u.bodyUuid=o.uuid))}}return-1===u.lineSegId?null:u}},setGeomSameMaterialFlag:function(e){if(e.leafBodyAttri){var t=e.leafBodyAttri.bodyMeshIds;if(t)for(var n=0,i=t.length;n<i;++n){var r=t[n];-1<this.geomId[r]&&1<(a=this.geomManager.getGeomFromId(this.geomId[r])).refMeshes.length&&(a.refMeshesSameMaterial=!1)}var o=e.leafBodyAttri.bodyLineSegIds;if(o)for(n=0,i=o.length;n<i;++n){var a,r=o[n];-1<this.geomId[r]&&1<(a=this.geomManager.getGeomFromId(this.geomId[r])).refLineSegs.length&&(a.refLineSegsSameMaterial=!1)}}},resetGeomSameMaterialFlags:function(){for(var e=0,t=this.geomManager.geoms.length;e<t;++e)this.geomManager.geoms[e].refMeshesSameMaterial=this.geomManager.geoms[e].refMeshesSameMaterialOriginal,this.geomManager.geoms[e].refLineSegsSameMaterial=this.geomManager.geoms[e].refLineSegsSameMaterialOriginal;for(e=0,t=this.ndsModel.wholeLeafBodyNodes.length;e<t;++e)if(this.ndsModel.wholeLeafBodyNodes[e].leafBodyAttri){var n=this.ndsModel.wholeLeafBodyNodes[e];if(n.isHidden()||n.isIsolated()||n.isDragged()||n.isSelected()||n.isTransparent()||n.getUserMaterial()||n.getUseBodyNodeMaterial()){var i=n.leafBodyAttri.bodyMeshIds;if(i)for(var r=0,o=i.length;r<o;++r){var a=i[r];-1<this.geomId[a]&&1<(d=this.geomManager.getGeomFromId(this.geomId[a])).refMeshes.length&&(d.refMeshesSameMaterial=!1)}var s=n.leafBodyAttri.bodyLineSegIds;if(s)for(var r=0,l=s.length;r<l;++r){var d,a=s[r];-1<this.geomId[a]&&1<(d=this.geomManager.getGeomFromId(this.geomId[a])).refLineSegs.length&&(d.refLineSegsSameMaterial=!1)}}}},isMeshSelected:function(e){return this.bodyNodes[e].isSelected()},isLineSegSelected:function(e){return this.lineSegBodyNodes[e].isSelected()},isTextSelected:function(e){return this.textBodyNodes[e].isSelected()},setSelectedMaterial:function(e,t){this.selectedMaterial=e,this.selectedLineSegMaterial=t},isMeshHidden:function(e){return this.bodyNodes[e].isHidden()},isLineHidden:function(e){return this.lineSegBodyNodes[e].isHidden()},isTextHidden:function(e){return this.textBodyNodes[e].isHidden()},RemoveElement:function(e,t){for(var n=1;-1<n;)-1<(n=e.indexOf(t))&&e.splice(n,1)},getNumBodyMeshs:function(e){return e.leafBodyAttri?e.leafBodyAttri.bodyMeshIds.length:0},getBodyMesh:function(e,t){e=e.leafBodyAttri.bodyMeshIds[t];return this.getSingleMesh(e)},getBodyMeshId:function(e,t){return e.leafBodyAttri.bodyMeshIds[t]},getBodyMeshIdFromGeomUUid:function(e,t){for(var n=0,i=e.leafBodyAttri.bodyMeshIds.length;n<i;++n){var r=e.leafBodyAttri.bodyMeshIds[n];if(this.geomUuid[r]==t)return r}return-1},getNumBodyLineSegments:function(e){return e.leafBodyAttri?e.leafBodyAttri.bodyLineSegIds.length:0},getBodyLineSegments:function(e,t){e=e.leafBodyAttri.bodyLineSegIds[t];return this.getLineSegments(e)},getBodyLineSegmentsFromGeomUUid:function(e,t){for(var n,i=[],r=new Set,o=0,a=(e=_e.HideLeafBody&&(n=e.parent.FirstVisibleNode||0,e.parent.children[n].uuid!=e.uuid)?e.parent.children[n]:e).leafBodyAttri.bodyLineSegIds.length;o<a;++o){var s,l=e.leafBodyAttri.bodyLineSegIds[o];this.lineSegGeomUuid[l]!=t||r.has(l)||(s=this.getLineSegments(l),r.add(l),s&&(i[i.length]=s.clone()))}return 1===i.length?i[0]:1<i.length?i:null},getBodyNode:function(e){return this.bodyNodes[e]}},function(e,t){this.sptIndex=e,this.node=t,this.loaded=!1,this.sorted=!1,this.renderOnce=!1,this.geoms=[],this.requireReload=!1,this.dirty=!0,this.visible=!0,this.bufferId=0}),ft=(pt.prototype={constructor:pt,isLoaded:function(){if(this.loaded)return!0;for(var e=this.sptIndex.getNumMeshes(this.node),t=[],n=0;n<e;++n){var i=this.sptIndex.getMeshId(this.node,n),r=this.sptIndex.meshManager.geomId[i];if(!(r<0)){if(!(a=this.sptIndex.meshManager.geomManager.getGeomFromId(r))||!a.loaded)return!1;1===a.refMeshes.length&&t.push(a)}}this.geoms=t;for(var o=this.sptIndex.meshManager.geomManager,n=0;n<e;++n){var a,i=this.sptIndex.getMeshId(this.node,n);(r=this.sptIndex.meshManager.geomId[i])<0||null==(a=o.getGeomFromId(r)).index||(this.bufferId||(this.bufferId=a.id),o.loadedVertexAttributes.has(a.index.uuid)||(o.usedMemory+=a.index.array.byteLength,o.usedGpuMemory+=a.index.array.byteLength,o.loadedVertexAttributes.add(a.index.uuid)),o.loadedVertexAttributes.has(a.attributes.position.uuid))||(o.usedMemory+=(a.attributes.position.array?a.attributes.position:a.attributes.position.data).array.byteLength,o.usedGpuMemory+=(a.attributes.position.array?a.attributes.position:a.attributes.position.data).array.byteLength,o.loadedVertexAttributes.add(a.attributes.position.uuid))}return this.loaded=!0},sortMeshes:function(e){for(var t=[],n=this.sptIndex.getNumMeshes(this.node),i=0;i<n;++i){var r=this.sptIndex.getMeshId(this.node,i),o=new THREE.Vector3,a=(o.z=0,this.sptIndex.meshManager.materialId[r]),s=this.sptIndex.meshManager.mats[a],s=s.program?s.program.id:1e4;t.push(new L(r,a,s,o.z))}t.sort(D);for(var l=this.sptIndex.getNode(this.node),i=0;i<n;++i)l.meshes[i]=t[i].meshId;this.sorted=!0},isAllMeshHidden:function(){this.visible=!0;for(var e=this.sptIndex.getNumMeshes(this.node),t=0;t<e;++t){var n=this.sptIndex.getMeshId(this.node,t);if(!this.sptIndex.meshManager.isMeshHidden(n))return!1}for(var i=this.sptIndex.getNumLineSegments(this.node),t=0;t<i;++t){var r=this.sptIndex.getLineSegmentsId(this.node,t);if(!this.sptIndex.meshManager.isLineHidden(r))return!1}var o=this.sptIndex.getNumTexts(this.node);for(t=0;t<o;++t){var a=this.sptIndex.getTextId(this.node,t);if(!this.sptIndex.meshManager.isTextHidden(a))return!1}return!(this.visible=!1)},isVisible:function(e,t){var n,i=new THREE.Box3;if(this.sptIndex.getNodeBox(this.node,i),0<t.length&&((n=new THREE.Matrix4).fromArray(t),i.applyMatrix4(n)),0<this.sptIndex.meshManager.ndsModel.explodeFactor||this.sptIndex.meshManager.ndsModel.hasDraggedBodies()||_e.ScenarioEditor){for(var r=this.sptIndex.getNumMeshes(this.node),o=[0,0,0],a=[0,0,0],s=[0,0,0],l=0;l<r;++l){var d,c,h=this.sptIndex.getMeshId(this.node,l),h=this.sptIndex.meshManager.bodyNodes[h],u=this.sptIndex.meshManager.ndsModel.getBodyTranslate(h);if(h.originalPosition&&(d=new THREE.Vector3,c=h.getModel().getBodyBoundingBox(h),d.copy(c.getCenter(new THREE.Vector3)),d.sub(h.originalPosition),u[0]=d.x,u[1]=d.y,u[2]=d.z),0===l){for(var p=0;p<3;++p)o[p]=u[p],a[p]=u[p];h.getModel().rootBodyNode.delta&&(s[0]=h.getModel().rootBodyNode.delta.x,s[1]=h.getModel().rootBodyNode.delta.y,s[2]=h.getModel().rootBodyNode.delta.z)}else for(p=0;p<3;++p)u[p]<o[p]?o[p]=u[p]:u[p]>a[p]&&(a[p]=u[p])}i.min.x+=o[0],i.min.y+=o[1],i.min.z+=o[2],i.max.x+=a[0],i.max.y+=a[1],i.max.z+=a[2],i.min.x+=s[0],i.min.y+=s[1],i.min.z+=s[2],i.max.x+=s[0],i.max.y+=s[1],i.max.z+=s[2]}if(this.visible=e.intersectsBox(i),!this.visible&&(_e.AnimationEdit||_e.ScenarioEditor))for(var f=this.sptIndex.getNumMeshes(this.node),m=new THREE.Box3,g=0;g<f;++g){var v=this.sptIndex.getMeshId(this.node,g),v=this.sptIndex.meshManager.bodyNodes[v];if(v.leafBodyAttri&&v.leafBodyAttri.bodyBbox)if(m.setFromArray(v.leafBodyAttri.bodyBbox),e.intersectsBox(m)){this.visible=!0;break}}return 0==this.visible&&(this.dirty=!1),this.visible},removeGeometry:function(e){var t;0!==this.geoms.length&&this.geoms[0].index&&this.geoms[0].index.array&&(t=this.geoms[0],0===e&&!t.useSharedGlBuffer&&t.index.indexBuffer?this.sptIndex.meshManager.geomManager.unloadGeometry(t):0<e&&t.useSharedGlBuffer&&(this.requireReload=!0,this.sptIndex.meshManager.geomManager.unloadGeometry(t)))},reloadGeometry:function(){0===this.geoms.length||(this.requireReload=!1,this.renderOnce=!1,this.geoms[0].index.array)||this.sptIndex.meshManager.geomManager.reloadGeometry(this.geoms[0])},isReloadingGeometry:function(){return!(!(0<this.geoms.length&&this.geoms[0].useSharedGlBuffer)||this.geoms[0].index.array)},getNumMeshes:function(){return this.sptIndex.getNumMeshes(this.node)},getMesh:function(e){return this.sptIndex.getMesh(this.node,e)},getMeshId:function(e){return this.sptIndex.getMeshId(this.node,e)},includeTexts:function(){return!!this.sptIndex.texts},getNumTexts:function(){return this.sptIndex.getNumTexts(this.node)},getTextId:function(){return this.sptIndex.getTextId(this.node)},getText:function(e){return this.sptIndex.getText(this.node,e)},includeLineSegments:function(){return!!this.sptIndex.lines},getNumLineSegments:function(){return this.sptIndex.getNumLineSegments(this.node)},getLineSegmentsWithState:function(e,t,n){return this.sptIndex.getLineSegmentsWithState(this.node,e,t=void 0===t?!1:t,n=void 0===n?!1:n)},getLineSegments:function(e,t,n){e=this.sptIndex.getLineSegmentsWithState(this.node,e,t=void 0===t?!1:t,n=void 0===n?!1:n);return 1===e.state?e.lineSegments:null},intersect:function(e,t){for(var n=this.sptIndex.getNumMeshes(this.node),i=new THREE.Box3,r=0;r<n;++r){var o=this.sptIndex.getMeshId(this.node,r),a=this.sptIndex.meshManager.bodyNodes[o];this.sptIndex.meshManager.ndsModel.hasHiddenBodies&&a.isHidden()||(this.sptIndex.meshManager.getMeshBBox(o,i),e.intersectsBox(i)&&t.push(o))}}},at.CurrentNodeId=0,function(){function e(e,t){this.isSpatialIndex=!0,this.nodeId2NodeMap=[],this.root=new at,e&&e.isModelBvh&&(this.meshManager=e.meshManager||t,this.buildFromModelBvh(e)),!this.meshManager&&t&&(this.meshManager=t)}var t=e.prototype;return t.mergeSubTree=function(e,t){if(!e){if(t.isModelBvh)return this.buildFromModelBvh(t);if(t.isSpatialIndex)return this.nodeId2NodeMap=t.nodeId2NodeMap,this.root=t.root,this.meshManager=t.meshManager||this.meshManager,this.root}return e.addSubTree(t)},t.buildFromModelBvh=function(e){return 0<e.nNodes&&this.initNodeByModelBvhNode(this.root,e,0),e&&0<e.leftChild.length&&-1!==e.leftChild[0]&&(this.buildSubTreeFromModelBvh(this.root,e,e.leftChild[0]),this.buildSubTreeFromModelBvh(this.root,e,e.leftChild[0]+1)),this.root},t.initNodeByModelBvhNode=function(e,t,n){if(!(t.nNodes<=n))if(e.boundingBox.min.set(t.bboxes[6*n+0],t.bboxes[6*n+1],t.bboxes[6*n+2]),e.boundingBox.max.set(t.bboxes[6*n+3],t.bboxes[6*n+4],t.bboxes[6*n+5]),4===t.version){e.meshes=new Uint32Array(t.nMeshes[n]);for(var i=0,r=e.meshes.length;i<r;++i)e.meshes[i]=t.getMeshId(n,i);var o=t.nLines[n];if(o){e.lines=new Uint32Array(o);for(var a=0;a<o;++a)e.lines[a]=t.getLineSegmentsId(n,a)}var s=t.nTexts[n];if(s){e.texts=new Uint32Array(s);for(var l=0;l<s;++l)e.texts[l]=t.getTextId(n,l)}}else if(0<t.leftChild.length&&-1!==t.leftChild[n])e.meshes=[];else{e.meshes=new Uint32Array(t.nMeshes[n]);for(var d=0,c=e.meshes.length;d<c;++d)e.meshes[d]=t.getMeshId(n,d)}},t.buildSubTreeFromModelBvh=function(e,t,n){var i=new at;i.parent=e,this.initNodeByModelBvhNode(i,t,n),e.children.push(i),0<t.leftChild.length&&-1!==t.leftChild[n]&&(this.buildSubTreeFromModelBvh(i,t,t.leftChild[n]),this.buildSubTreeFromModelBvh(i,t,t.leftChild[n]+1))},t.buildMeshSets=function(){var r=this,o=0,a=[];return this.nodeId2MeshSetIdMap=[],this.nodeId2NodeMap=[],function e(t){t.id=o++,(r.nodeId2NodeMap[t.id]=t).meshes&&0<t.meshes.length||t.lines&&0<t.lines.length||t.texts&&0<t.texts.length?(a.push(new pt(r,t.id)),t.meshSetId=a.length-1,r.nodeId2MeshSetIdMap[t.id]=t.meshSetId):r.nodeId2MeshSetIdMap[t.id]=-1;for(var n=0,i=t.children.length;n<i;++n)e(t.children[n])}(this.root),a},t.getNode=function(e){return this.nodeId2NodeMap[e]},t.getNodeBox=function(e,t){t=t||new THREE.Box3,e=this.nodeId2NodeMap[e];return e&&t.copy(e.boundingBox),t},t.getNumMeshes=function(e){e=this.nodeId2NodeMap[e];return e&&e.meshes?e.meshes.length:0},t.getMesh=function(e,t){var e=this.nodeId2NodeMap[e];return e&&e.meshes&&t<e.meshes.length?(e=e.meshes[t],this.meshManager.getMesh(e)):null},t.getMeshId=function(e,t){e=this.nodeId2NodeMap[e];return e&&e.meshes&&t<e.meshes.length?e.meshes[t]:-1},t.getNumTexts=function(e){e=this.nodeId2NodeMap[e];return e&&e.texts?e.texts.length:-1},t.getTextId=function(e,t){e=this.nodeId2NodeMap[e];return e?e.texts[t]:-1},t.getText=function(e,t){var e=this.nodeId2NodeMap[e];return e&&e.texts&&t<e.texts.length?(e=e.texts[t],this.meshManager.getText(e)):null},t.getNumLineSegments=function(e){e=this.nodeId2NodeMap[e];return e&&e.lines?e.lines.length:-1},t.getLineSegmentsId=function(e,t){e=this.nodeId2NodeMap[e];return e&&e.lines&&t<e.lines.length?e.lines[t]:-1},t.getLineSegmentsWithState=function(e,t,n,i){var e=this.nodeId2NodeMap[e];return e&&e.lines&&t<e.lines.length?(e=e.lines[t],this.meshManager.getLineSegmentsWithState(e,n,i)):{state:-1,lineSegments:null}},t.getLineSegments=function(e,t,n,i){e=this.getLineSegmentsWithState(e,t,n,i);return 1===e.state?e.lineSegments:null},t.intersect=function(e){var t=[];if(this.meshManager.ndsModel.hasDraggedBodies()||0<this.meshManager.ndsModel.explodeFactor||0<this.meshManager.ndsModel.explodeFactorX||0<this.meshManager.ndsModel.explodeFactorY||0<this.meshManager.ndsModel.explodeFactorZ||NDSWebViewer.SETTING.inBIMContext||"posy"!=_e.modelUpDirection||_e.ScenarioEditor||_e.AnimationEdit)for(var n=0,i=this.nodeId2MeshSetIdMap.length;n<i;++n)0<=this.nodeId2MeshSetIdMap[n]&&(t[t.length]=this.nodeId2MeshSetIdMap[n]);else this.root.queryByRayCast(e,t);return t},e}()),mt=function(l,e,t,n,i){THREE.Geometry.call(this),this.uvs=[];var r=t.length(),o=n.length(),t=t.clone(),n=(t.normalize(),n.clone()),a=(n.normalize(),new THREE.Vector3);if(a.crossVectors(t,n),l.hasOwnProperty("geometry")){for(var s=new THREE.Box3,d=(s.setFromObject(l),new Array),c=s.min.clone(),s=(d.push(c),s.max.clone()),h=(d.push(s),new THREE.Vector3),h=(h.set(s.x,c.y,c.z),d.push(h),new THREE.Vector3),h=(h.set(s.x,s.y,c.z),d.push(h),new THREE.Vector3),h=(h.set(c.x,s.y,c.z),d.push(h),new THREE.Vector3),h=(h.set(c.x,c.y,s.z),d.push(h),new THREE.Vector3),h=(h.set(s.x,c.y,s.z),d.push(h),new THREE.Vector3),u=(h.set(c.x,s.y,s.z),d.push(h),1e8),p=-1e8,f=0;f<d.length;f++){var m=new THREE.Vector3,m=(m.subVectors(d[f],e),m.dot(a));m<u&&(u=m),p<m&&(p=m)}c=e.clone(),s=(c.addScaledVector(a,p),e.clone()),h=(s.addScaledVector(a,u),p-u),r=(null!=i&&"ProjBoth"==i&&(h*=2.1),this.dimensions=new THREE.Vector3(r,o,h),this.cube=new THREE.Mesh(new THREE.BoxGeometry(r,o,h),new THREE.MeshBasicMaterial),new THREE.Matrix4);r.makeBasis(t,n,a),null!=i&&"ProjBackward"==i?r.setPosition(s):r.setPosition(c),this.cube.applyMatrix(r),this.iCubeMatrix=(new THREE.Matrix4).getInverse(this.cube.matrix),this.faceIndices=["a","b","c","d"],this.clipFace=function(e,t){var r=.5*Math.abs(this.dimensions.clone().dot(t));function n(e,t,n){var i=e.vertex.dot(n)-r,i=i/(i-(t.vertex.dot(n)-r));return new THREE.DecalVertex(new THREE.Vector3(e.vertex.x+i*(t.vertex.x-e.vertex.x),e.vertex.y+i*(t.vertex.y-e.vertex.y),e.vertex.z+i*(t.vertex.z-e.vertex.z)),new THREE.Vector3(e.normal.x+i*(t.normal.x-e.normal.x),e.normal.y+i*(t.normal.y-e.normal.y),e.normal.z+i*(t.normal.z-e.normal.z)))}if(0===e.length)return[];for(var i=[],o=0;o<e.length;o+=3){var a,s,l,d=0<e[o+0].vertex.dot(t)-r,c=0<e[o+1].vertex.dot(t)-r,h=0<e[o+2].vertex.dot(t)-r;switch((d?1:0)+(c?1:0)+(h?1:0)){case 0:i.push(e[o]),i.push(e[o+1]),i.push(e[o+2]);break;case 1:(d&&(a=e[o+1],s=e[o+2],l=n(e[o],a,t),nV4=n(e[o],s,t)),c)?(a=e[o],s=e[o+2],l=n(e[o+1],a,t),nV4=n(e[o+1],s,t),i.push(l),i.push(s.clone()),i.push(a.clone()),i.push(s.clone()),i.push(l.clone()),i.push(nV4)):(h&&(a=e[o],s=e[o+1],l=n(e[o+2],a,t),nV4=n(e[o+2],s,t)),i.push(a.clone()),i.push(s.clone()),i.push(l),i.push(nV4),i.push(l.clone()),i.push(s.clone()));break;case 2:d||(s=n(a=e[o].clone(),e[o+1],t),l=n(a,e[o+2],t),i.push(a),i.push(s),i.push(l)),c||(s=n(a=e[o+1].clone(),e[o+2],t),l=n(a,e[o],t),i.push(a),i.push(s),i.push(l)),h||(s=n(a=e[o+2].clone(),e[o],t),l=n(a,e[o+1],t),i.push(a),i.push(s),i.push(l))}}return i},this.pushVertex=function(e,t,n){t=l.geometry.vertices[t].clone();t.applyMatrix4(l.matrixWorld),t.applyMatrix4(this.iCubeMatrix),e.push(new THREE.DecalVertex(t,n.clone()))},this.pushVertexBufferGeometry=function(e,t){var n=l.geometry.attributes.position.array,i=l.geometry.attributes.normal.array,r=new THREE.Vector3,o=new THREE.Vector3;r.fromArray(n,3*t),o.fromArray(i,3*t),r.applyMatrix4(l.matrixWorld),r.applyMatrix4(this.iCubeMatrix),e.push(new THREE.DecalVertex(r,o))},this.computeDecal=function(){var e=[];if(l.geometry instanceof THREE.Geometry)for(var t=0;t<l.geometry.faces.length;t++){var n=l.geometry.faces[t],i=[];this.pushVertex(i,n[this.faceIndices[0]],n.vertexNormals[0]),this.pushVertex(i,n[this.faceIndices[1]],n.vertexNormals[1]),this.pushVertex(i,n[this.faceIndices[2]],n.vertexNormals[2]),i=this.clipFace(i,new THREE.Vector3(1,0,0)),i=this.clipFace(i,new THREE.Vector3(-1,0,0)),i=this.clipFace(i,new THREE.Vector3(0,1,0)),i=this.clipFace(i,new THREE.Vector3(0,-1,0)),i=this.clipFace(i,new THREE.Vector3(0,0,1)),i=this.clipFace(i,new THREE.Vector3(0,0,-1));for(var r=0;r<i.length;r++){var o=i[r];this.uvs.push(new THREE.Vector2(.5+o.vertex.x/this.dimensions.x,.5+o.vertex.y/this.dimensions.y)),i[r].vertex.applyMatrix4(this.cube.matrix)}0!==i.length&&(e=e.concat(i))}else if(l.geometry instanceof THREE.BufferGeometry)for(var a=l.geometry.index.array,t=0;t<a.length/3;t++){i=[];this.pushVertexBufferGeometry(i,a[3*t]),this.pushVertexBufferGeometry(i,a[3*t+1]),this.pushVertexBufferGeometry(i,a[3*t+2]),i=this.clipFace(i,new THREE.Vector3(1,0,0)),i=this.clipFace(i,new THREE.Vector3(-1,0,0)),i=this.clipFace(i,new THREE.Vector3(0,1,0)),i=this.clipFace(i,new THREE.Vector3(0,-1,0)),i=this.clipFace(i,new THREE.Vector3(0,0,1)),i=this.clipFace(i,new THREE.Vector3(0,0,-1));for(r=0;r<i.length;r++){o=i[r];this.uvs.push(new THREE.Vector2(.5+o.vertex.x/this.dimensions.x,.5+o.vertex.y/this.dimensions.y)),i[r].vertex.applyMatrix4(this.cube.matrix)}0!==i.length&&(e=e.concat(i))}for(var s=0;s<e.length;s+=3)this.vertices.push(e[s].vertex,e[s+1].vertex,e[s+2].vertex),(n=new THREE.Face3(s,s+1,s+2)).vertexNormals.push(e[s+0].normal),n.vertexNormals.push(e[s+1].normal),n.vertexNormals.push(e[s+2].normal),this.faces.push(n),this.faceVertexUvs[0].push([this.uvs[s],this.uvs[s+1],this.uvs[s+2]]);this.verticesNeedUpdate=!0,this.elementsNeedUpdate=!0,this.morphTargetsNeedUpdate=!0,this.uvsNeedUpdate=!0,this.normalsNeedUpdate=!0,this.colorsNeedUpdate=!0,this.computeFaceNormals()},this.computeDecal()}},Ve=(mt.prototype=Object.create(THREE.Geometry.prototype),mt.prototype.constructor=mt,Ve||{}),M=(Ve.CompressionMethod={RAW:5718354,MG1:3229517,MG2:3295053},Ve.Flags={NORMALS:1},Ve.File=function(e){this.load(e)},Ve.File.prototype.load=function(e){this.header=new Ve.FileHeader(e),this.body=new Ve.FileBody(this.header),this.getReader().read(e,this.body)},Ve.File.prototype.getReader=function(){var e;switch(this.header.compressionMethod){case Ve.CompressionMethod.RAW:e=new Ve.ReaderRAW;break;case Ve.CompressionMethod.MG1:e=new Ve.ReaderMG1;break;case Ve.CompressionMethod.MG2:e=new Ve.ReaderMG2}return e},Ve.FileHeader=function(e){e.readInt32(),this.fileFormat=e.readInt32(),this.compressionMethod=e.readInt32(),this.vertexCount=e.readInt32(),this.triangleCount=e.readInt32(),this.uvMapCount=e.readInt32(),this.attrMapCount=e.readInt32(),this.flags=e.readInt32(),this.comment=e.readString()},Ve.FileHeader.prototype.hasNormals=function(){return this.flags&Ve.Flags.NORMALS},Ve.FileBody=function(e){var t=3*e.triangleCount,n=3*e.vertexCount,i=e.hasNormals()?3*e.vertexCount:0,r=2*e.vertexCount,o=4*e.vertexCount,a=0,s=new ArrayBuffer(4*(t+n+i+r*e.uvMapCount+o*e.attrMapCount));if(this.indices=new Uint32Array(s,0,t),this.vertices=new Float32Array(s,4*t,n),e.hasNormals()&&(this.normals=new Float32Array(s,4*(t+n),i)),e.uvMapCount)for(this.uvMaps=[],a=0;a<e.uvMapCount;++a)this.uvMaps[a]={uv:new Float32Array(s,4*(t+n+i+a*r),r)};if(e.attrMapCount)for(this.attrMaps=[],a=0;a<e.attrMapCount;++a)this.attrMaps[a]={attr:new Float32Array(s,4*(t+n+i+r*e.uvMapCount+a*o),o)}},Ve.FileMG2Header=function(e){e.readInt32(),this.vertexPrecision=e.readFloat32(),this.normalPrecision=e.readFloat32(),this.lowerBoundx=e.readFloat32(),this.lowerBoundy=e.readFloat32(),this.lowerBoundz=e.readFloat32(),this.higherBoundx=e.readFloat32(),this.higherBoundy=e.readFloat32(),this.higherBoundz=e.readFloat32(),this.divx=e.readInt32(),this.divy=e.readInt32(),this.divz=e.readInt32(),this.sizex=(this.higherBoundx-this.lowerBoundx)/this.divx,this.sizey=(this.higherBoundy-this.lowerBoundy)/this.divy,this.sizez=(this.higherBoundz-this.lowerBoundz)/this.divz},Ve.ReaderRAW=function(){},Ve.ReaderRAW.prototype.read=function(e,t){this.readIndices(e,t.indices),this.readVertices(e,t.vertices),t.normals&&this.readNormals(e,t.normals),t.uvMaps&&this.readUVMaps(e,t.uvMaps),t.attrMaps&&this.readAttrMaps(e,t.attrMaps)},Ve.ReaderRAW.prototype.readIndices=function(e,t){e.readInt32(),e.readArrayInt32(t)},Ve.ReaderRAW.prototype.readVertices=function(e,t){e.readInt32(),e.readArrayFloat32(t)},Ve.ReaderRAW.prototype.readNormals=function(e,t){e.readInt32(),e.readArrayFloat32(t)},Ve.ReaderRAW.prototype.readUVMaps=function(e,t){for(var n=0;n<t.length;++n)e.readInt32(),t[n].name=e.readString(),t[n].filename=e.readString(),e.readArrayFloat32(t[n].uv)},Ve.ReaderRAW.prototype.readAttrMaps=function(e,t){for(var n=0;n<t.length;++n)e.readInt32(),t[n].name=e.readString(),e.readArrayFloat32(t[n].attr)},Ve.ReaderMG1=function(){},Ve.ReaderMG1.prototype.read=function(e,t){this.readIndices(e,t.indices),this.readVertices(e,t.vertices),t.normals&&this.readNormals(e,t.normals),t.uvMaps&&this.readUVMaps(e,t.uvMaps),t.attrMaps&&this.readAttrMaps(e,t.attrMaps)},Ve.ReaderMG1.prototype.readIndices=function(e,t){e.readInt32(),e.readInt32();var n=new Ve.InterleavedStream(t,3);LZMA.decompress(e,e,n,n.data.length),Ve.restoreIndices(t,t.length)},Ve.ReaderMG1.prototype.readVertices=function(e,t){e.readInt32(),e.readInt32();t=new Ve.InterleavedStream(t,1);LZMA.decompress(e,e,t,t.data.length)},Ve.ReaderMG1.prototype.readNormals=function(e,t){e.readInt32(),e.readInt32();t=new Ve.InterleavedStream(t,3);LZMA.decompress(e,e,t,t.data.length)},Ve.ReaderMG1.prototype.readUVMaps=function(e,t){for(var n=0;n<t.length;++n){e.readInt32(),t[n].name=e.readString(),t[n].filename=e.readString(),e.readInt32();var i=new Ve.InterleavedStream(t[n].uv,2);LZMA.decompress(e,e,i,i.data.length)}},Ve.ReaderMG1.prototype.readAttrMaps=function(e,t){for(var n=0;n<t.length;++n){e.readInt32(),t[n].name=e.readString(),e.readInt32();var i=new Ve.InterleavedStream(t[n].attr,4);LZMA.decompress(e,e,i,i.data.length)}},Ve.ReaderMG2=function(){},Ve.ReaderMG2.prototype.read=function(e,t){this.MG2Header=new Ve.FileMG2Header(e),this.readVertices(e,t.vertices),this.readIndices(e,t.indices),t.normals&&this.readNormals(e,t),t.uvMaps&&this.readUVMaps(e,t.uvMaps),t.attrMaps&&this.readAttrMaps(e,t.attrMaps)},Ve.ReaderMG2.prototype.readVertices=function(e,t){e.readInt32(),e.readInt32();var n=new Ve.InterleavedStream(t,3),n=(LZMA.decompress(e,e,n,n.data.length),this.readGridIndices(e,t));Ve.restoreVertices(t,this.MG2Header,n,this.MG2Header.vertexPrecision)},Ve.ReaderMG2.prototype.readGridIndices=function(e,t){e.readInt32(),e.readInt32();var t=new Uint32Array(t.length/3),n=new Ve.InterleavedStream(t,1);return LZMA.decompress(e,e,n,n.data.length),Ve.restoreGridIndices(t,t.length),t},Ve.ReaderMG2.prototype.readIndices=function(e,t){e.readInt32(),e.readInt32();var n=new Ve.InterleavedStream(t,3);LZMA.decompress(e,e,n,n.data.length),Ve.restoreIndices(t,t.length)},Ve.ReaderMG2.prototype.readNormals=function(e,t){e.readInt32(),e.readInt32();var n=new Ve.InterleavedStream(t.normals,3),e=(LZMA.decompress(e,e,n,n.data.length),Ve.calcSmoothNormals(t.indices,t.vertices));Ve.restoreNormals(t.normals,e,this.MG2Header.normalPrecision)},Ve.ReaderMG2.prototype.readUVMaps=function(e,t){for(var n=0;n<t.length;++n){e.readInt32(),t[n].name=e.readString(),t[n].filename=e.readString();var i=e.readFloat32(),r=(e.readInt32(),new Ve.InterleavedStream(t[n].uv,2));LZMA.decompress(e,e,r,r.data.length),Ve.restoreMap(t[n].uv,2,i)}},Ve.ReaderMG2.prototype.readAttrMaps=function(e,t){for(var n=0;n<t.length;++n){e.readInt32(),t[n].name=e.readString();var i=e.readFloat32(),r=(e.readInt32(),new Ve.InterleavedStream(t[n].attr,4));LZMA.decompress(e,e,r,r.data.length),Ve.restoreMap(t[n].attr,4,i)}},Ve.restoreIndices=function(e,t){var n=3;for(0<t&&(e[2]+=e[0],e[1]+=e[0]);n<t;n+=3)e[n]+=e[n-3],e[n]===e[n-3]?e[n+1]+=e[n-2]:e[n+1]+=e[n],e[n+2]+=e[n]},Ve.restoreIndices2=function(e,t,n){var i=3;for(0<n&&(e[t+2]+=e[t+0],e[t+1]+=e[t+0]);i<n;i+=3)e[t+i]+=e[t+i-3],e[t+i]===e[t+i-3]?e[t+i+1]+=e[t+i-2]:e[t+i+1]+=e[t+i],e[t+i+2]+=e[t+i]},Ve.restoreGridIndices=function(e,t){for(var n=1;n<t;++n)e[n]+=e[n-1]},Ve.restoreVertices=function(e,t,n,i){for(var r,o,a,s,l,d=new Uint32Array(e.buffer,e.byteOffset,e.length),c=t.divx,h=c*t.divy,u=2147483647,p=0,f=0,m=0,g=n.length;f<g;m+=3)a=r=n[f++],a=(a-=~~((l=~~(a/h))*h))-~~((s=~~(a/c))*c),o=d[m],r===u&&(o+=p),e[m]=t.lowerBoundx+a*t.sizex+i*o,e[m+1]=t.lowerBoundy+s*t.sizey+i*d[m+1],e[m+2]=t.lowerBoundz+l*t.sizez+i*d[m+2],u=r,p=o},Ve.restoreNormals=function(e,t,n){for(var i,r,o,a,s,l,d=new Uint32Array(e.buffer,e.byteOffset,e.length),c=0,h=e.length,u=1.5707963267948966;c<h;c+=3)s=d[c]*n,0===(a=d[c+1])?(e[c]=t[c]*s,e[c+1]=t[c+1]*s,e[c+2]=t[c+2]*s):(o=a<=4?(d[c+2]-2)*u:(4*d[c+2]/a-2)*u,a*=n*u,i=(r=s*Math.sin(a))*Math.cos(o),r=r*Math.sin(o),o=s*Math.cos(a),s=t[c+1],a=t[c]-t[c+2],1e-20<(l=Math.sqrt(2*s*s+a*a))&&(a/=l,s/=l),e[c]=t[c]*o+(t[c+1]*s-t[c+2]*a)*r-s*i,e[c+1]=t[c+1]*o-(t[c+2]+t[c])*s*r+a*i,e[c+2]=t[c+2]*o+(t[c]*a+t[c+1]*s)*r+s*i)},Ve.restoreMap=function(e,t,n){for(var i,r,o,a=new Uint32Array(e.buffer,e.byteOffset,e.length),s=0,l=e.length;s<t;++s)for(i=0,o=s;o<l;o+=t)i+=1&(r=a[o])?-(r+1>>1):r>>1,e[o]=i*n},Ve.calcSmoothNormals=function(e,t){for(var n,i,r,o,a,s,l,d,c,h,u,p=new Float32Array(t.length),f=0,m=e.length;f<m;)n=3*e[f++],i=3*e[f++],r=3*e[f++],a=t[i]-t[n],d=t[r]-t[n],s=t[1+i]-t[1+n],c=t[1+r]-t[1+n],l=t[2+i]-t[2+n],o=s*(h=t[2+r]-t[2+n])-l*c,l=l*d-a*h,h=a*c-s*d,1e-10<(u=Math.sqrt(o*o+l*l+h*h))&&(o/=u,l/=u,h/=u),p[n]+=o,p[1+n]+=l,p[2+n]+=h,p[i]+=o,p[1+i]+=l,p[2+i]+=h,p[r]+=o,p[1+r]+=l,p[2+r]+=h;for(f=0,m=p.length;f<m;f+=3)1e-10<(u=Math.sqrt(p[f]*p[f]+p[f+1]*p[f+1]+p[f+2]*p[f+2]))&&(p[f]/=u,p[f+1]/=u,p[f+2]/=u);return p},Ve.isLittleEndian=(e=new ArrayBuffer(2),$n=new Uint8Array(e),e=new Uint16Array(e),($n[0]=1)===e[0]),Ve.InterleavedStream=function(e,t){this.data=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),this.offset=Ve.isLittleEndian?3:0,this.count=4*t,this.len=this.data.length},Ve.InterleavedStream.prototype.writeByte=function(e){this.data[this.offset]=e,this.offset+=this.count,this.offset>=this.len&&(this.offset-=this.len-4,this.offset>=this.count)&&(this.offset-=this.count+(Ve.isLittleEndian?1:-1))},Ve.BIMStream=function(e,t,n){this.data=e,this.offset=t,this.count=n,this.len=this.data.length},Ve.BIMStream.prototype.writeByte=function(e){this.data[this.offset]=e,this.offset+=this.count,this.offset>=this.len&&(this.offset=0)},Ve.Stream=function(e){this.data=e,this.dataView=new DataView(e.buffer),this.offset=0},Ve.Stream.prototype.TWO_POW_MINUS23=Math.pow(2,-23),Ve.Stream.prototype.TWO_POW_MINUS126=Math.pow(2,-126),Ve.Stream.prototype.readByte=function(){return 255&this.data[this.offset++]},Ve.Stream.prototype.readUInt8=function(){return this.dataView.getUint8(this.offset++,!0)},Ve.Stream.prototype.readInt32=function(){var e=this.dataView.getInt32(this.offset,!0);return this.offset+=4,e},Ve.Stream.prototype.readUInt32=function(){var e=this.dataView.getUint32(this.offset,!0);return this.offset+=4,e},Ve.Stream.prototype.readInt64=function(){var e=this.dataView.getUint32(this.offset,!0),t=(this.offset+=4,this.dataView.getUint32(this.offset,!0)),t=(this.offset+=4,BigInt(t)<<BigInt(32)|BigInt(e));return Number(t.valueOf())},Ve.Stream.prototype.readInt16=function(){var e=this.dataView.getInt16(this.offset,!0);return this.offset+=2,e},Ve.Stream.prototype.readUInt16=function(){var e=this.dataView.getUint16(this.offset,!0);return this.offset+=2,e},Ve.Stream.prototype.readFloat32=function(){var e=this.dataView.getFloat32(this.offset,!0);return this.offset+=4,e},Ve.Stream.prototype.readFloat64=function(){var e=this.dataView.getFloat64(this.offset,!0);return this.offset+=8,e},Ve.Stream.prototype.readString=function(){var e=this.readInt32();return this.offset+=e,String.fromCharCode.apply(null,this.data.subarray(this.offset-e,this.offset))},Ve.Stream.prototype.readTexture=function(){for(var e=this.readByte(),t=[],n=0;n<8;n++){var i=4*n;e&Math.pow(2,n)?(t[i]=0,t[1+i]=0,t[2+i]=0,t[3+i]=255):(t[i]=255,t[1+i]=255,t[2+i]=255,t[3+i]=0)}return t},Ve.Stream.prototype.readGuid=function(){for(var e,t="";t+=e=String.fromCharCode(this.readByte()),0!==e.charCodeAt(0););return 0==_e.ScenarioEditorid?t.substring(0,t.length-1):Se.addSceneID(t.substring(0,t.length-1))},Ve.Stream.prototype.readArrayUint8=function(e){for(var t=0,n=e.length;t<n;++t)e[t]=this.data[this.offset++];return e},Ve.Stream.prototype.readArrayInt32=function(e){for(var t=0,n=e.length;t<n;)e[t++]=this.readInt32();return e},Ve.Stream.prototype.readArrayUInt32=function(e){for(var t=0,n=e.length;t<n;)e[t++]=this.readUInt32();return e},Ve.Stream.prototype.readArrayInt16=function(e){for(var t=0,n=e.length;t<n;)e[t++]=this.readInt16();return e},Ve.Stream.prototype.readArrayFloat32=function(e){for(var t=0,n=e.length;t<n;)e[t++]=this.readFloat32();return e},M||{}),gt=(M.OutWindow=function(){this._windowSize=0},M.OutWindow.prototype.create=function(e){this._buffer&&this._windowSize===e||(this._buffer=[]),this._windowSize=e,this._pos=0,this._streamPos=0},M.OutWindow.prototype.flush=function(){var e=this._pos-this._streamPos;if(0!==e){for(;e--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},M.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},M.OutWindow.prototype.setStream=function(e){this.releaseStream(),this._stream=e},M.OutWindow.prototype.init=function(e){e||(this._streamPos=0,this._pos=0)},M.OutWindow.prototype.copyBlock=function(e,t){var n=this._pos-e-1;for(n<0&&(n+=this._windowSize);t--;)n>=this._windowSize&&(n=0),this._buffer[this._pos++]=this._buffer[n++],this._pos>=this._windowSize&&this.flush()},M.OutWindow.prototype.putByte=function(e){this._buffer[this._pos++]=e,this._pos>=this._windowSize&&this.flush()},M.OutWindow.prototype.getByte=function(e){e=this._pos-e-1;return e<0&&(e+=this._windowSize),this._buffer[e]},M.RangeDecoder=function(){},M.RangeDecoder.prototype.setStream=function(e){this._stream=e},M.RangeDecoder.prototype.releaseStream=function(){this._stream=null},M.RangeDecoder.prototype.init=function(){var e=5;for(this._code=0,this._range=-1;e--;)this._code=this._code<<8|this._stream.readByte()},M.RangeDecoder.prototype.decodeDirectBits=function(e){for(var t,n=0,i=e;i--;)this._range>>>=1,t=this._code-this._range>>>31,this._code-=this._range&t-1,n=n<<1|1-t,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return n},M.RangeDecoder.prototype.decodeBit=function(e,t){var n=e[t],i=(this._range>>>11)*n;return(2147483648^this._code)<(2147483648^i)?(this._range=i,e[t]+=2048-n>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=i,this._code-=i,e[t]-=n>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},M.initBitModels=function(e,t){for(;t--;)e[t]=1024},M.BitTreeDecoder=function(e){this._models=[],this._numBitLevels=e},M.BitTreeDecoder.prototype.init=function(){M.initBitModels(this._models,1<<this._numBitLevels)},M.BitTreeDecoder.prototype.decode=function(e){for(var t=1,n=this._numBitLevels;n--;)t=t<<1|e.decodeBit(this._models,t);return t-(1<<this._numBitLevels)},M.BitTreeDecoder.prototype.reverseDecode=function(e){for(var t,n=1,i=0,r=0;r<this._numBitLevels;++r)n=n<<1|(t=e.decodeBit(this._models,n)),i|=t<<r;return i},M.reverseDecode2=function(e,t,n,i){for(var r,o=1,a=0,s=0;s<i;++s)o=o<<1|(r=n.decodeBit(e,t+o)),a|=r<<s;return a},M.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new M.BitTreeDecoder(8),this._numPosStates=0},M.LenDecoder.prototype.create=function(e){for(;this._numPosStates<e;++this._numPosStates)this._lowCoder[this._numPosStates]=new M.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new M.BitTreeDecoder(3)},M.LenDecoder.prototype.init=function(){var e=this._numPosStates;for(M.initBitModels(this._choice,2);e--;)this._lowCoder[e].init(),this._midCoder[e].init();this._highCoder.init()},M.LenDecoder.prototype.decode=function(e,t){return 0===e.decodeBit(this._choice,0)?this._lowCoder[t].decode(e):0===e.decodeBit(this._choice,1)?8+this._midCoder[t].decode(e):16+this._highCoder.decode(e)},M.Decoder2=function(){this._decoders=[]},M.Decoder2.prototype.init=function(){M.initBitModels(this._decoders,768)},M.Decoder2.prototype.decodeNormal=function(e){for(var t=1;(t=t<<1|e.decodeBit(this._decoders,t))<256;);return 255&t},M.Decoder2.prototype.decodeWithMatchByte=function(e,t){var n,i,r=1;do{if(n=t>>7&1,t<<=1,r=r<<1|(i=e.decodeBit(this._decoders,(1+n<<8)+r)),n!==i){for(;r<256;)r=r<<1|e.decodeBit(this._decoders,r);break}}while(r<256);return 255&r},M.LiteralDecoder=function(){},M.LiteralDecoder.prototype.create=function(e,t){var n;if(!this._coders||this._numPrevBits!==t||this._numPosBits!==e)for(this._numPosBits=e,this._posMask=(1<<e)-1,this._numPrevBits=t,this._coders=[],n=1<<this._numPrevBits+this._numPosBits;n--;)this._coders[n]=new M.Decoder2},M.LiteralDecoder.prototype.init=function(){for(var e=1<<this._numPrevBits+this._numPosBits;e--;)this._coders[e].init()},M.LiteralDecoder.prototype.getDecoder=function(e,t){return this._coders[((e&this._posMask)<<this._numPrevBits)+((255&t)>>>8-this._numPrevBits)]},M.Decoder=function(){this._outWindow=new M.OutWindow,this._rangeDecoder=new M.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new M.BitTreeDecoder(4),this._lenDecoder=new M.LenDecoder,this._repLenDecoder=new M.LenDecoder,this._literalDecoder=new M.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new M.BitTreeDecoder(6),this._posSlotDecoder[1]=new M.BitTreeDecoder(6),this._posSlotDecoder[2]=new M.BitTreeDecoder(6),this._posSlotDecoder[3]=new M.BitTreeDecoder(6)},M.Decoder.prototype.setDictionarySize=function(e){return!(e<0||(this._dictionarySize!==e&&(this._dictionarySize=e,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),0))},M.Decoder.prototype.setLcLpPb=function(e,t,n){var i=1<<n;return!(8<e||4<t||4<n||(this._literalDecoder.create(t,e),this._lenDecoder.create(i),this._repLenDecoder.create(i),this._posStateMask=i-1,0))},M.Decoder.prototype.init=function(){var e=4;for(this._outWindow.init(!1),M.initBitModels(this._isMatchDecoders,192),M.initBitModels(this._isRep0LongDecoders,192),M.initBitModels(this._isRepDecoders,12),M.initBitModels(this._isRepG0Decoders,12),M.initBitModels(this._isRepG1Decoders,12),M.initBitModels(this._isRepG2Decoders,12),M.initBitModels(this._posDecoders,114),this._literalDecoder.init();e--;)this._posSlotDecoder[e].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},M.Decoder.prototype.decode=function(e,t,n){var i,r,o,a,s=0,l=0,d=0,c=0,h=0,u=0,p=0;for(this._rangeDecoder.setStream(e),this._outWindow.setStream(t),this.init();n<0||u<n;)if(a=u&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(s<<4)+a))o=this._literalDecoder.getDecoder(u++,p),p=7<=s?o.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(l)):o.decodeNormal(this._rangeDecoder),this._outWindow.putByte(p),s=s<4?0:s-(s<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,s))(i=0)===this._rangeDecoder.decodeBit(this._isRepG0Decoders,s)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(s<<4)+a)&&(s=s<7?9:11,i=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,s)?r=d:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,s)?r=c:(r=h,h=c),c=d),d=l,l=r),0===i&&(i=2+this._repLenDecoder.decode(this._rangeDecoder,a),s=s<7?8:11);else if(h=c,c=d,d=l,i=2+this._lenDecoder.decode(this._rangeDecoder,a),s=s<7?7:10,4<=(o=this._posSlotDecoder[i<=5?i-2:3].decode(this._rangeDecoder))){if(l=(2|1&o)<<(a=(o>>1)-1),o<14)l+=M.reverseDecode2(this._posDecoders,l-o-1,this._rangeDecoder,a);else if((l=(l+=this._rangeDecoder.decodeDirectBits(a-4)<<4)+this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===l)break;return!1}}else l=o;if(u<=l||l>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(l,i),u+=i,p=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},M.Decoder.prototype.setDecoderProperties=function(e){var t;return!(e.size<5||(t=e.readByte(),!this.setLcLpPb(t%9,(t=~~(t/9))%5,~~(t/5))))&&(t=e.readByte(),t=(t=(t|=e.readByte()<<8)|e.readByte()<<16)+16777216*e.readByte(),this.setDictionarySize(t))},M.decompress=function(e,t,n,i){var r=new M.Decoder;if(!r.setDecoderProperties(e))throw"Incorrect stream properties";if(r.decode(t,n,i))return!0;throw"Error in data stream"},$n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),ht=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),"object"!=typeof WebAssembly?{supported:!1}:(e="B9h79tEBBBE8fV9gBB9gVUUUUUEU9gIUUUB9gEUEU9gIUUUEUIKQBEEEDDDILLVIEBEOWEUEC+Q/IEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBEy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBDe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBIl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBLk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBOL79iv9rBRQ+f8yQDBK/tSEhU8jJJJJBCJ/EB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rADZ1JJJBHWCJ/ABAD9uC/wfBgGOCJDAOCJD6eHdAICEFHQDNDNADtMBCBHKINAKAE9PMDAdAEAK9rAKAdFAE6eGXCSFGOCL4CIFCD4HMDNDNDNDNAOC9wgGptMBCBHSCEHZAWCJDFHhAQHoINARAo9rAM6MLAoAMFHQCBHICBHLINARAQ9rCk6MIAWCJ/CBFALFHODNDNDNDNDNAoALCO4FrBBAICOg4CIgpLBEDIBKAO9CB83IBAOCWF9CB83IBXIKAOAQrBLAQrBBGaCO4GcAcCIsGce86BBAOCEFAQCLFAcFGcrBBAaCL4CIgGxAxCIsGxe86BBAOCDFAcAxFGcrBBAaCD4CIgGxAxCIsGxe86BBAOCIFAcAxFGcrBBAaCIgGaAaCIsGae86BBAOCLFAcAaFGcrBBAQrBEGaCO4GxAxCIsGxe86BBAOCVFAcAxFGcrBBAaCL4CIgGxAxCIsGxe86BBAOCOFAcAxFGcrBBAaCD4CIgGxAxCIsGxe86BBAOCRFAcAxFGcrBBAaCIgGaAaCIsGae86BBAOCWFAcAaFGcrBBAQrBDGaCO4GxAxCIsGxe86BBAOCdFAcAxFGcrBBAaCL4CIgGxAxCIsGxe86BBAOCQFAcAxFGcrBBAaCD4CIgGxAxCIsGxe86BBAOCKFAcAxFGcrBBAaCIgGaAaCIsGae86BBAOCXFAcAaFGarBBAQrBIGQCO4GcAcCIsGce86BBAOCMFAaAcFGarBBAQCL4CIgGcAcCIsGce86BBAOCpFAaAcFGarBBAQCD4CIgGcAcCIsGce86BBAOCSFAaAcFGOrBBAQCIgGQAQCIsGQe86BBAOAQFHQXDKAOAQrBWAQrBBGaCL4GcAcCSsGce86BBAOCEFAQCWFAcFGcrBBAaCSgGaAaCSsGae86BBAOCDFAcAaFGarBBAQrBEGcCL4GxAxCSsGxe86BBAOCIFAaAxFGarBBAcCSgGcAcCSsGce86BBAOCLFAaAcFGarBBAQrBDGcCL4GxAxCSsGxe86BBAOCVFAaAxFGarBBAcCSgGcAcCSsGce86BBAOCOFAaAcFGarBBAQrBIGcCL4GxAxCSsGxe86BBAOCRFAaAxFGarBBAcCSgGcAcCSsGce86BBAOCWFAaAcFGarBBAQrBLGcCL4GxAxCSsGxe86BBAOCdFAaAxFGarBBAcCSgGcAcCSsGce86BBAOCQFAaAcFGarBBAQrBVGcCL4GxAxCSsGxe86BBAOCKFAaAxFGarBBAcCSgGcAcCSsGce86BBAOCXFAaAcFGarBBAQrBOGcCL4GxAxCSsGxe86BBAOCMFAaAxFGarBBAcCSgGcAcCSsGce86BBAOCpFAaAcFGarBBAQrBRGQCL4GcAcCSsGce86BBAOCSFAaAcFGOrBBAQCSgGQAQCSsGQe86BBAOAQFHQXEKAOAQ8pBB83BBAOCWFAQCWF8pBB83BBAQCZFHQKAICDFHIALCZFGLAp6MBKAQtMDDNAXtMBAWASFrBBHICBHOAhHLINALAWCJ/CBFAOFrBBGoCE4CBAoCEg9r7AIFGI86BBALADFHLAOCEFGOAX9HMBKKAhCEFHhASCEFGSAD6HZAQHoASAD9HMBXIKKAQAMAD2FHcDNAXtMBCBHpCEHZAWCJDFHaINARAQ9rAM6MLAQtMDAQAMFHQAWApFrBBHICBHOAaHLINALAWCJ/CBFAOFrBBGoCE4CBAoCEg9r7AIFGI86BBALADFHLAOCEFGOAX9HMBKAaCEFHaApCEFGpAD6HZApAD9HMBKAcHQXDKCBHOCEHZINARAQ9rAM6MIAQtMEAOCEFGOAD6HZAQAMFHQADAO9HMBKAcHQXEKCBHQAZCEgMEKABAKAD2FAWCJDFAXAD2Z1JJJB8aAWAWCJDFAXCUFAD2FADZ1JJJB8aAXAKFHKAQMEKKC9+HOXDKAEtMBCBHOINAdAEAO9rAOAdFAE6eAOFGOAE6MBKKCBC99ARAQ9rADCAADCA0eseHOKAVCJ/EBF8kJJJJBAOK/YZEhU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJEZ+JJJJB8aAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBALAIFC9wFHQAICEFGWARFHODNAEtMBCMCSAdCEseHKCBHXCBHMCBHdCBHICBHLINDNAOAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFALARCL4CU7FCSgCITFGpYDLHSApYDBHZDNARCSgGpAK9PMBAVAIARCU7FCSgCDTFYDBAXApeHRAptHpDNDNADCD9HMBABAdCETFGhAZ87EBAhCDFAS87EBAhCLFAR87EBXEKABAdCDTFGhAZbDBAhCLFASbDBAhCWFARbDBKAXApFHXAVC/ABFALCITFGhARbDBAhASbDLAVAICDTFARbDBAVC/ABFALCEFCSgGLCITFGhAZbDBAhARbDLAIApFHIALCEFHLXDKDNDNApCSsMBAMApFApC987FCEFHMXEKAOCEFHRAO8sBBGpCfEgHhDNDNApCU9MMBARHOXEKAOCVFHOAhCfBgHhCRHpDNINAR8sBBGoCfBgApTAhvHhAoCU9KMEARCEFHRApCRFGpC8j9HMBXDKKARCEFHOKAhCE4CBAhCEg9r7AMFHMKDNDNADCD9HMBABAdCETFGRAZ87EBARCDFAS87EBARCLFAM87EBXEKABAdCDTFGRAZbDBARCLFASbDBARCWFAMbDBKAVC/ABFALCITFGRAMbDBARASbDLAVAICDTFAMbDBAVC/ABFALCEFCSgGLCITFGRAZbDBARAMbDLAICEFHIALCEFHLXEKDNARCPE0MBAXCEFGoAVAIAQARCSgFrBBGpCL49rCSgCDTFYDBApCZ6GheHRAVAIAp9rCSgCDTFYDBAoAhFGSApCSgGoeHpAotHoDNDNADCD9HMBABAdCETFGZAX87EBAZCDFAR87EBAZCLFAp87EBXEKABAdCDTFGZAXbDBAZCLFARbDBAZCWFApbDBKAVAICDTFAXbDBAVC/ABFALCITFGZARbDBAZAXbDLAVAICEFGICSgCDTFARbDBAVC/ABFALCEFCSgCITFGZApbDBAZARbDLAVAIAhFCSgGICDTFApbDBAVC/ABFALCDFCSgGLCITFGRAXbDBARApbDLALCEFHLAIAoFHIASAoFHXXEKAXCBAOrBBGZeGaARC/+EsGRFHSAZCSgHcAZCL4HxDNDNAZCS0MBASCEFHoXEKASHoAVAIAx9rCSgCDTFYDBHSKDNDNAcMBAoCEFHXXEKAoHXAVAIAZ9rCSgCDTFYDBHoKDNDNARtMBAOCEFHRXEKAOCDFHRAO8sBEGhCfEgHpDNAhCU9KMBAOCOFHaApCfBgHpCRHODNINAR8sBBGhCfBgAOTApvHpAhCU9KMEARCEFHRAOCRFGOC8j9HMBKAaHRXEKARCEFHRKApCE4CBApCEg9r7AMFGMHaKDNDNAxCSsMBARHpXEKARCEFHpAR8sBBGOCfEgHhDNAOCU9KMBARCVFHSAhCfBgHhCRHODNINAp8sBBGRCfBgAOTAhvHhARCU9KMEApCEFHpAOCRFGOC8j9HMBKASHpXEKApCEFHpKAhCE4CBAhCEg9r7AMFGMHSKDNDNAcCSsMBApHOXEKApCEFHOAp8sBBGRCfEgHhDNARCU9KMBApCVFHoAhCfBgHhCRHRDNINAO8sBBGpCfBgARTAhvHhApCU9KMEAOCEFHOARCRFGRC8j9HMBKAoHOXEKAOCEFHOKAhCE4CBAhCEg9r7AMFGMHoKDNDNADCD9HMBABAdCETFGRAa87EBARCDFAS87EBARCLFAo87EBXEKABAdCDTFGRAabDBARCLFASbDBARCWFAobDBKAVC/ABFALCITFGRASbDBARAabDLAVAICDTFAabDBAVC/ABFALCEFCSgCITFGRAobDBARASbDLAVAICEFGICSgCDTFASbDBAVC/ABFALCDFCSgCITFGRAabDBARAobDLAVAIAZCZ6AxCSsvFGICSgCDTFAobDBAIActAcCSsvFHIALCIFHLKAWCEFHWALCSgHLAICSgHIAdCIFGdAE6MBKKCBC99AOAQseHOKAVC/AEF8kJJJJBAOK+LLEVU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHRALAIFC98FHWDNAEtMBDNADCDsMBCBHdINDNARAW6MBC9+SKARCEFHOAR8sBBGLCfEgHIDNDNALCU9MMBAOHRXEKARCVFHRAICfBgHICRHLDNINAO8sBBGDCfBgALTAIvHIADCU9KMEAOCEFHOALCRFGLC8j9HMBXDKKAOCEFHRKABAdCDTFAICD4CBAICE4CEg9r7AVCWFAICEgCDTvGOYDBFGLbDBAOALbDBAdCEFGdAE9HMBXDKKCBHdINDNARAW6MBC9+SKARCEFHOAR8sBBGLCfEgHIDNDNALCU9MMBAOHRXEKARCVFHRAICfBgHICRHLDNINAO8sBBGDCfBgALTAIvHIADCU9KMEAOCEFHOALCRFGLC8j9HMBXDKKAOCEFHRKABAdCETFAICD4CBAICE4CEg9r7AVCWFAICEgCDTvGOYDBFGL87EBAOALbDBAdCEFGdAE9HMBKKCBC99ARAWseHOKAOK+lVOEUE99DUD99EUD99DNDNADCL9HMBAEtMEINDNDNjBBBzjBBB+/ABCDFGD8sBB+yAB8sBBGI+yGL+L+TABCEFGV8sBBGO+yGR+L+TGWjBBBB9gGdeAWjBB/+9CAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI86BBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD86BBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD86BBABCLFHBAECUFGEMBXDKKAEtMBINDNDNjBBBzjBBB+/ABCLFGD8uEB+yAB8uEBGI+yGL+L+TABCDFGV8uEBGO+yGR+L+TGWjBBBB9gGdeAWjB/+fsAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI87EBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD87EBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD87EBABCWFHBAECUFGEMBKKK/SILIUI99IUE99DNAEtMBCBHIABHLINDNDNj/zL81zALCOF8uEBGVCIv+y+VGOAL8uEB+ynGRjB/+fsnjBBBzjBBB+/ARjBBBB9gemGW+LjBBB9P9dtMBAW+oHdXEKCJJJJ94HdKALCLF8uEBHQALCDF8uEBHKABAVCEFCIgAIvCETFAd87EBDNDNAOAK+ynGWjB/+fsnjBBBzjBBB+/AWjBBBB9gemGX+LjBBB9P9dtMBAX+oHKXEKCJJJJ94HKKABAVCDFCIgAIvCETFAK87EBDNDNAOAQ+ynGOjB/+fsnjBBBzjBBB+/AOjBBBB9gemGX+LjBBB9P9dtMBAX+oHQXEKCJJJJ94HQKABAVCUFCIgAIvCETFAQ87EBDNDNjBBJzARARn+TAWAWn+TAOAOn+TGRjBBBBARjBBBB9ge+RjB/+fsnjBBBzmGR+LjBBB9P9dtMBAR+oHQXEKCJJJJ94HQKABAVCIgAIvCETFAQ87EBALCWFHLAICLFHIAECUFGEMBKKK9MBDNADCD4AE2GEtMBINABABYDBGDCWTCW91+yADCE91CJJJ/8IFCJJJ98g++nuDBABCLFHBAECUFGEMBKKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIK/lEEEUDNDNAEABvCIgtMBABHIXEKDNDNADCZ9PMBABHIXEKABHIINAIAEYDBbDBAICLFAECLFYDBbDBAICWFAECWFYDBbDBAICXFAECXFYDBbDBAICZFHIAECZFHEADC9wFGDCS0MBKKADCL6MBINAIAEYDBbDBAECLFHEAICLFHIADC98FGDCI0MBKKDNADtMBINAIAErBB86BBAICEFHIAECEFHEADCUFGDMBKKABK/AEEDUDNDNABCIgtMBABHIXEKAECfEgC+B+C+EW2HLDNDNADCZ9PMBABHIXEKABHIINAIALbDBAICXFALbDBAICWFALbDBAICLFALbDBAICZFHIADC9wFGDCS0MBKKADCL6MBINAIALbDBAICLFHIADC98FGDCI0MBKKDNADtMBINAIAE86BBAICEFHIADCUFGDMBKKABKKKEBCJWKLZ9kBB",WebAssembly.validate($n)&&(e="B9h79tEBBBEkL9gBB9gVUUUUUEU9gIUUUB9gEUEUIKQBBEBEEDDDILVE9wEEEVIEBEOWEUEC+Q/aEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBDy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBLe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBOk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBRl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBWL79iv9rBdQ/49TQLBZIK9+EVU8jJJJJBCZ9rHBCBHEINCBHDCBHIINABCWFADFAICJUAEAD4CEgGLe86BBAIALFHIADCEFGDCW9HMBKAEC+Q+YJJBFAI86BBAECITC+Q1JJBFAB8pIW83IBAECEFGECJD9HMBKK/s8jLhUD97EUO978jJJJJBCJ/KB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rAD/8QBBCJ/ABAD9uC/wfBgGLCJDALCJD6eHWAICEFHLDNDNADtMBCBHdINAdAE9PMDAWAEAd9rAdAWFAE6eGQCSFGOC9wgGKCI2HXAKCETHMAOCL4CIFCD4HpABAdAD2FHSCBHZDNINCEHhALHoCBHaDNINARAo9rAp6MIAVCJ/CBFAaAK2FHcAoApFHLCBHIDNAKC/AB6MBARAL9rC/gB6MBCBHOINAcAOFHIDNDNDNDNDNAoAOCO4FrBBGxCIgpLBEDIBKAIPXBBBBBBBBBBBBBBBBPKLBXIKAIALPBBLALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlGqCDP+MEAqPMBZEhDoIaLcVxOqRlPXIIIIIIIIIIIIIIIIP9OGlPXIIIIIIIIIIIIIIIIP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLBALCLFAkC+Q+YJJBFrBBAyPqBFFHLXDKAIALPBBWALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlPXSSSSSSSSSSSSSSSSP9OGlPXSSSSSSSSSSSSSSSSP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLBALCWFAkC+Q+YJJBFrBBAyPqBFFHLXEKAIALPBBBPKLBALCZFHLKDNDNDNDNDNAxCD4CIgpLBEDIBKAIPXBBBBBBBBBBBBBBBBPKLZXIKAIALPBBLALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlGqCDP+MEAqPMBZEhDoIaLcVxOqRlPXIIIIIIIIIIIIIIIIP9OGlPXIIIIIIIIIIIIIIIIP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLZALCLFAkC+Q+YJJBFrBBAyPqBFFHLXDKAIALPBBWALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlPXSSSSSSSSSSSSSSSSP9OGlPXSSSSSSSSSSSSSSSSP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLZALCWFAkC+Q+YJJBFrBBAyPqBFFHLXEKAIALPBBBPKLZALCZFHLKDNDNDNDNDNAxCL4CIgpLBEDIBKAIPXBBBBBBBBBBBBBBBBPKLAXIKAIALPBBLALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlGqCDP+MEAqPMBZEhDoIaLcVxOqRlPXIIIIIIIIIIIIIIIIP9OGlPXIIIIIIIIIIIIIIIIP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLAALCLFAkC+Q+YJJBFrBBAyPqBFFHLXDKAIALPBBWALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlPXSSSSSSSSSSSSSSSSP9OGlPXSSSSSSSSSSSSSSSSP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLAALCWFAkC+Q+YJJBFrBBAyPqBFFHLXEKAIALPBBBPKLAALCZFHLKDNDNDNDNDNAxCO4pLBEDIBKAIPXBBBBBBBBBBBBBBBBPKL8wXIKAIALPBBLALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlGqCDP+MEAqPMBZEhDoIaLcVxOqRlPXIIIIIIIIIIIIIIIIP9OGlPXIIIIIIIIIIIIIIIIP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGxCITC+Q1JJBFPBIBAxC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGxCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKL8wALCLFAxC+Q+YJJBFrBBAyPqBFFHLXDKAIALPBBWALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlPXSSSSSSSSSSSSSSSSP9OGlPXSSSSSSSSSSSSSSSSP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGxCITC+Q1JJBFPBIBAxC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGxCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKL8wALCWFAxC+Q+YJJBFrBBAyPqBFFHLXEKAIALPBBBPKL8wALCZFHLKAOC/ABFHIAOCJEFAK0MEAIHOARAL9rC/fB0MBKKDNDNAIAK9PMBAICI4HOINARAL9rCk6MDAcAIFHxDNDNDNDNDNAoAICO4FrBBAOCOg4CIgpLBEDIBKAxPXBBBBBBBBBBBBBBBBPKLBXIKAxALPBBLALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlGqCDP+MEAqPMBZEhDoIaLcVxOqRlPXIIIIIIIIIIIIIIIIP9OGlPXIIIIIIIIIIIIIIIIP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLBALCLFAkC+Q+YJJBFrBBAyPqBFFHLXDKAxALPBBWALPBBBGqCLP+MEAqPMBZEhDoIaLcVxOqRlPXSSSSSSSSSSSSSSSSP9OGlPXSSSSSSSSSSSSSSSSP8jGqP5B9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBAkC+Q+YJJBFPBBBGyAyPMBBBBBBBBBBBBBBBBAqP5E9CJf/8/4/w/g/AB9+9Cu1+nGkCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAlAqP9SPKLBALCWFAkC+Q+YJJBFrBBAyPqBFFHLXEKAxALPBBBPKLBALCZFHLKAOCDFHOAICZFGIAK6MBKKALtMBAaCI6HhALHoAaCEFGOHaAOCLsMDXEKKCBHLAhCEgMDKDNAKtMBAVCJDFAZFHIAVAZFPBDBHyCBHxINAIAVCJ/CBFAxFGOPBLBGlCEP9tAlPXEEEEEEEEEEEEEEEEGqP9OP9hP9RGlAOAKFPBLBG8aCEP9tA8aAqP9OP9hP9RG8aPMBZEhDoIaLcVxOqRlGeAOAMFPBLBG3CEP9tA3AqP9OP9hP9RG3AOAXFPBLBG5CEP9tA5AqP9OP9hP9RG5PMBZEhDoIaLcVxOqRlG8ePMBEZhDIoaLVcxORqlGqAqPMBEDIBEDIBEDIBEDIAyP9uGyP9aDBBAIADFGOAyAqAqPMLVORLVORLVORLVORP9uGyP9aDBBAOADFGOAyAqAqPMWdQKWdQKWdQKWdQKP9uGyP9aDBBAOADFGOAyAqAqPMXMpSXMpSXMpSXMpSP9uGyP9aDBBAOADFGOAyAeA8ePMWdkyQK8aeXM35pS8e8fGqAqPMBEDIBEDIBEDIBEDIP9uGyP9aDBBAOADFGOAyAqAqPMLVORLVORLVORLVORP9uGyP9aDBBAOADFGOAyAqAqPMWdQKWdQKWdQKWdQKP9uGyP9aDBBAOADFGOAyAqAqPMXMpSXMpSXMpSXMpSP9uGyP9aDBBAOADFGOAyAlA8aPMWkdyQ8aKeX3M5p8eS8fGlA3A5PMWkdyQ8aKeX3M5p8eS8fG8aPMBEZhDIoaLVcxORqlGqAqPMBEDIBEDIBEDIBEDIP9uGyP9aDBBAOADFGOAyAqAqPMLVORLVORLVORLVORP9uGyP9aDBBAOADFGOAyAqAqPMWdQKWdQKWdQKWdQKP9uGyP9aDBBAOADFGOAyAqAqPMXMpSXMpSXMpSXMpSP9uGyP9aDBBAOADFGOAyAlA8aPMWdkyQK8aeXM35pS8e8fGqAqPMBEDIBEDIBEDIBEDIP9uGyP9aDBBAOADFGOAyAqAqPMLVORLVORLVORLVORP9uGyP9aDBBAOADFGOAyAqAqPMWdQKWdQKWdQKWdQKP9uGyP9aDBBAOADFGOAyAqAqPMXMpSXMpSXMpSXMpSP9uGyP9aDBBAOADFHIAxCZFGxAK6MBKKAZCLFGZAD6MBKASAVCJDFAQAD2/8QBBAVAVCJDFAQCUFAD2FAD/8QBBAQAdFHdC9+HOALMEXLKKC9+HOXDKAEtMBCBHOINAWAEAO9rAOAWFAE6eAOFGOAE6MBKKCBC99ARAL9rADCAADCA0eseHOKAVCJ/KBF8kJJJJBAOKWBZ+BJJJBK/UZEhU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJE/8KBAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBALAIFC9wFHQAICEFGWARFHODNAEtMBCMCSAdCEseHKCBHXCBHMCBHdCBHICBHLINDNAOAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFALARCL4CU7FCSgCITFGpYDLHSApYDBHZDNARCSgGpAK9PMBAVAIARCU7FCSgCDTFYDBAXApeHRAptHpDNDNADCD9HMBABAdCETFGhAZ87EBAhCDFAS87EBAhCLFAR87EBXEKABAdCDTFGhAZbDBAhCLFASbDBAhCWFARbDBKAXApFHXAVC/ABFALCITFGhARbDBAhASbDLAVAICDTFARbDBAVC/ABFALCEFCSgGLCITFGhAZbDBAhARbDLAIApFHIALCEFHLXDKDNDNApCSsMBAMApFApC987FCEFHMXEKAOCEFHRAO8sBBGpCfEgHhDNDNApCU9MMBARHOXEKAOCVFHOAhCfBgHhCRHpDNINAR8sBBGoCfBgApTAhvHhAoCU9KMEARCEFHRApCRFGpC8j9HMBXDKKARCEFHOKAhCE4CBAhCEg9r7AMFHMKDNDNADCD9HMBABAdCETFGRAZ87EBARCDFAS87EBARCLFAM87EBXEKABAdCDTFGRAZbDBARCLFASbDBARCWFAMbDBKAVC/ABFALCITFGRAMbDBARASbDLAVAICDTFAMbDBAVC/ABFALCEFCSgGLCITFGRAZbDBARAMbDLAICEFHIALCEFHLXEKDNARCPE0MBAXCEFGoAVAIAQARCSgFrBBGpCL49rCSgCDTFYDBApCZ6GheHRAVAIAp9rCSgCDTFYDBAoAhFGSApCSgGoeHpAotHoDNDNADCD9HMBABAdCETFGZAX87EBAZCDFAR87EBAZCLFAp87EBXEKABAdCDTFGZAXbDBAZCLFARbDBAZCWFApbDBKAVAICDTFAXbDBAVC/ABFALCITFGZARbDBAZAXbDLAVAICEFGICSgCDTFARbDBAVC/ABFALCEFCSgCITFGZApbDBAZARbDLAVAIAhFCSgGICDTFApbDBAVC/ABFALCDFCSgGLCITFGRAXbDBARApbDLALCEFHLAIAoFHIASAoFHXXEKAXCBAOrBBGZeGaARC/+EsGRFHSAZCSgHcAZCL4HxDNDNAZCS0MBASCEFHoXEKASHoAVAIAx9rCSgCDTFYDBHSKDNDNAcMBAoCEFHXXEKAoHXAVAIAZ9rCSgCDTFYDBHoKDNDNARtMBAOCEFHRXEKAOCDFHRAO8sBEGhCfEgHpDNAhCU9KMBAOCOFHaApCfBgHpCRHODNINAR8sBBGhCfBgAOTApvHpAhCU9KMEARCEFHRAOCRFGOC8j9HMBKAaHRXEKARCEFHRKApCE4CBApCEg9r7AMFGMHaKDNDNAxCSsMBARHpXEKARCEFHpAR8sBBGOCfEgHhDNAOCU9KMBARCVFHSAhCfBgHhCRHODNINAp8sBBGRCfBgAOTAhvHhARCU9KMEApCEFHpAOCRFGOC8j9HMBKASHpXEKApCEFHpKAhCE4CBAhCEg9r7AMFGMHSKDNDNAcCSsMBApHOXEKApCEFHOAp8sBBGRCfEgHhDNARCU9KMBApCVFHoAhCfBgHhCRHRDNINAO8sBBGpCfBgARTAhvHhApCU9KMEAOCEFHOARCRFGRC8j9HMBKAoHOXEKAOCEFHOKAhCE4CBAhCEg9r7AMFGMHoKDNDNADCD9HMBABAdCETFGRAa87EBARCDFAS87EBARCLFAo87EBXEKABAdCDTFGRAabDBARCLFASbDBARCWFAobDBKAVC/ABFALCITFGRASbDBARAabDLAVAICDTFAabDBAVC/ABFALCEFCSgCITFGRAobDBARASbDLAVAICEFGICSgCDTFASbDBAVC/ABFALCDFCSgCITFGRAabDBARAobDLAVAIAZCZ6AxCSsvFGICSgCDTFAobDBAIActAcCSsvFHIALCIFHLKAWCEFHWALCSgHLAICSgHIAdCIFGdAE6MBKKCBC99AOAQseHOKAVC/AEF8kJJJJBAOK+LLEVU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHRALAIFC98FHWDNAEtMBDNADCDsMBCBHdINDNARAW6MBC9+SKARCEFHOAR8sBBGLCfEgHIDNDNALCU9MMBAOHRXEKARCVFHRAICfBgHICRHLDNINAO8sBBGDCfBgALTAIvHIADCU9KMEAOCEFHOALCRFGLC8j9HMBXDKKAOCEFHRKABAdCDTFAICD4CBAICE4CEg9r7AVCWFAICEgCDTvGOYDBFGLbDBAOALbDBAdCEFGdAE9HMBXDKKCBHdINDNARAW6MBC9+SKARCEFHOAR8sBBGLCfEgHIDNDNALCU9MMBAOHRXEKARCVFHRAICfBgHICRHLDNINAO8sBBGDCfBgALTAIvHIADCU9KMEAOCEFHOALCRFGLC8j9HMBXDKKAOCEFHRKABAdCETFAICD4CBAICE4CEg9r7AVCWFAICEgCDTvGOYDBFGL87EBAOALbDBAdCEFGdAE9HMBKKCBC99ARAWseHOKAOK+epLIUO97EUE978jJJJJBCA9rHIDNDNADCL9HMBDNAEC98gGLtMBCBHVABHDINADADPBBBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdPXBBBBBBBBBBBBBBBBP+2EGQARPXBBBJBBBJBBBJBBBJGKP9OP9RP/kEGRPXBB/+9CBB/+9CBB/+9CBB/+9CARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEPXBBN0BBN0BBN0BBN0GQP/kEPXfBBBfBBBfBBBfBBBP9OAOPXBBBfBBBfBBBfBBBfP9OP9QARAWP/mEAQP/kECWP+rEPXBfBBBfBBBfBBBfBBP9OP9QAdAWP/mEAQP/kECZP+rEPXBBfBBBfBBBfBBBfBP9OP9QPKBBADCZFHDAVCLFGVAL6MBKKALAE9PMEAIAECIgGVCDTGDvCBCZAD9r/8KBAIABALCDTFGLAD/8QBBDNAVtMBAIAIPBLBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdPXBBBBBBBBBBBBBBBBP+2EGQARPXBBBJBBBJBBBJBBBJGKP9OP9RP/kEGRPXBB/+9CBB/+9CBB/+9CBB/+9CARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEPXBBN0BBN0BBN0BBN0GQP/kEPXfBBBfBBBfBBBfBBBP9OAOPXBBBfBBBfBBBfBBBfP9OP9QARAWP/mEAQP/kECWP+rEPXBfBBBfBBBfBBBfBBP9OP9QAdAWP/mEAQP/kECZP+rEPXBBfBBBfBBBfBBBfBP9OP9QPKLBKALAIAD/8QBBSKDNAEC98gGXtMBCBHVABHDINADCZFGLALPBBBGOPXBBBBBBffBBBBBBffGKP9OADPBBBGdAOPMLVORXMpScxql358e8fPXfUBBfUBBfUBBfUBBP9OP/6EAdAOPMBEDIWdQKZhoaky8aeGOCZP+sEP/6EGRP/gEAOCZP+rECZP+sEP/6EGWP/gEP/kEP/lEGOPXB/+fsB/+fsB/+fsB/+fsAWAOPXBBBBBBBBBBBBBBBBP+2EGQAWPXBBBJBBBJBBBJBBBJGMP9OP9RP/kEGWAWP/mEAOAOP/mEARAQARAMP9OP9RP/kEGOAOP/mEP/kEP/kEP/jEP/nEGRP/mEPXBBN0BBN0BBN0BBN0GQP/kECZP+rEAWARP/mEAQP/kEPXffBBffBBffBBffBBP9OP9QGWAOARP/mEAQP/kEPXffBBffBBffBBffBBP9OGOPMWdkyQK8aeXM35pS8e8fP9QPKBBADAdAKP9OAWAOPMBEZhDIoaLVcxORqlP9QPKBBADCAFHDAVCLFGVAX6MBKKAXAE9PMBAIAECIgGVCITGDFCBCAAD9r/8KBAIABAXCITFGLAD/8QBBDNAVtMBAIAIPBLZGOPXBBBBBBffBBBBBBffGKP9OAIPBLBGdAOPMLVORXMpScxql358e8fPXfUBBfUBBfUBBfUBBP9OP/6EAdAOPMBEDIWdQKZhoaky8aeGOCZP+sEP/6EGRP/gEAOCZP+rECZP+sEP/6EGWP/gEP/kEP/lEGOPXB/+fsB/+fsB/+fsB/+fsAWAOPXBBBBBBBBBBBBBBBBP+2EGQAWPXBBBJBBBJBBBJBBBJGMP9OP9RP/kEGWAWP/mEAOAOP/mEARAQARAMP9OP9RP/kEGOAOP/mEP/kEP/kEP/jEP/nEGRP/mEPXBBN0BBN0BBN0BBN0GQP/kECZP+rEAWARP/mEAQP/kEPXffBBffBBffBBffBBP9OP9QGWAOARP/mEAQP/kEPXffBBffBBffBBffBBP9OGOPMWdkyQK8aeXM35pS8e8fP9QPKLZAIAdAKP9OAWAOPMBEZhDIoaLVcxORqlP9QPKLBKALAIAD/8QBBKK/4WLLUE97EUV978jJJJJBC8w9rHIDNAEC98gGLtMBCBHVABHOINAIAOPBBBGRAOCZFGWPBBBGdPMLVORXMpScxql358e8fGQCZP+sEGKCLP+rEPKLBAOPXBBJzBBJzBBJzBBJzPX/zL81z/zL81z/zL81z/zL81zAKPXIBBBIBBBIBBBIBBBP9QP/6EP/nEGKARAdPMBEDIWdQKZhoaky8aeGRCZP+rECZP+sEP/6EP/mEGdAdP/mEAKARCZP+sEP/6EP/mEGXAXP/mEAKAQCZP+rECZP+sEP/6EP/mEGQAQP/mEP/kEP/kEP/lEPXBBBBBBBBBBBBBBBBP+4EP/jEPXB/+fsB/+fsB/+fsB/+fsGKP/mEPXBBN0BBN0BBN0BBN0GRP/kEPXffBBffBBffBBffBBGMP9OAXAKP/mEARP/kECZP+rEP9QGXAQAKP/mEARP/kECZP+rEAdAKP/mEARP/kEAMP9OP9QGKPMBEZhDIoaLVcxORqlGRP5BAIPBLBPeB+t+J83IBAOCWFARP5EAIPBLBPeE+t+J83IBAWAXAKPMWdkyQK8aeXM35pS8e8fGKP5BAIPBLBPeD+t+J83IBAOCkFAKP5EAIPBLBPeI+t+J83IBAOCAFHOAVCLFGVAL6MBKKDNALAE9PMBAIAECIgGVCITGOFCBCAAO9r/8KBAIABALCITFGWAO/8QBBDNAVtMBAIAIPBLBGRAIPBLZGdPMLVORXMpScxql358e8fGQCZP+sEGKCLP+rEPKLAAIPXBBJzBBJzBBJzBBJzPX/zL81z/zL81z/zL81z/zL81zAKPXIBBBIBBBIBBBIBBBP9QP/6EP/nEGKARAdPMBEDIWdQKZhoaky8aeGRCZP+rECZP+sEP/6EP/mEGdAdP/mEAKARCZP+sEP/6EP/mEGXAXP/mEAKAQCZP+rECZP+sEP/6EP/mEGQAQP/mEP/kEP/kEP/lEPXBBBBBBBBBBBBBBBBP+4EP/jEPXB/+fsB/+fsB/+fsB/+fsGKP/mEPXBBN0BBN0BBN0BBN0GRP/kEPXffBBffBBffBBffBBGMP9OAXAKP/mEARP/kECZP+rEP9QGXAQAKP/mEARP/kECZP+rEAdAKP/mEARP/kEAMP9OP9QGKPMBEZhDIoaLVcxORqlGRP5BAIPBLAPeB+t+J83IBAIARP5EAIPBLAPeE+t+J83IWAIAXAKPMWdkyQK8aeXM35pS8e8fGKP5BAIPBLAPeD+t+J83IZAIAKP5EAIPBLAPeI+t+J83IkKAWAIAO/8QBBKK+pDDIUE978jJJJJBC/AB9rHIDNADCD4AE2GLC98gGVtMBCBHDABHEINAEAEPBBBGOCWP+rECWP+sEP/6EAOCEP+sEPXBBJzBBJzBBJzBBJzP+uEPXBBJfBBJfBBJfBBJfP9OP/mEPKBBAECZFHEADCLFGDAV6MBKKDNAVAL9PMBAIALCIgGDCDTGEvCBC/ABAE9r/8KBAIABAVCDTFGVAE/8QBBDNADtMBAIAIPBLBGOCWP+rECWP+sEP/6EAOCEP+sEPXBBJzBBJzBBJzBBJzP+uEPXBBJfBBJfBBJfBBJfP9OP/mEPKLBKAVAIAE/8QBBKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIKKKEBCJWKLZ9tBB"),$n=WebAssembly.instantiate(function(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;++n){var i=e.charCodeAt(n);t[n]=96<i?i-71:64<i?i-65:47<i?i+4:46<i?63:62}for(var r=0,n=0;n<e.length;++n)t[r++]=t[n]<60?ht[t[n]]:64*(t[n]-60)+t[++n];return t.buffer.slice(0,r)}(e),{}).then(function(e){(lt=e.instance).exports.__wasm_call_ctors()}),dt={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},ct={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},{ready:$n,supported:!0,decodeVertexBuffer:function(e,t,n,i,r){vt(lt.exports.meshopt_decodeVertexBuffer,e,t,n,i,lt.exports[dt[r]])},decodeIndexBuffer:function(e,t,n,i){vt(lt.exports.meshopt_decodeIndexBuffer,e,t,n,i)},decodeIndexSequence:function(e,t,n,i){vt(lt.exports.meshopt_decodeIndexSequence,e,t,n,i)},decodeGltfBuffer:function(e,t,n,i,r,o){vt(lt.exports[ct[r]],e,t,n,i,lt.exports[dt[o]])}}));function vt(e,t,n,i,r,o){var a=lt.exports.sbrk,s=n+3&-4,l=a(s*i),d=a(r.length),c=new Uint8Array(lt.exports.memory.buffer),e=(c.set(r,d),e(l,n,i,d,r.length));if(0==e&&o&&o(l,s,i),t.set(c.subarray(l,l+n*i)),a(l-a(0)),0!=e)throw new Error("Malformed buffer data: "+e)}function At(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager}var yt,k=function(e){(e=void 0===e?{}:e)&&(this.objectIdType=void 0!==e.objectIdType?e.objectIdType:1,this.materialIdType=void 0!==e.materialIdType?e.materialIdType:1,this.geomIdType=void 0!==e.geomIdType?e.geomIdType:1,this.instanceIdType=void 0!==e.instanceIdType?e.instanceIdType:1)},le=(k.prototype=Object.create(THREE.Loader.prototype),k.prototype.load=function(e,l,d,c,h,u){c=c||{};var t=l.lastIndexOf("."),t=l.substring(t+1,l.length),n=l.lastIndexOf("/"),p=l.substring(n+1,l.length),f=("drc"==t&&(c.compress=!1),this),m=void 0!==c.bufferlenth?c.bufferlenth:0,g=new XMLHttpRequest;Date.now(),performance.now().toFixed(0);if(g.onreadystatechange=function(){if(4===g.readyState){if(200===g.status||0===g.status){var e=new Uint8Array(g.response),r=(d&&d(p,e),!c.geometriesArray),o=r?c.ndsGeometriesArray:c.geometriesArray;if(c.compress){if(c.useWorker)return(s=c.worker||("."==_e.loadWorkerUrl.charAt(0)?new Worker(_e.loadWorkerUrl):(s=new Blob(['importScripts("'+_e.loadWorkerUrl+'")'],{type:"application/javascript"}),s=window.URL.createObjectURL(s),new Worker(s)))).onmessage=function(e){var e=e.data,t=new Ve.Stream(e.data),n=(t.offset=e.offset,f.readBIMBuffer(t,d,o,h),o.length);if(c.ndsGeometriesArray)for(var i=0;i<n;++i)r||c.ndsGeometriesArray[i].copy(c.geometriesArray[i]),c.ndsGeometriesArray[i].loaded=!0,c.ndsGeometriesArray[i].bufferChunkUrl=l;this.terminate(),u&&u()},n={data:e,bufferlenth:m},void(-1!==(t=navigator.userAgent.toLowerCase()).indexOf("chrome")||-1!==t.indexOf("firefox")?s.postMessage(n,[n.data.buffer]):s.postMessage(n));var t=new ArrayBuffer(m),n=((s=new Ve.Stream(e)).readInt32(),new Uint8Array(t)),t=new Ve.BIMStream(n,0,1),n=(M.decompress(s,s,t,t.data.length),new Ve.Stream(t.data)),i=(f.readBIMBuffer(n,d,o,h),o.length);if(c.ndsGeometriesArray)for(var a=0;a<i;++a)r||c.ndsGeometriesArray[a].copy(c.geometriesArray[a]),c.ndsGeometriesArray[a].loaded=!0,c.ndsGeometriesArray[a].bufferChunkUrl=l;u&&u()}else{c.useWorker&&c.worker&&c.worker.terminate();var s=new Ve.Stream(e);try{f.readBIMBufferDraco(s,d,o,h)}catch(e){d&&d(),h&&h()}}i=o.length;if(c.ndsGeometriesArray)for(a=0;a<i;++a)r||c.ndsGeometriesArray[a].copy(c.geometriesArray[a]),c.ndsGeometriesArray[a].loaded=!0,c.ndsGeometriesArray[a].bufferChunkUrl=l}else console.error("Couldn't load ["+l+"] ["+g.status+"]");u&&u()}else 3!==g.readyState&&g.readyState},g.open("GET",l,!0),e)for(var i in e)g.setRequestHeader(i,e[i]);g.responseType="arraybuffer",g.send(null)},k.prototype.parseBvh=function(e,t,n){e=new Ve.Stream(e);this.readBvh(e,t,n)},k.prototype.parseBrep=function(e,B,t){if(6<=e[0]){var n=new Ve.Stream(e);this.readBrep(n,B.brepManager,null)}else{B.brepManager.type=1;var i,r=function(e){for(var t=e.readByte(),n=(B.brepManager.version=t,e.readInt32()),i={},r=0,r=0;r<n;++r){var o={},a=e.readGuid();if(3<B.brepManager.version)if(e.readByte()){o.referenceBodyUuid=e.readGuid(),i[a]=o;continue}o.area=e.readFloat32(),o.volume=e.readFloat32();var s=e.readInt32();o.edgeGroups=[],i[a]=o;for(var l=0;l<s;++l)for(var d={},c=(o.edgeGroups.push(d),d.meshID=e.readGuid(),d.edges=[],void 0),c=2<t?e.readInt32():e.readInt16(),h=0;h<c;++h){var u={},p=(d.edges.push(u),e.readByte());0==p?(u.type="circle",u.center=[],u.center[0]=e.readFloat32(),u.center[1]=e.readFloat32(),u.center[2]=e.readFloat32(),u.radius=e.readFloat32()):1==p?u.type="line":2==p?u.type="ellipse":3==p?u.type="nurbs":4==p&&(u.type="other"),u.id=e.readInt32(),u.indexRange=[],u.indexRange[0]=e.readInt32(),u.indexRange[1]=e.readInt32(),u.length=e.readFloat32()}var f=e.readInt32();o.faceGroups=[];for(var m=0;m<f;++m)for(var g={},v=(o.faceGroups.push(g),g.meshID=e.readGuid(),g.faces=[],void 0),v=2<t?e.readInt32():e.readInt16(),A=0;A<v;++A){var y={},E=(g.faces.push(y),e.readByte());if(0==E?(y.type="plane",y.origin=[],y.origin[0]=e.readFloat32(),y.origin[1]=e.readFloat32(),y.origin[2]=e.readFloat32(),y.normal=[],y.normal[0]=e.readFloat32(),y.normal[1]=e.readFloat32(),y.normal[2]=e.readFloat32()):1==E?(y.type="cylinder",y.origin=[],y.origin[0]=e.readFloat32(),y.origin[1]=e.readFloat32(),y.origin[2]=e.readFloat32(),y.axis=[],y.axis[0]=e.readFloat32(),y.axis[1]=e.readFloat32(),y.axis[2]=e.readFloat32(),y.radius=e.readFloat32()):2==E?(y.type="cone",4<B.brepManager.version&&(y.origin=[],y.origin[0]=e.readFloat32(),y.origin[1]=e.readFloat32(),y.origin[2]=e.readFloat32(),y.axis=[],y.axis[0]=e.readFloat32(),y.axis[1]=e.readFloat32(),y.axis[2]=e.readFloat32(),y.radius=e.readFloat32())):3==E?y.type="sphere":4==E?y.type="torus":5==E?y.type="nurbs":6==E&&(y.type="other"),y.id=e.readInt32(),y.indexRange=[],y.indexRange[0]=e.readInt32(),y.indexRange[1]=e.readInt32(),y.area=e.readFloat32(),B.brepManager.version<4&&(y.perimeter=e.readFloat32()),1<t){var M=void 0,M=2<t?e.readInt32():e.readInt16();y.edgeIDS=[];for(var w,b=0;b<M;++b)B.brepManager.version<4?y.edgeIDS[b]=e.readInt32():(w={perimeter:e.readFloat32(),startID:e.readInt32()},y.edgeIDS[b]=w)}B.brepManager.version<4&&(0<(E=e.readGuid()).length&&(y.materialID=E),y.thick=e.readFloat32())}var x=e.readInt32(),I=[];x&&(o.vertices=I);for(var T=0;T<x;++T){var S={};I.push(S),S.id=e.readInt32(),S.coords=[],S.coords[0]=e.readFloat32(),S.coords[1]=e.readFloat32(),S.coords[2]=e.readFloat32()}}return i}(new Ve.Stream(e));for(i in r)B.brepManager.brepInfos[i]=r[i]}var o,a=!1,s=!1,l=!1,d=2===B.brepManager.type?B.brepManager.brepInfos.breps:B.brepManager.brepInfos;for(o in d)if(1e-9<d[o].volume&&(a=!0),1e-9<d[o].area&&(s=!0),d[o].faceGroups&&0<d[o].faceGroups.length&&(l=!0),1==s&&1==a&&1==l)break;return{BbodyVolume:a,BbodyArea:s,BfaceArea:l}},k.prototype.computeGeometryFaceNormal=function(e){if(e instanceof THREE.Geometry)for(var t=new THREE.Vector3,n=new THREE.Vector3,i=new THREE.Vector3,r=0,o=e.faces.length;r<o;r++){var a,s,l,d=e.faces[r];!0===d.normal.equals(i)&&(a=e.vertices[d.a],s=e.vertices[d.b],l=e.vertices[d.c],t.subVectors(l,s),n.subVectors(a,s),t.cross(n),t.normalize(),d.normal=t.clone())}},k.prototype.createModel=function(a,e){function t(){THREE.BufferGeometry.call(this),this.materials=[];var e,t,n=a.body.indices,i=a.body.vertices,r=a.body.normals,o=a.body.uvMaps;void 0!==o&&0<o.length&&(e=o[0].uv),void 0!==(o=a.body.attrMaps)&&0<o.length&&"Color"===o[0].name&&(t=o[0].attr),this.addAttribute("index",new THREE.BufferAttribute(n,1)),this.addAttribute("position",new THREE.BufferAttribute(i,3)),void 0!==r&&this.addAttribute("normal",new THREE.BufferAttribute(r,3)),void 0!==e&&this.addAttribute("uv",new THREE.BufferAttribute(e,2)),void 0!==t&&this.addAttribute("color",new THREE.BufferAttribute(t,4))}t.prototype=Object.create(THREE.BufferGeometry.prototype);var n=new t;n.computeOffsets(),void 0===n.attributes.normal&&n.computeVertexNormals(),e(n)},k.prototype.readTexture=function(e,t,n){var i=new Ve.Stream(e),r=(i.readInt32(),i.readInt32()),o=(r++,4096),a=[];if(2<n)for(var s=o*o,l=0;l<r;l++){for(var e=new Uint8Array(67108864),d=0,c=0;c<s;++c)e[d++]=0,e[d++]=0,e[d++]=0,e[d++]=i.readByte();var h=new THREE.DataTexture(e,o,o);a.push(h)}else for(s=2097152,a=[],l=0;l<r;l++){for(e=new Uint8Array(67108864),d=0,c=0;c<s;++c)for(var h=i.readTexture(),u=0;u<32;u++,d++)e[d]=h[u];h=new THREE.DataTexture(e,o,o);a.push(h)}return a},k.prototype.readBIMBuffer=function(e,t,n,i){e.readString();var r=e.readInt32();1===r?this.readBIMBufferVersion1(e,t,n,i):2===r?this.readBIMBufferVersion2(e,t,n,i):3===r?this.readBIMBufferVersion3(e,t,n,i):4===r?this.readBIMBufferVersion4(e,t,n,i):5===r?this.readBIMBufferVersion5(e,t,n,i):6===r?this.readBIMBufferVersion6(e,t,n,i):7===r?this.readBIMBufferVersion7(e,t,n,i):8===r?this.readBIMBufferVersion8(e,t,n,i):9===r&&this.readBIMBufferVersion9(e,t,n,i)},k.prototype.readBIMBufferDraco=function(e,F,N,j){for(var t,n,i,_,V,k,r=0,o=0,U=0,G=N.length,z=new Int8Array(G),W=new Int8Array(G),Y=!1,a=0;a<G;++a)t=N[a],z[a]=t.index?0:1,W[a]=t.index&&!t.index.array?1:0,W[a]&&(Y=!0);for(var s=[],a=0;a<G;++a){var l,d=e.readInt64(),c=(r+=8,new this.DracoModule.DecoderBuffer),h=(c.Init(e.data.slice(r,r+d),d),new this.DracoModule.Decoder),d=(r+=d,e.offset+=d,h.GetEncodedGeometryType(c)),X=(d==this.DracoModule.TRIANGULAR_MESH?(l=new this.DracoModule.Mesh,h.DecodeBufferToMesh(c,l)):d==this.DracoModule.POINT_CLOUD&&(l=new this.DracoModule.PointCloud,h.DecodeBufferToPointCloud(c,l)),this.DracoModule.destroy(c),[]);if(d==this.DracoModule.POINT_CLOUD){var Q=e.readInt32();r+=4;for(var u=0;u<Q/4;++u)X.push(e.readInt32()),r+=4}var Z,q,K,c=h.GetAttributeId(l,this.DracoModule.NORMAL),p=(-1!=c&&(p=h.GetAttribute(l,c),Z=new this.DracoModule.DracoFloat32Array,h.GetAttributeFloatForAllPoints(l,p,Z)),h.GetAttributeId(l,this.DracoModule.TEX_COORD)),f=(-1!=p&&(f=h.GetAttribute(l,p),q=new this.DracoModule.DracoFloat32Array,h.GetAttributeFloatForAllPoints(l,f,q)),h.GetAttributeId(l,this.DracoModule.COLOR)),J=(-1!=f&&(J=h.GetAttribute(l,f),K=new this.DracoModule.DracoFloat32Array,h.GetAttributeFloatForAllPoints(l,J,K)),h.GetAttributeId(l,this.DracoModule.POSITION)),m=h.GetAttribute(l,J),$=new this.DracoModule.DracoFloat32Array,m=(h.GetAttributeFloatForAllPoints(l,m,$),t=N[a],z[a]),g=W[a];if(d==this.DracoModule.TRIANGULAR_MESH){var v,A,y=l.num_points(),E=-1==h.GetAttributeId(l,this.DracoModule.COLOR)?0:y,M=-1==h.GetAttributeId(l,this.DracoModule.TEX_COORD)?0:y,w=-1==h.GetAttributeId(l,this.DracoModule.NORMAL)?0:y,ee=l.num_faces(),b=0<(E=0<E&&E!==y?0:E)?3:0,x=0<(M=0<M&&M!==y?0:M)?2:0,I=0<(w=0<w&&w!==y?0:w)?3:0,w=3+b+x+I,U=(m?(n=new Float32Array(y*w),i=new THREE.InterleavedBuffer(n,w),Me=new THREE.InterleavedBufferAttribute(i,3,0,!1),_=new THREE.InterleavedBufferAttribute(i,b,3,!1),V=new THREE.InterleavedBufferAttribute(i,x,3+b,!1),k=new THREE.InterleavedBufferAttribute(i,I,3+b+x,!1)):i=g?(t.attributes.position.data.array=new Float32Array(y*w),n=t.attributes.position.data.array,t.attributes.position.data):n=null,o=0,we=m?(L=new(y<=65535?Uint16Array:Uint32Array)(3*ee),new THREE.BufferAttribute(L,1)):g?(t.index.array=new(y<=65535?Uint16Array:Uint32Array)(3*ee),L=t.index.array,t.index):L=null,0),T=l.num_points(),S=-1==h.GetAttributeId(l,this.DracoModule.COLOR)?0:T,te=-1==h.GetAttributeId(l,this.DracoModule.TEX_COORD)?0:T,ne=-1==h.GetAttributeId(l,this.DracoModule.NORMAL)?0:T,B=l.num_faces(),ee=new THREE.Vector3,ie=new THREE.Vector3,P=0,C=3+(b=0<S?3:0)+(x=0<te?2:0)+(I=0<ne?3:0),re=!1,oe=!1;if(n?(0===E&&0<S&&(re=!0,C-=b),0===M&&0<te&&(oe=!0,C-=x),v=n,A=i):(A=m?(v=new Float32Array(T*C),new THREE.InterleavedBuffer(v,C)):g?(t.attributes.position.data.array=new Float32Array(T*C),v=t.attributes.position.data.array,t.attributes.position.data):v=null,U=o=0),0<T){for(u=0;u<T;++u)for(H=0;H<3;++H)v&&(v[o+u*C+H]=$.GetValue(3*u+H));m&&(t.attributes.position=n?Me:new THREE.InterleavedBufferAttribute(A,3,0,!1)),P+=3}if(0<S)if(re)for(u=0;u<S;++u)for(H=0;H<b;++H)e.readByte();else{for(u=0;u<S;++u)for(H=0;H<b;++H)v?v[o+u*C+P+H]=e.readByte()*(1/255):e.readByte();m&&(t.attributes.color=n?_:new THREE.InterleavedBufferAttribute(A,b,P,!1)),P+=b}if(0<te)if(oe)for(u=0;u<te;++u)for(H=0;H<x;++H)e.readFloat32();else{for(u=0;u<te;++u)for(H=0;H<x;++H)v?v[o+u*C+P+H]=e.readFloat32():e.readFloat32();m&&(t.attributes.uv=n?V:new THREE.InterleavedBufferAttribute(A,x,P,!1)),P+=x}if(0<ne){for(u=0;u<ne;++u)for(H=0;H<I;++H)v&&(v[o+u*C+P+H]=Z.GetValue(u*I+H));m&&(t.attributes.normal=n?k:new THREE.InterleavedBufferAttribute(A,I,P,!1))}if(0<B){for(var ae=3*B,se=0,le=(se=n?(O=L,D=we,o/C):(D=m?(O=new(T<=65535?Uint16Array:Uint32Array)(ae),new THREE.BufferAttribute(O,1)):g?(t.index.array=new(T<=65535?Uint16Array:Uint32Array)(ae),O=t.index.array,t.index):O=null,0),new this.DracoModule.DracoInt32Array),R=0;R<B;++R){h.GetFaceFromMesh(l,R,le);var de=3*R;O[de]=le.GetValue(0),O[1+de]=le.GetValue(1),O[2+de]=le.GetValue(2)}m&&(t.setIndex(D),t.drawRange.start=U,t.drawRange.count=ae)}n&&(U+=3*B,y*w<=(o+=T*C))&&(n=null,U=o=0)}else if(d==this.DracoModule.POINT_CLOUD){if(T=l.num_points(),B=X.length,m&&0<T&&s.push(t),0<T){var ae=3*T,ce=new Float32Array(ae);for(R=0;R<ae;++R)ce[R]=$.GetValue(R);m&&t.addAttribute("position",new THREE.BufferAttribute(ce,3))}if(0<B){for(var O=new(T<=65535?Uint16Array:Uint32Array)(B),u=0;u<X.length;++u)O[u]=X[u];if(!1===_e.OES_element_index_uint&&65535<T&&0===nLineIndexSorted){var he=new Uint16Array(B),ue=0,pe=0,fe=1,me=0;for(R=0;R<B-1;R+=2)O[R]<=65535*fe&&O[R+1]<=65535*fe?(pe+=2,he[R]=O[R]-ue,he[R+1]=O[R+1]-ue):(t.addDrawCall(me,pe,ue),me=R,pe=0,R-=2,ue+=65535*(++fe-1));1!==fe&&t.addDrawCall(me,pe,ue),t.setIndex(new THREE.BufferAttribute(he,1))}else m&&t.setIndex(new THREE.BufferAttribute(O,1))}}t.boundingBox||(ee.equals(ie)?(t.boundingBox=null,t.attributes.position&&t.computeBoundingBox()):t.boundingBox=new THREE.Box3(ee,ie)),this.DracoModule.destroy($),-1!=f&&this.DracoModule.destroy(K),-1!=c&&this.DracoModule.destroy(Z),-1!=p&&this.DracoModule.destroy(q),this.DracoModule.destroy(h),this.DracoModule.destroy(l),_e.OES_element_index_uint,t.boundingSphere=null,m?F&&F():g&&!n&&F&&F(t)}if(!Y&&0<s.length){for(var ge=0,ve=0,u=0,Ae=s.length;u<Ae;++u)ge+=s[u].attributes.position.array.length,ve+=s[u].index.array.length;for(var ye=ge/3,Ee=new Float32Array(ge),L=new(ye<=65535?Uint16Array:Uint32Array)(ve),Me=new THREE.BufferAttribute(Ee,3),we=new THREE.BufferAttribute(L,1),P=0,be=0,u=0,Ae=s.length;u<Ae;++u){for(var xe=s[u].attributes.position,D=s[u].index,se=(s[u].attributes.position=Me,s[u].setIndex(we),s[u].drawRange.start=be,s[u].drawRange.count=D.array.length,P/3),H=0,Ie=D.array.length;H<Ie;++H)L[be+H]=D.array[H]+se;be+=D.array.length;for(var Te=0,Se=xe.array.length;Te<Se;++Te)Ee[P+Te]=xe.array[Te];P+=xe.array.length}}j&&j()},k.prototype.readBIMBufferVersion7=function(e,F,N,j){for(var _=e.readInt32(),V=(e.readInt32(),e.readInt32()),k=[],t=(NDSWebViewer.Viewer.renderer.context,0);t<V;++t){var n=e.readInt32(),i=e.readInt32(),r=e.readInt32(),o=e.readInt32(),a=e.readInt32(),s=new THREE.BufferGeometry,U=0<i?3:0,G=0<r?2:0,l=0<o?3:0,d=n/3;if(0<n&&(n=new Float32Array(n),e.readArrayFloat32(n),s.addAttribute("position",new THREE.BufferAttribute(n,3,0,!1))),0<i){for(var c=new Uint8Array(i),z=0;z<d;++z)c[12]=e.readByte(),c[13]=e.readByte(),c[14]=e.readByte(),c[15]=255;s.addAttribute("color",new THREE.BufferAttribute(c,U,0,!0))}if(0<r&&(n=new Float32Array(r),e.readArrayFloat32(n),s.addAttribute("uv",new THREE.BufferAttribute(n,G,0,!1))),0<o){var h=new Float32Array(o);if(4===a)for(var u=0;u<d;++u)h[3*u+0]=e.readFloat32(),h[3*u+1]=e.readFloat32(),h[3*u+2]=e.readFloat32();else{var W=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),p=void 0,Y=1===a?1/255:1/65535;if(1===a)for(var f=0;f<d;++f){p=e.readByte(),--p;for(var m=0;m<l;++m){var X=e.readByte();h[3*f+m]=W[3*p+m]*X*Y}}else if(2===a)for(var g=0;g<d;++g){p=e.readByte(),--p;for(var v=0;v<l;++v)h[3*g+v]=W[3*p+v]*e.readInt16()*Y}}s.addAttribute("normal",new THREE.BufferAttribute(h,l,0,!1))}var A=e.readInt32(),y=e.readInt32(),E=e.readInt32();if(0<A){for(var Q=new(65535<d?Uint32Array:256<d?Uint16Array:Uint8Array)(A),M=0;M<A;++M)Q[M]=e.readInt32();s.setIndex(new THREE.BufferAttribute(Q,1)),s.attributes.normal}if(0<y){for(var w,b=new(65535<d?Uint32Array:256<d?Uint16Array:Uint8Array)(y),x=s.getAttribute("position"),I=new Float32Array(x.count),T=new THREE.Vector3,S=new THREE.Vector3,Z=new THREE.Vector3,q=0,B=0;B<y;B+=2)b[B]=e.readInt32(),b[B+1]=e.readInt32(),T.fromBufferAttribute(x,b[B]),S.fromBufferAttribute(x,b[B+1]),w=S.distanceTo(T),0!=B&&T.equals(Z)?(I[b[B]]=I[q],I[b[B+1]]=w+I[b[B]]):I[b[B+1]]=w,Z.copy(S),q=b[B+1];s.addAttribute("lineIndices",new THREE.BufferAttribute(b,1)),s.addAttribute("lineDistance",new THREE.BufferAttribute(I,1))}if(0<E){for(var K=new(65535<d?Uint32Array:256<d?Uint16Array:Uint8Array)(E),J=0;J<E;++J)K[J]=e.readInt32();s.addAttribute("pointIndices",new THREE.BufferAttribute(K,1))}k[t]=s}for(var P=new THREE.Vector3,C=new THREE.Vector3,$=0;$<_;++$){var R=e.readInt32(),O=(P.x=e.readFloat32(),P.y=e.readFloat32(),P.z=e.readFloat32(),C.x=e.readFloat32(),C.y=e.readFloat32(),C.z=e.readFloat32(),e.readInt32()),L=e.readInt32(),D=e.readInt32(),H=N[$],O=(H.geomType,k[O]);O.attributes.position&&(H.attributes.position=O.attributes.position),O.attributes.normal&&(H.attributes.normal=O.attributes.normal),O.attributes.color&&(H.attributes.color=O.attributes.color),O.attributes.lineDistance&&(H.attributes.lineDistance=O.attributes.lineDistance),O.uv,O.normal,O.validEntities,0===R?(H.isTriangles=!0,O.index?(H.setIndex(O.index),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)):1===R?(H.isLines=!0,O.attributes.lineIndices?(H.setIndex(O.attributes.lineIndices),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)):2===R&&(H.isPoints=!0,O.attributes.pointIndices?(H.setIndex(O.attributes.pointIndices),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)),(!H.boundingBox||H.boundingBox.min.x>H.boundingBox.max.x||H.boundingBox.min.y>H.boundingBox.max.y||H.boundingBox.min.z>H.boundingBox.max.z)&&P.equals(C)?(H.boundingBox=null,H.attributes.position&&H.computeBoundingBox()):H.boundingBox.set(P,C),0===R&&H.attributes.normal,H.boundingSphere=null,F&&F()}j&&j()},k.prototype.readBIMBufferVersion8=function(e,F,N,j){for(var _=e.readInt32(),V=(e.readInt32(),e.readInt32()),k=[],t=(NDSWebViewer.Viewer.renderer.context,0);t<V;++t){var n=e.readInt32(),i=e.readInt32(),r=e.readInt32(),U=e.readInt32(),o=e.readInt32(),a=new THREE.BufferGeometry,s=0<i?3:0,l=0<r?2:0,d=0<U?3:0,c=n/3,h=3+s+l+d,u=null,G=null,z=null,W=null,Y=null,u=new Float32Array(c*h),p=new THREE.InterleavedBuffer(u,h),f=0,G=new THREE.InterleavedBufferAttribute(p,3,f,!1);if(f+=3,0<s&&(z=new THREE.InterleavedBufferAttribute(p,s,f,!1),f+=s),0<l&&(W=new THREE.InterleavedBufferAttribute(p,l,f,!1),f+=l),0<d&&(Y=new THREE.InterleavedBufferAttribute(p,d,f,!1),f+=d),0<n)if(u){for(var X=0;X<c;++X)for(var Q=0;Q<3;++Q)u[X*h+Q]=e.readFloat32();a.attributes.position=G}else{p=new Float32Array(n);e.readArrayFloat32(p),a.addAttribute("position",new THREE.BufferAttribute(p,3,0,!1))}if(0<i)if(u){for(var m=0;m<c;++m)u[m*h+3]=e.readByte(),u[m*h+3+1]=e.readByte(),u[m*h+3+2]=e.readByte();a.attributes.color=z}else{for(var g=new Uint8Array(i),Z=0;Z<c;++Z)g[12]=e.readByte(),g[13]=e.readByte(),g[14]=e.readByte(),g[15]=255;a.addAttribute("color",new THREE.BufferAttribute(g,s,0,!0))}if(0<r)if(u){for(var q=0;q<c;++q)for(var K=0;K<l;++K)u[q*h+3+s+K]=e.readFloat32();a.attributes.uv=W}else{f=new Float32Array(r);e.readArrayFloat32(f),a.addAttribute("uv",new THREE.BufferAttribute(f,l,0,!1))}if(0<U)if(u){if(4===o)for(var v=0;v<c;++v)u[v*h+3+s+l]=e.readFloat32(),u[v*h+3+s+l+1]=e.readFloat32(),u[v*h+3+s+l+2]=e.readFloat32();else{var J=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),A=void 0,$=1===o?1/255:1/65535;if(1===o)for(var ee=0;ee<c;++ee){A=e.readByte(),--A;for(var y=0;y<d;++y){var te=e.readByte();u[ee*h+3+s+l+y]=J[3*A+y]*te*$}}else if(2===o)for(var ne=0;ne<c;++ne){A=e.readByte(),--A;for(var E=0;E<d;++E)u[ne*h+3+s+l+E]=J[3*A+E]*e.readInt16()*$}}a.attributes.normal=Y}else{var M=new Float32Array(U);if(4===o)for(var w=0;w<c;++w)M[3*w+0]=e.readFloat32(),M[3*w+1]=e.readFloat32(),M[3*w+2]=e.readFloat32();else{var ie=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),b=void 0,re=1===o?1/255:1/65535;if(1===o)for(var oe=0;oe<c;++oe){b=e.readByte(),--b;for(var x=0;x<d;++x){var ae=e.readByte();M[3*oe+x]=ie[3*b+x]*ae*re}}else if(2===o)for(var se=0;se<c;++se){b=e.readByte(),--b;for(var I=0;I<d;++I)M[3*se+I]=ie[3*b+I]*e.readInt16()*re}}a.addAttribute("normal",new THREE.BufferAttribute(M,d,0,!1))}var le=e.readInt32(),de=e.readInt32(),ce=e.readInt32();if(0<le){for(var he=new(65535<c?Uint32Array:256<c?Uint16Array:Uint8Array)(le),ue=0;ue<le;++ue)he[ue]=65535<c?e.readInt32():256<c?e.readUInt16():e.readUInt8();a.setIndex(new THREE.BufferAttribute(he,1)),a.attributes.normal}if(0<de){for(var pe,T=new(65535<c?Uint32Array:256<c?Uint16Array:Uint8Array)(de),fe=a.getAttribute("position"),S=new Float32Array(fe.count),me=new THREE.Vector3,ge=new THREE.Vector3,ve=new THREE.Vector3,Ae=0,B=0;B<de;B+=2)T[B]=65535<c?e.readInt32():256<c?e.readUInt16():e.readUInt8(),T[B+1]=65535<c?e.readInt32():256<c?e.readUInt16():e.readUInt8(),me.fromBufferAttribute(fe,T[B]),ge.fromBufferAttribute(fe,T[B+1]),pe=ge.distanceTo(me),0!=B&&me.equals(ve)?(S[T[B]]=S[Ae],S[T[B+1]]=pe+S[T[B]]):S[T[B+1]]=pe,ve.copy(ge),Ae=T[B+1];a.addAttribute("lineIndices",new THREE.BufferAttribute(T,1)),a.addAttribute("lineDistance",new THREE.BufferAttribute(S,1))}if(0<ce){for(var ye=new(65535<c?Uint32Array:256<c?Uint16Array:Uint8Array)(ce),Ee=0;Ee<ce;++Ee)ye[Ee]=65535<c?e.readInt32():256<c?e.readUInt16():e.readUInt8();a.addAttribute("pointIndices",new THREE.BufferAttribute(ye,1))}k[t]=a}for(var P=new THREE.Vector3,C=new THREE.Vector3,Me=0;Me<_;++Me){var R=e.readInt32(),O=(P.x=e.readFloat32(),P.y=e.readFloat32(),P.z=e.readFloat32(),C.x=e.readFloat32(),C.y=e.readFloat32(),C.z=e.readFloat32(),e.readInt32()),L=e.readInt32(),D=e.readInt32(),H=N[Me],O=(H.geomType,k[O]);O.attributes.position&&(H.attributes.position=O.attributes.position),O.attributes.normal&&(H.attributes.normal=O.attributes.normal),O.attributes.color&&(H.attributes.color=O.attributes.color),O.attributes.lineDistance&&(H.attributes.lineDistance=O.attributes.lineDistance),O.uv,O.normal,O.validEntities,0===R?(H.isTriangles=!0,O.index?(H.setIndex(O.index),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)):1===R?(H.isLines=!0,O.attributes.lineIndices?(H.setIndex(O.attributes.lineIndices),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)):2===R&&(H.isPoints=!0,O.attributes.pointIndices?(H.setIndex(O.attributes.pointIndices),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)),(!H.boundingBox||H.boundingBox.min.x>H.boundingBox.max.x||H.boundingBox.min.y>H.boundingBox.max.y||H.boundingBox.min.z>H.boundingBox.max.z)&&P.equals(C)?(H.boundingBox=null,H.attributes.position&&H.computeBoundingBox()):H.boundingBox.set(P,C),0===R&&H.attributes.normal,H.boundingSphere=null,F&&F()}j&&j()},k.prototype.readBIMBufferVersion9=function(e,F,N,j){for(var t,n,i,r,o,a,s=gt,_=e.readInt32(),V=(e.readInt32(),e.readInt32()),k=[],l=(NDSWebViewer.Viewer.renderer.context,0);l<V;++l){var d=e.readInt32(),c=e.readInt32(),h=e.readInt32(),u=e.readInt32(),p=e.readInt32(),f=new THREE.BufferGeometry;0<c&&(e.readFloat32(),e.readFloat32(),e.readFloat32(),c=new Float32Array(3*d),e.readArrayFloat32(c),f.addAttribute("position",new THREE.BufferAttribute(c,3,0,!1))),0<h&&(c=new Uint8Array(h),e.readArrayUint8(c),h=new Uint8Array(3*d),s.decodeVertexBuffer(h,d,3,c),f.addAttribute("color",new THREE.BufferAttribute(h,3,0,!0))),0<u&&(c=new Float32Array(2*d),e.readArrayFloat32(c),f.addAttribute("uv",new THREE.BufferAttribute(c,2,0,!1)));if(0<p){for(var U=new Int16Array(2*d),G=(e.readArrayInt16(U),new Float32Array(3*d)),m=0;m<d;++m)n=G,a=o=r=void 0,r=(t=U)[2*(i=m)+0]/2047,t=t[2*i+1]/2047,o=1-(Math.abs(r)+Math.abs(t)),a=Math.max(-o,0),r+=0<=r?-a:a,t+=0<=t?-a:a,a=Math.sqrt(r*r+t*t+o*o),n[3*i+0]=r/a,n[3*i+1]=t/a,n[3*i+2]=o/a;f.addAttribute("normal",new THREE.BufferAttribute(G,3,0,!1))}h=e.readInt32(),u=e.readInt32(),c=e.readInt32();if(0<h){var g=e.readInt32(),p=new Uint8Array(h),h=(e.readArrayUint8(p),new ArrayBuffer(4*g)),v=(s.decodeIndexBuffer(new Uint8Array(h),g,4,p),new Uint32Array(h,0,g)),A=v;if(!(65535<d))if(256<=d)for(var A=new Uint16Array(g),y=0;y<g;++y)A[y]=v[y];else{A=new Uint8Array(g);for(var E=0;E<g;++E)A[E]=v[E]}f.setIndex(new THREE.BufferAttribute(A,1)),f.attributes.normal}if(0<u){var M=e.readInt32(),p=new Uint8Array(u),h=(e.readArrayUint8(p),new ArrayBuffer(4*M)),w=(s.decodeIndexSequence(new Uint8Array(h),M,4,p),new Uint32Array(h,0,M)),b=w;if(!(65535<d))if(256<=d)for(var b=new Uint16Array(M),x=0;x<M;++x)b[x]=w[x];else{b=new Uint8Array(M);for(var I=0;I<M;++I)b[I]=w[I]}for(var T,z=f.getAttribute("position"),S=new Float32Array(z.count),W=new THREE.Vector3,Y=new THREE.Vector3,X=new THREE.Vector3,Q=0,B=0;B<M;B+=2)W.fromBufferAttribute(z,b[B]),Y.fromBufferAttribute(z,b[B+1]),T=Y.distanceTo(W),0!=B&&W.equals(X)?(S[b[B]]=S[Q],S[b[B+1]]=T+S[b[B]]):S[b[B+1]]=T,X.copy(Y),Q=b[B+1];f.addAttribute("lineIndices",new THREE.BufferAttribute(b,1)),f.addAttribute("lineDistance",new THREE.BufferAttribute(S,1))}if(0<c){for(var Z=e.readInt32(),q=void 0,q=new(65535<d?Uint32Array:256<=d?Uint16Array:Uint8Array)(Z),K=0;K<Z;K++)q[K]=e.readInt32();f.addAttribute("pointIndices",new THREE.BufferAttribute(q,1))}k[l]=f}for(var P=new THREE.Vector3,C=new THREE.Vector3,J=0;J<_;++J){var R=e.readInt32(),O=(P.x=e.readFloat32(),P.y=e.readFloat32(),P.z=e.readFloat32(),C.x=e.readFloat32(),C.y=e.readFloat32(),C.z=e.readFloat32(),e.readInt32()),L=e.readInt32(),D=e.readInt32(),H=N[J],O=(H.geomType,k[O]);H.id=O.id,O.attributes.position&&(H.attributes.position=O.attributes.position),O.attributes.normal&&(H.attributes.normal=O.attributes.normal),O.attributes.color&&(H.attributes.color=O.attributes.color),O.attributes.lineDistance&&(H.attributes.lineDistance=O.attributes.lineDistance),O.attributes.uv&&(H.attributes.uv=O.attributes.uv),O.normal,O.validEntities,0===R?(H.isTriangles=!0,O.index?(H.setIndex(O.index),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)):1===R?(H.isLines=!0,O.attributes.lineIndices?(H.setIndex(O.attributes.lineIndices),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)):2===R&&(H.isPoints=!0,O.attributes.pointIndices?(H.setIndex(O.attributes.pointIndices),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)),(!H.boundingBox||H.boundingBox.min.x>H.boundingBox.max.x||H.boundingBox.min.y>H.boundingBox.max.y||H.boundingBox.min.z>H.boundingBox.max.z)&&P.equals(C)?(H.boundingBox=null,H.attributes.position&&H.computeBoundingBox()):H.boundingBox.set(P,C),0===R&&H.attributes.normal,H.boundingSphere=null,F&&F()}j&&j()},k.prototype.readBIMBufferVersion7_=function(e,F,N,j){for(var _=e.readInt32(),V=(e.readInt32(),e.readInt32()),k=[],t=0;t<V;++t){var n=e.readInt32(),i=e.readInt32(),r=e.readInt32(),o=e.readInt32(),a=e.readInt32(),s=e.readInt32(),l={},d=0<i?3:0,c=0<r?2:0,h=0<o?3:0,U=0<a?1:0,u=n/3,p=new ArrayBuffer(4*n+4*i/3+4*r+4*o+4*a),f=3+(0<d?1:0)+c+h+U,G=f,z=4*f,m=new Float32Array(p),g=new Uint8Array(p),W=new Int32Array(p),p=new THREE.InterleavedBuffer(m,f),Y=new THREE.InterleavedBuffer(z),G=new THREE.InterleavedBuffer(W,G);if(0<n){for(var v=0;v<u;++v){var A=v*f;m[0+A]=e.readFloat32(),m[1+A]=e.readFloat32(),m[2+A]=e.readFloat32()}l.position=new THREE.InterleavedBufferAttribute(p,3,0,!1)}if(0<i){for(var y=0;y<u;++y){var E=y*z+12;g[E]=e.readByte(),g[1+E]=e.readByte(),g[2+E]=e.readByte(),g[3+E]=255}l.color=new THREE.InterleavedBufferAttribute(Y,d,12,!0)}if(0<r){for(var X=3+(0<d?1:0),M=0;M<u;++M){var Q=M*f+X;m[Q]=e.readFloat32(),m[1+Q]=e.readFloat32()}l.uv=new THREE.InterleavedBufferAttribute(p,c,X,!1)}if(0<o){var w=3+(0<d?1:0)+c;if(4===s)for(var b=0;b<u;++b){var x=b*f+w;m[x]=e.readFloat32(),m[1+x]=e.readFloat32(),m[2+x]=e.readFloat32()}else{var Z=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),I=void 0,q=1===s?1/255:1/65535;if(1===s)for(var T=0;T<u;++T){I=e.readByte(),--I;for(var K=T*f+w,S=0;S<h;++S){var J=e.readByte();m[K+S]=Z[3*I+S]*J*q}}else if(2===s)for(var $=0;$<u;++$){I=e.readByte(),--I;for(var ee=$*f+w,B=0;B<h;++B)m[ee+B]=Z[3*I+B]*e.readInt16()*q}}l.normal=new THREE.InterleavedBufferAttribute(p,h,w,!1)}if(0<a){for(var te=3+(0<d?1:0)+c+h,ne=0;ne<u;++ne)W[te]=e.readInt32();l.validEntities=new THREE.InterleavedBufferAttribute(G,U,te,!1)}var ie=e.readInt32(),re=e.readInt32(),oe=e.readInt32();if(0<ie){l.faceIndices=new(65535<u?Uint32Array:256<u?Uint16Array:Uint8Array)(ie);for(var ae=0;ae<ie;++ae)l.faceIndices[ae]=e.readInt32()}if(0<re){l.lineIndices=new(65535<u?Uint32Array:256<u?Uint16Array:Uint8Array)(re);for(var se=0;se<re;++se)l.lineIndices[se]=e.readInt32()}if(0<oe){l.pointIndices=new(65535<u?Uint32Array:256<u?Uint16Array:Uint8Array)(oe);for(var le=0;le<oe;++le)l.pointIndices[le]=e.readInt32()}k[t]=l}for(var P=new THREE.Vector3,C=new THREE.Vector3,de=0;de<_;++de){var R=e.readInt32(),O=(P.x=e.readFloat32(),P.y=e.readFloat32(),P.z=e.readFloat32(),C.x=e.readFloat32(),C.y=e.readFloat32(),C.z=e.readFloat32(),e.readInt32()),L=e.readInt32(),D=e.readInt32(),H=N[de],O=k[O];O.position&&(H.attributes.position=O.position),O.color&&(H.attributes.color=O.color),O.uv&&(H.attributes.uv=O.uv),O.normal&&(H.attributes.normal=O.normal),O.validEntities&&(H.attributes.validEntity=O.validEntities),0===R?O.faceIndices?(H.setIndex(new THREE.BufferAttribute(O.faceIndices,1)),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D):1===R?O.lineIndices?(H.setIndex(new THREE.BufferAttribute(O.lineIndices,1)),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D):2===R&&(O.pointIndices?(H.setIndex(new THREE.BufferAttribute(O.pointIndices,1)),H.drawRange.start=L,H.drawRange.count=D):(H.drawRange.start=-L,H.drawRange.count=-D)),H.boundingBox||(P.equals(C)?(H.boundingBox=null,H.attributes.position&&H.computeBoundingBox()):H.boundingBox=new THREE.Box3(P,C)),0===R&&null==H.attributes.normal&&H.computeVertexNormals(),H.boundingSphere=null,F&&F()}j&&j()},k.prototype.readBIMBufferVersion6=function(e,F,N,j){for(var t,n,i,r,o,a,s,l,d,_,V,k,U=e.readInt32(),G=e.readInt32(),z=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),c=0,h=0,W=new Int8Array(U),Y=new Int8Array(U),X=!1,u=0;u<U;++u)f=N[u],W[u]=f.index?0:1,Y[u]=f.index&&!f.index.array?1:0,Y[u]&&(X=!0);for(var p=[],u=0;u<U;++u){var f=N[u],Q=e.readInt32(),m=W[u],Z=Y[u];if(100<=Q){var g=e.readInt32(),q=e.readInt32(),K=e.readInt32(),v=e.readInt32(),A=e.readInt32(),v=(y=3)+(E=0<(q=0<q&&q!==g?0:q)?3:0)+(M=0<(K=0<K&&K!==g?0:K)?2:0)+(w=0<(v=0<v&&v!==g?0:v)?3:0);m?(l=new Float32Array(g*v),d=new THREE.InterleavedBuffer(l,v),we=new THREE.InterleavedBufferAttribute(d,y,0,!1),_=new THREE.InterleavedBufferAttribute(d,E,y,!1),V=new THREE.InterleavedBufferAttribute(d,M,y+E,!1),k=new THREE.InterleavedBufferAttribute(d,w,y+E+M,!1)):d=Z?(f.attributes.position.data.array=new Float32Array(g*v),l=f.attributes.position.data.array,f.attributes.position.data):l=null,c=0,xe=m?(L=new(g<=65535?Uint16Array:Uint32Array)(3*A),new THREE.BufferAttribute(L,1)):Z?(f.index.array=new(g<=65535?Uint16Array:Uint32Array)(3*A),L=f.index.array,f.index):L=null,h=0,--u}else{if(0===Q){t=e.readInt32(),n=e.readInt32(),i=e.readInt32(),r=e.readInt32(),o=e.readInt32(),A=e.readInt32(),a=new THREE.Vector3,s=new THREE.Vector3,a.x=e.readFloat32(),a.y=e.readFloat32(),a.z=e.readFloat32(),s.x=e.readFloat32(),s.y=e.readFloat32(),s.z=e.readFloat32();var y,E,M,w,b,J,x=0,I=(y=3)+(E=0<n?3:0)+(M=0<i?2:0)+(w=0<r?3:0),$=!1,ee=!1;if(l?(0===q&&0<n&&($=!0,I-=E),0===K&&0<i&&(ee=!0,I-=M),b=l,J=d):(J=m?(b=new Float32Array(t*I),new THREE.InterleavedBuffer(b,I)):Z?(f.attributes.position.data.array=new Float32Array(t*I),b=f.attributes.position.data.array,f.attributes.position.data):b=null,h=c=0),0<t){for(O=0;O<t;++O)for(H=0;H<y;++H)b?b[c+O*I+H]=e.readFloat32():e.readFloat32();m&&(f.attributes.position=l?we:new THREE.InterleavedBufferAttribute(J,y,0,!1)),x+=y}if(0<n)if($)for(O=0;O<n;++O)for(H=0;H<E;++H)e.readByte();else{var te=1/255;for(O=0;O<n;++O)for(H=0;H<E;++H)b?b[c+O*I+x+H]=e.readByte()*te:e.readByte();m&&(f.attributes.color=l?_:new THREE.InterleavedBufferAttribute(J,E,x,!1)),x+=E}if(0<i)if(ee)for(O=0;O<i;++O)for(H=0;H<M;++H)e.readFloat32();else{for(O=0;O<i;++O)for(H=0;H<M;++H)b?b[c+O*I+x+H]=e.readFloat32():e.readFloat32();m&&(f.attributes.uv=l?V:new THREE.InterleavedBufferAttribute(J,M,x,!1)),x+=M}if(0<r){if(4===A)for(C=0;C<r;++C)for(H=0;H<w;++H)b?b[c+O*I+x+H]=e.readFloat32():e.readFloat32();else{var ne,te=1===A?1/255:1/65535;if(1===A)for(O=0;O<r;++O)for(ne=e.readByte(),--ne,H=0;H<w;++H){var ie=e.readByte();b&&(b[c+O*I+x+H]=z[3*ne+H]*ie*te)}else if(2===A)for(O=0;O<r;++O)for(ne=e.readByte(),--ne,H=0;H<w;++H)b&&(b[c+O*I+x+H]=z[3*ne+H]*e.readInt16()*te)}m&&(f.attributes.normal=l?k:new THREE.InterleavedBufferAttribute(J,w,x,!1))}if(0<o){var T=e.readInt32(),S=3*o,re=0;if(re=l?(R=L,D=xe,c/I):(D=m?(R=new(t<=65535?Uint16Array:Uint32Array)(S),new THREE.BufferAttribute(R,1)):Z?(f.index.array=new(t<=65535?Uint16Array:Uint32Array)(S),R=f.index.array,f.index):R=null,0),1===T)for(C=0;C<S;++C)R?R[h+C]=e.readByte():e.readByte();else if(2===T)for(C=0;C<S;++C)R?R[h+C]=e.readInt16():e.readInt16();else if(4===T)for(C=0;C<S;++C)R?R[h+C]=e.readInt32():e.readInt32();if(R){Ve.restoreIndices2(R,h,S);for(var B=0;B<S;++B)R[h+B]+=re}m&&(f.setIndex(D),f.drawRange.start=h,f.drawRange.count=S)}l&&(h+=3*o,g*v<=(c+=t*I))&&(l=null,h=c=0)}else if(1===Q){if(t=e.readInt32(),o=e.readInt32(),m&&0<t&&p.push(f),a=new THREE.Vector3,s=new THREE.Vector3,a.x=e.readFloat32(),a.y=e.readFloat32(),a.z=e.readFloat32(),s.x=e.readFloat32(),s.y=e.readFloat32(),s.z=e.readFloat32(),0<t){for(var oe,S=3*t,P=new Float32Array(S),ae=new Float32Array(t),se=new THREE.Vector3,le=new THREE.Vector3,de=!1,C=0;C<t;++C)P[3*C]=e.readFloat32(),P[3*C+1]=e.readFloat32(),P[3*C+2]=e.readFloat32(),le.copy(se),se.set(P[3*C],P[3*C+1],P[3*C+2]),0!=C&&(C+1)%2!=0&&P[3*C]==P[3*(C-1)]&&P[3*C+1]==P[3*(C-1)+1]&&P[3*C+2]==P[3*(C-1)+2]&&(ae[C]=ae[C-1],de=!0),(C+1)%2==0&&(oe=se.distanceTo(le),de?(ae[C]=oe+ae[C-1],de=!1):ae[C]=oe);"TextBufferGeometry"!=f.type&&m&&(f.addAttribute("position",new THREE.BufferAttribute(P,3)),f.addAttribute("lineDistance",new THREE.BufferAttribute(ae,1)))}if(0<o){T=e.readInt32();var R=new(t<=65535?Uint16Array:Uint32Array)(o);if(1===T)for(C=0;C<o;++C)R[C]=e.readByte();else if(2===T)for(C=0;C<o;++C)R[C]=e.readInt16();else if(4===T)for(C=0;C<o;++C)R[C]=e.readInt32();if(0===G)for(C=1;C<o;++C)R[C]+=R[C-1];if(!1===_e.OES_element_index_uint&&65535<t&&0===G){var ce=new Uint16Array(o),he=0,ue=0,pe=1,fe=0;for(C=0;C<o-1;C+=2)R[C]<=65535*pe&&R[C+1]<=65535*pe?(ue+=2,ce[C]=R[C]-he,ce[C+1]=R[C+1]-he):(f.addDrawCall(fe,ue,he),fe=C,ue=0,C-=2,he+=65535*(++pe-1));1!==pe&&f.addDrawCall(fe,ue,he),f.setIndex(new THREE.BufferAttribute(ce,1))}else m&&f.setIndex(new THREE.BufferAttribute(R,1))}}f.boundingBox||(a.equals(s)?(f.boundingBox=null,f.attributes.position&&f.computeBoundingBox()):f.boundingBox=new THREE.Box3(a,s)),0===Q&&null==f.attributes.normal&&f.computeVertexNormals(),!1===_e.OES_element_index_uint&&0===Q&&65535<t&&f.computeOffsets(),f.boundingSphere=null,m&&F?F():Z&&!l&&F&&F(f)}}if(!X&&0<p.length){for(var me=0,ge=0,ve=0,O=0,Ae=p.length;O<Ae;++O)me+=p[O].attributes.position.array.length,ve+=p[O].attributes.lineDistance.array.length,ge+=p[O].index.array.length;for(var ye=me/3,Ee=new Float32Array(me),Me=new Float32Array(ve),L=new(ye<=65535?Uint16Array:Uint32Array)(ge),we=new THREE.BufferAttribute(Ee,3),be=new THREE.BufferAttribute(Me,1),xe=new THREE.BufferAttribute(L,1),x=0,Ie=0,Te=0,O=0,Ae=p.length;O<Ae;++O){for(var Se=p[O].attributes.position,D=p[O].index,Be=p[O].attributes.lineDistance,re=(p[O].attributes.position=we,p[O].attributes.lineDistance=be,p[O].setIndex(xe),p[O].drawRange.start=Ie,p[O].drawRange.count=D.array.length,x/3),H=0,Pe=D.array.length;H<Pe;++H)L[Ie+H]=D.array[H]+re;Ie+=D.array.length;for(var B=0,Ce=Se.array.length;B<Ce;++B)Ee[x+B]=Se.array[B];x+=Se.array.length;for(B=0,Ce=Be.array.length;B<Ce;++B)Me[Te+B]=Be.array[B];Te+=Be.array.length}}j&&j()},k.prototype.readBIMBufferVersion5=function(e,F,N,j){for(var _,t,n,i,r,o,a,s,V=e.readInt32(),k=e.readInt32(),U=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),G=new Int8Array(V),z=new Int8Array(V),W=!1,Y=0,l=0;l<N.length;++l)(t=N[l])&&t.isRawMeshEdge||(t?(G[Y]=t.index?0:1,z[Y]=t.index&&!t.index.array?1:0,z[Y]&&(W=!0)):(G[Y]=0,z[Y]=0),Y++);for(var d,X,Q,c,h,u=[],Z=0,l=0;l<V;++l){t=N[Z],Z++;var p=e.readInt32(),f=G[l],q=z[l];if(0===p){n=e.readInt32(),i=e.readInt32(),r=e.readInt32(),o=e.readInt32(),X=e.readInt32(),R=e.readInt32(),Q=e.readInt32(),a=e.readInt32(),s=e.readInt32(),c=new THREE.Vector3,h=new THREE.Vector3,c.x=e.readFloat32(),c.y=e.readFloat32(),c.z=e.readFloat32(),h.x=e.readFloat32(),h.y=e.readFloat32(),h.z=e.readFloat32();var m=0,g=(S=3)+(B=0<i?3:0)+(P=0<r?2:0)+(C=0<o?3:0);if(x=f?(b=new Float32Array(n*g),new THREE.InterleavedBuffer(b,g)):q?(t.attributes.position.data.array=new Float32Array(n*g),b=t.attributes.position.data.array,t.attributes.position.data):b=null,0<n){for(L=0;L<n;++L)for(H=0;H<S;++H)b?b[0+L*g+H]=e.readFloat32():e.readFloat32();f&&(t.attributes.position=new THREE.InterleavedBufferAttribute(x,S,0,!1)),m+=S}if(0<i){var v=1/255;for(L=0;L<i;++L)for(H=0;H<B;++H)b?b[0+L*g+m+H]=e.readByte()*v:e.readByte();f&&(t.attributes.color=new THREE.InterleavedBufferAttribute(x,B,m,!1)),m+=B}if(0<r){for(L=0;L<r;++L)for(H=0;H<P;++H)b?b[0+L*g+m+H]=e.readFloat32():e.readFloat32();f&&(t.attributes.uv=new THREE.InterleavedBufferAttribute(x,P,m,!1)),m+=P}if(0<o){if(4===s)for(A=0;A<o;++A)for(H=0;H<C;++H)b?b[0+L*g+m+H]=e.readFloat32():e.readFloat32();else{v=1===s?1/255:1/65535;if(1===s)for(L=0;L<o;++L)for(T=e.readByte(),--T,H=0;H<C;++H){var K=e.readByte();b&&(b[0+L*g+m+H]=U[3*T+H]*K*v)}else if(2===s)for(L=0;L<o;++L)for(T=e.readByte(),--T,H=0;H<C;++H)b&&(b[0+L*g+m+H]=U[3*T+H]*e.readInt16()*v)}f&&(t.attributes.normal=new THREE.InterleavedBufferAttribute(x,C,m,!1))}if(0<R){for(var J=R*X,$=new Float32Array(J),A=0;A<J;A++)$[A]=e.readInt32();t.addAttribute("skinIndex",new THREE.BufferAttribute($,X))}if(0<Q){var ee=Q*X,te=new Float32Array(ee);for(A=0;A<ee;A++)te[A]=e.readFloat32();t.addAttribute("skinWeight",new THREE.BufferAttribute(te,X))}if(0<a){d=e.readInt32();var y=3*a,ne=0;if(D=f?(M=new(n<=65535?Uint16Array:Uint32Array)(y),new THREE.BufferAttribute(M,1)):q?(t.index.array=new(n<=65535?Uint16Array:Uint32Array)(y),M=t.index.array,t.index):M=null,ne=0,1===d)for(A=0;A<y;++A)M?M[0+A]=e.readByte():e.readByte();else if(2===d)for(A=0;A<y;++A)M?M[0+A]=e.readInt16():e.readInt16();else if(4===d)for(A=0;A<y;++A)M?M[0+A]=e.readInt32():e.readInt32();if(M){Ve.restoreIndices2(M,0,y);for(var E=0;E<y;++E)M[0+E]+=ne}f&&(t.setIndex(D),t.drawRange.start=0,t.drawRange.count=y)}}else if(1===p){if(n=e.readInt32(),w=e.readInt32(),f&&0<n&&u.push(t),c=new THREE.Vector3,h=new THREE.Vector3,c.x=e.readFloat32(),c.y=e.readFloat32(),c.z=e.readFloat32(),h.x=e.readFloat32(),h.y=e.readFloat32(),h.z=e.readFloat32(),0<n){var y=3*n,ie=new Float32Array(y);for(A=0;A<y;++A)ie[A]=e.readFloat32();"TextBufferGeometry"!=t.type&&f&&t.addAttribute("position",new THREE.BufferAttribute(ie,3))}if(0<w){d=e.readInt32();var M=new(n<=65535?Uint16Array:Uint32Array)(w);if(1===d)for(A=0;A<w;++A)M[A]=e.readByte();else if(2===d)for(A=0;A<w;++A)M[A]=e.readInt16();else if(4===d)for(A=0;A<w;++A)M[A]=e.readInt32();if(0===k)for(A=1;A<w;++A)M[A]+=M[A-1];if(!1===_e.OES_element_index_uint&&65535<n&&0===k){var re=new Uint16Array(w),oe=0,ae=0,se=1,le=0;for(A=0;A<w-1;A+=2)M[A]<=65535*se&&M[A+1]<=65535*se?(ae+=2,re[A]=M[A]-oe,re[A+1]=M[A+1]-oe):(t.addDrawCall(le,ae,oe),le=A,ae=0,A-=2,oe+=65535*(++se-1));1!==se&&t.addDrawCall(le,ae,oe),t.setIndex(new THREE.BufferAttribute(re,1))}else f&&t.setIndex(new THREE.BufferAttribute(M,1))}else if(f&&0<n){var w=2*n-2,M=new(n<=65535?Uint16Array:Uint32Array)(w);for(A=0;A<n-1;A++)M[2*A]=A,M[2*A+1]=A+1;t.setIndex(new THREE.BufferAttribute(M,1))}}else if(2===p){if(0<(n=e.readInt32())){y=3*n,ie=new Float32Array(y);for(A=0;A<y;++A)ie[A]=e.readFloat32();t instanceof NdsPointGeometry&&(t.vertices=ie)}}else if(3===p){n=e.readInt32(),i=e.readInt32(),r=e.readInt32(),o=e.readInt32(),a=e.readInt32(),w=e.readInt32(),s=e.readInt32(),c=new THREE.Vector3,h=new THREE.Vector3,c.x=e.readFloat32(),c.y=e.readFloat32(),c.z=e.readFloat32(),h.x=e.readFloat32(),h.y=e.readFloat32(),h.z=e.readFloat32();var b,x,I,de,ce,he,ue,m=0,g=(S=3)+(B=0<i?3:0)+(P=0<r?2:0)+(C=0<o?3:0),y=0;if(0<n)for(y=3*n,I=new Float32Array(y),L=0;L<y;++L)I[L]=e.readFloat32();if(0<i){v=1/255;for(y=3*i,de=new Float32Array(y),L=0;L<y;++L)de[L]=e.readByte()*v}if(0<r)for(y=2*r,ce=new Float32Array(y),L=0;L<y;++L)ce[L]=e.readByte()*v;if(0<o)if(y=3*o,he=new Float32Array(y),4===s)for(L=0;L<y;++L)he[L]=e.readFloat32();else{var T,v=1===s?1/255:1/65535;if(1===s)for(L=0;L<o;++L)for(T=e.readByte(),--T,H=0;H<3;++H)he[3*L+H]=U[3*T+H]*e.readByte()*v;else if(2===s)for(L=0;L<o;++L)for(T=e.readByte(),--T,H=0;H<3;++H)he[3*L+H]=U[3*T+H]*e.readInt16()*v}if(0<a){d=e.readInt32();var pe=3*a,fe=new(n<=65535?Uint16Array:Uint32Array)(pe);if(1===d)for(A=0;A<pe;++A)fe[A]=e.readByte();else if(2===d)for(A=0;A<pe;++A)fe[A]=e.readInt16();else if(4===d)for(A=0;A<pe;++A)fe[A]=e.readInt32()}if(0<w)if(d=e.readInt32(),ue=new(n<=65535?Uint16Array:Uint32Array)(w),1===d)for(A=0;A<w;++A)ue[A]=e.readByte();else if(2===d)for(A=0;A<w;++A)ue[A]=e.readInt16();else if(4===d)for(A=0;A<w;++A)ue[A]=e.readInt32();if(0<a){var S,B,P,C,g=(S=3)+(B=0<i?3:0)+(P=0<r?2:0)+(C=3),R=3*a;if(f?(b=new Float32Array(R*g),x=new THREE.InterleavedBuffer(b,g),M=new(R<=65535?Uint16Array:Uint32Array)(R),D=new THREE.BufferAttribute(M,1)):q&&(t.attributes.position.data.array=new Float32Array(R*g),b=t.attributes.position.data.array,x=t.attributes.position.data,t.index.array=new(R<=65535?Uint16Array:Uint32Array)(R),M=t.index.array,D=t.index),f||q){var me,ge,ve,Ae,ye,m=0,Ee=new THREE.Vector3,Me=new THREE.Vector3,we=new THREE.Vector3,be=new THREE.Vector3,xe=new THREE.Vector3,Ie=new THREE.Vector3,Te=new Float32Array(3);for(A=0;A<a;++A){if(0<o)for(var O=0;O<3;++O)Te[O]=he[3*A+O];else ve=fe[3*A+0],Ae=fe[3*A+1],ye=fe[3*A+2],Ee.set(I[3*ve],I[3*ve+1],I[3*ve+2]),Me.set(I[3*Ae],I[3*Ae+1],I[3*Ae+2]),we.set(I[3*ye],I[3*ye+1],I[3*ye+2]),be.subVectors(Me,Ee),xe.subVectors(we,Ee),Ie.crossVectors(be,xe),Ie.normalize(),Ie.toArray(Te);for(_=0;_<3;++_){ge=fe[3*A+_],M[me=3*A+_]=me;for(O=0;O<S;++O)b[me*g+O]=I[ge*S+O];if(0<B){m=S;for(O=0;O<B;++O)b[me*g+m+O]=de[ge*B+O]}if(0<P){m=S+B;for(O=0;O<P;++O)b[me*g+m+O]=ce[ge*P+O]}m=S+B+P;for(O=0;O<C;++O)b[me*g+m+O]=Te[O]}}f&&(t.attributes.position=new THREE.InterleavedBufferAttribute(x,S,0,!1),0<B&&(m=S,t.attributes.color=new THREE.InterleavedBufferAttribute(x,B,m,!1)),0<P&&(m=S+B,t.attributes.uv=new THREE.InterleavedBufferAttribute(x,P,m,!1)),0<C&&(m=S+B+P,t.attributes.normal=new THREE.InterleavedBufferAttribute(x,C,m,!1)),t.setIndex(D),t.drawRange.start=0,t.drawRange.count=R)}}t=N[Z],Z++,w&&f&&(t.addAttribute("position",new THREE.BufferAttribute(I,3)),D=new THREE.BufferAttribute(ue,1),t.setIndex(D),t.drawRange.start=0,t.drawRange.count=w)}t&&(2==p||t.boundingBox||(c.equals(h)?(t.boundingBox=null,t.attributes.position&&t.computeBoundingBox()):t.boundingBox=new THREE.Box3(c,h)),0===p&&void 0!==t.attributes&&null==t.attributes.normal&&"TextBufferGeometry"!=t.type&&t.computeVertexNormals(),!1===_e.OES_element_index_uint&&0===p&&65535<n&&t.computeOffsets(),t.boundingSphere=null,f&&F?F():q&&F&&F(t))}if(!W&&0<u.length){for(var Se=0,Be=0,L=0,Pe=u.length;L<Pe;++L)Se+=u[L].attributes.position.array.length,Be+=u[L].index.array.length;for(var Ce=Se/3,Re=new Float32Array(Se),Oe=new(Ce<=65535?Uint16Array:Uint32Array)(Be),Le=new THREE.BufferAttribute(Re,3),De=new THREE.BufferAttribute(Oe,1),m=0,He=0,L=0,Pe=u.length;L<Pe;++L){for(var Fe=u[L].attributes.position,D=u[L].index,ne=(u[L].attributes.position=Le,u[L].setIndex(De),u[L].drawRange.start=He,u[L].drawRange.count=D.array.length,m/3),H=0,Ne=D.array.length;H<Ne;++H)Oe[He+H]=D.array[H]+ne;He+=D.array.length;for(var E=0,je=Fe.array.length;E<je;++E)Re[m+E]=Fe.array[E];m+=Fe.array.length}}j&&j()},k.prototype.readBIMBufferVersion4=function(e,t,n,i){for(var r,o,a,s,l,d,c,h,u,p,f=e.readInt32(),m=e.readInt32(),g=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),v=0;v<f;++v){if(r=n[v],0===(h=e.readInt32())){if(o=e.readInt32(),a=e.readInt32(),s=e.readInt32(),l=e.readInt32(),d=e.readInt32(),c=e.readInt32(),u=new THREE.Vector3,p=new THREE.Vector3,u.x=e.readFloat32(),u.y=e.readFloat32(),u.z=e.readFloat32(),p.x=e.readFloat32(),p.y=e.readFloat32(),p.z=e.readFloat32(),0<o){for(var A=3*o,y=new Float32Array(A),E=0;E<A;++E)y[E]=e.readFloat32();r.addAttribute("position",new THREE.BufferAttribute(y,3))}if(0<a){var A=3*a,M=new Float32Array(A),w=1/255;for(E=0;E<A;++E)M[E]=e.readByte()*w;r.addAttribute("color",new THREE.BufferAttribute(M,3))}if(0<s){var A=2*s,b=new Float32Array(A);for(E=0;E<A;++E)b[E]=e.readFloat32();r.addAttribute("uv",new THREE.BufferAttribute(b,2))}if(0<l){if(4===c){var A=3*l,x=new Float32Array(A);for(E=0;E<A;++E)x[E]=e.readFloat32()}else{var I,w=1===c?1/255:1/65535,x=new Float32Array(3*l);if(1===c)for(E=0;E<l;++E){I=e.readByte(),--I;var T=e.readByte();x[3*E]=g[3*I]*T*w,T=e.readByte(),x[3*E+1]=g[3*I+1]*T*w,T=e.readByte(),x[3*E+2]=g[3*I+2]*T*w}else if(2===c)for(E=0;E<l;++E)I=e.readByte(),--I,x[3*E]=g[3*I]*e.readInt16()*w,x[3*E+1]=g[3*I+1]*e.readInt16()*w,x[3*E+2]=g[3*I+2]*e.readInt16()*w}r.addAttribute("normal",new THREE.BufferAttribute(x,3))}if(0<d){var S=e.readInt32(),A=3*d,B=new(o<=65535?Uint16Array:Uint32Array)(A);if(1===S)for(E=0;E<A;++E)B[E]=e.readByte();else if(2===S)for(E=0;E<A;++E)B[E]=e.readInt16();else if(4===S)for(E=0;E<A;++E)B[E]=e.readInt32();Ve.restoreIndices(B,B.length),r.setIndex(new THREE.BufferAttribute(B,1))}}else if(1===h){if(o=e.readInt32(),d=e.readInt32(),u=new THREE.Vector3,p=new THREE.Vector3,u.x=e.readFloat32(),u.y=e.readFloat32(),u.z=e.readFloat32(),p.x=e.readFloat32(),p.y=e.readFloat32(),p.z=e.readFloat32(),0<o){A=3*o,y=new Float32Array(A);for(E=0;E<A;++E)y[E]=e.readFloat32();r.addAttribute("position",new THREE.BufferAttribute(y,3))}if(0<d){S=e.readInt32();B=new(o<=65535?Uint16Array:Uint32Array)(d);if(1===S)for(E=0;E<d;++E)B[E]=e.readByte();else if(2===S)for(E=0;E<d;++E)B[E]=e.readInt16();else if(4===S)for(E=0;E<d;++E)B[E]=e.readInt32();if(0===m)for(E=1;E<d;++E)B[E]+=B[E-1];if(!1===_e.OES_element_index_uint&&65535<o&&0===m){var P=new Uint16Array(d),C=0,R=0,O=1,L=0;for(E=0;E<d-1;E+=2)B[E]<=65535*O&&B[E+1]<=65535*O?(R+=2,P[E]=B[E]-C,P[E+1]=B[E+1]-C):(r.addDrawCall(L,R,C),L=E,R=0,E-=2,C+=65535*(++O-1));1!==O&&r.addDrawCall(L,R,C),r.setIndex(new THREE.BufferAttribute(P,1))}else r.setIndex(new THREE.BufferAttribute(B,1))}}r.boundingBox||(u.equals(p)?r.attributes.position&&r.computeBoundingBox():r.boundingBox=new THREE.Box3(u,p)),0===h&&null==r.attributes.normal&&r.computeVertexNormals(),!1===_e.OES_element_index_uint&&0===h&&65535<o&&r.computeOffsets(),r.boundingSphere=null,t&&t()}i&&i()},k.prototype.readBIMBufferVersion3=function(e,t,n,i){for(var r,o,a,s,l,d,c,h,u,p=e.readInt32(),f=e.readInt32(),m=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),g=0;g<p;++g){if(r=n[g],0===(c=e.readInt32())){if(o=e.readInt32(),a=e.readInt32(),s=e.readInt32(),l=e.readInt32(),d=e.readInt32(),h=new THREE.Vector3,u=new THREE.Vector3,h.x=e.readFloat32(),h.y=e.readFloat32(),h.z=e.readFloat32(),u.x=e.readFloat32(),u.y=e.readFloat32(),u.z=e.readFloat32(),0<o){for(var v=3*o,A=new Float32Array(v),y=0;y<v;++y)A[y]=e.readFloat32();r.addAttribute("position",new THREE.BufferAttribute(A,3))}if(0<a){var v=2*a,E=new Float32Array(v);for(y=0;y<v;++y)E[y]=e.readFloat32();r.addAttribute("uv",new THREE.BufferAttribute(E,2))}if(0<s){if(4===d){var v=3*s,M=new Float32Array(v);for(y=0;y<v;++y)M[y]=e.readFloat32()}else{var w,b=1===d?1/255:1/65535,M=new Float32Array(3*s);if(1===d)for(y=0;y<s;++y){w=e.readByte(),--w;var x=e.readByte();M[3*y]=m[3*w]*x*b,x=e.readByte(),M[3*y+1]=m[3*w+1]*x*b,x=e.readByte(),M[3*y+2]=m[3*w+2]*x*b}else if(2===d)for(y=0;y<s;++y)w=e.readByte(),--w,M[3*y]=m[3*w]*e.readInt16()*b,M[3*y+1]=m[3*w+1]*e.readInt16()*b,M[3*y+2]=m[3*w+2]*e.readInt16()*b}r.addAttribute("normal",new THREE.BufferAttribute(M,3))}if(0<l){var I=e.readInt32(),v=3*l,T=new(o<=65535?Uint16Array:Uint32Array)(v);if(1===I)for(y=0;y<v;++y)T[y]=e.readByte();else if(2===I)for(y=0;y<v;++y)T[y]=e.readInt16();else if(4===I)for(y=0;y<v;++y)T[y]=e.readInt32();Ve.restoreIndices(T,T.length),r.setIndex(new THREE.BufferAttribute(T,1))}}else if(1===c){if(o=e.readInt32(),l=e.readInt32(),h=new THREE.Vector3,u=new THREE.Vector3,h.x=e.readFloat32(),h.y=e.readFloat32(),h.z=e.readFloat32(),u.x=e.readFloat32(),u.y=e.readFloat32(),u.z=e.readFloat32(),0<o){v=3*o,A=new Float32Array(v);for(y=0;y<v;++y)A[y]=e.readFloat32();r.addAttribute("position",new THREE.BufferAttribute(A,3))}if(0<l){I=e.readInt32();T=new(o<=65535?Uint16Array:Uint32Array)(l);if(1===I)for(y=0;y<l;++y)T[y]=e.readByte();else if(2===I)for(y=0;y<l;++y)T[y]=e.readInt16();else if(4===I)for(y=0;y<l;++y)T[y]=e.readInt32();if(0===f)for(y=1;y<l;++y)T[y]+=T[y-1];if(!1===_e.OES_element_index_uint&&65535<o&&0===f){var S=new Uint16Array(l),B=0,P=0,C=1,R=0;for(y=0;y<l-1;y+=2)T[y]<=65535*C&&T[y+1]<=65535*C?(P+=2,S[y]=T[y]-B,S[y+1]=T[y+1]-B):(r.addDrawCall(R,P,B),R=y,P=0,y-=2,B+=65535*(++C-1));1!==C&&r.addDrawCall(R,P,B),r.setIndex(new THREE.BufferAttribute(S,1))}else r.setIndex(new THREE.BufferAttribute(T,1))}}r.boundingBox||(h.equals(u)?r.attributes.position&&r.computeBoundingBox():r.boundingBox=new THREE.Box3(h,u)),0===c&&null==r.attributes.normal&&r.computeVertexNormals(),!1===_e.OES_element_index_uint&&0===c&&65535<o&&r.computeOffsets(),r.boundingSphere=null,t&&t()}i&&i()},k.prototype.readBIMBufferVersion2=function(e,t,n,i){for(var r,o,a,s,l,d,c,h=e.readInt32(),u=new Int32Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1]),p=0;p<h;++p){if(r=n[p],0===(l=e.readInt32())){if(o=e.readInt32(),e.readInt32(),a=e.readInt32(),s=e.readInt32(),w=e.readInt32(),d=new THREE.Vector3,c=new THREE.Vector3,d.x=e.readFloat32(),d.y=e.readFloat32(),d.z=e.readFloat32(),c.x=e.readFloat32(),c.y=e.readFloat32(),c.z=e.readFloat32(),0<o){for(var f=3*o,m=new Float32Array(f),g=0;g<f;++g)m[g]=e.readFloat32();r.addAttribute("position",new THREE.BufferAttribute(m,3))}if(0<a){if(4===w){var f=3*a,v=new Float32Array(f);for(g=0;g<f;++g)v[g]=e.readFloat32()}else{var A,y=1===w?1/255:1/65535,v=new Float32Array(3*a);if(1===w)for(g=0;g<a;++g){A=e.readByte(),--A;var E=e.readByte();v[3*g]=u[3*A]*E*y,E=e.readByte(),v[3*g+1]=u[3*A+1]*E*y,E=e.readByte(),v[3*g+2]=u[3*A+2]*E*y}else if(2===w)for(g=0;g<a;++g)A=e.readByte(),--A,v[3*g]=u[3*A]*e.readInt16()*y,v[3*g+1]=u[3*A+1]*e.readInt16()*y,v[3*g+2]=u[3*A+2]*e.readInt16()*y}r.addAttribute("normal",new THREE.BufferAttribute(v,3))}if(w=e.readInt32(),0<s){var f=3*s,M=new(o<=65535?Uint16Array:Uint32Array)(f);if(1===w)for(g=0;g<f;++g)M[g]=e.readByte();else if(2===w)for(g=0;g<f;++g)M[g]=e.readInt16();else if(4===w)for(g=0;g<f;++g)M[g]=e.readInt32();Ve.restoreIndices(M,M.length),r.setIndex(new THREE.BufferAttribute(M,1))}}else if(1===l){if(o=e.readInt32(),s=e.readInt32(),d=new THREE.Vector3,c=new THREE.Vector3,d.x=e.readFloat32(),d.y=e.readFloat32(),d.z=e.readFloat32(),c.x=e.readFloat32(),c.y=e.readFloat32(),c.z=e.readFloat32(),0<o){f=3*o,m=new Float32Array(f);for(g=0;g<f;++g)m[g]=e.readFloat32();r.addAttribute("position",new THREE.BufferAttribute(m,3))}if(0<s){var w=e.readInt32(),M=new(o<=65535?Uint16Array:Uint32Array)(s);if(1===w)for(g=0;g<s;++g)M[g]=e.readByte();else if(2===w)for(g=0;g<s;++g)M[g]=e.readInt16();else if(4===w)for(g=0;g<s;++g)M[g]=e.readInt32();for(g=1;g<s;++g)M[g]+=M[g-1];if(!1===_e.OES_element_index_uint&&65535<o){var b=new Uint16Array(s),x=0,I=0,T=1,S=0;for(g=0;g<s-1;g+=2)M[g]<=65535*T&&M[g+1]<=65535*T?(I+=2,b[g]=M[g]-x,b[g+1]=M[g+1]-x):(r.addDrawCall(S,I,x),S=g,I=0,g-=2,x+=65535*(++T-1));1!==T&&r.addDrawCall(S,I,x),r.setIndex(new THREE.BufferAttribute(b,1))}else r.setIndex(new THREE.BufferAttribute(M,1))}}r.boundingBox||(d.equals(c)?r.computeBoundingBox():r.boundingBox=new THREE.Box3(d,c)),0===l&&null==r.attributes.normal&&r.computeVertexNormals(),!1===_e.OES_element_index_uint&&0===l&&65535<o&&r.computeOffsets(),r.boundingSphere=null,t&&t()}i&&i()},k.prototype.readBIMBufferVersion1=function(e,t,n,i){for(var r,o,a,s,l,d,c,h,u,p,f,m,g,v,A,y,E,M,w=e.readInt32(),b=[],x=[],I=0;I<w;++I){for(b=[],x=[],(f=n[I]).faceVertexUvs[0]=[],m=e.readInt32(),g=e.readInt32(),v=e.readInt32(),A=e.readInt32(),y=m<=255?1:m<=65535?2:4,E=g<=255?1:g<=65535?2:4,M=v<=255?1:v<=65535?2:4,r=0;r<m;++r)(c=new THREE.Vector3).x=e.readFloat32(),c.y=e.readFloat32(),c.z=e.readFloat32(),f.vertices.push(c);for(r=0;r<g;++r)(p=new THREE.Vector2).x=e.readFloat32(),p.y=e.readFloat32(),x.push(p);for(r=0;r<v;++r)(u=new THREE.Vector3).x=e.readFloat32(),u.y=e.readFloat32(),u.z=e.readFloat32(),b.push(u);for(o=0;o<A;++o){if(s=(d=e.readByte())&8,l=d&16,d=d&32,h=new THREE.Face3,1==y?(h.a=e.readByte(),h.b=e.readByte(),h.c=e.readByte()):2==y?(h.a=e.readInt16(),h.b=e.readInt16(),h.c=e.readInt16()):(h.a=e.readInt32(),h.b=e.readInt32(),h.c=e.readInt32()),a=f.faces.length,0!=s)for(r=0;r<1;r++)f.faceVertexUvs[r][a]=[],1==E?(f.faceVertexUvs[r][a].push(x[e.readByte()]),f.faceVertexUvs[r][a].push(x[e.readByte()]),f.faceVertexUvs[r][a].push(x[e.readByte()])):2==E?(f.faceVertexUvs[r][a].push(x[e.readInt16()]),f.faceVertexUvs[r][a].push(x[e.readInt16()]),f.faceVertexUvs[r][a].push(x[e.readInt16()])):(f.faceVertexUvs[r][a].push(x[e.readInt32()]),f.faceVertexUvs[r][a].push(x[e.readInt32()]),f.faceVertexUvs[r][a].push(x[e.readInt32()]));l&&(h.normal=1==M?b[e.readByte()]:2==M?b[e.readInt16()]:b[e.readInt32()]),d&&(1==M?(h.vertexNormals.push(b[e.readByte()]),h.vertexNormals.push(b[e.readByte()]),h.vertexNormals.push(b[e.readByte()])):2==M?(h.vertexNormals.push(b[e.readInt16()]),h.vertexNormals.push(b[e.readInt16()]),h.vertexNormals.push(b[e.readInt16()])):(h.vertexNormals.push(b[e.readInt32()]),h.vertexNormals.push(b[e.readInt32()]),h.vertexNormals.push(b[e.readInt32()]))),f.faces.push(h)}this.computeGeometryFaceNormal(f),f.computeBoundingBox(),t&&t()}i&&i()},k.prototype.parseString=function(e,t,n){for(var i=new Uint8Array(e,t,n),r="",o=0;o<n;o++)r+=String.fromCharCode(i[t+o]);return r},k.prototype.parseUChar8=function(e,t){return new Uint8Array(e,t,1)[0]},k.prototype.parseUInt32=function(e,t){return new Uint32Array(e,t,1)[0]},k.prototype.parseUInt16=function(e,t){return new Uint16Array(e,t,1)[0]},k.prototype.parseInt32=function(e,t){e=new Uint8Array(e,t,4),t=255&e[0];return(t|=(255&e[1])<<8)|(255&e[2])<<16|(255&e[3])<<24},k.prototype.parseInt16=function(e,t){e=new Uint8Array(e,t,2);return 255&e[0]|(255&e[1])<<8},k.prototype.parseFloat32Lzma=function(e,t){e=new Uint8Array(e,t,4),t=255&e[0];return(t|=(255&e[1])<<8)|(255&e[2])<<16|(255&e[3])<<24},k.prototype.readUuid=function(e){for(var t=[e.readInt32()>>>0,e.readInt32()>>>0,e.readInt32()>>>0,e.readInt32()>>>0],n="",i=0,i=0;i<4;++i){var r=t[i].toString(16);r.length<8&&(n+="00000000".slice(0,8-r.length)),n+=r}return n=0!=_e.ScenarioEditorid?Se.addSceneID(n):n},k.prototype.readUuid3=function(e){e=(e.readInt32()>>>0).toString();return e=0!=_e.ScenarioEditorid?Se.addSceneID(e):e},k.prototype.readBvhV1=function(e,t){for(var n,i,r=e.readInt32(),o=(t.setNumNodes(r),new Float32Array(6)),a=0,s=0;s<r;++s){for(var l=0;l<6;++l)o[l]=e.readFloat32();n=e.readInt32(),a=e.readInt32(),i=e.readInt32(),t.setNode(s,o,n,a,i)}for(var d,c,a=e.readInt32(),h=new Int32Array(a),u=0;u<a;++u)h[u]=e.readInt32();t.setMeshIds(h),t.meshManager.setNumMeshes(a);for(u=0;u<a;++u){for(var p=this.readUuid(e),f=e.readInt32(),l=0;l<6;++l)o[l]=e.readFloat32();e.readInt32(),d=e.readInt32(),c=e.readInt32(),e.readInt32(),t.meshManager.setMeshFromGeomUuid(u,o,p,f,d,c)}for(var m=e.readInt32(),g=new THREE.Matrix4,v=0;v<m;++v)g.set(e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32());for(var A,y=e.readInt32(),E=[],l=0;l<y;++l)A=this.readUuid(e),E.push(A);t.meshManager.setMaterialUuids(E);for(var M,w=e.readInt32(),b=[],x=0;x<w;++x)M=this.readUuid(e),b.push(M);var I=e.readInt32();t.meshManager.setNumLineSegments(I);for(var T=0;T<I;++T)p=this.readUuid(e),e.readInt32(),c=e.readInt32(),e.readInt32(),t.meshManager.setLineSegmentsFromGeomUuid(T,p,c);t.meshManager.setBodyUuids(b)},k.prototype.readBvhV2=function(e,t,n){for(var i,r,o=e.readInt32(),a=(t.setNumNodes(o),new Float32Array(6)),s=0,l=0;l<o;++l){for(var d=0;d<6;++d)a[d]=e.readFloat32();i=e.readInt32(),s=e.readInt32(),r=e.readInt32(),t.setNode(l,a,i,s,r)}for(var c,h,s=e.readInt32(),u=new Int32Array(s),p=0;p<s;++p)u[p]=e.readInt32();t.setMeshIds(u),t.meshManager.setNumMeshes(s);for(p=0;p<s;++p){for(var f=2<n?this.readUuid3(e):this.readUuid(e),m=e.readInt32(),d=0;d<6;++d)a[d]=e.readFloat32();e.readInt32(),c=e.readInt32(),h=e.readInt32(),e.readInt32(),t.meshManager.setMeshFromGeomUuid(p,a,f,m,c,h)}for(var g=e.readInt32(),v=new THREE.Matrix4,A=0;A<g;++A)v.set(e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32());for(var y,E=e.readInt32(),M=[],d=0;d<E;++d)y=2<n?this.readUuid3(e):this.readUuid(e),M.push(y);t.meshManager.setMaterialUuids(M);for(var w,b=e.readInt32(),x=[],I=0;I<b;++I)w=2<n?this.readUuid3(e):this.readUuid(e),x.push(w);var T=e.readInt32();t.meshManager.setNumLineSegments(T);for(var S=0;S<T;++S)f=2<n?this.readUuid3(e):this.readUuid(e),e.readInt32(),c=e.readInt32(),h=e.readInt32(),e.readInt32(),t.meshManager.setLineSegmentsFromGeomUuid(S,f,h,c);t.meshManager.setBodyUuids(x)},k.prototype.readBvhV3=function(e,t){for(var n,i,r,o,a,s,l=e.readInt32(),d=(t.setNumNodes(l),new Float32Array(6)),c=0,h=0;h<l;++h){e.readInt32();for(var u=0;u<6;++u)d[u]=e.readFloat32();n=e.readInt32(),c=e.readInt32(),o=e.readInt32(),i=e.readInt32(),a=e.readInt32(),r=e.readInt32(),s=e.readInt32(),t.setNode(h,d,n,c,o,i,a,r,s)}for(var p,f=e.readInt32(),m=[],u=0;u<f;++u)p=0===this.materialIdType?this.readUuid3(e):this.readUuid(e),m.push(p);t.meshManager.setMaterialUuids(m);for(var g,v=e.readInt32(),A=[],y=0;y<v;++y)g=0===this.objectIdType?this.readUuid3(e):this.readUuid(e),A.push(g);for(var E,M,c=e.readInt32(),w=new Int32Array(c),b=0;b<c;++b)w[b]=b;t.setMeshIds(w),t.meshManager.setNumMeshes(c,!0,!1);for(var x=0;x<c;++x){for(var I=e.readInt32(),T=0===this.geomIdType?this.readUuid3(e):this.readUuid(e),S=e.readInt32(),u=0;u<6;++u)d[u]=e.readFloat32();E=e.readInt32(),M=e.readInt32(),e.readInt32(),t.meshManager.setMeshFromGeomUuid(x,d,T,S,E,M,I,-1)}var B=e.readInt32();t.meshManager.setNumLineSegments(B,!0,!1);for(var P=0;P<B;++P)I=e.readInt32(),T=0===this.geomIdType?this.readUuid3(e):this.readUuid(e),E=e.readInt32(),M=e.readInt32(),e.readInt32(),t.meshManager.setLineSegmentsFromGeomUuid(P,T,M,E,I,-1);var C=e.readInt32();t.meshManager.setNumTexts(C,!0,!1);for(var R=0;R<C;++R)I=e.readInt32(),T=0===this.geomIdType?this.readUuid3(e):this.readUuid(e),E=e.readInt32(),M=e.readInt32(),e.readInt32(),t.meshManager.setTextFromGeomUuid(R,T,M,E,I,-1);t.meshManager.setBodyUuids(A)},k.prototype.readBvhV4=function(e,t,n,i,r){void 0===n&&(n=null),void 0===i&&(i=0),void 0===r&&(r=null);for(var o,a,s,l,d,c,h=new THREE.Matrix4,u=new THREE.Box3,p=e.readInt32(),f=e.readByte(),m=(t.setNumNodes(p),new Float32Array(6)),g=0,v=function(e){return!(e[0]>e[3]||e[1]>e[4]||e[2]>e[5])},F=function(){u.min.fromArray(m,0),u.max.fromArray(m,3),u.applyMatrix4(n),m[0]=u.min.x,m[1]=u.min.y,m[2]=u.min.z,m[3]=u.max.x,m[4]=u.max.y,m[5]=u.max.z},A=0;A<p;++A){e.readInt32();for(var y=0;y<6;++y)m[y]=e.readFloat32();n&&v(m)&&F(),o=e.readInt32(),g=e.readInt32(),l=e.readInt32(),a=e.readInt32(),d=e.readInt32(),s=e.readInt32(),c=e.readInt32(),t.setNode(A,m,o,g,l,a,d,s,c)}var E=null;if(1===f)for(var N=e.readInt32(),E=new Float32Array(16*N),A=0;A<N;++A){for(y=0;y<16;++y){var j=e.readFloat32();E[16*A+y]=j,n&&(h.elements[y]=j)}n&&(h.premultiply(n),E.set(h.elements,offset))}for(var M,w=0,_=(1===f&&(w=t.meshManager.expandMatrixes(E)),e.readInt32()),b=[],y=0;y<_;++y)M=0===this.materialIdType?this.readUuid3(e):this.readUuid(e),t.meshManager.ndsModel.viewer.ndsModel.materialuuidOld2New[M]&&(M=t.meshManager.ndsModel.viewer.ndsModel.materialuuidOld2New[M]),r&&r.uuidMaterialMap.has(M)?b.push(r.uuidMaterialMap.get(M).uuid):b.push(M);for(var x,I=t.meshManager.expandMaterialUuids(b),V=e.readInt32(),k=[],U=0;U<V;++U)x=0===this.objectIdType?this.readUuid3(e):this.readUuid(e),0<i&&(x+="_"+i),k.push(x);for(var T,S,B,g=e.readInt32(),P=t.meshManager.expandMeshes(g,!0,1===f),G=new Int32Array(g),C=0;C<g;++C)G[C]=P+C;t.setMeshIds(G);for(var R=0;R<g;++R){for(var O=e.readInt32(),L=0===this.geomIdType?this.readUuid3(e):this.readUuid(e),z=e.readInt32(),y=0;y<6;++y)m[y]=e.readFloat32();n&&v(m)&&F(),T=e.readInt32(),I&&(T=I[T]),S=e.readInt32(),e.readInt32(),B=-1,1===f&&(B=e.readInt32()),t.meshManager.setMeshFromGeomUuid(P+R,m,L,z,T,S,O,w+B)}for(var W=e.readInt32(),Y=t.meshManager.expandLineSegments(W,!0,1===f),D=0;D<W;++D)O=e.readInt32(),L=0===this.geomIdType?this.readUuid3(e):this.readUuid(e),T=e.readInt32(),I&&(T=I[T]),S=e.readInt32(),e.readInt32(),B=-1,1===f&&(B=e.readInt32()),t.meshManager.setLineSegmentsFromGeomUuid(Y+D,L,S,T,O,w+B);for(var X=e.readInt32(),Q=t.meshManager.expandTexts(X,!0,1===f),H=0;H<X;++H)O=e.readInt32(),L=0===this.geomIdType?this.readUuid3(e):this.readUuid(e),T=e.readInt32(),I&&(T=I[T]),S=e.readInt32(),e.readInt32(),B=-1,1===f&&(B=e.readInt32()),t.meshManager.setTextFromGeomUuid(Q+H,L,S,T,O,w+B);t.meshManager.expandBodyUuids(k,P,Y,Q)},k.prototype.readBvh=function(e,t,n){e.readString();var i=e.readInt32();4===(t.bvh.version=i)?this.readBvhV4(e,t.bvh,t.worldMatrix,t.numRef,t.refModelContext):1==i?this.readBvhV1(e,t.bvh):1<i&&this.readBvhV2(e,t.bvh,i),n&&n()},k.prototype.readBrep=function(e,t,F){for(var n=e.readByte(),N=(t.version=n,e.readInt32()),i=new Array(N),r=0;r<N;++r){var j=e.readGuid(),o=(i[r]={geomUUID:j},e.readInt32());if(0<o){i[r].lines={ids:new Int32Array(o),indexRanges:new Int32Array(2*o),lengthes:new Float32Array(o)};for(var a=0;a<o;++a)i[r].lines.ids[a]=e.readInt32(),i[r].lines.indexRanges[2*a]=e.readInt32(),i[r].lines.indexRanges[2*a+1]=e.readInt32(),i[r].lines.lengthes[a]=e.readFloat32()}var s=e.readInt32();if(0<s){i[r].circles={ids:new Int32Array(s),indexRanges:new Int32Array(2*s),lengthes:new Float32Array(s),centers:new Float32Array(3*s),radiuses:new Float32Array(s)};for(var l=0;l<s;++l){i[r].circles.ids[l]=e.readInt32(),i[r].circles.indexRanges[2*l]=e.readInt32(),i[r].circles.indexRanges[2*l+1]=e.readInt32(),i[r].circles.lengthes[l]=e.readFloat32();for(var _=0;_<3;++_)i[r].circles.centers[3*l+_]=e.readFloat32();i[r].circles.radiuses[l]=e.readFloat32()}}var d=e.readInt32();if(0<d){i[r].ellipses={ids:new Int32Array(d),indexRanges:new Int32Array(2*d),lengthes:new Float32Array(d)};for(var c=0;c<d;++c)i[r].ellipses.ids[c]=e.readInt32(),i[r].ellipses.indexRanges[2*c]=e.readInt32(),i[r].ellipses.indexRanges[2*c+1]=e.readInt32(),i[r].ellipses.lengthes[c]=e.readFloat32()}var h=e.readInt32();if(0<h){i[r].nurbses={ids:new Int32Array(h),indexRanges:new Int32Array(2*h),lengthes:new Float32Array(h)};for(var u=0;u<h;++u)i[r].nurbses.ids[u]=e.readInt32(),i[r].nurbses.indexRanges[2*u]=e.readInt32(),i[r].nurbses.indexRanges[2*u+1]=e.readInt32(),i[r].nurbses.lengthes[u]=e.readFloat32()}var p=e.readInt32();if(0<p){i[r].others={ids:new Int32Array(p),indexRanges:new Int32Array(2*p),lengthes:new Float32Array(p)};for(var f=0;f<p;++f)i[r].others.ids[f]=e.readInt32(),i[r].others.indexRanges[2*f]=e.readInt32(),i[r].others.indexRanges[2*f+1]=e.readInt32(),i[r].others.lengthes[f]=e.readFloat32()}}for(var V=t.brepInfos.edgeGroups.length,k=(t.brepInfos.edgeGroups=t.brepInfos.edgeGroups.concat(i),e.readInt32()),m=new Array(k),g=0;g<k;++g){var U=e.readGuid(),v=(m[g]={geomUUID:U,loopPerimeters:[],loopStartEdgeId:[]},e.readInt32());if(0<v){m[g].planes={ids:new Int32Array(v),triIndexRanges:new Int32Array(2*v),areas:new(n<7?Float32Array:Float64Array)(v),origins:new Float32Array(3*v),normals:new Float32Array(3*v),loops:new Int32Array(2*v)};for(var A=0;A<v;++A){m[g].planes.ids[A]=e.readInt32(),m[g].planes.triIndexRanges[2*A]=e.readInt32(),m[g].planes.triIndexRanges[2*A+1]=e.readInt32(),m[g].planes.areas[A]=n<7?e.readFloat32():e.readFloat64();for(var G=e.readInt32(),z=m[g].loopPerimeters.length,y=0;y<G;++y)m[g].loopPerimeters[z+y]=e.readFloat32(),m[g].loopStartEdgeId[z+y]=e.readInt32();m[g].planes.loops[2*A]=z,m[g].planes.loops[2*A+1]=G;for(var W=0;W<3;++W)m[g].planes.origins[3*A+W]=e.readFloat32();for(var Y=0;Y<3;++Y)m[g].planes.normals[3*A+Y]=e.readFloat32()}}var E=e.readInt32();if(0<E){m[g].cylinders={ids:new Int32Array(E),triIndexRanges:new Int32Array(2*E),areas:new(n<7?Float32Array:Float64Array)(E),loops:new Int32Array(2*E),origins:new Float32Array(3*E),axis:new Float32Array(3*E),radiuses:new Float32Array(E)};for(var M=0;M<E;++M){m[g].cylinders.ids[M]=e.readInt32(),m[g].cylinders.triIndexRanges[2*M]=e.readInt32(),m[g].cylinders.triIndexRanges[2*M+1]=e.readInt32(),m[g].cylinders.areas[M]=n<7?e.readFloat32():e.readFloat64();for(var X=e.readInt32(),Q=m[g].loopPerimeters.length,w=0;w<X;++w)m[g].loopPerimeters[Q+w]=e.readFloat32(),m[g].loopStartEdgeId[Q+w]=e.readInt32();m[g].cylinders.loops[2*M]=Q,m[g].cylinders.loops[2*M+1]=X;for(var Z=0;Z<3;++Z)m[g].cylinders.axis[3*M+Z]=e.readFloat32();for(var q=0;q<3;++q)m[g].cylinders.origins[3*M+q]=e.readFloat32();m[g].cylinders.radiuses[M]=e.readFloat32()}}var b=e.readInt32();if(0<b){m[g].cones={ids:new Int32Array(b),triIndexRanges:new Int32Array(2*b),areas:new(n<7?Float32Array:Float64Array)(b),loops:new Int32Array(2*b),origins:new Float32Array(3*b),axis:new Float32Array(3*b),radiuses:new Float32Array(b)};for(var x=0;x<b;++x){m[g].cones.ids[x]=e.readInt32(),m[g].cones.triIndexRanges[2*x]=e.readInt32(),m[g].cones.triIndexRanges[2*x+1]=e.readInt32(),m[g].cones.areas[x]=n<7?e.readFloat32():e.readFloat64();for(var K=e.readInt32(),J=m[g].loopPerimeters.length,I=0;I<K;++I)m[g].loopPerimeters[J+I]=e.readFloat32(),m[g].loopStartEdgeId[J+I]=e.readInt32();m[g].cones.loops[2*x]=J,m[g].cones.loops[2*x+1]=K;for(var $=0;$<3;++$)m[g].cones.axis[3*x+$]=e.readFloat32();for(var ee=0;ee<3;++ee)m[g].cones.origins[3*x+ee]=e.readFloat32();m[g].cones.radiuses[x]=e.readFloat32()}}var T=e.readInt32();if(0<T){m[g].spheres={ids:new Int32Array(T),triIndexRanges:new Int32Array(2*T),areas:new(n<7?Float32Array:Float64Array)(T),loops:new Int32Array(2*T)};for(var S=0;S<T;++S){m[g].spheres.ids[S]=e.readInt32(),m[g].spheres.triIndexRanges[2*S]=e.readInt32(),m[g].spheres.triIndexRanges[2*S+1]=e.readInt32(),m[g].spheres.areas[S]=n<7?e.readFloat32():e.readFloat64();for(var te=e.readInt32(),ne=m[g].loopPerimeters.length,ie=0;ie<te;++ie)m[g].loopPerimeters[ne+ie]=e.readFloat32(),m[g].loopStartEdgeId[ne+ie]=e.readInt32();m[g].spheres.loops[2*S]=ne,m[g].spheres.loops[2*S+1]=te}}var B=e.readInt32();if(0<B){m[g].toruses={ids:new Int32Array(B),triIndexRanges:new Int32Array(2*B),areas:new(n<7?Float32Array:Float64Array)(B),loops:new Int32Array(2*B)};for(var P=0;P<B;++P){m[g].toruses.ids[P]=e.readInt32(),m[g].toruses.triIndexRanges[2*P]=e.readInt32(),m[g].toruses.triIndexRanges[2*P+1]=e.readInt32(),m[g].toruses.areas[P]=n<7?e.readFloat32():e.readFloat64();for(var re=e.readInt32(),oe=m[g].loopPerimeters.length,ae=0;ae<re;++ae)m[g].loopPerimeters[oe+ae]=e.readFloat32(),m[g].loopStartEdgeId[oe+ae]=e.readInt32();m[g].toruses.loops[2*P]=oe,m[g].toruses.loops[2*P+1]=re}}var C=e.readInt32();if(0<C){m[g].nurbses={ids:new Int32Array(C),triIndexRanges:new Int32Array(2*C),areas:new(n<7?Float32Array:Float64Array)(C),loops:new Int32Array(2*C)};for(var R=0;R<C;++R){m[g].nurbses.ids[R]=e.readInt32(),m[g].nurbses.triIndexRanges[2*R]=e.readInt32(),m[g].nurbses.triIndexRanges[2*R+1]=e.readInt32(),m[g].nurbses.areas[R]=n<7?e.readFloat32():e.readFloat64();for(var se=e.readInt32(),le=m[g].loopPerimeters.length,de=0;de<se;++de)m[g].loopPerimeters[le+de]=e.readFloat32(),m[g].loopStartEdgeId[le+de]=e.readInt32();m[g].nurbses.loops[2*R]=le,m[g].nurbses.loops[2*R+1]=se}}var O=e.readInt32();if(0<O){m[g].others={ids:new Int32Array(O),triIndexRanges:new Int32Array(2*O),areas:new(n<7?Float32Array:Float64Array)(O),loops:new Int32Array(2*O)};for(var L=0;L<O;++L){m[g].others.ids[L]=e.readInt32(),m[g].others.triIndexRanges[2*L]=e.readInt32(),m[g].others.triIndexRanges[2*L+1]=e.readInt32(),m[g].others.areas[L]=n<7?e.readFloat32():e.readFloat64();for(var ce=e.readInt32(),he=m[g].loopPerimeters.length,ue=0;ue<ce;++ue)m[g].loopPerimeters[he+ue]=e.readFloat32(),m[g].loopStartEdgeId[he+ue]=e.readInt32();m[g].others.loops[2*L]=he,m[g].others.loops[2*L+1]=ce}}}for(var pe=t.brepInfos.faceGroups.length,fe=(t.brepInfos.faceGroups=t.brepInfos.faceGroups.concat(m),e.readInt32()),me=new Uint32Array(fe),ge=new Float32Array(3*fe),ve=0;ve<fe;++ve){me[ve]=e.readInt32();for(var Ae=0;Ae<3;++Ae)ge[3*ve+Ae]=e.readFloat32()}t.brepInfos.vertices={ids:me,coords:ge};for(var ye=e.readInt32(),D=new Array(ye),H=0;H<ye;++H){D[H]={},D[H].area=n<7?e.readFloat32():e.readFloat64(),D[H].volume=n<7?e.readFloat32():e.readFloat64();var Ee=e.readInt32();if(0<Ee){D[H].edgeGroups=new Int32Array(Ee);for(var Me=0;Me<Ee;++Me)D[H].edgeGroups[Me]=e.readInt32()+V}var we=e.readInt32();if(0<we){D[H].faceGroups=new Int32Array(we);for(var be=0;be<we;++be)D[H].faceGroups[be]=e.readInt32()+pe}var xe=e.readInt32();if(0<xe){D[H].vertices=new Int32Array(xe);for(var Ie=0;Ie<xe;++Ie)D[H].vertices[Ie]=e.readInt32()}}for(var Te=t.brepInfos.breps.length,Se=(t.brepInfos.breps=t.brepInfos.breps.concat(D),e.readInt32()),Be=0;Be<Se;++Be){var Pe=e.readGuid(),Ce=e.readInt32();t.brepInfos.bodies.set(Pe,Ce+Te)}},k.prototype.readMorph=function(e){for(var t=new Ve.Stream(e),n=(t.readString(),t.readInt32(),[]),i=t.readInt32(),r=0;r<i;r++){var o=t.readInt32(),a=t.readInt32(),s={position:null,normal:null};0<o&&(s.position=new Float32Array(o),t.readArrayFloat32(s.position)),0<a&&(s.normal=new Float32Array(a),t.readArrayFloat32(s.normal)),n.push(s)}return n},k.prototype.DracoModule=DracoDecoderModule(),At.prototype={constructor:At,load:function(e,t,n,i){var r=this,o=new THREE.Texture,a=new THREE.FileLoader(this.manager);return a.setResponseType("arraybuffer"),a.load(e,function(e){o.image=r.parse(e),o.needsUpdate=!0,void 0!==t&&t(o)},n,i),o},parse:function(e){e.length<19&&console.error("TGALoader: Not enough data to contain header.");var t=new Uint8Array(e),n=0,Ce={id_length:t[n++],colormap_type:t[n++],image_type:t[n++],colormap_index:t[n++]|t[n++]<<8,colormap_length:t[n++]|t[n++]<<8,colormap_size:t[n++],origin:[t[n++]|t[n++]<<8,t[n++]|t[n++]<<8],width:t[n++]|t[n++]<<8,height:t[n++]|t[n++]<<8,pixel_size:t[n++],flags:t[n++]},i=Ce;switch(i.image_type){case 1:case 9:(256<i.colormap_length||24!==i.colormap_size||1!==i.colormap_type)&&console.error("TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:i.colormap_type&&console.error("TGALoader: Invalid type colormap data for colormap type.");break;case 0:console.error("TGALoader: No data.");default:console.error('TGALoader: Invalid type "%s".',i.image_type)}(i.width<=0||i.height<=0)&&console.error("TGALoader: Invalid image size."),8!==i.pixel_size&&16!==i.pixel_size&&24!==i.pixel_size&&32!==i.pixel_size&&console.error('TGALoader: Invalid pixel size "%s".',i.pixel_size),Ce.id_length+18>e.length&&console.error("TGALoader: No data."),n+=Ce.id_length;var r=!1,o=!1,Re=!1;switch(Ce.image_type){case 9:o=r=!0;break;case 1:o=!0;break;case 10:r=!0;break;case 2:break;case 11:Re=r=!0;break;case 3:Re=!0}e=function(e,t,n,i,r){var o,a=n.pixel_size>>3,s=n.width*n.height*a;if(t&&(o=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e)for(var l,d,c,h=new Uint8Array(s),u=0,p=new Uint8Array(a);u<s;)if(d=1+(127&(l=r[i++])),128&l){for(c=0;c<a;++c)p[c]=r[i++];for(c=0;c<d;++c)h.set(p,u+c*a);u+=a*d}else{for(d*=a,c=0;c<d;++c)h[u+c]=r[i++];u+=d}else h=r.subarray(i,i+=t?n.width*n.height:s);return{pixel_data:h,palettes:o}}(r,o,Ce,n,t),n=function(e,t,n,F){var i,r,o,a,s,l,d=new Uint8Array(e*t*4);switch((48&Ce.flags)>>4){default:case 2:s=e,r=i=0,a=o=1,l=t;break;case 0:i=0,s=e,r=t-(o=1),l=a=-1;break;case 3:i=e-1,s=o=-1,r=0,a=1,l=t;break;case 1:i=e-1,r=t-1,l=a=s=o=-1}if(Re)switch(Ce.pixel_size){case 8:for(var c,h,u=d,N=r,j=a,_=l,V=i,k=o,U=s,G=n,z=0,p=Ce.width,f=N;f!==_;f+=j)for(h=V;h!==U;h+=k,z++)c=G[z],u[4*(h+p*f)+0]=c,u[4*(h+p*f)+1]=c,u[4*(h+p*f)+2]=c,u[4*(h+p*f)+3]=255;break;case 16:for(var m,g=d,N=r,W=a,Y=l,X=i,Q=o,Z=s,v=n,A=0,y=Ce.width,E=N;E!==Y;E+=W)for(m=X;m!==Z;m+=Q,A+=2)g[4*(m+y*E)+0]=v[A+0],g[4*(m+y*E)+1]=v[A+0],g[4*(m+y*E)+2]=v[A+0],g[4*(m+y*E)+3]=v[A+1];break;default:console.error("TGALoader: Format not supported.")}else switch(Ce.pixel_size){case 8:for(var M,w,b=d,q=r,K=a,J=l,$=i,ee=o,te=s,ne=n,ie=F,re=0,x=Ce.width,I=q;I!==J;I+=K)for(w=$;w!==te;w+=ee,re++)M=ne[re],b[4*(w+x*I)+3]=255,b[4*(w+x*I)+2]=ie[3*M+0],b[4*(w+x*I)+1]=ie[3*M+1],b[4*(w+x*I)+0]=ie[3*M+2];break;case 16:for(var T,S,B=d,q=r,oe=a,ae=l,se=i,le=o,de=s,ce=n,he=0,P=Ce.width,C=q;C!==ae;C+=oe)for(S=se;S!==de;S+=le,he+=2)T=ce[he+0]+(ce[he+1]<<8),B[4*(S+P*C)+0]=(31744&T)>>7,B[4*(S+P*C)+1]=(992&T)>>2,B[4*(S+P*C)+2]=(31&T)>>3,B[4*(S+P*C)+3]=32768&T?0:255;break;case 24:for(var R,ue=d,pe=r,fe=a,me=l,ge=i,ve=o,Ae=s,ye=n,Ee=0,Me=Ce.width,O=pe;O!==me;O+=fe)for(R=ge;R!==Ae;R+=ve,Ee+=3)ue[4*(R+Me*O)+3]=255,ue[4*(R+Me*O)+2]=ye[Ee+0],ue[4*(R+Me*O)+1]=ye[Ee+1],ue[4*(R+Me*O)+0]=ye[Ee+2];break;case 32:for(var L,we=d,pe=r,be=a,xe=l,Ie=i,Te=o,Se=s,Be=n,D=0,Pe=Ce.width,H=pe;H!==xe;H+=be)for(L=Ie;L!==Se;L+=Te,D+=4)we[4*(L+Pe*H)+2]=Be[D+0],we[4*(L+Pe*H)+1]=Be[D+1],we[4*(L+Pe*H)+0]=Be[D+2],we[4*(L+Pe*H)+3]=Be[D+3];break;default:console.error("TGALoader: Format not supported.")}return d}(Ce.width,Ce.height,e.pixel_data,e.palettes);return{width:Ce.width,height:Ce.height,data:n,magFilter:THREE.NearestFilter,minFilter:THREE.NearestFilter}}},function(e){var a=this;this.is2DModel=e,this.metrics={},this.TextMaterial={},this.TextMaterialItalic={},this.TextMaterialBold={},this.TextMaterialIandB={},this.blendMaterial=null,this.newblendMaterial=null,this.shxMaterial=null,this.mappableUnit=4096,this.textSize=100,this.textUnit=parseInt(1.125*this.textSize),this.specialCodeArray=[],this.AddSpecialCode(),this.AttributeArray=[],this.HashTable=[],this.textString="",this.textPos=[],this.geometrytoRange=[],this.lines=[],this.objectuuidToGeo={},this.numTextGeom=0,this.ttfCompositeStride=6,this.ttfGeometryBuffers=[],this.shxCompositeStride=3,this.ttfMeshCompositeStride=3,this.shxGeometryBuffers=[],this.ttfMeshGeometryBuffers=[],this.genTTFGeometryBuffer=function(e){void 0===e&&(e=1024);e={compositeIBuffer:new THREE.InterleavedBuffer(new Float32Array(4*e*a.ttfCompositeStride),a.ttfCompositeStride),index:new THREE.Uint32BufferAttribute(new Uint32Array(6*e),1),bufferOffset:0,indexOffset:0};return e.compositePositionAttrib=new THREE.InterleavedBufferAttribute(e.compositeIBuffer,3,0,!1),e.compositeUvAttrib=new THREE.InterleavedBufferAttribute(e.compositeIBuffer,2,3,!1),e.compositeTextureAttrib=new THREE.InterleavedBufferAttribute(e.compositeIBuffer,1,5,!1),a.ttfGeometryBuffers[a.ttfGeometryBuffers.length]=e,a.ttfGeometryBuffers.length-1},this.getTTFGeometryBuffer=function(e){for(var t=-1,n=0,i=a.ttfGeometryBuffers.length;n<i;++n){var r=a.ttfGeometryBuffers[n];if(4*e*a.ttfCompositeStride<r.compositeIBuffer.array.length-r.bufferOffset){t=n;break}}return t<0&&(t=a.genTTFGeometryBuffer(a.mappableUnit)),a.ttfGeometryBuffers[t]},this.genSHXGeometryBuffer=function(e){void 0===e&&(e=65536);e={compositeIBuffer:new THREE.InterleavedBuffer(new Float32Array(e*a.shxCompositeStride),a.shxCompositeStride),index:new THREE.Uint32BufferAttribute(new Uint32Array(e),1),bufferOffset:0,indexOffset:0};return e.compositePositionAttrib=new THREE.InterleavedBufferAttribute(e.compositeIBuffer,3,0,!1),a.shxGeometryBuffers[a.shxGeometryBuffers.length]=e,a.shxGeometryBuffers.length-1},this.genMeshTTFGeometryBuffer=function(e){void 0===e&&(e=65536);e={compositeIBuffer:new THREE.InterleavedBuffer(new Float32Array(e*a.ttfMeshCompositeStride),a.ttfMeshCompositeStride),index:new THREE.Uint32BufferAttribute(new Uint32Array(e),1),indexLine:new THREE.Uint32BufferAttribute(new Uint32Array(2*e),1),bufferOffset:0,indexOffset:0};return e.compositePositionAttrib=new THREE.InterleavedBufferAttribute(e.compositeIBuffer,3,0,!1),a.ttfMeshGeometryBuffers[a.ttfMeshGeometryBuffers.length]=e,a.ttfMeshGeometryBuffers.length-1},this.getMeshTTFGeometryBuffer=function(e){for(var t=-1,n=0,i=a.ttfMeshGeometryBuffers.length;n<i;++n){var r=a.ttfMeshGeometryBuffers[n];if(e*a.ttfMeshCompositeStride<r.compositeIBuffer.array.length-r.bufferOffset){t=n;break}}return t<0&&(t=a.genMeshTTFGeometryBuffer(65536)),a.ttfMeshGeometryBuffers[t]},this.getSHXGeometryBuffer=function(e){for(var t=-1,n=0,i=a.shxGeometryBuffers.length;n<i;++n){var r=a.shxGeometryBuffers[n];if(e*a.shxCompositeStride<r.compositeIBuffer.array.length-r.bufferOffset){t=n;break}}return t<0&&(t=a.genSHXGeometryBuffer(65536)),a.shxGeometryBuffers[t]},this.textCompositeStride=9,this.textGeometryBuffers=[],this.genTextGeometryBuffer=function(e,t){void 0===t&&(t=1024);t={compositeIBuffer:new THREE.InterleavedBuffer(new Float32Array(4*t*a.textCompositeStride),a.textCompositeStride),index:new THREE.Uint32BufferAttribute(new Uint32Array(6*t),1),bufferOffset:0,indexOffset:0,uuidtorange:new Object};return t.compositePositionAttrib=new THREE.InterleavedBufferAttribute(t.compositeIBuffer,3,0,!1),t.compositeColorAttrib=new THREE.InterleavedBufferAttribute(t.compositeIBuffer,3,3,!1),t.compositeUvAttrib=new THREE.InterleavedBufferAttribute(t.compositeIBuffer,2,6,!1),t.compositeTextureAttrib=new THREE.InterleavedBufferAttribute(t.compositeIBuffer,1,8,!1),a.textGeometryBuffers[e][a.textGeometryBuffers[e].length]=t,a.textGeometryBuffers[e].length-1},this.getTextGeometryBuffer=function(e,t){var n=-1;a.textGeometryBuffers[e]||(a.textGeometryBuffers[e]=[]);for(var i=0,r=a.textGeometryBuffers[e].length;i<r;++i){var o=a.textGeometryBuffers[e][i];if(4*t*a.textCompositeStride<o.compositeIBuffer.array.length-o.bufferOffset){n=i;break}}return n<0&&(n=a.genTextGeometryBuffer(e,a.mappableUnit)),a.textGeometryBuffers[e][n]},this.SDFVerison=1,this.nametotextureID=[],this.textures=[],this.shxTextArray=[],this.ShxData=null,this.ttfTextArray=[],this.ttfData=null,this.needShxLoad=!1}),Et=(le.prototype={constructor:le,SetVersion:function(e){this.SDFVerison=e},IsChinese:function(e){return 19968<=e.charCodeAt(0)&&e.charCodeAt(0)<=40869},IsChinese2:function(e){return 255<e.charCodeAt(0)},IsSpecialCharacter:function(e){return 8709==e||216==e||63740==e||177==e||63741==e||176==e||63742==e},IsShxFont:function(e){return!!e&&".shx"==e.substring(e.length-4).toLowerCase()},GetTextScale:function(e,t){return 3<=this.SDFVerison||this.IsShxFont(t)?1:1.6},GetTextOffset:function(e,t,n){return n||1==this.SDFVerison||3<=this.SDFVerison?0:this.IsShxFont(t)?.05:.25},AddSpecialCode:function(){for(var e=[8982,9007],t=0;t<e.length;++t)this.specialCodeArray.push(String.fromCharCode(e[t]))},getFontType:function(e){return this.is2DModel&&1==this.SDFVerison?"N":new RegExp("fang","gi").test(e)?"F":new RegExp("kaiti","gi").test(e)?"K":new RegExp("arial","gi").test(e)?"A":new RegExp("yahei","gi").test(e)?"M":new RegExp("SimSun","gi").test(e)?"S":"N"},CreateImage:((yt=document.createElement("canvas")).width=4096,yt.height=4096,function(e,t,n){void 0===t&&(t=!0),void 0===n&&(n=!1);for(var i,r,o,a=this.mappableUnit-this.textUnit,s=yt.getContext("2d",{willReadFrequently:!0}),l=(s.clearRect(0,0,this.mappableUnit,this.mappableUnit),s.textBaseline="bottom",s.fillStyle="black",s.clearRect(0,0,yt.width,yt.height),2),d=0,c=1,h=(this.metrics[0]=new Object,this.metrics[1]=new Object,this.metrics[2]=new Object,this.metrics[3]=new Object,null),u=0;u<e.length;u++){var p=e[u],f=this.IsChinese(p.charAt(0));switch(p.charAt(2)){case"I":i="italic "+this.textSize+"px ",r=le.ITALIC;break;case"B":i="bold "+this.textSize+"px ",r=le.BOLD;break;case"D":i="italic bold "+this.textSize+"px ",r=le.ITALICANDBOLD;break;case"N":i="normal "+this.textSize+"px ",r=le.NORMAL}var h=this.metrics[r],m=void 0,m=p.charAt(3);switch(p.charAt(3)){case"F":i+="FangSong";break;case"A":i+="Arial";break;case"S":i+="SimSun";break;case"K":i+="KaiTi";break;case"M":i+="Microsoft YaHei";break;case"N":m=f?(i+="FangSong","F"):(i+="Arial","A")}p=p.charAt(0),o=!1,-1!=this.specialCodeArray.indexOf(p)&&(o=!0),s.font=i,s.clearRect(a,a,this.textUnit,this.textUnit),s.textAlign="center",s.fillText(p,a+this.textUnit/2,this.mappableUnit);var g=50,v=0;if(f)b=this.textSize,g=0,v=112;else{for(var A=s.getImageData(a-2,a-2,this.textUnit,this.textUnit),y=0;y<this.textUnit;y++){for(var E=0;E<this.textUnit;E++){var M=A.data[4*(y*this.textUnit+E)+3];if(0!=M&&E<g){g=E;break}}for(var w=this.textUnit-1;0<=w;w--){M=A.data[4*(y*this.textUnit+w)+3];if(0!=M&&v<w){v=w;break}}}var b=v-g;b<0&&(b=6)}var x=this.textUnit/2>g?this.textUnit/2-g:0,d=((l=l+d+x+28)+(b>>1)>this.mappableUnit&&(l=(l=14)+((d=0)>>1)+(b>>1)+28,c++),s.textAlign="center",s.fillText(p,l,this.textUnit*c),v>this.textUnit/2?v-this.textUnit/2:0),I=l,T=this.textUnit*c,x={height:1,width:f?1:(b+28)/this.textUnit,left:this.textUnit/2>g?(I-x-7)/this.mappableUnit:(I+g-this.textUnit/2-7)/this.mappableUnit,top:1-(T-this.textUnit+7)/this.mappableUnit,right:this.textUnit/2>g?(I-x+b+7)/this.mappableUnit:(I+g-this.textUnit/2+b+7)/this.mappableUnit,bottom:1-T/this.mappableUnit};n&&f&&(x.height=1.5,x.width=1.5),o&&(I=x.right-x.left,x.right-=(I*=.35)/2,x.left+=I/2,T=x.top-x.bottom,x.top-=(T*=.35)/2,x.bottom+=T/2),h[m]||(h[m]=new Object),h[m][p]=x}var S=null;return t&&((S=document.createElement("img")).src=yt.toDataURL("image/png")),S}),addHash:function(e){this.HashTable.push(e)},containHash:function(e){return-1!=this.HashTable.indexOf(e)},getHashKey:function(){return this.HashTable.concat()},SetTexture:function(e,t,n){this.textures=e;for(var i=0;i<this.textures.length;++i)this.textures[i].flipY=!1,this.textures[i].needsUpdate=!0,this.blendMaterial&&(this.blendMaterial.uniforms["uSampler"+i].value=this.textures[i],this.blendMaterial.uniforms["uSampler"+i].value.flipY=!1,this.blendMaterial.uniforms["uSampler"+i].value.needsUpdate=!0),this.newblendMaterial&&t<2&&(this.newblendMaterial.uniforms["uSampler"+i].value=this.textures[i],this.newblendMaterial.uniforms["uSampler"+i].value.flipY=!1,this.newblendMaterial.uniforms["uSampler"+i].value.needsUpdate=!0);n&&n()},CollectCharSet:function(a){if(!a.charSetCollected){var s=this,l=!1,d=new Map;if(a.fonts)for(var e=0,t=a.fonts.length;e<t;++e)d.set(a.fonts[e].uuid,a.fonts[e]);for(var n=0;n<a.bufferchunks.length;n++)a.bufferchunks[n].geometries.map(function(e,t){if("TextGeometry"===e.type)for(var n=e.textFont,i=(!n.style&&a.fonts&&(n=d.get(e.textFont)),s.getFontType(n.name)),r=0;r<e.text.length;r++){var o=e.text.charAt(r);"normal"!=n.style&&"normal"==n.weight?o+="_I":"normal"!=n.weight&&"normal"==n.style?o+="_B":"normal"!=n.style&&"normal"!=n.weight?o+="_D":"normal"==n.style&&"normal"==n.weight&&(o+="_N"),o+=i,s.containHash(o)||(l=!0,s.addHash(o))}});var i=this.getHashKey();0!==i.length&&l&&(this.CreateImage(i,!1),a.charSetCollected=!0)}},CreateOldMaterialFromImage:function(e){var t=this,n=new THREE.ShaderMaterial({vertexColors:!0,uniforms:{uSampler0:{type:"t",value:null},uSampler1:{type:"t",value:null},uSampler2:{type:"t",value:null},uSampler3:{type:"t",value:null},uSampler4:{type:"t",value:null},uGamma:{type:"f",value:4e-4}},vertexShader:["varying vec2 vUv;","varying vec3 vColor;","varying float vtextureid;","attribute float textureid;","void main() { ","vUv = uv;","vColor = color;","vtextureid = textureid;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","varying vec2 vUv;","varying vec3 vColor;","varying float vtextureid;","uniform sampler2D uSampler0;","uniform sampler2D uSampler1;","uniform sampler2D uSampler2;","uniform sampler2D uSampler3;","uniform sampler2D uSampler4;","uniform float uGamma;","const float cBuffer = 0.2;","void main(void) {","float dist = 0.0;","if( vtextureid > -0.5 && vtextureid < 0.5){","dist = texture2D(uSampler0, vUv).a;","}","if( vtextureid > 0.5 && vtextureid < 1.5){","dist = texture2D(uSampler1, vUv).a;","}","if( vtextureid > 1.5 && vtextureid < 2.5){","dist = texture2D(uSampler2, vUv).a;","}","if( vtextureid > 2.5 && vtextureid < 3.5){","dist = texture2D(uSampler3, vUv).a;","}","if( vtextureid > 3.5 && vtextureid < 4.5){","dist = texture2D(uSampler4, vUv).a;","}","float alpha = smoothstep(cBuffer - uGamma, cBuffer + uGamma, dist);","vec3 destColor = vColor;","if(destColor.r> 1.0){","destColor.r = 1.0;","alpha = 0.0;","}","if(destColor.g> 1.0){","destColor.r = 0.090;","destColor.g = 0.501;","destColor.b = 0.890;","}","gl_FragColor = vec4(destColor, alpha);","}"].join("\n")});if(1<t.SDFVerison)for(var i,r=0;r<e.length;++r)(i=e[r]).flipY=!1,i.needsUpdate=!0,n.uniforms["uSampler"+r].value=i;else(i=new THREE.Texture(e)).needsUpdate=!0,n.uniforms.uSampler0.value=i;n.side=THREE.DoubleSide,n.transparent=!0,n.depthWrite=!1,n.alphaTest=.4,_e.StopPMIOcclusion&&(n.depthTest=!1),t.TextMaterial=n,t.TextMaterial.styleId=le.NORMAL,t.is2DModel&&1==t.SDFVerison&&(t.TextMaterialItalic=n,t.TextMaterialItalic.styleId=le.ITALIC,t.TextMaterialBold=n,t.TextMaterialBold.styleId=le.BOLD,t.TextMaterialIandB=n,t.TextMaterialIandB.styleId=le.ITALICANDBOLD)},CreateMaterial:function(a,e,t){function n(e,t,n,i){var r=new THREE.ShaderMaterial({vertexColors:!0,uniforms:{uSampler0:{type:"t",value:null},uSampler1:{type:"t",value:null},uSampler2:{type:"t",value:null},uSampler3:{type:"t",value:null},uSampler4:{type:"t",value:null},uGamma:{type:"f",value:4e-4},diffuse:{value:new THREE.Color(16777215)}},vertexShader:["varying vec2 vUv;","varying float vtextureid;","attribute float textureid;","void main() { ","vUv = uv;","vtextureid = textureid;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","varying vec2 vUv;","varying float vtextureid;","uniform sampler2D uSampler0;","uniform sampler2D uSampler1;","uniform sampler2D uSampler2;","uniform sampler2D uSampler3;","uniform sampler2D uSampler4;","uniform float uGamma;","uniform vec3 diffuse;","const float cBuffer = 0.2;","void main(void) {","float dist = 0.0;","if( vtextureid > -0.5 && vtextureid < 0.5){","dist = texture2D(uSampler0, vUv).a;","}","if( vtextureid > 0.5 && vtextureid < 1.5){","dist = texture2D(uSampler1, vUv).a;","}","if( vtextureid > 1.5 && vtextureid < 2.5){","dist = texture2D(uSampler2, vUv).a;","}","if( vtextureid > 2.5 && vtextureid < 3.5){","dist = texture2D(uSampler3, vUv).a;","}","if( vtextureid > 3.5 && vtextureid < 4.5){","dist = texture2D(uSampler4, vUv).a;","}","float alpha = smoothstep(cBuffer - uGamma, cBuffer + uGamma, dist);","vec3 destColor = diffuse;","if(destColor.r> 1.0){","destColor.r = 1.0;","alpha = 0.0;","}","if(destColor.g> 1.0){","destColor.r = 0.090;","destColor.g = 0.501;","destColor.b = 0.890;","}","gl_FragColor = vec4(destColor, alpha);","}"].join("\n")});if(1<e.SDFVerison)for(var o,a=0;a<t.length;++a)(o=t[a]).flipY=!1,o.needsUpdate=!0,r.uniforms["uSampler"+a].value=o;else(o=new THREE.Texture(t)).needsUpdate=!0,r.uniforms.uSampler0.value=o;switch(r.side=THREE.DoubleSide,r.transparent=!0,r.depthWrite=!1,r.alphaTest=.4,n){case le.ITALIC:e.TextMaterialItalic=r,e.TextMaterialItalic.styleId=n;break;case le.BOLD:e.TextMaterialBold=r,e.TextMaterialBold.styleId=n;break;case le.NORMAL:e.TextMaterial=r,e.TextMaterial.styleId=n;break;case le.ITALICANDBOLD:e.TextMaterialIandB=r,e.TextMaterialIandB.styleId=n;break;case le.BLEND:i?(e.newblendMaterial=r,e.newblendMaterial.styleId=n):(e.blendMaterial=r,e.blendMaterial.styleId=n)}}var s=new Map;if(a.fonts)for(var i=0,F=a.fonts.length;i<F;++i)s.set(a.fonts[i].uuid,a.fonts[i]);var l=this;if(4==e&&this.SDFVerison==e&&a){this.metrics[le.NORMAL]=new Object,this.metrics[le.BOLD]=new Object,this.metrics[le.ITALIC]=new Object,this.metrics[le.ITALICANDBOLD]=new Object;for(var r=0;r<a.length;r++){var o=a[r].name,d=a[r].str,c=!a[r].isTTF,h=a[r].isTTF,N=a[r].bVertical,u=(this.nametotextureID[o]=c?0:a[r].textureid,a[r].uvs),j=a[r].range,p=c?d&&u?u.length/d.length:7:6,f=new Object;if(d&&u)for(var m=0;m<d.length;m++){var g,_=d[m];c?(g=j[m],f[_]={advanceX:u[m*p],advanceY:u[m*p+1],left:u[m*p+2],right:u[m*p+3],top:u[m*p+4],bottom:u[m*p+5],fontScale:7==p?u[m*p+6]:1,shxRange:0==g.length?null:g,isShx:c,isTTF:h,isVertical:c&&N}):(g=j[m],f[_]={advanceX:u[m*p],advanceY:u[m*p+1],left:u[m*p+2],right:u[m*p+3],top:u[m*p+4],bottom:u[m*p+5],shxRange:0==g.length?null:g,isShx:c,isTTF:h,isVertical:c&&N})}switch(a[r].styleId){case 0:this.metrics[le.NORMAL][o]=f;break;case 1:this.metrics[le.BOLD][o]=f;break;case 2:this.metrics[le.ITALIC][o]=f;break;case 3:this.metrics[le.ITALICANDBOLD][o]=f}}this.shxMaterial=new THREE.ShaderMaterial({uniforms:{diffuse:{value:new THREE.Color(16777215)},max2:{value:new THREE.Vector2(0,0)},min2:{value:new THREE.Vector2(0,0)}},vertexShader:["varying vec2 posxy;","void main() { ","vec4 tmp = modelMatrix * vec4(position, 1.0);","posxy.xy= tmp.xy;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","uniform vec3 diffuse;","uniform vec2 max2;","uniform vec2 min2;","varying vec2 posxy;","void main(void) {","float alpha=1.0;","if(max2.x > min2.x && max2.y > min2.y && (posxy.x < min2.x || posxy.x > max2.x || posxy.y < min2.y || posxy.y > max2.y)){","alpha = 0.0;","}","gl_FragColor = vec4(diffuse, alpha);","}"].join("\n")}),this.shxMaterial.transparent=!0,this.shxMaterial.depthWrite=!1,this.blendMaterial=new THREE.ShaderMaterial({uniforms:{diffuse:{value:new THREE.Color(16777215)},max2:{value:new THREE.Vector2(0,0)},min2:{value:new THREE.Vector2(0,0)}},vertexShader:["varying vec2 posxy;","void main() { ","vec4 tmp = modelMatrix * vec4(position, 1.0);","posxy.xy= tmp.xy;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","uniform vec3 diffuse;","uniform vec2 max2;","uniform vec2 min2;","varying vec2 posxy;","void main(void) {","float alpha=1.0;","if(max2.x > min2.x && max2.y > min2.y && (posxy.x < min2.x || posxy.x > max2.x || posxy.y < min2.y || posxy.y > max2.y)){","alpha = 0.0;","}","gl_FragColor = vec4(diffuse, alpha);","}"].join("\n")}),this.blendMaterial.transparent=!0,this.blendMaterial.depthWrite=!1,this.TextMaterialItalic=this.blendMaterial,this.TextMaterial=this.blendMaterial,this.TextMaterialBold=this.blendMaterial,this.TextMaterialIandB=this.blendMaterial}else if(3==e&&this.SDFVerison==e&&a){for(var V=new Object,v=0;v<a.length;v++){var k=a[v].name,A=a[v].str,y=void 0===a[v].textureid,E=(this.nametotextureID[k]=y?0:a[v].textureid,a[v].uvs),U=a[v].range,M=y?2:10,w=new Object;if(A&&E)for(var b=0;b<A.length;b++){var x,G=A[b];y?(x=U[b],w[G]={advanceX:E[b*M],advanceY:E[b*M+1],shxRange:0==x.length?null:x,isShx:!0}):w[G]={top:E[b*M],bottom:E[b*M+1],left:E[b*M+2],right:E[b*M+3],bearingX:E[b*M+4],bearingY:E[b*M+5],advanceX:E[b*M+6],advanceY:E[b*M+7],width:E[b*M+8],height:E[b*M+9],shxRange:null,isShx:!1}}V[k]=w}this.metrics[le.BLEND]=V,n(this,this.textures,le.BLEND,!1),this.shxMaterial=new THREE.ShaderMaterial({uniforms:{diffuse:{value:new THREE.Color(16777215)}},vertexShader:["void main() { ","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","uniform vec3 diffuse;","void main(void) {","gl_FragColor = vec4(diffuse, 1.0);","}"].join("\n")})}else if(2==e&&this.SDFVerison==e&&a){for(var z=new Object,I=0;I<a.length;I++){var W=a[I].name,T=a[I].uvs,S=a[I].str,Y=(this.nametotextureID[W]=a[I].textureid,a[I].shapid),B=a[I].range,P={};if(B)for(var C=0;C<B.length;C++)P[B[C].char]=B[C].data;var R=new Object;if(S&&T)for(var O=0;O<S.length;O++){var X=S[O];R[X]={height:1,width:(T[4*O+3]-T[4*O+2])/(T[4*O+1]-T[4*O]),left:T[4*O+2],top:T[4*O],right:T[4*O+3],bottom:T[4*O+1],shxRange:null!=B?P[X]:null}}if(Y)for(var L=Y.split(","),D=0;D<L.length&&L[D];D++)R[L[D]]={height:2<=t?4:2,width:2<=t?4:2*(T[4*D+3]-T[4*D+2])/(T[4*D+1]-T[4*D]),left:T[4*D+2],top:T[4*D],right:T[4*D+3],bottom:T[4*D+1],shxRange:null!=B?P[String.fromCharCode(L[D])]:null},"131"==L[D]&&(R[L[D]].height=2<=t?4:1,R[L[D]].width=2<=t?4:2),"130"==L[D]&&2<=t&&(R[L[D]].height=4,R[L[D]].width=1);z[W]=R}this.metrics[le.BLEND]=z,1==t?(this.CreateOldMaterialFromImage(this.textures,le.BLEND),n(this,this.textures,le.BLEND,!0)):(n(this,this.textures,le.BLEND,!1),this.shxMaterial=new THREE.ShaderMaterial({uniforms:{diffuse:{value:new THREE.Color(16777215)}},vertexShader:["void main() { ","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","uniform vec3 diffuse;","void main(void) {","gl_FragColor = vec4(diffuse, 1.0);","}"].join("\n")}))}else if(1==e&&this.SDFVerison==e&&a){for(var H=0;H<a.bufferchunks.length;H++)a.bufferchunks[H].geometries.map(function(e,t){if("TextGeometry"===e.type)for(var n=e.textFont,i=(!n.style&&a.fonts&&(n=s.get(e.textFont)),l.getFontType(n.name)),r=0;r<e.text.length;r++){var o=e.text.charAt(r);"normal"!=n.style&&"normal"==n.weight?o+="_I":"normal"!=n.weight&&"normal"==n.style?o+="_B":"normal"!=n.style&&"normal"!=n.weight?o+="_D":"normal"==n.style&&"normal"==n.weight&&(o+="_N"),o+=i,l.containHash(o)||l.addHash(o)}});0!==(e=this.getHashKey()).length&&(e=this.CreateImage(e,!0,this.is2DModel&&1==this.SDFVerison),this.CreateOldMaterialFromImage(e))}},GetMaterialStyleId:function(e,t,n){var i;return"normal"!=e&&"normal"!=t?i=le.ITALICANDBOLD:"normal"==e&&"normal"==t?i=le.NORMAL:"normal"!=e&&"normal"==t?i=le.ITALIC:"normal"==e&&"normal"!=t&&(i=le.BOLD),1<this.SDFVerison&&this.SDFVerison<4&&(i=le.BLEND),i=n?le.SHX:i},RegText:function(e){var t={text:e,underscode:!1,dash:!1,box:!1,superscript:!1,superscriptbegin:0,superscriptend:0,subscript:!1,subscriptbegin:0,subscriptend:0},n=new RegExp("%%145|%%144","gi"),n=(e=e.replace(n,""),(n=new RegExp("%%u","gi")).test(e)&&(e=e.replace(n,""),t.underscode=!0),(n=new RegExp("%%o","gi")).test(e)&&(e=e.replace(n,""),t.dash=!0),(n=new RegExp("%%nnn","gi")).test(e)&&(e=e.replace(n,""),t.box=!0),(n=new RegExp("%%140","gi")).test(e)&&(t.superscriptbegin=e.search(n),t.superscriptend=e.search("%%141"),t.superscriptend-=6,t.superscript=!0),(n=new RegExp("%%142","gi")).test(e)&&(t.subscriptbegin=e.search(n),t.subscriptend=e.search("%%143"),t.subscriptend-=6,t.subscript=!0),new RegExp("%%140|%%141|%%142|%%143","gi"));return t.text=e.replace(n,""),t.subscript&&-7==t.subscriptend&&(t.subscriptend=t.text.length),t},ParseSDFTextGeometry:function(e,t,n,i,r,o,a,s,l,d,c){void 0===a&&(a=!1),void 0===s&&(s=!1),void 0===d&&(d=!1),void 0===c&&(c=2);for(var h,F,u=0,p=0,f=(l=void 0===l?!1:l)?1:e.text.length,m=0,g=0,v=0,A=new((o=void 0===o?!1:o)?de:THREE.BufferGeometry),y=(A.textLoad="ttfLoad",this.GetMaterialStyleId(e.textFont.style,e.textFont.weight,!1)),E=this.RegText(e.text),M=(e.text=E.text,A.type="TextBufferGeometry",A.name=e.text,A.styleId=y,e.index&&(A.textIndex=e.index),null==e.subInd&&null==e.subInd||(A.subInd=e.subInd),0),w=0,b=[],x=0,I=0;I<e.text.length;I++){var T,S,B,P,C,R,O,L,D=l?e.text:e.text[I];if(!(T=this.GetDimensionsForSize(D,e.textFont.size,y,e.textFont.name,e.textFont.width,e.textFont.bigName)))return null;if(T.isShx||T.isTTF)return A.isShx=T.isShx,A.isTTF=T.isTTF,A.textLoad="unLoad",A.styleId=T.isShx?le.SHX:le.BLEND,S=new THREE.Euler,n&&S.setFromQuaternion(n),u=e.text.length*(2<c?T.advanceX:T.width),p<T.height+T.bearingY&&(p=T.height+T.bearingY),d&&((e.regResult=E).underscode&&((B=new THREE.LineBasicMaterial).color.setRGB(i.r,i.g,i.b),(P=new THREE.Geometry).vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(u,0,0)),P.rotateZ(S.z),P.rotateY(S.y),P.rotateX(S.x),P.translate(t.x,t.y-.1*T.height,t.z),(C=new THREE.LineSegments(P,B)).name=r,C.color=B.color.clone(),this.AddLine(C)),E.box&&((B=new THREE.LineBasicMaterial).color.setRGB(i.r,i.g,i.b),(P=new THREE.Geometry).vertices.push(new THREE.Vector3(u,p,0),new THREE.Vector3(u,0,0),new THREE.Vector3(u,0,0),new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0),new THREE.Vector3(0,p,0),new THREE.Vector3(0,p,0),new THREE.Vector3(u,p,0)),P.rotateZ(S.z),P.rotateY(S.y),P.rotateX(S.x),P.translate(t.x,t.y,t.z),(C=new THREE.LineSegments(P,B)).name=r,C.color=B.color.clone(),this.AddLine(C)),E.dash)&&((B=new THREE.LineBasicMaterial).color.setRGB(i.r,i.g,i.b),(P=new THREE.Geometry).vertices.push(new THREE.Vector3(0,p,0),new THREE.Vector3(u,p,0)),P.rotateZ(S.z),P.rotateY(S.y),P.rotateX(S.x),P.translate(t.x,t.y+.1*T.height,t.z),(C=new THREE.LineSegments(P,B)).name=r,C.color=B.color.clone(),this.AddLine(C)),A;if(0===I&&(g=(m=(H=this.getTTFGeometryBuffer(f)).bufferOffset)/6,R=H.compositePositionAttrib,O=H.compositeUvAttrib,L=H.compositeTextureAttrib,H.bufferOffset+=24*f,F=H.index,h=H.index.array,v=H.indexOffset,H.indexOffset+=6*f),2<c&&" "==D)M=M<(u+=T.advanceX)?u:M,w=T.height>w?T.height:w,x=T.bearingY<x?T.bearingY:x,b.push(2<c?T.advanceX:T.width,T.height);else{(E.superscript&&I>=E.superscriptbegin&&I<=E.superscriptend||E.subscript&&I>=E.subscriptbegin&&I<=E.subscriptend)&&(T.height*=.5,T.width*=.5,T.bearingX*=.5,T.bearingY*=.5,T.advanceX*=.5,T.advanceY*=.5),E.superscript&&I>=E.superscriptbegin&&I<=E.superscriptend&&(T.bearingY-=T.height),p<T.height+T.bearingY&&(p=T.height+T.bearingY);var H=e.textFont.rotate&&this.IsChinese(D);if(R.data.array[m+24*I]=u+T.bearingX,R.data.array[m+24*I+1]=T.height+T.bearingY,R.data.array[m+24*I+2]=0,O.data.array[m+24*I+3]=H?T.right:T.left,O.data.array[m+24*I+4]=T.top,L.data.array[m+24*I+5]=T.textureid,R.data.array[m+24*I+6]=u+T.bearingX+T.width,R.data.array[m+24*I+7]=T.height+T.bearingY,R.data.array[m+24*I+8]=0,O.data.array[m+24*I+9]=T.right,O.data.array[m+24*I+10]=H?T.bottom:T.top,L.data.array[m+24*I+11]=T.textureid,R.data.array[m+24*I+12]=u+T.bearingX,R.data.array[m+24*I+13]=T.bearingY,R.data.array[m+24*I+14]=0,O.data.array[m+24*I+15]=T.left,O.data.array[m+24*I+16]=H?T.top:T.bottom,L.data.array[m+24*I+17]=T.textureid,R.data.array[m+24*I+18]=u+T.bearingX+T.width,R.data.array[m+24*I+19]=T.bearingY,R.data.array[m+24*I+20]=0,O.data.array[m+24*I+21]=H?T.left:T.right,O.data.array[m+24*I+22]=T.bottom,L.data.array[m+24*I+23]=T.textureid,h[v+6*I]=g+4*I,h[v+6*I+1]=g+4*I+2,h[v+6*I+2]=g+4*I+1,h[v+6*I+3]=g+4*I+2,h[v+6*I+4]=g+4*I+3,h[v+6*I+5]=g+4*I+1,M=M<(u+=2<c?T.advanceX:T.width)?u:M,w=T.height>w?T.height:w,x=T.bearingY<x?T.bearingY:x,b.push(2<c?T.advanceX:T.width,T.height),l)break}}return"ttfLoad"==A.textLoad&&(A.addAttribute("position",R),A.addAttribute("uv",O),A.addAttribute("textureid",L),A.setIndex(F),A.drawRange.start=v,A.drawRange.count=6*f),A.characterWidthHeight=b,A.rectWidth=M,A.rectHeight=w,A.rectBearingY=x,A.rectBearingX=0,d&&(S=new THREE.Euler,n&&S.setFromQuaternion(n),c<2&&(A.rotateZ(S.z),A.rotateY(S.y),A.rotateX(S.x),A.translate(t.x,t.y,t.z),this.AddObject(A,y,r)),E.underscode&&((B=new THREE.LineBasicMaterial).color.setRGB(i.r,i.g,i.b),(P=new THREE.Geometry).vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(u,0,0)),P.rotateZ(S.z),P.rotateY(S.y),P.rotateX(S.x),P.translate(t.x,t.y-.1*T.height,t.z),(C=new THREE.LineSegments(P,B)).name=r,C.color=B.color.clone(),this.AddLine(C)),E.box&&((B=new THREE.LineBasicMaterial).color.setRGB(i.r,i.g,i.b),(P=new THREE.Geometry).vertices.push(new THREE.Vector3(u,p,0),new THREE.Vector3(u,0,0),new THREE.Vector3(u,0,0),new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0),new THREE.Vector3(0,p,0),new THREE.Vector3(0,p,0),new THREE.Vector3(u,p,0)),P.rotateZ(S.z),P.rotateY(S.y),P.rotateX(S.x),P.translate(t.x,t.y,t.z),(C=new THREE.LineSegments(P,B)).name=r,C.color=B.color.clone(),this.AddLine(C)),E.dash)&&((B=new THREE.LineBasicMaterial).color.setRGB(i.r,i.g,i.b),(P=new THREE.Geometry).vertices.push(new THREE.Vector3(0,p,0),new THREE.Vector3(u,p,0)),P.rotateZ(S.z),P.rotateY(S.y),P.rotateX(S.x),P.translate(t.x,t.y+.1*T.height,t.z),(C=new THREE.LineSegments(P,B)).name=r,C.color=B.color.clone(),this.AddLine(C)),A},AddShxTextInfo:function(e){this.shxTextArray.push(e)},AddTtfTextInfo:function(e){this.ttfTextArray.push(e)},ProcessShxText:function(e,t,n){null!=t&&(this.ShxData=t);for(var i=0;i<this.shxTextArray.length;i++){var r=this.shxTextArray[i],o=e.ndsModel.getGeomManager().getGeomFromUuid(r.geomuuid,r.id);o&&(this.SetShxTextGeometry(this.ShxData,o,r.jsonText,!1,n),o.needsUpdate=!0,o.textLoad="shxLoad")}},ProcessTtfText:function(e,t,n){null!=t&&(this.ttfData=t);for(var i=0;i<this.ttfTextArray.length;i++){var r=this.ttfTextArray[i],o=e.ndsModel.getGeomManager().getGeomFromUuid(r.geomuuid,r.id);o&&(this.SetTtfTextGeometry(this.ttfData,o,r.jsonText,!1,n),o.needsUpdate=!0,o.textLoad="ttfLoad")}},SetLineStyleShxTextGeometry:function(e,t,n,i,r){if(!e)return!1;for(var o=0,a=this.GetMaterialStyleId(n.textFont.style,n.textFont.weight,!1),s=this.RegText(n.text),l=(n.text=s.text,new THREE.Box3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0))),d=new THREE.Box3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0)),c=[],h=[],u=0,p=[],f=0,m=0,g=0,v=0;v<n.text.length;v++){d.set(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0));var A=i?n.text:n.text[v],y=this.GetDimensionsForSize(A,n.textFont.size,a,n.textFont.name,n.textFont.width,n.textFont.bigName);if(y&&y.shxRange){for(var E=y.height,M=y.width,w=y.shxRange[0],b=1;b<y.shxRange.length;b++){for(var x=w;x<y.shxRange[b]+w;x+=4)c.push(o+e[x]*M),c.push(e[x+1]*E),c.push(0),c.push(o+e[x+2]*M),c.push(e[x+3]*E),c.push(0),h[u]=u,h[++u]=u,u++,d.expandByPoint(new THREE.Vector3(o+e[x]*M,e[x+1]*E,0)),d.expandByPoint(new THREE.Vector3(o+e[x+2]*M,e[x+3]*E,0)),l.expandByPoint(new THREE.Vector3(o+e[x]*M,e[x+1]*E,0)),l.expandByPoint(new THREE.Vector3(o+e[x+2]*M,e[x+3]*E,0));w+=y.shxRange[b]}o+=2<r?y.advanceX:y.width;var f=l.min.y<f?l.min.y:f,g=l.min.x<g?l.min.x:g,I=l.max.x-l.min.x-m,m=l.max.x-l.min.x,T=d.max.y-d.min.y;if(p.push(I,T),i)break}else" "!=A&&console.log("LineStyle faild: ",A," info: ",n),o+=2<r?y.advanceX:y.width}s=new Float32Array(c),s=new THREE.InterleavedBuffer(s,3),s=new THREE.InterleavedBufferAttribute(s,3,0,!1);return t.addAttribute("position",s),t.setIndex(new(65536<c.length/3?THREE.Uint32BufferAttribute:256<c.length/3?THREE.Uint16BufferAttribute:THREE.Uint8BufferAttribute)(h,1)),t.characterWidthHeight=p,t.rectWidth=l.max.x-l.min.x,t.rectHeight=l.max.y-l.min.y,t.rectBearingY=f,t.rectBearingX=g,!0},SetLineStyleTtfTextGeometry:function(e,t,n,i,r){if(!e)return!1;for(var o=0,a=this.GetMaterialStyleId(n.textFont.style,n.textFont.weight,!1),s=this.RegText(n.text),l=(n.text=s.text,new THREE.Box3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0))),d=new THREE.Box3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0)),c=[],h=[],u=0,p=[],f=0,m=0,g=0,v=0;v<n.text.length;v++){d.set(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0));var A=i?n.text:n.text[v],y=this.GetDimensionsForSize(A,n.textFont.size,a,n.textFont.name,n.textFont.width,n.textFont.bigName);if(y&&y.shxRange){for(var E=y.height,M=y.width,w=y.shxRange[0],b=1;b<y.shxRange.length;b++){for(var x=w;x<y.shxRange[b]+w;x+=6)c[c.length]=o+e[x]*M,c[c.length]=e[x+1]*E+y.bearingY,c[c.length]=0,c[c.length]=o+e[x+2]*M,c[c.length]=e[x+3]*E+y.bearingY,c[c.length]=0,c[c.length]=o+e[x+4]*M,c[c.length]=e[x+5]*E+y.bearingY,c[c.length]=0,h[u]=u,h[++u]=u,h[++u]=u,u++,d.expandByPoint(new THREE.Vector3(o+e[x]*M,e[x+1]*E+y.bearingY,0)),d.expandByPoint(new THREE.Vector3(o+e[x+2]*M,e[x+3]*E+y.bearingY,0)),d.expandByPoint(new THREE.Vector3(o+e[x+4]*M,e[x+5]*E+y.bearingY,0)),l.expandByPoint(new THREE.Vector3(o+e[x]*M,e[x+1]*E+y.bearingY,0)),l.expandByPoint(new THREE.Vector3(o+e[x+2]*M,e[x+3]*E+y.bearingY,0)),l.expandByPoint(new THREE.Vector3(o+e[x+4]*M,e[x+5]*E+y.bearingY,0));w+=y.shxRange[b]}o+=2<r?y.advanceX:y.width;var f=l.min.y<f?l.min.y:f,g=l.min.x<g?l.min.x:g,I=l.max.x-l.min.x-m,m=l.max.x-l.min.x,T=d.max.y-d.min.y;if(p.push(I,T),i)break}else" "!=A&&console.log("LineStyle faild: ",A," info: ",n),o+=2<r?y.advanceX:y.width}s=new Float32Array(c),s=new THREE.InterleavedBuffer(s,3),s=new THREE.InterleavedBufferAttribute(s,3,0,!1);return t.addAttribute("position",s),t.setIndex(new(65536<c.length/3?THREE.Uint32BufferAttribute:256<c.length/3?THREE.Uint16BufferAttribute:THREE.Uint8BufferAttribute)(h,1)),t.characterWidthHeight=p,t.rectWidth=l.max.x-l.min.x,t.rectHeight=l.max.y-l.min.y,t.rectBearingY=f,t.rectBearingX=g,!0},SetTtfTextGeometry:function(e,t,n,i,r){for(var o=0,a=this.GetMaterialStyleId(n.textFont.style,n.textFont.weight,!1),s=this.RegText(n.text),l=(n.text=s.text,[]),d=[],c=[],h=0,u=new THREE.Box3,p=0;p<n.text.length;p++){var f=i?n.text:n.text[p],m=this.GetDimensionsForSize(f,n.textFont.size,a,n.textFont.name,n.textFont.width,n.textFont.bigName);if(m&&m.shxRange){n.regResult&&((n.regResult.superscript&&p>=n.regResult.superscriptbegin&&p<=n.regResult.superscriptend||n.regResult.subscript&&p>=n.regResult.subscriptbegin&&p<=n.regResult.subscriptend)&&(m.height*=.5,m.width*=.5,m.bearingX*=.5,m.bearingY*=.5,m.advanceX*=.5,m.advanceY*=.5),n.regResult.superscript)&&p>=n.regResult.superscriptbegin&&p<=n.regResult.superscriptend&&(m.bearingY+=m.height);for(var g=m.height,v=m.width,A=m.shxRange[0],y=1;y<m.shxRange.length;y++){for(var E=A;E<m.shxRange[y]+A;E+=6){var M=l.length;l[M]=o+e[E]*v,l[M+1]=e[E+1]*g+m.bearingY,l[M+2]=0,l[M+3]=o+e[E+2]*v,l[M+4]=e[E+3]*g+m.bearingY,l[M+5]=0,l[M+6]=o+e[E+4]*v,l[M+7]=e[E+5]*g+m.bearingY,l[M+8]=0,d[h]=h,d[++h]=h,d[++h]=h,h++,u.expandByPoint(new THREE.Vector3(l[M],l[M+1],l[M+2])),u.expandByPoint(new THREE.Vector3(l[M+3],l[M+4],l[M+5])),u.expandByPoint(new THREE.Vector3(l[M+6],l[M+7],l[M+8]))}A+=m.shxRange[y]}if(o+=2<r?m.advanceX:m.width,i)break}else" "!=f&&console.log("faild: ",f," info: ",n),o+=2<r?m.advanceX:m.width}var w=this.getMeshTTFGeometryBuffer(l.length/3);t.drawRange.start=w.indexOffset,t.drawRange.count=d.length;for(var b=0,x=d.length;b<x;b+=3)d[b]+=w.indexOffset,d[b+1]+=w.indexOffset,d[b+2]+=w.indexOffset,c[2*b]=d[b],c[2*b+1]=d[b+1],c[2*b+2]=d[b+1],c[2*b+3]=d[b+2],c[2*b+4]=d[b+2],c[2*b+5]=d[b];w.compositeIBuffer.array.set(l,w.bufferOffset),w.bufferOffset+=l.length,w.index.array.set(d,w.indexOffset),w.indexLine.array.set(c,2*w.indexOffset),w.indexOffset+=d.length;s=w.compositePositionAttrib;t.addAttribute("position",s),t.setIndex(w.index),t.boundingBox=u,t.textWireFrame=new THREE.BufferGeometry,t.textWireFrame.drawRange.start=2*t.drawRange.start,t.textWireFrame.drawRange.count=2*t.drawRange.count,t.textWireFrame.addAttribute("position",s),t.textWireFrame.setIndex(w.indexLine),t.textWireFrame.name="ttf wireframe",t.textWireFrame.needsUpdate=!0},SetShxTextGeometry:function(e,t,n,i,r){for(var o=0,a=this.GetMaterialStyleId(n.textFont.style,n.textFont.weight,!1),s=this.RegText(n.text),l=(n.text=s.text,[]),d=[],c=0,h=new THREE.Box3,u=0,p=0,f=[],m=0,g=0;g<n.text.length;g++){var v=i?n.text:n.text[g],A=this.GetDimensionsForSize(v,n.textFont.size,a,n.textFont.name,n.textFont.width,n.textFont.bigName);if(A&&A.shxRange){n.regResult&&((n.regResult.superscript&&g>=n.regResult.superscriptbegin&&g<=n.regResult.superscriptend||n.regResult.subscript&&g>=n.regResult.subscriptbegin&&g<=n.regResult.subscriptend)&&(A.height*=.5,A.width*=.5,A.bearingX*=.5,A.bearingY*=.5,A.advanceX*=.5,A.advanceY*=.5),n.regResult.superscript)&&g>=n.regResult.superscriptbegin&&g<=n.regResult.superscriptend&&(A.bearingY+=A.height);for(var y=A.height,E=A.width,M=A.shxRange[0],w=1;w<A.shxRange.length;w++){for(var b=M;b<A.shxRange[w]+M;b+=4){var x=l.length;l[x]=o+e[b]*E,l[x+1]=e[b+1]*y+A.bearingY,l[x+2]=0,l[x+3]=o+e[b+2]*E,l[x+4]=e[b+3]*y+A.bearingY,l[x+5]=0,d[c]=c,d[++c]=c,c++,h.expandByPoint(new THREE.Vector3(l[x],l[x+1],l[x+2])),h.expandByPoint(new THREE.Vector3(l[x+3],l[x+4],l[x+5]))}M+=A.shxRange[w]}if(u=o+=2<r?A.advanceX:A.width,p=A.height>p?A.height:p,m=A.bearingY<m?A.bearingY:m,f.push(2<r?A.advanceX:A.width,A.height),i)break}else" "!=v&&console.log("faild: ",v," info: ",n),u=o+=2<r?A.advanceX:A.width,p=A.height>p?A.height:p,m=A.bearingY<m?A.bearingY:m,f.push(2<r?A.advanceX:A.width,A.height)}var I=this.getSHXGeometryBuffer(l.length/3);t.characterWidthHeight=f,t.rectWidth=u,t.rectHeight=p,t.rectBearingY=m,t.rectBearingX=0,t.drawRange.start=I.indexOffset,t.drawRange.count=d.length;for(var T=0,S=d.length;T<S;++T)d[T]+=I.indexOffset;I.compositeIBuffer.array.set(l,I.bufferOffset),I.bufferOffset+=l.length,I.index.array.set(d,I.indexOffset),I.indexOffset+=d.length;s=I.compositePositionAttrib;t.addAttribute("position",s),t.setIndex(I.index),t.boundingBox=h},GetDimensionsForSize:function(e,t,n,i,r,o){var a,s=null,l=i,d="msyh.ttf",c="gbenor.shx",h="gbcbig.shx",c=(2<this.SDFVerison&&this.metrics[n]?(o&&this.metrics[n][o]&&(s=this.metrics[n][o][e],l=o),!s&&this.metrics[n][i]&&(s=this.metrics[n][i][e],l=i),s||(this.IsShxFont(i)?(!s&&this.metrics[n][h]&&(s=this.metrics[n][h][e],l=h),!s&&this.metrics[n][c]&&(s=this.metrics[n][c][e],l=c)):!s&&this.metrics[n][d]&&(s=this.metrics[n][d][e],l=d))):2==this.SDFVerison&&this.metrics[n]?(this.metrics[n][i]&&(s=this.metrics[n][i][e],l=i),!s&&o&&this.metrics[n][o]&&(s=this.metrics[n][o][e],l=o),!s&&this.metrics[n][d]&&(s=this.metrics[n][d][e],l=d)):1==this.SDFVerison&&this.metrics[n]&&("N"==(h=this.getFontType(i))&&(h=this.IsChinese(e)?"F":"A"),s=this.metrics[n][h][e],l=d),!1),s=s||{height:1,width:1,left:0,top:0,right:1,bottom:1,textureid:0,shxRange:null,advanceX:0,advanceY:0,bearingX:0,bearingY:0,isShx:!(c=!0),isTTF:!1},o=1,i=1,n=1,h=0,d=0,u=0,p=0,f=5,m=!1,g=!1,v=!1;return 1==this.SDFVerison?(i=s.width*o*t,n=s.height*t,f=c?5:this.nametotextureID[l]):2==this.SDFVerison?(a=this.GetTextScale(e,l),i=s.width*a*(o=null==r?1:r)*t,n=s.height*a*t,f=c?5:this.nametotextureID[l],m=null!=s.shxRange,d=-n*this.GetTextOffset(null,l,m),o*=o<1.5?.95:1):3<=this.SDFVerison&&(u=s.advanceX*(o=null==r?1:r)*t,p=s.advanceY*t," "==e?s.isShx||s.isTTF?(n=i=u,m=s.isShx,g=s.isTTF,v=s.isVertical):(n=i=u,f=c?5:this.nametotextureID[l],h=s.bearingX*o*t,d=s.bearingY*t):s.isShx||s.isTTF?(i=i*o*t,n*=t,m=s.isShx,g=s.isTTF,v=s.isVertical):(i=s.width*o*t,n=s.height*t,f=c?5:this.nametotextureID[l],h=s.bearingX*o*t,d=s.bearingY*t)),{width:i,height:n,bearingX:h,bearingY:d,advanceX:u,advanceY:p,left:s.left,top:s.top,right:s.right,bottom:s.bottom,textureid:f||0,font:l,widthScale:o,discard:c,isShx:m,isTTF:g,isVertical:v,shxRange:s.shxRange,fontScale:s.fontScale||1}},AddTextGeometryBuffer:function(e,t,n,i,r){var o=this.AttributeArray[t];o&&!Array.isArray(o)?this.AttributeArray[t]=o=[o]:o||(this.AttributeArray[t]=o=[]),e.uuidtorange[n]={start:i,count:r},o.indexOf(e)<0&&(o[o.length]=e)},AddObject:function(e,t,n){var i=this.AttributeArray[t],r=(i||(i={propertyArray:new Array,IndexArray:new Array,ArrayLength:0,uuidtorange:new Object},this.AttributeArray[t]=i),e.getAttribute("position"));i.uuidtorange[n]={start:i.propertyArray.length/9,count:r.count};for(var o=0;o<r.array.length;++o)i.propertyArray.push(r.array[o]);for(var a=e.getIndex(),s=0;s<a.array.length;s++)i.IndexArray.push(a.array[s]+i.ArrayLength);i.ArrayLength+=r.count},AddLine:function(e){this.lines.push(e)},GetLines:function(){return this.lines},GetLineStyleMaterial:function(e,t){return t?this.shxMaterial:2<=e?this.blendMaterial:this.newblendMaterial},GetMaterial:function(e){switch(e){case le.ITALIC:return this.TextMaterialItalic;case le.NORMAL:return this.TextMaterial;case le.BOLD:return this.TextMaterialBold;case le.ITALICANDBOLD:return this.TextMaterialIandB;case le.BLEND:return this.blendMaterial;case le.SHX:return this.shxMaterial}},HaveSDF:function(){return this.AttributeArray.length},CreateMesh:function(){for(var e=new THREE.Group,t=0;t<this.AttributeArray.length;t++)if(this.AttributeArray[t])if(Array.isArray(this.AttributeArray[t]))for(var n=0,i=this.AttributeArray[t].length;n<i;++n){var r=this.AttributeArray[t][n],o=(r.compositeIBuffer,r.compositePositionAttrib),a=r.compositeColorAttrib,s=r.compositeUvAttrib,l=r.compositeTextureAttrib,o=((d=new THREE.BufferGeometry).addAttribute("position",o),d.addAttribute("color",a),d.addAttribute("uv",s),d.addAttribute("textureid",l),d.setIndex(r.index),new THREE.Mesh(d,this.GetMaterial(t)));o.name=t+"_"+n,e.add(o)}else{var d=new THREE.BufferGeometry,c=new Float32Array(this.AttributeArray[t].propertyArray),c=new THREE.InterleavedBuffer(c,9),h=new THREE.InterleavedBufferAttribute(c,3,0,!1),u=new THREE.InterleavedBufferAttribute(c,3,3,!1),p=new THREE.InterleavedBufferAttribute(c,2,6,!1),c=new THREE.InterleavedBufferAttribute(c,1,8,!1),h=(d.addAttribute("position",h),d.addAttribute("color",u),d.addAttribute("uv",p),d.addAttribute("textureid",c),d.setIndex(this.AttributeArray[t].IndexArray),new THREE.Mesh(d,this.GetMaterial(t)));h.name=t,e.add(h)}return e.name="TextGroup",this.ClearMemory(),e},ClearMemory:function(){for(var e=0;e<this.AttributeArray.length;++e)if(Array.isArray(this.AttributeArray[e]))for(var t=0;t<this.AttributeArray[e].length;++t)this.AttributeArray[e][t]&&(this.AttributeArray[e][t]=this.AttributeArray[e][t].uuidtorange);else this.AttributeArray[e]&&(this.AttributeArray[e]=this.AttributeArray[e].uuidtorange);this.specialCodeArray=[],this.HashTable=[]},clear:function(){null!=this.TextMaterial.dispose&&this.TextMaterial.dispose(),null!=this.TextMaterialItalic.dispose&&this.TextMaterialItalic.dispose(),null!=this.TextMaterialBold.dispose&&this.TextMaterialBold.dispose(),null!=this.TextMaterialIandB.dispose&&this.TextMaterialIandB.dispose();for(var e=0;e<this.textures.length;++e)this.textures[e].image.data=[],this.textures[e].dispose();this.shxMaterial&&this.shxMaterial.dispose()},MeshTextParseGeometry:function(e,t,F,n,N,j,i,_,V,r,k){void 0===j&&(j=!1),void 0===i&&(i=!1),void 0===_&&(_=!1),void 0===V&&(V=!1),void 0===r&&(r=!1),void 0===k&&(k=2);for(var o=0,a=0,U=this.GetMaterialStyleId(e.textFont.style,e.textFont.weight,!1),s=this.RegText(e.text),l=(e.text=s.text,new(j?de:THREE.BufferGeometry)),d=(l.type="TextBufferGeometry",l.name=e.text,l.styleId=U,e.index&&(l.textIndex=e.index),null==e.subInd&&null==e.subInd||(l.subInd=e.subInd),[]),c=[],h=[],u=0,p=new THREE.Box3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0)),f=new THREE.Box3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0)),m=1,g=Math.tan(e.textFont.oblique),v=e.textFont.mirrorX,A=e.textFont.mirrorY,G=0,z=0,y=1,W=[],Y=0,X=0,Q=0,Z=0,E=0;E<e.text.length;E++){var M,q=V?e.text:e.text[E];if(!(M=this.GetDimensionsForSize(q,e.textFont.size,U,e.textFont.name,e.textFont.width,e.textFont.bigName)))return null;0==E&&(M.isShx||M.isTTF)&&(l.isShx=M.isShx,l.isTTF=M.isTTF,l.styleId=M.isShx?le.SHX:le.BLEND,M.isTTF)&&(K=!1);var K=e.textFont.vertical&&M.isVertical;if(K?a+=0==E?-M.height:z:o+=G,M&&M.shxRange){(s.superscript&&E>=s.superscriptbegin&&E<=s.superscriptend||s.subscript&&E>=s.subscriptbegin&&E<=s.subscriptend)&&(M.height*=.5,M.width*=.5,M.bearingX*=.5,M.bearingY*=.5,M.advanceX*=.5,M.advanceY*=.5),s.superscript&&E>=s.superscriptbegin&&E<=s.superscriptend&&(M.bearingY+=M.height);var w=M.height,b=M.width,J=e.textFont.rotate&&this.IsChinese2(q),x=M.shxRange[0];if(f.set(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0)),l.isShx)for(var $=1;$<M.shxRange.length;$++){for(var I=x;I<M.shxRange[$]+x;I+=4){var T=d.length;v?(d[T+0]=o-this.ShxData[I]*b*y,d[T+3]=o-this.ShxData[I+2]*b*y):(d[T+0]=o+this.ShxData[I]*b*y,d[T+3]=o+this.ShxData[I+2]*b*y),A?(d[T+1]=a-(this.ShxData[I+1]*w+M.bearingY)*y,d[T+4]=a-(this.ShxData[I+3]*w+M.bearingY)*y):(d[T+1]=a+(this.ShxData[I+1]*w+M.bearingY)*y,d[T+4]=a+(this.ShxData[I+3]*w+M.bearingY)*y),d[T+2]=0,d[T+5]=0,c[u]=u,c[++u]=u,u++,v!=A?(d[T+0]-=d[T+1]*g,d[T+3]-=d[T+4]*g):(d[T+0]+=d[T+1]*g,d[T+3]+=d[T+4]*g),p.expandByPoint(new THREE.Vector3(d[T],d[T+1],d[T+2])),p.expandByPoint(new THREE.Vector3(d[T+3],d[T+4],d[T+5])),f.expandByPoint(new THREE.Vector3(d[T],d[T+1],d[T+2])),f.expandByPoint(new THREE.Vector3(d[T+3],d[T+4],d[T+5]))}x+=M.shxRange[$]}if(l.isTTF){M.top>m&&(m=M.top);for(var ee=1;ee<M.shxRange.length;ee++){for(var S=x;S<M.shxRange[ee]+x;S+=6){var B=d.length;J?(v?(d[B+0]=o-(M.top-this.ttfData[S+1])*w+M.bearingY,d[B+3]=o-(M.top-this.ttfData[S+3])*w+M.bearingY,d[B+6]=o-(M.top-this.ttfData[S+5])*w+M.bearingY):(d[B+0]=o+(M.top-this.ttfData[S+1])*w+M.bearingY,d[B+3]=o+(M.top-this.ttfData[S+3])*w+M.bearingY,d[B+6]=o+(M.top-this.ttfData[S+5])*w+M.bearingY),A?(d[B+1]=a-(m+this.ttfData[S]-M.right)*b,d[B+4]=a-(m+this.ttfData[S+2]-M.right)*b,d[B+7]=a-(m+this.ttfData[S+4]-M.right)*b):(d[B+1]=a+(m+this.ttfData[S]-M.right)*b,d[B+4]=a+(m+this.ttfData[S+2]-M.right)*b,d[B+7]=a+(m+this.ttfData[S+4]-M.right)*b)):(v?(d[B+0]=o-this.ttfData[S+0]*b,d[B+3]=o-this.ttfData[S+2]*b,d[B+6]=o-this.ttfData[S+4]*b):(d[B+0]=o+this.ttfData[S+0]*b,d[B+3]=o+this.ttfData[S+2]*b,d[B+6]=o+this.ttfData[S+4]*b),A?(d[B+1]=a-this.ttfData[S+1]*w+M.bearingY,d[B+4]=a-this.ttfData[S+3]*w+M.bearingY,d[B+7]=a-this.ttfData[S+5]*w+M.bearingY):(d[B+1]=a+this.ttfData[S+1]*w+M.bearingY,d[B+4]=a+this.ttfData[S+3]*w+M.bearingY,d[B+7]=a+this.ttfData[S+5]*w+M.bearingY)),d[B+2]=0,d[B+5]=0,d[B+8]=0,c[u]=u,c[++u]=u,c[++u]=u,u++,v!=A?(d[B+0]-=d[B+1]*g,d[B+3]-=d[B+4]*g,d[B+6]-=d[B+7]*g):(d[B+0]+=d[B+1]*g,d[B+3]+=d[B+4]*g,d[B+6]+=d[B+7]*g),p.expandByPoint(new THREE.Vector3(d[B],d[B+1],d[B+2])),p.expandByPoint(new THREE.Vector3(d[B+3],d[B+4],d[B+5])),p.expandByPoint(new THREE.Vector3(d[B+6],d[B+7],d[B+8])),f.expandByPoint(new THREE.Vector3(d[B],d[B+1],d[B+2])),f.expandByPoint(new THREE.Vector3(d[B+3],d[B+4],d[B+5])),f.expandByPoint(new THREE.Vector3(d[B+6],d[B+7],d[B+8]))}x+=M.shxRange[ee]}}var G=v?-M.advanceX*y:M.advanceX*y,z=-M.advanceY,Y=p.min.y<Y?p.min.y:Y,Q=p.min.x<Q?p.min.x:Q,te=p.max.x-p.min.x-X,ne=(te<=0&&" "==q?Z+=M.advanceX:Z=0,X=p.max.x-p.min.x+Z,f.max.y-f.min.y);if(W.push(te<=0?M.advanceX:te,ne<=0?M.advanceY:ne),V)break}else" "!=q&&(1e-4<Math.abs(M.fontScale-1)?(a+=M.advanceY*y,y*=M.fontScale):console.log("faild: ",q," info: ",e)),K?a-=M.advanceY:v?o-=M.advanceX*y:o+=M.advanceX*y,W.push(z=G=0,0)}l.characterWidthHeight=W,l.rectWidth=p.max.x-p.min.x,l.rectHeight=p.max.y-p.min.y,l.rectBearingY=Y,l.rectBearingX=Q,l.mirrorX=v,l.mirrorY=A;for(var P,C,R,i=new THREE.Euler,ie=(F&&i.setFromQuaternion(F),s.underscode&&((P=new THREE.LineBasicMaterial).color.setRGB(n.r,n.g,n.b),(C=new THREE.Geometry).vertices.push(new THREE.Vector3(p.min.x,p.min.y,0),new THREE.Vector3(p.max.x,p.min.y,0)),C.rotateZ(i.z),C.rotateY(i.y),C.rotateX(i.x),C.translate(t.x,t.y-.1*M.height,t.z),(R=new THREE.LineSegments(C,P)).name=N,R.color=P.color.clone(),this.AddLine(R)),s.box&&((P=new THREE.LineBasicMaterial).color.setRGB(n.r,n.g,n.b),(C=new THREE.Geometry).vertices.push(new THREE.Vector3(p.min.x,p.min.y,0),new THREE.Vector3(p.min.x,p.max.y,0),new THREE.Vector3(p.min.x,p.max.y,0),new THREE.Vector3(p.max.x,p.max.y,0),new THREE.Vector3(p.max.x,p.max.y,0),new THREE.Vector3(p.max.x,p.min.y,0),new THREE.Vector3(p.max.x,p.min.y,0),new THREE.Vector3(p.min.x,p.min.y,0)),C.rotateZ(i.z),C.rotateY(i.y),C.rotateX(i.x),C.translate(t.x,t.y,t.z),(R=new THREE.LineSegments(C,P)).name=N,R.color=P.color.clone(),this.AddLine(R)),s.dash&&((P=new THREE.LineBasicMaterial).color.setRGB(n.r,n.g,n.b),(C=new THREE.Geometry).vertices.push(new THREE.Vector3(p.min.x,p.max.y,0),new THREE.Vector3(p.max.x,p.max.y,0)),C.rotateZ(i.z),C.rotateY(i.y),C.rotateX(i.x),C.translate(t.x,t.y+.1*M.height,t.z),(R=new THREE.LineSegments(C,P)).name=N,R.color=P.color.clone(),this.AddLine(R)),(new THREE.Matrix4).compose(t,F,new THREE.Vector3(1,1,1))),re=new THREE.Vector3,O=0;O<d.length;O+=3)re.set(d[O],d[O+1],d[O+2]),re.applyMatrix4(ie),d[O]=re.x,d[O+1]=re.y,d[O+2]=0;if(p.applyMatrix4(ie),l.isShx){var L=this.getSHXGeometryBuffer(d.length/3);l.drawRange.start=L.indexOffset,l.drawRange.count=c.length;for(var oe=0,ae=c.length;oe<ae;++oe)c[oe]+=L.indexOffset;L.compositeIBuffer.array.set(d,L.bufferOffset),L.bufferOffset+=d.length,L.index.array.set(c,L.indexOffset),L.indexOffset+=c.length;_=L.compositePositionAttrib;l.addAttribute("position",_),l.setIndex(L.index),l.boundingBox=p,l.needsUpdate=!0,l.textLoad="shxLoad"}if(l.isTTF){var D=this.getMeshTTFGeometryBuffer(d.length/3);l.drawRange.start=D.indexOffset,l.drawRange.count=c.length;for(var H=0,se=c.length;H<se;H+=3)c[H]+=D.indexOffset,c[H+1]+=D.indexOffset,c[H+2]+=D.indexOffset,h[2*H]=c[H],h[2*H+1]=c[H+1],h[2*H+2]=c[H+1],h[2*H+3]=c[H+2],h[2*H+4]=c[H+2],h[2*H+5]=c[H];D.compositeIBuffer.array.set(d,D.bufferOffset),D.bufferOffset+=d.length,D.index.array.set(c,D.indexOffset),D.indexLine.array.set(h,2*D.indexOffset),D.indexOffset+=c.length;r=D.compositePositionAttrib;l.addAttribute("position",r),l.setIndex(D.index),l.boundingBox=p,l.textWireFrame=new THREE.BufferGeometry,l.textWireFrame.drawRange.start=2*l.drawRange.start,l.textWireFrame.drawRange.count=2*l.drawRange.count,l.textWireFrame.addAttribute("position",r),l.textWireFrame.setIndex(D.indexLine),l.textWireFrame.name="ttf wireframe",l.textWireFrame.needsUpdate=!0,l.needsUpdate=!0,l.textLoad="ttfLoad"}return l},MeshTextSetData:function(e,t){this.ShxData=e,this.ttfData=t}},le.ITALIC=0,le.BOLD=1,le.NORMAL=2,le.ITALICANDBOLD=3,le.BLEND=4,le.SHX=5,function(e){this.viewer=e;this.uuidToLineStyle={},this.geomUUidToLineInfo={},this.ttfMesh=new THREE.Mesh,this.shxMesh=new THREE.LineSegments,this.pointMesh=new THREE.Points,this.lineMesh=new THREE.LineSegments,this.lineMaterials=[],this.createLineStyle=function(e,t){var n=null;if(t)for(var n={},i=0;i<t.length;i++)n[t[i].uuid]=t[i];for(var r=0;r<e.length;r++){for(var o,a=e[r].fScale,s={pattern:e[r].fPatternLength*a,pointPattern:[],linePattern:[],textPattern:[],textureArray:new Uint8Array(4096),textGeomArray:[],textOrPoint:!1},l=0,d=0,c=0;c<e[r].nDashes;c++){var h,u,p,f,m=e[r].lItem[c];if(d+=Math.abs(m.fLength*a),0==m.fLength)s.pointPattern.push(d),s.textOrPoint=!0;else{for(o=Math.floor(d/s.pattern*1024),s.linePattern.push(m.fLength*a);l<o;)s.textureArray[4*l]=0<=m.fLength?0:255,l++;(0<m.nShapeId||null!=m.strText)&&(h={bigName:"",name:m.fontName,size:m.fScale*a,style:"normal",weight:"normal",width:1},n)&&m.fontUUid&&n[m.fontUUid]&&(h.bigName=n[m.fontUUid].bigName,h.name=n[m.fontUUid].name,h.style=n[m.fontUUid].style,h.weight=n[m.fontUUid].weight,h.width=n[m.fontUUid].width,u=this.viewer.SDFMaker.IsShxFont(h.name),f=m.strText,p=m.nShapeId,0<m.nShapeId&&(2<this.viewer.modelContentVersion?(f=String.fromCharCode(m.nShapeId),p=-1):f=m.nShapeId.toString()),(f={text:f,textFont:h,dash:d,rotation:m.fRotation,isShx:u,shapeId:p,offset:new THREE.Vector2}).offset.x=m.offset[0],f.offset.y=m.offset[1],s.textPattern.push(f),s.textOrPoint=!0)}}this.uuidToLineStyle[e[r].strId]=s}},this.createTextGeometry=function(e,t,n){if(!(0<this.uuidToLineStyle[e].textGeomArray.length))for(var i=this.uuidToLineStyle[e].textPattern,r=0;r<i.length;r++){var o=i[r],a=o.textFont.size,s=(o.textFont.size=a*n,this.viewer.SDFMaker.ParseSDFTextGeometry(o,null,null,t,null,!1,!1,!1,0<o.shapeId,!0,this.viewer.modelContentVersion)),a=("unLoad"==s.textLoad&&(s.isTTF?(this.viewer.SDFMaker.SetLineStyleTtfTextGeometry(this.viewer.SDFMaker.ttfData,s,o,!1,this.viewer.modelContentVersion),s.textLoad="ttfLoad"):(this.viewer.SDFMaker.SetLineStyleShxTextGeometry(this.viewer.SDFMaker.ShxData,s,o,0<o.shapeId,this.viewer.modelContentVersion),s.textLoad="shxLoad")),s.characterWidthHeight&&this.viewer.ndsModel.getMeshManager().lineTypeUuid2ParamsMap.set(e,{characterWidthHeight:s.characterWidthHeight,rectHeight:s.rectHeight,rectWidth:s.rectWidth,text:o.text,rectBearingX:s.rectBearingX,rectBearingY:s.rectBearingY,visible:!0}),o.textFont.size=a,s.computeBoundingBox(),{position:s.getAttribute("position"),index:s.getIndex(),color:t,drawRange:s.drawRange,translateX:s.boundingBox.max.x-s.boundingBox.min.x,translateY:(s.boundingBox.max.y-s.boundingBox.min.y)/this.viewer.SDFMaker.GetTextScale(null,o.textFont.name)});this.uuidToLineStyle[e].textGeomArray.push(a)}},this.setBackGroundColor=function(e){this.backColor=e},this.colorTest=function(e){return this.backColor&&this.backColor.equals(e)?new THREE.Color(16777215-e.getHex()):e},this.getLineStyleInfo=function(e,t,n,i,r,o){if(!(this.viewer.SDFMaker.needShxLoad&&!this.viewer.SDFMaker.ShxData&&2<=this.viewer.modelContentVersion)){var a,s,l,d,c=this.geomUUidToLineInfo[e.uuid],h=this.uuidToLineStyle[t];if(!c&&h&&h.textOrPoint){var u=h.textPattern,p=h.pointPattern,f=h.pattern,F=(0<u.length&&this.createTextGeometry(t,i,n),e.getAttribute("position"));if(e.index){for(var N,m,g=new THREE.Vector3,v=new THREE.Vector3,A=new THREE.Vector3,y=new THREE.Vector3,E=new THREE.Vector3,M=(new THREE.Vector3,new THREE.Vector3),w=[],j=[],b={data:[],index:[],length:0},x={data:[],index:[],length:0},I=e.drawRange.start,_=e.drawRange.start+e.drawRange.count;I<_;I+=2){P=e.index.getX(I),N=e.index.getX(I+1),g.fromBufferAttribute(F,P),v.fromBufferAttribute(F,N),A.subVectors(v,g);var T=g.distanceTo(v);if(!(T<=0)){var S=Math.floor(T/(f*n))+1;if(0<p.length&&1e4<S||u.length&&1e3<S)console.log("lineStyle pattern repeat : ",S," use solid line"),w.push(g.x,g.y,g.z,v.x,v.y,v.z);else{m=A.clone().normalize(),M.set(0,0,1),M.cross(m).normalize(),E.set(1,0,0);var B=E.angleTo(m),P=(E.cross(m).normalize(),0<=E.z?1:-1),C=B>Math.PI/2?(B-Math.PI)*P:B*P;E.set(0,0,1);for(var R=0;R<p.length;R++)for(var O=0;O<S;O++){var V=(p[R]+O*f)*n/T;if(.999<=V)break;(y=g.clone()).addScaledVector(A,V),j.push(y.x,y.y,y.z)}for(var L=0;L<u.length;L++){for(var D=u[L],k=h.textGeomArray[L].position,U=h.textGeomArray[L].index,G=h.textGeomArray[L].translateX,z=h.textGeomArray[L].translateY,W=h.textGeomArray[L].drawRange,Y=this.viewer.ndsModel.getMeshManager().lineTypeUuid2ParamsMap.get(t),X=[],Q=0;Q<S;Q++){var H=(D.dash+Q*f)*n/T;if(.999<=H)break;(y=g.clone()).addScaledVector(A,H),B>Math.PI/2&&(y.addScaledVector(m,G),D.isShx||y.addScaledVector(M,z)),D.isShx&&D.shapeId<=0&&(M.y=Math.abs(M.y)),y.addScaledVector(m,D.offset.x),y.addScaledVector(M,D.offset.y),(130==D.shapeId||132==D.shapeId||133==D.shapeId)&&this.viewer.modelContentVersion<2&&y.addScaledVector(M,-M.y*z*.5);H={x:y.x,y:y.y,z:y.z};X.push(H),D.isShx&&2<=this.viewer.modelContentVersion?this.addShxTextAttribute(x,k,U,W,y,E,C+D.rotation):3<this.viewer.modelContentVersion?this.addMeshTextAttribute(b,k,U,W,y,E,C+D.rotation):this.addTextAttribute(b,k,U,W,y,E,C+D.rotation)}Y.vD=X}}}}this.geomUUidToLineInfo[e.uuid]={lineTypeID:t,textGeom:null,textIsShx:!1,pointGeom:null,lineGeom:null,color:i,linewidth:r},0<u.length&&(0<b.length&&(3<this.viewer.modelContentVersion?this.createMeshTextGeom(e.uuid,b,u[0].text,t):this.createTextGeom(e.uuid,b,u[0].text,t)),0<x.length)&&this.createShxTextGeom(e.uuid,x),0<p.length&&this.createPointGeom(e.uuid,j),0<w.length&&this.createLineGeom(e.uuid,w)}}return c?(i=this.getTextMaterial(),r=this.getShxTextMaterial(),a=this.getPointMaterial(),s=this.getLineMaterial(),i&&(i.uniforms.diffuse.value.copy(this.colorTest(o?_e.selectedColor:c.color)),i.uniformsNeedUpdate=!0),r&&(r.uniforms.diffuse.value.copy(this.colorTest(o?_e.selectedColor:c.color)),r.uniformsNeedUpdate=!0,1<c.linewidth?r.linewidthCopy=c.linewidth:delete r.linewidthCopy),a&&(a.uniforms.diffuse.value.copy(this.colorTest(o?_e.selectedColor:c.color)),a.uniforms.linewidth.value=this.viewer.showLineWidth&&1.5<c.linewidth?c.linewidth*this.viewer.renderer.getPixelRatio():1.5,a.uniformsNeedUpdate=!0),s&&(s.uniforms.diffuse.value.copy(this.colorTest(o?_e.selectedColor:c.color)),s.uniformsNeedUpdate=!0),d=l=o=null,c.textGeom&&(c.textIsShx?((o=this.shxMesh).geometry=c.textGeom,o.material=r,o.isShx=!0):((o=this.ttfMesh).geometry=c.textGeom,o.material=i,o.isShx=!1)),c.pointGeom&&((l=this.pointMesh).geometry=c.pointGeom,l.material=a),c.lineGeom&&((d=this.lineMesh).geometry=c.lineGeom,d.material=s),{textMesh:o,pointMesh:l,lineMesh:d}):null}},this.getLineStyleInfoForPDF=function(e,t,n,i){if(this.viewer.is2DModel&&!(this.viewer.SDFMaker.needShxLoad&&!this.viewer.SDFMaker.ShxData&&2<=this.viewer.modelContentVersion)){var r=this.uuidToLineStyle[t];if(r&&r.textOrPoint){var o=r.textPattern,a=r.pointPattern,s=r.pattern,l=(0<o.length&&this.createTextGeometry(t,i,n),e.getAttribute("position"));if(e.index){for(var d,c,h=new THREE.Vector3,u=new THREE.Vector3,p=new THREE.Vector3,f=new THREE.Vector3,m=new THREE.Vector3,g=(new THREE.Vector3,new THREE.Vector3),v={},A=[],y=[],E=e.drawRange.start,M=e.drawRange.start+e.drawRange.count;E<M;E+=2){I=e.index.getX(E),d=e.index.getX(E+1),h.fromBufferAttribute(l,I),u.fromBufferAttribute(l,d),p.subVectors(u,h);var w=h.distanceTo(u);if(!(w<=0)){var b=Math.floor(w/(s*n))+1;if(0<a.length&&1e4<b||o.length&&1e3<b)console.log("lineStyle pattern repeat : ",b," use solid line"),y.push(h.x,h.y,h.z,u.x,u.y,u.z);else{c=p.clone().normalize(),g.set(0,0,1),g.cross(c).normalize(),m.set(1,0,0);var x=m.angleTo(c),I=(m.cross(c).normalize(),0<=m.z?1:-1),T=x>Math.PI/2?(x-Math.PI)*I:x*I;m.set(0,0,1);for(var S=0;S<a.length;S++)for(var B=0;B<b;B++){var P=(a[S]+B*s)*n/w;if(.999<=P)break;(f=h.clone()).addScaledVector(p,P),A.push(f.x,f.y,f.z)}for(var C=0;C<o.length;C++){var R=o[C],O=r.textGeomArray[C].translateX,F=r.textGeomArray[C].translateY,L=v[R.text];L||(L={fontName:R.textFont.name,isShx:R.isShx,shapeId:R.shapeId,size:R.textFont.size,data:new Array},v[R.text]=L);for(var D=0;D<b;D++){var H=(R.dash+D*s)*n/w;if(.999<=H)break;(f=h.clone()).addScaledVector(p,H),x>Math.PI/2&&(f.addScaledVector(c,O),R.isShx||f.addScaledVector(g,F)),R.isShx&&0==R.shapeId&&(g.y=Math.abs(g.y)),f.addScaledVector(c,R.offset.x),f.addScaledVector(g,R.offset.y),L.data.push(f.x,f.y,T+R.rotation)}}}}}return{styleText:v,stylePoint:A,styleLine:y}}}return{styleText:null,stylePoint:null,styleLine:null}}},this.addTextAttribute=function(e,t,n,i,r,o,a){for(var s=new THREE.Vector3,l=i.start,d=Math.min(i.count,n.count),c=n.array[l],h=c,u=l;u<l+d;++u)c=c>n.array[u]?n.array[u]:c,h=h>n.array[u]?h:n.array[u];for(var p=c;p<=h;p++)s.fromArray(t.array,6*p),s.applyAxisAngle(o,a),s.add(r),e.data.push(s.x),e.data.push(s.y),e.data.push(s.z),e.data.push(t.array[6*p+3]),e.data.push(t.array[6*p+4]),e.data.push(t.array[6*p+5]);for(var f=l;f<l+d;++f)e.index.push(n.array[f]-c+e.length);e.length+=h-c+1},this.addMeshTextAttribute=function(e,t,n,i,r,o,a){for(var s=new THREE.Vector3,l=i.start,d=Math.min(i.count,n.count),c=n.array[l],h=c,u=l;u<l+d;++u)c=c>n.array[u]?n.array[u]:c,h=h>n.array[u]?h:n.array[u];for(var p=c;p<=h;p++)s.fromArray(t.array,3*p),s.applyAxisAngle(o,a),s.add(r),e.data.push(s.x),e.data.push(s.y),e.data.push(s.z);for(var f=l;f<l+d;++f)e.index.push(n.array[f]-c+e.length);e.length+=h-c+1},this.addShxTextAttribute=function(e,t,n,i,r,o,a){if(t){for(var s=new THREE.Vector3,l=i.start,d=Math.min(i.count,n.count),c=n.array[l],h=c,u=l;u<l+d;++u)c=c>n.array[u]?n.array[u]:c,h=h>n.array[u]?h:n.array[u];for(var p=c;p<=h;++p)s.fromArray(t.array,3*p),s.applyAxisAngle(o,a),s.add(r),e.data.push(s.x),e.data.push(s.y),e.data.push(s.z);for(var f=l;f<l+d;++f)e.index.push(n.array[f]-c+e.length);e.length+=h-c+1}},this.createTextGeom=function(e,t,n,i){var r=new THREE.BufferGeometry,o=new Float32Array(t.data),o=new THREE.InterleavedBuffer(o,6),a=new THREE.InterleavedBufferAttribute(o,3,0,!1),s=new THREE.InterleavedBufferAttribute(o,2,3,!1),o=new THREE.InterleavedBufferAttribute(o,1,5,!1);r.addAttribute("position",a),r.addAttribute("uv",s),r.addAttribute("textureid",o),r.setIndex(t.index),r.name="ttf",r.drawRange.start=0,r.drawRange.count=t.index.length,r.needsUpdate=!0,r.text=n,r.lineTypeId=i,this.geomUUidToLineInfo[e].textGeom=r,this.geomUUidToLineInfo[e].textIsShx=!1},this.createMeshTextGeom=function(e,t,n,i){for(var r=new THREE.BufferGeometry,o=new Float32Array(t.data),o=new THREE.InterleavedBuffer(o,3),o=new THREE.InterleavedBufferAttribute(o,3,0,!1),a=(r.addAttribute("position",o),r.setIndex(t.index),r.name="ttf",r.drawRange.start=0,r.drawRange.count=t.index.length,r.needsUpdate=!0,r.text=n,r.lineTypeId=i,this.geomUUidToLineInfo[e].textGeom=r,this.geomUUidToLineInfo[e].textIsShx=!1,[2*t.index.length]),s=0,l=t.index.length;s<l;s+=3)a[2*s]=t.index[s],a[2*s+1]=t.index[s+1],a[2*s+2]=t.index[s+1],a[2*s+3]=t.index[s+2],a[2*s+4]=t.index[s+2],a[2*s+5]=t.index[s];n=new THREE.BufferGeometry;n.addAttribute("position",o),n.setIndex(a),n.name="meshTtf wireframe",n.isTtfWire=!0,n.needsUpdate=!0,this.geomUUidToLineInfo[e].lineGeom=n},this.createShxTextGeom=function(e,t){var n=new THREE.BufferGeometry,i=new Float32Array(t.data),i=new THREE.InterleavedBuffer(i,3),i=new THREE.InterleavedBufferAttribute(i,3,0,!1);n.addAttribute("position",i),n.setIndex(t.index),n.name="shx",n.drawRange.start=0,n.drawRange.count=t.index.length,n.needsUpdate=!0,this.geomUUidToLineInfo[e].textGeom=n,this.geomUUidToLineInfo[e].textIsShx=!0},this.createPointGeom=function(e,t){for(var n=[],i=0;i<t.length/3;i++)n.push(i);var r=new THREE.BufferGeometry,o=new Float32Array(t),o=new THREE.InterleavedBuffer(o,3),o=new THREE.InterleavedBufferAttribute(o,3,0,!1);r.addAttribute("position",o),r.setIndex(n),r.drawRange.start=0,r.drawRange.count=n.length,r.name="point",r.needsUpdate=!0,this.geomUUidToLineInfo[e].pointGeom=r},this.createLineGeom=function(e,t){for(var n=[],i=0;i<t.length/3;i++)n.push(i);var r=new THREE.BufferGeometry,o=new Float32Array(t),o=new THREE.InterleavedBuffer(o,3),o=new THREE.InterleavedBufferAttribute(o,3,0,!1);r.addAttribute("position",o),r.setIndex(n),r.drawRange.start=0,r.drawRange.count=n.length,r.name="line",r.needsUpdate=!0,this.geomUUidToLineInfo[e].lineGeom=r},this.getMaterial=function(e){var e=this.uuidToLineStyle[e],t=null,n=1,e=(e?(t=new THREE.DataTexture(e.textureArray,1024,1,THREE.RGBAFormat),n=e.pattern):(t=new THREE.DataTexture(new Uint8Array(4096),1024,1,THREE.RGBAFormat),console.log("lineType map failded")),t.needsUpdate=!0,new THREE.ShaderMaterial({uniforms:{lineScale:{value:1},lineTypeId:{value:0},uSampler:{value:t},patternLength:{value:n},opacity:{value:.8},diffuse:{value:new THREE.Color(16711680)}},linewidth:1,transparent:!0,fragmentShader:["uniform vec3 diffuse;","uniform float opacity;","uniform float patternLength;","uniform float lineScale;","uniform sampler2D uSampler;","varying float vLineDistance;","void main() {","float newDistance = vLineDistance/lineScale;","float modSize = mod( newDistance, patternLength);","vec3 value = texture2D(uSampler,vec2(modSize/patternLength,0.0)).rgb;","if(value.r > 0.9){","discard;","}","vec3 outgoingLight = vec3( 0.0 );","vec4 diffuseColor = vec4( diffuse, opacity );","outgoingLight = diffuseColor.rgb;","gl_FragColor = vec4(outgoingLight, diffuseColor.a );","}"].join("\n"),vertexShader:["attribute float lineDistance;","varying float vLineDistance;","void main() {","vLineDistance = lineDistance;","#ifdef USE_MODELMATRIXATTRIB\n\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\tgl_Position = projectionMatrix * ndsModelViewMatrix * vec4( position, 1.0 );\n#else\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n#endif\n","}"].join("\n")}));return this.lineMaterials.push(e),e},this.getTextMaterial=function(){return this.viewer.SDFMaker.GetLineStyleMaterial(this.viewer.modelContentVersion)},this.getShxTextMaterial=function(){return 2<=this.viewer.modelContentVersion?this.viewer.SDFMaker.GetMaterial(le.SHX):this.getTextMaterial()},this.getPointMaterial=function(){return this.pointMaterial||(this.pointMaterial=new THREE.ShaderMaterial({uniforms:{diffuse:{value:new THREE.Color(16711680)},linewidth:{value:1}},vertexShader:["uniform float linewidth;","void main() { ","gl_PointSize = linewidth;","#ifdef USE_MODELMATRIXATTRIB\n\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\tgl_Position = projectionMatrix * ndsModelViewMatrix * vec4( position, 1.0 );\n#else\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n#endif\n","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","uniform vec3 diffuse;","void main(void) {","gl_FragColor = vec4(diffuse, 1.0);","}"].join("\n")}),0==_e.enableTextRenderingBothSide?this.pointMaterial.side=THREE.DoubleSide:this.pointMaterial.side=THREE.FrontSide),this.pointMaterial},this.getLineMaterial=function(){return this.lineMaterial||(this.lineMaterial=new THREE.ShaderMaterial({uniforms:{diffuse:{value:new THREE.Color(16711680)}},vertexShader:["void main() { ","#ifdef USE_MODELMATRIXATTRIB\n\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\tgl_Position = projectionMatrix * ndsModelViewMatrix * vec4( position, 1.0 );\n#else\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n#endif\n","}"].join("\n"),fragmentShader:["#ifdef GL_ES","precision mediump float;","#endif","uniform vec3 diffuse;","void main(void) {","gl_FragColor = vec4(diffuse, 1.0);","}"].join("\n")})),this.lineMaterial},this.getLineStyleArray=function(e){return this.uuidToLineStyle[e].linePattern},this.clearLineType=function(){for(var e=0;e<this.lineMaterials.length;e++)this.lineMaterials[e].dispose();this.lineMaterials=[]}});function Mt(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function(e){e=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof e?e:e+""}(i.key),i)}}function wt(e,t){return(wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function bt(e,t,n){this.showStatus=e,this.statusDomElement=e?bt.prototype.addStatusElement():null,this.imageLoader=new THREE.ImageLoader,this.manager=void 0!==t?t:THREE.DefaultLoadingManager,this.viewer=n,this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}var xt,It=function(n){function e(e){var t=n.call(this,{type:"MeshGradientShader",uniforms:{diffuse:{value:new THREE.Color(16711680)},diffuse1:{value:new THREE.Color(16711680)},diffuse2:{value:new THREE.Color(0)},hatchType:{value:0},shift:{value:0},params:{value:0}},vertexShader:"\n\t\t\t#include <common>\n\t\t\tuniform vec3 minPos;\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main() {\n\n\t\t\t\tvUv = uv;\n\n\t\t\t\t#ifdef USE_MODELMATRIXATTRIB\n\t\t\t\t\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\t\t\t\t\tgl_Position = projectionMatrix * ndsModelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t#else\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\tuniform vec3 diffuse1;\n uniform vec3 diffuse2;\n\t\t\tuniform float hatchType;\n\t\t\tuniform float shift;\n\t\t\tuniform float params;\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#define SQRT_2_VALUE 1.414213562373\n\t\t\t#define PI_VALUE 3.14159265359\n\n\t\t\tvoid main(){\n\t\t\t\tvec3 outColor;\n\t\t\t\tfloat dist = 0.0;\n\n\t\t\t\t// 直线形\n\t\t\t\tif( hatchType >0.5 && hatchType <1.5){\n\t\t\t\t\tdist = vUv.x;\n\t\t\t\t}\n\n\t\t\t\t// 球形\n\t\t\t\tif( hatchType >1.5 && hatchType <2.5){\n\t\t\t\t\tdist = length(vUv);\n\t\t\t\t\tdist = dist > 1.0 ? 0.0 : (sqrt(2.0-dist*dist)-1.0)/(SQRT_2_VALUE-1.0);\n\t\t\t\t}\n\n\t\t\t\t// 半球形\n\t\t\t\tif( hatchType >2.5 && hatchType <3.5){\n\t\t\t\t\tdist = sin((1.0 - length(vUv)) *PI_VALUE*0.5);\n\t\t\t\t}\n\n\t\t\t\t// 曲线形\n\t\t\t\tif( hatchType >3.5 && hatchType <4.5){\n\t\t\t\t\t//dist = cos(length(vUv)*PI_VALUE/2.0);\n\n\t\t\t\t\tdist = cos((length(vUv) - params)*PI_VALUE/2.0);\n\t\t\t\t}\n\n\t\t\t\t// 圆柱形\n\t\t\t\tif( hatchType >4.5 && hatchType <5.5){\n\t\t\t\t\t//dist = abs(vUv.x);\n\t\t\t\t\t//dist = vUv.x < 0.0 ? dist / (1.0-shift/2.0) : dist/(1.0+shift/2.0);\n\t\t\t\t\t//dist = 1.0 - dist;\n\t\t\t\t\t//dist = (sin(dist * PI_VALUE *3.0/4.0 - PI_VALUE/4.0)+SQRT_2_VALUE/2.0)/(1.0 + SQRT_2_VALUE/2.0);\n\n\t\t\t\t\tdist = vUv.x < 0.0 ? 1.0 + vUv.x /(1.0-shift/2.0): 1.0 - vUv.x/(1.0+shift/2.0);\n\t\t\t\t\tdist = (sin(dist * PI_VALUE *3.0/4.0 - PI_VALUE/4.0)+SQRT_2_VALUE/2.0)/(1.0 + SQRT_2_VALUE/2.0);\n\t\t\t\t}\n\n\t\t\t\toutColor = mix(diffuse1,diffuse2,dist);\n\t\t\t\tgl_FragColor = vec4(outColor, 1.0);\n\t\t\t}\n\t\t\t"})||this;return t.isMeshGradientShader=!0,t.setValues(e),t}var t,i,r;return i=n,(t=e).prototype=Object.create(i.prototype),wt(t.prototype.constructor=t,i),t=e,(i=[{key:"color",get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},{key:"color1",get:function(){return this.uniforms.diffuse1.value},set:function(e){this.uniforms.diffuse1.value=e}},{key:"color2",get:function(){return this.uniforms.diffuse2.value},set:function(e){this.uniforms.diffuse2.value=e}},{key:"hatchType",get:function(){return this.uniforms.hatchType.value},set:function(e){this.uniforms.hatchType.value=e}},{key:"shift",get:function(){return this.uniforms.shift.value},set:function(e){this.uniforms.shift.value=e}},{key:"params",get:function(){return this.uniforms.params.value},set:function(e){this.uniforms.params.value=e}}])&&Mt(t.prototype,i),r&&Mt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(THREE.ShaderMaterial),Tt=(ve.DASHTYPE={SOLID:0,DASH:1,DASHSPACE:2,LONGDASH_DOT:3,LONGDASH_DOUBLEDOT:4,LONGDASH_TRIPLEDOT:5,DOT0:6,LONGDASH_SHORTDASH:7,LONGDASH_DOUBLESHORTDASH:8,DASH_DOT:9,DOUBLEDASH_DOT:10,DASH_DOUBLEDOT:11,DOUBLEDASH_DOUBLEDOT:12,DASH_TRIPLEDOT:13,DOUBLEDASH_TRIPLEDOT:14,BATTING:15,BORDER:16,BORDER2:17,BORDERX2:18,CENTER:19,CENTER2:20,CENTERX2:21,DASHDOT:22,DASHDOT2:23,DASHDOTX2:24,DASHED:25,DASHED2:26,DASHEDX2:27,DIVIDE:28,DIVIDE2:29,DIVIDEX2:30,DOT:31,DOT2:32,DOTX2:33,FENCELINE1:34,FENCELINE2:35,GAS_LINE:36,HIDDEN:37,HIDDEN2:38,HIDDENX2:39,HOT_WATER_SUPPLY:40,JIS_02_07:41,JIS_02_10:42,JIS_02_12:43,JIS_02_20:44,JIS_02_40:45,JIS_08_11:46,JIS_08_15:47,JIS_08_25:48,JIS_08_37:49,JIS_08_50:50,JIS_09_08:51,JIS_09_15:52,JIS_09_29:53,JIS_09_50:54,PHANTOM:55,PHANTOM2:56,PHANTOMX2:57,TRACKS:58,ZIGZAG:59,CUSTOM:999},bt.prototype={constructor:bt,crossOrigin:void 0,addStatusElement:function(){var e=document.createElement("div");return e.style.position="absolute",e.style.right="0px",e.style.top="0px",e.style.fontSize="0.8em",e.style.textAlign="left",e.style.background="rgba(0,0,0,0.25)",e.style.color="#fff",e.style.width="120px",e.style.padding="0.5em 0.5em 0.5em 0.5em",e.style.zIndex=1e3,e.innerHTML="Loading ...",e},updateProgress:function(e){var t="Loaded ";e.total?t+=(100*e.loaded/e.total).toFixed(0)+"%":t+=(e.loaded/1024).toFixed(2)+" KB",this.statusDomElement.innerHTML=t},extractUrlBase:function(e){e=e.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")},loadTexture:function(t,e,n,i,r,o){var a,s,l,d;return void 0!==e[n]?e[n]:(a=null,s=n,_e.avoidCaching&&(s=n+"?time="+Date.now()),_e.singleHTML&&this.viewer.ZIPData?(l=new THREE.Texture,(d=this).viewer.ZIPData.file(n).async("blob").then(function(e){(a=new THREE.ImageLoader(ve.TextureLoadingManager)).crossOrigin=d.crossOrigin,a.crossOrigin="anonymous",a.load(window.URL.createObjectURL(e),function(e){l.image=e,l.needsUpdate=!0,r&&r(l)},void 0,function(){t.map=null,t.needsUpdate=!0,o&&o()})})):null!==a?l=a.load(s,r):-1<n.toLowerCase().indexOf(".tga")?((a=new At).crossOrigin=this.crossOrigin,ve.TextureLoadingManager.itemStart(),l=a.load(s,function(e){e.flipY=!0,e.needsUpdate=!0,r&&r(e),ve.TextureLoadingManager.itemEnd()},void 0,function(){t.map=null,t.needsUpdate=!0,o&&o()})):(l=new THREE.Texture,(a=new THREE.ImageLoader(ve.TextureLoadingManager)).crossOrigin=this.crossOrigin,a.crossOrigin="anonymous",a.load(s,function(e){l.image=e,l.needsUpdate=!0,r&&r(l)},void 0,function(){t.map=null,t.needsUpdate=!0,o&&o()})),void 0!==i&&(l.mapping=i),e[n]=l)},getTrueTexName:function(e){var t=e;if(this.viewer.trueMapList)for(var n in this.viewer.trueMapList)if(e.toLowerCase()===this.viewer.trueMapList[n].toLowerCase()){t=this.viewer.trueMapList[n];break}return t},getFullTextPath:function(e,t){return-1<t.indexOf(e)||-1<t.indexOf("/")?t:e+this.getTrueTexName(t)},createMaterialForBIM:function(e,t,n,i,r){var o,a,s,l,d={side:THREE.FrontSide};function c(e){return 1<e?e:1}if(void 0!==t.name&&(d.name=t.name),void 0!==t.uuid&&(d.uuid=t.uuid),void 0!==t.type&&"LineBasicMaterial"===t.type&&(null==t.lineStyle&&null==t.lineTypeId||t.lineStyle==ve.DASHTYPE.SOLID||t.lineStyle==ve.DASHTYPE.CUSTOM&&null==t.lineTypeId))void 0!==t.color&&(d.color=(new THREE.Color).setHex(parseInt(t.color))),void 0!==t.doubleSided&&t.doubleSided&&(d.side=THREE.DoubleSide),void 0!==t.opacity&&(l=parseFloat(t.opacity))<1&&(d.transparent=!0,d.opacity=l),void 0!==_e.lineColor&&void 0!==d.color&&d.color.setHex(_e.lineColor),void 0!==t.linewidth&&(d.linewidth=c(parseFloat(t.linewidth))),s=new THREE.LineBasicMaterial(d),this.viewer.sketchStartLoad&&(s.defines={NOCLIPPING:""});else{if(void 0!==t.type&&"LineBasicMaterial"===t.type&&(t.lineStyle==ve.DASHTYPE.CUSTOM&&null!=t.lineTypeId||null==t.lineStyle&&null!=t.lineTypeId)&&this.viewer.lineTypes)(s=this.viewer.lineTypes.getMaterial(t.lineTypeId)).uniforms.lineTypeId.value=t.lineTypeId,void 0!==t.lineScale&&(s.uniforms.lineScale.value=parseFloat(t.lineScale)),void 0!==t.color&&s.uniforms.diffuse.value.setHex(parseInt(t.color)),void 0!==t.linewidth&&(s.linewidth=c(parseFloat(t.linewidth))),void 0!==t.opacity&&(l=parseFloat(t.opacity))<1&&(s.transparent=!0,s.uniforms.opacity.value=l),void 0!==_e.lineColor&&void 0!==d.color&&s.uniforms.diffuse.value.setHex(_e.lineColor);else{if(void 0===t.type||"LineBasicMaterial"!==t.type||null==t.lineStyle||t.lineStyle==ve.DASHTYPE.SOLID)return void 0!==t.version&&"LineBasicMaterial"!=t.type?((o=this.parseJsonMaterial(t,d))&&(o.polygonOffset=!0,o.polygonOffsetFactor=1,o.polygonOffsetUnits=1),o):(s=null,"PointMaterial"==t.type&&(o=this.viewer.modelContentVersion,t.type=4<=o?"PointsMaterial":"MeshStandardMaterial"),"MeshStandardMaterial"==t.type&&(t.type="MeshPhongMaterial"),o="","MeshBasicMaterial"==t.type&&(s=new((a=t.hatchType&&r&&r.has(t.hatchType))?It:THREE.MeshBasicMaterial),void 0!==t.color&&(d.color=(new THREE.Color).setHex(parseInt(t.color))),void 0!==t.doubleSided&&t.doubleSided&&(d.side=THREE.DoubleSide),void 0!==t.linewidth&&(s.linewidth=c(parseFloat(t.linewidth))),void 0!==t.opacity&&(l=parseFloat(t.opacity))<1&&(d.transparent=!0,d.opacity=l),void 0!==t.map&&null!==t.map&&this.viewer.is2DModel&&(o=this.getFullTextPath(n,t.map),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),s.setValues(d),a)&&((a=r.get(t.hatchType)).invert?(s.color1=(new THREE.Color).setHex(parseInt(a.sColor)),s.color2=(new THREE.Color).setHex(parseInt(a.mColor))):(s.color1=(new THREE.Color).setHex(parseInt(a.mColor)),s.color2=(new THREE.Color).setHex(parseInt(a.sColor))),s.hatchType=a.type,s.shift=a.shift,s.params=a.params||0),void 0===t.type||"MeshPhongMaterial"===t.type?(s=new THREE.MeshPhongMaterial,void 0!==t.color&&(d.color=(new THREE.Color).setHex(parseInt(t.color))),void 0!==t.wireframe&&(d.wireframe=t.wireframe),void 0!==t.emissive&&(d.emissive=(new THREE.Color).setHex(parseInt(t.emissive))),void 0!==t.specular&&(d.specular=(new THREE.Color).setHex(parseInt(t.specular))),void 0!==t.shininess&&(d.shininess=parseInt(t.shininess)),void 0!==t.doubleSided&&t.doubleSided&&(d.side=THREE.DoubleSide),void 0!==t.opacity&&(l=parseFloat(t.opacity))<1&&(d.transparent=!0,d.opacity=l),void 0!==t.mapDiffuse&&null!==t.mapDiffuse&&(o=this.getFullTextPath(n,t.mapDiffuse),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),void 0!==t.map&&null!==t.map&&(o=this.getFullTextPath(n,t.map),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),void 0!==t.mapBump&&null!==t.mapBump&&(o=this.getFullTextPath(n,t.mapBump),d.bumpMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.bumpMap.sourceFile=o,d.bumpMap.wrapS=THREE.RepeatWrapping,d.bumpMap.wrapT=THREE.RepeatWrapping),void 0!==t.bumpMap&&null!==t.bumpMap&&(o=this.getFullTextPath(n,t.bumpMap),d.bumpMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.bumpMap.sourceFile=o,d.bumpMap.wrapS=THREE.RepeatWrapping,d.bumpMap.wrapT=THREE.RepeatWrapping),void 0!==t.bumpScale&&(d.bumpScale=parseFloat(t.bumpScale)),void 0!==t.reflectivity&&(d.reflectivity=parseFloat(t.reflectivity)),void 0!==t.refractionRatio&&(d.refractionRatio=parseFloat(t.refractionRatio)),void 0!==t.emissiveIntensity&&(d.emissiveIntensity=parseFloat(t.emissiveIntensity)),void 0!==t.shading&&(0==t.shading||2==parseInt(t.shading)?d.flatShading=!1:d.flatShading=!0),s.setValues(d)):"MeshStandardMaterial"===t.type?(s=new THREE.MeshStandardMaterial,void 0!==t.color&&(d.color=(new THREE.Color).setHex(parseInt(t.color))),void 0!==t.wireframe&&(d.wireframe=t.wireframe),void 0!==t.emissive&&(d.emissive=(new THREE.Color).setHex(parseInt(t.emissive))),void 0!==t.doubleSided&&t.doubleSided&&(d.side=THREE.DoubleSide),void 0!==t.opacity&&(l=parseFloat(t.opacity))<1&&(d.transparent=!0,d.opacity=l),void 0!==t.mapDiffuse&&null!==t.mapDiffuse&&(o=this.getFullTextPath(n,t.mapDiffuse),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),void 0!==t.map&&null!==t.map&&(o=this.getFullTextPath(n,t.map),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),void 0!==t.mapBump&&null!==t.mapBump&&(o=this.getFullTextPath(n,t.mapBump),d.bumpMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.bumpMap.sourceFile=o,d.bumpMap.wrapS=THREE.RepeatWrapping,d.bumpMap.wrapT=THREE.RepeatWrapping),void 0!==t.bumpMap&&null!==t.bumpMap&&(o=this.getFullTextPath(n,t.bumpMap),d.bumpMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.bumpMap.sourceFile=o,d.bumpMap.wrapS=THREE.RepeatWrapping,d.bumpMap.wrapT=THREE.RepeatWrapping),void 0!==t.bumpScale&&(d.bumpScale=parseFloat(t.bumpScale)),void 0!==t.reflectivity&&(d.envMapIntensity=parseFloat(t.reflectivity)),void 0!==t.emissiveIntensity&&(d.emissiveIntensity=parseFloat(t.emissiveIntensity)),void 0!==t.envMapIntensity&&(d.envMapIntensity=parseFloat(t.envMapIntensity)),void 0!==t.refractionRatio&&(d.refractionRatio=parseFloat(t.refractionRatio)),void 0!==t.roughness&&(d.roughness=1,this.viewer.reflected)&&(d.roughness=.5),void 0!==t.metalness&&(d.metalness=.3,this.viewer.reflected)&&(d.metalness=.5),void 0===t.roughness&&void 0===t.metalness&&void 0!==t.shininess&&(0==t.shininess?(d.roughness=.8,d.metalness=.5):15<t.shininess&&(d.metalness=.65,d.roughness=.1)),void 0!==t.shading&&(0==t.shading||2==parseInt(t.shading)?d.flatShading=!1:d.flatShading=!0),s.setValues(d),s.polygonOffset=!0,s.polygonOffsetFactor=1,s.polygonOffsetUnits=1):"MeshPhysicalMaterial"==t.type?(this.viewer.hasPbrMaterial=!0,s=new THREE.MeshPhysicalMaterial,void 0!==t.color&&(d.color=(new THREE.Color).setHex(parseInt(t.color))),void 0!==t.wireframe&&(d.wireframe=t.wireframe),void 0!==t.emissive&&(d.emissive=(new THREE.Color).setHex(parseInt(t.emissive))),void 0!==t.specular&&(d.specularColor=(new THREE.Color).setHex(3158064)),void 0!==t.shininess&&(d.shininess=parseInt(t.shininess)),void 0!==t.doubleSided&&t.doubleSided&&(d.side=THREE.DoubleSide),void 0!==t.bumpScale&&(d.bumpScale=parseFloat(t.bumpScale)),void 0!==t.reflectivity&&(d.reflectivity=parseFloat(t.reflectivity)),void 0!==t.refractionRatio&&(d.refractionRatio=parseFloat(t.refractionRatio)),void 0!==t.emissiveIntensity&&(d.emissiveIntensity=parseFloat(t.emissiveIntensity)),void 0!==t.roughness&&(d.roughness=parseFloat(t.roughness)),void 0!==t.metalness&&(d.metalness=parseFloat(t.metalness)),void 0!==t.alphaTest&&(d.alphaTest=parseFloat(t.alphaTest)),void 0!==t.clearcoat&&(d.clearcoat=parseFloat(t.clearcoat)),void 0!==t.clearcoatRoughness&&(d.clearcoatRoughness=parseFloat(t.clearcoatRoughness)),void 0!==t.specularIntensity&&(d.specularIntensity=parseFloat(t.specularIntensity)),void 0!==t.ior&&(d.ior=parseFloat(t.ior)),void 0!==t.transmission&&Se.isSupportCanvas2()&&(d.transmission=parseFloat(t.transmission)),void 0!==t.normalScale&&(r=parseFloat(t.normalScale),d.normalScale=new THREE.Vector2(r,r)),void 0!==t.opacity&&(a=parseFloat(t.opacity))<1&&(d.transparent=!0,d.opacity=a),void 0!==t.shading&&(0==t.shading||2==parseInt(t.shading)?d.flatShading=!1:d.flatShading=!0),void 0!==t.mapDiffuse&&null!==t.mapDiffuse&&(o=this.getFullTextPath(n,t.mapDiffuse),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),void 0!==t.mapDiffuse&&null!==t.mapDiffuse&&(o=this.getFullTextPath(n,t.mapDiffuse),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),void 0!==t.map&&null!==t.map&&(o=this.getFullTextPath(n,t.map),d.map=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.map.sourceFile=o,d.map.wrapS=THREE.RepeatWrapping,d.map.wrapT=THREE.RepeatWrapping),void 0!==t.normalMap&&null!==t.normalMap&&(o=this.getFullTextPath(n,t.normalMap),d.normalMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.normalMap.sourceFile=o,d.normalMap.wrapS=THREE.RepeatWrapping,d.normalMap.wrapT=THREE.RepeatWrapping),void 0!==t.emissiveMap&&null!==t.emissiveMap&&(o=this.getFullTextPath(n,t.emissiveMap),d.emissiveMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.emissiveMap.sourceFile=o,d.emissiveMap.wrapS=THREE.RepeatWrapping,d.emissiveMap.wrapT=THREE.RepeatWrapping),void 0!==t.alphaMap&&null!==t.alphaMap&&(o=this.getFullTextPath(n,t.alphaMap),d.alphaMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.alphaMap.sourceFile=o,d.alphaMap.wrapS=THREE.RepeatWrapping,d.alphaMap.wrapT=THREE.RepeatWrapping),void 0!==t.metalnessMap&&null!==t.metalnessMap&&(o=this.getFullTextPath(n,t.metalnessMap),d.metalnessMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.metalnessMap.sourceFile=o,d.metalnessMap.wrapS=THREE.RepeatWrapping,d.metalnessMap.wrapT=THREE.RepeatWrapping),void 0!==t.roughnessMap&&null!==t.roughnessMap&&(o=this.getFullTextPath(n,t.roughnessMap),d.roughnessMap=this.loadTexture(s,e,o,void 0,void 0,ve.TextureLoadingManager.onError),d.roughnessMap.sourceFile=o,d.roughnessMap.wrapS=THREE.RepeatWrapping,d.roughnessMap.wrapT=THREE.RepeatWrapping),s.setValues(d)):"PointsMaterial"===t.type&&(s=new THREE.PointsMaterial,void 0!==t.color&&(d.color=(new THREE.Color).setHex(parseInt(t.color))),s.setValues(d),s.linewidth=t.pointSize?c(parseFloat(t.pointSize)):1),i&&s&&(s.polygonOffset=!0,s.polygonOffsetFactor=1,s.polygonOffsetUnits=1),s);switch((s=_e.dashedMaterial.clone()).uniforms.lineStyle.value=t.lineStyle,t.lineStyle){case ve.DASHTYPE.DASH:s.uniforms.dashNum.value=1,s.uniforms.pointNum.value=0,s.uniforms.pointSize.value=0;break;case ve.DASHTYPE.DASHSPACE:s.uniforms.dashNum.value=1,s.uniforms.grapSize.value*=6,s.uniforms.pointNum.value=0,s.uniforms.pointSize.value=0;break;case ve.DASHTYPE.LONGDASH_DOT:s.uniforms.dashSize.value*=2;break;case ve.DASHTYPE.LONGDASH_DOUBLEDOT:s.uniforms.dashSize.value*=2,s.uniforms.pointNum.value=2;break;case ve.DASHTYPE.LONGDASH_TRIPLEDOT:s.uniforms.dashSize.value*=2,s.uniforms.pointNum.value=3;break;case ve.DASHTYPE.DOT0:s.uniforms.dashNum.value=0;break;case ve.DASHTYPE.LONGDASH_SHORTDASH:s.uniforms.dashSize.value*=2,s.uniforms.pointSize.value=6;break;case ve.DASHTYPE.LONGDASH_DOUBLESHORTDASH:s.uniforms.dashSize.value*=2,s.uniforms.pointSize.value=6,s.uniforms.pointNum.value=2;break;case ve.DASHTYPE.DASH_DOT:break;case ve.DASHTYPE.DOUBLEDASH_DOT:s.uniforms.dashNum.value=2;break;case ve.DASHTYPE.DASH_DOUBLEDOT:s.uniforms.pointNum.value=2;break;case ve.DASHTYPE.DOUBLEDASH_DOUBLEDOT:s.uniforms.dashNum.value=2,s.uniforms.pointNum.value=2;break;case ve.DASHTYPE.DASH_TRIPLEDOT:s.uniforms.pointNum.value=3;break;case ve.DASHTYPE.DOUBLEDASH_TRIPLEDOT:s.uniforms.dashNum.value=2,s.uniforms.pointNum.value=3;break;case ve.DASHTYPE.BATTING:break;case ve.DASHTYPE.BORDER:s.uniforms.dashNum.value=2;break;case ve.DASHTYPE.BORDER2:s.uniforms.dashSize.value*=.5,s.uniforms.dashNum.value=2;break;case ve.DASHTYPE.BORDERX2:s.uniforms.dashNum.value=2,s.uniforms.dashSize.value*=2;break;case ve.DASHTYPE.CENTER:s.uniforms.pointSize.value=6,s.uniforms.dashSize.value*=2,s.uniforms.grapSize.value=6;break;case ve.DASHTYPE.CENTER2:s.uniforms.pointSize.value=3;break;case ve.DASHTYPE.CENTERX2:s.uniforms.pointSize.value=6,s.uniforms.dashSize.value*=4,s.uniforms.grapSize.value=6;break;case ve.DASHTYPE.DASHDOT:break;case ve.DASHTYPE.DASHDOT2:s.uniforms.dashSize.value*=.5,s.uniforms.grapSize.value*=.5;break;case ve.DASHTYPE.DASHDOTX2:s.uniforms.dashSize.value*=2,s.uniforms.grapSize.value*=2;break;case ve.DASHTYPE.DASHED:s.uniforms.pointNum.value=0,s.uniforms.grapSize.value*=2;break;case ve.DASHTYPE.DASHED2:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.5;break;case ve.DASHTYPE.DASHEDX2:s.uniforms.pointNum.value=2,s.uniforms.dashSize.value*=2,s.uniforms.grapSize.value*=4;break;case ve.DASHTYPE.DIVIDE:s.uniforms.pointNum.value=2,s.uniforms.grapSize.value*=2;break;case ve.DASHTYPE.DIVIDE2:s.uniforms.pointNum.value=2,s.uniforms.dashSize.value*=.5;break;case ve.DASHTYPE.DIVIDEX2:s.uniforms.pointNum.value=2,s.uniforms.dashSize.value*=2,s.uniforms.grapSize.value*=4;break;case ve.DASHTYPE.DOT:s.uniforms.dashNum.value=0,s.uniforms.grapSize.value*=2;break;case ve.DASHTYPE.DOT2:s.uniforms.dashNum.value=0;break;case ve.DASHTYPE.DOTX2:s.uniforms.dashNum.value=0,s.uniforms.grapSize.value*=4;break;case ve.DASHTYPE.FENCELINE1:case ve.DASHTYPE.FENCELINE2:case ve.DASHTYPE.GAS_LINE:break;case ve.DASHTYPE.HIDDEN:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.5;break;case ve.DASHTYPE.HIDDEN2:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.25,s.uniforms.grapSize.value*=.5;break;case ve.DASHTYPE.HIDDENX2:s.uniforms.pointNum.value=0,s.uniforms.grapSize.value*=2;break;case ve.DASHTYPE.HOT_WATER_SUPPLY:break;case ve.DASHTYPE.JIS_02_07:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.07,s.uniforms.grapSize.value*=.17;break;case ve.DASHTYPE.JIS_02_10:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.1,s.uniforms.grapSize.value*=.2;break;case ve.DASHTYPE.JIS_02_12:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.12,s.uniforms.grapSize.value*=.22;break;case ve.DASHTYPE.JIS_02_20:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.2,s.uniforms.grapSize.value*=.26;break;case ve.DASHTYPE.JIS_02_40:s.uniforms.pointNum.value=0,s.uniforms.dashSize.value*=.4,s.uniforms.grapSize.value*=.5;break;case ve.DASHTYPE.JIS_08_11:s.uniforms.pointSize.value=.7,s.uniforms.dashSize.value=11;break;case ve.DASHTYPE.JIS_08_15:s.uniforms.pointSize.value=.7,s.uniforms.dashSize.value=15;break;case ve.DASHTYPE.JIS_08_25:s.uniforms.pointSize.value=.7,s.uniforms.dashSize.value=25;break;case ve.DASHTYPE.JIS_08_37:s.uniforms.pointSize.value=.7,s.uniforms.grapSize.value=1,s.uniforms.dashSize.value=37;break;case ve.DASHTYPE.JIS_08_50:s.uniforms.pointSize.value=.7,s.uniforms.grapSize.value=1.4,s.uniforms.dashSize.value=50;break;case ve.DASHTYPE.JIS_09_08:s.uniforms.pointNum.value=2,s.uniforms.pointSize.value=.5,s.uniforms.dashSize.value=8,s.uniforms.grapSize.value=.9;break;case ve.DASHTYPE.JIS_09_15:s.uniforms.pointNum.value=2,s.uniforms.pointSize.value=.5,s.uniforms.dashSize.value=15,s.uniforms.grapSize.value=.9;break;case ve.DASHTYPE.JIS_09_29:s.uniforms.pointNum.value=2,s.uniforms.pointSize.value=.5,s.uniforms.dashSize.value=29,s.uniforms.grapSize.value=.9;break;case ve.DASHTYPE.JIS_09_50:s.uniforms.pointNum.value=2,s.uniforms.pointSize.value=.5,s.uniforms.dashSize.value=50,s.uniforms.grapSize.value=.9;break;case ve.DASHTYPE.PHANTOM:s.uniforms.pointNum.value=2,s.uniforms.pointSize.value=6,s.uniforms.dashSize.value=31,s.uniforms.grapSize.value=6;break;case ve.DASHTYPE.PHANTOM2:s.uniforms.pointNum.value=2,s.uniforms.pointSize.value=3,s.uniforms.dashSize.value=15,s.uniforms.grapSize.value=3;break;case ve.DASHTYPE.PHANTOMX2:s.uniforms.pointNum.value=2,s.uniforms.pointSize.value=12,s.uniforms.dashSize.value=60,s.uniforms.grapSize.value=12;break;case ve.DASHTYPE.TRACKS:case ve.DASHTYPE.ZIGZAG:}void 0!==t.color&&s.uniforms.diffuse.value.setHex(parseInt(t.color)),void 0!==t.opacity&&(l=parseFloat(t.opacity))<1&&(s.transparent=!0,s.uniforms.opacity.value=l),void 0!==_e.lineColor&&void 0!==d.color&&s.uniforms.diffuse.value.setHex(_e.lineColor),void 0!==t.linewidth&&(s.linewidth=c(parseFloat(t.linewidth)))}s.color=new THREE.Color(16777215),s.color.copy(s.uniforms.diffuse.value),s.setValues(d)}return s},parseJsonMaterial:function(e,t){return"MeshPhongMaterial"==e.type?this.parsePhongMaterial(e,t):"MeshPhysicalMaterial"==e.type?this.parsePhysicalMaterial(e,t):"MeshBasicMaterial"==e.type?this.parseBasicMaterial(e,t):"MeshStandardMaterial"==e.type?this.parseStandardMaterial(e,t):this.parsePhongMaterial(e,t)},parsePhongMaterial:function(e,t){var n,i=new THREE.MeshPhongMaterial;return void 0!==e.color&&(t.color=(new THREE.Color).setHex(parseInt(e.color))),void 0!==e.wireframe&&(t.wireframe=e.wireframe),void 0!==e.emissive&&(t.emissive=(new THREE.Color).setHex(parseInt(e.emissive))),void 0!==e.specular&&(t.specular=(new THREE.Color).setHex(parseInt(e.specular))),void 0!==e.shininess&&(t.shininess=parseFloat(e.shininess)),void 0!==e.doubleSided&&e.doubleSided&&(t.side=THREE.DoubleSide),void 0!==e.bumpScale&&(t.bumpScale=parseFloat(e.bumpScale)),void 0!==e.reflectivity&&(t.reflectivity=parseFloat(e.reflectivity)),void 0!==e.refractionRatio&&(t.refractionRatio=parseFloat(e.refractionRatio)),void 0!==e.emissiveIntensity&&(t.emissiveIntensity=parseFloat(e.emissiveIntensity)),void 0!==e.opacity&&(n=parseFloat(e.opacity))<1&&(t.transparent=!0,t.opacity=n),void 0!==e.shading&&(0==e.shading||2==parseInt(e.shading)?t.flatShading=!1:t.flatShading=!0),void 0!==e.normalScale&&(n=parseFloat(e.normalScale),t.normalScale=new THREE.Vector2(n,n)),e.map&&this.loadMapTexture(e,t,"map",e.map),e.normalMap&&this.loadMapTexture(e,t,"normalMap",e.normalMap),e.emissiveMap&&this.loadMapTexture(e,t,"emissiveMap",e.emissiveMap),e.normalMap&&this.loadMapTexture(e,t,"normalMap",e.normalMap),e.specularMap&&this.loadMapTexture(e,t,"specularMap",e.specularMap),e.alphaMap&&this.loadMapTexture(e,t,"alphaMap",e.alphaMap),e.alphaMap&&(t.transparent=!0),i.setValues(t),i},parsePhysicalMaterial:function(e,t){var n,i=new THREE.MeshPhysicalMaterial;return void 0!==e.color&&(t.color=(new THREE.Color).setHex(parseInt(e.color))),void 0!==e.wireframe&&(t.wireframe=e.wireframe),void 0!==e.emissive&&(t.emissive=(new THREE.Color).setHex(parseInt(e.emissive))),void 0!==e.specular&&(t.specularColor=(new THREE.Color).setHex(parseInt(e.specular))),void 0!==e.shininess&&(t.shininess=parseFloat(e.shininess)),void 0!==e.doubleSided&&e.doubleSided&&(t.side=THREE.DoubleSide),void 0!==e.bumpScale&&(t.bumpScale=parseFloat(e.bumpScale)),void 0!==e.reflectivity&&(t.reflectivity=parseFloat(e.reflectivity)),void 0!==e.refractionRatio&&(t.refractionRatio=parseFloat(e.refractionRatio)),void 0!==e.emissiveIntensity&&(t.emissiveIntensity=parseFloat(e.emissiveIntensity)),void 0!==e.roughness&&(t.roughness=parseFloat(e.roughness)),void 0!==e.metalness&&(t.metalness=parseFloat(e.metalness)),void 0!==e.alphaTest&&(t.alphaTest=parseFloat(e.alphaTest)),void 0!==e.clearcoat&&(t.clearcoat=parseFloat(e.clearcoat)),void 0!==e.clearcoatRoughness&&(t.clearcoatRoughness=parseFloat(e.clearcoatRoughness)),void 0!==e.specularIntensity&&(t.specularIntensity=parseFloat(e.specularIntensity)),void 0!==e.ior&&(t.ior=parseFloat(e.ior)),void 0!==e.transmission&&Se.isSupportCanvas2()&&(t.transmission=parseFloat(e.transmission)),void 0!==e.normalScale&&(n=parseFloat(e.normalScale),t.normalScale=new THREE.Vector2(n,n)),void 0!==e.opacity&&(n=parseFloat(e.opacity))<1&&(t.transparent=!0,t.opacity=n),void 0!==e.shading&&(0==e.shading||2==parseInt(e.shading)?t.flatShading=!1:t.flatShading=!0),e.map&&this.loadMapTexture(e,t,"map",e.map),e.normalMap&&this.loadMapTexture(e,t,"normalMap",e.normalMap),e.emissiveMap&&this.loadMapTexture(e,t,"emissiveMap",e.emissiveMap),e.alphaMap&&this.loadMapTexture(e,t,"alphaMap",e.alphaMap),e.metalnessMap&&this.loadMapTexture(e,t,"metalnessMap",e.metalnessMap),e.roughnessMap&&this.loadMapTexture(e,t,"roughnessMap",e.roughnessMap),e.specularIntensityMap&&this.loadMapTexture(e,t,"specularIntensityMap",e.specularIntensityMap),e.mapSpecular&&this.loadMapTexture(e,t,"specularColorMap",e.mapSpecular),e.alphaMap&&(t.transparent=!0),i.setValues(t),i},parseBasicMaterial:function(e,t){var n,i=new THREE.MeshBasicMaterial;return void 0!==e.color&&(t.color=(new THREE.Color).setHex(parseInt(e.color))),void 0!==e.doubleSided&&e.doubleSided&&(t.side=THREE.DoubleSide),void 0!==e.opacity&&(n=parseFloat(e.opacity))<1&&(t.transparent=!0,t.opacity=n),e.map&&this.loadMapTexture(e,t,"map",e.map),e.alphaMap&&this.loadMapTexture(e,t,"alphaMap",e.alphaMap),i.setValues(t),e.alphaMap&&(t.transparent=!0),i},parseStandardMaterial:function(e,t){var n,i=new THREE.MeshStandardMaterial;return void 0!==e.color&&(t.color=(new THREE.Color).setHex(parseInt(e.color))),void 0!==e.wireframe&&(t.wireframe=e.wireframe),void 0!==e.emissive&&(t.emissive=(new THREE.Color).setHex(parseInt(e.emissive))),void 0!==e.doubleSided&&e.doubleSided&&(t.side=THREE.DoubleSide),void 0!==e.bumpScale&&(t.bumpScale=parseFloat(e.bumpScale)),void 0!==e.reflectivity&&(t.envMapIntensity=parseFloat(e.reflectivity)),void 0!==e.emissiveIntensity&&(t.emissiveIntensity=parseFloat(e.emissiveIntensity)),void 0!==e.envMapIntensity&&(t.envMapIntensity=parseFloat(e.envMapIntensity)),void 0!==e.refractionRatio&&(t.refractionRatio=parseFloat(e.refractionRatio)),void 0!==e.roughness&&(t.roughness=parseFloat(e.roughness)),void 0!==e.metalness&&(t.metalness=parseFloat(e.metalness)),void 0!==e.alphaTest&&(t.alphaTest=parseFloat(e.alphaTest)),void 0!==e.normalScale&&(n=parseFloat(e.normalScale),t.normalScale=new THREE.Vector2(n,n)),void 0!==e.opacity&&(n=parseFloat(e.opacity))<1&&(t.transparent=!0,t.opacity=n),void 0!==e.shading&&(0==e.shading||2==parseInt(e.shading)?t.flatShading=!1:t.flatShading=!0),e.map&&this.loadMapTexture(e,t,"map",e.map),e.normalMap&&this.loadMapTexture(e,t,"normalMap",e.normalMap),e.emissiveMap&&this.loadMapTexture(e,t,"emissiveMap",e.emissiveMap),e.alphaMap&&this.loadMapTexture(e,t,"alphaMap",e.alphaMap),e.metalnessMap&&this.loadMapTexture(e,t,"metalnessMap",e.metalnessMap),e.roughnessMap&&this.loadMapTexture(e,t,"roughnessMap",e.roughnessMap),e.alphaMap&&(t.transparent=!0),i.setValues(t),i},loadMapTexture:function(e,t,n,i){t[n]=(new THREE.TextureLoader).load(i),t[n].sourceFile=i,t[n].wrapS=THREE.RepeatWrapping,t[n].wrapT=THREE.RepeatWrapping},initMaterials:function(e,t,n,i,r,o){if(e){null!=n&&(this.viewer.lineTypes&&this.viewer.lineTypes.clearLineType(),this.viewer.lineTypes=new Et(this.viewer),this.viewer.lineTypes.createLineStyle(n,r));var a=new Map;if(null!=i)for(var s=0;s<i.length;s++)a.set(i[s].uuid,i[s]);for(var l=!1,d=0;d<e.length;++d)if(void 0!==(u=e[d]).type&&"LineBasicMaterial"===u.type){l=!0;break}for(var c=[],h={},d=0;d<e.length;++d){36===(u=e[d]).uuid.length&&(u.uuid=u.uuid.slice(0,8)+u.uuid.slice(9,13)+u.uuid.slice(14,18)+u.uuid.slice(19,23)+u.uuid.slice(24,36)),_e.ScenarioEditor&&(m=Se.addSceneID(u.uuid),u.uuid=THREE.Math.generateUUID(),u.uuid=u.uuid.slice(0,8)+u.uuid.slice(9,13)+u.uuid.slice(14,18)+u.uuid.slice(19,23)+u.uuid.slice(24,36),this.viewer.ndsModel.materialuuidOld2New[m]=u.uuid),u.jsonUrl&&(t=this.extractUrlBase(u.jsonUrl));var u,p,f="";for(p in u)"uuid"!=p&&(f+=u[p]);var m=null;(o.loadingPmi?(o.refModelContext.uniquePMIMaterialMap.has(f)?m=o.refModelContext.uniquePMIMaterialMap.get(f):(m=this.createMaterialForBIM(h,u,t,l,a),o.refModelContext.uniquePMIMaterialMap.set(f,m)),c[u.uuid]={mat:m},o.refModelContext.uuidPMIMaterialMap):(o.refModelContext.uniqueMaterialMap.has(f)?m=o.refModelContext.uniqueMaterialMap.get(f):(m=this.createMaterialForBIM(h,u,t,l,a),o.refModelContext.uniqueMaterialMap.set(f,m),c[u.uuid]={mat:m,refCount:0}),o.refModelContext.uuidMaterialMap)).set(u.uuid,m)}return c}},needsTangents:function(e){for(var t=0,n=e.length;t<n;t++)if(e[t]instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(e,c){var h=this;function u(e){e=Math.log(e)/Math.LN2;return Math.pow(2,Math.round(e))}function t(e,t,n,i,r,o,a){var s=c+n,l=null,d=new THREE.Texture;(l=h.imageLoader).crossOrigin=h.crossOrigin,l.load(s,function(e){var t,n,i;!1===THREE.Math.isPowerOfTwo(e.width)||!1===THREE.Math.isPowerOfTwo(e.height)?(t=u(e.width),n=u(e.height),(i=document.createElement("canvas")).width=t,i.height=n,i.getContext("2d").drawImage(e,0,0,t,n),d.image=i):d.image=e,d.needsUpdate=!0}),d.sourceFile=n,i&&(d.repeat.set(i[0],i[1]),1!==i[0]&&(d.wrapS=THREE.RepeatWrapping),1!==i[1])&&(d.wrapT=THREE.RepeatWrapping),r&&d.offset.set(r[0],r[1]),o&&(void 0!==(l={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping})[o[0]]&&(d.wrapS=l[o[0]]),void 0!==l[o[1]])&&(d.wrapT=l[o[1]]),a&&(d.anisotropy=a),e[t]=d}function n(e){return(255*e[0]<<16)+(255*e[1]<<8)+255*e[2]}var i,r,o="MeshLambertMaterial",a={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:!1};return e.shading&&("phong"===(i=e.shading.toLowerCase())?o="MeshPhongMaterial":"basic"===i&&(o="MeshBasicMaterial")),void 0!==e.blending&&void 0!==THREE[e.blending]&&(a.blending=THREE[e.blending]),(void 0!==e.transparent||e.opacity<1)&&(a.transparent=e.transparent),void 0!==e.depthTest&&(a.depthTest=e.depthTest),void 0!==e.depthWrite&&(a.depthWrite=e.depthWrite),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.flipSided&&(a.side=THREE.BackSide),void 0!==e.doubleSided&&(a.side=THREE.DoubleSide),void 0!==e.wireframe&&(a.wireframe=e.wireframe),void 0!==e.vertexColors&&(a.vertexColors=!0),e.colorDiffuse?a.color=n(e.colorDiffuse):e.DbgColor&&(a.color=e.DbgColor),e.colorSpecular&&(a.specular=n(e.colorSpecular)),e.colorAmbient&&(a.ambient=n(e.colorAmbient)),e.colorEmissive&&(a.emissive=n(e.colorEmissive)),e.transparency&&(a.opacity=e.transparency),e.specularCoef&&(a.shininess=e.specularCoef),e.mapDiffuse&&c&&t(a,"map",e.mapDiffuse,e.mapDiffuseRepeat,e.mapDiffuseOffset,e.mapDiffuseWrap,e.mapDiffuseAnisotropy),e.mapLight&&c&&t(a,"lightMap",e.mapLight,e.mapLightRepeat,e.mapLightOffset,e.mapLightWrap,e.mapLightAnisotropy),e.mapBump&&c&&t(a,"bumpMap",e.mapBump,e.mapBumpRepeat,e.mapBumpOffset,e.mapBumpWrap,e.mapBumpAnisotropy),e.mapNormal&&c&&t(a,"normalMap",e.mapNormal,e.mapNormalRepeat,e.mapNormalOffset,e.mapNormalWrap,e.mapNormalAnisotropy),e.mapSpecular&&c&&t(a,"specularMap",e.mapSpecular,e.mapSpecularRepeat,e.mapSpecularOffset,e.mapSpecularWrap,e.mapSpecularAnisotropy),e.mapAlpha&&c&&t(a,"alphaMap",e.mapAlpha,e.mapAlphaRepeat,e.mapAlphaOffset,e.mapAlphaWrap,e.mapAlphaAnisotropy),e.mapBumpScale&&(a.bumpScale=e.mapBumpScale),e.mapNormal?(i=THREE.ShaderLib.normalmap,(r=THREE.UniformsUtils.clone(i.uniforms)).tNormal.value=a.normalMap,e.mapNormalFactor&&r.uNormalScale.value.set(e.mapNormalFactor,e.mapNormalFactor),a.map&&(r.tDiffuse.value=a.map,r.enableDiffuse.value=!0),a.specularMap&&(r.tSpecular.value=a.specularMap,r.enableSpecular.value=!0),a.lightMap&&(r.tAO.value=a.lightMap,r.enableAO.value=!0),r.diffuse.value.setHex(a.color),r.specular.value.setHex(a.specular),r.ambient.value.setHex(a.ambient),r.shininess.value=a.shininess,void 0!==a.opacity&&(r.opacity.value=a.opacity),i={fragmentShader:i.fragmentShader,vertexShader:i.vertexShader,uniforms:r,lights:!0,fog:!0},r=new THREE.ShaderMaterial(i),a.transparent&&(r.transparent=!0)):r=new THREE[o](a),void 0!==e.DbgName&&(r.name=e.DbgName),r}},bt.ensurePowerOfTwo_=function(e){var t;return THREE.Math.isPowerOfTwo(e.width)&&THREE.Math.isPowerOfTwo(e.height)?e:((t=document.createElement("canvas")).width=bt.nextHighestPowerOfTwo_(e.width),t.height=bt.nextHighestPowerOfTwo_(e.height),t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),t)},bt.nextHighestPowerOfTwo_=function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},function(e,t){this.viewer=e,this.type=2,this.version=0;function l(e,i){function t(e){for(var t=0,n=e.length;t<n;++t)if(e[t]===i)return 1}if(C.viewer.ndsModel&&C.brepInfos.bodies.has(e)){for(var n,r=C.brepInfos.breps[C.brepInfos.bodies.get(e)],o=0,a=r.edgeGroups.length;o<a;++o){var s=C.brepInfos.edgeGroups[r.edgeGroups[o]];!(n=!(n=!(n=!(n=s.lines&&t(s.lines.ids)?s.geomUUID:n)&&s.circles&&t(s.circles.ids)?s.geomUUID:n)&&s.ellipses&&t(s.ellipses.ids)?s.geomUUID:n)&&s.nurbses&&t(s.nurbses.ids)?s.geomUUID:n)&&s.others&&t(s.others.ids)&&(n=s.geomUUID)}if(n){e=C.viewer.ndsModel.getBodyNodeFromUuid(e);if(e)return C.viewer.ndsModel.meshManager.getBodyMeshIdFromGeomUUid(e,n)}}return null}function o(e,i,t){if(!0!==R)return null;if(!C.brepInfos.bodies.has(e))return null;function n(e){for(var t=0,n=e.length;t<n;t++)if(e[t]==i)return t;return-1}var r=C.brepInfos.breps[C.brepInfos.bodies.get(e)];if(t.toLowerCase(),"face"===t&&r.faceGroups)for(var o=0,a=r.faceGroups.length;o<a;o++){var s=C.brepInfos.faceGroups[r.faceGroups[o]],l=!1,d=null;if(s.planes){var c=n(s.planes.ids);if(-1<c&&(l=!0,d=w(s,"plane",c)),!l&&s.cylinders&&-1<(c=n(s.cylinders.ids))&&(l=!0,d=w(s,"cylinder",c)),!l&&s.cones&&-1<(c=n(s.cones.ids))&&(l=!0,d=w(s,"cone",c)),!l&&s.spheres&&-1<(c=n(s.spheres.ids))&&(l=!0,d=w(s,"sphere",c)),!l&&s.toruses&&-1<(c=n(s.toruses.ids))&&(l=!0,d=w(s,"torus",c)),!l&&s.nurbses&&-1<(c=n(s.nurbses.ids))&&(l=!0,d=w(s,"nurbs",c)),!l&&s.others&&-1<(c=n(s.others.ids))&&(l=!0,d=w(s,"other",c)),l&&C.viewer.ndsModel){var h=s.geomUUID;if(A=C.viewer.ndsModel.getBodyNodeFromUuid(e)){c=C.viewer.ndsModel.meshManager.getBodyMeshIdFromGeomUUid(A,h);if(-1<c)if(v=C.viewer.ndsModel.meshManager.getSingleMesh(c))return d.parentObj=v,d.bodyId=e,d.meshId=h,d}}}return null}else{if("edge"===t&&r.edgeGroups){for(o=0,a=r.edgeGroups.length;o<a;o++){var u,p,f,m=C.brepInfos.edgeGroups[r.edgeGroups[o]],l=!1,g=null;if(m.lines&&-1<(u=n(m.lines.ids))&&(l=!0,g=b(m,"line",u)),!l&&m.circles&&-1<(u=n(m.circles.ids))&&(l=!0,g=b(m,"circle",u)),!l&&m.ellipses&&-1<(p=n(m.ellipses.ids))&&(l=!0,g=b(m,"ellipse",p)),!l&&m.nurbses&&-1<(p=n(m.nurbses.ids))&&(l=!0,g=b(m,"nurbs",p)),!l&&m.others&&-1<(f=n(m.others.ids))&&(l=!0,g=b(m,"other",f)),l&&C.viewer.ndsModel){var v,h=m.geomUUID,A=C.viewer.ndsModel.getBodyNodeFromUuid(e);if(A)if(v=C.viewer.ndsModel.meshManager.getBodyLineSegmentsFromGeomUUid(A,h))return g.parentObj=v,g.bodyId=e,g.meshId=h,g}}return null}if("vertex"===t&&r.vertices){for(o=0,a=r.vertices.length;o<a;o++){var y,E,M=r.vertices[o];if(i===C.brepInfos.vertices.ids[M])return y=null,C.viewer.ndsModel&&(A=C.viewer.ndsModel.getBodyNodeFromUuid(e),C.viewer.ndsModel.meshManager.getMeshInfor(A.id,E={}),y=E.matrixWorld),(E=new THREE.Vector3(C.brepInfos.vertices.coords[3*M+0],C.brepInfos.vertices.coords[3*M+1],C.brepInfos.vertices.coords[3*M+2])).applyMatrix4(y),{id:i,coords:[E.x,E.y,E.z],bodyId:e}}return null}}}var C=this,R=(this.modelRequestor=t||null,this.mesh2geom=null,this.brepInfos={},this.brepInfos.bodies=new Map,this.brepInfos.edgeGroups=[],this.brepInfos.faceGroups=[],!(this.brepInfos.breps=[])),O={},a=[],s=[],n=[],d=[],L=new Map,w=(this.maxRequestNum=10,this.chunkRequestQueue=[],this.addRequest=function(){if(this.modelRequestor)for(var e=0;e<a.length;e++)s[e]||(this.modelRequestor.addRequest(a[e],1e5,"loadBrepData",{modelId:n[e],keepSourceFile:!!_e.ScenarioEditor,gobalReqHeader:C.viewer.gobalReqHeader}),d[e]=!0)},this.addBrepFileUrl=function(e,t){a.push(e),s.push(!1),n.push(t),this.modelRequestor&&d.push(!1)},this.bindReference=function(e,t){L.set(e,t)},this.onLoad=function(e,t,n,i){C.filesToLoadCount--;for(var r=0;r<a.length;r++)a[r]===e&&(R=!(d[r]=!(s[r]=!0)));_e.singleHTML&&0==a.length&&(R=!0),C.viewer.brepInfo.BfaceArea=i,C.viewer.brepInfo.BbodyVolume=t,C.viewer.brepInfo.BbodyArea=!!t&&n,C.viewer.brepInfo.BtotalArea=n,C.viewer.brepInfo.BfacePerimeter=!!(i&&1<C.version),C.viewer.dispatchBrepEvent(),_e.enableBroadcast&&C.viewer.broadcastManager.broadcastInfo&&C.viewer.broadcastManager.setBroadcastInfo(C.viewer.broadcastManager.broadcastInfo),!0===C.showWaitCursor&&C.filesToLoadCount<1&&C.viewer.exitWaitProcedure(),1==C.type?C.viewer.ndsModel.LeafbodyToFirstBodyMap.forEach(function(e,t){t=C.brepInfos[t],e=C.brepInfos[e];t&&e&&!t.referenceBodyUuid&&(e.area+=t.area,e.volume+=t.volume,e.edgeGroups=e.edgeGroups.concat(t.edgeGroups),e.faceGroups=e.faceGroups.concat(t.faceGroups))}):C.viewer.ndsModel.LeafbodyToFirstBodyMap.forEach(function(e,t){var n;C.brepInfos.bodies.has(t)&&C.brepInfos.bodies.has(e)&&(t=C.brepInfos.breps[C.brepInfos.bodies.get(t)],e=C.brepInfos.breps[C.brepInfos.bodies.get(e)],t)&&e&&(e.area+=t.area,e.volume+=t.volume,e.edgeGroups||(e.edgeGroups=new Int32Array(0)),e.faceGroups||(e.faceGroups=new Int32Array(0)),t.edgeGroups&&((n=new Int32Array(e.edgeGroups.length+t.edgeGroups.length)).set(e.edgeGroups),n.set(t.edgeGroups,e.edgeGroups.length),e.edgeGroups=n),t.faceGroups)&&((n=new Int32Array(e.faceGroups.length+t.faceGroups.length)).set(e.faceGroups),n.set(t.faceGroups,e.faceGroups.length),e.faceGroups=n)})},this.onError=function(e){C.filesToLoadCount--,C.filesToLoadCount<1&&C.viewer.exitWaitProcedure()},this.loadBreps=function(e,t){if(!(s.length<1)){for(var n=C.filesToLoadCount=0;n<s.length;n++)0==s[n]&&0==d[n]&&C.filesToLoadCount++;C.filesToLoadCount<1||(this.addRequest(),!0===e&&(C.showWaitCursor=!0,C.viewer.startWaitProcedure()))}},this.scaleBrepValue=function(e,t){if(e){var t=C.viewer.ndsModel.bodyUuid2NodeMap[t],t=C.viewer.getBodyNodeFileUnit(t),n=C.viewer.ndsModel.rootBodyNode.fileUnit;if(_e.ScenarioEditor&&(n=C.viewer.modelUnit),t&&n){var i=C.viewer.getUnitTransfrom(n,t);if(e.length&&(e.length*=i),e.radius&&(e.radius*=i),e.area&&(e.area*=i*i),e.volume&&(e.volume*=i*i*i),e.edgeIDS)for(var r=0;r<e.edgeIDS.length;r++)e.edgeIDS[r].perimeter*=i}}},this.GetBodyVolumeAndArea=function(e){var t,n,i;if(e&&1==R)return t=L.has(e)?L.get(e):e,i=null,i=2===C.type?(n=t,C.brepInfos.bodies.has(n)?{volume:(n=C.brepInfos.breps[C.brepInfos.bodies.get(n)]).volume,area:n.area}:null):function(e){e=C.brepInfos[e];return(e=e&&e.referenceBodyUuid?C.brepInfos[e.referenceBodyUuid]:e)&&null!=e.volume?{volume:parseFloat(e.volume),area:parseFloat(e.area)}:null}(t),this.scaleBrepValue(i,e),i},this.GetEdegMeshIDfromID=function(e,t){if(e&&1==R){e=L.has(e)?L.get(e):e;if(2===C.type)return l(e,t);var n=t;if(1===C.type){var i=C.brepInfos[e];i&&i.referenceBodyUuid&&(i=C.brepInfos[i.referenceBodyUuid]);for(var r=0;r<i.edgeGroups.length;++r)for(var o=i.edgeGroups[r],a=o.meshID,s=0;s<o.edges.length;++s)if(o.edges[s].id==n)return a}return null}},this.GetBrepInfoByUUidAndTopolIndex=function(e,t,n,i){if(!0===R){if(!i)return c(e,t,n)||p(e,t,n);i.toLowerCase();var r=null,r=("edge"===i?p:c)(e,t,n);return this.scaleBrepValue(r,e),r}},function(e,t,n){function i(e,t,n,i){e.id=n.ids[t],e.geomUUID=i.geomUUID,e.indexRange=[n.triIndexRanges[2*t],n.triIndexRanges[2*t+1]],e.area=n.areas[t];var r=n.loops[2*t],o=n.loops[2*t+1];e.edgeIDS=[];for(var a=0;a<o;++a)e.edgeIDS[a]={perimeter:i.loopPerimeters[r+a],startID:i.loopStartEdgeId[r+a]}}var r;return"plane"===t?i(r={type:"plane",origin:[e.planes.origins[3*n],e.planes.origins[3*n+1],e.planes.origins[3*n+2]],normal:[e.planes.normals[3*n],e.planes.normals[3*n+1],e.planes.normals[3*n+2]]},n,e.planes,e):"cylinder"===t?i(r={type:"cylinder",origin:[e.cylinders.origins[3*n],e.cylinders.origins[3*n+1],e.cylinders.origins[3*n+2]],axis:[e.cylinders.axis[3*n],e.cylinders.axis[3*n+1],e.cylinders.axis[3*n+2]],radius:e.cylinders.radiuses[n]},n,e.cylinders,e):"cone"===t?i(r={type:"cone",origin:[e.cones.origins[3*n],e.cones.origins[3*n+1],e.cones.origins[3*n+2]],axis:[e.cones.axis[3*n],e.cones.axis[3*n+1],e.cones.axis[3*n+2]],radius:e.cones.radiuses[n]},n,e.cones,e):"sphere"===t?i(r={type:"sphere"},n,e.spheres,e):"torus"===t?i(r={type:"torus"},n,e.toruses,e):"nurbs"===t?i(r={type:"nurbs"},n,e.nurbses,e):"other"===t&&i(r={type:"other"},n,e.others,e),r}),b=function(e,t,n){var i;return"line"===t?i={id:e.lines.ids[n],geomUUID:e.geomUUID,indexRange:[e.lines.indexRanges[2*n],e.lines.indexRanges[2*n+1]],length:e.lines.lengthes[n],type:"line"}:"circle"===t?i={id:e.circles.ids[n],geomUUID:e.geomUUID,indexRange:[e.circles.indexRanges[2*n],e.circles.indexRanges[2*n+1]],length:e.circles.lengthes[n],center:[e.circles.centers[3*n],e.circles.centers[3*n+1],e.circles.centers[3*n+2]],radius:e.circles.radiuses[n],type:"circle"}:"ellipse"===t?i={id:e.ellipses.ids[n],geomUUID:e.geomUUID,indexRange:[e.ellipses.indexRanges[2*n],e.ellipses.indexRanges[2*n+1]],length:e.ellipses.lengthes[n],type:"ellipse"}:"nurbs"===t?i={id:e.nurbses.ids[n],geomUUID:e.geomUUID,indexRange:[e.nurbses.indexRanges[2*n],e.nurbses.indexRanges[2*n+1]],length:e.nurbses.lengthes[n],type:"nurbs"}:"other"===t&&(i={id:e.others.ids[n],geomUUID:e.geomUUID,indexRange:[e.others.indexRanges[2*n],e.others.indexRanges[2*n+1]],length:e.others.lengthes[n],type:"other"}),i},i=(this.GetBrepInfoByBodyUuidAndTopoId=function(e,t,n){var i,r;if(e&&1==R)return i=L.has(e)?L.get(e):e,r=null,r=(2===C.type?o:function(e,t,n){if(!0!==R)return null;var i=C.brepInfos[e];if(!i)return null;if(i.referenceBodyUuid&&(i=C.brepInfos[i.referenceBodyUuid]),n.toLowerCase(),"face"===n){for(var r=0,o=i.faceGroups.length;r<o;r++){for(var a=i.faceGroups[r],s=a.faces,l=!1,d=null,c=0,h=s.length;c<h;c++)if(s[c].id==t){l=!0,d=Object.assign({},s[c]);break}if(l){var u=a.meshID;if(C.viewer.ndsModel){var p=C.viewer.ndsModel.meshUuid2GeomUuidMap[u];if(A=C.viewer.ndsModel.getBodyNodeFromUuid(e)){a=C.viewer.ndsModel.meshManager.getBodyMeshIdFromGeomUUid(A,p);if(-1<a)if(v=C.viewer.ndsModel.meshManager.getSingleMesh(a))return d.parentObj=v,d.bodyId=e,d.meshId=p,d}}else if(v=C.viewer.getObjectByUUID(u))return d.parentObj=v,d.bodyId=e,d.meshId=u,d}}return null}if("edge"===n){for(r=0,o=i.edgeGroups.length;r<o;r++){for(var f=i.edgeGroups[r],m=f.edges,l=!1,g=null,c=0,h=m.length;c<h;c++)if(m[c].id==t){l=!0,g=Object.assign({},m[c]);break}if(l){u=f.meshID;if(C.viewer.ndsModel){var v,p=C.viewer.ndsModel.meshUuid2GeomUuidMap[u],A=C.viewer.ndsModel.getBodyNodeFromUuid(e);if(A)if(v=C.viewer.ndsModel.meshManager.getBodyLineSegmentsFromGeomUUid(A,p))return g.parentObj=v,g.bodyId=e,g.meshId=p,g}else if(v=C.viewer.getObjectByUUID(u))return g.parentObj=v,g.bodyId=e,g.meshId=u,g}}return null}if("vertex"===n){for(var y,E,r=0,o=i.vertices.length;r<o;r++)if(t===i.vertices[r].id)return y=null,y=(C.viewer.ndsModel?(A=C.viewer.ndsModel.getBodyNodeFromUuid(e),C.viewer.ndsModel.meshManager.getMeshInfor(A.id,E={}),E):C.viewer.getObjectByUUID(e)).matrixWorld,(E=new THREE.Vector3(i.vertices[r].coords[0],i.vertices[r].coords[1],i.vertices[r].coords[2])).applyMatrix4(y),{id:i.vertices[r].id,coords:[E.x,E.y,E.z],bodyId:e};return null}})(i,t,n),this.scaleBrepValue(r,e),r},this.hasBrepInfo=function(){return R},this.hasBrepFile=function(){return 0<a.length},this.parse=function(e){e&&e.length},this.GetEdgesExtremePointsByBodyUUID=function(e){if(e&&1==R){var t=L.has(e)?L.get(e):e;if(2===C.type){var n=t,i=e;if(!n||1!=R)return null;if(O[i])return O[i];if(!C.brepInfos.bodies.has(n))return null;var r=C.brepInfos.breps[C.brepInfos.bodies.get(n)];if(!r.edgeGroups)return null;for(var g=[],o=function(e,t,n,i){void 0===i&&(i={});var r=[];Array.isArray(t)?r=t:r[0]=t;for(var o=0,a=r.length;o<a;++o){var s=r[o],l=s.geometry;if(!l||!l.isBufferGeometry||!l.index)return;for(var d=l.attributes.position.array,c=0,h=e.length/2;c<h;c++){var u=[e[2*c],e[2*c+1]],p=(C.viewer.ndsModel&&(u[0]+=l.drawRange.start/2,u[1]+=l.drawRange.start/2),l.index.array),f=new THREE.Vector3,m=new THREE.Vector3;f.fromArray(d,3*p[2*u[0]]),m.fromArray(d,3*p[2*u[1]+1]),f.applyMatrix4(s.matrixWorld),m.applyMatrix4(s.matrixWorld),"circle"===n&&g.push(new THREE.Vector3(i.centers[3*c+0],i.centers[3*c+1],i.centers[3*c+2]).applyMatrix4(s.matrixWorld)),g.push(f),g.push(m)}}},a=0,s=r.edgeGroups.length;a<s;a++){var l=C.brepInfos.edgeGroups[r.edgeGroups[a]];if(C.viewer.ndsModel){var d=C.viewer.ndsModel.getBodyNodeFromUuid(i);if(!d)continue;d=C.viewer.ndsModel.meshManager.getBodyLineSegmentsFromGeomUUid(d,l.geomUUID)}d&&(l.lines&&o(l.lines.indexRanges,d,"line"),l.circles&&o(l.circles.indexRanges,d,"circle",{centers:l.circles.centers}),l.ellipses&&o(l.ellipses.indexRanges,d,"ellipse"),l.nurbses&&o(l.nurbses.indexRanges,d,"nurbs"),l.others)&&o(l.others.indexRanges,d,"other")}return O[i]=g}var c=t;if(c&&1==R){if(O[c])return O[c];var h=C.brepInfos[c];if((h=h&&(h.referenceBodyUuid?C.brepInfos[h.referenceBodyUuid]:h))&&h.edgeGroups){for(var u=[],p=0,f=h.edgeGroups.length;p<f;p++){var m=h.edgeGroups[p];if(m){var v=m.edges;if(v){var A,y,m=m.meshID;if(C.viewer.ndsModel){var m=C.viewer.ndsModel.meshUuid2GeomUuidMap[m],E=C.viewer.ndsModel.getBodyNodeFromUuid(c);if(!E)continue;A=C.viewer.ndsModel.meshManager.getBodyLineSegmentsFromGeomUUid(E,m)}else A=C.viewer.selectionManager.getLineObjectFromUUid(m);if(A&&(y=A.geometry)&&y.isBufferGeometry){var M=y.index;if(null!=M)for(var w=y.attributes.position.array,b=0,x=v.length;b<x;b++){var I=v[b],T=I.indexRange.concat(),S=(C.viewer.ndsModel&&(T[0]+=y.drawRange.start/2,T[1]+=y.drawRange.start/2),M.array),B=new THREE.Vector3,P=new THREE.Vector3;B.fromArray(w,3*S[2*T[0]]),P.fromArray(w,3*S[2*T[1]+1]),B.applyMatrix4(A.matrixWorld),P.applyMatrix4(A.matrixWorld),"circle"==I.type&&u.push(new THREE.Vector3(I.center[0],I.center[1],I.center[2]).applyMatrix4(A.matrixWorld)),u.push(B),u.push(P)}}}}}return O[c]=u}}}},this.GetVerticesByBodyUUID=function(e){if(e&&1==R)return e=L.has(e)?L.get(e):e,2!==C.type&&(e=e,e=(e=C.brepInfos[e])&&(e.referenceBodyUuid?C.brepInfos[e.referenceBodyUuid]:e))&&e.vertices?e.vertices:null},this.GetEdgeInfoFromFace=function(e,t){if(e&&1==R){e=L.has(e)?L.get(e):e;if(2===C.type){var n=e,i=t;if(n&&i&&C.brepInfos.bodies.has(n)){var r=C.brepInfos.breps[C.brepInfos.bodies.get(n)];if(r.faceGroups&&r.edgeGroups){var o="Array"===i.constructor.name?i.slice():[i],a=[];if(C.viewer.ndsModel.getBodyNodeFromUuid(n)){for(var s=function(e,t,n){for(var i=0,r=e.ids.length;i<r&&(-1===o.indexOf(e.ids[i])||(a.push(b(n,t,i)),o.splice(o.indexOf(e.ids[i]),1),0!=o.length));++i);},l=0,d=r.edgeGroups.length;l<d;l++){var c=C.brepInfos.edgeGroups[r.edgeGroups[l]],h=c.geomUUID;if(c.lines&&s(c.lines,"line",c),c.circles&&s(c.circles,"circle",c),c.ellipses&&s(c.ellipses,"ellipse",c),c.nurbses&&s(c.nurbses,"nurbs",c),c.others&&s(c.others,"other",c),0==o.length)break}return{array:a,meshID:-1,geomUUID:h}}}}}else{i=e,n=t;if(i&&n){var u=C.brepInfos[i];if((u=u&&(u.referenceBodyUuid?C.brepInfos[u.referenceBodyUuid]:u))&&u.faceGroups){for(var p="Array"===n.constructor.name?n.slice():[n],f=[],m=0,g=u.edgeGroups.length;m<g;m++){var v=u.edgeGroups[m],A=v.edges,y=v.meshID;if(A){for(var E=0,M=A.length;E<M;E++){var w=A[E];if(-1!=p.indexOf(w.id)&&(f.push(w),p.splice(p.indexOf(w.id),1),0==p.length))break}if(0==p.length)break}}return{array:f,meshID:y}}}}}},function(e,t,n){if(e&&t&&!(n<0)){var i=C.brepInfos[e];if((i=i&&(i.referenceBodyUuid?C.brepInfos[i.referenceBodyUuid]:i))&&i.faceGroups)for(var r=0,o=i.faceGroups.length;r<o;r++){var a=i.faceGroups[r],s=a.meshID;if(t===(s=C.viewer.ndsModel?C.viewer.ndsModel.meshUuid2GeomUuidMap[s]:s)){var l=a.faces;if(l)for(var d=0,c=l.length;d<c;d++){var h=l[d],u=h.indexRange[0],p=h.indexRange[1];if(u<=n&&n<=p)return Object.assign({},h)}}}}}),r=function(e,t,o){if(e&&t&&!(o<0)&&C.viewer.ndsModel&&C.brepInfos.bodies.has(e)){var n=C.brepInfos.breps[C.brepInfos.bodies.get(e)];if(n.faceGroups){for(var i=function(e){for(var t=0,n=e.length/2;t<n;++t){var i=e[2*t],r=e[2*t+1];if(i<=o&&o<=r)return t}return-1},r=0,a=n.faceGroups.length;r<a;r++){var s=C.brepInfos.faceGroups[n.faceGroups[r]],l=s.geomUUID;if(t===l){var d,c,h,u,l=!1,p=void 0;if(s.planes&&-1<(d=i(s.planes.triIndexRanges))&&(l=!0,p=w(s,"plane",d)),!l&&s.cylinders&&-1<(d=i(s.cylinders.triIndexRanges))&&(l=!0,p=w(s,"cylinder",d)),!l&&s.cones&&-1<(c=i(s.cones.triIndexRanges))&&(l=!0,p=w(s,"cone",c)),!l&&s.spheres&&-1<(c=i(s.spheres.triIndexRanges))&&(l=!0,p=w(s,"sphere",c)),!l&&s.toruses&&-1<(h=i(s.toruses.triIndexRanges))&&(l=!0,p=w(s,"torus",h)),!l&&s.nurbses&&-1<(h=i(s.nurbses.triIndexRanges))&&(l=!0,p=w(s,"nurbs",h)),!l&&s.others&&-1<(u=i(s.others.triIndexRanges))&&(l=!0,p=w(s,"other",u)),l)return p}}return null}}};function c(e,t,n){if(e&&1==R)return e=L.has(e)?L.get(e):e,(2===C.type?r:i)(e,t,n)}var h=function(e,t,n){if(e&&t&&!(n<0)){var i=C.brepInfos[e];if((i=i&&(i.referenceBodyUuid?C.brepInfos[i.referenceBodyUuid]:i))&&i.edgeGroups)for(var r=0,o=i.edgeGroups.length;r<o;r++){var a=i.edgeGroups[r],s=a.meshID;if(t===(s=C.viewer.ndsModel?C.viewer.ndsModel.meshUuid2GeomUuidMap[s]:s)){var l=a.edges;if(l)for(var d=0,c=l.length;d<c;d++){var h=l[d],u=h.indexRange[0],p=h.indexRange[1];if(u<=n&&n<=p)return Object.assign({},h)}}}}},u=function(e,t,o){if(e&&t&&!(o<0)&&C.viewer.ndsModel&&C.brepInfos.bodies.has(e)){var n=C.brepInfos.breps[C.brepInfos.bodies.get(e)];if(n.edgeGroups){for(var i=function(e){for(var t=0,n=e.length/2;t<n;++t){var i=e[2*t],r=e[2*t+1];if(i<=o&&o<=r)return t}return-1},r=0,a=n.edgeGroups.length;r<a;r++){var s=C.brepInfos.edgeGroups[n.edgeGroups[r]],l=s.geomUUID;if(t===l){var d,c,h,l=!1,u=void 0;if(s.lines&&-1<(d=i(s.lines.indexRanges))&&(l=!0,u=b(s,"line",d)),!l&&s.circles&&-1<(d=i(s.circles.indexRanges))&&(l=!0,u=b(s,"circle",d)),!l&&s.ellipses&&-1<(c=i(s.ellipses.indexRanges))&&(l=!0,u=b(s,"ellipse",c)),!l&&s.nurbses&&-1<(c=i(s.nurbses.indexRanges))&&(l=!0,u=b(s,"nurbs",c)),!l&&s.others&&-1<(h=i(s.others.indexRanges))&&(l=!0,u=b(s,"other",h)),l)return u}}return null}}};function p(e,t,n){if(e&&1==R)return e=L.has(e)?L.get(e):e,(2===C.type?u:h)(e,t,n)}}),St=function(e){var c=this,s=(this.viewer=e,{}),n=[],i=null,d=new THREE.TextureLoader(new THREE.LoadingManager),h=(d.crossOrigin="anonymous",new At),u=(h.crossOrigin="anonymous",null),o=!1,r=0;function a(e){var t,n=[];for(t in c.viewer.ndsModel.bodyNodeUUidToMaterial)if(e.uuid==c.viewer.ndsModel.bodyNodeUUidToMaterial[t].uuid){for(var i=c.viewer.ndsModel.getBodyNodeFromUuid(t),r=c.viewer.ndsModel.getLeafBodies(i),o=0;o<r.length;o++){var a=r[o].leafBodyAttri.bodyMeshIds;if(0<a.length)for(var s=0,l=a.length;s<l;++s){var d=c.viewer.ndsModel.meshManager.geomId[a[s]];-1<d&&n.push(c.viewer.ndsModel.geomManager.getGeomFromId(d))}}break}return n}function T(e){var e=e.boundingBox,t=e.min.x,n=e.min.y,i=e.min.z,r=e.max.x,o=e.max.y,e=e.max.z,a=[],r=(a.push(r-t),a.push(o-n),a.push(e-i),a.sort(function(e,t){return e-t}),a[1]);return 6/(r=r<1?1:r)}function l(e){if(null==e.getAttribute("position"))console.log("生成纹理坐标失败,无顶点数据,有可能geometry未加载完!!!");else if(void 0===e.getAttribute("uv"))if(null==e.getAttribute("normal"))console.log("生成纹理坐标失败无法线!!!");else{var o=e,a=1;if(o instanceof THREE.Geometry)o.faceVertexUvs[0]=[],a=T(o),o.faces.forEach(function(n){var e=["x","y","z"].sort(function(e,t){return Math.abs(n.normal[e])-Math.abs(n.normal[t])}),t=o.vertices[n.a],i=o.vertices[n.b],r=o.vertices[n.c];o.faceVertexUvs[0].push([new THREE.Vector2(t[e[0]]*a,t[e[1]]*a),new THREE.Vector2(i[e[0]]*a,i[e[1]]*a),new THREE.Vector2(r[e[0]]*a,r[e[1]]*a)])});else if(a=T(o),o.getAttribute("position")){var t=o.getAttribute("normal"),n=o.getAttribute("position"),i=o.index,r=0;if(i)if(r=3*i.count,d=new Float32Array(8*i.count),n instanceof THREE.InterleavedBufferAttribute)for(var s=0;s<i.count;s++)d[8*s]=n.array[i.array[s]*n.data.stride+n.offset],d[8*s+1]=n.array[i.array[s]*n.data.stride+n.offset+1],d[8*s+2]=n.array[i.array[s]*n.data.stride+n.offset+2],d[8*s+3]=t.array[i.array[s]*t.data.stride+t.offset],d[8*s+4]=t.array[i.array[s]*t.data.stride+t.offset+1],d[8*s+5]=t.array[i.array[s]*t.data.stride+t.offset+2];else for(var l=0;l<i.count;l++)d[8*l]=n.array[3*i.array[l]],d[8*l+1]=n.array[3*i.array[l]+1],d[8*l+2]=n.array[3*i.array[l]+2],d[8*l+3]=t.array[3*i.array[l]],d[8*l+4]=t.array[3*i.array[l]+1],d[8*l+5]=t.array[3*i.array[l]+2];else for(var r=n.count,d=new Float32Array(8*r),c=0;c<r/3;c++)d[8*c]=n.array[3*c],d[8*c+1]=n.array[3*c+1],d[8*c+2]=n.array[3*c+2],d[8*c+3]=t.array[3*c],d[8*c+4]=t.array[3*c+1],d[8*c+5]=t.array[3*c+2];for(var h=r/9,u=[],p=0;p<h;p++){var f=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,v=(f.x=d[8*p*3],f.y=d[8*p*3+1],f.z=d[8*p*3+2],m.x=d[8*p*3+8],m.y=d[8*p*3+9],m.z=d[8*p*3+10],g.x=d[8*p*3+16],g.y=d[8*p*3+17],g.z=d[8*p*3+18],new THREE.Vector3),A=new THREE.Vector3,m=(v.subVectors(m,f),A.subVectors(g,f),new THREE.Vector3);m.crossVectors(v,A),u.push(m)}for(var y=new Uint32Array(r/3),E=0;E<r/3;E++){new THREE.Vector3;var M=u[parseInt(E/3)].clone(),w=["x","y","z"].sort(function(e,t){return Math.abs(M[e])-Math.abs(M[t])}),b=new THREE.Vector3;b.x=d[8*E],b.y=d[8*E+1],b.z=d[8*E+2],d[8*E+6]=b[w[0]]*a,d[8*E+7]=b[w[1]]*a,y[E]=E}var e=new THREE.InterleavedBuffer(d,8),x=new THREE.InterleavedBufferAttribute(e,3,0,!1),I=new THREE.InterleavedBufferAttribute(e,3,3,!1),e=new THREE.InterleavedBufferAttribute(e,2,6,!1);o.addAttribute("position",x),o.addAttribute("normal",I),o.addAttribute("uv",e),o.setIndex(new THREE.BufferAttribute(y,1))}}}function p(e,t,n){var i,r,o,a,s,l;-1<(n=_e.avoidCaching?n+"?time="+Date.now():n).toLowerCase().indexOf(".tga")?(a=e,s=t,l=n,ve.TextureLoadingManager.itemStart(),h.load(l,function(e){e.flipY=!0,a[s]=e,a[s].sourceFile=l,a[s].wrapS=THREE.RepeatWrapping,a[s].wrapT=THREE.RepeatWrapping,e.needsUpdate=!0,ve.TextureLoadingManager.itemEnd(),c.viewer.render()},void 0,function(){a[s]=null,a.needsUpdate=!0,c.viewer.render()})):(i=e,r=t,o=n,d.load(o,function(e){i[r]=e,i[r].sourceFile=o,i[r].wrapS=THREE.RepeatWrapping,i[r].wrapT=THREE.RepeatWrapping,i.needsUpdate=!0,"bumpMap"===r?(i.normalMap=null,u.normalMap=null):"normalMap"===r&&(i.bumpMap=null,u.bumpMap=null),c.viewer.render()},void 0,function(){i.needsUpdate=!0,i[r]=null,c.viewer.render()}))}function f(e,t,n){if(e&&void 0!==n)if(null===n||""===n){if(o)for(var i=a(e),r=0;r<i.length;r++)l(i[r]);e.needsUpdate=!0,e[t]=null}else{for(i=a(e),r=0;r<i.length;r++)l(i[r]);e[t]&&e[t].sourceFile===n&&!o||(e.needsUpdate=!0,p(e,t,n))}}function m(e){return null!=e&&""!==e?!0:!1}function g(e,t){m(t.color)&&e.color.set(t.color),m(t.linewidth)&&(e.linewidth=parseInt(t.linewidth)),m(t.opacity)&&(e.opacity=parseFloat(t.opacity),e.opacity<1?e.transparent=!0:e.transparent=!1)}function v(e,t,n){m(t.color)&&e.color.set(t.color),m(t.specular)&&e.specular.set(t.specular),m(t.emissive)&&e.emissive.set(t.emissive),m(t.skinning)&&(e.skinning=t.skinning),m(t.shininess)&&(e.shininess=parseInt(t.shininess),0==e.shininess?(e.initialSpecular=new THREE.Color,e.initialSpecular.copy(e.specular),e.specular.setRGB(0,0,0)):e.initialSpecular=void 0),m(t.opacity)&&(e.opacity=parseFloat(t.opacity),e.opacity<1?e.transparent=!0:e.transparent=!1),m(t.emissiveIntensity)&&(e.emissiveIntensity=parseFloat(t.emissiveIntensity)),m(t.reflectivity)&&(e.reflectivity=parseFloat(t.reflectivity)),m(t.refractionRatio)&&(e.refractionRatio=parseFloat(t.refractionRatio)),m(t.shading)&&(0==t.shading||2==parseInt(t.shading)?e.flatShading=!1:e.flatShading=!0),m(t.wireframe)&&(e.wireframe=t.wireframe),m(t.doubleSided)&&(t.doubleSided?e.side=THREE.DoubleSide:e.side=THREE.FrontSide),2==n?e.wireframe=!0:(e.wireframe=!1,1==n&&e.specular.setRGB(0,0,0)),m(t.bumpScale)&&(e.bumpScale=t.bumpScale),m(t.normalScale)&&(e.normalScale=new THREE.Vector2(t.normalScale,t.normalScale)),f(e,"map",t.map),f(e,"bumpMap",t.bumpMap),f(e,"normalMap",t.normalMap),f(e,"emissiveMap",t.emissiveMap),f(e,"alphaMap",t.alphaMap),f(e,"specularMap",t.specularMap)}function A(e,t,n){m(t.color)&&e.color.set(t.color),m(t.skinning)&&(e.skinning=t.skinning),m(t.emissive)&&e.emissive.set(t.emissive),m(t.metalness)&&(e.metalness=parseFloat(t.metalness)),m(t.roughness)&&(e.roughness=parseFloat(t.roughness)),m(t.opacity)&&(e.opacity=parseFloat(t.opacity),e.opacity<1?e.transparent=!0:e.transparent=!1),m(t.emissiveIntensity)&&(e.emissiveIntensity=parseFloat(t.emissiveIntensity)),m(t.envMapIntensity)&&(e.envMapIntensity=parseFloat(t.envMapIntensity)),m(t.refractionRatio)&&(e.refractionRatio=parseFloat(t.refractionRatio)),m(t.shading)&&(0==t.shading||2==parseInt(t.shading)?e.flatShading=!1:e.flatShading=!0),m(t.wireframe)&&(e.wireframe=t.wireframe),m(t.doubleSided)&&(t.doubleSided?e.side=THREE.DoubleSide:e.side=THREE.FrontSide),e.wireframe=2==n,m(t.bumpScale)&&(e.bumpScale=t.bumpScale),m(t.normalScale)&&(e.normalScale=new THREE.Vector2(t.normalScale,t.normalScale)),f(e,"map",t.map),f(e,"bumpMap",t.bumpMap),f(e,"normalMap",t.normalMap),f(e,"emissiveMap",t.emissiveMap),f(e,"alphaMap",t.alphaMap),f(e,"metalnessMap",t.metalnessMap),f(e,"roughnessMap",t.roughnessMap)}function y(e){var t,n=["map","bumpMap","normalMap","emissiveMap","alphaMap","specularMap","metalnessMap","roughnessMap"];for(t in n){var i,r=e[n[t]];!r||(i=!1,i=0<=r.indexOf("/")||i)||(i=function(e){var t=e;if(c.viewer.trueMapList)for(var n in c.viewer.trueMapList)if(e.toLowerCase()===c.viewer.trueMapList[n].toLowerCase()){t=c.viewer.trueMapList[n];break}return t}(r),e[n[t]]=(1===(r=(r=c.viewer.modelInfo[c.viewer.modelInfo.length-1].url).split("/")).length?"./":(r.pop(),r.join("/")+"/"))+i)}}function E(e,t,n,i){e[t]&&e[t].sourceFile===n&&((n={uuid:e.uuid})[t]=null,c.updateMaterialInfo(n,i),c.viewer.render())}function M(e,t,n){e[t]&&e[t]===n&&(e[t]=null)}function w(e,t,n){t[n]&&!function(e,t){for(var n=!1,i=0;i<e.length;i++)if(e[i]===t){n=!0;break}return n}(e,t=t[n].sourceFile)&&e.push(t)}this.setForceUpdateTex=function(e){o=e},this.getMaterialsMarkersMat=function(){return i},this.setMaterialsMarkersMat=function(e){i=e},this.setMaterialsMarkers=function(e){n=e},this.cleanMaterialsMarkers=function(){for(var e=0;e<n.length;e++){var t=n[e];t.parent.remove(t.marker)}n=[],i=null},this.forceUpdateAllMats=function(){c.setForceUpdateTex(!0);var e=c.getMaterialsInfo();c.updateAllMateriaslInfo(e,c.viewer.getRenderMode()),c.setForceUpdateTex(!1)},this.updateAllMateriaslInfo=function(e,t,n){if(e){var i,r,o=function(e){var t=null;if(e&&e.materials)for(var n in e.materials){n=e.materials[n];if("MeshPhongMaterial"===n.type){t=n.type;break}if("MeshStandardMaterial"===n.type){t=n.type;break}}return t}(e);for(r in o!==function(){var e,t=null;for(e in s){var n=s[e];if(n instanceof THREE.MeshPhongMaterial){t="MeshPhongMaterial";break}if(n instanceof THREE.MeshStandardMaterial){t="MeshStandardMaterial";break}}return t}()&&(i=c.getMaterialsInfo(),c.viewer.convertAllMaterialsInfo(i,o)),e.materials)c.updateMaterialInfo(e.materials[r],t,n)}c.removeAllObjectMaterials()},this.removeAllObjectMaterials=function(){this.viewer.ndsModel.removeAllBodyNodeMaterials()},this.removeObjectMaterial=function(e){this.viewer.ndsModel.removeBodyNodeMaterial(e)},this.getObjectMaterialInfo=function(e){var t,n;return this.viewer.ndsModel.bodyNodeUUidToMaterial[e]?(t=this.viewer.ndsModel.bodyNodeUUidToMaterial[e],s[t.uuid]=t):(e=this.viewer.ndsModel.getBodyNodeFromUuid(e),n=this.viewer.ndsModel.getLeafBodies(e)[0].leafBodyAttri.bodyMeshIds[0],n=this.viewer.ndsModel.meshManager.materialId[n],n=this.viewer.ndsModel.meshManager.materialUuids[n],(n=s[n])instanceof THREE.MeshPhongMaterial?t=new THREE.MeshPhongMaterial:n instanceof THREE.MeshStandardMaterial&&(t=new THREE.MeshStandardMaterial),t.uuid=t.uuid.replaceAll("-",""),t.uuid=t.uuid.toLowerCase(),t.copy(n),s[t.uuid]=t,this.viewer.ndsModel.setBodyNodeMaterial(e.uuid,t)),this.materialToJson(t)},this.getBodyNodeMaterialsInfo=function(){var e,t=this.viewer.ndsModel.getBodyNodeUUidToMaterial(),n={};for(e in t)n[e]=this.materialToJson(t[e]);return n},this.autoCreateMaterial=function(e){var t;return"MeshPhongMaterial"==e?t=new THREE.MeshPhongMaterial:"MeshStandardMaterial"==e&&(t=new THREE.MeshStandardMaterial),t.uuid=t.uuid.replaceAll("-",""),t.uuid=t.uuid.toLowerCase(),t},this.randColor=function(){var e=[Math.floor(240*Math.random()+15),Math.floor(240*Math.random()+15),Math.floor(240*Math.random()+15)];return 65536*e[0]+256*e[1]+e[2]},this.autoSetBodyNodeMaterial=function(e){for(var e=this.viewer.ndsModel.getBodyNodeFromUuid(e),t=this.viewer.ndsModel.getLeafBodies(e),n=0;n<t.length;n++){var i=void 0;(i=t[n].useBodyNodeMaterial?this.viewer.ndsModel.bodyNodeUUidToMaterial[t[n].uuid]:this.autoCreateMaterial("MeshStandardMaterial")).color.set(this.randColor()),i.needsUpdate=!0,s[i.uuid]=i,this.viewer.ndsModel.setBodyNodeMaterial(t[n].uuid,i)}this.viewer.render()},this.updateMaterialInfo=function(e,t,n){if(y(e),u=e,n){var i,r=e,o=["map","bumpMap","normalMap","emissiveMap","alphaMap","specularMap","metalnessMap","roughnessMap"];for(i in o)void 0===r[o[i]]&&(r[o[i]]=null)}e&&e.uuid&&(n=s[e.uuid])&&(n instanceof THREE.LineBasicMaterial?g(n,e):n instanceof THREE.MeshPhongMaterial?v(n,e,t):n instanceof THREE.MeshStandardMaterial&&A(n,e,t),n.needsUpdate=!0),c.viewer.render()},this.initMaterialsInfo=function(e){for(var t in e){var n=e[t];0<n.refCount&&(n.mat.wireframe=!1,s[t]=n.mat)}},this.removeMap=function(e,t,n){if(null==e||""===e)return!1;for(var i in e=e.replace(/ /g,"%20"),s){i=s[i];i.needsUpdate=!0,E(i,"map",e,n),E(i,"bumpMap",e,n),E(i,"normalMap",e,n),E(i,"emissiveMap",e,n),E(i,"alphaMap",e,n),E(i,"specularMap",e,n),E(i,"roughnessMap",e,n),E(i,"metalnessMap",e,n)}if(t){var r,o=e,a=t;for(r in a.materials){r=a.materials[r];M(r,"map",o),M(r,"bumpMap",o),M(r,"normalMap",o),M(r,"emissiveMap",o),M(r,"alphaMap",o),M(r,"specularMap",o),M(r,"roughnessMap",o),M(r,"metalnessMap",o),M(r,"specularMapOld",o),M(r,"roughnessMapOld",o),M(r,"metalnessMapOld",o)}}return!0},this.isMapWorking=function(e){for(var t=!1,n=(e=e.replace(/ /g,"%20"),c.getMapList()),i=0;i<n.length;i++)if(e===n[i]){t=!0;break}return t},this.getMapList=function(){var e,t=[];for(e in s){var n=s[e];w(t,n,"map"),w(t,n,"bumpMap"),w(t,n,"normalMap"),w(t,n,"emissiveMap"),w(t,n,"alphaMap"),w(t,n,"specularMap"),w(t,n,"roughnessMap"),w(t,n,"metalnessMap")}return t},this.getMaterialIndex=function(e){var t,n=[],i=-1;for(t in s)n.push(s[t]);for(var r=0,o=n.length;r<o;r++)if(n[r].uuid===e.uuid){i=r;break}return i},this.getMaterialsInfo=function(){var e,t={materials:[]};for(e in r=0,s){var n=this.materialToJson(s[e]);t.materials.push(n)}return t},this.materialToJson=function(e){var t,n,i={};return e instanceof THREE.LineBasicMaterial?i={version:"1.00",name:(n=e).name,type:n.type,uuid:n.uuid,color:n.color.getHex(),linewidth:n.linewidth,opacity:n.opacity}:e instanceof THREE.MeshPhongMaterial?(t={version:"1.00",name:(n=e).name,type:n.type,uuid:n.uuid,doubleSided:n.side===THREE.DoubleSide,shininess:n.shininess,reflectivity:n.reflectivity,refractionRatio:n.refractionRatio,opacity:n.opacity,color:n.color.getHex(),specular:n.specular.getHex(),emissive:n.emissive.getHex(),emissiveIntensity:n.emissiveIntensity,shading:n.flatShading,wireframe:n.wireframe,skinning:n.skinning},n.map?t.map=n.map.sourceFile:t.map=null,n.bumpMap?(t.bumpMap=n.bumpMap.sourceFile,t.bumpScale=n.bumpScale):(t.bumpScale=n.bumpScale,t.bumpMap=null),n.normalMap?t.normalMap=n.normalMap.sourceFile:t.normalMap=null,t.normalScale=n.normalScale.x,n.emissiveMap?t.emissiveMap=n.emissiveMap.sourceFile:t.emissiveMap=null,n.alphaMap?t.alphaMap=n.alphaMap.sourceFile:t.alphaMap=null,n.specularMap?t.specularMap=n.specularMap.sourceFile:t.specularMap=null,i=t):e instanceof THREE.MeshStandardMaterial&&(e={version:"1.00",name:(t=e).name,type:t.type,uuid:t.uuid,doubleSided:t.side===THREE.DoubleSide,envMapIntensity:t.envMapIntensity,refractionRatio:t.refractionRatio,opacity:t.opacity,color:t.color.getHex(),emissive:t.emissive.getHex(),emissiveIntensity:t.emissiveIntensity,shading:t.flatShading,roughness:t.roughness,metalness:t.metalness,wireframe:t.wireframe,skinning:t.skinning},t.map?e.map=t.map.sourceFile:e.map=null,t.bumpMap?e.bumpMap=t.bumpMap.sourceFile:e.bumpMap=null,e.bumpScale=t.bumpScale,t.normalMap?e.normalMap=t.normalMap.sourceFile:e.normalMap=null,e.normalScale=t.normalScale.x,t.emissiveMap?e.emissiveMap=t.emissiveMap.sourceFile:e.emissiveMap=null,t.alphaMap?e.alphaMap=t.alphaMap.sourceFile:e.alphaMap=null,t.metalnessMap?e.metalnessMap=t.metalnessMap.sourceFile:e.metalnessMap=null,t.roughnessMap?e.roughnessMap=t.roughnessMap.sourceFile:e.roughnessMap=null,i=e),""===i.name&&(i.name="Material_"+r.toString(),++r),i},this.jsonToMaterial=function(e){var t;return"LineBasicMaterial"==e.type?g(t=new THREE.LineBasicMaterial,e):"MeshPhongMaterial"==e.type?v(t=new THREE.MeshPhongMaterial,e):"MeshStandardMaterial"==e.type&&A(t=new THREE.MeshStandardMaterial,e),t.uuid=e.uuid,t},this.convertMaterialInfo=function(e,t,n){var i,r,o={matJson:null,matObj:null};return null!=e&&null!=t&&e.type!=t&&"LineBasicMaterial"!=e.type&&(i=s[e.uuid],r={},"MeshPhongMaterial"==t?(o.matObj=new THREE.MeshPhongMaterial,r={version:"1.00",name:e.name,type:"MeshPhongMaterial",uuid:e.uuid,doubleSided:e.doubleSided,reflectivity:e.envMapIntensity,refractionRatio:e.refractionRatio,opacity:e.opacity,color:e.color,skinning:e.skinning,emissive:e.emissive,emissiveIntensity:e.emissiveIntensity,shading:e.shading,wireframe:e.wireframe,roughnessOld:e.roughness,metalnessOld:e.metalness,metalnessMapOld:e.metalnessMap,roughnessMapOld:e.roughnessMap},null!=e.specularOld?r.specular=e.specularOld:r.specular=o.matObj.specular.getHex(),null!=e.shininessOld?r.shininess=e.shininessOld:r.shininess=o.matObj.shininess,e.map&&(r.map=e.map),e.bumpMap&&(r.bumpMap=e.bumpMap),e.bumpScale&&(r.bumpScale=e.bumpScale),e.normalMap&&(r.normalMap=e.normalMap),e.normalScale&&(r.normalScale=e.normalScale),e.emissiveMap&&(r.emissiveMap=e.emissiveMap),e.alphaMap&&(r.alphaMap=e.alphaMap),e.specularMapOld?r.specularMap=e.specularMapOld:r.specularMap=null):"MeshStandardMaterial"==t&&(o.matObj=new THREE.MeshStandardMaterial,r={version:"1.00",name:e.name,type:"MeshStandardMaterial",uuid:e.uuid,doubleSided:e.doubleSided,envMapIntensity:e.reflectivity,refractionRatio:e.refractionRatio,opacity:e.opacity,color:e.color,skinning:e.skinning,emissive:e.emissive,emissiveIntensity:e.emissiveIntensity,shading:e.shading,wireframe:e.wireframe,specularOld:e.specular,shininessOld:e.shininess,specularMapOld:e.specularMap},null!=e.roughnessOld?r.roughness=e.roughnessOld:r.roughness=o.matObj.roughness,null!=e.metalnessOld?r.metalness=e.metalnessOld:r.metalness=o.matObj.metalness,e.map&&(r.map=e.map),e.bumpMap&&(r.bumpMap=e.bumpMap),e.bumpScale&&(r.bumpScale=e.bumpScale),e.normalMap&&(r.normalMap=e.normalMap),e.normalScale&&(r.normalScale=e.normalScale),e.emissiveMap&&(r.emissiveMap=e.emissiveMap),e.alphaMap&&(r.alphaMap=e.alphaMap),e.metalnessMapOld?r.metalnessMap=e.metalnessMapOld:r.metalnessMap=null,e.roughnessMapOld?r.roughnessMap=e.roughnessMapOld:r.roughnessMap=null),i.map&&(o.matObj.map=i.map),i.bumpMap&&(o.matObj.bumpMap=i.bumpMap,o.matObj.bumpScale=i.bumpScale),i.normalMap&&(o.matObj.normalMap=i.normalMap,o.matObj.normalScale=i.normalScale),i.emissiveMap&&(o.matObj.emissiveMap=i.emissiveMap),i.alphaMap&&(o.matObj.alphaMap=i.alphaMap),i.envMap&&(o.matObj.envMap=i.envMap),o.matObj.name=e.name,o.matObj.uuid=e.uuid,s[e.uuid]=o.matObj,o.matJson=r,c.updateMaterialInfo(r,n)),o}},Bt=function(e){this.isModelBvh=!0,this.version=0,this.parent=-1,this.bboxes=[],this.leftChild=[],this.nMeshes=[],this.startMesh=[],this.nLines=null,this.startLine=null,this.nTexts=null,this.startText=null,this.nNodes=0,this.meshIds=[],this.lineIds=null,this.textIds=null,this.meshManager=e,this.nodeId2MeshSetIdMap={}},Pt=(Bt.prototype={constructor:Bt,setNumNodes:function(e){this.nNodes=e,this.bboxes=new Float32Array(6*e),this.leftChild=new Int32Array(e),this.nMeshes=new Int32Array(e),this.startMesh=new Int32Array(e),4===this.version&&(this.nLines=new Int32Array(e),this.startLine=new Int32Array(e),this.nTexts=new Int32Array(e),this.startText=new Int32Array(e))},setNode:function(e,t,n,i,r,o,a,s,l){for(var d=0,d=0;d<6;++d)this.bboxes[6*e+d]=t[d];this.leftChild[e]=n,this.nMeshes[e]=i,this.startMesh[e]=r,this.nLines&&void 0!==o&&(this.nLines[e]=o,this.startLine[e]=a),this.nTexts&&void 0!==s&&(this.nTexts[e]=s,this.startText[e]=l)},buildMeshSets:function(){var e=[],t=0;if(4===this.version)for(t=0;t<this.nNodes;++t)(0<this.nMeshes[t]||0<this.nLines[t]||0<this.nTexts[t])&&(e.push(new pt(this,t)),this.nodeId2MeshSetIdMap[t]=e.length-1);else for(t=0;t<this.nNodes;++t)-1===this.leftChild[t]&&(e.push(new pt(this,t)),this.nodeId2MeshSetIdMap[t]=e.length-1);return e},getNodeBox:function(e,t){t=t||new THREE.Box3;return t.min.fromArray(this.bboxes,6*e),t.max.fromArray(this.bboxes,6*e+3),t},setMeshIds:function(e){this.meshIds=e},getNumMeshes:function(e){return this.nMeshes[e]},getMesh:function(e,t){e=this.startMesh[e]+t,t=this.meshIds?this.meshIds[e]:e;return this.meshManager.getMesh(t)},getMeshId:function(e,t){e=this.startMesh[e]+t;return this.meshIds?this.meshIds[e]:e},getNumTexts:function(e){return this.nTexts?this.nTexts[e]:-1},getTextId:function(e,t){return this.startText[e]+t},getText:function(e,t){return this.startText?(e=this.startText[e]+t,this.meshManager.getText(e)):null},getNumLineSegments:function(e){return this.nLines?this.nLines[e]:-1},getLineSegmentsId:function(e,t){return this.startLine[e]+t},getLineSegmentsWithState:function(e,t,n,i){return this.startLine?(e=this.startLine[e]+t,this.meshManager.getLineSegmentsWithState(e,n,i)):{state:-1,lineSegments:null}},getLineSegments:function(e,t,n,i){e=this.getLineSegmentsWithState(e,t,n,i);return 1===e.state?e.lineSegments:null},intersect:function(e){var t,n,i=[0],r=new THREE.Box3,o=[];if(0<this.nNodes)for(var a=0;a<i.length;++a)t=i[a],r.min.fromArray(this.bboxes,6*t),r.max.fromArray(this.bboxes,6*t+3),(this.meshManager.ndsModel.hasDraggedBodies()||0<this.meshManager.ndsModel.explodeFactor||0<this.meshManager.ndsModel.explodeFactorX||0<this.meshManager.ndsModel.explodeFactorY||0<this.meshManager.ndsModel.explodeFactorZ||_e.inBIMContext||_e.ScenarioEditor||_e.AnimationEdit||e.intersectsBox(r))&&(0<this.nMeshes[t]&&void 0!==(n=this.nodeId2MeshSetIdMap[t])&&o.push(n),-1!==this.leftChild[t])&&(i.push(this.leftChild[t]),i.push(this.leftChild[t]+1));return o}},function(e,t,n){this.manager=e||THREE.DefaultLoadingManager,this.loader=null,this.linkMap={},this.linkWaitingArray={},this.linkDoneMap={},this.treeIndex=1e4,this.viewer=n,this.chunkRequestQueue=[],this.pmiChunkRequestQueue=[],this.maxRequestNum=7,(Se.isIOSDevice()||Se.isIpadDevice())&&(this.maxRequestNum=4),this.loadCanceled=!1,this.chunkRequestFiredNum=0,this.SDFMaker=t,this.geometryTOchild={},n.SDFMaker=this.SDFMaker});function Ct(e,t){var n,i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){{var n;if(e)return"string"==typeof e?Rt(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Rt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length)return i&&(e=i),n=0,function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Rt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function Ot(){return{hasRefModel:!1,configurations:new Map,bodyNode_sptIndexNode:new WeakMap,modelCaches:new Map,uniqueMaterialMap:new Map,uuidMaterialMap:new Map,uniquePMIMaterialMap:new Map,uuidPMIMaterialMap:new Map,allModelLoaded:!1}}Pt.numObject=0,Pt.prototype={constructor:Pt,getRefUUID:function(e,t){return t&&0<t?e+"_"+t:e},parse:function(e,t,n,i,r,o,a){this.treeIndex=1e4;var s=this;if(this.ndsBinParser=new k({objectIdType:e.objectIdType,materialIdType:e.materialIdType,geomIdType:e.geomIdType,instanceIdType:e.instanceIdType}),s.viewer.materialIdType=e.materialIdType,s.viewer.objectIdType=e.objectIdType,s.viewer.modelContentVersion=e.modelContentVersion||1,e.sceneInfo&&(_e.ScenarioEditor&&s.viewer.ndsModel.models.length<=1||!_e.ScenarioEditor&&!s.viewer.sceneInfo)&&(s.viewer.sceneInfo=e.sceneInfo,s.viewer.sceneInfo.setScene=!0,_e.AnimationEdit)&&(s.viewer.sceneInfo.renderMode=5,s.viewer.sceneInfo.cameraInfo)&&(s.viewer.sceneInfo.cameraInfo.isPerspective=!1),e.fileID&&!s.viewer.watermark){var l=e.fileID.slice(4);s.viewer.watermark="";for(var d=0;d<l.length/4;d++){var c=l.slice(4*d,4*(d+1));s.viewer.watermark+=String.fromCharCode(parseInt(c,16))}}s.viewer.isModelSpace=!0,s.viewer.cameraInfoFile=e.cameraInfo,s.viewer.cameraInfoFile&&(s.viewer.cameraInfoFile.hasSet=!1);var h,u,p,f=s.parseModelContent(e.modelContent,t),m=null,g=!1,v=(e.bvhData?(s.viewer.modelneedLoad=!1,s.viewer.ndsModel.is2DModel=s.viewer.is2DModel,v={bvh:new Bt(s.viewer.ndsModel.meshManager),worldMatrix:f.bodyNodeRoot.worldMatrix,refModelContext:t.refModelContext,numRef:t.numRef},s.ndsBinParser.parseBvh(e.bvhData,v,null),m=s.viewer.ndsModel.sptIndex.mergeSubTree(t.parentSptIndexNode,v.bvh),s.viewer.ndsModel.buildMeshSets(),g=!0):m=s.viewer.ndsModel.sptIndex.mergeSubTree(t.parentSptIndexNode,new ft(null,null)),f.sptIndexRoot=m,t.basUri),m=!1;if(e.pmiContent&&(s.viewer.is2DModel?(s.SDFMaker.CreateMaterial(e.pmiContent,1,s.viewer.modelContentVersion),s.viewer.modelContentVersion<=3&&s.viewer.saveTextForPDF(e.pmiContent,1)):s.SDFMaker.CollectCharSet(e.pmiContent),u=s.parseModelContentInner({loadingPmi:!0,basUri:t.basUri,refModelContext:t.refModelContext,numRef:t.numRef},e.pmiContent),f.pmiObjectRoot=u.objectRoot,m=!0),e.brepMemory&&(s.viewer.brepMemory+=e.brepMemory),e.external&&e.external.url.includes("../")&&(e.bundleFile&&(s.viewer.sketchIsSub=!0),u=v.replace(/\/[^\/]+\/$/,"/")+e.external.url.split("../")[1]+"/model.js",s.viewer.sketchFileUrlQueue.push(u),f.bodyNodeRoot.sketchRefModelUri=u,f.bodyNodeRoot.sketchModel=!0),e.animationFile&&(s.viewer.animationFile=v+e.animationFile,e.animationFileData)&&e.animationFileData.deformationShapes&&(e.animationMorphAttri=s.parseMorphAnimation(e.animationMorphData)),s.viewer.preLoadAnimationFile(v,e.animationFileData,e.animationMorphAttri),null!=e.modelBrepData&&null!=e.modelBrepData&&(u=v+e.modelBrepData,null==s.viewer.brepManager&&(s.viewer.brepManager=new Tt(s.viewer,t.modelRequestor)),"modelBrep.js.gz"==e.modelBrepData&&(s.viewer.brepManager.type=0),s.viewer.brepManager.addBrepFileUrl(u,t.modelId),_e.enablePreSelectBrep||s.viewer.loadbrepDefault||_e.ScenarioEditor)&&s.viewer.loadBrepInfo(!1),e.xyDirection&&!e.sceneInfo&&(v=e.xyDirection[0],u=e.xyDirection[1],2==v?_e.modelUpDirection="posx":2==u?_e.modelUpDirection="posy":3==v?_e.modelUpDirection="negx":3==u?_e.modelUpDirection="negy":1==u&&5==v?_e.modelUpDirection="posz":0==u&&5==v?_e.modelUpDirection="negz":5==u&&0==v&&(_e.modelUpDirection="posz1")),void 0===f.bodyNodeRoot.area&&e.productData||s.viewer.useProductData?(s.viewer.useProductData=!0,h={},u=e.productData,p=t.numRef,function e(t){var n,i;if(t.uuid&&(n={area:t.area,volume:t.volume},i=s.getRefUUID(t.uuid,p),h[i]=n),0<t.children.length)for(var r=0;r<t.children.length;++r)e(t.children[r])}(u.datas[0].modelTree),function e(t){var n=h[t.uuid];t.area=n?n.area:0,t.volume=n?n.volume:0;for(var i=0;i<t.children.length;++i)e(t.children[i])}(f.bodyNodeRoot)):void 0!==f.bodyNodeRoot.area||s.viewer.is2DModel||s.viewer.loadBrepInfo(!1),e.productData&&e.productData.datas[0].matrixs){s.viewer.productDataMatrixMap||(s.viewer.productDataMatrixMap={}),s.viewer.productDataMatrixMapBuild=void 0;var A=e.productData.datas[0].matrixs;if(A)for(var y=0;y<A.length;y++){var E=s.getRefUUID(A[y].name,t.numRef);s.viewer.productDataMatrixMap[E]=A[y].matrix}}return{rootObject:f,hasBVH:g,hasPMI:m,binResquester:{chunkRequests:s.chunkRequestQueue,pmiGeomRequests:s.pmiChunkRequestQueue}}},parseModelContent:function(e,t){var n=this,t=(e.uv&&(n.SDFMaker.SetVersion(n.viewer.modelContentVersion),n.SDFMaker.CreateMaterial(e.uv,n.viewer.modelContentVersion,n.viewer.modelContentVersion),3<n.viewer.modelContentVersion&&n.SDFMaker.MeshTextSetData(e.shxData,e.ttfData),e.uvData&&n.SDFMaker.SetTexture(n.ndsBinParser.readTexture(e.uvData,null,n.viewer.modelContentVersion),n.viewer.modelContentVersion,function(){n.viewer.render()}),n.viewer.is2DModel)&&n.viewer.saveTextForPDF(e,2<=n.viewer.modelContentVersion?2:1),n.viewer.modelUnit||(n.viewer.modelUnit=e.unit),e.dwgScale?n.viewer.dwgScale=e.dwgScale:n.viewer.dwgScale=[1,1],t.materialsSetting&&(e.materials=t.materialsSetting.materials),n.parseModelContentInner({loadingPmi:!1,basUri:t.basUri,parentNode:t.parentNode,numRef:t.numRef,refModelContext:t.refModelContext},e));return e.uv&&e.shxData&&n.viewer.modelContentVersion<4&&n.SDFMaker.ProcessShxText(n.viewer,e.shxData,n.viewer.modelContentVersion),t},setCrossOrigin:function(e){this.crossOrigin=e},extractUrlBase:function(e){e=e.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")},checkGeometries:function(e,t){if(this.needsTangents(t))for(var n=0,i=e.length;n<i;n++)e[n].computeTangents()},needsTangents:function(e){for(var t in e)if(e[t].mat instanceof THREE.ShaderMaterial)return!0;return!1},parseMorphing:function(e,t){if(t instanceof THREE.Geometry){if(null!=e.morphTargets&&0<e.morphTargets.length){this.viewer.animationsManager.bHasMorph=!0;for(var n=0,i=e.morphTargets.length;n<i;n++){t.morphTargets[n]={},t.morphTargets[n].name=e.morphTargets[n].name,t.morphTargets[n].vertices=[];for(var r=t.morphTargets[n].vertices,o=0,a=(c=e.morphTargets[n].vertices).length;o<a;o+=3){var s=new THREE.Vector3;s.x=+c[o],s.y=+c[o+1],s.z=+c[o+2],r.push(s)}}}}else if(t instanceof THREE.BufferGeometry&&null!=e.morphTargets&&0<e.morphTargets.length){this.viewer.animationsManager.bHasMorph=!0;var l=e.morphTargets.length,d=[];t.morphAttributes.position=d;for(n=0;n<l;n++){var c=e.morphTargets[n].vertices,h=new THREE.Float32BufferAttribute(c.length,3);h.name=e.morphTargets[n].name,d.push(h.copyArray(c))}}},parseGeometry:function(e){},parseTexGeometry:function(e){var t={size:e.textFont.size,height:0,weight:e.textFont.weight,font:this.viewer.fontsManager.Fonts.default,style:e.textFont.style,bevelEnabled:!1,curveSegments:12,steps:1},e=(0==t.size&&(t.size=1),e.isChina&&(t.font=this.viewer.fontsManager.Fonts.simfang),new THREE.TextBufferGeometry(e.text,t));return e.type="TextBufferGeometry",e},parseSDFTextGeometry:function(e,t,F,n,i,r,o,a){void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!1);for(var s=0,l=0,o=null,d=this.SDFMaker.GetMaterialStyleId(e.textFont.style,e.textFont.weight),c=this.SDFMaker.RegText(e.text),a=(e.text=c.text,e.text.length),h=this.SDFMaker.textCompositeStride,u=this.SDFMaker.getTextGeometryBuffer(d,a),p=(u.compositeIBuffer,u.compositePositionAttrib),f=u.compositeColorAttrib,m=u.compositeUvAttrib,g=u.compositeTextureAttrib,v=u.index.array,N=4*a*this.SDFMaker.textCompositeStride,A=u.bufferOffset,y=6*a,E=u.indexOffset,M=4*a,w=A/this.SDFMaker.textCompositeStride,b=(u.bufferOffset+=N,u.indexOffset+=y,0),x=0;x<e.text.length;x++){var I=e.text[x];if(!(L=this.SDFMaker.GetDimensionsForSize(I,e.textFont.size,d,e.textFont.name,e.textFont.width,e.textFont.bigName)))return null;b+=L.width}for(var T,S,B,P=1,a=(e.textLength&&(P=e.textLength/b),new THREE.Euler),C=new THREE.Matrix4,R=new THREE.Vector3,O=new THREE.Box3,x=0;x<e.text.length;x++){var L,I=e.text[x];if(!(L=this.SDFMaker.GetDimensionsForSize(I,e.textFont.size,d,e.textFont.name,e.textFont.width,e.textFont.bigName)))return null;(c.superscript&&x>=c.superscriptbegin&&x<=c.superscriptend||c.subscript&&x>=c.subscriptbegin&&x<=c.subscriptend)&&(L.height*=.5,L.width*=.5),L.height*=P,L.width*=P;var D=L.height*this.SDFMaker.GetTextOffset(I,e.textFont.name),j=(c.superscript&&x>=c.superscriptbegin&&x<=c.superscriptend&&(D-=L.height),l<L.height-D&&(l=L.height-D),p.array[A+36*x]=s,p.array[A+36*x+1]=L.height-D,p.array[A+36*x+2]=0,f.array[A+36*x+3]=n.r,f.array[A+36*x+4]=n.g,f.array[A+36*x+5]=n.b,m.array[A+36*x+6]=L.left,m.array[A+36*x+7]=L.top,g.array[A+36*x+8]=L.textureid,p.array[A+36*x+9]=s+L.width,p.array[A+36*x+10]=L.height-D,p.array[A+36*x+11]=0,f.array[A+36*x+12]=n.r,f.array[A+36*x+13]=n.g,f.array[A+36*x+14]=n.b,m.array[A+36*x+15]=L.right,m.array[A+36*x+16]=L.top,g.array[A+36*x+17]=L.textureid,p.array[A+36*x+18]=s,p.array[A+36*x+19]=-D,p.array[A+36*x+20]=0,f.array[A+36*x+21]=n.r,f.array[A+36*x+22]=n.g,f.array[A+36*x+23]=n.b,m.array[A+36*x+24]=L.left,m.array[A+36*x+25]=L.bottom,g.array[A+36*x+26]=L.textureid,p.array[A+36*x+27]=s+L.width,p.array[A+36*x+28]=-D,p.array[A+36*x+29]=0,f.array[A+36*x+30]=n.r,f.array[A+36*x+31]=n.g,f.array[A+36*x+32]=n.b,m.array[A+36*x+33]=L.right,m.array[A+36*x+34]=L.bottom,g.array[A+36*x+35]=L.textureid,v[E+6*x]=w+4*x,v[E+6*x+1]=w+4*x+2,v[E+6*x+2]=w+4*x+1,v[E+6*x+3]=w+4*x+2,v[E+6*x+4]=w+4*x+3,v[E+6*x+5]=w+4*x+1,new THREE.Vector3(s,L.height-D,0)),_=new THREE.Vector3(s+L.width,L.height-D,0),V=new THREE.Vector3(s,-D,0),D=new THREE.Vector3(s+L.width,-D,0);s+=L.width,O.expandByPoint(j),O.expandByPoint(_),O.expandByPoint(V),O.expandByPoint(D)}if(this.viewer.is2DModel){if(a.setFromQuaternion(F),this.viewer.modelContentVersion<2){C.identity(),C.makeRotationFromEuler(a),C.setPosition(t);for(var H=0;H<M;++H)R.x=p.array[A+H*h],R.y=p.array[A+H*h+1],R.z=p.array[A+H*h+2],R.applyMatrix4(C),p.array[A+H*h]=R.x,p.array[A+H*h+1]=R.y,p.array[A+H*h+2]=R.z;this.SDFMaker.AddTextGeometryBuffer(u,d,i,w,M)}c.underscode&&((T=new THREE.LineBasicMaterial).color.setRGB(n.r,n.g,n.b),(S=new THREE.Geometry).vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(s,0,0)),S.rotateZ(a.z),S.rotateY(a.y),S.rotateX(a.x),S.translate(t.x,t.y,t.z),(B=new THREE.LineSegments(S,T)).name=i,B.color=T.color.clone(),this.SDFMaker.AddLine(B)),c.box&&((T=new THREE.LineBasicMaterial).color.setRGB(n.r,n.g,n.b),(S=new THREE.Geometry).vertices.push(new THREE.Vector3(s,l,0),new THREE.Vector3(s,0,0),new THREE.Vector3(s,0,0),new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0),new THREE.Vector3(0,l,0),new THREE.Vector3(0,l,0),new THREE.Vector3(s,l,0)),S.rotateZ(a.z),S.rotateY(a.y),S.rotateX(a.x),S.translate(t.x,t.y,t.z),(B=new THREE.LineSegments(S,T)).name=i,B.color=T.color.clone(),this.SDFMaker.AddLine(B)),c.dash&&((T=new THREE.LineBasicMaterial).color.setRGB(n.r,n.g,n.b),(S=new THREE.Geometry).vertices.push(new THREE.Vector3(0,l,0),new THREE.Vector3(s,l,0)),S.rotateZ(a.z),S.rotateY(a.y),S.rotateX(a.x),S.translate(t.x,t.y,t.z),(B=new THREE.LineSegments(S,T)).name=i,B.color=T.color.clone(),this.SDFMaker.AddLine(B))}else(o=new(r?de:THREE.BufferGeometry)).type="TextBufferGeometry",o.name=e.text,o.styleId=le.NORMAL,o.addAttribute("position",p),o.addAttribute("color",f),o.addAttribute("uv",m),o.addAttribute("textureid",g),o.setIndex(u.index),o.setDrawRange(E,y),this.SDFMaker.objectuuidToGeo[i]=o;return o&&(o.computeBoundingBox(),o.TextBox=O),o},parseBufferGeometry:function(e){var t=new THREE.BufferGeometry,n=(t.morphTargets=[],this.parseMorphing(e,t),t.bones=e.bones,[]),i=[];void 0!==e.animations&&null!=e.animations&&(e.animations.length?i=i.concat(e.animations):i.push(e.animations));for(var r=0;r<i.length;r++){var o=THREE.AnimationClip.parseAnimation(i[r],t.bones);o&&(this.viewer.animationsManager.bHasSkeletonAnimation=!0,o.animationUUID=i[r].uuid,n.push(o))}if(t.morphAttributes.position&&0<t.morphAttributes.position.length){var a=THREE.AnimationClip.CreateClipsFromMorphTargetSequences(t.morphAttributes.position,5);if(null!=a&&0<a.length)for(var n=n.concat(a),s=0;s<a.length;s++)a[s].uuid=e.morphInfos[s].uuid,a[s].ndsDuration=e.morphInfos[s].duration,a[s].ndsFps=e.morphInfos[s].fps}return 0<n.length&&(t.animations=n),t},parseNdsGeomBufferChunk:function(e,t){var n=0,i=e.bufferchunks.concat();if(i){for(var r=0;r<i.length;++r)(0<i[r].bufferlenth||0==i[r].bufferlenth&&null==i[r].buffer)&&(i[r].geometries.forEach(function(e){0!=_e.ScenarioEditorid&&(e.uuid=Se.addSceneID(e.uuid))}),e.bufferchunks[n]=i[r],n++);0<i.length-n&&e.bufferchunks.splice(n,i.length-n)}for(var o={},a=[],s=[],l=0;l<n;++l){for(var d=[],c=0;c<e.bufferchunks[l].geometries.length;++c){var h=e.bufferchunks[l].geometries[c].type,u=(null!=e.bufferchunks[l].geometries[c].id&&null!=e.bufferchunks[l].geometries[c].id||(e.bufferchunks[l].geometries[c].id=0),e.bufferchunks[l].geometries[c].uuid);if(36===u.length&&(u=u.slice(0,8)+u.slice(9,13)+u.slice(14,18)+u.slice(19,23)+u.slice(24,36)),"PointGeometry"===h){var p=this.viewer.ndsModel.getGeomManager().getPointGeomFromUuid(u);p||((p=new NdsPointGeometry).uuid=u,this.viewer.ndsModel.getGeomManager().addPointGeom(p)),d.push(p)}else if("BufferGeometry"===h){p=this.viewer.ndsModel.getGeomManager().getGeomFromUuid(u,e.bufferchunks[l].geometries[c].id);p||((p=new de).geomType=e.bufferchunks[l].geometries[c].geomType,p.uuid=u,p.subGeomId=e.bufferchunks[l].geometries[c].id,p.bufferLength=e.bufferchunks[l].geometries[c].bufferLength,e.bufferchunks[l].geometries[c].box&&p.boundingBox.setFromArray(e.bufferchunks[l].geometries[c].box),e.bufferchunks[l].geometries[c].vertexColors&&(p.vertexColors=!0),this.viewer.ndsModel.getGeomManager().addGeom(p)),d.push(p),p.updateModelMatrix=!0,o[p.uuid]=p}else if("TextGeometry"===h){h=this.viewer.ndsModel.getGeomManager().getGeomFromUuid(u,e.bufferchunks[l].geometries[c].id);if(!h){var f=e.bufferchunks[l].geometries[c];if(e.fonts&&(f.textFont=t.get(f.textFont.uuid||f.textFont)),!f.textFont)continue;var m=new THREE.Vector3,g=(f.position&&(m.x=f.position.x,m.y=f.position.y,m.z=f.position.z),new THREE.Quaternion),v=(void 0!==f.angle&&g.setFromAxisAngle(new THREE.Vector3(0,0,1),f.angle),new THREE.Vector2(0,0)),A=new THREE.Vector2(0,0),y=(f.viewBox&&(A.set(f.viewBox[0],f.viewBox[1]),v.set(f.viewBox[2],f.viewBox[3])),new THREE.Color),y=(3<this.viewer.modelContentVersion?h=this.SDFMaker.MeshTextParseGeometry(f,m,g,y,e.bufferchunks[l].geometries[c].uuid,!0,f.isMirroredInX,f.isMirroredInY,!1,this.viewer.is2DModel,this.viewer.modelContentVersion):"unLoad"==(h=this.SDFMaker.ParseSDFTextGeometry(f,m,g,y,e.bufferchunks[l].geometries[c].uuid,!0,f.isMirroredInX,f.isMirroredInY,!1,this.viewer.is2DModel,this.viewer.modelContentVersion)).textLoad&&(h.isTTF?this.SDFMaker.AddTtfTextInfo({jsonText:f,geomuuid:u,id:e.bufferchunks[l].geometries[c].id}):this.SDFMaker.AddShxTextInfo({jsonText:f,geomuuid:u,id:e.bufferchunks[l].geometries[c].id})),h.text=f.text,h.uuid=u,h.isTextGeometry=!0,h.subGeomId=e.bufferchunks[l].geometries[c].id,h.bufferLength=e.bufferchunks[l].geometries[c].bufferLength,h.position=m,h.quaternion=g,h.needsUpdate=!0,f.viewBox&&(h.viewBox={max2:v,min2:A}),this.viewer.ndsModel.getGeomManager().addGeom(h),"text:"+h.styleId);this.viewer.ndsModel.getMeshManager().materials[y]||(this.viewer.ndsModel.getMeshManager().materials[y]={mat:this.SDFMaker.GetMaterial(h.styleId),refCount:0})}d.push(h),h.updateModelMatrix=!0,o[h.uuid]=h}null!=e.bufferchunks[l].urlIndex&&(o[e.bufferchunks[l].geometries[c].uuid].urlIndex=e.bufferchunks[l].urlIndex),1==e.bufferchunks[l].geometries[c].vertexColors&&(s[e.bufferchunks[l].geometries[c].uuid]=!0)}a.push(d)}return{nTotalBufferChunksCount:n,geometries:o,totalChunksNdsGeometries:a,geometriesVertexColorsUUIDs:s}},parseThreeGeomBufferChunk:function(e,t,n){var i=0,r=e.bufferchunks.concat();if(r){for(var o=0;o<r.length;++o)(0<r[o].bufferlenth||0==r[o].bufferlenth&&null==r[o].buffer)&&(r[o].geometries.forEach(function(e){0!=_e.ScenarioEditorid&&(e.uuid=Se.addSceneID(e.uuid))}),e.bufferchunks[i]=r[o],i++);0<r.length-i&&e.bufferchunks.splice(i,r.length-i)}for(var a={},s=[],l=[],d=0;d<i;++d){for(var c=[],h=0;h<e.bufferchunks[d].geometries.length;++h){var u=e.bufferchunks[d].geometries[h].type;if(null!=e.bufferchunks[d].geometries[h].id&&null!=e.bufferchunks[d].geometries[h].id||(e.bufferchunks[d].geometries[h].id=0),"BufferGeometry"===u){var p=this.parseBufferGeometry(e.bufferchunks[d].geometries[h]);c.push(p)}else if("Geometry"===u){p=new THREE.Geometry;c.push(p)}else if("TextGeometry"===u){var f=this.geometryTOchild[e.bufferchunks[d].geometries[h].uuid];if(f)if(this.viewer.is2DModel)for(var m=0;m<f.length;++m){var g=t[(E=f[m]).material].mat.color,v=new THREE.Vector3,A=new THREE.Quaternion,y=(E.position?(v.set(E.position[0],E.position[1],E.position[2]),A.setFromAxisAngle(new THREE.Vector3(0,0,1),E.angle)):E.matrix&&((M=new THREE.Matrix4).fromArray(E.matrix),w=new THREE.Vector3,M.decompose(v,A,w)),e.bufferchunks[d].geometries[h]);e.fonts&&(y.textFont=n.get(y.textFont.uuid||y.textFont)),b=this.parseSDFTextGeometry(y,v,A,g,E.uuid),c.push(b)}else for(m=0;m<f.length;++m){(E=f[m]).material=Se.getUUid32(E.material),E.material=Se.addSceneID(E.material),_e.ScenarioEditor&&this.viewer.ndsModel.materialuuidOld2New[E.material]&&(E.material=this.viewer.ndsModel.materialuuidOld2New[E.material]);var E,M,w,g=t[E.material].mat.color,v=new THREE.Vector3,A=new THREE.Quaternion,y=(E.position?(v.set(E.position[0],E.position[1],E.position[2]),A.setFromAxisAngle(new THREE.Vector3(0,0,1),E.angle)):E.matrix&&((M=new THREE.Matrix4).fromArray(E.matrix),w=new THREE.Vector3,M.decompose(v,A,w)),e.bufferchunks[d].geometries[h]);e.fonts&&(y.textFont=n.get(y.textFont.uuid||y.textFont)),b=this.parseSDFTextGeometry(y,v,A,g,E.uuid),0==m&&c.push(b)}else{var y=e.bufferchunks[d].geometries[h],v=(e.fonts&&(y.textFont=n.get(y.textFont)),new THREE.Vector3),A=(y.position&&(v.x=y.position.x,v.y=y.position.y,v.z=y.position.z),new THREE.Quaternion),g=(void 0!==y.angle&&A.setFromAxisAngle(new THREE.Vector3(0,0,1),y.angle),new THREE.Color),b=this.parseSDFTextGeometry(y,v,A,g,e.bufferchunks[d].geometries[h].uuid);c.push(b)}}a[e.bufferchunks[d].geometries[h].uuid]=c[h],null!=e.bufferchunks[d].urlIndex&&(a[e.bufferchunks[d].geometries[h].uuid].urlIndex=e.bufferchunks[d].urlIndex),c[h]&&(e.bufferchunks[d].geometries[h].box?(c[h].boundingBox=new THREE.Box3,c[h].boundingBox.setFromArray(e.bufferchunks[d].geometries[h].box)):c[h].computeBoundingBox()),1==e.bufferchunks[d].geometries[h].vertexColors&&(l[e.bufferchunks[d].geometries[h].uuid]=!0)}s.push(c)}return{nTotalBufferChunksCount:i,geometries:a,totalChunksGeometries:s,geometriesVertexColorsUUIDs:l}},getColorAndMatrix:function(e){null!=e.geometry&&(this.geometryTOchild[e.geometry]||(this.geometryTOchild[e.geometry]=new Array),this.geometryTOchild[e.geometry].push(e));var t=e.children;if(t&&0<t.length)for(var n=0;n<t.length;n++)this.getColorAndMatrix(t[n])},parseNdsModelNode:function(e,s){var l=this,t={},n={},i={};if(e.instances)for(var r=0,o=e.instances.length;r<o;++r)e.instances[r].geometries&&(i[e.instances[r].uuid]={geometries:e.instances[r].geometries,materials:e.instances[r].materials});var a,d,c={},h=this.parseNdsModelObject(e.object,t,n,i,0,c,s);return s.parentNode&&((a=s.parentNode).unit&&(d=1,"meter"==e.unit?d=1e3:"centimeter"==e.unit?d=10:"millimeter"==e.unit?d=1:"inch"==e.unit?d=25.4:"feet"==e.unit&&(d=304.8),a.matrix||(a.matrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])),a.matrix[0]*=d,a.matrix[1]*=d,a.matrix[2]*=d,a.matrix[4]*=d,a.matrix[5]*=d,a.matrix[6]*=d,a.matrix[8]*=d,a.matrix[9]*=d,a.matrix[10]*=d),a.type=h.type,a.objectid=h.objectid,a.fileUnit=h.fileUnit,0<s.numRef&&function e(t){var n=l.getRefUUID(t.uuid,s.numRef);"Body"===t.type&&l.viewer.brepManager&&l.viewer.brepManager.bindReference(n,t.uuid),c[t.uuid]&&(c[n]=c[t.uuid],delete c[t.uuid]),t.referenceNode=t.uuid,t.uuid=n,l.viewer.ndsModel.objectidTouuid[t.objectid]=t.uuid;for(var i=0,r=t.children.length;i<r;++i)e(t.children[i]);if(t.pmiuuid)for(var o=0,a=t.pmiuuid.length;o<a;++o)t.pmiuuid[o]=l.getRefUUID(t.pmiuuid[o],s.numRef)}(h),this.viewer.ndsModel.objectidTouuid[a.objectid]=a.uuid),h=this.viewer.ndsModel.attachBodyNode(s.parentNode,h,t,n,c),s.parentNode&&s.parentNode.matrix&&(h.refMatrix=s.parentNode.matrix),h.fileUnit=e.unit,h},parsePMINode:function(e,t,n,i,r){var o=this,a=this,s=new THREE.Object3D,l=a.parseObject(e.object,t,n,r.basUri+"*",i,!1);if(0<r.numRef&&function e(t){t.uuid=o.getRefUUID(t.uuid,r.numRef),t.views&&t.views.forEach(function(e){if(e.pmiuuid)for(var t=0;t<e.pmiuuid.length;t++)e.pmiuuid[t]=a.getRefUUID(e.pmiuuid[t],r.numRef)}),t.captures&&t.captures.forEach(function(e){if(e.pmiuuid)for(var t=0;t<e.pmiuuid.length;t++)e.pmiuuid[t]=a.getRefUUID(e.pmiuuid[t],r.numRef)});for(var n=0,i=t.children.length;n<i;++n)e(t.children[n])}(l),this.SDFMaker.HaveSDF()&&this.viewer.is2DModel&&this.viewer.modelContentVersion<2){l.add(this.SDFMaker.CreateMesh());for(var d=0;d<this.SDFMaker.lines.length;d++)l.add(this.SDFMaker.lines[d])}else this.SDFMaker.objectuuidToGeo={},l.updateMatrixWorld(!0);return s.add(l),s},parseNdsBufferChunk:function(e,t,n,i,r){var o,a=r.texturePath||r.basUri,s=(i?(o=this.parseNdsGeomBufferChunk(e,n),e.nTotalBufferChunksCount=o.nTotalBufferChunksCount):(this.getColorAndMatrix(e.object),o=this.parseThreeGeomBufferChunk(e,t,n),this.checkGeometries(o.geometries,t),e.threeGeometries=o.geometries,e.geometriesVertexColorsUUIDs=o.geometriesVertexColorsUUIDs),o.nTotalBufferChunksCount),l=o.totalChunksGeometries||[],d=o.totalChunksNdsGeometries||[];this.viewer.nBufferChunks+=s;for(var c,h,u,p,f=0;f<s;++f)null!=e.bufferchunks[f].buffer&&(u=l[f],p=i?d[f]:null,h=(c=a+e.bufferchunks[f].buffer).lastIndexOf("."),h=c.substring(h+1,c.length),u={bufferlenth:e.bufferchunks[f].bufferlenth,compress:e.compress,bufferIndex:f,geometriesArray:i?null:u,ndsGeometriesArray:p,isDraco:"drc"==h},null!=e.bufferchunks[f].compress&&(u.compress=e.bufferchunks[f].compress),e.bufferchunks[f].jsonUrl&&(c=this.extractUrlBase(e.bufferchunks[f].jsonUrl)+e.bufferchunks[f].buffer),p={url:c=0==e.bufferchunks[f].isChunk?e.bufferchunks[f].buffer:c,parameters:u},(r.loadingPmi?this.pmiChunkRequestQueue:this.chunkRequestQueue).push(p),i)&&(this.viewer.ndsModel.getGeomManager().bufferChunk[c]=u);return o},parseModelContentInner:function(e,t){var n,i,r,o=0<e.numRef,a=e.texturePath||e.basUri,s=!!this.viewer.ndsModel,l=(e.loadingPmi&&(s=!1),null),d=null;if(o)l=t.materials,d=t._fonts;else{l=new bt(void 0,this.manager,this.viewer).initMaterials(t.materials,a,t.lineType,t.hatchType,t.fonts,e);if(t.materials=l,s&&this.viewer.ndsModel.getMeshManager().setMaterials(l),t.fonts){for(var d=new Map,c=0,h=t.fonts.length;c<h;++c)d.set(t.fonts[c].uuid,t.fonts[c]);t._fonts=d}}o?s?t.nTotalBufferChunksCount&&this.chunkRequestQueue.push({url:a+"geom_*.bin."+e.numRef,isRefChunk:!0,parameters:{}}):(n=t.threeGeometries,i=t.geometriesVertexColorsUUIDs):(n=(o=this.parseNdsBufferChunk(t,l,d,s,e)).geometries,i=o.geometriesVertexColorsUUIDs),this.geometryTOchild={};a=null;if(s){var u,a=this.parseNdsModelNode(t,e);if(e.parentNode&&e.parentNode.refModelUri&&(u=e.parentNode.worldMatrix),(r=new THREE.Object3D).boundingBox=new THREE.Box3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0)),t.bbox&&(this.viewer.is2DModel&&(t.bbox[2]=0,t.bbox[5]=0),r.boundingBox.min.fromArray(t.bbox,0),r.boundingBox.max.fromArray(t.bbox,3)),u&&r.boundingBox.applyMatrix4(u),0<this.SDFMaker.lines.length){var p=new THREE.Group;p.name="dashLine";for(var f=0;f<this.SDFMaker.lines.length;f++)p.add(this.SDFMaker.lines[f]);this.viewer.scene.add(p)}}else r=this.parsePMINode(t,n,l,i,e);return r.isPmi=e.loadingPmi,t.solidAnimations&&0<(o=this.parseSolidAnimations(t.solidAnimations,n,l)).length&&this.viewer&&(this.viewer.animationsManager.bHasSolidAnimation=!0,this.viewer.animationsManager.initSolidAnimations(r,o)),this.viewer&&(this.viewer.materialsSetting||(this.viewer.materialsSetting=new St(this.viewer)),e.loadingPmi||this.viewer.materialsSetting.initMaterialsInfo(l)),{objectRoot:r,bodyNodeRoot:a}},parseSolidAnimations:function(e,t,n){if(e.length<=0)return null;for(var i,r,o,a=[],s=0;s<e.length;s++)null!=e[s].fps&&(e[s].fps=parseFloat(e[s].fps)),null!=e[s].duration&&(e[s].duration=parseFloat(e[s].duration)),null==e[s].fps||null==e[s].duration||e[s].fps<=0||e[s].duration<=0||(i=THREE.AnimationClip.parse(e[s]),null!=e[s].uuid&&(i.uuid=e[s].uuid),null!=e[s].fps&&(i.fps=parseFloat(e[s].fps)),e[s].animationObject&&(r=this.parseObject(e[s].animationObject,t,n,null),(o=new THREE.Object3D).add(r),i.animationScene=new THREE.Scene,i.animationScene.autoUpdate=!1,i.animationScene.add(o)),a.push(i));return a},parseDecals:function(e,t,n){if(void 0!==t&&void 0!==n){var i={},r={},o={},a=new THREE.Object3D;a.type="decals",n.add(a),n.updateMatrixWorld(!0);for(var s=0;s<t.length;++s){var l,d=void 0,d=new(void 0!==this.viewer.convertPhongToPBR&&this.viewer.convertPhongToPBR?THREE.MeshStandardMaterial:THREE.MeshPhongMaterial);i[t[s].uuid]=t[s],d.map=(new bt).loadTexture(d,r,e+t[s].textureFile,void 0,void 0,ve.TextureLoadingManager.onError),o[t[s].uuid]=d,void 0!==t[s].opacity&&(l=parseFloat(t[s].opacity))<1&&(d.transparent=!0,d.opacity=l)}this.traverseDecals(a,n,o,i),a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1,a.updateMatrixWorld(!0)}},traverseDecals:function(e,t,n,i){if(null!=t&&t instanceof THREE.Object3D&&!(t instanceof THREE.Light))if(void 0!==t.decals)if(t.hasOwnProperty("geometry"))for(var r=0;r<t.decals.length;++r){var o=i[t.decals[r]],a=n[t.decals[r]],s=new THREE.Vector3(o.origin[0],o.origin[1],o.origin[2]),l=new THREE.Vector3(o.vecX[0],o.vecX[1],o.vecX[2]),d=new THREE.Vector3(o.vecY[0],o.vecY[1],o.vecY[2]);s.addScaledVector(l,.5),s.addScaledVector(d,.5),"MapPlanar"===o.mappingType&&(s=new mt(t,s,l,d,o.projectionType),(l=new THREE.Mesh(s,a)).matrixAutoUpdate=!1,l.matrixWorldNeedsUpdate=!1,l.updateMatrixWorld(!0),e.add(l))}else for(var c=t.children,h=0;h<c.length;++h)this.traverseChild(t.decals,e,t.children[h],n,i);else if(null!=t.children)for(c=t.children,h=0;h<c.length;++h)this.traverseDecals(e,t.children[h],n,i)},traverseChild:function(e,t,n,i,r){if(null!=n&&n instanceof THREE.Object3D&&!(n instanceof THREE.Light))if(void 0!==e){if(n.hasOwnProperty("geometry"))for(var o=0;o<e.length;++o){var a=r[e[o]],s=i[e[o]],l=new THREE.Vector3(a.origin[0],a.origin[1],a.origin[2]),d=new THREE.Vector3(a.vecX[0],a.vecX[1],a.vecX[2]),c=new THREE.Vector3(a.vecY[0],a.vecY[1],a.vecY[2]);l.addScaledVector(d,.5),l.addScaledVector(c,.5),"MapPlanar"===a.mappingType&&(l=new mt(n,l,d,c,a.projectionType),(d=new THREE.Mesh(l,s)).matrixAutoUpdate=!1,d.matrixWorldNeedsUpdate=!1,d.updateMatrixWorld(!0),t.add(d))}}else if(null!=n.children)for(var h=n.children,u=0;u<h.length;++u)this.traverseChild(e,t,n.children[u],i,r)},parseGeometries:function(e){var t={};if(void 0!==e)for(var n=new BIMJSONLoader,i=new THREE.BufferGeometryLoader,r=0,o=e.length;r<o;r++){var a,s=e[r];switch(s.type){case"PlaneGeometry":a=new THREE.PlaneGeometry(s.width,s.height,s.widthSegments,s.heightSegments);break;case"BoxGeometry":case"CubeGeometry":a=new THREE.BoxGeometry(s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments);break;case"CircleGeometry":a=new THREE.CircleGeometry(s.radius,s.segments);break;case"CylinderGeometry":a=new THREE.CylinderGeometry(s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded);break;case"SphereGeometry":a=new THREE.SphereGeometry(s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength);break;case"IcosahedronGeometry":a=new THREE.IcosahedronGeometry(s.radius,s.detail);break;case"TorusGeometry":a=new THREE.TorusGeometry(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc);break;case"TorusKnotGeometry":a=new THREE.TorusKnotGeometry(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.p,s.q,s.heightScale);break;case"BufferGeometry":a=i.parse(s.data);break;case"Geometry":a=n.parse(s.data).geometry}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),t[s.uuid]=a}return t},parseMaterials:function(e){var t={};if(void 0!==e)for(var n=new THREE.MaterialLoader,i=0,r=e.length;i<r;i++){var o=e[i],a=n.parse(o);a.uuid=o.uuid,void 0!==o.name&&(a.name=o.name),t[o.uuid]=a}return t},parseLink:function(e,a,s,l,t){var d=this,c=this.extractUrlBase(t)+e.linkPath;this.manager.itemStart(),this.loader.load(d.viewer.gobalReqHeader,c,function(e){var t=JSON.parse(e);if(t.buffer){for(var n={},i=[],r=0;r<t.geometries.length;++r)"BufferGeometry"===t.geometries[r].type?i.push(new THREE.BufferGeometry):"Geometry"===t.geometries[r].type&&i.push(new THREE.Geometry),n[t.geometries[r].uuid]=i[r];var e=d.extractUrlBase(c)+t.buffer,o={useWorker:!0,bufferlenth:t.bufferlenth,compress:t.compress,geometriesArray:i},o=((new CTMLoader).load(d.viewer.gobalReqHeader,e,function(){d.manager.itemEnd()},o),d.checkGeometries(n,l),d.parseObject(t.object,n,l,c))}else o=d.parseObject(t.object,s,l,c);a.add(o),d.onLinkComplete(a.linkID)})},recordLink:function(e,t){return null==this.linkMap[e]&&(this.linkMap[e]=t,!(this.linkDoneMap[e]=!1))},addWaitingLink:function(e,t){var n=this.linkWaitingArray[e];null==n&&(this.linkWaitingArray[e]=n=[]),n.push(t)},cloneObject:function(e,t){var n=null;if(null!=e.linkID?((n=e.clone(void 0,t=!1)).linkID=e.linkID,this.isLinkComplete(n.linkID)?this.processLoadedLink(n,this.getCompleteLink(n.linkID)):this.addWaitingLink(n.linkID,n)):n=e.clone(void 0,!1),n.uuid=e.uuid,n.type=e.type,!0===t)for(var i=0;i<e.children.length;i++){var r=e.children[i];n.add(this.cloneObject(r,t))}return n},processLoadedLink:function(e,t){for(var n=0;n<t.children.length;n++)e.add(this.cloneObject(t.children[n],!0))},isLinkComplete:function(e){return this.linkDoneMap[e]},getCompleteLink:function(e){return this.linkMap[e]},onLinkComplete:function(e){this.linkDoneMap[e]=!0;for(var t=this.linkWaitingArray[e],n=0;n<t.length;n++)this.processLoadedLink(t[n],this.linkMap[e])},parseObject:(xt=new THREE.Matrix4,function(e,t,n,i,r,o){var a,s=i;switch(e.geometry&&(e.geometry=Se.addSceneID(e.geometry)),e.material&&(e.material=Se.addSceneID(e.material),_e.ScenarioEditor)&&this.viewer.ndsModel.materialuuidOld2New[e.material]&&(e.material=this.viewer.ndsModel.materialuuidOld2New[e.material]),e.type){case"Scene":a=new THREE.Scene;break;case"PerspectiveCamera":a=new THREE.PerspectiveCamera(e.fov,e.aspect,e.near,e.far);break;case"OrthographicCamera":a=new THREE.OrthographicCamera(e.left,e.right,e.top,e.bottom,e.near,e.far);break;case"AmbientLight":a=new THREE.AmbientLight(e.color);break;case"DirectionalLight":a=new THREE.DirectionalLight(e.color,e.intensity);break;case"PointLight":a=new THREE.PointLight(e.color,e.intensity,e.distance);break;case"SpotLight":a=new THREE.SpotLight(e.color,e.intensity,e.distance,e.angle,e.exponent);break;case"HemisphereLight":a=new THREE.HemisphereLight(e.color,e.groundColor,e.intensity);break;case"Mesh":if(null==(d=t[e.geometry]))return null;if("TextBufferGeometry"!==d.type||this.viewer.is2DModel){if("TextBufferGeometry"===d.type&&this.viewer.is2DModel)return null;36===e.material.length&&(e.material=e.material.slice(0,8)+e.material.slice(9,13)+e.material.slice(14,18)+e.material.slice(19,23)+e.material.slice(24,36));var l=n[e.material];r&&r[e.geometry]&&l.mat&&(l.mat.vertexColors=!0),++l.refCount,void 0===d&&console.warn("BIMObjectLoader: Undefined geometry",e.geometry),void 0===l&&console.warn("BIMObjectLoader: Undefined material",e.material),l.mat.defines={NOCLIPPING:""},_e.StopPMIOcclusion&&(l.mat.depthTest=!1),a=new THREE.Mesh(d,l.mat)}else{var l=this.SDFMaker.GetMaterial(d.styleId);this.SDFMaker.objectuuidToGeo[e.uuid]&&(d=this.SDFMaker.objectuuidToGeo[e.uuid]),l.defines={NOCLIPPING:""},_e.StopPMIOcclusion&&(l.depthTest=!1),a=new THREE.Mesh(d,l)}null!=d.urlIndex&&(a.urlIndex=d.urlIndex);break;case"Line":var d=t[e.geometry];36===e.material.length&&(e.material=e.material.slice(0,8)+e.material.slice(9,13)+e.material.slice(14,18)+e.material.slice(19,23)+e.material.slice(24,36)),++(l=n[e.material]).refCount,void 0===d&&console.warn("BIMObjectLoader: Undefined geometry",e.geometry),void 0===l&&console.warn("BIMObjectLoader: Undefined material",e.material),l.mat.defines={NOCLIPPING:""},_e.StopPMIOcclusion&&(l.mat.depthTest=!1),a=new THREE.Line(d,l.mat),null!=d.urlIndex&&(a.urlIndex=d.urlIndex),null!=e.tangentEdgeObject&&(a.tangentEdgeObject=!0,0==_e.tangentEdgeVisible)&&(a.visible=!1);break;case"LineStrip":d=t[e.geometry];e.material&&36===e.material.length&&(e.material=e.material.slice(0,8)+e.material.slice(9,13)+e.material.slice(14,18)+e.material.slice(19,23)+e.material.slice(24,36)),++(l=(l=n[e.material])||new THREE.LineBasicMaterial({color:0,linewidth:1})).refCount,void 0===d&&console.warn("BIMObjectLoader: Undefined geometry",e.geometry),void 0===l&&console.warn("BIMObjectLoader: Undefined material",e.material),l.mat?(l.mat.defines={NOCLIPPING:""},_e.StopPMIOcclusion&&(l.mat.depthTest=!1)):(l.defines={NOCLIPPING:""},_e.StopPMIOcclusion&&(l.depthTest=!1)),a=new THREE.Line(d,l.mat||l,THREE.LineStrip),null!=d.urlIndex&&(a.urlIndex=d.urlIndex),null!=e.tangentEdgeObject&&(a.tangentEdgeObject=!0,0==_e.tangentEdgeVisible)&&(a.visible=!1);break;case"LinePieces":d=t[e.geometry];e.material&&36===e.material.length&&(e.material=e.material.slice(0,8)+e.material.slice(9,13)+e.material.slice(14,18)+e.material.slice(19,23)+e.material.slice(24,36)),++(l=(l=n[e.material])||new THREE.LineBasicMaterial({color:0,linewidth:1})).refCount,void 0===d&&console.warn("BIMObjectLoader: Undefined geometry",e.geometry),void 0===l&&console.warn("BIMObjectLoader: Undefined material",e.material),l.mat?(l.mat.defines={NOCLIPPING:""},_e.StopPMIOcclusion&&(l.mat.depthTest=!1)):(l.defines={NOCLIPPING:""},_e.StopPMIOcclusion&&(l.depthTest=!1)),a=new THREE.LineSegments(d,l.mat||l),null!=d.urlIndex&&(a.urlIndex=d.urlIndex),null!=e.tangentEdgeObject&&(a.tangentEdgeObject=!0,0==_e.tangentEdgeVisible)&&(a.visible=!1);break;case"Sprite":36===e.material.length&&(e.material=e.material.slice(0,8)+e.material.slice(9,13)+e.material.slice(14,18)+e.material.slice(19,23)+e.material.slice(24,36)),void 0===(l=n[e.material])&&console.warn("BIMObjectLoader: Undefined material",e.material),a=new THREE.Sprite(l.mat);break;case"Group":a=new THREE.Group;break;case"Link":(a=new THREE.Object3D).type="Link",a.linkID=e.linkID,this.recordLink(e.linkID,a)?this.parseLink(e,a,t,n,s):this.isLinkComplete(e.linkID)?this.processLoadedLink(a,this.getCompleteLink(e.linkID)):this.addWaitingLink(e.linkID,a);break;default:a=new THREE.Object3D,void 0!==e.type&&(a.type=e.type)}void 0!==e.uuid?a.uuid=e.uuid:(a.uuid=this.treeIndex.toString(),++this.treeIndex),void 0!==e.propertyfile&&(a.propertyfile=e.propertyfile,this.viewer.containProperty=!0);function c(e){for(var t=[],n=0;n<e.length;n++){var i,r=e[n],o={};for(i in r)o[i]=r[i];t.push(o)}return t}if(e.captures&&0<e.captures.length){a.captures=c(e.captures);for(var h=0;h<a.captures.length;h++)e.captures[h].pmiuuid&&(a.captures[h].pmiuuid=e.captures[h].pmiuuid.concat())}if(e.views&&0<e.views.length){a.views=c(e.views);for(var u=0;u<a.views.length;u++)e.views[u].pmiuuid&&(a.views[u].pmiuuid=e.views[u].pmiuuid.concat())}void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(xt.fromArray(e.matrix),xt.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.scale&&a.scale.fromArray(e.scale)),a.updateMatrixWorld(!0),a.originMatrixWorld=a.matrixWorld.clone(),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.decals&&(a.decals=e.decals),e.textOrSymbolObject&&(a.textOrSymbolObject=!0),!this.viewer.isPartPmi()&&!this.viewer.isAssemblyPmi()||this.viewer.pmiVisible||"PMI"==a.type||"Object3D"==a.type||(a.visible=!1),o?a.followCamera=!0:void 0!==e.followCamera&&(a.followCamera=e.followCamera),null!=e.autoOrientation&&(a.autoOrientation=e.autoOrientation);var p=!1;if(void 0!==e.children){for(var f=0;f<e.children.length;++f){var m=this.parseObject(e.children[f],t,n,i,r,"Note"!==e.type&&a.followCamera);null!=m&&(!a.followCamera||"Note"!=a.type||"Mesh"===m.type&&"TextBufferGeometry"===m.geometry.type||m.textOrSymbolObject||(p=!0),(a.followCamera&&("Mesh"===m.type&&"TextBufferGeometry"===m.geometry.type||m.textOrSymbolObject)?"Note"!==a.type?(a.noteGroup||(a.noteGroup=new THREE.Group,a.noteGroup.type="Note",a.noteGroup.followCamera=a.followCamera,a.noteGroup.position.copy(m.position),a.noteGroup.updateMatrixWorld(!0),a.noteGroup.originMatrixWorld=a.matrixWorld.clone(),a.add(a.noteGroup)),m.position.sub(a.noteGroup.position),m.updateMatrix(),delete m.followCamera,a.noteGroup):(a.offset?a.offset.set(Math.min(a.offset.x,m.position.x),Math.max(a.offset.y,m.position.y),Math.min(a.offset.z,m.position.z)):(a.offset=new THREE.Vector3,a.offset.copy(m.position)),a):a).add(m),m.autoOrientation)&&"GeomTol"!=m.type&&!a.hasOrientation&&(a.hasOrientation=!0)}if(a.offset){a.position.add(a.offset);for(var g=0;g<a.children.length;++g)a.children[g].position.sub(a.offset),a.children[g].updateMatrix()}}return p&&(a.followCamera=!1),a.updateMatrix(),a.updateMatrixWorld(!0),a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1,a}),setVisibleOfChild:function(e){for(var t in e.children)e.children[t].visible=!1,this.setVisibleOfChild(e.children[t])},parseNdsModelObject:function(e,t,n,i,r,o,a){o=o||{};var s,l=new Ae;if(l.unload=!1,this.viewer.CADViewer&&this.viewer.currentSketchFileUrl&&this.viewer.sketchStartLoad&&(l.sketchBody=!0),void 0!==e.uuid?(l.uuid=e.uuid,36===l.uuid.length&&"-"==l.uuid.charAt(8)&&"-"==l.uuid.charAt(13)&&"-"==l.uuid.charAt(18)&&"-"==l.uuid.charAt(23)&&(l.uuid=l.uuid.slice(0,8)+l.uuid.slice(9,13)+l.uuid.slice(14,18)+l.uuid.slice(19,23)+l.uuid.slice(24,36)),l.uuid=l.uuid.toLowerCase()):(l.uuid=this.treeIndex.toString(),++this.treeIndex),_e.ScenarioEditor&&(s=Se.addSceneID(l.uuid),l.uuid=THREE.Math.generateUUID(),l.uuid=l.uuid.slice(0,8)+l.uuid.slice(9,13)+l.uuid.slice(14,18)+l.uuid.slice(19,23)+l.uuid.slice(24,36),this.viewer.ndsModel.bodyuuidOld2New[s]=l.uuid),void 0!==e.objectid?(l.objectid=e.objectid+"_"+Pt.numObject++,this.viewer.ndsModel.objectidTouuid[l.objectid]=l.uuid):this.viewer.ndsModel.objectidTouuid&&(this.viewer.ndsModel.objectidTouuid=null),void 0!==e.name?(l.name=e.name,this.viewer._CATIA&&e.referenceName&&(a.parentNode&&a.parentNode.name?l.name=e.referenceName+"("+a.parentNode.name+")":l.name=e.referenceName+"("+e.name+")",l.oriName=e.name)):l.name=l.uuid,e.referenceName?l.referencename=e.referenceName:l.referencename=l.name,e.unit&&(l.unit=e.unit),e.material&&(s=e.material,a.refModelContext)&&a.refModelContext.hasRefModel&&a.refModelContext.uuidMaterialMap.has(e.material)&&(s=a.refModelContext.uuidMaterialMap.get(e.material),o)&&s&&(o[l.uuid]=s,l.useBodyNodeMaterial=!0),e.referenceModel&&(l.refModelUri=e.referenceModel,e.configName?l.configName=e.configName:l.configName="0"),void 0!==e.propertyfile&&(l.propertyfile=e.propertyfile,this.viewer.containProperty=!0,_e.ScenarioEditor)&&(s=this.extractUrlBase(this.viewer.ndsModel.modelUri)+l.propertyfile,this.viewer.propertyFielSet||(this.viewer.propertyFielSet=new Set),this.viewer.propertyFielSet.has(s)||(this.viewer.modelRequestor.addRequest(s,1e4,"propertyfile",{modelId:this.viewer.ndsModel.id,keepSourceFile:!0}),this.viewer.propertyFielSet.add(s))),this.viewer.useUnvisibleList||void 0===e.visible||(l.visible=e.visible),void 0!==e.fixed&&(l.fixed=e.fixed),null!=e.area&&(l.area=isNaN(Number(e.area))?0:Number(e.area)),null!=e.volume&&(l.volume=isNaN(Number(e.volume))?0:Number(e.volume)),void 0!==e.matrix&&(l.matrix=e.matrix.slice(0)),void 0!==e.worldMatrix&&(l.worldMatrix=e.worldMatrix.clone()),l.type=e.type,null!=e.pmiuuid&&(l.pmiuuid=e.pmiuuid.concat(),"Assembly"!==e.type&&"Model"!==e.type?(this.viewer.haspartPMI=!0,this.viewer.PartPMIuuid.push(e.pmiuuid)):this.viewer.hasAssemblyPMI=!0),void 0!==e.children){"Body"===e.children[0].type&&(r=0);for(var d=0;d<e.children.length;d++){var c=e.children[d];if(0!=_e.ScenarioEditorid&&(c.geometry=Se.addSceneID(c.geometry)),"Mesh"===c.type||"Surface"===c.type||"Line"===c.type||"LinePieces"===c.type)"Line"!==c.type&&"LinePieces"!==c.type||!c.tangentEdgeObject||(n[c.geometry]=!0),"Surface"===c.type&&(c.type="Mesh",l.hasSurface=!0),36===c.material.length&&"-"==c.material.charAt(8)&&"-"==c.material.charAt(13)&&"-"==c.material.charAt(18)&&"-"==c.material.charAt(23)&&(c.material=c.material.slice(0,8)+c.material.slice(9,13)+c.material.slice(14,18)+c.material.slice(19,23)+c.material.slice(24,36)),c.material=Se.addSceneID(c.material),_e.ScenarioEditor&&this.viewer.ndsModel.materialuuidOld2New[c.material]&&(c.material=this.viewer.ndsModel.materialuuidOld2New[c.material]),a.refModelContext&&a.refModelContext.uuidMaterialMap.has(c.material)&&(c.material=a.refModelContext.uuidMaterialMap.get(c.material).uuid),this.viewer.ndsModel.getMeshManager().materials[c.material],this.viewer.ndsModel.getMeshManager().materials[c.material].refCount++,_e.ScenarioEditor?(h=Se.addSceneID(c.uuid),c.uuid=THREE.Math.generateUUID(),c.uuid=Se.getUUid32(c.uuid),this.viewer.ndsModel.bodyuuidOld2New[h]=c.uuid):c.uuid=Se.addSceneID(c.uuid),t[c.uuid]=c.geometry;else if("RefPoint"===c.type||"RefAxis"===c.type||"RefPlane"===c.type){var h={parentNode:l,uuid:c.uuid,type:c.type,name:c.name,visible:c.visible,coords:c.points};this.viewer.ndsModel.addReferenceEntity(h),"RefAxis"===c.type&&c.visible&&l.setComponentRefAxisVisibility(!0),"RefPlane"===c.type&&c.visible&&l.setComponentRefPlaneVisibility(!0)}else{"Meshes"==e.type&&"Object3D"===c.type&&(c.type="Body");var u=this.parseNdsModelObject(c,t,n,i,r,o,a);if(u.parent=l,"Body"===c.type&&r++,"Body"===c.type||!_e.inBIMContext||u.children&&0!=u.children.length){if(void 0!==l.visible&&0==l.visible&&(u.visible=!1,this.setVisibleOfChild(u)),"Root"===u.type||"Geometry"===u.type||"Meshes"===u.type||"Group"===u.type)for(var p=0;p<u.children.length;p++)l.children.push(u.children[p]),u.children[p].parent=l;else l.children.push(u);"CoordSystem"===c.type&&c.visible&&l.setComponentCoordinateSysVisibility(!0)}}}}return"Body"!=e.type?void 0!==e.fileguid&&(l.fileguid=e.fileguid,this.viewer.ndsModel.fileguidTouuid[l.fileguid]||(this.viewer.ndsModel.fileguidTouuid[l.fileguid]=[]),"Model"==e.type&&1==e.children.length&&"Part"==e.children[0].type?this.viewer.ndsModel.fileguidTouuid[l.fileguid].push(e.children[0].uuid):this.viewer.ndsModel.fileguidTouuid[l.fileguid].push(l.uuid)):l.BodyfileID=r,l},parseMorphAnimation:function(e){return e?(new k).readMorph(e):null}};function Lt(e,T){function p(e){return 1===(e=e.split("/")).length?"./":(e.pop(),e.join("/")+"/")}function S(e,t){void 0===e&&(e=10);var n=null;return P.zipModelWorker&&j.zipModelWorker.has(t)?j.zipModelWorker.get(t):0<V.length&&(V.sort(function(e,t){return e.workingRequestCount-t.workingRequestCount}),0===V[0].workingRequestCount)?V[0]:(V.length<i?(n=r(),V.push(n)):V[0].workingRequestCount<e&&(n=V[0]),n)}function f(e,t,o,n,i){var d=new Pt(null,i.SDFMaker,P.viewer).parse(e,{basUri:t,modelId:o,keepSourceFile:n,modelRequestor:P,StoploadBrep:!0,refModelContext:B});if(j.viewer.currentSketchFileUrl||(v=v||d.hasBVH,A=A||d.hasPMI),d.rootObject.bodyNodeRoot&&d.rootObject.sptIndexRoot&&B.bodyNode_sptIndexNode.set(d.rootObject.bodyNodeRoot,d.rootObject.sptIndexRoot),P.viewer.loadCallback(d.rootObject.objectRoot,e.modelContent.lightsPreset),d.rootObject.pmiObjectRoot&&i.addPMIObject(d.rootObject.pmiObjectRoot),d.binResquester.chunkRequests&&0<d.binResquester.chunkRequests.length)for(var r=0;r<d.binResquester.chunkRequests.length;++r)!function(i){d.binResquester.chunkRequests[i].parameters.modelId=o,d.binResquester.chunkRequests[i].parameters.keepSourceFile=n;var r=d.binResquester.chunkRequests[i].url;j.viewer.ZIPData.file(r).async("uint8array").then(function(e){var t={isPMI:!1,keepSourceFile:!1,modelId:o,operate:"loadChunkBuffer",state:"successed",url:r},e=new Uint8Array(e),n=new ArrayBuffer(d.binResquester.chunkRequests[i].parameters.bufferlenth),e=new Ve.Stream(e),n=(e.readInt32(),new Uint8Array(n)),n=new Ve.BIMStream(n,0,1);M.decompress(e,e,n,n.data.length),t.chunkData=n.data,t.bufferlenth=d.binResquester.chunkRequests[i].parameters.bufferlenth,D.push(t),O.set(r,d.binResquester.chunkRequests[i])})}(r);if(d.binResquester.pmiGeomRequests&&0<d.binResquester.pmiGeomRequests.length)for(var a=0;a<d.binResquester.pmiGeomRequests.length;++a)!function(s){d.binResquester.pmiGeomRequests[s].isPMI=!0,d.binResquester.pmiGeomRequests[s].parameters.modelId=o,d.binResquester.pmiGeomRequests[s].parameters.keepSourceFile=n;var l=d.binResquester.pmiGeomRequests[s].url;j.viewer.ZIPData.file(l).async("uint8array").then(function(e){var e=new Uint8Array(e),t=new ArrayBuffer(d.binResquester.pmiGeomRequests[s].parameters.bufferlenth),t=((e=new Ve.Stream(e)).readInt32(),new Uint8Array(t)),t=new Ve.BIMStream(t,0,1),n=(M.decompress(e,e,t,t.data.length),d.binResquester.pmiGeomRequests[s]),i=!n.parameters.geometriesArray,r=i?n.parameters.ndsGeometriesArray:n.parameters.geometriesArray,e=new Ve.Stream(t.data),o=((new k).readBIMBuffer(e,null,r,null),r.length);if(n.parameters.ndsGeometriesArray)for(var a=0;a<o;++a)i||n.parameters.ndsGeometriesArray[a].copy(n.parameters.geometriesArray[a]),n.parameters.ndsGeometriesArray[a].loaded=!0,n.parameters.ndsGeometriesArray[a].bufferChunkUrl=l})}(a)}var B,P=this,C=(this.viewer=e,[]),m=new Map,R=[],O=new Map,L=new Map,D=[],H=[],i=Se.isMobileDevice()?Se.isIOSDevice()||Se.isIpadDevice()?6:10:14,g=new Map,F=-1,N=null,v=!1,A=!1,u=new Map,j=this,_=(this.pauseRequest=new Set,this.zipModelWorker=new Map,this.propertys=new Map,this.addRequest=function(e,t,n,i){C.push({weight:t,uri:e,operate:n,params:i=void 0===i?{}:i})},function(e,t){var n="0";if(B.configurations.has(e)&&(i=B.configurations.get(e))){if(!i.loaded)return null;for(var i,r=0,o=(i=i.Configurations).length;r<o;++r)if(i[r].Name===t.configName){n=i[r].Folder;break}}return t.path+"/"+n+"/model.js"}),r=function(){var e,t,n;return(e=j.viewer.serverUrl?(t=new Blob(['importScripts("'+_e.NdsLoadWorkerUrl+'")'],{type:"application/javascript"}),n=window.URL.createObjectURL(t),new Worker(n)):_e.singleHTML?(e=j.viewer.workerString,t=new Blob([e],{type:"application/javascript"}),n=window.URL.createObjectURL(t),new Worker(n)):new Worker(_e.NdsLoadWorkerUrl)).workingRequestCount=0,e.onmessage=function(o){var e,t,n;if("getModelData"===o.data.operate)"successed"===o.data.res.state?(t=o.data.res,m.set(o.data.url,t),this.workingRequestCount--,t.keepSourceFile&&!u.has(t.modelId)&&u.set(t.modelId,{url:o.data.url,modelSourceData:t.jsonMain.modelSourceData,modelContentSourceData:t.jsonMain.modelContentSourceData,bvhSourceData:t.jsonMain.bvhSourceData,pmiContentSourceData:t.jsonMain.pmiContentSourceData,animationSourceData:t.jsonMain.animationFileSourceData,geomBins:[],PropertyFile:[]})):"loading"===o.data.res.state?m.get(o.data.url).state="loading":(m.get(o.data.url).state="failed",this.workingRequestCount--,0);else if("loadBrepData"===o.data.operate)this.workingRequestCount--,null==j.viewer.brepManager&&(j.viewer.brepManager=new Tt(j.viewer,j)),"successed"!==o.data.state?(console.log("load "+o.data.url+" failed"),j.viewer.brepManager.onError(o.data.url.uri)):(t=(new k).parseBrep(o.data.brepData,{brepManager:j.viewer.brepManager},null),o.data.keepSourceFile&&(e=u.get(o.data.modelId))&&(e.brepSourceData={url:o.data.url,data:o.data.brepSourceData}),j.viewer.brepManager.onLoad(o.data.url,t.BbodyVolume,t.BbodyVolume,t.BfaceArea));else if("loadChunkBuffer"===o.data.operate)this.workingRequestCount--,"successed"!==o.data.state?console.log("load "+o.data.url+" failed"):o.data.isPMI?(H.push(o.data),o.data.keepSourceFile&&(e=u.get(o.data.modelId))&&(e.pmiGeomBin={url:o.data.url,data:o.data.chunkSourceData})):(D.push(o.data),o.data.keepSourceFile&&(t=u.get(o.data.modelId))&&t.geomBins.push({url:o.data.url,data:o.data.chunkSourceData}));else if("propertyfile"===o.data.operate){if(this.workingRequestCount--,"successed"!==o.data.state)console.log("load "+o.data.url+" failed");else if(o.data.keepSourceFile){var i=u.get(o.data.modelId);if(i){for(var r=!0,a=0;a<i.PropertyFile.length;a++)if(i.PropertyFile[a].uri==o.data.url){r=!1;break}r&&i.PropertyFile.push({url:o.data.url,data:o.data.PropertySourceData})}}}else if("requestRefModel"===o.data.operate){var s=function(e,t){(t=void 0===t?!1:t)?C.push({weight:o.data.weight,path:e,operate:"loadModelData",needsConfName:!0,params:{keepSourceFile:o.data.keepSourceFile,modelId:o.data.modelId}}):(B.modelCaches.has(e)||B.modelCaches.set(e,{state:"waiting",numRef:0,numRequest:0}),C.push({weight:o.data.weight,uri:e,operate:"loadModelData",params:{keepSourceFile:o.data.keepSourceFile,modelId:o.data.modelId}}))};if(_e.singleHTML)for(var l=0;l<o.data.refModelConfigurations.length;++l){var d=o.data.refModelConfigurations[l],c=o.data.refModelPathes[l].path+"/Configurations.json";B.configurations.has(c)||(d.loaded=!0,B.configurations.set(c,d))}for(var h=0;h<o.data.refModelPathes.length;++h)!function(){var e=o.data.refModelPathes[h];if("0"===e.configName){var t=e.path+"/0/model.js";s(t)}else{var n=e.path+"/Configurations.json";if(B.configurations.has(n)){t=_(n,e);t?s(t):s(e,!0)}else{B.configurations.set(n,{loaded:!1});var i=new Headers;if(j.viewer.gobalReqHeader)for(var r in j.viewer.gobalReqHeader)i.append(r,j.gobalReqHeader[r]);fetch(n,{headers:i}).then(function(e){return e.json()}).then(function(e){e.loaded=!0,B.configurations.set(n,e)}).catch(function(e){B.configurations.set(n,{loaded:!0,Configurations:[]})}),s(e,!0)}}}();B.hasRefModel=!0}else"loadModelZip"===o.data.operate?(this.workingRequestCount--,j.pauseRequest.delete(o.data.modelID)):"loadModelPropertys"===o.data.operate&&(this.workingRequestCount--,n=new Map,Object.keys(o.data.propertys).forEach(function(e){n.set(e,o.data.propertys[e])}),j.propertys.set(o.data.modelID,n))},e.addTask=function(e){this.workingRequestCount++,this.postMessage(e),"loadModelData"===e.operate&&0,"loadChunkBuffer"!==e.operate&&g.set(e.url,this)},e},V=[],y=(this.setZipData=function(o,t){var i=p(o);P.viewer.ZIPData.file(o).async("string").then(function(e){e={jsonMain:JSON.parse(e),keepSourceFile:!1,modelId:t,state:"zipfile",type:"zip"};m.set(o,e)}).then(function(){var e,r=m.get(o).jsonMain;r.modelContentFile?(e=i+r.modelContentFile,j.viewer.ZIPData.file(e).async("uint8array").then(function(t){if(t&&0!==t.byteLength){t=pako.inflate(t,{to:"string"});try{var e=/\\"/g,n=t.replace(e,""),e=/\\(?!\u[0-9a-fA-F]{4})/g,n=n.replace(e,"-"),i=JSON.parse(n)}catch(e){i=JSON.parse(t)}i.objectIdType=r.objectIdType,i.materialIdType=r.materialIdType,i.geomIdType=r.geomIdType,i.instanceIdType=r.instanceIdType,r.modelContent=i,r.modelContentState=1,(r.pmiContentState=1==r.bvhDataState&&1==r.modelContentState)&&(m.get(o).state="successed")}else r.modelContentState=-1})):(r.modelContentState=1,(r.pmiContentState=1==r.bvhDataState&&1==r.modelContentState)&&(m.get(o).state="successed"))}).then(function(){var e,n=m.get(o).jsonMain;n.bvh?(n.bvhDataState=0,e=i+n.bvh,j.viewer.ZIPData.file(e).async("uint8array").then(function(e){var t;e&&0!==e.byteLength?(e=new Uint8Array(e),t=new ArrayBuffer(n.bvhBufferLength),(e=new Ve.Stream(e)).readInt32(),t=new Uint8Array(t),t=new Ve.BIMStream(t,0,1),M.decompress(e,e,t,t.data.length),n.bvhData=t.data,n.bvhDataState=1,(n.pmiContentState=1==n.bvhDataState&&1==n.modelContentState)&&(m.get(o).state="successed")):n.bvhDataState=-1})):(n.bvhDataState=1,(n.pmiContentState=1==n.bvhDataState&&1==n.modelContentState)&&(m.get(o).state="successed"))}).then(function(){var e,t=m.get(o).jsonMain;t.pmiContentFile?(t.pmiContentState=0,e=i+t.pmiContentFile,j.viewer.ZIPData.file(e).async("uint8array").then(function(e){e&&0!==e.byteLength?(e=pako.inflate(e,{to:"string"}),e=JSON.parse(e),t.pmiContent=e,t.pmiContentState=1,(t.pmiContentState=1==t.bvhDataState&&1==t.modelContentState)&&(m.get(o).state="successed")):t.pmiContentState=-1})):(t.pmiContentState=1,(t.pmiContentState=1==t.bvhDataState&&1==t.modelContentState)&&(m.get(o).state="successed"))}).then(function(){var n,e=m.get(o).jsonMain;e.modelBrepData&&(n=i+e.modelBrepData,j.viewer.ZIPData.file(n).async("uint8array").then(function(e){var t;e&&0!==e.byteLength&&(e=pako.inflate(e),t=new k,null==j.viewer.brepManager&&(j.viewer.brepManager=new Tt(j.viewer,j)),t=t.parseBrep(e,{brepManager:j.viewer.brepManager},null),j.viewer.brepManager.onLoad(n,t.BbodyVolume,t.BbodyVolume,t.BfaceArea))}))})},this.afterModelLoaded=function(e){var t;B.allModelLoaded=!0,j.viewer.currentSketchFileUrl||(j.viewer.configurations=B.configurations),(t=B).configurations=null,t.bodyNode_sptIndexNode=null,t.modelCaches=null,t.uniqueMaterialMap=null,t.uuidMaterialMap=null,t.uniquePMIMaterialMap=null,t.uuidPMIMaterialMap=null,j.viewer.sketchFileUrlQueue.length||(j.viewer.dispatchEvent({type:"BVHInfoEvent",hasbvh:v}),j.viewer.dispatchEvent({type:"PMIInfoEvent",PMI:A}))},this.request=function(){for(;C.length&&0!==function(){if(_e.singleHTML&&j.pauseRequest&&j.pauseRequest.has(C[0].params.modelId))return 0;if(C[0].needsConfName){var e=C[0].path.path+"/Configurations.json";if(B.configurations.has(e)){e=_(e,C[0].path);if(!e)return 0;C[0].uri=e,C[0].needsConfName=!1,B.modelCaches.has(e)||B.modelCaches.set(e,{state:"waiting",numRef:0,numRequest:0})}}if(_e.singleHTML&&!j.viewer.zipMutiModel){e=C.shift();F!==e.params.modelId&&(F=e.params.modelId,B=Ot(),N=null),"zip"==e.params.type&&P.setZipData(e.uri,e.params.modelId)}else{var t=S(10,C[0].params.modelId);if(!t)return 0;var n,e=C.shift();if(F!==e.params.modelId&&(F=e.params.modelId,B=Ot(),N=null),"js_zip"===e.params.type)return e.params.type="js",C.push(e),n={operate:"loadModelZip",modelID:e.params.modelId,gobalReqHeader:j.viewer.gobalReqHeader},P.viewer.ZIPData?P.viewer.ZIPData.generateAsync({type:"blob"}).then(function(e){n.zip=e,t.addTask(n)}).catch(function(e){console.error("创建失败:",e)}):(n.url=P.viewer.zipModelURLs.get(e.uri),t.addTask(n)),j.pauseRequest.add(e.params.modelId),j.zipModelWorker.set(e.params.modelId,t),1;if("loadModelData"===e.operate)if(B.modelCaches.has(e.uri)){var i=B.modelCaches.get(e.uri);if(0<i.numRequest)return i.numRequest++,1;i.numRequest++,i.state="requesting"}else B.modelCaches.set(e.uri,{state:"requesting",numRef:0,numRequest:1});else if("loadModelPropertys"===e.operate)return j.propertys&&j.propertys.has(modelId)||t.addTask({operate:e.operate,modelID:e.params.modelId}),1;t.addTask({operate:e.operate,url:e.uri,keepSourceFile:!!e.params.keepSourceFile,modelId:e.params.modelId,gobalReqHeader:j.viewer.gobalReqHeader})}}(););for(;R.length;)if(R[0].isRefChunk){var e=R.shift();O.set(e.url,e),D.push({url:e.url})}else{e=S(5,R[0].parameters.modelId);if(!e)break;var t=R.shift();e.addTask({operate:"loadChunkBuffer",url:t.url,isPMI:!!t.isPMI,bufferlenth:t.parameters.bufferlenth,modelId:t.parameters.modelId,keepSourceFile:!!t.parameters.keepSourceFile,gobalReqHeader:j.viewer.gobalReqHeader,isDraco:!!t.parameters.isDraco}),t.state="loading",(t.isPMI?L:O).set(t.url,t)}if(B&&B.allModelLoaded){for(var n=0,i=D.length;n<i;++n){var r=D.shift(),o=O.get(r.url);if(O.delete(r.url),!o.isRefChunk){var a=!o.parameters.geometriesArray,s=a?o.parameters.ndsGeometriesArray:o.parameters.geometriesArray;if(o.parameters.compress){var l=new Ve.Stream(r.chunkData),d=new k,c=(o.parameters.isDraco?d.readBIMBufferDraco(l,function(){},s,null):d.readBIMBuffer(l,null,s,null),s.length);if(o.parameters.ndsGeometriesArray)for(var h=0;h<c;++h)a||o.parameters.ndsGeometriesArray[h].copy(o.parameters.geometriesArray[h]),o.parameters.ndsGeometriesArray[h].loaded=!0,o.parameters.ndsGeometriesArray[h].bufferChunkUrl=r.url}}}for(var u=H.length;n<u;++n){var p=H.shift(),f=L.get(p.url),m=(L.delete(p.url),!f.parameters.geometriesArray),g=m?f.parameters.ndsGeometriesArray:f.parameters.geometriesArray,v=new Ve.Stream(p.chunkData),c=((new k).readBIMBuffer(v,null,g,null),g.length);if(f.parameters.ndsGeometriesArray)for(h=0;h<c;++h)m||f.parameters.ndsGeometriesArray[h].copy(f.parameters.geometriesArray[h]),f.parameters.ndsGeometriesArray[h].loaded=!0,f.parameters.ndsGeometriesArray[h].bufferChunkUrl=p.url}if(0<n){if(T.onBufferChunkCallback){var A=!0;if((!B.allModelLoaded||0<R.length||0<O.size||0<L.size)&&(A=!1),T.onBufferChunkCallback(A,!0),A){P.viewer.currentSketchFileUrl||N.afterAllGeomLoaded();var A=!1,y=(void 0===A&&(A=!0),new Set);if(!0===A){for(var E=0;E<V.length;++E)V[E].terminate();V=[]}else{for(var M=Ct(j.zipModelWorker.values());!(w=M()).done;){var w=w.value;y.add(w)}for(var b=0;b<V.length;++b)y.has(V[b])||V[b].terminate();V=[];for(var x=Ct(y.values());!(I=x()).done;){var I=I.value;V.push(I)}}P.viewer.CADViewer&&P.viewer.loadSketch(),P.viewer.is2DModel&&(P.viewer.init2dTextFind(),P.viewer._loaded=!0,P.viewer._filterTextByShowHide())}}}else{A=!0;(A=!B.allModelLoaded||0<R.length||0<O.size||0<L.size||0<P.viewer.sketchFileUrlQueue.length||1==P.viewer.sketchStartLoad?!1:A)&&P.viewer.ndsModel&&0==P.viewer.ndsModel.meshManager.geomManager.geoms.length&&!P.viewer.GeomEmpty&&(P.viewer.dispatchAsyncEvent({type:"loadError",errorInfo:"geom empty"}),P.viewer.GeomEmpty=!0)}}},this.initRequest=function(){B=null,g=new Map},function(e){for(var t=e;!B.bodyNode_sptIndexNode.has(t)&&t.parent;)t=t.parent;return B.bodyNode_sptIndexNode.has(t)?B.bodyNode_sptIndexNode.get(t):j.viewer.ndsModel.sptIndex.root});this.tryMergeNode=function(e,t,n){var i;if(N=N||t,!(i=e.configName?(i=e.path+"/Configurations.json",_(i,e)):e))return!1;var e=!1,r=m.get(i),o=0;if(!r&&B.modelCaches&&B.modelCaches.has(i)&&"loaded"===(a=B.modelCaches.get(i)).state&&(r=a.node,o=++a.numRef),r&&"successed"===r.state&&"zip"==r.type){var a=p(i);f(r.jsonMain,a,r.modelId,r.keepSourceFile,t),m.delete(i),e=!0}else if(r&&"successed"===r.state){P.viewer.sketchStartLoad&&(P.viewer.currentSketchFileUrl=i);var a=p(i),s=(-1===t.dataVersion&&(t.dataVersion=Number(r.jsonMain.metadata.version)),r.jsonMain),l=r.modelId,d=r.keepSourceFile,c=(s.metadata&&"CATIA"==s.metadata.format&&(P.viewer._CATIA=!0),P.viewer.jsonMainText=s.modelSourceData||JSON.stringify(s),new Pt(null,t.SDFMaker,P.viewer).parse(s,{basUri:a,modelId:l,numRef:o,keepSourceFile:d,modelRequestor:P,parentNode:n,parentSptIndexNode:n&&B?y(n):null,refModelContext:B}));if(P.viewer.currentSketchFileUrl||(v=v||c.hasBVH,A=A||c.hasPMI),c.rootObject.bodyNodeRoot&&c.rootObject.sptIndexRoot&&B.bodyNode_sptIndexNode.set(c.rootObject.bodyNodeRoot,c.rootObject.sptIndexRoot),n||(t.hasRefModel=B.hasRefModel),P.viewer.loadCallback(c.rootObject.objectRoot,s.modelContent.lightsPreset),c.rootObject.pmiObjectRoot&&t.addPMIObject(c.rootObject.pmiObjectRoot),c.binResquester.chunkRequests&&0<c.binResquester.chunkRequests.length){for(var h=0;h<c.binResquester.chunkRequests.length;++h)c.binResquester.chunkRequests[h].parameters.modelId=l,c.binResquester.chunkRequests[h].parameters.keepSourceFile=d;R=R.concat(c.binResquester.chunkRequests)}if(c.binResquester.pmiGeomRequests&&0<c.binResquester.pmiGeomRequests.length){for(var u=0;u<c.binResquester.pmiGeomRequests.length;++u)c.binResquester.pmiGeomRequests[u].isPMI=!0,c.binResquester.pmiGeomRequests[u].parameters.modelId=l,c.binResquester.pmiGeomRequests[u].parameters.keepSourceFile=d;R=R.concat(c.binResquester.pmiGeomRequests)}m.delete(i),r.cached||(o=B.modelCaches.get(i))&&(o.state="loaded",r.cached=!0,o.node=r),e=!0}else r&&"loading"!==r.state?r&&"failed"===r.state&&(B.modelCaches.get(i).state="failed",P.viewer.loadErrorCallback(i+" load failed",B.hasRefModel),e=!0):(n=g.get(i))&&(n.postMessage({operate:"getModelData",url:i}),m.set(i,{state:"asking"}));return e},this.getModelSourceFile=function(){return u}}function Dt(e,t){return e.z-t.z}function Ht(e,t,n){void 0===n&&(n=0),this.id=e,this.z=t,this.t=n}ve.EXPLODEMODE={NORMAL:32,X:1,Y:2,Z:4,LEVEL:8,SELECTED:16};var Ft,Nt,jt,_t,Vt,kt,Ut,Gt=0,zt=function(e,t,n){function i(e){for(var t=0;t<e.children.length;++t){var n=e.children[t];!n.refModelUri||n.loaded||(n.loaded=c.nodeRequestor.tryMergeNode({path:n.refModelUri,configName:n.configName},c,n),n.loaded)?i(n):h++}}function r(e){e.sketchRefModelUri&&!e.loaded&&(e.loaded=c.nodeRequestor.tryMergeNode(e.sketchRefModelUri,c,e),e.loaded||h++);for(var t=0;t<e.children.length;++t)r(e.children[t])}var o,a,s,l,d,c=this,h=(void 0===n&&(n={}),this.viewer=e,this.id=void 0!==n.modelId&&null!==n.modelId?n.modelId:Gt++,this.id>Gt&&(Gt=this.id+1),this.dataVersion=-1,this.nodeRequestor=n.nodeRequestor||new Lt(this,{loadingManager:n.loadingManager,onLoadCallback:n.onLoadCallback,onRenderSettingCallback:n.onRenderSettingCallback,onBufferChunkCallback:n.onBufferChunkCallback,onLoadErrorCallback:n.onLoadErrorCallback}),this.modelUri=t,this.geomManager=new R(e),this.meshManager=new ut(this.geomManager,this),this.referenceEntityDispManager=new st(this),this.meshSets=[],this.sptIndex=new ft(null,this.meshManager),this.lineSegmentsSet=new O(this.meshManager),this.SHADED_WITH_EDGES=1,this.SHADED=2,this.WIREFRAME=3,this.HIDDEN_LINE_REMOVE=4,this.HIDDEN_LINE_VISIBLE=5,this.TRANSPARENT=6,this.drawMode=1,this.renderOnce=!1,this.renderMeshSetCount=0,this.spriteDirty=!0,this.SDFMaker=new le(this.viewer.is2DModel),this.pmiObject=null,this.rootBodyNode=null,this.bodyUuid2NodeMap={},this.meshUuid2GeomUuidMap={},this.fileguidTouuid={},this.objectidTouuid={},this.is2DModel=!1,this.state=0,this.forceRenderAll=!1,this.wholeLeafBodyNodes=[],this.wholeRefEntityNodes=[],this.wholeCoordinateNodes=[],this.emptyBodyNodes=[],this.hasRawMesh=!1,this.transparentBodies=[],this.transparentBodiesDirty=!1,this.transparentBodyChanged=!1,this.containsOriginalTransparentBodies=!1,this.transparentizedBodies=[],this.transparentModeBodiesMap=new Map,this.selectedBodies=[],this.selectedBodiesDirty=!1,this.draggedBodies=[],this.hideBodies=[],this.UnloadNodes=[],this.pureLineBody=[],this.preselectedObject=null,this.hasHiddenBodies=!1,this.referenceEntityDirty=!1,this.explodeFactor=0,this.explodeFactorX=0,this.explodeFactorY=0,this.explodeFactorZ=0,this.explodeMode=ve.EXPLODEMODE.NORMAL,this.explodeLevel=0,this.explodeObject=null,this.LeafbodyToFirstBodyMap=new Map,this.leafNodeCount=0,this.tempCenterBox=new THREE.Vector3,this.bodyNodeUUidToMaterial={},this.ModelUpMatrix4=[],this.NeedsMergeBodyNode=!1,this.sortMeshSets=(o=[],a=new THREE.Vector3,s=new THREE.Box3,l=new THREE.Vector3,d=new THREE.Vector3,function(e,t){for(var n=o.length=0,i=e.length;n<i;++n){c.sptIndex.getNodeBox(c.meshSets[e[n]].node,s),s.getCenter(l),s.getSize(d);var r=.5*d.length(),r=Math.abs(r/(a.dot(t.pixelSizeVector)+t.pixelSizeVector.w));o.push(new Ht(e[n],r,c.meshSets[e[n]].bufferId))}o.sort(function(e,t){return 250<=t.z||250<=e.z?t.z-e.z:t.t-e.t});for(n=0,i=e.length;n<i;++n)e[n]=o[n].id}),this.needsFastRendering=!1,this.setDirty=function(e){function i(){o.needsFastRendering=!1,clearTimeout(r),r=null}var r=null,o=e=void 0===e?this:e;return function(e){for(void 0===e&&(e=200),t=0,n=o.meshSets.length;t<n;++t)o.meshSets[t].dirty=!0,o.meshSets[t].visible=!0;for(o.selectedBodiesDirty=!0,o.transparentBodiesDirty=!0,o.referenceEntityDirty=!0,t=0,n=o.geomManager.geoms.length;t<n;++t)o.geomManager.geoms[t].dirty=!0;for(o.lineSegmentsSet.dirty=!0,o.meshManager.dirty=!0,t=0,n=o.meshManager.instancedMeshIds.length;t<n;++t)o.meshManager.instancedMeshDirtyFlags[t]=!0;for(var t=0,n=o.meshManager.instancedLineSegs.size;t<n;++t)o.meshManager.instancedLineDirtyFlags[t]=!0;o.spriteDirty=!0,o.needsFastRendering||(o.needsFastRendering=!0,r&&clearTimeout(r),r=setTimeout(i,e))}}(this),this.backupDirty=function(){for(var e=0,t=this.meshSets.length;e<t;++e)this.meshSets[e].oldDirty=this.meshSets[e].dirty,this.meshSets[e].oldVisible=this.meshSets[e].visible;for(this.oldSelectedBodiesDirty=this.selectedBodiesDirty,this.oldTransparentBodiesDirty=this.transparentBodiesDirty,this.oldReferenceEntityDirty=this.referenceEntityDirty,e=0,t=this.geomManager.geoms.length;e<t;++e)this.geomManager.geoms[e].oldDirty=this.geomManager.geoms[e].dirty;this.lineSegmentsSet.oldDirty=this.lineSegmentsSet.dirty,this.meshManager.oldDirty=this.meshManager.dirty,this.oldSpriteDirty=this.spriteDirty},this.resetDirty=function(){for(var e=0,t=this.meshSets.length;e<t;++e)null!=this.meshSets[e].oldDirty&&(this.meshSets[e].dirty=this.meshSets[e].oldDirty),null!=this.meshSets[e].oldVisible&&(this.meshSets[e].visible=this.meshSets[e].oldVisible);for(this.selectedBodiesDirty=this.oldSelectedBodiesDirty,this.transparentBodiesDirty=this.oldTransparentBodiesDirty,this.referenceEntityDirty=this.oldReferenceEntityDirty,e=0,t=this.geomManager.geoms.length;e<t;++e)null!=this.geomManager.geoms[e].oldDirty&&(this.geomManager.geoms[e].dirty=this.geomManager.geoms[e].oldDirty);this.lineSegmentsSet.dirty=this.lineSegmentsSet.oldDirty,this.meshManager.dirty=this.meshManager.oldDirty,this.spriteDirty=this.oldSpriteDirty},this.dispose=function(){c.meshManager.dispose(),c.geomManager.dispose()},this.addPMIObject=function(e){c.pmiObject||(c.pmiObject=new THREE.Object3D),c.pmiObject.add(e)},0);this.SetBodyNodePropertyList=function(){var r=this,n=new Set;function i(e,t){r.viewer.propertyManager.cachedProperties&&!function t(e){var n,i=r.viewer.getObjectByUUID(e.uuid);i&&i.refModelUri&&r.viewer.propertyManager.referenceMap&&r.viewer.propertyManager.referenceMap.has(e.uuid)&&(n=r.viewer.propertyManager.referenceMap.get(e.uuid)),e.propertyList||(e.propertyList=r.viewer.propertyManager.cachedProperties[n||e.uuid]&&r.viewer.propertyManager.cachedProperties[n||e.uuid].PropertyCategories),Array.isArray(e.children)&&e.children.forEach(function(e){t(e)})}(r.rootBodyNode)}!function t(e){e.propertyfile&&!n.has(e.propertyfile)&&(n.add(e.propertyfile),r.viewer.getObjectProperty(e,i)),Array.isArray(e.children)&&e.children.forEach(function(e){t(e)})}(r.rootBodyNode)},this.update=function(e){void 0===e&&(e={}),0===c.state?(c.nodeRequestor.addRequest(c.modelUri,1e5,"loadModelData",{modelId:c.id,keepSourceFile:n.keepSourceFile,type:n.type}),c.state=1):1===c.state?(h=0,c.rootBodyNode?c.hasRefModel&&(c.viewer.sketchStartLoad?r:i)(c.rootBodyNode):c.nodeRequestor.tryMergeNode(c.modelUri,c,null)?c.hasRefModel&&i(c.rootBodyNode):h++,0===h&&(c.state=2,c.pmiObject&&(c.preparePMI(),c.viewer.addPMIObject(c.pmiObject)),c.prepareForRendering(c.viewer.renderer.supportInstancedArrays(),c.viewer),c.setBodyNodeMaterialsInfo(c.viewer.bodyNodeUUidToMaterial),c.viewer.prepareModelForRendering(),c.nodeRequestor.afterModelLoaded(c.id),c.SetBodyNodePropertyList())):c.state}};function Wt(e,t){return e.z-t.z}function Yt(e,t){return t.z-e.z}zt.prototype={constructor:zt,getGeomManager:function(){return this.geomManager},getMeshManager:function(){return this.meshManager},getMeshSets:function(){return this.meshSets},buildMeshSets:function(){this.meshSets=this.sptIndex.buildMeshSets()},sortMeshSets2:function(e){for(var t,n,i,r=[],o=new THREE.Box3,a=0,s=e.length;a<s;++a)o.min.fromArray(this.sptIndex.bboxes,6*this.meshSets[e[a]].node),o.max.fromArray(this.sptIndex.bboxes,6*this.meshSets[e[a]].node+3),t=o.max.x-o.min.x,n=o.max.y-o.min.y,i=o.max.z-o.min.z,r.push(new Ht(e[a],t*n*i));r.sort(Dt);for(a=0,s=e.length;a<s;++a)e[a]=r[a].id},getRightBodyuuid:function(e,t){for(var n=0;n<t.length;++n)for(var i=this.bodyUuid2NodeMap[t[n]];i.parent;){if(i.parent.fileguid==e)return t[n];i=i.parent}return t[0]},getLineSegmentsSet:function(){return this.lineSegmentsSet},OrientationPMI:function(e){function _(e,t){var n=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],i=new THREE.Box3;n[0].set(e.min.x,e.min.y,e.min.z).applyMatrix4(t),n[1].set(e.min.x,e.min.y,e.max.z).applyMatrix4(t),n[2].set(e.min.x,e.max.y,e.min.z).applyMatrix4(t),n[3].set(e.min.x,e.max.y,e.max.z).applyMatrix4(t),n[4].set(e.max.x,e.min.y,e.min.z).applyMatrix4(t),n[5].set(e.max.x,e.min.y,e.max.z).applyMatrix4(t),n[6].set(e.max.x,e.max.y,e.min.z).applyMatrix4(t),n[7].set(e.max.x,e.max.y,e.max.z).applyMatrix4(t);for(var r=0;r<n.length;r++)i.expandByPoint(n[r]);return i}e=e||(this.pmiObject?this.pmiObject.children[0].children[0]:null);if(e){var V=[],k=[];for(e.traverse(function(e){if(e.hasOrientation){for(var t=new THREE.Vector3,n=new THREE.Vector3,i=new THREE.Box3,r=new THREE.Line3(new THREE.Vector3(0,0,0),new THREE.Vector3(1e3,0,0)),o=new THREE.Line3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,1)),a=null,s=0;s<e.children.length;s++){var l,d,c,h,u,p=e.children[s];p.autoOrientation&&p.geometry?(p.geometry.TextBox?(l=_(p.geometry.TextBox,p.matrixWorld),i.containsBox(l)||i.union(l)):(p.geometry.boundingBox||p.geometry.computeBoundingBox(),l=_(p.geometry.boundingBox,p.matrixWorld),i.containsBox(l)||i.union(l)),a=a||p.matrixWorld):"Line"==p.type&&8==p.geometry.drawRange.count&&(d=p.geometry.drawRange.start,c=p.geometry.getAttribute("position"),u=p.geometry.index.getX(d),h=p.geometry.index.getX(d+7),t.fromBufferAttribute(c,u),n.fromBufferAttribute(c,h),p.geometry.index.getX(d+1)==p.geometry.index.getX(d+2))&&p.geometry.index.getX(d+3)==p.geometry.index.getX(d+4)&&p.geometry.index.getX(d+5)==p.geometry.index.getX(d+6)&&t.distanceTo(n)<1e-6&&(p.autoOrientation=!0,p.geometry.boundingBox||p.geometry.computeBoundingBox(),u=_(p.geometry.boundingBox,p.matrixWorld),i.containsBox(u)||i.union(u))}e.line=r.applyMatrix4(a);for(var f=null,m=0;m<e.children.length;m++){var g=e.children[m];if("Mesh"==g.type&&"TextBufferGeometry"==g.geometry.type&&g.geometry.name.includes("°")){f=null;break}if("Line"==g.type&&2==g.geometry.drawRange.count){var v=g.geometry.drawRange.start,A=g.geometry.getAttribute("position"),y=g.geometry.index.getX(v),v=g.geometry.index.getX(v+1),y=(t.fromBufferAttribute(A,y),n.fromBufferAttribute(A,v),new THREE.Line3(t,n)),A=(y.applyMatrix4(g.matrixWorld),(new THREE.Vector3).subVectors(y.end,y.start)),v=(A.normalize(),(new THREE.Vector3).subVectors(e.line.end,e.line.start)),g=(v.normalize(),A.dot(v));if(1-Math.abs(g)<1e-4){if(f){f=null;break}f=y.clone()}}}o.applyMatrix4(a);r=(new THREE.Vector3).subVectors(o.end,o.start),o=new THREE.Vector3;i.getCenter(o),f?(H=new THREE.Vector3,f.closestPointToPoint(o,!1,H),H=new THREE.Line3(H,new THREE.Vector3(H.x+r.x,H.y+r.y,H.z+r.z)),e.axis=H,e.BaseLine=f,k.push(e)):(H=new THREE.Line3(o,new THREE.Vector3(o.x+r.x,o.y+r.y,o.z+r.z)),e.axis=H)}if("GeomTol"==e.type&&e.autoOrientation){var E=[],M=[];e.hasOrientation=!1;for(var w=0;w<e.children.length;w++){var b=e.children[w];if("Line"==b.type){var x=b.geometry.drawRange.start,I=new THREE.Vector3,T=new THREE.Vector3,F=b.geometry.getAttribute("position"),N=b.geometry.index.getX(x),x=b.geometry.index.getX(x+1);if(I.fromBufferAttribute(F,N),T.fromBufferAttribute(F,x),I.distanceToSquared(T)<1e-4)continue;for(var S={start:I,end:T,uuid:b.uuid,p1:-1,p2:-1},B=0;B<E.length;B++){var j=E[B];I.distanceToSquared(j)<1e-4&&(S.p1=B),T.distanceToSquared(j)<1e-4&&(S.p2=B)}-1==S.p1&&(S.p1=E.length,E.push(I)),-1==S.p2&&(S.p2=E.length,E.push(T)),M.push(S)}(b.geometry&&"TextBufferGeometry"==b.geometry.type||"LineSegments"==b.type)&&(e.hasOrientation=!0)}if(e.hasOrientation){var P=function(e,t){for(var n=[],i={},r=new THREE.Line3,o=0;o<e.length;o++)(A=e[o]).p1!==A.p2&&(void 0!==i[A.p1]?i[A.p1].push(A.p2):i[A.p1]=[A.p2],void 0!==i[A.p2]?i[A.p2].push(A.p1):i[A.p2]=[A.p1]);for(var a=[];;){for(var s in i)if(1==i[s].length)for(var l in delete i[s],i){var d=parseInt(s),c=i[l].indexOf(d);-1!=c&&i[l].splice(c,1)}var h=!1;for(s in i)if(1==i[s].length){h=!0;break}if(!h)break}for(;;){var u=void 0;for(s in i)if(1<i[s].length){u=s;break}if(!u)for(var s in i)if(0<i[s].length){u=s;break}if(!u)break;var p=-1,d=parseInt(u),f=i[u];for(a.push(d);f&&f.length;){var m=f.shift();if(void 0===(m=m===p?f.shift():m)){delete i[d];break}a.push(m);for(h=!1,o=0;o<a.length-1;++o)if(m==a[o]){a=a.slice(o),h=!0;break}if(h)break;(0==f.length||f[0]===p)&&delete i[d],p=d,f=i[d=m]}if(5==a.length){if(a[0]==a[a.length-1]){n.push(a);break}a=[]}}var g=n[0],v=[];if(g&&0!=g.length)for(o=0;o<e.length;o++){var A=e[o];if(-1!=g.indexOf(A.p1))v.push(A.uuid);else{for(var y=!1,E=!1,M=0;M<g.length-1;M++){var w,b=g[M],x=g[M+1],b=t[b],x=t[x],x=(r.set(b,x),(new THREE.Vector3).subVectors(x,b)),I=(x.normalize(),(new THREE.Vector3).subVectors(A.start,b)),T=(I.normalize(),x.dot(I)),T=(1-Math.abs(T)<1e-4&&(w=r.closestPointToPointParameter(A.start,!1))<1&&0<w&&(y=!0),I.subVectors(A.end,b),I.normalize(),x.dot(I));1-Math.abs(T)<1e-4&&(w=r.closestPointToPointParameter(A.end,!1))<1&&0<w&&(E=!0)}y&&E&&v.push(A.uuid)}}return v}(M,E);if(0!=P.length){for(var C=new THREE.Box3,o=new THREE.Line3(new THREE.Vector3(0,0,0),new THREE.Vector3(1e3,0,0)),r=new THREE.Line3(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,1)),R=null,O=0;O<e.children.length;O++){var L,D=e.children[O];-1==P.indexOf(D.uuid)&&"TextBufferGeometry"!=D.geometry.type&&"LineSegments"!=D.type||(D.autoOrientation=!0,"TextBufferGeometry"==D.geometry.type||"LineSegments"==D.type?P.push(D.uuid):(D.geometry.boundingBox||D.geometry.computeBoundingBox(),L=_(D.geometry.boundingBox,D.matrixWorld),C.containsBox(L)||C.union(L)),R)||"TextBufferGeometry"!=D.geometry.type&&"LineSegments"!=D.type||(R=D.matrixWorld)}var H=new THREE.Vector3,o=(C.getCenter(H),e.line=o.applyMatrix4(R),r.applyMatrix4(R),(new THREE.Vector3).subVectors(r.end,r.start)),r=new THREE.Line3(H,new THREE.Vector3(H.x+o.x,H.y+o.y,H.z+o.z));e.axis=r,P.length==e.children.length&&(e.vec=o,e.box=C,V.push(e))}}}});;){if(0==V.length)break;for(var t=V.shift(),n=0;n<k.length;n++){var i,r,o,a=k[n];a.BaseLine&&((i=(new THREE.Vector3).subVectors(a.BaseLine.end,a.BaseLine.start)).normalize(),(r=(new THREE.Vector3).subVectors(t.line.end,t.line.start)).normalize(),i=i.dot(r),1-Math.abs(i)<1e-4)&&(r=new THREE.Vector3,i=new THREE.Vector3,t.box.getCenter(i),a.BaseLine.closestPointToPoint(i,!1,r),r=new THREE.Line3(r,new THREE.Vector3(r.x+t.vec.x,r.y+t.vec.y,r.z+t.vec.z)),o=Math.min(i.distanceTo(a.BaseLine.start),i.distanceTo(a.BaseLine.end)),!t.distance||t.distance>o)&&(Math.abs(a.BaseLine.start.x-a.BaseLine.end.x)<1e-6&&Math.abs(i.x-a.BaseLine.end.x)<1e-6||Math.abs(a.BaseLine.start.y-a.BaseLine.end.y)<1e-6&&Math.abs(i.y-a.BaseLine.end.y)<1e-6||Math.abs(a.BaseLine.start.z-a.BaseLine.end.z)<1e-6&&Math.abs(i.z-a.BaseLine.end.z)<1e-6)&&(t.distance=o,t.axis=r)}}}},preparePMI:function(){},afterAllGeomLoaded:function(){var h=this,u=new THREE.Matrix4,e=new THREE.Matrix4;if(this.viewer.pmiObject&&!_e.ScenarioEditor&&!this.viewer.is2DModel){0<(t=this.viewer.SDFMaker.getHashKey()).length&&(t=this.viewer.SDFMaker.CreateImage(t),this.viewer.SDFMaker.CreateOldMaterialFromImage(t)),this.viewer.pmiObject.children[0].traverse(function(e){e.geometry&&"TextBufferGeometry"==e.geometry.type&&null!=e.geometry.styleId&&(e.material=h.viewer.SDFMaker.TextMaterial)});for(var t,n=this.pmiObject.children[0].children[0],i=1;i<this.pmiObject.children.length;i++)for(var r=this.pmiObject.children[i],o=0;o<r.children[0].children.length;o++){var a=r.children[0].children[o];n.add(a)}this.viewer.pmiObject.remove(this.viewer.pmiObject.children[0]),this.viewer.pmiObject.add(n),this.viewer.pmiNum=0,n.version||("PMI_Model1"==n.name?(n.version=2,n.name=this.viewer.ndsModel.rootBodyNode.name,this.viewer.viewerPMIVisible||n.traverse(function(e){e.visible=h.viewer.viewerPMIVisible})):n.version=1,Se.isMobileDevice()&&this.viewer.haspartPMI&&this.viewer.hasAssemblyPMI&&(n.visible||(n.visible=!0)),this.viewer.PMIUUIDtoPMIObject[n.uuid]=n,0<this.viewer.ndsModel.ModelUpMatrix4.length&&((t=new THREE.Matrix4).fromArray(this.viewer.ndsModel.ModelUpMatrix4),n.applyMatrix(t),n.updateMatrixWorld(!0)),n.traverse(function(e){e.geometry&&h.viewer.leafPMIObjects.push(e),(h.viewer.PMIUUIDtoPMIObject[e.uuid]=e).originMatrixWorld&&e.originMatrixWorld.copy(e.matrixWorld),"en"!=Se.getLanguage()&&(e.name=e.name.replace(/Circular Region/gi,Se.translateString("PMI_Circular")),e.name=e.name.replace(/Rectangular Region/gi,Se.translateString("PMI_Rectangular")),e.name=e.name.replace(/Hole Callout/gi,Se.translateString("PMI_HOLE")),e.name=e.name.replace(/Notes Area/gi,Se.translateString("PMI_NOTEAREA")),e.name=e.name.replace(/Datum Reference Frams/gi,Se.translateString("PMI_DatumReference")),e.name=e.name.replace(/Construction geometries/gi,Se.translateString("PMI_Construction")),e.name=e.name.replace(/Restricted Areas/gi,Se.translateString("PMI_RestrictedAreas")),e.name=e.name.replace(/Datum features and datum targets/gi,Se.translateString("PMI_RestrictedAreas")),e.name=e.name.replace(/Reference Frams/gi,Se.translateString("PMI_ReferenceFrams")),e.name=e.name.replace(/radius Dimension/gi,Se.translateString("PMI_RadialDimension")),e.name=e.name.replace(/horizontal Dimension/gi,Se.translateString("PMI_horizontalDimension")),e.name=e.name.replace(/vertical Dimension/gi,Se.translateString("PMI_verticalDimension")),e.name=e.name.replace(/perpendicular Dimension/gi,Se.translateString("PMI_perpendicularDimension")),e.name=e.name.replace(/Chamfer Dimension/gi,Se.translateString("PMI_ChamferDimension")),e.name=e.name.replace(/Radial Dimension/gi,Se.translateString("PMI_RadialDimension")),e.name=e.name.replace(/Thickness Dimension/gi,Se.translateString("PMI_ThicknessDimension")),e.name=e.name.replace(/Ordinate Origin/gi,Se.translateString("PMI_OrdinateOrigin")),e.name=e.name.replace(/Ordinate Dimension/gi,Se.translateString("PMI_OrdinateDimension")),e.name=e.name.replace(/Datum Feature Symbol/gi,Se.translateString("PMI_DatumFeatureSymbol")),e.name=e.name.replace(/Datum Target/gi,Se.translateString("PMI_DatumTarget")),e.name=e.name.replace(/Arc Length Dimension/gi,Se.translateString("PMI_ArcLengthDimension")),e.name=e.name.replace(/Feature Control Frame/gi,Se.translateString("PMI_FeatureControlFrame")),e.name=e.name.replace(/Balloon Note/gi,Se.translateString("PMI_BalloonNote")),e.name=e.name.replace(/Surface Finish/gi,Se.translateString("PMI_SurfaceFinish")),e.name=e.name.replace(/Angular Dimension/gi,Se.translateString("PMI_AngularDimension")),e.name=e.name.replace(/Flag Note/gi,Se.translateString("PMI_FlagNote")),e.name=e.name.replace(/Weld Symbol/gi,Se.translateString("PMI_WeldSymbol")),e.name=e.name.replace(/Geometrica Tolerances/gi,Se.translateString("PMI_GeometricaTolerances")),e.name=e.name.replace(/geometrical tolerance/gi,Se.translateString("PMI_geometricaltolerance")),e.name=e.name.replace(/surface texture/gi,Se.translateString("PMI_surfacetexture")),e.name=e.name.replace(/Linear Size/gi,Se.translateString("PMI_LinearSize")),e.name=e.name.replace(/Coordinate Dimension/gi,Se.translateString("PMI_CoordinateDimension")),e.name=e.name.replace(/Note/gi,Se.translateString("PMI_Note")),e.name=e.name.replace(/Datum/gi,Se.translateString("PMI_Datum")),e.name=e.name.replace(/GeomTol/gi,Se.translateString("PMI_GeomTol")),e.name=e.name.replace(/Roughness/gi,Se.translateString("PMI_Roughness")),e.name=e.name.replace(/Capture/gi,Se.translateString("PMI_Capture")),e.name=e.name.replace(/View/gi,Se.translateString("PMI_VIEW")),e.name=e.name.replace(/Feature/gi,Se.translateString("PMI_Feature")),e.name=e.name.replace(/Target/gi,Se.translateString("PMI_Target")),e.name=e.name.replace(/Text/gi,Se.translateString("PMI_Text")),e.name=e.name.replace(/Weld/gi,Se.translateString("PMI_Weld")),e.name=e.name.replace(/Dimension/gi,Se.translateString("PMI_Dimension")),e.name=e.name.replace(/Label/gi,Se.translateString("PMI_Label"))),-1!=e.name.indexOf("pmi_")&&(e.name=e.name.substr(4)),e.children[0]&&e.children[0].geometry&&h.viewer.pmiNum++}),(t=new THREE.Raycaster(new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0))).linePrecision=1,t.intersectObjects(h.viewer.leafPMIObjects,!0)),!function e(t,n,i){var r=new THREE.Matrix4;if(t.pmiuuid&&0<t.pmiuuid.length){t.worldMatrix=h.calculateNodeWorldMatrix(t),u.extractRotation(t.worldMatrix),t.refMatrix&&(r.fromArray(t.refMatrix),r.multiply(i),n=!0);for(var o=0;o<t.pmiuuid.length;++o){var a=t.pmiuuid[o],s=h.viewer.PMIUUIDtoPMIObject[a];if(n&&s){s.applyMatrix4(r),s.updateMatrixWorld(!0);for(var l=0;l<s.children.length;l++){var d=s.children[l];d.originMatrixWorld.copy(d.matrixWorld)}}}}for(var c=0;c<t.children.length;c++)e(t.children[c],!1,r)}(this.rootBodyNode,!1,e),this.OrientationPMI(n)}0<this.transparentBodies.length&&(this.containsOriginalTransparentBodies=!0)},prepareForRendering:function(e,t){this.meshManager.supportInstancedArrays=e,this.meshManager.supportInstancedArraysCopy=e,this.meshManager.mapGeomUuidToGeomId();for(var i=this,r=[],n=function e(t){if(t.unload=!0,t.visible=!1,-1==r.indexOf(t.uuid)&&(i.UnloadNodes.push(t),r.push(t.uuid)),0<t.children.length)for(var n=0;n<t.children.length;++n)e(t.children[n])},o=(!_e.HideLeafBody||"Part"!=this.rootBodyNode.type&&"Model"!=this.rootBodyNode.type||1!=this.rootBodyNode.children.length||"Part"!=this.rootBodyNode.children[0].type||1<this.rootBodyNode.children[0].children.length&&(_e.HideLeafBody=!1),!_e.HideLeafBody||0!=this.rootBodyNode.children.length||"Part"!=this.rootBodyNode.type&&"Model"!=this.rootBodyNode.type||(_e.HideLeafBody=!1),[this.rootBodyNode]),a=0;a<o.length;++a){var s=(((x=o[a]).ndsModel=this).bodyUuid2NodeMap[x.uuid]=x).type.toLowerCase();if(0===x.children.length&&("part"!=s&&"assembly"!=s&&(x.id=this.meshManager.bodyUuid2IdMap[x.uuid],null==x.id||x.id<0)&&(1==_e.inAssemblyContext?x.id=this.leafNodeCount++:(this.meshManager.bodyUuid2IdMap[x.uuid]=this.meshManager.bodyUuids.length,this.meshManager.bodyUuids.push(x.uuid),x.id=this.meshManager.bodyUuid2IdMap[x.uuid])),x.isReferenceEntity()?this.wholeRefEntityNodes.push(x):x.isCoordinate()?(this.wholeCoordinateNodes.push(x),null==x.worldMatrix&&(x.worldMatrix=this.calculateNodeWorldMatrix(x)),null==x.leafBodyAttri&&(x.leafBodyAttri=new C,x.visible||x.hide())):("part"!=s&&"assembly"!=s&&this.wholeLeafBodyNodes.push(x),null==x.worldMatrix&&(x.worldMatrix=this.calculateNodeWorldMatrix(x))),this.hasRawMesh||"rawmesh"!=s||(this.hasRawMesh=!0)),x.isEmptyNode()&&this.emptyBodyNodes.push(x),x.pmiuuid&&!t.is2DModel&&t.pmiObject){null==x.worldMatrix&&(x.worldMatrix=this.calculateNodeWorldMatrix(x));var l=!1;t.pmiObject&&0<t.pmiObject.children.length&&(l="modelPMI"==t.pmiObject.children[0].name);for(var d=0;d<x.pmiuuid.length;++d){var c=x.pmiuuid[d],h=t.pmiObject.getObjectByProperty("uuid",c);if(h&&"PMI"==h.type)if(l)h.matrix.multiply(x.worldMatrix),h.updateMatrixWorld(!0);else if(0<h.children.length)for(var u=0;u<h.children.length;u++){var p=h.children[u];"PMI"!=p.type&&(p.matrix.multiply(x.worldMatrix),p.updateMatrixWorld(!0))}}}this.objectidTouuid?t.unvisibleList&&-1!=t.unvisibleList.indexOf(x.objectid)&&n(x):(null==(s=this.meshManager.bodyUuid2IdMap[x.uuid])&&(this.meshManager.bodyUuid2IdMap[x.uuid]=this.meshManager.bodyUuids.length,this.meshManager.bodyUuids.push(x.uuid),s=this.meshManager.bodyUuid2IdMap[x.uuid]),t.useUnvisibleList&&t.unvisibleList&&-1!=t.unvisibleList.indexOf(s)&&n(x));for(var d=0,f=x.children.length;d<f;++d)o.push(x.children[d])}for(a=0;a<o.length;++a)for(d=0,f=(x=o[a]).children.length;d<f;++d)"Body"==x.children[0].type&&!x.DiffVisible&&x.children[d].visible&&(x.DiffVisible=!0,x.children[0].visible?x.FirstVisibleNode=0:x.FirstVisibleNode=d);for(a=0;a<this.meshManager.nMeshes;++a){var m=this.meshManager.bodyUuids[a];if(y=this.bodyUuid2NodeMap[m]){if(_e.HideLeafBody){if(!y.visible&&y.parent.DiffVisible||y.unload){n(y),this.meshManager.bodyNodes[a]=this.bodyUuid2NodeMap[m];continue}var g=y.parent.FirstVisibleNode||0;y.parent.children[g].uuid==y.uuid||null!=y.leafBodyAttri||y.IsMergedNode||(y.IsMergedNode=!0)}else if(y.unload){this.meshManager.bodyNodes[a]=this.bodyUuid2NodeMap[m];continue}if(this.meshManager.bodyNodes[a]=this.bodyUuid2NodeMap[m],null==y.leafBodyAttri){y.leafBodyAttri=new S(y),null==y.worldMatrix&&(y.worldMatrix=this.calculateNodeWorldMatrix(y)),this.inIsolate()&&y.isolate(),y.leafBodyAttri.bodyMeshIds.push(a);for(d=0;d<6;++d)y.leafBodyAttri.bodyBbox[d]=this.meshManager.bboxes[6*a+d]}else if(-1==y.leafBodyAttri.bodyMeshIds.indexOf(a)){y.leafBodyAttri.bodyMeshIds.push(a);for(d=0;d<3;++d)this.meshManager.bboxes[6*a+d]<y.leafBodyAttri.bodyBbox[d]&&(y.leafBodyAttri.bodyBbox[d]=this.meshManager.bboxes[6*a+d]),this.meshManager.bboxes[6*a+3+d]>y.leafBodyAttri.bodyBbox[3+d]&&(y.leafBodyAttri.bodyBbox[3+d]=this.meshManager.bboxes[6*a+3+d])}}}for(var v=[],a=0;a<this.meshManager.nLineSegments;++a){m=this.meshManager.lineSegBodyUuids[a];if(y=this.bodyUuid2NodeMap[m]){if(_e.HideLeafBody&&!this.sketchFileUrl){if(!y.visible&&y.parent.DiffVisible||y.unload){n(y),this.meshManager.lineSegBodyNodes[a]=this.bodyUuid2NodeMap[m];continue}var A=y.parent.FirstVisibleNode||0;y.parent.children[A].uuid==y.uuid||null!=y.leafBodyAttri||y.IsMergedNode||(y.IsMergedNode=!0)}else if(y.unload){this.meshManager.lineSegBodyNodes[a]=this.bodyUuid2NodeMap[m];continue}this.meshManager.lineSegBodyNodes[a]=this.bodyUuid2NodeMap[m],null==y.leafBodyAttri?(y.leafBodyAttri=new S(y),y.leafBodyAttri.bodyLineSegIds.push(a),null==y.worldMatrix&&(y.worldMatrix=this.calculateNodeWorldMatrix(y)),v.push(y)):-1==y.leafBodyAttri.bodyLineSegIds.indexOf(a)&&y.leafBodyAttri.bodyLineSegIds.push(a)}}for(a=0;a<this.meshManager.nTexts;++a){var m=this.meshManager.textBodyUuids[a],y=this.bodyUuid2NodeMap[m];if(null==(this.meshManager.textBodyNodes[a]=y).leafBodyAttri?(y.leafBodyAttri=new S(y),y.leafBodyAttri.bodyTextIds.push(a),null==y.worldMatrix&&(y.worldMatrix=this.calculateNodeWorldMatrix(y))):-1==y.leafBodyAttri.bodyTextIds.indexOf(a)&&y.leafBodyAttri.bodyTextIds.push(a),!(this.meshManager.textGeomId[a]<0)){var E=this.meshManager.geomManager.getGeomFromId(this.meshManager.textGeomId[a]),M=this.viewer.scene.getObjectByName("dashLine");if(M){M=M.getObjectByName(E.uuid);if(M){var E=this.meshManager.mats[this.meshManager.textMaterialId[a]],w=(M.material.color.copy(E.color),new THREE.Matrix4);if(this.meshManager.matrixes)for(var b=0;b<16;++b)w.elements[b]=this.meshManager.matrixes[16*this.meshManager.textMatrixId[a]+b];else w.copy(y.worldMatrix);M.applyMatrix(w)}}}}if(0<(this.pureLineBody=v).length)for(a=0;a<v.length;a++)6!=v[a].leafBodyAttri.bodyBbox.length&&this.calculateLineBodyBoundingBox(v[a]);_e.HideLeafBody&&!this.sketchFileUrl?(this.viewer.selectionManager.setSelectType("part"),this.viewer.controls.getOperator().oldSelectType="part",this.mergeNode()):(this.transparentBodyChanged=!0,this.getAllTransparentBodies(!0));for(var x,o=[this.rootBodyNode],a=0;a<o.length;++a)if((x=o[a]).visible)for(d=0,f=x.children.length;d<f;++d)o.push(x.children[d]);else this.hideBody(x);for(a=0;a<this.wholeCoordinateNodes.length;++a){var I,T=this.wholeCoordinateNodes[a];T.visible&&(T.leafBodyAttri.renderObject?T.leafBodyAttri.renderObject.attach(T):(I=null,I=this.viewer.canvas2D||this.viewer.canvas3D,(I=new Ne(this.viewer.camera,I)).attach(T),T.leafBodyAttri.renderObject=I,this.viewer.scene.add(I)))}this.meshManager.resetGeomSameMaterialFlags(),this.viewer.prepareModelCallBack&&this.viewer.prepareModelCallBack(this.rootBodyNode)},mergeNode:function(){this.NeedsMergeBodyNode=!0,this.transparentBodyChanged=!0,this.getAllTransparentBodies()},unmergeNode:function(){this.NeedsMergeBodyNode=!1,this.transparentBodyChanged=!0,this.getAllTransparentBodies()},backupAllBodyFlag:function(){for(var e=0,t=this.wholeLeafBodyNodes.length;e<t;++e)this.wholeLeafBodyNodes[e].leafBodyAttri&&(this.wholeLeafBodyNodes[e].leafBodyAttri.bodyFlagBackup=this.wholeLeafBodyNodes[e].leafBodyAttri.bodyFlag)},resetAllBodyFlag:function(){for(var e=!1,t=0,n=this.wholeLeafBodyNodes.length;t<n;++t)this.wholeLeafBodyNodes[t].leafBodyAttri&&null!=this.wholeLeafBodyNodes[t].leafBodyAttri.bodyFlagBackup&&(this.wholeLeafBodyNodes[t].leafBodyAttri.bodyFlag=this.wholeLeafBodyNodes[t].leafBodyAttri.bodyFlagBackup,e=!(this.wholeLeafBodyNodes[t].leafBodyAttri.bodyFlagBackup=void 0));e&&this.meshManager.resetGeomSameMaterialFlags()},backupEmptyBodyNodeVisibleState:function(){for(var e=0,t=this.emptyBodyNodes.length;e<t;++e)this.emptyBodyNodes[e].oldVisible=this.emptyBodyNodes[e].visible},resetEmptyBodyNodeVisibleState:function(){for(var e=0,t=this.emptyBodyNodes.length;e<t;++e)null!=this.emptyBodyNodes[e].oldVisible&&(this.emptyBodyNodes[e].visible=this.emptyBodyNodes[e].oldVisible)},requireContinueLoading:function(){return 0<this.geomManager.bufferChunksToLoad.length},hasEnoughAvailableMemory:function(){return 10485760<=this.geomManager.maxMemory-this.geomManager.usedMemory||this.geomManager.usedMemory<.9*this.geomManager.maxMemory},pageOut:function(){for(var e=this.getMeshSets(),t=0,n=0;n<e.length&&!this.hasEnoughAvailableMemory();++n)(o=e[n]).renderOnce&&o.removeGeometry(t);t=1;var i=this.getLineSegmentsSet();if(this.hasEnoughAvailableMemory()||i.removeGeometry(),!this.hasEnoughAvailableMemory()){for(var t=2,r=[],n=0;n<e.length;++n)(o=e[n]).visible&&o.dirty||r.push(n);this.sortMeshSets2(r);for(var o,a=0;a<r.length&&!this.hasEnoughAvailableMemory();++a)(o=e[r[a]]).removeGeometry(t)}},continueLoading:function(){this.geomManager.stopLoading=!1,this.geomManager.bufferChunksInLoading<=this.geomManager.maxBufferChunksInLoading&&this.geomManager.loadBufferChunk(this.geomManager.bufferChunksToLoad.shift())},setDrawMode:function(e){this.drawMode=e},getDrawModeFace:function(){return this.drawMode===this.SHADED_WITH_EDGES||this.drawMode===this.SHADED||this.drawMode===this.HIDDEN_LINE_REMOVE||this.drawMode===this.HIDDEN_LINE_VISIBLE||this.drawMode===this.TRANSPARENT},getDrawModeFaceColorMask:function(){return this.drawMode!==this.HIDDEN_LINE_REMOVE&&this.drawMode!==this.HIDDEN_LINE_VISIBLE},getDrawModeEdge:function(){return this.drawMode===this.SHADED_WITH_EDGES||this.drawMode===this.WIREFRAME||this.drawMode===this.HIDDEN_LINE_REMOVE||this.drawMode===this.HIDDEN_LINE_VISIBLE},getDrawModeHiddenEdge:function(){return this.drawMode===this.HIDDEN_LINE_VISIBLE},setOverrideMaterial:function(e,t,n){this.meshManager.overrideMaterial=e,this.meshManager.overrideMaterialCopy=t,this.meshManager.useBodyIdMaterial=n,this.referenceEntityDispManager.overrideMaterial=e,this.referenceEntityDispManager.overrideMaterialCopy=t,this.referenceEntityDispManager.useBodyIdMaterial=n,e?n&&(this.meshManager.supportInstancedArrays=!1):this.meshManager.supportInstancedArrays=this.meshManager.supportInstancedArraysCopy},attachBodyNode:function(e,t,n,i,r){if(r&&Object.assign(this.bodyNodeUUidToMaterial,r),!e)return this.viewer._CATIA&&t.referencename&&t.name&&t.oriName&&(t.name=t.oriName),this.setRootBodyNode(t,n,i),this.rootBodyNode;!e.propertyfile&&t.propertyfile&&(e.propertyfile=t.propertyfile,this.viewer.propertyManager.bindReference(e.uuid,t.referenceNode||t.uuid)),!e.pmiuuid&&t.pmiuuid&&(e.pmiuuid=t.pmiuuid),this.viewer._CATIA&&t.referencename&&(e.referencename=t.referencename),this.viewer._CATIA&&t.oriName&&(e.name=t.name);for(var o,a=0;a<t.children.length;a++)e.children.push(t.children[a]),t.children[a].parent=e;for(o in n)this.meshUuid2GeomUuidMap[o]=n[o];for(var s=0,l=this.geomManager.geoms.length;s<l;++s){var d=this.geomManager.geoms[s];i[d.uuid]&&(d.tangentEdgeObject=!0)}return this.viewer.CADViewer&&this.viewer.sketchIsSub&&this.viewer.sketchStartLoad&&(e.volume=t.volume,e.area=t.area),e.worldMatrix=this.calculateNodeWorldMatrix(e,e.worldMatrix),e},setRootBodyNode:function(e,t,n){if(this.rootBodyNode)if("assembly"==e.type.toLowerCase())this.rootBodyNode.children.push(e),e.parent=this.rootBodyNode;else for(var i=0;i<e.children.length;i++)this.rootBodyNode.children.push(e.children[i]),e.children[i].parent=this.rootBodyNode;else this.rootBodyNode=e;for(var r in this.rootBodyNode.ndsModel=this,t)this.meshUuid2GeomUuidMap[r]=t[r];for(var o=0,a=this.geomManager.geoms.length;o<a;++o){var s=this.geomManager.geoms[o];n[s.uuid]&&(s.tangentEdgeObject=!0)}},setBodyNodeMaterials:function(e){for(var t in Object.assign(this.bodyNodeUUidToMaterial,e),this.bodyNodeUUidToMaterial){var n=this.getBodyNodeFromUuid(t),t=this.bodyNodeUUidToMaterial[t];n&&t&&(n.useBodyNodeMaterial=!0)}this.meshManager.resetGeomSameMaterialFlags()},getBodyNodeUUidToMaterial:function(){return this.bodyNodeUUidToMaterial},setBodyNodeMaterialsInfo:function(e){if(e){var t,n={};for(t in n){var i=n[t],i=this.viewer.materialsSetting.jsonToMaterial(i);i&&(n[t]=i)}this.setBodyNodeMaterials(n)}},setBodyNodeMaterial:function(e,t){e=this.getBodyNodeFromUuid(e);this.bodyNodeUUidToMaterial[e.uuid]=t,e.useBodyNodeMaterial=!0,this.meshManager.setGeomSameMaterialFlag(e)},removeAllBodyNodeMaterials:function(){for(var e in this.bodyNodeUUidToMaterial){var t=this.getBodyNodeFromUuid(e);t&&this.bodyNodeUUidToMaterial[e]&&(t.useBodyNodeMaterial=!1)}this.bodyNodeUUidToMaterial={},this.meshManager.resetGeomSameMaterialFlags()},removeBodyNodeMaterial:function(e){var t=this.getBodyNodeFromUuid(e);t&&this.bodyNodeUUidToMaterial[e]&&(delete this.bodyNodeUUidToMaterial[e],t.useBodyNodeMaterial=!1,this.meshManager.setGeomSameMaterialFlag(t))},getBodyNode:function(e){for(var t=0,n=this.wholeLeafBodyNodes.length;t<n;t++)if(this.wholeLeafBodyNodes[t].id==e)return this.wholeLeafBodyNodes[t];for(t=0,n=this.wholeRefEntityNodes.length;t<n;t++)if(this.wholeRefEntityNodes[t].id==e)return this.wholeRefEntityNodes[t];for(t=0,n=this.wholeCoordinateNodes.length;t<n;t++)if(this.wholeCoordinateNodes[t].id==e)return this.wholeCoordinateNodes[t];return null},getBodyNodeFromUuid:function(e){return this.bodyUuid2NodeMap[e]},getSelectedLeafBodyNodes:function(e){for(var t=[],n=this.getLeafBodies(e),i=0,r=n.length;i<r;i++)n[i].leafBodyAttri&&n[i].isSelected()&&t.push(n[i]);return t},getLeafBodies:function(e){var t=[];if(0==e.children.length)0<=e.id&&!e.isReferenceEntity()&&!e.isCoordinate()&&!e.isOtherNode()&&e._leafBodyAttri&&(0<e._leafBodyAttri._bodyMeshIds.length||0<e._leafBodyAttri.bodyLineSegIds.length||0<e._leafBodyAttri.bodyTextIds.length)&&t.push(e);else for(var n=[e],i=0;i<n.length;++i)if(0==n[i].children.length)0<=n[i].id&&!n[i].isReferenceEntity()&&!n[i].isCoordinate()&&!n[i].isOtherNode()&&n[i]._leafBodyAttri&&(0<n[i]._leafBodyAttri._bodyMeshIds.length||0<n[i]._leafBodyAttri.bodyLineSegIds.length||0<n[i]._leafBodyAttri.bodyTextIds.length)&&t.push(n[i]);else for(var r=0,o=n[i].children.length;r<o;++r)n.push(n[i].children[r]);return t},getPartBodies:function(e){for(var t=[],n=[e],i=0;i<n.length;++i)if("Part"==n[i].type&&0<n[i].children.length&&"Body"==n[i].children[0].type)t.push(n[i]);else if(0<n[i].children.length)for(var r=0,o=n[i].children.length;r<o;++r)n.push(n[i].children[r]);return t},getLeafPMIuuid:function(e){var t=[];if(e.pmiuuid&&(t=t.concat(e.pmiuuid)),0<e.children.length)for(var n=[e],i=0;i<n.length;++i)if(n[i].pmiuuid&&0!=i&&(t=t.concat(n[i].pmiuuid)),0<n[i].children.length)for(var r=0,o=n[i].children.length;r<o;++r)n.push(n[i].children[r]);return t},getLayerBodies:function(e){var t=[];if("AcDbLayerTableRecord"===e.type)t.push(e);else for(var n=[e],i=0;i<n.length;++i)if("AcDbLayerTableRecord"===n[i].type)t.push(n[i]);else for(var r=0,o=n[i].children.length;r<o;++r)n.push(n[i].children[r]);return t},getLeafReferenceEntities:function(e){var t=[];if(0==e.children.length)e.isReferenceEntity()&&t.push(e);else for(var n=[e],i=0;i<n.length;++i)if(0==n[i].children.length)n[i].isReferenceEntity()&&t.push(n[i]);else for(var r=0,o=n[i].children.length;r<o;++r)n.push(n[i].children[r]);return t},getLeafCoordinate:function(e){var t=[];if(0==e.children.length)e.isCoordinate()&&t.push(e);else for(var n=[e],i=0;i<n.length;++i)if(0==n[i].children.length)n[i].isCoordinate()&&t.push(n[i]);else for(var r=0,o=n[i].children.length;r<o;++r)n.push(n[i].children[r]);return t},getAllLeafNodes:function(e){var t=[];if(0==e.children.length)t.push(e);else for(var n=[e],i=0;i<n.length;++i)if(0==n[i].children.length)t.push(n[i]);else for(var r=0,o=n[i].children.length;r<o;++r)n.push(n[i].children[r]);return t},updateSubSketchNodeMatrix:function(e){for(var e=this.bodyUuid2NodeMap[e],t=this.getLeafBodies(e),n=0,i=t.length;n<i;n++)if(t[n].worldMatrix=this.calculateNodeWorldMatrix(t[n]),t[n].leafBodyAttri){var r=t[n].leafBodyAttri.bodyMeshIds;if(0<r.length){for(var o=new THREE.Box3,a=null,s=0,l=r.length;s<l;++s){var d=r[s];-1<this.meshManager.geomId[d]&&(this.geomManager.getGeomFromId(this.meshManager.geomId[d]).updateModelMatrix=!0,this.meshManager.updateMeshBBox(d)),this.meshManager.getMeshBBox(d,o),this.bvhCreater&&this.bvhCreater.m_boxes[d].SetMinMaxPointFromArray([o.min.x,o.min.y,o.min.z,o.max.x,o.max.y,o.max.z]),0==s?a=o.clone():a.union(o)}a&&(t[n].leafBodyAttri.bodyBbox[0]=a.min.x,t[n].leafBodyAttri.bodyBbox[1]=a.min.y,t[n].leafBodyAttri.bodyBbox[2]=a.min.z,t[n].leafBodyAttri.bodyBbox[3]=a.max.x,t[n].leafBodyAttri.bodyBbox[4]=a.max.y,t[n].leafBodyAttri.bodyBbox[5]=a.max.z)}else this.calculateLineBodyBoundingBox(t[n])}},updateNodeMatrix:(_t=new THREE.Matrix4,Vt=new THREE.Matrix4,kt=new THREE.Matrix4,Ut=new THREE.Vector3,function(e,t){var n=this.bodyUuid2NodeMap[e];if(n){!n.originalPosition&&(n.originalPosition=new THREE.Vector3,i=this.viewer.ndsModel.getBodyBoundingBox(n))&&n.originalPosition.copy(i.getCenter(Ut)),n.worldMatrix=this.calculateNodeWorldMatrix(n),_t.copy(n.worldMatrix),n.matrix=t.slice(0),n.worldMatrix=this.calculateNodeWorldMatrix(n),Vt.copy(n.worldMatrix);for(var i,r=this.getLeafBodies(n),o=Vt.transpose().premultiply(kt.getInverse(_t.transpose())).transpose(),a=0,s=r.length;a<s;a++)r[a].worldMatrix=this.calculateNodeWorldMatrix(r[a]);for(a=0,s=r.length;a<s;a++)if(r[a]._leafBodyAttri){var l=r[a]._leafBodyAttri._bodyMeshIds;if(0<l.length){for(var d=new THREE.Box3,c=null,h=0,u=l.length;h<u;++h){var p=l[h];-1<this.meshManager.geomId[p]&&(this.geomManager.getGeomFromId(this.meshManager.geomId[p]).updateModelMatrix=!0,this.meshManager.updateMeshBBox(p)),this.meshManager.getMeshBBox(p,d),this.bvhCreater&&this.bvhCreater.m_boxes[p].SetMinMaxPointFromArray([d.min.x,d.min.y,d.min.z,d.max.x,d.max.y,d.max.z]),0==h?c=d.clone():c.union(d)}c&&(r[a]._leafBodyAttri._bodyBbox[0]=c.min.x,r[a]._leafBodyAttri._bodyBbox[1]=c.min.y,r[a]._leafBodyAttri._bodyBbox[2]=c.min.z,r[a]._leafBodyAttri._bodyBbox[3]=c.max.x,r[a]._leafBodyAttri._bodyBbox[4]=c.max.y,r[a]._leafBodyAttri._bodyBbox[5]=c.max.z,r[a]._leafBodyAttri.totalBbox)&&(r[a]._leafBodyAttri.totalBbox=null);var f=this.viewer.controls.getBoundingBox();f.containsBox(c)||(f.union(c),this.viewer.controls.setBoundingBox(f.min,f.max),this.viewer.cameraControl.adjustNearAndFar()),this.viewer.controls.staticAnnotation&&this.viewer.controls.staticAnnotation.useOffsetMatrix&&this.viewer.controls.staticAnnotation.updateTextPos(r[a].uuid,o)}else this.calculateLineBodyBoundingBox(r[a]);this.viewer.annotationsManager&&this.viewer.annotationsManager.updateAnnotaion(r[a].uuid,o)}var m=this.getLeafPMIuuid(n);if(this.viewer.pmiObject&&this.viewer.pmiObject.children[0].version){for(var g=0;g<m.length;g++){var v=m[g];if(this.viewer.pmiObject){var A=this.viewer.PMIUUIDtoPMIObject[v];if(A){A.matrixWorld.premultiply(o),A.originMatrixWorld.copy(A.matrixWorld),A.updateMatrixWorld(!0),A.matrixAutoUpdate=!1;for(var y=0;y<A.children.length;y++){var E=A.children[y];E.originMatrixWorld.copy(E.matrixWorld)}}}}this.OrientationPMI(),this.viewer.pmiObject.box3=null,this.viewer.calculatePMIBoundingBox()}for(var M=this.getLeafReferenceEntities(n),a=0,s=M.length;a<s;a++)M[a].worldMatrix=this.calculateNodeWorldMatrix(M[a]),M[a].leafBodyAttri&&(M[a].leafBodyAttri.bbox.setFromArray(M[a].leafBodyAttri.coords),M[a].leafBodyAttri.bbox.applyMatrix4(M[a].worldMatrix),"RefPlane"==M[a].type?this.referenceEntityDispManager.needUpdateRefPlaneVertexBuffer=!0:"RefAxis"==M[a].type&&(this.referenceEntityDispManager.needUpdateRefAxisVertexBuffer=!0));for(var w=this.getLeafCoordinate(n),a=0,s=w.length;a<s;a++)w[a].worldMatrix=this.calculateNodeWorldMatrix(w[a]);this.viewer.ScenarioEditorInfo.nodeMatrix[e]=t}}),calculateNodeWorldMatrix:(jt=new THREE.Matrix4,function(e,t){var n=e,i=[];for(i.push(n);n.parent;)n=n.parent,i.push(n);t&&t.identity();for(var r=t||new THREE.Matrix4,o=i.length-1;0<=o;o--)null!=i[o].matrix&&(jt.fromArray(i[o].matrix),r.multiply(jt));return r}),calculateNodeWorldMatrix4D:(Nt=new THREE.Matrix4D,function(e,t){var n=e,i=[];for(i.push(n);n.parent;)n=n.parent,i.push(n);t&&t.identity();for(var r=t||new THREE.Matrix4D,o=i.length-1;0<=o;o--)null!=i[o].matrix&&(Nt.fromArray(i[o].matrix),r.multiply(Nt));return r}),intersectPolytope:function(e){var t=this.sptIndex.intersect(e);if(!t||0===t.length)return null;for(var n=[],i=0,r=0,i=0,r=t.length;i<r;++i){var o=t[i];this.meshSets[o].intersect(e,n)}var a=[],s=[];for(i=0,r=n.length;i<r;++i){var l,o=n[i];(l=this.meshManager.intersectPolytope(o,e))&&!s.includes(l.bodyUuid)&&(a.push(l),s.push(l.bodyUuid))}return a},intersect:function(e,t,n){void 0===n&&(n=!1);var i=this.intersectReferenceEntity(e,t);if(i&&"RefAxis"==i.bodyNode.type)return[i];var r=[];if(0<t){for(d=0,c=this.lineSegmentsSet.getNumLineSegments();d<c;++d){var o,a=d;(o=this.meshManager.intersectLineSegments(a,e,1/0,t,this.is2DModel))&&this.meshManager.getLineSegments(o.lineSegId)&&r.push(o)}if(0<r.length){for(var s=0,l=r[0].distance,d=1,c=r.length;d<c;++d)r[d].distance<l&&(l=r[d].distance,s=d);r[s].bodyNode=this.bodyUuid2NodeMap[r[s].bodyUuid],r[s].object=r[s].bodyNode,0!==s&&(r[0]=r[s]),r.length=1}}if(!this.is2DModel||0==r.length){var h=this.sptIndex.intersect(e);if((!h||0===h.length)&&i)return[i];var u=[],d=0,c=0;for(d=0,c=h.length;d<c;++d){a=h[d];this.meshSets[a].intersect(e,u)}var p,f=[];if(n){for(d=0,c=u.length;d<c;++d){var a=u[d],m=this.meshManager.intersectall(a,e,this.is2DModel);0<m.length&&(f=f.concat(m))}return(f.sort(function(e,t){return e.distance-t.distance}),0==f.length)?[]:(p=f[0].meshId,f.filter(function(e){return e.meshId===p}))}for(d=0,c=u.length;d<c;++d){var g,a=u[d];if((g=this.meshManager.intersect(a,e,this.is2DModel))&&f.push(g),this.is2DModel)break}if(0<f.length){var v=0,A=f[0].distance;for(d=1,c=f.length;d<c;++d)f[d].distance<A&&(A=f[d].distance,v=d);f[v].bodyNode=this.bodyUuid2NodeMap[f[v].bodyUuid],f[v].object=f[v].bodyNode,0!==v&&(f[0]=f[v]),f.length=1}!this.is2DModel&&0<f.length&&0<r.length&&r[0].distance>f[0].distance+2*t&&(r.length=0)}return 0<r.length?[r[0]]:0<f.length?[f[0]]:i?[i]:null},intersectReferenceEntity:function(e,t){var n=new THREE.Matrix4,i=new THREE.Ray,r=new THREE.Vector3,o=new THREE.Vector3,a=new THREE.Vector3,s=new THREE.Vector3,l=new THREE.Vector3,d=new THREE.Vector3,c=new THREE.Vector3,h=null,u=null;if(0<t)for(var p=t*t,f=0,m=this.wholeRefEntityNodes.length;f<m;++f)(g=this.wholeRefEntityNodes[f]).isHidden()||"RefAxis"==g.type&&(A=g.worldMatrix,v=g.leafBodyAttri.coords,r.fromArray(v,0),o.fromArray(v,3),r.applyMatrix4(A),o.applyMatrix4(A),e.distanceSqToSegment(r,o,c,d)<p)&&(y=e.origin.distanceTo(c),null==h?((h={}).distance=y,h.point=d.clone(),h.bodyNode=g,h.bodyUuid=g.uuid):y<h.distance&&(h.distance=y,h.point=d.clone(),h.bodyNode=g,h.bodyUuid=g.uuid));if(null==h)for(var g,v,A,y,f=0,m=this.wholeRefEntityNodes.length;f<m;++f)(g=this.wholeRefEntityNodes[f]).isHidden()||"RefPlane"==g.type&&e.intersectsBox(g.leafBodyAttri.bbox)&&(v=g.leafBodyAttri.coords,A=g.worldMatrix,n.getInverse(A),i.copy(e).applyMatrix4(n),r.fromArray(v,0),o.fromArray(v,3),a.fromArray(v,6),s.fromArray(v,9),i.intersectTriangle(r,o,a,!1,l)||i.intersectTriangle(a,s,r,!1,l))&&(l.applyMatrix4(A),y=e.origin.distanceTo(l),null==u?((u={}).distance=y,u.point=l.clone(),u.bodyNode=g,u.bodyUuid=g.uuid):y<u.distance&&(u.distance=y,u.point=l.clone(),u.bodyNode=g,u.bodyUuid=g.uuid));return h||u},setExplodeFactor:function(e,t){if(this.explodeFactor=0,this.explodeFactorX=0,this.explodeFactorY=0,this.explodeFactorZ=0,this.explodeMode&ve.EXPLODEMODE.NORMAL?this.explodeFactor=t:this.explodeMode&ve.EXPLODEMODE.X?this.explodeFactorX=t:this.explodeMode&ve.EXPLODEMODE.Y?this.explodeFactorY=t:this.explodeMode&ve.EXPLODEMODE.Z&&(this.explodeFactorZ=t),0==(this.explodeMode&ve.EXPLODEMODE.LEVEL)&&0==(this.explodeMode&ve.EXPLODEMODE.SELECTED))for(var n=this.wholeLeafBodyNodes.length,i=new THREE.Box3,r=0;r<n;++r){var o=this.wholeLeafBodyNodes[r].leafBodyAttri;o&&(i.min.fromArray(o.bodyBbox,0),i.max.fromArray(o.bodyBbox,3),_e.HideLeafBody&&(i=this.getBodyBoundingBox(this.wholeLeafBodyNodes[r].parent)),o.bodyTranslate[0]=.5*(i.min.x+i.max.x)-e.x,o.bodyTranslate[1]=.5*(i.min.y+i.max.y)-e.y,o.bodyTranslate[2]=.5*(i.min.z+i.max.z)-e.z)}for(var a=0,s=this.geomManager.geoms.length;a<s;++a)this.geomManager.geoms[a].updateModelMatrix=!0},getExplodeTranslate:function(e,t){var n=[0,0,0];return 0<e&&(t=t.leafBodyAttri)&&(n[0]+=e*t.bodyTranslate[0],n[1]+=e*t.bodyTranslate[1],n[2]+=e*t.bodyTranslate[2]),n},getBodyTranslate:function(e){var t,n=this,i=[0,0,0];return(e=_e.HideLeafBody&&(t=e.parent.FirstVisibleNode||0,e.parent.children[t].uuid!=e.uuid)?e.parent.children[t]:e).leafBodyAttri&&(t=function(e){return n.viewer.ndsModel.objectidTouuid?-1!=n.viewer.explodeObjects.indexOf(e.objectid):-1!=n.viewer.explodeObjects.indexOf(e.id)},this.explodeMode&ve.EXPLODEMODE.NORMAL&&(this.explodeMode&ve.EXPLODEMODE.SELECTED&&t(e)||0==(this.explodeMode&ve.EXPLODEMODE.SELECTED))&&(i[0]+=this.explodeFactor*e.leafBodyAttri.bodyTranslate[0],i[1]+=this.explodeFactor*e.leafBodyAttri.bodyTranslate[1],i[2]+=this.explodeFactor*e.leafBodyAttri.bodyTranslate[2]),this.explodeMode&ve.EXPLODEMODE.X&&(this.explodeMode&ve.EXPLODEMODE.SELECTED&&t(e)||0==(this.explodeMode&ve.EXPLODEMODE.SELECTED))&&(i[0]+=this.explodeFactorX*e.leafBodyAttri.bodyTranslate[0]),this.explodeMode&ve.EXPLODEMODE.Y&&(this.explodeMode&ve.EXPLODEMODE.SELECTED&&t(e)||0==(this.explodeMode&ve.EXPLODEMODE.SELECTED))&&(i[1]+=this.explodeFactorY*e.leafBodyAttri.bodyTranslate[1]),this.explodeMode&ve.EXPLODEMODE.Z&&(this.explodeMode&ve.EXPLODEMODE.SELECTED&&t(e)||0==(this.explodeMode&ve.EXPLODEMODE.SELECTED))&&(i[2]+=this.explodeFactorZ*e.leafBodyAttri.bodyTranslate[2]),this.hasDraggedBodies())&&e.isDragged()&&(i[0]+=e.leafBodyAttri.bodyDragTranslate[0],i[1]+=e.leafBodyAttri.bodyDragTranslate[1],i[2]+=e.leafBodyAttri.bodyDragTranslate[2]),i},getBodyTranslateWithoutExplode:function(e){var t=[0,0,0];return this.hasDraggedBodies()&&e.isDragged()&&(t[0]=e.leafBodyAttri.bodyDragTranslate[0],t[1]=e.leafBodyAttri.bodyDragTranslate[1],t[2]=e.leafBodyAttri.bodyDragTranslate[2]),t},getBodyTransform:(Ft=new THREE.Matrix4,function(e){var t=this.getBodyTranslate(e);return e.matrix?Ft.fromArray(e.matrix):Ft.makeTranslation(0,0,0),Ft.elements[12]+=t[0],Ft.elements[13]+=t[1],Ft.elements[14]+=t[2],Ft}),getLeafBodyBoundingBox:function(e){var t=new THREE.Box3,e=(t.min.fromArray(e.leafBodyAttri.bodyBbox,0),t.max.fromArray(e.leafBodyAttri.bodyBbox,3),this.getBodyTranslate(e));return t.min.x+=e[0],t.min.y+=e[1],t.min.z+=e[2],t.max.x+=e[0],t.max.y+=e[1],t.max.z+=e[2],t},getLeafBodyBoundingBoxTrue:function(e){var t=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],n=new THREE.Box3;if(0<e.leafBodyAttri.bodyMeshIds.length){for(var i=0;i<e.leafBodyAttri.bodyMeshIds.length;++i){var r=e.leafBodyAttri.bodyMeshIds[i],r=this.sptIndex.meshManager.geomId[r],r=this.sptIndex.meshManager.geomManager.getGeomFromId(r).boundingBox;r&&e.worldMatrix&&(n.expandByPoint(r.max),n.expandByPoint(r.min))}t[0].set(n.min.x,n.min.y,n.min.z).applyMatrix4(e.worldMatrix),t[1].set(n.min.x,n.min.y,n.max.z).applyMatrix4(e.worldMatrix),t[2].set(n.min.x,n.max.y,n.min.z).applyMatrix4(e.worldMatrix),t[3].set(n.min.x,n.max.y,n.max.z).applyMatrix4(e.worldMatrix),t[4].set(n.max.x,n.min.y,n.min.z).applyMatrix4(e.worldMatrix),t[5].set(n.max.x,n.min.y,n.max.z).applyMatrix4(e.worldMatrix),t[6].set(n.max.x,n.max.y,n.min.z).applyMatrix4(e.worldMatrix),t[7].set(n.max.x,n.max.y,n.max.z).applyMatrix4(e.worldMatrix);var o=this.getBodyTranslate(e),o=(new THREE.Vector3).fromArray(o);return t[0].add(o),t[1].add(o),t[2].add(o),t[3].add(o),t[4].add(o),t[5].add(o),t[6].add(o),t[7].add(o),t}return null},calculateMeshBodyBoundingBox:function(e){if(e.leafBodyAttri){var t=e.leafBodyAttri.bodyMeshIds;if(0<t.length){for(var n=new THREE.Box3,i=null,r=0,o=t.length;r<o;r++){var a=t[r];this.meshManager.updateMeshBBox(a),this.meshManager.getMeshBBox(a,n),0==j?i=n.clone():i.union(n)}if(i)return e.leafBodyAttri.bodyBbox[0]=i.min.x,e.leafBodyAttri.bodyBbox[1]=i.min.y,e.leafBodyAttri.bodyBbox[2]=i.min.z,e.leafBodyAttri.bodyBbox[3]=i.max.x,e.leafBodyAttri.bodyBbox[4]=i.max.y,e.leafBodyAttri.bodyBbox[5]=i.max.z,!0}}return!1},calculateLineBodyBoundingBox:function(e){if(e._leafBodyAttri){var t=e._leafBodyAttri._bodyMeshIds,n=e._leafBodyAttri.bodyLineSegIds;if(0==t.length&&0<n.length){for(var i=null,r=0;r<n.length;r++){var o=this.meshManager.lineSegGeomId[n[r]],o=this.geomManager.getGeomFromId(o);o&&o.boundingBox&&!o.boundingBox.isEmpty()&&(i?i.union(o.boundingBox):i=o.boundingBox.clone())}if(i&&!i.isEmpty())return i.applyMatrix4(e.worldMatrix),e._leafBodyAttri._bodyBbox[0]=i.min.x,e._leafBodyAttri._bodyBbox[1]=i.min.y,e._leafBodyAttri._bodyBbox[2]=i.min.z,e._leafBodyAttri._bodyBbox[3]=i.max.x,e._leafBodyAttri._bodyBbox[4]=i.max.y,e._leafBodyAttri._bodyBbox[5]=i.max.z,e._leafBodyAttri.totalBbox&&(e._leafBodyAttri.totalBbox=null),!0}}return!1},getVisibleBodyBoundingBox:function(e,t){for(var n=this.getLeafBodies(e),i=null,r=0,o=n.length;r<o;++r){var a=n[r];t&&!a.visible||a.leafBodyAttri&&(a=this.getLeafBodyBoundingBox(a))&&(i||a.isEmpty()||isNaN(a.max.x)||isNaN(a.min.x)?a.isEmpty()||isNaN(a.max.x)||isNaN(a.min.x)||(i.expandByPoint(a.min),i.expandByPoint(a.max)):i=a.clone())}return i},getBodyBoundingBox:function(e){for(var t=this.getLeafBodies(e),n=null,i=0,r=t.length;i<r;++i){var o=t[i];if(_e.HideLeafBody||o.leafBodyAttri&&(this.viewer.is2DModel||0!=o.leafBodyAttri.bodyMeshIds.length)){if(_e.HideLeafBody){if(o.unload)continue;var a=o.parent.FirstVisibleNode||0;o.parent.children[a].uuid!=o.uuid&&(o=o.parent.children[a])}a=this.getLeafBodyBoundingBox(o);a&&(n||a.isEmpty()||isNaN(a.max.x)||isNaN(a.min.x)?a.isEmpty()||isNaN(a.max.x)||isNaN(a.min.x)||(n.expandByPoint(a.min),n.expandByPoint(a.max)):n=a.clone())}}return n},getBodyBoundingBoxTrue:function(e){var t;if((e=_e.HideLeafBody&&(t=e.parent.FirstVisibleNode||0,e.parent.children[t].uuid!=e.uuid)?e.parent.children[t]:e).leafBodyAttri)return this.getLeafBodyBoundingBoxTrue(e)},RemoveElement:function(e,t){for(var n=1;-1<n;)-1<(n=e.indexOf(t))&&e.splice(n,1)},hasDraggedBodies:function(){return 0<this.draggedBodies.length},dragBody:function(e,t){for(var n=this.getLeafBodies(e),i=0,r=n.length;i<r;++i){var o=n[i];if(o.leafBodyAttri){if(o.isDragged()||(o.setDragged(!0),this.draggedBodies.push(o)),o.leafBodyAttri.bodyDragTranslate[0]+=t.x,o.leafBodyAttri.bodyDragTranslate[1]+=t.y,o.leafBodyAttri.bodyDragTranslate[2]+=t.z,o.pmiuuid&&this.viewer.pmiObject)for(var a=0;a<o.pmiuuid.length;++a){var s=o.pmiuuid[a],s=this.viewer.pmiObject.getObjectByProperty("uuid",s);s&&(s.matrixWorld.copy(s.originMatrixWorld),(s=s.matrixWorld.elements)[12]+=o.leafBodyAttri.bodyDragTranslate[0],s[13]+=o.leafBodyAttri.bodyDragTranslate[1],s[14]+=o.leafBodyAttri.bodyDragTranslate[2])}this.meshManager.setGeomSameMaterialFlag(o)}}},restoreDraggedBody:function(e){for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n){var r=t[n];if(r.leafBodyAttri&&r.isDragged()){r.setDragged(!1),r.leafBodyAttri.bodyDragTranslate[0]=0,r.leafBodyAttri.bodyDragTranslate[1]=0,r.leafBodyAttri.bodyDragTranslate[2]=0;var o=this.draggedBodies.indexOf(r);if(-1<o&&this.draggedBodies.splice(o,1),r.pmiuuid&&this.viewer.pmiObject)for(var a=0;a<r.pmiuuid.length;++a){var s=r.pmiuuid[a],s=this.viewer.pmiObject.getObjectByProperty("uuid",s);s&&s.matrixWorld.copy(s.originMatrixWorld)}this.meshManager.setGeomSameMaterialFlag(r)}}},changeBodyOpactiy:function(e,i){var r=this,o=this.getLeafBodies(e),t=o.length;if(0<t)if(null!=i){for(var a,s,l=new Map,d=0;d<t;++d)(function(){var e=o[d].getUserMaterial();if(o[d].isTransparent()||(o[d].transparent(),r.transparentBodies.push(o[d]),r.transparentBodyChanged=!0),e)Array.isArray(i)?e.opacities=i:(e.opacity=i,e.opacities=null),o[d].setUserMaterial(e),r.meshManager.setGeomSameMaterialFlag(o[d]),e.transparent=1!=i,e.transmission=0;else{a=o[d].leafBodyAttri.bodyMeshIds,s=r.meshManager.materialId[a[0]];var e=r.meshManager.mats[s],n=[];if(a.forEach(function(e){var t=r.viewer.ndsModel.meshManager.materialId[e],t=r.viewer.ndsModel.meshManager.mats[t];t&&(t=t.color.clone(),n.push({meshId:e,value:t}))}),!e)return;if(l.has(e.uuid))o[d].setUserMaterial(l.get(e.uuid));else{var t=e;if(t.opacity==i)return t.opacities=null,l.set(e.uuid,t);t=e.clone(),Array.isArray(i)?t.opacities=i:(t.opacity=i,t.opacities=null),l.set(e.uuid,t),t.transparent=1!=i,t.colors=n,o[d].setUserMaterial(t)}r.meshManager.setGeomSameMaterialFlag(o[d])}})();l.clear()}else for(d=0;d<t;++d)o[d].setUserMaterial(null),this.meshManager.setGeomSameMaterialFlag(o[d])},changeBodyColor:function(e,i,t){var r=this,o=this.getLeafBodies(e),n=o.length;if(0<n)if(i)if(t)for(var a,s=0;s<n;++s)o[s].leafBodyAttri&&(l=o[s].leafBodyAttri.bodyMeshIds,d=this.meshManager.materialId[l[0]],(a=this.meshManager.mats[d])&&!(a=a.clone()).color.equals(i)&&(a.color.setHex(i),o[s].setUserMaterial(a),this.meshManager.setGeomSameMaterialFlag(o[s]),16777215<(i+=1000335))&&(i-=16777215));else for(var l,d,s=0;s<n;++s)(function(){var e,n,t;o[s].leafBodyAttri&&((e=o[s].getUserMaterial())?(Array.isArray(i)?e.colors=i:(e.color.setHex(i),e.colors=null,e.backMaterial&&e.backMaterial.color&&e.backMaterial.color.setHex(i)),o[s].setUserMaterial(e),r.meshManager.setGeomSameMaterialFlag(o[s])):(l=o[s].leafBodyAttri.bodyMeshIds,d=r.meshManager.materialId[l[0]],(e=r.meshManager.mats[d])&&(n=[],l.forEach(function(e){var t=r.viewer.ndsModel.meshManager.materialId[e],t=r.viewer.ndsModel.meshManager.mats[t];t&&(t=t.opacity,n.push({meshId:e,value:t}))}),(t=e).color.equals(i)?t.colors=null:(t=e.clone(),Array.isArray(i)?t.colors=i:(t.color.setHex(i),t.colors=null),t.opacities=n,o[s].setUserMaterial(t),r.meshManager.setGeomSameMaterialFlag(o[s])))))})();else for(s=0;s<n;++s)o[s].setUserMaterial(null),this.meshManager.setGeomSameMaterialFlag(o[s])},hasTransparentBodies:function(){return 0<this.transparentBodies.length||0<this.transparentizedBodies.length},transparentBody:function(e,t,n){t=t||_e.bodyOpacity,n=n||_e.lineOpacity;for(var i=this.getLeafBodies(e),r=0,o=i.length;r<o;++r){var a=i[r];a.leafBodyAttri&&(a.transparent(),a.leafBodyAttri.bodyOpacity=t,this.transparentModeBodiesMap.set(a.uuid,!0),this.transparentizedBodies.push(a),this.transparentBodyChanged=!0,this.meshManager.setGeomSameMaterialFlag(a))}if(!this.meshManager.lineSegMaterial){for(var s in this.meshManager.materials)if("LineBasicMaterial"===this.meshManager.materials[s].mat.type){this.meshManager.lineSegMaterial=this.meshManager.materials[s].mat;break}this.meshManager.lineSegMaterial||(this.meshManager.lineSegMaterial=new THREE.LineBasicMaterial({color:0,linewidth:1}))}this.meshManager.lineSegMaterialCopy||(this.meshManager.lineSegMaterialCopy=this.meshManager.lineSegMaterial.clone(),this.meshManager.lineSegMaterialCopy.uuid=this.meshManager.lineSegMaterial.uuid,this.meshManager.lineSegMaterialCopy.program=this.meshManager.lineSegMaterial.program,this.meshManager.lineSegMaterialCopy.needsUpdate=this.meshManager.lineSegMaterial.needsUpdate,this.meshManager.lineSegMaterialCopy.opacity=null!=n?n:t,this.meshManager.lineSegMaterialCopy.transparent=!0)},opaqueBody:function(e){for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n){var r,o=t[n];o.leafBodyAttri&&o.isTransparent()&&(o.opaque(),-(o.leafBodyAttri.bodyOpacity=1)<(r=this.transparentizedBodies.indexOf(o)))&&(this.transparentModeBodiesMap.delete(o.uuid),this.transparentizedBodies.splice(r,1),this.transparentBodyChanged=!0)}this.meshManager.resetGeomSameMaterialFlags()},transparentizeBodies:function(e){if(e&&e.length){this.transparentizedBodies=[];for(var t=0;t<e.length;++t){var n=this.getLeafBodies(e[t]);if(n&&0<n.length)for(var i=0,r=n.length;i<r;++i){var o=n[i];this.transparentModeBodiesMap.set(o.uuid,!0),o.isTransparent()||(o.transparent(),o.deIsolate(),this.transparentizedBodies.push(o),this.transparentBodyChanged=!0)}}for(t=0;t<this.wholeLeafBodyNodes.length;++t){var a=this.wholeLeafBodyNodes[t];a.isTransparent()||a.isolate()}if(this.meshManager.resetGeomSameMaterialFlags(),!this.meshManager.matsCopy||0===this.meshManager.matsCopy.length)for(i=0,r=this.meshManager.mats.length;i<r;++i)this.meshManager.mats[i]&&(this.meshManager.matsCopy[i]=this.meshManager.mats[i].clone(),this.meshManager.matsCopy[i].uuid=this.meshManager.mats[i].uuid,this.meshManager.matsCopy[i].program=this.meshManager.mats[i].program,this.meshManager.matsCopy[i].needsUpdate=this.meshManager.mats[i].needsUpdate,this.meshManager.matsCopy[i].opacity=_e.bodyOpacity,this.meshManager.matsCopy[i].transparent=!0);if(!this.meshManager.lineSegMaterial){for(var s in this.meshManager.materials)if("LineBasicMaterial"===this.meshManager.materials[s].mat.type){this.meshManager.lineSegMaterial=this.meshManager.materials[s].mat;break}this.meshManager.lineSegMaterial||(this.meshManager.lineSegMaterial=new THREE.LineBasicMaterial({color:0,linewidth:1}))}this.meshManager.lineSegMaterialCopy||(this.meshManager.lineSegMaterialCopy=this.meshManager.lineSegMaterial.clone(),this.meshManager.lineSegMaterialCopy.uuid=this.meshManager.lineSegMaterial.uuid,this.meshManager.lineSegMaterialCopy.program=this.meshManager.lineSegMaterial.program,this.meshManager.lineSegMaterialCopy.needsUpdate=this.meshManager.lineSegMaterial.needsUpdate,this.meshManager.lineSegMaterialCopy.opacity=_e.lineOpacity,this.meshManager.lineSegMaterialCopy.transparent=!0)}},transparentizeBodiesOnly:function(e,t){for(var n=0;n<e.length;++n){var i=this.getLeafBodies(e[n]);if(i&&0<i.length)for(var r=0,o=i.length;r<o;++r){var a=i[r];a.isTransparent()||(a.transparent(),a.deIsolate(),this.transparentModeBodiesMap.set(a.uuid,!0),this.transparentizedBodies.push(a),this.transparentBodyChanged=!0)}}if(this.meshManager.resetGeomSameMaterialFlags(),!this.meshManager.matsCopy||0===this.meshManager.matsCopy.length)for(r=0,o=this.meshManager.mats.length;r<o;++r)this.meshManager.mats[r]&&(this.meshManager.matsCopy[r]=this.meshManager.mats[r].clone(),this.meshManager.matsCopy[r].uuid=this.meshManager.mats[r].uuid,this.meshManager.matsCopy[r].program=this.meshManager.mats[r].program,this.meshManager.matsCopy[r].needsUpdate=this.meshManager.mats[r].needsUpdate,this.meshManager.matsCopy[r].opacity=_e.bodyOpacity,this.meshManager.matsCopy[r].transparent=!0);if(!this.meshManager.lineSegMaterial){for(var s in this.meshManager.materials)if("LineBasicMaterial"===this.meshManager.materials[s].mat.type){this.meshManager.lineSegMaterial=this.meshManager.materials[s].mat;break}this.meshManager.lineSegMaterial||(this.meshManager.lineSegMaterial=new THREE.LineBasicMaterial({color:0,linewidth:1}))}this.meshManager.lineSegMaterialCopy||(this.meshManager.lineSegMaterialCopy=this.meshManager.lineSegMaterial.clone(),this.meshManager.lineSegMaterialCopy.uuid=this.meshManager.lineSegMaterial.uuid,this.meshManager.lineSegMaterialCopy.program=this.meshManager.lineSegMaterial.program,this.meshManager.lineSegMaterialCopy.needsUpdate=this.meshManager.lineSegMaterial.needsUpdate,this.meshManager.lineSegMaterialCopy.opacity=_e.lineOpacity,this.meshManager.lineSegMaterialCopy.transparent=!0)},getTransparentizedBodies:function(){return this.transparentizedBodies},getAllTransparentBodies:function(e){if(this.transparentBodyChanged){for(var t=this.transparentBodies.length=0,n=this.wholeLeafBodyNodes.length;t<n;++t){var i=this.wholeLeafBodyNodes[t];if(i.isTransparent())this.transparentBodies.push(this.wholeLeafBodyNodes[t]);else for(var r=this.meshManager.getNumBodyMeshs(i),o=0;o<r;++o){var a=this.meshManager.getBodyMeshId(i,o),a=this.meshManager.getMeshOriginalMaterial(a);if(a&&a.transparent&&(a.opacity<=.99||a.alphaMap)){this.transparentBodies.push(i);break}}}this.transparentBodyChanged=!1,e&&this.sortBodiesByVolume(this.transparentBodies)}return this.transparentBodies},inIsolate:function(){return 0<this.transparentizedBodies.length},exitIsolate:function(){for(var e=0;e<this.wholeLeafBodyNodes.length;++e){var t=this.wholeLeafBodyNodes[e];t.deIsolate(),t.opaque()}this.transparentizedBodies.length=0,this.transparentBodyChanged=!0,this.meshManager.resetGeomSameMaterialFlags()},isolateBodiesOnly:function(e){for(var t=0;t<e.length;++t){var n=e[t],i=this.getLeafBodies(n);if(i&&0<i.length)for(var r=0,o=i.length;r<o;++r)i[r].leafBodyAttri&&(i[r].isolate(),i[r].opaque(),this.transparentModeBodiesMap.delete(i[r].uuid),this.RemoveElement(this.transparentizedBodies,i[r]),this.transparentBodyChanged=!0)}this.meshManager.resetGeomSameMaterialFlags(),0==this.transparentizedBodies.length&&this.exitIsolate()},isolateBodyOnly:function(e){var t=this.getLeafBodies(e);if(t&&0<t.length)for(var n=0,i=t.length;n<i;++n)t[n].leafBodyAttri&&(t[n].isolate(),t[n].opaque(),this.transparentModeBodiesMap.set(t[n].uuid,!0),this.RemoveElement(this.transparentizedBodies,t[n]),this.transparentBodyChanged=!0);this.meshManager.resetGeomSameMaterialFlags()},isolateBodies:function(e,t,n){if(e){for(var i=0,r=e.length;i<r;++i){var o=this.getLeafBodies(e[i]);if(o&&0<o.length)for(var a=0,s=o.length;a<s;++a)o[a].leafBodyAttri&&(o[a].isolate(),o[a].opaque(),this.meshManager.setGeomSameMaterialFlag(o[a]))}this.transparentizedBodies=[];for(i=0;i<this.wholeLeafBodyNodes.length;++i){var l=this.wholeLeafBodyNodes[i];this.transparentModeBodiesMap.set(l.uuid,!0),l.isIsolated()||(l.transparent(),this.transparentizedBodies.push(l))}if(this.transparentBodyChanged=!0,!this.meshManager.matsCopy||0===this.meshManager.matsCopy.length)for(a=0,s=this.meshManager.mats.length;a<s;++a)this.meshManager.mats[a]&&(this.meshManager.matsCopy[a]=this.meshManager.mats[a].clone(),this.meshManager.matsCopy[a].uuid=this.meshManager.mats[a].uuid,this.meshManager.matsCopy[a].program=this.meshManager.mats[a].program,this.meshManager.matsCopy[a].needsUpdate=this.meshManager.mats[a].needsUpdate,this.meshManager.matsCopy[a].opacity=t,this.meshManager.matsCopy[a].transparent=!0);if(!this.meshManager.lineSegMaterial){for(var d in this.meshManager.materials)if("LineBasicMaterial"===this.meshManager.materials[d].mat.type){this.meshManager.lineSegMaterial=this.meshManager.materials[d].mat;break}this.meshManager.lineSegMaterial||(this.meshManager.lineSegMaterial=new THREE.LineBasicMaterial({color:0,linewidth:1}))}this.meshManager.lineSegMaterialCopy||(this.meshManager.lineSegMaterialCopy=this.meshManager.lineSegMaterial.clone(),this.meshManager.lineSegMaterialCopy.uuid=this.meshManager.lineSegMaterial.uuid,this.meshManager.lineSegMaterialCopy.program=this.meshManager.lineSegMaterial.program,this.meshManager.lineSegMaterialCopy.needsUpdate=this.meshManager.lineSegMaterial.needsUpdate,this.meshManager.lineSegMaterialCopy.opacity=null!=n?n:t,this.meshManager.lineSegMaterialCopy.transparent=!0),0==this.transparentizedBodies.length&&this.exitIsolate()}},hideBody:function(e){for(var t=[e],o=0;o<t.length;++o)if(0==t[o].children.length){if(t[o].leafBodyAttri||(t[o].visible=!1),0<=t[o].id&&!t[o].isReferenceEntity()&&!t[o].isCoordinate())if((p=t[o]).leafBodyAttri){if(this.hasHiddenBodies=!0,p.hide(),this.hideBodies.push(p),this.meshManager.setGeomSameMaterialFlag(p),p.leafBodyAttri&&p.leafBodyAttri.bodyTextIds&&0<p.leafBodyAttri.bodyTextIds.length)for(var n=0;n<p.leafBodyAttri.bodyTextIds.length;++n){var i,r=p.leafBodyAttri.bodyTextIds[n];this.meshManager.textGeomId[r]<0||((r=this.meshManager.geomManager.getGeomFromId(this.meshManager.textGeomId[r]))._visible=!1,(i=this.viewer.scene.getObjectByName("dashLine"))&&(A=i.getObjectByName(r.uuid))&&(A.visible=!1))}if(p.leafBodyAttri&&p.leafBodyAttri.bodyLineSegIds&&0<p.leafBodyAttri.bodyLineSegIds.length)for(var a=0;a<p.leafBodyAttri.bodyLineSegIds.length;++a){var s=p.leafBodyAttri.bodyLineSegIds[a];this.meshManager.lineSegGeomId[s]<0||(s=this.meshManager.geomManager.getGeomFromId(this.meshManager.lineSegGeomId[s]),(s=this.viewer.lineTypes?this.viewer.lineTypes.geomUUidToLineInfo[s.uuid]:null)&&s.lineTypeID&&(s._visible=!1,s=this.meshManager.lineTypeUuid2ParamsMap.get(s.lineTypeID))&&(s.visible=!1))}}}else{t[o].visible=!1;for(var l=0,d=t[o].children.length;l<d;++l)t.push(t[o].children[l])}(e.isReferenceEntity()||e.isCoordinate())&&(e.hide(),this.hideBodies.push(e));for(var c=this.getLeafReferenceEntities(e),o=0,h=c.length;o<h;o++)c[o].leafBodyAttri&&(c[o].hide(),this.hideBodies.push(c[o]));for(var u=this.getLeafCoordinate(e),o=0,h=u.length;o<h;o++)u[o].hide(),this.hideBodies.push(u[o]);if(this.viewer.is2DModel&&this.viewer.pmiObject)for(var p,f=this.getLayerBodies(e),m=0,h=f.length;m<h;++m)if((p=f[m]).pmiuuid){for(var g=this.viewer,v=g.pmiObject.getObjectByName("TextGroup"),l=0;l<p.pmiuuid.length;++l){for(var A,y=p.pmiuuid[l],o=0;o<g.SDFMaker.AttributeArray.length;++o)g.SDFMaker.AttributeArray[o]&&g.SDFMaker.AttributeArray[o].forEach(function(e,t){var n=e[y];if(n){for(var e=o+"_"+t,i=v.getObjectByName(e).geometry.attributes.position.data,r=n.start;r<n.start+n.count;r++)i.array[r*i.stride+3]<=1&&(i.array[r*i.stride+3]+=1.25);i.needsUpdate=!0,i.updateRange.count=i.count*i.stride}});(A=g.pmiObject.getObjectByProperty("uuid",y))&&(A.visible=!1)}p.visible=!1}this.viewer.is2DModel&&this.viewer._filterTextByShowHide(),this.viewer.render()},showBody:function(e){for(var t=[e],n=!1,o=0;o<t.length;++o)if(!t[o].unload)if(0==t[o].children.length){if(t[o].leafBodyAttri||(t[o].visible=!0),0<=t[o].id&&!t[o].isReferenceEntity()&&!t[o].isCoordinate())if((f=t[o]).leafBodyAttri){if(n=!0,f.show(),this.RemoveElement(this.hideBodies,f),f.leafBodyAttri&&f.leafBodyAttri.bodyTextIds&&0<f.leafBodyAttri.bodyTextIds.length)for(var i=0;i<f.leafBodyAttri.bodyTextIds.length;++i){var r,a=f.leafBodyAttri.bodyTextIds[i];this.meshManager.textGeomId[a]<0||((a=this.meshManager.geomManager.getGeomFromId(this.meshManager.textGeomId[a]))._visible=!0,(r=this.viewer.scene.getObjectByName("dashLine"))&&(y=r.getObjectByName(a.uuid))&&(y.visible=!0))}if(f.leafBodyAttri&&f.leafBodyAttri.bodyLineSegIds&&0<f.leafBodyAttri.bodyLineSegIds.length)for(var s=0;s<f.leafBodyAttri.bodyLineSegIds.length;++s){var l=f.leafBodyAttri.bodyLineSegIds[s];this.meshManager.lineSegGeomId[l]<0||(l=this.meshManager.geomManager.getGeomFromId(this.meshManager.lineSegGeomId[l]),(l=this.viewer.lineTypes?this.viewer.lineTypes.geomUUidToLineInfo[l.uuid]:null)&&l.lineTypeID&&(l._visible=!0,l=this.meshManager.lineTypeUuid2ParamsMap.get(l.lineTypeID))&&(l.visible=!0))}}}else{t[o].visible=!0;for(var d=0,c=t[o].children.length;d<c;++d)t.push(t[o].children[d])}n&&this.meshManager.resetGeomSameMaterialFlags(),(e.isReferenceEntity()||e.isCoordinate())&&(e.show(),this.RemoveElement(this.hideBodies,e));for(var h=this.getLeafReferenceEntities(e),o=0,u=h.length;o<u;o++)h[o].leafBodyAttri&&(h[o].parent.isComponentRefPlaneVisible()&&"RefPlane"==h[o].type||h[o].parent.isComponentRefAxisVisible()&&"RefAxis"==h[o].type)&&(h[o].show(),this.RemoveElement(this.hideBodies,h[o]));for(var p=this.getLeafCoordinate(e),o=0,u=p.length;o<u;o++)p[o].parent.isComponentCoordinateSysVisible()&&(p[o].show(),this.RemoveElement(this.hideBodies,p[o]));if(this.viewer.is2DModel&&this.viewer.pmiObject){for(var f,m=this.getLayerBodies(e),g=0,u=m.length;g<u;++g)if((f=m[g]).pmiuuid){for(var v=this.viewer,A=v.pmiObject.getObjectByName("TextGroup"),d=0;d<f.pmiuuid.length;++d){for(var y,E=f.pmiuuid[d],o=0;o<v.SDFMaker.AttributeArray.length;++o)v.SDFMaker.AttributeArray[o]&&v.SDFMaker.AttributeArray[o].forEach(function(e,t){var n=e[E];if(n){for(var e=o+"_"+t,i=A.getObjectByName(e).geometry.attributes.position.data,r=n.start;r<n.start+n.count;r++)1<i.array[r*i.stride+3]&&(i.array[r*i.stride+3]-=1.25);i.needsUpdate=!0,i.updateRange.count=i.count*i.stride}});(y=v.pmiObject.getObjectByProperty("uuid",E))&&(y.visible=!0)}f.visible=!0}e="0x"+this.viewer.renderer.getClearColor(this.viewer.oldClearColor).getHexString();this.viewer.setBackGroundColor(e)}0==this.hideBodies.length&&(this.hasHiddenBodies=!1),this.viewer.is2DModel&&this.viewer._filterTextByShowHide()},showBodyReversed:function(e){for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n){var r=t[n];r.leafBodyAttri&&(r.isHidden()?(r.show(),this.RemoveElement(this.hideBodies,r)):(r.hide(),this.hideBodies.push(r)),r.isHidden())&&(this.hasHiddenBodies=!0)}this.meshManager.resetGeomSameMaterialFlags()},showAllBodies:function(){this.hasHiddenBodies=!1,this.hideBodies=[];for(var e=0,t=this.wholeLeafBodyNodes.length;e<t;++e)this.wholeLeafBodyNodes[e].leafBodyAttri&&this.wholeLeafBodyNodes[e].show();for(var n=0,i=this.emptyBodyNodes.length;n<i;++n)this.emptyBodyNodes[n].show();this.meshManager.resetGeomSameMaterialFlags()},hideAllBodies:function(e){this.hasHiddenBodies=!0,e&&(this.hideBodies=[]);for(var t=0,n=this.wholeLeafBodyNodes.length;t<n;++t)this.wholeLeafBodyNodes[t].leafBodyAttri&&(this.wholeLeafBodyNodes[t].hide(),e)&&this.hideBodies.push(this.wholeLeafBodyNodes[t]);for(var i=0,r=this.emptyBodyNodes.length;i<r;++i)this.emptyBodyNodes[i].hide(),e&&this.hideBodies.push(this.emptyBodyNodes[i]);this.meshManager.resetGeomSameMaterialFlags()},reverseBodyVisibility:function(){this.hasHiddenBodies=!1,this.hideBodies=[];for(var e=0,t=this.wholeLeafBodyNodes.length;e<t;++e)this.wholeLeafBodyNodes[e].leafBodyAttri&&(this.wholeLeafBodyNodes[e].isHidden()?this.wholeLeafBodyNodes[e].show():(this.wholeLeafBodyNodes[e].hide(),this.hideBodies.push(this.wholeLeafBodyNodes[e]),this.hasHiddenBodies=!0));this.meshManager.resetGeomSameMaterialFlags()},isBodyAllChildHidden:function(e){for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n)if(!t[n].isHidden())return!1;return!(e.isReferenceEntity()&&!e.isHidden()||e.isCoordinate()&&!e.isHidden())},isBodyAllChildSelected:function(e){for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n)if(!t[n].isSelected())return!1;return!(e.isReferenceEntity()&&!e.isSelected()||e.isCoordinate()&&!e.isSelected())},isBodyAllChildShow:function(e){for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n)if(t[n].isHidden())return!1;return!0},isBodyOrSomeChildHidden:function(e){if(e.isHidden())return!0;for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n){var r=t[n];if(r.leafBodyAttri&&(r.isHidden()&&!r.unload))return!0}for(var o=[e],n=0;n<o.length;++n){if(0==o[n].children.length&&!o[n].leafBodyAttri&&"Body"!=o[n].type&&!o[n].visible)return!0;for(var a=0,s=o[n].children.length;a<s;++a)o.push(o[n].children[a])}if(this.viewer.is2DModel&&this.viewer.pmiObject)for(var l=this.getLayerBodies(e),d=0,i=l.length;d<i;++d)if((r=l[d]).pmiuuid&&!r.visible)return!0;return!1},getBodyOrSomeChildVisibleStatus:function(e){if(e.isHidden())return 0;for(var t=function(e,t){return 0==t?1:0<e&&e<t?2:e==t?0:0==e?1:void 0},n=this.getLeafBodies(e),i=0,r=0,o=0,a=n.length;o<a;++o){var s=n[o];if(s.leafBodyAttri&&(s.unload||(r++,s.isHidden()&&i++),2==t(i,r)))return 2}for(var l=[e],o=0;o<l.length;++o){if(0!=l[o].children.length||l[o].leafBodyAttri||"Body"==l[o].type)for(var d=0,c=l[o].children.length;d<c;++d)l.push(l[o].children[d]);else r++,l[o].visible||i++;if(2==t(i,r))return 2}if(this.viewer.is2DModel&&this.viewer.pmiObject)for(var h=this.getLayerBodies(e),u=0,a=h.length;u<a;++u)if((s=h[u]).pmiuuid&&(r++,s.visible||i++),2==t(i,r))return 2;return t(i,r)},isBodyAllChildTransparent:function(e){for(var t=this.getLeafBodies(e),n=0,i=t.length;n<i;++n)if(!t[n].isTransparent())return!1;return!0},getSelectedBodies:function(){return this.selectedBodies},clearSelection:function(){for(var e=!1,o=0,t=this.selectedBodies.length;o<t;++o)this.selectedBodies[o].deSelect(),e=!0;this.selectedBodies.length=0;var n=this.viewer.ndsModel.rootBodyNode;if(this.viewer.pmiObject&&this.deselectPMIObject(this.viewer.pmiObject),this.viewer.is2DModel&&this.viewer.pmiObject)for(var i=this.getLayerBodies(n),r=0,t=i.length;r<t;++r)if((c=i[r]).pmiuuid)for(var a=this.viewer,s=a.pmiObject.getObjectByName("TextGroup"),l=0;l<c.pmiuuid.length;++l){for(var d=c.pmiuuid[l],o=0;o<a.SDFMaker.AttributeArray.length;++o)a.SDFMaker.AttributeArray[o]&&a.SDFMaker.AttributeArray[o].forEach(function(e,t){var n=e[d];if(n){for(var e=o+"_"+t,i=s.getObjectByName(e).geometry.attributes.position.data,r=n.start;r<n.start+n.count;r++)1<i.array[r*i.stride+4]&&(i.array[r*i.stride+4]-=1.25);i.needsUpdate=!0,i.updateRange.count=i.count*i.stride}});(g=a.pmiObject.getObjectByProperty("uuid",d))&&g.material&&g.material.color.copy(g.color)}for(var c,h=this.getLeafBodies(n),u=0,p=h.length;u<p;u++)if((c=h[u]).leafBodyAttri&&c.leafBodyAttri.bodyTextIds&&0<c.leafBodyAttri.bodyTextIds.length)for(var f=0;f<c.leafBodyAttri.bodyTextIds.length;++f){var m,g,v,A=c.leafBodyAttri.bodyTextIds[f];this.meshManager.textGeomId[A]<0||(m=this.meshManager.geomManager.getGeomFromId(this.meshManager.textGeomId[A]),(v=this.viewer.scene.getObjectByName("dashLine"))&&(g=v.getObjectByName(m.uuid))&&(v=this.meshManager.mats[this.meshManager.textMaterialId[A]],g.material.color.copy(v.color)))}e&&this.meshManager.resetGeomSameMaterialFlags();for(o=0,t=this.wholeRefEntityNodes.length;o<t;++o)this.wholeRefEntityNodes[o].deSelect();for(o=0,t=this.wholeCoordinateNodes.length;o<t;++o)this.wholeCoordinateNodes[o].deSelect();this.viewer.is2DModel&&(n="0x"+this.viewer.renderer.getClearColor(this.viewer.oldClearColor).getHexString(),this.viewer.setBackGroundColor(n))},addSelection:function(e){for(var t=this.getLeafBodies(e),o=0,n=t.length;o<n;++o){var i=t[o];if(i.leafBodyAttri&&!i.isSelected()){if(i.select(),this.selectedBodies.push(i),i.leafBodyAttri&&i.leafBodyAttri.bodyTextIds&&0<i.leafBodyAttri.bodyTextIds.length)for(var r=0;r<i.leafBodyAttri.bodyTextIds.length;++r){var a,s=i.leafBodyAttri.bodyTextIds[r];this.meshManager.textGeomId[s]<0||(s=this.meshManager.geomManager.getGeomFromId(this.meshManager.textGeomId[s]),(a=this.viewer.scene.getObjectByName("dashLine"))&&(f=a.getObjectByName(s.uuid))&&f.material.color.copy(_e.selectedColor))}this.meshManager.setGeomSameMaterialFlag(i)}}for(var l=this.getLeafReferenceEntities(e),o=0,n=l.length;o<n;o++)l[o].leafBodyAttri&&l[o].select();if(this.viewer.is2DModel&&this.viewer.pmiObject)for(var d=this.getLayerBodies(e),c=0,n=d.length;c<n;++c)if((i=d[c]).pmiuuid)for(var h=this.viewer,u=h.pmiObject.getObjectByName("TextGroup"),p=0;p<i.pmiuuid.length;++p){for(var f,m=i.pmiuuid[p],o=0;o<h.SDFMaker.AttributeArray.length;++o)h.SDFMaker.AttributeArray[o]&&h.SDFMaker.AttributeArray[o].forEach(function(e,t){var n=e[m];if(n){for(var e=o+"_"+t,i=u.getObjectByName(e).geometry.attributes.position.data,r=n.start;r<n.start+n.count;r++)i.array[r*i.stride+4]<=1&&(i.array[r*i.stride+4]+=1.25);i.needsUpdate=!0,i.updateRange.count=i.count*i.stride}});(f=h.pmiObject.getObjectByProperty("uuid",m))&&f.material&&f.material.color&&f.material.color.set(16776960)}},selectPMIObject:function(o,e){void 0===e&&(e=!0),(o="NoteNDS"==o.type?o.parent:o).visible||(this.viewer.setPMIObjectVisible(o,!0),o.SelectVisible=!0),o.select=!0,o.traverse(function(e){if(e.select=!0,o.SelectVisible&&(e.SelectVisible=!0),e.geometry){var t=null;if(t="ShaderMaterial"==e.material.type?e.geometry.attributes.position.data:t){if(Number.isFinite(e.geometry.drawRange.count))for(var n=e.geometry.drawRange.count,i=e.geometry.drawRange.start;i<e.geometry.drawRange.start+n;++i){var r=e.geometry.index.array[i];t.array[r*t.stride+4]<=1&&(t.array[r*t.stride+4]+=1.25)}else for(i=0;i<e.geometry.index.array.length;++i){r=e.geometry.index.array[i];t.array[r*t.stride+4]<=1&&(t.array[r*t.stride+4]+=1.25)}t.needsUpdate=!0,t.updateRange.count=t.count*t.stride}else e.material.selectMaterial||(e.material.selectMaterial=e.material.clone(),e.material.selectMaterial.color.setRGB(.09,.501,.89),e.material.selectMaterial.originMateial=e.material),e.material.originMateial||(e.material=e.material.selectMaterial)}}),e&&this.viewer.dispatchEvent({type:"selPMI",object:o})},deselectPMIObject:function(e,t){void 0===t&&(t=!0),(e="NoteNDS"==e.type?e.parent:e).SelectVisible&&(e.SelectVisible=!1,this.viewer.setPMIObjectVisible(e,!1));var o=e.select=!1,a=this;e.traverse(function(e){if(e.select&&(o=!0),e.select=!1,e.SelectVisible&&(e.SelectVisible=!1,a.viewer.setPMIObjectVisible(e,!1)),e.geometry){var t=null;if(t="ShaderMaterial"==e.material.type?e.geometry.attributes.position.data:t){if(Number.isFinite(e.geometry.drawRange.count))for(var n=e.geometry.drawRange.count,i=e.geometry.drawRange.start;i<e.geometry.drawRange.start+n;++i){var r=e.geometry.index.array[i];1<t.array[r*t.stride+4]&&(t.array[r*t.stride+4]-=1.25)}else for(i=0;i<e.geometry.index.array.length;++i){r=e.geometry.index.array[i];1<t.array[r*t.stride+4]&&(t.array[r*t.stride+4]-=1.25)}t.needsUpdate=!0,t.updateRange.count=t.count*t.stride}else e.material.originMateial&&(e.material=e.material.originMateial)}}),t&&(e.uuid==this.viewer.pmiObject.uuid&&o?this.viewer.dispatchAsyncEvent({type:"clearSelPMI"}):this.viewer.dispatchAsyncEvent({type:"deselPMI",object:e}))},removeSelection:function(e){var t=this.getLeafBodies(e);if(0<t.length){for(var o=0,n=t.length;o<n;++o){var i=t[o];if(i.leafBodyAttri&&i.isSelected()){i.deSelect();var r=this.selectedBodies.indexOf(i);if(-1<r&&this.selectedBodies.splice(r,1),i.leafBodyAttri&&i.leafBodyAttri.bodyTextIds&&0<i.leafBodyAttri.bodyTextIds.length)for(var a=0;a<i.leafBodyAttri.bodyTextIds.length;++a){var s,l,d=i.leafBodyAttri.bodyTextIds[a];this.meshManager.textGeomId[d]<0||(s=this.meshManager.geomManager.getGeomFromId(this.meshManager.textGeomId[d]),(l=this.viewer.scene.getObjectByName("dashLine"))&&(v=l.getObjectByName(s.uuid))&&(l=this.meshManager.mats[this.meshManager.textMaterialId[d]],v.material.color.copy(l.color)))}}}this.meshManager.resetGeomSameMaterialFlags()}for(var c=this.getLeafReferenceEntities(e),o=0,h=c.length;o<h;o++)c[o].leafBodyAttri&&c[o].deSelect();if(this.viewer.is2DModel&&this.viewer.pmiObject){for(var u=this.getLayerBodies(e),p=0,h=u.length;p<h;++p)if((i=u[p]).pmiuuid)for(var f=this.viewer,m=f.pmiObject.getObjectByName("TextGroup"),g=0;g<i.pmiuuid.length;++g){for(var v,A=i.pmiuuid[g],o=0;o<f.SDFMaker.AttributeArray.length;++o)f.SDFMaker.AttributeArray[o]&&f.SDFMaker.AttributeArray[o].forEach(function(e,t){var n=e[A];if(n){for(var e=o+"_"+t,i=m.getObjectByName(e).geometry.attributes.position.data,r=n.start;r<n.start+n.count;r++)1<i.array[r*i.stride+4]&&(i.array[r*i.stride+4]-=1.25);i.needsUpdate=!0,i.updateRange.count=i.count*i.stride}});(v=f.pmiObject.getObjectByProperty("uuid",A))&&v.material&&v.material.color&&v.material.color.copy(v.color)}this.viewer.is2DModel&&(e="0x"+this.viewer.renderer.getClearColor(this.viewer.oldClearColor).getHexString(),this.viewer.setBackGroundColor(e))}},preSelectObject:function(e){if(!this.preselectedObject||this.preselectedObject.uuid!=e.uuid){if(this.preselectedObject)for(var t=0,n=(i=this.getAllLeafNodes(this.preselectedObject)).length;t<n;++t)i[t].leafBodyAttri&&i[t].dePreSelect();this.preselectedObject=e;for(var i,t=0,n=(i=this.getAllLeafNodes(e)).length;t<n;++t)i[t].leafBodyAttri&&i[t].preSelect()}},clearPreSelection:function(){if(this.preselectedObject){for(var e=this.getAllLeafNodes(this.preselectedObject),t=0,n=e.length;t<n;++t)e[t].leafBodyAttri&&e[t].dePreSelect();return!(this.preselectedObject=null)}return!1},sortBodies:function(e){for(var t,n=[],i=(new THREE.Box3,0),r=e.length;i<r;++i)e[i].leafBodyAttri&&(t=this.getLeafBodyBoundingBox(e[i]).distanceToPoint(this.viewer.camera.position),n.push({body:e[i],z:t}));n.sort(Yt);for(i=0,r=e.length;i<r;++i)e[i]=n[i].body},sortBodiesByVolume:function(e){for(var t,n,i,r=[],o=[],a=(new THREE.Box3,0),s=e.length;a<s;++a)e[a].leafBodyAttri?(t=(i=this.getLeafBodyBoundingBox(e[a])).max.x-i.min.x,n=i.max.y-i.min.y,i=i.max.z-i.min.z,r.push({body:e[a],z:t*n*i})):o.push(e[a]);r.sort(Wt);for(a=0,s=r.length;a<s;++a)e[a]=r[a].body;if(0<o.length)for(var l=r.length,d=e.length;l<d;++l)e[l]=o[l-r.length]},getGeometriesCount:function(){var e={Mesh:{count:0,triangles:0,points:0},Line:{count:0,points:0}};e.Mesh.count=this.wholeLeafBodyNodes.length;for(var t=0,n=this.geomManager.geoms.length;t<n;++t){var i,r,o=this.geomManager.geoms[t];null!=o&&null!=o.index&&(i=o.refMeshes.length,r=o.refLineSegs.length,0<i?(e.Mesh.triangles+=o.drawRange.count/3*i,o.index.count===o.drawRange.start+o.drawRange.count&&(o.attributes.position.isInterleavedBufferAttribute?e.Mesh.points+=o.attributes.position.data.count:e.Mesh.points+=o.attributes.position.count)):0<r&&(e.Line.count+=r,o.index.count===o.drawRange.start+o.drawRange.count)&&(o.attributes.position.isInterleavedBufferAttribute?e.Line.points+=o.attributes.position.data.count:e.Line.points+=o.attributes.position.count))}return e},updateBodyMeshIds:function(){for(var e=0,t=this.wholeLeafBodyNodes.length;e<t;++e)this.wholeLeafBodyNodes[e].leafBodyAttri&&(this.wholeLeafBodyNodes[e].leafBodyAttri.bodyMeshIds.length=0,this.wholeLeafBodyNodes[e].leafBodyAttri.bodyLineSegIds.length=0);for(e=0;e<this.meshManager.nMeshes;++e)this.meshManager.bodyNodes[e].leafBodyAttri.bodyMeshIds.push(e);for(e=0;e<this.meshManager.nLineSegments;++e)this.meshManager.lineSegBodyNodes[e].leafBodyAttri.bodyLineSegIds.push(e)},delete:function(e){var t=e.parent;if(null!=t){for(var n=0;n<t.children.length;++n)if(t.children[n]===e){t.children.splice(n,1);break}for(var i=[e],r=0;r<i.length;++r){var o=i[r];delete this.bodyUuid2NodeMap[o.uuid];for(var a=0,s=o.children.length;a<s;++a)i.push(o.children[a])}var l=this.getLeafBodies(e);if(0<l.length){for(var d=[],c=[],r=0,h=l.length;r<h;++r){var u=l[r];u.leafBodyAttri&&(d.extend(u.leafBodyAttri.bodyMeshIds),c.extend(u.leafBodyAttri.bodyLineSegIds),u.leafBodyAttri=null),-1<(f=this.wholeLeafBodyNodes.indexOf(u))&&this.wholeLeafBodyNodes.splice(f,1),0<this.transparentBodies.length&&-1<(f=this.transparentBodies.indexOf(u))&&(this.transparentBodies.splice(f,1),this.transparentBodiesDirty=!0),0<this.transparentizedBodies.length&&-1<(f=this.transparentizedBodies.indexOf(u))&&(this.transparentModeBodiesMap.delete(u.uuid),this.transparentizedBodies.splice(f,1),this.transparentBodiesDirty=!0),0<this.selectedBodies.length&&-1<(f=this.selectedBodies.indexOf(u))&&(this.selectedBodies.splice(f,1),this.selectedBodiesDirty=!0),0<this.draggedBodies.length&&-1<(f=this.draggedBodies.indexOf(u))&&this.draggedBodies.splice(f,1),0<this.hideBodies.length&&-1<(f=this.hideBodies.indexOf(u))&&this.hideBodies.splice(f,1)}this.bvhCreater.delete(d,c),this.meshManager.instancedMeshIds.length=0,this.updateBodyMeshIds(),this.meshManager.collectGeomRefEntities(),this.meshManager.setMaterialInfor(),this.viewer.modelRootObject.boundingBox.copy(this.sptIndex.root.boundingBox),this.viewer.controls.setBoundingBox(this.viewer.modelRootObject.boundingBox.min,this.viewer.modelRootObject.boundingBox.max)}var p=this.getLeafReferenceEntities(e);if(0<p.length){for(r=0,h=p.length;r<h;++r)p[r].leafBodyAttri=null,-1<(f=this.wholeRefEntityNodes.indexOf(p[r]))&&this.wholeRefEntityNodes.splice(f,1),this.referenceEntityDispManager.removeRefEntity(p[r]);this.referenceEntityDirty=!0}for(var f,m=this.getLeafCoordinate(e),r=0,g=m.length;r<g;r++)m[r].leafBodyAttri.renderObject&&(this.viewer.scene.remove(m[r].leafBodyAttri.renderObject),m[r].leafBodyAttri.renderObject.detach(),m[r].leafBodyAttri.renderObject=null),-1<(f=this.wholeCoordinateNodes.indexOf(m[r]))&&this.wholeCoordinateNodes.splice(f,1)}},addReferenceEntity:function(e){var t,n=null;!(n=e.parentNode||this.getBodyNodeFromUuid(e.parentUuid))||(t=this.getBodyNodeFromUuid(e.uuid))||((t=new Ae).uuid=e.uuid,t.name=e.name,void 0!==e.visible?t.visible=e.visible:t.visible=!1,t.type=e.type,(t.parent=n).children.push(t),t.worldMatrix=this.calculateNodeWorldMatrix(t),t.id=this.leafNodeCount++,this.bodyUuid2NodeMap[t.uuid]=t,this.wholeRefEntityNodes.push(t),n=new x,t.visible||(n.bodyFlag|=ve.BODYFLAG.HIDDEN_FLAG),n.coords=e.coords.slice(0),n.bbox.setFromArray(n.coords),n.bbox.applyMatrix4(t.worldMatrix),t.leafBodyAttri=n,this.referenceEntityDispManager.addRefEntity(t),this.referenceEntityDirty=!0)},addReferenceEntities:function(e){for(var t=0;t<e.length;t++)this.addReferenceEntity(e[t])}};var Xt=function(e){this.activeModel=null,this.viewer=e,this.bodyUuid2NodeMap={},this.models=[],this.bodyuuidOld2New={},this.materialuuidOld2New={}};function Qt(e,t){return(Qt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}Xt.prototype={constructor:Xt,fuseData:function(){for(var e in this.activeModel.bodyUuid2NodeMap)null==this.bodyUuid2NodeMap[e]&&(this.bodyUuid2NodeMap[e]=this.activeModel.bodyUuid2NodeMap[e])},isEmpty:function(){return!(0<this.models.length)},getgeoIds:function(t){var n=[],i=this;return this.models.forEach(function(e){null!=e.geomManager.uuidToIdMap[t]&&(n=e.geomManager.uuidToIdMap[t],i.activeModel=e)}),n},addModel:function(e){for(var t in this.viewer&&this.viewer.sketchStartLoad&&(e.sketchFileUrl=!0,this.staticModel=this.models[0],this.sketchModel=e),this.activeModel=e,this.activeModel)null==this[t]&&(this[t]=this.activeModel[t]);this.models.push(e),!this.viewer.sketchStartLoad&&1<this.models.length&&(_e.ScenarioEditor=!0),_e.ScenarioEditorid++,this.viewer.ScenarioEditorInfo.folderArray[_e.ScenarioEditorid]=1},setActiveModel:function(e){e<this.models.length&&(this.activeModel=this.models[e])},setStaticModel:function(e){e<this.models.length&&(this.staticModel=this.models[e])},getActiveModel:function(){return this.activeModel},getModelById:function(e){for(var t=0;t<this.models.length;++t)if(this.models[t]===e)return this.models[t]},update:function(t){this.models.forEach(function(e){e.update(t)})},getMeshManager:function(){if(this.activeModel)return this.activeModel.getMeshManager()},getGeomManager:function(){if(this.activeModel)return this.activeModel.getGeomManager()},getMeshSets:function(){if(this.activeModel)return this.activeModel.getMeshSets()},getStaticMeshSets:function(){if(this.staticModel)return this.staticModel.getMeshSets()},buildMeshSets:function(){if(this.activeModel)return this.activeModel.buildMeshSets()},sortMeshSets2:function(e){if(this.activeModel)return this.activeModel.sortMeshSets2(e)},getRightBodyuuid:function(e,t){if(this.activeModel)return this.activeModel.getRightBodyuuid(e,t)},getLineSegmentsSet:function(){if(this.activeModel)return this.activeModel.getLineSegmentsSet()},prepareForRendering:function(e,t){if(this.activeModel)return this.activeModel.prepareForRendering(e,t)},backupAllBodyFlag:function(){if(this.activeModel)return this.activeModel.backupAllBodyFlag()},backupAllBodiesFlag:function(){this.models.forEach(function(e){e.backupAllBodyFlag()})},resetAllBodyFlag:function(){if(this.activeModel)return this.activeModel.resetAllBodyFlag()},resetAllBodiesFlag:function(){this.models.forEach(function(e){e.resetAllBodyFlag()})},backupEmptyBodyNodeVisibleState:function(){this.models.forEach(function(e){e.backupEmptyBodyNodeVisibleState()})},resetEmptyBodyNodeVisibleState:function(){this.models.forEach(function(e){e.resetEmptyBodyNodeVisibleState()})},requireContinueLoading:function(){if(this.activeModel)return this.activeModel.requireContinueLoading()},hasEnoughAvailableMemory:function(){if(this.activeModel)return this.activeModel.hasEnoughAvailableMemory()},pageOut:function(){if(this.activeModel)return this.activeModel.pageOut()},continueLoading:function(){if(this.activeModel)return this.activeModel.continueLoading()},setDrawMode:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.setDrawMode(t)})},getDrawModeFace:function(){if(this.activeModel)return this.activeModel.getDrawModeFace()},getDrawModeFaceColorMask:function(){if(this.activeModel)return this.activeModel.getDrawModeFaceColorMask()},getDrawModeEdge:function(){if(this.activeModel)return this.activeModel.getDrawModeEdge()},getDrawModeHiddenEdge:function(){if(this.activeModel)return this.activeModel.getDrawModeHiddenEdge()},setOverrideMaterial:function(t,n,i){this.models.forEach(function(e){e.setOverrideMaterial(t,n,i)})},attachBodyNode:function(e,t,n,i,r){if(this.activeModel)return this.activeModel.attachBodyNode(e,t,n,i,r)},setBodyNodeMaterials:function(e){if(this.activeModel)return this.activeModel.setBodyNodeMaterials(e)},getBodyNodeUUidToMaterial:function(){if(this.activeModel)return this.activeModel.getBodyNodeUUidToMaterial()},setBodyNodeMaterial:function(e,t){if(this.activeModel)return this.activeModel.setBodyNodeMaterial(e,t)},removeAllBodyNodeMaterials:function(){if(this.activeModel)return this.activeModel.removeAllBodyNodeMaterials()},removeBodyNodeMaterial:function(e){return this.removeBodyNodeMaterial(e)},getBodyNode:function(e){if(this.activeModel)return this.activeModel.getBodyNode(e)},getBodyNodeFromUuid:function(t){var n=null;return this.models.forEach(function(e){e=e.getBodyNodeFromUuid(t);e&&(n=e)}),n},getSelectedLeafBodyNodes:function(e){if(this.activeModel)return this.activeModel.getSelectedLeafBodyNodes(e)},getLeafBodies:function(e){if(this.activeModel)return this.activeModel.getLeafBodies(e)},getLeafPMIuuid:function(e){if(this.activeModel)return this.activeModel.getLeafPMIuuid(e)},getLayerBodies:function(e){if(this.activeModel)return this.activeModel.getLayerBodies(e)},getLeafReferenceEntities:function(e){if(this.activeModel)return this.activeModel.getLayerBodies(e)},getLeafCoordinate:function(e){if(this.activeModel)return this.activeModel.getLeafCoordinate(e)},getAllLeafNodes:function(t){var n=[],i=this;return"parentNode"==t.type?t.children.forEach(function(e){n=n.concat(i.getAllLeafNodes(e))}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=n.concat(e.getAllLeafNodes(t)))}),n},updateNodeMatrix:function(t,n){var i=this.getBodyNodeFromUuid(t),r=this;"parentNode"==i.type?i.children.forEach(function(e){r.updateNodeMatrix(e.uuid,n)}):this.models.forEach(function(e){e.rootBodyNode.uuid==i.getModel().rootBodyNode.uuid&&e.updateNodeMatrix(t,n)})},updateBvh:function(){if(this.activeModel)return this.activeModel.updateBvh()},calculateNodeWorldMatrix:function(e){if(this.activeModel)return this.activeModel.calculateNodeWorldMatrix(e)},intersectPolytope:function(t){var n=[];return this.models.forEach(function(e){e=e.intersectPolytope(t);e&&0<e.length&&(n=n.concat(e))}),n},intersect:function(n,i,r){var o=[],a=this;return this.models.forEach(function(e){if(e.sketchFileUrl)return!0;var t=e.intersect(n,i,r);t&&0<t.length&&(r?o=o.concat(t):0==o.length?(o=o.concat(t),a.activeModel=e):o[0].distance>t[0].distance&&(o[0]=t[0],a.activeModel=e))}),o},intersectReferenceEntity:function(e,t){if(this.activeModel)return this.activeModel.intersectReferenceEntity(e,t)},setExplodeFactor:function(t,n){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.setExplodeFactor(t,n)})},getExplodeTranslate:function(e,t){return this.viewer.currentSketchFileUrl?this.staticModel.getExplodeTranslate(e,t):this.activeModel?this.activeModel.getExplodeTranslate(e,t):void 0},getBodyTranslate:function(t){var n=[];return this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.rootBodyNode&&e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=e.getBodyTranslate(t))}),n},getBodyTranslateWithoutExplode:function(e){return this.viewer.currentSketchFileUrl?this.staticModel.getBodyTranslateWithoutExplode(e):this.activeModel?this.activeModel.getBodyTranslateWithoutExplode(e):void 0},getBodyTransform:function(e){if(this.activeModel)return this.activeModel.getBodyTransform(e)},getLeafBodyBoundingBox:function(e){if(this.activeModel)return this.activeModel.getLeafBodyBoundingBox(e)},getLeafBodyBoundingBoxTrue:function(e){if(this.activeModel)return this.activeModel.getLeafBodyBoundingBoxTrue(e)},calculateMeshBodyBoundingBox:function(e){if(this.activeModel)return this.activeModel.calculateMeshBodyBoundingBox(e)},calculateLineBodyBoundingBox:function(e){if(this.activeModel)return this.activeModel.calculateLineBodyBoundingBox(e)},getBodyBoundingBox:function(t){var n=new THREE.Box3,i=this;return"parentNode"==t.type?t.children.forEach(function(e){n.union(i.getBodyBoundingBox(e))}):this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.rootBodyNode&&e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=e.getBodyBoundingBox(t))}),n},getVisibleBodyBoundingBox:function(t,n){var i=new THREE.Box3,r=this;return n&&!t.visible||("parentNode"==t.type?t.children.forEach(function(e){n?e.visible&&i.union(r.getVisibleBodyBoundingBox(e)):i.union(r.getBodyBoundingBox(e))}):this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n?child.visible&&(i=e.getVisibleBodyBoundingBox(t,n)):i=e.getBodyBoundingBox(t,n))})),i},getTotalVisibleBoundingBox:function(n){var i=new THREE.Box3;return this.models.forEach(function(e){if(e.sketchFileUrl)return!0;var t;(t=e.rootBodyNode?e.getVisibleBodyBoundingBox(e.rootBodyNode,n):t)&&i.union(t)}),i},getTotalBodyBoundingBox:function(){var n=new THREE.Box3;return this.models.forEach(function(e){if(e.sketchFileUrl)return!0;var t;(t=e.rootBodyNode?e.getBodyBoundingBox(e.rootBodyNode):t)&&n.union(t)}),n},getBodyBoundingBoxTrue:function(t){var n=null;return this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=e.getBodyBoundingBoxTrue(t))}),n},RemoveElement:function(e,t){if(this.activeModel)return this.activeModel.RemoveElement(e,t)},hasDraggedBodies:function(){var t=!1;return this.models.forEach(function(e){e.hasDraggedBodies()&&(t=!0)}),t},dragBody:function(t,n){this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.dragBody(t,n)})},restoreDraggedBody:function(t){this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.restoreDraggedBody(t)})},changeBodyColor:function(t,n,i){this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.changeBodyColor(t,n,i)})},hasTransparentBodies:function(){var t=!1;return this.models.forEach(function(e){e.hasTransparentBodies()&&(t=!0)}),t},transparentBody:function(t,n,i){var r=this;"parentNode"==t.type?t.children.forEach(function(e){r.transparentBody(e,n,i)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.transparentBody(t,n,i)})},opaqueBody:function(t){var n=this;"parentNode"==t.type?t.children.forEach(function(e){n.opaqueBody(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.opaqueBody(t)})},transparentizeBodies:function(r){var t=this;1==r.length&&"parentNode"==r[0].type?body.children.forEach(function(e){t.transparentizeBodies([e])}):this.models.forEach(function(e){for(var t=[],n=0;n<r.length;n++){var i=r[n];e.rootBodyNode.uuid==i.getModel().rootBodyNode.uuid&&t.push(i)}e.transparentizeBodies(t)})},transparentizeBodiesOnly:function(r,o){var t=this;1==r.length&&"parentNode"==r[0].type?r[0].children.forEach(function(e){t.transparentizeBodiesOnly([e],o)}):this.models.forEach(function(e){for(var t=[],n=0;n<r.length;n++){var i=r[n];e.rootBodyNode.uuid==i.getModel().rootBodyNode.uuid&&t.push(i)}0<t.length&&e.transparentizeBodiesOnly(t,o)})},getTransparentizedBodies:function(){var t=[];return this.models.forEach(function(e){e=e.getTransparentizedBodies();e&&0<e.length&&(t=t.concat(e))}),t},getAllTransparentBodies:function(t){var n=[];return this.models.forEach(function(e){e=e.getAllTransparentBodies(t);e&&0<e.length&&(n=n.concat(e))}),n},inIsolate:function(){var t=!1;return this.models.forEach(function(e){e.hasTransparentBodies()&&(t=!0)}),t},exitIsolate:function(){this.models.forEach(function(e){e.exitIsolate()})},isolateBodiesOnly:function(r){var t=this;1==r.length&&"parentNode"==r[0].type?r[0].children.forEach(function(e){t.isolateBodiesOnly([e])}):this.models.forEach(function(e){for(var t=[],n=0;n<r.length;n++){var i=r[n];e.rootBodyNode.uuid==i.getModel().rootBodyNode.uuid&&t.push(i)}0<t.length&&e.isolateBodiesOnly(t)})},isolateBodyOnly:function(t){var n=this;"parentNode"==t.type?t.children.forEach(function(e){n.isolateBodyOnly(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.isolateBodyOnly(t)})},isolateBodies:function(r,o,a){var t=this;1==r.length&&"parentNode"==r[0].type?body.children.forEach(function(e){t.isolateBodies([e],o,a)}):this.models.forEach(function(e){if(e.sketchFileUrl)return!0;for(var t=[],n=0;n<r.length;n++){var i=r[n];e.rootBodyNode.uuid==i.getModel().rootBodyNode.uuid&&t.push(i)}e.isolateBodies(t,o,a)})},hideBody:function(t){var n=this;"parentNode"==t.type?t.children.forEach(function(e){n.hideBody(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.hideBody(t)})},showBody:function(t){var n=this;"parentNode"==t.type?t.children.forEach(function(e){n.showBody(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.showBody(t)})},showBodyReversed:function(t){var n=this;"parentNode"==t.type?t.children.forEach(function(e){n.showBodyReversed(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.showBodyReversed(t)})},showAllBodies:function(){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.showAllBodies()})},hideAllBodies:function(t){void 0===t&&(t=!0),this.models.forEach(function(e){if(e.sketchFileUrl&&e.outCall)return!(e.outCall=!1);e.hideAllBodies(t)})},reverseBodyVisibility:function(){this.models.forEach(function(e){e.reverseBodyVisibility()})},isBodyAllChildHidden:function(t){var n=!1,i=this;return"parentNode"==t.type?t.children.forEach(function(e){i.isBodyAllChildHidden(e)}):this.models.forEach(function(e){e.rootBodyNode&&e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=e.isBodyAllChildHidden(t))}),n},isBodyAllChildSelected:function(t){var n=!1,i=this;return"parentNode"==t.type?t.children.forEach(function(e){i.isBodyAllChildSelected(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=e.isBodyAllChildSelected(t))}),n},isBodyAllChildShow:function(t){var n=!1,i=this;return"parentNode"==t.type?t.children.forEach(function(e){i.isBodyAllChildShow(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=e.isBodyAllChildShow(t))}),n},isBodyOrSomeChildHidden:function(t){var n=!1,i=this;return"parentNode"==t.type?t.children.forEach(function(e){i.isBodyOrSomeChildHidden(e)&&(n=!0)}):this.models.forEach(function(e){e.rootBodyNode&&e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&(n=e.isBodyOrSomeChildHidden(t))}),n},unloadModel:function(e){this.viewer.annotationsManager&&this.viewer.annotationsManager.unloadAnnotation(this.models[e].rootBodyNode.uuid),this.models.splice(e,1)},getSelectedBodies:function(){var t=[];return this.models.forEach(function(e){e=e.getSelectedBodies();e&&0<e.length&&(t=t.concat(e))}),t},clearSelection:function(){this.models.forEach(function(e){e.clearSelection()})},addSelection:function(t){var n=this;"parentNode"==t.type?t.children.forEach(function(e){n.addSelection(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.addSelection(t)})},selectPMIObject:function(e,t){if(this.activeModel)return this.activeModel.selectPMIObject(e,t)},deselectPMIObject:function(e,t){if(void 0===t&&(t=!0),this.activeModel)return this.activeModel.deselectPMIObject(e,t)},removeSelection:function(t){var n=this;"parentNode"==t.type?t.children.forEach(function(e){n.removeSelection(e)}):this.models.forEach(function(e){e.rootBodyNode.uuid==t.getModel().rootBodyNode.uuid&&e.removeSelection(t)})},preSelectObject:function(e){if(this.activeModel)return this.activeModel.preSelectObject(e)},clearPreSelection:function(){if(this.activeModel)return this.activeModel.clearPreSelection()},sortBodies:function(e){if(this.activeModel)return this.activeModel.sortBodies(e)},sortBodiesByVolume:function(e){if(this.activeModel)return this.activeModel.sortBodiesByVolume(e)},getGeometriesCount:function(){if(this.activeModel)return this.activeModel.getGeometriesCount()},getStaticGeometriesCount:function(){if(this.staticModel)return this.staticModel.getGeometriesCount()},updateBodyMeshIds:function(){if(this.activeModel)return this.activeModel.updateBodyMeshIds()},delete:function(e){if(this.activeModel)return this.activeModel.delete(e)},addReferenceEntity:function(e){if(this.activeModel)return this.activeModel.addReferenceEntity(e)},addReferenceEntities:function(e){if(this.activeModel)return this.activeModel.addReferenceEntities(e)},sortMeshSets:function(e,t){if(this.activeModel)return this.activeModel.sortMeshSets(e,t)},setDirty:function(){this.models.forEach(function(e){e.setDirty()})},backupDirty:function(){this.models.forEach(function(e){e.backupDirty()})},resetDirty:function(){this.models.forEach(function(e){e.resetDirty()})},dispose:function(){this.models.forEach(function(e){e.dispose()})}},Object.defineProperties(Xt.prototype,{id:{get:function(){return this.activeModel.id}},needsFastRendering:{get:function(){return this.activeModel.needsFastRendering},set:function(e){this.activeModel.needsFastRendering=e}},leafNodeCount:{get:function(){return this.activeModel.leafNodeCount},set:function(e){this.activeModel.leafNodeCount=e}},sptIndex:{get:function(){return this.activeModel.sptIndex},set:function(e){this.activeModel.sptIndex=e}},drawMode:{get:function(){return this.activeModel.drawMode},set:function(e){this.activeModel.drawMode=e}},renderOnce:{get:function(){return this.activeModel.renderOnce},set:function(e){this.activeModel.renderOnce=e}},renderMeshSetCount:{get:function(){return this.activeModel.renderMeshSetCount},set:function(e){this.activeModel.renderMeshSetCount=e}},spriteDirty:{get:function(){return this.activeModel.spriteDirty},set:function(e){this.activeModel.spriteDirty=e}},rootBodyNode:{get:function(){return this.activeModel?this.activeModel.rootBodyNode:null},set:function(e){this.activeModel.rootBodyNode=e}},is2DModel:{get:function(){return this.activeModel.is2DModel},set:function(e){this.activeModel.is2DModel=e}},hasRawMesh:{get:function(){return this.activeModel.hasRawMesh},set:function(e){this.activeModel.hasRawMesh=e}},bvhCreater:{get:function(){return this.activeModel.bvhCreater},set:function(e){this.activeModel.bvhCreater=e}},transparentBodiesDirty:{get:function(){return this.activeModel.transparentBodiesDirty},set:function(e){this.activeModel.transparentBodiesDirty=e}},transparentBodyChanged:{get:function(){return this.activeModel.transparentBodyChanged},set:function(e){this.activeModel.transparentBodyChanged=e}},selectedBodiesDirty:{get:function(){return this.activeModel.selectedBodiesDirty},set:function(e){this.activeModel.selectedBodiesDirty=e}},preselectedObject:{get:function(){return this.activeModel.preselectedObject},set:function(e){this.activeModel.preselectedObject=e}},modelUri:{get:function(){return this.activeModel.modelUri},set:function(e){this.activeModel.modelUri=e}},referenceEntityDirty:{get:function(){return this.activeModel.referenceEntityDirty},set:function(e){this.activeModel.referenceEntityDirty=e}},hasHiddenBodies:{get:function(){return this.activeModel.hasHiddenBodies},set:function(e){this.activeModel.hasHiddenBodies=e}},explodeFactor:{get:function(){return(this.viewer.currentSketchFileUrl?this.staticModel:this.activeModel).explodeFactor},set:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.explodeFactor=t})}},explodeFactorX:{get:function(){return(this.viewer.currentSketchFileUrl?this.staticModel:this.activeModel).explodeFactorX},set:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.explodeFactorX=t})}},explodeFactorY:{get:function(){return(this.viewer.currentSketchFileUrl?this.staticModel:this.activeModel).explodeFactorY},set:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.explodeFactorY=t})}},explodeFactorZ:{get:function(){return(this.viewer.currentSketchFileUrl?this.staticModel:this.activeModel).explodeFactorZ},set:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.explodeFactorZ=t})}},meshManager:{get:function(){return this.activeModel.meshManager},set:function(e){this.activeModel.meshManager=e}},explodeMode:{get:function(){return(this.viewer.currentSketchFileUrl?this.staticModel:this.activeModel).explodeMode},set:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.explodeMode=t})}},explodeLevel:{get:function(){return(this.viewer.currentSketchFileUrl?this.staticModel:this.activeModel).explodeLevel},set:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.explodeLevel=t})}},explodeObject:{get:function(){return(this.viewer.currentSketchFileUrl?this.staticModel:this.activeModel).explodeObject},set:function(t){this.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.explodeObject=t})}},wholeLeafBodyNodes:{get:function(){return this.activeModel.wholeLeafBodyNodes},set:function(e){this.activeModel.wholeLeafBodyNodes=e}},geomManager:{get:function(){return this.activeModel.geomManager},set:function(e){this.activeModel.geomManager=e}},pureLineBody:{get:function(){return this.activeModel.pureLineBody},set:function(e){this.activeModel.pureLineBody=e}},ModelUpMatrix4:{get:function(){return this.activeModel.ModelUpMatrix4},set:function(e){this.activeModel.ModelUpMatrix4=e}},hideBodies:{get:function(){var t=[];return this.models.forEach(function(e){t=t.concat(e.hideBodies)}),t}},UnloadNodes:{get:function(){var t=[];return this.models.forEach(function(e){t=t.concat(e.UnloadNodes)}),t}},forceRenderAll:{get:function(){return this.activeModel.forceRenderAll},set:function(e){this.activeModel.forceRenderAll=e}}});function Zt(e,t,n,i,r,o){void 0===o&&(o=!0),this.viewer=e,this.renderScene=n,this.renderCamera=i,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new THREE.Color(255,255,255),this.edgeThickness=1,this.edgeStrength=1,this.downSampleRatio=2,this.shouldRenderMaskDownSample=o,c.call(this),this.resolution=void 0!==t?new THREE.Vector2(t.x,t.y):new THREE.Vector2(256,256),e={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat},n=Math.round(this.resolution.x/this.downSampleRatio),i=Math.round(this.resolution.y/this.downSampleRatio),this.maskBufferMaterial=new THREE.MeshBasicMaterial({color:255}),this.maskBufferMaterial.side=THREE.DoubleSide,this.maskBufferMaterialCopy=(new this.maskBufferMaterial.constructor).copy(this.maskBufferMaterial),r=this.shouldRenderMaskDownSample?this.resolution.x:n,o=this.shouldRenderMaskDownSample?this.resolution.y:i,this.renderTargetMaskBuffer=new THREE.WebGLRenderTarget(r,o,e),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.shouldRenderMaskDownSample&&(this.renderTargetMaskDownSampleBuffer=new THREE.WebGLRenderTarget(n,i,e),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1),this.renderTargetBlurBuffer1=new THREE.WebGLRenderTarget(n,i,e),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new THREE.WebGLRenderTarget(n,i,e),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.separableBlurMaterial1=this.getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value=new THREE.Vector2(n,i),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.overlayMaterial=this.getOverlayMaterial(),t=je,this.copyUniforms=THREE.UniformsUtils.clone(t.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new THREE.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,blending:THREE.NoBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new THREE.Color,this.oldClearAlpha=1,this.camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),this.scene=new THREE.Scene,this.quad=new THREE.Mesh(new THREE.PlaneGeometry(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)}function qt(e,t,n,i,r){this.tempSelectedObjects=[],this.tempScene=new THREE.Scene,Zt.call(this,e,t,n,i,r),this.visibleEdgeColor=new THREE.Color(0,1,0),this.edgeThickness=3,this.edgeStrength=3,this.downSampleRatio=2,this.tempPulseColor1=new THREE.Color,this.tempPulseColor2=new THREE.Color,this.textureMatrix=new THREE.Matrix4}function Kt(e,t,n,i){Zt.call(this,e,t,n,i,void 0,!0),this.visibleEdgeColor=new THREE.Color(250,225,0),this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2}function Jt(e,t){this.textureID=void 0!==t?t:"tDiffuse",this.uniforms=THREE.UniformsUtils.clone(e.uniforms),this.material=new THREE.ShaderMaterial({uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,defines:THREE.UniformsUtils.clone(e.defines)}),this.renderToScreen=!1,this.enabled=!0,this.clear=!1,this.camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1);var t=new THREE.BufferGeometry,n=((e=new Float32Array(9))[0]=-1,e[1]=-1,e[2]=0,e[3]=3,e[4]=-1,e[5]=0,e[6]=-1,e[7]=3,e[8]=0,new Float32Array(6));n[0]=0,n[1]=0,n[2]=2,n[3]=0,n[4]=0,n[5]=2,t.addAttribute("position",new THREE.BufferAttribute(e,3)),t.addAttribute("uv",new THREE.BufferAttribute(n,2)),this.quad=new THREE.Mesh(t,this.material),this.scene=new THREE.Scene,this.scene.add(this.quad)}function $t(e,t,n){this.baseUrl=e,this.options=t,this.crossOrigin=n}function en(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager}function tn(e){function o(){if(c=[],d&&0<d.length)for(var e,t=0;t<d.length;++t)d[t]&&(e=h.clipAction(d[t]),null!=d[t].timeScale&&(e.timeScale=d[t].timeScale),c.push(e))}var l=this,d=null,c=[],h=null,a=null,u=0,s=!0,t=0,p=!1,f=1e3/30,m=null,n=!1,r=0,g=(this.viewer=e,this.bHasSkeletonAnimation=!1,this.bHasSolidAnimation=!1,this.bHasMorph=!1,this.bHasInitSleletonAnimation=!1,this.skeletonAnimationObjects=[],null),v=(this.morphMixer=null,this.morphClipActions=[],new THREE.Clock);this.initMorphAnimations=function(){var r=this.viewer.scene;r.traverse(function(e){if(e instanceof THREE.Mesh){var t=e;t.parent;if(null==l.morphMixer&&(l.morphMixer=new THREE.AnimationMixer(r),l.morphMixer.addEventListener("finished",function(e){p=!0})),t.geometry.animations&&0<t.geometry.animations.length){t.material.morphTargets=!0;for(var n=0;n<t.geometry.animations.length;n++){var i=l.morphMixer.clipAction(t.geometry.animations[n],t);l.morphClipActions.push(i)}}}}),this.viewer.onBoxSectionView(!0),this.viewer.onBoxSectionView(!1)},this.updateMorphAnimation=function(e){null!=this.morphMixer&&(this.morphMixer.update(e),l.viewer.render())},this.updateSkeletonAnimation=function(e){for(var t=0;t<l.skeletonAnimationObjects.length;t++){var n=l.skeletonAnimationObjects[t].mixer;if(n){n.update(e);for(var i=0;i<l.skeletonAnimationObjects[t].actionSkinMeshs.length;i++)l.skeletonAnimationObjects[t].actionSkinMeshs[i].skingMesh.updateMatrixWorld(!0);l.viewer.render()}}},this.initSkeletonAnimation=function(){if(!this.bHasInitSleletonAnimation){this.bHasInitSleletonAnimation=!0;var e=this.viewer.scene,n=[],i=[],t=(e.traverse(function(e){var t;e instanceof THREE.Mesh&&(t=e.parent,n.push(e),i.push(t))}),new an),r=null;t.name="AnimationRoot",this.skeletonAnimationObjects.push(t);for(var o,a,s=0;s<n.length;s++)if(n[s].geometry.animations&&0<n[s].geometry.animations.length){i[s].remove(n[s]),n[s].material.skinning=!0;var l=new THREE.SkinnedMesh(n[s].geometry,n[s].material),d=(o=n[s],(a=l).position.copy(o.position),a.quaternion.copy(o.quaternion),a.scale.copy(o.scale),a.updateMatrixWorld(!0),i[s].add(l),r||(r=new THREE.AnimationMixer(l.parent),t.mixer=r),new on);d.skingMesh=l;for(var c=0;c<l.geometry.animations.length;c++){var h=r.clipAction(l.geometry.animations[c],l),u=(h.name=l.geometry.animations[c].name,d.actions.push(h),l.geometry.animations[c].animationUUID);d.actionMap[u]=h}t.actionSkinMeshs.push(d)}this.viewer.selectionManager.computeTargetList(e),this.viewer.recordOriginalMeshes(),r&&r.addEventListener("finished",function(e){p=!0})}},this.getCurrentAnimationUuid=function(){return g},this.getAnimationsExitCount=function(){return r},this.isMaterialsUpdated=function(){return n},this.setMaterialsUpdated=function(e){n=e},this.getCurrentAnimationScene=function(){return a&&a.animationScene?a.animationScene:null},this.getAllAnimationScenes=function(){if(d){for(var e=[],t=0;t<d.length;++t)d[t]&&d[t].animationScene&&e.push(d[t].animationScene);return e}return null},this.getAnimationFinishedFlag=function(){return p},this.setAnimationFinishedFlag=function(e){p=e},this.setAnimationLoopReatDelayTime=function(e){t=e},this.getAnimationLoopReatDelayTime=function(){return t},this.delayAnimation=function(){},this.initSolidAnimations=function(e,t){m=e,d=t,(h=new THREE.AnimationMixer(e)).addEventListener("finished",function(e){p=!0}),o()},this.update=function(){var e,t;return!p&&(e=!1,t=v.getDelta(),h&&(h.update(t),e=!0),this.bHasSkeletonAnimation&&(this.updateSkeletonAnimation(t),e=!0),this.bHasMorph&&(this.updateMorphAnimation(t),e=!0),e)},this.hasAnimations=function(){return this.bHasSkeletonAnimation||this.bHasSolidAnimation||this.bHasMorph},this.hasSolidAnimations=function(){return this.bHasSolidAnimation},this.getAllAnimationsInfo=function(){if(!this.hasAnimations())return null;var e={animations:[]};if(d&&0<d.length)for(var t=0;t<d.length;++t)d[t]&&0<d[t].tracks.length&&0<d[t].duration&&((r={}).duration=d[t].duration,r.name=d[t].name,r.uuid=d[t].uuid,r.fps=d[t].fps,r.version="1.00",e.animations.push(r));else if(!this.bHasSolidAnimation&&this.bHasSkeletonAnimation){var n,i=this.skeletonAnimationObjects[0].actionSkinMeshs[0].actionMap;for(n in i)(r={}).duration=i[n]._clip.duration,r.name=i[n]._clip.name,r.uuid=n,r.fps=i[n]._clip.fps,r.version="1.00",e.animations.push(r)}else if(this.bHasMorph)for(var r,o=0;o<l.morphClipActions.length;o++)(r={}).duration=l.morphClipActions[o]._clip.duration,r.name=l.morphClipActions[o]._clip.name,r.uuid=l.morphClipActions[o]._clip.uuid,r.fps=l.morphClipActions[o]._clip.ndsFps,r.version="1.00",e.animations.push(r);return e},this.getAnimationInfoByUUID=function(e){if(this.hasAnimations())if(d&&0<d.length){null==e&&(e=d[0].uuid);for(var t=0;t<d.length;++t)if(d[t])if(d[t].uuid==e&&0<d[t].tracks.length&&0<d[t].duration)return(r={}).duration=d[t].duration,r.name=d[t].name,r.uuid=d[t].uuid,r.fps=d[t].fps,r.version="1.00",r}else if(!this.bHasSolidAnimation&&this.bHasSkeletonAnimation){var n,i=this.skeletonAnimationObjects[0].actionSkinMeshs[0].actionMap;for(n in i)if(n==e)return(r={}).duration=i[n]._clip.duration,r.name=i[n]._clip.name,r.uuid=n,r.fps=i[n]._clip.fps,r.version="1.00",r}else{var r;if(this.bHasMorph)return(r={}).duration=l.morphClipActions[0]._clip.duration,r.name=l.morphClipActions[0]._clip.name,r.uuid=l.morphClipActions[0]._clip.uuid,r.fps=l.morphClipActions[0]._clip.ndsFps,r.version="1.00",r}return null},this.startMorphAnimationByUUID=function(e,t){if(this.bHasMorph){if(p=s=!1,null==e)null!=t&&!t||(g=l.morphClipActions[0]._clip.uuid,l.morphClipActions[0].play());else if(g!=e){for(var n=0;n<l.morphClipActions.length;n++)l.morphClipActions[n]._clip.uuid==e&&(l.morphClipActions[n].enabled=!1,l.morphClipActions[n].stop());g=e}for(n=0;n<l.morphClipActions.length;n++){var i=l.morphClipActions[n];i.isRunning()||i.time>=i._clip.duration&&(i.reset(),v=new THREE.Clock),i.enabled=!0,i.paused=!t,i.play()}}},this.startSkeletonAnimationByUUID=function(e,t){if(this.bHasSkeletonAnimation)if(p=s=!1,null==e){if(null==t||t){g=this.skeletonAnimationObjects[0].actionSkinMeshs[0].actions[0]._clip.animationUUID;for(var n=0;n<this.skeletonAnimationObjects[0].actionSkinMeshs.length;n++)this.skeletonAnimationObjects[0].actionSkinMeshs[n].skingMesh.material.skinning=!0,this.skeletonAnimationObjects[0].actionSkinMeshs[n].actions[0].play();this.viewer.onBoxSectionView(!0),this.viewer.onBoxSectionView(!1)}}else{if(g!=e){for(n=0;n<this.skeletonAnimationObjects[0].actionSkinMeshs.length;n++)for(r in(i=this.skeletonAnimationObjects[0].actionSkinMeshs[n]).actionMap)r==g&&(i.actionMap[r].enabled=!1,i.actionMap[r].stop());g=e}for(var i,r,o,n=0;n<this.skeletonAnimationObjects[0].actionSkinMeshs.length;n++)for(r in(i=this.skeletonAnimationObjects[0].actionSkinMeshs[n]).skingMesh.material.skinning=!0,i.actionMap)r==e&&((o=i.actionMap[r]).isRunning()||o.time>=o._clip.duration&&(o.reset(),v=new THREE.Clock),o.enabled=!0,o.paused=!t,o.play())}},this.startSolidAnimationByUUID=function(e,t){if(d&&0<d.length){var n=a,i=u;if(null==e)null==a&&(a=d[0],g=d[0].uuid,u=0);else for(var r=0;r<d.length;++r)if(d[r].uuid==e){a=d[r],u=r;break}n&&n!=a&&c[i].stop(),n!=a&&(h=a.animationScene?new THREE.AnimationMixer(a.animationScene):new THREE.AnimationMixer(m),o(),h.addEventListener("finished",function(e){p=!0})),a&&(i=c[u])&&(null==t||t?(i.isRunning()||i.time>=i._clip.duration&&(i.reset(),v=new THREE.Clock),i.paused=!1,i.play(),s=p=!1,f=1e3/a.fps):i.paused=!0)}return a},this.getAnimationLoopModeByUUID=function(e){var t="loopRepeat";if(d&&0<d.length){if(null!=e)for(var n=0;n<d.length;++n)if(d[n].uuid==e){d[n].loop==THREE.LoopOnce?t="loopOnce":d[n].loop==THREE.LoopRepeat&&(t="loopRepeat");break}}else if(!this.bHasSolidAnimation&&this.bHasSkeletonAnimation){if(null!=e)for(var i in this.skeletonAnimationObjects[0].actionSkinMeshs[0].actionMap)i==e&&(this.skeletonAnimationObjects[0].actionSkinMeshs[0].actionMap[i].loop==THREE.LoopOnce?t="loopOnce":this.skeletonAnimationObjects[0].actionSkinMeshs[0].actionMap[i].loop==THREE.LoopRepeat&&(t="loopRepeat"))}else if(l.bHasMorph&&null!=e)for(var r=0;r<l.morphClipActions.length;r++)e==l.morphClipActions[r]._clip.uuid&&(l.morphClipActions[r].loop==THREE.LoopOnce?t="loopOnce":l.morphClipActions[r].loop==THREE.LoopRepeat&&(t="loopRepeat"));return t},this.setAnimationLoopModeByUUID=function(e,t){if(d&&0<d.length&&null!=e)for(var n=0;n<d.length;++n)if(d[n].uuid==e){"loopOnce"==t?d[n].loop=THREE.LoopOnce:"loopRepeat"==t&&(d[n].loop=THREE.LoopRepeat);var i=h.clipAction(d[n]);i&&(i.loop=d[n].loop);break}if(this.bHasSkeletonAnimation&&null!=e)for(var r=0;r<this.skeletonAnimationObjects[0].actionSkinMeshs.length;r++)for(var o=this.skeletonAnimationObjects[0].actionSkinMeshs[r],a=0;a<o.actions.length;a++)o.actions[a]._clip.animationUUID==e&&("loopOnce"==t?o.actions[a].loop=THREE.LoopOnce:"loopRepeat"==t&&(o.actions[a].loop=THREE.LoopRepeat));if(l.bHasMorph&&null!=e)for(r=0;r<l.morphClipActions.length;r++){var s=l.morphClipActions[r];s._clip.uuid==e&&("loopOnce"==t?s.loop=THREE.LoopOnce:"loopRepeat"==t&&(s.loop=THREE.LoopRepeat))}},this.getCurrentAnimationTime=function(){if(a){var e=c[u];if(e)return e.time}if(!this.bHasSolidAnimation&&this.bHasSkeletonAnimation){var t,n=this.skeletonAnimationObjects[0].actionSkinMeshs[0];for(t in n.actionMap)if(t==g)return n.actionMap[t].time}if(l.bHasMorph)for(var i=0;i<l.morphClipActions.length;i++){var r=l.morphClipActions[i];if(r._clip.uuid==g)return r.time}return 0},this.getCurrentAnimationDuration=function(){if(a)return a.duration;if(!this.bHasSolidAnimation&&this.bHasSkeletonAnimation){var e,t=this.skeletonAnimationObjects[0].actionSkinMeshs[0];for(e in t.actionMap)if(e==g)return t.actionMap[e]._clip.duration}if(l.bHasMorph)for(var n=0;n<l.morphClipActions.length;n++){var i=l.morphClipActions[n];if(i._clip.uuid==g)return i._clip.duration}return 0},this.setAnimationTimeByUUID=function(e,t){if(d&&0<d.length&&null!=e)for(var n=0;n<d.length;++n)if(d[n].uuid==e){var i=c[u];i&&(i.time=Math.floor(1e3*t/f)*f*.001);break}if(this.bHasSkeletonAnimation)for(var r=0;r<this.skeletonAnimationObjects[0].actionSkinMeshs.length;r++){var o,a=this.skeletonAnimationObjects[0].actionSkinMeshs[r];for(o in a.actionMap)o==e&&(a.actionMap[o].time=Math.floor(1e3*t/f)*f*.001)}if(l.bHasMorph)for(r=0;r<l.morphClipActions.length;r++){var s=l.morphClipActions[r];s._clip.uuid==e&&(s.time=Math.floor(1e3*t/f)*f*.001)}},this.getAnimationScaleByUUID=function(e){var t=1;if(d&&0<d.length&&null!=e)for(var n=0;n<d.length;++n)if(d[n].uuid==e){t=c[n].timeScale;break}if(!this.bHasSolidAnimation&&this.bHasSkeletonAnimation){var i,r=this.skeletonAnimationObjects[0].actionSkinMeshs[0];for(i in r.actionMap)if(i==e)return r.actionMap[i].timeScale}if(l.bHasMorph)for(var o=0;o<l.morphClipActions.length;o++){var a=l.morphClipActions[o];if(a._clip.uuid==e)return a.timeScale}return t},this.setAnimationScaleByUUID=function(e,t){if(d&&0<d.length&&null!=e)for(var n=0;n<d.length;++n)if(d[n].uuid==e){c[n].timeScale=t,d[n].timeScale=t;break}if(null!=e){if(this.bHasSkeletonAnimation)for(var i=0;i<this.skeletonAnimationObjects[0].actionSkinMeshs.length;i++){var r,o=this.skeletonAnimationObjects[0].actionSkinMeshs[i];for(r in o.actionMap)r==e&&(o.actionMap[r].timeScale=t)}if(l.bHasMorph)for(i=0;i<l.morphClipActions.length;i++){var a=l.morphClipActions[i];a._clip.uuid==e&&(a.timeScale=t)}}},this.isAnimationsExited=function(){return s},this.exitAnimations=function(){if(a&&c[u].stop(),this.bHasSkeletonAnimation)for(var e=0;e<this.skeletonAnimationObjects[0].actionSkinMeshs.length;e++){var t,n=this.skeletonAnimationObjects[0].actionSkinMeshs[e];for(t in n.actionMap)n.actionMap[t].stop(),n.actionMap[t].reset()}if(l.bHasMorph)for(e=0;e<l.morphClipActions.length;e++){var i=l.morphClipActions[e];i.stop(),i.reset()}s=!0,++r}}function nn(e){this.viewer=e;var x=this,n=null,I={},T={},A={},y={lineWidth:1,strokeStyle:"#000000"},E="",S="",M=!1,w=null,h=[],t="lineSeg",i=!1,u=null,p=null,f=null,m=null,g=null,v=null,b=null,B=null,P=null,C=null,R=(this.tempVector3=new THREE.Vector3,this.viewer.renderer.domElement),O=new THREE.WebGLRenderTarget(R.width,R.height,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1}),L=(O.texture.generateMipmaps=!1,new THREE.Scene),D=new THREE.MeshBasicMaterial,H=(D.side=THREE.DoubleSide,this.viewer.ndsModel?(new D.constructor).copy(D):null),o=10,r=new THREE.ShaderMaterial({vertexShader:V.vertexShader,fragmentShader:V.fragmentShader}),F=(r.side=THREE.DoubleSide,null);function N(e,t){var n=t?"annotationLogoSelected":"annotationLogo";return null!=e&&("ImageAnno"==e?n=t?"imgAnnotationLogoSelected":"imgAnnotationLogo":"ViewportAnno"==e?n=t?"viewportAnnotationLogoSelected":"viewportAnnotationLogo":"VideoAnno"==e?n=t?"videoAnnotationLogoSelected":"videoAnnotationLogo":"AudioAnno"==e&&(n=t?"AudioAnnotationLogoSelected":"AudioAnnotationLogo")),n}function j(){var e,t,n,i,r=null,o=new THREE.Box2,a=x.viewer.renderer.domElement.width/2,s=x.viewer.renderer.domElement.height/2,l=x.viewer.renderer.getPixelRatio(),d=new THREE.Vector3;for(p in I)(f=I[p])&&(null!=f.type&&null!=f.type&&"lineSeg"==f.type?d.set(f.coords[f.coords.length-3],f.coords[f.coords.length-2],f.coords[f.coords.length-1]):d.copy((e=f,i=n=t=void 0,(i=new THREE.Vector3).set(e.coords[0],e.coords[1],e.coords[2]),e.locationObjectUUID&&""!=e.locationObjectUUID&&(e.locationObject||(e.locationObject=x.viewer.ndsModel.getBodyNodeFromUuid(e.locationObjectUUID)),!e.locationObject&&x.viewer.ndsModel&&e.fileguid&&(t=null,(n=x.viewer.ndsModel.fileguidTouuid[e.fileguid])&&0<n.length&&(t=x.viewer.ndsModel.getRightBodyuuid(e.rootfileguid,n)),n=x.viewer.ndsModel.bodyUuid2NodeMap[t])&&n.children&&!n.children[e.BodyfileID]&&(n=n.children[e.BodyfileID],e.locationObject=n),e.locationObject)&&("4"==e.version||"5"==e.version?x.viewer.ndsModel?0<=e.locationObject.id&&(t=x.viewer.ndsModel.getBodyTranslate(e.locationObject),i.x+=t[0],i.y+=t[1],i.z+=t[2]):i.applyMatrix4(e.locationObject.matrixWorld):e.locationObject.matrixWorldTransOrginal&&((n=new THREE.Vector3).setFromMatrixPosition(e.locationObject.matrixWorld),n.sub(e.locationObject.matrixWorldTransOrginal),i.add(n)),T[e.uuid])&&T[e.uuid].position.copy(i),i)),f.worldPosition=d.clone(),d.project(x.viewer.camera),d.x=Math.round(d.x*a+a),d.y=Math.round(-d.y*s+s),f.screenPosition=d.clone(),0<=d.x)&&d.x<=O.width&&0<=d.y&&d.y<=O.height&&o.expandByPoint(d),S==p&&(t=(t=document.getElementById("calcAudioShow"))&&"none"!=t.style.display?t:document.getElementById("calcPicTextShow"))&&"none"!=t.style.display&&(t.style.left=d.x/l+4+"px",t.style.top=d.y/l+8+"px");if(x.viewer.isRotationEnable()){var c,h,u,p,f;d.y=d.x=4,o.expandByVector(d),o.min.x<0&&(o.min.x=0),o.min.y<0&&(o.min.y=0),o.max.x>O.width&&(o.max.x=O.width),o.max.y>O.height&&(o.max.y=O.height),o.isEmpty()||(c=x.viewer.scene.overrideMaterial,h=x.viewer.renderer.getClearColor(x.viewer.oldClearColor).clone(),u=x.viewer.renderer.getClearAlpha(),x.viewer.scene.overrideMaterial=D,x.viewer.renderer.setClearColor(3),x.viewer.ndsModel&&(x.viewer.ndsModel.backupDirty(),x.viewer.ndsModel.setDirty(),x.viewer.ndsModel.setDrawMode(x.viewer.ndsModel.SHADED),x.viewer.scene.children.push(x.viewer.ndsModel),x.viewer.ndsModel.setOverrideMaterial(D,H,!1)),x.viewer.renderer.render(x.viewer.scene,x.viewer.camera,O,!0),x.viewer.scene.overrideMaterial=c,x.viewer.ndsModel&&(x.viewer.ndsModel.setOverrideMaterial(null,null,!1),x.viewer.ndsModel.resetDirty()),x.viewer.renderer.render(L,x.viewer.camera,O,!1),A=o.max.x-o.min.x,y=o.max.y-o.min.y,r=new Uint8Array(4*A*y),x.viewer.renderer.readRenderTargetPixels(O,o.min.x,O.height-o.max.y,A,y,r),x.viewer.renderer.setRenderTarget(null),x.viewer.renderer.setClearColor(h,u));for(p in I)if(f=I[p]){var m=!0;if("1"!=f.version){var g=T[f.uuid];if(g&&r)for(var v=g.material.color.getHex(""),A=o.max.x-o.min.x,y=o.max.y-o.min.y,m=!1,E=f.screenPosition.x-1;E<=f.screenPosition.x+1&&E<=o.max.x&&E>=o.min.x;++E){for(var M=f.screenPosition.y-1;M<=f.screenPosition.y+1&&M<=o.max.y&&M>=o.min.y;++M){var w=4*((y-(M-o.min.y))*A+(E-o.min.x)),w=r[w]<<16|r[1+w]<<8|r[2+w];if(Math.abs(w-v)<3){m=!0;break}}if(1==m)break}}else{var g=f.worldPosition.clone(),b=(g.clone(),x.viewer.camera.position.distanceTo(g)),b=new THREE.Raycaster(x.viewer.camera.position,g.sub(x.viewer.camera.position).normalize(),0,.9999*b).intersectObjects(x.viewer.selectionManager.getTargetList());0<b.length&&b[0].point&&(m=!1)}f.bShowAnnoOpacity=m}}}this.getAnnotationJsonArray=function(){return n},this.getAnnotationsArray=function(){return I},this.getSelectAnnotation=function(){return S},this.getDepthRGBAMaterial=function(){return r},this.getRenderTarget=function(){return O},this.setSize=function(e,t){e==O.width&&t==O.height||(O.dispose(),(O=new THREE.WebGLRenderTarget(e,t,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1})).texture.generateMipmaps=!1)},this.listenAnnotation=function(e){(F=e)&&A[F]&&x.viewer.dispatchEvent({type:"annotationMoved",annotationDiv:A[F]})},this.setAnnotationMode=function(e){null!=e&&(t=e)},this.getAnnotationMode=function(){return t},this.setLineSegAnnotationStyle=function(e){e&&(null!=e.lineWidth&&(y.lineWidth=e.lineWidth),null!=e.strokeStyle)&&(y.strokeStyle=e.strokeStyle)},this.getLineSegAnnotationStyle=function(){return y},this.getposFromFileGuid=function(e,t,n){var i,r=e.fileguid,o=e.rootfileguid,a=e.matrix,s=e.BodyfileID,l=e.explodeFactor,r=x.viewer.ndsModel.fileguidTouuid[r],d=null;return null!=(d=r&&0<r.length?x.viewer.ndsModel.getRightBodyuuid(o,r):d)&&!!((o=x.viewer.ndsModel.bodyUuid2NodeMap[d])&&o.children&&o.children[s]&&o.children[s].uuid)&&(r=o.children[s],(d=x.viewer.ndsModel.getExplodeTranslate(4*l,r))[0]+=e.translate[0],d[1]+=e.translate[1],d[2]+=e.translate[2],(o=new THREE.Matrix4).fromArray(a),s=r.worldMatrix,null!=t.cx&&(i=new THREE.Vector3(t.cx,t.cy,t.cz),null!=n&&0!=n&&(i.x-=e.annoTranslate[0],i.y-=e.annoTranslate[1],i.z-=e.annoTranslate[2]),i.applyMatrix4(o),i.applyMatrix4(s),null!=n&&0!=n&&(i.x+=d[0],i.y+=d[1],i.z+=d[2]),t.cx=i.x,t.cy=i.y,t.cz=i.z),null!=t.x&&(i=new THREE.Vector3(t.x,t.y,t.z),null!=n&&0!=n&&(i.x-=e.annoTranslate[0],i.y-=e.annoTranslate[1],i.z-=e.annoTranslate[2]),i.applyMatrix4(o),i.applyMatrix4(s),null!=n&&0!=n&&(i.x+=d[0],i.y+=d[1],i.z+=d[2]),t.x=i.x,t.y=i.y,t.z=i.z),null!=t.cx2&&(i=new THREE.Vector3(t.cx2,t.cy2,t.cz2),null!=n&&0!=n&&(i.x-=e.annoTranslate[0],i.y-=e.annoTranslate[1],i.z-=e.annoTranslate[2]),i.applyMatrix4(o),i.applyMatrix4(s),null!=n&&0!=n&&(i.x+=d[0],i.y+=d[1],i.z+=d[2]),t.cx2=i.x,t.cy2=i.y,t.cz2=i.z),!0)},this.getCamupFromFileGuid=function(e,t){var n,i=e.fileguid,r=e.rootfileguid,o=e.matrix,e=e.BodyfileID,i=x.viewer.ndsModel.fileguidTouuid[i],a=null;return null!=(a=i&&0<i.length?x.viewer.ndsModel.getRightBodyuuid(r,i):a)&&!!((r=x.viewer.ndsModel.bodyUuid2NodeMap[a])&&r.children&&r.children[e]&&r.children[e].uuid)&&(i=r.children[e],(a=new THREE.Matrix4).fromArray(o),r=i.worldMatrix,e=new THREE.Vector3(t.x,t.y,t.z),o=new THREE.Quaternion,i=new THREE.Vector3,n=new THREE.Vector3,a.decompose(i,o,n),e.applyQuaternion(o),r.decompose(i,o,n),e.applyQuaternion(o),t.x=e.x,t.y=e.y,t.z=e.z,!0)},this.selectAnnotation=function(e){var t,n,i,r,o,a,s,l,d,c;M=!1,S&&""!=S&&this.resetSelectAnnotation(!0),null==e?E="":(S=E=e,u=x.viewer.getExplodeFactor(),m=x.viewer.getExplodeMode(),p=x.viewer.getExplodeLevel(),f=x.viewer.explodeObjects.concat(),(t=x.getAnnotation(e))&&t.cameraInfo&&(x.viewer.restoreAllDraggedObjects(!1),null==g&&(g=x.viewer.camera.position.clone(),v=x.viewer.camera.target.clone(),b=x.viewer.camera.up.clone(),B=x.viewer.camera.far,P=x.viewer.camera.near,C=x.viewer.camera.IsPerspective()),n=t.cameraInfo.far,t.other&&!t.haschange&&t.rootfileguid&&t.fileguid&&t.translate&&(this.getposFromFileGuid(t,t.cameraInfo.position,!0),this.getposFromFileGuid(t,t.cameraInfo.target,!0),this.getCamupFromFileGuid(t,t.cameraInfo.up),t.haschange=!0,t.cameraInfo.modelScreenBBox=x.viewer.computeModelScreenBBox()),!t.locationObject&&t.locationObjectUUID&&(x.viewer.ndsModel?t.locationObject=x.viewer.ndsModel.getBodyNodeFromUuid(t.locationObjectUUID):t.locationObject=x.viewer.modelRootObject.getObjectByProperty("uuid",t.locationObjectUUID)),t.bOnModel&&t.locationObject&&t.translate&&(i=t.locationObject,0<(h=x.viewer.ndsModel.getBodyTranslateWithoutExplode(i)).length)&&(r=new THREE.Vector3(t.translate[0]-h[0],t.translate[1]-h[1],t.translate[2]-h[2]),x.viewer.ndsModel.dragBody(i,r)),x.viewer.camera.IsPerspective()!=t.cameraInfo.isPerspective&&(t.cameraInfo.isPerspective?x.viewer.camera.toPerspective():x.viewer.camera.toOrthographic()),i={center:new THREE.Vector3(t.cameraInfo.target.x,t.cameraInfo.target.y,t.cameraInfo.target.z),up:new THREE.Vector3(t.cameraInfo.up.x,t.cameraInfo.up.y,t.cameraInfo.up.z),position:new THREE.Vector3(t.cameraInfo.position.x,t.cameraInfo.position.y,t.cameraInfo.position.z)},"ViewportAnno"!=t.type&&1<(r=function(e,t){if(null==t.width||null==t.height||null==t.modelScreenBBox)return 1;var n=x.viewer.renderer.getPixelRatio(),i=x.viewer.renderer.domElement.width/n,n=x.viewer.renderer.domElement.height/n;if(Math.abs(t.width-i)/i<.1&&Math.abs(t.height-n)/n<.1)return 1;var r=x.viewer.camera.position.clone(),o=x.viewer.camera.target.clone(),a=x.viewer.camera.up.clone(),e=(x.viewer.camera.position.copy(e.position),x.viewer.camera.target.copy(e.center),x.viewer.camera.up.copy(e.up),x.viewer.camera.lookAt(e.center),x.viewer.camera.updateMatrixWorld(!0),x.viewer.camera.updateProjectionMatrix(),x.viewer.computeModelScreenBBox()),r=(x.viewer.camera.position.copy(r),x.viewer.camera.target.copy(o),x.viewer.camera.up.copy(a),x.viewer.camera.lookAt(o),x.viewer.camera.updateMatrixWorld(!0),x.viewer.camera.updateProjectionMatrix(),e.max.x-e.min.x),a=e.max.y-e.min.y,o=e.min.x,s=i-e.max.x,l=e.min.y,e=n-e.max.y,d=t.width,c=t.height,h=t.modelScreenBBox.max.x-t.modelScreenBBox.min.x,u=t.modelScreenBBox.max.y-t.modelScreenBBox.min.y,p=t.modelScreenBBox.min.x,d=d-t.modelScreenBBox.max.x,f=t.modelScreenBBox.min.y,c=c-t.modelScreenBBox.max.y,t=0;o<0&&(p<0?(m=-p/h)<-o/r&&(t=-r*m-o):t=-o);p=0;s<0&&(d<0?(m=-d/h)<-s/r&&(p=-r*m-s):p=-s);o=Math.max(t,p),d=1;0<o&&(d=(i+2*o)/i);h=0;l<0&&(f<0?(m=-f/u)<-l/a&&(h=-a*m-l):h=-l);r=0;{var m;e<0&&(c<0?(m=-c/u)<-e/a&&(r=-a*m-e):r=-e)}s=Math.max(h,r),t=1;0<s&&(t=(n+2*s)/n);p=Math.max(d,t);1<p&&(p*=1.1);return p}(i,t.cameraInfo))&&!t.other&&(2<r?(o=(l=(l=x.viewer.controls.getExplosionBoundingBox())||x.viewer.controls.getBoundingBox()).getCenter(),d=(a=.5*(new THREE.Vector3).subVectors(l.max,l.min).length())/Math.sin(Math.PI/180*x.viewer.camera.fov*.5),x.viewer.camera.IsPerspective()&&x.viewer.camera.aspect<1&&(d/=x.viewer.camera.aspect),(s=i.position.clone()).sub(i.center),s.normalize(),s.multiplyScalar(d),i.center=o.clone(),i.position.addVectors(i.center,s)):((s=i.position.clone()).sub(i.center),s.multiplyScalar(r),i.position.addVectors(i.center,s),n<2*(c=s.length())&&(n=2*c))),t.other?(d=(l=null==(l=x.viewer.controls.getExplosionBoundingBox())?x.viewer.controls.getBoundingBox():l).getCenter(),a=.5*(new THREE.Vector3).subVectors(l.max,l.min).length(),c=i.position.distanceTo(d),(c+=a)<n&&(c=n),x.viewer.camera.setFarNear(c,t.cameraInfo.near)):x.viewer.camera.setFarNear(n,t.cameraInfo.near),"4"==t.version&&(i.center.applyMatrix4(x.viewer.modelRootObject.matrixWorld),i.position.applyMatrix4(x.viewer.modelRootObject.matrixWorld),i.up.transformDirection(x.viewer.modelRootObject.matrixWorld)),null!=t.explodeFactor&&null!=t.explodeFactor&&(t.explodeMode&ve.EXPLODEMODE.SELECTED?(x.viewer.explodeObjects=t.explodeObjects.concat(),x.viewer.setExplodeMode(t.explodeMode,t.exploseLevel,!0)):x.viewer.setExplodeMode(t.explodeMode,t.exploseLevel),x.viewer.explodeModel(t.explodeFactor)),x.viewer.toggleAutoRotation(!1),x.viewer.startSmoothTranslation(i,function(){A[e]||x.renderAnnotations(),x.viewer.dispatchEvent({type:"annotationSelectedEvent",userData:{uuid:e,index:t.index||-1,annotationDiv:A[e]}}),x.viewer.dispatchEvent({type:"annotationMoved",annotationDiv:A[e]})}),_e.enableBroadcast)&&!_e.broadcastMajor&&(A[e]||x.renderAnnotations(),x.viewer.dispatchEvent({type:"annotationSelectedEvent",userData:{uuid:e,index:t.index||-1,annotationDiv:A[e]}}),x.viewer.dispatchEvent({type:"annotationMoved",annotationDiv:A[e]}))),this.viewer.pmiObject&&this.viewer.deselectPMIObject(this.viewer.pmiObject)},this.setAnnotationType=function(e,t){t=I[t];t&&(t.type=e)},this.setAnnotationsVisibilityByUuid=function(e,t){t=A[t];t&&(e?(t.style.visibility="visible",i=!1):t.style.visibility="hidden")},this.resetSelectAnnotation=function(e){if(S&&""!=S){var t=x.getAnnotation(S);if(!t)return null!=u&&(m&ve.EXPLODEMODE.SELECTED?(x.viewer.explodeObjects=f.concat(),x.viewer.setExplodeMode(m,p,!0)):x.viewer.setExplodeMode(m,p),x.viewer.explodeModel(u)),S="",m=f=p=u=null,void(h=[]);t.bOnModel&&(n=t.locationObject)&&0<h.length&&t.translate&&(t=new THREE.Vector3(h[0]-t.translate[0],h[1]-t.translate[1],h[2]-t.translate[2]),x.viewer.ndsModel.dragBody(n,t)),null!=u&&(m&ve.EXPLODEMODE.SELECTED?(x.viewer.explodeObjects=f.concat(),x.viewer.setExplodeMode(m,p,!0)):x.viewer.setExplodeMode(m,p),x.viewer.explodeModel(u)),S="",m=f=p=u=null,h=[]}var n;(e=null==e?!1:e)||null==g||null==v||null==b||(n={center:v,up:b,position:g},x.viewer.camera.IsPerspective()!=C&&(C?x.viewer.camera.toPerspective():x.viewer.camera.toOrthographic()),x.viewer.camera.setFarNear(B,P),x.viewer.startSmoothTranslation(n,function(){P=B=b=v=g=null}))},this.addAnnotationRenderObject=function(e){var t,n,i,r;T[e.uuid]||(r=x.viewer.controls.getBoundingBox().getSize(),t=Math.min(r.x,r.y),(t=Math.min(t,r.z))<.1&&(n=Math.max(r.x,r.y),i=Math.max(r.z,r.y),t=Math.min(n,i)),30<Math.max(r.x,r.y,r.z)/t&&(t*=10),n=new THREE.SphereBufferGeometry(.03*t,8,8),(i=new THREE.MeshBasicMaterial).color.setHex(o),r=new THREE.Mesh(n,i),T[e.uuid]=r,L.add(T[e.uuid]),o+=10),null!=e.type&&null!=e.type&&"lineSeg"==e.type?T[e.uuid].position.set(e.coords[e.coords.length-3],e.coords[e.coords.length-2],e.coords[e.coords.length-1]):T[e.uuid].position.set(e.coords[0],e.coords[1],e.coords[2]),T[e.uuid].updateMatrixWorld(!0)},this.addAnnotation=function(e,t,n){if(e&&e.uuid){if(e.locationObject=null,n&&!e.other){var n=new THREE.Vector3(e.coords[0],e.coords[1],e.coords[2]),n=(this.getposFromFileGuid(e,n),e.coords[0]=n.x,e.coords[1]=n.y,e.coords[2]=n.z,e.other=!0,x.viewer.ndsModel.fileguidTouuid[e.fileguid]),i=null,r=(n&&0<n.length&&(i=x.viewer.ndsModel.getRightBodyuuid(e.rootfileguid,n)),x.viewer.ndsModel.bodyUuid2NodeMap[i]);if(!r||!r.children||!r.children[e.BodyfileID])return!1;for(var o=0,a=0;a<r.children.length;++a){var s=r.children[a];if(!s.isReferenceEntity()&&!s.isCoordinate()){if(o==e.BodyfileID){o=a;break}o++}}r=r.children[o],e.locationObject=r}I[e.uuid]=e,M=!1,E=e.uuid,null!=t&&0==t||x.addAnnotationRenderObject(e)}},this.addAnnotations=function(e){M=!1,E="";for(var t=0;t<e.length;++t)e[t]&&e[t].uuid&&(I[e[t].uuid]=e[t],x.addAnnotationRenderObject(e[t]));n=e},this.getAnnotation=function(e){return e?I[e]:null},this.removeAnnotation=function(e){var t;e&&(e==E&&(M=!1,E=""),I[e]=null,(t=A[e])&&(this.viewer.container.removeChild(t),A[e]=null,Number(t.innerText)),T[e])&&(T[e].geometry&&T[e].geometry.dispose(),T[e].material&&T[e].material.dispose(),L.remove(T[e]),T[e]=null)},this.removeAllAnnotations=function(){for(var e in I={},A){var t=A[e];t&&this.viewer.container.removeChild(t)}for(e in M=!(A={}),w&&(this.viewer.canvas2D.getContext("2d").clearRect(w.min.x,w.min.y,w.max.x-w.min.x,w.max.y-w.min.y),w=null),E="",T)T[e]&&(T[e].geometry&&T[e].geometry.dispose(),T[e].material)&&T[e].material.dispose();T={};for(var n=0;n<L.children.length;n++)L.remove(L.children[n]),n--;x.viewer.render()},this.addAnnotationTip=function(e,t,n,i,r){var o=document.createElement("div");return o.className=N(n,!1),Se.isMobileDevice()?(o.style.top=r-30+"px",o.style.left=i-12+"px"):(o.style.top=r-35+"px",o.style.left=i-13+"px"),o.style.opacity=1,(null==n||"ImageAnno"!=n&&"VideoAnno"!=n&&"AudioAnno"!=n)&&(o.innerHTML=t.toString(),o.innerText=t.toString()),o.setAttribute("uuid",e),o.onclick=function(e){e&&(e.preventDefault(),e.stopPropagation()),null!=o.style.opacity&&1==o.style.opacity&&(e=o.getAttribute("uuid"),x.selectAnnotation(e))},o.onselectstart=function(){return!1},o},this.restoreAllAnnotations=function(){if(this.viewer.canvas2D){for(var e in A){e=A[e];e&&(e.style.visibility="visible")}i=!1}},this.hasAnnotationsForAnimation=function(e){if(this.viewer.canvas2D)for(var t in I)if(I[t]&&e==I[t].ownerUuid&&"animation"==I[t].ownerType)return!0;return!1},this.updateAnnotationsVisiblilityForAnimation=function(e,t){if(this.viewer.canvas2D)for(var n in A){var i=A[n];i&&"animation"==I[n].ownerType&&(e==I[n].ownerUuid&&I[n].timeStart<=t&&I[n].timeEnd>=t?i.style.visibility="visible":(i.style.visibility="hidden",E==n&&(E="")))}},this.setAnnotationsVisiblilityForAnimation=function(e){if(this.viewer.canvas2D)for(var t in A){var n=A[t];n&&"animation"==I[t].ownerType&&(n.style.visibility=e?"visible":"hidden")}},this.hideAllAnnotations=function(e){if(this.viewer.canvas2D)for(var t in w&&(this.viewer.canvas2D.getContext("2d").clearRect(w.min.x,w.min.y,w.max.x-w.min.x,w.max.y-w.min.y),w=null),E="",A){var n,i=A[t];i&&(n=!0,n=("animation"!=I[t].ownerType||e!=I[t].ownerUuid)&&n)&&(i.style.visibility="hidden")}},this.setAnnotationsVisibility=function(e){if(this.viewer.canvas2D){for(var t in i=!e,w&&(this.viewer.canvas2D.getContext("2d").clearRect(w.min.x,w.min.y,w.max.x-w.min.x,w.max.y-w.min.y),w=null),E="",A){t=A[t];t&&(t.style.visibility=e?"visible":"hidden")}x.viewer.render()}},this.isAnnotationsVisible=function(){i=!0;var e,t=0;for(e in A)if(A.hasOwnProperty(e)){t++;var n=A[e];if(n&&("visible"==n.style.visibility||n.style.hidemodel)){i=!1;break}}return!(i=0==t?!1:i)},this.getHotPoint=function(e,t){function n(e){return e.parent?e.parent.fileguid||n(e.parent):null}var i,r,o,a,s,l=this.viewer.renderer.getPixelRatio(),d=new THREE.Matrix4,c=(d.multiplyMatrices(this.viewer.camera.matrixWorld,d.getInverse(this.viewer.camera.projectionMatrix)),!1),h=new Object,u=this.viewer.selectionManager.getPickIntersects(e,t);return u&&0<u.length&&(s=u[0].point.clone(),this.viewer.ndsModel?(i=u[0].bodyNode,o=this.viewer.ndsModel.getBodyTranslate(i),s.x-=o[0],s.y-=o[1],s.z-=o[2],a=i.worldMatrix,(r=new THREE.Matrix4).getInverse(a),h.matrix=Array.prototype.slice.call(new Float32Array(r.elements)),n(i)&&(h.fileguid=n(i)),this.viewer.ndsModel.rootBodyNode.fileguid&&(h.rootfileguid=this.viewer.ndsModel.rootBodyNode.fileguid),null!=i.BodyfileID&&null!=i.BodyfileID&&(h.BodyfileID=i.BodyfileID),a=this.viewer.ndsModel.getBodyTranslateWithoutExplode(i),h.annoTranslate=o,h.translate=a):(null==(i=this.viewer.selectionManager.findParentElement(u[0].object))&&(i=u[0].object),(r=new THREE.Matrix4).getInverse(i.matrixWorld),s.applyMatrix4(r)),h.coords=[s.x,s.y,s.z],h.bOnModel=!0,h.locationObjectUUID=i.uuid,c=!0),this.viewer.ndsModel.rootBodyNode.fileguid&&(h.rootfileguid=this.viewer.ndsModel.rootBodyNode.fileguid),c||(o=new THREE.Vector3,this.viewer.controls.getBoundingBox().getCenter(o),o.project(this.viewer.camera),(a=o.z)<-1&&(a=-.99),(s=new THREE.Vector3).set(e*l/R.width*2-1,2*-(t*l/R.height)+1,a),s.applyMatrix4(d),(u=[])[0]=s.x,u[1]=s.y,u[2]=s.z,h.coords=u,h.bOnModel=!1,h.locationObjectUUID=null),h.cameraInfo=this.viewer.getCameraInfo(),h.explodeFactor=this.viewer.getExplodeFactor(),h.explodeMode=this.viewer.getExplodeMode(),h.exploseLevel=this.viewer.getExplodeLevel(),h.explodeObjects=this.viewer.explodeObjects.concat(),h},this.renderAnnotations=function(){if(this.viewer.canvas2D){w&&(this.viewer.canvas2D.getContext("2d").clearRect(w.min.x,w.min.y,w.max.x-w.min.x,w.max.y-w.min.y),w=null);var e,t=this.viewer.renderer.getPixelRatio();for(e in j(),I){var n=I[e];if(n){var i=!0,r=(n.locationObject&&(i=x.viewer.ndsModel?!n.locationObject.isHidden():n.locationObject.visible),A[n.uuid]),o=(r&&(o=!0,!(o="hidden"==r.style.visibility?!1:o)&&r.style.hidemodel&&i?r.style.hidemodel=!1:!o||i||r.style.hidemodel?i&=o:r.style.hidemodel=!0),!1);if(null!=n.version&&(m=n,v=g=void 0,g=new THREE.Vector3(m.cameraInfo.position.x,m.cameraInfo.position.y,m.cameraInfo.position.z),"4"==m.version&&g.applyMatrix4(x.viewer.modelRootObject.matrixWorld),v=!1,E==m.uuid&&((v=x.viewer.camera.position.distanceToSquared(g)<1e-6)&&(g.set(m.cameraInfo.up.x,m.cameraInfo.up.y,m.cameraInfo.up.z),"4"==m.version&&g.transformDirection(x.viewer.modelRootObject.matrixWorld),v=x.viewer.camera.up.distanceToSquared(g)<1e-6),M?v||(E="",M=!1):M=v),o=v),o&&i)if(null!=n.type&&null!=n.type&&"lineSeg"==n.type){h=c=d=l=s=a=void 0;var a=n,s=x.viewer.renderer.domElement.width/2,l=x.viewer.renderer.domElement.height/2,d=x.viewer.canvas2D.getContext("2d"),c=(null!=a.lineWidth?d.lineWidth=a.lineWidth:d.lineWidth=y.lineWidth,null!=a.strokeStyle?d.strokeStyle=a.strokeStyle:d.strokeStyle=y.strokeStyle,w=new THREE.Box2,new THREE.Vector3);d.beginPath(),c.set(a.coords[0],a.coords[1],a.coords[2]),c.project(x.viewer.camera),c.x=Math.round(c.x*s+s),c.y=Math.round(-c.y*l+l),d.moveTo(c.x,c.y),w.expandByPoint(c);for(var h=1;h<a.coords.length/3-1;++h)c.set(a.coords[3*h],a.coords[3*h+1],a.coords[3*h+2]),c.project(x.viewer.camera),c.x=Math.round(c.x*s+s),c.y=Math.round(-c.y*l+l),d.lineTo(c.x,c.y),w.expandByPoint(c);c.x=2*d.lineWidth,c.y=c.x,w.expandByVector(c),d.stroke()}else m=n,g=void 0,g=x.viewer.canvas2D.getContext("2d"),null!=m.strokeStyle?(g.fillStyle=m.strokeStyle,g.strokeStyle=m.strokeStyle):(g.fillStyle=y.strokeStyle,g.strokeStyle=y.strokeStyle),w=new THREE.Box2,g.beginPath(),g.arc(m.screenPosition.x,m.screenPosition.y,2,0,2*Math.PI),g.fill(),g.stroke(),w.min.set(m.screenPosition.x-4,m.screenPosition.y-4),w.max.set(m.screenPosition.x+4,m.screenPosition.y+4);void 0!==n.index&&((v=n.screenPosition.clone()).x/=t,v.y/=t,A[e]||(r=this.addAnnotationTip(n.uuid,n.index,n.type,v.x,v.y))&&(this.viewer.container.appendChild(r),A[e]=r),this.viewer.isRotationEnable()||(n.bShowAnnoOpacity=!0),r=v,u=o,p=(n=n).bShowAnnoOpacity,i=i,f=void 0,f=A[n.uuid])&&(u=N(n.type,u),f.className!=u&&(f.className=u),Se.isMobileDevice()?(f.style.top=r.y-30+"px",f.style.left=r.x-12+"px"):(f.style.top=r.y-35+"px",f.style.left=r.x-13+"px"),p?(f.style.opacity=1,f.style.cursor="pointer"):(f.style.opacity=.2,null!=(u=x.viewer.renderer.domElement)&&(f.style.cursor=u.style.cursor)),f.style.visibility=i?"visible":"hidden",null==n.type||"ImageAnno"!=n.type&&"VideoAnno"!=n.type&&"AudioAnno"!=n.type?(f.innerHTML=n.index.toString(),f.innerText=n.index.toString()):(f.innerHTML="",f.innerText=""))}}F&&A[F]&&x.viewer.dispatchEvent({type:"annotationMoved",annotationDiv:A[F]})}var u,p,f,m,g,v},this.updateAnnotaion=function(e,t){for(var n in I){var i,n=I[n];n&&n.locationObject&&n.locationObject.uuid==e&&((i=new THREE.Vector3).set(n.coords[0],n.coords[1],n.coords[2]),i.applyMatrix4(t),i.toArray(n.coords))}},this.unloadAnnotation=function(e){for(var t in I){var n=I[t];n&&n.locationObject&&n.locationObject.getModel().rootBodyNode.uuid==e&&(this.removeAnnotation(t),this.viewer.dispatchEvent({type:"annotationRemove",uuid:t}))}}}var rn=function(c){function e(e){var r,o=c.call(this,e||{})||this,U=(THREE.DefaultSide=-1,console.log("THREE.WebGLRenderer",THREE.REVISION),o.maxPrimitivesPerFrame=6e7,o.maxTrianglesPerFrame=1e5,o.maxLinesPerFrame=1e5,o.disableTransparent=!1,o.renderContext.info.memory.ndsGeometries=0,o),G=e.is2DModel,a=o.getContext(),s=o.domElement,l=THREE.DefaultSide,g=(o.colorTarget=r,o._ndsCurrentTarget=null,new THREE.Matrix4),g=(o.capabilities.isWebGL2||(o.extensions.get("WEBGL_depth_texture"),o.extensions.get("OES_texture_float"),o.extensions.get("OES_texture_float_linear"),o.extensions.get("OES_texture_half_float"),o.extensions.get("OES_texture_half_float_linear"),o.extensions.get("OES_standard_derivatives"),o.extensions.get("ANGLE_instanced_arrays"),o.extensions.get("OES_vertex_array_object"),o.extensions.get("WEBGL_draw_buffers")),(o.capabilities.isWebGL2||o.extensions.get("OES_element_index_uint"))&&(THREE.BufferGeometry.MaxIndex=4294967296),o._renderScene_=o.renderScene,o._render_=o.render,o._setSize_=o.setSize,new THREE.Matrix4),z=-1;function d(e){for(var t in null!==e.index&&U.renderContext.attributes.remove(e.index),e.attributes)U.renderContext.attributes.remove(e.attributes[t]);for(var n in e.morphAttributes)for(var i=e.morphAttributes[n],r=0,o=i.length;r<o;r++)U.renderContext.attributes.remove(i[r]);e.removeEventListener("dispose",d);var a=U.renderContext.geometries.wireframeAttributes.get(e);a&&(U.renderContext.attributes.remove(a),U.renderContext.geometries.wireframeAttributes.delete(e)),U.renderContext.bindingStates.releaseStatesOfGeometry(e),!0===e.isInstancedBufferGeometry&&delete e._maxInstanceCount,U.renderContext.info.memory.ndsGeometries--}o.setSize=function(e,t,n){U._setSize_(e,t,n);var e=a.getParameter(a.MAX_TEXTURE_SIZE),t=2,n=s.width*(t=G?1:t),t=s.height*t,i=n/t;t<n?e<n&&(n=e,t=Math.floor(n/i)):e<t&&(t=e,n=Math.floor(t*i)),_e.isVRmodel||_e.isARmodel&&_e.supportAR||r&&r.width===n&&r.height===t||(r&&(r.dispose(),r=null),e={magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter,format:THREE.RGBAFormat,type:THREE.UnsignedByteType,depthBuffer:!0,stencilBuffer:!1,depthTexture:null},(r=new THREE.WebGLRenderTarget(n,t,e)).texture.generateMipmaps=!1),this.colorTarget=r},o.clearTarget=function(e,t,n,i){_e.isVRmodel||_e.isARmodel&&_e.supportAR||(this.setRenderTarget(e),this.clear(t,n,i))},o.supportInstancedArrays=function(){return this.capabilities.isWebGL2||!!this.extensions.get("ANGLE_instanced_arrays")},o.setNdsModelRenderSide=function(e){l=e},o.getNdsModelRenderSide=function(){return l};var W=function(e,t,n,i){var r=n.geometry;r.onNdsGeometryDispose||(r.addEventListener("dispose",d),r.onNdsGeometryDispose=d,U.renderContext.info.memory.ndsGeometries++),r.needsUpdate&&(U.renderContext.geometries.update(r),r.needsUpdate=!1),r.modelMatrixAttribute&&r.modelMatrixAttribute.unUsed&&(o.renderContext.attributes.remove(r.modelMatrixAttribute),n.geometry.deleteAttribute("modelMatrixAttrib"),delete n.geometry.modelMatrixAttribute),t.disableTransparent=o.disableTransparent,6.3<=z?l!==THREE.DefaultSide?(n.material._old_side_=n.material.side,n.material.side=!0===n.hasSurface?THREE.DoubleSide:l):void 0!==n.material._old_side_&&(n.material.side=n.material._old_side_,n.material._old_side_=void 0):n.material.side=THREE.DoubleSide,U.renderBufferDirect(e,t,r,n.material,n,i)};function h(e,t,n){var i;e.referenceEntityDirty&&0<e.wholeRefEntityNodes.length&&!e.referenceEntityDispManager.overrideMaterial&&(performance.now(),(i=e.referenceEntityDispManager.getAxisDispData()).normalAxisLines&&(i.normalAxisLines.modelViewMatrix.copy(n.matrixWorldInverse),i.normalAxisLines.matrixAutoUpdate=!1,i.normalAxisLines.matrixWorldNeedsUpdate=!1,W(n,t,i.normalAxisLines,null)),i.selectedAxisLines&&(i.selectedAxisLines.modelViewMatrix.copy(n.matrixWorldInverse),i.selectedAxisLines.matrixAutoUpdate=!1,i.selectedAxisLines.matrixWorldNeedsUpdate=!1,W(n,t,i.selectedAxisLines,null)),i.preselectedAxisLines&&(i.preselectedAxisLines.modelViewMatrix.copy(n.matrixWorldInverse),i.preselectedAxisLines.matrixAutoUpdate=!1,i.preselectedAxisLines.matrixWorldNeedsUpdate=!1,W(n,t,i.preselectedAxisLines,null)),(i=e.referenceEntityDispManager.getPlaneDispData()).normalPlaneEdge&&(i.normalPlaneEdge.modelViewMatrix.copy(n.matrixWorldInverse),i.normalPlaneEdge.matrixAutoUpdate=!1,i.normalPlaneEdge.matrixWorldNeedsUpdate=!1,U.renderContext.objects.update(i.normalPlaneEdge),W(n,t,i.normalPlaneEdge,null)),i.selectedPlaneEdge&&(i.selectedPlaneEdge.modelViewMatrix.copy(n.matrixWorldInverse),i.selectedPlaneEdge.matrixAutoUpdate=!1,i.selectedPlaneEdge.matrixWorldNeedsUpdate=!1,W(n,t,i.selectedPlaneEdge,null)),i.preselectedPlaneEdge&&(i.preselectedPlaneEdge.modelViewMatrix.copy(n.matrixWorldInverse),i.preselectedPlaneEdge.matrixAutoUpdate=!1,i.preselectedPlaneEdge.matrixWorldNeedsUpdate=!1,W(n,t,i.preselectedPlaneEdge,null)),i.normalPlaneMesh&&(i.normalPlaneMesh.modelViewMatrix.copy(n.matrixWorldInverse),i.normalPlaneMesh.matrixAutoUpdate=!1,i.normalPlaneMesh.matrixWorldNeedsUpdate=!1,W(n,t,i.normalPlaneMesh,null)),i.selectedPlaneMesh&&(i.selectedPlaneMesh.modelViewMatrix.copy(n.matrixWorldInverse),i.selectedPlaneMesh.matrixAutoUpdate=!1,i.selectedPlaneMesh.matrixWorldNeedsUpdate=!1,W(n,t,i.selectedPlaneMesh,null)),i.preselectedPlaneMesh&&(i.preselectedPlaneMesh.modelViewMatrix.copy(n.matrixWorldInverse),i.preselectedPlaneMesh.matrixAutoUpdate=!1,i.preselectedPlaneMesh.matrixWorldNeedsUpdate=!1,W(n,t,i.preselectedPlaneMesh,null)),e.referenceEntityDirty=!1,performance.now())}function u(e,t,n,i){if(void 0!==e.renderOnce&&!e.lineSegmentsSet.dirty||(e.renderOnce=!0),e.hasrenderMesh=!1,e.renderOnce){z=e.dataVersion;var r=e.getDrawModeFace(),o=e.getDrawModeFaceColorMask(),a=e.getDrawModeEdge(),s=r&&o&&e.renderOnce&&e.hasTransparentBodies()&&!e.meshManager.overrideMaterial&&e.geomManager.allGeomInMemory,l=s,d=!!e.sptIndex.lines,c=(e.needsFastRendering&&(i/=1.2),e.forceRenderAll&&(i=500,e.forceRenderAll=d=!1),function(){return(i<0||i<300&&U.info.render.triangles+U.info.render.lines>U.maxPrimitivesPerFrame)&&!(i=0)});if(r&&0<i){e.viewer.isIn3DViewer()||e.meshManager.overrideMaterial||Y(e,t,n,o);for(var h,u=U.info.render.triangles,p=performance.now(),f=0,m=e.meshManager.getNumInstancedMeshes();f<m;++f)if(e.meshManager.instancedMeshDirtyFlags[f]){var g=e.meshManager.getInstancedMeshId(f);if(!e.meshManager.isMeshSelected(g))if(L=e.meshManager.getInstancedMesh(f))if(l&&L.material.transparent&&L.material.opacity<=.99)L.geometry.dirty=!0,L.geometry.updateModelMatrix=!0;else if(e.meshManager.instancedMeshDirtyFlags[f]=!1,L.matrixAutoUpdate=!1,L.matrixWorldNeedsUpdate=!1,o||(L.material.colorWrite=!1),W(n,t,L,null),o||(L.material.colorWrite=!0),(U.info.render.triangles>u+U.maxTrianglesPerFrame||f+1===m)&&(u=U.info.render.triangles,h=performance.now(),i-=h-p,p=h,c()))break}var v=e.getMeshSets(),A=[];if(0==v.length&&(d=!1),0<i){for(var y=0;y<v.length;++y)!(w=v[y]).isLoaded()||!(w.dirty||w.lineDirty||w.hiddenLineDirty)||w.isAllMeshHidden()||e.renderOnce&&!w.isVisible(U.renderContext.frustum,e.ModelUpMatrix4)||w.isReloadingGeometry()||A.push(y);e.sortMeshSets(A,n),o||(U.renderContext.state.buffers.color.setMask(!1),U.renderContext.state.buffers.color.setLocked(!0));for(var E=0,M=A.length;E<M;++E){var w=v[A[E]];if(w.dirty&&(i=function(e,t,n,i,r,o){function a(e){o&&e.material.transparent&&e.material.opacity<=.99?(e.geometry.dirty=!0,e.geometry.updateModelMatrix=!0):(G||"MeshBasicMaterial"==e.material.type||(e.geometry.attributes.normal?e.material.flatShading=!1:e.material.flatShading=!0),e.instancedCount||e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.matrixAutoUpdate=!1,e.matrixWorldNeedsUpdate=!1,W(n,t,e,null))}var s=performance.now();e.sorted||e.sortMeshes();if(r){for(var l=0,d=e.getNumMeshes();l<d;++l){var c=e.getMeshId(l);e.sptIndex.meshManager.isMeshSelected(c)||(f=e.getMesh(l))&&a(f)}for(var h=0,u=e.getNumTexts();h<u;++h)(m=e.getText(h))&&(a(m),m.lineSegments2&&X(n,t,m.lineSegments2,m.matrixWorld,m.instancedCount,m.matrixWorlds),m.line)&&X(n,t,m.line,m.matrixWorld,m.instancedCount,m.matrixWorlds)}else{for(var p=e.getNumMeshes()-1;0<=p;--p){var f,c=e.getMeshId(p);e.sptIndex.meshManager.isMeshSelected(c)||(f=e.getMesh(p))&&a(f)}for(var m,g=e.getNumTexts()-1;0<=g;--g)(m=e.getText(g))&&(a(m),m.lineSegments2&&X(n,t,m.lineSegments2,m.matrixWorld,m.instancedCount,m.matrixWorlds),m.line)&&X(n,t,m.line,m.matrixWorld,m.instancedCount,m.matrixWorlds)}return r=performance.now(),i-=r-s}(w,t,n,i,!0,l),e.renderMeshSetCount+=1,e.hasrenderMesh=!0,w.renderOnce=!0,w.dirty=!1,d&&(w.lineDirty=!0),c()))break}}if((s||_e.inBIMContext&&0<e.getSelectedBodies().length)&&e.transparentBodiesDirty){for(var b=0,F=e.meshManager.getNumInstancedMeshes();b<F;++b)e.meshManager.instancedMeshDirtyFlags[b]&&(g=e.meshManager.getInstancedMeshId(b),e.meshManager.isMeshSelected(g)||(L=e.meshManager.getInstancedMesh(b))&&(e.meshManager.instancedMeshDirtyFlags[b]=!1,l)&&L.material.transparent&&L.material.opacity<=.99&&(L.matrixAutoUpdate=!1,L.matrixWorldNeedsUpdate=!1,o||(L.material.colorWrite=!1),W(n,t,L,null),o||(L.material.colorWrite=!0)));for(var r=e.getAllTransparentBodies(!0),x=e,I=r,N=t,T=n,S=(performance.now(),0),j=I.length;S<j;++S)for(var B=I[S],_=x.meshManager.getNumBodyMeshs(B),P=0;P<_;++P){var C=x.meshManager.getBodyMeshId(B,P);x.meshManager.isMeshSelected(C)||(C=x.meshManager.getMesh(C))&&C.material.transparent&&C.material.opacity<=.99&&(C.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,C.matrixWorld),C.matrixAutoUpdate=!1,C.matrixWorldNeedsUpdate=!1,W(T,N,C,null))}if(performance.now(),e.transparentBodiesDirty=!1,e.selectedBodiesDirty&&!e.meshManager.overrideMaterial&&_e.inBIMContext){for(var R=e.getSelectedBodies(),O=0,V=R.length;O<V;++O)for(var L,D=R[O],H=0,k=e.meshManager.getNumBodyMeshs(D);H<k;++H)(L=e.meshManager.getBodyMesh(D,H))&&(L.material=_e.BIMselectedMaterial,L.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,L.matrixWorld),L.matrixAutoUpdate=!1,L.matrixWorldNeedsUpdate=!1,o||(L.material.colorWrite=!1),W(n,t,L,null),o||(L.material.colorWrite=!0));e.selectedBodiesDirty=!1}}o||(U.renderContext.state.buffers.color.setLocked(!1),U.renderContext.state.buffers.color.setMask(!0)),e.viewer.isIn3DViewer()&&Y(e,t,n,o)}a&&0<i&&(i=function(e,t,n,i,r,o){if(t.dirty){var a,s=e.getDrawModeHiddenEdge(),l=performance.now(),d=o,c=U.info.render.lines,h=0,u=e.meshManager.getNumInstancedLineSegs(),p=0;if(n){var f=e.getMeshSets();for(y=0,E=n.length;y<E;++y){var m=f[n[y]];p+=m.getNumLineSegments()}}else p=u?e.meshManager.getNumUnInstancedLineSegs():t.getNumLineSegments();var u=u+p,g=0,v=1;for(s&&(v+=1),g=0;g<v;++g){var A=e.meshManager.getNumInstancedLineSegs();1==g&&e.meshManager.resetLineInstance();for(var y=0,E=A;y<E;++y)if(++h,e.meshManager.instancedLineDirtyFlags[y]){for(var M=e.meshManager.instancedLineSegInfos[y],w=!0,b=0;b<M.lineSegIds.length;b++){var x=e.meshManager.lineSegBodyNodes[M.lineSegIds[b]],I=e.meshManager.getLineSegmentsWithState(M.lineSegIds[b],!1);if(x.isSelected()||I.lineSegments&&!I.lineSegments.geometry.refLineSegsSameMaterial){w=!1;break}}if(w){if(1!==(I=e.meshManager.getInstancedLineSegWithState(y,1===g)).state)continue;var T=I.lineSegments;T.matrixAutoUpdate=!1,T.matrixWorldNeedsUpdate=!1,I.points?(Q(r,i,I.points,T.matrixWorld,T.instancedCount,T.matrixWorlds),I.lineSegments2&&X(r,i,I.lineSegments2,T.matrixWorld,T.instancedCount,T.matrixWorlds)):I.lineSegments2&&(X(r,i,I.lineSegments2,T.matrixWorld,T.instancedCount,T.matrixWorlds),!I.lineSegments2.isWorldUnit)||W(r,i,T,null),Z(r,i,I.lineStyle,T.matrixWorld,T.instancedCount,T.matrixWorlds)}else for(var S,M=e.meshManager.instancedLineSegInfos[y],b=0;b<M.lineSegIds.length;b++)1===(I=e.meshManager.getLineSegmentsWithState(M.lineSegIds[b],1===g,!1)).state&&((S=I.lineSegments).instancedCount||S.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,S.matrixWorld),S.matrixAutoUpdate=!1,S.matrixWorldNeedsUpdate=!1,I.points?(Q(r,i,I.points,S.matrixWorld,S.instancedCount,S.matrixWorlds),I.lineSegments2&&X(r,i,I.lineSegments2,S.matrixWorld,S.instancedCount,S.matrixWorlds)):I.lineSegments2&&(X(r,i,I.lineSegments2,S.matrixWorld,S.instancedCount,S.matrixWorlds),!I.lineSegments2.isWorldUnit)||W(r,i,S,null),Z(r,i,I.lineStyle,S.matrixWorld,S.instancedCount,S.matrixWorlds));if(g!=v&&!G||(e.meshManager.instancedLineDirtyFlags[y]=!1),(U.info.render.lines>c+U.maxLinesPerFrame||h===E)&&(c=U.info.render.lines,a=performance.now(),(o=d-(a-l))<0||o<300&&U.info.render.triangles+U.info.render.lines>U.maxPrimitivesPerFrame)&&!(o=0))return o}if(n){f=e.getMeshSets();for(y=0,E=n.length;y<E;++y){if((m=f[n[y]]).lineDirty||m.hiddenLineDirty){for(var B=0,P=m.getNumLineSegments();B<P;++B){var C,I=m.getLineSegmentsWithState(B,1===g,!0);++h,1===I.state&&((C=I.lineSegments).instancedCount||C.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,C.matrixWorld),C.matrixAutoUpdate=!1,C.matrixWorldNeedsUpdate=!1,I.points?(Q(r,i,I.points,C.matrixWorld,C.instancedCount,C.matrixWorlds),I.lineSegments2&&X(r,i,I.lineSegments2,C.matrixWorld,C.instancedCount,C.matrixWorlds)):I.lineSegments2&&(X(r,i,I.lineSegments2,C.matrixWorld,C.instancedCount,C.matrixWorlds),!I.lineSegments2.isWorldUnit)||W(r,i,C,null),Z(r,i,I.lineStyle,C.matrixWorld,C.instancedCount,C.matrixWorlds))}m.lineDirty?(m.lineDirty=!1,2===v&&(m.hiddenLineDirty=!0)):m.hiddenLineDirty&&(m.hiddenLineDirty=!1)}a=performance.now(),o=d-(a-l)}}else{var R=A?e.meshManager.getNumUnInstancedLineSegs():t.getNumLineSegments();for(y=0,E=R;y<E;++y){var O=void 0,L=void 0;L=A?e.meshManager.getUnInstancedLineSegWithState(y,1===g):t.getLineSegmentsWithState(y,1===g),++h,1===L.state&&((O=L.lineSegments).instancedCount||O.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,O.matrixWorld),O.matrixAutoUpdate=!1,O.matrixWorldNeedsUpdate=!1,L.points?(Q(r,i,L.points,O.matrixWorld,O.instancedCount,O.matrixWorlds),L.lineSegments2&&X(r,i,L.lineSegments2,O.matrixWorld,O.instancedCount,O.matrixWorlds)):L.lineSegments2&&(X(r,i,L.lineSegments2,O.matrixWorld,O.instancedCount,O.matrixWorlds),!L.lineSegments2.isWorldUnit)||W(r,i,O,null),Z(r,i,L.lineStyle,O.matrixWorld,O.instancedCount,O.matrixWorlds))}a=performance.now(),o=d-(a-l)}}(u*v<=h||n&&0===n.length)&&(t.dirty=!1)}return o}(e,e.getLineSegmentsSet(),d?A:null,t,n,i)),e.renderOnce&&(e.renderOnce=v&&e.renderMeshSetCount>=A.length,d&&e.renderOnce&&(e.renderOnce=e.getLineSegmentsSet().dirty),null==e.renderOnce)&&(e.renderOnce=!0),e.renderOnce||(e.renderMeshSetCount=0)}}function Y(e,t,n,i){if(e.selectedBodiesDirty&&!_e.inBIMContext){for(var r=e.getSelectedBodies(),o=0,a=r.length;o<a;++o){var s=r[o],l=s.isHidden();l&&s.show();for(var d=0,c=e.meshManager.getNumBodyMeshs(s);d<c;++d){var h=e.meshManager.getBodyMesh(s,d);h&&(e.viewer.selectionManager.shouldApplySelectedMaterial&&(h.material=e.meshManager.selectedMaterial,e.meshManager.overrideMaterial)&&(h.material=e.meshManager.overrideMaterial),G||"MeshBasicMaterial"==h.material.type||(h.geometry.attributes.normal?h.material.flatShading=!1:h.material.flatShading=!0),h.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,h.matrixWorld),h.matrixAutoUpdate=!1,h.matrixWorldNeedsUpdate=!1,i||(h.material.colorWrite=!1),W(n,t,h,null),i||(h.material.colorWrite=!0))}l&&s.hide()}e.selectedBodiesDirty=!1}}function X(e,t,n,i,r,o){if(n)if(r)for(var a=0;a<r;a++){var s,l,d,c=(new THREE.Matrix4).fromArray(o,16*a);n.matrixWorld.copy(c),n.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,n.matrixWorld),n.matrixAutoUpdate=!1,n.matrixWorldNeedsUpdate=!1,n.material.mutiWidth?(s=new THREE.Vector3,l=new THREE.Quaternion,d=new THREE.Vector3(1,1,1),c.decompose(s,l,d),n.material.linewidthScale=d.x):n.material.linewidthScale=1,W(e,t,n,null)}else n.matrixWorld.copy(i),n.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,i),n.matrixAutoUpdate=!1,n.matrixWorldNeedsUpdate=!1,W(e,t,n,null)}function Q(e,t,n,i,r,o){if(n)if(r)for(var a=0;a<r;a++){var s=(new THREE.Matrix4).fromArray(o,16*a);n.matrixWorld.copy(s),n.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,n.matrixWorld),n.matrixAutoUpdate=!1,n.matrixWorldNeedsUpdate=!1,W(e,t,n,null)}else n.matrixWorld.copy(i),n.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,i),n.matrixAutoUpdate=!1,n.matrixWorldNeedsUpdate=!1,W(e,t,n,null)}function Z(o,e,t,n,i,r){if(t){var a=t.textMesh;if(t.textMesh)if(i)for(var s=0;s<i;s++){var l=(new THREE.Matrix4).fromArray(r,16*s);a.matrixWorld.copy(l),a.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,a.matrixWorld),a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1,W(o,e,a,null)}else{a.matrixWorld.copy(n),a.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n),a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1,W(o,e,a,null);var d,c=o.viewer.ndsModel.getMeshManager(),h=c.lineTypeUuid2ParamsMap,u=c.geomUuid2MeshPosMap,p=c.spliceTextRow,f=(c.oriGeomUuid2MeshPosMap,c.geomUuid2MeshMtMap),m=c.lineStyleGeomUuid2MeshPosMap,g=h.get(a.geometry.lineTypeId);g&&!u.has(a.geometry.lineTypeId)&&(d=n.elements,f.set(a.geometry.lineTypeId,a.matrix.clone()),p.push({uuid:a.geometry.lineTypeId,text:a.geometry.text,characterWidthHeight:g.characterWidthHeight,rectBearingY:g.rectBearingY||0,rectBearingX:g.rectBearingX||0,rectWidth:g.rectWidth,rectHeight:g.rectHeight}),g.vD.forEach(function(e){var t=[],n={x:d[12]+e.x,y:d[13]+e.y,z:0},i={x:d[12]+e.x+g.rectWidth,y:d[13]+e.y,z:0},r={x:d[12]+e.x+g.rectWidth,y:d[13]+e.y+g.rectHeight,z:0},e={x:d[12]+e.x,y:d[13]+e.y+g.rectHeight,z:0},r=(t.push(n,i,r,e),m.has(a.geometry.lineTypeId)?(i=c.geomUuid2MeshPosMap.get(a.geometry.lineTypeId).concat(t),m.set(a.geometry.lineTypeId,i)):m.set(a.geometry.lineTypeId,t),o.viewer._transMt2(t,n,a.matrix));u.has(a.geometry.lineTypeId)?(e=c.geomUuid2MeshPosMap.get(a.geometry.lineTypeId).concat(r),u.set(a.geometry.lineTypeId,e)):u.set(a.geometry.lineTypeId,r)}))}var v=t.pointMesh;if(v)if(i)for(var A=0;A<i;A++){var y=(new THREE.Matrix4).fromArray(r,16*A);v.matrixWorld.copy(y),v.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,v.matrixWorld),v.matrixAutoUpdate=!1,v.matrixWorldNeedsUpdate=!1,W(o,e,v,null)}else v.matrixWorld.copy(n),v.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n),v.matrixAutoUpdate=!1,v.matrixWorldNeedsUpdate=!1,W(o,e,v,null);var E=t.lineMesh;if(E)if(i)for(var M=0;M<i;M++){var w=(new THREE.Matrix4).fromArray(r,16*M);E.matrixWorld.copy(w),E.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,E.matrixWorld),E.matrixAutoUpdate=!1,E.matrixWorldNeedsUpdate=!1,W(o,e,E,null)}else E.matrixWorld.copy(n),E.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n),E.matrixAutoUpdate=!1,E.matrixWorldNeedsUpdate=!1,W(o,e,E,null);var b=t.lineSegments2;if(b)if(i)for(var x=0;x<i;x++){var I=(new THREE.Matrix4).fromArray(r,16*x);b.matrixWorld.copy(I),b.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,E.matrixWorld),b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=!1,W(o,e,b,null)}else b.matrixWorld.copy(n),b.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n),b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=!1,W(o,e,b,null)}}var t=!1,n=null;function i(e){null!==n&&n(e),(vr.getDevice()||window).requestAnimationFrame(i)}o.animate=function(e){n=e,t||((vr.getDevice()||window).requestAnimationFrame(i),t=!0)};var v=new THREE.Vector3,A=new THREE.Quaternion,y=new THREE.Vector3;return o.renderScene=function(e,t,n,i,r){n.pixelSizeVector=(d=U.domElement.clientWidth,o=U.domElement.clientHeight,s=n.projectionMatrix,a=n.matrixWorldInverse,l=s.elements[0]*d*.5,d=s.elements[8]*d*.5+s.elements[11]*d*.5,l=new THREE.Vector3(a.elements[0]*l+a.elements[2]*d,a.elements[4]*l+a.elements[6]*d,a.elements[8]*l+a.elements[10]*d),d=s.elements[5]*o*.5,o=s.elements[9]*o*.5+s.elements[11]*o*.5,d=new THREE.Vector3(a.elements[1]*d+a.elements[2]*o,a.elements[5]*d+a.elements[6]*o,a.elements[9]*d+a.elements[10]*o),o=s.elements[11],s=s.elements[15],o=new THREE.Vector4(a.elements[2]*o,a.elements[6]*o,a.elements[10]*o,a.elements[14]*o+a.elements[15]*s),a=.7071067811/Math.sqrt(l.lengthSq()+d.lengthSq()),o.multiplyScalar(a),o);var o,a,m=r.ndsModelset,s=r.ndsModel,l=e.opaque,d=e.transparent,c=(r.renderInfo.currentRenderState.setupLightsView(n),!0===r.renderInfo.clippingEnabled&&this.renderContext.clipping.setGlobalState(U.clippingPlanes,n),i&&this.setViewportDirect(i),!1);m&&(r.bDrawReferenceEntity?m.models.forEach(function(e){h(m.activeModel=e,t,n)}):m.models.forEach(function(e){if(m.activeModel=e,_e.isVRmodel||_e.isARmodel&&_e.supportAR)renderNDSVR(e,t,n,r.remainTime);else{if(e.sketchFileUrl&&m.viewer.sketchStartLoad)return!0;u(e,t,n,r.remainTime)}})),s&&(r.bDrawReferenceEntity?h(s,t,n):(_e.isVRmodel||_e.isARmodel&&_e.supportAR?renderNDSVR:u)(element,t,n,r.remainTime)),m&&m.viewer.pmiObject&&m.viewer.pmiObject.traverse(function(e){if(e.followCamera)if("Mesh"===e.type&&"TextBufferGeometry"===e.geometry.type)e.quaternion.copy(m.viewer.camera.quaternion),e.updateMatrix(),e.updateMatrixWorld(!0),e.matrixAutoUpdate=!1;else if(0<e.children.length&&function(e){for(var t=0;t<e.length;t++){var n=e[t];if(0==t||5==t||10==t){if(1!=n)return 1}else if((1==t||2==t||4==t||6==t||8==t||9==t)&&0!=n)return 1}}(e.children[0].matrix.toArray())){e.children[0].matrix.decompose(v,A,y);var t=A.clone().conjugate();e.matrixWorld.decompose(v,A,y),A.copy(t),A.premultiply(m.viewer.camera.quaternion),e.matrixWorld.compose(v,A,y),e.matrixAutoUpdate=!1;for(var n=0;n<e.children.length;n++)e.children[n].updateMatrixWorld(!0)}else{e.matrixWorld.decompose(v,A,y),A.copy(m.viewer.camera.quaternion),e.matrixWorld.compose(v,A,y),e.matrixAutoUpdate=!1;for(var i=0;i<e.children.length;i++)e.children[i].updateMatrixWorld(!0)}if(e.hasOrientation&&e.line&&e.visible){var t=[],r=(t[0]=e.line.start.x,t[1]=e.line.start.y,t[2]=e.line.start.z,m.viewer.modelCoordToClientCoord(t)),t=((t=[])[0]=e.line.end.x,t[1]=e.line.end.y,t[2]=e.line.end.z,m.viewer.modelCoordToClientCoord(t)),o=t[0]-r[0],t=t[1]-r[1],a=!1;if(Math.abs(o),(5.67*o<t&&-5.67*o<t||t<5.67*o&&t<-5.67*o)&&1e-7<Math.abs(o))a=!0;else if(0<(o=Math.abs(o)<1e-7&&(o=-1,t<0)?1:o))for(var s=0;s<e.children.length;s++){var l=e.children[s];l.autoOrientation&&(l.matrixWorld.copy(l.originMatrixWorld),l.overturn=!1)}else for(var d=0;d<e.children.length;d++){var c=e.children[d];c.autoOrientation&&(c.matrixWorld.copy(c.originMatrixWorld),g.makeTranslation(-e.axis.start.x,-e.axis.start.y,-e.axis.start.z),c.matrixWorld.premultiply(g),g.makeRotationAxis(new THREE.Vector3(e.axis.end.x-e.axis.start.x,e.axis.end.y-e.axis.start.y,e.axis.end.z-e.axis.start.z),Math.PI),c.matrixWorld.premultiply(g),g.makeTranslation(e.axis.start.x,e.axis.start.y,e.axis.start.z),c.matrixWorld.premultiply(g),c.overturn=!1)}r=m.viewer.camera.getCameraTarget(),t=m.viewer.camera.position,o=new THREE.Vector3,r=(o.subVectors(r,t),new THREE.Vector3);if(r.subVectors(e.axis.start,e.axis.end),0==(o.dot(r)<=0?0:1))for(var h=0;h<e.children.length;h++){var u=e.children[h];!u.autoOrientation||a&&u.overturn||(g.makeTranslation(-e.axis.start.x,-e.axis.start.y,-e.axis.start.z),u.matrixWorld.premultiply(g),g.makeRotationAxis(new THREE.Vector3(e.line.end.x-e.line.start.x,e.line.end.y-e.line.start.y,e.line.end.z-e.line.start.z).normalize(),Math.PI),u.matrixWorld.premultiply(g),g.makeTranslation(e.axis.start.x,e.axis.start.y,e.axis.start.z),u.matrixWorld.premultiply(g),u.overturn=!0)}else for(var p=0;p<e.children.length;p++){var f=e.children[p];f.autoOrientation&&a&&f.overturn&&(f.matrixWorld.copy(f.originMatrixWorld),f.overturn=!1)}}}),t.overrideMaterial?(a=t.overrideMaterial,l.length&&this.renderObjects(l,t,n,a),d.length&&this.renderObjects(d,t,n,a)):(m&&!m.viewer.CADViewer?(5==m.viewer.getRenderMode()||4==m.viewer.getRenderMode()?m.models.forEach(function(e){c|=e.hasrenderMesh}):c=!0,l.length&&c&&this.renderObjects(l,t,n)):l.length&&this.renderObjects(l,t,n),d.length&&this.renderObjects(d,t,n),this.renderContext.state.buffers.depth.setTest(!0),this.renderContext.state.buffers.depth.setMask(!0),this.renderContext.state.buffers.color.setMask(!0),this.renderContext.state.setPolygonOffset(!1))},o.render=function(e,t,n,i,r,o,a){void 0===a&&(a=60);var s=null,l=(0<e.children.length&&e.children[e.children.length-1]instanceof Xt&&(s=e.children.pop()),null);0<e.children.length&&e.children[e.children.length-1]instanceof zt&&(l=e.children.pop()),void 0===n&&(n=null),_e.isVRmodel||_e.isARmodel&&_e.supportAR||(this.setRenderTarget(n),i&&(n?this.clearTarget(n):this.clear())),_e.isARmodel&&_e.supportAR&&t.ARCamera&&(t=t.ARCamera),this._render_(e,t,{forceClear:i,bDrawForPick:r,bDrawReferenceEntity:o,remainTime:a,ndsModelset:s,ndsModel:l})},o}var t,n;return n=c,(t=e).prototype=Object.create(n.prototype),Qt(t.prototype.constructor=t,n),e}(Se.isSupportCanvas2()?THREE.WebGLRenderer:THREE.WebGL1Renderer),on=(Zt.prototype=Object.assign(Object.create(c.prototype),{constructor:Zt,dispose:function(){this.renderTargetMaskBuffer.dispose(),this.shouldRenderMaskDownSample&&this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetEdgeBuffer1.dispose()},setSize:function(e,t){var n=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);(this.shouldRenderMaskDownSample?(this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetMaskDownSampleBuffer):this.renderTargetMaskBuffer).setSize(n,i),this.renderTargetBlurBuffer1.setSize(n,i),this.renderTargetEdgeBuffer1.setSize(n,i),this.separableBlurMaterial1.uniforms.texSize.value=new THREE.Vector2(n,i)},changeVisibilityOfNonSelectedObjects:function(o){var a=[];function e(e){(e instanceof THREE.Mesh||e instanceof THREE.SkinnedMesh||e instanceof THREE.Line||e instanceof THREE.LineSegments)&&a.push(e)}for(var t=0,n=this.selectedObjects.length;t<n;t++)this.selectedObjects[t].traverse(e);this.renderScene.traverse(function(e){if(e instanceof THREE.Mesh||e instanceof THREE.SkinnedMesh||e instanceof THREE.Line||e instanceof THREE.LineSegments){for(var t,n=!1,i=0,r=a.length;i<r;i++)if(a[i].id===e.id){n=!0;break}n||(t=e.visible,o&&!e.bVisible||(e.visible=o),e.bVisible=t)}})},renderToMaskBuffer:function(e){e.render(this.renderScene,this.renderCamera,this.renderTargetMaskBuffer,!0)},hideUnselectedObjects:function(){if(this.viewer.ndsModel){for(var e=0,t=this.selectedObjects.length;e<t;e++)this.selectedObjects[e].oldVisible=this.selectedObjects[e].visible;this.viewer.ndsModel.backupAllBodiesFlag(),this.viewer.ndsModel.backupEmptyBodyNodeVisibleState(),this.viewer.ndsModel.hideAllBodies(!1);for(e=0,t=this.renderScene.children.length;e<t;e++)this.renderScene.children[e]!=this.viewer.ndsModel&&(this.renderScene.children[e].oldVisible=this.renderScene.children[e].visible,this.renderScene.children[e].visible=!1);for(e=0,t=this.selectedObjects.length;e<t;e++)this.selectedObjects[e].isEmptyNode()||this.viewer.ndsModel.showBody(this.selectedObjects[e]);this.viewer.ndsModel.backupDirty(),this.viewer.ndsModel.setDirty(),this.viewer.ndsModel.setDrawMode(this.viewer.ndsModel.SHADED),this.renderScene.children.push(this.viewer.ndsModel),this.viewer.ndsModel.setOverrideMaterial(this.maskBufferMaterial,this.maskBufferMaterialCopy,!1)}else this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.maskBufferMaterial},resetVisibleState:function(){if(this.viewer.ndsModel){this.viewer.ndsModel.setOverrideMaterial(null,null,!1),this.viewer.ndsModel.resetAllBodiesFlag(),this.viewer.ndsModel.resetEmptyBodyNodeVisibleState(),this.viewer.ndsModel.resetDirty();for(var e=0,t=this.renderScene.children.length;e<t;e++)this.renderScene.children[e]!=this.viewer.ndsModel&&(this.renderScene.children[e].visible=this.renderScene.children[e].oldVisible);for(e=0,t=this.selectedObjects.length;e<t;e++)this.selectedObjects[e].oldVisible&&this.selectedObjects[e].oldVisible!==this.selectedObjects[e].visible&&!this.selectedObjects[e].isEmptyNode()&&(this.selectedObjects[e].oldVisible?this.viewer.ndsModel.showBody(this.selectedObjects[e]):this.viewer.ndsModel.hideBody(this.selectedObjects[e])),this.selectedObjects[e].oldVisible=void 0}else this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0)},renderToColorBuffer:function(e,t,n){this.quad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,n&&e.context.enable(e.context.STENCIL_TEST),this.viewer.ndsModel?e.render(this.scene,this.camera,t,!1):e.render(this.scene,this.camera)},renderOutline:function(e,t,n){n&&e.context.disable(e.context.STENCIL_TEST),e.setClearColor(16777215,1),this.hideUnselectedObjects(),this.renderToMaskBuffer(e),this.resetVisibleState(),this.shouldRenderMaskDownSample&&(this.quad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.render(this.scene,this.camera,this.renderTargetMaskDownSampleBuffer,!0)),this.quad.material=this.edgeDetectionMaterial;var i=this.shouldRenderMaskDownSample?this.renderTargetMaskDownSampleBuffer:this.renderTargetMaskBuffer;this.edgeDetectionMaterial.uniforms.maskTexture.value=i.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new THREE.Vector2(i.width,i.height),this.edgeDetectionMaterial.uniforms.edgeColor.value=this.visibleEdgeColor,e.render(this.scene,this.camera,this.renderTargetEdgeBuffer1,!0),this.quad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Zt.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.render(this.scene,this.camera,this.renderTargetBlurBuffer1,!0),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Zt.BlurDirectionY,e.render(this.scene,this.camera,this.renderTargetEdgeBuffer1,!0),this.renderToColorBuffer(e,t,n)},render:function(e,t,n,i,r){var o;0!==this.selectedObjects.length&&(e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha(),o=e.autoClear,e.autoClear=!1,this.renderOutline(e,n,r),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=o)},getEdgeDetectionMaterial:function(){return new THREE.ShaderMaterial({uniforms:{maskTexture:{value:null},texSize:{value:new THREE.Vector2(.5,.5)},edgeColor:{value:new THREE.Vector3(1,1,1)}},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"varying vec2 vUv; uniform sampler2D maskTexture; uniform vec2 texSize; uniform vec3 edgeColor; void main() {\n vec2 invSize = 1.0 / texSize; vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize); vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy); vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy); vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw); vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw); float diff1 = (c1.r - c2.r)*0.5; float diff2 = (c3.r - c4.r)*0.5; float d = length( vec2(diff1, diff2) ); gl_FragColor = vec4(edgeColor, 1.0) * vec4(d); }"})},getSeperableBlurMaterial:function(e){return new THREE.ShaderMaterial({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new THREE.Vector2(.5,.5)},direction:{value:new THREE.Vector2(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"#include <common> varying vec2 vUv; uniform sampler2D colorTexture; uniform vec2 texSize; uniform vec2 direction; uniform float kernelRadius; float gaussianPdf(in float x, in float sigma) { return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma; } void main() { vec2 invSize = 1.0 / texSize; float weightSum = gaussianPdf(0.0, kernelRadius); vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum; vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS); vec2 uvOffset = delta; for( int i = 1; i <= MAX_RADIUS; i ++ ) { float w = gaussianPdf(uvOffset.x, kernelRadius); vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb; vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb; diffuseSum += ((sample1 + sample2) * w); weightSum += (2.0 * w); uvOffset += delta; } float alpha = texture2D( colorTexture, vUv).a; gl_FragColor = vec4(diffuseSum/weightSum, alpha); }"})},getOverlayMaterial:function(){return new THREE.ShaderMaterial({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeStrength:{value:1}},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"varying vec2 vUv; uniform sampler2D maskTexture; uniform sampler2D edgeTexture1; uniform float edgeStrength; void main() { vec4 edgeValue = texture2D(edgeTexture1, vUv); vec4 maskColor = texture2D(maskTexture, vUv); vec4 finalColor = edgeStrength * maskColor.r * edgeValue; gl_FragColor = finalColor; }",blending:THREE.NormalBlending,depthTest:!1,depthWrite:!1,transparent:!0})}}),Zt.BlurDirectionX=new THREE.Vector2(1,0),Zt.BlurDirectionY=new THREE.Vector2(0,1),qt.prototype=Object.assign(Object.create(Zt.prototype),{constructor:qt,renderToMaskBuffer:function(e){if(0<this.tempSelectedObjects.length)for(var t=0,n=this.tempSelectedObjects.length;t<n;t++)this.tempScene.children.push(this.tempSelectedObjects[t]);e.render(this.renderScene,this.renderCamera,this.renderTargetMaskBuffer,!0),e.render(this.tempScene,this.renderCamera,this.renderTargetMaskBuffer,!1),0<this.tempSelectedObjects.length&&(this.tempScene.children.length=0)},render:function(e,t,n,i,r){var o;0===this.selectedObjects.length&&0===this.tempSelectedObjects.length||(e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha(),o=e.autoClear,e.autoClear=!1,this.renderOutline(e,n,r),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=o)}}),Kt.prototype=Object.assign(Object.create(Zt.prototype),{constructor:Kt,hideUnselectedObjects:function(){if(this.viewer.ndsModel){for(var e=0,t=this.selectedObjects.length;e<t;e++)this.selectedObjects[e].oldVisible=this.selectedObjects[e].visible;var n=this.viewer.ndsModel.getActiveModel();if(n.hasRefModel&&n.containsOriginalTransparentBodies)for(var i=this.viewer.ndsModel.getAllTransparentBodies(),r=0;r<i.length;++r)i[r].setDragged(!0);this.viewer.ndsModel.backupAllBodiesFlag(),this.viewer.ndsModel.backupEmptyBodyNodeVisibleState(),this.viewer.ndsModel.hideAllBodies(!1);for(e=0,t=this.renderScene.children.length;e<t;e++)this.renderScene.children[e]!=this.viewer.ndsModel&&(this.renderScene.children[e].oldVisible=this.renderScene.children[e].visible,this.renderScene.children[e].visible=!1);this.viewer.ndsModel.backupDirty(),this.viewer.ndsModel.setDirty(),this.viewer.ndsModel.setDrawMode(this.viewer.ndsModel.SHADED),this.renderScene.children.push(this.viewer.ndsModel),this.viewer.ndsModel.setOverrideMaterial(this.maskBufferMaterial,this.maskBufferMaterialCopy,!1)}else this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.maskBufferMaterial}}),Jt.prototype={render:function(e,t,n,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n&&n.texture?n.texture:n),this.renderToScreen||!t?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)},dispose:function(){this.material.dispose(),this.quad.geometry.dispose()}},$t.prototype={constructor:$t,load:function(e,t,n,i){var r=this,o=new THREE.XHRLoader;o.setCrossOrigin(this.crossOrigin),o.load(e,function(e){t(r.parse(e))},n,i)},parse:function(e){for(var t=e.split("\n"),n={},i=/\s+/,r={},o=0;o<t.length;o++){var a,s,l=(l=t[o]).trim();0!==l.length&&"#"!==l.charAt(0)&&(a=(a=0<=(s=l.indexOf(" "))?l.substring(0,s):l).toLowerCase(),l=(l=0<=s?l.substring(s+1):"").trim(),"newmtl"===a?r[l]=n={name:l}:n&&("ka"===a||"kd"===a||"ks"===a?(s=l.split(i,3),n[a]=[parseFloat(s[0]),parseFloat(s[1]),parseFloat(s[2])]):n[a]=l))}e=new $t.MaterialCreator(this.baseUrl,this.options);return e.setMaterials(r),e}},($t.MaterialCreator=function(e,t){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping}).prototype={constructor:$t.MaterialCreator,setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t,n={};for(t in e){var i,r=e[t],o={};for(i in n[t]=o,r){var a=!0,s=r[i],l=i.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(s=[s[0]/255,s[1]/255,s[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===s[0]&&0===s[1]&&0===s[1]&&(a=!1);break;case"d":this.options&&this.options.invertTransparency&&(s=1-s)}a&&(o[l]=s)}}return n},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e,t=0;for(e in this.materialsInfo)this.materialsArray[t]=this.create(e),this.nameLookup[e]=t,t++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){var t,n=this.materialsInfo[e],i={name:e,side:this.side};for(t in n){var r=n[t];switch(t.toLowerCase()){case"kd":i.diffuse=(new THREE.Color).fromArray(r);break;case"ka":i.ambient=(new THREE.Color).fromArray(r);break;case"ks":i.specular=(new THREE.Color).fromArray(r);break;case"map_kd":i.map=this.loadTexture(this.baseUrl+r),i.map.wrapS=this.wrap,i.map.wrapT=this.wrap;break;case"ns":i.shininess=r;break;case"d":r<1&&(i.transparent=!0,i.opacity=r)}}return i.diffuse&&(i.ambient||(i.ambient=i.diffuse),i.color=i.diffuse),this.materials[e]=new THREE.MeshPhongMaterial(i),this.materials[e]},loadTexture:function(e,t,n,i){var r=null,o=new THREE.Texture;return(r=new THREE.ImageLoader).crossOrigin=this.crossOrigin,r.load(e,function(e){o.image=$t.ensurePowerOfTwo_(e),o.needsUpdate=!0,n&&n(o)}),o.mapping=t,o}},$t.ensurePowerOfTwo_=function(e){var t;return THREE.Math.isPowerOfTwo(e.width)&&THREE.Math.isPowerOfTwo(e.height)?e:((t=document.createElement("canvas")).width=$t.nextHighestPowerOfTwo_(e.width),t.height=$t.nextHighestPowerOfTwo_(e.height),t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),t)},$t.nextHighestPowerOfTwo_=function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},$t.prototype=Object.create(THREE.EventDispatcher.prototype),en.prototype={constructor:en,load:function(t,e,i,r,o){function n(e){var n=e,e=(n&&n.preload(),new THREE.XHRLoader(a.manager));e.setCrossOrigin(this.crossOrigin),e.load(t,function(e){e=a.parse(e);e.traverse(function(e){var t;e instanceof THREE.Mesh&&e.material.name&&(t=n?n.create(e.material.name):null)&&(e.material=t)}),i(e)},r,o)}var a=this;e?new $t(t.substr(0,t.lastIndexOf("/")+1)).load(e,n,r,o):n()},parse:function(e,t){function n(e,t,n){return new THREE.Vector3(e,t,n)}function r(e,t,n,i){return new THREE.Face3(e,t,n,i)}var o=0;function i(e,t){0<h.length&&(l.vertices=h,l.mergeVertices(),l.computeFaceNormals(),l.computeBoundingSphere(),s.add(c),l=new THREE.Geometry,c=new THREE.Mesh(l,d)),void 0!==e&&(c.name=e),void 0!==t&&((d=new THREE.MeshLambertMaterial).name=t,c.material=d)}var a=new THREE.Group,s=a,l=new THREE.Geometry,d=new THREE.MeshLambertMaterial,c=new THREE.Mesh(l,d),h=[],u=[],p=[];function f(e,t,n,i){void 0===i?l.faces.push(r(parseInt(e)-(o+1),parseInt(t)-(o+1),parseInt(n)-(o+1))):l.faces.push(r(parseInt(e)-(o+1),parseInt(t)-(o+1),parseInt(n)-(o+1),[u[parseInt(i[0])-1].clone(),u[parseInt(i[1])-1].clone(),u[parseInt(i[2])-1].clone()]))}function m(e,t,n){l.faceVertexUvs[0].push([p[parseInt(e)-1].clone(),p[parseInt(t)-1].clone(),p[parseInt(n)-1].clone()])}function g(e,t,n){void 0===e[3]?(f(e[0],e[1],e[2],n),void 0!==t&&0<t.length&&m(t[0],t[1],t[2])):(void 0!==n&&0<n.length?(f(e[0],e[1],e[3],[n[0],n[1],n[3]]),f(e[1],e[2],e[3],[n[1],n[2],n[3]])):(f(e[0],e[1],e[3]),f(e[1],e[2],e[3])),void 0!==t&&0<t.length&&(m(t[0],t[1],t[3]),m(t[1],t[2],t[3])))}for(var v,A,y=/v( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,E=/vn( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,M=/vt( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,w=/f( +\d+)( +\d+)( +\d+)( +\d+)?/,b=/f( +(\d+)\/(\d+))( +(\d+)\/(\d+))( +(\d+)\/(\d+))( +(\d+)\/(\d+))?/,x=/f( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))?/,I=/f( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))?/,T=e.split("\n"),S=0;S<T.length;S++){var B,P=T[S];0!==(P=P.trim()).length&&"#"!==P.charAt(0)&&(null!==(B=y.exec(P))?h.push(n(parseFloat(B[1]),parseFloat(B[2]),parseFloat(B[3]))):null!==(B=E.exec(P))?u.push(n(parseFloat(B[1]),parseFloat(B[2]),parseFloat(B[3]))):null!==(B=M.exec(P))?p.push((v=parseFloat(B[1]),A=parseFloat(B[2]),new THREE.Vector2(v,A))):null!==(B=w.exec(P))?g([B[1],B[2],B[3],B[4]]):null!==(B=b.exec(P))?g([B[2],B[5],B[8],B[11]],[B[3],B[6],B[9],B[12]]):null!==(B=x.exec(P))?g([B[2],B[6],B[10],B[14]],[B[3],B[7],B[11],B[15]],[B[4],B[8],B[12],B[16]]):null!==(B=I.exec(P))?g([B[2],B[5],B[8],B[11]],[],[B[3],B[6],B[9],B[12]]):/^o /.test(P)?(i(),o+=h.length,h=[],(s=new THREE.Object3D).name=P.substring(2).trim(),a.add(s)):/^g /.test(P)?i(P.substring(2).trim(),void 0):/^usemtl /.test(P)?i(void 0,P.substring(7).trim()):/^mtllib /.test(P)?t&&t(P.substring(7).trim()):/^s /.test(P)||console.log("OBJMTLLoader: Unhandled line "+P))}return i(void 0,void 0),a}},en.prototype=Object.create(THREE.EventDispatcher.prototype),function(){this.skingMesh=null,this.actions=[],this.actionMap={}}),an=function(){this.mixer=null,this.actionSkinMeshs=[]},sn=function(e,t){var n,i,r,o=this,a=(this.viewer=e,new ve.Dialog({id:"dlgOpMeasure",className:"dialog",callbackEvent:c,title:"Measure Selection",noTitlebar:!0,noScrollbar:!0})),e=(a.setVisibility(!1),a.setSize(150,570),a.setOpacity(_e.dialogOpacity),e.container.appendChild(a.domElement),this.dialog=a,new ve.Element({className:"dialog-content"})),s=(a.setContent(e),new ve.Table),l="radioGroup",d={idRadioPointToPoint:"radioPointToPoint",idRadioPointToFace:"radioPointToFace",idRadioFaceDist:"radioFaceDist",idRadioFaceThickness:"radioFaceThickness",idRadioFaceAngle:"radioFaceAngle",idRadioMeasureEdges:"radioMeasureEdges",idRadioMeasureFaceArea:"radioFaceArea",idRadioMeasureFacePerimeter:"radioFacePerimeter",idRadioMeasureBoundingBox:"radioFaceBoundingBox",idRadioMeasureHoleDist:"radioHoleDist",idRadioMeasureRadius:"radioRadius",idRadioMeasureDiameter:"radioDiameter",idRadioMeasureDistance:"radioDistance",idRadioMeasureLineAngle:"radioLineAngle",idRadioMeasureBodyArea:"radioBodyArea",idRadioMeasureBodyVolume:"radioBodyVolume",idRadioMeasureTotalArea:"radioTotalArea",idRadioMeasureBodyAngle:"radioBodyAngle",idRadioMeasureBodyEdgeLength:"radioBodyEdgeLength",idRadioMeasureBodyDistance:"radioBodyDistance"};function c(e){var t=e.target.domElement.id;switch(t){case"dlgOpMeasure":var n=e,i=n.event.type,r=n.target;switch(i){case"mouseenter":r.deleteOpacity();break;case"mouseleave":r.setOpacity(_e.dialogOpacity);break;case"mouseover":r.deleteOpacity();break;case"mouseout":r.setOpacity(_e.dialogOpacity)}break;case d.idRadioPointToPoint:"click"===e.event.type&&h(d.idRadioPointToPoint);break;case d.idRadioPointToFace:"click"===e.event.type&&h(d.idRadioPointToFace);break;case d.idRadioFaceDist:"click"===e.event.type&&h(d.idRadioFaceDist);break;case d.idRadioFaceThickness:"click"===e.event.type&&h(d.idRadioFaceThickness);break;case d.idRadioFaceAngle:"click"===e.event.type&&h(d.idRadioFaceAngle);break;case d.idRadioMeasureEdges:"click"===e.event.type&&h(d.idRadioMeasureEdges);break;case d.idRadioMeasureFaceArea:"click"===e.event.type&&h(d.idRadioMeasureFaceArea);break;case d.idRadioMeasureFacePerimeter:"click"===e.event.type&&h(d.idRadioMeasureFacePerimeter);break;case d.idRadioMeasureBoundingBox:"click"===e.event.type&&h(d.idRadioMeasureBoundingBox);break;case d.idRadioMeasureHoleDist:"click"===e.event.type&&h(d.idRadioMeasureHoleDist);break;case d.idRadioMeasureRadius:"click"===e.event.type&&h(d.idRadioMeasureRadius);break;case d.idRadioMeasureDiameter:"click"===e.event.type&&h(d.idRadioMeasureDiameter);break;case d.idRadioMeasureDistance:"click"===e.event.type&&h(d.idRadioMeasureDistance);break;case d.idRadioMeasureLineAngle:"click"===e.event.type&&h(d.idRadioMeasureLineAngle);break;case d.idRadioMeasureBodyAngle:"click"===e.event.type&&h(d.idRadioMeasureBodyAngle);break;case d.idRadioMeasureBodyEdgeLength:"click"===e.event.type&&h(d.idRadioMeasureBodyEdgeLength);break;case d.idRadioMeasureBodyDistance:"click"===e.event.type&&h(d.idRadioMeasureBodyDistance);break;default:o.viewer.setMeasureOpType(t)}}function h(e){e=function(e){var t=null;switch(e){case d.idRadioPointToPoint:t="pt2pt";break;case d.idRadioPointToFace:t="LineAngle";break;case d.idRadioFaceDist:t="faceDist";break;case d.idRadioFaceThickness:t="faceThickness";break;case d.idRadioFaceAngle:t="faceAngle";break;case d.idRadioMeasureEdges:t="measureEdges";break;case d.idRadioMeasureFaceArea:t="faceArea";break;case d.idRadioMeasureFacePerimeter:t="facePerimeter";break;case d.idRadioMeasureBoundingBox:t="BoundingBox";break;case d.idRadioMeasureHoleDist:t="holeDist";break;case d.idRadioMeasureRadius:t="radius";break;case d.idRadioMeasureDiameter:t="contourarea";break;case d.idRadioMeasureDistance:t="Lineargauge";break;case d.idRadioMeasureLineAngle:t="lineAngle";break;case d.idRadioMeasureBodyAngle:t="bodyAngle";break;case d.idRadioMeasureBodyEdgeLength:t="bodyEdgeLength";break;case d.idRadioMeasureBodyDistance:t="bodyDistance"}return t}(e);e&&(o.viewer.setMeasureOpType(e),Se.isMobileDevice())&&o.viewer.Optoolbar&&o.viewer.Optoolbar.getMeasureDlg().show(!1)}t?(this.viewer.is2DModel?a.setSize(150,188):a.setSize(150,338),s.addRow(),n=new ve.Input({id:"PointToLine",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"点到线"}),s.addCol({element:i}),s.addRow(),this.viewer.is2DModel||(n=new ve.Input({id:"PointToFace",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"点到面"}),s.addCol({element:i})),s.addRow(),n=new ve.Input({id:"LineToLine",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"线到线"}),s.addCol({element:i}),this.viewer.is2DModel||(s.addRow(),n=new ve.Input({id:"LineToFace",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"线到面"}),s.addCol({element:i})),s.addRow(),n=new ve.Input({id:"AxisToPoint",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"孔轴到点"}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:"AxisToLine",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"孔轴到线"}),s.addCol({element:i}),this.viewer.is2DModel||(s.addRow(),n=new ve.Input({id:"AxisToFace",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"孔轴到面"}),s.addCol({element:i})),s.addRow(),n=new ve.Input({id:"LineAngle",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"线夹角"}),s.addCol({element:i}),this.viewer.is2DModel||(s.addRow(),n=new ve.Input({id:"LineFaceAngle",name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:"线面夹角"}),s.addCol({element:i}))):(s.addRow(),n=new ve.Input({id:d.idRadioMeasureBodyAngle,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_BODY_ANGLE")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureBodyEdgeLength,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_BODY_LENGTH")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureBodyDistance,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_BODY_DISATANCE")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioPointToPoint,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_DIST")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioPointToFace,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_ANGLE")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioFaceDist,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_FACE_DIST")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioFaceThickness,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_FACE_THICKNESS")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioFaceAngle,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_FACE_ANGLE")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureEdges,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_MEASURE_EDGES")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureFaceArea,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_FACE_AREA")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureFacePerimeter,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_FACE_PERIMETER")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureBoundingBox,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_BOUNDINGBOX")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureHoleDist,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_HOLE_DIST")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureRadius,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_RADIUS")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureDiameter,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_DIAMETER")}),s.addCol({element:i}),s.addRow(),n=new ve.Input({id:d.idRadioMeasureDistance,name:l,type:"radio",callbackEvent:c}),s.addCol({element:n}),a.addChildElement(n),i=new ve.Element({className:"dialog-content-info",text:Se.translateString("IDS_MEASURETYPE_2DDISTANCE")}),s.addCol({element:i})),e.domElement.appendChild(s.domElement),this.release=function(){o.viewer.container.removeChild(a.domElement)},this.show=function(e){var t,n,i;e&&(t=(i=o.viewer.tlbOperator).getChildElement("btnMeasure").domElement,t=(i=i.domElement).offsetLeft+t.offsetLeft,n=parseInt(Se.getStyle(i,"padding-top"))+parseInt(Se.getStyle(i,"padding-bottom"))+parseInt(Se.getStyle(i,"border-top-width"))+parseInt(Se.getStyle(i,"border-bottom-width"))+parseInt(Se.getStyle(i,"margin-bottom")),i=i.offsetHeight+n,a.setLeft(t),a.setBottom(i)),a.setVisibility(e)},this.setChecked=function(e){e=a.getChildElement(e);e&&(e.domElement.checked=!0)},this.getChecked=(r=l,function(){for(var e=document.getElementsByName(r),t=0;t<e.length;++t)if(e[t].checked)return e[t].id})};sn.prototype=Object.create(THREE.EventDispatcher.prototype),ve.TOUCH={TOUCH_SINGLE:10,TOUCH_DOUBLE:11,TOUCH_TRIPLE:12},ve.MOUSE={NONE:-1,LEFT:0,MIDDLE:1,RIGHT:2};function ln(e){h.call(this,e),this.measureClass="Distance"}function dn(e){h.call(this,e),this.measureClass="Hole"}function cn(e){h.call(this,e),this.measureClass="Edge"}function hn(e){h.call(this,e),this.measureClass="Face"}function r(e){h.call(this,e),this.measureClass="Angle"}function un(e){h.call(this,e),this.measureClass="BodyAndTotal"}function pn(e){h.call(this,e),this.measureClass="Coordinate"}function fn(e){h.call(this,e),this.measureClass="Lineargauge"}var mn=30,gn=20,g=function i(e){this.type="OpBase",this.viewer=e,this.state=-1,this.pointer=new THREE.Vector2,this.pointerOld=new THREE.Vector2,this.pointer2nd=new THREE.Vector2,this.pointerOld2nd=new THREE.Vector2,this.MouseDown=new THREE.Vector2,this.MouseUp=new THREE.Vector2,this.lMouseDown=new THREE.Vector2,this.lMouseUp=new THREE.Vector2,this.downModelPnt=new THREE.Vector3,this.singleTouchStartPos=new THREE.Vector2,this.singleTouchEndPos=new THREE.Vector2,this.normalMatrix=new THREE.Matrix3,this.intervalTimer=null,this.isDoubleTouch=!1;var t=.7,n=new THREE.SphereGeometry(t,20,20),r=new THREE.MeshPhongMaterial({color:7829503,depthTest:!0}),o=(this.rotateCenterHelper=new THREE.Mesh(n,r),this.rotateCenterHelper.name="rotateCenterHelper",this.rotateSphereCenter=null),a=(this.OpBeginTime=null,this.oldSelectType=e.selectionManager.getSelectType(),this.startTransform=null,this.endTransform=null,this.entityIsTransformed=!1,this.transformType="",(e.canvas2D||e.canvas3D).height,this.latAngle=0,this.selectBodyByRect=!this.viewer.is2DModel,this);function s(){this.getCameraScale=function(e,t){var n,i,r;return e?(t=null!=t?t:5,n=a.viewer.camera.getCameraTarget(),i=a.viewer.camera.position,(r=new THREE.Vector3).subVectors(n,i),n=e.clone(),e=a.viewer.camera.isPerspective?n.sub(i).dot(r.normalize()):1.2*r.length(),n=a.viewer.camera.fov,i=2*e*Math.tan(THREE.Math.degToRad(.5*n)),r=a.viewer.renderer.domElement.height,t*i*a.viewer.renderer.getPixelRatio()/r):1},this.run=function(){var e;a.rotateSphereCenter&&a.viewer.scene.getObjectByName("rotateCenterHelper")&&(e=this.getCameraScale(a.rotateCenterHelper.position,10*t),a.rotateCenterHelper.scale.x=a.rotateCenterHelper.scale.y=a.rotateCenterHelper.scale.z=e,a.rotateCenterHelper.updateMatrixWorld(!0))}}this.showRotateCenterHelper=function(){try{if(a.viewer.scene.getObjectByName("rotateCenterHelper"))return}catch(e){return}if(!a.rotateSphereCenter){var e=a.viewer.cameraControl.getRotateCenter();if(!e){var t=a.viewer.controls.getBoundingBox();if(t||renturn,!(e=t.getCenter()))return}a.rotateSphereCenter=e.clone(),a.rotateCenterHelper.position.x=a.rotateSphereCenter.x,a.rotateCenterHelper.position.y=a.rotateSphereCenter.y,a.rotateCenterHelper.position.z=a.rotateSphereCenter.z}o=o||new s,a.viewer.addFrameListener(o),a.viewer.scene.add(a.rotateCenterHelper),a.rotateCenterHelper.updateMatrixWorld(!0),a.viewer.render()},this.hideRotateCenterHelper=function(){try{if(!a.viewer.scene.getObjectByName("rotateCenterHelper"))return}catch(e){return}o&&a.viewer.removeFrameListener(o),a.viewer.scene.remove(a.rotateCenterHelper),a.viewer.render()},this.updateRotateCenterHelper=function(){var e=a.viewer.cameraControl.getRotateCenter();e&&(a.rotateSphereCenter=e.clone()),a.rotateSphereCenter&&!a.rotateCenterHelper.position.equals(a.rotateSphereCenter)&&(a.rotateCenterHelper.position.x=a.rotateSphereCenter.x,a.rotateCenterHelper.position.y=a.rotateSphereCenter.y,a.rotateCenterHelper.position.z=a.rotateSphereCenter.z,a.rotateCenterHelper.updateMatrixWorld(!0))},this.onMouseOut=function(e){_e.enableBroadcast&&!_e.broadcastMajor||(e.preventDefault(),a.IsNodeChildOfContainer(e.toElement))||a.onMouseUp(e)},this.IsNodeChildOfContainer=function(e){return!!e&&(e==a.viewer.container||a.IsNodeChildOfContainer(e.parentNode))},this.onMouseDown=function(e){var t,n,i,r;0===e.button&&1==e.buttons||1===e.button&&4==e.buttons||2===e.button&&2==e.buttons?_e.enableBroadcast&&!_e.broadcastMajor||a.viewer.isClipTransformControlSelected()||(e.preventDefault(),t=e.offsetX||e.clientX-a.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-a.viewer.container.getBoundingClientRect().top,e.srcElement&&e.srcElement!==a.viewer.renderer.domElement&&(t=e.clientX-a.viewer.container.getBoundingClientRect().left,n=e.clientY-a.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==a.viewer.renderer.domElement&&(t=e.clientX-a.viewer.container.getBoundingClientRect().left,n=e.clientY-a.viewer.container.getBoundingClientRect().top),a.pointer.set(t,n),i=[t,n],(r=null)!=(r=a.viewer.is2DModel?r:a.viewer.getIntersectionPtByScreenPt(i,!1))?a.downModelPnt.set(r.coords[0],r.coords[1],r.coords[2]):(r=a.viewer.clientCoordToModelCoord(i),a.downModelPnt.set(r[0],r[1],r[2])),a.MouseDown.set(t,n),0===e.button?(a.lMouseDown.set(t,n),a.onLMouseDown(e)):1===e.button?(a.onMMouseDown(e),a.viewer.renderer.domElement.removeEventListener("mousewheel",a.onMouseWheel,!1),a.viewer.canvas2D&&a.viewer.canvas2D.removeEventListener("mousewheel",a.onMouseWheel,!1)):2===e.button&&a.onRMouseDown(e),a.pointerOld.set(t,n),document.addEventListener("mouseup",a.onMouseUp,!1),a.viewer.testMode&&console.log("屏幕按下坐标为 x :"+e.clientX+" y :"+e.clientY)):console.log("onMouseDown btn %d btns %d undefined combo",e.button,e.buttons)};l=a.onNMouseMove,d=100,h=a;var l,d,c,h,u=function(){var e=arguments;c&&clearTimeout(c),c=setTimeout(function(){l.apply(h,e)},d)};this.onMouseMove=function(e){var t,n;a.OpBeginTime=Date.now(),_e.enableBroadcast&&!_e.broadcastMajor||a.viewer.isClipTransformControlSelected()||a.viewer.isLightEditControlSelected()||(e.preventDefault(),t=e.offsetX||e.clientX-a.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-a.viewer.container.getBoundingClientRect().top,e.srcElement&&e.srcElement!==a.viewer.renderer.domElement&&(t=e.clientX-a.viewer.container.getBoundingClientRect().left,n=e.clientY-a.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==a.viewer.renderer.domElement&&(t=e.clientX-a.viewer.container.getBoundingClientRect().left,n=e.clientY-a.viewer.container.getBoundingClientRect().top),a.pointer.set(t,n),a.pointer.equals(a.pointerOld))||(a.viewer.promptshow?(a.viewer.prompt.innerHTML=a.viewer.promptstring,a.viewer.prompt.style.display="inline",a.viewer.prompt&&(a.viewer.prompt.style.left=e.clientX+16-a.viewer.prompt.clientoffsetX+"px",a.viewer.prompt.style.top=e.clientY+16-a.viewer.prompt.clientoffsetY+"px")):a.viewer.prompt&&(a.viewer.prompt.style.display="none"),a.state===ve.MOUSE.LEFT?a.viewer.controls.staticAnnotation&&a.viewer.controls.staticAnnotation.onLMouseMoveEnable()?"OpAnnotationNew"==a.type&&a.onLMouseMove(e):_e.enableDirectMove&&a.viewer.selectionManager.hasTransformableObjectSelected()&&"OpBall"!=a.viewer.controls.getOperator().type?i.prototype.onLMouseMove.call(a,e):a.viewer.controls.getOperator().type==a.type&&a.onLMouseMove(e):a.state===ve.MOUSE.MIDDLE?a.onMMouseMove(e):a.state===ve.MOUSE.RIGHT?_e.enableDirectRotate&&a.viewer.selectionManager.hasTransformableObjectSelected()&&"OpBall"!=a.viewer.controls.getOperator().type?i.prototype.onRMouseMove.call(a,e):a.onRMouseMove(e):a.viewer.is2DModel&&Se.isMobileDevice()&&"OpMeasure"==a.type?u(e):(a.viewer.viewBox&&(a.viewer.viewBox.processMouseMove(e),a.viewer.viewBox.mouseMoveSave=e),a.onNMouseMove(e)),a.pointerOld.set(t,n))},this.onMouseUp=function(e){var t,n;0!==e.button&&1!==e.button&&2!==e.button||0!=e.buttons?("OpAnnotationNew"==this.type&&(this._isDragging||this._isResizing)&&(this._isDragging=!1,this._isResizing=!1,this.onLMouseUp()),console.log("onMouseUp btn %d btns %d undefined combo",e.button,e.buttons)):a.viewer.isClipTransformControlSelected()?a.onLMouseUp(e):(a.hideRotateCenterHelper(),document.removeEventListener("mouseup",a.onMouseUp,!1),e.preventDefault(),n=e.offsetX||e.clientX-a.viewer.container.getBoundingClientRect().left,t=e.offsetY||e.clientY-a.viewer.container.getBoundingClientRect().top,e.srcElement&&e.srcElement!==a.viewer.renderer.domElement&&(n=e.clientX-a.viewer.container.getBoundingClientRect().left,t=e.clientY-a.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==a.viewer.renderer.domElement&&(n=e.clientX-a.viewer.container.getBoundingClientRect().left,t=e.clientY-a.viewer.container.getBoundingClientRect().top),a.MouseUp.set(n,t),a.state===ve.MOUSE.LEFT?(a.lMouseUp.set(n,t),a.onLMouseUp(e),"OpDrag"==a.viewer.controls.getOperator().type&&"OpDrag"==a.type&&a.onLMouseUpEnd(e)):a.state===ve.MOUSE.MIDDLE?(a.onMMouseUp(e),a.viewer.renderer.domElement.addEventListener("mousewheel",a.onMouseWheel,!1),a.viewer.canvas2D&&a.viewer.canvas2D.addEventListener("mousewheel",a.onMouseWheel,!1)):a.state===ve.MOUSE.RIGHT&&a.onRMouseUp(e),a.viewer.testMode&&(n=a.viewer.getCameraInfo(),console.log("相机信息: "+JSON.stringify(n))))};p=function(){var e=a.viewer.getCameraInfo();console.log("相机信息: "+JSON.stringify(e))},f=null;var p,f,m=function(){null!==f&&clearTimeout(f),f=setTimeout(p,1e3)};this.onMouseWheel=function(e){var t,n;a.OpBeginTime=Date.now(),_e.enableBroadcast&&!_e.broadcastMajor||(e.preventDefault(),a.mouseEvent(e),t=0,n=mn,e.shiftKey&&(n=gn),e.wheelDelta?t=-e.wheelDelta:e.detail&&(t=e.detail),a.viewer.getMouseWheelForwardEnlargeFlag()||(t*=-1),t=0<t?n:-n,a.zoom(new THREE.Vector3(0,0,t),e),a.viewer.testMode&&m())},this.onClick=function(e){a.OpBeginTime=Date.now(),_e.enableBroadcast&&!_e.broadcastMajor||a.viewer.isClipTransformControlSelected()||a.viewer.isLightEditControlSelected()||(e.preventDefault(),0===e.button?a.lMouseDown.equals(a.lMouseUp)&&a.onLMouseClick(e):1===e.button?a.onMMouseClick(e):2===e.button&&a.onRMouseClick(e))},this.ondblClick=function(e){_e.enableBroadcast&&!_e.broadcastMajor||(e.preventDefault(),0===e.button?a.onLMouseDbClick():1!==e.button&&e.button)},this.touchstart=function(e){if((!_e.enableBroadcast||_e.broadcastMajor)&&!(a.viewer.isClipTransformControlSelected()||"Lineargauge"==a.measureType&&a.MeasureOper.lineargaugediv&&"block"==a.MeasureOper.lineargaugediv.style.display)){switch(e.preventDefault(),e.touches.length){case 1:if(clearTimeout(a.intervalTimer),a.isDoubleTouch)return"OpMeasure"!=a.type&&(_e.enableSelect?a.selectAndZoom(a.singleTouchEndPos.x,a.singleTouchEndPos.y):a.viewer.zoomExtents()),a.updateRotateCenterHelper(),a.state=-1,void(a.isDoubleTouch=!1);a.isDoubleTouch=!0,a.intervalTimer=setTimeout(function(){a.isDoubleTouch=!1},300);var t=e.touches[0].offsetX||e.touches[0].clientX-a.viewer.container.getBoundingClientRect().left,n=e.touches[0].offsetY||e.touches[0].clientY-a.viewer.container.getBoundingClientRect().top;a.pointer.set(t,n),a.pointerOld.set(t,n),a.singleTouchStartPos.set(t,n),a.viewer.testMode&&console.log("屏幕按下坐标为 x :"+t+" y :"+n),a.onTouchSingleStart(e);break;case 2:a.isDoubleTouch=!1;t=e.touches[0].offsetX||e.touches[0].clientX-a.viewer.container.getBoundingClientRect().left,n=e.touches[0].offsetY||e.touches[0].clientY-a.viewer.container.getBoundingClientRect().top;a.pointer.set(t,n),a.pointerOld.set(t,n),t=e.touches[1].offsetX||e.touches[1].clientX-a.viewer.container.getBoundingClientRect().left,n=e.touches[1].offsetY||e.touches[1].clientY-a.viewer.container.getBoundingClientRect().top,a.pointer2nd.set(t,n),a.pointerOld2nd.set(t,n),a.onTouchDoubleStart(e);break;default:a.isDoubleTouch=!1}var i=[a.pointer.x,a.pointer.y],r=null;null!=(r=a.viewer.is2DModel||1!=e.touches.length?r:a.viewer.getIntersectionPtByScreenPt(i,!1))?a.downModelPnt.set(r.coords[0],r.coords[1],r.coords[2]):(r=a.viewer.clientCoordToModelCoord(i),a.downModelPnt.set(r[0],r[1],r[2]))}},this.touchmove=function(e){if((!_e.enableBroadcast||_e.broadcastMajor)&&!(a.viewer.isClipTransformControlSelected()||a.viewer.isLightEditControlSelected()||"Lineargauge"==a.measureType&&a.MeasureOper.lineargaugediv&&"block"==a.MeasureOper.lineargaugediv.style.display)){switch(e.preventDefault(),e.touches.length){case 1:var t=e.touches[0].offsetX||e.touches[0].clientX-a.viewer.container.getBoundingClientRect().left,n=e.touches[0].offsetY||e.touches[0].clientY-a.viewer.container.getBoundingClientRect().top;if(a.pointer.set(t,n),a.viewer.limitEventArea){var i=a.viewer.container.getBoundingClientRect().width,r=a.viewer.container.getBoundingClientRect().height;if(i<t||r<n)return void a.touchend(e)}break;case 2:t=e.touches[0].offsetX||e.touches[0].clientX-a.viewer.container.getBoundingClientRect().left,n=e.touches[0].offsetY||e.touches[0].clientY-a.viewer.container.getBoundingClientRect().top;if(a.pointer.set(t,n),t=e.touches[1].offsetX||e.touches[1].clientX-a.viewer.container.getBoundingClientRect().left,n=e.touches[1].offsetY||e.touches[1].clientY-a.viewer.container.getBoundingClientRect().top,a.pointer2nd.set(t,n),a.viewer.limitEventArea){i=a.viewer.container.getBoundingClientRect().width,r=a.viewer.container.getBoundingClientRect().height;if((a.pointer.x>i||a.pointer.y>r)&&(a.pointer2nd.x>i||a.pointer2nd.y>r))return void a.touchend(e)}}switch(a.state){case ve.TOUCH.TOUCH_SINGLE:a.viewer.controls.getOperator().type!=a.type&&1!=e.force||a.onTouchSingleMove(e);break;case ve.TOUCH.TOUCH_DOUBLE:a.onTouchDoubleMove(e)}a.pointerOld.copy(a.pointer),a.pointerOld2nd.copy(a.pointer2nd)}},this.touchend=function(e){if((!_e.enableBroadcast||_e.broadcastMajor)&&!(a.viewer.isClipTransformControlSelected()||"Lineargauge"==a.measureType&&a.MeasureOper.lineargaugediv&&"block"==a.MeasureOper.lineargaugediv.style.display)){switch(a.state){case ve.TOUCH.TOUCH_SINGLE:var t,n;e.changedTouches&&0<e.changedTouches.length&&(n=e.changedTouches[0].offsetX||e.changedTouches[0].clientX-a.viewer.container.getBoundingClientRect().left,t=e.changedTouches[0].offsetY||e.changedTouches[0].clientY-a.viewer.container.getBoundingClientRect().top,a.singleTouchEndPos.set(n,t)),a.viewer.testMode&&(n=a.viewer.getCameraInfo(),console.log("相机信息: "+JSON.stringify(n))),a.onTouchSingleEnd(e);break;case ve.TOUCH.TOUCH_DOUBLE:a.onTouchDoubleEnd(e)}a.state=-1}},this.touchcancel=function(e){a.state=-1},this.onKeyDown=function(e){switch(e.keyCode){case 38:_e.enableArrowKeyOp&&a.moveForwardBack(!0,!0);break;case 37:_e.enableArrowKeyOp&&a.pan(new THREE.Vector3(-20,0,0),!0);break;case 40:_e.enableArrowKeyOp&&a.moveForwardBack(!1,!0);break;case 39:_e.enableArrowKeyOp&&a.pan(new THREE.Vector3(20,0,0),!0);break;case 46:var t;"OpAnnotationNew"==a.type&&a.enableMove&&(a.clearFlag(!0),a.deleteNoteAnnotation(a.selectID),a.deleteNoteAnnotation(a.picSelectID),(t=a.selectIDs.concat()).length)&&a.deleteNoteAnnotation(t)}},this.onKeyUp=function(e){}},ye=(g.prototype={constructor:g,center:function(){return this.viewer.camera.getCameraTarget()},render:function(e){this.dispatchEvent({type:"render",forceRenderAll:e=void 0===e?!1:e})},renderModel:function(){},update:function(){},mouseEvent:function(e){this.dispatchEvent({type:"mouseEvent",event:e})},onTouchSingleStart:function(e){this.state=ve.TOUCH.TOUCH_SINGLE},onTouchSingleMove:function(e){var t,n,i,r;this.viewer.is2DModel&&_e.New2DAPPMeasure&&"OpMeasure"==this.type?(i=this.pointer.x-this.pointerOld.x,r=this.pointer.y-this.pointerOld.y,this.pan(new THREE.Vector3(-i,r,0))):(t=new THREE.Vector2,n=new THREE.Vector2,t.copy(this.getMouseOnCircle(this.pointerOld.x,this.pointerOld.y)),n.copy(this.getMouseOnCircle(this.pointer.x,this.pointer.y)),i=n.x-t.x,r=n.y-t.y,this.rotate(new THREE.Vector3(i,r,0)))},onTouchSingleEnd:function(e){var t,n;this.state=-1,_e.enableSelect&&(t=Math.abs(this.singleTouchEndPos.x-this.singleTouchStartPos.x),n=Math.abs(this.singleTouchEndPos.y-this.singleTouchStartPos.y),t<3)&&n<3&&(this.viewer.is2DModel||this.selectByClick(this.singleTouchEndPos.x,this.singleTouchEndPos.y)),this.hideRotateCenterHelper()},onTouchDoubleStart:function(e){this.state=ve.TOUCH.TOUCH_DOUBLE},onTouchDoubleMove:function(e){var t=.5*(this.pointerOld.x+this.pointerOld2nd.x),n=.5*(this.pointerOld.y+this.pointerOld2nd.y),i=.5*(this.pointer.x+this.pointer2nd.x),r=.5*(this.pointer.y+this.pointer2nd.y),t=i-t,n=r-n,o=this.pointerOld.x-this.pointerOld2nd.x,a=this.pointerOld.y-this.pointerOld2nd.y,s=o*o+a*a,s=((o=this.pointer.x-this.pointer2nd.x)*o+(a=this.pointer.y-this.pointer2nd.y)*a)/s-1,o=this.pointer.x-this.pointerOld.x,a=this.pointer.y-this.pointerOld.y,l=this.pointer2nd.x-this.pointerOld2nd.x,d=this.pointer2nd.y-this.pointerOld2nd.y,o=new THREE.Vector2(o,a),a=(o.normalize(),new THREE.Vector2(l,d)),l=(a.normalize(),o.dot(a)),d=0,o=mn,a=!1;l<.6?.05<Math.abs(s)&&(d=0<s?-o:o,l={offsetX:i,offsetY:r},this.zoom(new THREE.Vector3(0,0,.4*d),l,!1),a=!0):0==t&&0==n||(this.pan(new THREE.Vector3(-t,n,0),!1),a=!0),a&&this.render()},onTouchDoubleEnd:function(e){this.state=-1,this.hideRotateCenterHelper()},onLMouseDbClick:function(e){_e.enableSelect?this.selectAndZoom(this.lMouseUp.x,this.lMouseUp.y):this.viewer.zoomExtents(),this.updateRotateCenterHelper()},onLMouseClick:function(e){_e.enableSelect&&!this.viewer.is2DModel&&this.selectByClick(this.lMouseUp.x,this.lMouseUp.y,e.ctrlKey)},onMMouseClick:function(e){},onRMouseClick:function(e){},onTransformStart:function(){var e;this.viewer.selectionManager.hasTransformableObjectSelected()&&(e=this.viewer.selectionManager.getSelectedObjects()[0],this.entityIsTransformed=!1,this.transformType="",this.startTransform=new THREE.Matrix4,e.matrix)&&this.startTransform.fromArray(e.matrix)},onTransformFinish:function(){var e,t,n;this.viewer.selectionManager.hasTransformableObjectSelected()&&this.entityIsTransformed&&(e=this.viewer.selectionManager.getSelectedObjects()[0],this.entityIsTransformed=!1,t=e.matrix.slice(0),this.startTransform.toArray(n=[]),this.viewer.dispatchEvent({type:"ComponentTransformedEvent",componentUuid:e.uuid,originalTransform:n,endTransform:t,transformType:this.transformType}),this.transformType="",this.viewer.ndsModel.updateBvh())},onLMouseDown:function(e){this.state=ve.MOUSE.LEFT,_e.enableDirectMove&&!this.viewer.isExploded()&&this.onTransformStart()},onMMouseDown:function(e){this.state=ve.MOUSE.MIDDLE,this.mouseEvent(e)},onRMouseDown:function(e){this.state=ve.MOUSE.RIGHT,this.mouseEvent(e),_e.enableDirectRotate&&!this.viewer.isExploded()&&this.onTransformStart()},onLMouseMove:function(e){var t,n,i,r,o;_e.enableDirectMove&&!this.viewer.isExploded()&&this.viewer.selectionManager.hasTransformableObjectSelected()?(i=this.viewer.selectionManager.getSelectedComponent())&&!i.isFixed()&&(r=this.pointer.x-this.pointerOld.x,o=this.pointer.y-this.pointerOld.y,n=[this.downModelPnt.x,this.downModelPnt.y,this.downModelPnt.z],n=[(n=this.viewer.modelCoordToClientCoord(n))[0]+r,n[1]+o,n[2]],n=this.viewer.clientCoordToModelCoord(n),(n=new THREE.Vector3(n[0],n[1],n[2]).clone()).sub(this.downModelPnt),t=new THREE.Matrix4,n=(new THREE.Matrix4).makeTranslation(n.x,n.y,n.z),i.matrix?t.fromArray(i.matrix).premultiply(n):t.copy(n),this.viewer.ndsModel.updateNodeMatrix(i.uuid,t.toArray()),this.render(),this.entityIsTransformed=!0,this.transformType="Move"):(n=new THREE.Vector2,i=new THREE.Vector2,n.copy(this.getMouseOnCircle(this.pointerOld.x,this.pointerOld.y)),i.copy(this.getMouseOnCircle(this.pointer.x,this.pointer.y)),r=i.x-n.x,o=i.y-n.y,this.rotate(new THREE.Vector3(r,o,0)))},drawRectangle:function(e,t,n,i,r){var o=this.viewer.renderer.getPixelRatio(),a=this.viewer.canvas2D.getContext("2d");a.clearRect(0,0,window.innerWidth*o,window.innerHeight*o),this.viewer.Rectangle=[],a.strokeStyle=r||"#00FFFF",a.setLineDash([5,5]),a.beginPath(),a.moveTo(e,t),a.lineTo(n,t),a.lineTo(n,i),a.lineTo(e,i),a.lineTo(e,t),a.closePath(),a.stroke(),a.setLineDash([]),this.viewer.Rectangle.push(e),this.viewer.Rectangle.push(n),this.viewer.Rectangle.push(t),this.viewer.Rectangle.push(i)},onMMouseMove:function(e){var t;this.selectBodyByRect&&(t=this.viewer.renderer.getPixelRatio(),this.drawRectangle(this.MouseDown.x*t,this.MouseDown.y*t,this.pointer.x*t,this.pointer.y*t))},onRMouseMove:function(e){var t,n,i,r,o,a,s=this.pointer.x-this.pointerOld.x,l=this.pointer.y-this.pointerOld.y;_e.enableDirectRotate&&!this.viewer.isExploded()&&this.viewer.selectionManager.hasTransformableObjectSelected()?(t=this.viewer.selectionManager.getSelectedComponent())&&!t.isFixed()&&((n=new THREE.Vector3(0,0,0)).unproject(this.viewer.camera),(r=new THREE.Vector3(10,0,0)).unproject(this.viewer.camera),r.sub(n).normalize(),(i=new THREE.Vector3(0,10,0)).unproject(this.viewer.camera),i.sub(n).normalize(),(n=new THREE.Quaternion).setFromAxisAngle(i,s/200),(i=new THREE.Quaternion).setFromAxisAngle(r,l/200),r=new THREE.Matrix4,o=new THREE.Matrix4,a=new THREE.Matrix4,t.matrix&&r.fromArray(t.matrix),a.makeTranslation(-this.downModelPnt.x,-this.downModelPnt.y,-this.downModelPnt.z),r.premultiply(a),o.premultiply(a),a.makeRotationFromQuaternion(n),r.premultiply(a),o.premultiply(a),a.makeRotationFromQuaternion(i),r.premultiply(a),o.premultiply(a),a.makeTranslation(this.downModelPnt.x,this.downModelPnt.y,this.downModelPnt.z),r.premultiply(a),o.premultiply(a),this.viewer.ndsModel.updateNodeMatrix(t.uuid,r.toArray()),this.render(),this.entityIsTransformed=!0,this.transformType="Rotate"):this.pan(new THREE.Vector3(-s,l,0))},onNMouseMove:function(e){_e.enablePreSelectBrep&&this.viewer.selectionManager.selectOnMouseMove(this.pointer.x,this.pointer.y)},onLMouseUp:function(e){this.state=-1,_e.enableDirectMove&&!this.viewer.isExploded()&&this.onTransformFinish(),_e.enableBroadcast&&_e.broadcastMajor&&this.viewer.dispatchEvent({type:"broadcastEvent"})},setSelectBodyByRect:function(e){this.selectBodyByRect=e},onMMouseUp:function(e){if(this.state=-1,this.mouseEvent(e),this.selectBodyByRect){e=this.viewer.renderer.getPixelRatio();if(this.viewer.canvas2D.getContext("2d").clearRect(0,0,window.innerWidth*e,window.innerHeight*e),this.MouseDown.x==this.MouseUp.x||this.MouseDown.y==this.MouseUp.y)return this.viewer.Rectangle=[],void this.viewer.render();this.viewer.Rectangle=[],this.viewer.selectionManager.selectBodyByRect(this.MouseDown.x,this.MouseDown.y,this.MouseUp.x,this.MouseUp.y)}this.viewer.render()},onRMouseUp:function(e){this.state=-1,this.mouseEvent(e),_e.enableDirectRotate&&!this.viewer.isExploded()&&this.onTransformFinish()},pan:function(e,t){this.viewer.cameraControl.pan(this,e,t),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[平移]",this.OpBeginTime)},moveForwardBack:function(e,t){this.viewer.cameraControl.moveForwardBack(this,e,t)},zoom:function(e,t,n){this.viewer.cameraControl.zoom(this,e,t,n),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[缩放]",this.OpBeginTime)},calFarthestDistToCamera:function(){return this.viewer.cameraControl.calFarthestDistToCamera()},zoomByMouse:function(e,t,n){this.cameraControl.zoomByMouse(this,e,t,n)},rotateByTrackBall:function(e,t){this.viewer.cameraControl.rotateByTrackBall(this,e,t)},rotateByHall:function(e,t){this.viewer.cameraControl.rotateByHall(this,t)},rotateByBim:function(e,t){this.viewer.cameraControl.rotateByBim(this,t)},rotateByFirstPerson:function(e){this.viewer.cameraControl.rotateByFirstPerson(this,e)},rotate:function(e,t){var n;this.viewer.isRotationEnable()&&("hall"==(n=this.viewer.getModelOperationMode())?this.rotateByHall(e,t):"bim"==n?this.rotateByBim(e,t):"FirstPerson"==n?this.rotateByFirstPerson(e):this.rotateByTrackBall(e,t),"FirstPerson"==n||ve.MOUSE.LEFT!==this.state&&ve.TOUCH.TOUCH_SINGLE!==this.state||this.showRotateCenterHelper()),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[旋转]",this.OpBeginTime)},createEventListener:function(){var e=this.viewer.canvas2D;e?Se.isMobileDevice()?(e.addEventListener("touchstart",this.touchstart,!1),e.addEventListener("touchend",this.touchend,!1),e.addEventListener("touchmove",this.touchmove,!1),e.addEventListener("touchcancel",this.touchmove,!1)):(e.addEventListener("mousedown",this.onMouseDown,!1),e.addEventListener("mousemove",this.onMouseMove,!1),e.addEventListener("mousewheel",this.onMouseWheel,!1),this.viewer.limitEventArea&&e.addEventListener("mouseout",this.onMouseOut,!1),e.addEventListener("DOMMouseScroll",this.onMouseWheel,!1),e.addEventListener("click",this.onClick,!1),e.addEventListener("dblclick",this.ondblClick,!1),e.addEventListener("touchstart",this.touchstart,!1),e.addEventListener("touchend",this.touchend,!1),e.addEventListener("touchmove",this.touchmove,!1),e.addEventListener("touchcancel",this.touchmove,!1),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1)):(e=null!=(e=this.viewer.renderer.domElement)?e:document,Se.isMobileDevice()?(e.addEventListener("touchstart",this.touchstart,!1),e.addEventListener("touchend",this.touchend,!1),e.addEventListener("touchmove",this.touchmove,!1),e.addEventListener("touchcancel",this.touchmove,!1)):(e.addEventListener("mousedown",this.onMouseDown,!1),e.addEventListener("mousemove",this.onMouseMove,!1),e.addEventListener("mousewheel",this.onMouseWheel,!1),this.viewer.limitEventArea&&e.addEventListener("mouseout",this.onMouseOut,!1),e.addEventListener("DOMMouseScroll",this.onMouseWheel,!1),e.addEventListener("click",this.onClick,!1),e.addEventListener("dblclick",this.ondblClick,!1),e.addEventListener("touchstart",this.touchstart,!1),e.addEventListener("touchend",this.touchend,!1),e.addEventListener("touchmove",this.touchmove,!1),e.addEventListener("touchcancel",this.touchmove,!1),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1)))},releaseEventListener:function(){var e=this.viewer.canvas2D;e?Se.isMobileDevice()?(e.removeEventListener("touchstart",this.touchstart,!1),e.removeEventListener("touchend",this.touchend,!1),e.removeEventListener("touchmove",this.touchmove,!1),e.removeEventListener("touchcancel",this.touchmove,!1)):(e.removeEventListener("mousedown",this.onMouseDown,!1),e.removeEventListener("mousemove",this.onMouseMove,!1),e.removeEventListener("mousewheel",this.onMouseWheel,!1),this.viewer.limitEventArea&&e.removeEventListener("mouseout",this.onMouseOut,!1),e.removeEventListener("DOMMouseScroll",this.onMouseWheel,!1),e.removeEventListener("click",this.onClick,!1),e.removeEventListener("dblclick",this.ondblClick,!1),e.removeEventListener("touchstart",this.touchstart,!1),e.removeEventListener("touchend",this.touchend,!1),e.removeEventListener("touchmove",this.touchmove,!1),e.removeEventListener("touchcancel",this.touchmove,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1)):(e=null!=(e=this.viewer.renderer.domElement)?e:document,Se.isMobileDevice()?(e.removeEventListener("touchstart",this.touchstart,!1),e.removeEventListener("touchend",this.touchend,!1),e.removeEventListener("touchmove",this.touchmove,!1),e.removeEventListener("touchcancel",this.touchmove,!1)):(e.removeEventListener("mousedown",this.onMouseDown,!1),e.removeEventListener("mousemove",this.onMouseMove,!1),e.removeEventListener("mousewheel",this.onMouseWheel,!1),this.viewer.limitEventArea&&e.removeEventListener("mouseout",this.onMouseOut,!1),e.removeEventListener("DOMMouseScroll",this.onMouseWheel,!1),e.removeEventListener("click",this.onClick,!1),e.removeEventListener("dblclick",this.ondblClick,!1),e.removeEventListener("touchstart",this.touchstart,!1),e.removeEventListener("touchend",this.touchend,!1),e.removeEventListener("touchmove",this.touchmove,!1),e.removeEventListener("touchcancel",this.touchmove,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1)))},create:function(){this.createEventListener()},init:function(){},release:function(){this.viewer.selectionManager.setSelectType(this.oldSelectType),this.releaseEventListener()},resetEventListener:function(){this.releaseEventListener(),this.createEventListener()},getMouseOnCircle:function(e,t){var n=this.viewer.renderer.domElement,i=new THREE.Vector2,r=this.viewer.renderer.getPixelRatio();return i.set((e*r-.5*n.width)/(.5*n.width),(n.height-2*t*r)/n.height),i},selectByClick:function(e,t,n){this.viewer.selectionManager.selectByClick(e,t,n),0==this.viewer.selectionManager.getSelectedObjects().length&&this.viewer.dispatchEvent({type:"pickOnEmptyArea",clickPosX:e,clickPosY:t}),this.render(),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[选择(单击)]",this.OpBeginTime)},selectAndZoom:function(e,t){this.viewer.selectionManager.clearSelection(),this.viewer.selectionManager.selectByClick(e,t);var n,i,e=this.viewer.selectionManager.getSelectedObjects();1==e.length?(this.viewer.zoomToObject(e[0]),_e.dynamicRotateCenter&&(t=new THREE.Vector3,n=new THREE.Vector3,this.viewer.computeBoundingBox(e[0],t,n,{flag:!0}),(i=new THREE.Vector3).x=.5*(n.x+t.x),i.y=.5*(n.y+t.y),i.z=.5*(n.z+t.z),this.viewer.cameraControl.setRotateCenter(i)),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[自动缩放(模型)]",this.OpBeginTime)):(this.viewer.is2DModel&&this.viewer.fixedViewInfo?this.viewer.startSmoothTranslation(this.viewer.fixedViewInfo,function(){}):this.viewer.zoomExtents(),i=this.viewer.controls.getBoundingBox().getCenter(),this.viewer.cameraControl.setRotateCenter(i),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[自动缩放(鼠标点击位置)]",this.OpBeginTime))}},Object.assign(g.prototype,THREE.EventDispatcher.prototype),function(e){g.call(this,e),this.type="OpDrag",this.opMode="default"}),vn=(ye.prototype=Object.create(g.prototype),ye.prototype.setMoveMode=function(){this.opMode="move"},ye.prototype.setRestoreMode=function(){this.opMode="restore"},ye.prototype.setDefaultMode=function(){this.opMode="default"},ye.prototype.isModelMoved=function(){var t;return this.viewer.ndsModel?this.viewer.ndsModel.hasDraggedBodies():(t=!1,this.viewer.scene.traverse(function(e){e.hasOwnProperty("geometry")&&null!=e.matrixWorldTransOrginalDrag&&(t=!0)}),t)},ye.prototype.hideSelectedModel=function(){this.viewer.hideSelectedObjects(),this.viewer.isSectionViewEnabled()&&this.viewer.clipPlaneManager.updateClipPlane()},ye.prototype.showAllModel=function(){this.viewer.showObject(this.viewer.scene,!0),this.viewer.isSectionViewEnabled()&&this.viewer.clipPlaneManager.updateClipPlane(),this.render()},ye.prototype.reverseVisibleAndHidingModel=function(){this.viewer.showObjectReversed(this.viewer.scene),this.viewer.isSectionViewEnabled()&&this.viewer.clipPlaneManager.updateClipPlane(),this.render()},ye.prototype.create=function(){_e.HideLeafBody?(this.viewer.selectionManager.setSelectType("part"),this.viewer.controls.getOperator().oldSelectType="part"):this.viewer.selectionManager.setSelectType("body"),g.prototype.create.call(this)},ye.prototype.release=function(){this.update(),this.render(),g.prototype.release.call(this)},ye.prototype.update=function(){this.viewer.selectionManager.clearSelection(),g.prototype.update.call(this)},ye.prototype.onLMouseClick=function(e){e.preventDefault();var t=this.viewer,n=(t.renderer.domElement,e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left),i=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top;e.srcElement&&e.srcElement!==this.viewer.renderer.domElement&&(n=e.clientX-this.viewer.container.getBoundingClientRect().left,i=e.clientY-this.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==this.viewer.renderer.domElement&&(n=e.clientX-this.viewer.container.getBoundingClientRect().left,i=e.clientY-this.viewer.container.getBoundingClientRect().top),Math.abs(n-this.lMouseDown.x)<1&&Math.abs(i-this.lMouseDown.y)<1&&("move"==this.opMode||"default"==this.opMode?(t.selectionManager.selectByClick(n,i,e.ctrlKey),this.render()):"restore"==this.opMode&&this.onOpRestore(n,i))},ye.prototype.onOpDrag=function(){var e=this.viewer.ndsModel?this.viewer.selectionManager.getSelectedObjects():this.viewer.selectionManager.getSelectedMeshes(),t=this.pointer.x-this.pointerOld.x,n=this.pointer.y-this.pointerOld.y,i=[this.downModelPnt.x,this.downModelPnt.y,this.downModelPnt.z],i=this.viewer.modelCoordToClientCoord(i),t=[i[0]+t,i[1]+n,i[2]],n=this.viewer.clientCoordToModelCoord(t),r=new THREE.Vector3(n[0],n[1],n[2]).clone();if(r.sub(this.downModelPnt),null==this.viewer.draggedObjects&&(this.viewer.draggedObjects=new Array),this.viewer.ndsModel){for(var o=0;o<e.length;++o){var a=e[o];this.viewer.ndsModel.dragBody(a,r),this.addDraggedObject(a)}this.viewer.isSectionViewEnabled()&&this.viewer.clipPlaneManager.updateClipPlane()}else for(o=0;o<e.length;++o){void 0===(a=e[o].key).matrixWorldTransOrginal&&(a.matrixWorldTransOrginal=new THREE.Vector3,a.matrixWorldTransOrginal.setFromMatrixPosition(a.matrixWorld));var s=new THREE.Vector3;s.setFromMatrixPosition(a.matrixWorld),s.add(r),a.matrixWorld.setPosition(s),a.matrixWorldTransExplode?s.sub(a.matrixWorldTransExplode):s.sub(a.matrixWorldTransOrginal),void 0===a.matrixWorldTransOrginalDrag&&(a.matrixWorldTransOrginalDrag=new THREE.Vector3),a.matrixWorldTransOrginalDrag.copy(s),this.addDraggedObject(a)}this.render(),this.viewer.dispatchEvent({type:"dragingModel"})},ye.prototype.addDraggedObject=function(e){for(var t=0;t<this.viewer.draggedObjects.length;++t)if(e==this.viewer.draggedObjects[t])return;this.viewer.draggedObjects.push(e)},ye.prototype.removeDraggedObject=function(e){if(null!=this.viewer.draggedObjects)for(var t=0;t<this.viewer.draggedObjects.length;++t)if(e==this.viewer.draggedObjects[t])return void this.viewer.draggedObjects.splice(t,1)},ye.prototype.onOpRestore=function(e,t){if(this.viewer.selectionManager.clearSelection(),this.viewer.selectionManager.selectByClick(e,t),this.viewer.ndsModel){for(var n=this.viewer.selectionManager.getSelectedObjects(),i=0;i<n.length;++i){var r=n[i];this.viewer.ndsModel.restoreDraggedBody(r),this.removeDraggedObject(r)}this.viewer.isSectionViewEnabled()&&this.viewer.clipPlaneManager.updateClipPlane()}else for(n=this.viewer.selectionManager.getSelectedMeshes(),i=0;i<n.length;++i)(r=n[i].key).matrixWorldTransOrginalDrag&&(r.matrixWorldTransOrginalDrag=void 0),r.matrixWorldTransExplode?r.matrixWorld.setPosition(r.matrixWorldTransExplode):r.matrixWorldTransOrginal&&(r.matrixWorld.setPosition(r.matrixWorldTransOrginal),r.matrixWorldTransOrginal=void 0),this.removeDraggedObject(r);this.render(),this.viewer.dispatchEvent({type:"dragingModel"})},ye.prototype.onLMouseMove=function(e){0<(this.viewer.ndsModel?this.viewer.selectionManager.getSelectedObjects():this.viewer.selectionManager.getSelectedMeshes()).length&&"move"==this.opMode?this.onOpDrag():g.prototype.onLMouseMove.call(this,e)},ye.prototype.onLMouseUpEnd=function(e){var t,n,i;0<(this.viewer.ndsModel?this.viewer.selectionManager.getSelectedObjects():this.viewer.selectionManager.getSelectedMeshes()).length&&(t=new THREE.Vector3,n=new THREE.Vector3,this.viewer.ndsModel&&(i=!this.viewer.is2DModel&&this.viewer.ndsModel instanceof NDSWebViewer.NdsModelSet&&!(i=this.viewer.ndsModel.getTotalBodyBoundingBox()).isEmpty()?i:this.viewer.modelRootObject.boundingBox.clone())&&(t.copy(i.min),n.copy(i.max)),t.x>n.x||t.y>n.y||t.z>n.z||this.viewer.cameraControl.setBoundingBox(t,n))},ye.prototype.onTouchSingleStart=function(e){g.prototype.onTouchSingleStart.call(this,e)},ye.prototype.onTouchSingleMove=function(e){0<(this.viewer.ndsModel?this.viewer.selectionManager.getSelectedObjects():this.viewer.selectionManager.getSelectedMeshes()).length&&"move"==this.opMode?this.onOpDrag():g.prototype.onTouchSingleMove.call(this,e)},ye.prototype.onTouchSingleEnd=function(e){this.state=-1,Math.abs(this.singleTouchEndPos.x-this.singleTouchStartPos.x)<1&&Math.abs(this.singleTouchEndPos.y-this.singleTouchStartPos.y)<1&&("move"==this.opMode||"default"==this.opMode?(this.viewer.selectionManager.selectByClick(this.singleTouchEndPos.x,this.singleTouchEndPos.y),this.render()):"restore"==this.opMode&&this.onOpRestore(this.singleTouchEndPos.x,this.singleTouchEndPos.y)),this.hideRotateCenterHelper()},0),An=function(e){var r,E=e,o=null,a=null,s=null,l=!1,d=null,p=Number.MAX_VALUE,c=null,h=null;this.isSnapped=function(){return l},this.getSnappedType=function(){return d},this.getSnappedVertex=function(){return a},this.isEqualWithPrecision=function(e,t){return Math.abs(e-t)<=.001},this.isEqualVectorsWithPrecision=function(e,t){return Math.abs(e.x-t.x)<=.001&&Math.abs(e.y-t.y)<=.001&&Math.abs(e.z-t.z)<=.001},this.isInverseVectorsWithPrecision=function(e,t){return Math.abs(e.x+t.x)<=.001&&Math.abs(e.y+t.y)<=.001&&Math.abs(e.z+t.z)<=.001},this.trianglesSharedEdge=function(e,t,n,i,r,o){var a=!1,s=!1,l=!1;return(e.equals(i)||e.equals(r)||e.equals(o))&&(a=!0),(t.equals(i)||t.equals(r)||t.equals(o))&&(s=!0),(n.equals(i)||n.equals(r)||n.equals(o))&&(l=!0),!!(a&s||a&l||s&l)},this.getTrianglesOnSameFace=function(e,t,n,i){var r=!1,o=e.vertices.slice(),a=new THREE.Geometry,s=(a.vertices.push(t),a.vertices.push(n),a.vertices.push(i),a.faces.push(new THREE.Face3(0,1,2)),[]);do{for(var s=[],l=0;l<o.length;l+=3)if(o[l].equals(t)&&o[l+1].equals(n)&&o[l+2].equals(i))r=!0,s.push(l);else for(var d=0;d<a.vertices.length;d+=3)if(this.trianglesSharedEdge(o[l],o[l+1],o[l+2],a.vertices[d],a.vertices[d+1],a.vertices[d+2])){var c=a.vertices.length;a.vertices.push(o[l].clone()),a.vertices.push(o[l+1].clone()),a.vertices.push(o[l+2].clone()),a.faces.push(new THREE.Face3(c,c+1,c+2)),s.push(l);break}for(var h=s.length-1;0<=h;--h)o.splice(s[h],3)}while(0<s.length);return r?a:null},this.faceSnapping=function(e,t){var n=new THREE.Vector3,i=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Geometry;if(t instanceof THREE.Geometry){h=t.vertices[e.a].clone(),u=t.vertices[e.b].clone(),p=t.vertices[e.c].clone();for(var a=0;a<t.faces.length;a++){var s=t.faces[a],n=t.vertices[s.a].clone(),i=t.vertices[s.b].clone(),r=t.vertices[s.c].clone(),l=THREE.Triangle.normal(n,i,r);this.isEqualVectorsWithPrecision(l,e.normal)&&this.isEqualWithPrecision(l.dot(n),e.normal.dot(h))&&(y=o.vertices.length,o.vertices.push(n.clone()),o.vertices.push(i.clone()),o.vertices.push(r.clone()),o.faces.push(new THREE.Face3(y,y+1,y+2)))}}else if(E.ndsModel&&t instanceof de){var d=t.attributes.position,c=t.index.array,h=new THREE.Vector3,u=new THREE.Vector3,p=new THREE.Vector3;h.fromBufferAttribute(d,e.a),u.fromBufferAttribute(d,e.b),p.fromBufferAttribute(d,e.c);for(var a=t.drawRange.start,f=t.drawRange.start+t.drawRange.count;a<f;a+=3){var m=c[a],g=(n.fromBufferAttribute(d,m),c[a+1]),v=(i.fromBufferAttribute(d,g),c[a+2]),l=(r.fromBufferAttribute(d,v),THREE.Triangle.normal(n,i,r));this.isEqualVectorsWithPrecision(l,e.normal)&&this.isEqualWithPrecision(l.dot(n),e.normal.dot(h))&&(y=o.vertices.length,o.vertices.push(n.clone()),o.vertices.push(i.clone()),o.vertices.push(r.clone()),o.faces.push(new THREE.Face3(y,y+1,y+2)))}}else if(t instanceof THREE.BufferGeometry){var A=t.attributes.position.array,c=t.index.array;(h=new THREE.Vector3).set(A[3*e.a],A[3*e.a+1],A[3*e.a+2]),(u=new THREE.Vector3).set(A[3*e.b],A[3*e.b+1],A[3*e.b+2]),(p=new THREE.Vector3).set(A[3*e.c],A[3*e.c+1],A[3*e.c+2]);for(a=0;a<c.length;a+=3){var y,m=c[a],g=(n.set(A[3*m],A[3*m+1],A[3*m+2]),c[a+1]),v=(i.set(A[3*g],A[3*g+1],A[3*g+2]),c[a+2]),l=(r.set(A[3*v],A[3*v+1],A[3*v+2]),THREE.Triangle.normal(n,i,r));this.isEqualVectorsWithPrecision(l,e.normal)&&this.isEqualWithPrecision(l.dot(n),e.normal.dot(h))&&(y=o.vertices.length,o.vertices.push(n.clone()),o.vertices.push(i.clone()),o.vertices.push(r.clone()),o.faces.push(new THREE.Face3(y,y+1,y+2)))}}return 0<o.vertices.length&&o.vertices.length<5e3?this.getTrianglesOnSameFace(o,h,u,p):null},this.edgeSnapping=function(e,t){for(var n=new THREE.Geometry,i=!0,r=!0,o=!0,a=0;a<e.vertices.length;a+=3){for(var s=0;s<e.vertices.length;s+=3)a!==s&&((e.vertices[a].equals(e.vertices[s])||e.vertices[a].equals(e.vertices[s+1])||e.vertices[a].equals(e.vertices[s+2]))&&(e.vertices[a+1].equals(e.vertices[s])||e.vertices[a+1].equals(e.vertices[s+1])||e.vertices[a+1].equals(e.vertices[s+2]))&&(i=!1),(e.vertices[a].equals(e.vertices[s])||e.vertices[a].equals(e.vertices[s+1])||e.vertices[a].equals(e.vertices[s+2]))&&(e.vertices[a+2].equals(e.vertices[s])||e.vertices[a+2].equals(e.vertices[s+1])||e.vertices[a+2].equals(e.vertices[s+2]))&&(r=!1),e.vertices[a+1].equals(e.vertices[s])||e.vertices[a+1].equals(e.vertices[s+1])||e.vertices[a+1].equals(e.vertices[s+2]))&&(e.vertices[a+2].equals(e.vertices[s])||e.vertices[a+2].equals(e.vertices[s+1])||e.vertices[a+2].equals(e.vertices[s+2]))&&(o=!1);i&&(n.vertices.push(e.vertices[a].clone()),n.vertices.push(e.vertices[a+1].clone())),r&&(n.vertices.push(e.vertices[a].clone()),n.vertices.push(e.vertices[a+2].clone())),o&&(n.vertices.push(e.vertices[a+1].clone()),n.vertices.push(e.vertices[a+2].clone())),o=r=i=!0}for(var l,d=new THREE.Geometry,c=Number.MAX_VALUE,h=0;h<n.vertices.length;h+=2){var u=this.distancePointToLine(t,n.vertices[h],n.vertices[h+1]);u<c&&(c=u,l=h)}return d.vertices.push(n.vertices[l].clone()),d.vertices.push(n.vertices[l+1].clone()),d.vertices=this.getConnectedLineSegmentsOnSameLine(n,d.vertices),p=c,d},this.distancePointToLine=function(e,t,n){var i,r=new THREE.Vector3,o=new THREE.Vector3;return r.subVectors(t,e),o.subVectors(n,t),i=r.dot(o),r.subVectors(n,t),(i=-i/r.dot(r))<0?e.distanceTo(t):1<i?e.distanceTo(n):(r.subVectors(e,t),o.subVectors(e,n),r.cross(o),o.subVectors(n,t),Math.sqrt(r.dot(r))/Math.sqrt(o.dot(o)))},this.getConnectedLineSegmentsOnSameLine=function(e,t){var n=e.vertices.slice(),i=t[0],r=t[1],o=[];do{for(var o=[],a=0;a<n.length;a+=2)if(!n[a].equals(i)||!n[a+1].equals(r))for(var s=0;s<t.length;s+=2)if(n[a].equals(t[s])||n[a+1].equals(t[s])||n[a].equals(t[s+1])||n[a+1].equals(t[s+1])){var l=new THREE.Vector3,d=new THREE.Vector3;if(l.subVectors(t[s],t[s+1]),l.normalize(),d.subVectors(n[a],n[a+1]),d.normalize(),this.isEqualVectorsWithPrecision(l,d)||this.isInverseVectorsWithPrecision(l,d)){o.push(a);break}}for(var c=o.length-1;0<=c;--c)t.push(n[o[c]]),t.push(n[o[c]+1]),n.splice(o[c],2)}while(0<o.length);return t},this.vertexSnapping=function(e,t){for(var n=Number.MAX_VALUE,i=new THREE.Vector3,r=0;r<e.vertices.length;++r){var o=t.distanceTo(e.vertices[r]);o<n-.001&&(n=o,i=e.vertices[r].clone())}return c=n,i},this.setDetectRadius=function(e){var t=Se.isMobileDevice()?25:10,n=E.camera.getCameraTarget(),i=E.camera.position,r=new THREE.Vector3,n=(r.subVectors(n,i),e.clone()),e=E.camera.isPerspective?n.sub(i).dot(r.normalize()):r.length(),n=E.camera.fov,i=2*e*Math.tan(THREE.Math.degToRad(.5*n)),r=E.renderer.domElement.height;return t*i*E.renderer.getPixelRatio()/r},this.doSnapping=function(e){l=!1,a=o=null;var t,n=e.face,i=(s=e.point,e.object);(i=E.ndsModel&&i instanceof Ae&&-1<e.meshId?E.ndsModel.meshManager.getSingleMesh(e.meshId):i)instanceof THREE.Mesh&&i.hasOwnProperty("geometry")?(o=this.faceSnapping(n,i.geometry))&&(o.applyMatrix(i.matrixWorld),r=this.edgeSnapping(o,s),a=this.vertexSnapping(r,s),h=this.setDetectRadius(s),d=c<h?vn:p<h?1:2,l=!0):i instanceof THREE.LineSegments&&i.hasOwnProperty("geometry")&&(n=i.geometry)instanceof THREE.BufferGeometry&&(i=n.attributes.position.array,t=(n=n.index.array)[e=e.index],n=n[e+1],(e=new THREE.Vector3).set(i[3*t],i[3*t+1],i[3*t+2]),(t=new THREE.Vector3).set(i[3*n],i[3*n+1],i[3*n+2]),h=2*this.setDetectRadius(s),s.distanceTo(e)<h?(d=vn,a=e,l=!0):s.distanceTo(t)<h&&(d=vn,a=t,l=!0))}},h=(ve.INFOTYPE={POINT:1,SECONDPOINT:2,POINTLINE:3,LINE:4,POINTPLANE:5,PLANE:6,SECONDLINE:7,LINEPLANE:8,PARALLELLINE:9,PARALLELPLANE:10,CIRCLE:11,SECONDCIRCLE:12,SECONDPLANE:13,AXISLINE:14,AXISPOINT:15,AXIS:16,AXISPLANE:17,FACE:18,CIRCLEANDLINE:19,FIRSTPOINT:20,BODY:21,LINEPOSITION:22,FIRMEASUREBODY:23,SECMEASUREBODY:24,MEASUREBODY:25,THIRDPOINT:26,ENDMEASURE:27,CANCELLINE:28,FIRSTLINE:29,MOUSEENTER:30,CROSSENTER:31,FIRSTPLANE:32,COORDINATEPOINT:33,CIRCLEA:34,LINEANDCIRCLE:35,FIRSTPARALLELPLANE:36,CLICKFIRSTPOINT:37,CLICKSECONDPOINT:38,PROJECTPLANE:39,SELECTPROJECTPLANE:40,PLACELINELOCATION:41,SELECTPLACELINELOCATION:42,FIRSTMESH:43,SECONDMESH:44,MEASURENOTICEBEGIN:45,AXISNOPARALLEL:46,NOPARALLEL:47,INTERSECT:48,LINEPARALLEL:49,PLANEPARALLELLINE:50,LINEPARALLELPLANE:51,PLANEPARALLEL:52,TWOAXISNOPARALLEL:53,NOBREP:54,NOCONJOINT:55,NOCLOSE:56,PLANENOPARALLEL:57,LINENOPARALLEL:58,NOTFACE:59,LOADDATE:60,TWOBODYPARALLEL:61,TWOBODYNOTPARALLEL:62,NOTFACEPARALLEL:63,NOTFACESECOND:64,MESHVERTICAL:65,AXISNOPARALLELLINE:66,NOBREPNOPLNE:67},ve.MEASUREFLAG={pt2pt:1,pointtoline:2,pointtoface:4,axistopoint:8,linetoline:16,linetoface:32,facedist:64,axistoline:128,axistoface:256,holedist:512,Edge:512,perimeter:1024,LineAngle:2048,LineFaceAngle:4096,faceAngle:8192,radius:16384,contour:32768,contourarea:65536,Lineargauge:131072,coordinate:262144,bodyAngle:524288,bodyDistance:1048576,bodyEdgeLength:2097152,angle:4194304,pt2ptbim:8388608,LmPt2Pt:16777216,LmPt2Line:33554432,LmLine2Line:67108864,LmHole2Hole:134217728,LmAxis2Pt:268435456,LmAxis2Line:536870912,WallThickness:1073741824},function(e){this.viewer=e.viewer,this.OpMeasure=e,this.measureType="",this.measureClass="Base",this.InfoType=0,this.snappingTool=new An(this.viewer),this.snappedPoint=null,this.textLines=[],this.POINTSIZE=3,this.LINEWIDTH=2,this.ARCWIDTH=2,this.CYLINDERWIDTH=14,this.cylinderRadiusBottom=.4,this.cylinderHeight=1.2,this.edgeInfo={startPos:null,endPos:null,selLineInfo:null,selLineObj:null,preSelLineInfo:null,preSelLineObj:null,startToClndLine:null,endToClndLine:null,clndToClndLine:null,lineType:"",boxToClndLine:null,centerToClndLine:null,fstClnd:null,sndClnd:null,fstClndPos:null,sndClndPos:null,selLineCenterPos:null,dimString:"",unit:"",textBox:null,textPos:null},this.holeInfo={firstHoleInfo:null,secondHoleInfo:null,preSelHoleInfo:null,preSelHoleObj:null,firstSelHoleObj:null,secondSelHoleObj:null,fstToClndLine:null,sndToClndLine:null,clndToClndLine:null,boxToClndLine:null,centerToClndLine:null,centerToClndLine2:null,fstClnd:null,sndClnd:null,fstClndPos:null,sndClndPos:null,selLineCenterPos:null,textBox:null,textPos:null,dimString:"",unit:""},this.distanceInfo={firstSelObj:null,firstSelInfo:null,secondSelObj:null,secondSelInfo:null,axisLineObj:null,secaxisLineObj:null,projectPlaneObj:null,projectPlaneInfo:null,projectPlane:null,projectFstPos:null,projectSecPos:null,projectFstClnd:null,projectSecClnd:null,firstPoint:null,secondPoint:null,preSelInfo:null,preSelObj:null,preSelInfoOld:null,fstToSndLine:null,FstToFstPointLine:null,SndToSndPointLine:null,fstToClndLine:null,sndToClndLine:null,clndToClndLine:null,boxToClndLine:null,fstClnd:null,sndClnd:null,fstClndPos:null,sndClndPos:null,dimStringPrefix:"",dimString:"",unit:"",textBox:null,textPos:null,XorY:0,mousePos:null},this.faceInfo={fstIntersect:null,sndIntersect:null,firstFaceInfo:null,secondFaceInfo:null,preSelFaceInfo:null,preSelFaceObj:null,fstSelFaceObj:null,sndSelFaceObj:null,fstToClndLine:null,sndToClndLine:null,clndToClndLine:null,boxToClndLine:null,fstClnd:null,sndClnd:null,fstToMidLine:null,midToClndLine:null,arcMeshes:[],arcCenter:null,midLineEndPt:null,fstClndPos:null,sndClndPos:null,dimString:"",unit:"",textBox:null,textPos:null,selFaceObjs:[],selFaceInfors:[]},this.lineAngleInfo={firstLineObj:null,firstLineInfo:null,secondLineObj:null,secondLineInfo:null,preSelLineInfo:null,preSelLineObj:null,fstClnd:null,sndClnd:null,fstClndPos:null,sndClndPos:null,arcMeshes:[],arcCenter:null,auxLine1:null,auxLine2:null,dimString:"",unit:"",textBox:null,textPos:null,twoPlane:!1,firstHelpPointobj:null,firstHelpPointInfo:null,secHelpPointobj:null,secHelpPointInfo:null,thrHelpPointobj:null,thrHelpPointInfo:null},this.lineContoursInfo={preSelLineInfo:null,preSelLineObj:null,prestart:new THREE.Vector2,preend:new THREE.Vector2,unit:"",divPos:null,divBox:null,perimeter:0,Contours:[],start:new THREE.Vector2,end:new THREE.Vector2},this.perimeterInfos=[],this.preSelectBody=null,this.preSelectBodyMat=null,this.contourdiv=null,this.coordinatediv=null,this.coordinatedivtextPos=null,this.coordinatedivdims=null,this.lineargaugediv=null,this.shadowdiv=null,this.materialLine=new THREE.MeshBasicMaterial({color:8190976,opacity:.8,transparent:!0,depthTest:!1,depthWrite:!1,side:THREE.DoubleSide}),this.appmaterialLine=new THREE.MeshBasicMaterial({color:16743724,opacity:.8,transparent:!0,depthTest:!1,depthWrite:!1,side:THREE.DoubleSide}),this.materialPoint=_e.selectedVertexMaterial,this.materialProjectPoint=new THREE.MeshBasicMaterial({color:65535,opacity:.8,transparent:!0,depthTest:!1,depthWrite:!1}),this.axisLine=new THREE.LineBasicMaterial({opacity:1,color:16711680,side:THREE.DoubleSide,depthTest:!1,depthWrite:!1,transparent:!1}),this.materialBoxLine=new THREE.LineBasicMaterial({opacity:.8,color:8190976,side:THREE.DoubleSide,depthTest:!1,depthWrite:!1,transparent:!0}),this.materialPreSelectMeshopacity=new THREE.MeshBasicMaterial({color:65535,side:THREE.DoubleSide,depthTest:!0,depthWrite:!0,transparent:!1});var o=this;this.touchstart=function(e){if(this.parentElement){switch(o.OpMeasure.unsteady=!0,o.measureType){case"PointToLine":case"PointToFace":case"AxisToPoint":case"LineToLine":case"LineToFace":case"faceDist":case"AxisToLine":case"AxisToFace":case"holeDist":case"pt2pt":case"pt2ptbim":o.OpMeasure.unsteadyType="Distance";break;case"radius":o.OpMeasure.unsteadyType="Radius";break;case"measureEdges":o.OpMeasure.unsteadyType="measureEdges";break;case"LineAngle":case"LineFaceAngle":case"faceAngle":case"angle":o.OpMeasure.unsteadyType="Angle";break;case"bodyAngle":case"bodyEdgeLength":case"bodyDistance":o.OpMeasure.unsteadyType=o.measureType;break;case"LmPt2Pt":case"LmPt2Line":case"LmLine2Line":case"LmHole2Hole":case"LmAxis2Pt":case"LmAxis2Line":o.OpMeasure.unsteadyType="Lineargauge3D";break;case"WallThickness":o.OpMeasure.unsteadyType="WallThickness";break;default:o.OpMeasure.unsteadyType=o.OpMeasure.unsteadyData[this.getAttribute("group")].measureType}o.OpMeasure.unsteadyuuid=this.getAttribute("group"),o.OpMeasure.unsteadyTextBox=this,o.OpMeasure.unsteadyMoving=!1,o.OpMeasure.startPoint=e.touches?[e.touches[0].clientX,e.touches[0].clientY]:[e.clientX,e.clientY],e.preventDefault()}},this.touchend=function(e){o.OpMeasure.unsteady=!1,o.OpMeasure.unsteadyuuid=null,o.OpMeasure.unsteadyMoving=!1,o.OpMeasure.startPoint=null,o.OpMeasure.unsteadyType="",e.preventDefault()},this.touchmove=function(e){var t=e.touches?[e.touches[0].clientX,e.touches[0].clientY]:[e.clientX,e.clientY],n=o.OpMeasure.startPoint,i=1.1*window.devicePixelRatio;t&&n&&(Math.abs(t[0]-n[0])>i||Math.abs(t[1]-n[1])>i)?(o.OpMeasure.startPoint=t,o.OpMeasure.unsteadyTextBox=this,o.OpMeasure.unsteadyMoving=!0,n=document.createEvent("HTMLEvents"),Se.isMobileDevice()?(n.initEvent("touchmove",!0,!0),n.touches=e.touches,n.force=!0,1==e.touches.length&&(o.OpMeasure.state=ve.TOUCH.TOUCH_SINGLE)):(n.initEvent("mousemove",!0,!0),0===e.button&&(o.OpMeasure.state=ve.MOUSE.NONE),n.offsetX=e.offsetX,n.clientX=e.clientX,n.offsetY=e.offsetY,n.clientY=e.clientY),(o.viewer.canvas2D||o.viewer.canvas3D).dispatchEvent(n),e.preventDefault()):Se.isMobileDevice()||o.OpMeasure.InfoType!=ve.INFOTYPE.MOUSEENTER&&o.OpMeasure.InfoType!=ve.INFOTYPE.CROSSENTER&&o.OpMeasure.PostInfo(ve.INFOTYPE.MOUSEENTER)},this.mouseenter=function(){o.OpMeasure.InfoType!=ve.INFOTYPE.MOUSEENTER&&o.OpMeasure.InfoType!=ve.INFOTYPE.CROSSENTER&&o.OpMeasure.InfoType!=ve.INFOTYPE.MEASURENOTICEBEGIN&&(o.InfoType=o.OpMeasure.InfoType),o.OpMeasure.PostInfo(ve.INFOTYPE.MOUSEENTER),o.clearPreInfo()},this.mouseleave=function(e){o.OpMeasure.unsteady||o.OpMeasure.PostInfo(o.InfoType)},this.sectionCrossend=function(e){if(e&&e.preventDefault(),!o.OpMeasure.unsteadyMoving){o.OpMeasure.unsteadyuuid=this.parentElement.getAttribute("group");for(var e=o.OpMeasure.rootObject.getObjectByProperty("uuid",o.OpMeasure.unsteadyuuid),t=(delete o.OpMeasure.unsteadyData[o.OpMeasure.unsteadyuuid],o.OpMeasure.rootObject.remove(e),o.viewer.container.removeChild(this.parentElement),999),n=0;n<o.OpMeasure.boxInfos.length;++n){var i=o.OpMeasure.boxInfos[n],r=Number(i.textBox.getAttribute("lineInfo"));i.textBox.getAttribute("group")==o.OpMeasure.unsteadyuuid&&(o.OpMeasure.boxInfos.splice(n,1),t=r,n--),t<r&&i.textBox.setAttribute("lineInfo",r-1)}for(n=0;n<o.OpMeasure.textLines.length;++n)if((i=o.OpMeasure.textLines[n]).uuid==o.OpMeasure.unsteadyuuid){o.OpMeasure.textLines.splice(n,1);break}o.OpMeasure.unsteady=!1,o.OpMeasure.submeasureTimes(),o.OpMeasure.PostInfo(o.InfoType),o.OpMeasure.viewer.render()}},this.crossenter=function(e){e.preventDefault(),o.OpMeasure.InfoType!=ve.INFOTYPE.MOUSEENTER&&o.OpMeasure.InfoType!=ve.INFOTYPE.CROSSENTER&&o.OpMeasure.InfoType!=ve.INFOTYPE.MEASURENOTICEBEGIN&&(o.InfoType=o.OpMeasure.InfoType),o.OpMeasure.PostInfo(ve.INFOTYPE.CROSSENTER)},this.crossleave=function(e){e.preventDefault(),o.OpMeasure.PostInfo(o.InfoType)}});h.prototype.OperatorClear=function(e){},h.prototype.OperatorStart=function(e){this.measureType=e,this.snappedPoint=null,this.OpMeasure.PostInfo()},h.prototype.OperatorEnd=function(){this.OpMeasure.PostInfo(),this.clearDistanceInfo(),this.clearHoleInfo(),this.clearEdgeInfo(),this.clearPerimetrBox(),this.clearFaceInfo(),this.clearLineAngleInfo(),this.ClearmeasureBodyVolumeAndAreaPre(),this.measureBoundingBox(!1),this.clearCoordinate(),this.clearContoursInfo()},h.prototype.onNMouseMove=function(e,t){},h.prototype.onLMouseClick=function(e,t,n){},h.prototype.renderMeasureScene=function(){this.update2DScene()},h.prototype.Bline=function(e){var t=e.geometry,e=e.indexRange.concat();if(e[1]==e[0])return!0;if(this.viewer.ndsModel&&(e[0]+=t.drawRange.start/2,e[1]+=t.drawRange.start/2),t.isBufferGeometry){var n=t.index,t=t.attributes.position.array;if(null!=n){var n=n.array,i=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Vector3,a=e[0],e=e[1],s=Math.round(.5*(a+e));if(i.fromArray(t,3*n[2*a]),r.fromArray(t,3*n[2*e+1]),r.distanceTo(i)<1e-7)return!1;o.fromArray(t,3*n[2*s]);a=i.clone().sub(o).normalize();return o.clone().sub(r).normalize().distanceTo(a)<2*Math.sin(2*Math.PI/180)}}},h.prototype.FindParentElement=function(e){if(null==e)return null;if(e instanceof THREE.Object3D||e instanceof Ae){var t=e.type.toLowerCase();if(this.viewer.isObjectTypeOfElement(e)){if("object"==t)for(var n=e.parent;null!=n;)"instanceobject"==n.type.toLowerCase()&&(e=n),n=n.parent;return e}}return this.FindParentElement(e.parent)},h.prototype.getFilterDistByBody=function(e){var t,n;return e?(e.boxDiagonalLength||(t=new THREE.Vector3,n=new THREE.Vector3,this.viewer.computeBoundingBox(e,t,n,{flag:!0}),e.boxDiagonalLength=n.distanceTo(t)),.015*e.boxDiagonalLength):.5},h.prototype.getSnappingPntEx=function(e){if(e){var t;if(this.viewer.hasBrepInfo()){var n=this.viewer.ndsModel?e.object:this.FindParentElement(e.object);if(!n)return;var i=n.uuid,r=this.viewer.brepManager.GetEdgesExtremePointsByBodyUUID(i);if(!r||r.length<=0)return;for(var o,i=this.getFilterDistByBody(n),a=i*i,s=e.point.clone(),n=this.viewer.modelCoordToClientCoord([s.x,s.y,s.z]),l=new THREE.Vector3(n[0],n[1],0),d=new THREE.Vector3,c=64,h=0;h<r.length;h++)s.distanceToSquared(r[h])<a&&(o=this.viewer.modelCoordToClientCoord([r[h].x,r[h].y,r[h].z]),d.set(o[0],o[1],0),(o=l.distanceToSquared(d))<c)&&(t=r[h],c=o)}else _e.inBIMContext||(this.snappingTool.doSnapping(e),this.snappingTool.isSnapped()&&this.snappingTool.getSnappedType()==vn&&(t=this.snappingTool.getSnappedVertex()));return t}},h.prototype.doRaycasterPick=function(e,t,n){var i=this.viewer,r=i.renderer.domElement,o=i.renderer.getPixelRatio(),e=e*o/r.width*2-1,t=2*-(t*o/r.height)+1,o=new THREE.Raycaster;i.camera.setCastRay(o,e,t),n&&(o.linePrecision=this.getLinePrecision());return i.ndsModel?n?i.ndsModel.intersect(o.ray,o.linePrecision):i.ndsModel.intersect(o.ray):n?o.intersectObjects(i.selectionManager.getTargetIncludeLineList()):o.intersectObjects(i.selectionManager.getTargetList())},h.prototype.getSelectInfoFromIntersect=function(e){if(e&&this.viewer.hasBrepInfo()){var t,n,i,r,o=this.viewer.ndsModel?e.object:this.FindParentElement(e.object);if(o)return o=o.uuid,n=e.object.uuid,this.viewer.ndsModel&&(0<=e.meshId?(e.mesh=this.viewer.ndsModel.meshManager.getSingleMesh(e.meshId),e.mesh&&(i=e.faceIndex-e.mesh.geometry.drawRange.start/3,t="face")):0<=e.lineSegId&&(e.mesh=this.viewer.ndsModel.meshManager.getLineSegments(e.lineSegId),e.mesh)&&(i=.5*(e.index-e.mesh.geometry.drawRange.start),t="edge"),n=e.geomUuid),0<=i&&(r=this.viewer.brepManager.GetBrepInfoByUUidAndTopolIndex(o,n,i,t))&&(r.parentObj=e.mesh,r.geometry=e.mesh.geometry,r.matrixWorld=e.mesh.matrixWorld.clone(),r.intersect=e.point.clone(),r.bodyId=e.bodyId,r.bodyUuid=e.bodyUuid,r.meshId=e.meshId,r.topolIndex=i,r.topolType=t,r.lineSegId=e.lineSegId,"face"==t&&(r.edgeInfos=this.viewer.brepManager.GetEdgeInfoFromFace(o,r.edgeIDS)),r.normal&&null==r.worldNormal&&(n=new THREE.Vector3,i=new THREE.Quaternion,e=new THREE.Vector3,r.parentObj.matrixWorld.decompose(n,i,e),r.worldNormal=new THREE.Vector3(r.normal[0],r.normal[1],r.normal[2]),r.worldNormal.applyQuaternion(i)),r.origin)&&null==r.worldOrigin&&(r.worldOrigin=new THREE.Vector3(r.origin[0],r.origin[1],r.origin[2]),r.worldOrigin.applyMatrix4(r.matrixWorld)),r}},h.prototype.previewSnappedPoint=function(e,t,n){var i=!1,e=(null!=this.snappedPoint&&(i=!0),this.snappedPoint=null,this.doRaycasterPick(e,t,!0));e&&0<e.length&&((t=this.getSnappingPntEx(e[0]))?(this.snappedPoint=t,i=!0):e[0].isPointsGeom&&(this.snappedPoint=e[0].point,i=!0)),!this.snappedPoint&&e&&0<e.length&&(t=this.getSelectInfoFromIntersect(e[0]))&&"circle"==t.type&&n&&((e=new THREE.Vector3(t.center[0],t.center[1],t.center[2])).applyMatrix4(t.matrixWorld),this.snappedPoint=e,i=!0),i&&this.update2DScene()},h.prototype.previewSnappedPoint2=function(e,t){var n,i=!1;null!=this.snappedPoint&&(i=!0),this.snappedPoint=null,e&&0<e.length&&((n=this.getSnappingPntEx(e[0]))?(this.snappedPoint=n,i=!0):e[0].isPointsGeom&&(this.snappedPoint=e[0].point,i=!0)),!this.snappedPoint&&e&&0<e.length&&(n=this.getSelectInfoFromIntersect(e[0]))&&"circle"==n.type&&t&&((e=new THREE.Vector3(n.center[0],n.center[1],n.center[2])).applyMatrix4(n.matrixWorld),this.snappedPoint=e,i=!0),i&&this.update2DScene()},h.prototype.get2dPoint=function(e){e.project(this.viewer.camera);var t=this.viewer.renderer.domElement.width/2,n=this.viewer.renderer.domElement.height/2;return{x:Math.round(e.x*t+t),y:Math.round(-e.y*n+n)}},h.prototype.addAnnotationTip=function(e,t,n){var i,r,o=this.viewer.renderer.getPixelRatio();t/=o,n/=o;var o=this.viewer.renderer.domElement.width*this.viewer.renderer.domElement.height/(o*o)/445440,o=1<=o?(i=13,r=35,14):((r=Math.round(35*o))<22&&(o=(r=22)/35),i=Math.round(13*o),Math.round(.35*r)),a=document.createElement("div");return a.className="perimeterLogo",a.style.width=2*i+"px",a.style.height=r+"px",a.style.top=n-r+"px",a.style.left=t-i+"px",a.style.fontSize=o+"px",a.style.paddingTop=Math.round(.3*(r-o))+"px",a.style.opacity=1,a.innerHTML=e.toString(),a.innerText=e.toString(),a},h.prototype.getAndShowTextBox=function(e,t,n){var i,r,o;n&&(e=this.get2dPoint(e),null!=n.screenX&&Math.abs(n.screenX-e.x)<=2&&null!=n.screenY&&Math.abs(n.screenY-e.y)<=2||(i=this.viewer.renderer.getPixelRatio(),r=n.clientWidth,o=n.clientHeight,n.screenX=e.x,n.screenY=e.y,"up"==n.getAttribute("mobile")?(n.style.left=Math.round(e.x/i-r/2)+"px",n.style.top=Math.round(e.y/i-o)+"px",null!=t&&(n.childNodes[0].data=t)):"right"==n.getAttribute("mobile")?(n.style.left=Math.round(e.x/i-r)+"px",n.style.top=Math.round(e.y/i-o/2)+"px",null!=t&&(n.childNodes[0].data=t)):"down"==n.getAttribute("mobile")?(n.style.left=Math.round(e.x/i-r/2)+"px",n.style.top=Math.round(e.y/i+0)+"px",null!=t&&(n.childNodes[0].data=t)):"left"==n.getAttribute("mobile")?(n.style.left=Math.round(e.x/i+0)+"px",n.style.top=Math.round(e.y/i-o/2)+"px",null!=t&&(n.childNodes[0].data=t)):(n.style.left=Math.round(e.x/i)+"px",n.style.top=Math.round(e.y/i)+"px",null!=t&&(n.innerHTML=t)),"true"==n.getAttribute("needDown")&&(n.style.top=Math.round(e.y/i)+20+"px")))},h.prototype.update2DScene=function(){var e,t,n,i,r=this.viewer.renderer.getPixelRatio(),o=this.viewer.canvas2D.getContext("2d");if(o.clearRect(0,0,window.innerWidth*r,window.innerHeight*r),4==this.viewer.Rectangle.length&&(e=this.viewer.Rectangle[0],i=this.viewer.Rectangle[1],t=this.viewer.Rectangle[2],n=this.viewer.Rectangle[3],o.strokeStyle="#00FFFF",o.setLineDash([5,5]),o.beginPath(),o.moveTo(e,t),o.lineTo(i,t),o.lineTo(i,n),o.lineTo(e,n),o.lineTo(e,t),o.closePath(),o.stroke(),o.setLineDash([])),this.viewer.renderWaterMark(),this.snappedPoint&&(i=this.get2dPoint(this.snappedPoint.clone()),o.fillStyle="#00FFFF",o.beginPath(),o.arc(i.x,i.y,4,0,2*Math.PI),o.closePath(),o.fill()),"radius"!=this.measureType&&"diameter"!=this.measureType||!this.OpMeasure.rootObject.visible||this.holeInfo.textPos&&this.holeInfo.fstClndPos&&(s=this.get2dPoint(this.holeInfo.textPos.clone()),l=this.get2dPoint(this.holeInfo.fstClndPos.clone()),o.strokeStyle="#00FF00",o.lineWidth=r,o.beginPath(),o.moveTo(s.x,s.y),o.lineTo(l.x,l.y),o.stroke()),0<this.OpMeasure.textLines.length&&this.OpMeasure.rootObject.visible){this.viewer.is2DModel?o.strokeStyle="#00FF00":o.strokeStyle="#FF7D2C",o.lineWidth=r,o.beginPath();for(var a=0;a<this.OpMeasure.textLines.length;a++){var s=this.get2dPoint(this.OpMeasure.textLines[a].start.clone()),l=this.get2dPoint(this.OpMeasure.textLines[a].end.clone());o.moveTo(s.x,s.y),o.lineTo(l.x,l.y)}o.stroke()}},h.prototype.clearPreSelect=function(){this.holeInfo.preSelHoleObj&&this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.distanceInfo.preSelObj&&this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.lineContoursInfo.preSelLineObj&&this.OpMeasure.rootObject.remove(this.lineContoursInfo.preSelLineObj),this.edgeInfo.preSelLineObj&&this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.faceInfo.preSelFaceObj&&this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.ClearmeasureBodyVolumeAndAreaPre(),this.snappedPoint=null,this.clearCoordinate()},h.prototype.clearHoleInfo=function(e){this.holeInfo.preSelHoleObj&&this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),1!=e&&(this.holeInfo.firstSelHoleObj&&this.OpMeasure.rootObject.remove(this.holeInfo.firstSelHoleObj),this.holeInfo.secondSelHoleObj&&this.OpMeasure.rootObject.remove(this.holeInfo.secondSelHoleObj),this.holeInfo.textBox&&this.viewer.container.removeChild(this.holeInfo.textBox),this.holeInfo.fstToClndLine&&this.OpMeasure.rootObject.remove(this.holeInfo.fstToClndLine),this.holeInfo.sndToClndLine&&this.OpMeasure.rootObject.remove(this.holeInfo.sndToClndLine),this.holeInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.holeInfo.clndToClndLine),this.holeInfo.centerToClndLine2&&this.OpMeasure.rootObject.remove(this.holeInfo.centerToClndLine2),this.holeInfo.centerToClndLine&&this.OpMeasure.rootObject.remove(this.holeInfo.centerToClndLine),this.holeInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.holeInfo.boxToClndLine),this.holeInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.holeInfo.fstClnd),this.holeInfo.sndClnd)&&this.OpMeasure.rootObject.remove(this.holeInfo.sndClnd),this.holeInfo.preSelHoleObj=null,this.holeInfo.preSelHoleInfo=null,this.holeInfo.firstSelHoleObj=null,this.holeInfo.firstHoleInfo=null,this.holeInfo.secondSelHoleObj=null,this.holeInfo.secondHoleInfo=null,this.holeInfo.fstToClndLine=null,this.holeInfo.sndToClndLine=null,this.holeInfo.clndToClndLine=null,this.holeInfo.boxToClndLine=null,this.holeInfo.centerToClndLine=null,this.holeInfo.centerToClndLine2=null,this.holeInfo.selLineCenterPos=null,this.holeInfo.fstClnd=null,this.holeInfo.sndClnd=null,this.holeInfo.fstClndPos=null,this.holeInfo.sndClndPos=null,this.holeInfo.textBox=null,this.holeInfo.textPos=null,this.holeInfo.dimString="",this.holeInfo.unit=""},h.prototype.clearPreInfo=function(){this.distanceInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelLineObj),this.distanceInfo.preSelLineObj=null,this.distanceInfo.preSelLineInfo=null),this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null),this.holeInfo.preSelHoleObj&&(this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.holeInfo.preSelLineObj=null,this.holeInfo.preSelLineInfo=null),this.edgeInfo.preSelHoleObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelHoleObj),this.edgeInfo.preSelLineObj=null,this.edgeInfo.preSelLineInfo=null),this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null,this.faceInfo.preSelFaceInfo=null),this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null),this.ClearmeasureBodyVolumeAndAreaPre(),this.lineContoursInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineContoursInfo.preSelLineObj),this.lineContoursInfo.preSelLineObj=null,this.lineContoursInfo.preSelLineInfo=null)},h.prototype.clearDistanceInfo=function(e){this.distanceInfo.preSelLineObj&&this.OpMeasure.rootObject.remove(this.distanceInfo.preSelLineObj),this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelInfo=null),1!=e&&(this.distanceInfo.firstSelObj&&this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.distanceInfo.secondSelObj&&this.OpMeasure.rootObject.remove(this.distanceInfo.secondSelObj),this.distanceInfo.axisLineObj&&this.OpMeasure.rootObject.remove(this.distanceInfo.axisLineObj),this.distanceInfo.secaxisLineObj&&this.OpMeasure.rootObject.remove(this.distanceInfo.secaxisLineObj),this.distanceInfo.fstToSndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstToSndLine),this.distanceInfo.FstToFstPointLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.FstToFstPointLine),this.distanceInfo.SndToSndPointLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.SndToSndPointLine),this.distanceInfo.textBox&&this.viewer.container.removeChild(this.distanceInfo.textBox),this.distanceInfo.fstToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstToClndLine),this.distanceInfo.sndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndToClndLine),this.distanceInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.clndToClndLine),this.distanceInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.boxToClndLine),this.distanceInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstClnd),this.distanceInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndClnd),this.distanceInfo.projectPlaneObj&&this.OpMeasure.rootObject.remove(this.distanceInfo.projectPlaneObj),this.distanceInfo.projectFstClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.projectFstClnd),this.distanceInfo.projectSecClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.projectSecClnd),this.distanceInfo.projectPlaneInfo=null,this.distanceInfo.projectPlane=null),this.distanceInfo.preSelLineObj=null,this.distanceInfo.preSelLineInfo=null,this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null,this.distanceInfo.secondSelObj=null,this.distanceInfo.axisLineObj=null,this.distanceInfo.secaxisLineObj=null,this.distanceInfo.secondSelInfo=null,this.distanceInfo.firstPoint=null,this.distanceInfo.secondPoint=null,this.distanceInfo.fstToSndLine=null,this.distanceInfo.FstToFstPointLine=null,this.distanceInfo.SndToSndPointLine=null,this.distanceInfo.fstToClndLine=null,this.distanceInfo.sndToClndLine=null,this.distanceInfo.clndToClndLine=null,this.distanceInfo.boxToClndLine=null,this.distanceInfo.fstClnd=null,this.distanceInfo.sndClnd=null,this.distanceInfo.fstClndPos=null,this.distanceInfo.sndClndPos=null,this.distanceInfo.dimStringPrefix="",this.distanceInfo.dimString="",this.distanceInfo.unit="",this.distanceInfo.textBox=null,this.distanceInfo.textPos=null,this.distanceInfo.mousePos=null,this.distanceInfo.XorY=0,this.distanceInfo.projectPlaneObj=null,this.distanceInfo.projectPlaneInfo=null,this.distanceInfo.projectPlane=null,this.distanceInfo.projectFstPos=null,this.distanceInfo.projectSecPos=null,this.distanceInfo.projectFstClnd=null,this.distanceInfo.projectSecClnd=null,this.lineargaugediv&&"none"!=this.lineargaugediv.style.display&&(this.lineargaugediv.style.display="none"),this.shadowdiv&&"none"!=this.shadowdiv.style.display&&(this.shadowdiv.style.display="none")},h.prototype.clearContoursInfo=function(e){if(this.lineContoursInfo.preSelLineObj&&this.OpMeasure.rootObject.remove(this.lineContoursInfo.preSelLineObj),1!=e)for(var t=0;t<this.lineContoursInfo.Contours.length;++t){var n=this.lineContoursInfo.Contours[t];this.OpMeasure.rootObject.remove(n.lineobj)}this.lineContoursInfo.Contours=[],this.lineContoursInfo.preSelLineInfo=null,this.lineContoursInfo.preSelLineObj=null,this.lineContoursInfo.prestart=new THREE.Vector2,this.lineContoursInfo.preend=new THREE.Vector2,this.lineContoursInfo.unit="",this.lineContoursInfo.divPos=null,this.lineContoursInfo.divBox=null,this.lineContoursInfo.perimeter=0,this.lineContoursInfo.start=new THREE.Vector2,this.lineContoursInfo.end=new THREE.Vector2,this.contourdiv&&1!=e&&(this.viewer.container.removeChild(this.contourdiv),this.contourdiv=null)},h.prototype.clearEdgeInfo=function(e){1!=e&&(this.edgeInfo.selLineObj&&this.OpMeasure.rootObject.remove(this.edgeInfo.selLineObj),this.edgeInfo.preSelLineObj&&this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.startToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.startToClndLine),this.edgeInfo.endToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.endToClndLine),this.edgeInfo.textBox&&this.OpMeasure.viewer.container.removeChild(this.edgeInfo.textBox),this.edgeInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.clndToClndLine),this.edgeInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.boxToClndLine),this.edgeInfo.centerToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.centerToClndLine),this.edgeInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.boxToClndLine),this.edgeInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.edgeInfo.fstClnd),this.edgeInfo.sndClnd)&&this.OpMeasure.rootObject.remove(this.edgeInfo.sndClnd),this.edgeInfo.startPos=null,this.edgeInfo.endPos=null,this.edgeInfo.selLineInfo=null,this.edgeInfo.selLineObj=null,this.edgeInfo.preSelLineInfo=null,this.edgeInfo.preSelLineObj=null,this.edgeInfo.startToClndLine=null,this.edgeInfo.endToClndLine=null,this.edgeInfo.clndToClndLine=null,this.edgeInfo.lineType="",this.edgeInfo.clndToClndLine=null,this.edgeInfo.boxToClndLine=null,this.edgeInfo.centerToClndLine=null,this.edgeInfo.fstClnd=null,this.edgeInfo.sndClnd=null,this.edgeInfo.fstClndPos=null,this.edgeInfo.sndClndPos=null,this.edgeInfo.selLineCenterPos=null,this.edgeInfo.dimString="",this.edgeInfo.unit="",this.edgeInfo.textBox=null,this.edgeInfo.textPos=null},h.prototype.clearPerimetrBox=function(){for(var e=0,t=this.perimeterInfos.length;e<t;e++){var n=this.perimeterInfos[e];this.viewer.container.removeChild(n.textimg),n.textPos=null,n.textimg=null}this.perimeterInfos.splice(0,this.perimeterInfos.length)},h.prototype.measureBoundingBox=function(e){for(var t,n,i,r,o,a,s,l,d,c=0,h=this.OpMeasure.boundingboxInfos.length;c<h;c++){var u=this.OpMeasure.boundingboxInfos[c];this.viewer.container.removeChild(u.textBox),u.textPos=null,u.textBox=null}this.OpMeasure.boundingboxInfos.splice(0,this.OpMeasure.boundingboxInfos.length),e?(e=this.viewer.modelRootObject.boundingBox.clone(),this.OpMeasure.boundingboxmesh&&(this.OpMeasure.rootObject.remove(this.OpMeasure.boundingboxmesh),this.OpMeasure.boundingboxmesh=null),_e.inBIMContext&&0<this.viewer.ndsModel.ModelUpMatrix4.length&&((l=new THREE.Matrix4).fromArray(this.viewer.ndsModel.ModelUpMatrix4),e.applyMatrix4(l)),this.OpMeasure.boundingboxmesh=this.createBoundingBox(e),this.distanceInfo.unit=this.getUnitString(),this.OpMeasure.rootObject.add(this.OpMeasure.boundingboxmesh),l=e.max.x-e.min.x,t=e.max.y-e.min.y,n=e.max.z-e.min.z,l*=(i=this.viewer.getDispalyModelUnit(l)).scale,t*=i.scale,n*=i.scale,i=this.getUnitStringmap(i.unit),l=l.toFixed(2)+i,t=t.toFixed(2)+i,n=n.toFixed(2)+i,(i=document.createElement("div")).style.position="absolute",i.style.color="white",i.style.zIndex=3,i.style.backgroundColor="rgba(115,0,230,0.75)",i.style.userSelect="none",i.style.pointerEvents="none",this.viewer.container.appendChild(i),(r=document.createElement("div")).style.position="absolute",r.style.color="white",r.style.zIndex=3,r.style.backgroundColor="rgba(115,0,230,0.75)",r.style.userSelect="none",r.style.pointerEvents="none",this.viewer.container.appendChild(r),(o=document.createElement("div")).style.position="absolute",o.style.color="white",o.style.zIndex=3,o.style.backgroundColor="rgba(115,0,230,0.75)",o.style.userSelect="none",o.style.pointerEvents="none",this.viewer.container.appendChild(o),d=e.max.clone().sub(new THREE.Vector3((e.max.x-e.min.x)/2,0,0)),a=e.max.clone().sub(new THREE.Vector3(0,(e.max.y-e.min.y)/2,0)),e=e.max.clone().sub(new THREE.Vector3(0,0,(e.max.z-e.min.z)/2)),this.getAndShowTextBox(d.clone(),l,i),this.getAndShowTextBox(a.clone(),t,r),this.getAndShowTextBox(e.clone(),n,o),(s={}).dimString=l,s.textPos=d.clone(),s.textBox=i,this.OpMeasure.boundingboxInfos.push(s),(l={}).dimString=t,l.textPos=a.clone(),l.textBox=r,this.OpMeasure.boundingboxInfos.push(l),(d={}).dimString=n,d.textPos=e.clone(),d.textBox=o,this.OpMeasure.boundingboxInfos.push(d)):this.OpMeasure.boundingboxmesh&&(this.OpMeasure.rootObject.remove(this.OpMeasure.boundingboxmesh),this.OpMeasure.boundingboxmesh=null)},h.prototype.clearFaceInfo=function(e){if(this.faceInfo.preSelFaceObj&&this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.fstSelFaceObj&&this.OpMeasure.rootObject.remove(this.faceInfo.fstSelFaceObj),this.faceInfo.sndSelFaceObj&&this.OpMeasure.rootObject.remove(this.faceInfo.sndSelFaceObj),1!=e){this.faceInfo.textBox&&this.viewer.container.removeChild(this.faceInfo.textBox),this.faceInfo.fstToMidLine&&this.OpMeasure.rootObject.remove(this.faceInfo.fstToMidLine),this.faceInfo.fstToClndLine&&this.OpMeasure.rootObject.remove(this.faceInfo.fstToClndLine),this.faceInfo.sndToClndLine&&this.OpMeasure.rootObject.remove(this.faceInfo.sndToClndLine),this.faceInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.faceInfo.clndToClndLine),this.faceInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.faceInfo.boxToClndLine),this.faceInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.faceInfo.fstClnd),this.faceInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.faceInfo.sndClnd);for(var t=0;t<this.faceInfo.arcMeshes.length;t++)this.OpMeasure.rootObject.remove(this.faceInfo.arcMeshes[t])}this.faceInfo.arcMeshes=[],this.faceInfo.fstIntersect=null,this.faceInfo.sndIntersect=null,this.faceInfo.firstFaceInfo=null,this.faceInfo.secondFaceInfo=null,this.faceInfo.preSelFaceInfo=null,this.faceInfo.preSelFaceObj=null,this.faceInfo.fstSelFaceObj=null,this.faceInfo.sndSelFaceObj=null,this.faceInfo.fstToMidLine=null,this.faceInfo.fstToClndLine=null,this.faceInfo.sndToClndLine=null,this.faceInfo.clndToClndLine=null,this.faceInfo.boxToClndLine=null,this.faceInfo.fstClnd=null,this.faceInfo.sndClnd=null,this.faceInfo.fstClndPos=null,this.faceInfo.sndClndPos=null,this.faceInfo.dimString="",this.faceInfo.unit="",this.faceInfo.textBox=null,this.faceInfo.textPos=null,this.faceInfo.arcCenter=null,this.faceInfo.midLineEndPt=null;for(var n=this.faceInfo.selFaceInfors.length=0,i=this.faceInfo.selFaceObjs.length;n<i;n++)this.OpMeasure.rootObject.remove(this.faceInfo.selFaceObjs[n]);this.faceInfo.selFaceObjs.length=0},h.prototype.clearLineAngleInfo=function(e){if(this.lineAngleInfo.preSelLineObj&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),1!=e){this.lineAngleInfo.firstLineObj&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.firstLineObj),this.lineAngleInfo.secondLineObj&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.secondLineObj),this.lineAngleInfo.textBox&&this.viewer.container.removeChild(this.lineAngleInfo.textBox),this.lineAngleInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.fstClnd),this.lineAngleInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.sndClnd),this.lineAngleInfo.auxLine1&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.auxLine1),this.lineAngleInfo.auxLine2&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.auxLine2);for(var t=0;t<this.lineAngleInfo.arcMeshes.length;t++)this.OpMeasure.rootObject.remove(this.lineAngleInfo.arcMeshes[t]);this.lineAngleInfo.firstHelpPointobj&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.firstHelpPointobj),this.lineAngleInfo.secHelpPointobj&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.secHelpPointobj),this.lineAngleInfo.thrHelpPointobj&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.thrHelpPointobj)}this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.firstLineObj=null,this.lineAngleInfo.firstLineInfo=null,this.lineAngleInfo.secondLineObj=null,this.lineAngleInfo.secondLineInfo=null,this.lineAngleInfo.firstHelpPointobj=null,this.lineAngleInfo.firstHelpPointInfo=null,this.lineAngleInfo.thrHelpPointobj=null,this.lineAngleInfo.thrHelpPointInfo=null,this.lineAngleInfo.secHelpPointInfo=null,this.lineAngleInfo.secHelpPointobj=null,this.lineAngleInfo.fstClnd=null,this.lineAngleInfo.sndClnd=null,this.lineAngleInfo.fstClndPos=null,this.lineAngleInfo.sndClndPos=null,this.lineAngleInfo.auxLine1=null,this.lineAngleInfo.auxLine2=null,this.lineAngleInfo.arcCenter=null;for(t=0;t<this.lineAngleInfo.arcMeshes.length;t++)this.lineAngleInfo.arcMeshes[t]=null;this.lineAngleInfo.arcMeshes.length=0,this.lineAngleInfo.dimString="",this.lineAngleInfo.unit="",this.lineAngleInfo.textBox=null,this.lineAngleInfo.textPos=null,this.lineAngleInfo.twoPlane=!1},h.prototype.clearCoordinate=function(){this.coordinatediv&&(this.viewer.container.removeChild(this.coordinatediv),this.coordinatediv=null,this.coordinatedivtextPos=null,this.coordinatedivdims=null)},h.prototype.getSelectedFaceArea=function(){for(var e=0,t=0,n=this.faceInfo.selFaceInfors.length;t<n;t++)e+=parseFloat(this.faceInfo.selFaceInfors[t].area);return e},h.prototype.getLineStartEndPoints=function(e){if(("cylinder"==e.type||"cone"==e.type)&&e.origin&&e.axis){var t=e.geometry,n=e.indexRange.concat();if(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/3,n[1]+=t.drawRange.start/3),t.isBufferGeometry){var i=t.index,r=t.attributes.position,o=new THREE.Vector3,a=new THREE.Vector3,s=(o.fromArray(e.origin),a.fromArray(e.axis),new THREE.Quaternion),l=new THREE.Vector3,d=new THREE.Vector3,c=(e.matrixWorld.decompose(l,s,d),a.applyQuaternion(s),a.normalize(),-1/0),h=1/0;o.applyMatrix4(e.matrixWorld);for(var u=n[0],p=n[1];u<=p;u++){var f=3*u,m=i.getX(f),g=i.getX(1+f),f=i.getX(2+f),v=new THREE.Vector3,A=new THREE.Vector3,y=new THREE.Vector3,m=(v.fromBufferAttribute(r,m),A.fromBufferAttribute(r,g),y.fromBufferAttribute(r,f),v.applyMatrix4(e.matrixWorld),A.applyMatrix4(e.matrixWorld),y.applyMatrix4(e.matrixWorld),v.clone().sub(o).dot(a));c<m&&(c=m),m<h&&(h=m),(m=A.clone().sub(o).dot(a))<h&&(h=m),(c=c<m?m:c)<(m=y.clone().sub(o).dot(a))&&(c=m),m<h&&(h=m),y=A=v=null}return 0==Math.abs(c-h)?null:(w=o.clone().add(a.clone().multiplyScalar(c)),{start:o.clone().add(a.clone().multiplyScalar(h)),end:w})}}if("circle"==e.type&&e.center){t=e.geometry,n=e.indexRange.concat();if(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/2,n[1]+=t.drawRange.start/2),t.isBufferGeometry){var i=t.index,E=t.attributes.position.array;if(null!=i)return M=i.array,o=new THREE.Vector3,w=new THREE.Vector3,o.fromArray(E,3*M[2*n[0]]),w.fromArray(E,3*M[2*n[0]+1]),this.viewer.is2DModel&&o.z==w.z&&(e.center[2]=o.z),v=(l=new THREE.Vector3(e.center[0],e.center[1],e.center[2])).clone().sub(o).normalize(),A=w.clone().sub(o).normalize(),o.applyMatrix4(e.matrixWorld),w.applyMatrix4(e.matrixWorld),l.applyMatrix4(e.matrixWorld),o.sub(l),w.sub(l),(a=o.clone().cross(w)).normalize(),o.set(e.center[0],e.center[1],e.center[2]),o.applyMatrix4(e.matrixWorld),w=o.clone().add(a),{start:o,end:w}}}t=e.geometry,n=e.indexRange.concat();if(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/2,n[1]+=t.drawRange.start/2),t.isBufferGeometry){var M,w,i=t.index,E=t.attributes.position.array;if(null!=i)return M=i.array,o=new THREE.Vector3,w=new THREE.Vector3,o.fromArray(E,3*M[2*n[0]]),w.fromArray(E,3*M[2*n[1]+1]),o.applyMatrix4(e.matrixWorld),w.applyMatrix4(e.matrixWorld),{start:o,end:w}}return null},h.prototype.ClearmeasureBodyVolumeAndAreaPre=function(){this.preSelectBody&&(this.preSelectBodyMat?this.preSelectBody.setUserMaterial(this.preSelectBodyMat):this.preSelectBody.setUserMaterial(null)),this.preSelectBody=null,this.preSelectBodyMat=null},h.prototype.createFace=function(e,t){if(e&&e.parentObj instanceof THREE.Mesh){var n,i=e.geometry,r=e.indexRange.concat();if(this.viewer.ndsModel&&(r[0]+=i.drawRange.start/3,r[1]+=i.drawRange.start/3),i.isBufferGeometry){for(var o=i.index,a=i.attributes.position,i=r[1]-r[0]+1,s=new Float32Array(9*i),l=0,d=new THREE.Vector3,c=r[0],h=r[1];c<=h;c++,l+=1){var u=3*c,p=o.getX(u),f=o.getX(1+u),u=o.getX(2+u),m=new THREE.Vector3,g=new THREE.Vector3,v=new THREE.Vector3,p=(m.fromBufferAttribute(a,p),g.fromBufferAttribute(a,f),v.fromBufferAttribute(a,u),(new THREE.Vector3).subVectors(g,m)),f=(new THREE.Vector3).subVectors(v,m);p.cross(f).normalize(),d.add(p),s[9*l]=m.x,s[9*l+1]=m.y,s[9*l+2]=m.z,s[9*l+3]=g.x,s[9*l+4]=g.y,s[9*l+5]=g.z,s[9*l+6]=v.x,s[9*l+7]=v.y,s[9*l+8]=v.z,v=g=m=null}i=new THREE.BufferGeometry,r=(i.addAttribute("position",new THREE.BufferAttribute(s,3)),(n=new THREE.Mesh(i,0==t?_e.selectedFaceMaterial:_e.preSelectedFaceMaterial)).objectType="Face",n.FaceInfo=[],this.viewer.ndsModel.geomManager.uuidToIdMap[e.geometry.uuid][0]),i=(n.FaceInfo.push(this.viewer.ndsModel.bodyUuid2NodeMap[e.bodyUuid].id),n.FaceInfo.push(r),n.FaceInfo.push(e.topolIndex),n.FaceInfo.push(e.meshId),t?1:0);n.FaceInfo.push(i),n.applyMatrix(e.matrixWorld),n.matrixWorldNeedsUpdate=!0,d.normalize(),e.averagenormal=d}return n}},h.prototype.createAxisLine=function(e){if(e&&e.parentObj instanceof THREE.Mesh){var t=e.geometry,n=e.indexRange.concat();if(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/3,n[1]+=t.drawRange.start/3),t.isBufferGeometry){var i=t.index,r=t.attributes.position,o=new THREE.Vector3,a=new THREE.Vector3,t=(o.fromArray(e.origin),a.fromArray(e.axis),new THREE.Quaternion),s=new THREE.Vector3,l=new THREE.Vector3,d=(e.matrixWorld.decompose(s,t,l),a.applyQuaternion(t),a.normalize(),-1/0),c=1/0;o.applyMatrix4(e.matrixWorld);for(var h=n[0],u=n[1];h<=u;h++){var p=3*h,f=i.getX(p),m=i.getX(1+p),p=i.getX(2+p),g=new THREE.Vector3,v=new THREE.Vector3,A=new THREE.Vector3,f=(g.fromBufferAttribute(r,f),v.fromBufferAttribute(r,m),A.fromBufferAttribute(r,p),g.applyMatrix4(e.matrixWorld),v.applyMatrix4(e.matrixWorld),A.applyMatrix4(e.matrixWorld),g.clone().sub(o).dot(a));d<f&&(d=f),f<c&&(c=f),(f=v.clone().sub(o).dot(a))<c&&(c=f),(d=d<f?f:d)<(f=A.clone().sub(o).dot(a))&&(d=f),f<c&&(c=f),A=v=g=null}var y=Math.abs(d-c);if(0==y)return null;for(var E=o.clone().add(a.clone().multiplyScalar(d)),M=o.clone().add(a.clone().multiplyScalar(c)),w=(a.subVectors(E,M).normalize(),Math.ceil(Math.abs(y/6))),b=new Float32Array(6*w),x=0;x<w;++x){var I=new THREE.Vector3,T=new THREE.Vector3,I=M.clone().add(a.clone().multiplyScalar(6*x));6*x+4<Math.abs(y)?T=I.clone().add(a.clone().multiplyScalar(4)):T.set(E.x,E.y,E.z),b[6*x]=I.x,b[6*x+1]=I.y,b[6*x+2]=I.z,b[6*x+3]=T.x,b[6*x+4]=T.y,b[6*x+5]=T.z}s=new THREE.BufferGeometry;s.addAttribute("position",new THREE.BufferAttribute(b,3)),(l=new THREE.LineSegments(s,this.axisLine)).objectType="AxisLine",l.Start=M,l.End=E,l.matrixWorldNeedsUpdate=!0}return l}},h.prototype.createLine=function(e,t,n){if(e&&e.parentObj instanceof THREE.Line){var i,r=e.geometry,o=e.indexRange.concat();if(this.viewer.ndsModel&&(o[0]+=r.drawRange.start/2,o[1]+=r.drawRange.start/2),r.isBufferGeometry){var a=o[1]-o[0]+1,s=r.index,l=r.attributes.position.array,d=new Float32Array(6*a);if(null!=s){for(var c=s.array,h=0,r=(this.edgeInfo.startPos=new THREE.Vector3,this.edgeInfo.endPos=new THREE.Vector3,this.edgeInfo.midPos=new THREE.Vector3,o[0]),u=o[1],p=(Math.round(.5*(r+u)),this.edgeInfo.thirdPos=null,this.edgeInfo.startPos.fromArray(l,3*c[2*r]),this.edgeInfo.endPos.fromArray(l,3*c[2*u+1]),this.edgeInfo.endPos.distanceTo(this.edgeInfo.startPos)<1e-7&&(this.edgeInfo.thirdPos=new THREE.Vector3,this.edgeInfo.thirdPos.fromArray(l,3*c[2*(u-1)])),0),f=r,m=u;f<=m;f++,h+=1){var g=c[2*f],v=c[2*f+1],A=new THREE.Vector3,y=new THREE.Vector3;A.fromArray(l,3*g),y.fromArray(l,3*v),d[6*h]=A.x,d[6*h+1]=A.y,d[6*h+2]=A.z,d[6*h+3]=y.x,d[6*h+4]=y.y,d[6*h+5]=y.z,p+=A.clone().distanceTo(y),y=A=null}for(var E=0,f=r;f<=u;f++){var g=c[2*f],v=c[2*f+1],A=new THREE.Vector3,y=new THREE.Vector3,M=(A.fromArray(l,3*g),y.fromArray(l,3*v),E);if(.5*p<(E+=A.clone().distanceTo(y))){var M=.5*p-M,w=y.clone().sub(A);w.normalize(),this.edgeInfo.midPos=A.clone().addScaledVector(w,M);break}}n=n||(0==t?_e.SelectedEdgeMaterial1:_e.preSelectedEdgeMaterial);a=new G,s=(a.setPositions(d),new Q({linewidth:n.linewidth,opacity:n.opacity,color:n.color,depthTest:n.depthTest,depthWrite:n.depthWrite})),o=this.viewer.renderer.getPixelRatio(),r=this.viewer.renderer.domElement.width/o,n=this.viewer.renderer.domElement.height/o,o=(s.resolution.set(r,n),(i=new qe(a,s)).objectType="SelLine",i.LineInfo=[],i.LineInfo.push(this.viewer.ndsModel.bodyUuid2NodeMap[e.bodyUuid].id),this.viewer.ndsModel.geomManager.uuidToIdMap[e.geometry.uuid][0]),r=(i.LineInfo.push(o),i.LineInfo.push(e.topolIndex),i.LineInfo.push(e.lineSegId),t?1:0);i.LineInfo.push(r),i.applyMatrix(e.matrixWorld),i.matrixWorldNeedsUpdate=!0,this.edgeInfo.startPos.applyMatrix4(e.matrixWorld),this.edgeInfo.endPos.applyMatrix4(e.matrixWorld),this.edgeInfo.midPos.applyMatrix4(e.matrixWorld),this.edgeInfo.thirdPos&&this.edgeInfo.thirdPos.applyMatrix4(e.matrixWorld)}}return i}},h.prototype.isBetweenTwoVectors=function(e,t,n){var i,r;return!(!e.equals(t)&&!e.equals(n))||(i=(new THREE.Vector3).crossVectors(e,t),r=(new THREE.Vector3).crossVectors(e,n),i.dot(r)<0&&e.angleTo(t)+e.angleTo(n)<Math.PI)},h.prototype.createLineMesh=function(e,t,n){var i=(new THREE.Vector3).subVectors(t,e),r=new THREE.Matrix4,i=(r.lookAt(e,t,(new THREE.Object3D).up),r.multiply((new THREE.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1)),new THREE.CylinderGeometry(.5,.5,i.length(),8,1,!1)),i=new THREE.Mesh(i,n);return i.applyMatrix(r),i.position.addVectors(e,t),i.position.multiplyScalar(.5),i},h.prototype.createLineMesh2=function(e,t,n){var i=new THREE.Geometry,i=(i.vertices.push(t),i.vertices.push(e),new THREE.Line(i,n));return i.updateMatrixWorld(!0),i.objectType="Line",i.Start=e.clone(),i.End=t.clone(),i},h.prototype.createLineMesh3=function(e,t,n){for(var i=t.clone().sub(e).normalize(),r=e.distanceTo(t),o=Math.ceil(Math.abs(r/6)),a=0<r?1:-1,s=new Float32Array(6*o),l=0;l<o;++l){var d=new THREE.Vector3,c=new THREE.Vector3,d=e.clone().add(i.clone().multiplyScalar(6*l*a));6*l+4<Math.abs(r)?c=d.clone().add(i.clone().multiplyScalar(3*a)):c.set(t.x,t.y,t.z),s[6*l]=d.x,s[6*l+1]=d.y,s[6*l+2]=d.z,s[6*l+3]=c.x,s[6*l+4]=c.y,s[6*l+5]=c.z}var h=new THREE.BufferGeometry,h=(h.addAttribute("position",new THREE.BufferAttribute(s,3)),new THREE.LineSegments(h,n));return h.objectType="Edge",h.Start=e.clone(),h.End=t.clone(),h.matrixWorldNeedsUpdate=!0,h},h.prototype.createLineMesh4=function(e,t,n,i){for(var r=t.clone().sub(e).normalize(),o=e.distanceTo(t),a=Math.ceil(Math.abs(o/6)),s=Math.ceil(n.distanceTo(t)/6),l=new Float32Array(6*(a+s)),d=0;d<a;++d){var c=new THREE.Vector3,h=new THREE.Vector3;c=e.clone().add(r.clone().multiplyScalar(6*d)),6*d+4<o?h=c.clone().add(r.clone().multiplyScalar(3)):h.set(t.x,t.y,t.z),l[6*d]=c.x,l[6*d+1]=c.y,l[6*d+2]=c.z,l[6*d+3]=h.x,l[6*d+4]=h.y,l[6*d+5]=h.z}for(r=n.clone().sub(t).normalize(),o=n.distanceTo(t),d=0;d<s;++d){c=new THREE.Vector3,h=new THREE.Vector3;c=t.clone().add(r.clone().multiplyScalar(6*d)),6*d+4<o?h=c.clone().add(r.clone().multiplyScalar(3)):h.set(n.x,n.y,n.z),l[6*(d+a)]=c.x,l[6*(d+a)+1]=c.y,l[6*(d+a)+2]=c.z,l[6*(d+a)+3]=h.x,l[6*(d+a)+4]=h.y,l[6*(d+a)+5]=h.z}var u=new THREE.BufferGeometry,u=(u.addAttribute("position",new THREE.BufferAttribute(l,3)),new THREE.LineSegments(u,i));return u.objectType="CircleLine",u.Start=e.clone(),u.Mid=t.clone(),u.End=n.clone(),u.matrixWorldNeedsUpdate=!0,u},h.prototype.createCylinderMesh=function(e,t,n){var i=new THREE.Matrix4,r=(i.lookAt(e,t,(new THREE.Object3D).up),i.multiply((new THREE.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1)),new THREE.CylinderGeometry(0,this.cylinderRadiusBottom,this.cylinderHeight,8,1,!1)),r=new THREE.Mesh(r,n);return r.applyMatrix(i),r.position.copy(e),r.objectType="Cylinder",r.Start=e.clone(),r.End=t.clone(),r},h.prototype.createAngleArcMeshes2=function(e,t,n,i,r,o,a){var s=new THREE.Vector3,l=new THREE.Vector3,e=(s.subVectors(e,t),l.subVectors(n,t),s.dot(l)),n=s.length(),d=l.length(),e=(e=Math.acos(e/(n*d)))/Math.PI*180,c=(this.dimString=e.toFixed(2),this.dimString+="°",new THREE.Vector3),c=(c.crossVectors(s,l),c.normalize(),o&&c.copy(o),Math.min(n,d));return this.createAngleArcMeshesWithAngle(t,s,l,c,e,i,r)},h.prototype.createAngleArcMeshesWithAngle=function(r,e,t,o,n,i,a){this.dimString=n.toFixed(2),this.dimString+="°",e.normalize(),t.normalize();var s=new THREE.Vector3,s=(s.crossVectors(e,t),s.normalize(),new THREE.CircleGeometry(o,18,0,n*Math.PI/180));if(new THREE.Mesh(s,this.materialLine).geometry.attributes.position.count<2)return[];var l=[];!function e(t,n){var i=(new THREE.Vector3).addVectors(t,n);i.normalize(),i.angleTo(t)/Math.PI*180<=2?(l.push(r.clone().addScaledVector(t,o)),l.push(r.clone().addScaledVector(i,o)),l.push(r.clone().addScaledVector(n,o))):(e(t.clone(),i.clone()),e(i.clone(),n.clone()))}(e,t);var d=[];a=a||this.materialLine;for(var c=0;c<l.length-1;c++){var h=this.createLineMesh2(l[c],l[c+1],a,i);d.push(h)}return d},h.prototype.createContour=function(e){var t=new Float32Array(e),n=new THREE.BufferGeometry,t=(n.addAttribute("position",new THREE.BufferAttribute(t,3)),new THREE.LineSegments(n,_e.selectedVertexMaterial));return t.objectType="Contour",t.Vertices=e,t.matrixWorldNeedsUpdate=!0,t},h.prototype.getCameraScale=function(e,t){var n,i,r;return e?(t=null!=t?t:5,n=this.viewer.camera.getCameraTarget(),i=this.viewer.camera.position,(r=new THREE.Vector3).subVectors(n,i),n=e.clone(),e=this.viewer.camera.isPerspective?n.sub(i).dot(r.normalize()):1.2*r.length(),n=this.viewer.camera.fov,i=2*e*Math.tan(THREE.Math.degToRad(.5*n)),r=this.viewer.renderer.domElement.height,t*i*this.viewer.renderer.getPixelRatio()/r):1},h.prototype.setPointScale=function(e,t){t=this.OpMeasure.getScale(e,t);e.scale.x=t,e.scale.y=t,e.scale.z=t,e.updateMatrixWorld()},h.prototype.setCylinderScale=function(e,t){t=this.OpMeasure.getScale(e,t);e.scale.x=t,e.scale.y=t,e.scale.z=t,e.oldPosition&&e.offsetPos&&e.position.addVectors(e.oldPosition,e.offsetPos.clone().multiplyScalar(t)),e.updateMatrixWorld()},h.prototype.createPointMesh=function(e,t,n){t=new THREE.Mesh(new THREE.SphereGeometry(1),t);return t.position.set(e.x,e.y,e.z),this.setPointScale(t,n),t.objectType="Point",t.Point=e.clone(),t},h.prototype.isTwoTopolInfoTheSame=function(e,t){return!(e&&!t||!e&&t||!e&&!t||this.viewer.ndsModel&&(e.bodyId!=t.bodyId||e.meshId!=t.meshId||e.lineSegId!=t.lineSegId)||e.parentObj!=t.parentObj||e.id!=t.id||e.indexRange[0]!==t.indexRange[0]||e.indexRange[1]!==t.indexRange[1])},h.prototype.isTwoPointTheSame=function(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6},h.prototype.getIntersectsByPriorityOfLine=function(e,t,n){var i=this.viewer,r=i.renderer.domElement,o=i.renderer.getPixelRatio(),a=new THREE.Raycaster,s=(i.camera.setCastRay(a,e*o/r.width*2-1,2*-(t*o/r.height)+1),a.linePrecision=this.getLinePrecision(),n&&(a.linePrecision=n),null),s=i.ndsModel?i.ndsModel.intersect(a.ray,a.linePrecision):a.intersectObjects(i.selectionManager.getTargetIncludeLineList());if(s&&0<s.length&&!i.ndsModel&&1<s.length&&!(s[0].object instanceof THREE.Line)){s[0].object;for(var l=s[0].distance,d=1;d<s.length;d++){var c=s[d].object,h=s[d].distance;if(!(l+2*a.linePrecision>=h))break;if(c instanceof THREE.Line){h=s[d];s[d]=s[0],s[0]=h;break}}}return s},h.prototype.createAndShowDistanceDimension=function(e,t){var n,i,r,o,a,s,l,d,c,h,u,p,f,m,g,v,A,y,E,M,w,b,x,I,T;this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&(n=!1,r=((n=this.distanceInfo.firstSelInfo&&"plane"==this.distanceInfo.firstSelInfo.type&&this.distanceInfo.secondSelInfo&&"plane"==this.distanceInfo.secondSelInfo.type?!0:n)?(i=this.distanceInfo.firstSelInfo.intersect.clone(),this.distanceInfo.secondSelInfo.intersect):(i=this.distanceInfo.firstPoint.clone(),this.distanceInfo.secondPoint)).clone(),this.distanceInfo.fstClndPos||(this.distanceInfo.fstClndPos=this.distanceInfo.firstPoint.clone()),this.distanceInfo.sndClndPos||(this.distanceInfo.sndClndPos=this.distanceInfo.secondPoint.clone()),this.distanceInfo.textPos&&e&&((T=new THREE.Plane).setFromCoplanarPoints(i,this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos),T.normal.length()<1e-8&&T.setFromCoplanarPoints(i.clone().add(new THREE.Vector3(1,-1,1)),this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos),w=this.clientCoordToModelCoordOnPlane(e.x,e.y,T))&&(this.viewer.is2DModel&&(w.z=0),this.distanceInfo.textPos.copy(w)),this.distanceInfo.fstClnd&&this.distanceInfo.sndClnd?!n&&this.distanceInfo.textPos?(l=(new THREE.Vector3).subVectors(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos),(o=this.getProjectPntToLine(r,this.distanceInfo.sndClndPos,this.distanceInfo.textPos.clone()))&&(1e-5<(w=o.clone().sub(r)).length()?(this.distanceInfo.sndClndPos.addVectors(r,w),this.distanceInfo.fstClndPos.subVectors(this.distanceInfo.sndClndPos,l)):(a=this.viewer.camera.position,s=(new THREE.Vector3).subVectors(a,this.distanceInfo.fstClndPos),(d=(l=(new THREE.Vector3).subVectors(this.distanceInfo.secondPoint,this.distanceInfo.firstPoint)).length())<1e-8?(d=(l=new THREE.Vector3(100,100,100)).length(),(c=(new THREE.Vector3).crossVectors(l,s)).normalize().multiplyScalar(Math.max(.001*d,1e-4)),this.distanceInfo.fstClndPos.add(c),this.distanceInfo.sndClndPos.sub(c)):((c=(new THREE.Vector3).crossVectors(l,s)).normalize().multiplyScalar(Math.max(.001*d,1e-4)),this.distanceInfo.fstClndPos.add(c),this.distanceInfo.sndClndPos.add(c))))):n&&(w=(new THREE.Vector3).subVectors(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos),b=(new THREE.Vector3).subVectors(this.distanceInfo.textPos,this.distanceInfo.fstClndPos),(T=new THREE.Plane).setFromCoplanarPoints(i,r,this.distanceInfo.sndClndPos),(e=this.clientCoordToModelCoordOnPlane(e.x,e.y,T))&&(o=this.getProjectPntToLine(this.distanceInfo.secondSelInfo.intersect,this.distanceInfo.sndClndPos,e))&&this.distanceInfo.sndClndPos.copy(o),this.distanceInfo.fstClndPos=this.distanceInfo.sndClndPos.clone().sub(w),this.distanceInfo.textPos.copy(this.distanceInfo.fstClndPos.clone().add(b))):n?(T=(new THREE.Vector3).subVectors(r,i),(e=this.distanceInfo.firstSelInfo.worldNormal.clone()).normalize(),this.distanceInfo.fstClndPos=i.clone(),this.distanceInfo.sndClndPos=new THREE.Vector3,o=this.distanceInfo.dimString,o*=x=this.viewer.getUnitScale(this.distanceInfo.unit),o=Math.max(o,1e-4),0<T.dot(e)?this.distanceInfo.sndClndPos.addVectors(this.distanceInfo.fstClndPos,e.multiplyScalar(o)):this.distanceInfo.sndClndPos.addVectors(this.distanceInfo.fstClndPos,e.multiplyScalar(-1*o))):(a=this.viewer.camera.position,s=(new THREE.Vector3).subVectors(a,this.distanceInfo.fstClndPos),(d=(l=(new THREE.Vector3).subVectors(this.distanceInfo.secondPoint,this.distanceInfo.firstPoint)).length())<1e-8?(d=(l=new THREE.Vector3(100,100,100)).length(),(c=(new THREE.Vector3).crossVectors(l,s)).normalize().multiplyScalar(Math.max(.001*d,1e-4)),this.viewer.is2DModel&&(c.z=0),this.distanceInfo.fstClndPos.add(c),this.distanceInfo.sndClndPos.sub(c)):((c=(new THREE.Vector3).crossVectors(l,s)).normalize().multiplyScalar(Math.max(.001*d,1e-4)),this.viewer.is2DModel&&(c.z=0),this.distanceInfo.fstClndPos.add(c),this.distanceInfo.sndClndPos.add(c))),this.distanceInfo.textPos||(this.distanceInfo.textPos=this.distanceInfo.sndClndPos.clone()),n||this.distanceInfo.fstToSndLine||(this.distanceInfo.fstToSndLine=this.createLineMesh2(this.distanceInfo.firstPoint,this.distanceInfo.secondPoint,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.fstToSndLine),this.distanceInfo.firstSelInfo&&"plane"==this.distanceInfo.firstSelInfo.type&&(h=this.getClosePoint(this.distanceInfo.firstSelInfo,this.distanceInfo.firstPoint),this.distanceInfo.FstToFstPointLine=this.createLineMesh3(this.distanceInfo.firstPoint,h,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.FstToFstPointLine)),this.distanceInfo.secondSelInfo&&"plane"==this.distanceInfo.secondSelInfo.type&&(h=this.getClosePoint(this.distanceInfo.secondSelInfo,this.distanceInfo.secondPoint),this.distanceInfo.SndToSndPointLine=this.createLineMesh3(this.distanceInfo.secondPoint,h,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.SndToSndPointLine)),this.distanceInfo.firstSelInfo&&"circle"==this.distanceInfo.firstSelInfo.type&&((u=new THREE.Vector3(this.distanceInfo.firstSelInfo.center[0],this.distanceInfo.firstSelInfo.center[1],this.distanceInfo.firstSelInfo.center[2])).applyMatrix4(this.distanceInfo.firstSelInfo.matrixWorld),p=this.distanceInfo.firstSelInfo.geometry,f=new THREE.Vector3,m=this.distanceInfo.firstSelInfo.indexRange.concat(),this.viewer.ndsModel&&(m[0]+=p.drawRange.start/2,m[1]+=p.drawRange.start/2),p.isBufferGeometry&&(g=p.index,v=p.attributes.position.array,null!=g)&&(A=g.array,y=m[0],f.fromArray(v,3*A[2*y]),f.applyMatrix4(this.distanceInfo.firstSelInfo.matrixWorld)),this.distanceInfo.FstToFstPointLine=this.createLineMesh4(this.distanceInfo.firstPoint,u,f,this.materialLine),this.OpMeasure.rootObject.add(this.distanceInfo.FstToFstPointLine)),this.distanceInfo.secondSelInfo&&"circle"==this.distanceInfo.secondSelInfo.type&&((u=new THREE.Vector3(this.distanceInfo.secondSelInfo.center[0],this.distanceInfo.secondSelInfo.center[1],this.distanceInfo.secondSelInfo.center[2])).applyMatrix4(this.distanceInfo.secondSelInfo.matrixWorld),p=this.distanceInfo.secondSelInfo.geometry,f=new THREE.Vector3,m=this.distanceInfo.secondSelInfo.indexRange.concat(),this.viewer.ndsModel&&(m[0]+=p.drawRange.start/2,m[1]+=p.drawRange.start/2),p.isBufferGeometry&&(g=p.index,v=p.attributes.position.array,null!=g)&&(A=g.array,y=m[0],f.fromArray(v,3*A[2*y]),f.applyMatrix4(this.distanceInfo.secondSelInfo.matrixWorld)),this.distanceInfo.SndToSndPointLine=this.createLineMesh4(this.distanceInfo.secondPoint,u,f,this.materialLine),this.OpMeasure.rootObject.add(this.distanceInfo.SndToSndPointLine)),!this.distanceInfo.firstSelInfo||"line"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type&&"cone"!=this.distanceInfo.firstSelInfo.type||(E=this.getLineStartEndPoints(this.distanceInfo.firstSelInfo))&&1e-5<(M=new THREE.Line3(E.start,E.end).closestPointToPoint(this.distanceInfo.firstPoint,!0)).distanceTo(this.distanceInfo.firstPoint)&&(this.distanceInfo.FstToFstPointLine=this.createLineMesh3(this.distanceInfo.firstPoint,M,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.FstToFstPointLine)),!this.distanceInfo.secondSelInfo)||"line"!=this.distanceInfo.secondSelInfo.type&&"cylinder"!=this.distanceInfo.secondSelInfo.type&&"cone"!=this.distanceInfo.secondSelInfo.type||(E=this.getLineStartEndPoints(this.distanceInfo.secondSelInfo))&&1e-5<(M=new THREE.Line3(E.start,E.end).closestPointToPoint(this.distanceInfo.secondPoint,!0)).distanceTo(this.distanceInfo.secondPoint)&&(this.distanceInfo.SndToSndPointLine=this.createLineMesh3(this.distanceInfo.secondPoint,M,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.SndToSndPointLine)),w=this.isPointBetweenIn(this.distanceInfo.textPos,this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos),this.distanceInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstClnd),(b=(new THREE.Vector3).subVectors(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos)).normalize(),w?(this.distanceInfo.fstClnd=this.createCylinderMesh(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos,this.materialLine),x=this.OpMeasure.getScale(this.distanceInfo.fstClnd,this.CYLINDERWIDTH),b.multiplyScalar(.5*this.distanceInfo.fstClnd.geometry.parameters.height),this.distanceInfo.fstClnd.oldPosition=this.distanceInfo.fstClndPos.clone(),this.distanceInfo.fstClnd.offsetPos=b.clone(),this.distanceInfo.fstClnd.position.addVectors(this.distanceInfo.fstClndPos,b.clone().multiplyScalar(x))):(this.distanceInfo.fstClnd=this.createCylinderMesh(this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos,this.materialLine,!1),x=this.OpMeasure.getScale(this.distanceInfo.fstClnd,this.CYLINDERWIDTH),b.multiplyScalar(.5*this.distanceInfo.fstClnd.geometry.parameters.height),this.distanceInfo.fstClnd.oldPosition=this.distanceInfo.fstClndPos.clone(),this.distanceInfo.fstClnd.offsetPos=b.clone().multiplyScalar(-1),this.distanceInfo.fstClnd.position.subVectors(this.distanceInfo.fstClndPos,b.clone().multiplyScalar(x))),this.distanceInfo.fstClnd.updateMatrixWorld(),this.OpMeasure.rootObject.add(this.distanceInfo.fstClnd),this.distanceInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndClnd),w?(this.distanceInfo.sndClnd=this.createCylinderMesh(this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos,this.materialLine),this.distanceInfo.sndClnd.oldPosition=this.distanceInfo.sndClndPos.clone(),this.distanceInfo.sndClnd.offsetPos=b.clone().multiplyScalar(-1),this.distanceInfo.sndClnd.position.subVectors(this.distanceInfo.sndClndPos,b.clone().multiplyScalar(x))):(this.distanceInfo.sndClnd=this.createCylinderMesh(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos,this.materialLine,!1),this.distanceInfo.sndClnd.oldPosition=this.distanceInfo.sndClndPos.clone(),this.distanceInfo.sndClnd.offsetPos=b.clone(),this.distanceInfo.sndClnd.position.addVectors(this.distanceInfo.sndClndPos,b.clone().multiplyScalar(x))),this.distanceInfo.sndClnd.updateMatrixWorld(),this.OpMeasure.rootObject.add(this.distanceInfo.sndClnd),this.distanceInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.clndToClndLine),this.distanceInfo.clndToClndLine=this.createLineMesh2(this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.clndToClndLine),this.distanceInfo.fstToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstToClndLine),this.distanceInfo.fstToClndLine=this.createLineMesh2(i,this.distanceInfo.fstClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.fstToClndLine),this.distanceInfo.sndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndToClndLine),this.distanceInfo.sndToClndLine=this.createLineMesh2(r,this.distanceInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.sndToClndLine),this.distanceInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.boxToClndLine),this.distanceInfo.boxToClndLine=this.createLineMesh2(this.distanceInfo.fstClndPos,this.distanceInfo.textPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.boxToClndLine),""==this.distanceInfo.dimString?(this.distanceInfo.dimString=this.distanceInfo.firstPoint.distanceTo(this.distanceInfo.secondPoint),this.distanceInfo.dimString<1&&.999999<this.distanceInfo.dimString&&(this.distanceInfo.dimString=1),I=this.viewer.getDispalyModelUnit(this.distanceInfo.dimString),this.distanceInfo.dimString*=I.scale,this.distanceInfo.dimString=this.distanceInfo.dimString.toFixed(2),this.distanceInfo.unit=this.getUnitStringmap(I.unit)):(d=parseFloat(this.distanceInfo.dimString))<1&&""==this.distanceInfo.unit&&(.999999<d&&(d=1),d*=(I=this.viewer.getDispalyModelUnit(this.distanceInfo.dimString)).scale,this.distanceInfo.dimString=d.toFixed(2),this.distanceInfo.unit=this.getUnitStringmap(I.unit)),T=(this.distanceInfo.dimString*this.viewer.measuringScale).toFixed(2)+this.distanceInfo.unit,this.distanceInfo.textBox||(this.distanceInfo.textBox=document.createElement("div"),this.distanceInfo.textBox.className="mearesult",this.viewer.container.appendChild(this.distanceInfo.textBox)),this.getAndShowTextBox(this.distanceInfo.textPos.clone(),T,this.distanceInfo.textBox),1==t)&&((e={}).dimString=T,e.textPos=this.distanceInfo.textPos.clone(),e.textBox=this.distanceInfo.textBox,e.textBox.setAttribute("type","length"),e.textBox.setAttribute("dimString",this.distanceInfo.dimString),e.textBox.setAttribute("dimStringPrefix",""),e.textBox.setAttribute("unit",this.distanceInfo.unit),this.OpMeasure.boxInfos.push(e),this.clearDistanceInfo(!0),Se.isMobileDevice())&&this.ChangeMeasureFlag()},h.prototype.DeepCopy=function(e,t){var n={};switch(n.textPos=e.textPos,n.fstClndPos=e.fstClndPos,n.sndClndPos=e.sndClndPos,n.unit=e.unit,t){case"Distance":n.firstPoint=e.firstPoint,n.secondPoint=e.secondPoint;break;case"Angle":n.arcCenter=e.arcCenter,e.firstLineInfo&&e.secondLineInfo&&(n.firstLineInfo={},n.secondLineInfo={},n.firstLineInfo.start=e.firstLineInfo.start,n.secondLineInfo.start=e.secondLineInfo.start,n.firstLineInfo.end=e.firstLineInfo.end,n.secondLineInfo.end=e.secondLineInfo.end);break;case"measureEdges":n.thirdPos=e.thirdPos,n.endPos=e.endPos,n.startPos=e.startPos,n.midPos=e.midPos,n.fstClnd=!!e.fstClnd,n.sndClnd=!!e.sndClnd;break;case"Radius":n.selLineCenterPos=e.selLineCenterPos,n.firstHoleInfo={},e.firstHoleInfo&&(n.firstHoleInfo.center=e.firstHoleInfo.center,n.firstHoleInfo.intersect=e.firstHoleInfo.intersect,n.firstHoleInfo.radius=e.firstHoleInfo.radius,n.firstHoleInfo.worldAxis=e.firstHoleInfo.worldAxis,n.firstHoleInfo.worldCenter=e.firstHoleInfo.worldCenter);break;case"Lineargauge3D":n.firstPoint=e.firstPoint,n.secondPoint=e.secondPoint;break;default:console.log("ERROR: unknow measure type")}return n.measureType=t,n},h.prototype.ChangeMeasureFlag=function(){switch(this.measureType){case"pt2pt":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.pt2pt;break;case"pt2ptbim":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.pt2ptbim;break;case"PointToLine":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.pointtoline;break;case"PointToFace":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.pointtoface;break;case"AxisToPoint":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.axistopoint;break;case"LineToLine":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.linetoline;break;case"LineToFace":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.linetoface;break;case"faceDist":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.facedist;break;case"AxisToLine":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.axistoline;break;case"AxisToFace":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.axistoface;break;case"holeDist":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.holedist;break;case"measureEdges":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.Edge;break;case"perimeter":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.perimeter;break;case"LineAngle":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.LineAngle;break;case"LineFaceAngle":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.LineFaceAngle;break;case"faceAngle":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.faceAngle;break;case"contour":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.contour;break;case"contourarea":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.contourarea;break;case"Lineargauge":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.Lineargauge;break;case"coordinate":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.coordinate;break;case"bodyAngle":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.bodyAngle;break;case"bodyDistance":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.bodyDistance;break;case"bodyEdgeLength":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.bodyEdgeLength;break;case"angle":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.angle;break;case"WallThickness":this.OpMeasure.measureFlag|=ve.MEASUREFLAG.WallThickness}this.OpMeasure.PostInfo()},h.prototype.hasMeasured=function(){switch(this.measureType){case"pt2pt":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.pt2pt;case"PointToLine":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.pointtoline;case"PointToFace":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.pointtoface;case"AxisToPoint":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.axistopoint;case"LineToLine":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.linetoline;case"LineToFace":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.linetoface;case"faceDist":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.facedist;case"AxisToLine":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.axistoline;case"AxisToFace":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.axistoface;case"holeDist":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.holedist;case"measureEdges":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.Edge;case"perimeter":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.perimeter;case"LineAngle":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.LineAngle;case"LineFaceAngle":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.LineFaceAngle;case"faceAngle":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.faceAngle;case"contour":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.contour;case"contourarea":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.contourarea;case"Lineargauge":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.Lineargauge;case"coordinate":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.coordinate;case"bodyAngle":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.bodyAngle;case"bodyDistance":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.bodyDistance;case"bodyEdgeLength":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.bodyEdgeLength;case"angle":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.angle;case"pt2ptbim":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.pt2ptbim;case"WallThickness":return this.OpMeasure.measureFlag&ve.MEASUREFLAG.WallThickness}},h.prototype.createAndShow3DDistanceDimension=function(e,t){var n,i,r,o,a,s,l,d,c,h,u,p,f,m,g,v,A,y,E,M,w,b,x,I,T;this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&(u=!1,i=((u=this.distanceInfo.firstSelInfo&&"plane"==this.distanceInfo.firstSelInfo.type&&this.distanceInfo.secondSelInfo&&"plane"==this.distanceInfo.secondSelInfo.type?!0:u)?(n=this.distanceInfo.firstSelInfo.intersect.clone(),this.distanceInfo.secondSelInfo.intersect):(n=this.distanceInfo.firstPoint.clone(),this.distanceInfo.secondPoint)).clone(),this.distanceInfo.fstClndPos||(this.distanceInfo.fstClndPos=this.distanceInfo.firstPoint.clone()),this.distanceInfo.sndClndPos||(this.distanceInfo.sndClndPos=this.distanceInfo.secondPoint.clone()),this.distanceInfo.textPos&&e&&((p=new THREE.Plane).setFromCoplanarPoints(n,this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos),p.normal.length()<1e-8&&p.setFromCoplanarPoints(n.clone().add(new THREE.Vector3(1,-1,1)),this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos),c=this.clientCoordToModelCoordOnPlane(e.x,e.y,p))&&this.distanceInfo.textPos.copy(c),this.distanceInfo.fstClnd&&this.distanceInfo.sndClnd?!u&&this.distanceInfo.textPos?(g=(new THREE.Vector3).subVectors(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos),(f=this.getProjectPntToLine(i,this.distanceInfo.sndClndPos,this.distanceInfo.textPos.clone()))&&(1e-5<(c=f.clone().sub(i)).length()?(this.distanceInfo.sndClndPos.addVectors(i,c),this.distanceInfo.fstClndPos.subVectors(this.distanceInfo.sndClndPos,g)):(m=this.viewer.camera.position,v=(new THREE.Vector3).subVectors(m,this.distanceInfo.fstClndPos),(r=(g=(new THREE.Vector3).subVectors(this.distanceInfo.secondPoint,this.distanceInfo.firstPoint)).length())<1e-8?(r=(g=new THREE.Vector3(100,100,100)).length(),(A=(new THREE.Vector3).crossVectors(g,v)).normalize().multiplyScalar(Math.max(.001*r,1e-4)),this.distanceInfo.fstClndPos.add(A),this.distanceInfo.sndClndPos.sub(A)):((A=(new THREE.Vector3).crossVectors(g,v)).normalize().multiplyScalar(Math.max(.001*r,1e-4)),this.distanceInfo.fstClndPos.add(A),this.distanceInfo.sndClndPos.add(A))))):u&&(c=(new THREE.Vector3).subVectors(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos),h=(new THREE.Vector3).subVectors(this.distanceInfo.textPos,this.distanceInfo.fstClndPos),(p=new THREE.Plane).setFromCoplanarPoints(n,i,this.distanceInfo.sndClndPos),(e=this.clientCoordToModelCoordOnPlane(e.x,e.y,p))&&(f=this.getProjectPntToLine(this.distanceInfo.secondSelInfo.intersect,this.distanceInfo.sndClndPos,e))&&this.distanceInfo.sndClndPos.copy(f),this.distanceInfo.fstClndPos=this.distanceInfo.sndClndPos.clone().sub(c),this.distanceInfo.textPos.copy(this.distanceInfo.fstClndPos.clone().add(h))):u?(p=(new THREE.Vector3).subVectors(i,n),(e=this.distanceInfo.firstSelInfo.worldNormal.clone()).normalize(),this.distanceInfo.fstClndPos=n.clone(),this.distanceInfo.sndClndPos=new THREE.Vector3,f=this.distanceInfo.dimString,f*=this.viewer.getUnitScale(this.distanceInfo.unit),f=Math.max(f,1e-4),0<p.dot(e)?this.distanceInfo.sndClndPos.addVectors(this.distanceInfo.fstClndPos,e.multiplyScalar(f)):this.distanceInfo.sndClndPos.addVectors(this.distanceInfo.fstClndPos,e.multiplyScalar(-1*f))):(m=this.viewer.camera.position,v=(new THREE.Vector3).subVectors(m,this.distanceInfo.fstClndPos),(r=(g=(new THREE.Vector3).subVectors(this.distanceInfo.secondPoint,this.distanceInfo.firstPoint)).length())<1e-8?(r=(g=new THREE.Vector3(100,100,100)).length(),(A=(new THREE.Vector3).crossVectors(g,v)).normalize().multiplyScalar(Math.max(.001*r,1e-4)),this.distanceInfo.fstClndPos.add(A),this.distanceInfo.sndClndPos.sub(A)):((A=(new THREE.Vector3).crossVectors(g,v)).normalize().multiplyScalar(Math.max(.001*r,1e-4)),this.distanceInfo.fstClndPos.add(A),this.distanceInfo.sndClndPos.add(A))),this.distanceInfo.textPos||(this.distanceInfo.textPos=this.distanceInfo.firstPoint.clone().add(this.distanceInfo.secondPoint).divideScalar(2)),this.distanceInfo.fstToSndLine||(this.distanceInfo.fstToSndLine=this.createLineMesh2(this.distanceInfo.firstPoint,this.distanceInfo.secondPoint,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.fstToSndLine)),this.distanceInfo.firstSelInfo&&"plane"==this.distanceInfo.firstSelInfo.type&&(E=this.getClosePoint(this.distanceInfo.firstSelInfo,this.distanceInfo.firstPoint),this.distanceInfo.FstToFstPointLine=this.createLineMesh3(this.distanceInfo.firstPoint,E,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.FstToFstPointLine)),this.distanceInfo.secondSelInfo&&"plane"==this.distanceInfo.secondSelInfo.type&&(E=this.getClosePoint(this.distanceInfo.secondSelInfo,this.distanceInfo.secondPoint),this.distanceInfo.SndToSndPointLine=this.createLineMesh3(this.distanceInfo.secondPoint,E,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.SndToSndPointLine)),this.distanceInfo.firstSelInfo&&"circle"==this.distanceInfo.firstSelInfo.type&&((o=new THREE.Vector3(this.distanceInfo.firstSelInfo.center[0],this.distanceInfo.firstSelInfo.center[1],this.distanceInfo.firstSelInfo.center[2])).applyMatrix4(this.distanceInfo.firstSelInfo.matrixWorld),M=this.distanceInfo.firstSelInfo.geometry,a=new THREE.Vector3,b=this.distanceInfo.firstSelInfo.indexRange.concat(),this.viewer.ndsModel&&(b[0]+=M.drawRange.start/2,b[1]+=M.drawRange.start/2),M.isBufferGeometry&&(w=M.index,x=M.attributes.position.array,null!=w)&&(I=w.array,T=b[0],a.fromArray(x,3*I[2*T]),a.applyMatrix4(this.distanceInfo.firstSelInfo.matrixWorld)),this.distanceInfo.FstToFstPointLine=this.createLineMesh4(this.distanceInfo.firstPoint,o,a,this.materialLine),this.OpMeasure.rootObject.add(this.distanceInfo.FstToFstPointLine)),this.distanceInfo.secondSelInfo&&"circle"==this.distanceInfo.secondSelInfo.type&&((o=new THREE.Vector3(this.distanceInfo.secondSelInfo.center[0],this.distanceInfo.secondSelInfo.center[1],this.distanceInfo.secondSelInfo.center[2])).applyMatrix4(this.distanceInfo.secondSelInfo.matrixWorld),M=this.distanceInfo.secondSelInfo.geometry,a=new THREE.Vector3,b=this.distanceInfo.secondSelInfo.indexRange.concat(),this.viewer.ndsModel&&(b[0]+=M.drawRange.start/2,b[1]+=M.drawRange.start/2),M.isBufferGeometry&&(w=M.index,x=M.attributes.position.array,null!=w)&&(I=w.array,T=b[0],a.fromArray(x,3*I[2*T]),a.applyMatrix4(this.distanceInfo.secondSelInfo.matrixWorld)),this.distanceInfo.SndToSndPointLine=this.createLineMesh4(this.distanceInfo.secondPoint,o,a,this.appmaterialLine),this.OpMeasure.rootObject.add(this.distanceInfo.SndToSndPointLine)),!this.distanceInfo.firstSelInfo||"line"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type&&"cone"!=this.distanceInfo.firstSelInfo.type||(s=this.getLineStartEndPoints(this.distanceInfo.firstSelInfo))&&1e-5<(l=new THREE.Line3(s.start,s.end).closestPointToPoint(this.distanceInfo.firstPoint,!0)).distanceTo(this.distanceInfo.firstPoint)&&(this.distanceInfo.FstToFstPointLine=this.createLineMesh3(this.distanceInfo.firstPoint,l,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.FstToFstPointLine)),!this.distanceInfo.secondSelInfo||"line"!=this.distanceInfo.secondSelInfo.type&&"cylinder"!=this.distanceInfo.secondSelInfo.type&&"cone"!=this.distanceInfo.secondSelInfo.type||(s=this.getLineStartEndPoints(this.distanceInfo.secondSelInfo))&&1e-5<(l=new THREE.Line3(s.start,s.end).closestPointToPoint(this.distanceInfo.secondPoint,!0)).distanceTo(this.distanceInfo.secondPoint)&&(this.distanceInfo.SndToSndPointLine=this.createLineMesh3(this.distanceInfo.secondPoint,l,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.SndToSndPointLine)),""==this.distanceInfo.dimString?(this.distanceInfo.dimString=this.distanceInfo.firstPoint.distanceTo(this.distanceInfo.secondPoint),this.distanceInfo.dimString<1&&.999999<this.distanceInfo.dimString&&(this.distanceInfo.dimString=1),d=this.viewer.getDispalyModelUnit(this.distanceInfo.dimString),this.distanceInfo.dimString*=d.scale,this.distanceInfo.dimString=this.distanceInfo.dimString.toFixed(2),this.distanceInfo.unit=this.getUnitStringmap(d.unit)):(r=parseFloat(this.distanceInfo.dimString))<1&&""==this.distanceInfo.unit&&(.999999<r&&(r=1),r*=(d=this.viewer.getDispalyModelUnit(this.distanceInfo.dimString)).scale,this.distanceInfo.dimString=r.toFixed(2),this.distanceInfo.unit=this.getUnitStringmap(d.unit)),c=(this.distanceInfo.dimString*this.viewer.measuringScale).toFixed(2)+this.distanceInfo.unit,""==!this.distanceInfo.dimStringPrefix&&(c=this.distanceInfo.dimStringPrefix+c),h=null,this.distanceInfo.textBox||("pt2ptbim"==this.measureType?(this.distanceInfo.textBox=document.createElement("div"),this.distanceInfo.textBox.className="measure-tc",(h=document.createElement("div")).className="sectionCross",this.distanceInfo.textBox.appendChild(h),(y=document.createElement("div")).className="sectionPoint",y.style.left="calc(50% - 6px)",y.style.top="calc(100% - 5.5px)",this.distanceInfo.textBox.appendChild(y),u=document.createElement("p"),p="en"==Se.getLanguage(),u.innerHTML=p?"<span>dis:</span>"+c:"<span>距离:</span>"+c,this.distanceInfo.textBox.appendChild(u),e=document.createElement("p"),f=Math.abs(this.distanceInfo.firstPoint.x-this.distanceInfo.secondPoint.x),d=this.viewer.getDispalyModelUnit(f),e.innerHTML="<span>X:</span>"+(f*this.viewer.measuringScale*d.scale).toFixed(2)+this.getUnitStringmap(d.unit),this.distanceInfo.textBox.appendChild(e),m=document.createElement("p"),g=Math.abs(this.distanceInfo.firstPoint.z-this.distanceInfo.secondPoint.z),d=this.viewer.getDispalyModelUnit(g),m.innerHTML="<span>Y:</span>"+(g*this.viewer.measuringScale*d.scale).toFixed(2)+this.getUnitStringmap(d.unit),this.distanceInfo.textBox.appendChild(m),v=document.createElement("p"),A=Math.abs(this.distanceInfo.firstPoint.y-this.distanceInfo.secondPoint.y),d=this.viewer.getDispalyModelUnit(A),v.innerHTML="<span>Z:</span>"+(A*this.viewer.measuringScale*d.scale).toFixed(2)+this.getUnitStringmap(d.unit),this.distanceInfo.textBox.appendChild(v)):(this.distanceInfo.textBox=document.createElement("div"),this.distanceInfo.textBox.className="section10",this.distanceInfo.textBox.innerHTML=c,(y=document.createElement("div")).className="sectionPoint",this.distanceInfo.textBox.appendChild(y),(h=document.createElement("div")).className="sectionCross",this.distanceInfo.textBox.appendChild(h)),this.viewer.container.appendChild(this.distanceInfo.textBox)),this.distanceInfo.boxToClndLine&&(this.OpMeasure.rootObject.remove(this.distanceInfo.boxToClndLine),this.distanceInfo.boxToClndLine=null),E=this.distanceInfo.firstPoint.clone().add(this.distanceInfo.secondPoint).divideScalar(2),this.distanceInfo.boxToClndLine||(this.distanceInfo.boxToClndLine=this.createLineMesh2(E,this.distanceInfo.textPos,this.appmaterialLine,1),this.distanceInfo.boxToClndLine.name="unsteady",this.OpMeasure.rootObject.add(this.distanceInfo.boxToClndLine)),M=this.get2dPoint(this.distanceInfo.textPos.clone()),w=this.viewer.renderer.getPixelRatio(),this.distanceInfo.textBox.style.left=Math.round(M.x/w-49)+"px",this.distanceInfo.textBox.style.top=Math.round(M.y/w-26)+"px",1==t)&&((b={}).dimString=c,b.textPos=this.distanceInfo.textPos.clone(),b.textBox=this.distanceInfo.textBox,x=this,(I=new THREE.Group).objectType="Group",x.OpMeasure.rootObject.remove(x.distanceInfo.boxToClndLine),x.OpMeasure.rootObject.remove(x.distanceInfo.fstToSndLine),x.OpMeasure.rootObject.remove(x.distanceInfo.firstSelObj),x.OpMeasure.rootObject.remove(x.distanceInfo.secondSelObj),x.distanceInfo.FstToFstPointLine&&(x.OpMeasure.rootObject.remove(x.distanceInfo.FstToFstPointLine),I.add(x.distanceInfo.FstToFstPointLine)),x.distanceInfo.SndToSndPointLine&&(x.OpMeasure.rootObject.remove(x.distanceInfo.SndToSndPointLine),I.add(x.distanceInfo.SndToSndPointLine)),x.distanceInfo.axisLineObj&&(x.OpMeasure.rootObject.remove(x.distanceInfo.axisLineObj),I.add(x.distanceInfo.axisLineObj)),x.distanceInfo.secaxisLineObj&&(x.OpMeasure.rootObject.remove(x.distanceInfo.secaxisLineObj),I.add(x.distanceInfo.secaxisLineObj)),I.add(x.distanceInfo.fstToSndLine),I.add(x.distanceInfo.firstSelObj),I.add(x.distanceInfo.secondSelObj),x.OpMeasure.rootObject.add(I),Se.isMobileDevice()?(b.textBox.addEventListener("touchstart",this.touchstart,!1),b.textBox.addEventListener("touchend",this.touchend,!1),b.textBox.addEventListener("touchmove",this.touchmove,!1)):(b.textBox.addEventListener("mousedown",this.touchstart,!1),b.textBox.addEventListener("mouseup",this.touchend,!1),b.textBox.addEventListener("mousemove",this.touchmove,!1),b.textBox.addEventListener("mouseleave",this.mouseleave,!1),b.textBox.addEventListener("mouseenter",this.mouseenter,!1)),Se.isMobileDevice()?h.addEventListener("touchend",this.sectionCrossend,!1):(h.addEventListener("mousedown",this.sectionCrossend,!1),h.addEventListener("mouseleave",this.crossleave,!1),h.addEventListener("mouseenter",this.crossenter,!1)),(T={}).start=this.distanceInfo.textPos.clone(),T.end=E.clone(),T.uuid=I.uuid,this.OpMeasure.textLines.push(T),b.textBox.setAttribute("mobile","up"),b.textBox.setAttribute("group",I.uuid),b.textBox.setAttribute("type","length"),b.textBox.setAttribute("dimString",this.distanceInfo.dimString),b.textBox.setAttribute("dimStringPrefix",this.distanceInfo.dimStringPrefix),b.textBox.setAttribute("unit",this.distanceInfo.unit),b.textBox.setAttribute("lineInfo",this.OpMeasure.textLines.length-1),this.OpMeasure.boxInfos.push(b),this.OpMeasure.unsteadyData[I.uuid]=this.DeepCopy(this.distanceInfo,"Distance"),this.OpMeasure.unsteadyData[I.uuid].p1=n,this.OpMeasure.unsteadyData[I.uuid].p2=i,this.clearDistanceInfo(!0),Se.isMobileDevice())&&this.ChangeMeasureFlag()},h.prototype.changeMeasureDistance=function(e){var t=this.OpMeasure.unsteadyData[this.OpMeasure.unsteadyuuid],n=(t.textPos&&e&&((i=new THREE.Plane).setFromCoplanarPoints(t.p1,t.fstClndPos,t.sndClndPos),i.normal.length()<1e-8&&i.setFromCoplanarPoints(t.p2,t.fstClndPos,t.sndClndPos),i.normal.length()<1e-8&&i.setFromCoplanarPoints(t.p1.clone().add(new THREE.Vector3(1,-1,1)),t.fstClndPos,t.sndClndPos),i.normal.length()<1e-8&&i.setFromCoplanarPoints(t.p1,t.fstClndPos.clone().add(new THREE.Vector3(1,-1,1)),t.sndClndPos),i.normal.length()<1e-8&&i.setFromCoplanarPoints(t.p1,t.fstClndPos,t.sndClndPos.clone().add(new THREE.Vector3(1,-1,1))),e=this.clientCoordToModelCoordOnPlane(e.x,e.y,i))&&t.textPos.copy(e),null),n=("Lineargauge3D"==this.measureClass?t.fstClndPos.clone().add(t.sndClndPos):t.firstPoint.clone().add(t.secondPoint)).divideScalar(2),i=this.get2dPoint(t.textPos.clone()),e=this.get2dPoint(n.clone()),i=new THREE.Vector2(i.x-e.x,i.y-e.y);i.normalize(),i.y>=i.x/2&&i.y>=-i.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(50% - 6px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="-5.5px",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","down")):i.y>i.x/2&&i.y<-i.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(100% - 4px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(50% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","right")):i.y<i.x/2&&i.y<-i.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(50% - 6px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(100% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","up")):i.y<i.x/2&&i.y>-i.x/2&&(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="-5.5px",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(50% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","left"));for(var r=0;r<this.OpMeasure.boxInfos.length;r++){var o=this.OpMeasure.boxInfos[r];if(o.textBox.getAttribute("group")==this.OpMeasure.unsteadyuuid){o.textPos=t.textPos;break}}for(r=0;r<this.OpMeasure.textLines.length;r++){var a=this.OpMeasure.textLines[r];if(a.uuid==this.OpMeasure.unsteadyuuid){a.start=t.textPos.clone(),a.end=n.clone();break}}this.OpMeasure.viewer.render()},h.prototype.getClosePoint=function(e,t){if(e&&e.parentObj instanceof THREE.Mesh){var n=e.geometry,i=e.indexRange.concat();if(this.viewer.ndsModel&&(i[0]+=n.drawRange.start/3,i[1]+=n.drawRange.start/3),n.isBufferGeometry)for(var r=n.index,o=n.attributes.position,a=new THREE.Vector3,s=1/0,l=i[0],d=i[1];l<=d;l++){var c=3*l,h=r.getX(c),u=r.getX(1+c),c=r.getX(2+c),p=new THREE.Vector3,f=new THREE.Vector3,m=new THREE.Vector3,h=(p.fromBufferAttribute(o,h),f.fromBufferAttribute(o,u),m.fromBufferAttribute(o,c),p.applyMatrix4(e.matrixWorld),f.applyMatrix4(e.matrixWorld),m.applyMatrix4(e.matrixWorld),new THREE.Triangle(p,f,m));if(h.containsPoint(t))return t;u=new THREE.Vector3;h.closestPointToPoint(t,u),t.distanceTo(u)<s&&(s=t.distanceTo(u),a=u.clone()),u=m=f=p=null}return a}},h.prototype.getLinePrecision=function(){var e=this.viewer.clientCoordToModelCoord([0,0]),e=new THREE.Vector3(e[0],e[1],e[2]),t=this.viewer.clientCoordToModelCoord([4,0]),t=new THREE.Vector3(t[0],t[1],t[2]);return e.distanceTo(t)},h.prototype.getUnitString=function(){var e="mm";if(this.viewer.modelUnit)switch(this.viewer.modelUnit.toLowerCase()){case"meter":e="m";break;case"centimeter":e="cm";break;case"millimeter":e="mm";break;case"inch":e="in";break;case"feet":e="ft"}return e},h.prototype.getUnitStringmap=function(e){var t="mm";if(e)switch(e.toLowerCase()){case"meter":t="m";break;case"centimeter":t="cm";break;case"millimeter":t="mm";break;case"inch":t="in";break;case"feet":t="ft"}return t},h.prototype.OperatorRelease=function(){this.OperatorEnd(),this.measureType="",this.OpMeasure.prompt&&(this.viewer.container.removeChild(this.OpMeasure.prompt),this.OpMeasure.prompt=null)},h.prototype.getViewClientCoords=function(e){var t=e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top;return e.srcElement&&e.srcElement!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),new THREE.Vector2(t,n)},h.prototype.isZero=function(e){return Math.abs(e)<1e-6},h.prototype.isPointBetweenIn=function(e,t,n){var i;return!!(e&&t&&n)&&(i=t.distanceTo(n),t=e.distanceTo(t),e=e.distanceTo(n),this.isZero(i-t-e))},h.prototype.getAngle=function(e,t,n){return e&&t&&n?(e=(new THREE.Vector3).subVectors(e,t),n=(new THREE.Vector3).subVectors(n,t),e.angleTo(n)):0},h.prototype.getBaceFaceDir=function(e){var t,n,i,r,o,a,s,l,d,c,h,u;return e?(t=new THREE.Vector3(0,0,1),n=new THREE.Vector3(0,0,-1),i=new THREE.Vector3(1,0,0),r=new THREE.Vector3(-1,0,0),o=new THREE.Vector3(0,1,0),a=new THREE.Vector3(0,-1,0),s=e.angleTo(t),l=e.angleTo(n),d=e.angleTo(i),c=e.angleTo(r),h=e.angleTo(o),e=e.angleTo(a),u=Math.min(s,l),u=Math.min(u,d),u=Math.min(u,c),u=Math.min(u,h),u=Math.min(u,e),Math.abs(s-u)<1e-6?t:Math.abs(l-u)<1e-6?n:Math.abs(d-u)<1e-6?i:Math.abs(c-u)<1e-6?r:Math.abs(h-u)<1e-6?o:a):new THREE.Vector3(0,0,1)},h.prototype.getProjectPntToPlane=function(e,t,n,i){t=(new THREE.Vector3).subVectors(t,e),n=(new THREE.Vector3).subVectors(n,e),t=(new THREE.Vector3).crossVectors(t,n);t.normalize();n=(new THREE.Vector3).subVectors(i,e).dot(t);return i.clone().sub(t.multiplyScalar(n))},h.prototype.getProjectPntToLine=function(e,t,n){return e.equals(t)?e.clone():((t=(new THREE.Vector3).subVectors(t,e)).normalize(),n=(new THREE.Vector3).subVectors(n,e),n=t.dot(n),e.clone().add(t.multiplyScalar(n)))},h.prototype.clientCoordToModelCoordOnPlane=function(e,t,n){e=[e,t,.99],t=this.viewer.clientCoordToModelCoord(e),t=new THREE.Vector3(t[0],t[1],t[2]),e[2]=-.99,e=this.viewer.clientCoordToModelCoord(e),e=new THREE.Vector3(e[0],e[1],e[2]);return this.intersectLine(t,e,n)},h.prototype.intersectLine=function(e,t,n){var i,r;return!(e&&t&&n)||(i=e.clone(),(e=(new THREE.Vector3).subVectors(t,e)).normalize(),r=e.dot(n.normal),Math.abs(r)<=1e-8)?null:(t=n.coplanarPoint(t.clone()),t=(new THREE.Vector3).subVectors(t,i).dot(n.normal)/r,i.add(e.multiplyScalar(t)))},h.prototype.createBoundingBox=function(e){var t=new Float32Array(24),e=(t[0]=e.max.x,t[1]=e.max.y,t[2]=e.max.z,t[3]=e.max.x,t[4]=e.max.y,t[5]=e.min.z,t[6]=e.min.x,t[7]=e.max.y,t[8]=e.min.z,t[9]=e.min.x,t[10]=e.max.y,t[11]=e.max.z,t[12]=e.max.x,t[13]=e.min.y,t[14]=e.max.z,t[15]=e.max.x,t[16]=e.min.y,t[17]=e.min.z,t[18]=e.min.x,t[19]=e.min.y,t[20]=e.min.z,t[21]=e.min.x,t[22]=e.min.y,t[23]=e.max.z,new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7])),n=new THREE.BufferGeometry;return n.setIndex(new THREE.BufferAttribute(e,1)),n.addAttribute("position",new THREE.BufferAttribute(t,3)),(e=new THREE.LineSegments(n,this.materialBoxLine)).objectType="BoundingBox",e},(ln.prototype=Object.create(h.prototype)).OperatorStart=function(e){switch(this.measureType=e,this.measureType){case"pt2pt":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT);break;case"PointToLine":case"PointToFace":case"AxisToPoint":this.OpMeasure.PostInfo(ve.INFOTYPE.POINT);break;case"pt2ptbim":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT);break;case"LineToLine":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTLINE);break;case"LineToFace":this.OpMeasure.PostInfo(ve.INFOTYPE.LINEPLANE);break;case"faceDist":this.OpMeasure.PostInfo(ve.INFOTYPE.PLANE);break;case"AxisToLine":this.OpMeasure.PostInfo(ve.INFOTYPE.AXISLINE);break;case"AxisToFace":this.OpMeasure.PostInfo(ve.INFOTYPE.AXISPLANE);break;case"holeDist":this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLE);break;case"bodyDistance":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRMEASUREBODY)}},ln.prototype.onNMouseMove=function(e,t){var n=new THREE.Vector3(e,t,0);if(this.OpMeasure.unsteady)this.changeMeasureDistance(n);else if(this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&!Se.isMobileDevice())this.createAndShowDistanceDimension(n);else{var i=[];switch(this.measureType){case"bodyDistance":i=4<this.viewer.brepManager.version?["point","line","plane","circle","cylinder","cone"]:["point","line","plane","circle","cylinder"];break;case"PointToLine":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"point"==this.distanceInfo.firstSelInfo.type&&(i=["line"]):i=["point"];break;case"PointToFace":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"point"==this.distanceInfo.firstSelInfo.type&&(i=["plane"]):i=["point"];break;case"holeDist":i=["circle","cylinder"];break;case"AxisToPoint":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"point"==this.distanceInfo.firstSelInfo.type&&(i=["circle","cylinder"]):i=["point"];break;case"LineToLine":i=["line"];break;case"LineToFace":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"line"==this.distanceInfo.firstSelInfo.type?i=["plane"]:"plane"==this.distanceInfo.firstSelInfo.type&&(i=["line"]):i=["line","plane"];break;case"faceDist":i=["plane"];break;case"AxisToLine":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"line"==this.distanceInfo.firstSelInfo.type?i=["circle","cylinder"]:"circle"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type||(i=["line"]):i=["line","circle","cylinder"];break;case"AxisToFace":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"plane"==this.distanceInfo.firstSelInfo.type?i=["circle","cylinder"]:"circle"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type||(i=["plane"]):i=["plane","circle","cylinder"];break;case"pt2pt":case"pt2ptbim":i=["point"];break;default:return}this.measureDistance(e,t,!0,i),this.updateMeasureDistanceScene("true")}},ln.prototype.onLMouseClick=function(e,t,n){var i=new THREE.Vector3(e,t,0);if(this.OpMeasure.PostInfo(),this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj)this.viewer.is2DModel?this.createAndShowDistanceDimension(i,!0):this.createAndShow3DDistanceDimension(i,!0),this.OperatorStart(this.measureType);else{var r=[];switch(this.measureType){case"bodyDistance":r=4<this.viewer.brepManager.version?["point","line","plane","circle","cylinder","cone"]:["point","line","plane","circle","cylinder"];break;case"PointToLine":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"point"==this.distanceInfo.firstSelInfo.type&&(r=["line"]):r=["point"];break;case"holeDist":r=["circle","cylinder"];break;case"PointToFace":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"point"==this.distanceInfo.firstSelInfo.type&&(r=["plane"]):r=["point"];break;case"AxisToPoint":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"point"==this.distanceInfo.firstSelInfo.type&&(r=["circle","cylinder"]):r=["point"];break;case"LineToLine":r=["line"];break;case"LineToFace":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"line"==this.distanceInfo.firstSelInfo.type?r=["plane"]:"plane"==this.distanceInfo.firstSelInfo.type&&(r=["line"]):r=["line","plane"];break;case"faceDist":r=["plane"];break;case"AxisToLine":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"line"==this.distanceInfo.firstSelInfo.type?r=["circle","cylinder"]:"circle"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type||(r=["line"]):r=["line","circle","cylinder"];break;case"AxisToFace":this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo?"plane"==this.distanceInfo.firstSelInfo.type?r=["circle","cylinder"]:"circle"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type||(r=["plane"]):r=["plane","circle","cylinder"];break;case"pt2pt":case"pt2ptbim":r=["point"]}switch(this.measureDistance(e,t,!1,r),this.updateMeasureDistanceScene("false"),this.measureType){case"pt2pt":case"pt2ptbim":this.distanceInfo.firstSelInfo&&"point"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDPOINT):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT);break;case"PointToLine":this.distanceInfo.firstSelInfo&&"point"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.LINE):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.POINT);break;case"PointToFace":this.distanceInfo.firstSelInfo&&"point"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN?this.OpMeasure.PostInfo(ve.INFOTYPE.PLANE):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.POINT);break;case"AxisToPoint":this.distanceInfo.firstSelInfo&&"point"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo?this.viewer.is2DModel?this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEA):this.OpMeasure.PostInfo(ve.INFOTYPE.AXIS):!this.distanceInfo.firstSelInfo||"circle"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type||this.distanceInfo.secondSelInfo?this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.POINT):this.OpMeasure.PostInfo(ve.INFOTYPE.POINT);break;case"LineToLine":this.distanceInfo.firstSelInfo&&!this.distanceInfo.secondSelInfo&&this.OpMeasure.InfoType!=ve.INFOTYPE.INTERSECT?this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDLINE):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.distanceInfo.secondSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTLINE);break;case"LineToFace":this.distanceInfo.firstSelInfo&&"plane"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo&&this.OpMeasure.InfoType!=ve.INFOTYPE.LINENOPARALLEL?this.OpMeasure.PostInfo(ve.INFOTYPE.PARALLELLINE):this.distanceInfo.firstSelInfo&&"line"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo&&ve.INFOTYPE.PLANENOPARALLEL!=this.OpMeasure.InfoType&&this.OpMeasure.InfoType!=ve.INFOTYPE.NOTFACEPARALLEL?this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPARALLELPLANE):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.LINEPLANE);break;case"faceDist":this.distanceInfo.firstSelInfo&&!this.distanceInfo.secondSelInfo&&this.OpMeasure.InfoType!=ve.INFOTYPE.PLANENOPARALLEL&&this.OpMeasure.InfoType!=ve.INFOTYPE.NOTFACEPARALLEL?this.OpMeasure.PostInfo(ve.INFOTYPE.PARALLELPLANE):this.distanceInfo.firstSelInfo?this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo&&this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.OpMeasure.PostInfo(ve.INFOTYPE.PLANE);break;case"AxisToLine":this.distanceInfo.firstSelInfo&&"line"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo?this.viewer.is2DModel?this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEA):this.OpMeasure.PostInfo(ve.INFOTYPE.AXIS):!this.distanceInfo.firstSelInfo||"circle"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type||this.distanceInfo.secondSelInfo?this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.AXISLINE):this.OpMeasure.PostInfo(ve.INFOTYPE.LINE);break;case"AxisToFace":this.distanceInfo.firstSelInfo&&"plane"==this.distanceInfo.firstSelInfo.type&&!this.distanceInfo.secondSelInfo&&ve.INFOTYPE.AXISNOPARALLEL!=this.OpMeasure.InfoType?this.OpMeasure.PostInfo(ve.INFOTYPE.AXIS):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.AXISPLANE),this.distanceInfo.firstSelInfo&&("circle"==this.distanceInfo.firstSelInfo.type||"cylinder"==this.distanceInfo.firstSelInfo.type)&&!this.distanceInfo.secondSelInfo&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN&&this.OpMeasure.PostInfo(ve.INFOTYPE.PARALLELPLANE);break;case"holeDist":this.distanceInfo.firstSelInfo&&!this.distanceInfo.secondSelInfo&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN?this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDCIRCLE):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLE);break;case"bodyDistance":this.distanceInfo.firstSelInfo&&!this.distanceInfo.secondSelInfo&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN?this.OpMeasure.PostInfo(ve.INFOTYPE.SECMEASUREBODY):this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.distanceInfo.firstSelInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.FIRMEASUREBODY)}}},ln.prototype.calculateDistanceFromPoint=function(e){var t,n=0;if("point"==e.firstSelInfo.type){if((n=e.firstSelInfo.point.distanceTo(e.secondSelInfo.point))<1e-10)return void(e.secondSelInfo=null);e.dimString=n.toFixed(2)}else"line"==e.firstSelInfo.type?(i=this.getLineStartEndPoints(e.firstSelInfo))&&(n=(t=new THREE.Line3(i.start,i.end).closestPointToPoint(e.secondSelInfo.point,!1)).distanceTo(e.secondSelInfo.point),e.dimString=n.toFixed(2),e.firstPoint=t):"circle"==e.firstSelInfo.type||"cylinder"==e.firstSelInfo.type||"cone"==e.firstSelInfo.type?"bodyDistance"==this.measureType&&"circle"==e.firstSelInfo.type?(i=this.getLineStartEndPoints(e.firstSelInfo))&&(n=e.secondSelInfo.point.distanceTo(i.start),e.dimString=n.toFixed(2),e.firstPoint=i.start):(i=this.getLineStartEndPoints(e.firstSelInfo))&&(n=(t=new THREE.Line3(i.start,i.end).closestPointToPoint(e.secondSelInfo.point,!1)).distanceTo(e.secondSelInfo.point),e.dimString=n.toFixed(2),e.firstPoint=t):"plane"==e.firstSelInfo.type&&((i=new THREE.Plane).setFromNormalAndCoplanarPoint(e.firstSelInfo.worldNormal,e.firstSelInfo.worldOrigin),t=new THREE.Vector3,i.projectPoint(e.secondSelInfo.point,t),n=t.distanceTo(e.secondSelInfo.point),e.dimString=n.toFixed(2),e.firstPoint=t);var i=this.viewer.getDispalyModelUnit(n=n<1&&.999999<n?1:n);n*=i.scale,e.unit=this.getUnitStringmap(i.unit),e.dimString=n.toFixed(2)},ln.prototype.measureDistance=function(e,t,n,i){""==this.distanceInfo.unit&&(this.distanceInfo.unit=this.getUnitString()),i=i||(this.viewer.is2DModel?["line","circle","point"]:["line","circle","cylinder","plane","point","cone"]);e=this.doRaycasterPick(e,t,!0);if(-1!=i.indexOf("point")&&n&&this.previewSnappedPoint2(e),null!=this.snappedPoint)this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null),n||(null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstSelInfo={type:"point",point:this.snappedPoint.clone()},this.distanceInfo.firstPoint=this.distanceInfo.firstSelInfo.point):"bodyDistance"==this.measureType&&"point"==this.distanceInfo.firstSelInfo.type&&this.isTwoPointTheSame(this.distanceInfo.firstSelInfo.point,this.snappedPoint)?(this.distanceInfo.firstSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null),this.distanceInfo.axisLineObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.axisLineObj),this.distanceInfo.axisLineObj=null)):(this.distanceInfo.secondSelInfo={type:"point",point:this.snappedPoint.clone()},this.distanceInfo.secondPoint=this.distanceInfo.secondSelInfo.point,this.calculateDistanceFromPoint(this.distanceInfo)),this.snappedPoint=null);else{t=this.viewer;if(e&&0!=e.length){var r=null;if(r=!t.ndsModel&&!(e[0].object instanceof THREE.Line||e[0].object instanceof THREE.LineSegments)&&1<e.length&&(e[1].object instanceof THREE.Line||e[1].object instanceof THREE.LineSegments)&&(M=Math.abs(e[1].distance-e[0].distance))<linePrecision?e[1]:e[0]){var o,a,t=null,e=(n||-1==i.indexOf("point")||(t=this.getSnappingPntEx(r)),this.getSelectInfoFromIntersect(r));if(e)if("bodyDistance"==this.measureType&&-1==i.indexOf(e.type))this.distanceInfo.preSelInfo=null,this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null);else if("line"!=e.type||this.Bline(e))if(1==n)-1==i.indexOf(e.type)?this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null):this.isTwoTopolInfoTheSame(this.distanceInfo.preSelInfo,e)||(this.distanceInfo.preSelInfo=e,this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null));else if(-1!=i.indexOf(e.type)||-1==i.indexOf("plane")||"cylinder"!==e.type&&"other"!==e.type&&"nurbs"!==e.type)if(this.OpMeasure.InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN&&(this.OpMeasure.InfoType=ve.INFOTYPE.MEASURENOTICEBEGIN),this.distanceInfo.preSelInfo=null,this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null),t)null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstSelInfo={type:"point",point:t},this.distanceInfo.firstPoint=this.distanceInfo.firstSelInfo.point):(this.distanceInfo.secondSelInfo={type:"point",point:t},this.distanceInfo.secondPoint=this.distanceInfo.secondSelInfo.point,this.calculateDistanceFromPoint(this.distanceInfo));else if(-1!=i.indexOf("point")&&-1==i.indexOf(e.type))a=e.intersect.clone(),null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstPoint=a,this.distanceInfo.firstSelInfo={type:"point",point:a}):(this.distanceInfo.secondSelInfo={type:"point",point:a},this.distanceInfo.secondPoint=this.distanceInfo.secondSelInfo.point,this.calculateDistanceFromPoint(this.distanceInfo));else if(this.distanceInfo.firstSelInfo){if(this.isTwoTopolInfoTheSame(this.distanceInfo.firstSelInfo,e))this.distanceInfo.firstSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null),this.distanceInfo.axisLineObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.axisLineObj),this.distanceInfo.axisLineObj=null);else if(-1!=i.indexOf(e.type)||-1!=i.indexOf("point")){if("line"==this.distanceInfo.firstSelInfo.type){var s=this.getLineStartEndPoints(this.distanceInfo.firstSelInfo);if("line"==e.type){var l=this.getLineStartEndPoints(e);if(s&&l){(g=(new THREE.Vector3).subVectors(s.end,s.start)).normalize();(y=(new THREE.Vector3).subVectors(l.end,l.start)).normalize();var d=g.dot(y);if(1-Math.abs(d)<1e-4){if((M=(E=new THREE.Line3(s.start,s.end).closestPointToPoint(l.start,!1)).distanceTo(l.start))<1e-5)return void this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.INTERSECT);this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondSelInfo=e,this.distanceInfo.firstPoint=E,this.distanceInfo.secondPoint=l.start.clone()}else{var c=l.start.clone().sub(s.start),h=Math.pow(g.clone().cross(y).length(),2),u=c.clone().cross(y).dot(g.clone().cross(y))/h,p=c.clone().cross(g).dot(g.clone().cross(y))/h,f=g.clone().multiplyScalar(u).add(s.start),m=y.clone().multiplyScalar(p).add(l.start);if((M=f.distanceTo(m))<1e-5)return void this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.INTERSECT);this.distanceInfo.secondSelInfo=e,this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=f,this.distanceInfo.secondPoint=m}}}else"plane"==e.type?((g=(new THREE.Vector3).subVectors(s.end,s.start)).normalize(),Math.abs(e.worldNormal.dot(g))<1e-5?(this.distanceInfo.secondSelInfo=e,(v=new THREE.Plane).setFromNormalAndCoplanarPoint(e.worldNormal,e.worldOrigin),A=new THREE.Vector3,v.projectPoint(s.start,A),M=A.distanceTo(s.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=s.start.clone(),this.distanceInfo.secondPoint=A):this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.PLANENOPARALLEL)):"circle"!=e.type&&"cylinder"!=e.type&&"cone"!=e.type||(l=this.getLineStartEndPoints(e),"bodyDistance"==this.measureType&&"circle"==e.type?s&&l&&(M=(E=new THREE.Line3(s.start,s.end).closestPointToPoint(l.start,!1)).distanceTo(l.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=E,this.distanceInfo.secondPoint=l.start.clone(),this.distanceInfo.secondSelInfo=e):s&&l&&((g=(new THREE.Vector3).subVectors(s.end,s.start)).normalize(),(y=(new THREE.Vector3).subVectors(l.end,l.start)).normalize(),d=g.dot(y),1-Math.abs(d)<1e-4?(this.distanceInfo.secondSelInfo=e,M=(E=new THREE.Line3(s.start,s.end).closestPointToPoint(l.start,!1)).distanceTo(l.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=E,this.distanceInfo.secondPoint=l.start.clone()):(c=l.start.clone().sub(s.start),h=Math.pow(g.clone().cross(y).length(),2),u=c.clone().cross(y).dot(g.clone().cross(y))/h,p=c.clone().cross(g).dot(g.clone().cross(y))/h,f=g.clone().multiplyScalar(u).add(s.start),m=y.clone().multiplyScalar(p).add(l.start),M=f.distanceTo(m),this.distanceInfo.secondSelInfo=e,this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=f,this.distanceInfo.secondPoint=m)))}else if("point"==this.distanceInfo.firstSelInfo.type||"bodyDistance"==this.measureType&&"circle"==this.distanceInfo.firstSelInfo.type)"bodyDistance"==this.measureType&&"circle"==this.distanceInfo.firstSelInfo.type?(s=this.getLineStartEndPoints(this.distanceInfo.firstSelInfo),this.distanceInfo.firstPoint=s.start.clone()):this.distanceInfo.firstPoint=this.distanceInfo.firstSelInfo.point,"line"==(this.distanceInfo.secondSelInfo=e).type?(s=this.getLineStartEndPoints(e))&&(M=(E=new THREE.Line3(s.start,s.end).closestPointToPoint(this.distanceInfo.firstPoint,!1)).distanceTo(this.distanceInfo.firstPoint),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondPoint=E):"plane"==e.type?((v=new THREE.Plane).setFromNormalAndCoplanarPoint(e.worldNormal,e.worldOrigin),A=new THREE.Vector3,v.projectPoint(this.distanceInfo.firstPoint,A),M=A.distanceTo(this.distanceInfo.firstPoint),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondPoint=A):"circle"!=e.type&&"cylinder"!=e.type&&"cone"!=e.type||("bodyDistance"==this.measureType&&"circle"==e.type?(s=this.getLineStartEndPoints(e))&&(M=s.start.distanceTo(this.distanceInfo.firstPoint),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondPoint=s.start.clone()):(s=this.getLineStartEndPoints(e))&&(M=(E=new THREE.Line3(s.start,s.end).closestPointToPoint(this.distanceInfo.firstPoint,!1)).distanceTo(this.distanceInfo.firstPoint),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondPoint=E));else if("plane"==this.distanceInfo.firstSelInfo.type)"line"==e.type?(s=this.getLineStartEndPoints(e))&&((g=(new THREE.Vector3).subVectors(s.end,s.start)).normalize(),Math.abs(this.distanceInfo.firstSelInfo.worldNormal.dot(g))<1e-5?((v=new THREE.Plane).setFromNormalAndCoplanarPoint(this.distanceInfo.firstSelInfo.worldNormal,this.distanceInfo.firstSelInfo.worldOrigin),A=new THREE.Vector3,v.projectPoint(s.start,A),M=A.distanceTo(s.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondSelInfo=e,this.distanceInfo.firstPoint=A,this.distanceInfo.secondPoint=s.start.clone()):this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.LINENOPARALLEL)):"plane"==e.type?(o=this.distanceInfo.firstSelInfo.worldNormal,w=e.worldNormal.clone(),o.normalize(),w.normalize(),o=Math.abs(o.dot(w)),Math.abs(o-1)<1e-5?(this.distanceInfo.secondSelInfo=e,this.distanceInfo.firstPoint=this.distanceInfo.firstSelInfo.intersect,(v=new THREE.Plane).setFromNormalAndCoplanarPoint(e.worldNormal,e.worldOrigin),A=new THREE.Vector3,v.projectPoint(this.distanceInfo.firstPoint,A),M=A.distanceTo(this.distanceInfo.firstPoint),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondPoint=A):this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.PLANENOPARALLEL)):"circle"!=e.type&&"cylinder"!=e.type&&"cone"!=e.type||(s=this.getLineStartEndPoints(e),"bodyDistance"==this.measureType&&"circle"==e.type?s&&((v=new THREE.Plane).setFromNormalAndCoplanarPoint(this.distanceInfo.firstSelInfo.worldNormal,this.distanceInfo.firstSelInfo.worldOrigin),A=new THREE.Vector3,v.projectPoint(s.start,A),M=A.distanceTo(s.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=A,this.distanceInfo.secondPoint=s.start.clone(),this.distanceInfo.secondSelInfo=e):s&&((g=(new THREE.Vector3).subVectors(s.end,s.start)).normalize(),Math.abs(this.distanceInfo.firstSelInfo.worldNormal.dot(g))<1e-5?(this.distanceInfo.secondSelInfo=e,(v=new THREE.Plane).setFromNormalAndCoplanarPoint(this.distanceInfo.firstSelInfo.worldNormal,this.distanceInfo.firstSelInfo.worldOrigin),A=new THREE.Vector3,v.projectPoint(s.start,A),M=A.distanceTo(s.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=A,this.distanceInfo.secondPoint=s.start.clone()):this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.AXISNOPARALLEL)));else if("circle"==this.distanceInfo.firstSelInfo.type||"cylinder"==this.distanceInfo.firstSelInfo.type||"cone"==this.distanceInfo.firstSelInfo.type){var g,v,A,s=this.getLineStartEndPoints(this.distanceInfo.firstSelInfo),l=this.getLineStartEndPoints(e);if("line"==e.type||"circle"==e.type||"cylinder"==e.type||"cone"==e.type){if("bodyDistance"==this.measureType&&"circle"==e.type)s&&l&&(M=(E=new THREE.Line3(s.start,s.end).closestPointToPoint(l.start,!1)).distanceTo(l.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondSelInfo=e,this.distanceInfo.firstPoint=E,this.distanceInfo.secondPoint=l.start.clone());else if(s&&l){(g=(new THREE.Vector3).subVectors(s.end,s.start)).normalize();(y=(new THREE.Vector3).subVectors(l.end,l.start)).normalize();var y,d=g.dot(y);if(1-Math.abs(d)<1e-4){this.distanceInfo.secondSelInfo=e;var E,M=(E=new THREE.Line3(s.start,s.end).closestPointToPoint(l.start,!1)).distanceTo(l.start);this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=E,this.distanceInfo.secondPoint=l.start.clone()}else{if("bodyDistance"==this.measureType&&("line"==e.type||"cylinder"==e.type||"cone"==e.type)){c=l.start.clone().sub(s.start),h=Math.pow(g.clone().cross(y).length(),2),u=c.clone().cross(y).dot(g.clone().cross(y))/h,p=c.clone().cross(g).dot(g.clone().cross(y))/h,f=g.clone().multiplyScalar(u).add(s.start),m=y.clone().multiplyScalar(p).add(l.start);if((M=f.distanceTo(m))<1e-5)return void this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.INTERSECT);this.distanceInfo.secondSelInfo=e,this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=f,this.distanceInfo.secondPoint=m}if("circle"==e.type||"cylinder"==e.type||"cone"==e.type)return void this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.TWOAXISNOPARALLEL);c=l.start.clone().sub(s.start),h=Math.pow(g.clone().cross(y).length(),2),u=c.clone().cross(y).dot(g.clone().cross(y))/h,p=c.clone().cross(g).dot(g.clone().cross(y))/h,f=g.clone().multiplyScalar(u).add(s.start),m=y.clone().multiplyScalar(p).add(l.start);M=f.distanceTo(m),this.distanceInfo.secondSelInfo=e,this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.firstPoint=f,this.distanceInfo.secondPoint=m}}}else"plane"==e.type&&((g=(new THREE.Vector3).subVectors(s.end,s.start)).normalize(),Math.abs(e.worldNormal.dot(g))<1e-4?((v=new THREE.Plane).setFromNormalAndCoplanarPoint(e.worldNormal,e.worldOrigin),A=new THREE.Vector3,v.projectPoint(s.start,A),M=A.distanceTo(s.start),this.distanceInfo.dimString=M.toFixed(2),this.distanceInfo.secondSelInfo=e,this.distanceInfo.firstPoint=s.start.clone(),this.distanceInfo.secondPoint=A):this.OpMeasure.PostInfo("bodyDistance"==this.measureType?ve.INFOTYPE.TWOBODYNOTPARALLEL:ve.INFOTYPE.PLANENOPARALLEL))}var w=this.viewer.getDispalyModelUnit(M=M<1&&.999999<M?1:M);M*=w.scale,this.distanceInfo.unit=this.getUnitStringmap(w.unit),this.distanceInfo.dimString=M.toFixed(2)}}else-1==i.indexOf(e.type)&&-1==i.indexOf("point")||(this.distanceInfo.firstSelInfo=e);else this.OpMeasure.PostInfo(ve.INFOTYPE.NOTFACEPARALLEL),this.distanceInfo.firstSelInfo&&this.isTwoTopolInfoTheSame(this.distanceInfo.firstSelInfo,e)&&(this.distanceInfo.firstSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null),this.distanceInfo.axisLineObj)&&(this.OpMeasure.rootObject.remove(this.distanceInfo.axisLineObj),this.distanceInfo.axisLineObj=null);else this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null);else n||(t?null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstSelInfo={type:"point",point:t},this.distanceInfo.firstPoint=this.distanceInfo.firstSelInfo.point):(this.distanceInfo.secondSelInfo={type:"point",point:t},this.distanceInfo.secondPoint=this.distanceInfo.secondSelInfo.point,this.calculateDistanceFromPoint(this.distanceInfo)):-1!=i.indexOf("point")&&(a=r.point,null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstPoint=a,this.distanceInfo.firstSelInfo={type:"point",point:a}):(this.distanceInfo.secondSelInfo={type:"point",point:a},this.distanceInfo.secondPoint=this.distanceInfo.secondSelInfo.point,this.calculateDistanceFromPoint(this.distanceInfo))))}}else this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null)}},ln.prototype.updateMeasureDistanceScene=function(e){var t;this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj?this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null):!(!e||"true"!==e.toLowerCase())?this.distanceInfo.preSelInfo&&!this.distanceInfo.preSelObj&&("line"==this.distanceInfo.preSelInfo.type||"circle"==this.distanceInfo.preSelInfo.type?(this.viewer.is2DModel,(t=this.createLine(this.distanceInfo.preSelInfo,!(t=null)))&&(this.OpMeasure.rootObject.add(t),this.distanceInfo.preSelObj=t)):"plane"!=this.distanceInfo.preSelInfo.type&&"cylinder"!=this.distanceInfo.preSelInfo.type&&"cone"!=this.distanceInfo.preSelInfo.type||(t=this.createFace(this.distanceInfo.preSelInfo,!0))&&((e=[]).push(t),this.viewer.outlinePass&&this.viewer.outlinePass.enabled&&(this.viewer.outlinePass.tempSelectedObjects=e),this.OpMeasure.rootObject.add(t),this.distanceInfo.preSelObj=t)):(this.distanceInfo.firstSelInfo&&!this.distanceInfo.firstSelObj&&(this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null),t=null,"point"==this.distanceInfo.firstSelInfo.type?t=this.createPointMesh(this.distanceInfo.firstSelInfo.point,this.materialPoint,this.POINTSIZE):"line"==this.distanceInfo.firstSelInfo.type||"circle"==this.distanceInfo.firstSelInfo.type?t=this.createLine(this.distanceInfo.firstSelInfo,!1):"plane"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type&&"cone"!=this.distanceInfo.firstSelInfo.type||(t=this.createFace(this.distanceInfo.firstSelInfo,!1),"cylinder"!=this.distanceInfo.firstSelInfo.type&&"cone"!=this.distanceInfo.firstSelInfo.type)||(this.distanceInfo.axisLineObj=this.createAxisLine(this.distanceInfo.firstSelInfo),this.OpMeasure.rootObject.add(this.distanceInfo.axisLineObj)),t)&&(this.OpMeasure.rootObject.add(t),this.distanceInfo.firstSelObj=t),this.distanceInfo.secondSelInfo&&!this.distanceInfo.secondSelObj&&(this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null),t=null,"point"==this.distanceInfo.secondSelInfo.type?t=this.createPointMesh(this.distanceInfo.secondSelInfo.point,this.materialPoint,this.POINTSIZE):"line"==this.distanceInfo.secondSelInfo.type||"circle"==this.distanceInfo.secondSelInfo.type?t=this.createLine(this.distanceInfo.secondSelInfo,!1):"plane"!=this.distanceInfo.secondSelInfo.type&&"cylinder"!=this.distanceInfo.secondSelInfo.type&&"cone"!=this.distanceInfo.secondSelInfo.type||(t=this.createFace(this.distanceInfo.secondSelInfo,!1),"cylinder"!=this.distanceInfo.secondSelInfo.type&&"cone"!=this.distanceInfo.secondSelInfo.type)||(this.distanceInfo.secaxisLineObj=this.createAxisLine(this.distanceInfo.secondSelInfo),this.OpMeasure.rootObject.add(this.distanceInfo.secaxisLineObj)),t)&&(this.OpMeasure.rootObject.add(t),this.distanceInfo.secondSelObj=t),this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&(_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes(),this.viewer.is2DModel?this.createAndShowDistanceDimension():(this.createAndShow3DDistanceDimension(null,!0),this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.OpMeasure.rootObject.remove(this.distanceInfo.secondSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null,this.distanceInfo.secondSelInfo=null)))},(dn.prototype=Object.create(h.prototype)).OperatorStart=function(e){this.measureType=e,"radius"!==this.measureType||Se.isMobileDevice()||this.OpMeasure.PostInfo(ve.INFOTYPE.MEASUREBODY)},dn.prototype.onNMouseMove=function(e,t){var n=new THREE.Vector3(e,t,0);this.OpMeasure.unsteady?this.changeRadius(n):"radius"==this.measureType&&(this.holeInfo.firstSelHoleObj&&!Se.isMobileDevice()?this.createAndShowMeasureRadiusAndDiameterDimension(n):(this.measureRadiusAndDiameter(e,t,!0),this.updateMeasureRadiusAndDiameterScene("true",n)))},dn.prototype.onLMouseClick=function(e,t,n){var i=new THREE.Vector3(e,t,0);"radius"==this.measureType&&(this.holeInfo.firstSelHoleObj?(this.viewer.is2DModel?this.createAndShowMeasureRadiusAndDiameterDimension(i,!0):this.createAndShowMeasure3DRadiusAndDiameterDimension(i,!0),this.holeInfo.firstSelHoleObj||Se.isMobileDevice()||this.OpMeasure.PostInfo(ve.INFOTYPE.MEASUREBODY)):(this.measureRadiusAndDiameter(e,t,!1),this.updateMeasureRadiusAndDiameterScene("false",i),this.holeInfo.firstSelHoleObj&&!Se.isMobileDevice()&&this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE)))},dn.prototype.getCylinderOrigin=function(e){var t=e.geometry,n=e.indexRange.concat(),i=(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/3,n[1]+=t.drawRange.start/3),t.index),t=t.attributes.position,r=i.getX(3*n[0]),o=i.getX(3*n[0]+1),i=i.getX(3*n[0]+2),n=new THREE.Vector3,a=new THREE.Vector3,s=new THREE.Vector3,r=(n.fromBufferAttribute(t,r),a.fromBufferAttribute(t,o),s.fromBufferAttribute(t,i),new THREE.Vector3(e.origin[0],e.origin[1],e.origin[2])),o=new THREE.Vector3(e.axis[0],e.axis[1],e.axis[2]),t=(new THREE.Vector3).addVectors(r,o),i=this.getProjectPntToLine(r,t,n),e=i.distanceTo(r),o=this.getProjectPntToLine(r,t,a),n=o.distanceTo(r),a=this.getProjectPntToLine(r,t,s),t=a.distanceTo(r);return e<=n&&e<=t?i:n<=e&&n<=t?o:a},dn.prototype.getHoleAxisAndCenter=function(e){var t=new THREE.Vector3,n=new THREE.Quaternion,i=new THREE.Vector3;if(e.matrixWorld.decompose(t,n,i),"cylinder"==e.type)return(t=this.getCylinderOrigin(e)).applyMatrix4(e.matrixWorld),(a=new THREE.Vector3(e.axis[0],e.axis[1],e.axis[2])).applyQuaternion(n),a.normalize(),{center:t,axis:a};if("circle"==e.type){var r,o,a,i=new THREE.Vector3(e.center[0],e.center[1],e.center[2]),t=e.geometry,s=e.indexRange.concat(),l=(this.viewer.ndsModel&&(s[0]+=t.drawRange.start/2,s[1]+=t.drawRange.start/2),(s[0]+s[1])/2),d=(l-1>s[0]&&l--,t.index),t=t.attributes.position.array;if(null!=d)return d=d.array,r=new THREE.Vector3,o=new THREE.Vector3,r.fromArray(t,3*d[2*s[0]]),o.fromArray(t,3*d[2*l]),s=(new THREE.Vector3).subVectors(r,i),t=(new THREE.Vector3).subVectors(o,i),a=(new THREE.Vector3).crossVectors(s,t),i.applyMatrix4(e.matrixWorld),a.applyQuaternion(n),a.normalize(),{center:i,axis:a}}return null},dn.prototype.measureRadiusAndDiameter=function(e,t,n){if(""==this.holeInfo.unit&&(this.holeInfo.unit=this.getUnitString()),this.holeInfo.firstSelHoleObj)this.holeInfo.preSelHoleObj&&(this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.holeInfo.preSelHoleObj=null,this.holeInfo.preSelHoleInfo=null);else{var i=this.viewer,e=this.doRaycasterPick(e,t,!0);if(e&&0!=e.length){if(0<e.length){t=null;if(i.ndsModel||e[0].object instanceof THREE.Line||e[0].object instanceof THREE.LineSegments?t=e[0]:1<e.length&&(e[1].object instanceof THREE.Line||e[1].object instanceof THREE.LineSegments)&&Math.abs(e[1].distance-e[0].distance)<(i=this.viewer.controls.getBoundingBox()).min.distanceTo(i.max)/1e3&&(t=e[1]),t){i=this.getSelectInfoFromIntersect(t);if(!i||"cylinder"!=i.type&&"circle"!=i.type)return this.holeInfo.preSelHoleInfo=i,void(this.holeInfo.preSelHoleObj&&(this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.holeInfo.preSelHoleObj=null));if(i)return void(1==n?this.isTwoTopolInfoTheSame(this.holeInfo.preSelHoleInfo,i)||(this.holeInfo.preSelHoleInfo=i,this.holeInfo.preSelHoleObj&&(this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.holeInfo.preSelHoleObj=null)):(this.holeInfo.firstHoleInfo=i,e=this.getHoleAxisAndCenter(i),this.holeInfo.firstHoleInfo.worldCenter=e.center,this.holeInfo.firstHoleInfo.worldAxis=e.axis,t="radius"==this.measureType?i.radius:2*i.radius,e=this.viewer.getDispalyModelUnit(t=t<1&&.999999<t?1:t),t*=e.scale,this.holeInfo.dimString=(parseInt(t*Math.pow(10,2)+.5)/Math.pow(10,2)).toFixed(2),this.holeInfo.unit=this.getUnitStringmap(e.unit),"radius"==this.measureType?this.holeInfo.dimString="R "+this.holeInfo.dimString:this.holeInfo.dimString="Φ "+this.holeInfo.dimString))}}1==n&&this.holeInfo.preSelHoleInfo&&(this.holeInfo.preSelHoleInfo=null,this.holeInfo.preSelHoleObj)&&(this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.holeInfo.preSelHoleObj=null)}else this.holeInfo.preSelHoleObj&&(this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.holeInfo.preSelHoleObj=null,this.holeInfo.preSelHoleInfo=null)}},dn.prototype.updateMeasureRadiusAndDiameterScene=function(e,t){var n;"radius"!==this.measureType&&"diameter"!=this.measureType||(this.holeInfo.firstSelHoleObj?this.holeInfo.preSelHoleObj&&(this.OpMeasure.rootObject.remove(this.holeInfo.preSelHoleObj),this.holeInfo.preSelHoleObj=null,this.holeInfo.preSelHoleInfo=null):!(!e||"true"!==e.toLowerCase())?this.holeInfo.preSelHoleInfo&&!this.holeInfo.preSelHoleObj&&("cylinder"==this.holeInfo.preSelHoleInfo.type?(n=this.createFace(this.holeInfo.preSelHoleInfo,!0))&&((e=[]).push(n),this.viewer.outlinePass&&this.viewer.outlinePass.enabled&&(this.viewer.outlinePass.tempSelectedObjects=e),this.OpMeasure.rootObject.add(n),this.holeInfo.preSelHoleObj=n):"circle"==this.holeInfo.preSelHoleInfo.type&&(n=this.createLine(this.holeInfo.preSelHoleInfo,!0))&&(this.OpMeasure.rootObject.add(n),this.holeInfo.preSelHoleObj=n)):(this.holeInfo.firstHoleInfo&&!this.holeInfo.firstSelHoleObj&&(n=null,"cylinder"==this.holeInfo.firstHoleInfo.type?n=this.createFace(this.holeInfo.firstHoleInfo,!1):"circle"==this.holeInfo.firstHoleInfo.type&&(n=this.createLine(this.holeInfo.firstHoleInfo,!1)),n)&&(this.OpMeasure.rootObject.add(n),this.holeInfo.firstSelHoleObj=n),this.holeInfo.firstSelHoleObj&&(_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes(),this.viewer.is2DModel?this.createAndShowMeasureRadiusAndDiameterDimension(t):this.createAndShowMeasure3DRadiusAndDiameterDimension(t,!0))))},dn.prototype.createAndShowMeasureRadiusAndDiameterDimension=function(e,t){var n,i,r,o;"radius"!=this.measureType&&"diameter"!=this.measureType||this.holeInfo.firstHoleInfo&&this.holeInfo.firstSelHoleObj&&(this.holeInfo.selLineCenterPos||(this.holeInfo.selLineCenterPos=this.holeInfo.firstHoleInfo.worldCenter.clone()),this.holeInfo.textPos?e&&((o=new THREE.Plane).setFromNormalAndCoplanarPoint(this.holeInfo.firstHoleInfo.worldAxis,this.holeInfo.firstHoleInfo.worldCenter),r=this.clientCoordToModelCoordOnPlane(e.x,e.y,o))&&this.holeInfo.textPos.copy(r):((o=new THREE.Plane).setFromNormalAndCoplanarPoint(this.holeInfo.firstHoleInfo.worldAxis,this.holeInfo.firstHoleInfo.worldCenter),(r=this.clientCoordToModelCoordOnPlane(e.x,e.y,o))?this.holeInfo.textPos=r:((e=(new THREE.Vector3).subVectors(this.holeInfo.firstHoleInfo.intersect,this.holeInfo.firstHoleInfo.worldCenter)).projectOnPlane(this.holeInfo.firstHoleInfo.worldAxis),this.holeInfo.textPos=(new THREE.Vector3).addVectors(this.holeInfo.firstHoleInfo.worldCenter,e))),(o=(new THREE.Vector3).subVectors(this.holeInfo.textPos,this.holeInfo.selLineCenterPos)).normalize(),this.holeInfo.fstClnd?(this.OpMeasure.rootObject.remove(this.holeInfo.fstClnd),this.holeInfo.fstClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(this.holeInfo.firstHoleInfo.radius)),this.holeInfo.sndClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(-this.holeInfo.firstHoleInfo.radius)),r=this.isPointBetweenIn(this.holeInfo.textPos,this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos),this.holeInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.holeInfo.fstClnd),this.holeInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.holeInfo.sndClnd),r?(this.holeInfo.fstClnd=this.createCylinderMesh(this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos,this.materialLine),i=this.OpMeasure.getScale(this.holeInfo.fstClnd,this.CYLINDERWIDTH),(n=o.clone()).multiplyScalar(.5*this.holeInfo.fstClnd.geometry.parameters.height),this.holeInfo.fstClnd.oldPosition=this.holeInfo.fstClndPos.clone(),this.holeInfo.fstClnd.offsetPos=n.clone().multiplyScalar(-1),this.holeInfo.fstClnd.position.subVectors(this.holeInfo.fstClndPos,n.clone().multiplyScalar(i)),"diameter"==this.measureType&&(this.holeInfo.sndClnd=this.createCylinderMesh(this.holeInfo.selLineCenterPos,this.holeInfo.sndClndPos,this.materialLine),i=this.OpMeasure.getScale(this.holeInfo.sndClnd,this.CYLINDERWIDTH),this.holeInfo.sndClnd.oldPosition=this.holeInfo.sndClndPos.clone(),this.holeInfo.sndClnd.offsetPos=n.clone(),this.holeInfo.sndClnd.position.addVectors(this.holeInfo.sndClndPos,n.clone().multiplyScalar(i)))):(this.holeInfo.fstClnd=this.createCylinderMesh(this.holeInfo.fstClndPos,this.holeInfo.selLineCenterPos,this.materialLine),i=this.OpMeasure.getScale(this.holeInfo.fstClnd,this.CYLINDERWIDTH),(n=o.clone()).multiplyScalar(.5*this.holeInfo.fstClnd.geometry.parameters.height),this.holeInfo.fstClnd.oldPosition=this.holeInfo.fstClndPos.clone(),this.holeInfo.fstClnd.offsetPos=n.clone(),this.holeInfo.fstClnd.position.addVectors(this.holeInfo.fstClndPos,n.clone().multiplyScalar(i)),"diameter"==this.measureType&&(this.holeInfo.sndClnd=this.createCylinderMesh(this.holeInfo.sndClndPos,this.holeInfo.selLineCenterPos,this.materialLine),i=this.OpMeasure.getScale(this.holeInfo.sndClnd,this.CYLINDERWIDTH),this.holeInfo.sndClnd.oldPosition=this.holeInfo.sndClndPos.clone(),this.holeInfo.sndClnd.offsetPos=n.clone().multiplyScalar(-1),this.holeInfo.sndClnd.position.subVectors(this.holeInfo.sndClndPos,n.clone().multiplyScalar(i)))),this.OpMeasure.rootObject.add(this.holeInfo.fstClnd),"diameter"==this.measureType&&this.holeInfo.sndClnd&&this.OpMeasure.rootObject.add(this.holeInfo.sndClnd)):(this.holeInfo.fstClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(this.holeInfo.firstHoleInfo.radius)),this.holeInfo.sndClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(-this.holeInfo.firstHoleInfo.radius)),this.holeInfo.fstClnd=this.createCylinderMesh(this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos,this.materialLine),i=this.OpMeasure.getScale(this.holeInfo.fstClnd,this.CYLINDERWIDTH),(n=o.clone()).multiplyScalar(.5*this.holeInfo.fstClnd.geometry.parameters.height),this.holeInfo.fstClnd.oldPosition=this.holeInfo.fstClndPos.clone(),this.holeInfo.fstClnd.offsetPos=n.clone().multiplyScalar(-1),this.holeInfo.fstClnd.position.subVectors(this.holeInfo.fstClndPos,n.clone().multiplyScalar(i)),this.OpMeasure.rootObject.add(this.holeInfo.fstClnd),"diameter"==this.measureType&&(this.holeInfo.sndClnd=this.createCylinderMesh(this.holeInfo.selLineCenterPos,this.holeInfo.sndClndPos,this.materialLine),i=this.OpMeasure.getScale(this.holeInfo.sndClnd,ve.INFOTYPE.CYLINDERWIDTH),this.holeInfo.sndClnd.oldPosition=this.holeInfo.sndClndPos.clone(),this.holeInfo.sndClnd.offsetPos=n.clone(),this.holeInfo.sndClnd.position.addVectors(this.holeInfo.sndClndPos,n.clone().multiplyScalar(i)),this.OpMeasure.rootObject.add(this.holeInfo.sndClnd))),this.holeInfo.centerToClndLine&&this.OpMeasure.rootObject.remove(this.holeInfo.centerToClndLine),this.holeInfo.centerToClndLine=this.createLineMesh2(this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.holeInfo.centerToClndLine),this.holeInfo.centerToClndLine2&&this.OpMeasure.rootObject.remove(this.holeInfo.centerToClndLine2),"diameter"==this.measureType&&(this.holeInfo.centerToClndLine2=this.createLineMesh2(this.holeInfo.selLineCenterPos,this.holeInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.holeInfo.centerToClndLine2)),e=this.holeInfo.dimString.slice(0,2)+(this.holeInfo.dimString.slice(2)*this.viewer.measuringScale).toFixed(2)+this.holeInfo.unit,this.holeInfo.textBox||(this.holeInfo.textBox=document.createElement("div"),this.holeInfo.textBox.className="mearesult",this.viewer.container.appendChild(this.holeInfo.textBox)),this.getAndShowTextBox(this.holeInfo.textPos.clone(),e,this.holeInfo.textBox),1==t)&&((r={}).start=this.holeInfo.textPos.clone(),r.end=this.holeInfo.fstClndPos.clone(),this.OpMeasure.textLines.push(r),(o={}).dimString=e,o.textPos=this.holeInfo.textPos.clone(),o.textBox=this.holeInfo.textBox,o.textBox.setAttribute("type","radius"),o.textBox.setAttribute("dimString",this.holeInfo.dimString),o.textBox.setAttribute("unit",this.holeInfo.unit),o.textBox.setAttribute("lineInfo",this.OpMeasure.textLines.length-1),this.OpMeasure.boxInfos.push(o),this.clearHoleInfo(!0),Se.isMobileDevice())&&this.ChangeMeasureFlag()},dn.prototype.createAndShowMeasure3DRadiusAndDiameterDimension=function(e,t){var n,i,r,o;"radius"!=this.measureType&&"diameter"!=this.measureType||this.holeInfo.firstHoleInfo&&this.holeInfo.firstSelHoleObj&&(this.holeInfo.selLineCenterPos||(this.holeInfo.selLineCenterPos=this.holeInfo.firstHoleInfo.worldCenter.clone()),this.holeInfo.textPos?e&&((o=new THREE.Plane).setFromNormalAndCoplanarPoint(this.holeInfo.firstHoleInfo.worldAxis,this.holeInfo.firstHoleInfo.worldCenter),n=this.clientCoordToModelCoordOnPlane(e.x,e.y,o))&&this.holeInfo.textPos.copy(n):((o=new THREE.Plane).setFromNormalAndCoplanarPoint(this.holeInfo.firstHoleInfo.worldAxis,this.holeInfo.firstHoleInfo.worldCenter),(n=this.clientCoordToModelCoordOnPlane(e.x,e.y,o))?this.holeInfo.textPos=n:((e=(new THREE.Vector3).subVectors(this.holeInfo.firstHoleInfo.intersect,this.holeInfo.firstHoleInfo.worldCenter)).projectOnPlane(this.holeInfo.firstHoleInfo.worldAxis),this.holeInfo.textPos=(new THREE.Vector3).addVectors(this.holeInfo.firstHoleInfo.worldCenter,e))),(o=(new THREE.Vector3).subVectors(this.holeInfo.textPos,this.holeInfo.selLineCenterPos)).normalize(),this.holeInfo.fstClnd?(this.holeInfo.fstClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(this.holeInfo.firstHoleInfo.radius)),this.holeInfo.sndClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(-this.holeInfo.firstHoleInfo.radius)),this.isPointBetweenIn(this.holeInfo.textPos,this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos)?(this.holeInfo.fstClnd=this.createCylinderMesh(this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos,this.appmaterialLine),r=this.OpMeasure.getScale(this.holeInfo.fstClnd,this.CYLINDERWIDTH),(i=o.clone()).multiplyScalar(.5*this.holeInfo.fstClnd.geometry.parameters.height),this.holeInfo.fstClnd.oldPosition=this.holeInfo.fstClndPos.clone(),this.holeInfo.fstClnd.offsetPos=i.clone().multiplyScalar(-1),this.holeInfo.fstClnd.position.subVectors(this.holeInfo.fstClndPos,i.clone().multiplyScalar(r))):(this.holeInfo.fstClnd=this.createCylinderMesh(this.holeInfo.fstClndPos,this.holeInfo.selLineCenterPos,this.appmaterialLine),r=this.OpMeasure.getScale(this.holeInfo.fstClnd,this.CYLINDERWIDTH),(i=o.clone()).multiplyScalar(.5*this.holeInfo.fstClnd.geometry.parameters.height),this.holeInfo.fstClnd.oldPosition=this.holeInfo.fstClndPos.clone(),this.holeInfo.fstClnd.offsetPos=i.clone(),this.holeInfo.fstClnd.position.addVectors(this.holeInfo.fstClndPos,i.clone().multiplyScalar(r)))):(this.holeInfo.fstClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(this.holeInfo.firstHoleInfo.radius)),this.holeInfo.sndClndPos=this.holeInfo.selLineCenterPos.clone().add(o.clone().multiplyScalar(-this.holeInfo.firstHoleInfo.radius)),this.holeInfo.fstClnd=this.createCylinderMesh(this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos,this.appmaterialLine),r=this.OpMeasure.getScale(this.holeInfo.fstClnd,this.CYLINDERWIDTH),(i=o.clone()).multiplyScalar(.5*this.holeInfo.fstClnd.geometry.parameters.height),this.holeInfo.fstClnd.oldPosition=this.holeInfo.fstClndPos.clone(),this.holeInfo.fstClnd.offsetPos=i.clone().multiplyScalar(-1),this.holeInfo.fstClnd.position.subVectors(this.holeInfo.fstClndPos,i.clone().multiplyScalar(r)),"diameter"==this.measureType&&(this.holeInfo.sndClnd=this.createCylinderMesh(this.holeInfo.selLineCenterPos,this.holeInfo.sndClndPos,this.appmaterialLine),r=this.OpMeasure.getScale(this.holeInfo.sndClnd,ve.INFOTYPE.CYLINDERWIDTH),this.holeInfo.sndClnd.oldPosition=this.holeInfo.sndClndPos.clone(),this.holeInfo.sndClnd.offsetPos=i.clone(),this.holeInfo.sndClnd.position.addVectors(this.holeInfo.sndClndPos,i.clone().multiplyScalar(r)))),this.holeInfo.centerToClndLine=this.createLineMesh2(this.holeInfo.selLineCenterPos,this.holeInfo.fstClndPos,this.appmaterialLine,1),n=this.holeInfo.dimString.slice(0,2)+(this.holeInfo.dimString.slice(2)*this.viewer.measuringScale).toFixed(2)+this.holeInfo.unit,e=null,this.holeInfo.textBox||(this.holeInfo.textBox=document.createElement("div"),this.holeInfo.textBox.className="section10",this.holeInfo.textBox.innerHTML=n,(o=document.createElement("div")).className="sectionPoint",this.holeInfo.textBox.appendChild(o),(e=document.createElement("div")).className="sectionCross",this.holeInfo.textBox.appendChild(e),this.viewer.container.appendChild(this.holeInfo.textBox)),1==t)&&((i={}).dimString=n,i.textPos=this.holeInfo.textPos.clone(),i.textBox=this.holeInfo.textBox,r=new THREE.Group,o=new THREE.Group,r.objectType="Group",o.objectType="Group",o.name="unsteady",o.add(this.holeInfo.fstClnd),o.add(this.holeInfo.centerToClndLine),this.OpMeasure.rootObject.remove(this.holeInfo.firstSelHoleObj),r.add(this.holeInfo.firstSelHoleObj),r.add(o),this.OpMeasure.rootObject.add(r),Se.isMobileDevice()?(i.textBox.addEventListener("touchstart",this.touchstart,!1),i.textBox.addEventListener("touchend",this.touchend,!1),i.textBox.addEventListener("touchmove",this.touchmove,!1)):(i.textBox.addEventListener("mousedown",this.touchstart,!1),i.textBox.addEventListener("mouseup",this.touchend,!1),i.textBox.addEventListener("mousemove",this.touchmove,!1),i.textBox.addEventListener("mouseleave",this.mouseleave,!1),i.textBox.addEventListener("mouseenter",this.mouseenter,!1)),Se.isMobileDevice()?e.addEventListener("touchend",this.sectionCrossend,!1):(e.addEventListener("mousedown",this.sectionCrossend,!1),e.addEventListener("mouseleave",this.crossleave,!1),e.addEventListener("mouseenter",this.crossenter,!1)),(t={}).start=this.holeInfo.textPos.clone(),t.end=this.holeInfo.fstClndPos.clone(),t.uuid=r.uuid,this.OpMeasure.textLines.push(t),i.textBox.setAttribute("mobile","up"),i.textBox.setAttribute("group",r.uuid),i.textBox.setAttribute("type","radius"),i.textBox.setAttribute("dimString",this.holeInfo.dimString),i.textBox.setAttribute("unit",this.holeInfo.unit),i.textBox.setAttribute("lineInfo",this.OpMeasure.textLines.length-1),this.OpMeasure.unsteadyData[r.uuid]=this.DeepCopy(this.holeInfo,"Radius"),this.OpMeasure.boxInfos.push(i),this.getAndShowTextBox(this.holeInfo.textPos.clone(),n,this.holeInfo.textBox),this.clearHoleInfo(!0),Se.isMobileDevice())&&this.ChangeMeasureFlag()},dn.prototype.changeRadius=function(e){var t=this.OpMeasure.rootObject.getObjectByProperty("uuid",this.OpMeasure.unsteadyuuid),n=t.getObjectByName("unsteady");n&&t.remove(n);(n=new THREE.Group).name="unsteady",n.objectType="Group",t.add(n);var i=this.OpMeasure.unsteadyData[this.OpMeasure.unsteadyuuid],t=(i.selLineCenterPos||(i.selLineCenterPos=i.firstHoleInfo.worldCenter.clone()),i.textPos?e&&((r=new THREE.Plane).setFromNormalAndCoplanarPoint(i.firstHoleInfo.worldAxis,i.firstHoleInfo.worldCenter),(o=this.clientCoordToModelCoordOnPlane(e.x,e.y,r))?i.textPos.copy(o):((a=(new THREE.Vector3).subVectors(i.firstHoleInfo.intersect,i.firstHoleInfo.worldCenter)).projectOnPlane(i.firstHoleInfo.worldAxis),i.textPos=(new THREE.Vector3).addVectors(i.firstHoleInfo.worldCenter,a))):((r=new THREE.Plane).setFromNormalAndCoplanarPoint(i.firstHoleInfo.worldAxis,i.firstHoleInfo.worldCenter),(o=this.clientCoordToModelCoordOnPlane(e.x,e.y,r))?i.textPos=o:((a=(new THREE.Vector3).subVectors(i.firstHoleInfo.intersect,i.firstHoleInfo.worldCenter)).projectOnPlane(i.firstHoleInfo.worldAxis),i.textPos=(new THREE.Vector3).addVectors(i.firstHoleInfo.worldCenter,a))),(new THREE.Vector3).subVectors(i.textPos,i.selLineCenterPos)),r=(t.normalize(),i.fstClndPos=i.selLineCenterPos.clone().add(t.clone().multiplyScalar(i.firstHoleInfo.radius)),i.sndClndPos=i.selLineCenterPos.clone().add(t.clone().multiplyScalar(-i.firstHoleInfo.radius)),e=this.createCylinderMesh(i.selLineCenterPos,i.fstClndPos,this.appmaterialLine),this.OpMeasure.getScale(e,this.CYLINDERWIDTH)),o=t.clone(),a=(o.multiplyScalar(.5*e.geometry.parameters.height),e.oldPosition=i.fstClndPos.clone(),e.offsetPos=o.clone().multiplyScalar(-1),e.position.subVectors(i.fstClndPos,o.clone().multiplyScalar(r)),"diameter"==this.measureType&&(i.sndClnd=this.createCylinderMesh(i.selLineCenterPos,i.sndClndPos,this.materialLine),r=this.OpMeasure.getScale(i.sndClnd,ve.INFOTYPE.CYLINDERWIDTH),i.sndClnd.oldPosition=i.sndClndPos.clone(),i.sndClnd.offsetPos=o.clone(),i.sndClnd.position.addVectors(i.sndClndPos,o.clone().multiplyScalar(r))),this.createLineMesh2(i.selLineCenterPos,i.fstClndPos,this.appmaterialLine,1));n.add(e),n.add(a);for(var s=0;s<this.OpMeasure.boxInfos.length;s++){var l=this.OpMeasure.boxInfos[s];if(l.textBox.getAttribute("group")==this.OpMeasure.unsteadyuuid){l.textPos=i.textPos;break}}for(s=0;s<this.OpMeasure.textLines.length;s++){var d=this.OpMeasure.textLines[s];if(d.uuid==this.OpMeasure.unsteadyuuid){d.start=i.textPos.clone(),d.end=i.fstClndPos.clone();break}}t=this.get2dPoint(i.textPos.clone()),o=this.get2dPoint(i.fstClndPos.clone()),this.viewer.renderer.getPixelRatio(),r=new THREE.Vector2(t.x-o.x,t.y-o.y);r.normalize(),r.y>=r.x/2&&r.y>=-r.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(50% - 6px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="-5.5px",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","down")):r.y>r.x/2&&r.y<-r.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(100% - 4px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(50% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","right")):r.y<r.x/2&&r.y<-r.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(50% - 6px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(100% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","up")):r.y<r.x/2&&r.y>-r.x/2&&(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="-5.5px",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(50% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","left")),this.OpMeasure.viewer.render()},(cn.prototype=Object.create(h.prototype)).OperatorStart=function(e){switch(this.measureType=e,this.measureType){case"bodyEdgeLength":this.OpMeasure.PostInfo(ve.INFOTYPE.MEASUREBODY);break;case"measureEdges":this.OpMeasure.PostInfo(ve.INFOTYPE.LINEANDCIRCLE)}},cn.prototype.onNMouseMove=function(e,t){var n=new THREE.Vector3(e,t,0);this.OpMeasure.unsteady?this.changeMeasureEdge(n):this.edgeInfo.selLineObj&&!Se.isMobileDevice()?this.createAndShowMeasureEdgesDimension(n):(this.measureEdges(e,t,!0),this.viewer.is2DModel?this.updateMeasureEdgesScene("true",n):this.update3DMeasureEdgesScene("true",n))},cn.prototype.onLMouseClick=function(e,t,n){var i=new THREE.Vector3(e,t,0);this.edgeInfo.selLineObj?this.viewer.is2DModel?(this.createAndShowMeasureEdgesDimension(i,!0),this.OpMeasure.PostInfo(ve.INFOTYPE.LINEANDCIRCLE)):this.createAndShow3DMeasureEdgesDimension(i,!0):(this.measureEdges(e,t,!1),this.viewer.is2DModel?(this.updateMeasureEdgesScene("false",i),this.edgeInfo.selLineObj&&this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE)):this.update3DMeasureEdgesScene("false",i))},cn.prototype.createAndShowMeasureEdgesDimension=function(e,t){var n,i,r,o,a,s,l,d;"measureEdges"!=this.measureType&&"bodyEdgeLength"!=this.measureType||this.edgeInfo.selLineInfo&&this.edgeInfo.selLineObj&&(n=!1,(n=this.edgeInfo.thirdPos?!0:n)?((i=new THREE.Plane).setFromCoplanarPoints(this.edgeInfo.startPos,this.edgeInfo.midPos,this.edgeInfo.thirdPos),this.edgeInfo.textPos||(this.edgeInfo.textPos=this.edgeInfo.startPos.clone()),e&&((n=this.clientCoordToModelCoordOnPlane(e.x,e.y,i))&&(this.edgeInfo.textPos=n),this.edgeInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.boxToClndLine),this.edgeInfo.boxToClndLine=this.createLineMesh2(this.edgeInfo.startPos,this.edgeInfo.textPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.edgeInfo.boxToClndLine))):(this.edgeInfo.fstClndPos||(this.edgeInfo.fstClndPos=this.edgeInfo.startPos.clone()),this.edgeInfo.sndClndPos||(this.edgeInfo.sndClndPos=this.edgeInfo.endPos.clone()),n=(new THREE.Vector3).subVectors(this.edgeInfo.endPos,this.edgeInfo.startPos),this.edgeInfo.fstClnd&&this.edgeInfo.sndClnd?e&&((i=new THREE.Plane).setFromCoplanarPoints(this.edgeInfo.startPos,this.edgeInfo.endPos,this.edgeInfo.fstClndPos),r=this.clientCoordToModelCoordOnPlane(e.x,e.y,i))&&(o=this.getProjectPntToLine(this.edgeInfo.startPos,this.edgeInfo.fstClndPos,r))&&(a=o.clone().sub(this.edgeInfo.startPos),this.edgeInfo.fstClndPos.addVectors(this.edgeInfo.startPos,a),this.edgeInfo.sndClndPos=this.edgeInfo.fstClndPos.clone().add(n)):"line"==this.edgeInfo.selLineInfo.type?(d=this.viewer.camera.getWorldDirection(),l=(new THREE.Vector3).crossVectors(n,d),l=this.getBaceFaceDir(l),s=(s=n.length())<1?.01:.5,l.normalize().multiplyScalar(s),this.edgeInfo.fstClndPos.add(l),this.edgeInfo.sndClndPos.add(l)):(a=(new THREE.Vector3).subVectors(this.edgeInfo.midPos,this.edgeInfo.startPos),1e-7<(a=(new THREE.Vector3).crossVectors(n,a)).lengthSq()?((a=(new THREE.Vector3).crossVectors(a,n)).normalize().multiplyScalar(.5),this.edgeInfo.fstClndPos.add(a),this.edgeInfo.sndClndPos.add(a)):(d=this.viewer.camera.getWorldDirection(),l=(new THREE.Vector3).crossVectors(n,d),(l=this.getBaceFaceDir(l)).normalize().multiplyScalar(.5),this.edgeInfo.fstClndPos.add(l),this.edgeInfo.sndClndPos.add(l))),this.edgeInfo.textPos?e&&((i=new THREE.Plane).setFromCoplanarPoints(this.edgeInfo.startPos,this.edgeInfo.endPos,this.edgeInfo.fstClndPos),r=this.clientCoordToModelCoordOnPlane(e.x,e.y,i))&&(o=this.getProjectPntToLine(this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos,r))&&this.edgeInfo.textPos.copy(o):this.edgeInfo.textPos=this.edgeInfo.sndClndPos.clone(),this.edgeInfo.startToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.startToClndLine),this.edgeInfo.startToClndLine=this.createLineMesh2(this.edgeInfo.startPos,this.edgeInfo.fstClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.edgeInfo.startToClndLine),this.edgeInfo.endToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.endToClndLine),this.edgeInfo.endToClndLine=this.createLineMesh2(this.edgeInfo.endPos,this.edgeInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.edgeInfo.endToClndLine),a=this.isPointBetweenIn(this.edgeInfo.textPos,this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos),this.edgeInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.edgeInfo.fstClnd),n.normalize(),a?(this.edgeInfo.fstClnd=this.createCylinderMesh(this.edgeInfo.sndClndPos,this.edgeInfo.fstClndPos,this.materialLine),s=this.OpMeasure.getScale(this.edgeInfo.fstClnd,this.CYLINDERWIDTH),n.multiplyScalar(.5*this.edgeInfo.fstClnd.geometry.parameters.height),this.edgeInfo.fstClnd.oldPosition=this.edgeInfo.fstClndPos.clone(),this.edgeInfo.fstClnd.offsetPos=n.clone(),this.edgeInfo.fstClnd.position.addVectors(this.edgeInfo.fstClndPos,n.clone().multiplyScalar(s))):(this.edgeInfo.fstClnd=this.createCylinderMesh(this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos,this.materialLine),s=this.OpMeasure.getScale(this.edgeInfo.fstClnd,this.CYLINDERWIDTH),n.multiplyScalar(.5*this.edgeInfo.fstClnd.geometry.parameters.height),this.edgeInfo.fstClnd.oldPosition=this.edgeInfo.fstClndPos.clone(),this.edgeInfo.fstClnd.offsetPos=n.clone().multiplyScalar(-1),this.edgeInfo.fstClnd.position.subVectors(this.edgeInfo.fstClndPos,n.clone().multiplyScalar(s))),this.OpMeasure.rootObject.add(this.edgeInfo.fstClnd),this.edgeInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.edgeInfo.sndClnd),a?(this.edgeInfo.sndClnd=this.createCylinderMesh(this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos,this.materialLine),this.edgeInfo.sndClnd.oldPosition=this.edgeInfo.sndClndPos.clone(),this.edgeInfo.sndClnd.offsetPos=n.clone().multiplyScalar(-1),this.edgeInfo.sndClnd.position.subVectors(this.edgeInfo.sndClndPos,n.clone().multiplyScalar(s))):(this.edgeInfo.sndClnd=this.createCylinderMesh(this.edgeInfo.sndClndPos,this.edgeInfo.fstClndPos,this.materialLine),this.edgeInfo.sndClnd.oldPosition=this.edgeInfo.sndClndPos.clone(),this.edgeInfo.sndClnd.offsetPos=n.clone(),this.edgeInfo.sndClnd.position.addVectors(this.edgeInfo.sndClndPos,n.clone().multiplyScalar(s))),this.OpMeasure.rootObject.add(this.edgeInfo.sndClnd),this.edgeInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.clndToClndLine),this.edgeInfo.clndToClndLine=this.createLineMesh2(this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.edgeInfo.clndToClndLine),this.edgeInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.edgeInfo.boxToClndLine),this.edgeInfo.boxToClndLine=this.createLineMesh2(this.edgeInfo.fstClndPos,this.edgeInfo.textPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.edgeInfo.boxToClndLine)),d="",d="⌒"==this.edgeInfo.dimString[0]?"⌒ "+(this.edgeInfo.dimString.slice(2)*this.viewer.measuringScale).toFixed(2)+this.edgeInfo.unit:(this.edgeInfo.dimString*this.viewer.measuringScale).toFixed(2)+this.edgeInfo.unit,this.edgeInfo.textBox||(this.edgeInfo.textBox=document.createElement("div"),this.edgeInfo.textBox.className="mearesult",this.viewer.container.appendChild(this.edgeInfo.textBox)),this.getAndShowTextBox(this.edgeInfo.textPos.clone(),d,this.edgeInfo.textBox),1==t)&&((l={}).dimString=d,l.textPos=this.edgeInfo.textPos.clone(),l.textBox=this.edgeInfo.textBox,l.textBox.setAttribute("type","length"),l.textBox.setAttribute("dimString",this.edgeInfo.dimString),l.textBox.setAttribute("dimStringPrefix",""),l.textBox.setAttribute("unit",this.edgeInfo.unit),this.OpMeasure.boxInfos.push(l),this.clearEdgeInfo(!0),Se.isMobileDevice()&&this.ChangeMeasureFlag(),_e.enableBroadcast)&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes()},cn.prototype.measureEdges=function(e,t,n){if(""==this.edgeInfo.unit&&(this.edgeInfo.unit=this.getUnitString()),this.edgeInfo.selLineObj)this.edgeInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null,this.edgeInfo.preSelLineInfo=null);else{var i=this.viewer,e=this.doRaycasterPick(e,t,!0);if(e&&0!=e.length){if(0<e.length){t=null;if(i.ndsModel?0<=e[0].lineSegId&&(t=e[0]):e[0].object instanceof THREE.Line||e[0].object instanceof THREE.LineSegments?t=e[0]:1<e.length&&(e[1].object instanceof THREE.Line||e[1].object instanceof THREE.LineSegments)&&Math.abs(e[1].distance-e[0].distance)<(i=this.viewer.controls.getBoundingBox()).min.distanceTo(i.max)/1e3&&(t=e[1]),t){i=this.getSelectInfoFromIntersect(t);if(i)return void(1==n?this.isTwoTopolInfoTheSame(this.edgeInfo.preSelLineInfo,i)||(this.edgeInfo.preSelLineInfo=i,this.edgeInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null)):(this.edgeInfo.selLineInfo=i,this.edgeInfo.dimString=parseFloat(i.length),this.edgeInfo.dimString<1&&.999999<this.edgeInfo.dimString&&(this.edgeInfo.dimString=1),e=this.viewer.getDispalyModelUnit(this.edgeInfo.dimString),this.edgeInfo.dimString*=e.scale,this.edgeInfo.dimString=this.edgeInfo.dimString.toFixed(2),this.edgeInfo.unit=this.getUnitStringmap(e.unit),"line"!=i.type&&(this.edgeInfo.dimString="⌒ "+this.edgeInfo.dimString)))}}1==n&&this.edgeInfo.preSelLineInfo&&(this.edgeInfo.preSelLineInfo=null,this.edgeInfo.preSelLineObj)&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null)}else this.edgeInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null,this.edgeInfo.preSelLineInfo=null)}},cn.prototype.updateMeasureEdgesScene=function(e,t){var n;"measureEdges"!==this.measureType&&"radius"!==this.measureType&&"bodyEdgeLength"!=this.measureType||(this.edgeInfo.selLineObj?this.edgeInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null,this.edgeInfo.preSelLineInfo=null):!(!e||"true"!==e.toLowerCase())?this.edgeInfo.preSelLineInfo&&!this.edgeInfo.preSelLineObj&&(n=this.createLine(this.edgeInfo.preSelLineInfo,!0))&&(this.OpMeasure.rootObject.add(n),this.edgeInfo.preSelLineObj=n):(this.edgeInfo.selLineInfo&&!this.edgeInfo.selLineObj&&(this.edgeInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null,this.edgeInfo.preSelLineInfo=null),n=this.createLine(this.edgeInfo.selLineInfo,!1))&&(this.OpMeasure.rootObject.add(n),this.edgeInfo.selLineObj=n),this.edgeInfo.selLineObj&&this.createAndShowMeasureEdgesDimension(t)))},cn.prototype.update3DMeasureEdgesScene=function(e,t){var n;"measureEdges"!==this.measureType&&"radius"!==this.measureType&&"bodyEdgeLength"!=this.measureType||(this.edgeInfo.selLineObj?this.edgeInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null,this.edgeInfo.preSelLineInfo=null):!(!e||"true"!==e.toLowerCase())?this.edgeInfo.preSelLineInfo&&!this.edgeInfo.preSelLineObj&&(n=this.createLine(this.edgeInfo.preSelLineInfo,!0))&&(this.OpMeasure.rootObject.add(n),this.edgeInfo.preSelLineObj=n):(this.edgeInfo.selLineInfo&&!this.edgeInfo.selLineObj&&(this.edgeInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.edgeInfo.preSelLineObj),this.edgeInfo.preSelLineObj=null,this.edgeInfo.preSelLineInfo=null),n=this.createLine(this.edgeInfo.selLineInfo,!1))&&(this.edgeInfo.selLineObj=n),this.edgeInfo.selLineObj&&(_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes(),this.createAndShow3DMeasureEdgesDimension(t,!0))))},cn.prototype.createAndShow3DMeasureEdgesDimension=function(e,t){var n,i,r,o,a,s,l,d;"measureEdges"!=this.measureType&&"bodyEdgeLength"!=this.measureType||this.edgeInfo.selLineInfo&&this.edgeInfo.selLineObj&&(n=!1,(n=this.edgeInfo.thirdPos?!0:n)?((s=new THREE.Plane).setFromCoplanarPoints(this.edgeInfo.startPos,this.edgeInfo.midPos,this.edgeInfo.thirdPos),this.edgeInfo.textPos||(this.edgeInfo.textPos=this.edgeInfo.startPos.clone()),e&&(n=this.clientCoordToModelCoordOnPlane(e.x,e.y,s))&&(this.edgeInfo.textPos=n)):(this.edgeInfo.fstClndPos||(this.edgeInfo.fstClndPos=this.edgeInfo.startPos.clone()),this.edgeInfo.sndClndPos||(this.edgeInfo.sndClndPos=this.edgeInfo.endPos.clone()),n=(new THREE.Vector3).subVectors(this.edgeInfo.endPos,this.edgeInfo.startPos),this.edgeInfo.fstClnd&&this.edgeInfo.sndClnd?e&&((s=new THREE.Plane).setFromCoplanarPoints(this.edgeInfo.startPos,this.edgeInfo.endPos,this.edgeInfo.fstClndPos),l=this.clientCoordToModelCoordOnPlane(e.x,e.y,s))&&(d=this.getProjectPntToLine(this.edgeInfo.startPos,this.edgeInfo.fstClndPos,l))&&(i=d.clone().sub(this.edgeInfo.startPos),this.edgeInfo.fstClndPos.addVectors(this.edgeInfo.startPos,i),this.edgeInfo.sndClndPos=this.edgeInfo.fstClndPos.clone().add(n)):"line"==this.edgeInfo.selLineInfo.type?(o=this.viewer.camera.getWorldDirection(),a=(new THREE.Vector3).crossVectors(n,o),a=this.getBaceFaceDir(a),r=(r=n.length())<1?.01:.5,a.normalize().multiplyScalar(r),this.edgeInfo.fstClndPos.add(a),this.edgeInfo.sndClndPos.add(a)):(i=(new THREE.Vector3).subVectors(this.edgeInfo.midPos,this.edgeInfo.startPos),1e-7<(i=(new THREE.Vector3).crossVectors(n,i)).lengthSq()?((i=(new THREE.Vector3).crossVectors(i,n)).normalize().multiplyScalar(.5),this.edgeInfo.fstClndPos.add(i),this.edgeInfo.sndClndPos.add(i)):(o=this.viewer.camera.getWorldDirection(),a=(new THREE.Vector3).crossVectors(n,o),(a=this.getBaceFaceDir(a)).normalize().multiplyScalar(.5),this.edgeInfo.fstClndPos.add(a),this.edgeInfo.sndClndPos.add(a))),this.edgeInfo.textPos?e&&((s=new THREE.Plane).setFromCoplanarPoints(this.edgeInfo.startPos,this.edgeInfo.endPos,this.edgeInfo.fstClndPos),l=this.clientCoordToModelCoordOnPlane(e.x,e.y,s))&&(d=this.getProjectPntToLine(this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos,l))&&this.edgeInfo.textPos.copy(d):this.edgeInfo.textPos=this.edgeInfo.sndClndPos.clone(),this.edgeInfo.startToClndLine=this.createLineMesh2(this.edgeInfo.startPos,this.edgeInfo.fstClndPos,this.materialLine,1),this.edgeInfo.endToClndLine=this.createLineMesh2(this.edgeInfo.endPos,this.edgeInfo.sndClndPos,this.materialLine,1),i=this.isPointBetweenIn(this.edgeInfo.textPos,this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos),n.normalize(),i?(this.edgeInfo.fstClnd=this.createCylinderMesh(this.edgeInfo.sndClndPos,this.edgeInfo.fstClndPos,this.materialLine),r=this.OpMeasure.getScale(this.edgeInfo.fstClnd,this.CYLINDERWIDTH),n.multiplyScalar(.5*this.edgeInfo.fstClnd.geometry.parameters.height),this.edgeInfo.fstClnd.oldPosition=this.edgeInfo.fstClndPos.clone(),this.edgeInfo.fstClnd.offsetPos=n.clone(),this.edgeInfo.fstClnd.position.addVectors(this.edgeInfo.fstClndPos,n.clone().multiplyScalar(r))):(this.edgeInfo.fstClnd=this.createCylinderMesh(this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos,this.materialLine),r=this.OpMeasure.getScale(this.edgeInfo.fstClnd,this.CYLINDERWIDTH),n.multiplyScalar(.5*this.edgeInfo.fstClnd.geometry.parameters.height),this.edgeInfo.fstClnd.oldPosition=this.edgeInfo.fstClndPos.clone(),this.edgeInfo.fstClnd.offsetPos=n.clone().multiplyScalar(-1),this.edgeInfo.fstClnd.position.subVectors(this.edgeInfo.fstClndPos,n.clone().multiplyScalar(r))),i?(this.edgeInfo.sndClnd=this.createCylinderMesh(this.edgeInfo.fstClndPos,this.edgeInfo.sndClndPos,this.materialLine),this.edgeInfo.sndClnd.oldPosition=this.edgeInfo.sndClndPos.clone(),this.edgeInfo.sndClnd.offsetPos=n.clone().multiplyScalar(-1),this.edgeInfo.sndClnd.position.subVectors(this.edgeInfo.sndClndPos,n.clone().multiplyScalar(r))):(this.edgeInfo.sndClnd=this.createCylinderMesh(this.edgeInfo.sndClndPos,this.edgeInfo.fstClndPos,this.materialLine),this.edgeInfo.sndClnd.oldPosition=this.edgeInfo.sndClndPos.clone(),this.edgeInfo.sndClnd.offsetPos=n.clone(),this.edgeInfo.sndClnd.position.addVectors(this.edgeInfo.sndClndPos,n.clone().multiplyScalar(r)))),o="",o="⌒"==this.edgeInfo.dimString[0]?"⌒ "+(this.edgeInfo.dimString.slice(2)*this.viewer.measuringScale).toFixed(2)+this.edgeInfo.unit:(this.edgeInfo.dimString*this.viewer.measuringScale).toFixed(2)+this.edgeInfo.unit,a=null,this.edgeInfo.textBox||(this.edgeInfo.textBox=document.createElement("div"),this.edgeInfo.textBox.className="section10",this.edgeInfo.textBox.innerHTML=o,(e=document.createElement("div")).className="sectionPoint",this.edgeInfo.textBox.appendChild(e),(a=document.createElement("div")).className="sectionCross",this.edgeInfo.textBox.appendChild(a),this.viewer.container.appendChild(this.edgeInfo.textBox)),1==t)&&(s={},"line"==this.edgeInfo.selLineInfo.type&&(this.edgeInfo.midPos=this.edgeInfo.startPos.clone().add(this.edgeInfo.endPos).divideScalar(2)),this.edgeInfo.textPos=this.edgeInfo.midPos.clone(),s.dimString=o,s.textPos=this.edgeInfo.textPos.clone(),s.textBox=this.edgeInfo.textBox,(l=new THREE.Group).objectType="Group",l.add(this.edgeInfo.selLineObj),this.OpMeasure.rootObject.add(l),Se.isMobileDevice()?(s.textBox.addEventListener("touchstart",this.touchstart,!1),s.textBox.addEventListener("touchend",this.touchend,!1),s.textBox.addEventListener("touchmove",this.touchmove,!1)):(s.textBox.addEventListener("mousedown",this.touchstart,!1),s.textBox.addEventListener("mouseup",this.touchend,!1),s.textBox.addEventListener("mousemove",this.touchmove,!1),s.textBox.addEventListener("mouseleave",this.mouseleave,!1),s.textBox.addEventListener("mouseenter",this.mouseenter,!1)),Se.isMobileDevice()?a.addEventListener("touchend",this.sectionCrossend,!1):(a.addEventListener("mousedown",this.sectionCrossend,!1),a.addEventListener("mouseleave",this.crossleave,!1),a.addEventListener("mouseenter",this.crossenter,!1)),(d={}).start=this.edgeInfo.textPos.clone(),d.end=this.edgeInfo.midPos.clone(),d.uuid=l.uuid,this.OpMeasure.textLines.push(d),s.textBox.setAttribute("mobile","up"),s.textBox.setAttribute("group",l.uuid),s.textBox.setAttribute("type","length"),s.textBox.setAttribute("dimString",this.edgeInfo.dimString),s.textBox.setAttribute("dimStringPrefix",""),s.textBox.setAttribute("unit",this.edgeInfo.unit),s.textBox.setAttribute("lineInfo",this.OpMeasure.textLines.length-1),this.OpMeasure.boxInfos.push(s),this.OpMeasure.unsteadyData[l.uuid]=this.DeepCopy(this.edgeInfo,"measureEdges"),this.getAndShowTextBox(this.edgeInfo.textPos.clone(),o,this.edgeInfo.textBox),this.clearEdgeInfo(!0),Se.isMobileDevice())&&this.ChangeMeasureFlag()},cn.prototype.changeMeasureEdge=function(e){var t,n,i,r=this.OpMeasure.unsteadyData[this.OpMeasure.unsteadyuuid],o=!1,a=((o=r.thirdPos?!0:o)?((t=new THREE.Plane).setFromCoplanarPoints(r.startPos,r.midPos,r.thirdPos),e&&(o=this.clientCoordToModelCoordOnPlane(e.x,e.y,t))&&(r.textPos=o)):(o=(new THREE.Vector3).subVectors(r.endPos,r.startPos),r.fstClnd&&r.sndClnd&&e&&(t=new THREE.Plane,Math.abs(r.startPos.x-r.endPos.x)<1e-6&&Math.abs(r.startPos.x-r.fstClndPos.x)<1e-6&&(r.fstClndPos.x+=10),Math.abs(r.startPos.y-r.endPos.y)<1e-6&&Math.abs(r.startPos.y-r.fstClndPos.y)<1e-6&&(r.fstClndPos.y+=10),t.setFromCoplanarPoints(r.startPos,r.endPos,r.fstClndPos),n=this.clientCoordToModelCoordOnPlane(e.x,e.y,t))&&(i=this.getProjectPntToLine(r.startPos,r.fstClndPos,n))&&(a=i.clone().sub(r.startPos),r.fstClndPos.addVectors(r.startPos,a),r.sndClndPos=r.fstClndPos.clone().add(o)),e&&((t=new THREE.Plane).setFromCoplanarPoints(r.startPos,r.endPos,r.fstClndPos),n=this.clientCoordToModelCoordOnPlane(e.x,e.y,t))&&(i=this.getProjectPntToLine(r.fstClndPos,r.sndClndPos,n))&&r.textPos.copy(i)),this.get2dPoint(r.textPos.clone())),o=this.get2dPoint(r.midPos.clone()),e=(this.viewer.renderer.getPixelRatio(),new THREE.Vector2(a.x-o.x,a.y-o.y));e.normalize(),e.y>=e.x/2&&e.y>=-e.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(50% - 6px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="-5.5px",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","down")):e.y>e.x/2&&e.y<-e.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(100% - 4px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(50% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","right")):e.y<e.x/2&&e.y<-e.x/2?(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="calc(50% - 6px)",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(100% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","up")):e.y<e.x/2&&e.y>-e.x/2&&(this.OpMeasure.unsteadyTextBox.childNodes[1].style.left="-5.5px",this.OpMeasure.unsteadyTextBox.childNodes[1].style.top="calc(50% - 5.5px)",this.OpMeasure.unsteadyTextBox.setAttribute("mobile","left"));for(var s=0;s<this.OpMeasure.boxInfos.length;s++){var l=this.OpMeasure.boxInfos[s];if(l.textBox.getAttribute("group")==this.OpMeasure.unsteadyuuid){l.textPos=r.textPos;break}}for(s=0;s<this.OpMeasure.textLines.length;s++){var d=this.OpMeasure.textLines[s];if(d.uuid==this.OpMeasure.unsteadyuuid){d.start=r.textPos.clone(),d.end=r.midPos.clone();break}}this.OpMeasure.viewer.render()},(hn.prototype=Object.create(h.prototype)).OperatorStart=function(e){switch(this.measureType=e,this.measureType){case"faceArea":Se.isMobileDevice()||this.OpMeasure.PostInfo(ve.INFOTYPE.FACE);break;case"facePerimeter":this.OpMeasure.PostInfo(ve.INFOTYPE.FACE)}},hn.prototype.onNMouseMove=function(e,t){switch(this.measureType){case"faceArea":this.measurefaceAreaAndPerimeter(e,t,!0);break;case"facePerimeter":this.measurefaceAreaAndPerimeter(e,t,!0,!1,!0)}},hn.prototype.onLMouseClick=function(e,t,n){switch(this.measureType){case"faceArea":this.measurefaceAreaAndPerimeter(e,t,!1,n);break;case"facePerimeter":this.measurefaceAreaAndPerimeter(e,t,!1,n,!0)}},hn.prototype.renderMeasureScene=function(){this.update2DScene();for(var e=0,t=this.perimeterInfos.length;e<t;e++){var n=this.perimeterInfos[e],i=(this.viewer.container.removeChild(n.textimg),this.get2dPoint(n.textPos.clone())),i=this.addAnnotationTip(n.dimString,i.x,i.y);i&&this.viewer.container.appendChild(i),n.textimg=i}},hn.prototype.measurefaceAreaAndPerimeter=function(e,t,n,i,r){var o=this.viewer;o.renderer.domElement,o.renderer.getPixelRatio();if(!(r&&null!=i&&1==i||this.viewer.brepManager.version<2&&r)){var a=this.doRaycasterPick(e,t,!1);if(a&&0!=a.length){for(var s=0;s<a.length;){var l,d=this.getSelectInfoFromIntersect(a[s]);if(d&&null!=d.area){if(1==n)this.isTwoTopolInfoTheSame(this.faceInfo.preSelFaceInfo,d)||(this.faceInfo.preSelFaceInfo=d,this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null),this.faceInfo.preSelFaceObj=this.createFace(this.faceInfo.preSelFaceInfo,!0),this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.add(this.faceInfo.preSelFaceObj),this.viewer.outlinePass)&&this.viewer.outlinePass.enabled&&((l=[]).push(this.faceInfo.preSelFaceObj),this.viewer.outlinePass.tempSelectedObjects=l));else{for(var c=!1,h=-1,u=0,p=this.faceInfo.selFaceInfors.length;u<p;u++)if(this.isTwoTopolInfoTheSame(this.faceInfo.selFaceInfors[u],d)){c=!0,h=u;break}if(null!=i&&1==i)c?(this.faceInfo.selFaceInfors.splice(h,1),this.OpMeasure.rootObject.remove(this.faceInfo.selFaceObjs[h]),this.faceInfo.selFaceObjs[h]=null,this.faceInfo.selFaceObjs.splice(h,1)):(this.faceInfo.selFaceInfors.push(d),(f=this.createFace(d,!1))&&(this.OpMeasure.rootObject.add(f),this.faceInfo.selFaceObjs.push(f))),r||(this.clearPerimetrBox(),g=(g=(g=this.getSelectedFaceArea())<1&&.999999<g?1:g)*(v=this.viewer.getDispalyModelUnit(g)).scale*v.scale,o.dispatchEvent({type:"FaceSelectionChangeEvent",faceArea:g,modelUnit:v.unit}));else{for(var f,u=this.faceInfo.selFaceInfors.length=0,p=this.faceInfo.selFaceObjs.length;u<p;u++)this.OpMeasure.rootObject.remove(this.faceInfo.selFaceObjs[u]);this.faceInfo.selFaceObjs.length=0,!c&&(this.faceInfo.selFaceInfors.push(d),f=this.createFace(d,!1))&&(this.OpMeasure.rootObject.add(f),this.faceInfo.selFaceObjs.push(f)),r?(this.clearPerimetrBox(),d.edgeInfos&&0<d.edgeInfos.array.length?this.createPerimetrBox(this.getLinePoint(d.edgeInfos.array,d.bodyUuid,d.matrixWorld)):this.createPerimetrBox(this.getedgePoint(d.edgeIDS,d.bodyUuid,d.matrixWorld))):(this.clearPerimetrBox(),g=(g=(g=this.getSelectedFaceArea())<1&&.999999<g?1:g)*(v=this.viewer.getDispalyModelUnit(g)).scale*v.scale,o.dispatchEvent({type:"FaceSelectionChangeEvent",faceArea:g,modelUnit:v.unit}))}}return}s++}if(1==n&&this.faceInfo.preSelFaceInfo&&(this.faceInfo.preSelFaceInfo=null,this.faceInfo.preSelFaceObj)&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null),!n&&(null==i||0==i)){m=!1;0<this.faceInfo.selFaceInfors.length&&(m=!0);for(u=this.faceInfo.selFaceInfors.length=0,p=this.faceInfo.selFaceObjs.length;u<p;u++)this.OpMeasure.rootObject.remove(this.faceInfo.selFaceObjs[u]);this.faceInfo.selFaceObjs.length=0,m&&(r?(o.dispatchEvent({type:"FaceSelectionPerimeterEvent",perimeters:[]}),this.clearPerimetrBox()):(this.clearPerimetrBox(),g=this.getSelectedFaceArea(),v=this.viewer.getDispalyModelUnit(g=g<1&&.999999<g?1:g),g=g*v.scale*v.scale,o.dispatchEvent({type:"FaceSelectionChangeEvent",faceArea:g,modelUnit:v.unit})))}}else if(this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null,this.faceInfo.preSelFaceInfo=null),this.viewer.outlinePass&&this.viewer.outlinePass.enabled&&(this.viewer.outlinePass.tempSelectedObjects.length=0),!n&&(null==i||0==i)){var m=!1;0<this.faceInfo.selFaceInfors.length&&(m=!0);for(var g,v,u=this.faceInfo.selFaceInfors.length=0,p=this.faceInfo.selFaceObjs.length;u<p;u++)this.OpMeasure.rootObject.remove(this.faceInfo.selFaceObjs[u]);this.faceInfo.selFaceObjs.length=0,m&&(r?(o.dispatchEvent({type:"FaceSelectionPerimeterEvent",perimeters:[]}),this.clearPerimetrBox()):(this.clearPerimetrBox(),g=this.getSelectedFaceArea(),v=this.viewer.getDispalyModelUnit(g=g<1&&.999999<g?1:g),g=g*v.scale*v.scale,o.dispatchEvent({type:"FaceSelectionChangeEvent",faceArea:g,modelUnit:v.unit})))}}},hn.prototype.getSelectedFacePerimeter=function(){for(var e=0,t=0,n=this.faceInfo.selFaceInfors.length;t<n;t++)e+=parseFloat(this.faceInfo.selFaceInfors[t].perimeter);return e},hn.prototype.createPerimetrBox=function(e){var t=[];if(0!=e.length){for(var n=this.viewer.getDispalyModelUnit(e[0].perimeter),i=0;i<e.length;i++){var r=e[i].perimeter,o=e[i].startPos,a=(this.distanceInfo.unit=this.getUnitString(),i+1),s={},l=this.get2dPoint(o.clone()),l=this.addAnnotationTip(i+1,l.x,l.y);l&&this.viewer.container.appendChild(l),s.dimString=a,s.textPos=o.clone(),s.textimg=l,this.perimeterInfos.push(s),r*=n.scale,t[i]=r.toFixed(2)}this.viewer.dispatchEvent({type:"FaceSelectionPerimeterEvent",perimeters:t,modelUnit:n.unit}),Se.isMobileDevice()&&this.ChangeMeasureFlag(),this.OpMeasure.perimeterunit=n.unit,this.OpMeasure.perimeterBroadcast=t}},hn.prototype.getLinePoint=function(e,t,n){for(var i,r=[],o=null,a=0;a<e.length;++a){var s,l,d,c,h=e[a],u=this.viewer.brepManager.GetEdegMeshIDfromID(t,h.id),u=this.viewer.ndsModel.geomManager.getGeomFromUuid(this.viewer.ndsModel.meshUuid2GeomUuidMap[u],0),p=h.indexRange.concat();this.viewer.ndsModel&&(p[0]+=u.drawRange.start/2,p[1]+=u.drawRange.start/2),u.isBufferGeometry&&(s=u.index,u=u.attributes.position.array,null!=s)&&(s=s.array,l=new THREE.Vector3,d=new THREE.Vector3,c=p[0],p=p[1],l.fromArray(u,3*s[2*c]),d.fromArray(u,3*s[2*p+1]),d.distanceTo(l)<1e-7&&(new THREE.Vector3).fromArray(u,3*s[2*(p-1)]),l.applyMatrix4(n),d.applyMatrix4(n),c={startPos:l,endPos:d,perimeter:h.length},r.push(c))}for(var f=[],m=0;m<r.length;++m){for(var g=(o=r.shift()).perimeter,v=0;v<r.length;++v)o.startPos.distanceTo((i=r[v]).endPos)<1e-7?(o.startPos.copy(i.startPos),r.splice(v,1),v=-1,g+=i.perimeter):o.endPos.distanceTo(i.startPos)<1e-7?(o.endPos.copy(i.endPos),r.splice(v,1),v=-1,g+=i.perimeter):o.endPos.distanceTo(i.endPos)<1e-7?(o.endPos.copy(i.startPos),r.splice(v,1),v=-1,g+=i.perimeter):o.startPos.distanceTo(i.startPos)<1e-7&&(o.startPos.copy(i.endPos),r.splice(v,1),v=-1,g+=i.perimeter);o.perimeter=g,f.push(o),m=-1}return f},hn.prototype.getedgePoint=function(e,t,n){for(var i=0;i<e.length;++i){var r,o,a,s,l,d,c=this.viewer.brepManager.GetEdgeInfoFromFace(t,e[i].startID).array[0],c=(r=c.geomUUID?this.viewer.ndsModel.geomManager.getGeomFromUuid(c.geomUUID,0):(r=this.viewer.brepManager.GetEdegMeshIDfromID(t,e[i].startID),this.viewer.ndsModel.geomManager.getGeomFromUuid(this.viewer.ndsModel.meshUuid2GeomUuidMap[r],0)),c.indexRange.concat());this.viewer.ndsModel&&(c[0]+=r.drawRange.start/2,c[1]+=r.drawRange.start/2),r.isBufferGeometry&&(a=r.index,o=r.attributes.position.array,null!=a)&&(a=a.array,s=new THREE.Vector3,l=new THREE.Vector3,d=c[0],c=c[1],s.fromArray(o,3*a[2*d]),l.fromArray(o,3*a[2*c+1]),l.distanceTo(s)<1e-7&&(new THREE.Vector3).fromArray(o,3*a[2*(c-1)]),s.applyMatrix4(n),l.applyMatrix4(n),e[i].startPos=s)}return e},(r.prototype=Object.create(h.prototype)).OperatorStart=function(e){switch(this.measureType=e,this.measureType){case"bodyAngle":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRMEASUREBODY);break;case"LineAngle":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTLINE);break;case"LineFaceAngle":this.OpMeasure.PostInfo(ve.INFOTYPE.LINEPLANE);break;case"faceAngle":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPLANE);break;case"angle":this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT)}},r.prototype.onNMouseMove=function(e,t){var n,i,r=new THREE.Vector3(e,t,0);if(this.OpMeasure.unsteady)this.changeLineAngle(r);else switch(this.measureType){case"bodyAngle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj&&!Se.isMobileDevice()?this.lineAngleInfo.twoPlane?(i=this.viewer.clientCoordToModelCoord([e,t]),r.set(i[0],i[1],i[2]),this.createAndShowFaceAngleDimension(r)):this.createAndShowLineAngleDimension(r):(n=4<this.viewer.brepManager.version?["line","plane","cylinder","cone"]:["line","plane","cylinder"],this.measureBodyAngle(e,t,!0,n),this.updateBodyAngleScene("true"));break;case"LineAngle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj&&!Se.isMobileDevice()?this.createAndShowLineAngleDimension(r):(this.measureLineAngle(e,t,!0,n=["line"]),this.updateLineAngleScene("true"));break;case"LineFaceAngle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj&&!Se.isMobileDevice()?this.createAndShowLineAngleDimension(r):(n=[],this.lineAngleInfo.firstLineInfo||this.lineAngleInfo.secondLineInfo?"plane"==this.lineAngleInfo.firstLineInfo.type?n=["line"]:"line"==this.lineAngleInfo.firstLineInfo.type&&(n=["plane"]):n=["plane","line"],this.measureLineAngle(e,t,!0,n),this.updateLineAngleScene("true"));break;case"faceAngle":this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj&&!Se.isMobileDevice()?(i=this.viewer.clientCoordToModelCoord([e,t]),r.set(i[0],i[1],i[2]),this.createAndShowFaceAngleDimension(r)):(this.measurefaceAngle(e,t,!0),this.updateFaceAngleScene("true"));break;case"angle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj&&!Se.isMobileDevice()?this.createAndShowLineAngleDimension(r):this.previewSnappedPoint(e,t,!0)}},r.prototype.onLMouseClick=function(e,t,n){var i,r,o=new THREE.Vector3(e,t,0);switch(this.measureType){case"bodyAngle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?(this.viewer.is2DModel?this.lineAngleInfo.twoPlane?(i=this.viewer.clientCoordToModelCoord([e,t]),o.set(i[0],i[1],i[2]),this.createAndShowFaceAngleDimension(o,!0)):this.createAndShowLineAngleDimension(o,!0):this.lineAngleInfo.twoPlane?(i=this.viewer.clientCoordToModelCoord([e,t]),o.set(i[0],i[1],i[2]),this.createAndShow3DFaceAngleDimension(o,!0)):this.createAndShow3DLineAngleDimension(o,!0),this.OperatorStart(this.measureType)):(r=4<this.viewer.brepManager.version?["line","plane","cylinder","cone"]:["line","plane","cylinder"],this.measureBodyAngle(e,t,!1,r),this.updateBodyAngleScene("false"),this.viewer.is2DModel?this.lineAngleInfo.twoPlane?(i=this.viewer.clientCoordToModelCoord([e,t]),o.set(i[0],i[1],i[2]),this.createAndShowFaceAngleDimension(o,!1)):this.createAndShowLineAngleDimension(o,!1):this.createAndShow3DLineAngleDimension(o,!0),this.lineAngleInfo.firstLineObj&&!this.lineAngleInfo.secondLineObj&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN?this.OpMeasure.PostInfo(ve.INFOTYPE.SECMEASUREBODY):this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.lineAngleInfo.firstLineObj||this.OpMeasure.PostInfo(ve.INFOTYPE.FIRMEASUREBODY));break;case"LineAngle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?(this.viewer.is2DModel?this.createAndShowLineAngleDimension(o,!0):this.createAndShow3DLineAngleDimension(o,!0),this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTLINE)):(this.measureLineAngle(e,t,!(r=["line"]),r),this.updateLineAngleScene("false"),this.viewer.is2DModel?this.createAndShowLineAngleDimension(o,!1):this.createAndShow3DLineAngleDimension(o,!0),this.lineAngleInfo.firstLineObj&&!this.lineAngleInfo.secondLineObj&&this.OpMeasure.InfoType!=ve.INFOTYPE.LINEPARALLEL&&this.OpMeasure.InfoType!=ve.INFOTYPE.PLANEPARALLELLINE&&this.OpMeasure.InfoType!=ve.INFOTYPE.LINEPARALLELPLANE?this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDLINE):this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):this.lineAngleInfo.firstLineObj||this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTLINE));break;case"LineFaceAngle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?(this.createAndShowLineAngleDimension(o,!0),this.OpMeasure.PostInfo(ve.INFOTYPE.LINEPLANE)):(r=[],this.lineAngleInfo.firstLineInfo||this.lineAngleInfo.secondLineInfo?"plane"==this.lineAngleInfo.firstLineInfo.type?r=["line"]:"line"==this.lineAngleInfo.firstLineInfo.type&&(r=["plane"]):r=["plane","line"],this.measureLineAngle(e,t,!1,r),this.updateLineAngleScene("false"),this.viewer.is2DModel?this.createAndShowLineAngleDimension(o,!1):this.createAndShow3DLineAngleDimension(o,!0),this.lineAngleInfo.firstLineInfo&&"plane"==this.lineAngleInfo.firstLineInfo.type&&!this.lineAngleInfo.secondLineInfo&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN?this.OpMeasure.PostInfo(ve.INFOTYPE.LINE):this.lineAngleInfo.firstLineInfo&&"line"==this.lineAngleInfo.firstLineInfo.type&&!this.lineAngleInfo.secondLineInfo&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN?this.OpMeasure.PostInfo(ve.INFOTYPE.PLANE):this.lineAngleInfo.firstLineInfo&&this.lineAngleInfo.secondLineInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):!this.lineAngleInfo.firstLineInfo&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN&&this.OpMeasure.PostInfo(ve.INFOTYPE.LINEPLANE));break;case"faceAngle":this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj?(i=this.viewer.clientCoordToModelCoord([e,t]),o.set(i[0],i[1],i[2]),this.createAndShowFaceAngleDimension(o,!0),this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPLANE)):(this.measurefaceAngle(e,t,!1),this.updateFaceAngleScene("false"),this.viewer.is2DModel?this.createAndShowLineAngleDimension(o,!1):this.createAndShow3DLineAngleDimension(o,!0),this.faceInfo.fstSelFaceObj&&!this.faceInfo.sndSelFaceObj&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN?this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDPLANE):this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj?this.OpMeasure.PostInfo(ve.INFOTYPE.ENDMEASURE):!this.faceInfo.fstSelFaceObj&&this.OpMeasure.InfoType<=ve.INFOTYPE.MEASURENOTICEBEGIN&&this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPLANE));break;case"angle":this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?(this.viewer.is2DModel?this.createAndShowLineAngleDimension(o,!0):this.createAndShow3DLineAngleDimension(o,!0),this.lineAngleInfo.firstHelpPointInfo||this.lineAngleInfo.secHelpPointInfo||this.lineAngleInfo.thrHelpPointInfo||this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT)):(this.AngleMeasure(e,t),this.lineAngleInfo.thrHelpPointInfo&&this.lineAngleInfo.firstHelpPointInfo&&this.lineAngleInfo.secHelpPointInfo&&(r=new THREE.Vector2(this.lineAngleInfo.firstHelpPointInfo.x-this.lineAngleInfo.secHelpPointInfo.x,this.lineAngleInfo.firstHelpPointInfo.y-this.lineAngleInfo.secHelpPointInfo.y),i=new THREE.Vector2(this.lineAngleInfo.thrHelpPointInfo.x-this.lineAngleInfo.secHelpPointInfo.x,this.lineAngleInfo.thrHelpPointInfo.y-this.lineAngleInfo.secHelpPointInfo.y),r=r.add(i).divideScalar(2),o.setX(this.lineAngleInfo.secHelpPointInfo.x+r.x),o.setY(this.lineAngleInfo.secHelpPointInfo.y+r.y)),this.updateLineAngleScene("false"),this.viewer.is2DModel?this.createAndShowLineAngleDimension(o,!1):this.createAndShow3DLineAngleDimension(o,!0),this.lineAngleInfo.firstHelpPointInfo||this.lineAngleInfo.secHelpPointInfo||this.lineAngleInfo.thrHelpPointInfo?!this.lineAngleInfo.firstHelpPointInfo||this.lineAngleInfo.secHelpPointInfo||this.lineAngleInfo.thrHelpPointInfo?this.lineAngleInfo.firstHelpPointInfo&&this.lineAngleInfo.secHelpPointInfo&&!this.lineAngleInfo.thrHelpPointInfo&&this.OpMeasure.PostInfo(ve.INFOTYPE.THIRDPOINT):this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDPOINT):this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT))}},r.prototype.createAndShowLineAngleDimension=function(e,t){if(this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj){var n=this.lineAngleInfo.firstLineInfo.start,i=(new THREE.Vector3).subVectors(this.lineAngleInfo.firstLineInfo.end,this.lineAngleInfo.firstLineInfo.start),r=(i.normalize(),i.clone().negate()),o=this.lineAngleInfo.secondLineInfo.start,a=(new THREE.Vector3).subVectors(this.lineAngleInfo.secondLineInfo.end,this.lineAngleInfo.secondLineInfo.start),s=(a.normalize(),a.clone().negate()),n=(this.lineAngleInfo.arcCenter||(this.lineAngleInfo.arcCenter=this.getIntersectPointOfTwoLine(n,i,o,a),this.lineAngleInfo.fstClndPos=new THREE.Vector3,this.lineAngleInfo.sndClndPos=new THREE.Vector3),(new THREE.Vector3).addVectors(this.lineAngleInfo.arcCenter,i)),o=(new THREE.Vector3).addVectors(this.lineAngleInfo.arcCenter,a),l=new THREE.Plane,n=(l.setFromCoplanarPoints(this.lineAngleInfo.arcCenter,n,o),this.clientCoordToModelCoordOnPlane(e.x,e.y,l));if(n){this.lineAngleInfo.textPos=n;o=(new THREE.Vector3).subVectors(this.lineAngleInfo.textPos,this.lineAngleInfo.arcCenter),e=o.length(),l=(o.normalize(),i),n=a;this.isBetweenTwoVectors(o,i,a)?(l=i,n=a):this.isBetweenTwoVectors(o,i,s)?(l=i,n=s):this.isBetweenTwoVectors(o,r,a)?(l=r,n=a):this.isBetweenTwoVectors(o,r,s)&&(l=r,n=s);o=(o=l.angleTo(n))/Math.PI*180;this.lineAngleInfo.dimString=o.toFixed(2),this.lineAngleInfo.fstClndPos.addVectors(this.lineAngleInfo.arcCenter,l.clone().multiplyScalar(e)),this.lineAngleInfo.sndClndPos.addVectors(this.lineAngleInfo.arcCenter,n.clone().multiplyScalar(e));for(var d=0;d<this.lineAngleInfo.arcMeshes.length;d++)this.OpMeasure.rootObject.remove(this.lineAngleInfo.arcMeshes[d]),this.lineAngleInfo.arcMeshes[d]=null;if(this.lineAngleInfo.arcMeshes=this.createAngleArcMeshes2(this.lineAngleInfo.fstClndPos,this.lineAngleInfo.arcCenter,this.lineAngleInfo.sndClndPos,this.ARCWIDTH),0!=this.lineAngleInfo.arcMeshes.length){for(d=0;d<this.lineAngleInfo.arcMeshes.length;d++)this.OpMeasure.rootObject.add(this.lineAngleInfo.arcMeshes[d]);this.lineAngleInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.fstClnd),this.lineAngleInfo.fstClnd=this.createCylinderMesh(this.lineAngleInfo.arcMeshes[1].geometry.vertices[0],this.lineAngleInfo.fstClndPos,this.materialLine);var c,h,o=(new THREE.Vector3).subVectors(this.lineAngleInfo.fstClndPos,this.lineAngleInfo.arcMeshes[1].geometry.vertices[0]),l=(o.normalize(),this.OpMeasure.getScale(this.lineAngleInfo.fstClnd,this.CYLINDERWIDTH)),n=(o.multiplyScalar(.5*this.lineAngleInfo.fstClnd.geometry.parameters.height),this.lineAngleInfo.fstClnd.oldPosition=this.lineAngleInfo.fstClndPos.clone(),this.lineAngleInfo.fstClnd.offsetPos=o.clone().multiplyScalar(-1),this.lineAngleInfo.fstClnd.position.subVectors(this.lineAngleInfo.fstClndPos,o.clone().multiplyScalar(l)),this.OpMeasure.rootObject.add(this.lineAngleInfo.fstClnd),this.lineAngleInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.sndClnd),this.lineAngleInfo.sndClnd=this.createCylinderMesh(this.lineAngleInfo.arcMeshes[this.lineAngleInfo.arcMeshes.length-2].geometry.vertices[0],this.lineAngleInfo.sndClndPos,this.materialLine),(new THREE.Vector3).subVectors(this.lineAngleInfo.sndClndPos,this.lineAngleInfo.arcMeshes[this.lineAngleInfo.arcMeshes.length-2].geometry.vertices[0])),l=(n.normalize(),this.OpMeasure.getScale(this.lineAngleInfo.sndClnd,this.CYLINDERWIDTH)),e=(n.multiplyScalar(.5*this.lineAngleInfo.sndClnd.geometry.parameters.height),this.lineAngleInfo.sndClnd.oldPosition=this.lineAngleInfo.sndClndPos.clone(),this.lineAngleInfo.sndClnd.offsetPos=n.clone().multiplyScalar(-1),this.lineAngleInfo.sndClnd.position.subVectors(this.lineAngleInfo.sndClndPos,n.clone().multiplyScalar(l)),this.OpMeasure.rootObject.add(this.lineAngleInfo.sndClnd),this.lineAngleInfo.auxLine1&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.auxLine1),this.lineAngleInfo.auxLine1=null),this.lineAngleInfo.firstLineInfo.start.distanceTo(this.lineAngleInfo.firstLineInfo.end)),o=this.lineAngleInfo.fstClndPos.distanceTo(this.lineAngleInfo.firstLineInfo.start),n=this.lineAngleInfo.fstClndPos.distanceTo(this.lineAngleInfo.firstLineInfo.end),l=(this.isZero(o+n-e)||(h=n<o?(c=this.lineAngleInfo.firstLineInfo.end,(new THREE.Vector3).addVectors(c,i.clone().multiplyScalar(1.3*n))):(c=this.lineAngleInfo.firstLineInfo.start,(new THREE.Vector3).addVectors(c,r.clone().multiplyScalar(1.3*o))),this.lineAngleInfo.auxLine1=this.createLineMesh2(c,h,this.materialLine,1),this.OpMeasure.rootObject.add(this.lineAngleInfo.auxLine1)),this.lineAngleInfo.auxLine2&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.auxLine2),this.lineAngleInfo.auxLine2=null),e=this.lineAngleInfo.secondLineInfo.start.distanceTo(this.lineAngleInfo.secondLineInfo.end),o=this.lineAngleInfo.sndClndPos.distanceTo(this.lineAngleInfo.secondLineInfo.start),n=this.lineAngleInfo.sndClndPos.distanceTo(this.lineAngleInfo.secondLineInfo.end),this.isZero(o+n-e)||(h=n<o?(c=this.lineAngleInfo.secondLineInfo.end,(new THREE.Vector3).addVectors(c,a.clone().multiplyScalar(1.3*n))):(c=this.lineAngleInfo.secondLineInfo.start,(new THREE.Vector3).addVectors(c,s.clone().multiplyScalar(1.3*o))),this.lineAngleInfo.auxLine2=this.createLineMesh2(c,h,this.materialLine,1),this.OpMeasure.rootObject.add(this.lineAngleInfo.auxLine2)),this.lineAngleInfo.dimString+this.lineAngleInfo.unit);this.lineAngleInfo.textBox||(this.lineAngleInfo.textBox=document.createElement("div"),this.lineAngleInfo.textBox.className="mearesult",this.viewer.container.appendChild(this.lineAngleInfo.textBox)),this.getAndShowTextBox(this.lineAngleInfo.textPos.clone(),l,this.lineAngleInfo.textBox),t&&((i={}).dimString=l,i.textPos=this.lineAngleInfo.textPos.clone(),i.textBox=this.lineAngleInfo.textBox,i.textBox.setAttribute("type","angle"),i.textBox.setAttribute("dimString",this.lineAngleInfo.dimString),i.textBox.setAttribute("unit",this.lineAngleInfo.unit),this.OpMeasure.boxInfos.push(i),this.clearLineAngleInfo(!0),Se.isMobileDevice()&&this.ChangeMeasureFlag(),_e.enableBroadcast)&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes()}}}},r.prototype.createAndShow3DLineAngleDimension=function(e,t){if(this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj||this.faceInfo.fstIntersect&&this.faceInfo.sndIntersect){var n=this.lineAngleInfo.firstLineInfo.start,i=(new THREE.Vector3).subVectors(this.lineAngleInfo.firstLineInfo.end,this.lineAngleInfo.firstLineInfo.start),r=(i.normalize(),i.clone().negate()),o=this.lineAngleInfo.secondLineInfo.start,a=(new THREE.Vector3).subVectors(this.lineAngleInfo.secondLineInfo.end,this.lineAngleInfo.secondLineInfo.start),s=(a.normalize(),a.clone().negate()),n=(this.lineAngleInfo.arcCenter||(this.lineAngleInfo.arcCenter=this.getIntersectPointOfTwoLine(n,i,o,a),this.lineAngleInfo.fstClndPos=new THREE.Vector3,this.lineAngleInfo.sndClndPos=new THREE.Vector3),(new THREE.Vector3).subVectors(this.lineAngleInfo.firstLineInfo.end,this.lineAngleInfo.firstLineInfo.start)),o=(new THREE.Vector3).subVectors(this.lineAngleInfo.secondLineInfo.end,this.lineAngleInfo.secondLineInfo.start),n=.8*Math.max(Math.min(n.length(),o.length()),.1),o=(new THREE.Vector3).addVectors(i,a),o=(o.normalize(),this.lineAngleInfo.textPos=(new THREE.Vector3).addVectors(this.lineAngleInfo.arcCenter,o.clone().multiplyScalar(n)),(new THREE.Vector3).subVectors(this.lineAngleInfo.textPos,this.lineAngleInfo.arcCenter)),n=o.length(),l=(o.normalize(),i),d=a;this.isBetweenTwoVectors(o,i,a)?(l=i,d=a):this.isBetweenTwoVectors(o,i,s)?(l=i,d=s):this.isBetweenTwoVectors(o,r,a)?(l=r,d=a):this.isBetweenTwoVectors(o,r,s)&&(l=r,d=s);o=(o=l.angleTo(d))/Math.PI*180;if(this.lineAngleInfo.dimString=o.toFixed(2),this.lineAngleInfo.fstClndPos.addVectors(this.lineAngleInfo.arcCenter,l.clone().multiplyScalar(n)),this.lineAngleInfo.sndClndPos.addVectors(this.lineAngleInfo.arcCenter,d.clone().multiplyScalar(n)),this.lineAngleInfo.arcMeshes=this.createAngleArcMeshes2(this.lineAngleInfo.fstClndPos,this.lineAngleInfo.arcCenter,this.lineAngleInfo.sndClndPos,this.ARCWIDTH,this.appmaterialLine),0!=this.lineAngleInfo.arcMeshes.length){this.lineAngleInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.lineAngleInfo.fstClnd),this.lineAngleInfo.fstClnd=this.createCylinderMesh(this.lineAngleInfo.arcMeshes[1].geometry.vertices[0],this.lineAngleInfo.fstClndPos,this.appmaterialLine);var c,h,o=(new THREE.Vector3).subVectors(this.lineAngleInfo.fstClndPos,this.lineAngleInfo.arcMeshes[1].geometry.vertices[0]),l=(o.normalize(),this.OpMeasure.getScale(this.lineAngleInfo.fstClnd,this.CYLINDERWIDTH)),d=(o.multiplyScalar(.5*this.lineAngleInfo.fstClnd.geometry.parameters.height),this.lineAngleInfo.fstClnd.oldPosition=this.lineAngleInfo.fstClndPos.clone(),this.lineAngleInfo.fstClnd.offsetPos=o.clone().multiplyScalar(-1),this.lineAngleInfo.fstClnd.position.subVectors(this.lineAngleInfo.fstClndPos,o.clone().multiplyScalar(l)),this.lineAngleInfo.sndClnd=this.createCylinderMesh(this.lineAngleInfo.arcMeshes[this.lineAngleInfo.arcMeshes.length-2].geometry.vertices[0],this.lineAngleInfo.sndClndPos,this.appmaterialLine),(new THREE.Vector3).subVectors(this.lineAngleInfo.sndClndPos,this.lineAngleInfo.arcMeshes[this.lineAngleInfo.arcMeshes.length-2].geometry.vertices[0])),l=(d.normalize(),this.OpMeasure.getScale(this.lineAngleInfo.sndClnd,this.CYLINDERWIDTH)),n=(d.multiplyScalar(.5*this.lineAngleInfo.sndClnd.geometry.parameters.height),this.lineAngleInfo.sndClnd.oldPosition=this.lineAngleInfo.sndClndPos.clone(),this.lineAngleInfo.sndClnd.offsetPos=d.clone().multiplyScalar(-1),this.lineAngleInfo.sndClnd.position.subVectors(this.lineAngleInfo.sndClndPos,d.clone().multiplyScalar(l)),this.lineAngleInfo.firstLineInfo.start.distanceTo(this.lineAngleInfo.firstLineInfo.end)),o=this.lineAngleInfo.fstClndPos.distanceTo(this.lineAngleInfo.firstLineInfo.start),d=this.lineAngleInfo.fstClndPos.distanceTo(this.lineAngleInfo.firstLineInfo.end),l=(this.isZero(o+d-n)||(h=d<o?(c=this.lineAngleInfo.firstLineInfo.end,(new THREE.Vector3).addVectors(c,i.clone().multiplyScalar(1.3*d))):(c=this.lineAngleInfo.firstLineInfo.start,(new THREE.Vector3).addVectors(c,r.clone().multiplyScalar(1.3*o))),this.lineAngleInfo.auxLine1=this.createLineMesh2(c,h,this.appmaterialLine,1)),n=this.lineAngleInfo.secondLineInfo.start.distanceTo(this.lineAngleInfo.secondLineInfo.end),o=this.lineAngleInfo.sndClndPos.distanceTo(this.lineAngleInfo.secondLineInfo.start),d=this.lineAngleInfo.sndClndPos.distanceTo(this.lineAngleInfo.secondLineInfo.end),this.isZero(o+d-n)||(h=d<o?(c=this.lineAngleInfo.secondLineInfo.end,(new THREE.Vector3).addVectors(c,a.clone().multiplyScalar(1.3*d))):(c=this.lineAngleInfo.secondLineInfo.start,(new THREE.Vector3).addVectors(c,s.clone().multiplyScalar(1.3*o))),this.lineAngleInfo.auxLine2=this.createLineMesh2(c,h,this.appmaterialLine,1)),this.lineAngleInfo.dimString+this.lineAngleInfo.unit),i=null;if(this.lineAngleInfo.textBox||(this.lineAngleInfo.textBox=document.createElement("div"),this.lineAngleInfo.textBox.className="section10",this.lineAngleInfo.textBox.innerHTML=l,(r=document.createElement("div")).className="sectionPoint",this.lineAngleInfo.textBox.appendChild(r),(i=document.createElement("div")).className="sectionCross",this.lineAngleInfo.textBox.appendChild(i),this.viewer.container.appendChild(this.lineAngleInfo.textBox)),t){var n={},a=(n.dimString=l,n.textPos=this.lineAngleInfo.textPos.clone(),n.textBox=this.lineAngleInfo.textBox,new THREE.Group),u=new THREE.Group;a.objectType="Group",u.objectType="Group",u.name="unsteady";for(var p=0;p<this.lineAngleInfo.arcMeshes.length;p++)u.add(this.lineAngleInfo.arcMeshes[p]);u.add(this.lineAngleInfo.fstClnd),u.add(this.lineAngleInfo.sndClnd),this.lineAngleInfo.auxLine1&&u.add(this.lineAngleInfo.auxLine1),this.lineAngleInfo.auxLine2&&u.add(this.lineAngleInfo.auxLine2),this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.firstLineObj),this.OpMeasure.rootObject.remove(this.lineAngleInfo.secondLineObj),a.add(this.lineAngleInfo.firstLineObj),a.add(this.lineAngleInfo.secondLineObj)),this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.sndSelFaceObj),this.OpMeasure.rootObject.remove(this.faceInfo.fstSelFaceObj),a.add(this.faceInfo.sndSelFaceObj),a.add(this.faceInfo.fstSelFaceObj)),a.add(u),this.OpMeasure.rootObject.add(a),Se.isMobileDevice()?(n.textBox.addEventListener("touchstart",this.touchstart,!1),n.textBox.addEventListener("touchend",this.touchend,!1),n.textBox.addEventListener("touchmove",this.touchmove,!1)):(n.textBox.addEventListener("mousedown",this.touchstart,!1),n.textBox.addEventListener("mouseup",this.touchend,!1),n.textBox.addEventListener("mousemove",this.touchmove,!1),n.textBox.addEventListener("mouseleave",this.mouseleave,!1),n.textBox.addEventListener("mouseenter",this.mouseenter,!1)),Se.isMobileDevice()?i.addEventListener("touchend",this.sectionCrossend,!1):(i.addEventListener("mousedown",this.sectionCrossend,!1),i.addEventListener("mouseleave",this.crossleave,!1),i.addEventListener("mouseenter",this.crossenter,!1)),n.textBox.setAttribute("mobile","up"),n.textBox.setAttribute("group",a.uuid),n.textBox.setAttribute("type","angle"),n.textBox.setAttribute("dimString",this.lineAngleInfo.dimString),n.textBox.setAttribute("unit",this.lineAngleInfo.unit),this.OpMeasure.unsteadyData[a.uuid]=this.DeepCopy(this.lineAngleInfo,"Angle"),this.getAndShowTextBox(this.lineAngleInfo.textPos.clone(),l,this.lineAngleInfo.textBox),this.OpMeasure.boxInfos.push(n),this.clearLineAngleInfo(!0),this.faceInfo.fstIntersect&&this.faceInfo.sndIntersect&&this.clearFaceInfo(!0),Se.isMobileDevice()&&this.ChangeMeasureFlag(),_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes()}}}},r.prototype.createMeasureScene=function(){if(null!=this.dimensionObject&&(this.scene.remove(this.dimensionObject),this.dimensionObject=null),"angle"==this.measureType){if(this.firstSprite&&(null==this.dimensionObject&&(this.dimensionObject=new THREE.Object3D),(e=this.createPointMesh(this.firstSprite,this.materialPoint,this.POINTSIZE)).objectType="Point",this.dimensionObject.add(e)),this.secondSprite&&(null==this.dimensionObject&&(this.dimensionObject=new THREE.Object3D),(e=this.createPointMesh(this.secondSprite,this.materialPoint,this.POINTSIZE)).objectType="Point",this.dimensionObject.add(e)),this.lastMeasure&&(null==this.dimensionObject&&(this.dimensionObject=new THREE.Object3D),"angle"==this.measureType)){for(var e=this.createLineMesh2(this.lastMeasure.first,this.lastMeasure.second,this.materialLine,this.LINEWIDTH),e=(e.objectType="Line",this.dimensionObject.add(e),this.createLineMesh2(this.lastMeasure.third,this.lastMeasure.second,this.materialLine,this.LINEWIDTH)),t=(e.objectType="Line",this.dimensionObject.add(e),this.createAngleArcMeshes(this.lastMeasure.first,this.lastMeasure.second,this.lastMeasure.third,this.ARCWIDTH,this.midPoint)),n=0;n<t.length;n++)t[n].objectType="Arc",this.dimensionObject.add(t[n]);e=this.createPointMesh(this.lastMeasure.first,this.materialPoint,this.POINTSIZE),e=(e.objectType="Point",this.dimensionObject.add(e),this.createPointMesh(this.lastMeasure.second,this.materialPoint,this.POINTSIZE)),e=(e.objectType="Point",this.dimensionObject.add(e),this.createPointMesh(this.lastMeasure.third,this.materialPoint,this.POINTSIZE));e.objectType="Point",this.dimensionObject.add(e)}null!=this.dimensionObject&&this.scene.add(this.dimensionObject)}},r.prototype.AngleMeasure=function(e,t){var n;if(""==this.lineAngleInfo.unit&&(this.lineAngleInfo.unit="°"),null!=this.snappedPoint)n=this.snappedPoint;else{var i=this.getIntersectsByPriorityOfLine(e,t);if(i&&0<i.length)for(var r=0;r<i.length;){if(null!=(this.viewer.ndsModel?i[r].object:this.FindParentElement(i[r].object))){n=i[r].point.clone();break}r++}}n&&(null==this.lineAngleInfo.firstHelpPointInfo?this.lineAngleInfo.firstHelpPointInfo={type:"point",point:n.clone(),x:e,y:t}:null==this.lineAngleInfo.secHelpPointInfo?(this.lineAngleInfo.secHelpPointInfo={type:"point",point:n.clone(),x:e,y:t},this.lineAngleInfo.firstLineInfo={type:"helpline",start:this.lineAngleInfo.secHelpPointInfo.point.clone(),end:this.lineAngleInfo.firstHelpPointInfo.point.clone()}):null==this.lineAngleInfo.thrHelpPointInfo&&(this.lineAngleInfo.thrHelpPointInfo={type:"point",point:n.clone(),x:e,y:t},this.lineAngleInfo.secondLineInfo={type:"helpline",start:this.lineAngleInfo.secHelpPointInfo.point.clone(),end:this.lineAngleInfo.thrHelpPointInfo.point.clone()}))},r.prototype.changeLineAngle=function(e){var t=this.OpMeasure.rootObject.getObjectByProperty("uuid",this.OpMeasure.unsteadyuuid),n=t.getObjectByName("unsteady");n&&t.remove(n);(n=new THREE.Group).name="unsteady",n.objectType="Group",t.add(n);var i=this.OpMeasure.unsteadyData[this.OpMeasure.unsteadyuuid],t=i.firstLineInfo.start,r=(new THREE.Vector3).subVectors(i.firstLineInfo.end,i.firstLineInfo.start),o=(r.normalize(),r.clone().negate()),a=i.secondLineInfo.start,s=(new THREE.Vector3).subVectors(i.secondLineInfo.end,i.secondLineInfo.start),l=(s.normalize(),s.clone().negate()),t=(i.arcCenter||(i.arcCenter=this.getIntersectPointOfTwoLine(t,r,a,s),i.fstClndPos=new THREE.Vector3,i.sndClndPos=new THREE.Vector3),(new THREE.Vector3).addVectors(i.arcCenter,r)),a=(new THREE.Vector3).addVectors(i.arcCenter,s),d=new THREE.Plane,c=null,h=null,t=(d.setFromCoplanarPoints(i.arcCenter,t,a),d.normal.length()<1e-8&&(d.setFromCoplanarPoints(i.arcCenter.clone().add(new THREE.Vector3(1,-1,1)),t,a),c=new THREE.Vector3,h=new THREE.Vector3),this.clientCoordToModelCoordOnPlane(e.x,e.y,d));if(t){i.textPos=t;var a=(new THREE.Vector3).subVectors(i.textPos,i.arcCenter),e=a.length(),d=(a.normalize(),r),u=s;this.isBetweenTwoVectors(a,r,s)?(d=r,u=s):this.isBetweenTwoVectors(a,r,l)?(d=r,u=l):this.isBetweenTwoVectors(a,o,s)?(d=o,u=s):this.isBetweenTwoVectors(a,o,l)&&(d=o,u=l);var a=(a=d.angleTo(u))/Math.PI*180,p=(i.dimString=a.toFixed(2),i.fstClndPos.addVectors(i.arcCenter,d.clone().multiplyScalar(e)),i.sndClndPos.addVectors(i.arcCenter,u.clone().multiplyScalar(e)),null!=c&&(v=new THREE.Vector3,A=new THREE.Vector3,v.subVectors(i.fstClndPos,i.arcCenter),A.subVectors(t,i.arcCenter),c.crossVectors(v,A),c.normalize(),h.subVectors(t,i.arcCenter),h.normalize().negate()),(h=(new THREE.Vector3).addVectors(r,s)).normalize(),this.createAngleArcMeshesWithAngle(i.arcCenter,d,u,e,a,this.ARCWIDTH,this.appmaterialLine));if(0!=p.length){for(var f=0;f<p.length;f++)n.add(p[f]);for(var m,g,v=p[1].geometry.vertices[0],A=p[p.length-2].geometry.vertices[0],c=this.createCylinderMesh(v,i.fstClndPos,this.appmaterialLine),t=(new THREE.Vector3).subVectors(i.fstClndPos,v),h=(t.normalize(),this.OpMeasure.getScale(c,this.CYLINDERWIDTH)),d=(t.multiplyScalar(.5*c.geometry.parameters.height),c.oldPosition=i.fstClndPos.clone(),c.offsetPos=t.clone().multiplyScalar(-1),c.position.subVectors(i.fstClndPos,t.clone().multiplyScalar(h)),n.add(c),this.createCylinderMesh(A,i.sndClndPos,this.appmaterialLine)),u=(new THREE.Vector3).subVectors(i.sndClndPos,A),h=(u.normalize(),this.OpMeasure.getScale(d,this.CYLINDERWIDTH)),e=(u.multiplyScalar(.5*d.geometry.parameters.height),d.oldPosition=i.sndClndPos.clone(),d.offsetPos=u.clone().multiplyScalar(-1),d.position.subVectors(i.sndClndPos,u.clone().multiplyScalar(h)),n.add(d),i.firstLineInfo.start.distanceTo(i.firstLineInfo.end)),a=i.fstClndPos.distanceTo(i.firstLineInfo.start),v=i.fstClndPos.distanceTo(i.firstLineInfo.end),y=(this.isZero(a+v-e)||(g=v<a?(m=i.firstLineInfo.end,(new THREE.Vector3).addVectors(m,r.clone().multiplyScalar(1.3*v))):(m=i.firstLineInfo.start,(new THREE.Vector3).addVectors(m,o.clone().multiplyScalar(1.3*a))),t=this.createLineMesh2(m,g,this.appmaterialLine,1),n.add(t)),e=i.secondLineInfo.start.distanceTo(i.secondLineInfo.end),a=i.sndClndPos.distanceTo(i.secondLineInfo.start),v=i.sndClndPos.distanceTo(i.secondLineInfo.end),this.isZero(a+v-e)||(g=v<a?(m=i.secondLineInfo.end,(new THREE.Vector3).addVectors(m,s.clone().multiplyScalar(1.3*v))):(m=i.secondLineInfo.start,(new THREE.Vector3).addVectors(m,l.clone().multiplyScalar(1.3*a))),c=this.createLineMesh2(m,g,this.appmaterialLine,1),n.add(c)),i.dimString+i.unit),E=0;E<this.OpMeasure.boxInfos.length;E++){var M=this.OpMeasure.boxInfos[E];if(M.textBox.getAttribute("group")==this.OpMeasure.unsteadyuuid){M.textPos=i.textPos,M.dimString=y;break}}this.OpMeasure.viewer.render()}}},r.prototype.createAndShowFaceAngleDimension=function(e,t){if(this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj&&("faceAngle"===this.measureType||"bodyAngle"===this.measureType)){var n=this.faceInfo.fstIntersect,i=this.faceInfo.sndIntersect;if(this.faceInfo.arcCenter){if(!this.faceInfo.fstClnd||!this.faceInfo.sndClnd)return}else{var r=(new THREE.Vector3).subVectors(i,n),o=this.faceInfo.firstFaceInfo.worldNormal.clone(),a=this.faceInfo.secondFaceInfo.worldNormal.clone(),s=(o.normalize(),a.normalize(),new THREE.Vector3),l=new THREE.Vector3;if(!this.getIntersectLineOfTwoPlane(n,o,i,a,s,l))return;var l=s.clone().add(l.clone().multiplyScalar(10)),s=(this.faceInfo.arcCenter=this.getProjectPntToLine(s,l,i),r.dot(o)),l=(new THREE.Vector3).subVectors(i,o.clone().multiplyScalar(s)),s=(new THREE.Vector3).crossVectors(o,a),a=n.clone().add(s.multiplyScalar(2)),s=(this.faceInfo.midLineEndPt=this.getProjectPntToLine(n,a,l),this.faceInfo.arcCenter.distanceTo(l)),a=i.distanceTo(l),l=Math.min(s,a),s=(this.isZero(l)&&(l=.001),(new THREE.Vector3).subVectors(this.faceInfo.midLineEndPt,this.faceInfo.arcCenter)),a=(new THREE.Vector3).subVectors(i,this.faceInfo.arcCenter),a=(s.normalize(),a.normalize(),this.faceInfo.sndClndPos=(new THREE.Vector3).addVectors(i,a.multiplyScalar(l)),this.faceInfo.arcCenter.distanceTo(this.faceInfo.sndClndPos));this.faceInfo.fstClndPos=(new THREE.Vector3).addVectors(this.faceInfo.arcCenter,s.multiplyScalar(a));l=(l=this.getAngle(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos))/Math.PI*180;this.faceInfo.dimString=l.toFixed(2)}this.faceInfo.textPos?(e&&(s=this.getProjectPntToPlane(this.faceInfo.arcCenter,this.faceInfo.fstClndPos,this.faceInfo.sndClndPos,e))&&this.faceInfo.textPos.copy(s),r=(new THREE.Vector3).subVectors(this.faceInfo.midLineEndPt,this.faceInfo.arcCenter),o=(new THREE.Vector3).subVectors(i,this.faceInfo.arcCenter),r.normalize(),o.normalize(),a=this.faceInfo.arcCenter.distanceTo(this.faceInfo.textPos),this.faceInfo.fstClndPos.addVectors(this.faceInfo.arcCenter,r.multiplyScalar(a)),this.faceInfo.sndClndPos.addVectors(this.faceInfo.arcCenter,o.multiplyScalar(a))):this.faceInfo.textPos=this.faceInfo.sndClndPos.clone(),this.faceInfo.fstToMidLine||(this.faceInfo.fstToMidLine=this.createLineMesh2(n,this.faceInfo.midLineEndPt,this.materialLine,1),this.OpMeasure.rootObject.add(this.faceInfo.fstToMidLine)),this.faceInfo.fstToClndLine&&this.OpMeasure.rootObject.remove(this.faceInfo.fstToClndLine),this.faceInfo.fstToClndLine=this.createLineMesh2(this.faceInfo.midLineEndPt,this.faceInfo.fstClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.faceInfo.fstToClndLine),this.faceInfo.sndToClndLine&&this.OpMeasure.rootObject.remove(this.faceInfo.sndToClndLine),this.faceInfo.sndToClndLine=this.createLineMesh2(i,this.faceInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.faceInfo.sndToClndLine);for(var d=0;d<this.faceInfo.arcMeshes.length;d++)this.OpMeasure.rootObject.remove(this.faceInfo.arcMeshes[d]),this.faceInfo.arcMeshes[d]=null;this.faceInfo.arcMeshes=this.createAngleArcMeshes2(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos,this.ARCWIDTH);for(d=0;d<this.faceInfo.arcMeshes.length;d++)this.OpMeasure.rootObject.add(this.faceInfo.arcMeshes[d]);this.faceInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.faceInfo.fstClnd),this.faceInfo.fstClnd=this.createCylinderMesh(this.faceInfo.arcMeshes[1].geometry.vertices[0],this.faceInfo.fstClndPos,this.materialLine);l=(new THREE.Vector3).subVectors(this.faceInfo.fstClndPos,this.faceInfo.arcMeshes[1].geometry.vertices[0]),e=(l.normalize(),this.OpMeasure.getScale(this.faceInfo.fstClnd,this.CYLINDERWIDTH)),s=(l.multiplyScalar(.5*this.faceInfo.fstClnd.geometry.parameters.height),this.faceInfo.fstClnd.oldPosition=this.faceInfo.fstClndPos.clone(),this.faceInfo.fstClnd.offsetPos=l.clone().multiplyScalar(-1),this.faceInfo.fstClnd.position.subVectors(this.faceInfo.fstClndPos,l.clone().multiplyScalar(e)),this.OpMeasure.rootObject.add(this.faceInfo.fstClnd),this.faceInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.faceInfo.sndClnd),this.faceInfo.sndClnd=this.createCylinderMesh(this.faceInfo.arcMeshes[this.faceInfo.arcMeshes.length-2].geometry.vertices[0],this.faceInfo.sndClndPos,this.materialLine),(new THREE.Vector3).subVectors(this.faceInfo.sndClndPos,this.faceInfo.arcMeshes[this.faceInfo.arcMeshes.length-2].geometry.vertices[0])),e=(s.normalize(),this.OpMeasure.getScale(this.faceInfo.sndClnd,this.CYLINDERWIDTH)),r=(s.multiplyScalar(.5*this.faceInfo.sndClnd.geometry.parameters.height),this.faceInfo.sndClnd.oldPosition=this.faceInfo.sndClndPos.clone(),this.faceInfo.sndClnd.offsetPos=s.clone().multiplyScalar(-1),this.faceInfo.sndClnd.position.subVectors(this.faceInfo.sndClndPos,s.clone().multiplyScalar(e)),this.OpMeasure.rootObject.add(this.faceInfo.sndClnd),this.getAngle(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.textPos)),o=this.getAngle(this.faceInfo.textPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos),a=this.getAngle(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos),n=Math.abs(r+o-a)<.01,i=this.faceInfo.dimString+this.faceInfo.unit;this.faceInfo.textBox||(this.faceInfo.textBox=document.createElement("div"),this.faceInfo.textBox.className="mearesult",this.viewer.container.appendChild(this.faceInfo.textBox)),this.getAndShowTextBox(this.faceInfo.textPos.clone(),i,this.faceInfo.textBox),this.faceInfo.boxToClndLine&&this.OpMeasure.rootObject.remove(this.faceInfo.boxToClndLine),n||(l=this.faceInfo.sndClndPos,this.faceInfo.textPos.distanceToSquared(this.faceInfo.fstClndPos)<this.faceInfo.textPos.distanceToSquared(this.faceInfo.sndClndPos)&&(l=this.faceInfo.fstClndPos),this.faceInfo.boxToClndLine=this.createLineMesh2(l,this.faceInfo.textPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.faceInfo.boxToClndLine)),t&&((s={}).dimString=i,s.textPos=this.faceInfo.textPos.clone(),s.textBox=this.faceInfo.textBox,this.OpMeasure.boxInfos.push(s),this.clearFaceInfo(!0),this.lineAngleInfo.twoPlane&&this.clearLineAngleInfo(!0),this.ChangeMeasureFlag())}},r.prototype.createAndShow3DFaceAngleDimension=function(e,t){if(this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj&&("faceAngle"===this.measureType||"bodyAngle"===this.measureType)){var n=this.faceInfo.fstIntersect,i=this.faceInfo.sndIntersect;if(this.faceInfo.arcCenter){if(!this.faceInfo.fstClnd||!this.faceInfo.sndClnd)return}else{var r=(new THREE.Vector3).subVectors(i,n),o=this.faceInfo.firstFaceInfo.worldNormal.clone(),a=this.faceInfo.secondFaceInfo.worldNormal.clone(),s=(o.normalize(),a.normalize(),new THREE.Vector3),l=new THREE.Vector3;if(!this.getIntersectLineOfTwoPlane(n,o,i,a,s,l))return;var l=s.clone().add(l.clone().multiplyScalar(10)),s=(this.faceInfo.arcCenter=this.getProjectPntToLine(s,l,i),r.dot(o)),l=(new THREE.Vector3).subVectors(i,o.clone().multiplyScalar(s)),s=(new THREE.Vector3).crossVectors(o,a),a=n.clone().add(s.multiplyScalar(2)),s=(this.faceInfo.midLineEndPt=this.getProjectPntToLine(n,a,l),this.faceInfo.arcCenter.distanceTo(l)),a=i.distanceTo(l),l=Math.min(s,a),s=(this.isZero(l)&&(l=.001),(new THREE.Vector3).subVectors(this.faceInfo.midLineEndPt,this.faceInfo.arcCenter)),a=(new THREE.Vector3).subVectors(i,this.faceInfo.arcCenter),a=(s.normalize(),a.normalize(),this.faceInfo.sndClndPos=(new THREE.Vector3).addVectors(i,a.multiplyScalar(l)),this.faceInfo.arcCenter.distanceTo(this.faceInfo.sndClndPos));this.faceInfo.fstClndPos=(new THREE.Vector3).addVectors(this.faceInfo.arcCenter,s.multiplyScalar(a));l=(l=this.getAngle(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos))/Math.PI*180;this.faceInfo.dimString=l.toFixed(2)}this.faceInfo.textPos?(e&&(s=this.getProjectPntToPlane(this.faceInfo.arcCenter,this.faceInfo.fstClndPos,this.faceInfo.sndClndPos,e))&&this.faceInfo.textPos.copy(s),r=(new THREE.Vector3).subVectors(this.faceInfo.midLineEndPt,this.faceInfo.arcCenter),o=(new THREE.Vector3).subVectors(i,this.faceInfo.arcCenter),r.normalize(),o.normalize(),a=this.faceInfo.arcCenter.distanceTo(this.faceInfo.textPos),this.faceInfo.fstClndPos.addVectors(this.faceInfo.arcCenter,r.multiplyScalar(a)),this.faceInfo.sndClndPos.addVectors(this.faceInfo.arcCenter,o.multiplyScalar(a))):this.faceInfo.textPos=this.faceInfo.sndClndPos.clone(),this.faceInfo.fstToMidLine=this.createLineMesh2(n,this.faceInfo.midLineEndPt,this.appmaterialLine,1),this.faceInfo.fstToClndLine=this.createLineMesh2(this.faceInfo.midLineEndPt,this.faceInfo.fstClndPos,this.appmaterialLine,1),this.faceInfo.sndToClndLine=this.createLineMesh2(i,this.faceInfo.sndClndPos,this.appmaterialLine,1),this.faceInfo.arcMeshes=this.createAngleArcMeshes2(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos,this.ARCWIDTH,this.appmaterialLine),this.faceInfo.fstClnd=this.createCylinderMesh(this.faceInfo.arcMeshes[1].geometry.vertices[0],this.faceInfo.fstClndPos,this.appmaterialLine);var l=(new THREE.Vector3).subVectors(this.faceInfo.fstClndPos,this.faceInfo.arcMeshes[1].geometry.vertices[0]),e=(l.normalize(),this.OpMeasure.getScale(this.faceInfo.fstClnd,this.CYLINDERWIDTH)),s=(l.multiplyScalar(.5*this.faceInfo.fstClnd.geometry.parameters.height),this.faceInfo.fstClnd.oldPosition=this.faceInfo.fstClndPos.clone(),this.faceInfo.fstClnd.offsetPos=l.clone().multiplyScalar(-1),this.faceInfo.fstClnd.position.subVectors(this.faceInfo.fstClndPos,l.clone().multiplyScalar(e)),this.faceInfo.sndClnd=this.createCylinderMesh(this.faceInfo.arcMeshes[this.faceInfo.arcMeshes.length-2].geometry.vertices[0],this.faceInfo.sndClndPos,this.appmaterialLine),(new THREE.Vector3).subVectors(this.faceInfo.sndClndPos,this.faceInfo.arcMeshes[this.faceInfo.arcMeshes.length-2].geometry.vertices[0])),e=(s.normalize(),this.OpMeasure.getScale(this.faceInfo.sndClnd,this.CYLINDERWIDTH)),r=(s.multiplyScalar(.5*this.faceInfo.sndClnd.geometry.parameters.height),this.faceInfo.sndClnd.oldPosition=this.faceInfo.sndClndPos.clone(),this.faceInfo.sndClnd.offsetPos=s.clone().multiplyScalar(-1),this.faceInfo.sndClnd.position.subVectors(this.faceInfo.sndClndPos,s.clone().multiplyScalar(e)),this.getAngle(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.textPos)),o=this.getAngle(this.faceInfo.textPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos),a=this.getAngle(this.faceInfo.fstClndPos,this.faceInfo.arcCenter,this.faceInfo.sndClndPos),n=Math.abs(r+o-a)<.01,i=this.faceInfo.dimString+this.faceInfo.unit,l=(this.faceInfo.textBox=document.createElement("div"),this.faceInfo.textBox.className="section10",this.faceInfo.textBox.innerHTML=i,document.createElement("div")),s=(l.className="sectionPoint",this.faceInfo.textBox.appendChild(l),document.createElement("div"));if(s.className="sectionCross",this.faceInfo.textBox.appendChild(s),this.viewer.container.appendChild(this.faceInfo.textBox),n||(e=this.faceInfo.sndClndPos,this.faceInfo.textPos.distanceToSquared(this.faceInfo.fstClndPos)<this.faceInfo.textPos.distanceToSquared(this.faceInfo.sndClndPos)&&(e=this.faceInfo.fstClndPos),this.faceInfo.boxToClndLine=this.createLineMesh2(e,this.faceInfo.textPos,this.appmaterialLine,1)),t){var r={},o=(r.dimString=i,r.textPos=this.faceInfo.textPos.clone(),r.textBox=this.faceInfo.textBox,new THREE.Group),d=new THREE.Group;o.objectType="Group",d.objectType="Group",d.name="unsteady",d.add(this.faceInfo.fstToMidLine),d.add(this.faceInfo.fstToClndLine),d.add(this.faceInfo.sndToClndLine);for(var c=0;c<this.faceInfo.arcMeshes.length;c++)d.add(this.faceInfo.arcMeshes[c]);d.add(this.faceInfo.fstClnd),d.add(this.faceInfo.sndClnd),this.faceInfo.boxToClndLine&&d.add(this.faceInfo.boxToClndLine),this.OpMeasure.rootObject.remove(this.faceInfo.fstSelFaceObj),this.OpMeasure.rootObject.remove(this.faceInfo.sndSelFaceObj),o.add(this.faceInfo.fstSelFaceObj),o.add(this.faceInfo.sndSelFaceObj),o.add(d),this.OpMeasure.rootObject.add(o),Se.isMobileDevice()?(r.textBox.addEventListener("touchstart",this.touchstart,!1),r.textBox.addEventListener("touchend",this.touchend,!1),r.textBox.addEventListener("touchmove",this.touchmove,!1)):(r.textBox.addEventListener("mousedown",this.touchstart,!1),r.textBox.addEventListener("mouseup",this.touchend,!1),r.textBox.addEventListener("mousemove",this.touchmove,!1),r.textBox.addEventListener("mouseleave",this.mouseleave,!1),r.textBox.addEventListener("mouseenter",this.mouseenter,!1)),Se.isMobileDevice()?s.addEventListener("touchend",this.sectionCrossend,!1):(s.addEventListener("mousedown",this.sectionCrossend,!1),s.addEventListener("mouseleave",this.crossleave,!1),s.addEventListener("mouseenter",this.crossenter,!1)),r.textBox.setAttribute("mobile","up"),r.textBox.setAttribute("group",o.uuid),this.OpMeasure.unsteadyData[o.uuid]=this.DeepCopy(this.faceInfo,"Angle"),this.OpMeasure.boxInfos.push(r),this.clearFaceInfo(!0),this.lineAngleInfo.twoPlane&&this.clearLineAngleInfo(!0),Se.isMobileDevice()&&this.ChangeMeasureFlag()}}},r.prototype.changeFaceAngle=function(e){var t=this.OpMeasure.rootObject.getObjectByProperty("uuid",this.OpMeasure.unsteadyuuid),n=t.getObjectByName("unsteady");n&&t.remove(n);(n=new THREE.Group).name="unsteady",n.objectType="Group",t.add(n);var i=this.OpMeasure.unsteadyData[this.OpMeasure.unsteadyuuid],t=i.fstIntersect,r=i.sndIntersect;if(i.arcCenter){if(!i.fstClnd||!i.sndClnd)return}else{var o=(new THREE.Vector3).subVectors(r,t),a=i.firstFaceInfo.worldNormal.clone(),s=i.secondFaceInfo.worldNormal.clone(),l=(a.normalize(),s.normalize(),new THREE.Vector3),d=new THREE.Vector3;if(!this.getIntersectLineOfTwoPlane(t,a,r,s,l,d))return;var d=l.clone().add(d.clone().multiplyScalar(10)),l=(i.arcCenter=this.getProjectPntToLine(l,d,r),o.dot(a)),d=(new THREE.Vector3).subVectors(r,a.clone().multiplyScalar(l)),l=(new THREE.Vector3).crossVectors(a,s),s=t.clone().add(l.multiplyScalar(2)),l=(i.midLineEndPt=this.getProjectPntToLine(t,s,d),i.arcCenter.distanceTo(d)),s=r.distanceTo(d),d=Math.min(l,s),l=(this.isZero(d)&&(d=.001),(new THREE.Vector3).subVectors(i.midLineEndPt,i.arcCenter)),s=(new THREE.Vector3).subVectors(r,i.arcCenter),s=(l.normalize(),s.normalize(),i.sndClndPos=(new THREE.Vector3).addVectors(r,s.multiplyScalar(d)),i.arcCenter.distanceTo(i.sndClndPos));i.fstClndPos=(new THREE.Vector3).addVectors(i.arcCenter,l.multiplyScalar(s));d=(d=this.getAngle(i.fstClndPos,i.arcCenter,i.sndClndPos))/Math.PI*180;i.dimString=d.toFixed(2)}i.textPos?(e&&(l=this.getProjectPntToPlane(i.arcCenter,i.fstClndPos,i.sndClndPos,e))&&i.textPos.copy(l),o=(new THREE.Vector3).subVectors(i.midLineEndPt,i.arcCenter),a=(new THREE.Vector3).subVectors(r,i.arcCenter),o.normalize(),a.normalize(),s=i.arcCenter.distanceTo(i.textPos),i.fstClndPos.addVectors(i.arcCenter,o.multiplyScalar(s)),i.sndClndPos.addVectors(i.arcCenter,a.multiplyScalar(s))):i.textPos=i.sndClndPos.clone(),i.fstToMidLine||(i.fstToMidLine=this.createLineMesh2(t,i.midLineEndPt,this.appmaterialLine,1)),i.fstToClndLine=this.createLineMesh2(i.midLineEndPt,i.fstClndPos,this.appmaterialLine,1),i.sndToClndLine=this.createLineMesh2(r,i.sndClndPos,this.appmaterialLine,1),i.arcMeshes=this.createAngleArcMeshes2(i.fstClndPos,i.arcCenter,i.sndClndPos,this.ARCWIDTH,this.appmaterialLine),i.fstClnd=this.createCylinderMesh(i.arcMeshes[1].geometry.vertices[0],i.fstClndPos,this.appmaterialLine);d=(new THREE.Vector3).subVectors(i.fstClndPos,i.arcMeshes[1].geometry.vertices[0]),d.normalize(),e=this.OpMeasure.getScale(i.fstClnd,this.CYLINDERWIDTH),d.multiplyScalar(.5*i.fstClnd.geometry.parameters.height),i.fstClnd.oldPosition=i.fstClndPos.clone(),i.fstClnd.offsetPos=d.clone().multiplyScalar(-1),i.fstClnd.position.subVectors(i.fstClndPos,d.clone().multiplyScalar(e)),i.sndClnd=this.createCylinderMesh(i.arcMeshes[i.arcMeshes.length-2].geometry.vertices[0],i.sndClndPos,this.appmaterialLine),l=(new THREE.Vector3).subVectors(i.sndClndPos,i.arcMeshes[i.arcMeshes.length-2].geometry.vertices[0]),l.normalize(),e=this.OpMeasure.getScale(i.sndClnd,this.CYLINDERWIDTH),l.multiplyScalar(.5*i.sndClnd.geometry.parameters.height),i.sndClnd.oldPosition=i.sndClndPos.clone(),i.sndClnd.offsetPos=l.clone().multiplyScalar(-1),i.sndClnd.position.subVectors(i.sndClndPos,l.clone().multiplyScalar(e)),o=this.getAngle(i.fstClndPos,i.arcCenter,i.textPos),a=this.getAngle(i.textPos,i.arcCenter,i.sndClndPos),s=this.getAngle(i.fstClndPos,i.arcCenter,i.sndClndPos);Math.abs(o+a-s)<.01||(t=i.sndClndPos,i.textPos.distanceToSquared(i.fstClndPos)<i.textPos.distanceToSquared(i.sndClndPos)&&(t=i.fstClndPos),i.boxToClndLine=this.createLineMesh2(t,i.textPos,this.appmaterialLine,1)),n.add(i.fstToMidLine),n.add(i.fstToClndLine),n.add(i.sndToClndLine);for(var c=0;c<i.arcMeshes.length;c++)n.add(i.arcMeshes[c]);n.add(i.fstClnd),n.add(i.sndClnd),i.boxToClndLine&&n.add(i.boxToClndLine);for(var h=0;h<this.OpMeasure.boxInfos.length;h++){var u=this.OpMeasure.boxInfos[h];if(u.textBox.getAttribute("group")==this.OpMeasure.unsteadyuuid){u.textPos=i.textPos;break}}this.OpMeasure.viewer.render()},r.prototype.getIntersectLineOfTwoPlane=function(e,t,n,i,r,o){if(!r||!o)return!1;t.normalize(),i.normalize();var a=Math.abs(t.dot(i));if(Math.abs(a-1)<.001)return!1;o.crossVectors(t,i);a=t.clone().cross(o),t=(new THREE.Vector3).subVectors(n,e).dot(i),o=a.dot(i),n=t/(o=this.isZero(o)?1e-6:o);return r.addVectors(e,a.clone().multiplyScalar(n)),!0},r.prototype.getIntersectPointOfTwoLine=function(e,t,n,i){var r;return e.distanceToSquared(n)<1e-8?n.clone():(r=(new THREE.Vector3).crossVectors(t,i),(new THREE.Vector3).crossVectors(r,t),r=(new THREE.Vector3).crossVectors(r,i),i=(new THREE.Vector3).subVectors(n,e).dot(r)/r.dot(t),(n=new THREE.Vector3).addVectors(e,t.clone().multiplyScalar(i)),n)},r.prototype.measureLineAngle=function(e,t,n,i){if(""==this.lineAngleInfo.unit&&(this.lineAngleInfo.unit="°"),this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj)this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null);else{var r=this.viewer,e=this.doRaycasterPick(e,t,!0);if(e&&0!=e.length){t=null;if(t=r.ndsModel||e[0].object instanceof THREE.Line||e[0].object instanceof THREE.LineSegments?e[0]:t){r=this.getSelectInfoFromIntersect(t);if(r)if("line"!=r.type||this.Bline(r))if(1==n)this.isTwoTopolInfoTheSame(this.lineAngleInfo.preSelLineInfo,r)||-1!=i.indexOf(r.type)&&(this.lineAngleInfo.preSelLineInfo=r,this.lineAngleInfo.preSelLineObj)&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null);else if(this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null),this.lineAngleInfo.firstLineInfo)if(this.isTwoTopolInfoTheSame(this.lineAngleInfo.firstLineInfo,r))this.lineAngleInfo.firstLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.firstLineObj),this.lineAngleInfo.firstLineObj=null,this.lineAngleInfo.firstLineInfo=null);else if(-1!=i.indexOf(r.type)||-1==i.indexOf("plane")||"cylinder"!==r.type&&"other"!==r.type){if(-1!=i.indexOf(r.type)){this.OpMeasure.InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN&&(this.OpMeasure.InfoType=ve.INFOTYPE.MEASURENOTICEBEGIN);var o,a,e=new THREE.Plane;if(this.lineAngleInfo.firstLineInfo.type==r.type)s=this.getLineStartEndPoints(this.lineAngleInfo.firstLineInfo),o=this.getLineStartEndPoints(r);else{"line"==this.lineAngleInfo.firstLineInfo.type?(s=this.getLineStartEndPoints(this.lineAngleInfo.firstLineInfo),(e=new THREE.Plane).setFromNormalAndCoplanarPoint(r.worldNormal,r.worldOrigin),a=r.intersect):"plane"==this.lineAngleInfo.firstLineInfo.type&&(s=this.getLineStartEndPoints(r),e.setFromNormalAndCoplanarPoint(this.lineAngleInfo.firstLineInfo.worldNormal,this.lineAngleInfo.firstLineInfo.worldOrigin),a=this.lineAngleInfo.firstLineInfo.intersect);var s,t=this.intersectLine(s.start,s.end,e);if(!t)return void("line"==r.type?this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.LINEPARALLELPLANE):"plane"==r.type&&this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.PLANEPARALLELLINE));var n=new THREE.Vector3,l=(e.projectPoint(s.start,n),new THREE.Vector3);e.projectPoint(s.end,l),o=n.distanceTo(l)<1e-5?{start:t,end:a}:n.distanceTo(t)<1e-4?{start:t,end:l}:{start:t,end:n}}s&&o&&((e=(new THREE.Vector3).subVectors(s.end,s.start)).normalize(),(a=(new THREE.Vector3).subVectors(o.end,o.start)).normalize(),l=e.dot(a),1-Math.abs(l)<1e-6?(this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null),this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.LINEPARALLEL)):(this.lineAngleInfo.secondLineInfo=r,this.lineAngleInfo.firstLineInfo.start=s.start.clone(),this.lineAngleInfo.firstLineInfo.end=s.end.clone(),this.lineAngleInfo.secondLineInfo.start=o.start.clone(),this.lineAngleInfo.secondLineInfo.end=o.end.clone(),this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null)))}}else this.OpMeasure.PostInfo(ve.INFOTYPE.NOTFACE);else-1!=i.indexOf(r.type)||-1==i.indexOf("plane")||"cylinder"!==r.type&&"other"!==r.type?-1!=i.indexOf(r.type)&&(this.lineAngleInfo.firstLineInfo=r,this.OpMeasure.InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN)&&(this.OpMeasure.InfoType=ve.INFOTYPE.MEASURENOTICEBEGIN):this.OpMeasure.PostInfo(ve.INFOTYPE.NOTFACE);else this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null)}}else this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null)}},r.prototype.updateLineAngleScene=function(e){var t;"LineAngle"!==this.measureType&&"LineFaceAngle"!==this.measureType&&"angle"!==this.measureType||(this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null):!(!e||"true"!==e.toLowerCase())?this.lineAngleInfo.preSelLineInfo&&!this.lineAngleInfo.preSelLineObj&&("line"==this.lineAngleInfo.preSelLineInfo.type&&(t=this.createLine(this.lineAngleInfo.preSelLineInfo,!0)),t="plane"==this.lineAngleInfo.preSelLineInfo.type?this.createFace(this.lineAngleInfo.preSelLineInfo,!0):t)&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.preSelLineObj=t):(this.lineAngleInfo.firstLineInfo&&!this.lineAngleInfo.firstLineObj&&("line"==this.lineAngleInfo.firstLineInfo.type&&(t=this.createLine(this.lineAngleInfo.firstLineInfo,!1)),"plane"==this.lineAngleInfo.firstLineInfo.type&&(t=this.createFace(this.lineAngleInfo.firstLineInfo,!1)),t="helpline"==this.lineAngleInfo.firstLineInfo.type?this.createLineMesh2(this.lineAngleInfo.firstLineInfo.start,this.lineAngleInfo.firstLineInfo.end,this.materialLine,1):t)&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.firstLineObj=t),this.lineAngleInfo.secondLineInfo&&!this.lineAngleInfo.secondLineObj&&("line"==this.lineAngleInfo.secondLineInfo.type&&(t=this.createLine(this.lineAngleInfo.secondLineInfo,!1)),"plane"==this.lineAngleInfo.secondLineInfo.type&&(t=this.createFace(this.lineAngleInfo.secondLineInfo,!1)),t="helpline"==this.lineAngleInfo.secondLineInfo.type?this.createLineMesh2(this.lineAngleInfo.secondLineInfo.start,this.lineAngleInfo.secondLineInfo.end,this.materialLine,1):t)&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.secondLineObj=t),this.lineAngleInfo.firstHelpPointInfo&&!this.lineAngleInfo.firstHelpPointobj&&(t=this.createPointMesh(this.lineAngleInfo.firstHelpPointInfo.point,this.materialPoint,this.POINTSIZE))&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.firstHelpPointobj=t),this.lineAngleInfo.secHelpPointInfo&&!this.lineAngleInfo.secHelpPointobj&&(t=this.createPointMesh(this.lineAngleInfo.secHelpPointInfo.point,this.materialPoint,this.POINTSIZE))&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.secHelpPointobj=t),this.lineAngleInfo.thrHelpPointInfo&&!this.lineAngleInfo.thrHelpPointobj&&(this.lineAngleInfo.secHelpPointobj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.secHelpPointobj),this.lineAngleInfo.secHelpPointInfo=null),this.lineAngleInfo.firstHelpPointobj)&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.firstHelpPointobj),this.lineAngleInfo.firstHelpPointInfo=null)))},r.prototype.measurefaceAngle=function(e,t,n){if(""==this.lineAngleInfo.unit&&(this.lineAngleInfo.unit="°"),this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj)this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null,this.faceInfo.preSelFaceInfo=null);else{this.viewer;var i=this.doRaycasterPick(e,t,!1);if(i){for(var r=0;r<i.length;){var o=this.getSelectInfoFromIntersect(i[r]);if(o){if("plane"!=o.type){n||(null!=this.faceInfo.firstFaceInfo?this.OpMeasure.PostInfo(ve.INFOTYPE.NOTFACESECOND):this.OpMeasure.PostInfo(ve.INFOTYPE.NOTFACE));break}if(1==n)this.isTwoTopolInfoTheSame(this.faceInfo.preSelFaceInfo,o)||(this.faceInfo.preSelFaceInfo=o,this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null));else if(this.OpMeasure.InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN&&(this.OpMeasure.InfoType=ve.INFOTYPE.MEASURENOTICEBEGIN),this.faceInfo.firstFaceInfo)if(this.isTwoTopolInfoTheSame(this.faceInfo.firstFaceInfo,o))this.faceInfo.fstSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.fstSelFaceObj),this.faceInfo.fstSelFaceObj=null,this.faceInfo.firstFaceInfo=null);else{var a=this.faceInfo.firstFaceInfo.worldNormal.clone(),s=o.worldNormal.clone(),l=(a.normalize(),s.normalize(),a.dot(s)),a=null,s=null;if(Math.abs(Math.abs(l)-1)<1e-5)return this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.PLANEPARALLEL),this.faceInfo.preSelFaceInfo=null,void(this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null));this.faceInfo.secondFaceInfo=o,this.faceInfo.sndIntersect=o.intersect,this.faceInfo.preSelFaceInfo=null,this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null)}else this.faceInfo.firstFaceInfo=o,this.faceInfo.fstIntersect=o.intersect,this.faceInfo.preSelFaceInfo=null,this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null);return}r++}1==n&&this.faceInfo.preSelFaceInfo&&(this.faceInfo.preSelFaceInfo=null,this.faceInfo.preSelFaceObj)&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null)}else this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null,this.faceInfo.preSelFaceInfo=null),this.viewer.outlinePass&&this.viewer.outlinePass.enabled&&(this.viewer.outlinePass.tempSelectedObjects.length=0)}},r.prototype.updateFaceAngleScene=function(e){var t,n,i,r,o;"faceAngle"===this.measureType&&(this.faceInfo.fstSelFaceObj&&this.faceInfo.sndSelFaceObj?this.faceInfo.preSelFaceObj&&(this.OpMeasure.rootObject.remove(this.faceInfo.preSelFaceObj),this.faceInfo.preSelFaceObj=null,this.faceInfo.preSelFaceInfo=null):(!(!e||"true"!==e.toLowerCase())?this.faceInfo.preSelFaceInfo&&!this.faceInfo.preSelFaceObj&&(t=this.createFace(this.faceInfo.preSelFaceInfo,!0))&&((e=[]).push(t),this.viewer.outlinePass&&this.viewer.outlinePass.enabled&&(this.viewer.outlinePass.tempSelectedObjects=e),this.OpMeasure.rootObject.add(t),this.faceInfo.preSelFaceObj=t):(this.faceInfo.firstFaceInfo&&!this.faceInfo.fstSelFaceObj&&(t=this.createFace(this.faceInfo.firstFaceInfo,!1))&&(this.OpMeasure.rootObject.add(t),this.faceInfo.fstSelFaceObj=t),this.faceInfo.secondFaceInfo&&!this.faceInfo.sndSelFaceObj&&(t=this.createFace(this.faceInfo.secondFaceInfo,!1))&&(this.OpMeasure.rootObject.add(t),this.faceInfo.sndSelFaceObj=t)),this.faceInfo.fstIntersect&&this.faceInfo.sndIntersect&&(e=this.faceInfo.fstIntersect,t=this.faceInfo.sndIntersect,this.lineAngleInfo.firstLineInfo=this.faceInfo.firstFaceInfo,this.lineAngleInfo.secondLineInfo=this.faceInfo.secondFaceInfo,n=this.faceInfo.firstFaceInfo.worldNormal.clone(),i=this.faceInfo.secondFaceInfo.worldNormal.clone(),n.normalize(),i.normalize(),r=new THREE.Vector3,o=new THREE.Vector3,this.getIntersectLineOfTwoPlane(e,n,t,i,r,o),this.lineAngleInfo.firstLineInfo.start=e.clone(),this.lineAngleInfo.firstLineInfo.end=r.clone(),this.getIntersectLineOfTwoPlane(t,i,e,n,r,o),this.lineAngleInfo.secondLineInfo.start=t.clone(),this.lineAngleInfo.secondLineInfo.end=r.clone())))},r.prototype.measureBodyAngle=function(e,t,n,i){if(""==this.lineAngleInfo.unit&&(this.lineAngleInfo.unit="°"),""==this.faceInfo.unit&&(this.faceInfo.unit="°"),this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj)this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null);else{var r=this.viewer,e=this.doRaycasterPick(e,t,!0);if(e&&0!=e.length){t=null;if(t=r.ndsModel||e[0].object instanceof THREE.Line||e[0].object instanceof THREE.LineSegments?e[0]:t){r=this.getSelectInfoFromIntersect(t);if(r)if("bodyAngle"==this.measureType&&-1==i.indexOf(r.type))this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null);else if("line"!=r.type||this.Bline(r))if(1==n)this.isTwoTopolInfoTheSame(this.lineAngleInfo.preSelLineInfo,r)||-1!=i.indexOf(r.type)&&(this.lineAngleInfo.preSelLineInfo=r,this.lineAngleInfo.preSelLineObj)&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null);else if(this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null),this.lineAngleInfo.firstLineInfo){if(this.isTwoTopolInfoTheSame(this.lineAngleInfo.firstLineInfo,r))this.lineAngleInfo.firstLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.firstLineObj),this.lineAngleInfo.firstLineObj=null,this.lineAngleInfo.firstLineInfo=null);else if(-1==i.indexOf(r.type)&&-1!=i.indexOf("plane")&&"other"===r.type)this.OpMeasure.PostInfo(ve.INFOTYPE.NOTFACE);else if(-1!=i.indexOf(r.type)){this.OpMeasure.InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN&&(this.OpMeasure.InfoType=ve.INFOTYPE.MEASURENOTICEBEGIN);var o,e=new THREE.Plane;if("line"!=this.lineAngleInfo.firstLineInfo.type&&"cylinder"!=this.lineAngleInfo.firstLineInfo.type&&"cone"!=this.lineAngleInfo.firstLineInfo.type||"line"!=r.type&&"cylinder"!=r.type&&"cone"!=r.type){if("plane"==this.lineAngleInfo.firstLineInfo.type&&"plane"==r.type)return this.lineAngleInfo.twoPlane=!0,t=this.lineAngleInfo.firstLineInfo.worldNormal.clone(),n=r.worldNormal.clone(),t.normalize(),n.normalize(),t=t.dot(n),Math.abs(Math.abs(t)-1)<1e-5?(this.OpMeasure.PostInfo(ve.INFOTYPE.TWOBODYPARALLEL),void(this.lineAngleInfo.twoPlane=!1)):(this.faceInfo.firstFaceInfo=this.lineAngleInfo.firstLineInfo,this.faceInfo.fstIntersect=this.lineAngleInfo.firstLineInfo.intersect,this.faceInfo.secondFaceInfo=r,this.faceInfo.sndIntersect=r.intersect,void(this.lineAngleInfo.secondLineInfo=r));"line"!=this.lineAngleInfo.firstLineInfo.type&&"cylinder"!=this.lineAngleInfo.firstLineInfo.type&&"cone"!=this.lineAngleInfo.firstLineInfo.type||"plane"!=r.type?"plane"!=this.lineAngleInfo.firstLineInfo.type||"line"!=r.type&&"cylinder"!=r.type&&"cone"!=r.type||(a=this.getLineStartEndPoints(r),e.setFromNormalAndCoplanarPoint(this.lineAngleInfo.firstLineInfo.worldNormal,this.lineAngleInfo.firstLineInfo.worldOrigin),o=this.lineAngleInfo.firstLineInfo.intersect):(a=this.getLineStartEndPoints(this.lineAngleInfo.firstLineInfo),(e=new THREE.Plane).setFromNormalAndCoplanarPoint(r.worldNormal,r.worldOrigin),o=r.intersect);var a,n=this.intersectLine(a.start,a.end,e);if(!n)return void("line"==r.type||"cylinder"==r.type||"cone"==r.type?this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.LINEPARALLELPLANE):"plane"==r.type&&this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.PLANEPARALLELLINE));var t=new THREE.Vector3,s=(e.projectPoint(a.start,t),new THREE.Vector3);e.projectPoint(a.end,s),o=t.distanceTo(s)<1e-5?{start:n,end:o}:t.distanceTo(n)<1e-4?{start:n,end:s}:{start:n,end:t}}else a=this.getLineStartEndPoints(this.lineAngleInfo.firstLineInfo),o=this.getLineStartEndPoints(r);a&&o&&((e=(new THREE.Vector3).subVectors(a.end,a.start)).normalize(),(s=(new THREE.Vector3).subVectors(o.end,o.start)).normalize(),n=e.dot(s),1-Math.abs(n)<1e-6?(this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null),"line"==this.lineAngleInfo.firstLineInfo.type&&"line"==r.type||"line"==this.lineAngleInfo.firstLineInfo.type&&"line"==r.type||"cylinder"!=this.lineAngleInfo.firstLineInfo.type&&"cone"!=this.lineAngleInfo.firstLineInfo.type||"cylinder"!=r.type&&"cone"!=r.type?this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.LINEPARALLEL):this.OpMeasure.PostInfo("bodyAngle"==this.measureType?ve.INFOTYPE.TWOBODYPARALLEL:ve.INFOTYPE.AXISNOPARALLEL)):(this.lineAngleInfo.secondLineInfo=r,this.lineAngleInfo.firstLineInfo.start=a.start.clone(),this.lineAngleInfo.firstLineInfo.end=a.end.clone(),this.lineAngleInfo.secondLineInfo.start=o.start.clone(),this.lineAngleInfo.secondLineInfo.end=o.end.clone(),this.lineAngleInfo.preSelLineInfo=null,this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null)))}}else-1==i.indexOf(r.type)&&-1!=i.indexOf("plane")&&"other"===r.type?this.OpMeasure.PostInfo(ve.INFOTYPE.NOTFACE):-1!=i.indexOf(r.type)&&(this.lineAngleInfo.firstLineInfo=r,this.OpMeasure.InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN)&&(this.OpMeasure.InfoType=ve.INFOTYPE.MEASURENOTICEBEGIN);else this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null)}}else this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null)}},r.prototype.updateBodyAngleScene=function(e){var t,n,i,r,o;"bodyAngle"===this.measureType&&(this.lineAngleInfo.firstLineObj&&this.lineAngleInfo.secondLineObj?this.lineAngleInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineAngleInfo.preSelLineObj),this.lineAngleInfo.preSelLineObj=null,this.lineAngleInfo.preSelLineInfo=null):(!(!e||"true"!==e.toLowerCase())?this.lineAngleInfo.preSelLineInfo&&!this.lineAngleInfo.preSelLineObj&&("line"==this.lineAngleInfo.preSelLineInfo.type&&(t=this.createLine(this.lineAngleInfo.preSelLineInfo,!0)),"plane"==this.lineAngleInfo.preSelLineInfo.type&&(t=this.createFace(this.lineAngleInfo.preSelLineInfo,!0)),"cylinder"==this.lineAngleInfo.preSelLineInfo.type&&(t=this.createFace(this.lineAngleInfo.preSelLineInfo,!0)),t="cone"==this.lineAngleInfo.preSelLineInfo.type?this.createFace(this.lineAngleInfo.preSelLineInfo,!0):t)&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.preSelLineObj=t):(this.lineAngleInfo.firstLineInfo&&!this.lineAngleInfo.firstLineObj&&("line"==this.lineAngleInfo.firstLineInfo.type&&(t=this.createLine(this.lineAngleInfo.firstLineInfo,!1)),"plane"==this.lineAngleInfo.firstLineInfo.type&&(t=this.createFace(this.lineAngleInfo.firstLineInfo,!1)),"cylinder"==this.lineAngleInfo.firstLineInfo.type&&(t=this.createFace(this.lineAngleInfo.firstLineInfo,!0)),t="cone"==this.lineAngleInfo.firstLineInfo.type?this.createFace(this.lineAngleInfo.firstLineInfo,!0):t)&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.firstLineObj=t),this.lineAngleInfo.secondLineInfo&&!this.lineAngleInfo.secondLineObj&&("line"==this.lineAngleInfo.secondLineInfo.type&&(t=this.createLine(this.lineAngleInfo.secondLineInfo,!1)),"plane"==this.lineAngleInfo.secondLineInfo.type&&(t=this.createFace(this.lineAngleInfo.secondLineInfo,!1),this.faceInfo.fstSelFaceObj=this.lineAngleInfo.firstLineObj,this.faceInfo.sndSelFaceObj=t),"cylinder"==this.lineAngleInfo.secondLineInfo.type&&(t=this.createFace(this.lineAngleInfo.secondLineInfo,!0)),t="cone"==this.lineAngleInfo.secondLineInfo.type?this.createFace(this.lineAngleInfo.secondLineInfo,!0):t)&&(this.OpMeasure.rootObject.add(t),this.lineAngleInfo.secondLineObj=t)),this.faceInfo.fstIntersect&&this.faceInfo.sndIntersect&&(e=this.faceInfo.fstIntersect,t=this.faceInfo.sndIntersect,this.lineAngleInfo.firstLineInfo=this.faceInfo.firstFaceInfo,this.lineAngleInfo.secondLineInfo=this.faceInfo.secondFaceInfo,n=this.faceInfo.firstFaceInfo.worldNormal.clone(),i=this.faceInfo.secondFaceInfo.worldNormal.clone(),n.normalize(),i.normalize(),r=new THREE.Vector3,o=new THREE.Vector3,this.getIntersectLineOfTwoPlane(e,n,t,i,r,o),this.lineAngleInfo.firstLineInfo.start=e.clone(),this.lineAngleInfo.firstLineInfo.end=r.clone(),this.getIntersectLineOfTwoPlane(t,i,e,n,r,o),this.lineAngleInfo.secondLineInfo.start=t.clone(),this.lineAngleInfo.secondLineInfo.end=r.clone())))},(un.prototype=Object.create(h.prototype)).OperatorStart=function(e){switch(this.measureType=e,this.measureType){case"TotalArea":var t=this.viewer.getObjectProperty(this.viewer.ndsModel.rootBodyNode);this.viewer.dispatchAsyncEvent({type:"BodyTotalAreaEvent",totalArea:t.area,modelUnit:t.unit});break;case"TotalVolume":t=this.viewer.getObjectProperty(this.viewer.ndsModel.rootBodyNode);this.viewer.dispatchAsyncEvent({type:"BodyTotalVolumeEvent",totalVolume:t.volume,modelUnit:t.unit});break;case"BoundingBox":this.measureBoundingBox(!0),_e.enableBroadcast&&_e.broadcastMajor&&this.viewer.dispatchEvent({type:"broadcastEvent"});break;case"BodyArea":case"BodyVolume":this.OpMeasure.PostInfo(ve.INFOTYPE.BODY);break;case"bodyBoundingBox":Se.isMobileDevice()||this.OpMeasure.PostInfo(ve.INFOTYPE.BODY)}},un.prototype.onNMouseMove=function(e,t){switch(this.measureType){case"BodyArea":case"BodyVolume":case"bodyBoundingBox":this.measureBodyVolumeAndAreaPre(e,t,this.measureType)}},un.prototype.onLMouseClick=function(e,t,n){switch(this.ClearmeasureBodyVolumeAndAreaPre(),this.measureType){case"BodyArea":this.measureBodyVolumeAndArea(e,t,"FaceMeasure",n);break;case"BodyVolume":this.measureBodyVolumeAndArea(e,t,"VolumeMeasure",n);break;case"bodyBoundingBox":this.measureBodyBoundingBox(e,t)}},un.prototype.measureBodyVolumeAndAreaPre=function(e,t,n){var i=this.getIntersectsByPriorityOfLine(e,t),e=!1;if(this.preSelectBodyMat&&this.preSelectBody?(this.preSelectBody.setUserMaterial(this.preSelectBodyMat),e=!0,this.preSelectBodyMat=null):this.preSelectBody&&(this.preSelectBody.setUserMaterial(null),e=!0),i&&0<i.length){for(var r=0;r<i.length;){var o=this.viewer.ndsModel?i[r].object:this.FindParentElement(i[r].object);if(null!=o){_e.HideLeafBody&&(a=o.parent.FirstVisibleNode||0,o.parent.children[a].uuid!=o.uuid)&&(o=o.parent.children[a]),this.preSelectBody=o;var a=this.preSelectBody.getUserMaterial();this.preSelectBodyMat=a||null,this.preSelectBody.setUserMaterial(this.materialPreSelectMeshopacity);break}r++}this.OpMeasure.render()}else this.preSelectBody=null,e&&this.OpMeasure.render()},un.prototype.measureBodyBoundingBox=function(e,t){var n=this.getIntersectsByPriorityOfLine(e,t);if(n&&0<n.length){for(var i=0;i<n.length;){var r=this.viewer.ndsModel?n[i].object:this.FindParentElement(n[i].object);if(null!=r)break;i++}if(null!=r){_e.HideLeafBody?(r=r.parent,(e=this.viewer.ndsModel.getBodyBoundingBox(r))&&((m=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3])[0].set(e.min.x,e.min.y,e.min.z),m[1].set(e.min.x,e.min.y,e.max.z),m[2].set(e.min.x,e.max.y,e.min.z),m[3].set(e.min.x,e.max.y,e.max.z),m[4].set(e.max.x,e.min.y,e.min.z),m[5].set(e.max.x,e.min.y,e.max.z),m[6].set(e.max.x,e.max.y,e.min.z),m[7].set(e.max.x,e.max.y,e.max.z))):m=this.viewer.ndsModel.getBodyBoundingBoxTrue(r),this.OpMeasure.boundingboxmesh&&(this.OpMeasure.rootObject.remove(this.OpMeasure.boundingboxmesh),this.OpMeasure.boundingboxmesh=null);for(var o=0,a=this.OpMeasure.boundingboxInfos.length;o<a;o++){var s=this.OpMeasure.boundingboxInfos[o];this.viewer.container.removeChild(s.textBox),s.textPos=null,s.textBox=null}this.OpMeasure.boundingboxInfos.splice(0,this.OpMeasure.boundingboxInfos.length),this.OpMeasure.boundingboxmesh=this.createBodyBoundingBox(m),this.distanceInfo.unit=this.getUnitString(),this.OpMeasure.rootObject.add(this.OpMeasure.boundingboxmesh);var t=new THREE.Vector3,e=t.subVectors(m[7],m[3]).length(),l=t.subVectors(m[7],m[5]).length(),d=t.subVectors(m[7],m[6]).length(),c=this.viewer.getDispalyModelUnit(e),c=(e*=c.scale,l*=c.scale,d*=c.scale,this.getUnitStringmap(c.unit)),e=e.toFixed(2)+c,l=l.toFixed(2)+c,d=d.toFixed(2)+c,c=document.createElement("div"),h=(c.style.position="absolute",c.style.color="white",c.style.zIndex=3,c.style.backgroundColor="rgba(115,0,230,0.75)",c.style.userSelect="none",c.style.pointerEvents="none",this.viewer.container.appendChild(c),document.createElement("div")),u=(h.style.position="absolute",h.style.color="white",h.style.zIndex=3,h.style.backgroundColor="rgba(115,0,230,0.75)",h.style.userSelect="none",h.style.pointerEvents="none",this.viewer.container.appendChild(h),document.createElement("div")),p=(u.style.position="absolute",u.style.color="white",u.style.zIndex=3,u.style.backgroundColor="rgba(115,0,230,0.75)",u.style.userSelect="none",u.style.pointerEvents="none",this.viewer.container.appendChild(u),t.clone().addVectors(m[7],m[3]).divideScalar(2)),f=t.clone().addVectors(m[7],m[5]).divideScalar(2),t=t.clone().addVectors(m[7],m[6]).divideScalar(2),m=(this.getAndShowTextBox(p.clone(),e,c),this.getAndShowTextBox(f.clone(),l,h),this.getAndShowTextBox(t.clone(),d,u),{}),e=(m.dimString=e,m.textPos=p.clone(),m.textBox=c,this.OpMeasure.boundingboxInfos.push(m),{}),p=(e.dimString=l,e.textPos=f.clone(),e.textBox=h,this.OpMeasure.boundingboxInfos.push(e),{});p.dimString=d,p.textPos=t.clone(),p.textBox=u,this.OpMeasure.boundingboxInfos.push(p)}}else this.measureBoundingBox(!1)},un.prototype.createBodyBoundingBox=function(e){var t=new Float32Array(24),n=(t[0]=e[0].x,t[1]=e[0].y,t[2]=e[0].z,t[3]=e[1].x,t[4]=e[1].y,t[5]=e[1].z,t[6]=e[2].x,t[7]=e[2].y,t[8]=e[2].z,t[9]=e[3].x,t[10]=e[3].y,t[11]=e[3].z,t[12]=e[4].x,t[13]=e[4].y,t[14]=e[4].z,t[15]=e[5].x,t[16]=e[5].y,t[17]=e[5].z,t[18]=e[6].x,t[19]=e[6].y,t[20]=e[6].z,t[21]=e[7].x,t[22]=e[7].y,t[23]=e[7].z,new Uint16Array([0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,2,6,3,7])),i=new THREE.BufferGeometry;return i.setIndex(new THREE.BufferAttribute(n,1)),i.addAttribute("position",new THREE.BufferAttribute(t,3)),(n=new THREE.LineSegments(i,this.materialBoxLine)).objectType="BodyBoundingBox",n.box=e,n},un.prototype.measureBodyVolumeAndArea=function(e,t,n,i){var r=this.getIntersectsByPriorityOfLine(e,t);if(r&&0<r.length)for(var o=0;o<r.length;){if(null!=(this.viewer.ndsModel?r[o].object:this.FindParentElement(r[o].object)))break;o++}Se.isMobileDevice()&&this.ChangeMeasureFlag(),this.viewer.selectionManager.selectByClick(e,t,i)},(pn.prototype=Object.create(h.prototype)).OperatorStart=function(e){this.measureType=e,this.viewer.onOpChanged({id:"coordinate"}),this.coordinatediv||(this.coordinatediv=document.createElement("div"),this.coordinatediv.className="ActiveCoordinate",this.coordinatediv.style.position="absolute",this.coordinatediv.style.color="white",this.coordinatediv.style.zIndex=3,this.coordinatediv.style.backgroundColor="rgba(115,0,230,0.75)",this.coordinatediv.style.userSelect="none",this.coordinatediv.style.pointerEvents="none",this.viewer.container.appendChild(this.coordinatediv)),Se.isMobileDevice()&&this.OpMeasure.PostInfo(ve.INFOTYPE.COORDINATEPOINT)},pn.prototype.onNMouseMove=function(e,t){this.coordinatediv||(this.coordinatediv=document.createElement("div"),this.coordinatediv.className="ActiveCoordinate",this.coordinatediv.style.position="absolute",this.coordinatediv.style.color="white",this.coordinatediv.style.zIndex=3,this.coordinatediv.style.backgroundColor="rgba(115,0,230,0.75)",this.coordinatediv.style.userSelect="none",this.coordinatediv.style.pointerEvents="none",this.viewer.container.appendChild(this.coordinatediv));var n,i,r,o,a,s,l=48;Se.isMobileDevice()&&this.viewer.is2DModel&&(l=0),this.previewSnappedPoint(e+l,t+l,!0),this.snappedPoint?(n="X:"+parseFloat(this.snappedPoint.x.toFixed(4).toString())+"<br>Y:"+parseFloat(this.snappedPoint.y.toFixed(4).toString()),i=this.snappedPoint.clone(),this.getAndShowTextBox(i.clone(),n,this.coordinatediv),this.coordinatedivtextPos=i,this.coordinatedivdims=n):(r=(s=this.viewer).renderer.domElement,o=s.renderer.getPixelRatio(),a=new THREE.Raycaster,s.camera.setCastRay(a,(e+l)*o/r.width*2-1,2*-((t+l)*o/r.height)+1),s=new THREE.Plane(new THREE.Vector3(0,0,-1),0),e=new THREE.Vector3,a.ray.intersectPlane(s,e),e&&(n="X:"+parseFloat(e.x.toFixed(4).toString())+"<br>Y:"+parseFloat(e.y.toFixed(4).toString()),i=e.clone(),this.getAndShowTextBox(i.clone(),n,this.coordinatediv),this.coordinatedivtextPos=i,this.coordinatedivdims=n))},pn.prototype.onLMouseClick=function(e,t,n){var i,r,o,a,s,l,d=document.createElement("div"),c=(d.className="mearesult",this.viewer.container.appendChild(d),48),h=(Se.isMobileDevice()&&this.viewer.is2DModel&&(c=0),new THREE.Vector3),t=(this.snappedPoint?(i="X:"+parseFloat(this.snappedPoint.x.toFixed(4).toString())+"<br>Y:"+parseFloat(this.snappedPoint.y.toFixed(4).toString()),r=this.snappedPoint.clone(),this.getAndShowTextBox(r.clone(),i,d),h.copy(this.snappedPoint),this.snappedPoint=null):(o=(l=this.viewer).renderer.domElement,a=l.renderer.getPixelRatio(),s=new THREE.Raycaster,l.camera.setCastRay(s,(e+c)*a/o.width*2-1,2*-((t+c)*a/o.height)+1),l=new THREE.Plane(new THREE.Vector3(0,0,-1),0),s.ray.intersectPlane(l,h),h&&(i="X:"+parseFloat(h.x.toFixed(4).toString())+"<br>Y:"+parseFloat(h.y.toFixed(4).toString()),r=h.clone(),this.getAndShowTextBox(r.clone(),i,d))),h&&(e=this.createPointMesh(h,this.materialPoint,10*this.POINTSIZE))&&this.OpMeasure.rootObject.add(e),{});t.dimString=i,t.textPos=r,t.textBox=d,t.textBox.setAttribute("type","coordinate"),t.textBox.setAttribute("dimString",i),this.OpMeasure.boxInfos.push(t),Se.isMobileDevice()&&this.ChangeMeasureFlag(),_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes()};function yn(){this.start=new THREE.Vector2,this.end=new THREE.Vector2,this.p1=-1,this.p2=-1}function En(){this.edgeIndex=-1,this.Pos=-1}function Mn(){this.dimString="",this.textBox=null,this.textPos=null,this.lineobj=null,this.start=new THREE.Vector2,this.end=new THREE.Vector2,this.lineInfo=null,this.LineSegments=[],this.intersectMouse=null,this.intersectPos=[]}(fn.prototype=Object.create(h.prototype)).OperatorStart=function(e){var t,n,i,r;this.measureType=e,Se.isMobileDevice()&&this.viewer.is2DModel&&(t=this,Se.getLanguage(),this.lineargaugediv||(this.lineargaugediv=document.createElement("div"),this.lineargaugediv.className="tc-box ts-tc",(e=document.createElement("p")).innerHTML=Se.translateString("MEASURE_SELECTDIR"),(n=document.createElement("div")).className="ts-tcCnt",n.appendChild(e),(e=document.createElement("span")).innerHTML=Se.translateString("MEASURE_Horizontal"),e.onclick=function(){t.distanceInfo.XorY=0,t.lineargaugediv.style.display="none",t.shadowdiv.style.display="none",t.ShowLineargaugeDimension(null,!0,t.distanceInfo.XorY),t.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT),_e.enableBroadcast&&_e.broadcastMajor&&t.viewer.dispatchEvent({type:"broadcastEvent"})},(i=document.createElement("span")).innerHTML=Se.translateString("MEASURE_Vertical"),i.onclick=function(){t.distanceInfo.XorY=1,t.lineargaugediv.style.display="none",t.shadowdiv.style.display="none",t.ShowLineargaugeDimension(null,!0,t.distanceInfo.XorY),t.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT),_e.enableBroadcast&&_e.broadcastMajor&&t.viewer.dispatchEvent({type:"broadcastEvent"})},(r=document.createElement("div")).className="clearfix ts-tcBtn ts-tcBtn02",r.appendChild(e),r.appendChild(i),this.lineargaugediv.appendChild(n),this.lineargaugediv.appendChild(r),this.lineargaugediv.style.display="none",this.lineargaugediv.style.zIndex=10,this.viewer.container.appendChild(this.lineargaugediv),this.shadowdiv=document.createElement("div"),this.shadowdiv.className="shadowvtc",this.shadowdiv.style.display="none",this.viewer.container.appendChild(this.shadowdiv))),this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT)},fn.prototype.onNMouseMove=function(e,t){var n,i,r,o,a,s=new THREE.Vector3(e,t,0);this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&!Se.isMobileDevice()?(n=this.distanceInfo.firstPoint.clone(),i=this.distanceInfo.secondPoint.clone(),s&&(r=new THREE.Plane(new THREE.Vector3(0,0,-1),0),r=this.clientCoordToModelCoordOnPlane(s.x,s.y,r))&&(this.distanceInfo.mousePos||(this.distanceInfo.mousePos=r.clone()),a=o=!1,(o=this.distanceInfo.mousePos.y<Math.max(n.y,i.y)&&this.distanceInfo.mousePos.y>Math.min(n.y,i.y)&&this.distanceInfo.mousePos.x<Math.max(n.x,i.x)&&this.distanceInfo.mousePos.x>Math.min(n.x,i.x)?!0:o)!=(a=r.y<Math.max(n.y,i.y)&&r.y>Math.min(n.y,i.y)&&r.x<Math.max(n.x,i.x)&&r.x>Math.min(n.x,i.x)?!0:a)&&(n.y<Math.max(this.distanceInfo.mousePos.y,r.y)&&n.y>Math.min(this.distanceInfo.mousePos.y,r.y)||i.y<Math.max(this.distanceInfo.mousePos.y,r.y)&&i.y>Math.min(this.distanceInfo.mousePos.y,r.y)?this.distanceInfo.XorY=0:(n.x<Math.max(this.distanceInfo.mousePos.x,r.x)&&n.x>Math.min(this.distanceInfo.mousePos.x,r.x)||i.x<Math.max(this.distanceInfo.mousePos.x,r.x)&&i.x>Math.min(this.distanceInfo.mousePos.x,r.x))&&(this.distanceInfo.XorY=1)),this.distanceInfo.mousePos.set(r.x,r.y,0)),this.ShowLineargaugeDimension(s,!1,this.distanceInfo.XorY)):this.previewSnappedPoint(e,t,!0)},fn.prototype.onLMouseClick=function(e,t,n){var i=new THREE.Vector3(e,t,0);this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj?(this.ShowLineargaugeDimension(i,!0,this.distanceInfo.XorY),this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTPOINT)):(this.PtToPtMeasure(e,t,!1),this.updatePtToPtScene(),this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&Se.isMobileDevice()&&(this.lineargaugediv.style.display="block",this.shadowdiv.style.display="block"))},fn.prototype.PtToPtMeasure=function(e,t,n){if(null!=this.snappedPoint)null==this.distanceInfo.firstPoint?this.distanceInfo.firstPoint=this.snappedPoint.clone():this.distanceInfo.secondPoint=this.snappedPoint.clone(),this.snappedPoint=null;else{var i=this.getIntersectsByPriorityOfLine(e,t);if(i&&0<i.length)for(var r=0;r<i.length;){if(null!=(this.viewer.ndsModel?i[r].object:this.FindParentElement(i[r].object))){var o,a=i[r].point.clone();n&&(o=this.getSnappingPntEx(i[r]))&&a.copy(o),null==this.distanceInfo.firstPoint?this.distanceInfo.firstPoint=a:this.distanceInfo.secondPoint=a;break}r++}}this.distanceInfo.firstPoint&&!this.distanceInfo.secondPoint&&this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDPOINT),this.distanceInfo.firstPoint&&this.distanceInfo.secondPoint&&!Se.isMobileDevice()&&this.OpMeasure.PostInfo(ve.INFOTYPE.LINEPOSITION)},fn.prototype.ShowLineargaugeDimension=function(e,t,n){var i,r,o;this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&this.viewer.is2DModel&&(o=this.distanceInfo.firstPoint.clone(),i=this.distanceInfo.secondPoint.clone(),null==n&&(n=0),Math.abs(o.x-i.x)<1e-6&&!Se.isMobileDevice()?n=1:Math.abs(o.y-i.y)<1e-6&&!Se.isMobileDevice()&&(n=0),this.distanceInfo.fstClndPos?this.distanceInfo.fstClndPos.set(this.distanceInfo.firstPoint.x,this.distanceInfo.firstPoint.y,0):(this.distanceInfo.fstClndPos=this.distanceInfo.firstPoint.clone(),this.distanceInfo.fstClndPos.z=0),this.distanceInfo.sndClndPos?this.distanceInfo.sndClndPos.set(this.distanceInfo.secondPoint.x,this.distanceInfo.secondPoint.y,0):(this.distanceInfo.sndClndPos=this.distanceInfo.secondPoint.clone(),this.distanceInfo.sndClndPos.z=0),e?(r=new THREE.Plane(new THREE.Vector3(0,0,-1),0),(e=this.clientCoordToModelCoordOnPlane(e.x,e.y,r))&&0==n?(this.distanceInfo.fstClndPos.y=e.y,this.distanceInfo.sndClndPos.y=e.y):e&&1==n&&(this.distanceInfo.fstClndPos.x=e.x,this.distanceInfo.sndClndPos.x=e.x)):0==n?(r=(this.distanceInfo.fstClndPos.y+this.distanceInfo.sndClndPos.y)/2,this.distanceInfo.fstClndPos.y=r,this.distanceInfo.sndClndPos.y=r):1==n&&(e=(this.distanceInfo.fstClndPos.x+this.distanceInfo.sndClndPos.x)/2,this.distanceInfo.fstClndPos.x=e,this.distanceInfo.sndClndPos.x=e),this.distanceInfo.textPos?(this.distanceInfo.textPos.x=(this.distanceInfo.fstClndPos.x+this.distanceInfo.sndClndPos.x)/2,this.distanceInfo.textPos.y=(this.distanceInfo.fstClndPos.y+this.distanceInfo.sndClndPos.y)/2):this.distanceInfo.textPos=new THREE.Vector3((this.distanceInfo.fstClndPos.x+this.distanceInfo.sndClndPos.x)/2,(this.distanceInfo.fstClndPos.y+this.distanceInfo.sndClndPos.y)/2,0),this.distanceInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstClnd),(r=(new THREE.Vector3).subVectors(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos)).normalize(),this.distanceInfo.fstClnd=this.createCylinderMesh(this.distanceInfo.sndClndPos,this.distanceInfo.fstClndPos,this.materialLine),e=this.OpMeasure.getScale(this.distanceInfo.fstClnd,this.CYLINDERWIDTH),r.multiplyScalar(.5*this.distanceInfo.fstClnd.geometry.parameters.height),this.distanceInfo.fstClnd.oldPosition=this.distanceInfo.fstClndPos.clone(),this.distanceInfo.fstClnd.offsetPos=r.clone(),this.distanceInfo.fstClnd.position.addVectors(this.distanceInfo.fstClndPos,r.clone().multiplyScalar(e)),this.distanceInfo.fstClnd.updateMatrixWorld(),this.OpMeasure.rootObject.add(this.distanceInfo.fstClnd),this.distanceInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndClnd),this.distanceInfo.sndClnd=this.createCylinderMesh(this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos,this.materialLine),this.distanceInfo.sndClnd.oldPosition=this.distanceInfo.sndClndPos.clone(),this.distanceInfo.sndClnd.offsetPos=r.clone().multiplyScalar(-1),this.distanceInfo.sndClnd.position.subVectors(this.distanceInfo.sndClndPos,r.clone().multiplyScalar(e)),this.distanceInfo.sndClnd.updateMatrixWorld(),this.OpMeasure.rootObject.add(this.distanceInfo.sndClnd),this.distanceInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.clndToClndLine),this.distanceInfo.clndToClndLine=this.createLineMesh2(this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.clndToClndLine),this.distanceInfo.fstToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstToClndLine),this.distanceInfo.fstToClndLine=this.createLineMesh2(o,this.distanceInfo.fstClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.fstToClndLine),this.distanceInfo.sndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndToClndLine),this.distanceInfo.sndToClndLine=this.createLineMesh2(i,this.distanceInfo.sndClndPos,this.materialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.sndToClndLine),this.distanceInfo.dimString=this.distanceInfo.firstPoint.distanceTo(this.distanceInfo.secondPoint),0==n?this.distanceInfo.dimString=Math.abs(this.distanceInfo.firstPoint.x-this.distanceInfo.secondPoint.x):1==n&&(this.distanceInfo.dimString=Math.abs(this.distanceInfo.firstPoint.y-this.distanceInfo.secondPoint.y)),this.distanceInfo.dimString<1&&.999999<this.distanceInfo.dimString&&(this.distanceInfo.dimString=1),r=this.viewer.getDispalyModelUnit(this.distanceInfo.dimString),this.distanceInfo.dimString*=r.scale,this.distanceInfo.dimString=this.distanceInfo.dimString.toFixed(2),this.distanceInfo.unit=this.getUnitStringmap(r.unit),e=(this.distanceInfo.dimString*this.viewer.measuringScale).toFixed(2)+this.distanceInfo.unit,this.distanceInfo.textBox||(this.distanceInfo.textBox=document.createElement("div"),this.distanceInfo.textBox.className="mearesult",this.viewer.container.appendChild(this.distanceInfo.textBox)),this.getAndShowTextBox(this.distanceInfo.textPos.clone(),e,this.distanceInfo.textBox),1==t)&&((o={}).dimString=e,o.textPos=this.distanceInfo.textPos.clone(),o.textBox=this.distanceInfo.textBox,o.textBox.setAttribute("type","length"),o.textBox.setAttribute("dimString",this.distanceInfo.dimString),o.textBox.setAttribute("dimStringPrefix",""),o.textBox.setAttribute("unit",this.distanceInfo.unit),this.OpMeasure.boxInfos.push(o),this.clearDistanceInfo(!0),Se.isMobileDevice())&&this.ChangeMeasureFlag()},fn.prototype.updatePtToPtScene=function(){var e;this.distanceInfo.firstPoint&&!this.distanceInfo.firstSelObj&&(e=this.createPointMesh(this.distanceInfo.firstPoint,this.materialPoint,this.POINTSIZE))&&(this.OpMeasure.rootObject.add(e),this.distanceInfo.firstSelObj=e),this.distanceInfo.secondPoint&&!this.distanceInfo.secondSelObj&&(e=this.createPointMesh(this.distanceInfo.secondPoint,this.materialPoint,this.POINTSIZE))&&(this.OpMeasure.rootObject.add(e),this.distanceInfo.secondSelObj=e),this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&!Se.isMobileDevice()&&this.ShowLineargaugeDimension()};function wn(e){h.call(this,e),this.measureClass="Contour"}function bn(e){h.call(this,e),this.measureClass="Wall"}(wn.prototype=Object.create(h.prototype)).OperatorStart=function(e){var R,t,n,i;"contour"==(this.measureType=e)?(this.contourdiv||((R=this).contourdiv=document.createElement("div"),Se.isMobileDevice()?(this.contourdiv.className="continuityLength-arrow",(n=document.createElement("span")).className="arrow-prev no",(t=document.createElement("a")).className="continuityLength-btn no",t.innerHTML=Se.translateString("CONTOUR_CONFIRM"),this.contourdiv.appendChild(n),this.contourdiv.appendChild(t)):(this.contourdiv.id="contour",this.contourdiv.style.position="absolute",this.contourdiv.style.zIndex=3,(t=document.createElement("img")).style.height="36px",t.style.width="36px",(n=document.createElement("img")).style.height="36px",n.style.width="36px",(i=document.createElement("img")).style.height="36px",i.style.width="36px"),t.onclick=function(){if(0!=R.lineContoursInfo.Contours.length){R.contourdiv.style.display="none";for(var e=null,t=R.lineContoursInfo.perimeter=0;t<R.lineContoursInfo.Contours.length;++t){var n=R.lineContoursInfo.Contours[t];if(R.OpMeasure.rootObject.remove(n.lineobj),1==n.LineSegments.length){for(var i=0,r=1,o=0;o<n.intersectPos.length;++o){if(n.intersectMouse.Pos>=i&&n.intersectMouse.Pos<=n.intersectPos[o].Pos){r=n.intersectPos[o].Pos;break}i=n.intersectPos[o].Pos}var a=n.LineSegments[0].start.distanceTo(n.LineSegments[0].end),s=n.LineSegments[0].end.clone().sub(n.LineSegments[0].start).normalize(),l=((p=[])[0]=n.LineSegments[0].start.x+i*a*s.x,p[1]=n.LineSegments[0].start.y+i*a*s.y,p[2]=0,p[3]=n.LineSegments[0].start.x+r*a*s.x,p[4]=n.LineSegments[0].start.y+r*a*s.y,p[5]=0,t==R.lineContoursInfo.Contours.length-1&&(e=new THREE.Vector3(p[3],p[4],p[5])),R.createContour(p));R.OpMeasure.rootObject.add(l),n.lineobj=l,n.textPos=new THREE.Vector3((p[0]+p[3])/2,(p[1]+p[4])/2,0),n.dimString=(r-i)*a}else{for(var i=0,d=0,r=n.LineSegments.length-1,c=1,o=0;o<n.intersectPos.length;++o){if((n.intersectMouse.edgeIndex>i||n.intersectMouse.edgeIndex==i&&n.intersectMouse.Pos>d)&&(n.intersectMouse.edgeIndex<n.intersectPos[o].edgeIndex||n.intersectMouse.edgeIndex==n.intersectPos[o].edgeIndex&&n.intersectMouse.Pos<n.intersectPos[o].Pos)){r=n.intersectPos[o].edgeIndex,c=n.intersectPos[o].Pos;break}(n.intersectPos[o].edgeIndex<r||n.intersectPos[o].Pos<1)&&(i=n.intersectPos[o].edgeIndex,d=n.intersectPos[o].Pos)}for(var h=0,u=n.intersectPos.length-1,p=(n.start.distanceTo(n.end)<1e-6&&0==i&&0==d&&-1<u?h=n.LineSegments.length-n.intersectPos[u].edgeIndex:n.start.distanceTo(n.end)<1e-6&&r==n.LineSegments.length-1&&1==c&&-1<u&&(h=n.intersectPos[0].edgeIndex+1),[]),f=0,m=0,o=i;o<=r;++o,++f){var g=n.LineSegments[o].start.clone(),s=(v=n.LineSegments[o].end.clone()).clone().sub(g).normalize();o==i&&(a=g.distanceTo(v),g.x+=d*a*s.x,g.y+=d*a*s.y),o==r&&(a=g.distanceTo(v),v.x=g.x+c*a*s.x,v.y=g.y+c*a*s.y),o==parseInt((i+r)/2)&&(n.textPos=new THREE.Vector3((g.x+v.x)/2,(g.y+v.y)/2,0)),p[6*f+0]=g.x,p[6*f+1]=g.y,p[6*f+2]=0,p[6*f+3]=v.x,p[6*f+4]=v.y,p[6*f+5]=0,m+=g.distanceTo(v)}if(0<h)if(0==i&&0==d)for(o=n.intersectPos[u].edgeIndex;o<n.LineSegments.length;++o,++f){g=n.LineSegments[o].start.clone(),s=(v=n.LineSegments[o].end.clone()).clone().sub(g).normalize();o==n.intersectPos[u].edgeIndex&&(a=g.distanceTo(v),g.x+=n.intersectPos[u].Pos*a*s.x,g.y+=n.intersectPos[u].Pos*a*s.y),p[6*f+0]=g.x,p[6*f+1]=g.y,p[6*f+2]=0,p[6*f+3]=v.x,p[6*f+4]=v.y,p[6*f+5]=0,m+=g.distanceTo(v)}else for(o=0;o<=n.intersectPos[0].edgeIndex;++o,++f){var v,g=n.LineSegments[o].start.clone(),s=(v=n.LineSegments[o].end.clone()).clone().sub(g).normalize();o==n.intersectPos[0].edgeIndex&&(a=g.distanceTo(v),v.x=g.x+n.intersectPos[0].Pos*a*s.x,v.y=g.y+n.intersectPos[0].Pos*a*s.y),p[6*f+0]=g.x,p[6*f+1]=g.y,p[6*f+2]=0,p[6*f+3]=v.x,p[6*f+4]=v.y,p[6*f+5]=0,m+=g.distanceTo(v)}t==R.lineContoursInfo.Contours.length-1&&(e=new THREE.Vector3(p[6*(f-1)+3],p[6*(f-1)+4],p[6*(f-1)+5]));l=R.createContour(p);R.OpMeasure.rootObject.add(l),n.lineobj=l,n.dimString=m}var h=parseFloat(n.dimString),A=R.viewer.getDispalyModelUnit(h),y=(h*=A.scale,R.lineContoursInfo.unit=R.getUnitStringmap(A.unit),R.lineContoursInfo.perimeter+=h,(parseFloat(h)*R.viewer.measuringScale).toFixed(2));y+=R.lineContoursInfo.unit,n.textBox.style.display="inline",R.getAndShowTextBox(n.textPos.clone(),y,n.textBox),(M={}).dimString=y,M.textPos=n.textPos.clone(),M.textBox=n.textBox,M.textBox.setAttribute("type","length"),M.textBox.setAttribute("dimString",n.dimString),M.textBox.setAttribute("dimStringPrefix",""),M.textBox.setAttribute("unit",R.lineContoursInfo.unit);for(var E=0;E<R.OpMeasure.boxInfos.length;E++)R.OpMeasure.boxInfos[E].textPos.distanceTo(M.textPos)<1e-4&&(M.textPos.y+=3);R.OpMeasure.boxInfos.push(M)}var M,w=document.createElement("div"),y=(w.className="mearesult",R.viewer.container.appendChild(w),(R.lineContoursInfo.perimeter*R.viewer.measuringScale).toFixed(2));y+=R.lineContoursInfo.unit,y=Se.translateString("MEASURE_OVERLENGTH")+":"+y,R.getAndShowTextBox(e.clone(),y,w),(M={}).dimString=y,M.textPos=e.clone(),M.textBox=w,M.textBox.setAttribute("type","perimeter"),M.textBox.setAttribute("dimString",R.lineContoursInfo.perimeter),M.textBox.setAttribute("unit",R.lineContoursInfo.unit);for(E=0;E<R.OpMeasure.boxInfos.length;E++)R.OpMeasure.boxInfos[E].textPos.distanceTo(M.textPos)<1e-4&&(M.textPos.y+=3);R.OpMeasure.boxInfos.push(M),R.clearContoursInfo(!0),R.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE),Se.isMobileDevice()&&R.ChangeMeasureFlag(),_e.enableBroadcast&&_e.broadcastMajor&&R.viewer.dispatchEvent({type:"broadcastEvent"})}},n.onclick=function(){if(0!=R.lineContoursInfo.Contours.length){var e=null,t=R.lineContoursInfo.Contours.length-1,e=R.lineContoursInfo.Contours.pop();if(0<t)if(R.lineContoursInfo.divPos=R.lineContoursInfo.Contours[t-1].textPos,e.start.equals(R.lineContoursInfo.start))for(var n=0;n<R.lineContoursInfo.Contours.length;++n)(i=R.lineContoursInfo.Contours[n]).start.distanceTo(e.end)&&R.lineContoursInfo.start.copy(i.start);else for(var i,n=0;n<R.lineContoursInfo.Contours.length;++n)(i=R.lineContoursInfo.Contours[n]).end.distanceTo(e.start)&&R.lineContoursInfo.end.copy(i.end);0==R.lineContoursInfo.Contours.length?(Se.isMobileDevice()?(R.contourdiv.children[0].className="arrow-prev no",R.contourdiv.children[1].className="continuityLength-btn no"):R.contourdiv.style.display="none",R.lineContoursInfo.preSelLineInfo=null,R.lineContoursInfo.preSelLineObj=null,R.lineContoursInfo.prestart=new THREE.Vector2,R.lineContoursInfo.preend=new THREE.Vector2,R.lineContoursInfo.divPos=null,R.lineContoursInfo.start=new THREE.Vector2,R.lineContoursInfo.end=new THREE.Vector2):1==R.lineContoursInfo.Contours.length&&(R.lineContoursInfo.start.copy(R.lineContoursInfo.Contours[0].start),R.lineContoursInfo.end.copy(R.lineContoursInfo.Contours[0].end)),R.OpMeasure.rootObject.remove(e.lineobj),R.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE),R.viewer.render()}},Se.isMobileDevice()||(i.onclick=function(){R.contourdiv.style.display="none",R.lineContoursInfo.preSelLineInfo=null,R.lineContoursInfo.preSelLineObj=null,R.lineContoursInfo.prestart=new THREE.Vector2,R.lineContoursInfo.preend=new THREE.Vector2,R.lineContoursInfo.divPos=null;for(var e=0;e<R.lineContoursInfo.Contours.length;++e)R.OpMeasure.rootObject.remove(R.lineContoursInfo.Contours[e].lineobj);R.lineContoursInfo.Contours=[],R.lineContoursInfo.start=new THREE.Vector2,R.lineContoursInfo.end=new THREE.Vector2,R.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE)},this.contourdiv.style.display="none"),this.contourdiv.onmousemove=function(e){e.preventDefault(),e.stopPropagation(),R.lineContoursInfo.preSelLineObj&&(R.OpMeasure.rootObject.remove(R.lineContoursInfo.preSelLineObj),R.lineContoursInfo.preSelLineObj=null,R.lineContoursInfo.preSelLineInfo=null)},this.viewer.container.appendChild(this.contourdiv)),this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE)):"contourarea"==e&&(this.contourdiv||((R=this).contourdiv=document.createElement("div"),Se.isMobileDevice()?(this.contourdiv.className="continuityLength-arrow",(n=document.createElement("span")).className="arrow-prev no",(t=document.createElement("a")).className="continuityLength-btn no",t.innerHTML=Se.translateString("CONTOUR_CONFIRM"),this.contourdiv.appendChild(n),this.contourdiv.appendChild(t)):(this.contourdiv.id="contour",this.contourdiv.style.position="absolute",this.contourdiv.style.zIndex=3,(t=document.createElement("img")).style.height="36px",t.style.width="36px",(n=document.createElement("img")).style.height="36px",n.style.width="36px",(i=document.createElement("img")).style.height="36px",i.style.width="36px"),t.onclick=function(){if(0!=R.lineContoursInfo.Contours.length){Se.isMobileDevice()&&R.ChangeMeasureFlag();var e=[],o=[],a=[],t=[];R.contourdiv.style.display="none";for(var n=0;n<R.lineContoursInfo.Contours.length;++n)if("circle"==(P=R.lineContoursInfo.Contours[n]).lineInfo.type&&P.LineSegments[0].start.distanceTo(P.LineSegments[P.LineSegments.length-1].end)<.002){var i=new THREE.Vector3(P.lineInfo.center[0],P.lineInfo.center[1],P.lineInfo.center[2]),i=(i.applyMatrix4(P.lineInfo.matrixWorld),{radius:P.lineInfo.radius,pos:i.toArray()});t.push(i)}else{R.OpMeasure.rootObject.remove(P.lineobj),P.lineobj=null;for(var r=0;r<P.LineSegments.length;++r){for(var s=P.LineSegments[r],l={},d=0;d<a.length;++d){var c=new THREE.Vector3;R.lineIntersection2D(s.start,s.end,a[d].start,a[d].end,c)&&((l[c.z]=c).z=d)}if(Object.keys(l).length<1)s.p1=o.length,o.push(s.start),s.p2=o.length,o.push(s.end),a.push(s);else{var h=[];h.push(s.start),Object.keys(l).sort(function(e,t){return e-t}).forEach(function(e){var t,n,i,r;0!=l[e].s&&1!=l[e].s&&(t=a[l[e].z],(r=new THREE.Vector2).set(l[e].x,l[e].y),(i=new C).start.set(t.start.x,t.start.y),i.end.set(l[e].x,l[e].y),i.p1=t.p1,-1<(n=R.getIndexFromPoints(r,o))?i.p2=n:(i.p2=o.length,n=i.p2,o.push(r)),a.push(i),(i=new C).start.set(l[e].x,l[e].y),i.end.set(t.end.x,t.end.y),i.p1=n,i.p2=t.p2,a.push(i),a[l[e].z]=null),0!=e&&1!=e&&((r=new THREE.Vector2).set(l[e].x,l[e].y),h.push(r))}),h.push(s.end);for(d=0;d<h.length-1;++d){var u=new C,p=(u.start.set(h[d].x,h[d].y),u.end.set(h[d+1].x,h[d+1].y),R.getIndexFromPoints(h[d],o));-1<p?u.p1=p:(u.p1=o.length,o.push(h[d])),-1<(p=R.getIndexFromPoints(h[d+1],o))?u.p2=p:(u.p2=o.length,o.push(h[d+1])),a.push(u)}}for(d=0;d<a.length;++d)a[d]||(a.splice(d,1),--d)}}var f=new THREE.Box2(o[0],o[1]),m=new ve.Triangulator.ContourSet(a,f);m.sanitizeEdges(),m.stitchContoursCheng();for(var g=0;g<m.contours.length;g++){var v=m.contours[g];if(v[0]==v[v.length-1]){for(var A=0,y=new THREE.Vector2,E=[],M=1;M<v.length;M++){var w=o[v[M-1]],b=o[v[M]];E[6*(M-1)+0]=w.x,E[6*(M-1)+1]=w.y,E[6*(M-1)+2]=0,E[6*(M-1)+3]=b.x,E[6*(M-1)+4]=b.y,E[6*(M-1)+5]=0,A+=(w.x*b.y-w.y*b.x)/2,y.add(w)}var x=R.createContour(E);R.OpMeasure.rootObject.add(x),y.divideScalar(v.length-1),A=Math.abs(A),(T=document.createElement("div")).className="mearesult",R.viewer.container.appendChild(T);var A=A*(S=R.viewer.getDispalyModelUnit(A)).scale*S.scale,I=(R.lineContoursInfo.unit=R.getUnitStringmap(S.unit),(A*Math.pow(R.viewer.measuringScale,2)).toFixed(2));I=Se.translateString("MEASURE_AREA")+":"+I+R.lineContoursInfo.unit+"²",(B={}).dimString=I,B.textPos=new THREE.Vector3(y.x,y.y,0),B.textBox=T,B.textBox.setAttribute("type","area"),B.textBox.setAttribute("dimString",A),B.textBox.setAttribute("unit",R.lineContoursInfo.unit+"²");for(d=0;d<R.OpMeasure.boxInfos.length;d++)R.OpMeasure.boxInfos[d].textPos.distanceTo(B.textPos)<1e-4&&B.textBox.setAttribute("needDown","true");for(d=0;d<e.length;d++)e[d].textPos.distanceTo(B.textPos)<1e-4&&B.textBox.setAttribute("needDown","true");e.push(B)}}for(var T,g=0;g<t.length;++g){A=Math.pow(t[g].radius,2)*Math.PI,(T=document.createElement("div")).className="mearesult",R.viewer.container.appendChild(T);A=A*(S=R.viewer.getDispalyModelUnit(A)).scale*S.scale,R.lineContoursInfo.unit=R.getUnitStringmap(S.unit);var S,B,I=(A*Math.pow(R.viewer.measuringScale,2)).toFixed(2);I=Se.translateString("MEASURE_AREA")+": "+I+R.lineContoursInfo.unit+"²",(B={}).dimString=I,B.textPos=new THREE.Vector3(t[g].pos[0],t[g].pos[1],0),B.textBox=T,B.textBox.setAttribute("type","area"),B.textBox.setAttribute("dimString",A),B.textBox.setAttribute("unit",R.lineContoursInfo.unit+"²");for(d=0;d<R.OpMeasure.boxInfos.length;d++)R.OpMeasure.boxInfos[d].textPos.distanceTo(B.textPos)<1e-4&&B.textBox.setAttribute("needDown","true");for(d=0;d<e.length;d++)e[d].textPos.distanceTo(B.textPos)<1e-4&&B.textBox.setAttribute("needDown","true");e.push(B)}if(0<e.length)R.OpMeasure.boxInfos=R.OpMeasure.boxInfos.concat(e);else{R.OpMeasure.PostInfo(ve.INFOTYPE.NOCLOSE);for(n=0;n<R.lineContoursInfo.Contours.length;++n){var P=R.lineContoursInfo.Contours[n];R.OpMeasure.rootObject.remove(P.lineobj)}}R.clearContoursInfo(!0),_e.enableBroadcast&&_e.broadcastMajor&&R.viewer.dispatchEvent({type:"broadcastEvent"})}function C(){this.start=new THREE.Vector2,this.end=new THREE.Vector2,this.p1=-1,this.p2=-1}},n.onclick=function(){var e,t;0!=R.lineContoursInfo.Contours.length&&(t=null,e=R.lineContoursInfo.Contours.length-1,t=R.lineContoursInfo.Contours.pop(),0<e&&(R.lineContoursInfo.divPos=R.lineContoursInfo.Contours[e-1].textPos),0==R.lineContoursInfo.Contours.length&&(Se.isMobileDevice()?(R.contourdiv.children[0].className="arrow-prev no",R.contourdiv.children[1].className="continuityLength-btn no"):R.contourdiv.style.display="none",R.lineContoursInfo.preSelLineInfo=null,R.lineContoursInfo.preSelLineObj=null,R.lineContoursInfo.prestart=new THREE.Vector2,R.lineContoursInfo.preend=new THREE.Vector2,R.lineContoursInfo.divPos=null,R.lineContoursInfo.start=new THREE.Vector2,R.lineContoursInfo.end=new THREE.Vector2),R.OpMeasure.rootObject.remove(t.lineobj),R.viewer.render())},Se.isMobileDevice()||(i.onclick=function(){R.contourdiv.style.display="none",R.lineContoursInfo.preSelLineInfo=null,R.lineContoursInfo.preSelLineObj=null,R.lineContoursInfo.prestart=new THREE.Vector2,R.lineContoursInfo.preend=new THREE.Vector2,R.lineContoursInfo.divPos=null;for(var e=0;e<R.lineContoursInfo.Contours.length;++e)R.OpMeasure.rootObject.remove(R.lineContoursInfo.Contours[e].lineobj);R.lineContoursInfo.Contours=[],R.lineContoursInfo.start=new THREE.Vector2,R.lineContoursInfo.end=new THREE.Vector2},this.contourdiv.style.display="none"),this.contourdiv.onmousemove=function(e){e.preventDefault(),e.stopPropagation(),R.lineContoursInfo.preSelLineObj&&(R.OpMeasure.rootObject.remove(R.lineContoursInfo.preSelLineObj),R.lineContoursInfo.preSelLineObj=null,R.lineContoursInfo.preSelLineInfo=null)},this.viewer.container.appendChild(this.contourdiv)),this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE))},wn.prototype.measureEnd=function(){if("contour"==this.measureType){if(0==this.lineContoursInfo.Contours.length)return;this.contourdiv.style.display="none";for(var e=null,t=this.lineContoursInfo.perimeter=0;t<this.lineContoursInfo.Contours.length;++t){var n=this.lineContoursInfo.Contours[t];if(this.OpMeasure.rootObject.remove(n.lineobj),1==n.LineSegments.length){for(var i=0,r=1,o=0;o<n.intersectPos.length;++o){if(n.intersectMouse.Pos>=i&&n.intersectMouse.Pos<=n.intersectPos[o].Pos){r=n.intersectPos[o].Pos;break}i=n.intersectPos[o].Pos}var a=n.LineSegments[0].start.distanceTo(n.LineSegments[0].end),s=n.LineSegments[0].end.clone().sub(n.LineSegments[0].start).normalize(),l=((p=[])[0]=n.LineSegments[0].start.x+i*a*s.x,p[1]=n.LineSegments[0].start.y+i*a*s.y,p[2]=0,p[3]=n.LineSegments[0].start.x+r*a*s.x,p[4]=n.LineSegments[0].start.y+r*a*s.y,p[5]=0,t==this.lineContoursInfo.Contours.length-1&&(e=new THREE.Vector3(p[3],p[4],p[5])),this.createContour(p));this.OpMeasure.rootObject.add(l),n.lineobj=l,n.textPos=new THREE.Vector3((p[0]+p[3])/2,(p[1]+p[4])/2,0),n.dimString=(r-i)*a}else{for(var i=0,d=0,r=n.LineSegments.length-1,c=1,o=0;o<n.intersectPos.length;++o){if((n.intersectMouse.edgeIndex>i||n.intersectMouse.edgeIndex==i&&n.intersectMouse.Pos>d)&&(n.intersectMouse.edgeIndex<n.intersectPos[o].edgeIndex||n.intersectMouse.edgeIndex==n.intersectPos[o].edgeIndex&&n.intersectMouse.Pos<n.intersectPos[o].Pos)){r=n.intersectPos[o].edgeIndex,c=n.intersectPos[o].Pos;break}(n.intersectPos[o].edgeIndex<r||n.intersectPos[o].Pos<1)&&(i=n.intersectPos[o].edgeIndex,d=n.intersectPos[o].Pos)}for(var h=0,u=n.intersectPos.length-1,p=(n.start.distanceTo(n.end)<1e-6&&0==i&&0==d&&-1<u?h=n.LineSegments.length-n.intersectPos[u].edgeIndex:n.start.distanceTo(n.end)<1e-6&&r==n.LineSegments.length-1&&1==c&&-1<u&&(h=n.intersectPos[0].edgeIndex+1),[]),f=0,m=0,o=i;o<=r;++o,++f){var g=n.LineSegments[o].start.clone(),s=(v=n.LineSegments[o].end.clone()).clone().sub(g).normalize();o==i&&(a=g.distanceTo(v),g.x+=d*a*s.x,g.y+=d*a*s.y),o==r&&(a=g.distanceTo(v),v.x=g.x+c*a*s.x,v.y=g.y+c*a*s.y),o==parseInt((i+r)/2)&&(n.textPos=new THREE.Vector3((g.x+v.x)/2,(g.y+v.y)/2,0)),p[6*f+0]=g.x,p[6*f+1]=g.y,p[6*f+2]=0,p[6*f+3]=v.x,p[6*f+4]=v.y,p[6*f+5]=0,m+=g.distanceTo(v)}if(0<h)if(0==i&&0==d)for(o=n.intersectPos[u].edgeIndex;o<n.LineSegments.length;++o,++f){g=n.LineSegments[o].start.clone(),s=(v=n.LineSegments[o].end.clone()).clone().sub(g).normalize();o==n.intersectPos[u].edgeIndex&&(a=g.distanceTo(v),g.x+=n.intersectPos[u].Pos*a*s.x,g.y+=n.intersectPos[u].Pos*a*s.y),p[6*f+0]=g.x,p[6*f+1]=g.y,p[6*f+2]=0,p[6*f+3]=v.x,p[6*f+4]=v.y,p[6*f+5]=0,m+=g.distanceTo(v)}else for(o=0;o<=n.intersectPos[0].edgeIndex;++o,++f){var v,g=n.LineSegments[o].start.clone(),s=(v=n.LineSegments[o].end.clone()).clone().sub(g).normalize();o==n.intersectPos[0].edgeIndex&&(a=g.distanceTo(v),v.x=g.x+n.intersectPos[0].Pos*a*s.x,v.y=g.y+n.intersectPos[0].Pos*a*s.y),p[6*f+0]=g.x,p[6*f+1]=g.y,p[6*f+2]=0,p[6*f+3]=v.x,p[6*f+4]=v.y,p[6*f+5]=0,m+=g.distanceTo(v)}t==this.lineContoursInfo.Contours.length-1&&(e=new THREE.Vector3(p[6*(f-1)+3],p[6*(f-1)+4],p[6*(f-1)+5]));l=this.createContour(p);this.OpMeasure.rootObject.add(l),n.lineobj=l,n.dimString=m}var h=parseFloat(n.dimString),A=(h*=(D=this.viewer.getDispalyModelUnit(h)).scale,this.lineContoursInfo.unit=this.getUnitStringmap(D.unit),this.lineContoursInfo.perimeter+=h,(h*this.viewer.measuringScale).toFixed(2));A+=this.lineContoursInfo.unit,n.textBox.style.display="inline",this.getAndShowTextBox(n.textPos.clone(),A,n.textBox),(H={}).dimString=A,H.textPos=n.textPos.clone(),H.textBox=n.textBox,H.textBox.setAttribute("type","length"),H.textBox.setAttribute("dimString",h),H.textBox.setAttribute("dimStringPrefix",""),H.textBox.setAttribute("unit",this.lineContoursInfo.unit);for(var y=0;y<this.OpMeasure.boxInfos.length;y++)this.OpMeasure.boxInfos[y].textPos.distanceTo(H.textPos)<1e-4&&H.textBox.setAttribute("needDown","true");this.OpMeasure.boxInfos.push(H)}A=((L=document.createElement("div")).className="mearesult",this.viewer.container.appendChild(L),(this.lineContoursInfo.perimeter*this.viewer.measuringScale).toFixed(2));A+=this.lineContoursInfo.unit,A=Se.translateString("MEASURE_OVERLENGTH")+":"+A,this.getAndShowTextBox(e.clone(),A,L),(H={}).dimString=A,H.textPos=e.clone(),H.textBox=L,H.textBox.setAttribute("type","perimeter"),H.textBox.setAttribute("dimString",this.lineContoursInfo.perimeter),H.textBox.setAttribute("unit",this.lineContoursInfo.unit);for(y=0;y<this.OpMeasure.boxInfos.length;y++)this.OpMeasure.boxInfos[y].textPos.distanceTo(H.textPos)<1e-4&&H.textBox.setAttribute("needDown","true");this.OpMeasure.boxInfos.push(H),this.clearContoursInfo(!0),this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE),Se.isMobileDevice()&&this.ChangeMeasureFlag(),_e.enableBroadcast&&_e.broadcastMajor&&this.viewer.dispatchEvent({type:"broadcastEvent"})}else if("contourarea"==this.measureType){var F=function(){this.start=new THREE.Vector2,this.end=new THREE.Vector2,this.p1=-1,this.p2=-1};if(0==this.lineContoursInfo.Contours.length)return;Se.isMobileDevice()&&this.ChangeMeasureFlag();var E=[],M=[],w=[],b=[];this.contourdiv.style.display="none";for(t=0;t<this.lineContoursInfo.Contours.length;++t)if("circle"==(n=this.lineContoursInfo.Contours[t]).lineInfo.type&&n.LineSegments[0].start.distanceTo(n.LineSegments[n.LineSegments.length-1].end)<.002){var N=new THREE.Vector3(n.lineInfo.center[0],n.lineInfo.center[1],n.lineInfo.center[2]),N=(N.applyMatrix4(n.lineInfo.matrixWorld),{radius:n.lineInfo.radius,pos:N.toArray()});b.push(N)}else{this.OpMeasure.rootObject.remove(n.lineobj),n.lineobj=null;for(o=0;o<n.LineSegments.length;++o){for(var x=n.LineSegments[o],I={},y=0;y<w.length;++y){var j=new THREE.Vector3;this.lineIntersection2D(x.start,x.end,w[y].start,w[y].end,j)&&((I[j.z]=j).z=y)}if(Object.keys(I).length<1)x.p1=M.length,M.push(x.start),x.p2=M.length,M.push(x.end),w.push(x);else{var T=[],_=(T.push(x.start),this);Object.keys(I).sort(function(e,t){return e-t}).forEach(function(e){var t,n,i,r;0!=I[e].s&&1!=I[e].s&&(t=w[I[e].z],(r=new THREE.Vector2).set(I[e].x,I[e].y),(i=new F).start.set(t.start.x,t.start.y),i.end.set(I[e].x,I[e].y),i.p1=t.p1,-1<(n=_.getIndexFromPoints(r,M))?i.p2=n:(i.p2=M.length,n=i.p2,M.push(r)),w.push(i),(i=new F).start.set(I[e].x,I[e].y),i.end.set(t.end.x,t.end.y),i.p1=n,i.p2=t.p2,w.push(i),w[I[e].z]=null),0!=e&&1!=e&&((r=new THREE.Vector2).set(I[e].x,I[e].y),T.push(r))}),T.push(x.end);for(y=0;y<T.length-1;++y){var S=new F,V=(S.start.set(T[y].x,T[y].y),S.end.set(T[y+1].x,T[y+1].y),this.getIndexFromPoints(T[y],M));-1<V?S.p1=V:(S.p1=M.length,M.push(T[y])),-1<(V=this.getIndexFromPoints(T[y+1],M))?S.p2=V:(S.p2=M.length,M.push(T[y+1])),w.push(S)}}for(y=0;y<w.length;++y)w[y]||(w.splice(y,1),--y)}}var k=new THREE.Box2(M[0],M[1]),U=new ve.Triangulator.ContourSet(w,k);U.sanitizeEdges(),U.stitchContoursCheng();for(var B=0;B<U.contours.length;B++){var P=U.contours[B];if(P[0]==P[P.length-1]){for(var C=0,G=new THREE.Vector2,p=[],R=1;R<P.length;R++){var O=M[P[R-1]],z=M[P[R]];p[6*(R-1)+0]=O.x,p[6*(R-1)+1]=O.y,p[6*(R-1)+2]=0,p[6*(R-1)+3]=z.x,p[6*(R-1)+4]=z.y,p[6*(R-1)+5]=0,C+=(O.x*z.y-O.y*z.x)/2,G.add(O)}l=this.createContour(p);this.OpMeasure.rootObject.add(l),G.divideScalar(P.length-1),C=Math.abs(C),(L=document.createElement("div")).className="mearesult",this.viewer.container.appendChild(L);C=C*(D=this.viewer.getDispalyModelUnit(C)).scale*D.scale,A=(this.lineContoursInfo.unit=this.getUnitStringmap(D.unit),(C*Math.pow(this.viewer.measuringScale,2)).toFixed(2));A=Se.translateString("MEASURE_AREA")+": "+A+this.lineContoursInfo.unit+"²",(H={}).dimString=A,H.textPos=new THREE.Vector3(G.x,G.y,0),H.textBox=L,H.textBox.setAttribute("type","area"),H.textBox.setAttribute("dimString",C),H.textBox.setAttribute("unit",this.lineContoursInfo.unit+"²");for(y=0;y<this.OpMeasure.boxInfos.length;y++)this.OpMeasure.boxInfos[y].textPos.distanceTo(H.textPos)<1e-4&&H.textBox.setAttribute("needDown","true");for(y=0;y<E.length;y++)E[y].textPos.distanceTo(H.textPos)<1e-4&&H.textBox.setAttribute("needDown","true");E.push(H)}}for(var L,B=0;B<b.length;++B){C=Math.pow(b[B].radius,2)*Math.PI,(L=document.createElement("div")).className="mearesult",this.viewer.container.appendChild(L);C=C*(D=this.viewer.getDispalyModelUnit(C)).scale*D.scale,this.lineContoursInfo.unit=this.getUnitStringmap(D.unit);var D,H,A=(C*Math.pow(this.viewer.measuringScale,2)).toFixed(2);A=Se.translateString("MEASURE_AREA")+": "+A+this.lineContoursInfo.unit+"²",(H={}).dimString=A,H.textPos=new THREE.Vector3(b[B].pos[0],b[B].pos[1],0),H.textBox=L,H.textBox.setAttribute("type","area"),H.textBox.setAttribute("dimString",C),H.textBox.setAttribute("unit",this.lineContoursInfo.unit+"²");for(y=0;y<this.OpMeasure.boxInfos.length;y++)this.OpMeasure.boxInfos[y].textPos.distanceTo(H.textPos)<1e-4&&H.textBox.setAttribute("needDown","true");for(y=0;y<E.length;y++)E[y].textPos.distanceTo(H.textPos)<1e-4&&H.textBox.setAttribute("needDown","true");E.push(H)}if(0<E.length)this.OpMeasure.boxInfos=this.OpMeasure.boxInfos.concat(E);else{this.OpMeasure.PostInfo(ve.INFOTYPE.NOCLOSE);for(t=0;t<this.lineContoursInfo.Contours.length;++t){n=this.lineContoursInfo.Contours[t];this.OpMeasure.rootObject.remove(n.lineobj)}}this.clearContoursInfo(!0),_e.enableBroadcast&&_e.broadcastMajor&&this.viewer.dispatchEvent({type:"broadcastEvent"})}_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes()},wn.prototype.onNMouseMove=function(e,t){this.measureContour(e,t,!0)},wn.prototype.onLMouseClick=function(e,t,n){this.measureContour(e,t,!1)},wn.prototype.lineIntersection2D=function(e,t,n,i,r){var o;return e.distanceTo(n)<.002?(null!=r&&(r.x=e.x,r.y=e.y,r.z=0,r.s=0),!0):t.distanceTo(n)<.002?(null!=r&&(r.x=t.x,r.y=t.y,r.z=1,r.s=0),!0):e.distanceTo(i)<.002?(null!=r&&(r.x=e.x,r.y=e.y,r.z=0,r.s=1),!0):t.distanceTo(i)<.002?(null!=r&&(r.x=t.x,r.y=t.y,r.z=1,r.s=1),!0):!(Math.abs((t.x-e.x)*(i.y-n.y)-(t.y-e.y)*(i.x-n.x))<.002)&&(o=((e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y))/((t.x-e.x)*(i.y-n.y)-(t.y-e.y)*(i.x-n.x)),i=((e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y))/((t.x-e.x)*(i.y-n.y)-(t.y-e.y)*(i.x-n.x)),0<=o)&&o<=1&&0<=i&&i<=1&&(null!=r&&(r.x=e.x+o*(t.x-e.x),r.y=e.y+o*(t.y-e.y),r.z=o,r.s=i),!0)},wn.prototype.getIndexFromPoints=function(e,t){for(var n=0;n<t.length;++n){var i=t[n];if(e.distanceTo(i)<.002)return n}return-1},wn.prototype.measureContour=function(e,t,n){""==this.lineContoursInfo.unit&&(this.lineContoursInfo.unit=this.getUnitString());var i=this.viewer,r=this.doRaycasterPick(e,t,!0);if(r&&0!=r.length){r=r[0];if(r){r=this.getSelectInfoFromIntersect(r);if(r){if("line"==r.type&&!this.Bline(r))return void(this.lineContoursInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineContoursInfo.preSelLineObj),this.lineContoursInfo.preSelLineObj=null,this.lineContoursInfo.preSelLineInfo=null));this.isTwoTopolInfoTheSame(this.lineContoursInfo.preSelLineInfo,r)||(this.lineContoursInfo.preSelLineInfo=r,this.lineContoursInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineContoursInfo.preSelLineObj),this.lineContoursInfo.preSelLineObj=null),c=r.geometry,(D=r.indexRange.concat())[0]+=c.drawRange.start/2,D[1]+=c.drawRange.start/2,c.isBufferGeometry&&(h=c.index,u=c.attributes.position.array,null!=h)&&(p=h.array,M=D[0],w=D[1],this.lineContoursInfo.prestart.fromArray(u,3*p[2*M]),this.lineContoursInfo.preend.fromArray(u,3*p[2*w+1])),n&&(d=this.createLine(this.lineContoursInfo.preSelLineInfo,!0))&&(this.OpMeasure.rootObject.add(d),this.lineContoursInfo.preSelLineObj=d))}}if(this.lineContoursInfo.preSelLineInfo&&n){for(var o=0;o<this.lineContoursInfo.Contours.length;++o){var a=this.lineContoursInfo.Contours[o];if(this.isTwoTopolInfoTheSame(this.lineContoursInfo.preSelLineInfo,a.lineInfo)&&"contourarea"===this.measureType)return void this.OpMeasure.PostInfo(ve.INFOTYPE.CANCELLINE)}if("contour"===this.measureType&&0<this.lineContoursInfo.Contours.length){a=this.lineContoursInfo.Contours[this.lineContoursInfo.Contours.length-1];if(this.isTwoTopolInfoTheSame(this.lineContoursInfo.preSelLineInfo,a.lineInfo))return void this.OpMeasure.PostInfo(ve.INFOTYPE.CANCELLINE)}}if(this.lineContoursInfo.preSelLineInfo&&!n){this.lineContoursInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineContoursInfo.preSelLineObj),this.lineContoursInfo.preSelLineObj=null);var r=this.lineContoursInfo.Contours.length-1,s=null;if("contour"===this.measureType&&0<=r){a=this.lineContoursInfo.Contours[r];if(this.isTwoTopolInfoTheSame(this.lineContoursInfo.preSelLineInfo,a.lineInfo)){if(s=this.lineContoursInfo.Contours.pop(),0<r)if(this.lineContoursInfo.divPos=this.lineContoursInfo.Contours[r-1].textPos,s.start.equals(this.lineContoursInfo.start))for(var l=0;l<this.lineContoursInfo.Contours.length;++l)(a=this.lineContoursInfo.Contours[l]).start.equals(s.end)&&this.lineContoursInfo.start.copy(a.start);else for(l=0;l<this.lineContoursInfo.Contours.length;++l)(a=this.lineContoursInfo.Contours[l]).end.equals(s.start)&&this.lineContoursInfo.end.copy(a.end);return 0==this.lineContoursInfo.Contours.length?(this.contourdiv.style.display="none",this.lineContoursInfo.preSelLineInfo=null,this.lineContoursInfo.preSelLineObj=null,this.lineContoursInfo.prestart=new THREE.Vector2,this.lineContoursInfo.preend=new THREE.Vector2,this.lineContoursInfo.divPos=null,this.lineContoursInfo.start=new THREE.Vector2,this.lineContoursInfo.end=new THREE.Vector2):1==this.lineContoursInfo.Contours.length&&(this.lineContoursInfo.start.copy(this.lineContoursInfo.Contours[0].start),this.lineContoursInfo.end.copy(this.lineContoursInfo.Contours[0].end)),this.OpMeasure.rootObject.remove(s.lineobj),void(this.lineContoursInfo.preSelLineInfo=null)}}for(o=0;o<this.lineContoursInfo.Contours.length;++o){a=this.lineContoursInfo.Contours[o];if(this.isTwoTopolInfoTheSame(this.lineContoursInfo.preSelLineInfo,a.lineInfo)){if("contourarea"===this.measureType)return s=this.lineContoursInfo.Contours.splice(o,1)[0],this.OpMeasure.rootObject.remove(s.lineobj),void(this.lineContoursInfo.preSelLineInfo=null);if("contour"===this.measureType)return void(this.lineContoursInfo.preSelLineInfo=null)}}n=this.viewer.renderer.getPixelRatio();Se.isMobileDevice()?(this.contourdiv.children[0].className="arrow-prev",this.contourdiv.children[1].className="continuityLength-btn"):(this.contourdiv.style.left=Math.round(e/n)+"px",this.contourdiv.style.top=Math.round(t/n)+"px"),this.contourdiv.style.display="inline";var r=(i=this.viewer).renderer.domElement,F=new THREE.Raycaster,i=(i.camera.setCastRay(F,e*n/r.width*2-1,2*-(t*n/r.height)+1),new THREE.Plane(new THREE.Vector3(0,0,-1),0)),e=new THREE.Vector3;if(F.ray.intersectPlane(i,e),"contourarea"===this.measureType){e&&(this.lineContoursInfo.divPos=e);var d=this.createLine(this.lineContoursInfo.preSelLineInfo,!1);this.OpMeasure.rootObject.add(d);(b=new Mn).dimString=this.lineContoursInfo.preSelLineInfo.length,b.lineobj=d,b.lineInfo=this.lineContoursInfo.preSelLineInfo;var c=b.lineInfo.geometry;if((D=b.lineInfo.indexRange.concat())[0]+=c.drawRange.start/2,D[1]+=c.drawRange.start/2,c.isBufferGeometry){var h=c.index,u=c.attributes.position.array;if(null!=h)for(var p=h.array,f=0,m=M=D[0],g=w=D[1];m<=g;m++,f+=1){var v=p[2*m],A=p[2*m+1],y=new THREE.Vector3,E=new THREE.Vector3;y.fromArray(u,3*v),E.fromArray(u,3*A),y.applyMatrix4(b.lineInfo.matrixWorld),E.applyMatrix4(b.lineInfo.matrixWorld),(H=new yn).start.set(y.x,y.y),H.end.set(E.x,E.y),b.LineSegments.push(H),E=y=null}}b.start.set(this.edgeInfo.startPos.x,this.edgeInfo.startPos.y),b.end.set(this.edgeInfo.endPos.x,this.edgeInfo.endPos.y),b.textPos=new THREE.Vector3((b.start.x+b.end.x)/2,(b.start.y+b.end.y)/2,0),this.lineContoursInfo.Contours.push(b),this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE)}else if("contour"===this.measureType)if(0==this.lineContoursInfo.Contours.length){e&&(this.lineContoursInfo.divPos=e);d=this.createLine(this.lineContoursInfo.preSelLineInfo,!1);this.OpMeasure.rootObject.add(d),(b=new Mn).dimString=this.lineContoursInfo.preSelLineInfo.length,b.lineobj=d,b.lineInfo=this.lineContoursInfo.preSelLineInfo;c=((L=document.createElement("div")).className="mearesult",this.viewer.container.appendChild(L),b.textBox=L,b.lineInfo.geometry);if((D=b.lineInfo.indexRange.concat())[0]+=c.drawRange.start/2,D[1]+=c.drawRange.start/2,c.isBufferGeometry){h=c.index,u=c.attributes.position.array;if(null!=h)for(p=h.array,f=0,m=M=D[0],g=w=D[1];m<=g;m++,f+=1){v=p[2*m],A=p[2*m+1],y=new THREE.Vector3,E=new THREE.Vector3;y.fromArray(u,3*v),E.fromArray(u,3*A),y.x==E.x&&y.y==E.y?(f--,E=y=null):(y.applyMatrix4(b.lineInfo.matrixWorld),E.applyMatrix4(b.lineInfo.matrixWorld),S=b.lineInfo.intersect.clone().sub(y).normalize(),j=E.clone().sub(y).normalize(),S.distanceTo(j)<1e-6&&null==b.intersectMouse&&0<=(I=new THREE.Line3(y,E).closestPointToPointParameter(b.lineInfo.intersect,!1))&&I<=1&&((P=new En).edgeIndex=f,P.Pos=I,b.intersectMouse=P),(H=new yn).start.set(y.x,y.y),H.end.set(E.x,E.y),b.LineSegments.push(H),E=y=null)}}b.start.set(this.edgeInfo.startPos.x,this.edgeInfo.startPos.y),b.end.set(this.edgeInfo.endPos.x,this.edgeInfo.endPos.y),b.textPos=new THREE.Vector3((b.start.x+b.end.x)/2,(b.start.y+b.end.y)/2,0),this.lineContoursInfo.Contours.push(b),this.lineContoursInfo.start.copy(b.start),this.lineContoursInfo.end.copy(b.end),this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE)}else{var c=this.lineContoursInfo.preSelLineInfo.geometry,N=((D=this.lineContoursInfo.preSelLineInfo.indexRange.concat())[0]+=c.drawRange.start/2,D[1]+=c.drawRange.start/2,!1);if(c.isBufferGeometry){h=c.index,u=c.attributes.position.array;if(null!=h){for(var p=h.array,f=0,M=D[0],w=D[1],b=new Mn,x=null,m=M,g=w;m<=g;m++,f+=1){v=p[2*m],A=p[2*m+1],y=new THREE.Vector3,E=new THREE.Vector3;if(y.fromArray(u,3*v),E.fromArray(u,3*A),y.x==E.x&&y.y==E.y)f--;else{y.applyMatrix4(this.lineContoursInfo.preSelLineInfo.matrixWorld),E.applyMatrix4(this.lineContoursInfo.preSelLineInfo.matrixWorld);var I,T,S=this.lineContoursInfo.preSelLineInfo.intersect.clone().sub(y).normalize(),j=E.clone().sub(y).normalize();S.distanceTo(j)<1e-6&&null==x&&0<=(I=new THREE.Line3(y,E).closestPointToPointParameter(this.lineContoursInfo.preSelLineInfo.intersect,!1))&&I<=1&&((T=new En).edgeIndex=f,T.Pos=I,x=T);for(var _=0;_<this.lineContoursInfo.Contours.length;++_)for(var B=this.lineContoursInfo.Contours[_],l=0;l<B.LineSegments.length;++l){var s=B.LineSegments[l],V=new THREE.Vector2(y.x,y.y),k=new THREE.Vector2(E.x,E.y),U=new THREE.Vector3;if(this.lineIntersection2D(V,k,s.start,s.end,U)){(P=new En).edgeIndex=f,P.Pos=U.z;for(var P,C=!1,R=0;R<b.intersectPos.length;++R){if(b.intersectPos[R].edgeIndex>P.edgeIndex){b.intersectPos.splice(R,0,P),C=!0;break}if(b.intersectPos[R].edgeIndex==P.edgeIndex&&b.intersectPos[R].Pos>P.Pos){b.intersectPos.splice(R,0,P),C=!0;break}}C||b.intersectPos.push(P);var O=new En;O.edgeIndex=l,O.Pos=U.s;for(C=!1,R=0;R<B.intersectPos.length;++R){if(B.intersectPos[R].edgeIndex>O.edgeIndex){B.intersectPos.splice(R,0,O),C=!0;break}if(B.intersectPos[R].edgeIndex==O.edgeIndex&&B.intersectPos[R].Pos>O.Pos){B.intersectPos.splice(R,0,O),C=!0;break}}C||B.intersectPos.push(O),N=!0}}}E=y=null}if(N){e&&(this.lineContoursInfo.divPos=e);d=this.createLine(this.lineContoursInfo.preSelLineInfo,!1);this.OpMeasure.rootObject.add(d),b.intersectMouse=x,b.dimString=this.lineContoursInfo.preSelLineInfo.length,b.lineobj=d,b.lineInfo=this.lineContoursInfo.preSelLineInfo;(L=document.createElement("div")).className="mearesult",this.viewer.container.appendChild(L),b.textBox=L;var L,D,c=b.lineInfo.geometry;if((D=b.lineInfo.indexRange.concat())[0]+=c.drawRange.start/2,D[1]+=c.drawRange.start/2,c.isBufferGeometry){h=c.index,u=c.attributes.position.array;if(null!=h)for(p=h.array,f=0,m=M=D[0],g=w=D[1];m<=g;m++,f+=1){var H,v=p[2*m],A=p[2*m+1],y=new THREE.Vector3,E=new THREE.Vector3;y.fromArray(u,3*v),E.fromArray(u,3*A),y.x==E.x&&y.y==E.y?(f--,E=y=null):(y.applyMatrix4(b.lineInfo.matrixWorld),E.applyMatrix4(b.lineInfo.matrixWorld),(H=new yn).start.set(y.x,y.y),H.end.set(E.x,E.y),b.LineSegments.push(H),E=y=null)}}b.start.set(this.edgeInfo.startPos.x,this.edgeInfo.startPos.y),b.end.set(this.edgeInfo.endPos.x,this.edgeInfo.endPos.y),b.textPos=new THREE.Vector3((b.start.x+b.end.x)/2,(b.start.y+b.end.y)/2,0),this.lineContoursInfo.Contours.push(b),this.lineContoursInfo.start.copy(b.start),this.lineContoursInfo.end.copy(b.end),this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE)}else this.OpMeasure.PostInfo(ve.INFOTYPE.NOCONJOINT)}}}this.lineContoursInfo.preSelLineInfo=null}}else this.lineContoursInfo.preSelLineObj&&(this.OpMeasure.rootObject.remove(this.lineContoursInfo.preSelLineObj),this.lineContoursInfo.preSelLineObj=null,this.lineContoursInfo.preSelLineInfo=null),this.OpMeasure.PostInfo(ve.INFOTYPE.CIRCLEANDLINE)};function xn(e,t){var n,i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){{var n;if(e)return"string"==typeof e?In(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?In(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length)return i&&(e=i),n=0,function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function In(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}(bn.prototype=Object.create(h.prototype)).OperatorStart=function(e){this.measureType=e},bn.prototype.onNMouseMove=function(e,t){e=new THREE.Vector3(e,t,0);this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&!Se.isMobileDevice()&&this.createAndShowDistanceDimension(e)},bn.prototype.createWall=function(e,t){""==this.distanceInfo.unit&&(this.distanceInfo.unit=this.getUnitString());var n=this.viewer,i=n.renderer.domElement,r=n.renderer.getPixelRatio(),o=new THREE.Raycaster,e=(n.camera.setCastRay(o,e*r/i.width*2-1,2*-(t*r/i.height)+1),this.getLinePrecision()),t=(o.linePrecision=e,null);if(!(t=n.ndsModel?n.ndsModel.intersect(o.ray,o.linePrecision/600):t)||!t[0].face)return null;r=t[0].meshId,i=this.viewer.ndsModel.meshManager;if(i.geomId[r]<0)return null;e=i.geomManager.getGeomFromId(i.geomId[r]);if(!e.loaded||e.index&&null==e.index.array)return null;n=i.bodyNodes[r];if(n.isHidden())return null;var o=n.worldMatrix.clone(),r=i.ndsModel.getBodyTranslate(n),i=(o.elements[12]+=r[0],o.elements[13]+=r[1],o.elements[14]+=r[2],new THREE.Matrix4),a=(i.getInverse(o),new THREE.Ray(t[0].point.applyMatrix4(i),t[0].face.normal.divideScalar(-1))),s=t[0],l=e.index;if(!l)return null;for(var d=e.attributes.position,c=new THREE.Vector3,h=new THREE.Vector3,u=new THREE.Vector3,p=new THREE.Vector3,f=new THREE.Face3,m=e.drawRange.start,g=e.drawRange.start+e.drawRange.count;m<g;m+=3){var v=l.getX(m),A=l.getX(m+1),y=l.getX(m+2);c.fromBufferAttribute(d,v),h.fromBufferAttribute(d,A),u.fromBufferAttribute(d,y),null!==a.intersectTriangle(u,h,c,!0,p)&&(f.a=v,f.b=A,f.c=y,f.normal=THREE.Triangle.normal(c,h,u),(v=a.origin.distanceTo(p))<s.distance&&s.faceIndex!=m/3)&&(s.distance=v,s.point=p.clone())}this.distanceInfo.firstSelInfo={type:"point",point:a.origin.applyMatrix4(o)},this.distanceInfo.firstPoint=this.distanceInfo.firstSelInfo.point,this.distanceInfo.secondSelInfo={type:"point",point:s.point.applyMatrix4(o)},this.distanceInfo.secondPoint=this.distanceInfo.secondSelInfo.point,this.distanceInfo.dimString=s.distance.toFixed(2);n=this.createPointMesh(this.distanceInfo.firstSelInfo.point,this.materialPoint,this.POINTSIZE),n&&(this.OpMeasure.rootObject.add(n),this.distanceInfo.firstSelObj=n),r=this.createPointMesh(this.distanceInfo.secondSelInfo.point,this.materialPoint,this.POINTSIZE);r&&(this.OpMeasure.rootObject.add(r),this.distanceInfo.secondSelObj=r)},bn.prototype.onLMouseClick=function(e,t,n){var i=new THREE.Vector3(e,t,0);this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj?this.createAndShowDistanceDimension(i,!0):(this.createWall(e,t),this.createAndShowDistanceDimension(i))};function Tn(e){h.call(this,e),this.measureClass="Thickness"}function o(e){h.call(this,e),this.measureClass="Lineargauge3D";var t=this;this.clickBoxInfo=function(e){!Se.isMobileDevice()&&"Lineargauge3D"==t.measureClass&&t.isBoxMoving&&(t.getViewClientCoords(e),t.ShowLineargaugeDimension(null,!0,t.distanceInfo.XorY,!0),t.allowType=t.MeasurePostInfo(t.measureType,!0,!0))}}function a(e){h.call(this,e),this.measureClass="WallThickness",this.tmpDimStringPrefix=Se.translateString("MINIMUM")}(Tn.prototype=Object.create(h.prototype)).OperatorStart=function(e){},Tn.prototype.ClearPreSel=function(){this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelfInfo=null)},Tn.prototype.GetSelfInfoFromMouseXY=function(e,t){var n=null;return(e=this.doRaycasterPick(e,t,!1))&&0!=e.length?(t=e[0])&&(n=this.getSelectInfoFromIntersect(t)):this.ClearPreSel(),n},Tn.prototype.onNMouseMove=function(e,t){e=this.GetSelfInfoFromMouseXY(e,t);e&&"face"===e.topolType&&(this.isTwoTopolInfoTheSame(this.distanceInfo.preSelInfo,e)||(this.distanceInfo.preSelInfo=e,this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null)),this.distanceInfo.preSelInfo)&&!this.distanceInfo.preSelObj&&(t=this.createFace(this.distanceInfo.preSelInfo,!0))&&(this.OpMeasure.rootObject.add(t),this.distanceInfo.preSelObj=t)},Tn.prototype.onLMouseClick=function(e,t,n){var i,r,o;this.distanceInfo.firstSelObj?(r=this.GetSelfInfoFromMouseXY(e,t))&&"face"===r.topolType&&(this.ClearPreSel(),this.distanceInfo.secondSelInfo=r,o=this.createFace(this.distanceInfo.firstSelInfo,!1))&&(this.OpMeasure.rootObject.add(o),this.distanceInfo.secondSelObj=o,0<(i=this.CalculateNearestFaceToFace(this.distanceInfo.firstSelInfo,this.distanceInfo.secondSelInfo)).distLen)&&(this.distanceInfo.dimString=i.distLen.toFixed(2),new THREE.LineBasicMaterial({color:255,depthTest:!1}),this.distanceInfo.firstPoint=i.startP,this.distanceInfo.secondPoint=i.endP,this.viewer.is2DModel?this.createAndShowDistanceDimension():this.createAndShow3DDistanceDimension(null,!0),this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.OpMeasure.rootObject.remove(this.distanceInfo.secondSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.secondSelObj=null,this.distanceInfo.firstSelInfo=null,this.distanceInfo.secondSelInfo=null):(r=this.GetSelfInfoFromMouseXY(e,t))&&"face"===r.topolType&&(this.ClearPreSel(),this.distanceInfo.firstSelInfo=r,o=this.createFace(this.distanceInfo.firstSelInfo,!1))&&(this.OpMeasure.rootObject.add(o),this.distanceInfo.firstSelObj=o)},Tn.prototype.PointToTriangleNearestDistance=function(e,t){var n,i,r,o,a={},s=(new THREE.Vector3).subVectors(t.v0,e),l=(new THREE.Vector3).subVectors(t.v1,t.v0),d=(new THREE.Vector3).subVectors(t.v2,t.v0),c=l.dot(l),h=l.dot(d),u=d.dot(d),p=s.dot(l),s=s.dot(d),f=Math.max(c*u-h*h,0),m=h*s-u*p,g=h*p-c*s;return m+g<=f?m<0?g<0&&p<0?(g=0,m=c<=-p?1:-p/c):g=(m=0)<=s?0:u<=-s?1:-s/u:g<0?m=(g=0)<=p?0:c<=-p?1:-p/c:(m/=f,g/=f):m<0?g=(n=h+p)<(i=u+s)?(o=c-2*h+u)<=(r=i-n)?(m=1,0):1-(m=r/o):i<=(m=0)?1:0<=s?0:-s/u:g<0?m=(n=h+s)<(i=c+p)?(o=c-2*h+u)<=(r=i-n)?(g=1,0):1-(g=r/o):i<=(g=0)?1:0<=p?0:-p/c:g=(r=u+s-h-p)<=0?(m=0,1):(o=c-2*h+u)<=r?(m=1,0):1-(m=r/o),a.startP=e,a.endP=new THREE.Vector3,a.endP.x=t.v0.x+l.x*m+d.x*g,a.endP.y=t.v0.y+l.y*m+d.y*g,a.endP.z=t.v0.z+l.z*m+d.z*g,a.distLen=e.clone().distanceTo(a.endP),a},Tn.prototype.CalculateNearestFaceToFace=function(e,t){for(var n=e.geometry,i=t.geometry,r=e.indexRange.concat(),o=(r[0]+=n.drawRange.start/3,r[1]+=n.drawRange.start/3,t.indexRange.concat()),a=(o[0]+=i.drawRange.start/3,o[1]+=i.drawRange.start/3,n.index),s=new Set,l=r[0];l<=r[1];l++){var d=3*l,c=a.getX(d),h=a.getX(d+1),u=a.getX(d+2);s.add(c),s.add(h),s.add(u)}for(var p=i.index,f=new Set,l=o[0];l<=o[1];l++){d=3*l,c=p.getX(d),h=p.getX(d+1),u=p.getX(d+2);f.add(c),f.add(h),f.add(u)}for(var m={distLen:1/0},g=n.attributes.position,v=i.attributes.position,A=xn(s);!(y=A()).done;){var y=y.value;(T=new THREE.Vector3).fromBufferAttribute(g,y),T.applyMatrix4(e.matrixWorld);for(var E=o[0];E<=o[1];E++){var d=3*E,c=p.getX(d),h=p.getX(d+1),u=p.getX(d+2),M=new THREE.Vector3,w=new THREE.Vector3,b=new THREE.Vector3;M.fromBufferAttribute(v,c),w.fromBufferAttribute(v,h),b.fromBufferAttribute(v,u),M.applyMatrix4(t.matrixWorld),w.applyMatrix4(t.matrixWorld),b.applyMatrix4(t.matrixWorld),(B={}).v0=M,B.v1=w,B.v2=b,0<=(P=this.PointToTriangleNearestDistance(T,B)).distLen&&P.distLen<m.distLen&&(m=P)}}for(var x={distLen:1/0},I=xn(f);!(S=I()).done;){var T,S=S.value;(T=new THREE.Vector3).fromBufferAttribute(v,S),T.applyMatrix4(t.matrixWorld);for(E=r[0];E<=r[1];E++){var B,P,d=3*E,c=a.getX(d),h=a.getX(d+1),u=a.getX(d+2),M=new THREE.Vector3,w=new THREE.Vector3,b=new THREE.Vector3;M.fromBufferAttribute(g,c),w.fromBufferAttribute(g,h),b.fromBufferAttribute(g,u),M.applyMatrix4(e.matrixWorld),w.applyMatrix4(e.matrixWorld),b.applyMatrix4(e.matrixWorld),(B={}).v0=M,B.v1=w,B.v2=b,0<=(P=this.PointToTriangleNearestDistance(T,B)).distLen&&P.distLen<x.distLen&&(x=P)}}return m.distLen>x.distLen?x:m},(o.prototype=Object.create(h.prototype)).OperatorClear=function(e){this.allowType=[],this.selectProjectPlane=!1,this.matrxTrans=null,this.sectionCross=null,this.projectDirectionXorY=null,this.isBoxMoving=!1},o.prototype.OperatorStart=function(e){this.measureType=e,this.allowType=this.MeasurePostInfo(e,!0,!0),this.selectProjectPlane=!1,this.distanceInfo.projectPlane=null,this.matrxTrans=null,this.sectionCross=null,this.projectDirectionXorY=null,this.isBoxMoving=!1},o.prototype.MeasurePostInfo=function(e,t,n){var i=[];switch(e){case"LmPt2Pt":this.OpMeasure.PostInfo(t?ve.INFOTYPE.CLICKFIRSTPOINT:ve.INFOTYPE.CLICKSECONDPOINT),n&&(i=["point"]);break;case"LmPt2Line":this.OpMeasure.PostInfo(t?ve.INFOTYPE.POINT:ve.INFOTYPE.LINE),n&&(i=t?["point"]:["line"]);break;case"LmLine2Line":this.OpMeasure.PostInfo(t?ve.INFOTYPE.FIRSTLINE:ve.INFOTYPE.SECONDLINE),n&&(i=["line"]);break;case"LmHole2Hole":this.OpMeasure.PostInfo(t?ve.INFOTYPE.CIRCLE:ve.INFOTYPE.SECONDCIRCLE),n&&(i=["circle","cylinder"]);break;case"LmAxis2Pt":this.OpMeasure.PostInfo(t?ve.INFOTYPE.POINT:ve.INFOTYPE.AXIS),n&&(i=t?["point"]:["circle","cone","cylinder"]);break;case"LmAxis2Line":this.OpMeasure.PostInfo(t?ve.INFOTYPE.AXIS:ve.INFOTYPE.LINE),n&&(i=t?["circle","cone","cylinder"]:["line"])}return i},o.prototype.onNMouseMove=function(e,t){var n,i,r,o,a,s=new THREE.Vector3(e,t,0);this.OpMeasure.unsteady?this.changeMeasureDistance(s):this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj||this.selectProjectPlane?null==this.distanceInfo.projectPlane?this.selectProjectPlane&&(this.LineargaugeMeasure(e,t,!0,["plane"]),this.updateLineargaugeMeasure(!0,!0)):Se.isMobileDevice()||(this.distanceInfo.projectFstPos&&this.distanceInfo.projectSecPos||(this.distanceInfo.projectFstPos=new THREE.Vector3,this.distanceInfo.projectSecPos=new THREE.Vector3,this.distanceInfo.projectPlane.projectPoint(this.distanceInfo.firstPoint,this.distanceInfo.projectFstPos),this.distanceInfo.projectPlane.projectPoint(this.distanceInfo.secondPoint,this.distanceInfo.projectSecPos),this.distanceInfo.projectFstClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.projectFstClnd),this.distanceInfo.projectFstClnd=this.createPointMesh(this.distanceInfo.projectFstPos,this.materialProjectPoint,this.POINTSIZE),this.OpMeasure.rootObject.add(this.distanceInfo.projectFstClnd),this.distanceInfo.projectSecClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.projectSecClnd),this.distanceInfo.projectSecClnd=this.createPointMesh(this.distanceInfo.projectSecPos,this.materialProjectPoint,this.POINTSIZE),this.OpMeasure.rootObject.add(this.distanceInfo.projectSecClnd)),this.matrxTrans||this.lineargaugeRotateOnly(this.distanceInfo.projectPlane),n=this.distanceInfo.projectFstPos.clone(),i=this.distanceInfo.projectSecPos.clone(),this.lineargaugeModelCoord2PlaneCoord(n),this.lineargaugeModelCoord2PlaneCoord(i),s&&(r=this.distanceInfo.projectPlane,r=this.clientCoordToModelCoordOnPlane(s.x,s.y,r),this.lineargaugeModelCoord2PlaneCoord(r),r)&&(this.distanceInfo.mousePos||(this.distanceInfo.mousePos=r.clone()),a=o=!1,(o=this.distanceInfo.mousePos.y<Math.max(n.y,i.y)+0&&this.distanceInfo.mousePos.y>+Math.min(n.y,i.y)&&this.distanceInfo.mousePos.x<Math.max(n.x,i.x)+0&&this.distanceInfo.mousePos.x>+Math.min(n.x,i.x)?!0:o)!=(a=r.y<Math.max(n.y,i.y)+0&&r.y>+Math.min(n.y,i.y)&&r.x<Math.max(n.x,i.x)+0&&r.x>+Math.min(n.x,i.x)?!0:a)&&(n.y<Math.max(this.distanceInfo.mousePos.y,r.y)&&n.y>Math.min(this.distanceInfo.mousePos.y,r.y)||i.y<Math.max(this.distanceInfo.mousePos.y,r.y)&&i.y>Math.min(this.distanceInfo.mousePos.y,r.y)?this.distanceInfo.XorY=0:(n.x<Math.max(this.distanceInfo.mousePos.x,r.x)&&n.x>Math.min(this.distanceInfo.mousePos.x,r.x)||i.x<Math.max(this.distanceInfo.mousePos.x,r.x)&&i.x>Math.min(this.distanceInfo.mousePos.x,r.x))&&(this.distanceInfo.XorY=1)),this.distanceInfo.mousePos.set(r.x,r.y,0)),this.ShowLineargaugeDimension(s,!1,this.distanceInfo.XorY)):(this.LineargaugeMeasure(e,t,!0,this.allowType),this.updateLineargaugeMeasure(!0,!1))},o.prototype.onLMouseClick=function(e,t,n){var i=new THREE.Vector3(e,t,0);this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj||this.selectProjectPlane?null==this.distanceInfo.projectPlane?this.selectProjectPlane&&(this.LineargaugeMeasure(e,t,!1,["plane"]),this.updateLineargaugeMeasure(!1,!0),this.distanceInfo.projectPlane)&&this.LineargaugePostNotify():(this.matrxTrans||this.lineargaugeRotateOnly(this.distanceInfo.projectPlane),Se.isMobileDevice()||(this.ShowLineargaugeDimension(i,!0,this.distanceInfo.XorY),this.allowType=this.MeasurePostInfo(this.measureType,!0,!0))):(this.LineargaugeMeasure(e,t,!1,this.allowType),this.updateLineargaugeMeasure(!1,!1))},o.prototype.LineargaugeMeasure=function(e,t,n,i){e=this.doRaycasterPick(e,t,!0);if(e&&0!=e.length)if(n)-1!=i.indexOf("point")&&(this.previewSnappedPoint2(e),null!=this.snappedPoint)?this.LineargaugeClearPreSelect():(t=e[0])&&(n=this.getSelectInfoFromIntersect(t))&&(-1==i.indexOf(n.type)||"line"==n.type&&!this.Bline(n)?this.LineargaugeClearPreSelect():null!=this.distanceInfo.preSelInfo&&this.isTwoTopolInfoTheSame(this.distanceInfo.preSelInfo,n)||(this.distanceInfo.preSelInfo=n,this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null)));else if(null!=this.snappedPoint&&-1!=i.indexOf("point"))null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstPoint=this.snappedPoint.clone(),this.distanceInfo.firstSelInfo={type:"point",point:this.snappedPoint},this.LineargaugePostNotify()):"point"==this.distanceInfo.firstSelInfo.type&&this.distanceInfo.firstSelObj&&this.isTwoPointTheSame(this.distanceInfo.firstSelInfo.point,this.snappedPoint)?(this.LineargaugeClearFirstSelect(),this.LineargaugePostNotify()):(this.distanceInfo.secondPoint=this.snappedPoint.clone(),this.distanceInfo.secondSelInfo={type:"point",point:this.snappedPoint},this.LineargaugePostSelectPorjectPlane()),this.snappedPoint=null;else{t=e[0];if(t){var r,o,a,s,l,d,c,n=this.getSelectInfoFromIntersect(t);if(n){if(-1!=i.indexOf("line")&&"line"==n.type&&!this.Bline(n))return void this.LineargaugeClearPreSelect();if(-1==i.indexOf(n.type)&&-1!=i.indexOf("point")){var e=n.intersect.clone();null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstPoint=e,this.distanceInfo.firstSelInfo={type:"point",point:e},this.LineargaugePostNotify()):(this.distanceInfo.secondSelInfo={type:"point",point:e},this.distanceInfo.secondPoint=e,this.LineargaugePostSelectPorjectPlane())}else if(-1!=i.indexOf(n.type)){if("plane"==n.type&&this.selectProjectPlane&&null==this.distanceInfo.projectPlane)return e=(new THREE.Plane).setFromNormalAndCoplanarPoint(n.worldNormal,n.worldOrigin),this.distanceInfo.projectPlaneInfo=n,this.LineargaugePostSelectPorjectPlane(e),void this.LineargaugeClearPreSelect();null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstSelInfo=n,this.LineargaugePostNotify()):this.distanceInfo.firstSelInfo&&(this.isTwoTopolInfoTheSame(this.distanceInfo.firstSelInfo,n)?(this.LineargaugeClearFirstSelect(),this.LineargaugePostNotify()):(e=null,"point"==(r=this.distanceInfo.firstSelInfo).type&&"line"==n.type?(a=this.getLineStartEndPoints(n))&&(d=new THREE.Line3(a.start,a.end).closestPointToPoint(this.distanceInfo.firstPoint,!1),this.distanceInfo.secondPoint=d,this.distanceInfo.secondSelInfo=n,a=(new THREE.Vector3).subVectors(a.start,a.end),e=(new THREE.Plane).setFromNormalAndCoplanarPoint(a,d).normalize()):"line"==r.type&&"line"==n.type?(a=this.getLineStartEndPoints(r),d=this.getLineStartEndPoints(n),a&&d&&((o=(new THREE.Vector3).subVectors(a.end,a.start)).normalize(),(c=(new THREE.Vector3).subVectors(d.end,d.start)).normalize(),s=o.dot(c),l=new THREE.Line3(a.start,a.end).closestPointToPoint(d.start,!1),1-Math.abs(s)<1e-7?(this.distanceInfo.secondSelInfo=n,this.distanceInfo.firstPoint=l,this.distanceInfo.secondPoint=d.start.clone(),e=(new THREE.Plane).setFromNormalAndCoplanarPoint(c,this.distanceInfo.secondPoint).normalize()):this.OpMeasure.PostInfo(ve.INFOTYPE.LINENOPARALLEL))):"circle"!=r.type&&"cylinder"!=r.type||"circle"!=n.type&&"cylinder"!=n.type?"point"!=r.type||"circle"!=n.type&&"cylinder"!=n.type&&"cone"!=n.type?"circle"!=r.type&&"cylinder"!=r.type&&"cone"!=r.type||"line"!=n.type||(a=this.getLineStartEndPoints(r),d=this.getLineStartEndPoints(n),a&&d&&((o=(new THREE.Vector3).subVectors(a.end,a.start)).normalize(),(c=(new THREE.Vector3).subVectors(d.end,d.start)).normalize(),s=o.dot(c),l=new THREE.Line3(a.start,a.end).closestPointToPoint(d.start,!1),1-Math.abs(s)<1e-7?(this.distanceInfo.secondSelInfo=n,this.distanceInfo.firstPoint=l,this.distanceInfo.secondPoint=d.start.clone(),e=(new THREE.Plane).setFromNormalAndCoplanarPoint(c,this.distanceInfo.secondPoint).normalize()):this.OpMeasure.PostInfo(ve.INFOTYPE.AXISNOPARALLELLINE))):(o=this.getLineStartEndPoints(n))&&(a=new THREE.Line3(o.start,o.end).closestPointToPoint(this.distanceInfo.firstPoint,!1),this.distanceInfo.secondPoint=a.clone(),this.distanceInfo.secondSelInfo=n,s=(new THREE.Vector3).subVectors(o.start,o.end),e=(new THREE.Plane).setFromNormalAndCoplanarPoint(s,a).normalize()):(l=this.getLineStartEndPoints(r),this.distanceInfo.firstPoint=l.start,d=this.getLineStartEndPoints(n),this.distanceInfo.secondPoint=d.start.clone(),this.distanceInfo.secondSelInfo=n,this.LineargaugePostSelectPorjectPlane()),e&&this.LineargaugePostSelectPorjectPlane(e)))}}else-1!=i.indexOf("point")&&(c=t.point,null==this.distanceInfo.firstSelInfo?(this.distanceInfo.firstPoint=c,this.distanceInfo.firstSelInfo={type:"point",point:c},this.LineargaugePostNotify()):(this.distanceInfo.secondSelInfo={type:"point",point:c},this.distanceInfo.secondPoint=c,this.LineargaugePostSelectPorjectPlane()))}this.LineargaugeClearPreSelect()}else this.LineargaugeClearPreSelect()},o.prototype.updateLineargaugeMeasure=function(e,t){var n;this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&!t?this.LineargaugeClearPreSelect():e?this.distanceInfo.preSelInfo&&!this.distanceInfo.preSelObj&&("line"==this.distanceInfo.preSelInfo.type||"circle"==this.distanceInfo.preSelInfo.type?(n=this.createLine(this.distanceInfo.preSelInfo,!(n=null)))&&(this.OpMeasure.rootObject.add(n),this.distanceInfo.preSelObj=n):"plane"!=this.distanceInfo.preSelInfo.type&&"cylinder"!=this.distanceInfo.preSelInfo.type&&"cone"!=this.distanceInfo.preSelInfo.type||(n=this.createFace(this.distanceInfo.preSelInfo,!0))&&(this.OpMeasure.rootObject.add(n),this.distanceInfo.preSelObj=n)):(this.distanceInfo.firstSelInfo&&!this.distanceInfo.firstSelObj&&(this.LineargaugeClearPreSelect(),n=null,"point"==this.distanceInfo.firstSelInfo.type?n=this.createPointMesh(this.distanceInfo.firstSelInfo.point,this.materialPoint,this.POINTSIZE):"line"==this.distanceInfo.firstSelInfo.type||"circle"==this.distanceInfo.firstSelInfo.type?n=this.createLine(this.distanceInfo.firstSelInfo,!1):"plane"!=this.distanceInfo.firstSelInfo.type&&"cylinder"!=this.distanceInfo.firstSelInfo.type&&"cone"!=this.distanceInfo.firstSelInfo.type||(n=this.createFace(this.distanceInfo.firstSelInfo,!1),"cylinder"!=this.distanceInfo.firstSelInfo.type&&"cone"!=this.distanceInfo.firstSelInfo.type)||(this.distanceInfo.axisLineObj=this.createAxisLine(this.distanceInfo.firstSelInfo),this.OpMeasure.rootObject.add(this.distanceInfo.axisLineObj)),n)&&(this.OpMeasure.rootObject.add(n),this.distanceInfo.firstSelObj=n),this.distanceInfo.secondSelInfo&&!this.distanceInfo.secondSelObj&&(this.LineargaugeClearPreSelect(),n=null,"point"==this.distanceInfo.secondSelInfo.type?n=this.createPointMesh(this.distanceInfo.secondSelInfo.point,this.materialPoint,this.POINTSIZE):"line"==this.distanceInfo.secondSelInfo.type||"circle"==this.distanceInfo.secondSelInfo.type?n=this.createLine(this.distanceInfo.secondSelInfo,!1):"plane"!=this.distanceInfo.secondSelInfo.type&&"cylinder"!=this.distanceInfo.secondSelInfo.type&&"cone"!=this.distanceInfo.secondSelInfo.type||(n=this.createFace(this.distanceInfo.secondSelInfo,!1),"cylinder"!=this.distanceInfo.secondSelInfo.type&&"cone"!=this.distanceInfo.secondSelInfo.type)||(this.distanceInfo.secaxisLineObj=this.createAxisLine(this.distanceInfo.secondSelInfo),this.OpMeasure.rootObject.add(this.distanceInfo.secaxisLineObj)),n)&&(this.OpMeasure.rootObject.add(n),this.distanceInfo.secondSelObj=n),this.distanceInfo.projectPlaneInfo&&!this.distanceInfo.projectPlaneObj&&(this.LineargaugeClearPreSelect(),n=null,(n="plane"==this.distanceInfo.projectPlaneInfo.type?this.createFace(this.distanceInfo.projectPlaneInfo,!1):n)&&(this.OpMeasure.rootObject.add(n),this.distanceInfo.projectPlaneObj=n),this.lineargaugeRotateOnly(this.distanceInfo.projectPlane)),this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&this.distanceInfo.projectPlane&&(_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes(),this.LineargaugeClearPreSelect(),this.matrxTrans||this.lineargaugeRotateOnly(this.distanceInfo.projectPlane),Se.isMobileDevice()?null!=this.projectDirectionXorY?(this.ShowLineargaugeDimension(null,!0,this.projectDirectionXorY),this.LineargaugePostNotify()):this.OpMeasure.PostInfo(ve.INFOTYPE.SELECTPLACELINELOCATION):(this.OpMeasure.PostInfo(ve.INFOTYPE.PLACELINELOCATION),this.ShowLineargaugeDimension())))},o.prototype.ShowLineargaugeDimension=function(e,t,n,i){var r,o,a,s,l;this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&(this.distanceInfo.projectFstPos&&this.distanceInfo.projectSecPos||(this.distanceInfo.projectFstPos=new THREE.Vector3,this.distanceInfo.projectSecPos=new THREE.Vector3,this.distanceInfo.projectPlane.projectPoint(this.distanceInfo.firstPoint,this.distanceInfo.projectFstPos),this.distanceInfo.projectPlane.projectPoint(this.distanceInfo.secondPoint,this.distanceInfo.projectSecPos),this.distanceInfo.projectFstClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.projectFstClnd),this.distanceInfo.projectFstClnd=this.createPointMesh(this.distanceInfo.projectFstPos,this.materialProjectPoint,this.POINTSIZE),this.OpMeasure.rootObject.add(this.distanceInfo.projectFstClnd),this.distanceInfo.projectSecClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.projectSecClnd),this.distanceInfo.projectSecClnd=this.createPointMesh(this.distanceInfo.projectSecPos,this.materialProjectPoint,this.POINTSIZE),this.OpMeasure.rootObject.add(this.distanceInfo.projectSecClnd)),null==n&&(n=0),i||(this.distanceInfo.fstClndPos?this.distanceInfo.fstClndPos.set(this.distanceInfo.projectFstPos.x,this.distanceInfo.projectFstPos.y,this.distanceInfo.projectFstPos.z):this.distanceInfo.fstClndPos=this.distanceInfo.projectFstPos.clone(),this.distanceInfo.sndClndPos?this.distanceInfo.sndClndPos.set(this.distanceInfo.projectSecPos.x,this.distanceInfo.projectSecPos.y,this.distanceInfo.projectSecPos.z):this.distanceInfo.sndClndPos=this.distanceInfo.projectSecPos.clone()),this.lineargaugeModelCoord2PlaneCoord(this.distanceInfo.fstClndPos),this.lineargaugeModelCoord2PlaneCoord(this.distanceInfo.sndClndPos),e?(i=this.distanceInfo.projectPlane,e=this.clientCoordToModelCoordOnPlane(e.x,e.y,i),this.lineargaugeModelCoord2PlaneCoord(e),e&&0==n?(this.distanceInfo.fstClndPos.y=e.y,this.distanceInfo.sndClndPos.y=e.y,this.distanceInfo.fstClndPos.z=0,this.distanceInfo.sndClndPos.z=0):e&&1==n&&(this.distanceInfo.fstClndPos.x=e.x,this.distanceInfo.sndClndPos.x=e.x,this.distanceInfo.fstClndPos.z=0,this.distanceInfo.sndClndPos.z=0)):0==n?(i=(this.distanceInfo.fstClndPos.y+this.distanceInfo.sndClndPos.y)/2,this.distanceInfo.fstClndPos.y=i,this.distanceInfo.sndClndPos.y=i,this.distanceInfo.fstClndPos.z=0,this.distanceInfo.sndClndPos.z=0):1==n&&(e=(this.distanceInfo.fstClndPos.x+this.distanceInfo.sndClndPos.x)/2,this.distanceInfo.fstClndPos.x=e,this.distanceInfo.sndClndPos.x=e,this.distanceInfo.fstClndPos.z=0,this.distanceInfo.sndClndPos.z=0),i=this.distanceInfo.fstClndPos.clone(),e=this.distanceInfo.sndClndPos.clone(),i.distanceTo(e)<1e-6&&(0==n?(i.x+=.5,e.x-=.5):(i.y+=.5,e.y-=.5)),this.lineargaugePlaneCoord2ModelCoord(this.distanceInfo.fstClndPos),this.lineargaugePlaneCoord2ModelCoord(this.distanceInfo.sndClndPos),this.lineargaugePlaneCoord2ModelCoord(i),this.lineargaugePlaneCoord2ModelCoord(e),this.distanceInfo.textPos?(this.distanceInfo.textPos.x=(this.distanceInfo.fstClndPos.x+this.distanceInfo.sndClndPos.x)/2,this.distanceInfo.textPos.y=(this.distanceInfo.fstClndPos.y+this.distanceInfo.sndClndPos.y)/2,this.distanceInfo.textPos.z=(this.distanceInfo.fstClndPos.z+this.distanceInfo.sndClndPos.z)/2):this.distanceInfo.textPos=new THREE.Vector3((this.distanceInfo.fstClndPos.x+this.distanceInfo.sndClndPos.x)/2,(this.distanceInfo.fstClndPos.y+this.distanceInfo.sndClndPos.y)/2,(this.distanceInfo.fstClndPos.z+this.distanceInfo.sndClndPos.z)/2),(r=(new THREE.Vector3).subVectors(e,i)).normalize(),this.distanceInfo.fstClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstClnd),this.distanceInfo.fstClnd=this.createCylinderMesh(e,this.distanceInfo.fstClndPos,this.appmaterialLine),a=this.OpMeasure.getScale(this.distanceInfo.fstClnd,this.CYLINDERWIDTH),r.multiplyScalar(.5*this.distanceInfo.fstClnd.geometry.parameters.height),this.distanceInfo.fstClnd.oldPosition=this.distanceInfo.fstClndPos.clone(),this.distanceInfo.fstClnd.offsetPos=r.clone(),this.distanceInfo.fstClnd.position.addVectors(this.distanceInfo.fstClndPos,r.clone().multiplyScalar(a)),this.distanceInfo.fstClnd.updateMatrixWorld(),this.OpMeasure.rootObject.add(this.distanceInfo.fstClnd),this.distanceInfo.sndClnd&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndClnd),this.distanceInfo.sndClnd=this.createCylinderMesh(i,this.distanceInfo.sndClndPos,this.appmaterialLine),this.distanceInfo.sndClnd.oldPosition=this.distanceInfo.sndClndPos.clone(),this.distanceInfo.sndClnd.offsetPos=r.clone().multiplyScalar(-1),this.distanceInfo.sndClnd.position.subVectors(this.distanceInfo.sndClndPos,r.clone().multiplyScalar(a)),this.distanceInfo.sndClnd.updateMatrixWorld(),this.OpMeasure.rootObject.add(this.distanceInfo.sndClnd),this.distanceInfo.clndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.clndToClndLine),this.distanceInfo.clndToClndLine=this.createLineMesh2(this.distanceInfo.fstClndPos,this.distanceInfo.sndClndPos,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.clndToClndLine),this.distanceInfo.fstToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.fstToClndLine),this.distanceInfo.fstToClndLine=this.createLineMesh2(this.distanceInfo.projectFstPos,this.distanceInfo.fstClndPos,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.fstToClndLine),this.distanceInfo.sndToClndLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.sndToClndLine),this.distanceInfo.sndToClndLine=this.createLineMesh2(this.distanceInfo.projectSecPos,this.distanceInfo.sndClndPos,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.sndToClndLine),this.distanceInfo.FstToFstPointLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.FstToFstPointLine),this.distanceInfo.FstToFstPointLine=this.createLineMesh2(this.distanceInfo.projectFstPos,this.distanceInfo.firstPoint,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.FstToFstPointLine),this.distanceInfo.SndToSndPointLine&&this.OpMeasure.rootObject.remove(this.distanceInfo.SndToSndPointLine),this.distanceInfo.SndToSndPointLine=this.createLineMesh2(this.distanceInfo.projectSecPos,this.distanceInfo.secondPoint,this.appmaterialLine,1),this.OpMeasure.rootObject.add(this.distanceInfo.SndToSndPointLine),r=this.distanceInfo.projectFstPos.clone(),a=this.distanceInfo.projectSecPos.clone(),this.lineargaugeModelCoord2PlaneCoord(r),this.lineargaugeModelCoord2PlaneCoord(a),this.distanceInfo.dimString=r.distanceTo(a),0==n?this.distanceInfo.dimString=Math.abs(r.x-a.x):1==n&&(this.distanceInfo.dimString=Math.abs(r.y-a.y)),this.distanceInfo.dimString<1&&.999999<this.distanceInfo.dimString&&(this.distanceInfo.dimString=1),n=this.viewer.getDispalyModelUnit(this.distanceInfo.dimString),this.distanceInfo.dimString*=n.scale,this.distanceInfo.dimString=this.distanceInfo.dimString.toFixed(2),this.distanceInfo.unit=this.getUnitStringmap(n.unit),r=(this.distanceInfo.dimString*this.viewer.measuringScale).toFixed(2)+this.distanceInfo.unit,this.isBoxMoving=!0,this.distanceInfo.textBox||("pt2ptbim"==this.measureType?(this.distanceInfo.textBox=document.createElement("div"),this.distanceInfo.textBox.className="measure-tc",this.sectionCross=document.createElement("div"),this.sectionCross.className="sectionCross",this.distanceInfo.textBox.appendChild(this.sectionCross),(l=document.createElement("div")).className="sectionPoint",l.style.left="calc(50% - 6px)",l.style.top="calc(100% - 5.5px)",this.distanceInfo.textBox.appendChild(l),a=document.createElement("p"),s="en"==Se.getLanguage(),a.innerHTML=s?"<span>dis:</span>"+r:"<span>距离:</span>"+r,this.distanceInfo.textBox.appendChild(a),s=document.createElement("p"),a=Math.abs(this.distanceInfo.firstPoint.x-this.distanceInfo.secondPoint.x),n=this.viewer.getDispalyModelUnit(a),s.innerHTML="<span>X:</span>"+(a*this.viewer.measuringScale*n.scale).toFixed(2)+this.getUnitStringmap(n.unit),this.distanceInfo.textBox.appendChild(s),a=document.createElement("p"),s=Math.abs(this.distanceInfo.firstPoint.z-this.distanceInfo.secondPoint.z),n=this.viewer.getDispalyModelUnit(s),a.innerHTML="<span>Y:</span>"+(s*this.viewer.measuringScale*n.scale).toFixed(2)+this.getUnitStringmap(n.unit),this.distanceInfo.textBox.appendChild(a),s=document.createElement("p"),a=Math.abs(this.distanceInfo.firstPoint.y-this.distanceInfo.secondPoint.y),n=this.viewer.getDispalyModelUnit(a),s.innerHTML="<span>Z:</span>"+(a*this.viewer.measuringScale*n.scale).toFixed(2)+this.getUnitStringmap(n.unit),this.distanceInfo.textBox.appendChild(s)):(this.distanceInfo.textBox=document.createElement("div"),this.distanceInfo.textBox.className="section10",this.distanceInfo.textBox.innerHTML=r,this.distanceInfo.textBox.setAttribute("mobile","up"),(l=document.createElement("div")).className="sectionPoint",this.distanceInfo.textBox.appendChild(l),this.sectionCross=document.createElement("div"),this.sectionCross.className="sectionCross",this.distanceInfo.textBox.appendChild(this.sectionCross),Se.isMobileDevice()||(this.distanceInfo.textBox.addEventListener("mousedown",this.clickBoxInfo,!1),(o=this).distanceInfo.textBox.addEventListener("click",function e(t){0===t.button&&_e.enableBroadcast&&_e.broadcastMajor&&o.viewer.dispatchEvent({type:"broadcastEvent"}),this.removeEventListener("click",e)},!1))),this.viewer.container.appendChild(this.distanceInfo.textBox)),this.getAndShowTextBox(this.distanceInfo.textPos.clone(),r,this.distanceInfo.textBox),null!=r&&(this.distanceInfo.textBox.childNodes[0].data=r),1==t)&&(Se.isMobileDevice()||this.distanceInfo.textBox.removeEventListener("mousedown",this.clickBoxInfo,!1),(a={}).dimString=r,a.textPos=this.distanceInfo.textPos.clone(),a.textBox=this.distanceInfo.textBox,n=this,(s=new THREE.Group).objectType="Group",n.distanceInfo.firstSelObj&&(n.OpMeasure.rootObject.remove(n.distanceInfo.firstSelObj),s.add(n.distanceInfo.firstSelObj)),n.distanceInfo.secondSelObj&&(n.OpMeasure.rootObject.remove(n.distanceInfo.secondSelObj),s.add(n.distanceInfo.secondSelObj)),n.distanceInfo.projectPlaneObj&&(n.OpMeasure.rootObject.remove(n.distanceInfo.projectPlaneObj),s.add(n.distanceInfo.projectPlaneObj)),n.distanceInfo.boxToClndLine&&(n.OpMeasure.rootObject.remove(n.distanceInfo.boxToClndLine),s.add(n.distanceInfo.boxToClndLine)),n.distanceInfo.axisLineObj&&(n.OpMeasure.rootObject.remove(n.distanceInfo.axisLineObj),s.add(n.distanceInfo.axisLineObj)),n.distanceInfo.secaxisLineObj&&(n.OpMeasure.rootObject.remove(n.distanceInfo.secaxisLineObj),s.add(n.distanceInfo.secaxisLineObj)),n.distanceInfo.projectFstClnd&&(n.OpMeasure.rootObject.remove(n.distanceInfo.projectFstClnd),s.add(n.distanceInfo.projectFstClnd)),n.distanceInfo.projectSecClnd&&(n.OpMeasure.rootObject.remove(n.distanceInfo.projectSecClnd),s.add(n.distanceInfo.projectSecClnd)),n.distanceInfo.fstClnd&&(n.OpMeasure.rootObject.remove(n.distanceInfo.fstClnd),s.add(n.distanceInfo.fstClnd)),n.distanceInfo.sndClnd&&(n.OpMeasure.rootObject.remove(n.distanceInfo.sndClnd),s.add(n.distanceInfo.sndClnd)),n.distanceInfo.clndToClndLine&&(n.OpMeasure.rootObject.remove(n.distanceInfo.clndToClndLine),s.add(n.distanceInfo.clndToClndLine)),n.distanceInfo.fstToClndLine&&(n.OpMeasure.rootObject.remove(n.distanceInfo.fstToClndLine),s.add(n.distanceInfo.fstToClndLine)),n.distanceInfo.sndToClndLine&&(n.OpMeasure.rootObject.remove(n.distanceInfo.sndToClndLine),s.add(n.distanceInfo.sndToClndLine)),n.distanceInfo.FstToFstPointLine&&(n.OpMeasure.rootObject.remove(n.distanceInfo.FstToFstPointLine),s.add(n.distanceInfo.FstToFstPointLine)),n.distanceInfo.SndToSndPointLine&&(n.OpMeasure.rootObject.remove(n.distanceInfo.SndToSndPointLine),s.add(n.distanceInfo.SndToSndPointLine)),n.OpMeasure.rootObject.add(s),Se.isMobileDevice()?(a.textBox.addEventListener("touchstart",this.touchstart,!1),a.textBox.addEventListener("touchend",this.touchend,!1),a.textBox.addEventListener("touchmove",this.touchmove,!1)):(a.textBox.addEventListener("mousedown",this.touchstart,!1),a.textBox.addEventListener("mouseup",this.touchend,!1),a.textBox.addEventListener("mousemove",this.touchmove,!1),a.textBox.addEventListener("mouseleave",this.mouseleave,!1),a.textBox.addEventListener("mouseenter",this.mouseenter,!1)),Se.isMobileDevice()?this.sectionCross.addEventListener("touchend",this.sectionCrossend,!1):(this.sectionCross.addEventListener("mousedown",this.sectionCrossend,!1),this.sectionCross.addEventListener("mouseleave",this.crossleave,!1),this.sectionCross.addEventListener("mouseenter",this.crossenter,!1)),(l={}).start=this.distanceInfo.textPos.clone(),l.end=this.distanceInfo.textPos.clone(),l.uuid=s.uuid,this.OpMeasure.textLines.push(l),a.textBox.setAttribute("mobile","up"),a.textBox.setAttribute("group",s.uuid),a.textBox.setAttribute("type","length"),a.textBox.setAttribute("dimString",this.distanceInfo.dimString),a.textBox.setAttribute("dimStringPrefix",""),a.textBox.setAttribute("unit",this.distanceInfo.unit),a.textBox.setAttribute("lineInfo",this.OpMeasure.textLines.length-1),this.OpMeasure.boxInfos.push(a),this.OpMeasure.unsteadyData[s.uuid]=this.DeepCopy(this.distanceInfo,"Lineargauge3D"),this.OpMeasure.unsteadyData[s.uuid].p1=i,this.OpMeasure.unsteadyData[s.uuid].p2=e,this.sectionCross=null,this.matrxTrans=null,this.selectProjectPlane=!1,this.projectDirectionXorY=null,this.isBoxMoving=!1,!Se.isMobileDevice()&&"LmPt2Pt"!=this.measureType&&"LmHole2Hole"!=this.measureType||this.viewer.dispatchEvent({type:"Lineargauge3DMeasureEndEvent"}),this.clearDistanceInfo(!0),Se.isMobileDevice())&&this.ChangeMeasureFlag()},o.prototype.LineargaugeClearPreSelect=function(){this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null)},o.prototype.LineargaugeClearProjectPlaneSelect=function(){this.distanceInfo.projectPlaneObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.projectPlaneObj),this.distanceInfo.projectPlaneObj=null,this.distanceInfo.projectPlaneInfo=null)},o.prototype.LineargaugeClearFirstSelect=function(){this.distanceInfo.firstSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null),this.distanceInfo.axisLineObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.axisLineObj),this.distanceInfo.axisLineObj=null)},o.prototype.LineargaugePostSelectPorjectPlane=function(e){switch(this.measureType){case"LmPt2Pt":case"LmHole2Hole":this.distanceInfo.projectPlane?this.selectProjectPlane=!1:e?(this.distanceInfo.projectPlane=e,this.selectProjectPlane=!1,this.lineargaugeRotate(this.distanceInfo.projectPlane)):(this.OpMeasure.PostInfo(ve.INFOTYPE.SELECTPROJECTPLANE),this.selectProjectPlane=!1);break;default:this.selectProjectPlane=!1,this.distanceInfo.projectPlane=e}},o.prototype.LineargaugePostNotify=function(){this.distanceInfo.firstSelInfo?this.distanceInfo.firstSelInfo&&!this.distanceInfo.secondSelInfo&&(this.allowType=this.MeasurePostInfo(this.measureType,!1,!0)):this.allowType=this.MeasurePostInfo(this.measureType,!0,!0)},o.prototype.lineargaugeRotate=function(e,t){e=this.viewer.cameraControl.rotateToPlane(e);this.distanceInfo.projectFstPos=null,this.distanceInfo.projectSecPos=null,this.matrxTrans=e,this.viewer.render(),this.LineargaugePostNotify(),this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo&&(Se.isMobileDevice()?null!=this.projectDirectionXorY?this.lineargaugeSelectPlaceLine(this.projectDirectionXorY):this.OpMeasure.PostInfo(ve.INFOTYPE.SELECTPLACELINELOCATION):(t&&this.ShowLineargaugeDimension(null,!1,this.distanceInfo.XorY),this.OpMeasure.PostInfo(ve.INFOTYPE.PLACELINELOCATION)))},o.prototype.lineargaugeRotateOnly=function(e){e&&(e=this.viewer.cameraControl.rotateToPlane(e),this.distanceInfo.projectFstPos=null,this.distanceInfo.projectSecPos=null,this.viewer.render(),this.matrxTrans=e)},o.prototype.lineargaugeModelCoord2PlaneCoord=function(e){e.sub(this.matrxTrans.origin),e.applyMatrix3(this.matrxTrans.matrixInvert)},o.prototype.lineargaugePlaneCoord2ModelCoord=function(e){e.applyMatrix3(this.matrxTrans.matrix),e.add(this.matrxTrans.origin)},o.prototype.lineargaugeSelectPlaceLine=function(e){this.projectDirectionXorY=e,this.distanceInfo.firstSelInfo&&this.distanceInfo.secondSelInfo&&this.distanceInfo.projectPlane&&(this.matrxTrans||this.lineargaugeRotateOnly(this.distanceInfo.projectPlane),this.ShowLineargaugeDimension(null,!0,this.projectDirectionXorY),this.LineargaugePostNotify())};function Sn(e){this.viewer=e;var k=this,T=null,U=null,S=!1,G=null,B=null,P=null;this.broadcastInfo=null,this.initialization=!0,this.onTouchMove=function(e){if(!k.viewer.isClipTransformControlSelected()&&!k.viewer.isLightEditControlSelected()){switch(e.stopPropagation(),e.touches.length){case 1:var t=e.touches[0].offsetX||e.touches[0].clientX-k.viewer.container.getBoundingClientRect().left,n=e.touches[0].offsetY||e.touches[0].clientY-k.viewer.container.getBoundingClientRect().top;if(k.viewer.limitEventArea){var i=k.viewer.container.getBoundingClientRect().width,r=k.viewer.container.getBoundingClientRect().height;if(i<t||r<n)return}break;case 2:t=e.touches[0].offsetX||e.touches[0].clientX-k.viewer.container.getBoundingClientRect().left,n=e.touches[0].offsetY||e.touches[0].clientY-k.viewer.container.getBoundingClientRect().top;if(t=e.touches[1].offsetX||e.touches[1].clientX-k.viewer.container.getBoundingClientRect().left,n=e.touches[1].offsetY||e.touches[1].clientY-k.viewer.container.getBoundingClientRect().top,k.viewer.limitEventArea){i=k.viewer.container.getBoundingClientRect().width,r=k.viewer.container.getBoundingClientRect().height;if((k.pointer.x>i||k.pointer.y>r)&&(k.pointer2nd.x>i||k.pointer2nd.y>r))return}}if(null==T&&(T=new THREE.Vector2),"OpMeasure"==k.viewer.getCurrentOperatorID()){null==B&&(B=new THREE.Vector3);var o=k.viewer.controls.getOperator().MeasureOper.getIntersectsByPriorityOfLine(t,n),a=null;if(o&&0<o.length)for(var s=0;s<o.length;){if(null!=o[s].object){a=o[s].point.clone();break}s++}a?B.set(a.x,a.y,a.z):B=null}else B=null;var l=k.viewer.renderer.getPixelRatio();T.set(t*l/k.viewer.renderer.domElement.width,n*l/k.viewer.renderer.domElement.height)}},this.onBroadcastMouseMove=function(e){var t=e.offsetX||e.clientX-k.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-k.viewer.container.getBoundingClientRect().top;if(e.srcElement&&e.srcElement!==k.viewer.renderer.domElement&&(t=e.clientX-k.viewer.container.getBoundingClientRect().left,n=e.clientY-k.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==k.viewer.renderer.domElement&&(t=e.clientX-k.viewer.container.getBoundingClientRect().left,n=e.clientY-k.viewer.container.getBoundingClientRect().top),null==T&&(T=new THREE.Vector2),"OpMeasure"==k.viewer.getCurrentOperatorID()){null==B&&(B=new THREE.Vector3);var i=k.viewer.controls.getOperator().MeasureOper.getIntersectsByPriorityOfLine(t,n),r=null;if(i&&0<i.length)for(var o=0;o<i.length;){if(null!=i[o].object){r=i[o].point.clone();break}o++}r?B.set(r.x,r.y,r.z):B=null}else B=null;var a=k.viewer.renderer.getPixelRatio();T.set(t*a/k.viewer.renderer.domElement.width,n*a/k.viewer.renderer.domElement.height),S=!1,!e.srcElement||"toolbar"!=e.srcElement.className&&"toolbar-button"!=e.srcElement.className&&"dialog"!=e.srcElement.className&&"explode-tool-slider"!=e.srcElement.className||(S=!0),null!=e.srcElement||!e.target||"toolbar"!=e.target.className&&"toolbar-button"!=e.target.className&&"dialog"!=e.target.className&&"explode-tool-slider"!=e.target.className||(S=!0)},this.getBroadcastInfo=function(){var e={timestamp:Date.now(),version:1,isMobile:Se.isMobileDevice(),operator:k.viewer.getCurrentOperatorID(),state:k.viewer.getCurrentOperatorState(),explode:{factor:k.viewer.getExplodeFactor(),mode:k.viewer.getExplodeMode(),level:k.viewer.getExplodeLevel(),obj:k.viewer.explodeObjects},annoSetting:0,line:k.viewer.getLinesVisibility()?1:0,mousePos:T?[T.x,T.y]:[-1,-1],worldPos:B?[B.x,B.y,B.z]:[-1,-1,-1],ClearColor:k.viewer.clearColor,camera:{pos:[k.viewer.camera.position.x,k.viewer.camera.position.y,k.viewer.camera.position.z],center:[k.viewer.camera.getCameraTarget().x,k.viewer.camera.getCameraTarget().y,k.viewer.camera.getCameraTarget().z],fov:k.viewer.camera.fov,persp:k.viewer.camera.isPerspective?1:0,near:k.viewer.camera.near,far:k.viewer.camera.far,up:[k.viewer.camera.up.x,k.viewer.camera.up.y,k.viewer.camera.up.z]},selfromTree:k.viewer.selectionManager.selectfromtree,measuringScale:k.viewer.measuringScale},t=("OpZoomWindow"==e.operator&&(n={x:0,y:0},t=k.viewer.renderer.getPixelRatio(),e.state==ve.MOUSE.LEFT?(n.x=k.viewer.controls.getOperator().lMouseDown.x,n.y=k.viewer.controls.getOperator().lMouseDown.y):e.state==ve.TOUCH.TOUCH_SINGLE&&(n.x=k.viewer.controls.getOperator().singleTouchStartPos.x,n.y=k.viewer.controls.getOperator().singleTouchStartPos.y),n.x=n.x*t/k.viewer.renderer.domElement.width,n.y=n.y*t/k.viewer.renderer.domElement.height,e.lMouseDown=n),k.viewer.controls.staticmeasureOp),n=null,i=(t&&(n=t.getMeasureContent(!0)),("OpMeasure"===e.operator||null!==n&&JSON.stringify(n)!==k._measureContent)&&(e.click=t.click,e.InfoType=t.InfoType,e.MeasureType=t.measureType,(i=t.getDimString())?(e.unit=i.unit,e.dimString=i.str):(e.unit="",e.dimString=""),e.measureRelease=t.measureRelease,e.MeasureContent=n,k._measureContent=JSON.stringify(n),0<Object.keys(t.unsteadyData).length&&(e.MeasureContent.unsteadyData=t.unsteadyData),t.click=!1,t.measureRelease=!1),k.initialization&&null===n&&(e.shouldClearMeasureContent=!0),"OpDrag"==e.operator&&(e.opMode=k.viewer.controls.getOperator().opMode),null!=k.viewer.getShowNoteAnnotation()&&k._shouldShowAnnotationContent!==k.viewer.getShowNoteAnnotation()&&(k._shouldShowAnnotationContent=k.viewer.getShowNoteAnnotation(),e.shouldShowAnnotationContent=k.viewer.getShowNoteAnnotation()),k.viewer.getAllNoteContent()),t=JSON.stringify(i),n=(null!=i&&t!=k._annotationNoteContent&&(k._annotationNoteContent=t,e.annotationNoteContent=i),"");if(k.viewer.serverUrl&&(n=k.viewer.serverUrl),""!=k.viewer.renderer.domElement.style.cursor)switch(k.viewer.renderer.domElement.style.cursor){case"url('"+n+"img/cursorOrbit.ico'), wait":e.cursor="Orbit";break;case"url('"+n+"img/cursorPan.ico'), wait":e.cursor="Pan";break;case"url('"+n+"img/cursorZoom.ico'), wait":e.cursor="Zoom";break;case"url('"+n+"img/cursorCross.ico'), crosshair":e.cursor="Cross"}k.viewer.syncSendMsg(e),P!==_e.StopPMIOcclusion&&(P=_e.StopPMIOcclusion,e.shouldStopPMIOcclusion=_e.StopPMIOcclusion),S&&(e.cursor="Normal"),k.viewer.Optoolbar&&(k.viewer.Optoolbar.getExplodeDlgVisibility()&&(e.explodeDlg=1,e.explodeDlgValue=k.viewer.Optoolbar.getExplodeDlgValue()),e.annoSetting=k.viewer.Optoolbar.getAnnotationSetting()?1:0,(t=k.viewer.Optoolbar.getDispStyleToolbar())&&(t.getVisibility()?e.DispStyle=!0:e.DispStyle=!1),i=k.viewer.Optoolbar.getMeasureDlg())&&(e.measureDlg=i.dialog.getVisibility(),e.checkID=i.getChecked());var r=void 0;switch(k.viewer.getRenderMode()){case 0:r="lighting";break;case 1:r="primarycolor";break;case 2:r="wireframe";break;case 3:r="whitemold";break;case 4:r="shadedWithEdges";break;case 5:r="shaded";break;case 6:r="hiddenLineRemove";break;case 7:r="hiddenLineVisible";break;case 8:r="transparent"}e.RenderMode=r,null!=k.viewer.clipBoxManager.active&&(e.clipBoxActive=k.viewer.clipBoxManager.active,e.clipBoxActive)&&((n=k.viewer.clipBoxManager.getPlaneEditControls()).getCurrAttachObj()&&(e.PlaneName=n.getCurrAttachObj().name,e.PlanePosition=n.getCurrentControls().newPosition),t=k.viewer.clipBoxManager.getTransformControls().object.position,e.BoxPosition=t),k.viewer.isSectionViewEnabled()&&(e.clipPlaneInfo=k.viewer.clipPlaneManager.getClipPlaneInfor());var o=[],a=[],s=[],l=[],d=[];if(k.viewer.ndsModel){var c=k.viewer.ndsModel.getSelectedBodies();if(0<c.length){e.meshSel=[];for(var h=0;h<c.length;++h)k.viewer.ndsModel.objectidTouuid&&!k.viewer.is2DModel?e.meshSel.push(c[h].objectid):e.meshSel.push(c[h].id)}if(0<k.viewer.ndsModel.draggedBodies.length)for(var u=0;u<k.viewer.ndsModel.draggedBodies.length;++u){var p=k.viewer.ndsModel.draggedBodies[u];d.push({id:p.id,dragPos:p.leafBodyAttri.bodyDragTranslate})}for(var u=0,f=k.viewer.ndsModel.wholeLeafBodyNodes.length;u<f;++u)(p=k.viewer.ndsModel.wholeLeafBodyNodes[u]).leafBodyAttri&&((p.isHidden()?a:o).push(p.id),k.viewer.ndsModel.inIsolate())&&(!p.isIsolated()&&p.isTransparent()?s:l).push(p.id)}0<d.length&&(e.meshDrag=d),0==a.length?e.meshInvisible=[]:0==o.length&&0<a.length?e.meshVisible=[]:a.length<=o.length?e.meshInvisible=a:e.meshVisible=o,s.length<=l.length?e.meshTrans=s:e.meshNoTrans=l,k.viewer.Optoolbar&&k.viewer.Optoolbar.getDragToolbarBtnSelected()&&(e.dragBtn=k.viewer.Optoolbar.getDragToolbarBtnSelected()),k.viewer.annotationsManager&&(e.annotationsVisible=k.viewer.annotationsManager.isAnnotationsVisible(),e.SelectAnnotation=k.viewer.annotationsManager.getSelectAnnotation()),k.viewer.controls.staticmeasureOp&&(e.shouldShowMeasureContent=k.viewer.controls.staticmeasureOp.getMeasureVisible());var m=[],g=[];if(void 0!==k.viewer.PMINDSBodys&&0<k.viewer.PMINDSBodys.length){for(var v=0,A=k.viewer.PMINDSBodys.length;v<A;++v)null!==k.viewer.PMINDSBodys[v].uuid&&k.viewer.isPMIObjectOrSomeChildHidden(k.viewer.PMINDSBodys[v])&&g.push(k.viewer.PMINDSBodys[v].uuid);i=JSON.stringify(g)+k.viewer.isPmiVisible();k._PMIObjectVisibleContent!==i&&(e.PMIObjectVisibleList=g,k._PMIObjectVisibleContent=i)}if(k.viewer.pmiObject&&k.viewer.pmiObject.children){n=k.viewer.pmiObject.children[0];if(n.version||k.getPMIObject(),2===n.version){var y=k.viewer.getPMINDSBodySelectList();if(y&&0<y.length)for(var E=0,M=y.length;E<M;++E){var w=y[E];w.isHidden()||m.push(w.uuid)}}else if(1===n.version){var b=k.viewer.getPMISelectList();if(b&&0<b.length)for(var x=0,I=b.length;x<I;++x)m.push(b[x].uuid)}t=JSON.stringify(m);k._PMISelContent===t&&!e.PMIObjectVisibleList||(e.PMIObjectSelList=m,k._PMISelContent=t)}return k.initialization=!1,e},this.startBroadcast=function(e){k.exitBroadcast(),_e.enableBroadcast=!0,_e.broadcastMajor=null!=e&&e;var t,n,i,e=k.viewer.controls.getOperator();"OpMeasure"==e.type&&e.restrictMeasuretime(),_e.broadcastMajor&&(document.addEventListener("mousemove",k.onBroadcastMouseMove,!1),document.addEventListener("touchmove",k.onTouchMove,!1),k._resetLocalCacheEventintervalID=setInterval(k.resetLocalCache,1200),k.viewer.controls.staticmeasureOp)&&((e=k.viewer.getMeasureContent())&&e.content&&(t="",i=k.viewer.controls.staticmeasureOp.getMeasureVisible(),(n=e.content.boxInfos&&0<e.content.boxInfos.length)&&(t=k.viewer.controls.staticmeasureOp.measureType,k.viewer.controls.staticmeasureOp.setMeasureType(""),k.viewer.setMeasureContent(e,!0,i)),k.viewer.controls.staticmeasureOp.resetMeasureTimesWithMeasureContent(e.content),"OpMeasure"==this.viewer.getCurrentOperatorID())&&n&&k.viewer.controls.staticmeasureOp.setMeasureType(t),(i=k.viewer.controls.staticmeasureOp.MeasureOper)&&(i.clearPerimetrBox(),i.clearFaceInfo()),k.viewer.dispatchEvent({type:"FaceSelectionPerimeterEvent",perimeters:[]}))},this.exitBroadcast=function(){var e;_e.enableBroadcast&&_e.broadcastMajor&&(k.viewer.controls.staticmeasureOp&&(e=k.viewer.controls.staticmeasureOp.getMeasureContent(!0))&&0<e.perimeterInfos.length&&((e=k.viewer.controls.staticmeasureOp.MeasureOper).clearPerimetrBox(),e.clearFaceInfo()),k._resetLocalCacheEventintervalID&&clearInterval(k._resetLocalCacheEventintervalID),document.removeEventListener("mousemove",k.onBroadcastMouseMove,!1),document.removeEventListener("touchmove",k.onTouchMove,!1)),_e.enableBroadcast=!1,_e.broadcastMajor=!1,T=null,S=!1,U&&k.viewer.container.removeChild(U),U=null},this.setBroadcastInfo=function(e){try{if(_e.enableBroadcast&&null!=e){var t;if(e.timestamp&&(t=Date.now(),console.log("info send[",e.timestamp,"] rece[",t,"] ",t-e.timestamp,"ms")),k.viewer.syncGetMsg(e),e.operator&&k.viewer.getCurrentOperatorID()!=e.operator)switch(e.operator){case"OpOrbit":k.viewer.controls.setOperator(new Wn(k.viewer)),k.viewer.controls.addEventListener("change",k.viewer.render),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnOrbit")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpOrbit"});break;case"OpPan":k.viewer.controls.setOperator(new Yn(k.viewer)),k.viewer.controls.addEventListener("change",k.viewer.render),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnPan")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpPan"});break;case"OpZoom":k.viewer.controls.setOperator(new Xn(k.viewer)),k.viewer.controls.addEventListener("change",k.viewer.render),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnZoom")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpZoom"});break;case"OpDrag":k.viewer.controls.setOperator(new ye(k.viewer)),k.viewer.controls.addEventListener("change",k.viewer.render),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnDrag")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpDrag"});break;case"OpZoomWindow":k.viewer.controls.setOperator(new Qn(k.viewer)),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnZoomWindow")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpZoomWindow"});break;case"OpSelectWindow":k.viewer.controls.setOperator(new Zn(k.viewer)),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnSelectWindow")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpSelectWindow"});break;case"OpMeasure":k.viewer.controls.setOperator(new Me(k.viewer)),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnMeasure")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpMeasure"})}for(var n,i,r,o,a,s,l,d,c,h,u,p,f,m,g,v,A;0<k.viewer.ndsModel.draggedBodies.length;)(E=k.viewer.ndsModel.draggedBodies[0]).leafBodyAttri&&E.isDragged()&&(E.setDragged(!1),E.leafBodyAttri.bodyDragTranslate[0]=0,E.leafBodyAttri.bodyDragTranslate[1]=0,E.leafBodyAttri.bodyDragTranslate[2]=0,-1<(n=k.viewer.ndsModel.draggedBodies.indexOf(E))&&k.viewer.ndsModel.draggedBodies.splice(n,1),k.viewer.ndsModel.meshManager.setGeomSameMaterialFlag(E));if(e.meshDrag&&0<e.meshDrag.length)if(k.viewer.ndsModel)for(var y=0;y<e.meshDrag.length;++y){var E=k.viewer.ndsModel.getBodyNode(e.meshDrag[y].id),M=new THREE.Vector3;M.fromArray(e.meshDrag[y].dragPos),E.leafBodyAttri&&(E.isDragged()||(E.setDragged(!0),k.viewer.ndsModel.draggedBodies.push(E)),E.leafBodyAttri.bodyDragTranslate[0]=M.x,E.leafBodyAttri.bodyDragTranslate[1]=M.y,E.leafBodyAttri.bodyDragTranslate[2]=M.z,k.viewer.ndsModel.meshManager.setGeomSameMaterialFlag(E))}else for(var w=new THREE.Vector3,y=0;y<e.meshDrag.length;++y)(I=k.viewer.scene.getObjectByProperty("uuid",e.meshDrag[y].uuid))&&(void 0===I.matrixWorldTransOrginal&&(I.matrixWorldTransOrginal=new THREE.Vector3,I.matrixWorldTransOrginal.setFromMatrixPosition(I.matrixWorld)),null==I.matrixWorldTransOrginalDrag&&(I.matrixWorldTransOrginalDrag=new THREE.Vector3),I.matrixWorldTransOrginalDrag.fromArray(e.meshDrag[y].dragPos),w.copy(I.matrixWorldTransOrginal),w.add(I.matrixWorldTransOrginalDrag),I.matrixWorld.setPosition(w));if("OpZoomWindow"!=e.operator||e.state!=ve.MOUSE.LEFT&&e.state!=ve.TOUCH.TOUCH_SINGLE?"OpZoomWindow"==e.operator&&(r=k.viewer.controls.getOperator()).clearCanvas2D():(k.viewer.controls.getOperator().state=e.state,O=k.viewer.renderer.getPixelRatio(),(r=k.viewer.controls.getOperator()).drawRectangle(e.lMouseDown.x*k.viewer.renderer.domElement.width,e.lMouseDown.y*k.viewer.renderer.domElement.height,e.mousePos[0]*k.viewer.renderer.domElement.width,e.mousePos[1]*k.viewer.renderer.domElement.height)),"OpMeasure"!=e.operator||!k.viewer.brepManager.hasBrepInfo()&&k.viewer.hasBrepFile()?"OpDrag"==e.operator&&(k.viewer.controls.getOperator().opMode=e.opMode):(e.measureRelease&&k.viewer.getCurrentOperatorID()==e.operator&&(k.viewer.controls.setOperator(new Me(k.viewer)),k.viewer.tlbOperator?(i={target:k.viewer.tlbOperator.getChildElement("btnMeasure")},k.viewer.onOpChanged(i)):k.viewer.onOpChanged({id:"OpMeasure"})),r=k.viewer.controls.getOperator(),e.MeasureType!=r.measureType&&r.setMeasureType(e.MeasureType),r.PostInfo(e.InfoType),""!=e.dimString&&(r.dimString=e.dimString),""!=e.unit&&(r.unit=e.unit),r.setMeasureContent(e.MeasureContent),void 0!==e.MeasureContent.unsteadyData&&(r.unsteadyData=e.MeasureContent.unsteadyData),0<e.MeasureContent.perimeterInfos.length?k.viewer.dispatchEvent({type:"FaceSelectionPerimeterEvent",perimeters:e.MeasureContent.perimeterBroadcast,modelUnit:e.MeasureContent.perimeterunit}):(r.MeasureOper.clearPerimetrBox(),k.viewer.dispatchEvent({type:"FaceSelectionPerimeterEvent",perimeters:[]})),k.viewer.measuringScale!=e.measuringScale&&k.viewer.setMeasuringScale(e.measuringScale),k.viewer.Optoolbar&&k.viewer.Optoolbar.getMeasureDlg().setChecked(e.checkID),-1!=e.worldPos[0]||-1!=e.worldPos[1]||-1!=e.worldPos[2]?(o=k.viewer.modelCoordToClientCoord(e.worldPos))&&(o[0],o[1],o[0],o[1]):(e.mousePos[0],k.viewer.renderer.domElement.width,e.mousePos[1],k.viewer.renderer.domElement.height,e.mousePos[0],k.viewer.renderer.domElement.width,e.mousePos[1],k.viewer.renderer.domElement.height)),void 0!==e.MeasureContent&&(k.viewer.controls.staticmeasureOp||(a=k.viewer.getCurrentOperatorID(),k.viewer.setOperatorByID("OpMeasure"),k.viewer.setOperatorByID(a)),k.viewer.controls.staticmeasureOp.setMeasureContent(e.MeasureContent),void 0!==e.MeasureContent.unsteadyData)&&(k.viewer.controls.staticmeasureOp.unsteadyData=e.MeasureContent.unsteadyData),e.shouldClearMeasureContent&&k.viewer.controls.staticmeasureOp&&k.viewer.controls.staticmeasureOp.setMeasureContent({boxInfos:[],boundingboxInfos:[],perimeterInfos:[],textPos:[],textBox:null,textLines:[],snappedPoint:null,InMeasure:!1,cs:0,Ps:[],rootObject:[]}),"OpMeasure"==e.operator&&!k.viewer.brepManager.hasBrepInfo()&&k.viewer.hasBrepFile()?k.broadcastInfo=e:k.broadcastInfo=null,k.viewer.Optoolbar&&(s=k.viewer.Optoolbar.getDispStyleToolbar())&&s.setVisibility(e.DispStyle),e.RenderMode&&k.viewer.setRenderMode(e.RenderMode,!0),null!=e.annotationsVisible&&""==e.SelectAnnotation&&k.viewer.setAnnotationsVisibility(e.annotationsVisible),null!=e.clipBoxActive&&k.viewer.clipBoxManager.active!=e.clipBoxActive&&k.viewer.clipBoxManager.onBoxSectionView(e.clipBoxActive),null!=e.PlaneName&&""!==e.PlaneName?(l=k.viewer.clipBoxManager.getPlaneEditControls(),d=k.viewer.clipBoxManager.getTransformControls().object.children[e.PlaneName],l.attachTo(d),l.getCurrentControls().newPosition.equals(e.PlanePosition)||(l.getCurrentControls().newPosition.copy(e.PlanePosition),c=new THREE.Vector3(G.x-e.BoxPosition.x,G.y-e.BoxPosition.y,G.z-e.BoxPosition.z),G=e.BoxPosition,3==e.PlaneName||4==e.PlaneName||5==e.PlaneName?d.position.copy(e.PlanePosition):d.position.sub(c),h={type:"objectChange"},k.viewer.clipBoxManager.getPlaneEditControls().getCurrentControls().dispatchEvent(h))):k.viewer.clipBoxManager.active&&null==e.PlaneName&&k.viewer.clipBoxManager.getPlaneEditControls().detach(),e.clipBoxActive&&e.BoxPosition&&(k.viewer.clipBoxManager.getTransformControls().object.position.copy(e.BoxPosition),h={type:"objectChange"},k.viewer.clipBoxManager.getTransformControls().dispatchEvent(h),G=e.BoxPosition),k.viewer.Optoolbar&&null==(u=k.viewer.Optoolbar.getMeasureDlg())&&(u=new sn(k.viewer),k.viewer.Optoolbar.setMeasureDlg(u)),null!=e.measureDlg&&u.show(e.measureDlg),(k.viewer.bLinesVisibility&&0==e.line||!k.viewer.bLinesVisibility&&1==e.line)&&(k.viewer.setLinesVisibility(1==e.line,!1),k.viewer.tlbOperator)&&(k.viewer.getLinesVisibility()?null==(f=k.viewer.tlbOperator.getChildElement("btnLineInVisible"))&&(p=k.viewer.tlbOperator.getChildElement("btnLineVisible"))&&(p.domElement.id="btnLineInVisible",k.viewer.tlbOperator.updateChildElement("btnLineVisible","btnLineInVisible")):null==(p=k.viewer.tlbOperator.getChildElement("btnLineVisible"))&&(f=k.viewer.tlbOperator.getChildElement("btnLineInVisible"))&&(f.domElement.id="btnLineVisible",k.viewer.tlbOperator.updateChildElement("btnLineInVisible","btnLineVisible"))),null!=e.annoSetting&&k.viewer.tlbOperator&&(m=k.viewer.tlbOperator.getChildElement("btnAnnotationSettingShow"),1==e.annoSetting&&null==m&&((g=k.viewer.tlbOperator.getChildElement("btnAnnotationSettingHide"))&&(g.domElement.id="btnAnnotationSettingShow",k.viewer.tlbOperator.updateChildElement("btnAnnotationSettingHide","btnAnnotationSettingShow")),k.viewer.annotationsManager)&&k.viewer.annotationsManager.getAnnotationJsonArray()&&k.viewer.showAnnotations(k.viewer.annotationsManager.getAnnotationJsonArray(),!1),0==e.annoSetting)&&null!=m&&k.viewer.tlbOperator&&(m.domElement.id="btnAnnotationSettingHide",k.viewer.tlbOperator.updateChildElement("btnAnnotationSettingShow","btnAnnotationSettingHide"),k.viewer.annotationsManager)&&k.viewer.annotationsManager.removeAllAnnotations(!1),k.viewer.scene.traverse(function(e){"lightctrls"!=e.name&&(null!=e.matrixWorldTransOrginalDrag&&(e.matrixWorldTransOrginalDrag=void 0),e.matrixWorldTransExplode?e.matrixWorld.setPosition(e.matrixWorldTransExplode):e.matrixWorldTransOrginal&&e.matrixWorld.setPosition(e.matrixWorldTransOrginal))}),k.viewer.ndsModel)if(null!=e.meshSel&&0<e.meshSel.length){var F=!0,b=k.viewer.ndsModel.getSelectedBodies();if(e.meshSel.length==b.length){var x=!0;if(k.viewer.ndsModel.objectidTouuid&&!k.viewer.is2DModel){for(y=0;y<b.length;++y)if(e.meshSel[y]!=b[y].objectid){x=!1;break}}else for(y=0;y<b.length;++y)if(e.meshSel[y]!=b[y].id){x=!1;break}x&&(F=!1)}if(F){k.viewer.ndsModel.clearSelection();for(var I,N,j=k.viewer.selectionManager.getSelectedObjects(),y=j.length=0;y<e.meshSel.length;++y)(I=!this.viewer.ndsModel.objectidTouuid||k.viewer.is2DModel?k.viewer.ndsModel.getBodyNode(e.meshSel[y]):(N=k.viewer.ndsModel.objectidTouuid[e.meshSel[y]],k.viewer.ndsModel.getBodyNodeFromUuid(N)))&&(k.viewer.ndsModel.models.forEach(function(e){e.meshManager.setSelectedMaterial(_e.selectedMaterial,_e.selectedLineMaterial)}),k.viewer.ndsModel.addSelection(I),j.push(I));var T,S,B=k.viewer.getCurrentMeasureType(),P="BodyVolume"!==B&&"BodyArea"!==B?!0:!1;_e.enableBodyVolumeMeasure&&(!k.viewer.hasBrepInfo()||k.viewer.productData)&&P&&((T=k.viewer.getSelectedObjectProperty(function(){}))&&1e-7<T.area?k.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:T,modelUnit:T.unit}):k.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),_e.enableBodyVolumeMeasure&&k.viewer.hasBrepInfo()&&!k.viewer.productData&&P&&((S=k.viewer.selectionManager.getSelectedBodyVolumeAndArea())?k.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:S[0],modelUnit:S[1]}):k.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),_e.enableBodyVolumeMeasure&&k.viewer.hasBrepInfo()&&!P&&((S=k.viewer.selectionManager.getSelectedBodyVolumeAndArea())?k.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:S[0],measureType:B,modelUnit:S[1]}):k.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:null,measureType:B,modelUnit:null})),e.selfromTree||k.viewer.dispatchAsyncEvent({type:"selectObjectEvent"})}}else k.viewer.selectionManager.clearSelection();if(null!=e.explode&&(e.explode.mode&ve.EXPLODEMODE.SELECTED?(k.viewer.explodeObjects=e.explode.obj,k.viewer.setExplodeMode(e.explode.mode,e.explode.level,!0)):k.viewer.setExplodeMode(e.explode.mode,e.explode.level),k.viewer.getExplodeFactor()!=e.explode.factor)&&k.viewer.explodeModel(e.explode.factor),null!=e.dragBtn&&k.viewer.Optoolbar&&k.viewer.Optoolbar.setDragToolbarBtnSelected(e.dragBtn),k.viewer.Optoolbar&&(k.viewer.Optoolbar.setExplodeDlgVisibility(1==e.explodeDlg),k.viewer.Optoolbar.setExplodeDlgValue(1==e.explodeDlg?e.explodeDlgValue:0)),e.meshVisible&&k.viewer.ndsModel){k.viewer.ndsModel.hideBody(k.viewer.ndsModel.rootBodyNode);for(y=0;y<e.meshVisible.length;++y){var C=e.meshVisible[y];k.viewer.ndsModel.hasHiddenBodies=!0,(E=k.viewer.ndsModel.getBodyNode(C)).show()}}if(e.meshInvisible&&k.viewer.ndsModel){k.viewer.ndsModel.showBody(k.viewer.ndsModel.rootBodyNode);for(y=0;y<e.meshInvisible.length;++y){C=e.meshInvisible[y];k.viewer.ndsModel.hasHiddenBodies=!0,(E=k.viewer.ndsModel.getBodyNode(C)).hide(),k.viewer.ndsModel.meshManager.setGeomSameMaterialFlag(E)}}if(k.viewer.ndsModel&&k.viewer.ndsModel.inIsolate()&&k.viewer.ndsModel.exitIsolate(),e.meshTrans&&0<e.meshTrans.length&&k.viewer.ndsModel){for(var R=[],y=0;y<e.meshTrans.length;++y){C=e.meshTrans[y];R.push(k.viewer.ndsModel.getBodyNode(C))}k.viewer.ndsModel.transparentizeBodies(R)}if(e.meshNoTrans)if(0<e.meshNoTrans.length){for(R=[],y=0;y<e.meshNoTrans.length;++y){C=e.meshNoTrans[y];R.push(k.viewer.ndsModel.getBodyNode(C))}k.viewer.ndsModel.isolateBodies(R,_e.bodyOpacity,_e.lineOpacity)}else 0==e.meshNoTrans.length&&((v=[]).push(k.viewer.ndsModel.rootBodyNode),k.viewer.ndsModel.transparentizeBodies(v));if(null!=e.camera&&(k.viewer.camera.fov=e.camera.fov,k.viewer.camera.near=e.camera.near,k.viewer.camera.far=e.camera.far,k.viewer.camera.position.fromArray(e.camera.pos),k.viewer.camera.up.fromArray(e.camera.up),k.viewer.camera.setCameraTarget((new THREE.Vector3).fromArray(e.camera.center)),k.viewer.camera.isPerspective=e.camera.persp,k.viewer.camera.updateProjectionMatrix(),k.viewer.viewBox)&&k.viewer.cameraControl.updateViewBoxCamDir(),null!=e.clipPlaneInfo?(k.viewer.isSectionViewEnabled()||(k.viewer.onSectionView(!0,!1),k.viewer.tlbOperator&&(A=k.viewer.tlbOperator.getChildElement("btnSectionView"))&&(A.setBorder("1px solid rgba(150,150,150,0.8)"),A.setBgColor(_e.toolbarButtonClickedBkgColor))),k.viewer.clipPlaneManager.setClipPlaneInfor(e.clipPlaneInfo)):k.viewer.isSectionViewEnabled()&&(k.viewer.onSectionView(!1,!1),k.viewer.tlbOperator)&&(A=k.viewer.tlbOperator.getChildElement("btnSectionView"))&&(A.setBorder(""),A.setBgColor("")),null!=e.mousePos&&!e.isMobile){var O=k.viewer.renderer.getPixelRatio();switch(null==U&&((U=document.createElement("div")).className="broadcastMouseDiv",U.onselectstart=function(){return!1},k.viewer.container.appendChild(U)),U.style.top=e.mousePos[1]*k.viewer.renderer.domElement.height/O+"px",U.style.left=e.mousePos[0]*k.viewer.renderer.domElement.width/O+"px","Cross"==e.cursor?(U.style.width="96px",U.style.height="96px"):(U.style.width="24px",U.style.height="24px"),e.cursor){case"Orbit":"broadcastMouseDivOrbit"!=U.id&&(U.id="broadcastMouseDivOrbit");break;case"Pan":"broadcastMouseDivPan"!=U.id&&(U.id="broadcastMouseDivPan");break;case"Zoom":"broadcastMouseDivZoom"!=U.id&&(U.id="broadcastMouseDivZoom");break;case"Normal":"broadcastMouseDivNormal"!=U.id&&(U.id="broadcastMouseDivNormal");break;case"Cross":"broadcastMouseDivCoordinate"!=U.id&&(U.id="broadcastMouseDivCoordinate");break;default:"broadcastMouseDivNormal"!=U.id&&(U.id="broadcastMouseDivNormal")}}if((e.isMobile||_e.broadcastMajor)&&U&&(k.viewer.container.removeChild(U),U=null),void 0!==e.shouldShowMeasureContent&&k.viewer.controls.staticmeasureOp&&k.viewer.controls.staticmeasureOp.setMeasureVisible(e.shouldShowMeasureContent),void 0!==e.shouldStopPMIOcclusion&&k.viewer.stopPMIOcclusion(e.shouldStopPMIOcclusion),void 0!==e.PMIObjectVisibleList){k.viewer.getPMIObject()&&k.viewer.setPMIObjectVisible(k.viewer.getPMIObject(),!1);for(var L=0,_=e.PMIObjectVisibleList.length;L<_;L++)k.viewer.setPMIObjectVisible(k.viewer.PMIUUIDtoPMIObject[e.PMIObjectVisibleList[L]],!0)}if(void 0!==e.PMIObjectSelList){k.viewer.getPMIObject()&&k.viewer.deselectPMIObject(k.viewer.getPMIObject());for(var D=0,V=e.PMIObjectSelList.length;D<V;D++)k.viewer.selectPMIObject(k.viewer.PMIUUIDtoPMIObject[e.PMIObjectSelList[D]])}if(void 0!==e.shouldShowAnnotationContent&&k.viewer.showNoteAnnotation(e.shouldShowAnnotationContent),void 0!==e.annotationNoteContent){k.viewer.clearAnnotation();for(var H=0;H<e.annotationNoteContent.length;H++)k.viewer.setNoteAnnotation(e.annotationNoteContent[H])}k.viewer.render()}}catch(e){console.error(e)}},this.resetLocalCache=function(){k._measureContent=null,k._PMISelContent=null,k._PMIObjectVisibleContent=null}}function Bn(E){var M=this,w=(this.viewer=E,this.active=!1,[[0,1],[1,3],[3,2],[2,0]]),e=(this.tempVector3=new THREE.Vector3,null),e=E.canvas2D||E.canvas3D,b=[],x=[],I=null,T=null,S=null,B=null,P=null,C={},o="Right",R={},O={},L=1;function D(){this.run=function(){S&&(S.update(),S.updateMatrixWorld(!0)),B&&B.update()}}function H(){(S=new _(E.camera,e)).setSize(.6),S.setMode("translate"),S.setSpace("local"),S.addEventListener("change",function(){M.viewer.render()}),S.addEventListener("objectChange",function(){var e=Date.now();F(),M.viewer.logOperatorTime&&M.viewer.logOperatorTimeShow("[盒剖切][操作球]",e)}),S.attach(I),T.add(S),(B=new qn({objects:b,domElement:e,viewer:E,group:T})).setSize(.5),B.activate("translate","translateZ"),B.addEventListener("change",function(){M.viewer.render()}),B.addEventListener("objectChange",function(){var e=Date.now(),t=(F(),N(),M.viewer.renderer.clippingPlanes);if(t&&!(t.length<3)&&I){for(var n=E.controls.getBoundingBox().min.clone(),i=.001,r=0;r<t.length;r++)Math.abs(t[r].normal.x)>i?n.x=Math.max(n.x,-1*t[r].normal.x*t[r].constant):Math.abs(t[r].normal.y)>i?n.y=Math.max(n.y,-1*t[r].normal.y*t[r].constant):n.z=Math.max(n.z,-1*t[r].normal.z*t[r].constant);i=1e-6;var o,a=n.clone().sub(I.position),s=(a.x=Math.abs(a.x)<i?0:a.x,a.y=Math.abs(a.y)<i?0:a.y,a.z=Math.abs(a.z)<i?0:a.z,I.position.add(a),B.getCurrentControls());s&&(o=s.getOldPosition(),o=(o=o||new THREE.Vector3).clone().sub(a),s.setOldPosition(o));for(r=0;r<I.children.length;r++){var l=I.children[r];l instanceof ri&&l.position.sub(a)}I.updateMatrixWorld(!0)}M.viewer.render(),M.viewer.logOperatorTime&&M.viewer.logOperatorTimeShow("[盒剖切][操作球]",e)})}this.tempCenterBox=new THREE.Vector3,C.clipping_planes_fragment=THREE.ShaderChunk.clipping_planes_fragment,C.clipping_planes_pars_fragment=THREE.ShaderChunk.clipping_planes_pars_fragment,C.meshphong_frag=THREE.ShaderChunk.meshphong_frag,C.meshphysical_frag=THREE.ShaderChunk.meshphysical_frag,C.phongFrag=THREE.ShaderLib.phong.fragmentShader,C.physicalFrag=THREE.ShaderLib.physical.fragmentShader,this.getTransformControls=function(){return S},this.getPlaneEditControls=function(){return B},this.SetRenderBox=function(e){T&&(T.visible=e)},this.getBoxClipInfo=function(){var e={};if(e.clipBoxActive=M.active,e.clipBoxActive){for(var t=M.getPlaneEditControls(),n=(t.getCurrAttachObj()&&(e.PlaneName=t.getCurrAttachObj().name,e.PlanePosition=t.getCurrentControls().newPosition),M.viewer.renderer.clippingPlanes),i=new THREE.Vector3(-1e4,-1e4,-1e4),r=new THREE.Vector3(1e4,1e4,1e4),o=0;o<n.length;o++).001<Math.abs(n[o].normal.x)?(i.x=Math.max(i.x,-1*n[o].normal.x*n[o].constant),r.x=Math.min(r.x,-1*n[o].normal.x*n[o].constant)):.001<Math.abs(n[o].normal.y)?(i.y=Math.max(i.y,-1*n[o].normal.y*n[o].constant),r.y=Math.min(r.y,-1*n[o].normal.y*n[o].constant)):(i.z=Math.max(i.z,-1*n[o].normal.z*n[o].constant),r.z=Math.min(r.z,-1*n[o].normal.z*n[o].constant));t=M.getTransformControls().object.position,t=(e.BoxPosition=t,new THREE.Box3(r,i));e.clipbox=t,e.planeMeshPositions=[];for(var a=0;a<b.length;++a)e.planeMeshPositions[a]=b[a].position}return e},this.setPlanePosition=function(e){for(var t=0;t<b.length;++t)b[t].position.copy(e[t]),M.viewer.renderer.clippingPlanes[t]};var F=function(){I&&I.traverse(function(e){e instanceof ri&&e.update()});for(var e=[],t=0;t<x.length;t++){var n=(new THREE.Plane).setComponents(x[t].x,x[t].y,x[t].z,x[t].w);e.push(n)}M.viewer.renderer.clippingPlanes=e};this.getOperateMode=function(){return L},this.setOperateMode=function(e){L=e},this.setActivePlaneByName=function(e){o=e},this.getActivePlaneName=function(){return o},this.activePlaneCanForward=function(){if(!this.active)return!1;var e=!0,t=(R[o].updateMatrixWorld(!0),R[o].position),n=null;switch(o){case"Right":R.Left.updateMatrixWorld(!0),n=R.Left.position,t.distanceTo(n)<1&&(e=!1);break;case"Left":n=R.Right.position,t.distanceTo(n)<1&&(e=!1);break;case"Up":n=R.Down.position,t.distanceTo(n)<1&&(e=!1);break;case"Down":n=R.Up.position,t.distanceTo(n)<1&&(e=!1);break;case"Front":n=R.Back.position,t.distanceTo(n)<1&&(e=!1);break;case"Back":n=R.Front.position,t.distanceTo(n)<1&&(e=!1)}return e},this.planeTranslate=function(e){if(!this.active)return!1;var t=null,n=null,i=null,r=null;switch(o){case"Right":n=O.Left,i=O.Right,t=n.clone().sub(i),r=i.clone().add(t.multiplyScalar(e)),R[o].position.copy(r);break;case"Left":n=O.Right,i=O.Left,t=n.clone().sub(i),r=i.clone().add(t.multiplyScalar(e)),R[o].position.copy(r);break;case"Up":n=O.Down,i=O.Up,t=n.clone().sub(i),r=i.clone().add(t.multiplyScalar(e)),R[o].position.copy(r);break;case"Down":n=O.Up,i=O.Down,t=n.clone().sub(i),r=i.clone().add(t.multiplyScalar(e)),R[o].position.copy(r);break;case"Front":n=O.Back,i=O.Front,t=n.clone().sub(i),r=i.clone().add(t.multiplyScalar(e)),R[o].position.copy(r);break;case"Back":n=O.Front,i=O.Back,t=n.clone().sub(i),r=i.clone().add(t.multiplyScalar(e)),R[o].position.copy(r)}return R[o].updateMatrixWorld(!0),N(),F(),M.viewer.render(),!0},this.isClipTransformControlSelected=function(){var e=!1,t=!1;return S&&(e=S.isSelected()),B&&(t=B.isSelected()),e||t},this.renderClipBox=function(e,t){T&&T.visible&&(e?M.viewer.renderer.render(T,M.viewer.camera,e,t):M.viewer.renderer.render(T,M.viewer.camera))},this.onBoxSectionView=function(e,t){if(e){this.active=!0,THREE.ShaderChunk.clipping_planes_fragment=Jn,THREE.ShaderChunk.clipping_planes_pars_fragment=Kn,THREE.ShaderChunk.meshphong_frag=ei,THREE.ShaderLib.phong.fragmentShader=ei,THREE.ShaderChunk.meshphysical_frag=ti,THREE.ShaderLib.physical.fragmentShader=ti;var e=t,n=[new THREE.Vector3(1,0,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,0,1),new THREE.Vector3(-1,0,0),new THREE.Vector3(0,-1,0),new THREE.Vector3(0,0,-1)],i=["Right","Up","Front","Left","Down","Back"],r=[[[1,2],[1,5],[2,4],[4,5]],[[3,5],[0,5],[2,3],[0,2]],[[1,3],[0,1],[3,4],[0,4]],[[1,5],[1,2],[4,5],[2,4]],[[2,3],[0,2],[3,5],[0,5]],[[0,1],[3,1],[0,4],[3,4]]],o=new THREE.Group,t=(I=o,null),a=(t=0==M.viewer.getExplodeFactor()?E.controls.getBoundingBox():E.controls.getExplosionBoundingBox()).getSize(),a=Math.max(Math.max(a.x,a.y),a.z)/50,a=new THREE.Vector3(a,a,a),s=t.clone();s.expandByVector(a),e&&s.copy(e);for(var l=s.max,d=(o.position.copy(l),[]),c=[],h=0;h<n.length;h++){var u=new THREE.Plane(n[h],-1*l.dot(n[h]));d.push(u),2<h&&(3==h?u.constant-=s.max.x-s.min.x:4==h?u.constant-=s.max.y-s.min.y:5==h&&(u.constant-=s.max.z-s.min.z)),(p=function(e,t){var n=new THREE.Quaternion;n.setFromUnitVectors(new THREE.Vector3(0,0,1),e.normal),c=t?(i=e.projectPoint(t.max),o=e.projectPoint(t.min),a=n.clone().inverse(),i.applyQuaternion(a),o.applyQuaternion(a),a=(new THREE.Vector3).subVectors(i,o),new THREE.PlaneGeometry(a.x,a.y)):(a=2*(t=_viewer.getVisibleBounds()).getBoundingSphere().radius,new THREE.PlaneGeometry(a,a));for(var i=new THREE.MeshBasicMaterial({opacity:.1,color:16777215,side:THREE.DoubleSide,transparent:!0}),r=new ri(c,i,e),o=t.getCenter(),a=e.projectPoint(o),i=(r.position.copy(a),r.quaternion.multiply(n),new THREE.Color(16711680)),s=new THREE.LineBasicMaterial({color:i,linewidth:1}),l=r.geometry.getAttribute("position"),d=0;d<w.length;d++){(c=new THREE.Geometry).vertices.push((new THREE.Vector3).fromArray(l.array,w[d][0]*l.itemSize),(new THREE.Vector3).fromArray(l.array,w[d][1]*l.itemSize));var c,h=new THREE.Line(c,s);r.add(h),r.outlines.push(h)}return r}(u,s)).position.sub(l),p.name=h,o.add(p),c.push(p),b.push(p),R[i[h]]=p,O[i[h]]=p.position.clone(),x.push(p.planeVec)}for(h=0;h<c.length;h++)for(var p=c[h],f=r[h],m=0;m<f.length;m++){for(var g=[],v=f[m],A=0;A<v.length;A++)g.push(d[v[A]]);p.connectivity.push(g)}null==T&&(T=new THREE.Scene),I.updateMatrixWorld(!0),T.add(I),N(),F(),1==L&&H(),null==P&&(P=new D),M.viewer.addFrameListener(P),this.viewer.render()}else{this.active=!1,THREE.ShaderChunk.clipping_planes_fragment=C.clipping_planes_fragment,THREE.ShaderChunk.clipping_planes_pars_fragment=C.clipping_planes_pars_fragment,THREE.ShaderChunk.meshphong_frag=C.meshphong_frag,THREE.ShaderChunk.meshphysical_frag=C.meshphysical_frag,THREE.ShaderLib.phong.fragmentShader=C.phongFrag,THREE.ShaderLib.physical.fragmentShader=C.physicalFrag,P&&(M.viewer.removeFrameListener(P),P=null);for(var y=0;y<b.length;y++)Se.disposeObject(b[y]);if(b=[],x=[],I=null,T)for(y=0;y<T.children.length;y++)T.remove(T.children[y]),y--;T=null,S&&(S.dispose(),S=null),B&&(B.dispose(),B=null),M.viewer.renderer.clippingPlanes=[],M.viewer.render()}},a=new THREE.Matrix3,s=new THREE.Vector3,l=new THREE.Vector3,d=new THREE.Vector3;var a,s,l,d,c=function(e,t,n,i){a.set(e.normal.x,e.normal.y,e.normal.z,t.normal.x,t.normal.y,t.normal.z,n.normal.x,n.normal.y,n.normal.z);var r=a.determinant();return 0===r?null:(s.crossVectors(t.normal,n.normal).multiplyScalar(-e.constant),l.crossVectors(n.normal,e.normal).multiplyScalar(-t.constant),d.crossVectors(e.normal,t.normal).multiplyScalar(-n.constant),(i||new THREE.Vector3).copy(s).add(l).add(d).divideScalar(r))};function N(){for(var e=0;e<I.children.length;e++){var t=I.children[e];if(t instanceof ri&&0<t.connectivity.length){for(var n=(new THREE.Matrix4).getInverse(t.matrixWorld),i=new THREE.Vector3,r=t.geometry.getAttribute("position"),o=0;o<3*r.count/r.itemSize;o++){var a=t.connectivity[o];null!==c(t.plane,a[0],a[1],i)&&(i.applyMatrix4(n),r.setXYZ(o,i.x,i.y,i.z),i.clone().add(t.position))}r.needsUpdate=!0,t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere();for(o=0;o<t.outlines.length;o++){var s=t.outlines[o];s.geometry.vertices[0].fromArray(r.array,w[o][0]*r.itemSize),s.geometry.vertices[1].fromArray(r.array,w[o][1]*r.itemSize),s.geometry.verticesNeedUpdate=!0}}}}this.isSectionBoxEnabled=function(){return!!T},this.displaySectionBox=function(e){I&&((I.visible=e)?S.attach(I):(S.detach(S.object),B.detach())),M.viewer.render()},this.getSectionBoxVisible=function(){return!!I&&I.visible}}function Pn(e,t,n){this.viewer=e;var se=this,le=n,d=null,d=e.canvas2D||e.canvas3D,c=(this.tempQuat=new THREE.Quaternion,void 0===t?1:t),r=(1===c&&(THREE.ShaderChunk.clipping_planes_fragment=Jn,THREE.ShaderChunk.clipping_planes_pars_fragment=Kn,THREE.ShaderChunk.meshphong_frag=ei,THREE.ShaderLib.phong.fragmentShader=ei,THREE.ShaderChunk.meshphysical_frag=ti,THREE.ShaderLib.physical.fragmentShader=ti),this.tempVector3=new THREE.Vector3,this.clipModeState="both",this.clipTransRotControl=null,this.clipTransRotControls=[],this.clipActiveId=0,this.planeNameToId={},this.showSectionImage=!1,null),o=null,h=[],s=null,de=[],ce=-1/0,he=-1/0,ue=1/0,pe=1/0,fe=null,a=null,l=null,u=null,p=null,f=null,me=0,ge={};function m(){this.run=function(){se.clipTransRotControl&&(se.clipTransRotControl.update(),se.clipTransRotControl.updateMatrixWorld(!0))}}function g(){var e=fe.getObjectByName("sectionRoot"),e=(e&&(Se.disposeObject(e),fe.remove(e)),new THREE.Group),F=(e.name="sectionRoot",fe.add(e),new THREE.Group),N=(e.add(F),new THREE.Group),j=(e.add(N),new THREE.Geometry),t=new THREE.Box3;if(se.viewer.ndsModel){var _=se.viewer.ndsModel.meshManager;he=ce=-1/0,pe=ue=1/0;for(var n=0;n<se.viewer.renderer.clippingPlanes.length;n++){var V=se.viewer.renderer.clippingPlanes[n].clone(),k=ve.Intersector.makePlaneBasis(V),U=(new THREE.Matrix4).getInverse(k);ge={};for(var i,d,c,h,u,r,G=me=0;G<se.viewer.ndsModel.models.length;G++){se.viewer.ndsModel.setActiveModel(G);for(var _=se.viewer.ndsModel.meshManager,z=0,W=se.viewer.ndsModel.wholeLeafBodyNodes.length;z<W;++z){var o=se.viewer.ndsModel.wholeLeafBodyNodes[z];if(o.leafBodyAttri){var a=o.leafBodyAttri.bodyMeshIds;if(a&&!(a.length<1)){for(var s=[],Y=null,l=0;l<a.length;l++){var p=a[l];if(!_.isMeshHidden(p)&&(_.getMeshBBox(p,t),ve.Intersector.intersectBoxPlane(V,t))){for(var f,m,X=!0,g=0;g<se.viewer.renderer.clippingPlanes.length;++g)if(g!=n){var v=(A=se.viewer.renderer.clippingPlanes[g]).distanceToPoint(t.getCenter());if(!ve.Intersector.intersectBoxPlane(A,t)&&Math.sign(v)<0){X=!1;break}}X&&(_.getMeshInfor(p,m={}),Y=Y||m.material,f={},ve.Intersector.intersectMeshPlane(V,m.geometry,m.matrixWorld,p,m=[]),s=s.concat(m))}}if(!(s.length<1)){for(var A,y,E,M,Q,Z,q,w,g=0;g<se.viewer.renderer.clippingPlanes.length;++g)!function(){if(g==n)return;for(A=se.viewer.renderer.clippingPlanes[g],y=[],l=0;l<s.length;l++)E=new THREE.Vector3,M=new THREE.Vector3,1!=ve.Intersector.intersectSegmentPlane(A,s[l].pt1,s[l].pt2,E,M)?(v=A.distanceToPoint(s[l].pt1),Math.sign(v)<0&&1e-6<Math.abs(v)&&(s.splice(l,1),l--)):(v=A.distanceToPoint(s[l].pt1),M=A.distanceToPoint(s[l].pt2),w=s[l],Math.abs(v)<1e-6?(Math.sign(M)<0&&(s.splice(l,1),l--),f[w.eid1]=E):Math.sign(v)<0?(Math.abs(M)<1e-6?(s.splice(l,1),l--):(w.pt1=E,w.eid1=w.eid1+":"+g),f[w.eid1]=E):0<Math.sign(v)&&(1e-6<Math.abs(M)&&(w.pt2=E,w.eid2=w.eid2+":"+g),f[w.eid2]=E),y.find(function(e){return Math.abs(E.x-e.x)<1e-6&&Math.abs(E.y-e.y)<1e-6&&Math.abs(E.z-e.z)<1e-6})||y.push(E.clone()));function e(t,n){return Object.keys(t).find(function(e){return t[e]===n})}if(0<y.length&&y.length%2==0)for(2<y.length&&(Q=ve.Intersector.makePlaneBasis(A),y.sort(function(e,t){e=e.clone().applyMatrix4(Q),t=t.clone().applyMatrix4(Q);return 1e-6<Math.abs(e.x-t.x)?e.x-t.x:e.y-t.y})),l=0;l<y.length;l+=2)Z=e(f,y[l]),q=e(f,y[l+1]),(w=new ve.Triangulator.Edge(y[l],y[l+1],0,0,1,1,2)).eid1=Z,w.eid2=q,s.push(w)}();var o=!1,b=(se.clipActiveId==n&&se.showSectionImage&&!se.clipTransRotControl.isDragging()&&(o=!0),ae=oe=re=H=ie=D=L=O=R=ne=te=C=ee=P=B=S=T=$=J=I=x=K=b=void 0,s),K=Y,x=k,I=U,J=j,$=F,T=o;if(b.length){var S=new THREE.Box3,B=(ve.Intersector.convertToPlaneCoords(x,b,S),new ve.Triangulator.ContourSet(b,S));B.snapEdges(),B.sanitizeEdges(),B.stitchContours();for(var P=0;P<B.contours.length;P++)for(var ee=B.contours[P],C=1;C<ee.length;C++){var te=B.pts[ee[C-1]],ne=B.pts[ee[C]],te=new THREE.Vector3(te.x,te.y,0),ne=new THREE.Vector3(ne.x,ne.y,0);J.vertices.push(te.applyMatrix4(I)),J.vertices.push(ne.applyMatrix4(I))}if(le){var R=new ve.Triangulator.TriangulatedSurface(B);if(R.indices.length){de=[];for(var x=new THREE.BufferGeometry,O=new Float32Array(3*R.pts.length),P=0;P<R.pts.length;P++)O[3*P]=R.pts[P].x,O[3*P+1]=R.pts[P].y,O[3*P+2]=0;x.addAttribute("position",new THREE.BufferAttribute(O,3));for(var L=K.packedNormals,D=L?new Uint16Array(2*R.pts.length):new Float32Array(3*R.pts.length),P=0;P<R.pts.length;P++)L?(D[2*P]=32767,D[2*P+1]=65535):(D[3*P]=0,D[3*P+1]=0,D[3*P+2]=1);x.addAttribute("normal",new THREE.BufferAttribute(D,L?2:3)),L&&(x.attributes.normal.bytesPerItem=2,x.attributes.normal.normalize=!0);var b=new Uint16Array(R.indices.length),ie=(b.set(R.indices),(R.cset.bbox.max.x-R.cset.bbox.min.x)*(R.cset.bbox.max.y-R.cset.bbox.min.y));if(ce=Math.max(R.cset.bbox.max.x,ce),he=Math.max(R.cset.bbox.max.y,he),ue=Math.min(R.cset.bbox.min.x,ue),pe=Math.min(R.cset.bbox.min.y,pe),T)for(var H=0;H<R.indices.length;H+=3){var re=R.pts[R.indices[H]],oe=R.pts[R.indices[H+1]],ae=R.pts[R.indices[H+2]];de.push(new THREE.Vector2(re.x,re.y)),de.push(new THREE.Vector2(oe.x,oe.y)),de.push(new THREE.Vector2(ae.x,ae.y))}x.setIndex(new THREE.BufferAttribute(b,1)),x.streamingDraw=!0,x.streamingIndex=!0;S=new THREE.ShaderMaterial({side:THREE.DoubleSide,uniforms:{color:{type:"c",value:new THREE.Color(1,1,1)},hatchParams:{type:"v2",value:new THREE.Vector2(1,10)},hatchTintColor:{type:"c",value:new THREE.Color(0,1,1)},hatchTintIntensity:{type:"f",value:.2}},vertexShader:ii.vertex,fragmentShader:ii.fragment});for(S.polygonOffset=!0,S.polygonOffsetFactor=0,S.polygonOffsetUnits=1;-1!=Object.keys(ge).indexOf(ie.toString());)ie*=1+1e-5;ge[ie]={material:S,triangle:de.concat()};T=Object.keys(ge).length*Math.PI*10/180+Math.PI/4,b=Math.tan(T),T=(S.uniforms.hatchParams.value=new THREE.Vector2(b,20),S.uniforms.color.value=K.color.clone(),S.needsUpdate=!0,new THREE.Mesh(x,S));T.matrix.copy(I),T.matrixAutoUpdate=!1,$.add(T)}}}}}}}}Object.keys(ge).sort(function(e,t){return e-t}).forEach(function(e){ge[e].material.polygonOffsetFactor=me,me+=.01}),se.clipActiveId==n&&se.showSectionImage&&!se.clipTransRotControl.isDragging()&&(i=document.createElement("canvas"),r=Math.max(ce-ue,he-pe),i.width=1.1*r,i.height=1.1*r,d=1,r<40?(i.width=420,i.height=420,d=400/r):i.width<400?(i.width=10*r+40,i.height=10*r+40,d=10):6e3<i.width&&(i.width=640,i.height=640,d=600/r),c=i.width/2-(ce+ue)*d/2,h=i.height/2-(he+pe)*d/2,u=i.getContext("2d"),Object.keys(ge).sort(function(e,t){return t-e}).forEach(function(e){u.beginPath();var t=[Math.floor(176*Math.random()+79),Math.floor(112*Math.random()+15),Math.floor(32*Math.random()+15)];u.fillStyle="rgb("+t[0]+","+t[1]+","+t[2]+")",de=ge[e].triangle;for(var n=0;n<de.length;n+=3){var i=de[n].x,r=de[n].y,i=i*d+c,r=r*d+h,o=de[n+1].x,a=de[n+1].y,o=o*d+c,a=a*d+h,s=de[n+2].x,l=de[n+2].y,s=s*d+c,l=l*d+h;u.moveTo(i,r),u.lineTo(o,a),u.lineTo(s,l)}u.fill()}),r=i.toDataURL("image/png"),se.viewer.dispatchEvent({type:"ActiveSectionViewChangeEvent",base64Img:r})),ge={}}e=new THREE.LineBasicMaterial({opacity:1}),e=(e.color.setRGB(1,0,0),new THREE.LineSegments(j,e));e.matrixAutoUpdate=!1,e.frustumCulled=!1,N.add(e)}}function v(){var e;function t(e){var t,n,i,r,o=new THREE.Vector3(0,0,1),a=s.quaternion;o.applyQuaternion(a);t=o,n=e,i=Math.abs(t.x-n.x)<.001,r=Math.abs(t.y-n.y)<.001,t=Math.abs(t.z-n.z)<.001,i&&r&&t||((n=new THREE.Quaternion).setFromUnitVectors(o,e),a.multiplyQuaternions(n,a),s.setRotationFromQuaternion(a),s.updateMatrixWorld(!0))}0!=se.viewer.renderer.clippingPlanes.length&&0!=h.length&&(r=se.viewer.renderer.clippingPlanes[se.clipActiveId],o=h[se.clipActiveId],s=o.children[0],(e=se.clipTransRotControls[se.clipActiveId]).isDragging()&&"translate"===e.pickType&&("X"===e.axis?t(new THREE.Vector3(1,0,0)):"Y"===e.axis?t(new THREE.Vector3(0,1,0)):"Z"===e.axis&&t(new THREE.Vector3(0,0,1))),r.normal.set(0,0,-1),r.normal.applyQuaternion(s.getWorldQuaternion(se.tempQuat)),r.constant=-1*o.getWorldPosition(se.tempVector3).dot(r.normal))}this.hasClipCapScene=function(){return!p},this.setActiveSectionPlane=function(e){if(se.clipActiveId=se.planeNameToId[e],!(se.clipActiveId<0||se.clipActiveId>se.clipTransRotControls.length-1)){for(var t=0;t<se.clipTransRotControls.length;++t)se.clipTransRotControls[t].visible=!1,h[t].children[0].material.opacity=.2,Se.isMobileDevice()||(h[t].visible=!1);se.clipTransRotControls[se.clipActiveId].visible=!0,h[se.clipActiveId].visible=!0,Se.isMobileDevice()&&(h[se.clipActiveId].children[0].material.opacity=.4),se.clipTransRotControl=se.clipTransRotControls[se.clipActiveId],3===c&&g(),se.viewer.render()}},this.deleteSectionPlane=function(e){if(fe&&-1!=se.planeNameToId[e]){for(var t in se.clipActiveId=se.planeNameToId[e],se.planeNameToId[e]=-1,se.planeNameToId)se.planeNameToId[t]>se.clipActiveId&&se.planeNameToId[t]--;se.clipTransRotControls[se.clipActiveId].visible=!1,se.clipTransRotControls[se.clipActiveId].dispose(),fe.remove(se.clipTransRotControls[se.clipActiveId]),fe.remove(h[se.clipActiveId]),se.clipTransRotControls.splice(se.clipActiveId,1),h.splice(se.clipActiveId,1),se.viewer.renderer.clippingPlanes.splice(se.clipActiveId,1),3===c&&g(),se.viewer.render()}},this.renderClipScene=function(e,t){fe&&(e?se.viewer.renderer.render(fe,se.viewer.camera,e,t):se.viewer.renderer.render(fe,se.viewer.camera))},this.renderClipPlane=function(e,t){var n,i;p&&(n=se.viewer.scene.overrideMaterial,se.viewer.renderer.state.buffers.stencil.setTest(!0),i=se.viewer.renderer.context,se.viewer.renderer.state.buffers.stencil.setFunc(i.ALWAYS,1,255),se.viewer.renderer.state.buffers.stencil.setOp(i.KEEP,i.KEEP,i.INCR),se.viewer.scene.overrideMaterial=l,e?se.viewer.renderer.render(se.viewer.scene,se.viewer.camera,e,t):se.viewer.renderer.render(se.viewer.scene,se.viewer.camera),se.viewer.renderer.state.buffers.stencil.setFunc(i.ALWAYS,1,255),se.viewer.renderer.state.buffers.stencil.setOp(i.KEEP,i.KEEP,i.DECR),se.viewer.scene.overrideMaterial=u,e?se.viewer.renderer.render(se.viewer.scene,se.viewer.camera,e,!1):se.viewer.renderer.render(se.viewer.scene,se.viewer.camera),se.viewer.scene.overrideMaterial=n,se.viewer.renderer.state.buffers.stencil.setFunc(i.EQUAL,1,255),se.viewer.renderer.state.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),e?se.viewer.renderer.render(p,se.viewer.camera,e,!1):se.viewer.renderer.render(p,se.viewer.camera),se.viewer.renderer.state.buffers.stencil.setTest(!1))},this.isClipTransformControlSelected=function(){return!!se.clipTransRotControl&&se.clipTransRotControl.isSelected()},this.setClipTransControlMode=function(e){se.clipModeState=e=void 0===e||"translate"!==e&&"rotate"!==e?"both":e;for(var t=0;t<se.clipTransRotControls.length;t++)se.clipTransRotControls[t].setMode(e),"translate"===e?"YZ"===se.clipTransRotControls[t].name?(se.clipTransRotControls[t].children[0].showAxis("y",!1),se.clipTransRotControls[t].children[0].showAxis("z",!1)):"XZ"===se.clipTransRotControls[t].name?(se.clipTransRotControls[t].children[0].showAxis("z",!1),se.clipTransRotControls[t].children[0].showAxis("x",!1)):"XY"===se.clipTransRotControls[t].name&&(se.clipTransRotControls[t].children[0].showAxis("x",!1),se.clipTransRotControls[t].children[0].showAxis("y",!1)):"rotate"===e&&("YZ"===se.clipTransRotControls[t].name?(se.clipTransRotControls[t].children[1].showAxis("x",!1),se.clipTransRotControls[t].children[1].showAxis("y",!0),se.clipTransRotControls[t].children[1].showAxis("z",!0)):"XZ"===se.clipTransRotControls[t].name?(se.clipTransRotControls[t].children[1].showAxis("y",!1),se.clipTransRotControls[t].children[1].showAxis("x",!0),se.clipTransRotControls[t].children[1].showAxis("z",!0)):"XY"===se.clipTransRotControls[t].name&&(se.clipTransRotControls[t].children[1].showAxis("z",!1),se.clipTransRotControls[t].children[1].showAxis("x",!0),se.clipTransRotControls[t].children[1].showAxis("y",!0)))},this.addSectionPlane=function(e){if(fe&&-1==se.planeNameToId[e]){for(var t=0;t<se.clipTransRotControls.length;++t)se.clipTransRotControls[t].visible=!1,h[t].children[0].material.opacity=.2,Se.isMobileDevice()?h[t].visible=!0:h[t].visible=!1;var n=se.viewer.controls.getBoundingBox().getCenter(),i=se.viewer.controls.getBoundingBox().getSize(),i=Math.max(i.x,i.y,i.z),i=(i*=1.3,new THREE.PlaneGeometry(i,i,1,1)),r=null,o=new THREE.Color,a=("XZ"==e?(r=new THREE.Plane(new THREE.Vector3(0,-1,0),0),Se.isMobileDevice()?o.set(7514614):o.setRGB(.298,.8,.4)):"YZ"==e?(r=new THREE.Plane(new THREE.Vector3(-1,0,0),0),Se.isMobileDevice()?o.set(7514614):o.setRGB(.8,.4,.298)):"XY"==e&&(r=new THREE.Plane(new THREE.Vector3(0,0,-1),0),Se.isMobileDevice()?o.set(7514614):o.setRGB(.4,.298,.8)),r.setFromNormalAndCoplanarPoint(r.normal,n),se.viewer.renderer.clippingPlanes.push(r.clone()),new THREE.Object3D),n=(a.position.copy(n),a.updateMatrixWorld(),h.push(a),new THREE.Mesh(i,new THREE.MeshBasicMaterial({side:THREE.DoubleSide,opacity:.2}))),i=(3===c&&le&&(n.material.polygonOffset=!0,n.material.polygonOffsetFactor=-2,n.material.polygonOffsetUnits=1),n.material.color.copy(o),n.material.transparent=!0,a.add(n),new THREE.Quaternion),o=(i.setFromUnitVectors(new THREE.Vector3(0,0,-1),r.normal),n.setRotationFromQuaternion(i),n.updateMatrixWorld(!0),new _(se.viewer.camera,d));fe.add(o),fe.add(a),Se.isMobileDevice()?o.setSize(1):o.setSize(.7),o.setSpace("local"),o.attach(a),o.name=e,o.addEventListener("change",function(){se.viewer.render()}),o.addEventListener("objectChange",function(){var e=Date.now();v(),3===c&&g(),_e.enableBroadcast&&!_e.broadcastMajor||se.viewer.render(),se.viewer.logOperatorTime&&se.viewer.logOperatorTimeShow("[剖切][操作球]",e)}),se.clipTransRotControls.push(o),se.setClipTransControlMode(se.clipModeState),se.clipActiveId=se.clipTransRotControls.length-1,se.planeNameToId[e]=se.clipActiveId,se.clipTransRotControl=se.clipTransRotControls[se.clipActiveId],Se.isMobileDevice()&&(h[se.clipActiveId].children[0].material.opacity=.4),3===c&&g(),se.viewer.render()}},this.onSectionView=function(e,t){if(e)null==f&&(f=new m),se.viewer.addFrameListener(f),se.viewer.toggleAutoRotation(!1),se.viewer.zoomExtents(),2==c&&(a=new THREE.ShaderMaterial({uniforms:ni.uniforms.caps,vertexShader:ni.vertex,fragmentShader:ni.fragment}),l=new THREE.ShaderMaterial({defines:ni.defines,uniforms:ni.uniforms.clipping,vertexShader:ni.vertexClipping,fragmentShader:ni.fragmentClippingFront,colorWrite:!1,depthWrite:!1,side:THREE.BackSide}),u=new THREE.ShaderMaterial({defines:ni.defines,uniforms:ni.uniforms.clipping,vertexShader:ni.vertexClipping,fragmentShader:ni.fragmentClippingFront,colorWrite:!1,depthWrite:!1}),ni.uniforms.clipping.clippingPlaneNDS.value=[-1,0,0,0],(p=new THREE.Scene).add(new THREE.Mesh(new THREE.PlaneGeometry(2*se.viewer.camera.far,2*se.viewer.camera.far,1,1),a))),se.planeNameToId.YZ=-1,se.planeNameToId.XY=-1,se.planeNameToId.XZ=-1,fe=new THREE.Scene,se.addSectionPlane("YZ");else{if(se.clipTransRotControl){if(a&&a.dispose(),a=null,l&&l.dispose(),l=null,u&&u.dispose(),u=null,p)for(var n=0;n<p.children.length;n++)p.children[n].geometry&&p.children[n].geometry.dispose(),p.remove(p.children[n]),n--;p=null;for(var i=0;i<se.viewer.renderer.clippingPlanes.length;++i)r=se.viewer.renderer.clippingPlanes[i],r=null;for(i=0;i<se.clipTransRotControls.length;++i)se.clipTransRotControls[i].dispose();se.clipTransRotControls=[],o=null;for(n=0;n<h.length;n++)Se.disposeObject(h[n]);if(h=[],fe)for(n=0;n<fe.children.length;n++)fe.remove(fe.children[n]),n--;fe=null,se.viewer.renderer.clippingPlanes=[]}Se.isMobileDevice()?se.clipModeState="translate":se.clipModeState="both",this.planeNameToId={},se.clipActiveId=0,se.viewer.removeFrameListener(f),f=null}0!=t&&se.viewer.render()},this.onCloseViewSection=function(){se.fromView&&this.onSectionView(!1,!0)},this.onCloseClipControl=function(){se.clipTransRotControl&&(se.clipTransRotControl.visible=!1,se.viewer.render())},this.getClipControlVisible=function(){return!!se.clipTransRotControl&&se.clipTransRotControl.visible},this.onOpenClipControl=function(){se.clipTransRotControl&&(se.clipTransRotControl.visible=!0,se.viewer.render())},this.isSectionViewEnabled=function(){return!!fe},this.getClipPlaneInfor=function(){if(fe){for(var e={clipGlobalPlaneObjects:[]},t=0;t<h.length;++t){var n={position:h[t].position.clone(),quaternion:h[t].quaternion.clone(),meshquaternion:h[t].children[0].quaternion.clone()};e.clipGlobalPlaneObjects.push(n)}return e.planeNameToId=se.planeNameToId,e.clippingPlanes=se.viewer.renderer.clippingPlanes,e.clipActiveId=se.clipActiveId,o=h[se.clipActiveId],e.planeVisible=o.visible,e.clipModeState=se.clipModeState,e}return null},this.setClipPlaneInfor=function(e){se.planeNameToId=e.planeNameToId,se.viewer.renderer.clippingPlanes=[],h=[],se.clipTransRotControls=[],fe=new THREE.Scene;for(var t=null,n=0;n<e.clipGlobalPlaneObjects.length;++n){for(var i in se.planeNameToId)if(se.planeNameToId[i]==n){t=i;break}var r=se.viewer.controls.getBoundingBox().getSize(),r=Math.max(r.x,r.y,r.z),r=(r*=1.3,new THREE.PlaneGeometry(r,r,1,1)),o=new THREE.Plane(e.clippingPlanes[n].normal,e.clippingPlanes[n].constant),a=new THREE.Color,s=("XZ"==t?Se.isMobileDevice()?a.set(7514614):a.setRGB(.298,.8,.4):"YZ"==t?Se.isMobileDevice()?a.set(7514614):a.setRGB(.8,.4,.298):"XY"==t&&(Se.isMobileDevice()?a.set(7514614):a.setRGB(.4,.298,.8)),se.viewer.renderer.clippingPlanes.push(o.clone()),new THREE.Object3D),r=(s.position.copy(e.clipGlobalPlaneObjects[n].position),s.updateMatrixWorld(),h.push(s),new THREE.Mesh(r,new THREE.MeshBasicMaterial({side:THREE.DoubleSide,opacity:.2}))),a=(3===c&&le&&(r.material.polygonOffset=!0,r.material.polygonOffsetFactor=-2,r.material.polygonOffsetUnits=1),r.material.color.copy(a),r.material.transparent=!0,s.add(r),new THREE.Quaternion),o=(a.setFromUnitVectors(new THREE.Vector3(0,0,-1),o.normal),r.setRotationFromQuaternion(a),r.updateMatrixWorld(!0),new _(se.viewer.camera,d));fe.add(o),fe.add(s),Se.isMobileDevice()?o.setSize(1.1):o.setSize(.7),o.setMode(se.clipModeState),o.setSpace("local"),o.attach(s),o.name=t,o.update(),n!=e.clipActiveId&&(s.visible=!1,o.visible=!1),o.addEventListener("change",function(){se.viewer.render()}),o.addEventListener("objectChange",function(){v(),3===c&&g(),_e.enableBroadcast&&!_e.broadcastMajor||se.viewer.render()}),se.clipTransRotControls.push(o)}for(i in t=null,se.planeNameToId)if(se.planeNameToId[i]==e.clipActiveId){t=i;break}se.setActiveSectionPlane(t);var l=se.getClipControlVisible();se.clipTransRotControl=se.clipTransRotControls[se.clipActiveId],se.clipTransRotControl.visible=l,3===c&&g(),se.hideShowClipPlane(e.planeVisible),e.fromView&&(se.fromView=!0),se.viewer.render()},this.hideShowClipPlane=function(e){var t=Date.now();if(Se.isMobileDevice())for(var n=0;n<se.clipTransRotControls.length;++n)h[n]&&(h[n].visible=e);else(o=h[se.clipActiveId])&&(o.visible=e);se.viewer.render(),se.viewer.logOperatorTime&&se.viewer.logOperatorTimeShow("[剖切][显示/隐藏 投影面]",t)},this.getClipPlaneVisible=function(){return!!(o=h[se.clipActiveId])&&o.visible},this.reverseClipDirection=function(){var e=null;se.planeNameToId.XY==se.clipActiveId?e="XY":se.planeNameToId.XZ==se.clipActiveId?e="XZ":se.planeNameToId.YZ==se.clipActiveId&&(e="YZ"),o=h[se.clipActiveId],r=se.viewer.renderer.clippingPlanes[se.clipActiveId],s=o.children[0],r.normal.negate(),"XY"==e?o.quaternion.setFromUnitVectors(new THREE.Vector3(0,0,-1),r.normal):"XZ"==e?o.quaternion.setFromUnitVectors(new THREE.Vector3(0,-1,0),r.normal):"YZ"==e&&o.quaternion.setFromUnitVectors(new THREE.Vector3(-1,0,0),r.normal),r.setFromNormalAndCoplanarPoint(r.normal,o.position),3===c&&g(),se.viewer.render()},this.updateClipPlane=function(){3===c&&g(),se.viewer.render()}}function Cn(e){var t=this,r=(this.viewer=e,this.customComments=new Array,this.commentsStyle={font:"20px Verdana",color:"#ff0000"},this);this.clear=function(){t.customComments=new Array},this.setDefultStyle=function(e){null!=e&&(null!=e.font&&(this.commentsStyle.font=e.font),null!=e.color)&&(this.commentsStyle.color=e.color)},this.addComment=function(e){return null==e.visible&&(e.visible=!0),null==e.hasIndicator&&(e.visible=!1),r.customComments.push(e),r.viewer.render(),r.customComments.length-1},this.getAllComments=function(){return r.customComments},this.getCommentsCount=function(){return r.customComments.length},this.getComment=function(e){return null==e||e<0||e>=r.customComments.length?null:r.customComments[e]},this.setCommentVisible=function(e,t){null==e||null==t||e<0||e>=r.customComments.length||null!=t&&(r.customComments[e].visible=t,r.viewer.render())},this.removeComment=function(e){null==e||e<0||e>=r.customComments.length||(r.customComments.splice(e,1),r.viewer.render())},this.removeAllComments=function(){var e=r.customComments.length;r.customComments.splice(0,e),r.viewer.render()},this.get2dPoint=function(e){var e=(new THREE.Vector3).copy(e),t=(e.project(r.viewer.camera),r.viewer.container.offsetWidth/2),n=r.viewer.container.offsetHeight/2;return{x:Math.round(e.x*t+t),y:Math.round(-e.y*n+n)}},this.setAllCommentsVisible=function(e){if(null!=e){for(var t=0;t<r.customComments.length;t++)r.customComments[t].visible=e;r.viewer.render()}},this.renderComments=function(){if(null!=r.viewer.canvas2DLayer){var e=r.viewer.canvas2DLayer.getContext("2d");if(e.clearRect(0,0,window.innerWidth,window.innerHeight),0<r.customComments.length){r.viewer.canvas2DLayer.style.display="";for(var t=0;t<r.customComments.length;t++){var n,i=r.customComments[t];i.visible&&(n=r.get2dPoint(r.customComments[t].position),null!=i.font?e.font=i.font:e.font=this.commentsStyle.font,null!=i.color?e.fillStyle=i.color:e.fillStyle=this.commentsStyle.color,i.hasIndicator?(e.beginPath(),e.arc(n.x,n.y,4,0,2*Math.PI),e.fill(),e.fillText(r.customComments[t].text,n.x+6,n.y+5)):(e.beginPath(),e.fillText(r.customComments[t].text,n.x,n.y)))}}}}}function Rn(e,t){this.viewer=e;var n="coverer_"+Date.now();(n=new ve.Element({className:"coverer",id:n})).setVisibility(!1),void 0!==t&&n.setBgColor(t),e.container.appendChild(n.domElement),e.coverer=n}function On(e){var a=this;this.viewer=e,this.Fonts={},this.loadFonts=function(t,n){function i(){console.log("load Font error")}var r=new THREE.FontLoader,o=new oi(new THREE.LoadingManager);o.setCrossOrigin("anonymous"),o.setResponseType("arraybuffer");o.load(a.viewer.gobalReqHeader,"./Fonts/DS ISO 1_Regular.js.gz",function(e){e=pako.inflate(e,{to:"string"}),e=JSON.parse(e);a.Fonts.default=r.parse(e),t?o.load(a.viewer.gobalReqHeader,"./Fonts/simfang_Regular.js.gz",function(e){e=pako.inflate(e,{to:"string"}),e=JSON.parse(e);a.Fonts.simfang=r.parse(e),n&&n()},void 0,i):n&&n()},void 0,i)}}function Ln(e,t){var o=this,n=(this.viewer=e,this.operator=t,new ve.Dialog({id:"dlgOpAnnotation",className:"dialog",callbackEvent:r,title:"Comments",noScrollbar:!0})),t=(n.setVisibility(!1),n.setSize(250,180),n.addEventListener("close",function(e){o.dialog.setVisibility(!1),o.operator.clicked=-1}),n.setOpacity(_e.dialogOpacity),e.container.appendChild(n.domElement),this.dialog=n,new ve.Element({className:"dialog-content"}));n.setContent(t),this.textInput=new ve.TextArea({id:"AnnotationInput",name:"AnnotationInput",className:"annotation-input",type:"textarea",callbackEvent:r}),n.addChildElement(this.textInput),t.domElement.appendChild(this.textInput.domElement),this.link=document.createElement("a"),this.link.href="http://www.baidu.com",this.link.target="_blank",this.link.innerText="点击了解更多详情",t.domElement.appendChild(document.createElement("a")),t.domElement.appendChild(this.link);(e=new ve.Table).addRow(),e.addRow(),e.addRow(),e.addRow(),e.addRow(),e.addRow(),e.addRow(),e.addRow();var i=new ve.Button({id:"btnOk",className:"uploadify-button",callbackEvent:r,text:"OK"});function r(e){var t,n;switch(e.target.domElement.id){case"dlgOpAnnotation":break;case"btnOk":n={position:null,text:"",visible:!0,hasIndicator:!0},"click"!=(t=(t=e).event.type)&&"touchstart"!=t||null!=o.textInput.domElement.value&&null!=o.textInput.domElement.value&&""!=o.textInput.domElement.value&&(n.position=(new THREE.Vector3).copy(o.operator.lastSprite),o.operator.lastSprite=null,n.text=o.textInput.domElement.value,o.viewer.getCommentsManager().addComment(n),o.show(!1));break;case"btnCancel":"click"!=e.event.type&&"touchstart"!=e.event.tyep||(o.show(!1),o.operator.clicked=-1)}}i.domElement.width=70,e.addCol({element:i}),(i=new ve.Button({id:"btnCancel",className:"uploadify-button",callbackEvent:r,text:"Cancel"})).domElement.width=70,e.addCol({element:i}),n.addChildElement(e),t.domElement.appendChild(e.domElement),this.release=function(){o.viewer.container.removeChild(n.domElement)},this.show=function(e,t,n,i,r){e&&(o.dialog.setLeft(t),o.dialog.setTop(n),o.textInput.domElement.value=i,void 0!==r?(o.link.href=r,o.link.innerText="点击了解更多详情"):(o.link.href="",o.link.innerText=""),o.dialog.deleteOpacity()),o.dialog.setVisibility(e)}}function Dn(){this.init=function(){THREE.Object3D.call(this),this.handles=new THREE.Object3D,this.pickers=new THREE.Object3D,this.planes=new THREE.Object3D,this.add(this.handles),this.add(this.pickers),this.add(this.planes);var a,e=new THREE.PlaneGeometry(50,50,2,2),t=new THREE.MeshBasicMaterial({visible:!1,side:THREE.DoubleSide}),n={XY:new THREE.Mesh(e,t),YZ:new THREE.Mesh(e,t),XZ:new THREE.Mesh(e,t),XYZE:new THREE.Mesh(e,t)};for(a in this.activePlane=n.XYZE,n.YZ.rotation.set(0,Math.PI/2,0),n.XZ.rotation.set(-Math.PI/2,0,0),n)n[a].name=a,this.planes.add(n[a]),this.planes[a]=n[a];function i(e,t){for(var n in e)for(a=e[n].length;a--;){var i=e[n][a][0],r=e[n][a][1],o=e[n][a][2];i.name=n,r&&i.position.set(r[0],r[1],r[2]),o&&i.rotation.set(o[0],o[1],o[2]),t.add(i)}}i(this.handleGizmos,this.handles),i(this.pickerGizmos,this.pickers),this.traverse(function(e){var t;e instanceof THREE.Mesh&&(e.updateMatrix(),(t=e.geometry.clone()).applyMatrix(e.matrix),e.geometry=t,e.position.set(0,0,0),e.rotation.set(0,0,0),e.scale.set(1,1,1))})},this.highlight=function(t){this.traverse(function(e){e.material&&e.material.highlight&&(e.name===t?e.material.highlight(!0):e.material.highlight(!1))})}}function Hn(e){function t(e,t){var n=new Image,i=(n.crossOrigin="anonymous",new THREE.Texture(n));switch(e){case 0:n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGuSURBVDhPpZK/SwJxGMbPkwYVAg0CHcIlECPEU8iisS2i0Yi2hiiiKWpoiH6ttRQRDTk4RP9EtAQhJxYhRkNGQ9MRhIQEZp/3zs47bfOBh/e95/3h931flV7haVlF07QBj8ezhftpGMZutVr9sSJtkDNNzlSz2cwXi0VdNNWMAAQD0we3Q6HQuik6QHGM4kvcdL1eL1mqo0ELm7BC4l4qldIsiYp0OoC5gt9wvlwuN0QXuBrouv6FWYAyWp4mftF58jFNR3EXyXkT7Q/elrXxDiKRiMyfhYFwODxI8Q7+CcWHkuOEvUQn4vG41+fz3eCOwxp8aTQamVKpVJe4E/82ELC0YX65gqsyQoYl31kRNzqXaINiGcGM46+K/Q9dOxCw9UlMDl7DVzjLXp5YzyO+C10jJJPJoKqqcud++TRFRbmHcrpE5xW6RqD4HDMEl0muCtmBjBCEuWg06qpxjcDilph3A/eCwgNLNU/7wAgx3Bm/31/j+9aKOF5A8QjFR7jPnGzNUtvgZSsYef4+f7CEKQK7AcUTmDOem+XecnsXCoXCB7E53FM4Zoq9Q1F+AdSNjQGiWI24AAAAAElFTkSuQmCC";break;case 1:n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEnSURBVDhP3ZM9S8RAEIbz0ZhAsEgj+QF6pDjyYWFj5Q/wbyhiIYetCCeWtoKVxZWW9gaxECTR7mwFIVWw0c4Qn8ntrYa7RsXGB968k8nuzDJhjd9iKjfSNN3GlpumGRVFkU+yXeI4XrEsa4twnOf5meQseSju0a5pmqMoihYmqU/CMLTZfE64g3QDXYCKt9gJ6tm2fdgmv+A4zh62ho5YO1tAqOv6AHtEgyRJVtskcPQeNkR3rDlukwo9gynMQrrcoDFKqqqqfd+/lk8oprk00NjKNWVZPgdBsEi4id5c1+3jMrh9Nl/iHWZOIHAKF3tAS+hdYs/zNrIsa4g7zC0gUGQdy9Ar6tP9SfLfgkG+UOhKvc6l8xd+wn8vwL045XJdqNe/wDA+AM+DTooKvznTAAAAAElFTkSuQmCC";break;case 2:n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE0SURBVDhPpZI9S8RAEIbzQRCLA8FeFPsYErk6jf4HLbQQwfZK7fTA2sbeRixsxcreIiQgthbXWUXRFHbGZ3aXkGA2V9wDwzs7w8zObOIsimtUkSTJGNnTJysfeZ5Pjd9tEMfxPnKtT11c1/WRETajwYYKQqeBjTRN3aqqbnFlugkNrlQCPKODUHyKSPFdu1iY24B32UEusFfWOFbBFoMrULyG5JjsP+b2N4m3sU4QhuESco+tYgd9xYK1QRAEsqt81inFDyrYQ28DPuchcoI9lmV5roIW/r0BxVs81jPuu+d521mWfepMP/I4DVEUrVD0hDuq63qX0Wc6Y6dZQX4W3/dvcDexo6IoXlRiDs0KcjsNZNxfbv/W0X5YcZ3pvpSvIsDuyyQuzXEQLjhjwh9zXATH+QMUOlTdo/cuSQAAAABJRU5ErkJggg=="}n.onload=function(){i.needsUpdate=!0,c.parent.dispatchEvent({type:"change"})},e=new THREE.SpriteMaterial({map:i,depthTest:!1,depthWrite:!1,transparent:!0}),(e=new THREE.Sprite(e)).scale.set(.2,.2,1),e.material.needsUpdate=!0,t(e)}var n=this,i=(Dn.call(this),!0),r=!0,o=!0,a=(e&&(i=0<=e.indexOf("translateX"),r=0<=e.indexOf("translateY"),o=0<=e.indexOf("translateZ")),new THREE.CylinderGeometry(0,.05,.1,12,1,!1)),s=new THREE.Mesh(a);s.position.y=.5,s.updateMatrix(),a.applyMatrix(s.matrix);(s=new THREE.BufferGeometry).addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,.7,0,0],3));var l=new THREE.BufferGeometry,d=(l.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,.7,0],3)),new THREE.BufferGeometry),c=(d.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,0,.7],3)),this.handleGizmos={},i&&(this.handleGizmos.X=[[new THREE.Mesh(a,new y({color:16711680})),[.2,0,0],[0,0,-Math.PI/2]],[new THREE.Line(s,new E({color:16711680}))]]),r&&(this.handleGizmos.Y=[[new THREE.Mesh(a,new y({color:65280})),[0,.2,0]],[new THREE.Line(l,new E({color:65280}))]]),o&&(this.handleGizmos.Z=[[new THREE.Mesh(a,new y({color:255})),[0,0,.2],[Math.PI/2,0,0]],[new THREE.Line(d,new E({color:255}))]]),this);Se.isMobileDevice()||e||(t(0,function(e){e.position.set(.9,0,0),n.handleGizmos.X&&n.handleGizmos.X[0][0].add(e)}),t(1,function(e){e.position.set(0,.9,0),n.handleGizmos.Y&&n.handleGizmos.Y[0][0].add(e)}),t(2,function(e){e.position.set(0,0,.9),n.handleGizmos.Z&&n.handleGizmos.X&&n.handleGizmos.Y&&n.handleGizmos.Z[0][0].add(e)})),i&&r&&o&&(this.handleGizmos.XY=[[new THREE.Mesh(new THREE.PlaneGeometry(.29,.29),new y({color:16776960,opacity:.25})),[.15,.15,0]]],this.handleGizmos.YZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.29,.29),new y({color:65535,opacity:.25})),[0,.15,.15],[0,Math.PI/2,0]]],this.handleGizmos.XZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.29,.29),new y({color:16711935,opacity:.25})),[.15,0,.15],[-Math.PI/2,0,0]]]),this.pickerGizmos={},i&&(this.pickerGizmos.X=[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),di),[.6,0,0],[0,0,-Math.PI/2]]]),r&&(this.pickerGizmos.Y=[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),di),[0,.6,0]]]),o&&(this.pickerGizmos.Z=[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),di),[0,0,.6],[Math.PI/2,0,0]]]),i&&r&&o&&(this.pickerGizmos.XYZ=[[new THREE.Mesh(new THREE.OctahedronGeometry(.2,0),di)]],this.pickerGizmos.XY=[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),di),[.2,.2,0]]],this.pickerGizmos.YZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),di),[0,.2,.2],[0,Math.PI/2,0]]],this.pickerGizmos.XZ=[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),di),[.2,0,.2],[-Math.PI/2,0,0]]]),this.setActivePlane=function(e,t){var n=new THREE.Matrix4;t.applyMatrix4(n.getInverse(n.extractRotation(this.planes.XY.matrixWorld))),"X"===e&&(this.activePlane=this.planes.XY,Math.abs(t.y)>Math.abs(t.z))&&(this.activePlane=this.planes.XZ),"Y"===e&&(this.activePlane=this.planes.XY,Math.abs(t.x)>Math.abs(t.z))&&(this.activePlane=this.planes.YZ),"Z"===e&&(this.activePlane=this.planes.XZ,Math.abs(t.x)>Math.abs(t.y))&&(this.activePlane=this.planes.YZ),"XYZ"===e&&(this.activePlane=this.planes.XYZE),"XY"===e&&(this.activePlane=this.planes.XY),"YZ"===e&&(this.activePlane=this.planes.YZ),"XZ"===e&&(this.activePlane=this.planes.XZ)},this.init()}function Fn(e){Dn.call(this);var t=new THREE.BufferGeometry,n=new Float32Array([-.1,0,0,0,.3,0,0,0,-.1,0,0,-.1,0,.3,0,.1,0,0,.1,0,0,0,.3,0,0,0,.1,0,0,.1,0,.3,0,-.1,0,0,-.1,0,0,0,-.3,0,0,0,-.1,0,0,-.1,0,-.3,0,.1,0,0,.1,0,0,0,-.3,0,0,0,.1,0,0,.1,0,-.3,0,-.1,0,0]),i=(t.addAttribute("position",new THREE.BufferAttribute(n,3)),new THREE.MeshBasicMaterial({color:16711680}));new THREE.Mesh(t,i).position.set(.5,0,0),t.addAttribute("position",new THREE.BufferAttribute(n,3)),(i=new THREE.Mesh(t,new y({color:16711680}))).scale.set(.5,.5,.5),i.position.set(0,0,.5),(n=new THREE.Mesh(t,new y({color:65280}))).scale.set(.5,.5,.5),n.rotateZ(Math.PI/2),n.position.set(0,0,.5);(t=new THREE.Mesh(t,new y({color:255}))).scale.set(.5,.5,.5),t.position.set(.5,0,0);var r=e?2*Math.PI:Math.PI;this.handleGizmos={X:[[new THREE.Mesh(new THREE.TorusGeometry(.5,.01,10,40,r),new y({color:16711680})),[0,0,0],[0,-Math.PI/2,-Math.PI/2]],[i]],Y:[[new THREE.Mesh(new THREE.TorusGeometry(.5,.01,10,40,Math.PI),new y({color:65280})),[0,0,0],[Math.PI/2,0,0]],[n]],Z:[[new THREE.Mesh(new THREE.TorusGeometry(.5,.01,10,40,Math.PI),new y({color:255})),[0,0,0],[0,0,-Math.PI/2]],[t]],XYZE:[[new THREE.Line(new function(e,t,n){var i=new THREE.BufferGeometry,r=[];n=n||1;for(var o=0;o<=64*n;++o)"x"===t&&r.push(0,Math.cos(o/32*Math.PI)*e,Math.sin(o/32*Math.PI)*e),"y"===t&&r.push(Math.cos(o/32*Math.PI)*e,0,Math.sin(o/32*Math.PI)*e),"z"===t&&r.push(Math.sin(o/32*Math.PI)*e,Math.cos(o/32*Math.PI)*e,0);return i.addAttribute("position",new THREE.Float32BufferAttribute(r,3)),i}(.5,"z",1),new E({color:7895160}))]]},this.pickerGizmos={X:[[new THREE.Mesh(new THREE.TorusGeometry(.5,.12,4,12,r),di),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.TorusGeometry(.5,.12,4,12,Math.PI),di),[0,0,0],[Math.PI/2,0,0]]],Z:[[new THREE.Mesh(new THREE.TorusGeometry(.5,.12,4,12,Math.PI),di),[0,0,0],[0,0,-Math.PI/2]]],XYZE:[[new THREE.Mesh(new THREE.Geometry)]]},this.setActivePlane=function(e){"E"===e&&(this.activePlane=this.planes.XYZE),"X"===e&&(this.activePlane=this.planes.YZ),"Y"===e&&(this.activePlane=this.planes.XZ),"Z"===e&&(this.activePlane=this.planes.XY)},this.update=function(e,t){Dn.prototype.update.apply(this,arguments);this.handles,this.pickers;var n=new THREE.Matrix4,i=new THREE.Euler(0,0,1),r=new THREE.Quaternion,o=new THREE.Vector3(1,0,0),a=new THREE.Vector3(0,1,0),s=new THREE.Vector3(0,0,1),l=new THREE.Quaternion,d=new THREE.Quaternion,c=new THREE.Quaternion,h=t.clone();i.copy(this.planes.XY.rotation),r.setFromEuler(i),n.makeRotationFromQuaternion(r).getInverse(n),h.applyMatrix4(n),this.traverse(function(e){r.setFromEuler(i),"X"===e.name&&(l.setFromAxisAngle(o,Math.atan2(-h.y,h.z)),r.multiplyQuaternions(r,l),e.quaternion.copy(r)),"Y"===e.name&&(d.setFromAxisAngle(a,Math.atan2(h.x,h.z)),r.multiplyQuaternions(r,d),e.quaternion.copy(r)),"Z"===e.name&&(c.setFromAxisAngle(s,Math.atan2(h.y,h.x)),r.multiplyQuaternions(r,c),e.quaternion.copy(r))})},this.showAxis=function(e,t){if(void 0!==e&&""!==e)switch(e){case"x":this.handleGizmos.X[0][0].visible=t,this.handleGizmos.X[1][0].visible=t,this.pickerGizmos.X[0][0].visible=t;break;case"y":this.handleGizmos.Y[0][0].visible=t,this.handleGizmos.Y[1][0].visible=t,this.pickerGizmos.Y[0][0].visible=t;break;case"z":this.handleGizmos.Z[0][0].visible=t,this.handleGizmos.Z[1][0].visible=t,this.pickerGizmos.Z[0][0].visible=t;break;case"e":this.handleGizmos.XYZE[0][0].visible=t,this.pickerGizmos.XYZE[0][0].visible=t}},this.init(),e&&"translateX"==e[0]&&(this.showAxis("y",!1),this.showAxis("z",!1),this.showAxis("e",!1))}function Nn(){var n=this;THREE.Object3D.call(this),this._gizmoTranslate=new Hn,this._gizmoRotate=new Fn,this.add(this._gizmoTranslate),this.add(this._gizmoRotate),this._translatePickers=this._gizmoTranslate.pickers,this._rotatePickers=this._gizmoRotate.pickers,this.activePlane=this._gizmoTranslate.activePlane,this.highlight=function(e,t){"translate"==t?(this._gizmoRotate.highlight(null),this._gizmoTranslate.highlight(e)):"rotate"==t&&(this._gizmoTranslate.highlight(null),this._gizmoRotate.highlight(e))},this.setActivePlane=function(e,t){"translate"==n.pickType?(this._gizmoTranslate.setActivePlane(e,t),this.activePlane=this._gizmoTranslate.activePlane):"rotate"==n.pickType&&(this._gizmoRotate.setActivePlane(e,t),this.activePlane=this._gizmoRotate.activePlane)},this.update=function(e,t){this._gizmoTranslate.update(e,t),this._gizmoRotate.update(e,t)}}function jn(){Dn.call(this);var e=new THREE.BoxGeometry(.125,.125,.125),t=new THREE.Mesh(e);t.position.y=.5,t.updateMatrix(),e.applyMatrix(t.matrix);(t=new THREE.BufferGeometry).addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,1,0,0],3));var n=new THREE.BufferGeometry,i=(n.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,1,0],3)),new THREE.BufferGeometry);i.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,0,0,1],3)),this.handleGizmos={X:[[new THREE.Mesh(e,new y({color:16711680})),[.5,0,0],[0,0,-Math.PI/2]],[new THREE.Line(t,new E({color:16711680}))]],Y:[[new THREE.Mesh(e,new y({color:65280})),[0,.5,0]],[new THREE.Line(n,new E({color:65280}))]],Z:[[new THREE.Mesh(e,new y({color:255})),[0,0,.5],[Math.PI/2,0,0]],[new THREE.Line(i,new E({color:255}))]],XYZ:[[new THREE.Mesh(new THREE.BoxGeometry(.125,.125,.125),new y({color:16777215,opacity:.25}))]]},this.pickerGizmos={X:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),di),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),di),[0,.6,0]]],Z:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),di),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new THREE.Mesh(new THREE.BoxGeometry(.4,.4,.4),di)]]},this.setActivePlane=function(e,t){var n=new THREE.Matrix4;t.applyMatrix4(n.getInverse(n.extractRotation(this.planes.XY.matrixWorld))),"X"===e&&(this.activePlane=this.planes.XY,Math.abs(t.y)>Math.abs(t.z))&&(this.activePlane=this.planes.XZ),"Y"===e&&(this.activePlane=this.planes.XY,Math.abs(t.x)>Math.abs(t.z))&&(this.activePlane=this.planes.YZ),"Z"===e&&(this.activePlane=this.planes.XZ,Math.abs(t.x)>Math.abs(t.y))&&(this.activePlane=this.planes.YZ),"XYZ"===e&&(this.activePlane=this.planes.XYZE)},this.init()}function _n(l,d,F,N,j){THREE.Object3D.call(this),d=void 0!==d?d:document,this.object=void 0,this.viewer=F,this.visible=!1,this.translationSnap=null,this.rotationSnap=null,this.space="world",this.size=.5,this.axis=null,this.pickType=null,this.newPosition=new THREE.Vector3,this.down=!1,this.opBall=N,this.piovtDir=null;var _,c=this,r="translate",i=!1,o={translate:new Hn(j),rotate:new Fn(j),both:new Nn,scale:new jn};for(_ in o){var V=o[_];V.visible=_===r,this.add(V)}var a={type:"change"},k={type:"mouseDown"},U={type:"mouseUp",mode:r},G=(document.createEvent("HTMLEvents").initEvent("mousemove",!0,!0),{type:"objectChange"}),z=new THREE.Raycaster,W=new THREE.Vector2,n=new THREE.Vector3,s=new THREE.Vector3,Y=new THREE.Vector3,h=0,u=0,e=new THREE.Vector3,t=new THREE.Vector3,p=1,X=new THREE.Matrix4,f=new THREE.Vector3,m=new THREE.Matrix4,g=new THREE.Vector3,v=new THREE.Quaternion,A=new THREE.Vector3(1,0,0),y=new THREE.Vector3(0,1,0),E=new THREE.Vector3(0,0,1),M=new THREE.Quaternion,w=new THREE.Quaternion,b=new THREE.Quaternion,x=new THREE.Quaternion,I=new THREE.Quaternion,T=new THREE.Quaternion,S=new THREE.Vector3,Q=new THREE.Vector3,B=new THREE.Vector3,Z=new THREE.Matrix4,P=new THREE.Matrix4,C=new THREE.Vector3(1,1,1),R=new THREE.Vector3,q=new THREE.Euler,O=new THREE.Matrix4,K=new THREE.Vector3,J=new THREE.Euler;function L(e){var t,n;_e.enableBroadcast&&!_e.broadcastMajor||void 0===c.object||!0===i||void 0!==e.button&&0!==e.button||c.down||(n=e.changedTouches?e.changedTouches[0]:e,t=null,"both"!=r?t=H(n,o[r].pickers.children):(t=H(n,o[r]._rotatePickers.children))?c.pickType="rotate":(t=H(n,o[r]._translatePickers.children))&&(c.pickType="translate"),n=null,t&&(n=t.object.name,e.preventDefault()),c.axis!==n&&(c.axis=n,c.update(),c.dispatchEvent(a)))}function $(e){var t,n;_e.enableBroadcast&&!_e.broadcastMajor||(e.offsetX||(e.clientX,this.viewer.container.getBoundingClientRect().left),e.offsetY||(e.clientY,this.viewer.container.getBoundingClientRect().top),e.srcElement&&e.srcElement!==this&&(e.clientX,this.viewer.container.getBoundingClientRect().left,e.clientY,this.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==this&&(e.clientX,this.viewer.container.getBoundingClientRect().left,e.clientY,this.viewer.container.getBoundingClientRect().top),void 0===c.object)||!0===i||void 0!==e.button&&0!==e.button||(0!==(t=e.changedTouches?e.changedTouches[0]:e).button&&void 0!==t.button||(n=null,"both"!=r?(n=H(t,o[r].pickers.children))&&(c.pickType=r):(n=H(t,o[r]._rotatePickers.children))?c.pickType="rotate":(n=H(t,o[r]._translatePickers.children))&&(c.pickType="translate"),n?(e.preventDefault(),e.stopPropagation(),c.dispatchEvent(k),c.axis=n.object.name,c.down=!0,c.update(),f.copy(K).sub(R).normalize(),o[r].setActivePlane(c.axis,f),(e=H(t,[o[r].activePlane]))&&(S.copy(c.object.position),Q.copy(c.object.position),B.copy(c.object.scale),Z.extractRotation(c.object.matrix),O.extractRotation(c.object.matrixWorld),c.object.parent&&(P.extractRotation(c.object.parent.matrixWorld),C.setFromMatrixScale(m.getInverse(c.object.parent.matrixWorld))),s.copy(e.point))):(c.axis=null,c.update(),c.down=!1,c.pickType="default",c.dispatchEvent(a))),i=!0)}function ee(){"translate"===r||"translate"==c.pickType?(n.sub(s),"local"===c.space&&(c.piovtDir?n.projectOnVector(c.piovtDir):(-1===c.axis.search("X")&&(n.x=0),-1===c.axis.search("Y")&&(n.y=0),-1===c.axis.search("Z")&&(n.z=0)),c.object.position.copy(S),c.object.position.add(n),(Y=c.object.position.clone()).sub(Q),c.newPosition=c.object.position.clone(),Q.copy(c.newPosition)),"world"!==c.space&&-1===c.axis.search("XYZ")||(-1===c.axis.search("X")&&(n.x=0),-1===c.axis.search("Y")&&(n.y=0),-1===c.axis.search("Z")&&(n.z=0),n.applyMatrix4(m.getInverse(P)),c.object.position.copy(S),c.object.position.add(n)),null!==c.translationSnap&&("local"===c.space&&c.object.position.applyMatrix4(m.getInverse(O)),-1!==c.axis.search("X")&&(c.object.position.x=Math.round(c.object.position.x/c.translationSnap)*c.translationSnap),-1!==c.axis.search("Y")&&(c.object.position.y=Math.round(c.object.position.y/c.translationSnap)*c.translationSnap),-1!==c.axis.search("Z")&&(c.object.position.z=Math.round(c.object.position.z/c.translationSnap)*c.translationSnap),"local"===c.space)&&c.object.position.applyMatrix4(O)):"scale"===r?(n.sub(s),n.multiply(C),"local"===c.space&&("XYZ"===c.axis?(p=1+n.y/Math.max(B.x,B.y,B.z),c.object.scale.x=B.x*p,c.object.scale.y=B.y*p,c.object.scale.z=B.z*p):(n.applyMatrix4(m.getInverse(O)),"X"===c.axis&&(c.object.scale.x=B.x*(1+n.x/B.x)),"Y"===c.axis&&(c.object.scale.y=B.y*(1+n.y/B.y)),"Z"===c.axis&&(c.object.scale.z=B.z*(1+n.z/B.z))))):"rotate"!==r&&"rotate"!=c.pickType||(n.sub(R),n.multiply(C),g.copy(s).sub(R),g.multiply(C),"E"===c.axis?(n.applyMatrix4(m.getInverse(X)),g.applyMatrix4(m.getInverse(X)),e.set(Math.atan2(n.z,n.y),Math.atan2(n.x,n.z),Math.atan2(n.y,n.x)),t.set(Math.atan2(g.z,g.y),Math.atan2(g.x,g.z),Math.atan2(g.y,g.x)),v.setFromRotationMatrix(m.getInverse(P)),I.setFromAxisAngle(f,e.z-t.z),M.setFromRotationMatrix(O),v.multiplyQuaternions(v,I),v.multiplyQuaternions(v,M),c.object.quaternion.copy(v)):"XYZE"===c.axis?(I.setFromEuler(n.clone().cross(g).normalize()),v.setFromRotationMatrix(m.getInverse(P)),w.setFromAxisAngle(I,-n.clone().angleTo(g)),M.setFromRotationMatrix(O),v.multiplyQuaternions(v,w),v.multiplyQuaternions(v,M),c.object.quaternion.copy(v)):"local"===c.space?(n.applyMatrix4(m.getInverse(O)),g.applyMatrix4(m.getInverse(O)),e.set(Math.atan2(n.z,n.y),Math.atan2(n.x,n.z),Math.atan2(n.y,n.x)),t.set(Math.atan2(g.z,g.y),Math.atan2(g.x,g.z),Math.atan2(g.y,g.x)),M.setFromRotationMatrix(Z),null!==c.rotationSnap?(w.setFromAxisAngle(A,Math.round((e.x-t.x)/c.rotationSnap)*c.rotationSnap),b.setFromAxisAngle(y,Math.round((e.y-t.y)/c.rotationSnap)*c.rotationSnap),x.setFromAxisAngle(E,Math.round((e.z-t.z)/c.rotationSnap)*c.rotationSnap)):(w.setFromAxisAngle(A,e.x-t.x),b.setFromAxisAngle(y,e.y-t.y),x.setFromAxisAngle(E,e.z-t.z)),"X"===c.axis&&M.multiplyQuaternions(M,w),"Y"===c.axis&&M.multiplyQuaternions(M,b),"Z"===c.axis&&M.multiplyQuaternions(M,x),c.object.quaternion.copy(M)):"world"===c.space&&(e.set(Math.atan2(n.z,n.y),Math.atan2(n.x,n.z),Math.atan2(n.y,n.x)),t.set(Math.atan2(g.z,g.y),Math.atan2(g.x,g.z),Math.atan2(g.y,g.x)),v.setFromRotationMatrix(m.getInverse(P)),null!==c.rotationSnap?(w.setFromAxisAngle(A,Math.round((e.x-t.x)/c.rotationSnap)*c.rotationSnap),b.setFromAxisAngle(y,Math.round((e.y-t.y)/c.rotationSnap)*c.rotationSnap),x.setFromAxisAngle(E,Math.round((e.z-t.z)/c.rotationSnap)*c.rotationSnap)):(w.setFromAxisAngle(A,e.x-t.x),b.setFromAxisAngle(y,e.y-t.y),x.setFromAxisAngle(E,e.z-t.z)),M.setFromRotationMatrix(O),"X"===c.axis&&v.multiplyQuaternions(v,w),"Y"===c.axis&&v.multiplyQuaternions(v,b),"Z"===c.axis&&v.multiplyQuaternions(v,x),v.multiplyQuaternions(v,M),c.object.quaternion.copy(v))),c.update(),c.dispatchEvent(a),c.dispatchEvent(G)}function te(e){var t;_e.enableBroadcast&&!_e.broadcastMajor||void 0===c.object||null===c.axis||!1===i||void 0!==e.button&&0!==e.button||!1!==(t=H(e.changedTouches?e.changedTouches[0]:e,[o[r].activePlane]))&&(e.preventDefault(),e.stopPropagation(),n.copy(t.point),ee())}function D(e){_e.enableBroadcast&&!_e.broadcastMajor||(e.preventDefault(),void 0!==e.button&&0!==e.button)||(i&&null!==c.axis&&(U.mode=r,c.dispatchEvent(U)),i=!1,c.down=!1,"TouchEvent"in window&&e instanceof TouchEvent?(c.axis=null,c.update(),c.dispatchEvent(a)):L(e))}function H(e,t){var n=d.getBoundingClientRect(),i=n.width,r=n.height,i=(null!=d.clientWidth&&null!=d.clientHeight&&(10<Math.abs(i-d.clientWidth)&&(i=d.clientWidth),10<Math.abs(r-d.clientHeight))&&(r=d.clientHeight),(e.clientX-n.left)/i),e=(e.clientY-n.top)/r,o=(W.set(2*i-1,-2*e+1),l.setCastRay(z,W.x,W.y),z.intersectObjects(t,!0)),a=o[0];if(c.piovtDir)for(var s=0;s<o.length;s++)o[s].object.visible&&(a=o[s]);return a||!1}Se.isMobileDevice()?(d.addEventListener("touchstart",$,!1),d.addEventListener("touchmove",L,!1),d.addEventListener("touchmove",te,!0),d.addEventListener("touchend",D,!1),d.addEventListener("touchcancel",D,!1)):(d.addEventListener("mousedown",$,!1),d.addEventListener("mousemove",L,!1),d.addEventListener("mousemove",te,!0),d.addEventListener("mouseup",D,!1)),this.setPiovtDir=function(e){this.piovtDir=e.clone()},this.getOffset=function(){return Y},this.getRotate=function(){return M},this.getRotateAngle=function(){return h*Math.PI/180},this.getRotateOffset=function(){return T},this.initRotateOffset=function(){T.set(0,0,0,1),h=0},this.isDragging=function(){return i},this.isSelected=function(){return null!=c.axis},this.setOldPosition=function(e){e&&S.copy(e)},this.getOldPosition=function(){return S},this.dispose=function(){Se.isMobileDevice()?(d.removeEventListener("touchstart",$),d.removeEventListener("touchmove",L),d.removeEventListener("touchmove",te),d.removeEventListener("touchend",D),d.removeEventListener("touchcancel",D),d.removeEventListener("touchleave",D)):(d.removeEventListener("mousedown",$),d.removeEventListener("mousemove",L),d.removeEventListener("mousemove",te),d.removeEventListener("mouseup",D),d.removeEventListener("mouseout",D))},this.attach=function(e){this.object=e,this.visible=!0,this.update()},this.detach=function(){this.object=void 0,this.visible=!1,this.axis=null},this.getMode=function(){return r},this.setMode=function(e){for(var t in"scale"===(r=e||r)&&(c.space="local"),o)o[t].visible=t===r;this.update(),c.dispatchEvent(a)},this.setTranslationSnap=function(e){c.translationSnap=e},this.setRotationSnap=function(e){c.rotationSnap=e},this.setSize=function(e){c.size=e,this.update(),c.dispatchEvent(a)},this.setSpace=function(e){c.space=e,this.update(),c.dispatchEvent(a)},this.MoveFromTextValue=function(e){var t;parseFloat(c.textBox.value);r=e.mode,t=e.value,c.axis=e.axis,"translate"===r||"translate"==c.pickType?(n.copy(s),n.x+=t,n.y+=t,n.z+=t,ee()):"rotate"!==r&&"rotate"!=c.pickType||(t=t*Math.PI/180,M.setFromRotationMatrix(Z),"X"===c.axis?(w.setFromAxisAngle(A,t),M.multiplyQuaternions(M,w),T.copy(w)):"Y"===c.axis?(b.setFromAxisAngle(y,t),M.multiplyQuaternions(M,b),T.copy(b)):"Z"===c.axis&&(x.setFromAxisAngle(E,t),M.multiplyQuaternions(M,x),T.copy(x)),c.object.quaternion.copy(M)),c.opBall.onOpBall()},this.SetTextValue=function(){var e,t,n={mode:null,x:0,y:0,z:0};return"translate"===r||"translate"==c.pickType?(n.mode="translate",-1!=c.axis.search("X")?n.x=(this.newPosition.x-S.x).toFixed(4):-1!=c.axis.search("Y")?n.y=(this.newPosition.y-S.y).toFixed(4):-1!=c.axis.search("Z")&&(n.z=(this.newPosition.z-S.z).toFixed(4))):"rotate"!==r&&"rotate"!=c.pickType||(n.mode="rotate",e=new THREE.Euler,t=0,-1!=c.axis.search("X")?(t=180*e.setFromQuaternion(w).x/Math.PI,n.x=t.toFixed(1),u=t-h,h=t,this.piovtDir?T.setFromAxisAngle(this.piovtDir,u*Math.PI/180):T.setFromAxisAngle(A,u*Math.PI/180)):-1!=c.axis.search("Y")?(e.setFromQuaternion(b),t=180*e.y/Math.PI,Math.abs(Math.abs(e.x)-Math.PI)<1e-5&&(t=(180-Math.abs(t))*t/Math.abs(t)),n.y=t.toFixed(1),u=t-h,h=t,T.setFromAxisAngle(y,u*Math.PI/180)):-1!=c.axis.search("Z")&&(t=180*e.setFromQuaternion(x).z/Math.PI,n.z=t.toFixed(1),u=t-h,h=t,T.setFromAxisAngle(E,u*Math.PI/180))),n},this.update=function(){var e,t,n,i;void 0!==c.object&&(c.object.updateMatrixWorld(),R.setFromMatrixPosition(c.object.matrixWorld),q.setFromRotationMatrix(m.extractRotation(c.object.matrixWorld)),l.updateMatrixWorld(),K.setFromMatrixPosition(l.matrixWorld),J.setFromRotationMatrix(m.extractRotation(l.matrixWorld)),l.updateMatrix(),e=l.getCameraTarget(),n=l.position,(i=new THREE.Vector3).subVectors(e,n),t=R.clone(),t=l.isPerspective?t.sub(n).dot(i.normalize()):1.2*i.length(),n=l.fov,i=120*(2*t*Math.tan(THREE.Math.degToRad(.5*n)))/d.height*c.size,Se.isMobileDevice()&&(i*=3),this.position.copy(R),this.scale.set(i,i,i),f.copy(K).sub(e).normalize(),"local"===c.space?o[r].update(q,f):"world"===c.space&&o[r].update(new THREE.Euler,f),o[r].highlight(c.axis,c.pickType))}}function Vn(v,u){var A=this,y=(this.viewer=v,new ve.Toolbar({id:"tbOperator",className:"toolbar",callbackEvent:r})),E=(y.setVisibility(!1),A.viewer.getToolBarAutoHideFlag()&&y.setOpacity(_e.toolbarOpacity),v.container.appendChild(y.domElement),v.tlbOperator=y,[]),p=void 0,f=void 0,e=void 0,M=void 0,m=void 0,w=void 0,b=void 0,g=null,i="toolbar-button",x="",I=void 0,T=void 0,S=null,B=void 0,P=null,t=(null!=u.toolbarButtonSize&&"small"==u.toolbarButtonSize&&(x="-"+u.toolbarButtonSize,i+=x),null!=u.toolbarButtonListRule&&"row"==u.toolbarButtonListRule&&(g="none"),!0);if(u.toolbarButtons)for(var n=0;n<u.toolbarButtons.length;++n)switch(u.toolbarButtons[n].id){case"btnOrbit":(e=y.addButton({id:"btnOrbit"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_ORBIT")})),v.bDefaultOpRotate&&v.onOpChanged({target:e});break;case"btnPan":(e=y.addButton({id:"btnPan"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_PAN")})),!1===v.bDefaultOpRotate&&v.onOpChanged({target:e});break;case"btnZoom":(e=y.addButton({id:"btnZoom"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_ZOOM")}));break;case"btnExplode":(p=y.addButton({id:"btnExplode"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_EXPLODE")})),M=new ai(v,p,u);break;case"btnAnnotation":(e=y.addButton({id:"btnAnnotation"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_ANNOTATION")}));break;case"btnFitToView":(e=y.addButton({id:"btnFitToView"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_FITTOVIEW")}));break;case"btnResetCamera":(e=y.addButton({id:"btnResetCamera"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_RESETCAMERA")}));break;case"btnFullScreen":(e=y.addButton({id:"btnFullScreen"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_FULLSCREEN")}));break;case"btnLineVisibility":(e=A.viewer.getLinesVisibility()?y.addButton({id:"btnLineInVisible"+x,className:i,callbackEvent:r,float:g}):y.addButton({id:"btnLineVisible"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_HIDELINES")}));break;case"btnSelect":(e=y.addButton({id:"btnSelect"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_SELECT")}));break;case"btnDrag":(f=y.addButton({id:"btnDrag"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DRAG")})),(m=new ve.Toolbar({id:"dragOpToolbar",className:"toolbar",callbackEvent:r})).setVisibility(!1),v.getToolBarAutoHideFlag()&&m.setOpacity(_e.toolbarOpacity),f.setPopupDialog(m),(e=m.addButton({id:"btnDragOp_Select"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DRAGOP_SELECT")})),(e=m.addButton({id:"btnDragOp_Restore"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DRAGOP_RESTORE")})),(e=m.addButton({id:"btnDragOp_Hide"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DRAGOP_HIDE")})),(e=m.addButton({id:"btnDragOp_ReverseVisibility"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DRAGOP_REVERSEVISIBILITY")})),(e=m.addButton({id:"btnDragOp_ShowAll"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DRAGOP_SHOWALL")})),v.container.appendChild(m.domElement);break;case"btnDispStyle":(I=y.addButton({id:"btnDispStyle"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DISPSTYLE")})),(T=new ve.Toolbar({id:"dispStyleToolbar",className:"toolbar",callbackEvent:r})).setVisibility(!1),v.getToolBarAutoHideFlag()&&T.setOpacity(_e.toolbarOpacity),I.setPopupDialog(T),(e=T.addButton({id:"btnDispStyle_ShadedEdges"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DISPSTYLE_SHADEDEDGES")})),(e=T.addButton({id:"btnDispStyle_Shaded"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DISPSTYLE_SHADED")})),(e=T.addButton({id:"btnDispStyle_HiddenRemoved"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DISPSTYLE_HIDDENREMOVED")})),(e=T.addButton({id:"btnDispStyle_HiddenVisible"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DISPSTYLE_HIDDENVISIBLE")})),(e=T.addButton({id:"btnDispStyle_Wireframe"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_DISPSTYLE_WIREFRAME")})),v.container.appendChild(T.domElement);break;case"btnSectionView":(e=y.addButton({id:"btnSectionView"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_SECTIONVIEW")}));break;case"btnBoxSectionView":(e=y.addButton({id:"btnBoxSectionView"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_BOXSECTIONVIEW")}));break;case"btnAnnotationSetting":(e=y.addButton({id:"btnAnnotationSettingShow"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("btnAnnotationSettingHide")}));break;case"btnLightEditor":(e=y.addButton({id:"btnLightEditor"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_LIGHTEDITOR")}));break;case"btnAddComment":(e=y.addButton({id:"btnAddComment"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:"文字注记"}));break;case"btnMeasure":(e=y.addButton({id:"btnMeasure"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_MEASURE")}));break;case"btnModelBrowser":(e=y.addButton({id:"btnModelBrowser"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_MODELBROWSER")}));break;case"btnPerspective":(e=y.addButton({id:"btnPerspective"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_PERSPECTIVE")})),e.setBorder("1px solid rgba(150,150,150,0.8)"),e.setBgColor(_e.toolbarButtonClickedBkgColor);break;case"btnZoomWindow":(e=y.addButton({id:"btnZoomWindow"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_ZOOMWINDOW")}));break;case"btnSnap":(e=y.addButton({id:"btnSnap"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:"Snap"}));break;case"btnOperball":(e=y.addButton({id:"btnOperball"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_OPERATING_BALL")}))}else void 0!==u.hasViewOperationUI&&!u.hasViewOperationUI||((e=y.addButton({id:"btnOrbit"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_ORBIT")})),v.onOpChanged({target:e}),(e=y.addButton({id:"btnPan"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_PAN")})),(e=y.addButton({id:"btnZoom"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_ZOOM")}))),u.hasExplosionUI&&((p=y.addButton({id:"btnExplode"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_EXPLODE")})),M=new ai(v,p,u)),u.hasAnnotationUI&&(e=y.addButton({id:"btnAnnotation"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_ANNOTATION")})),(e=y.addButton({id:"btnFitToView"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_FITTOVIEW")})),(e=y.addButton({id:"btnResetCamera"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_RESETCAMERA")})),u.hasFullScreenUI&&(e=y.addButton({id:"btnFullScreen"+x,className:i,callbackEvent:r,float:g})).setTooltip(new ve.Tooltip({className:"tooltip",text:Se.translateString("IDS_FULLSCREEN")}));function r(e){if(!_e.enableBroadcast||_e.broadcastMajor){var t=e.target.domElement.id;if(A.viewer.controls instanceof Fe)switch(t){case"tbOperator":C(e);break;case"btnPan"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new N(A.viewer)),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnZoom"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new hi(A.viewer)),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnSelect"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new ui(A.viewer)),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnLoadModel"+x:R(e);break;case"btnSnap"+x:!function(e){var t=e.event.type;e.target.subElements.tooltip;switch(t){case"click":case"touchstart":var n=A.viewer.getSvgViewportInfo(),i=A.viewer.getSvgScreenCapture(function(e){A.viewer.dispatchEvent({type:"snapEvent",cameraInfo:n,imgData:i})});break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnResetCamera"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.resetSvgViewBox();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e)}else if(A.viewer.controls instanceof He)switch(t){case"tbOperator":C(e);break;case"dragOpToolbar":var n=e;if((!_e.enableBroadcast||_e.broadcastMajor)&&A.viewer.getToolBarAutoHideFlag()){var i=n.event.type,r=n.target;switch(i){case"mouseenter":r.deleteOpacity();break;case"mouseleave":r.setOpacity(_e.toolbarOpacity);break;case"mouseover":r.deleteOpacity();break;case"mouseout":r.setOpacity(_e.toolbarOpacity)}}break;case"btnOrbit"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new Wn(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnPan"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new Yn(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnZoom"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new Xn(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnSelect"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new ci(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnView"+x:var n=e,i=n.event.type,o=n.target.domElement,a=n.target.subElements.popupElement;switch(i){case"mouseenter":var s=Se.getStyle(a.domElement,"margin"),s=o.offsetLeft-parseInt(s),l=A.viewer.tlbOperator.domElement.offsetHeight;a.setLeft(s),a.setBottom(l),a.setVisibility(!0);break;case"mouseleave":Se.onAutoHide(a)}break;case"btnFitToView"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.zoomExtents();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnResetCamera"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.onResetCamera();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnSetting"+x:!function(e){switch(e.event.type){case"click":case"touchstart":break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnLoadModel"+x:R(e);break;case"btnSnap"+x:O(e);break;case"btnOperball"+x:!function(e){var t=e.event.type;e.target.subElements.tooltip;switch(t){case"click":case"touchstart":"OpBall"==A.viewer.controls.getOperator().type?A.viewer.controls.setOperator(new Wn(A.viewer)):A.viewer.controls.setOperator(new we(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnMeasure"+x:!function(e){var t=e.event.type;e.target.subElements.tooltip;switch(t){case"click":case"touchstart":var n=new Me(A.viewer);A.viewer.controls.setOperator(n),null!=b&&b.dialog.getVisibility()?(b.show(!1),A.viewer.controls.setOperator(new Wn(A.viewer)),A.viewer.clipPlaneManager.isSectionViewEnabled()&&A.viewer.clipPlaneManager.onOpenClipControl()):(b=new sn(A.viewer),A.viewer.Optoolbar.setMeasureDlg(b),b.show(!0),A.viewer.clipPlaneManager.onCloseClipControl()),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnExplode"+x:var d=e,c=d.event.type,h=d.target.subElements.tooltip,u=(d.target.domElement,d.target.subElements.popupDialog);switch(c){case"click":case"touchstart":A.viewer.isSectionViewEnabled()&&A.viewer.onSectionView(!1),u.setVisibility(!u.style.visibility),u.style.visibility?(d.target.domElement.style.backgroundColor=_e.toolbarButtonClickedBkgColor,_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render()):(d.target.domElement.style.backgroundColor="",M&&(0==M.getExplodeDlgValue()?A.viewer.render():M.resetExplosion()));break;case"mouseenter":A.viewer.getShowToolTipFlag()&&h.setVisibility(!0);break;case"mouseleave":A.viewer.getShowToolTipFlag()&&h.setVisibility(!1);break;case"mouseover":A.viewer.getShowToolTipFlag()&&h.setVisibility(!0);break;case"mouseout":A.viewer.getShowToolTipFlag()&&h.setVisibility(!1)}break;case"btnFullScreen"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.executeFullScreen();break;default:if(!A.viewer.getShowToolTipFlag(e.target.subElements.tooltip))return;Se.onShowTooltip(e)}}(e);break;case"btnAnnotation"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new li(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnLineVisibility"+x:case"btnLineVisible"+x:case"btnLineInVisible"+x:L(e);break;case"btnDrag"+x:!function(e){switch(e.event.type){case"click":case"touchstart":var t;"OpDrag"==A.viewer.controls.getOperator().type?(A.viewer.controls.setOperator(new Wn(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),t={target:y.getChildElement("btnOrbit")},A.viewer.onOpChanged(t)):(A.viewer.controls.setOperator(new ye(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e)),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDragOp_Select"+x:!function(e){switch(e.event.type){case"click":case"touchstart":var t=w;null!=t&&(t.setBorder(""),t.setBgColor("")),e.target.setBorder("1px solid rgba(150,150,150,0.8)"),e.target.setBgColor(_e.toolbarButtonClickedBkgColor),A.viewer.onSelectAndMoveModel(!0),w=e.target,_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDragOp_Restore"+x:!function(e){switch(e.event.type){case"click":case"touchstart":var t=w;null!=t&&(t.setBorder(""),t.setBgColor("")),e.target.setBorder("1px solid rgba(150,150,150,0.8)"),e.target.setBgColor(_e.toolbarButtonClickedBkgColor),A.viewer.onSelectAndRestoreModel(!0),w=e.target,_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDragOp_Hide"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.onHideModel();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDragOp_ReverseVisibility"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.onReverseVisibleAndHidingModel();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDragOp_ShowAll"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.onShowAllModel();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnSectionView"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.clipBoxManager.isSectionBoxEnabled()&&A.viewer.onBoxSectionView(!1);var t=A.viewer.isSectionViewEnabled(),n=(A.viewer.onSectionView(!t),e.target);null!=n&&(n.setBorder(""),n.setBgColor("")),t||(e.target.setBorder("1px solid rgba(150,150,150,0.8)"),e.target.setBgColor(_e.toolbarButtonClickedBkgColor));break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnBoxSectionView"+x:!function(e){switch(e.event.type){case"click":case"touchstart":var t=A.viewer.isSectionViewEnabled();t&&A.viewer.onSectionView(!1);A.viewer.clipBoxManager.isSectionBoxEnabled()?A.viewer.onBoxSectionView(!1):A.viewer.onBoxSectionView(!0);var n=e.target;null!=n&&(n.setBorder(""),n.setBgColor("")),t||(e.target.setBorder("1px solid rgba(150,150,150,0.8)"),e.target.setBgColor(_e.toolbarButtonClickedBkgColor));break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnAnnotationSettingShow"+x:case"btnAnnotationSettingHide"+x:F(e);break;case"btnLightEditor"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.onLightEditor();v.getLightControls();for(var t=0;t<E.length;t++)E[t].run();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnAddComment"+x:var p=e,c=p.event.type;switch(p.target.subElements.tooltip,c){case"click":case"touchstart":A.viewer.controls.setOperator(new si(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(p);break;default:A.viewer.getShowToolTipFlag()&&Se.onShowTooltip(p)}break;case"btnModelBrowser"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.onModelBrowser();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnPerspective"+x:!function(e){switch(e.event.type){case"click":case"touchstart":var t=A.viewer.camera.IsPerspective(),n=(t?A.viewer.camera.toOrthographic():A.viewer.camera.toPerspective(),A.viewer.render(),e.target);null!=n&&(n.setBorder(""),n.setBgColor(""),t||(n.setBorder("1px solid rgba(150,150,150,0.8)"),n.setBgColor(_e.toolbarButtonClickedBkgColor)));break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnZoomWindow"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.controls.setOperator(new Qn(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"dispStyleToolbar":var f=e;if((!_e.enableBroadcast||_e.broadcastMajor)&&A.viewer.getToolBarAutoHideFlag()){var m=f.event.type,g=f.target;switch(m){case"mouseenter":g.deleteOpacity();break;case"mouseleave":g.setOpacity(_e.toolbarOpacity);break;case"mouseover":g.deleteOpacity();break;case"mouseout":g.setOpacity(_e.toolbarOpacity)}}break;case"btnDispStyle"+x:!function(e){switch(e.event.type){case"click":case"touchstart":P=e.target,H(B=void 0===B||!1===B),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDispStyle_ShadedEdges"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.setRenderMode("shadedWithEdges"),D(e.target,S),S=e.target,H(!1),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDispStyle_Shaded"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.setRenderMode("shaded"),D(e.target,S),S=e.target,H(!1),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDispStyle_HiddenRemoved"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.setRenderMode("hiddenLineRemove"),D(e.target,S),S=e.target,H(!1),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDispStyle_HiddenVisible"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.setRenderMode("hiddenLineVisible"),D(e.target,S),S=e.target,H(!1),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnDispStyle_Wireframe"+x:!function(e){switch(e.event.type){case"click":case"touchstart":A.viewer.setRenderMode("wireframe"),D(e.target,S),S=e.target,H(!1),_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}(e);break;case"btnSnap"+x:O(e)}}}function C(e){if((!_e.enableBroadcast||_e.broadcastMajor)&&A.viewer.getToolBarAutoHideFlag()){var t=e.event.type,n=e.target;switch(t){case"mouseenter":n.deleteOpacity();break;case"mouseleave":n.setOpacity(_e.toolbarOpacity);break;case"mouseover":n.deleteOpacity();break;case"mouseout":n.setOpacity(_e.toolbarOpacity)}}}function R(e){var t=e.event.type,n=e.target.subElements.tooltip,i=e.target.domElement,r=e.target.subElements.popupDialog;switch(t){case"click":case"touchstart":var o=A.viewer.tlbOperator.domElement,a=o.offsetLeft+i.offsetLeft,s=parseInt(Se.getStyle(o,"padding-top"))+parseInt(Se.getStyle(o,"padding-bottom"))+parseInt(Se.getStyle(o,"border-top-width"))+parseInt(Se.getStyle(o,"border-bottom-width"))+parseInt(Se.getStyle(o,"margin-top"))+parseInt(Se.getStyle(o,"margin-bottom")),o=(parseInt(Se.getStyle(o,"margin-bottom")),o.offsetHeight+s);r.setLeft(a),r.setBottom(o),r.setVisibility(!r.style.visibility);break;case"mouseenter":A.viewer.getShowToolTipFlag()&&n.setVisibility(!0);break;case"mouseleave":A.viewer.getShowToolTipFlag()&&n.setVisibility(!1)}}function O(e){var t=e.event.type;e.target.subElements.tooltip;switch(t){case"click":case"touchstart":A.viewer.controls.setOperator(new pi(A.viewer)),A.viewer.controls.addEventListener("change",A.viewer.render),A.viewer.onOpChanged(e);break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}function L(e){switch(e.event.type){case"click":case"touchstart":A.viewer.getLinesVisibility()?A.viewer.setLinesVisibility(!1):A.viewer.setLinesVisibility(!0),A.viewer.getLinesVisibility()?(e.target.domElement.id="btnLineInVisible",e.target.subElements.tooltip.domElement.innerHTML=Se.translateString("IDS_HIDELINES")):(e.target.domElement.id="btnLineVisible",e.target.subElements.tooltip.domElement.innerHTML=Se.translateString("IDS_SHOWLINES"));break;default:if(A.viewer.getLinesVisibility()?e.target.subElements.tooltip.domElement.innerHTML=Se.translateString("IDS_HIDELINES"):e.target.subElements.tooltip.domElement.innerHTML=Se.translateString("IDS_SHOWLINES"),!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}function D(e,t){t&&(t.setBorder(""),t.setBgColor("")),e.setBorder("1px solid rgba(150,150,150,0.8)"),e.setBgColor(_e.toolbarButtonClickedBkgColor)}function H(e){B=e=null!=e&&e,T.setVisibility(e),null!=P&&(e?(P.setBorder("1px solid rgba(150,150,150,0.8)"),P.setBgColor(_e.toolbarButtonClickedBkgColor)):(P.setBorder(""),P.setBgColor("")))}function F(e){switch(e.event.type){case"click":case"touchstart":(t=!t)?(e.target.domElement.id="btnAnnotationSettingShow",e.target.subElements.tooltip.domElement.innerHTML=Se.translateString("IDS_ANNOTATIONSETTINGHIDE")):(e.target.domElement.id="btnAnnotationSettingHide",e.target.subElements.tooltip.domElement.innerHTML=Se.translateString("IDS_ANNOTATIONSETTINGSHOW")),t?A.viewer.annotationsManager&&A.viewer.annotationsManager.getAnnotationJsonArray()&&A.viewer.showAnnotations(A.viewer.annotationsManager.getAnnotationJsonArray()):A.viewer.annotationsManager&&(A.viewer.annotationsManager.removeAllAnnotations(),_e.enableBroadcast)&&_e.broadcastMajor&&A.viewer.render(),!A.viewer.annotationsManager&&_e.enableBroadcast&&_e.broadcastMajor&&A.viewer.render();break;default:if(e.target.subElements.tooltip.domElement.innerHTML=t?Se.translateString("IDS_ANNOTATIONSETTINGHIDE"):Se.translateString("IDS_ANNOTATIONSETTINGSHOW"),!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}y.showButton=function(e,t){this.getChildElement(e).domElement.parentElement.style.display=t?"":"none"},y.onResize=function(e,t){y.setLeft(0);var n,i,r,o,a,s,l=y.domElement.offsetWidth,d=y.domElement.offsetHeight,c=0,h=0;switch(u.toolbarVerticalAlign){case"top":h=t-d-10;break;case"center":h=(t-d-10)/2;break;default:h=0}switch(u.toolbarHorizontalAlign){case"left":c=0;break;case"right":c=e-l-10;break;default:c=(e-l-10)/2}y.setLeft(c),y.setBottom(h),0<e&&0<t&&A.viewer.toolbarInitialVisibility&&y.setVisibility(!0),p&&((n=y.getChildElementIndex(p.domElement.id))<0&&(n=0),o=r=0,g?(i=(d-2)/y.childElements.length,s=p.subElements.popupDialog.domElement.getBoundingClientRect(),r=c+l+6+4,o=h+(y.childElements.length-n)*i+6-s.height,null!=u.toolbarHorizontalAlign&&"right"==u.toolbarHorizontalAlign&&(r=c-s.width)):(r=c+n*(a=(l-2)/y.childElements.length)+6,o=h+d+6+4,null!=u.toolbarVerticalAlign&&"top"==u.toolbarVerticalAlign&&(o=h-(s=p.subElements.popupDialog.domElement.getBoundingClientRect()).height-4),null!=u.toolbarHorizontalAlign&&"right"==u.toolbarHorizontalAlign&&(r=r-(s=p.subElements.popupDialog.domElement.getBoundingClientRect()).width+a)),p.subElements.popupDialog.dispatchEvent({type:"resize",left:r,bottom:o})),f&&m&&((n=y.getChildElementIndex(f.domElement.id))<0&&(n=0),o=r=0,g?(i=(d-2)/y.childElements.length,s=f.subElements.popupDialog.domElement.getBoundingClientRect(),r=c+l+6+4,o=h+(y.childElements.length-n)*i+6-s.height,null!=u.toolbarHorizontalAlign&&"right"==u.toolbarHorizontalAlign&&(r=c-s.width)):(r=c+n*(a=(l-2)/y.childElements.length)-.5*a-5+6,o=h+d+6+4,null!=u.toolbarVerticalAlign&&"top"==u.toolbarVerticalAlign&&(s=f.subElements.popupDialog.domElement.getBoundingClientRect(),o=h-d-6-4),null!=u.toolbarHorizontalAlign&&"right"==u.toolbarHorizontalAlign&&(r=r-(s=f.subElements.popupDialog.domElement.getBoundingClientRect()).width+a)),m.setLeft(r),m.setBottom(o)),y.resizeDispStyleToolbar(I,T,l,d,c,h)},y.resizeDispStyleToolbar=function(e,t,n,i,r,o){var a,s,l,d,c;e&&t&&((a=y.getChildElementIndex(e.domElement.id))<0&&(a=0),l=s=0,g?(d=(i-2)/y.childElements.length,c=e.subElements.popupDialog.domElement.getBoundingClientRect(),s=r+n+6+4,l=o+(y.childElements.length-a)*d+6-c.height,null!=u.toolbarHorizontalAlign&&"right"==u.toolbarHorizontalAlign&&(s=r-c.width)):(s=r+a*(d=(n-2)/y.childElements.length)-.5*d-5+6,l=o+i+6+4,null!=u.toolbarVerticalAlign&&"top"==u.toolbarVerticalAlign&&(c=e.subElements.popupDialog.domElement.getBoundingClientRect(),l=o-i-6-4),null!=u.toolbarHorizontalAlign&&"right"==u.toolbarHorizontalAlign&&(s=s-(c=e.subElements.popupDialog.domElement.getBoundingClientRect()).width+d)),t.setLeft(s),t.setBottom(l))},this.addButton=function(e,t){y.addButton({img:e.backGroundImage,id:e.id,className:i,float:g,callbackEvent:function(e){switch(e.event.type){case"click":case"touchstart":t&&t();break;default:if(!A.viewer.getShowToolTipFlag())return;Se.onShowTooltip(e)}}}).setTooltip(new ve.Tooltip({className:"tooltip",text:e.tooltip}));var e=this.viewer.container.getBoundingClientRect(),n=e.width,e=e.height;y.onResize(n,e)},this.addLightEditBtnListener=function(e){E.push(e)},this.resetExplosion=function(){M&&M.resetExplosion()},this.getExplodeDlgVisibility=function(){return!!M&&M.dialog.getVisibility()},this.getExplodeDlgValue=function(){return M?M.getExplodeDlgValue():0},this.setExplodeDlgVisibility=function(e){M&&M.dialog.getVisibility()!=e&&M.dialog.setVisibility(e)},this.setExplodeDlgValue=function(e){M&&M.getExplodeDlgValue()!=e&&M.setExplodeDlgValue(e)},this.onOpChanged=function(e){var t;m&&e&&e.target&&(e.target.domElement.id=="btnDrag"+x?m.setVisibility(!0):(m.setVisibility(!1),null!=(t=w)&&(t.setBorder(""),t.setBgColor("")),w=void 0)),b&&e&&e.target&&e.target.domElement.id!="btnMeasure"+x&&e.target.domElement.id!="btnOperball"+x&&(b.release(),b=void 0)},this.getDispStyleToolbar=function(){return T},this.getMeasureDlg=function(){return b},this.setMeasureDlg=function(e){b=e},this.getAnnotationSetting=function(){return t},this.setVisibility=function(e){y&&y.setVisibility(e),0==e?(m&&(m.preVisibility=m.getVisibility(),m.setVisibility(!1)),M&&(M.preVisibility=M.dialog.getVisibility(),M.dialog.setVisibility(!1)),T&&(T.preVisibility=T.getVisibility(),T.setVisibility(!1))):(m&&(1==m.preVisibility&&m.setVisibility(!0),m.preVisibility=void 0),M&&(1==M.preVisibility&&M.dialog.setVisibility(!0),M.preVisibility=void 0),T&&(1==T.preVisibility&&T.setVisibility(!0),T.preVisibility=void 0))},this.getVisibility=function(){return!!y&&y.getVisibility()},this.getDragToolbarBtnSelected=function(){return w?w.domElement.id:null},this.setDragToolbarBtnSelected=function(e){var t;null==e||w&&e==w.domElement.id||(w&&(w.setBorder(""),w.setBgColor("")),m&&(t=m.getChildElement(e))&&(t.setBorder("1px solid rgba(150,150,150,0.8)"),t.setBgColor(_e.toolbarButtonClickedBkgColor)),w=t)}}function kn(e){this.viewer=e,this.renderTarget=null,this.bkgDepthRGBAMat=null,this.bkgDepthRGBAMatCopy=null,this.bodyIdMat=null,this.convertPointScreen=function(e,t){var n,i,r,o,a,s,l,d,c,h,u,p,f,m=this.viewer.renderer.domElement,g=this.viewer.renderer.getPixelRatio();return e&&2<=e.length?(this.renderTarget||(this.renderTarget=new THREE.WebGLRenderTarget(m.width,m.height,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1}),this.renderTarget.texture.generateMipmaps=!1),n=this.renderTarget,this.bkgDepthRGBAMat||(this.viewer.ndsModel?(this.bkgDepthRGBAMat=new THREE.ShaderMaterial({vertexShader:V.vertexShader,fragmentShader:V.fragmentShader}),this.bkgDepthRGBAMatCopy=(new this.bkgDepthRGBAMat.constructor).copy(this.bkgDepthRGBAMat)):(this.bkgDepthRGBAMat=new THREE.ShaderMaterial({vertexShader:V.vertexShader,fragmentShader:V.fragmentShader}),this.bkgDepthRGBAMat.side=THREE.DoubleSide)),i=this.viewer.scene.overrideMaterial,r=this.viewer.renderer.getClearColor(this.viewer.oldClearColor).clone(),o=this.viewer.renderer.getClearAlpha(),this.viewer.scene.overrideMaterial=this.bkgDepthRGBAMat,this.viewer.renderer.setClearColor(16777215),this.viewer.lightControls&&this.viewer.scene.remove(this.viewer.lightControls._scene),this.viewer.ndsModel&&(this.viewer.ndsModel.setDirty(),this.viewer.ndsModel.setDrawMode(this.viewer.ndsModel.SHADED),this.viewer.scene.children.push(this.viewer.ndsModel),this.viewer.ndsModel.setOverrideMaterial(this.bkgDepthRGBAMat,this.bkgDepthRGBAMatCopy,!1)),this.viewer.renderer.render(this.viewer.scene,this.viewer.camera,n,!0,!0),this.viewer.scene.overrideMaterial=i,this.viewer.ndsModel&&this.viewer.ndsModel.setOverrideMaterial(null,null,!1),(p=new THREE.Matrix4).multiplyMatrices(this.viewer.camera.matrixWorld,p.getInverse(this.viewer.camera.projectionMatrix)),a=[],s="",l=null,(u=new Uint8Array(4))[0]=u[1]=u[2]=u[3]=0,this.viewer.renderer.readRenderTargetPixels(n,e[0]*g,n.height-e[1]*g,1,1,u),(d=253<u[0]&&253<u[1]&&253<u[2]&&253<u[3])||(u=u[0]*(f=255/256)/16777216+u[1]*f/65536+u[2]*f/256+u[3]*f,u=2*(u/=255)-1,u-=4e-8*u,(f=new THREE.Vector3).set(e[0]*g/m.width*2-1,2*-(e[1]*g/m.height)+1,u),f.applyMatrix4(p),a.push(f.x),a.push(f.y),a.push(f.z)),d||null!=t&&1!=t||(c=10,h=[],this.viewer.ndsModel?this.bodyIdMat||(this.bodyIdMat=new THREE.MeshBasicMaterial):this.viewer.scene.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e.materialRaycasterRecord=e.material,e instanceof THREE.Line||e instanceof THREE.LineSegments?e.material=new THREE.LineBasicMaterial:(e.material=new THREE.MeshBasicMaterial,e.material.side=THREE.DoubleSide),e.material.color.setHex(c),h[c]=e,c+=10)}),this.viewer.scene.overrideMaterial=null,this.viewer.ndsModel&&(this.viewer.ndsModel.setDirty(),this.viewer.ndsModel.setDrawMode(this.viewer.ndsModel.SHADED),this.viewer.scene.children.push(this.viewer.ndsModel),this.viewer.ndsModel.setOverrideMaterial(this.bodyIdMat,null,!0)),this.viewer.renderer.render(this.viewer.scene,this.viewer.camera,n,!0,!0),this.viewer.scene.overrideMaterial=i,this.viewer.ndsModel&&this.viewer.ndsModel.setOverrideMaterial(null,null,!1),this.viewer.scene.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&e.materialRaycasterRecord&&(e.material&&e.material.dispose(),e.material=e.materialRaycasterRecord,e.materialRaycasterRecord=void 0)}),(m=new Uint8Array(4))[0]=m[1]=m[2]=m[3]=0,this.viewer.renderer.readRenderTargetPixels(n,e[0]*g,n.height-e[1]*g,1,1,m),d=253<m[0]&&253<m[1]&&253<m[2])||(u=m[0]<<16|m[1]<<8|m[2],this.viewer.ndsModel?(p=this.viewer.ndsModel.getBodyNode(u/10))&&(s=(l=p).uuid):h[u]&&(s=(l=h[u]).uuid)),this.viewer.renderer.setRenderTarget(null),this.viewer.renderer.setClearColor(r,o),this.viewer.lightControls&&this.viewer.scene.add(this.viewer.lightControls._scene),this.viewer.render(),f=null,0<a.length?{coords:a,locationObjectUUID:s,locationObject:l}:f):null}}function Un(e){var t=this,n=(this.viewer=e,new ve.Element({className:"stater"})),i=(n.setVisibility(!1),e.container.appendChild(n.domElement),new ve.Element({className:"stater-title",text:"Loading..."})),r=(n.domElement.appendChild(i.domElement),new ve.Button({className:"stater-button",text:"Cancel"}));function o(e){t.dispatchEvent({type:"cancel"})}n.domElement.appendChild(r.domElement),r.domElement.addEventListener("click",o,!1),this.show=function(e){n.setVisibility(e),e||r.setVisibility(e)},this.setText=function(e){i.setText(e)},this.setBtnCancelShow=function(e){r.setVisibility(e)}}function Gn(e){var t=this,n=(this.viewer=e,new ve.Menu({id:"menuView",className:"menu",callbackEvent:i}));function i(e){switch(n.setVisibility(!1),e.target.domElement.id){case"itemIsolate":"click"===e.event.type&&t.viewer.isolateSelectedObjects();break;case"itemHide":"click"===e.event.type&&t.viewer.hideSelectedObjects();break;case"itemShowAll":"click"===e.event.type&&t.viewer.showAllModel();break;case"itemProperty":"click"===e.event.type&&t.viewer.getSelectedObjectProperty(function(e){null!=e&&alert(JSON.stringify(e))});break;case"itemTransparent":"click"===e.event.type&&t.viewer.transparentSelectedObjects()}}n.setVisibility(!1),e.container.appendChild(n.domElement),(e.menuView=n).addItem({id:"itemIsolate",text:Se.translateString("IDS_RMB_ISOLATE"),className:"menuItem",callbackEvent:i}),n.addItem({id:"itemHide",text:Se.translateString("IDS_RMB_HIDE"),className:"menuItem",callbackEvent:i}),n.addItem({id:"itemShowAll",text:Se.translateString("IDS_RMB_SHOWALL"),className:"menuItem",callbackEvent:i}),n.addItem({id:"itemTransparent",text:"透明",className:"menuItem",callbackEvent:i}),n.addItem({id:"itemProperty",text:Se.translateString("IDS_RMB_PROPERTY"),className:"menuItem",callbackEvent:i})}function zn(e,t){this.viewer=e;var n="waiter_"+Date.now(),i=((n=new ve.Element({className:"waiter",id:n})).setVisibility(!1),new ve.Element({className:"bounce1"})),r=new ve.Element({className:"bounce2"}),o=new ve.Element({className:"bounce3"});void 0!==t&&(i.setBgColor(t),r.setBgColor(t),o.setBgColor(t)),n.addSubElement(i),n.addSubElement(r),n.addSubElement(o),e.container.appendChild(n.domElement),e.waiter=n}function Ee(e){g.call(this,e),this.type="OpAnnotationNew",this.mode="normal",this.oldmode="normal";var n=this,i=(this.POINTSIZE=3,this.materialPoint=new THREE.MeshBasicMaterial({color:"#FF6302",opacity:1,transparent:!1,depthTest:!1,depthWrite:!1}),this.SelectmaterialPoint=new THREE.MeshBasicMaterial({color:16761600,opacity:1,transparent:!1,depthTest:!1,depthWrite:!1}),this.rootObject=new THREE.Object3D,this.AnnotationScene=new THREE.Scene,this.AnnotationScene.add(this.rootObject),document.createElement("input"));i.id="picLoad",i.type="file",i.accept="image/jpeg, image/png, image/gif,image/jpg,image/bmp",i.width=0,i.height=0,document.body.appendChild(i),i.addEventListener("change",function(e){var t=e.target.files[0],e=t.name.substring(t.name.lastIndexOf(".")).toLowerCase();[".jpeg",".png",".gif",".jpg",".bmp"].includes(e)?t&&((e=new FileReader).onload=function(e){e=e.target.result;n.createElement(e,t.name),i.value=""},e.readAsDataURL(t)):(n.viewer.dispatchEvent({type:"errorMsgTips",msg:"格式不支持"}),i.value=null)}),this._isDragging=!1,this._isResizing=!1,this._currentTarget=null,this._zindex=Se.isMobileDevice()?2:7,this._tabIndex=90,this.startX,this.startY,this.startWidth,this.startHeight,this.Textbox=null,this.intersectPnt=null,this.picSelectID=0,this.selectIDs=[],this.unvisibleIDs=[],this.enableMove=!0,this.dpr=this.viewer.renderer.getPixelRatio(),this.materialLine=new THREE.MeshBasicMaterial({color:8190976,opacity:.8,transparent:!0,depthTest:!1,depthWrite:!1,side:THREE.DoubleSide}),this.TextContents=[],this.PicContents=[],this.MoveTarget=null,this.AnnotationShow=!0,this.useOffsetMatrix=!0,this.prompt=document.getElementById("op-prompt"),this.prompt||(this.prompt=document.createElement("div"),this.prompt.id="op-prompt"),Se.isMobileDevice()?this.prompt.className="app-alert":this.prompt.className="pc-alert",e.container.appendChild(this.prompt),this.Popup=null}(a.prototype=Object.create(h.prototype)).OperatorStart=function(e){this.measureType=e,this.allowType=["face"],this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTMESH)},a.prototype.onNMouseMove=function(e,t){var n=new THREE.Vector3(e,t,0);this.OpMeasure.unsteady?this.changeMeasureDistance(n):this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj||(this.WallThicknessMeasure(e,t,!0,this.allowType),this.updateWallThicknessMeasure(!0))},a.prototype.onLMouseClick=function(e,t,n){new THREE.Vector3(e,t,0);this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj||(this.WallThicknessMeasure(e,t,!1,this.allowType),this.updateWallThicknessMeasure(!1))},a.prototype.WallThicknessMeasure=function(e,t,n,i){(e=this.doRaycasterPick(e,t,!1))&&0!=e.length?(t=e[0])&&(n?(e=this.getSelectInfoFromIntersect(t))&&(-1==i.indexOf(e.topolType)?this.WallThicknessClearPreSelect():null!=this.distanceInfo.preSelInfo&&this.isTwoTopolInfoTheSame(this.distanceInfo.preSelInfo,e)||(this.distanceInfo.preSelInfo=e,this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null))):((n=this.getSelectInfoFromIntersect(t))&&-1!=i.indexOf(n.topolType)&&(null==this.distanceInfo.firstSelInfo?this.distanceInfo.firstSelInfo=n:this.distanceInfo.firstSelInfo&&(this.isTwoTopolInfoTheSame(this.distanceInfo.firstSelInfo,n)?(this.distanceInfo.firstSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null),this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTMESH),this.WallThicknessClearPreSelect()):"cylinder"==this.distanceInfo.firstSelInfo.type&&"cylinder"==n.type?(this.CalcCircleWallThickness(this.distanceInfo.firstSelInfo,n)||this.CalcWallThickness(this.distanceInfo.firstSelInfo,n))&&(this.distanceInfo.secondSelInfo=n,this.distanceInfo.firstSelInfo.type="wallFace",this.distanceInfo.secondSelInfo.type="wallFace"):"plane"==this.distanceInfo.firstSelInfo.type&&"plane"==n.type?(this.CalcPlaneWallThickness(this.distanceInfo.firstSelInfo,n)||this.CalcWallThickness(this.distanceInfo.firstSelInfo,n))&&(this.distanceInfo.secondSelInfo=n,this.distanceInfo.firstSelInfo.type="wallFace",this.distanceInfo.secondSelInfo.type="wallFace"):this.CalcWallThickness(this.distanceInfo.firstSelInfo,n)&&(this.distanceInfo.secondSelInfo=n,this.distanceInfo.firstSelInfo.type="wallFace",this.distanceInfo.secondSelInfo.type="wallFace"))),this.WallThicknessClearPreSelect())):this.WallThicknessClearPreSelect()},a.prototype.updateWallThicknessMeasure=function(e){var t;this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj?this.WallThicknessClearPreSelect():e?this.distanceInfo.preSelInfo&&!this.distanceInfo.preSelObj&&"face"==this.distanceInfo.preSelInfo.topolType&&(t=this.createFace(this.distanceInfo.preSelInfo,!0))&&(this.OpMeasure.rootObject.add(t),this.distanceInfo.preSelObj=t):(this.distanceInfo.firstSelInfo&&!this.distanceInfo.firstSelObj&&(this.WallThicknessClearPreSelect(),t=null,(t="face"==this.distanceInfo.firstSelInfo.topolType?this.createFace(this.distanceInfo.firstSelInfo,!1):t)&&(this.OpMeasure.rootObject.add(t),this.distanceInfo.firstSelObj=t),this.OpMeasure.PostInfo(ve.INFOTYPE.SECONDMESH)),this.distanceInfo.secondSelInfo&&!this.distanceInfo.secondSelObj&&(this.WallThicknessClearPreSelect(),t=null,t="face"==this.distanceInfo.secondSelInfo.topolType?this.createFace(this.distanceInfo.secondSelInfo,!1):t)&&(this.OpMeasure.rootObject.add(t),this.distanceInfo.secondSelObj=t),this.distanceInfo.firstSelObj&&this.distanceInfo.secondSelObj&&(_e.enableBroadcast&&_e.broadcastMajor&&this.OpMeasure.addmeasureTimes(),this.createAndShow3DDistanceDimension(null,!0),this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.OpMeasure.rootObject.remove(this.distanceInfo.secondSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.secondSelObj=null,this.distanceInfo.firstSelInfo=null,this.distanceInfo.secondSelInfo=null,this.OpMeasure.PostInfo(ve.INFOTYPE.FIRSTMESH)))},a.prototype.IntersectCylinderPoints=function(e,t,n,i){for(var r=e.geometry,o=n.geometry,a=r.index,s=o.index,l=e.indexRange.concat(),d=(l[0]+=r.drawRange.start/3,l[1]+=r.drawRange.start/3,n.indexRange.concat()),c=(d[0]+=o.drawRange.start/3,d[1]+=o.drawRange.start/3,new THREE.Vector3),h=new THREE.Vector3,u=new THREE.Vector3,p=new THREE.Vector3,f=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,v=new THREE.Vector3,A=new THREE.Vector3,y=(new THREE.Triangle,new THREE.Triangle),E=(new THREE.Vector3,new THREE.Vector3),M=l[0];M<=l[1];M++){var w=a.getX(T=3*M),b=a.getX(1+T),x=a.getX(2+T);c.fromBufferAttribute(r.attributes.position,w),h.fromBufferAttribute(r.attributes.position,b),u.fromBufferAttribute(r.attributes.position,x),c.applyMatrix4(e.matrixWorld),h.applyMatrix4(e.matrixWorld),u.applyMatrix4(e.matrixWorld),t.closestPointToPoint(c,!1,g),t.closestPointToPoint(h,!1,v),t.closestPointToPoint(u,!1,A);for(var I=d[0];I<=d[1];I++){var T,S,B,w=s.getX(T=3*I),b=s.getX(1+T),x=s.getX(2+T);if(p.fromBufferAttribute(o.attributes.position,w),f.fromBufferAttribute(o.attributes.position,b),m.fromBufferAttribute(o.attributes.position,x),p.applyMatrix4(n.matrixWorld),f.applyMatrix4(n.matrixWorld),m.applyMatrix4(n.matrixWorld),y.set(p,f,m),y.getNormal(E),this.IntersectLineToTriangle(g,c,y))return S=(new THREE.Vector3).subVectors(c,g).normalize(),{pt1:c,pt2:(new THREE.Vector3).copy(g).addScaledVector(S,n.radius)};if(this.IntersectLineToTriangle(v,h,y))return S=(new THREE.Vector3).subVectors(h,v).normalize(),{pt1:h,pt2:(new THREE.Vector3).copy(v).addScaledVector(S,n.radius)};if(this.IntersectLineToTriangle(A,u,y))return B=(new THREE.Vector3).subVectors(u,A).normalize(),{pt1:u,pt2:(new THREE.Vector3).copy(A).addScaledVector(B,n.radius)}}}return null},a.prototype.IntersectLineToTriangle=function(e,t,n){var i,t={origin:e,direction:(new THREE.Vector3).subVectors(t,e)},e=(new THREE.Vector3).subVectors(t.origin,n.a),r=(new THREE.Vector3).subVectors(n.b,n.a),n=(new THREE.Vector3).subVectors(n.c,n.a),o=(new THREE.Vector3).crossVectors(r,n),a=t.direction.dot(o);if(0<a)i=1;else{if(!(a<0))return!1;i=-1,a=-a}n=i*t.direction.dot((new THREE.Vector3).crossVectors(e,n));if(0<=n){t=i*t.direction.dot((new THREE.Vector3).crossVectors(r,e));if(0<=t)if(n+t<=a)if(0<=-i*e.dot(o))return!0}return!1},a.prototype.CalcCircleWallThickness=function(e,t){var n=this.getLineStartEndPoints(e),i=this.getLineStartEndPoints(t),r=(new THREE.Vector3).subVectors(n.end,n.start).normalize(),o=(new THREE.Vector3).subVectors(i.end,i.start).normalize(),r=r.dot(o);if(1-Math.abs(r)<1e-7){var o=new THREE.Line3(n.start,n.end),r=new THREE.Line3(i.start,i.end),a=n.start.distanceTo(n.end),s=i.start.distanceTo(n.start)+i.start.distanceTo(n.end),l=i.end.distanceTo(n.start)+i.end.distanceTo(n.end),d=i.start.distanceTo(i.end),c=n.start.distanceTo(i.start)+n.start.distanceTo(i.end),n=n.end.distanceTo(i.start)+n.end.distanceTo(i.end);if(Math.abs(s-a)<1e-6||Math.abs(l-a)<1e-6||Math.abs(c-d)<1e-6||Math.abs(n-d)<1e-6){i=this.IntersectCylinderPoints(e,o,t,r);if(i)return this.distanceInfo.firstPoint=i.pt1,this.distanceInfo.secondPoint=i.pt2,!0}}return!1},a.prototype.CalcPlaneWallThickness=function(e,t){var n=e.worldNormal.clone(),i=t.worldNormal.clone(),n=(n.normalize(),i.normalize(),Math.abs(n.dot(i)));return Math.abs(n-1)<1e-5&&((i=new THREE.Plane).setFromNormalAndCoplanarPoint(t.worldNormal,t.worldOrigin),n=new THREE.Vector3,i.projectPoint(e.intersect,n),i=n.distanceTo(e.intersect),this.CalcWallThickness(e,t)&&(n=this.distanceInfo.firstPoint.distanceTo(this.distanceInfo.secondPoint),Math.abs(i-n)<1e-5)&&(this.distanceInfo.dimStringPrefix=""),!0)},a.prototype.CalcWallThickness=function(e,t){for(var n=e.geometry,i=t.geometry,r=n.index,o=i.index,a=e.indexRange.concat(),s=(a[0]+=n.drawRange.start/3,a[1]+=n.drawRange.start/3,t.indexRange.concat()),l=(s[0]+=i.drawRange.start/3,s[1]+=i.drawRange.start/3,new THREE.Vector3),d=new THREE.Vector3,c=new THREE.Vector3,h=new THREE.Vector3,u=new THREE.Vector3,p=new THREE.Vector3,f=new THREE.Triangle,m=new THREE.Triangle,g=new THREE.Vector3,v=new THREE.Vector3,A=1/0,y=null,E=null,M=a[0];M<=a[1];M++){var w=r.getX(T=3*M),b=r.getX(1+T),x=r.getX(2+T);l.fromBufferAttribute(n.attributes.position,w),d.fromBufferAttribute(n.attributes.position,b),c.fromBufferAttribute(n.attributes.position,x),l.applyMatrix4(e.matrixWorld),d.applyMatrix4(e.matrixWorld),c.applyMatrix4(e.matrixWorld),f.set(l,d,c),f.getNormal(g);for(var I=s[0];I<=s[1];I++){var T,w=o.getX(T=3*I),b=o.getX(1+T),x=o.getX(2+T),S=(h.fromBufferAttribute(i.attributes.position,w),u.fromBufferAttribute(i.attributes.position,b),p.fromBufferAttribute(i.attributes.position,x),h.applyMatrix4(t.matrixWorld),u.applyMatrix4(t.matrixWorld),p.applyMatrix4(t.matrixWorld),m.set(h,u,p),m.getNormal(v),this.CalcTriangleToTriangleMinDist(f,m));S&&S.dist<A&&(y=S.pt1,E=S.pt2,A=S.dist)}}return A!=1/0&&(this.distanceInfo.firstPoint=y,this.distanceInfo.secondPoint=E,this.distanceInfo.dimStringPrefix=this.tmpDimStringPrefix,!0)},a.prototype.CalcTriangleDistance=function(e,t,n,i){var r,o,a;return Math.abs(t.dot(i))<1e-7?null:(t=new THREE.Vector3,r=i=null,o=1/0,(a=this.CalcNearestPointToTriangle(e,n.a,t))<o&&(o=a,i=n.a,r=t),(a=this.CalcNearestPointToTriangle(e,n.b,t))<o&&(o=a,i=n.b,r=t),(a=this.CalcNearestPointToTriangle(e,n.c,t))<o&&(o=a,i=n.c,r=t),(a=this.CalcNearestPointToTriangle(n,e.a,t))<o&&(o=a,i=e.a,r=t),(a=this.CalcNearestPointToTriangle(n,e.b,t))<o&&(o=a,i=e.b,r=t),(a=this.CalcNearestPointToTriangle(n,e.c,t))<o&&(o=a,i=e.c,r=t),{dist:o,pt1:i.clone(),pt2:r.clone()})},a.prototype.CalcNearestPointToTriangle=function(e,t,n){return e.closestPointToPoint(t,n),t.distanceTo(n)},a.prototype.CalcTriangleToTriangleMinDist=function(e,t){var n,i=1/0,r=0,o=null,a=null;return(n=this.CalcSegmentToTriangleMinDist(e.a,e.b,t)).distance<i&&(i=n.distance,r=n.sqrDistance,o=n.closest[0],a=n.closest[1]),(n=this.CalcSegmentToTriangleMinDist(e.b,e.c,t)).distance<i&&(i=n.distance,r=n.sqrDistance,o=n.closest[0],a=n.closest[1]),(n=this.CalcSegmentToTriangleMinDist(e.c,e.a,t)).distance<i&&(i=n.distance,r=n.sqrDistance,o=n.closest[0],a=n.closest[1]),(n=this.CalcSegmentToTriangleMinDist(t.a,t.b,e)).distance<i&&(i=n.distance,r=n.sqrDistance,o=n.closest[1],a=n.closest[0]),(n=this.CalcSegmentToTriangleMinDist(t.b,t.c,e)).distance<i&&(i=n.distance,r=n.sqrDistance,o=n.closest[1],a=n.closest[0]),(n=this.CalcSegmentToTriangleMinDist(t.c,t.a,e)).distance<i&&(i=n.distance,r=n.sqrDistance,o=n.closest[1],a=n.closest[0]),{dist:i,sqrDist:r,pt1:o,pt2:a}},a.prototype.CalcSegmentToTriangleMinDist=function(e,t,n){var i,r={origin:e,direction:(new THREE.Vector3).subVectors(t,e)},o={sqrDistance:-1,distance:-1,parameter:-1,closest:[2]},r=this.CalcLineToTriangleMinDist(r,n);return 0<=r.parameter?r.parameter<=1?o=r:(r=new THREE.Vector3,n.closestPointToPoint(t,r),i=t.distanceTo(r),o.sqrDistance=i,o.distance=i,o.parameter=1,o.closest[0]=t.clone(),o.closest[1]=r):(i=new THREE.Vector3,n.closestPointToPoint(e,i),t=e.distanceTo(i),o.sqrDistance=t,o.distance=t,o.parameter=0,o.closest[0]=e.clone(),o.closest[1]=i),o},a.prototype.CalcLineToTriangleMinDist=function(e,t){var n={sqrDistance:-1,distance:-1,parameter:-1,barycentric:[3],closest:[2]},i=(new THREE.Vector3).subVectors(t.b,t.a),r=(new THREE.Vector3).subVectors(t.c,t.a),o=(new THREE.Vector3).crossVectors(i,r),a=o.dot(e.direction);if(0<Math.abs(a)){var s=(new THREE.Vector3).subVectors(e.origin,t.a),o=-o.dot(s)/a,s=(new THREE.Vector3).copy(e.origin).addScaledVector(e.direction,o),a=(new THREE.Vector3).subVectors(s,t.a),l=i.dot(i),d=i.dot(r),c=r.dot(r),i=i.dot(a),r=r.dot(a),a=l*c-d*d,c=(c*i-d*r)/a,l=(l*r-d*i)/a;if(0<=1-c-l&&0<=c&&0<=l)return n.sqrDistance=0,n.distance=0,n.parameter=o,n.closest[0]=s,n.closest[1]=s,n}n.distance=-1,n.sqrDistance=-1;r=this.CalcLineToSegmentMinDist(e,t.a,t.b);return(-1==n.sqrDistance||r.sqrDistance<n.sqrDistance)&&(n.sqrDistance=r.sqrDistance,n.distance=r.distance,n.closest=r.closest,n.parameter=r.parameter[0]),r=this.CalcLineToSegmentMinDist(e,t.b,t.c),(-1==n.sqrDistance||r.sqrDistance<n.sqrDistance)&&(n.sqrDistance=r.sqrDistance,n.distance=r.distance,n.closest=r.closest,n.parameter=r.parameter[0]),r=this.CalcLineToSegmentMinDist(e,t.c,t.a),(-1==n.sqrDistance||r.sqrDistance<n.sqrDistance)&&(n.sqrDistance=r.sqrDistance,n.distance=r.distance,n.closest=r.closest,n.parameter=r.parameter[0]),n},a.prototype.CalcLineToSegmentMinDist=function(e,t,n){var i,r,o,a={sqrDistance:-1,distance:-1,parameter:[2],closest:[2]},n=(new THREE.Vector3).subVectors(n,t),s=(new THREE.Vector3).subVectors(e.origin,t),l=e.direction.dot(e.direction),d=-e.direction.dot(n),c=n.dot(n),h=e.direction.dot(s),u=Math.max(l*c-d*d,0);return 0<u&&0<=(o=d*h-l*(r=-n.dot(s)))?o<=u?(i=(d*r-c*h)/u,o/=u):(i=-(d+h)/l,o=1):(i=-h/l,o=0),a.parameter[0]=i,a.parameter[1]=o,a.closest[0]=(new THREE.Vector3).copy(e.origin).addScaledVector(e.direction,i),a.closest[1]=(new THREE.Vector3).copy(t).addScaledVector(n,o),s=(new THREE.Vector3).subVectors(a.closest[0],a.closest[1]),a.sqrDistance=s.dot(s),a.distance=Math.sqrt(a.sqrDistance),a},a.prototype.WallThicknessClearPreSelect=function(){this.distanceInfo.preSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.preSelObj),this.distanceInfo.preSelObj=null,this.distanceInfo.preSelInfo=null)},a.prototype.WallThicknessClearFirstSelect=function(){this.distanceInfo.firstSelObj&&(this.OpMeasure.rootObject.remove(this.distanceInfo.firstSelObj),this.distanceInfo.firstSelObj=null,this.distanceInfo.firstSelInfo=null)};var Me=function(e){g.call(this,e);var t,n,i,r,o,a,s,l,d,c,e=this;this.MeasureOper=new h(this),!this.viewer.hasBrepInfo()&&this.viewer.hasBrepFile()?this.viewer.loadBrepInfo(!1):this.viewer.dispatchEvent({type:"BrepInfoEvent"}),this.scene=new THREE.Scene,this.type="OpMeasure",this.dimString="",this.unit="",this.measureType="pt2pt",this.boxInfos=[],this.textLines=[],this.click=!1,this.measureRelease=!0,this.clientHeightRatio=0,this.clientWidthRatio=0,this.hasZoomArea=!1,this.longClick=0,this.totalArea=0,this.totalVolume=0,this.pixWidth=120,this.hasMouseZoomArea=!0,this.showMouseZoomArea=!1,this.dpr=Math.floor(window.devicePixelRatio),1!=this.dpr&&2!=this.dpr&&3!=this.dpr&&(this.dpr=1),this.textBoxBroadcast=null,this.textPosBroadcast=null,this.perimeterInfos=[],this.perimeterBroadcast=null,this.perimeterunit=null,this.measureTimes=0,this.measureShowResult=!1,this.unsteady=!1,this.unsteadyType="",this.unsteadyuuid=null,this.unsteadyData={},this.unsteadyTextBox=null,this.unsteadyMoving=!1,this.startPoint=null,this.measureFlag=0,this.Popup=null,this.lineargauge3DProcessedLineSet=new Set,this.prompt=document.createElement("div"),Se.isMobileDevice()?this.prompt.className="app-alert":this.prompt.className="pc-alert",this.viewer.container.appendChild(this.prompt);this.debounceTouchSinglemove=(t=function(){var e,t;this.debounceStop||(e=this.pointer.x,t=this.pointer.y,this.hasMouseZoomArea&&(t-=this.pixWidth/2),this.MeasureOper.onNMouseMove(e,t),this.MeasureOper.isTwoTopolInfoTheSame(this.MeasureOper.distanceInfo.preSelInfoOld,this.MeasureOper.distanceInfo.preSelInfo))||(this.imageData=null,this.MeasureOper.distanceInfo.preSelInfoOld=function(e){var t,n={};for(t in e)n[t]=e[t];return n}(this.MeasureOper.distanceInfo.preSelInfo),this.hasMouseZoomArea?this.changeMouseZoomArea():this.changeZoomArea())},n=80,r=e,function(){var e=arguments;i&&clearTimeout(i),i=setTimeout(function(){t.apply(r,e)},n)}),this.debounceTouchSinglemove2=(o=function(){var e,t;this.debounceStop||(e=this.pointer.x,t=this.pointer.y,this.hasMouseZoomArea&&1==this.longClick&&(t-=this.pixWidth/2),this.MeasureOper.onNMouseMove(e,t))},a=function(){this.render(),this.MeasureOper.isTwoTopolInfoTheSame(this.MeasureOper.distanceInfo.preSelInfoOld,this.MeasureOper.distanceInfo.preSelInfo)||(this.imageData=null,this.MeasureOper.distanceInfo.preSelInfoOld=function(e){var t,n={};for(t in e)n[t]=e[t];return n}(this.MeasureOper.distanceInfo.preSelInfo),this.hasMouseZoomArea?this.changeMouseZoomArea():this.changeZoomArea())},s=80,d=l=!0,c=e,function(){var e=arguments;if(a.apply(c,e),l&&(l=!1,setTimeout(function(){l=!0},s),d)){d=!1;try{o.apply(c,e)}catch(e){d=!0,console.error(e)}d=!0}}),this.debounceStop=!1,this.imageData=null,this.boundingboxmesh=null,this.boundingboxInfos=[],this.preSelectBody=null,this.preSelectBodyMat=null,this.rootObject=new THREE.Object3D,this.measureData=new THREE.Group,this.measureData.objectType="Group",this.scene.add(this.rootObject),this.viewer.canvas2D&&(this.viewer.canvas2D.style.display=""),this.render()},Wn=(Me.prototype=Object.create(g.prototype),Me.prototype.getMeasureVisible=function(){return!!this.rootObject&&this.rootObject.visible},Me.prototype.restrictMeasuretime=function(){var e=this.viewer.is2DModel?20:10;if(!this.viewer.is2DModel)for(;this.boxInfos.length>e;){var t=this.boxInfos[0].textBox.children[1];"sectionCross"==t.className&&this.MeasureOper.sectionCrossend.apply(t,[])}},Me.prototype.setMeasureVisible=function(e){this.rootObject&&(this.rootObject.visible=e);for(var t=0,n=this.boxInfos.length;t<n;t++)this.boxInfos[t].textBox.style.display=e?"block":"none"},Me.prototype.release=function(){this.showMouseZoomArea=!1;for(var e=0;e<this.perimeterInfos.length;e++)this.viewer.removeIconFromContainer(this.perimeterInfos[e].textimg);this.perimeterInfos=[],this.MeasureOper.OperatorRelease(),this.clearZoomArea(),this.MeasureOper.update2DScene();var t=this.viewer.renderer.getPixelRatio();this.viewer.canvas2D.getContext("2d").clearRect(0,0,window.innerWidth*t,window.innerHeight*t),this.measureTimes=0,this.measureShowResult=!1,this.lineargauge3DProcessedLineSet=new Set,_e.enableBroadcast&&!_e.broadcastMajor&&this.viewer.dispatchEvent({type:"FaceSelectionChangeEvent"}),this.boundingboxmesh&&(this.rootObject.remove(this.boundingboxmesh),this.boundingboxmesh=null),this.textBoxBroadcast&&(this.viewer.container.removeChild(this.textBoxBroadcast),this.textBoxBroadcast=null,this.textPosBroadcast=null),this.viewer.outlinePass&&this.viewer.outlinePass.enabled&&(this.viewer.outlinePass.tempSelectedObjects.length=0),this.scene.remove(this.rootObject),this.rootObject=null;for(var n=0,i=this.boxInfos.length;n<i;n++){var r=this.boxInfos[n];this.viewer.container.removeChild(r.textBox),r.textPos=null,r.textBox=null}this.boxInfos.splice(0,this.boxInfos.length);for(n=0,i=this.boundingboxInfos.length;n<i;n++){r=this.boundingboxInfos[n];this.viewer.container.removeChild(r.textBox),r.textPos=null,r.textBox=null}this.boundingboxInfos.splice(0,this.boundingboxInfos.length),this.viewer.selectionManager.clearSelection(),this.textLines.length=0,this.update(),this.render(),g.prototype.release.call(this)},Me.prototype.clearFlag=function(){this.measureFlag=0},Me.prototype.setBackGroundColor=function(){},Me.prototype.update=function(){g.prototype.update.call(this)},Me.prototype.addmeasureTimes=function(){this.viewer.dispatchEvent({type:"measureTimes",times:this.measureTimes}),this.measureTimes++},Me.prototype.submeasureTimes=function(){this.viewer.dispatchEvent({type:"measureTimes",times:this.measureTimes}),this.measureTimes--},Me.prototype.onNMouseMove=function(e){var t=this.MeasureOper.getViewClientCoords(e),n=t.x,t=t.y;if(this.prompt&&!Se.isMobileDevice()&&(0<this.InfoType?this.prompt.style.display="block":this.prompt.style.display="none",this.viewer.renderer.getPixelRatio(),this.prompt.style.left=e.clientX+16+"px",this.prompt.style.top=e.clientY+18+"px"),this.unsteady){var i,n=this.pointer.x,t=this.pointer.y;switch(this.unsteadyType){case"bodyDistance":(i=new ln(this)).measureType="bodyDistance";break;case"Distance":i=new ln(this);break;case"Radius":(i=new dn(this)).measureType="radius";break;case"bodyEdgeLength":(i=new cn(this)).measureType="bodyEdgeLength";break;case"measureEdges":(i=new cn(this)).measureType="measureEdges";break;case"bodyAngle":(i=new r(this)).measureType="bodyAngle";break;case"Angle":(i=new r(this)).measureType="LineAngle";break;case"FaceAngle":(i=new r(this)).measureType="faceAngle";break;case"Lineargauge3D":(i=new o(this)).measureType="Lineargauge3D";break;case"WallThickness":(i=new a(this)).measureType="WallThickness"}i.onNMouseMove(n,t),this.render(!0)}else this.MeasureOper.onNMouseMove(n,t),this.dispatchEvent({type:"render",forceRenderAll:!0,needBroadcast:!1})},Me.prototype.onLMouseClick=function(e){if(10==this.measureTimes&&_e.enableBroadcast&&!this.viewer.is2DModel&&"faceArea"!=this.measureType&&"BodyArea"!=this.measureType&&"BodyVolume"!=this.measureType)this.viewer.dispatchEvent({type:"measureTimes",times:this.measureTimes});else{if(20==this.measureTimes&&_e.enableBroadcast&&this.viewer.is2DModel&&"faceArea"!=this.measureType&&"BodyArea"!=this.measureType&&"BodyVolume"!=this.measureType){if(this.viewer.dispatchEvent({type:"measureTimes",times:this.measureTimes}),"coordinate"==this.measureType||this.measureShowResult)return;this.measureShowResult=!0}else this.measureShowResult=!1;var t;e.preventDefault(),!this.viewer.hasBrepInfo()&&this.measureType&&"pt2pt"!=this.measureType&&"angle"!=this.measureType&&"LmPt2Pt"!=this.measureType&&"pt2ptbim"!=this.measureType&&"BoundingBox"!=this.measureType&&"bodyBoundingBox"!=this.measureType?(this.PostInfo(ve.INFOTYPE.NOBREP),this.render(!0)):(t=this.MeasureOper.getViewClientCoords(e),this.click=!0,this.MeasureOper.onLMouseClick(t.x,t.y,e.ctrlKey),this.isInMeasure()&&"coordinate"!=this.measureType?this.dispatchEvent({type:"render",forceRenderAll:!0,needBroadcast:!0}):this.render(!0))}},Me.prototype.onLMouseDbClick=function(){"contour"!=this.MeasureOper.measureType&&"contourarea"!=this.MeasureOper.measureType||this.MeasureOper.measureEnd()},Me.prototype.onLMouseUp=function(e){this.state=-1,_e.enableDirectMove&&!this.viewer.isExploded()&&this.onTransformFinish()},Me.prototype.onTouchDoubleEnd=function(e){e.preventDefault(),g.prototype.onTouchDoubleEnd.call(this,e),this.getZoomAreaVisible()&&(this.invisible(),this.MeasureOper)&&this.MeasureOper.clearPreSelect(),clearTimeout(this.timeOutEvent),this.timeOutEvent=0,this.longClick=0},Me.prototype.onTouchSingleEnd=function(e){var t,n;this.hideRotateCenterHelper(),e.preventDefault(),this.lineargaugediv&&"block"==this.lineargaugediv.style.display||(10==this.measureTimes&&_e.enableBroadcast?this.viewer.dispatchEvent({type:"measureTimes",times:this.measureTimes}):(e=this.singleTouchEndPos.x,t=this.singleTouchEndPos.y,n=Date.now()-this.touchStartTime,!this.viewer.hasBrepInfo()&&this.measureType&&"pt2pt"!=this.measureType&&"pt2ptbim"!=this.measureType&&"LmPt2Pt"!=this.measureType&&"angle"!=this.measureType&&"BoundingBox"!=this.measureType?(this.PostInfo(ve.INFOTYPE.NOBREP),clearTimeout(this.timeOutEvent),this.timeOutEvent=0,this.longClick=0):((1==this.longClick||n<500&&Math.abs(this.singleTouchStartPos.x-this.singleTouchEndPos.x)<3&&Math.abs(this.singleTouchStartPos.y-this.singleTouchEndPos.y)<3)&&(this.hasMouseZoomArea&&1==this.longClick&&(t-=this.pixWidth/2),this.MeasureOper.onLMouseClick(e,t,!1),this.render(),this.invisible(),this.MeasureOper.clearCoordinate()),clearTimeout(this.timeOutEvent),this.timeOutEvent=0,this.longClick=0,this.debounceStop=!0)))},Me.prototype.onTouchDoubleStart=function(e){e.preventDefault(),g.prototype.onTouchDoubleStart.call(this,e),clearTimeout(this.timeOutEvent),this.timeOutEvent=0,this.longClick=0},Me.prototype.onTouchSingleStart=function(e){var t;this.lineargaugediv&&"block"==this.lineargaugediv.style.display||(g.prototype.onTouchSingleStart.call(this,e),(t=this).longClick=0,this.hasMouseZoomArea?this.createMouseZoomArea():t.createZoomArea(),_e.inBIMContext||(this.timeOutEvent=setTimeout(function(){t.longClick=1,t.hasMouseZoomArea?t.changeMouseZoomArea(!0):t.changeZoomArea(!0)},500)),this.touchStartTime=Date.now())},Me.prototype.onTouchDoubleMove=function(e){g.prototype.onTouchDoubleMove.call(this,e),clearTimeout(this.timeOutEvent),this.timeOutEvent=0,this.longClick=0},Me.prototype.onTouchSingleMove=function(e){var t=Date.now()-this.touchStartTime;if(t<500&&(3<Math.abs(this.pointer.x-this.singleTouchStartPos.x)||3<Math.abs(this.pointer.y-this.singleTouchStartPos.y))&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=0),0!=this.longClick||!(Math.abs(this.pointer.x-this.singleTouchStartPos.x)<3||Math.abs(this.pointer.y-this.singleTouchStartPos.y)<3))if(0==this.longClick)if(this.invisible(),this.MeasureOper.clearCoordinate(),this.unsteady){var n,t=this.pointer.x,i=this.pointer.y;switch(this.unsteadyType){case"bodyDistance":(n=new ln(this)).measureType="bodyDistance";break;case"Distance":n=new ln(this);break;case"Radius":(n=new dn(this)).measureType="radius";break;case"bodyEdgeLength":(n=new cn(this)).measureType="bodyEdgeLength";break;case"measureEdges":(n=new cn(this)).measureType="measureEdges";break;case"bodyAngle":(n=new r(this)).measureType="bodyAngle";break;case"Angle":(n=new r(this)).measureType="LineAngle";break;case"FaceAngle":(n=new r(this)).measureType="faceAngle";break;case"Lineargauge3D":(n=new o(this)).measureType="Lineargauge3D";break;case"WallThickness":(n=new a(this)).measureType="WallThickness"}n.onNMouseMove(t,i)}else g.prototype.onTouchSingleMove.call(this,e);else this.debounceStop=!1,this.hasMouseZoomArea?(this.debounceTouchSinglemove2(),this.changeMouseZoomArea()):(this.debounceTouchSinglemove(),this.changeZoomArea())},Me.prototype.PostInfo=function(e){if(this.prompt)if(!e||this.MeasureOper.hasMeasured()&&Se.isMobileDevice()&&e<=ve.INFOTYPE.MEASURENOTICEBEGIN)this.InfoType=0,this.prompt.style.display="none",this.prompt.innerHTML="";else{this.Popup&&(clearTimeout(this.Popup),this.Popup=null),this.InfoType=e;var t,n="",i=22;if(Se.isMobileDevice()&&(i=42),this.prompt.removeAttribute("height"),this.prompt.style.height="",Se.isMobileDevice())switch(e){case ve.INFOTYPE.POINT:n=Se.translateString("MEASURE_APP_POINT");break;case ve.INFOTYPE.MOUSEENTER:n=Se.translateString("MEASURE_APP_MOUSEENTER");break;case ve.INFOTYPE.THIRDPOINT:n=Se.translateString("MEASURE_APP_THIRDPOINT");break;case ve.INFOTYPE.COORDINATEPOINT:n=Se.translateString("MEASURE_APP_COORDINATEPOINT");break;case ve.INFOTYPE.CROSSENTER:n=Se.translateString("MEASURE_APP_CROSSENTER");break;case ve.INFOTYPE.SECONDPOINT:n=Se.translateString("MEASURE_APP_SECONDPOINT");break;case ve.INFOTYPE.POINTLINE:n=Se.translateString("MEASURE_APP_POINTLINE");break;case ve.INFOTYPE.LINE:n=Se.translateString("MEASURE_APP_LINE");break;case ve.INFOTYPE.POINTPLANE:n=Se.translateString("MEASURE_APP_POINTPLANE");break;case ve.INFOTYPE.PLANE:n=Se.translateString("MEASURE_APP_PLANE");break;case ve.INFOTYPE.FIRSTLINE:n=Se.translateString("MEASURE_APP_FIRSTLINE");break;case ve.INFOTYPE.LINEANDCIRCLE:n=Se.translateString("MEASURE_APP_LINEANDCIRCLE");break;case ve.INFOTYPE.SECONDLINE:n=Se.translateString("MEASURE_APP_SECONDLINE");break;case ve.INFOTYPE.ENDMEASURE:n="";break;case ve.INFOTYPE.LINEPLANE:n=Se.translateString("MEASURE_APP_LINEPLANE");break;case ve.INFOTYPE.FIRSTPLANE:n=Se.translateString("MEASURE_APP_FIRSTPLANE");break;case ve.INFOTYPE.PARALLELLINE:n=Se.translateString("MEASURE_APP_PARALLELLINE");break;case ve.INFOTYPE.PARALLELPLANE:n=Se.translateString("MEASURE_APP_PARALLELPLANE");break;case ve.INFOTYPE.FIRSTPARALLELPLANE:n=Se.translateString("MEASURE_APP_FIRSTPARALLELPLANE");break;case ve.INFOTYPE.CIRCLE:n=this.viewer.is2DModel?Se.translateString("MEASURE_APP_2D_CIRCLE"):Se.translateString("MEASURE_APP_CIRCLE");break;case ve.INFOTYPE.SECONDCIRCLE:n=this.viewer.is2DModel?Se.translateString("MEASURE_APP_2D_SECONDCIRCLE"):Se.translateString("MEASURE_APP_SECONDCIRCLE");break;case ve.INFOTYPE.CIRCLEA:n=this.viewer.is2DModel?Se.translateString("MEASURE_APP_2D_CIRCLEA"):Se.translateString("MEASURE_APP_CIRCLEA");break;case ve.INFOTYPE.SECONDPLANE:n=Se.translateString("MEASURE_APP_SECONDPLANE");break;case ve.INFOTYPE.AXISLINE:n=this.viewer.is2DModel?Se.translateString("MEASURE_APP_2D_AXISLINE"):Se.translateString("MEASURE_APP_AXISLINE");break;case ve.INFOTYPE.AXISPOINT:n=this.viewer.is2DModel?Se.translateString("MEASURE_APP_2D_AXISPOINT"):Se.translateString("MEASURE_APP_AXISPOINT");break;case ve.INFOTYPE.AXIS:n=Se.translateString("MEASURE_APP_AXIS");break;case ve.INFOTYPE.AXISPLANE:n=Se.translateString("MEASURE_APP_AXISPLANE");break;case ve.INFOTYPE.FACE:n=Se.translateString("MEASURE_APP_FACE");break;case ve.INFOTYPE.CIRCLEANDLINE:n=Se.translateString("MEASURE_APP_CIRCLEANDLINE");break;case ve.INFOTYPE.FIRSTPOINT:n=Se.translateString("MEASURE_APP_FIRSTPOINT");break;case ve.INFOTYPE.BODY:n=Se.translateString("MEASURE_APP_BODY");break;case ve.INFOTYPE.LINEPOSITION:n=Se.translateString("MEASURE_APP_LINEPOSITION");break;case ve.INFOTYPE.LINENOPARALLEL:n=Se.translateString("MEASURE_APP_LINENOPARALLEL");break;case ve.INFOTYPE.PLANENOPARALLEL:n=Se.translateString("MEASURE_APP_PLANENOPARALLEL");break;case ve.INFOTYPE.NOTFACE:n=Se.translateString("MEASURE_APP_NOTFACE");break;case ve.INFOTYPE.NOTFACEPARALLEL:n=Se.translateString("MEASURE_APP_NOTFACEPARALLEL");break;case ve.INFOTYPE.AXISNOPARALLEL:n=Se.translateString("MEASURE_APP_AXISNOPARALLEL");break;case ve.INFOTYPE.NOBREP:n=Se.translateString("MEASURE_APP_NOBREP");break;case ve.INFOTYPE.NOPARALLEL:n=Se.translateString("MEASURE_APP_NOPARALLEL");break;case ve.INFOTYPE.NOTFACESECOND:n=Se.translateString("MEASURE_APP_NOTFACESECOND");break;case ve.INFOTYPE.INTERSECT:n=Se.translateString("MEASURE_APP_INTERSECT");break;case ve.INFOTYPE.LINEPARALLEL:n=Se.translateString("MEASURE_APP_LINEPARALLEL");break;case ve.INFOTYPE.PLANEPARALLELLINE:n=Se.translateString("MEASURE_APP_PLANEPARALLELLINE");break;case ve.INFOTYPE.LINEPARALLELPLANE:n=Se.translateString("MEASURE_APP_LINEPARALLELPLANE");break;case ve.INFOTYPE.PLANEPARALLEL:n=Se.translateString("MEASURE_APP_PLANEPARALLEL");break;case ve.INFOTYPE.TWOAXISNOPARALLEL:n=Se.translateString("MEASURE_APP_TWOAXISNOPARALLEL");break;case ve.INFOTYPE.NOCONJOINT:n=Se.translateString("MEASURE_APP_NOCONJOINT");break;case ve.INFOTYPE.NOCLOSE:n=Se.translateString("MEASURE_APP_NOCLOSE");break;case ve.INFOTYPE.FIRMEASUREBODY:n=Se.translateString("MEASURE_APP_FIRMEASUREBODY");break;case ve.INFOTYPE.SECMEASUREBODY:n=Se.translateString("MEASURE_APP_SECMEASUREBODY");break;case ve.INFOTYPE.MEASUREBODY:n=Se.translateString("MEASURE_APP_MEASUREBODY");break;case ve.INFOTYPE.TWOBODYPARALLEL:n=Se.translateString("MEASURE_APP_TWOBODYPARALLEL");break;case ve.INFOTYPE.TWOBODYNOTPARALLEL:n=Se.translateString("MEASURE_APP_TWOBODYNOTPARALLEL");break;case ve.INFOTYPE.LOADDATE:n=Se.translateString("MEASURE_APP_LOADDATE");break;case ve.INFOTYPE.CLICKFIRSTPOINT:n=Se.translateString("MEASURE_APP_CLICKFIRSTPOINT");break;case ve.INFOTYPE.CLICKSECONDPOINT:n=Se.translateString("MEASURE_APP_CLICKSECONDPOINT");break;case ve.INFOTYPE.PROJECTPLANE:n=Se.translateString("MEASURE_APP_PROJECTPLANE");break;case ve.INFOTYPE.SELECTPROJECTPLANE:n=Se.translateString("MEASURE_APP_SELECTPROJECTPLANE");break;case ve.INFOTYPE.PLACELINELOCATION:n=Se.translateString("MEASURE_APP_PLACELINELOCATION");break;case ve.INFOTYPE.SELECTPLACELINELOCATION:n=Se.translateString("MEASURE_APP_SELECTPLACELINELOCATION");break;case ve.INFOTYPE.FIRSTMESH:n=Se.translateString("MEASURE_APP_FIRSTMESH");break;case ve.INFOTYPE.SECONDMESH:n=Se.translateString("MEASURE_APP_SECONDMESH");break;case ve.INFOTYPE.MESHVERTICAL:n=Se.translateString("MEASURE_APP_MESHVERTICAL");break;case ve.INFOTYPE.AXISNOPARALLELLINE:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_APP_AXISNOPARALLELLINE_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_APP_AXISNOPARALLELLINE_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.NOBREPNOPLNE:n=Se.translateString("MEASURE_APP_NOBREPNOPLNE")}else switch(e){case ve.INFOTYPE.POINT:n=Se.translateString("MEASURE_POINT");break;case ve.INFOTYPE.COORDINATEPOINT:n=Se.translateString("MEASURE_COORDINATEPOINT");break;case ve.INFOTYPE.SECONDPOINT:n=_e.inBIMContext?Se.translateString("MEASURE_BIM_SECONDPOINT"):Se.translateString("MEASURE_SECONDPOINT");break;case ve.INFOTYPE.THIRDPOINT:n=_e.inBIMContext?Se.translateString("MEASURE_BIM_THIRDPOINT"):Se.translateString("MEASURE_THIRDPOINT");break;case ve.INFOTYPE.POINTLINE:n=Se.translateString("MEASURE_POINTLINE");break;case ve.INFOTYPE.LINE:n=Se.translateString("MEASURE_LINE");break;case ve.INFOTYPE.LINEANDCIRCLE:n=Se.translateString("MEASURE_LINEANDCIRCLE");break;case ve.INFOTYPE.POINTPLANE:n=Se.translateString("MEASURE_POINTPLANE");break;case ve.INFOTYPE.PLANE:n=Se.translateString("MEASURE_PLANE");break;case ve.INFOTYPE.FIRSTLINE:n=Se.translateString("MEASURE_FIRSTLINE");break;case ve.INFOTYPE.SECONDLINE:n=Se.translateString("MEASURE_SECONDLINE");break;case ve.INFOTYPE.LINEPLANE:n=Se.translateString("MEASURE_LINEPLANE");break;case ve.INFOTYPE.PARALLELLINE:n=Se.translateString("MEASURE_PARALLELLINE");break;case ve.INFOTYPE.FIRSTPARALLELPLANE:n=Se.translateString("MEASURE_FIRSTPARALLELPLANE");break;case ve.INFOTYPE.PARALLELPLANE:n=Se.translateString("MEASURE_PARALLELPLANE");break;case ve.INFOTYPE.CIRCLE:n=this.viewer.is2DModel?Se.translateString("MEASURE_2D_CIRCLE"):Se.translateString("MEASURE_CIRCLE");break;case ve.INFOTYPE.CIRCLEA:n=this.viewer.is2DModel?Se.translateString("MEASURE_2D_CIRCLEA"):Se.translateString("MEASURE_CIRCLEA");break;case ve.INFOTYPE.SECONDCIRCLE:n=this.viewer.is2DModel?Se.translateString("MEASURE_2D_SECONDCIRCLE"):Se.translateString("MEASURE_SECONDCIRCLE");break;case ve.INFOTYPE.SECONDPLANE:n=Se.translateString("MEASURE_SECONDPLANE");break;case ve.INFOTYPE.FIRSTPLANE:n=Se.translateString("MEASURE_FIRSTPLANE");break;case ve.INFOTYPE.AXISLINE:n=this.viewer.is2DModel?Se.translateString("MEASURE_2D_AXISLINE"):Se.translateString("MEASURE_AXISLINE");break;case ve.INFOTYPE.AXISPOINT:n=this.viewer.is2DModel?Se.translateString("MEASURE_2D_AXISPOINT"):Se.translateString("MEASURE_AXISPOINT");break;case ve.INFOTYPE.AXIS:n=Se.translateString("MEASURE_AXIS");break;case ve.INFOTYPE.AXISPLANE:n=Se.translateString("MEASURE_AXISPLANE");break;case ve.INFOTYPE.FACE:n=Se.translateString("MEASURE_FACE");break;case ve.INFOTYPE.CIRCLEANDLINE:n="<div class = 'blackdiv'>"+Se.translateString("MEASURE_CIRCLEANDLINE_1")+"</div><div class = 'whitediv'>"+Se.translateString("MEASURE_CIRCLEANDLINE_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.FIRSTPOINT:n=_e.inBIMContext?Se.translateString("MEASURE_FIRSTPOINT_BIM"):Se.translateString("MEASURE_FIRSTPOINT");break;case ve.INFOTYPE.BODY:n=Se.translateString("MEASURE_BODY");break;case ve.INFOTYPE.LINEPOSITION:n=Se.translateString("MEASURE_LINEPOSITION");break;case ve.INFOTYPE.ENDMEASURE:n=Se.translateString("MEASURE_ENDMEASURE");break;case ve.INFOTYPE.CANCELLINE:n="<div class = 'blackdiv'>"+Se.translateString("MEASURE_CANCELLINE_1")+"</div><div class = 'whitediv'>"+Se.translateString("MEASURE_CANCELLINE_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.LINENOPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_LINENOPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_LINENOPARALLEL_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.PLANENOPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_PLANENOPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_PLANENOPARALLEL_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.NOTFACE:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_NOTFACE_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_NOTFACE_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.NOTFACESECOND:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_NOTFACESECOND_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_NOTFACESECOND_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.NOTFACEPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_NOTFACEPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_NOTFACEPARALLEL_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.AXISNOPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_AXISNOPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_AXISNOPARALLEL_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.MOUSEENTER:n=Se.translateString("MEASURE_MOUSEENTER");break;case ve.INFOTYPE.CROSSENTER:n=Se.translateString("MEASURE_CROSSENTER");break;case ve.INFOTYPE.NOBREP:n=Se.translateString("MEASURE_NOBREP");break;case ve.INFOTYPE.NOPARALLEL:n=Se.translateString("MEASURE_NOPARALLEL");break;case ve.INFOTYPE.INTERSECT:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_INTERSECT_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_INTERSECT_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.LINEPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_LINEPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_LINEPARALLEL_2")+"</div>",this.viewer.is2DModel&&(n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_LINEPARALLEL_2D_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_LINEPARALLEL_2D_2")+"</div>"),this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.PLANEPARALLELLINE:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_PLANEPARALLELLINE_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_PLANEPARALLELLINE_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.LINEPARALLELPLANE:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_LINEPARALLELPLANE_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_LINEPARALLELPLANE_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.PLANEPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_PLANEPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_PLANEPARALLEL_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.TWOAXISNOPARALLEL:var r=this.viewer.is2DModel?Se.translateString("MEASURE_TWOAXISNOPARALLEL_2D_2"):Se.translateString("MEASURE_TWOAXISNOPARALLEL_2"),n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_TWOAXISNOPARALLEL_1")+"</div><div class = 'blackdiv'>"+r+"</div>";this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.NOCONJOINT:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_NOCONJOINT_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_NOCONJOINT_2")+"</div><div class = 'whitediv'> "+Se.translateString("MEASURE_NOCONJOINT_3")+"</div>",this.prompt.style.height=3*i+"px";break;case ve.INFOTYPE.NOCLOSE:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_NOCLOSE_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_NOCLOSE_2")+"</div><div class = 'whitediv'>"+Se.translateString("MEASURE_NOCLOSE_3")+"</div>",this.prompt.style.height=3*i+"px";break;case ve.INFOTYPE.FIRMEASUREBODY:n=Se.translateString("MEASURE_FIRMEASUREBODY");break;case ve.INFOTYPE.SECMEASUREBODY:n=Se.translateString("MEASURE_SECMEASUREBODY");break;case ve.INFOTYPE.MEASUREBODY:n=Se.translateString("MEASURE_MEASUREBODY");break;case ve.INFOTYPE.TWOBODYPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_TWOBODYPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_TWOBODYPARALLEL_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.TWOBODYNOTPARALLEL:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_TWOBODYNOTPARALLEL_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_TWOBODYNOTPARALLEL_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.LOADDATE:n=Se.translateString("MEASURE_LOADDATE");break;case ve.INFOTYPE.CLICKFIRSTPOINT:n=Se.translateString("MEASURE_CLICKFIRSTPOINT");break;case ve.INFOTYPE.CLICKSECONDPOINT:n=Se.translateString("MEASURE_CLICKSECONDPOINT");break;case ve.INFOTYPE.PROJECTPLANE:n=Se.translateString("MEASURE_PROJECTPLANE");break;case ve.INFOTYPE.SELECTPROJECTPLANE:n=Se.translateString("MEASURE_SELECTPROJECTPLANE");break;case ve.INFOTYPE.PLACELINELOCATION:n=Se.translateString("MEASURE_PLACELINELOCATION");break;case ve.INFOTYPE.SELECTPLACELINELOCATION:n=Se.translateString("MEASURE_SELECTPLACELINELOCATION");break;case ve.INFOTYPE.FIRSTMESH:n=Se.translateString("MEASURE_FIRSTMESH");break;case ve.INFOTYPE.SECONDMESH:n=Se.translateString("MEASURE_SECONDMESH");break;case ve.INFOTYPE.MESHVERTICAL:n=Se.translateString("MEASURE_MESHVERTICAL");break;case ve.INFOTYPE.AXISNOPARALLELLINE:n="<div class = 'yellowdiv'>"+Se.translateString("MEASURE_AXISNOPARALLELLINE_1")+"</div><div class = 'blackdiv'>"+Se.translateString("MEASURE_AXISNOPARALLELLINE_2")+"</div>",this.prompt.style.height=2*i+"px";break;case ve.INFOTYPE.NOBREPNOPLNE:n=Se.translateString("MEASURE_NOBREPNOPLNE")}""==n||!_e.broadcastMajor&&_e.enableBroadcast?(this.prompt.style.display="none",this.prompt.innerHTML=n):(this.prompt.innerHTML=n,this.prompt.style.display="block",Se.isMobileDevice()&&(e=this.viewer.renderer.getSize().height/2-21+"px",this.prompt.style.top=e),this.InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN?this.prompt.style.color="#ff7d2c":Se.isMobileDevice()?this.prompt.style.color="rgba(27,27,27,1)":this.prompt.style.color="rgba(51,51,51,1)",e=2e3,(t=this).InfoType>ve.INFOTYPE.MEASURENOTICEBEGIN&&(e=3e3),Se.isMobileDevice()&&(this.Popup=setTimeout(function(){t.prompt.style.display="none"},e)))}},Me.prototype.setMeasureType=function(e){switch(""!=e&&this.viewer.hasBrepFile()?this.showMouseZoomArea=!0:this.showMouseZoomArea=!1,this.measureType=e,this.viewer.brepInfo.BfacePerimeter||"facePerimeter"!=this.measureType||(this.measureType="Base"),_e.enableBroadcast&&!_e.broadcastMajor&&this.viewer.dispatchEvent({type:"FaceSelectionChangeEvent"}),this.viewer.selectionManager.clearSelection(),this.viewer.onOpChanged({id:"MeasureType"}),this.MeasureOper.OperatorEnd(),this.measureType){case"bodyDistance":case"PointToLine":case"PointToFace":case"AxisToPoint":case"LineToLine":case"LineToFace":case"faceDist":case"AxisToLine":case"AxisToFace":case"holeDist":case"pt2pt":case"pt2ptbim":"Distance"!=this.MeasureOper.measureClass&&(this.MeasureOper=new ln(this));break;case"radius":"Hole"!=this.MeasureOper.measureClass&&(this.MeasureOper=new dn(this));break;case"measureEdges":case"bodyEdgeLength":"Edge"!=this.MeasureOper.measureClass&&(this.MeasureOper=new cn(this));break;case"facePerimeter":case"faceArea":"Face"!=this.MeasureOper.measureClass&&(this.MeasureOper=new hn(this));break;case"bodyAngle":case"LineAngle":case"LineFaceAngle":case"faceAngle":case"angle":"Angle"!=this.MeasureOper.measureClass&&(this.MeasureOper=new r(this));break;case"BodyArea":case"BodyVolume":case"bodyBoundingBox":case"TotalArea":case"TotalVolume":case"BoundingBox":"BodyAndTotal"!=this.MeasureOper.measureClass&&(this.MeasureOper=new un(this));break;case"coordinate":"Coordinate"!=this.MeasureOper.measureClass&&(this.MeasureOper=new pn(this));break;case"Lineargauge":"Lineargauge"!=this.MeasureOper.measureClass&&(this.MeasureOper=new fn(this));break;case"LmPt2Pt":case"LmPt2Line":case"LmLine2Line":case"LmHole2Hole":case"LmAxis2Pt":case"LmAxis2Line":"Lineargauge3D"!=this.MeasureOper.measureClass&&(this.MeasureOper=new o(this)),this.MeasureOper.OperatorClear(this.measureType);break;case"contour":case"contourarea":"Contour"!=this.MeasureOper.measureClass&&(this.MeasureOper=new wn(this));break;case"thickness":"Wall"!=this.MeasureOper.measureClass&&(this.MeasureOper=new bn(this));break;case"faceThickness":"Thickness"!=this.MeasureOper.measureClass&&(this.MeasureOper=new Tn(this));break;case"WallThickness":"WallThickness"!=this.MeasureOper.measureClass&&(this.MeasureOper=new a(this));break;default:"Base"!=this.MeasureOper.measureClass&&(this.MeasureOper=new h(this))}"Base"!=this.MeasureOper.measureClass&&!this.viewer.hasBrepInfo()&&this.viewer.hasBrepFile()?this.PostInfo(ve.INFOTYPE.LOADDATE):!this.viewer.hasBrepFile()&&this.measureType&&"pt2pt"!=this.measureType&&"pt2ptbim"!=this.measureType&&"angle"!=this.measureType&&"LmPt2Pt"!=this.measureType&&"BoundingBox"!=this.measureType&&"bodyBoundingBox"!=this.measureType||"facePerimeter"==e&&this.viewer.brepInfo&&!this.viewer.brepInfo.BfacePerimeter||"BodyArea"==e&&this.viewer.brepInfo&&!this.viewer.brepInfo.BbodyArea||("BodyVolume"==e||"TotalVolume"==e)&&this.viewer.brepInfo&&!this.viewer.brepInfo.BbodyVolume||"faceArea"==e&&this.viewer.brepInfo&&!this.viewer.brepInfo.BfaceArea||"TotalArea"==e&&this.viewer.brepInfo&&!this.viewer.brepInfo.BtotalArea?this.PostInfo(ve.INFOTYPE.NOBREP):this.MeasureOper.OperatorStart(this.measureType),this.prompt&&!Se.isMobileDevice()&&(this.prompt.style.display="none"),Se.isMobileDevice()&&(this.hasMouseZoomArea?this.createMouseZoomArea():this.createZoomArea()),this.render()},Me.prototype.setPointScale=function(e,t){t=this.getScale(e,t);e.scale.x=t,e.scale.y=t,e.scale.z=t,e.updateMatrixWorld()},Me.prototype.setCylinderScale=function(e,t){Se.isMobileDevice()&&(t*=1.5);t=this.getScale(e,t);e.scale.x=t,e.scale.y=t,e.scale.z=t,e.oldPosition&&e.offsetPos&&e.position.addVectors(e.oldPosition,e.offsetPos.clone().multiplyScalar(t)),e.updateMatrixWorld()},Me.prototype.setResolution=function(e){var t=this.viewer.renderer.getPixelRatio(),n=this.viewer.renderer.domElement.width/t,t=this.viewer.renderer.domElement.height/t;e.material.resolution.set(n,t)},Me.prototype.getScale=function(e,t){var n=5,t=(null!=t&&(n=t),this.viewer.camera.getCameraTarget()),i=this.viewer.camera.position,r=new THREE.Vector3,t=(r.subVectors(t,i),e.position.clone()),e=this.viewer.camera.isPerspective?t.sub(i).dot(r.normalize()):r.length(),t=this.viewer.camera.fov,i=2*e*Math.tan(THREE.Math.degToRad(.5*t)),r=this.viewer.renderer.domElement.height;return n*i*this.viewer.renderer.getPixelRatio()/r},Me.prototype.renderScale=function(e){for(var t=0;t<e.children.length;t++){var n=e.children[t];if(null!=n.objectType)switch(n.objectType){case"Point":this.setPointScale(n,this.MeasureOper.POINTSIZE);break;case"Cylinder":this.setCylinderScale(n,this.MeasureOper.CYLINDERWIDTH);break;case"Group":this.renderScale(n);break;case"SelLine":this.setResolution(n)}}},Me.prototype.renderMeasureScene=function(e,t){if(this.scene){if(null!=this.rootObject&&this.renderScale(this.rootObject),e?this.viewer.renderer.render(this.scene,this.viewer.camera,e,t):this.viewer.renderer.render(this.scene,this.viewer.camera),this.MeasureOper.renderMeasureScene(),this.perimeterInfos)for(var n=0,i=this.perimeterInfos.length;n<i;n++){var r=this.perimeterInfos[n],o=(this.viewer.removeIconFromContainer(r.textimg),this.MeasureOper.get2dPoint(r.textPos.clone())),o=this.MeasureOper.addAnnotationTip(r.dimString,o.x,o.y);o&&this.viewer.container.appendChild(o),r.textimg=o}for(n=0,i=this.boxInfos.length;n<i;n++){r=this.boxInfos[n];this.MeasureOper.getAndShowTextBox(r.textPos.clone(),r.dimString,r.textBox)}for(n=0,i=this.boundingboxInfos.length;n<i;n++){r=this.boundingboxInfos[n];this.MeasureOper.getAndShowTextBox(r.textPos.clone(),r.dimString,r.textBox)}}},Me.prototype.setMeasureProjectPlane=function(e){if("Lineargauge3D"==this.MeasureOper.measureClass)switch(this.MeasureOper.selectProjectPlane=!1,this.MeasureOper.LineargaugeClearProjectPlaneSelect(),e){case"S":if(!this.viewer.hasBrepFile()&&("LmPt2Pt"==this.measureType||"LmHole2Hole"==this.measureType))return void this.PostInfo(ve.INFOTYPE.NOBREPNOPLNE);this.MeasureOper.selectProjectPlane=!0,this.MeasureOper.distanceInfo.projectPlane=null,this.PostInfo(ve.INFOTYPE.PROJECTPLANE);break;case"X":var t=this.viewer.controls.getBoundingBox().getCenter();if(this.MeasureOper.distanceInfo.projectPlane=(new THREE.Plane).setFromNormalAndCoplanarPoint(new THREE.Vector3(1,0,0),t),!this.viewer.hasBrepFile()&&"LmHole2Hole"==this.measureType)return this.MeasureOper.lineargaugeRotateOnly(this.MeasureOper.distanceInfo.projectPlane),this.MeasureOper.distanceInfo.projectPlane=null,void this.PostInfo(ve.INFOTYPE.NOBREP);this.MeasureOper.lineargaugeRotate(this.MeasureOper.distanceInfo.projectPlane,!0);break;case"Y":t=this.viewer.controls.getBoundingBox().getCenter();if(this.MeasureOper.distanceInfo.projectPlane=(new THREE.Plane).setFromNormalAndCoplanarPoint(new THREE.Vector3(0,1,0),t),!this.viewer.hasBrepFile()&&"LmHole2Hole"==this.measureType)return this.MeasureOper.lineargaugeRotateOnly(this.MeasureOper.distanceInfo.projectPlane),this.MeasureOper.distanceInfo.projectPlane=null,void this.PostInfo(ve.INFOTYPE.NOBREP);this.MeasureOper.lineargaugeRotate(this.MeasureOper.distanceInfo.projectPlane,!0);break;case"Z":t=this.viewer.controls.getBoundingBox().getCenter();if(this.MeasureOper.distanceInfo.projectPlane=(new THREE.Plane).setFromNormalAndCoplanarPoint(new THREE.Vector3(0,0,1),t),!this.viewer.hasBrepFile()&&"LmHole2Hole"==this.measureType)return this.MeasureOper.lineargaugeRotateOnly(this.MeasureOper.distanceInfo.projectPlane),this.MeasureOper.distanceInfo.projectPlane=null,void this.PostInfo(ve.INFOTYPE.NOBREP);this.MeasureOper.lineargaugeRotate(this.MeasureOper.distanceInfo.projectPlane,!0);break;default:this.MeasureOper.distanceInfo.projectPlane=null}else console.log("ERROR: Cant not Select Project Plane ")},Me.prototype.setMeasureProjectDirection=function(e){Se.isMobileDevice()?"V"==e?this.MeasureOper.lineargaugeSelectPlaceLine(1):"H"==e&&this.MeasureOper.lineargaugeSelectPlaceLine(0):console.log("Error: unknow project direction")},Me.prototype.setMeasureScale=function(e){for(var t=0,n=this.boxInfos.length;t<n;t++){var i,r,o,a,s,l=this.boxInfos[t];"length"==l.textBox.getAttribute("type")?(i=l.textBox.getAttribute("dimString"),r=l.textBox.getAttribute("dimStringPrefix"),s=l.textBox.getAttribute("unit"),"⌒"==i[0]?l.dimString="⌒ "+(i.slice(2)*e).toFixed(2)+s:l.dimString=(i*e).toFixed(2)+s,r&&(l.dimString=r+l.dimString)):"radius"==l.textBox.getAttribute("type")?(r=(i=l.textBox.getAttribute("dimString")).slice(0,2),o=i.slice(2),s=l.textBox.getAttribute("unit"),l.dimString=r+(o*e).toFixed(2)+s):"perimeter"==l.textBox.getAttribute("type")?(a=parseFloat(l.textBox.getAttribute("dimString")),s=l.textBox.getAttribute("unit"),l.dimString=Se.translateString("MEASURE_OVERLENGTH")+":"+(a*e).toFixed(2)+s):"area"==l.textBox.getAttribute("type")&&(a=parseFloat(l.textBox.getAttribute("dimString")),s=l.textBox.getAttribute("unit"),l.dimString=Se.translateString("MEASURE_AREA")+":"+(a*e*e).toFixed(2)+s),l.textBox.screenX=-10,this.MeasureOper.getAndShowTextBox(l.textPos.clone(),l.dimString,l.textBox)}_e.enableBroadcast&&_e.broadcastMajor&&this.viewer.dispatchEvent({type:"broadcastEvent"})},Me.prototype.setMeasureDisplayUnit=function(){for(var e=0,t=this.boxInfos.length;e<t;e++){var n,i,r,o,a,s,l=this.boxInfos[e],d=this.viewer.userModelUnit||this.viewer.modelUnit;"length"==l.textBox.getAttribute("type")?(n=l.textBox.getAttribute("dimString"),i=l.textBox.getAttribute("dimStringPrefix"),o=l.textBox.getAttribute("unit"),a=this.viewer.getUnitTransfrom(d,o),s={unit:this.viewer.userModelUnit||this.viewer.modelUnit,scale:1},this.viewer.userModelUnit||(s=this.viewer.getDispalyModelUnit(n*a)),"⌒"==n[0]?l.dimString="⌒ "+(n.slice(2)*a*s.scale).toFixed(2)+this.MeasureOper.getUnitStringmap(s.unit):l.dimString=(n*a*s.scale).toFixed(2)+this.MeasureOper.getUnitStringmap(s.unit),i&&(l.dimString=i+l.dimString)):"radius"==l.textBox.getAttribute("type")&&(i=(n=l.textBox.getAttribute("dimString")).slice(0,2),r=n.slice(2),o=l.textBox.getAttribute("unit"),a=this.viewer.getUnitTransfrom(d,o),s={unit:this.viewer.userModelUnit||this.viewer.modelUnit,scale:1},this.viewer.userModelUnit||(s=this.viewer.getDispalyModelUnit(r*a)),l.dimString=i+(r*a*s.scale).toFixed(2)+this.MeasureOper.getUnitStringmap(s.unit)),l.textBox.screenX=-10,this.MeasureOper.getAndShowTextBox(l.textPos.clone(),l.dimString,l.textBox)}_e.enableBroadcast&&_e.broadcastMajor&&this.viewer.dispatchEvent({type:"broadcastEvent"})},Me.prototype.isInMeasure=function(){var e,t=!1;for(e in this.MeasureOper.coordinatedivtextPos&&this.MeasureOper.coordinatediv&&(t=!0),this.MeasureOper.faceInfo)if(!(null==this.MeasureOper.faceInfo[e]||""==this.MeasureOper.faceInfo[e]||Array.isArray(this.MeasureOper.faceInfo[e])||this.MeasureOper.faceInfo[e]instanceof THREE.Vector2||this.MeasureOper.faceInfo[e]instanceof THREE.Vector3)&&null!=this.MeasureOper.faceInfo.textBox&&null!=this.MeasureOper.faceInfo.textPos){t=!0;break}for(e in this.MeasureOper.holeInfo)if(!(null==this.MeasureOper.holeInfo[e]||""==this.MeasureOper.holeInfo[e]||Array.isArray(this.MeasureOper.holeInfo[e])||this.MeasureOper.holeInfo[e]instanceof THREE.Vector2||this.MeasureOper.holeInfo[e]instanceof THREE.Vector3)&&null!=this.MeasureOper.holeInfo.textBox&&null!=this.MeasureOper.holeInfo.textPos){t=!0;break}for(e in this.MeasureOper.edgeInfo)if(!(null==this.MeasureOper.edgeInfo[e]||""==this.MeasureOper.edgeInfo[e]||Array.isArray(this.MeasureOper.edgeInfo[e])||this.MeasureOper.edgeInfo[e]instanceof THREE.Vector2||this.MeasureOper.edgeInfo[e]instanceof THREE.Vector3)&&null!=this.MeasureOper.edgeInfo.textBox&&null!=this.MeasureOper.edgeInfo.textPos){t=!0;break}for(e in this.MeasureOper.distanceInfo)if(!(null==this.MeasureOper.distanceInfo[e]||""==this.MeasureOper.distanceInfo[e]||Array.isArray(this.MeasureOper.distanceInfo[e])||this.MeasureOper.distanceInfo[e]instanceof THREE.Vector2||this.MeasureOper.distanceInfo[e]instanceof THREE.Vector3)&&null!=this.MeasureOper.distanceInfo.textBox&&null!=this.MeasureOper.distanceInfo.textPos){t=!0;break}for(e in this.MeasureOper.lineContoursInfo)if(!(null==this.MeasureOper.lineContoursInfo[e]||""==this.MeasureOper.lineContoursInfo[e]||Array.isArray(this.MeasureOper.lineContoursInfo[e])||this.MeasureOper.lineContoursInfo[e]instanceof THREE.Vector2||this.MeasureOper.lineContoursInfo[e]instanceof THREE.Vector3)&&null!=this.MeasureOper.lineContoursInfo.textBox&&null!=this.MeasureOper.lineContoursInfo.textPos){t=!0;break}for(e in this.MeasureOper.lineAngleInfo)if(!(null==this.MeasureOper.lineAngleInfo[e]||""==this.MeasureOper.lineAngleInfo[e]||Array.isArray(this.MeasureOper.lineAngleInfo[e])||this.MeasureOper.lineAngleInfo[e]instanceof THREE.Vector2||this.MeasureOper.lineAngleInfo[e]instanceof THREE.Vector2)&&null!=this.MeasureOper.lineAngleInfo.textBox&&null!=this.MeasureOper.lineAngleInfo.textPos){t=!0;break}return t},Me.prototype.getMeasureContent=function(r){function e(e,t){var n=[],t=(n[0]=s(e.textPos),n[1]=e.dimString,n[2]=t?e.textBox.getAttribute("lineInfo"):null,!n[2]&&e.textBox&&(n[2]=e.textBox.getAttribute("group")),e.textBox);if(t)switch(e.textBox.getAttribute("type")){case"length":n[3]=0,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit"),n[6]=e.textBox.getAttribute("dimStringPrefix");break;case"radius":n[3]=1,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit");break;case"perimeter":n[3]=2,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit");break;case"area":n[3]=3,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit");break;case"coordinate":n[3]=4;break;default:n[3]=5}else if(e.textimg)switch(e.textimg.getAttribute("type")){case"length":n[3]=0,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit");break;case"radius":n[3]=1,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit");break;case"perimeter":n[3]=2,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit");break;case"area":n[3]=3,n[4]=e.textBox.getAttribute("dimString"),n[5]=e.textBox.getAttribute("unit");break;case"coordinate":n[3]=4;break;default:n[3]=5}return n}var o=this,a=(void 0===r&&(r=!1),[]),s=function(e){if(e instanceof THREE.Vector3){var t=e.clone();t.x=Number.parseFloat(Number.parseFloat(e.x).toPrecision(6)),t.y=Number.parseFloat(Number.parseFloat(e.y).toPrecision(6)),t.z=Number.parseFloat(Number.parseFloat(e.z).toPrecision(6));for(var n=0;n<a.length;n++)if(t.distanceTo(a[n])<1e-5)return n;return a.push(t.clone()),a.length-1}if(e instanceof Array){var i=[];if(e[0]instanceof THREE.Vector3)for(n=0;n<e.length;++n)i.push(Number.parseFloat(Number.parseFloat(e[n].x).toPrecision(6))),i.push(Number.parseFloat(Number.parseFloat(e[n].y).toPrecision(6))),i.push(Number.parseFloat(Number.parseFloat(e[n].z).toPrecision(6)));else for(n=0;n<e.length;n+=3)i.push(Number.parseFloat(Number.parseFloat(e[n]).toPrecision(6))),i.push(Number.parseFloat(Number.parseFloat(e[n+1]).toPrecision(6)));return i}},t=0,n=[],i=[],l=[],d=[];for(t=0;t<this.boxInfos.length;t++)n.push(e(this.boxInfos[t],!0));for(t=0;t<this.boundingboxInfos.length;t++)i.push(e(this.boundingboxInfos[t],!1));for(t=0;t<this.MeasureOper.perimeterInfos.length;t++)l.push(e(this.MeasureOper.perimeterInfos[t],!1));var c=this.isInMeasure(),h=!!c||null;for(t=0;t<this.boxInfos.length;t++)d.push(this.boxInfos[t].textPos);var u={boxInfos:n,boundingboxInfos:i,perimeterInfos:l,textPos:d,textBox:h,textLines:this.textLines,snappedPoint:this.MeasureOper.snappedPoint||null,InMeasure:c},p=(0<this.MeasureOper.perimeterInfos.length&&(u.perimeterBroadcast=this.MeasureOper.perimeterBroadcast,u.perimeterunit=this.MeasureOper.perimeterunit),"faceArea"==this.measureType&&(h=(h=this.MeasureOper.getSelectedFaceArea())*(c=this.viewer.getDispalyModelUnit(h)).scale*c.scale,u.faceArea=h,u.faceAreaunit=c.unit),"radius"==this.measureType&&this.MeasureOper.holeInfo.textPos&&this.MeasureOper.holeInfo.fstClndPos&&(u.holeInfotextPos=this.MeasureOper.holeInfo.textPos,u.holeInfofstClndPos=this.MeasureOper.holeInfo.fstClndPos),[]);if(this.rootObject){u.cs=this.rootObject.children.length;for(var f=function e(t){switch(t.objectType){case"Line":o.isInLinearguage3DAndMeasureLatestComponentMode(t)||(p.push(0),p.push(s(t.Start)),p.push(s(t.End))),o.lineargauge3DProcessedLineSet.add(t.uuid);break;case"Edge":p.push(1),p.push(s(t.Start)),p.push(s(t.End));break;case"CircleLine":p.push(2),p.push(s(t.Start)),p.push(s(t.Mid)),p.push(s(t.End));break;case"Cylinder":o.isInLinearguage3DAndMeasureLatestComponentMode(t)||(p.push(3),p.push(s(t.Start)),p.push(s(t.End)),p.push(s(t.position)),p.push(s(new THREE.Vector3(t.material.color.r,t.material.color.g,t.material.color.b)))),o.lineargauge3DProcessedLineSet.add(t.uuid);break;case"Point":p.push(4);var n=0;t.material.color.equals(o.MeasureOper.materialProjectPoint.color)&&(n=1),p.push(n),p.push(s(t.Point));break;case"Face":t.FaceInfo[4]?u.cs--:(p.push(5),p=p.concat(t.FaceInfo));break;case"AxisLine":p.push(6),p.push(s(t.Start)),p.push(s(t.End));break;case"SelLine":t.LineInfo[4]?u.cs--:(p.push(7),p=p.concat(t.LineInfo));break;case"BodyBoundingBox":p.push(8),p=p.concat(s(t.box));break;case"Contour":p.push(9),p.push(t.Vertices.length/3*2),p=p.concat(s(t.Vertices));break;case"Group":r&&(p.push(10),p.push(t.uuid),"Group"==t.parent.objectType&&"unsteady"==t.name?p.push(1):p.push(0));for(var i=0;i<t.children.length;++i)e(t.children[i])}},t=0;t<this.rootObject.children.length;++t)f(this.rootObject.children[t]);var m=[];for(t=0;t<a.length;++t){var g=a[t];m.push(g.x),m.push(g.y),m.push(g.z)}u.Ps=m}return u.rootObject=p,u},Me.prototype.createCoordinate=function(e,t){var n,i=document.createElement("div"),e=(i.className="mearesult",this.viewer.container.appendChild(i),e&&(n=e.clone(),this.MeasureOper.getAndShowTextBox(n.clone(),t,i)),{});e.dimString=t,e.textPos=n,e.textBox=i,e.textBox.setAttribute("type","coordinate"),e.textBox.setAttribute("dimString",t),this.boxInfos.push(e)},Me.prototype.setMeasureContent=function(e,d,c){void 0===d&&(d=!1),void 0===c&&(c=!1);function t(e,t,n,i,r){var o={},n=n?new THREE.Vector3(n.x,n.y,n.z):u[e[0]];if(o.textPos=n,o.dimString=e[1],Number.isInteger(o.dimString)){var a=h.MeasureOper.get2dPoint(o.textPos.clone()),s=h.MeasureOper.addAnnotationTip(o.dimString,a.x,a.y);s&&h.viewer.container.appendChild(s),o.textimg=s}else{var a,l=document.createElement("div");if(h.viewer.is2DModel?(l.className="mearesult",h.viewer.container.appendChild(l)):(l.className="section10",l.innerHTML=e[1],h.viewer.container.appendChild(l),(s=document.createElement("div")).className="sectionPoint",l.appendChild(s),c&&(Se.isMobileDevice()?(l.addEventListener("touchstart",h.MeasureOper.touchstart,!1),l.addEventListener("touchend",h.MeasureOper.touchend,!1),l.addEventListener("touchmove",h.MeasureOper.touchmove,!1)):(l.addEventListener("mousedown",h.MeasureOper.touchstart,!1),l.addEventListener("mouseup",h.MeasureOper.touchend,!1),l.addEventListener("mousemove",h.MeasureOper.touchmove,!1),l.addEventListener("mouseleave",h.MeasureOper.mouseleave,!1),l.addEventListener("mouseenter",h.MeasureOper.mouseenter,!1)),d)&&((s=document.createElement("div")).className="sectionCross",l.appendChild(s),Se.isMobileDevice()?s.addEventListener("touchend",h.MeasureOper.sectionCrossend,!1):(s.addEventListener("mousedown",h.MeasureOper.sectionCrossend,!1),s.addEventListener("mouseleave",h.MeasureOper.crossleave,!1),s.addEventListener("mouseenter",h.MeasureOper.crossenter,!1)))),l.textPos=n,e[3]<5)switch(e[3]){case 0:l.setAttribute("type","length"),l.setAttribute("dimString",e[4]),l.setAttribute("unit",e[5]),l.setAttribute("dimStringPrefix",e[6]);break;case 1:l.setAttribute("type","radius"),l.setAttribute("dimString",e[4]),l.setAttribute("unit",e[5]);break;case 2:l.setAttribute("type","perimeter"),l.setAttribute("dimString",e[4]),l.setAttribute("unit",e[5]);break;case 3:l.setAttribute("type","area"),l.setAttribute("dimString",e[4]),l.setAttribute("unit",e[5]);break;case 4:l.setAttribute("type","coordinate"),l.setAttribute("dimString",e[1])}r&&!h.viewer.is2DModel&&(t[e[2]]?(s=new THREE.Vector3(t[e[2]].start.x,t[e[2]].start.y,t[e[2]].start.z),r=new THREE.Vector3(t[e[2]].end.x,t[e[2]].end.y,t[e[2]].end.z),s=s.clone().add(r.clone()).divideScalar(2),a=i.get2dPoint(n.clone()),r=i.get2dPoint(s.clone()),(n=new THREE.Vector2(a.x-r.x,a.y-r.y)).normalize(),n.y>=n.x/2&&n.y>=-n.x/2?(l.childNodes[1].style.left="calc(50% - 6px)",l.childNodes[1].style.top="-5.5px",l.setAttribute("mobile","down")):n.y>n.x/2&&n.y<-n.x/2?(l.childNodes[1].style.left="calc(100% - 4px)",l.childNodes[1].style.top="calc(50% - 5.5px)",l.setAttribute("mobile","right")):n.y<n.x/2&&n.y<-n.x/2?(l.childNodes[1].style.left="calc(50% - 6px)",l.childNodes[1].style.top="calc(100% - 5.5px)",l.setAttribute("mobile","up")):n.y<n.x/2&&n.y>-n.x/2&&(l.childNodes[1].style.left="-5.5px",l.childNodes[1].style.top="calc(50% - 5.5px)",l.setAttribute("mobile","left")),l.setAttribute("group",t[e[2]].uuid),l.setAttribute("lineInfo",e[2])):(l.childNodes[1].style.left="calc(50% - 6px)",l.childNodes[1].style.top="calc(100% - 5.5px)",l.setAttribute("mobile","up"),l.setAttribute("group",e[2]))),o.textBox=l}return o}var h=this,u=[];if(e){var n=0;for(n=0;n<e.Ps.length;n+=3){var i=e.Ps[n],r=e.Ps[n+1],o=e.Ps[n+2],a=new THREE.Vector3(i,r,o);u.push(a)}e.InMeasure=!0;for(var s=0,l=this.boxInfos.length;s<l;s++)(f=this.boxInfos[s]).textBox&&(this.viewer.container.removeChild(f.textBox),f.textPos=null,f.textBox=null);for(this.boxInfos.splice(0,this.boxInfos.length),n=0;n<e.boxInfos.length;n++){var p=t(e.boxInfos[n],e.textLines,e.textPos[n],this.MeasureOper,!0);p&&this.boxInfos.push(p)}for(s=0,l=this.boundingboxInfos.length;s<l;s++){var f=this.boundingboxInfos[s];this.viewer.container.removeChild(f.textBox),f.textPos=null,f.textBox=null}for(this.boundingboxInfos.splice(0,this.boundingboxInfos.length),n=0;n<e.boundingboxInfos.length;n++)this.boundingboxInfos.push(t(e.boundingboxInfos[n],null,null,null,!1));for(n=0;n<this.perimeterInfos.length;n++)this.viewer.removeIconFromContainer(this.perimeterInfos[n].textimg);for(this.perimeterInfos=[],this.MeasureOper.perimeterInfos=[],n=0;n<e.perimeterInfos.length;n++)this.perimeterInfos.push(t(e.perimeterInfos[n],null,null,null,!1));for(this.textLines=[],n=0;n<e.textLines.length;n++){var m={};m.start=new THREE.Vector3(e.textLines[n].start.x,e.textLines[n].start.y,e.textLines[n].start.z),m.end=new THREE.Vector3(e.textLines[n].end.x,e.textLines[n].end.y,e.textLines[n].end.z),m.uuid=e.textLines[n].uuid,this.textLines.push(m)}e.snappedPoint?this.MeasureOper.snappedPoint=new THREE.Vector3(e.snappedPoint.x,e.snappedPoint.y,e.snappedPoint.z):this.MeasureOper.snappedPoint=null;var g=e.rootObject;if(g&&0==g.length&&(this.rootObject.children=[]),g&&0<g.length){this.rootObject.children=[];for(var v,A=null,n=0;n<g.length;){var y=null;switch(g[n++]){case 0:var E=u[g[n++]],M=u[g[n++]],y=this.viewer.is2DModel?this.MeasureOper.createLineMesh2(E,M,this.MeasureOper.materialLine,1):this.MeasureOper.createLineMesh2(E,M,_e.selectedEdgeMaterial,1);break;case 1:E=u[g[n++]],M=u[g[n++]];y=this.MeasureOper.createLineMesh3(E,M,_e.selectedEdgeMaterial,1);break;case 2:var E=u[g[n++]],w=u[g[n++]],M=u[g[n++]];y=this.MeasureOper.createLineMesh4(E,w,M,this.MeasureOper.materialLine);break;case 3:var E=u[g[n++]],M=u[g[n++]],w=u[g[n++]],b=u[g[n++]],x=this.MeasureOper.materialLine.clone();x.color.setRGB(b.x,b.y,b.z),(y=this.MeasureOper.createCylinderMesh(E,M,x)).position.copy(w);break;case 4:b=g[n++],a=u[g[n++]];y=this.MeasureOper.createPointMesh(a,0==b?this.MeasureOper.materialPoint:this.MeasureOper.materialProjectPoint,this.MeasureOper.POINTSIZE);break;case 5:var I=this.viewer.ndsModel.getBodyNode(g[n++]).uuid,T=this.viewer.ndsModel.geomManager.geoms[g[n++]].uuid,S=g[n++],B=this.viewer.brepManager.GetBrepInfoByUUidAndTopolIndex(I,T,S,"face"),x=g[n++],P=this.viewer.ndsModel.meshManager.getSingleMesh(x),C=!!g[n++];P&&B&&(B.parentObj=P,B.geometry=P.geometry,B.bodyUuid=I,B.topolIndex=S,B.meshId=x,B.matrixWorld=P.matrixWorld.clone(),y=this.MeasureOper.createFace(B,C));break;case 6:E=u[g[n++]],M=u[g[n++]];y=this.MeasureOper.createLineMesh3(E,M,this.MeasureOper.axisLine,1);break;case 7:var I=this.viewer.ndsModel.getBodyNode(g[n++]).uuid,T=this.viewer.ndsModel.geomManager.geoms[g[n++]].uuid,S=g[n++],B=this.viewer.brepManager.GetBrepInfoByUUidAndTopolIndex(I,T,S,"edge"),R=g[n++],P=this.viewer.ndsModel.meshManager.getLineSegments(R),C=!!g[n++];P&&B&&(B.parentObj=P,B.geometry=P.geometry,B.bodyUuid=I,B.matrixWorld=P.matrixWorld.clone(),B.topolIndex=S,B.lineSegId=R,y=this.MeasureOper.createLine(B,C));break;case 8:for(var O=[],L=0;L<8;L++,n+=3){var D=new THREE.Vector3(g[n],g[n+1],g[n+2]);O.push(D)}y=this.MeasureOper.createBodyBoundingBox(O);break;case 9:for(var H=[],F=g[n++],L=0;L<F;L+=2,n+=2)H.push(g[n]),H.push(g[n+1]),H.push(0);y=this.MeasureOper.createContour(H);break;case 10:R=g[n++];(y=new THREE.Group).objectType="Group",y.uuid=R,A=y,1==(v=g[n++])&&(y.name="unsteady")}y&&(d||"Group"==y.type?"Group"==y.type?0==v?(this.rootObject.add(y),this.measureTimes++):1==v&&this.rootObject.children[this.rootObject.children.length-1].add(y):null!==A&&A.add(y):this.rootObject.add(y))}}"radius"==this.measureType?e.holeInfotextPos&&e.holeInfofstClndPos&&(this.MeasureOper.holeInfo.textPos=new THREE.Vector3(e.holeInfotextPos.x,e.holeInfotextPos.y,e.holeInfotextPos.z),this.MeasureOper.holeInfo.fstClndPos=new THREE.Vector3(e.holeInfofstClndPos.x,e.holeInfofstClndPos.y,e.holeInfofstClndPos.z)):"faceArea"==this.measureType?this.viewer.dispatchEvent({type:"FaceSelectionChangeEvent",faceArea:e.faceArea,modelUnit:e.faceAreaunit}):"BoundingBox"==this.measureType&&this.MeasureOper.measureBoundingBox(!0)}},Me.prototype.isInLinearguage3DAndMeasureLatestComponentMode=function(e){return"Lineargauge3D"===this.MeasureOper.measureClass&&!this.lineargauge3DProcessedLineSet.has(e.uuid)&&this.isInMeasure()},Me.prototype.CreateVector3=function(e){for(var t in e){var n=e[t];n&&(null!=n.x&&null!=n.y&&null!=n.z?e[t]=new THREE.Vector3(n.x,n.y,n.z):"[object Object]"===Object.prototype.toString.call(n)&&this.CreateVector3(n))}},Me.prototype.setMeasureBox=function(e){e&&e.textBox&&e.textPos&&(this.textBoxBroadcast||(this.textBoxBroadcast=document.createElement("div"),this.textBoxBroadcast.className="mearesult",this.viewer.container.appendChild(this.textBoxBroadcast)),this.textPosBroadcast=new THREE.Vector3(e.textPos.x,e.textPos.y,e.textPos.z),e=this.dimString+this.unit,this.MeasureOper.getAndShowTextBox(this.textPosBroadcast.clone(),e,this.textBoxBroadcast))},Me.prototype.clearMeasureBox=function(){this.textBoxBroadcast&&(this.viewer.container.removeChild(this.textBoxBroadcast),this.textBoxBroadcast=null,this.textPosBroadcast=null),this.MeasureOper.clearFaceInfo(),this.MeasureOper.clearHoleInfo(),this.MeasureOper.clearEdgeInfo(),this.MeasureOper.clearDistanceInfo(),this.MeasureOper.clearLineAngleInfo(),this.MeasureOper.clearContoursInfo()},Me.prototype.setDimString=function(e,t){switch(this.measureType){case"pt2pt":case"PointToLine":case"PointToFace":case"LineToLine":case"LineToFace":case"AxisToPoint":case"AxisToLine":case"AxisToFace":case"LineAngle":case"LineFaceAngle":case"faceDist":this.MeasureOper.distanceInfo.dimString=e,this.MeasureOper.distanceInfo.unit=t;break;case"faceAngle":this.MeasureOper.faceInfo.dimString=e,this.MeasureOper.faceInfo.unit=t;break;case"measureEdges":this.MeasureOper.edgeInfo.dimString=e,this.MeasureOper.edgeInfo.unit=t;break;case"bodyAngle":this.MeasureOper.faceInfo.dimString=e,this.MeasureOper.faceInfo.unit=t;break;case"bodyDistance":this.MeasureOper.distanceInfo.dimString=e,this.MeasureOper.distanceInfo.unit=t;break;case"bodyEdgeLength":this.MeasureOper.edgeInfo.dimString=e,this.MeasureOper.edgeInfo.unit=t}},Me.prototype.getDimString=function(){switch(this.measureType){case"pt2pt":case"PointToLine":case"PointToFace":case"LineToLine":case"LineToFace":case"AxisToPoint":case"AxisToLine":case"AxisToFace":case"Lineargauge":case"LmPt2Pt":case"LmPt2Line":case"LmLine2Line":case"LmHole2Hole":case"LmAxis2Pt":case"LmAxis2Line":case"WallThickness":case"faceDist":case"holeDist":return{str:(this.MeasureOper.distanceInfo.dimString*this.viewer.measuringScale).toFixed(2),unit:this.MeasureOper.distanceInfo.unit};case"LineAngle":case"LineFaceAngle":return{str:this.MeasureOper.lineAngleInfo.dimString,unit:this.MeasureOper.lineAngleInfo.unit};case"faceAngle":return{str:this.MeasureOper.faceInfo.dimString,unit:this.MeasureOper.faceInfo.unit};case"measureEdges":var e="";return{str:e=""!=this.MeasureOper.edgeInfo.dimString?"⌒"==this.MeasureOper.edgeInfo.dimString[0]?"⌒ "+(this.MeasureOper.edgeInfo.dimString.slice(2)*this.viewer.measuringScale).toFixed(2):(this.MeasureOper.edgeInfo.dimString*this.viewer.measuringScale).toFixed(2):e,unit:this.MeasureOper.edgeInfo.unit};case"radius":return""==this.MeasureOper.holeInfo.dimString?{str:this.MeasureOper.holeInfo.dimString,unit:this.MeasureOper.holeInfo.unit}:{str:e=this.MeasureOper.holeInfo.dimString.slice(0,2)+(this.MeasureOper.holeInfo.dimString.slice(2)*this.viewer.measuringScale).toFixed(2),unit:this.MeasureOper.holeInfo.unit};case"coordinate":return{str:this.MeasureOper.coordinatedivdims,unit:" "};case"bodyAngle":return this.MeasureOper.lineAngleInfo.dimString?{str:this.MeasureOper.lineAngleInfo.dimString,unit:this.MeasureOper.lineAngleInfo.unit}:{str:this.MeasureOper.faceInfo.dimString,unit:this.MeasureOper.faceInfo.unit};case"bodyDistance":return{str:(this.MeasureOper.distanceInfo.dimString*this.viewer.measuringScale).toFixed(2),unit:this.MeasureOper.distanceInfo.unit};case"bodyEdgeLength":e="";return{str:e=""!=this.MeasureOper.edgeInfo.dimString?"⌒"==this.MeasureOper.edgeInfo.dimString[0]?"⌒ "+(this.MeasureOper.edgeInfo.dimString.slice(2)*this.viewer.measuringScale).toFixed(2):(this.MeasureOper.edgeInfo.dimString*this.viewer.measuringScale).toFixed(2):e,unit:this.MeasureOper.edgeInfo.unit}}},Me.prototype.createMouseZoomArea=function(){var e,t,n;this.hasZoomArea||(t=document.createElement("div"),(e=document.createElement("canvas")).id="ZoomArea",e.style.height=this.pixWidth+"px",e.style.width=this.pixWidth+"px",t.id="ZoomCanvas",t.style.zIndex=4,t.style.width=this.pixWidth+"px",t.style.height=this.pixWidth+"px",t.style.position="fixed",t.style.top="20px",t.style.left="20px",t.onmouseup=function(e){n.singleTouchEndPos.set(e.clientX,e.clientY),e.preventDefault(),n.onTouchSingleEnd(e)},t.onmousedown=function(e){n.singleTouchStartPos.set(e.clientX,e.clientY),e.preventDefault(),n.onTouchSingleStart(e)},t.appendChild(e),this.viewer.container.appendChild(t),this.hasZoomArea=!0,this.imgMouseObject=new Image,t="img/mouse_"+this.dpr.toString()+"x.png",this.imgMouseObject.src=this.viewer.serverUrl?this.viewer.serverUrl+t:t,(n=this).imgMouseObject.onload=function(){e.width=Math.floor(n.imgMouseObject.width*n.dpr),e.height=Math.floor(n.imgMouseObject.height*n.dpr)})},Me.prototype.changeMouseZoomArea=function(e){var t,n,i;this.showMouseZoomArea&&(t=document.getElementById("ZoomCanvas"))&&("inline"==t.style.display||e)&&(n=this.viewer.container.getBoundingClientRect(),i=parseInt(this.pointer.x)-this.pixWidth/2+n.left,n=parseInt(this.pointer.y)-this.pixWidth+n.top,t.style.top=n+"px",t.style.left=i+"px",i=(n=document.getElementById("ZoomArea")).getContext("2d"),n.width=this.imgMouseObject.width*this.dpr,n.height=this.imgMouseObject.height*this.dpr,i.scale(this.dpr,this.dpr),i.drawImage(this.imgMouseObject,0,0),"inline"!=t.style.display)&&e&&(t.style.display="inline")},Me.prototype.createZoomArea=function(){var e,t,n,i;this.hasZoomArea||(e=document.createElement("div"),(n=document.createElement("canvas")).id="ZoomArea",n.style.height=this.pixWidth+"px",n.style.width=this.pixWidth+"px",e.id="ZoomCanvas",e.style.zIndex=4,e.style.width=this.pixWidth+"px",e.style.height=this.pixWidth+"px",e.style.position="fixed",e.style.top="20px",e.style.left="20px",e.onmouseup=function(e){t.singleTouchEndPos.set(e.clientX,e.clientY),t.onTouchSingleEnd(e)},e.onmousedown=function(e){t.singleTouchStartPos.set(e.clientX,e.clientY),t.onTouchSingleStart(e)},e.appendChild(n),this.viewer.container.appendChild(e),this.hasZoomArea=!0,n=(t=this).viewer.getScreenCapture(null,null,null),this.imageData=n,(i=new Image).src=n,i.onload=function(){var e=t.viewer.container.getBoundingClientRect();t.clientWidthRatio=i.width/e.width,t.clientHeightRatio=i.height/e.height})},Me.prototype.clearZoomArea=function(){var e,t=document.getElementById("ZoomArea"),t=(t&&t.getContext("2d").clearRect(0,0,this.pixWidth,this.pixWidth),document.getElementById("ZoomCanvas"));t&&(e=document.getElementById("ZoomArea"),t.removeChild(e),this.viewer.container.removeChild(t),this.hasZoomArea=!1),this.imageData=null},Me.prototype.getZoomAreaVisible=function(){var e=document.getElementById("ZoomCanvas");return!!e&&"inline"==e.style.display},Me.prototype.invisible=function(){var e=document.getElementById("ZoomCanvas"),e=(e&&(e.style.display="none"),document.getElementById("ZoomArea"));e&&e.getContext("2d").clearRect(0,0,this.pixWidth,this.pixWidth),this.imageData=null},Me.prototype.changeZoomArea=function(e){var r,t,o,n=document.getElementById("ZoomCanvas");this.clientHeightRatio&&n&&("inline"==n.style.display||e)&&(this.imageData?t=this.imageData:(t=this.viewer.getScreenCapture(null,null,null),this.imageData=t),t=this.viewer.getScreenCapture(null,null,null),(r=new Image).src=t,t=this.viewer.container.getBoundingClientRect(),r.width=t.width*this.clientWidthRatio,r.height=t.height*this.clientHeightRatio,o=this,r.onload=function(){var e=o.pixWidth;o.getImagePortion(r,e,e,o.pointer.x*o.clientWidthRatio-e/2,o.pointer.y*o.clientHeightRatio-e/2,1);var t,n,i=document.getElementById("ZoomArea").getContext("2d");i.moveTo(e/2-20,e/2),i.lineTo(e/2+20,e/2),i.moveTo(e/2,e/2-20),i.lineTo(e/2,e/2+20),i.lineWidth=1,i.strokeStyle="#FF0000",i.stroke(),o.MeasureOper.snappedPoint&&(n=o.MeasureOper.get2dPoint(o.MeasureOper.snappedPoint.clone()),t=o.pointer.x*o.clientWidthRatio-n.x,n=o.pointer.y*o.clientHeightRatio-n.y,i.fillStyle="#00FFFF",i.beginPath(),i.arc(e/2-t,e/2-n,2,0,2*Math.PI),i.closePath(),i.fill())},"inline"!=n.style.display)&&e&&(n.style.display="inline")},Me.prototype.getImagePortion=function(e,t,n,i,r,o){var a=document.getElementById("ZoomArea"),s=a.getContext("2d"),a=(a.width=t,a.height=n,document.createElement("canvas")),l=a.getContext("2d");a.width=e.width,a.height=e.height,l.drawImage(e,0,0),s.drawImage(a,i,r,t*o,n*o,0,0,t,n)},Me.prototype.resetMeasureTimesWithMeasureContent=function(e){e.boxInfos&&(this.measureTimes=e.boxInfos.length)},function(e){g.call(this,e),this.type="OpOrbit"}),Yn=(Wn.prototype=Object.create(g.prototype),Wn.prototype.onOpOrbit=function(){var e=new THREE.Vector2,t=new THREE.Vector2,n=(e.copy(this.getMouseOnCircle(this.pointerOld.x,this.pointerOld.y)),t.copy(this.getMouseOnCircle(this.pointer.x,this.pointer.y)),t.x-e.x),t=t.y-e.y;this.rotate(new THREE.Vector3(n,t,0))},Wn.prototype.onLMouseMove=function(e){this.onOpOrbit()},Wn.prototype.onTouchSingleMove=function(e){this.onOpOrbit()},function(e){g.call(this,e),this.type="OpPan"}),Xn=(Yn.prototype=Object.create(g.prototype),Yn.prototype.onOpPan=function(){var e=this.pointer.x-this.pointerOld.x,t=this.pointer.y-this.pointerOld.y;this.pan(new THREE.Vector3(-e,t,0))},Yn.prototype.onLMouseMove=function(e){this.onOpPan()},Yn.prototype.onTouchSingleMove=function(e){this.onOpPan()},function(e){g.call(this,e),this.type="OpZoom"}),Qn=(Xn.prototype=Object.create(g.prototype),Xn.prototype.onOpZoom=function(){var e=this.pointer.y-this.pointerOld.y;this.zoom(new THREE.Vector3(0,0,5*e))},Xn.prototype.onLMouseMove=function(e){this.onOpZoom()},Xn.prototype.onTouchSingleMove=function(e){this.onOpZoom()},function(e){g.call(this,e),this.type="OpZoomWindow",this.clearCanvas2D=function(){var e=this.viewer.renderer.getPixelRatio();this.viewer.canvas2D.getContext("2d").clearRect(0,0,window.innerWidth*e,window.innerHeight*e),this.viewer.Rectangle=[]},this.zoomToRect=function(e,t,n,i){var r,o=this.viewer.container.getBoundingClientRect(),a=Math.abs(n-e),s=Math.abs(i-t);0!=a&&0!=s&&(e=[.5*(e+n),.5*(t+i)],n=new THREE.Vector3,null!=(t=this.viewer.getIntersectionPtByScreenPt(e,!1))?n.set(t.coords[0],t.coords[1],t.coords[2]):(i=this.viewer.clientCoordToModelCoord(e),n.set(i[0],i[1],i[2])),t=this.viewer.camera.position,i=(e=this.viewer.camera.target.clone().sub(t)).length(),e.normalize(),a=i/(i=Math.min(o.width/a,o.height/s)),this.viewer.is2DModel?(o=(n.z-t.z)/e.z,s=t.clone().addScaledVector(e,o),o=(t=this.viewer.camera.position.clone().sub(s)).length(),t.normalize(),r=(s=this.viewer.camera.target.clone().sub(s)).length(),s.normalize(),(t=t.clone()).multiplyScalar(o/i),t.add(n),(o=s.clone()).multiplyScalar(r/i),o.add(n),this.viewer.camera.position.set(t.x,t.y,t.z),this.viewer.camera.setCameraTarget(o)):(e.multiplyScalar(-a),e.add(n),this.viewer.camera.position.set(e.x,e.y,e.z),this.viewer.camera.setCameraTarget(n)),this.viewer.camera.updateProjectionMatrix(),this.viewer.render())},this.drawRectangle=function(e,t,n,i){this.clearCanvas2D();var r=this.viewer.canvas2D.getContext("2d");r.strokeStyle="#00FFFF",r.setLineDash([5,5]),r.beginPath(),r.moveTo(e,t),r.lineTo(n,t),r.lineTo(n,i),r.lineTo(e,i),r.lineTo(e,t),r.closePath(),r.stroke(),r.setLineDash([]),this.viewer.Rectangle.push(e),this.viewer.Rectangle.push(n),this.viewer.Rectangle.push(t),this.viewer.Rectangle.push(i)}}),Zn=(Qn.prototype=Object.create(g.prototype),Qn.prototype.release=function(){this.clearCanvas2D(),g.prototype.release.call(this)},Qn.prototype.onLMouseDown=function(e){e.preventDefault(),g.prototype.onLMouseDown.call(this,e)},Qn.prototype.onLMouseMove=function(e){e.preventDefault();e=this.viewer.renderer.getPixelRatio();this.drawRectangle(this.lMouseDown.x*e,this.lMouseDown.y*e,this.pointer.x*e,this.pointer.y*e)},Qn.prototype.onLMouseUp=function(e){var t=Date.now();e.preventDefault(),g.prototype.onLMouseUp.call(this,e),this.clearCanvas2D(),this.zoomToRect(this.lMouseDown.x,this.lMouseDown.y,this.lMouseUp.x,this.lMouseUp.y),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[框选-放大]",t)},Qn.prototype.onTouchSingleStart=function(e){e.preventDefault(),g.prototype.onTouchSingleStart.call(this,e)},Qn.prototype.onTouchSingleMove=function(e){e.preventDefault();e=this.viewer.renderer.getPixelRatio();this.drawRectangle(this.singleTouchStartPos.x*e,this.singleTouchStartPos.y*e,this.pointer.x*e,this.pointer.y*e)},Qn.prototype.onTouchSingleEnd=function(e){var t=Date.now();e.preventDefault(),g.prototype.onTouchSingleEnd.call(this,e),this.clearCanvas2D(),this.zoomToRect(this.singleTouchStartPos.x,this.singleTouchStartPos.y,this.singleTouchEndPos.x,this.singleTouchEndPos.y),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[框选-放大]",t)},t(17),t(18),function(e){g.call(this,e),this.type="OpSelectWindow",this.clearCanvas2D=function(){var e=this.viewer.renderer.getPixelRatio();this.viewer.canvas2D.getContext("2d").clearRect(0,0,window.innerWidth*e,window.innerHeight*e),this.viewer.Rectangle=[]},this.selectRect=function(e,t,n,i){this.viewer.selectionManager.selectBodyByRect(e,t,n,i),this.viewer.render()},this.drawRectangle=function(e,t,n,i,r){this.clearCanvas2D();var o=this.viewer.canvas2D.getContext("2d");o.strokeStyle=r||"#00FFFF",o.setLineDash([5,5]),o.beginPath(),o.moveTo(e,t),o.lineTo(n,t),o.lineTo(n,i),o.lineTo(e,i),o.lineTo(e,t),o.closePath(),o.stroke(),o.setLineDash([]),this.viewer.Rectangle.push(e),this.viewer.Rectangle.push(n),this.viewer.Rectangle.push(t),this.viewer.Rectangle.push(i)},this.viewer.selectionManager.clearSelection(),this.viewer.pmiObject&&this.viewer.deselectPMIObject(this.viewer.pmiObject),this.viewer.render()}),qn=(Zn.prototype=Object.create(g.prototype),Zn.prototype.release=function(){this.clearCanvas2D(),g.prototype.release.call(this)},Zn.prototype.onLMouseDown=function(e){e.preventDefault(),g.prototype.onLMouseDown.call(this,e)},Zn.prototype.onLMouseMove=function(e){e.preventDefault();e=this.viewer.renderer.getPixelRatio();this.drawRectangle(this.lMouseDown.x*e,this.lMouseDown.y*e,this.pointer.x*e,this.pointer.y*e)},Zn.prototype.onLMouseUp=function(e){var t=Date.now(),e=(e.preventDefault(),g.prototype.onLMouseUp.call(this,e),this.clearCanvas2D(),this.lMouseDown.x),n=this.lMouseDown.x,i=this.lMouseDown.y,r=this.lMouseDown.y;this.lMouseUp.x<e&&(e=this.lMouseUp.x),this.lMouseUp.x>n&&(n=this.lMouseUp.x),this.lMouseUp.y<i&&(i=this.lMouseUp.y),this.lMouseUp.y>r&&(r=this.lMouseUp.y),this.selectRect(e,i,n,r),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[框选-高亮]",t)},Zn.prototype.onTouchSingleStart=function(e){e.preventDefault(),g.prototype.onTouchSingleStart.call(this,e)},Zn.prototype.onTouchSingleMove=function(e){e.preventDefault();e=this.viewer.renderer.getPixelRatio();this.drawRectangle(this.singleTouchStartPos.x*e,this.singleTouchStartPos.y*e,this.pointer.x*e,this.pointer.y*e)},Zn.prototype.onTouchSingleEnd=function(e){var t=Date.now(),e=(e.preventDefault(),g.prototype.onTouchSingleEnd.call(this,e),this.clearCanvas2D(),this.singleTouchStartPos.x),n=this.singleTouchStartPos.x,i=this.singleTouchStartPos.y,r=this.singleTouchStartPos.y;this.singleTouchEndPos.x<e&&(e=this.singleTouchEndPos.x),this.singleTouchEndPos.x>n&&(n=this.singleTouchEndPos.x),this.singleTouchEndPos.y<i&&(i=this.singleTouchEndPos.y),this.singleTouchEndPos.y>r&&(r=this.singleTouchEndPos.y),this.selectRect(e,i,n,r),this.viewer.logOperatorTime&&this.viewer.logOperatorTimeShow("[框选-高亮]",t)},function(e){var t=e.viewer,n=t.camera,i=e.objects,r=e.domElement,o=e.group,a=null,s=(new THREE.Plane,new THREE.Raycaster),l=new THREE.Vector2,d=new THREE.Vector2,c=(new THREE.Vector3,null),h=!1,u=!0,p=!1,f=!1,m=!(this._enabled=!0),g=1,v=this;function A(e,t){if(e)switch(e){case"translate":v.setTransformEnable();break;case"rotate":v.setRotateEnable();break;case"both":v.setTransRotEnable()}Se.isMobileDevice()?(r.addEventListener("touchstart",E,!1),r.addEventListener("touchmove",M,!1),r.addEventListener("touchend",w,!1)):(r.addEventListener("mousemove",M,!1),r.addEventListener("mousedown",E,!1),r.addEventListener("mouseup",w,!1)),u?((a=new _(n,r,t)).setMode("translate"),a.setSpace("local"),o.add(a)):p?((a=new _(n,r,t)).setMode("rotate"),a.setSpace("local"),o.add(a)):f&&((a=new _(n,r,t)).setMode("both"),a.setSpace("local"),o.add(a)),v.setSize(g),m=!0}function y(){null!=a&&a.detach(a.object),Se.isMobileDevice()?(r.removeEventListener("touchstart",E,!1),r.removeEventListener("touchmove",M,!1),r.removeEventListener("touchend",w,!1)):(r.removeEventListener("mousemove",M,!1),r.removeEventListener("mousedown",E,!1),r.removeEventListener("mouseup",w,!1))}function E(e){h=!1,e.preventDefault(),e.stopPropagation();var t=e,e=(Se.isMobileDevice()&&0<e.changedTouches.length&&(t=e.changedTouches[0]),r.getBoundingClientRect()),e=(l.x=(t.clientX-e.left)/e.width*2-1,l.y=2*-((t.clientY-e.top)/e.height)+1,d.x=t.clientX,d.y=t.clientY,n instanceof ge?n.setCastRay(s,l.x,l.y):s.setFromCamera(l,n),s.intersectObjects(i,!1));0<e.length&&(c=e[0].object,r.style.cursor="move",v.dispatchEvent({type:"mousedown",object:c}))}function M(e){var t=e;Se.isMobileDevice()&&0<e.changedTouches.length&&(t=e.changedTouches[0]),Math.abs(t.clientX-d.x)<1&&Math.abs(t.clientY-d.y)<1||(e.preventDefault(),e.stopPropagation(),h=!0)}function w(e){null!=e&&e.preventDefault(),h?v.dispatchEvent({type:"mouseup",object:c}):(a.detach(a.object),null!=c&&v.attachTo(c)),t.render(),c=null,r.style.cursor="auto"}this.isActive=function(){return m},this.getCurrAttachObj=function(){if(a)return a.object},this.setSize=function(e){g=e,a&&a.setSize(e)},this.addEventListener=function(e,t){a&&a.addEventListener(e,t)},this.getCurrentControls=function(){return a},this.getObjByName=function(e){return i[e]},this.attachTo=function(e){a.detach(a.object),null!=e&&a&&a.attach(e),t.render()},this.detach=function(){a&&a.detach(a.object)},this.isSelected=function(){var e=!1;return e=a?a.isSelected():e},this.update=function(){a&&(a.update(),a.updateMatrixWorld(!0))},this.setTransformEnable=function(){f=p=!(u=!0)},this.setRotateEnable=function(){u=!(p=!0)},this.setTransRotEnable=function(){p=u=!(f=!0)},this.setEnabled=function(e){e?this._enabled||A():this._enabled&&y(),this._enabled=e},this.activate=A,this.deactivate=y,this.dispose=function(){y()}}),Kn=(qn.prototype=Object.create(THREE.EventDispatcher.prototype),qn.prototype.constructor=qn,["#if NUM_CLIPPING_PLANES > 0","#if ! defined( PHYSICAL ) && ! defined( PHONG )","vViewPosition = - mvPosition.xyz;","#endif","vec4 tempWorldPosition = modelMatrix * vec4( position, 1.0 );","vClippingWorldPosition = tempWorldPosition.xyz;","#endif"].join("\n"),["#if NUM_CLIPPING_PLANES > 0","#if ! defined( PHYSICAL ) && ! defined( PHONG )","varying vec3 vViewPosition;","#endif","varying vec3 vClippingWorldPosition;","#endif"].join("\n"),["#if NUM_CLIPPING_PLANES > 0 ","uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];","varying vec3 vClipPosition;","bvec2 checkClippingPlanes() {","bool isCut = false;","bool isCutEdge = false;","#if defined( STANDARD )","for (int i=0; i<NUM_CLIPPING_PLANES; i++) {","vec4 plane = clippingPlanes[ i ];","float dotPlane = dot(vec4(vViewPosition, -1.0), plane);","isCut = isCut || (dotPlane > 0.0 );","if (!isCut) {","isCutEdge = isCutEdge || (abs(dotPlane) < abs(0.0012 * length(vViewPosition)));","}","}","#else","vec4 plane;","#pragma unroll_loop_start","for (int i=0; i<NUM_CLIPPING_PLANES; i++) {","plane = clippingPlanes[ i ];","if ( dot( vClipPosition, plane.xyz ) > plane.w ) isCut = true;","}","#pragma unroll_loop_end","#endif","return bvec2(isCut,isCutEdge);","}","#endif"].join("\n")),Jn=["#if NUM_CLIPPING_PLANES > 0 && !defined( NOCLIPPING )","bvec2 clipRetVec2NDS = checkClippingPlanes();","if (clipRetVec2NDS.x) discard;","#endif"].join("\n"),e=["#if NUM_CLIPPING_PLANES > 0","if(clipRetVec2NDS.y) gl_FragColor = vec4(0.8, 0.4, 0.298, 1.0);","#endif","}"].join("\n"),$n=(ei=THREE.ShaderChunk.meshphong_frag).lastIndexOf("}"),ei=ei.substr(0,$n)+e,$n=(ti=THREE.ShaderChunk.meshphysical_frag).lastIndexOf("}"),ti=ti.substr(0,$n)+e,ni=(["#if NUM_CLIPPING_PLANES > 0","for ( int i = 0; i < NUM_CLIPPING_PLANES; ++ i ) {","vec4 plane = clippingPlanes[ i ];","if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;","}","if (!gl_FrontFacing) {","gl_FragColor = vec4(0.8, 0.4, 0.298, 1.0);","return;","}","#endif"].join("\n"),{defines:{NUM_CLIPPING_PLANES_NDS:1},uniforms:{clipping:{color:{type:"c",value:new THREE.Color(16711680)},clippingPlaneNDS:{type:"v4v",value:[0,0,-1,0]}},caps:{color:{type:"c",value:new THREE.Color(.8,.4,.298)}}},vertex:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),vertexClipping:["varying vec4 worldPosition;","varying vec3 camPosition;","void main() {","worldPosition = modelMatrix * vec4( position, 1.0 );","camPosition = cameraPosition;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragment:["uniform vec3 color;","void main( void ) {","gl_FragColor = vec4( color , 1.0 );","}"].join("\n"),fragmentClippingFront:["uniform vec3 color;","uniform vec4 clippingPlaneNDS[NUM_CLIPPING_PLANES_NDS];","varying vec4 worldPosition;","varying vec3 camPosition;","void main() {","#if NUM_CLIPPING_PLANES_NDS > 0","for ( int i = 0; i < NUM_CLIPPING_PLANES_NDS; ++ i ) {","vec4 plane = clippingPlaneNDS[i];","if ( -dot( worldPosition.xyz, plane.xyz ) > plane.w && -dot( camPosition, plane.xyz ) > plane.w) discard;","else {","gl_FragColor = vec4( color , 1.0 );","}","}","#endif","}"].join("\n")}),ii={vertex:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragment:["uniform vec3 color;","uniform vec2 hatchParams;","uniform vec3 hatchTintColor;","uniform float hatchTintIntensity;","vec4 calculateHatchPattern(vec2 hatchParams, vec2 coord, vec4 fragColor, vec3 hatchTintColor, float hatchTintIntensity ) {","float hatchSlope = hatchParams.x;","float hatchPeriod = hatchParams.y;","if (abs(hatchSlope) <= 1.0) {","float hatchPhase = coord.y - hatchSlope * coord.x;","float dist = abs(mod((hatchPhase), (hatchPeriod)));","if (dist < 2.0) {","fragColor = vec4(0.0,0.0,0.0,1.0);","} else {","fragColor.xyz = mix(fragColor.xyz, hatchTintColor, hatchTintIntensity);","}","} else {","float hatchPhase = - coord.y / hatchSlope + coord.x;","float dist = abs(mod((hatchPhase), (hatchPeriod)));","if (dist < 1.0) {","fragColor = vec4(0.0,0.0,0.0,1.0);","} else {","fragColor.xyz = mix(fragColor.xyz, hatchTintColor, hatchTintIntensity);","}","}","return fragColor;","}","void main( void ) {","gl_FragColor = vec4( color , 1.0 );","gl_FragColor = calculateHatchPattern(hatchParams, gl_FragCoord.xy, gl_FragColor, hatchTintColor, hatchTintIntensity);","}"].join("\n")},ri=function(e,t,n){THREE.Mesh.call(this,e,t,!1),this.tempVector3=new THREE.Vector3,this.plane=n,this.planeVec=new THREE.Vector4(n.normal.x,n.normal.y,n.normal.z,n.constant),this.connectivity=[],this.outlines=[]},oi=(ri.prototype=Object.create(THREE.Mesh.prototype),(ri.prototype.constructor=ri).prototype.update=function(){this.plane.normal.set(0,0,-1),this.plane.normal.applyQuaternion(this.quaternion);var e=this.plane.normal,t=-1*this.getWorldPosition(this.tempVector3).dot(e);this.planeVec.set(e.x,e.y,e.z,t),this.plane.constant=t},function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager}),ai=(oi.prototype={constructor:oi,load:function(e,t,n,i,r,o){var a=this,s="?time=",l=(0<t.indexOf("?")&&(s="&time="),null!=o?0==o&&(t=t+s+Date.now()):_e.avoidCaching&&(t=t+s+Date.now()),new XMLHttpRequest);if(l.open("GET",t,!0),e)for(var d in e)l.setRequestHeader(d,e[d]);l.addEventListener("load",function(e){404==this.status&&r?r():(n&&n(this.response,a.attribute),a.manager.itemEnd(t))},!1),void 0!==i&&l.addEventListener("progress",function(e){i(e)},!1),void 0!==r&&l.addEventListener("error",function(e){r(e)},!1),void 0!==this.crossOrigin&&(l.crossOrigin=this.crossOrigin),void 0!==this.responseType&&(l.responseType=this.responseType),null!=this.timeout&&(l.timeout=this.timeout),l.send(null),a.manager.itemStart(t)},setResponseType:function(e){this.responseType=e},setCrossOrigin:function(e){this.crossOrigin=e},setTimeout:function(e){this.timeout=e}},function(e,t,n){var i=this,r=(this.viewer=e,new ve.Dialog({id:"dlgExplodeTool",className:"dialog",callbackEvent:s,noTitlebar:!0,noScrollbar:!0})),o=(r.addEventListener("resize",function(e){a(e)}),r.setVisibility(!1),r.domElement.style.minHeight="20px",r.setSize(120,20),null!=n.toolbarButtonSize&&"small"==n.toolbarButtonSize?r.setPadding({left:4,right:4,top:4,bottom:4}):r.setPadding({left:10,right:10,top:10,bottom:10}),i.viewer.getToolBarAutoHideFlag()&&r.setOpacity(_e.dialogOpacity),t.setPopupDialog(r),e.container.appendChild(r.domElement),this.dialog=r,new ve.Slider({id:"sliderExplodeTool",className:"explode-tool-slider",callbackEvent:s}));function a(e){var t,n;null!=e.left&&null!=e.bottom?(r.setLeft(e.left),r.setBottom(e.bottom)):(t=(e=i.viewer.tlbOperator).getChildElement("btnExplode").domElement,t=(e=e.domElement).offsetLeft+t.offsetLeft,n=parseInt(Se.getStyle(e,"padding-top"))+parseInt(Se.getStyle(e,"padding-bottom"))+parseInt(Se.getStyle(e,"border-top-width"))+parseInt(Se.getStyle(e,"border-bottom-width"))+parseInt(Se.getStyle(e,"margin-bottom")),e=e.offsetHeight+n,r.setLeft(t),r.setBottom(e))}function s(e){var t=e.target.domElement.id;if("dlgExplodeTool"===t){t=e;if((!_e.enableBroadcast||_e.broadcastMajor)&&i.viewer.getToolBarAutoHideFlag()){var e=t.event.type,n=t.target;switch(e){case"mouseenter":n.deleteOpacity();break;case"mouseleave":n.setOpacity(_e.toolbarOpacity);break;case"mouseover":n.deleteOpacity();break;case"mouseout":n.setOpacity(_e.toolbarOpacity);break;case"resize":a()}}}}o.domElement.max="100",o.domElement.step="1",r.domElement.appendChild(o.domElement),o.domElement.oninput=function(e){_e.enableBroadcast&&!_e.broadcastMajor||i.viewer.explodeModel(o.domElement.value/100)},o.domElement.onchange=function(e){_e.enableBroadcast&&!_e.broadcastMajor||i.viewer.explodeModel(o.domElement.value/100)},this.resetExplosion=function(){o.domElement.value=0,i.viewer.explodeModel(0)},this.getExplodeDlgValue=function(){return o.domElement.value},this.setExplodeDlgValue=function(e){o.domElement.value=e}}),si=(ai.prototype=Object.create(THREE.EventDispatcher.prototype),Ln.prototype=Object.create(THREE.EventDispatcher.prototype),function(e){g.call(this,e),this.type="OpAddComment",this.lastSprite=null,this.addCommentDlg=new Ln(e,this),this.addCommentDlg.show(!1),this.viewer.canvas2D.style.display="",this.getClickPosition=function(){return this.lastSprite}}),li=(si.prototype=Object.create(g.prototype),si.prototype.release=function(){this.lastSprite=null,this.viewer.canvas2D.getContext("2d").clearRect(0,0,window.innerWidth,window.innerHeight),this.addCommentDlg.release(),this.addCommentDlg=null,this.update(),this.render(),g.prototype.release.call(this)},si.prototype.update=function(){g.prototype.update.call(this)},si.prototype.onLMouseClick=function(e){e.preventDefault(),this.onClickEvent(e.clientX,e.clientY)},si.prototype.onTouchSingleStart=function(e){e.preventDefault(),this.onClickEvent(e.touches[0].clientX,e.touches[0].clientY)},si.prototype.onClickEvent=function(e,t){var n=this.viewer,i=n.renderer.domElement,r=n.renderer.getPixelRatio(),o=e*r/i.width*2-1,r=2*-(t*r/i.height)+1,i=new THREE.Raycaster,o=(n.camera.setCastRay(i,o,r),i.intersectObjects(n.selectionManager.getTargetList()));0<o.length&&(this.lastSprite=o[0].point,this.viewer.getCommentsManager().renderComments(),r=this.viewer.canvas2D.getContext("2d"),i=this.get2dPoint(o[0].point.clone()),r.beginPath(),r.arc(i.x,i.y,4,0,2*Math.PI),r.fillStyle="red",r.fill(),this.addCommentDlg.show(!0,e,t))},si.prototype.FindParentElement=function(e){return null==e?null:e instanceof THREE.Object3D&&("RevitElement"===e.type||"Element"===e.type)?e:this.FindParentElement(e.parent)},si.prototype.pan=function(e){g.prototype.pan.call(this,e),this.reCalculatePos()},si.prototype.zoom=function(e,t){g.prototype.zoom.call(this,e,t),this.reCalculatePos()},si.prototype.rotate=function(e){this.viewer.is2DViewer||(g.prototype.rotate.call(this,e),this.reCalculatePos())},si.prototype.get2dPoint=function(e){e.project(this.viewer.camera);var t=this.viewer.renderer.domElement.width/2,n=this.viewer.renderer.domElement.height/2;return{x:Math.round(e.x*t+t),y:Math.round(-e.y*n+n)}},si.prototype.reCalculatePos=function(){this.viewer.getCommentsManager().renderComments();var e,t=this.viewer.canvas2D.getContext("2d");t.clearRect(0,0,window.innerWidth,window.innerHeight),t.fillStyle="red",this.lastSprite&&(e=this.get2dPoint(this.lastSprite.clone()),t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fill())},function(e){g.call(this,e),this.oldClearColor=new THREE.Color,this.type="OpAnnotation",this.interpPts=[],this.annotationUUID=null}),di=(li.prototype=Object.create(g.prototype),li.prototype.onLMouseDown=function(e){g.prototype.onLMouseDown.call(this,e),this.onAnnotationStart()},li.prototype.onLMouseMove=function(e){"pt"==this.viewer.getAnnotationMode()?g.prototype.onLMouseMove.call(this,e):this.onAnnotationMove()},li.prototype.onLMouseUp=function(e){g.prototype.onLMouseUp.call(this,e),this.onAnnotationEnd()},li.prototype.onTouchSingleStart=function(e){g.prototype.onTouchSingleStart.call(this,e),this.onAnnotationStart()},li.prototype.onTouchSingleMove=function(e){"pt"==this.viewer.getAnnotationMode()?g.prototype.onTouchSingleMove.call(this,e):this.onAnnotationMove()},li.prototype.onTouchSingleEnd=function(e){g.prototype.onTouchSingleEnd.call(this,e),this.onAnnotationEnd()},li.prototype.onAnnotationStart=function(e){this.interpPts=[],this.annotationUUID=THREE.Math.generateUUID(),this.interpPts.push(new THREE.Vector3(this.pointer.x,this.pointer.y,0)),li.prototype.onLMouseDbClick=function(e){g.prototype.onLMouseDbClick.call(this,e)}},li.prototype.onAnnotationMove=function(e){if(0<this.interpPts.length&&(!this.viewer.animationsManager||this.viewer.animationsManager.isAnimationsExited())){var t=this.viewer.getAnnotationMode();if("pt"!=t){var n=this.viewer.renderer.getPixelRatio(),t=this.viewer.renderer.domElement.width/(n*_e.lineSegAnnotationGridCount),i=this.viewer.renderer.domElement.height/(n*_e.lineSegAnnotationGridCount);if(t*t+i*i<this.pointer.distanceToSquared(this.interpPts[this.interpPts.length-1])&&this.interpPts.push(new THREE.Vector3(this.pointer.x,this.pointer.y,0)),1<this.interpPts.length){for(var r=new THREE.Matrix4,o=(r.multiplyMatrices(this.viewer.camera.matrixWorld,r.getInverse(this.viewer.camera.projectionMatrix)),this.viewer.renderer.domElement),a=[],s=new THREE.Vector3,l=0;l<this.interpPts.length;++l)s.set(this.interpPts[l].x*n/o.width*2-1,2*-(this.interpPts[l].y*n/o.height)+1,.5),s.applyMatrix4(r),a.push(s.x),a.push(s.y),a.push(s.z);this.viewer.showAnnotation({version:"2",type:"lineSeg",coords:a,uuid:this.annotationUUID,cameraInfo:this.viewer.getCameraInfo()},!1)}}}},li.prototype.onAnnotationEnd=function(e){this.onAnnotationDone()},li.prototype.onAnnotationDone=function(){var e=this.viewer;if(e.isSmoothTranslationDone()){var t=!1;if(this.viewer.animationsManager&&!this.viewer.animationsManager.isAnimationsExited()&&(t=!0),"pt"!=e.getAnnotationMode()||1!=this.interpPts.length||!(3<Math.abs(this.pointer.x-this.interpPts[0].x)||3<Math.abs(this.pointer.y-this.interpPts[0].y))){var n=e.renderer.domElement,i=e.renderer.getPixelRatio();if(0<this.interpPts.length){e.annotationsManager||(e.annotationsManager=new nn(e));var r=e.annotationsManager.getRenderTarget(),o=this.viewer.scene.overrideMaterial,a=this.viewer.renderer.getClearColor(this.oldClearColor).clone(),s=this.viewer.renderer.getClearAlpha(),l=(e.ndsModel||(e.scene.overrideMaterial=e.annotationsManager.getDepthRGBAMaterial(),e.renderer.setClearColor(16777215),e.scene.remove(e.lightControls._scene),e.renderer.render(e.scene,e.camera,r,!0),e.scene.add(e.lightControls._scene),e.scene.overrideMaterial=o),new THREE.Matrix4);l.multiplyMatrices(e.camera.matrixWorld,l.getInverse(e.camera.projectionMatrix));if(1==this.interpPts.length){var d,c,h=[],u="",p=null,o=(e.ndsModel?(S=[this.interpPts[0].x,this.interpPts[0].y,this.interpPts[0].z],(T=e.getIntersectionPtByScreenPt(S))&&(h=T.coords,u=T.locationObjectUUID,p=T.locationObject)&&p.id&&0<=p.id&&(x=e.ndsModel.getBodyTranslate(p),h[0]-=x[0],h[1]-=x[1],h[2]-=x[2])):((E=new Uint8Array(4))[0]=E[1]=E[2]=E[3]=0,e.renderer.readRenderTargetPixels(r,this.interpPts[0].x*i,r.height-this.interpPts[0].y*i,1,1,E),d=10,c=[],e.scene.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e.materialAnnotationRecord=e.material,e instanceof THREE.Line||e instanceof THREE.LineSegments?e.material=new THREE.LineBasicMaterial:(e.material=new THREE.MeshBasicMaterial,e.material.side=THREE.DoubleSide),e.material.color.setHex(d),c[d]=e,d+=10)}),e.scene.overrideMaterial=null,e.renderer.render(e.scene,e.camera,r,!0),e.scene.overrideMaterial=o,e.scene.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e.material=e.materialAnnotationRecord,e.materialAnnotationRecord=void 0)}),(x=new Uint8Array(4))[0]=x[1]=x[2]=x[3]=0,e.renderer.readRenderTargetPixels(r,this.interpPts[0].x*i,r.height-this.interpPts[0].y*i,1,1,x),e.renderer.setRenderTarget(null),e.renderer.setClearColor(a,s),253<x[0]&&253<x[1]&&253<x[2]||(o=x[0]<<16|x[1]<<8|x[2],c[o]&&(u=(p=c[o]).uuid)),253<E[0]&&253<E[1]&&253<E[2]&&253<E[3]||(w=E[0]*(M=255/256)/16777216+E[1]*M/65536+E[2]*M/256+E[3]*M,w=2*(w/=255)-1,this.interpPts[0].set(this.interpPts[0].x*i/n.width*2-1,2*-(this.interpPts[0].y*i/n.height)+1,w-=4e-8*w),this.interpPts[0].applyMatrix4(l),""!=u&&p&&((x=new THREE.Matrix4).getInverse(p.matrixWorld),this.interpPts[0].applyMatrix4(x)),h.push(this.interpPts[0].x),h.push(this.interpPts[0].y),h.push(this.interpPts[0].z))),e.getCameraInfo());e.ndsModel||((x=new THREE.Matrix4).getInverse(e.modelRootObject.matrixWorld),(I=new THREE.Vector3).set(o.position.x,o.position.y,o.position.z),I.applyMatrix4(x),o.position.x=I.x,o.position.y=I.y,o.position.z=I.z,I.set(o.target.x,o.target.y,o.target.z),I.applyMatrix4(x),o.target.x=I.x,o.target.y=I.y,o.target.z=I.z,I.set(o.up.x,o.up.y,o.up.z),I.transformDirection(x),o.up.x=I.x,o.up.y=I.y,o.up.z=I.z),0<h.length&&""!=u&&p&&(li.prototype.onLMouseDbClick=function(e){},b=e.getLineSegAnnotationStyle(),t?e.dispatchEvent({type:"annotationEventForAnimation",userData:{version:"4",type:"pt",ownerType:"animation",ownerUuid:e.animationsManager.getCurrentAnimationUuid(),timeStart:e.animationsManager.getCurrentAnimationTime(),timeEnd:e.animationsManager.getCurrentAnimationDuration(),coords:h,uuid:this.annotationUUID,strokeStyle:b.strokeStyle,locationObjectUUID:u,cameraInfo:o}}):e.dispatchEvent({type:"annotationEvent",userData:{version:"4",type:"pt",coords:h,uuid:this.annotationUUID,strokeStyle:b.strokeStyle,locationObjectUUID:u,cameraInfo:o}}))}else{var h=[],f=new THREE.Vector3,m=(e.controls.getBoundingBox().center(f),f.project(e.camera),f.z);m<-1&&(m=-.99);for(var g=0;g<this.interpPts.length;++g)f.set(this.interpPts[g].x*i/n.width*2-1,2*-(this.interpPts[g].y*i/n.height)+1,m),f.applyMatrix4(l),h.push(f.x),h.push(f.y),h.push(f.z);for(var v=0,A=0,y=0,g=0;g<h.length/3;++g)v+=h[3*g],A+=h[3*g+1],y+=h[3*g+2];v/=h.length/3,A/=h.length/3,y/=h.length/3;var E,M,w,b,x=new THREE.Vector3(v,A,y),I=new THREE.Matrix4,p=(I.multiplyMatrices(e.camera.projectionMatrix,e.camera.matrixWorldInverse),x.applyMatrix4(I),e.renderer.domElement.width/2),t=e.renderer.domElement.height/2;if(x.x=Math.round(x.x*p+p),x.y=Math.round(-x.y*t+t),e.ndsModel){for(var T,S=[0,0,0],B=0;B<this.interpPts.length;++B)S[0]+=this.interpPts[B].x,S[1]+=this.interpPts[B].y;S[0]/=this.interpPts.length,S[1]/=this.interpPts.length,(T=e.getIntersectionPtByScreenPt(S))&&(v=T.coords[0],A=T.coords[1],y=T.coords[2])}else(E=new Uint8Array(4))[0]=E[1]=E[2]=E[3]=0,e.renderer.readRenderTargetPixels(r,x.x,r.height-x.y,1,1,E),e.renderer.setRenderTarget(null),e.renderer.setClearColor(a,s),253<E[0]&&253<E[1]&&253<E[2]&&253<E[3]||(w=E[0]*(M=255/256)/16777216+E[1]*M/65536+E[2]*M/256+E[3]*M,w=2*(w/=255)-1,x.set(x.x/n.width*2-1,2*-(x.y/n.height)+1,w-=4e-8*w),x.applyMatrix4(l),v=x.x,A=x.y,y=x.z);h.push(v),h.push(A),h.push(y),0<h.length&&(b=e.getLineSegAnnotationStyle(),e.dispatchEvent({type:"annotationEvent",userData:{version:"2",type:"lineSeg",coords:h,uuid:this.annotationUUID,lineWidth:b.lineWidth,strokeStyle:b.strokeStyle,cameraInfo:e.getCameraInfo()}}))}this.interpPts=[],this.annotationUUID=null}}}else this.interpPts=[],this.annotationUUID=null},new y({visible:!1,transparent:!1})),we=(((Dn.prototype=Object.create(THREE.Object3D.prototype)).constructor=Dn).prototype.update=function(t,n){var i=new THREE.Vector3(0,0,0),r=new THREE.Vector3(0,1,0),o=new THREE.Matrix4;this.traverse(function(e){-1!==e.name.search("E")?e.quaternion.setFromRotationMatrix(o.lookAt(n,i,r)):-1===e.name.search("X")&&-1===e.name.search("Y")&&-1===e.name.search("Z")||e.quaternion.setFromEuler(t)})},(Hn.prototype=Object.create(Dn.prototype)).constructor=Hn,(Fn.prototype=Object.create(Dn.prototype)).constructor=Fn,(Nn.prototype=Object.create(THREE.Object3D.prototype)).constructor=Nn,(jn.prototype=Object.create(Dn.prototype)).constructor=jn,(_n.prototype=Object.create(THREE.Object3D.prototype)).constructor=_n,function(e){g.call(this,e),this.type="OpBall",this.opMode="move",this._setModel="both",this.translateScene=null,this.clipTransRotControl=null,this.clipObjectBox=null,this.geomPointSize=.04,this.domElement=null,this.WorldPosition=new THREE.Vector3,this.IntersectModel=null,this.MoveObjects=[],e.canvas2D?this.domElement=e.canvas2D:this.domElement=e.canvas3D,this.piovtRotatePos=null,this.piovtRotateDir=null,this.piovtRotateMid=null;var h=this,u=new THREE.Matrix4,p=new THREE.Matrix4,f=new THREE.Matrix4,m=new THREE.Matrix4;this.DecomposeQuaternion=new THREE.Quaternion,this.DecomposePosition=new THREE.Vector3,this.DecomposeScale=new THREE.Vector3,this.rotateAngle=0,this.angle=new THREE.Vector3,this.position=new THREE.Vector3,this.singleObject=null,this.emptyCenter=new THREE.Vector3,this.updateOpballCenter=function(e){if(h.MoveObjects=h.viewer.selectionManager.getSelectedleafObjects(),0==h.MoveObjects.length)h.translateScene&&(h.clipTransRotControl&&h.translateScene.remove(h.clipTransRotControl),h.clipObjectBox)&&h.translateScene.remove(h.clipObjectBox),h.render();else{for(var t=new THREE.Box3,n=0;n<h.MoveObjects.length;++n){var i=h.MoveObjects[n],r=null;i.isDrawGeom?(r=i.geometry.boundingBox.clone()).applyMatrix4(i.matrix):r=h.viewer.ndsModel.getBodyBoundingBox(i),r&&!r.isEmpty()&&(t.expandByPoint(r.max),t.expandByPoint(r.min))}h.emptyCenter.set(0,0,0),h.WorldPosition.copy(t.getCenter(h.emptyCenter)),h.render(),h.startMove()}},e.addEventListener("updateOpball",this.updateOpballCenter),this.mouseup=function(){var e,t;h.clipTransRotControl&&(h.clipTransRotControl.object.matrixWorld.decompose(h.DecomposePosition,h.DecomposeQuaternion,h.DecomposeScale),h.piovtRotateDir||h.clipTransRotControl.totalquaternion.multiply(h.DecomposeQuaternion),h.startMove(!0),e=new THREE.Vector3,t=new THREE.Vector3,h.viewer.computeBoundingBox(h.viewer.scene,e,t,{flag:!0}),e.x>t.x||e.y>t.y||e.z>t.z||(h.viewer.controls.setBoundingBox(e,t),h.viewer.switchRotateCenterBySelection()))},this.onOpBall=function(){if(h.clipTransRotControl){var e=h.viewer.selectionManager.getSelectedleafObjects(!0),t=h.clipTransRotControl.getOffset(),n=h.clipTransRotControl.getRotateOffset(),i=(h.rotateAngle=h.clipTransRotControl.getRotateAngle(),t.clone());if(t.set(0,0,0),null==h.viewer.draggedObjects&&(h.viewer.draggedObjects=new Array),"translate"==h.clipTransRotControl.pickType){if(h.viewer.ndsModel)for(var r=0;r<e.length;++r){var o,a=e[r];p.makeTranslation(i.x,i.y,i.z),a.isDrawGeom?(a.applyMatrix(p),a.updateMatrixWorld()):(a.worldMatrix=h.viewer.ndsModel.calculateNodeWorldMatrix(a),a.worldMatrix.premultiply(p),l=a.parent?h.viewer.ndsModel.calculateNodeWorldMatrix(a.parent):new THREE.Matrix4,(o=new THREE.Matrix4).getInverse(l),u=a.worldMatrix.premultiply(o),h.viewer.ndsModel.updateNodeMatrix(a.uuid,u.toArray()),h.viewer.translatePiovt(a.uuid,p))}h.clipTransRotControl.SetTextValue()}else if("rotate"==h.clipTransRotControl.pickType){for(var s=(new THREE.Euler).setFromQuaternion(n),r=0;r<e.length;++r){var l,d,c,a=e[r];f.makeTranslation(0,0,0),a.isDrawGeom?(m.makeTranslation(-h.WorldPosition.x,-h.WorldPosition.y,-h.WorldPosition.z),f.premultiply(m),m.makeRotationFromQuaternion(n),f.premultiply(m),m.makeTranslation(h.WorldPosition.x,h.WorldPosition.y,h.WorldPosition.z),f.premultiply(m),a.applyMatrix(f),a.updateMatrixWorld()):(a.worldMatrix=h.viewer.ndsModel.calculateNodeWorldMatrix(a),l=a.parent?h.viewer.ndsModel.calculateNodeWorldMatrix(a.parent):new THREE.Matrix4,h.piovtRotatePos?(m.makeTranslation(-h.WorldPosition.x,-h.WorldPosition.y,-h.WorldPosition.z),a.worldMatrix.premultiply(m),f.premultiply(m),m.makeRotationFromQuaternion(n),a.worldMatrix.premultiply(m),f.premultiply(m),m.makeTranslation(h.piovtRotatePos.x,h.piovtRotatePos.y,h.piovtRotatePos.z),a.worldMatrix.premultiply(m),f.premultiply(m),d=(new THREE.Vector3).subVectors(h.WorldPosition,h.piovtRotatePos),c=(new THREE.Vector3).copy(d).normalize().applyQuaternion(n),h.WorldPosition.copy(h.piovtRotatePos).addScaledVector(c,d.length()),m.makeTranslation(h.WorldPosition.x-h.piovtRotatePos.x,h.WorldPosition.y-h.piovtRotatePos.y,h.WorldPosition.z-h.piovtRotatePos.z),a.worldMatrix.premultiply(m),f.premultiply(m),h.viewer.rotatePiovt(a.uuid,h.piovtRotatePos,n)):(m.makeTranslation(-h.WorldPosition.x,-h.WorldPosition.y,-h.WorldPosition.z),a.worldMatrix.premultiply(m),f.premultiply(m),m.makeRotationFromQuaternion(n),a.worldMatrix.premultiply(m),f.premultiply(m),m.makeTranslation(h.WorldPosition.x,h.WorldPosition.y,h.WorldPosition.z),a.worldMatrix.premultiply(m),f.premultiply(m),h.viewer.rotatePiovt(a.uuid,h.WorldPosition,n)),m.getInverse(l),u=a.worldMatrix.premultiply(m),h.viewer.ndsModel.updateNodeMatrix(a.uuid,u.toArray())),a.originalEuler&&(h.piovtRotateDir?(a.originalEuler.x=s.x+a.originalEuler.x,a.originalEuler.y=s.y+a.originalEuler.y,a.originalEuler.z=s.z+a.originalEuler.z):"X"==h.clipTransRotControl.axis?a.originalEuler.x=s.x+a.originalEuler.x:"Y"==h.clipTransRotControl.axis?a.originalEuler.y=s.y+a.originalEuler.y:"Z"==h.clipTransRotControl.axis&&(a.originalEuler.z=s.z+a.originalEuler.z))}h.piovtRotateDir&&h.clipTransRotControl.totalquaternion.multiply(n),h.clipTransRotControl.SetTextValue()}h.updateclipTransRotControl(h.clipTransRotControl.pickType),h.dispatchPositonandAngle(),h.render()}}}),ci=(we.prototype=Object.create(g.prototype),we.prototype.onLMouseDown=function(e){this.state=ve.MOUSE.LEFT},we.prototype.onLMouseDbClick=function(e){this.viewer.zoomExtents(),this.updateRotateCenterHelper()},we.prototype.setMoveMode=function(){this.opMode="move"},we.prototype.setRestoreMode=function(){this.opMode="restore"},we.prototype.setDefaultMode=function(){this.opMode="default"},we.prototype.isModelMoved=function(){var t;return this.viewer.ndsModel?this.viewer.ndsModel.hasDraggedBodies():(t=!1,this.viewer.scene.traverse(function(e){e.hasOwnProperty("geometry")&&null!=e.matrixWorldTransoriginalDrag&&(t=!0)}),t)},we.prototype.hideSelectedModel=function(){this.viewer.hideSelectedObjects()},we.prototype.showAllModel=function(){this.viewer.showObject(this.viewer.scene,!0),this.render()},we.prototype.reverseVisibleAndHidingModel=function(){this.viewer.showObjectReversed(this.viewer.scene),this.render()},we.prototype.create=function(){_e.HideLeafBody?(this.viewer.selectionManager.setSelectType("part"),this.viewer.controls.getOperator().oldSelectType="part"):this.viewer.selectionManager.setSelectType("body"),g.prototype.create.call(this)},we.prototype.release=function(){this.update(),this.render(),this.clipTransRotControl&&(this.clipTransRotControl.removeEventListener("objectChange",this.onOpBall),this.clipTransRotControl.removeEventListener("mouseUp",this.mouseup),this.clipTransRotControl.dispose(),this.clipTransRotControl=null),this.clipObjectBox&&(this.clipObjectBox=null),this.viewer.removeEventListener("updateOpball",this.updateOpballCenter),this.MoveObjects=[],g.prototype.release.call(this)},we.prototype.update=function(){g.prototype.update.call(this)},we.prototype.onLMouseClick=function(e){e.preventDefault(),e.stopPropagation();this.viewer;var t=e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top;e.srcElement&&e.srcElement!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),Math.abs(t-this.lMouseDown.x)<1&&Math.abs(n-this.lMouseDown.y)<1&&("move"!=this.opMode&&"default"!=this.opMode||(this.viewer.selectionManager.selectByClick(t,n,!!e.ctrlKey),this.startMove()))},we.prototype.onMMouseUp=function(e){g.prototype.onMMouseUp.call(this,e),"move"!=this.opMode&&"default"!=this.opMode||this.startMove()},we.prototype.updateclipTransRotControl=function(e){if(this.MoveObjects=this.viewer.selectionManager.getSelectedleafObjects(!0),0==this.MoveObjects.length)this.translateScene&&(this.clipTransRotControl&&this.translateScene.remove(this.clipTransRotControl),this.clipObjectBox)&&this.translateScene.remove(this.clipObjectBox);else if("rotate"!=this._setModel&&"rotate"!=e){for(var t=new THREE.Box3,n=0;n<this.MoveObjects.length;++n){var i=this.MoveObjects[n],r=null;i.isDrawGeom?(r=i.geometry.boundingBox.clone()).applyMatrix4(i.matrix):r=this.viewer.ndsModel.getBodyBoundingBox(i),r&&!r.isEmpty()&&(t.expandByPoint(r.max),t.expandByPoint(r.min))}this.emptyCenter.set(0,0,0),this.WorldPosition.copy(t.getCenter(this.emptyCenter));var e=[],o=(o="rotate"==this._setModel||"translate"==this._setModel)&&this.viewer.isSelectObjectsPiovtLine(this.MoveObjects,e);this.piovtRotatePos=o&&0<e.length?e[0].center.clone():null,this.piovtRotateDir=o&&0<e.length&&e[0].normal?e[0].normal.clone():null,this.piovtRotateMid=this.piovtRotatePos?(new THREE.Vector3).copy(this.piovtRotatePos):null,this.piovtRotateDir&&(o=(new THREE.Vector3).copy(e[0].center).addScaledVector(this.piovtRotateDir,10),e=new THREE.Line3(e[0].center,o),this.piovtRotatePos=e.closestPointToPoint(this.WorldPosition,!1)),this.clipTransRotControl&&(this.clipTransRotControl.position.copy(this.piovtRotateMid||this.WorldPosition),this.clipTransRotControl.object.position.copy(this.piovtRotateMid||this.WorldPosition),this.clipTransRotControl.updateMatrixWorld(!0))}this.render()},we.prototype.startMove=function(n){var i=this,r=(void 0===n&&(n=!1),this.MoveObjects=this.viewer.selectionManager.getSelectedleafObjects(!0),n&&(d=this.MoveObjects,this.viewer.controls.staticDrawGeomOp&&0<(l=this.viewer.controls.staticDrawGeomOp.selectMeshMap.size)&&(d=this.MoveObjects.slice(0,this.MoveObjects.length-l)),l=[],s=this.viewer.selectionManager.getSelectedleafObjects(),s=this.viewer.isSelectObjectsPiovtLine(s,l)&&0<l.length?l[0].center.clone():null,this.viewer.dispatchEvent({type:"OpBallMoveEnd",MoveObjects:d,center:s?this.piovtRotatePos:this.WorldPosition})),this);if(this.MoveObjects.forEach(function(e){var t;e.originalPosition||(e.originalPosition=new THREE.Vector3,t=null,e.isDrawGeom?(t=e.geometry.boundingBox.clone()).applyMatrix4(e.matrix):t=r.viewer.ndsModel.getBodyBoundingBox(e),t&&(i.emptyCenter.set(0,0,0),e.originalPosition.copy(t.getCenter(i.emptyCenter)))),e.originalEuler||(e.originalEuler=new THREE.Euler,e.staticEuler=new THREE.Euler,e.worldMatrix.decompose(i.DecomposePosition,i.DecomposeQuaternion,i.DecomposeScale),e.originalEuler.setFromQuaternion(i.DecomposeQuaternion),e.staticEuler.copy(e.originalEuler)),e.originalMatrix||(e.originalMatrix=new THREE.Matrix4,e.originalMatrix.copy(e.worldMatrix)),n||(t=null,e.isDrawGeom?(t=e.geometry.boundingBox.clone()).applyMatrix4(e.matrix):t=r.viewer.ndsModel.getBodyBoundingBox(e),r.emptyCenter.set(0,0,0),t&&e.originalPosition.copy(t.getCenter(r.emptyCenter)),e.worldMatrix.decompose(i.DecomposePosition,i.DecomposeQuaternion,i.DecomposeScale),e.originalEuler.setFromQuaternion(i.DecomposeQuaternion),e.staticEuler.copy(e.originalEuler),e.originalMatrix.copy(e.worldMatrix)),n||(e.selectedMatrix=new THREE.Matrix4,e.selectedMatrix.copy(e.worldMatrix))}),this.singleObject&&!n&&(this.singleObject.originalEuler.set(this.angle.x*Math.PI/180,this.angle.y*Math.PI/180,this.angle.z*Math.PI/180),this.singleObject=null),1==this.MoveObjects.length&&(this.singleObject=this.MoveObjects[0]),0==this.MoveObjects.length)this.translateScene&&(this.clipTransRotControl&&this.translateScene.remove(this.clipTransRotControl),this.clipObjectBox)&&this.translateScene.remove(this.clipObjectBox),this.clipObjectBox&&(this.clipObjectBox=null),this.clipTransRotControl&&(this.clipTransRotControl.removeEventListener("objectChange",this.onOpBall),this.clipTransRotControl.removeEventListener("mouseUp",this.mouseup),this.clipTransRotControl.dispose(),this.clipTransRotControl=null),this.viewer.dispatchEvent({type:"OpBallModel",position:{x:0,y:0,z:0},angle:{x:0,y:0,z:0}}),this.render();else{if(!n){for(var e=new THREE.Box3,t=null,o=0;o<this.MoveObjects.length;++o){var a=this.MoveObjects[o];a.isDrawGeom?(t=a.geometry.boundingBox.clone()).applyMatrix4(a.matrix):t=this.viewer.ndsModel.getBodyBoundingBox(a),t&&!t.isEmpty()&&(e.expandByPoint(t.max),e.expandByPoint(t.min))}this.emptyCenter.set(0,0,0),this.WorldPosition.copy(e.getCenter(this.emptyCenter));var s,l=[],d=(d="rotate"==this._setModel||"translate"==this._setModel)&&this.viewer.isSelectObjectsPiovtLine(this.MoveObjects,l);this.piovtRotatePos=d&&0<l.length?l[0].center.clone():null,this.piovtRotateDir=d&&0<l.length&&l[0].normal?l[0].normal.clone():null,this.piovtRotateMid=this.piovtRotatePos?(new THREE.Vector3).copy(this.piovtRotatePos):null,this.piovtRotateDir&&(s=(new THREE.Vector3).copy(l[0].center).addScaledVector(r.piovtRotateDir,10),d=new THREE.Line3(l[0].center,s),this.piovtRotatePos=d.closestPointToPoint(this.WorldPosition,!1))}this.rotateAngle=0,"move"!=this.opMode&&"default"!=this.opMode||(l=new THREE.Object3D,this.piovtRotateDir?(s=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),this.piovtRotateDir),d=(new THREE.Matrix4).makeRotationFromQuaternion(s),s=(new THREE.Matrix4).makeTranslation(this.piovtRotateMid.x,this.piovtRotateMid.y,this.piovtRotateMid.z),l.applyMatrix(d),l.applyMatrix(s),l.updateMatrixWorld()):l.position.copy(this.piovtRotateMid||this.WorldPosition),l.visible=!0,s=d=null,this.clipTransRotControl&&(d=this.clipTransRotControl.originalPosition.clone(),s=this.clipTransRotControl.totalquaternion.clone()),this.translateScene||(this.translateScene=new THREE.Scene),this.clipObjectBox||"rotate"!=this._setModel||(this.clipObjectBox=new THREE.Mesh(new THREE.SphereGeometry(this.geomPointSize),new THREE.MeshBasicMaterial({color:750054,opacity:1,side:THREE.DoubleSide})),this.clipObjectBox.position.set(l.position.x,l.position.y,l.position.z),this.clipObjectBox.geometry.computeBoundingBox(),this.clipObjectBox.geometry.computeBoundingSphere(),this.clipObjectBox.updateMatrixWorld(),this.translateScene.add(this.clipObjectBox)),this.clipTransRotControl&&(this.piovtRotateDir&&null==this.clipTransRotControl.piovtDir||!this.piovtRotateDir&&this.clipTransRotControl.piovtDir)&&(this.translateScene&&this.translateScene.remove(this.clipTransRotControl),this.clipTransRotControl.removeEventListener("objectChange",this.onOpBall),this.clipTransRotControl.removeEventListener("mouseUp",this.mouseup),this.clipTransRotControl.dispose(),s=d=this.clipTransRotControl=null,this.viewer.render()),this.clipTransRotControl||(this.clipTransRotControl=new _n(this.viewer.camera,this.domElement,this.viewer,this,this.piovtRotateDir?["translateX"]:void 0),this.translateScene.add(this.clipTransRotControl)),this.clipTransRotControl.position.copy(this.piovtRotateMid||this.WorldPosition),this.clipTransRotControl.quaternion.set(0,0,0,1),this.clipTransRotControl.updateMatrixWorld(!0),this.clipTransRotControl.originalPosition=d||(this.piovtRotateMid||this.WorldPosition).clone(),n||(this.clipTransRotControl.selectedPosition=(this.piovtRotateMid||this.WorldPosition).clone()),this.clipTransRotControl.totalquaternion=s||new THREE.Quaternion,this.clipTransRotControl.setSize(.8),this.clipTransRotControl.initRotateOffset(),this.clipTransRotControl.axis=null,this.clipTransRotControl.setMode(this._setModel),this.clipTransRotControl.setSpace("local"),this.clipTransRotControl.attach(l),this.clipTransRotControl.addEventListener("objectChange",this.onOpBall),this.clipTransRotControl.addEventListener("mouseUp",this.mouseup),this.piovtRotateDir&&this.clipTransRotControl.setPiovtDir(this.piovtRotateDir),this.viewer.controls.getOperator()&&this.viewer.controls.getOperator().resetEventListener(),this.render(),n)||this.dispatchPositonandAngle(!0)}},we.prototype.renderModel=function(){this.translateScene&&this.clipTransRotControl&&(this.clipTransRotControl.updateMatrixWorld(),this.clipTransRotControl.update(),this.clipObjectBox&&(this.clipObjectBox.position.copy(this.clipTransRotControl.position),this.clipObjectBox.scale.copy(this.clipTransRotControl.scale),this.clipObjectBox.updateMatrixWorld()),this.viewer.renderer.render(this.translateScene,this.viewer.camera))},we.prototype.MoveFromTextValueByDelta=function(e){if(this.clipTransRotControl){e.x=b(parseFloat(e.x)),e.y=b(parseFloat(e.y)),e.z=b(parseFloat(e.z));var t=null,n=this.viewer.selectionManager.getSelectedleafObjects(!0);if("translate"==e.mode){if(1==n.length){this.piovtRotateDir?((t=new THREE.Vector3).x=e.x*Math.cos(this.piovtRotateDir.angleTo(new THREE.Vector3(1,0,0))),t.y=e.x*Math.cos(this.piovtRotateDir.angleTo(new THREE.Vector3(0,1,0))),t.z=e.x*Math.cos(this.piovtRotateDir.angleTo(new THREE.Vector3(0,0,1)))):t=new THREE.Vector3(e.x,e.y,e.z),n[0].worldMatrix.decompose(this.DecomposePosition,this.DecomposeQuaternion,this.DecomposeScale),this.clipTransRotControl.object.position.add(t),this.clipTransRotControl.object.updateMatrixWorld(),this.clipTransRotControl.update();for(var i=0;i<n.length;++i){var r,o=n[i],a=(new THREE.Matrix4).makeTranslation(t.x,t.y,t.z),s=new THREE.Matrix4;s.copy(n[0].selectedMatrix),s.premultiply(a),o.isDrawGeom?(o.matrix.copy(s),o.matrixAutoUpdate=!1,o.applyMatrix(new THREE.Matrix4),o.matrixAutoUpdate=!0,o.updateMatrixWorld()):((a=(new THREE.Matrix4).getInverse(o.worldMatrix)).premultiply(s),this.viewer.translatePiovt(o.uuid,a),o.worldMatrix=s,a=new THREE.Matrix4,s=o.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(o.parent):new THREE.Matrix4,(r=new THREE.Matrix4).getInverse(s),a=o.worldMatrix.clone().premultiply(r),this.viewer.ndsModel.updateNodeMatrix(o.uuid,a.toArray()))}}else{this.piovtRotateDir?((t=new THREE.Vector3).x=e.x*Math.cos(this.piovtRotateDir.angleTo(new THREE.Vector3(1,0,0))),t.y=e.x*Math.cos(this.piovtRotateDir.angleTo(new THREE.Vector3(0,1,0))),t.z=e.x*Math.cos(this.piovtRotateDir.angleTo(new THREE.Vector3(0,0,1)))):t=new THREE.Vector3(e.x,e.y,e.z),this.clipTransRotControl.object.position.add(t),this.clipTransRotControl.object.updateMatrixWorld(),this.clipTransRotControl.update();for(i=0;i<n.length;++i){var o=n[i],l=new THREE.Matrix4,d=(new THREE.Matrix4).makeTranslation(t.x,t.y,t.z),c=new THREE.Matrix4;c.copy(o.selectedMatrix),c.premultiply(d),o.isDrawGeom?(o.matrix.copy(c),o.matrixAutoUpdate=!1,o.applyMatrix(new THREE.Matrix4),o.matrixAutoUpdate=!0,o.updateMatrixWorld()):((d=(new THREE.Matrix4).getInverse(o.worldMatrix)).premultiply(c),this.viewer.translatePiovt(o.uuid,d),o.worldMatrix=c,v=o.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(o.parent):new THREE.Matrix4,(d=new THREE.Matrix4).getInverse(v),l=o.worldMatrix.clone().premultiply(d),this.viewer.ndsModel.updateNodeMatrix(o.uuid,l.toArray()))}}this.updateclipTransRotControl()}else if("rotate"==e.mode){var h=new THREE.Euler(e.x*Math.PI/180,e.y*Math.PI/180,e.z*Math.PI/180),u=this.piovtRotateDir?(new THREE.Quaternion).setFromAxisAngle(this.piovtRotateDir,e.x*Math.PI/180):(new THREE.Quaternion).setFromEuler(h),p=this.clipTransRotControl.totalquaternion.clone().conjugate();if(1==n.length){var o=n[0],h=(this.piovtRotatePos||u.setFromEuler(h),new THREE.Matrix4),f=new THREE.Matrix4,m=new THREE.Matrix4,g=(o.worldMatrix.copy(o.originalMatrix),o.isDrawGeom?(m.makeTranslation(-o.originalPosition.x,-o.originalPosition.y,-o.originalPosition.z),f.premultiply(m),m.makeRotationFromQuaternion(u),f.premultiply(m),m.makeTranslation(o.originalPosition.x,o.originalPosition.y,o.originalPosition.z),f.premultiply(m),o.applyMatrix(f),o.updateMatrixWorld()):(v=o.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(o.parent):new THREE.Matrix4,this.piovtRotatePos?(m.makeTranslation(-o.originalPosition.x,-o.originalPosition.y,-o.originalPosition.z),o.worldMatrix.premultiply(m),f.premultiply(m),m.makeRotationFromQuaternion(u),o.worldMatrix.premultiply(m),f.premultiply(m),m.makeTranslation(this.piovtRotatePos.x,this.piovtRotatePos.y,this.piovtRotatePos.z),o.worldMatrix.premultiply(m),f.premultiply(m),g=(new THREE.Vector3).subVectors(o.originalPosition,this.piovtRotatePos),w=(new THREE.Vector3).copy(g).normalize().applyQuaternion(u),w=(new THREE.Vector3).copy(this.piovtRotatePos).addScaledVector(w,g.length()),m.makeTranslation(w.x-this.piovtRotatePos.x,w.y-this.piovtRotatePos.y,w.z-this.piovtRotatePos.z)):(m.makeTranslation(-o.originalPosition.x,-o.originalPosition.y,-o.originalPosition.z),o.worldMatrix.premultiply(m),f.premultiply(m),m.makeRotationFromQuaternion(u),o.worldMatrix.premultiply(m),f.premultiply(m),m.makeTranslation(o.originalPosition.x,o.originalPosition.y,o.originalPosition.z)),o.worldMatrix.premultiply(m),f.premultiply(m),m.getInverse(v),h=o.worldMatrix.premultiply(m),this.viewer.ndsModel.updateNodeMatrix(o.uuid,h.toArray())),new THREE.Euler);g.setFromRotationMatrix(o.worldMatrix),o.originalEuler.set(g.x,g.y,g.z),this.angle.x=e.x,this.angle.y=e.y,this.angle.z=e.z}else for(i=0;i<n.length;++i){var v,A,y,o=n[i],E=new THREE.Matrix4,f=new THREE.Matrix4,M=new THREE.Matrix4;o.isDrawGeom?(M.makeTranslation(-this.WorldPosition.x,-this.WorldPosition.y,-this.WorldPosition.z),f.premultiply(M),M.makeRotationFromQuaternion(p),f.premultiply(M),M.makeRotationFromQuaternion(u),f.premultiply(M),M.makeTranslation(this.WorldPosition.x,this.WorldPosition.y,this.WorldPosition.z),f.premultiply(M),o.applyMatrix(f),o.updateMatrixWorld()):(o.worldMatrix=this.viewer.ndsModel.calculateNodeWorldMatrix(o),v=o.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(o.parent):new THREE.Matrix4,this.piovtRotatePos?(M.makeTranslation(-this.WorldPosition.x,-this.WorldPosition.y,-this.WorldPosition.z),o.worldMatrix.premultiply(M),f.premultiply(M),M.makeRotationFromQuaternion(p),o.worldMatrix.premultiply(M),f.premultiply(M),M.makeRotationFromQuaternion(u),o.worldMatrix.premultiply(M),f.premultiply(M),M.makeTranslation(this.piovtRotatePos.x,this.piovtRotatePos.y,this.piovtRotatePos.z),o.worldMatrix.premultiply(M),f.premultiply(M),A=(new THREE.Vector3).subVectors(this.WorldPosition,this.piovtRotatePos),y=(new THREE.Vector3).copy(A).normalize().applyQuaternion(p).applyQuaternion(u),y=(new THREE.Vector3).copy(this.piovtRotatePos).addScaledVector(y,A.length()),M.makeTranslation(y.x-this.piovtRotatePos.x,y.y-this.piovtRotatePos.y,y.z-this.piovtRotatePos.z),o.worldMatrix.premultiply(M),f.premultiply(M),this.viewer.rotatePiovt(o.uuid,this.piovtRotatePos,u,p)):(M.makeTranslation(-this.WorldPosition.x,-this.WorldPosition.y,-this.WorldPosition.z),o.worldMatrix.premultiply(M),f.premultiply(M),M.makeRotationFromQuaternion(p),o.worldMatrix.premultiply(M),f.premultiply(M),M.makeRotationFromQuaternion(u),o.worldMatrix.premultiply(M),f.premultiply(M),M.makeTranslation(this.WorldPosition.x,this.WorldPosition.y,this.WorldPosition.z),o.worldMatrix.premultiply(M),f.premultiply(M),this.viewer.rotatePiovt(o.uuid,this.WorldPosition,u,p)),M.getInverse(v),E=o.worldMatrix.premultiply(M),this.viewer.ndsModel.updateNodeMatrix(o.uuid,E.toArray()))}this.rotateAngle=e.x,this.clipTransRotControl.totalquaternion.copy(u)}var w=n,h=(this.viewer.controls.staticDrawGeomOp&&0<(m=this.viewer.controls.staticDrawGeomOp.selectMeshMap.size)&&(w=n.slice(0,n.length-m)),[]),g=this.viewer.selectionManager.getSelectedleafObjects(),e=this.viewer.isSelectObjectsPiovtLine(g,h)&&0<h.length?h[0].center.clone():null;this.viewer.dispatchEvent({type:"OpBallMoveEnd",MoveObjects:w,center:e?this.piovtRotatePos:this.WorldPosition}),this.render()}function b(e){return e%180==0?0<e?e-1e-5:e<0?e+1e-5:e:e}},we.prototype.MoveFromTextValue=function(e){if(this.clipTransRotControl){e.x=parseFloat(e.x),e.y=parseFloat(e.y),e.z=parseFloat(e.z);var t=null,n=null,i=this.viewer.selectionManager.getSelectedleafObjects(!0);if("translate"==e.mode){if(1==i.length){var t=new THREE.Vector3(e.x,e.y,e.z),r=new THREE.Box3,o=null,a=(i[0].isDrawGeom?(o=i[0].geometry.boundingBox.clone()).applyMatrix4(i[0].matrix):o=this.viewer.ndsModel.getBodyBoundingBox(i[0]),o&&!o.isEmpty()&&(r.expandByPoint(o.max),r.expandByPoint(o.min)),r.getCenter());i[0].worldMatrix.decompose(this.DecomposePosition,this.DecomposeQuaternion,this.DecomposeScale),t.sub(a),this.clipTransRotControl.object.position.add(t),this.clipTransRotControl.object.updateMatrixWorld(),this.clipTransRotControl.update();for(var s=0;s<i.length;++s){var l=i[s],d=new THREE.Matrix4,c=(new THREE.Matrix4).makeTranslation(t.x,t.y,t.z);l.isDrawGeom?(l.applyMatrix(c),l.updateMatrixWorld()):(l.worldMatrix=this.viewer.ndsModel.calculateNodeWorldMatrix(l),l.worldMatrix.premultiply(c),v=l.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(l.parent):new THREE.Matrix4,(c=new THREE.Matrix4).getInverse(v),d=l.worldMatrix.premultiply(c),this.viewer.ndsModel.updateNodeMatrix(l.uuid,d.toArray()))}}else{(t=new THREE.Vector3(e.x,e.y,e.z)).add(this.clipTransRotControl.originalPosition),t.sub(this.clipTransRotControl.object.position),this.clipTransRotControl.object.position.add(t),this.clipTransRotControl.object.updateMatrixWorld(),this.clipTransRotControl.update();for(s=0;s<i.length;++s){var l=i[s],h=new THREE.Matrix4,u=(new THREE.Matrix4).makeTranslation(t.x,t.y,t.z);l.isDrawGeom?(l.applyMatrix(u),l.updateMatrixWorld()):(l.worldMatrix=this.viewer.ndsModel.calculateNodeWorldMatrix(l),l.worldMatrix.premultiply(u),v=l.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(l.parent):new THREE.Matrix4,(u=new THREE.Matrix4).getInverse(v),h=l.worldMatrix.premultiply(u),this.viewer.ndsModel.updateNodeMatrix(l.uuid,h.toArray()))}}this.updateclipTransRotControl()}else if("rotate"==e.mode){var n=new THREE.Euler(e.x*Math.PI/180,e.y*Math.PI/180,e.z*Math.PI/180),p=(new THREE.Quaternion).setFromEuler(n),f=this.clipTransRotControl.totalquaternion.clone().conjugate();if(1==i.length){var l=i[0],n=(n.set(n.x-l.staticEuler.x,n.y-l.staticEuler.y,n.z-l.staticEuler.z),p.setFromEuler(n),new THREE.Matrix4),m=new THREE.Matrix4,g=new THREE.Matrix4,r=(l.worldMatrix.copy(l.originalMatrix),new THREE.Box3),o=null;l.isDrawGeom?(o=l.geometry.boundingBox.clone()).applyMatrix4(l.matrix):o=this.viewer.ndsModel.getBodyBoundingBox(l),o&&!o.isEmpty()&&(r.expandByPoint(o.max),r.expandByPoint(o.min));o=(a=r.getCenter()).sub(l.originalPosition);l.isDrawGeom?(g.makeTranslation(-l.originalPosition.x,-l.originalPosition.y,-l.originalPosition.z),m.premultiply(g),g.makeRotationFromQuaternion(p),m.premultiply(g),g.makeTranslation(l.originalPosition.x,l.originalPosition.y,l.originalPosition.z),m.premultiply(g),g.makeTranslation(o.x,o.y,o.z),m.premultiply(g),l.applyMatrix(m),l.updateMatrixWorld()):(v=l.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(l.parent):new THREE.Matrix4,g.makeTranslation(-l.originalPosition.x,-l.originalPosition.y,-l.originalPosition.z),l.worldMatrix.premultiply(g),m.premultiply(g),g.makeRotationFromQuaternion(p),l.worldMatrix.premultiply(g),m.premultiply(g),g.makeTranslation(l.originalPosition.x,l.originalPosition.y,l.originalPosition.z),l.worldMatrix.premultiply(g),m.premultiply(g),g.makeTranslation(o.x,o.y,o.z),l.worldMatrix.premultiply(g),m.premultiply(g),g.getInverse(v),n=l.worldMatrix.premultiply(g),this.viewer.ndsModel.updateNodeMatrix(l.uuid,n.toArray())),l.originalEuler.set(e.x*Math.PI/180,e.y*Math.PI/180,e.z*Math.PI/180),this.angle.x=e.x,this.angle.y=e.y,this.angle.z=e.z}else for(s=0;s<i.length;++s){var v,l=i[s],A=new THREE.Matrix4,m=new THREE.Matrix4,y=new THREE.Matrix4;l.isDrawGeom?(y.makeTranslation(-this.WorldPosition.x,-this.WorldPosition.y,-this.WorldPosition.z),m.premultiply(y),y.makeRotationFromQuaternion(f),m.premultiply(y),y.makeRotationFromQuaternion(p),m.premultiply(y),y.makeTranslation(this.WorldPosition.x,this.WorldPosition.y,this.WorldPosition.z),m.premultiply(y),l.applyMatrix(m),l.updateMatrixWorld()):(l.worldMatrix=this.viewer.ndsModel.calculateNodeWorldMatrix(l),v=l.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(l.parent):new THREE.Matrix4,y.makeTranslation(-this.WorldPosition.x,-this.WorldPosition.y,-this.WorldPosition.z),l.worldMatrix.premultiply(y),m.premultiply(y),y.makeRotationFromQuaternion(f),l.worldMatrix.premultiply(y),m.premultiply(y),y.makeRotationFromQuaternion(p),l.worldMatrix.premultiply(y),m.premultiply(y),y.makeTranslation(this.WorldPosition.x,this.WorldPosition.y,this.WorldPosition.z),l.worldMatrix.premultiply(y),m.premultiply(y),y.getInverse(v),A=l.worldMatrix.premultiply(y),this.viewer.ndsModel.updateNodeMatrix(l.uuid,A.toArray()))}this.clipTransRotControl.totalquaternion.copy(p)}this.render()}},we.prototype.dispatchPositonandAngle=function(e){var t,n,i,r,o,a;function s(e){return e=Number(e),Math.abs(e)<1e-5}void 0===e&&(e=!1),this.clipTransRotControl&&(t=new THREE.Euler,n=new THREE.Euler,i=new THREE.Euler,r=new THREE.Vector3,this.clipTransRotControl.updateMatrixWorld(!0),this.clipTransRotControl.object.matrixWorld.decompose(this.DecomposePosition,this.DecomposeQuaternion,this.DecomposeScale),r.copy(this.DecomposePosition),(o=new THREE.Quaternion).multiplyQuaternions(this.clipTransRotControl.totalquaternion,this.DecomposeQuaternion),this.DecomposePosition.sub(this.clipTransRotControl.originalPosition),r.sub(this.clipTransRotControl.selectedPosition),(a=new THREE.Euler).setFromQuaternion(o),"rotate"==this.clipTransRotControl.pickType?this.piovtRotateDir?(this.angle.x=180*a.x/Math.PI,this.angle.y=180*a.y/Math.PI,this.angle.z=180*a.z/Math.PI):"X"==this.clipTransRotControl.axis?this.angle.x=180*a.x/Math.PI:"Y"==this.clipTransRotControl.axis?this.angle.y=180*a.y/Math.PI:"Z"==this.clipTransRotControl.axis&&(this.angle.z=180*a.z/Math.PI):"translate"==this.clipTransRotControl.pickType&&this.position.copy(this.DecomposePosition),e&&(this.angle.x=0,this.angle.y=0,this.angle.z=0,this.DecomposePosition.set(0,0,0),this.position.copy(this.DecomposePosition)),1==(o=this.viewer.selectionManager.getSelectedleafObjects(!0)).length&&o[0].originalPosition&&(a=new THREE.Box3,e=null,o[0].isDrawGeom?(e=o[0].geometry.boundingBox.clone()).applyMatrix4(o[0].matrix):e=this.viewer.ndsModel.getBodyBoundingBox(o[0]),e&&!e.isEmpty()&&(a.expandByPoint(e.max),a.expandByPoint(e.min)),this.emptyCenter.set(0,0,0),e=a.getCenter(this.emptyCenter),o[0].originalEuler,"rotate"==this.clipTransRotControl.pickType?(this.angle.x=180*o[0].originalEuler.x/Math.PI,this.angle.y=180*o[0].originalEuler.y/Math.PI,this.angle.z=180*o[0].originalEuler.z/Math.PI):"translate"==this.clipTransRotControl.pickType?this.position.copy(e):(this.position.copy(e),this.angle.x=180*o[0].originalEuler.x/Math.PI,this.angle.y=180*o[0].originalEuler.y/Math.PI,this.angle.z=180*o[0].originalEuler.z/Math.PI),n.setFromRotationMatrix(o[0].worldMatrix),t.setFromRotationMatrix(o[0].selectedMatrix),i.set(n.x-t.x,n.y-t.y,n.z-t.z)),this.piovtRotateDir&&(this.angle.x=180*this.rotateAngle/Math.PI,this.angle.y=0,this.angle.z=0,a=this.piovtRotateDir.angleTo(r),r.x=(a>Math.PI/4?-1:1)*r.length(),r.y=0,r.z=0),this.viewer.dispatchEvent({type:"OpBallModel",position:{x:s(this.position.x)?0:this.position.x,y:s(this.position.y)?0:this.position.y,z:s(this.position.z)?0:this.position.z},angle:{x:s(this.angle.x)?0:this.angle.x,y:s(this.angle.y)?0:this.angle.y,z:s(this.angle.z)?0:this.angle.z},deltaAngle:{x:1!=o.length||this.piovtRotateDir?this.angle.x:180*i.x/Math.PI,y:1!=o.length||this.piovtRotateDir?this.angle.y:180*i.y/Math.PI,z:1!=o.length||this.piovtRotateDir?this.angle.z:180*i.z/Math.PI},deltaPosition:{x:r.x,y:r.y,z:r.z}}))},we.prototype.addDraggedObject=function(e){for(var t=0;t<this.viewer.draggedObjects.length;++t)if(e==this.viewer.draggedObjects[t])return;this.viewer.draggedObjects.push(e)},we.prototype.removeDraggedObject=function(e){if(null!=this.viewer.draggedObjects)for(var t=0;t<this.viewer.draggedObjects.length;++t)if(e==this.viewer.draggedObjects[t])return void this.viewer.draggedObjects.splice(t,1)},we.prototype.onLMouseMove=function(e){0<this.viewer.selectionManager.getSelectedleafObjects(!0).length&&this.clipTransRotControl&&"default"!=this.clipTransRotControl.pickType?this.onOpBall():g.prototype.onLMouseMove.call(this,e)},we.prototype.onTouchSingleStart=function(e){g.prototype.onTouchSingleStart.call(this,e)},we.prototype.onTouchSingleMove=function(e){0<(this.viewer.ndsModel?this.viewer.selectionManager.getSelectedleafObjects():this.viewer.selectionManager.getSelectedMeshes()).length&&this.clipTransRotControl&&"default"!=this.clipTransRotControl.pickType?this.onOpBall():g.prototype.onTouchSingleMove.call(this,e)},we.prototype.onTouchSingleEnd=function(e){this.state=-1,Math.abs(this.singleTouchEndPos.x-this.singleTouchStartPos.x)<1&&Math.abs(this.singleTouchEndPos.y-this.singleTouchStartPos.y)<1&&("move"!=this.opMode&&"default"!=this.opMode||(this.viewer.selectionManager.selectByClick(this.singleTouchEndPos.x,this.singleTouchEndPos.y),this.render()))},we.prototype.setModel=function(e){this._setModel=e,this.startMove(),this.clipTransRotControl&&this.clipTransRotControl.setMode(this._setModel)},function(e){g.call(this,e),this.type="OpSelect"}),hi=(ci.prototype=Object.create(g.prototype),ci.prototype.release=function(){this.update(),this.render(),g.prototype.release.call(this)},ci.prototype.update=function(){this.viewer.selectionManager.clearSelection(),g.prototype.update.call(this)},ci.prototype.onLMouseClick=function(e){e.preventDefault();var t=e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top;e.srcElement&&e.srcElement!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),this.viewer.selectionManager.selectByClick(t,n,e.ctrlKey),this.render()},function(e){g.call(this,e),this.type="OpSvgZoom",this.zoomRate=1.1}),N=(hi.prototype=Object.create(g.prototype),hi.prototype.addEvents=function(e){N.prototype.addEvents.call(this)},hi.prototype.removeEvents=function(e){N.prototype.removeEvents.call(this)},hi.prototype.onLMouseDown=function(e){g.prototype.onLMouseDown.call(this),this.addEvents()},hi.prototype.onLMouseUp=function(e){g.prototype.onLMouseUp.call(this),this.removeEvents()},hi.prototype.onMMouseDown=function(e){g.prototype.onMMouseDown.call(this);var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).removeEventListener("mousewheel",this.onMouseWheel,!1),this.addEvents()},hi.prototype.onMMouseUp=function(e){g.prototype.onMMouseUp.call(this);var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).addEventListener("mousewheel",this.onMouseWheel,!1),this.removeEvents()},hi.prototype.onLMouseMove=function(e){var t=this.pointer.y-this.pointerOld.y;this.zoom(new THREE.Vector3(0,0,5*t))},hi.prototype.onMMouseMove=function(e){N.prototype.onMMouseMove.call(this,e)},hi.prototype.onRMouseMove=function(e){},hi.prototype.pan=function(e,t){N.prototype.pan.call(this,e,t)},hi.prototype.zoom=function(e){var t=this.viewer.svgViewer.getSvgElement(),n=t.getAttribute("viewBox");if(null!=n){var n=n.split(" "),i=(n[2]=parseFloat(n[2]),n[3]=parseFloat(n[3]),n[2]),r=n[3];if(e.z<0)n[2]/=this.zoomRate,n[3]/=this.zoomRate;else{if(!(0<e.z))return;n[2]*=this.zoomRate,n[3]*=this.zoomRate}n[0]=parseFloat(n[0]),n[1]=parseFloat(n[1]);e=.5*(n[2]-i),i=.5*(n[3]-r);n[0]-=e,n[1]-=i,t.setAttribute("viewBox",n.join(" "))}},hi.prototype.create=function(){N.prototype.create.call(this)},hi.prototype.release=function(){N.prototype.release.call(this)},function(e){g.call(this,e),this.type="OpSvgPan",this.zoomRate=1.1}),ui=(N.prototype=Object.create(g.prototype),N.prototype.addEvents=function(e){var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).addEventListener("mousemove",this.onMouseMove,!1),t.addEventListener("mouseup",this.onMouseUp,!1)},N.prototype.removeEvents=function(e){var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).removeEventListener("mousemove",this.onMouseMove,!1),t.removeEventListener("mouseup",this.onMouseUp,!1)},N.prototype.onLMouseDown=function(e){g.prototype.onLMouseDown.call(this),this.addEvents()},N.prototype.onLMouseUp=function(e){g.prototype.onLMouseUp.call(this),this.removeEvents()},N.prototype.onMMouseDown=function(e){g.prototype.onMMouseDown.call(this);var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).removeEventListener("mousewheel",this.onMouseWheel,!1),this.addEvents()},N.prototype.onMMouseUp=function(e){g.prototype.onMMouseUp.call(this);var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).addEventListener("mousewheel",this.onMouseWheel,!1),this.removeEvents()},N.prototype.onLMouseMove=function(e){var t=this.pointer.x-this.pointerOld.x,n=this.pointer.y-this.pointerOld.y;this.pan(t,n)},N.prototype.onMMouseMove=function(e){N.prototype.onLMouseMove.call(this,e)},N.prototype.onRMouseMove=function(e){},N.prototype.pan=function(e,t){var n,i,r=this.viewer.svgViewer.getSvgElement(),o=r.getAttribute("viewBox");null!=o&&(n=this.viewer.svgViewer.svgObj.style.width,i=this.viewer.svgViewer.svgObj.style.height,(o=o.split(" "))[0]=parseFloat(o[0]),o[1]=parseFloat(o[1]),o[2]=parseFloat(o[2]),o[3]=parseFloat(o[3]),n=o[2]/n,i=o[3]/i,i*=1.15,o[0]-=e*(n*=1.15),o[1]-=t*i,r.setAttribute("viewBox",o.join(" ")))},N.prototype.zoom=function(e){hi.prototype.zoom.call(this,e)},N.prototype.create=function(){var e=this.viewer.svgViewer.getSvgElement();(e=null!==e?e:document).addEventListener("mousedown",this.onMouseDown,!1),e.addEventListener("mousewheel",this.onMouseWheel,!1),e.addEventListener("DOMMouseScroll",this.onMouseWheel,!1),e.addEventListener("click",this.onClick,!1)},N.prototype.release=function(){var e=this.viewer.svgViewer.getSvgElement();(e=null!==e?e:document).removeEventListener("mousedown",this.onMouseDown,!1),e.removeEventListener("mousewheel",this.onMouseWheel,!1),e.removeEventListener("DOMMouseScroll",this.onMouseWheel,!1),e.removeEventListener("click",this.onClick,!1)},function(e){g.call(this,e),this.type="OpSvgSelect",this.zoomRate=1.1}),pi=(ui.prototype=Object.create(g.prototype),ui.prototype.addEvents=function(e){N.prototype.addEvents.call(this)},ui.prototype.removeEvents=function(e){N.prototype.removeEvents.call(this)},ui.prototype.onLMouseDown=function(e){g.prototype.onLMouseDown.call(this),this.addEvents()},ui.prototype.onLMouseUp=function(e){g.prototype.onLMouseUp.call(this),this.removeEvents()},ui.prototype.onMMouseDown=function(e){g.prototype.onMMouseDown.call(this);var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).removeEventListener("mousewheel",this.onMouseWheel,!1),this.addEvents()},ui.prototype.onMMouseUp=function(e){g.prototype.onMMouseUp.call(this);var t=this.viewer.svgViewer.getSvgElement();(t=null!==t?t:document).addEventListener("mousewheel",this.onMouseWheel,!1),this.removeEvents()},ui.prototype.onLMouseClick=function(e){},ui.prototype.onMMouseMove=function(e){N.prototype.onMMouseMove.call(this,e)},ui.prototype.onRMouseMove=function(e){},ui.prototype.pan=function(e,t){N.prototype.pan.call(this,e,t)},ui.prototype.zoom=function(e){hi.prototype.zoom.call(this,e)},ui.prototype.create=function(){N.prototype.create.call(this)},ui.prototype.release=function(){N.prototype.release.call(this)},function(e){g.call(this,e),this.type="OpPrint",this.x_1,this.x_2,this.y_1,this.y_2}),fi=(pi.prototype=Object.create(g.prototype),pi.prototype.onOpPrint=function(){},pi.prototype.onLMouseDown=function(e){this.x_1=e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left,this.y_1=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top,this.state=ve.MOUSE.LEFT},pi.prototype.onLMouseMove=function(e){e.offsetX||(e.clientX,this.viewer.container.getBoundingClientRect().left),e.offsetY||(e.clientY,this.viewer.container.getBoundingClientRect().top)},pi.prototype.onLMouseUp=function(e){this.x_2=e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left,this.y_2=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top,this.state=ve.MOUSE.NONE;e=this.x_1>this.x_2?[this.x_2,this.y_2,this.x_1,this.y_1]:[this.x_1,this.y_1,this.x_2,this.y_2];this.viewer.getPrintData("temp","A4","l","color","select",e)},pi.prototype.onMMouseDown=function(e){this.state=ve.MOUSE.MIDDLE,this.viewer.getPrintData("temp","A4","l","color",null,null)},pi.prototype.onRMouseDown=function(e){this.state=ve.MOUSE.RIGHT,this.viewer.getPrintData("temp","A4","l","color","view",null)},pi.prototype.onTouchSingleMove=function(e){},function(){function e(e){this.viewer=e;var t=void 0,n=void 0,i=new THREE.LoadingManager;Object.defineProperties(this,{cachedProperties:{get:function(){return t},set:function(e){t=e}},cachedPropertyFileName:{get:function(){return n},set:function(e){n=e}},loadingManager:{get:function(){return i}}})}var t=e.prototype;return t.getObjectProperty=function(e,i,r){function t(e){return 1===(e=e.split("/")).length?"./":(e.pop(),e.join("/")+"/")}var o=e.uuid,a=((e=this.viewer.getObjectByUUID(o)).refModelUri&&this.referenceMap&&this.referenceMap.has(o)&&(o=this.referenceMap.get(o)),e.propertyfile);if(null==a)null!=i&&i(null,r);else if(void 0!==this.cachedProperties&&this.cachedPropertyFileName==a&&null!=this.cachedProperties[o]&&null!=i)i(this.cachedProperties[o],r);else{var n=new oi(this.loadingManager),s=(n.setCrossOrigin("anonymous"),n.setResponseType("arraybuffer"),e.getModel()),l=t(s.modelUri);if(e.refModelUri&&this.referenceMap&&0<e.refModelUri.indexOf("/")){var d=e.refModelUri+"/Configurations.json",c=e.configName;if(this.viewer.configurations&&this.viewer.configurations.has(d))for(var h=this.viewer.configurations.get(d).Configurations,u=0,p=h.length;u<p;++u)if(h[u].Name===e.configName){c=h[u].Folder;break}l=e.refModelUri+"/"+c+"/"}s.rootBodyNode.uuid==e.uuid&&(l=t(s.modelUri));var f,m=this,d=l+a;_e.singleHTML?(f=function(e){var t;try{t=pako.inflate(e,{to:"string"}),m.cachedProperties=JSON.parse(t),null!=m.cachedProperties&&(m.cachedPropertyFileName=a,null!=i)&&(null!=m.cachedProperties[o]?i(m.cachedProperties[o],r):i(null,r))}catch(e){null!=i&&i(null,r)}},m.viewer.modelRequestor.propertys.has(s.id)?((!(l=m.viewer.modelRequestor.propertys.get(s.id).get(d))||l.byteLength<1)&&console.error("缺少属性数据"),s=new Uint8Array(l.content),f(s)):(m.viewer.zipMutiModel&&(d=d.replace(/^\.\/|^\//,"")),l=m.viewer.ZIPData.files[d],m.viewer.ZIPData.file(l.name).async("uint8array").then(function(e){f(e)}))):n.load(this.viewer.gobalReqHeader,d,function(e){try{var t,n=pako.inflate(e,{to:"string"});m.cachedProperties=JSON.parse(n),null!=m.cachedProperties&&(m.cachedPropertyFileName=a,null!=i)&&(null!=m.cachedProperties[o]?i(m.cachedProperties[o],r):(t=o.split("_"),null!=m.cachedProperties[t[0]]?i(m.cachedProperties[t[0]],r):i(null,r)))}catch(e){null!=i&&i(null,r)}},void 0,function(e){null!=i&&i(null,r)},!0)}},t.bindReference=function(e,t){this.referenceMap||(this.referenceMap=new Map),this.referenceMap.set(e,t)},e}()),mi=function(){function e(C){this.viewer=C;var V=this,u=new Array,o=new Array,p=new Array,a=new Array,k=new Array,U="body",d=(_e.enablePreSelectBrep?U="vertex_edge_face":_e.inAssemblyContext&&(U="component"),"replace"),c=new Array,h=new Array,f=new Array,m=new Array,g=new Array,v=new Array,l=null,A=null,y=null,E=null,M=null,w=null,b=3,L=new THREE.Scene,x=new THREE.Object3D,G=(L.add(x),this.selectfromtree=!1),z=null,W=!1,Y=null,e=new THREE.MeshStandardMaterial({color:16763200,metalness:.2,roughness:1,side:THREE.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:2,skinning:!1}),t=new THREE.MeshLambertMaterial({color:16763200,side:THREE.DoubleSide,opacity:.5,transparent:!0,depthTest:!1,blending:THREE.NormalBlending,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:2,skinning:!1});function I(){if(V.viewer.ndsModel)V.viewer.ndsModel.clearSelection();else for(var e=V.viewer.getRenderMode(),t=0;t<a.length;++t){var n=a[t].key,i=a[t].value.oldMat;n.material=i,void 0!==n.material.colorWrite&&(4==e||5==e||8==e?n.material.colorWrite=!0:6!=e&&7!=e||(n instanceof THREE.Line||n instanceof THREE.LineSegments?n.material.colorWrite=!0:n.material.colorWrite=!1))}a.length=0,k.length=0,x.children.length=0,c.length=0,h.length=0,f.length=0,m.length=0,g.length=0,v.length=0}function T(e,t){var n=!1,t=("face"!=t&&(l=null,A)&&(x.remove(A),n=!(A=null)),"edge"!=t&&(y=null,E)&&(x.remove(E),n=!(E=null)),"vertex"!=t&&(M=null,w)&&(x.remove(w),n=!(w=null)),V.viewer.ndsModel.clearPreSelection());(n||t)&&e&&V.viewer.render()}function D(e,t){return e.uuid==t.uuid||!(!e.parent||!D(e.parent,t))}function H(e,t){if(void 0!==e&&!1!==e.visible&&!(e instanceof THREE.Light||"lightctrls"==e.name)){if(e.hasOwnProperty("geometry")){if(e instanceof THREE.Line){for(var n=0,i=o.length;n<i;n++)if(o[n]===e)return;o.push(e)}else t.push(e);p.push(e)}if(void 0!==e.children)for(var r=e.children,n=0,i=r.length;n<i;++n)H(r[n],t)}}function F(e,t,n){if(C.pmiVisible&&C.pmiObject&&"OpMeasure"!=C.controls.getOperator().type){var i=C.renderer.domElement,r=e*(B=C.renderer.getPixelRatio())/i.width*2-1,o=2*-(t*B/i.height)+1,a=((P=new THREE.Raycaster).linePrecision=1,[0,0]),s=C.clientCoordToModelCoord(a),l=new THREE.Vector3(s[0],s[1],s[2]),d=[4,0],c=C.clientCoordToModelCoord(d),h=new THREE.Vector3(c[0],c[1],c[2]),u=(P.linePrecision=.45*l.distanceTo(h),C.camera.setCastRay(P,r,o),new THREE.Matrix4),p=new THREE.Ray,f=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,v=1/0,A=P.intersectObjects(C.leafPMIObjects,!0),y=A[0];if(A[0]&&A[0].index&&Number.isFinite(A[0].object.geometry.drawRange.count)){y=null;for(var E=0;E<A.length;E++){if(null!=A[E].faceIndex&&!y){y=A[E];break}var M=A[E].object.geometry.drawRange.count;if(Number.isFinite(M))for(var w,b,x,I,T,S=A[E].object.geometry.drawRange.start;S<A[E].object.geometry.drawRange.start+M;++S)S==A[E].index&&(w=A[E].object.matrixWorld,u.getInverse(w),p.copy(P.ray).applyMatrix4(u),w=A[E].object.geometry.index.array[S],b=A[E].object.geometry.index.array[S+1],m.fromArray(A[E].object.geometry.attributes.position.array,3*w),g.fromArray(A[E].object.geometry.attributes.position.array,3*b),w=p.distanceSqToSegment(m,g,null,f),b=g.sub(m),x=f.sub(m),I=b.length(),T=x.length(),b.normalize(),x.normalize(),T<I&&Math.abs(b.x-x.x)<1e-5&&Math.abs(b.y-x.y)<1e-5&&Math.abs(b.z-x.z)<1e-5||x.length()<1e-6)&&w<v&&(v=w,y=A[E])}}if(y){if(2==C.pmiObject.children[0].version)for(;!y.object.NdsBodyNode&&y.object.parent;)y.object=y.object.parent;y.object.select?null==n||0==n?C.ndsModel.deselectPMIObject(C.pmiObject,!0):C.ndsModel.deselectPMIObject(y.object):(null!=n&&0!=n||C.ndsModel.deselectPMIObject(C.pmiObject,!1),y.object.visible&&C.ndsModel.selectPMIObject(y.object))}else null!=n&&0!=n||C.ndsModel.deselectPMIObject(C.pmiObject)}var B,P;C.controls.staticDrawGeomOp&&C.controls.staticDrawGeomOp.needSelectGeom()&&(i=C.renderer.domElement,r=e*(B=C.renderer.getPixelRatio())/i.width*2-1,o=2*-(t*B/i.height)+1,(P=new THREE.Raycaster).linePrecision=1,s=C.clientCoordToModelCoord(a=[0,0]),l=new THREE.Vector3(s[0],s[1],s[2]),c=C.clientCoordToModelCoord(d=[4,0]),h=new THREE.Vector3(c[0],c[1],c[2]),P.linePrecision=.65*l.distanceTo(h),C.camera.setCastRay(P,r,o),y=P.intersectObjects(C.controls.staticDrawGeomOp.drawScene.children,!0)[0],(C.controls.staticDrawGeomOp.isTraceMode()?y&&"Point"!=y.object.objectType:!!y)?(e=C.controls.staticDrawGeomOp.hasMeshSelected(y.object.uuid),null==n||0==n||C.controls.staticDrawGeomOp.isTraceMode()?(C.controls.staticDrawGeomOp.deselectAllMesh(e),e||C.controls.staticDrawGeomOp.selectMesh([y.object.uuid])):e?C.controls.staticDrawGeomOp.deselectMesh([y.object.uuid]):C.controls.staticDrawGeomOp.selectMesh([y.object.uuid])):null!=n&&0!=n||C.controls.staticDrawGeomOp.deselectAllMesh(!0))}function N(e,t){return!(e&&!t||!e&&t||!e&&!t||V.viewer.ndsModel&&(e.bodyId!=t.bodyId||e.meshId!=t.meshId||e.lineSegId!=t.lineSegId)||e.parentObj!=t.parentObj||e.id!=t.id)}function i(e){if(e&&V.viewer.hasBrepInfo()){var t,n,i,r,o=V.viewer.ndsModel?e.object:V.findParentElement(e.object);if(o)return i=o.type.toLowerCase(),o&&"body"===i&&(i=o.uuid,o=e.object.uuid,V.viewer.ndsModel&&(0<=e.meshId?(e.mesh=V.viewer.ndsModel.meshManager.getSingleMesh(e.meshId),e.mesh&&(t=e.faceIndex-e.mesh.geometry.drawRange.start/3,n="face")):0<=e.lineSegId&&(e.mesh=V.viewer.ndsModel.meshManager.getLineSegments(e.lineSegId),e.mesh)&&(t=.5*(e.index-e.mesh.geometry.drawRange.start),n="edge"),o=e.geomUuid),0<=t)&&(r=V.viewer.brepManager.GetBrepInfoByUUidAndTopolIndex(i,o,t,n))&&(r.parentObj=e.mesh,r.intersect=e.point.clone(),r.bodyId=i,r.meshId=o,r.lineSegId=e.lineSegId,r.normal)&&null==r.worldNormal&&(t=new THREE.Vector3,n=new THREE.Quaternion,i=new THREE.Vector3,r.parentObj.matrixWorld.decompose(t,n,i),r.worldNormal=new THREE.Vector3(r.normal[0],r.normal[1],r.normal[2]),r.worldNormal.applyQuaternion(n)),r}}function S(e,t){if(e&&e.parentObj instanceof THREE.Mesh){var n,i=e.parentObj.geometry,r=e.indexRange.concat();if(V.viewer.ndsModel&&(r[0]+=i.drawRange.start/3,r[1]+=i.drawRange.start/3),i.isBufferGeometry){for(var o=i.index,a=i.attributes.position,i=r[1]-r[0]+1,s=new Float32Array(9*i),l=0,d=r[0],c=r[1];d<=c;d++,l+=1){var h=3*d,u=o.getX(h),p=o.getX(1+h),h=o.getX(2+h),f=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3;f.fromBufferAttribute(a,u),m.fromBufferAttribute(a,p),g.fromBufferAttribute(a,h),s[9*l]=f.x,s[9*l+1]=f.y,s[9*l+2]=f.z,s[9*l+3]=m.x,s[9*l+4]=m.y,s[9*l+5]=m.z,s[9*l+6]=g.x,s[9*l+7]=g.y,s[9*l+8]=g.z,g=m=f=null}i=new THREE.BufferGeometry;i.addAttribute("position",new THREE.BufferAttribute(s,3)),(n=new THREE.Mesh(i,0==t?_e.selectedFaceMaterial:_e.preSelectedFaceMaterial)).objectType="Face",n.applyMatrix(e.parentObj.matrixWorld),n.matrixWorldNeedsUpdate=!0}return n}}function B(e,t){if(e&&e.parentObj instanceof THREE.Line){var n,i=e.parentObj.geometry,r=e.indexRange.concat();if(V.viewer.ndsModel&&(r[0]+=i.drawRange.start/2,r[1]+=i.drawRange.start/2),i.isBufferGeometry){var o=r[1]-r[0]+1,a=i.index,s=i.attributes.position.array,l=new Float32Array(6*o);if(null!=a){var d=a.array,c=0,i=r[0],o=r[1];"circle"==e.type&&Math.round(.5*(i+o));for(var h=i,u=o;h<=u;h++,c+=1){var p=d[2*h],f=d[2*h+1],m=new THREE.Vector3,g=new THREE.Vector3;m.fromArray(s,3*p),g.fromArray(s,3*f),l[6*c]=m.x,l[6*c+1]=m.y,l[6*c+2]=m.z,l[6*c+3]=g.x,l[6*c+4]=g.y,l[6*c+5]=g.z,g=m=null}a=new THREE.BufferGeometry;a.addAttribute("position",new THREE.BufferAttribute(l,3)),(n=new THREE.LineSegments(a,0==t?_e.selectedEdgeMaterial:_e.preSelectedEdgeMaterial)).objectType="Edge",n.applyMatrix(e.parentObj.matrixWorld),n.matrixWorldNeedsUpdate=!0}}return n}}function j(e,t){o=e,n=5,null!=(t=t)&&(n=t),t=V.viewer.camera.getCameraTarget(),i=V.viewer.camera.position,(r=new THREE.Vector3).subVectors(t,i),t=o.position.clone(),o=V.viewer.camera.isPerspective?t.sub(i).dot(r.normalize()):r.length(),t=V.viewer.camera.fov,i=2*o*Math.tan(THREE.Math.degToRad(.5*t)),r=V.viewer.renderer.domElement.height;var n,i,r,o=n*i*V.viewer.renderer.getPixelRatio()/r;e.scale.x=o,e.scale.y=o,e.scale.z=o,e.updateMatrixWorld()}function P(e,t,n){n=new THREE.Mesh(new THREE.SphereGeometry(1),0==n?_e.selectedVertexMaterial:_e.preSelectedVertexMaterial);return n.position.set(e.x,e.y,e.z),j(n,t),n.objectType="Point",n}function s(e,t,n){t?e.isPreSelected()||(V.viewer.ndsModel.preSelectObject(e),V.viewer.render(),V.viewer.dispatchAsyncEvent({type:"PreSelectedEntityChangeEvent",entityId:e.uuid})):null!=n&&1==n||"accumulate"==d?V.isObjectSelected(e)?(V.deselectObject(e),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:[{entityType:e.type,bodyId:e.uuid,entityId:""}]})):(V.selectObject(e),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:e.type,bodyId:e.uuid,entityId:""}],removed:[]})):V.isObjectSelected(e)?V.clearSelection():(V.clearSelection(),V.selectObject(e),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:e.type,bodyId:e.uuid,entityId:""}],removed:[]})),V.viewer.groundShadowChange()}function _(e){e=i(e[0]);return e&&null!=e.area?e:null}function X(e,t,n){if(t)T(!1,"face"),l?N(l,e)||(l=e,x.remove(A),A=S(e,!0),x.add(A),V.viewer.render(),V.viewer.dispatchAsyncEvent({type:"PreSelectedEntityChangeEvent",entityId:e.id})):(A=S(l=e,!0),x.add(A),V.viewer.render(),V.viewer.dispatchAsyncEvent({type:"PreSelectedEntityChangeEvent",entityId:e.id}));else{for(var i,r=!1,o=-1,a=0,s=c.length;a<s;a++)if(N(c[a],e)){r=!0,o=a;break}null!=n&&1==n||"accumulate"==d?r?(t=c[o],c.splice(o,1),x.remove(h[o]),h[o]=null,h.splice(o,1),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:[{entityType:"face",bodyId:t.bodyId,entityId:t.id}]})):(c.push(e),(i=S(e,!1))&&(x.add(i),h.push(i)),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"face",bodyId:e.bodyId,entityId:e.id}],removed:[]})):(n=V.getAllSelectionInfors(),t=[],I(),!r&&(c.push(e),t.push({entityType:"face",bodyId:e.bodyId,entityId:e.id}),i=S(e,!1))&&(x.add(i),h.push(i)),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:t,removed:n}))}}function Q(e,t,n,i,r){if(V.viewer.hasBrepInfo()){e=O(e,t,!1);if(e&&0<e.length){if("refplane"==e[0].bodyNode.type.toLowerCase())return void s(e[0].bodyNode,n,i);t=_(e);if(t)return r&&"plane"!=t.type?void 0:void X(t,n,i)}n?T(!0):null!=i&&0!=i||V.clearSelection()}}function r(e){var t=null;if(V.viewer.ndsModel?0<=e[0].lineSegId&&(t=e[0]):e[0].object instanceof THREE.Line||e[0].object instanceof THREE.LineSegments?t=e[0]:1<e.length&&(e[1].object instanceof THREE.Line||e[1].object instanceof THREE.LineSegments)&&Math.abs(e[1].distance-e[0].distance)<(n=V.viewer.controls.getBoundingBox()).min.distanceTo(n.max)/1e3&&(t=e[1]),t){var n=i(t);if(n)return n}return null}function R(e,t,n){if(t)T(!1,"edge"),y?N(y,e)||(y=e,x.remove(E),E=B(e,!0),x.add(E),V.viewer.render(),V.viewer.dispatchAsyncEvent({type:"PreSelectedEntityChangeEvent",entityId:e.id})):(E=B(y=e,!0),x.add(E),V.viewer.render(),V.viewer.dispatchAsyncEvent({type:"PreSelectedEntityChangeEvent",entityId:e.id}));else{for(var i,r=!1,o=-1,a=0,s=f.length;a<s;a++)if(N(f[a],e)){r=!0,o=a;break}null!=n&&1==n||"accumulate"==d?r?(t=f[o],f.splice(o,1),x.remove(m[o]),m[o]=null,m.splice(o,1),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:[{entityType:"edge",bodyId:t.bodyId,entityId:t.id}]})):(f.push(e),(i=B(e,!1))&&(x.add(i),m.push(i)),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"edge",bodyId:e.bodyId,entityId:e.id}],removed:[]})):(n=V.getAllSelectionInfors(),t=[],I(),!r&&(f.push(e),t.push({entityType:"edge",bodyId:e.bodyId,entityId:e.id}),i=B(e,!1))&&(x.add(i),m.push(i)),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:t,removed:n}))}}function Z(e,t,n,i){if(V.viewer.hasBrepInfo()){e=O(e,t,!0);if(e&&0<e.length){if("refaxis"==e[0].bodyNode.type.toLowerCase())return void s(e[0].bodyNode,n,i);t=r(e);if(null!=t)return void R(t,n,i)}n?T(!0):null!=i&&0!=i||V.clearSelection()}}function O(e,t,n){var i=V.viewer,r=i.renderer.domElement,o=i.renderer.getPixelRatio(),e=e*o/r.width*2-1,t=2*-(t*o/r.height)+1,o=new THREE.Raycaster,a=(i.camera.setCastRay(o,e,t),n&&(o.linePrecision=1,r=i.clientCoordToModelCoord([0,0]),e=new THREE.Vector3(r[0],r[1],r[2]),t=i.clientCoordToModelCoord([4,0]),r=new THREE.Vector3(t[0],t[1],t[2]),o.linePrecision=e.distanceTo(r)),null);if(i.ndsModel){if((a=n?i.ndsModel.intersect(o.ray,o.linePrecision):i.ndsModel.intersect(o.ray))&&0<a.length)if(G){if(z&&0<z.length)for(var s=!1,l=0;l<a.length;l++){c=a[l].bodyNode;for(var s=!1,d=0;d<z.length;d++)if(z[d]==c||c.isChildOfNode(z[d])){s=!0;break}s&&(a.splice(l,1),l--)}}else if(W&&Y&&0<Y.length)for(var c,h=!1,l=0;l<a.length;l++){c=a[l].bodyNode;for(h=!1,d=0;d<Y.length;d++)if(Y[d]==c||c.isChildOfNode(Y[d])){h=!0;break}h||(a.splice(l,1),l--)}}else t=V.viewer.getIsolateMeshes(),a=0<t.length?o.intersectObjects(t):n?o.intersectObjects(p):o.intersectObjects(u);return a}function q(e){var e=e[0],t=V.viewer.ndsModel?e.object:V.findParentElement(e.object);if(t&&"body"==t.type.toLowerCase()){var n=t.uuid,i=V.viewer.brepManager.GetVerticesByBodyUUID(n);if(i){for(var r,o=(d=t)?(d.boxDiagonalLength||(l=new THREE.Vector3,o=new THREE.Vector3,V.viewer.computeBoundingBox(d,l,o,{flag:!0}),d.boxDiagonalLength=o.distanceTo(l)),.015*d.boxDiagonalLength):.5,a=o*o,s=e.point.clone(),l=null,l=V.viewer.ndsModel?t.worldMatrix:t.matrixWorld,d=new THREE.Matrix4,e=(d.getInverse(l),s.applyMatrix4(d),V.viewer.modelCoordToClientCoord([s.x,s.y,s.z])),c=new THREE.Vector3(e[0],e[1],0),h=new THREE.Vector3,u=new THREE.Vector3,p=64,f=-1,m=0,g=i.length;m<g;m++)u.set(i[m].coords[0],i[m].coords[1],i[m].coords[2]),s.distanceToSquared(u)<a&&(r=V.viewer.modelCoordToClientCoord(i[m].coords),h.set(r[0],r[1],0),(r=c.distanceToSquared(h))<p)&&(f=m,p=r);if(0<=f)return u.set(i[f].coords[0],i[f].coords[1],i[f].coords[2]),u.applyMatrix4(l),{id:i[f].id,coords:[u.x,u.y,u.z],bodyId:n}}}return null}function K(e,t,n){var i=new THREE.Vector3(e.coords[0],e.coords[1],e.coords[2]);if(t)T(!1,"vertex"),M?M.id!=e.id&&(M=e,w.position.set(i.x,i.y,i.z),V.viewer.render(),V.viewer.dispatchAsyncEvent({type:"PreSelectedEntityChangeEvent",entityId:e.id})):(M=e,w=P(i,b,!0),x.add(w),V.viewer.render(),V.viewer.dispatchAsyncEvent({type:"PreSelectedEntityChangeEvent",entityId:e.id}));else{for(var r,o=!1,a=-1,s=0,l=g.length;s<l;s++)if(g[s].id==e.id){o=!0,a=s;break}null!=n&&1==n||"accumulate"==d?o?(t=g[a],g.splice(a,1),x.remove(v[a]),v[a]=null,v.splice(a,1),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:[{entityType:"vertex",bodyId:t.bodyId,entityId:t.id}]})):(g.push(e),(r=P(i,b,!1))&&(x.add(r),v.push(r)),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"vertex",bodyId:e.bodyId,entityId:e.id}],removed:[]})):(n=V.getAllSelectionInfors(),t=[],I(),!o&&(g.push(e),t.push({entityType:"vertex",bodyId:e.bodyId,entityId:e.id}),r=P(i,b,!1))&&(x.add(r),v.push(r)),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:t,removed:n}))}}function J(e,t,n,i){if(V.viewer.hasBrepInfo()){e=O(e,t,!0);if(e&&0<e.length){t=q(e);if(null!=t)return void K(t,n,i)}n?T(!0):null!=i&&0!=i||V.clearSelection()}}function $(e,t,n,i){if(V.viewer.hasBrepInfo()){e=O(e,t,!0);if(e&&0<e.length){t=e[0].bodyNode.type.toLowerCase();if("refpoint"==t||"refaxis"==t||"refplane"==t)return void s(e[0].bodyNode,n,i);t=q(e);if(t)return void K(t,n,i);t=r(e);if(t)return void R(t,n,i);t=_(e);if(t)return void X(t,n,i)}n?T(!0):null!=i&&0!=i||V.clearSelection()}}function ee(e,t,n,i){if(V.viewer.hasBrepInfo()){e=O(e,t,!0);if(e&&0<e.length){if("refaxis"==e[0].bodyNode.type.toLowerCase())return void s(e[0].bodyNode,n,i);t=r(e);if(t){if("line"==t.type)return void R(t,n,i)}else{t=_(e);if(t&&"cylinder"==t.type)return void X(t,n,i)}}n?T(!0):null!=i&&0!=i||V.clearSelection()}}function te(e,t,n,i){if(V.viewer.hasBrepInfo()){e=O(e,t,!0);if(e&&0<e.length){if("refaxis"==e[0].bodyNode.type.toLowerCase())return void s(e[0].bodyNode,n,i);t=r(e);if(null!=t&&"line"==t.type)return void R(t,n,i)}n?T(!0):null!=i&&0!=i||V.clearSelection()}}function ne(e,t,n,i){if(V.viewer.hasBrepInfo()){e=O(e,t,!0);if(e&&0<e.length){t=e[0].bodyNode.type.toLowerCase();if("refaxis"==t||"refplane"==t)return void s(e[0].bodyNode,n,i);t=r(e);if(null!=t){if("line"==t.type)return void R(t,n,i)}else{t=_(e);if(t&&"plane"==t.type)return void X(t,n,i)}}n?T(!0):null!=i&&0!=i||V.clearSelection()}}function ie(e){return null==e?null:e instanceof THREE.Object3D&&"Link"===e.type?e:ie(e.parent)}this.selectedObjects=k,this.shouldApplySelectedMaterial=!0,this.setSelectType=function(e){U=e},this.getSelectType=function(){return U},this.setSelectPolicy=function(e){d=e},this.getSelectPolicy=function(){return d},this.enableExclusivePicking=function(e,t){if(e)if(W=!(G=!0),Y=null,t&&0<t.length){var n;z=[];for(var i=0;i<t.length;i++)(n=V.viewer.ndsModel.getBodyNodeFromUuid(t[i]))&&z.push(n)}else z=null;else G=!1,z=null},this.enableInclusivePicking=function(e,t){if(e)if(G=!(W=!0),z=null,t&&0<t.length){var n;Y=[];for(var i=0;i<t.length;i++)(n=V.viewer.ndsModel.getBodyNodeFromUuid(t[i]))&&Y.push(n)}else Y=null;else W=!1,Y=null},this.clearSelection1=function(){if(0!=a.length||0!=k.length||0!=c.length||0!=f||0!=g.length){for(var e,t=0;t<a.length;++t){var n=a[t].key,i=a[t].value;n.material=i}a.length=0,k.length=0,x.children.length=0,c.length=0,h.length=0,f.length=0,m.length=0,g.length=0,v.length=0,V.viewer.dispatchAsyncEvent({type:"clearSelection"}),V.viewer.startMove(),V.viewer.drawTraceUpdate(),_e.enableBodyVolumeMeasure&&V.viewer.hasBrepInfo()&&((e=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:e[0],modelUnit:e[1]}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),V.viewer.groundShadowChange()}},this.clearSelection=function(){var e,t,n,i;(0!=a.length||0!=k.length||0!=c.length||0!=f||0!=g.length||V.viewer.ndsModel&&0!=V.viewer.ndsModel.selectedBodies.length)&&(e=0<k.length,t=V.getAllSelectionInfors(),I(),V.viewer.dispatchAsyncEvent({type:"clearSelection"}),V.viewer.dispatchAsyncEvent({type:"selectObjectEvent"}),V.viewer.startMove(),V.viewer.drawTraceUpdate(),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:t}),n="BodyVolume"!==(t=V.viewer.getCurrentMeasureType())&&"BodyArea"!==t,_e.enableBodyVolumeMeasure&&V.viewer.hasBrepInfo()&&e&&n&&((i=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:i[0],modelUnit:i[1]}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),_e.enableBodyVolumeMeasure&&V.viewer.hasBrepInfo()&&!n&&((i=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:i[0],measureType:t,modelUnit:i[1]}):V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:null,measureType:t,modelUnit:null})),V.viewer.groundShadowChange())},this.clearPreSelection=function(e){T(e)},this.clearSelectedBrepEntities=function(){var e;0==c.length&&0==f&&0==g.length||(e=V.getAllSelectedBrepEntities(),x.children.length=0,c.length=0,h.length=0,f.length=0,m.length=0,g.length=0,v.length=0,V.viewer.dispatchAsyncEvent({type:"clearSelectedBrepEntities"}),V.viewer.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:e}))},this.changeSelectedObjectMaterial=function(e,t){var n,i=e.children;if((null==i||i.length<=0||e instanceof THREE.SkinnedMesh)&&!function(e){for(var t=0,n=a.length;t<n;++t)if(e==a[t].key)return 1;return}(e)&&null!=e.material)(n=e.material.clone()).oldMat=e.material,a.push(new Se.map(e,n)),e instanceof THREE.SkinnedMesh?t.skinning=!0:t.skinning=!1,e.material=t;else for(var r=0;r<i.length;++r)V.changeSelectedObjectMaterial(i[r],t)},this.overrideMeshSelectionMaterialIn3DViewer=function(){V.viewer.isNdsModelInWireframeMode(V.viewer.getRenderMode())?_e.selectedMaterial=e:_e.selectedMaterial=t,_e.inBIMContext?V.viewer.ndsModel.meshManager.setSelectedMaterial(_e.selectedMaterial,_e.selectedLineMaterial):V.viewer.ndsModel.models.forEach(function(e){e.meshManager.setSelectedMaterial(V.viewer.is2DModel?_e.selectedFace2DMaterial:_e.selectedMaterial,_e.selectedLineMaterial)})},this.overrideLineSelectionMaterialIn3DViewer=function(e){e&&V.shouldApplySelectedMaterial&&V.viewer.isIn3DViewer()&&!V.viewer.isNdsModelInWireframeMode(V.viewer.getRenderMode())&&(e.transparent=!0,e.opacity=.9,e.depthTest=!1)},this.selectObjectByList=function(e,t){for(var n=null,i=0;i<e.length;++i){var r=(V.viewer.ndsModel.objectidTouuid||V.viewer.ndsModel.meshManager.bodyUuids)[e[i]],o=V.viewer.ndsModel.getBodyNodeFromUuid(r);if(o||(r=V.viewer.ndsModel.meshManager.lineSegBodyUuids[e[i]],o=V.viewer.ndsModel.getBodyNodeFromUuid(r)),o&&!V.isObjectSelected(o))for(V.selectObject(o,!1,!(!0===t)),n=o;o.parent&&V.viewer.ndsModel.isBodyAllChildSelected(o.parent);)V.selectObject(o.parent,!1,!(!0===t)),n=o=o.parent}!0===t&&n&&V.selectObject(o),V.viewer.render()},this.selectObjectList=function(e,t){V.selectfromtree=t||!1;for(var n=null,i=0;i<e.length;i++){var r,n=e[i];V.viewer.ndsModel&&(n=V.viewer.ndsModel.getBodyNodeFromUuid(n.uuid)),V.viewer.outlinePass&&V.viewer.outlinePass.enabled?V.viewer.outlinePass.selectedObjects=k:(_e.selectedMaterial.colorWrite=!0,V.viewer.ndsModel?"refpoint"==(r=n.type.toLowerCase())||"refaxis"==r||"refplane"==r?n.select():(_e.inBIMContext?V.viewer.ndsModel.meshManager.setSelectedMaterial(_e.selectedMaterial,_e.selectedLineMaterial):V.viewer.ndsModel.models.forEach(function(e){e.meshManager.setSelectedMaterial(V.viewer.is2DModel?_e.selectedFace2DMaterial:_e.selectedMaterial,_e.selectedLineMaterial)}),V.viewer.ndsModel.addSelection(n)):V.changeSelectedObjectMaterial(n,_e.selectedMaterial)),V.isObjectSelected(n)||k.push(n),V.viewer.selectionOutlinePass&&(V.viewer.selectionOutlinePass.selectedObjects=k)}V.viewer.dispatchAsyncEvent({type:"selectObject",object:n,selectfromtree:V.selectfromtree}),V.viewer.dispatchAsyncEvent({type:"selectObjectEvent"});var o,a,t=V.viewer.getCurrentMeasureType(),s="BodyVolume"!==t&&"BodyArea"!==t?!0:!1;_e.enableBodyVolumeMeasure&&(!V.viewer.hasBrepInfo()||V.viewer.productData)&&s&&((o=V.viewer.getSelectedObjectProperty(function(){}))&&1e-7<o.area?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:o,modelUnit:o.unit}):0<k.length?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:V.viewer.modelUnit}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),_e.enableBodyVolumeMeasure&&V.viewer.hasBrepInfo()&&!V.viewer.productData&&s&&((a=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:a[0],modelUnit:a[1]}):0<k.length?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:V.viewer.modelUnit}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),_e.enableBodyVolumeMeasure&&V.viewer.hasBrepInfo()&&!s&&((a=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:a[0],measureType:t,modelUnit:a[1]}):V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:null,measureType:t,modelUnit:null})),V.viewer.groundShadowChange()},this.selectObject=function(e,t,n){V.selectfromtree=t||!1;var i=e;if(i=V.viewer.ndsModel?V.viewer.ndsModel.getBodyNodeFromUuid(e.uuid):i){V.viewer.outlinePass&&V.viewer.outlinePass.enabled?V.viewer.outlinePass.selectedObjects=k:(_e.selectedMaterial.colorWrite=!0,V.viewer.ndsModel?"refpoint"==(t=i.type.toLowerCase())||"refaxis"==t||"refplane"==t?i.select():(_e.inBIMContext?V.viewer.ndsModel.meshManager.setSelectedMaterial(_e.selectedMaterial,_e.selectedLineMaterial):V.viewer.ndsModel.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.meshManager.setSelectedMaterial(V.viewer.is2DModel?_e.selectedFace2DMaterial:_e.selectedMaterial,_e.selectedLineMaterial)}),V.viewer.ndsModel.addSelection(i)):V.changeSelectedObjectMaterial(i,_e.selectedMaterial)),V.viewer.selectionOutlinePass&&(V.viewer.selectionOutlinePass.selectedObjects=k);for(var r=!1,o=0;o<k.length;++o)if(i.uuid==k[o].uuid){r=!0;break}if(!r){for(o=0;o<k.length;++o)D(k[o],i)&&(k.splice(o,1),o--);k.push(i)}"OpExplode"==V.viewer.controls.getOperator().type&&V.viewer.controls.getOperator().changeSelobject(),V.viewer.dispatchAsyncEvent({type:"selectObject",object:i,selectfromtree:V.selectfromtree});var a,e=V.viewer.getCurrentMeasureType(),t="BodyVolume"!==e&&"BodyArea"!==e?!0:!1;!1!==n&&(_e.enableBodyVolumeMeasure&&(!V.viewer.hasBrepInfo()||V.viewer.productData||_e.AnimationEdit)&&t&&((n=V.viewer.getSelectedObjectProperty(function(){}))&&1e-7<n.area?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:n,modelUnit:n.unit}):0<k.length?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:V.viewer.modelUnit}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),_e.enableBodyVolumeMeasure&&V.viewer.hasBrepInfo()&&!_e.AnimationEdit&&!V.viewer.productData&&t&&((a=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:a[0],modelUnit:a[1]}):0<k.length?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:V.viewer.modelUnit}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:null})),_e.enableBodyVolumeMeasure)&&V.viewer.hasBrepInfo()&&!_e.AnimationEdit&&!t&&((a=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:a[0],measureType:e,modelUnit:a[1]}):V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:null,measureType:e,modelUnit:null})),V.viewer.groundShadowChange(),V.viewer.startMove(),V.viewer.drawTraceUpdate()}},this.isObjectSelected=function(e){if(e.parent&&this.isObjectSelected(e.parent))return!0;for(var t=0,n=k.length;t<n;++t)if(e.uuid==k[t].uuid)return!0;return!1},this.deselectObject=function(e,t){var n=e;V.viewer.ndsModel&&(n=V.viewer.ndsModel.getBodyNodeFromUuid(e.uuid)),V.viewer.ndsModel?"refpoint"==(e=n.type.toLowerCase())||"refaxis"==e||"refplane"==e?n.deSelect():V.viewer.ndsModel.removeSelection(n):V.restoreSelectedObjectMaterial(n);for(var i=0;i<k.length;++i)D(k[i],n)&&(k.splice(i,1),i--);for(var r=[],i=0;i<k.length;++i)if(D(n,k[i])){var o=null;V.viewer.ndsModel?o=V.viewer.ndsModel.getSelectedLeafBodyNodes(k[i]):function e(t,n){if(V.viewer.isLeaf(t)){for(var i=!1,r=V.getSelectedMeshes(),o=0,a=r.length;o<a;++o){var s=r[o].key;if(s.uuid==t.uuid||s.parent.uuid==t.uuid){i=!0;break}}i&&n.push(t)}else for(o=0,a=t.children.length;o<a;o++)e(t.children[o],n)}(k[i],o=[]);for(var a=0,s=o.length;a<s;++a)r.push(o[a]);k.splice(i,1),i--}for(var l=k.length,i=0,s=r.length;i<s;++i){for(var d=!1,a=0;a<l;a++)if(r[i].uuid==k[a].uuid){d=!0;break}d||k.push(r[i])}"OpExplode"==V.viewer.controls.getOperator().type&&V.viewer.controls.getOperator().changeSelobject();var c,e=V.viewer.getCurrentMeasureType(),h="BodyVolume"!==e&&"BodyArea"!==e?!0:!1;!1!==t&&(_e.enableBodyVolumeMeasure&&(!V.viewer.hasBrepInfo()||V.viewer.productData)&&h&&((t=V.viewer.getSelectedObjectProperty(function(){}))&&1e-7<t.area?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:t,modelUnit:t.unit}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:V.viewer.modelUnit})),_e.enableBodyVolumeMeasure&&V.viewer.hasBrepInfo()&&!V.viewer.productData&&h&&((c=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:c[0],modelUnit:c[1]}):V.viewer.dispatchAsyncEvent({type:"BodySelectionChangeEvent",volumeAreaInfo:null,modelUnit:V.viewer.modelUnit})),_e.enableBodyVolumeMeasure)&&V.viewer.hasBrepInfo()&&!h&&((c=V.getSelectedBodyVolumeAndArea())?V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:c[0],measureType:e,modelUnit:c[1]}):V.viewer.dispatchAsyncEvent({type:"BodyMeasureChangeEvent",volumeAreaInfo:null,measureType:e,modelUnit:null})),V.viewer.groundShadowChange(),V.viewer.drawTraceUpdate()},this.restoreSelectedObjectMaterial=function(e){var t=e.children;if(null==t||t.length<1||e instanceof THREE.SkinnedMesh)for(var n,i=0;i<a.length;i++)if(e.uuid==a[i].key.uuid)return n=a[i].value,e.material=n,void 0!==e.material.colorWrite&&(4==(n=V.viewer.getRenderMode())||5==n||8==n?e.material.colorWrite=!0:6!=n&&7!=n||(e instanceof THREE.Line||e instanceof THREE.LineSegments?e.material.colorWrite=!0:e.material.colorWrite=!1)),void a.splice(i,1);for(i=0;i<t.length;++i)V.restoreSelectedObjectMaterial(t[i])},this.getSelectedMeshes=function(){return a},this.getSelectedObjects=function(){var t,n;return 0!=Object.keys(V.viewer.bodyUuid2ClonedNodeMap).length&&_e.HideLeafBody?(t=[],n=[],k.forEach(function(e){e=V.viewer.ndsModel.bodyUuid2NodeMap[e.uuid];"Body"==e.type?e.parent&&-1==n.indexOf(e.parent.uuid)&&(t.push(V.viewer.ndsModel.bodyUuid2NodeMap[e.parent.uuid]),n.push(e.parent.uuid)):-1==n.indexOf(e.uuid)&&(t.push(V.viewer.ndsModel.bodyUuid2NodeMap[e.uuid]),n.push(e.uuid))}),t):k},this.getSelectedNewObjects=function(){var n,i;return 0==Object.keys(V.viewer.bodyUuid2ClonedNodeMap).length?k:(n=[],i=[],k.forEach(function(e){var t;_e.HideLeafBody?"Body"==(t=V.viewer.bodyUuid2ClonedNodeMap[e.uuid]||V.viewer.ndsModel.bodyUuid2NodeMap[e.uuid]).type?t.parent&&-1==i.indexOf(t.parent.uuid)&&(n.push(V.viewer.bodyUuid2ClonedNodeMap[t.parent.uuid]),i.push(t.parent.uuid)):-1==i.indexOf(t.uuid)&&(n.push(V.viewer.bodyUuid2ClonedNodeMap[t.uuid]),i.push(t.uuid)):n.push(V.viewer.bodyUuid2ClonedNodeMap[e.uuid])}),n)},this.getSelectedleafObjects=function(e){for(var t=[],n=0;n<k.length;n++)var i=k[n],i=this.viewer.ndsModel.getLeafBodies(i),t=t.concat(i);return t=e&&this.viewer.controls.staticDrawGeomOp&&0<(e=this.viewer.controls.staticDrawGeomOp.getAllSelectObject()).length?t.concat(e):t},this.hasTransformableObjectSelected=function(){for(var e=0,t=k.length;e<t;e++){var n=k[e].type.toLowerCase();if("assembly"==n||"component"==n||"part"==n)return!0}return!1},this.getSelectedFaceInfors=function(){for(var e=[],t=0,n=c.length;t<n;t++)e.push({bodyId:c[t].bodyId,faceId:c[t].id});return e},this.getSelectedEdgeInfors=function(){for(var e=[],t=0,n=f.length;t<n;t++)e.push({bodyId:f[t].bodyId,edgeId:f[t].id});return e},this.getSelectedVertexInfors=function(){for(var e=[],t=0,n=g.length;t<n;t++)e.push({bodyId:g[t].bodyId,vertexId:g[t].id});return e},this.getAllSelectionInfors=function(){for(var e=[],t=0,n=c.length;t<n;t++)(i={entityType:"face"}).bodyId=c[t].bodyId,i.entityId=c[t].id,e.push(i);for(t=0,n=f.length;t<n;t++)(i={entityType:"edge"}).bodyId=f[t].bodyId,i.entityId=f[t].id,e.push(i);for(t=0,n=g.length;t<n;t++)(i={entityType:"vertex"}).bodyId=g[t].bodyId,i.entityId=g[t].id,e.push(i);for(t=0,n=k.length;t<n;t++){var i,r=k[t].type.toLowerCase();"body"!=r&&"rawmesh"!=r&&"refpoint"!=r&&"refaxis"!=r&&"refplane"!=r||((i={}).entityType=k[t].type,i.bodyId=k[t].uuid,i.entityId="",e.push(i))}return e},this.getAllSelectedBrepEntities=function(){for(var e=[],t=0,n=c.length;t<n;t++)(i={entityType:"face"}).bodyId=c[t].bodyId,i.entityId=c[t].id,e.push(i);for(t=0,n=f.length;t<n;t++)(i={entityType:"edge"}).bodyId=f[t].bodyId,i.entityId=f[t].id,e.push(i);for(var i,t=0,n=g.length;t<n;t++)(i={entityType:"vertex"}).bodyId=g[t].bodyId,i.entityId=g[t].id,e.push(i);return e},this.selectBrepEntities=function(e,t){if(V.viewer.hasBrepInfo()){t&&I();for(var n=0,i=e.length;n<i;n++)if("face"==e[n].entityType){for(var r=!1,o=0;o<c.length;o++)if(e[n].bodyId==c[o].bodyId&&e[n].entityId==c[o].id){r=!0;break}r||(a=V.viewer.brepManager.GetBrepInfoByBodyUuidAndTopoId(e[n].bodyId,e[n].entityId,e[n].entityType))&&(c.push(a),a=S(a,!1))&&(x.add(a),h.push(a))}else if("edge"==e[n].entityType){for(var a,r=!1,o=0;o<f.length;o++)if(e[n].bodyId==f[o].bodyId&&e[n].entityId==f[o].id){r=!0;break}r||(a=V.viewer.brepManager.GetBrepInfoByBodyUuidAndTopoId(e[n].bodyId,e[n].entityId,e[n].entityType))&&(f.push(a),s=B(a,!1))&&(x.add(s),m.push(s))}else if("vertex"==e[n].entityType){for(var s,l,r=!1,o=0;o<g.length;o++)if(e[n].bodyId==g[o].bodyId&&e[n].entityId==g[o].id){r=!0;break}r||(s=V.viewer.brepManager.GetBrepInfoByBodyUuidAndTopoId(e[n].bodyId,e[n].entityId,e[n].entityType))&&(g.push(s),l=P(new THREE.Vector3(s.coords[0],s.coords[1],s.coords[2]),b,!1))&&(x.add(l),v.push(l))}}},this.deselectBrepEntities=function(e){for(var t=0,n=e.length;t<n;t++)if("face"==e[t].entityType){for(var i=0;i<c.length;i++)if(e[t].bodyId==c[i].bodyId&&e[t].entityId==c[i].id){c.splice(i,1),x.remove(h[i]),h[i]=null,h.splice(i,1);break}}else if("edge"==e[t].entityType){for(i=0;i<f.length;i++)if(e[t].bodyId==f[i].bodyId&&e[t].entityId==f[i].id){f.splice(i,1),x.remove(m[i]),m[i]=null,m.splice(i,1);break}}else if("vertex"==e[t].entityType)for(i=0;i<g.length;i++)if(e[t].bodyId==g[i].bodyId&&e[t].entityId==g[i].id){g.splice(i,1),x.remove(v[i]),v[i]=null,v.splice(i,1);break}},this.selectEntities=function(e,t){if(V.viewer.hasBrepInfo()){t&&I();for(var n=0,i=e.length;n<i;n++){var r=e[n].entityType.toLowerCase();if("face"==r){for(var o=!1,a=0;a<c.length;a++)if(e[n].bodyId==c[a].bodyId&&e[n].entityId==c[a].id){o=!0;break}o||(s=V.viewer.brepManager.GetBrepInfoByBodyUuidAndTopoId(e[n].bodyId,e[n].entityId,e[n].entityType))&&(c.push(s),s=S(s,!1))&&(x.add(s),h.push(s))}else if("edge"==r){for(var s,o=!1,a=0;a<f.length;a++)if(e[n].bodyId==f[a].bodyId&&e[n].entityId==f[a].id){o=!0;break}o||(s=V.viewer.brepManager.GetBrepInfoByBodyUuidAndTopoId(e[n].bodyId,e[n].entityId,e[n].entityType))&&(f.push(s),l=B(s,!1))&&(x.add(l),m.push(l))}else if("vertex"==r){for(var l,d,o=!1,a=0;a<g.length;a++)if(e[n].bodyId==g[a].bodyId&&e[n].entityId==g[a].id){o=!0;break}o||(l=V.viewer.brepManager.GetBrepInfoByBodyUuidAndTopoId(e[n].bodyId,e[n].entityId,e[n].entityType))&&(g.push(l),d=P(new THREE.Vector3(l.coords[0],l.coords[1],l.coords[2]),b,!1))&&(x.add(d),v.push(d))}else"refplane"!=r&&"refaxis"!=r||V.viewer.ndsModel&&(d=V.viewer.ndsModel.getBodyNodeFromUuid(e[n].bodyId),V.isObjectSelected(d)||(d.select(),k.push(d)))}}},this.deselectEntities=function(e){for(var t=0,n=e.length;t<n;t++){var i=e[t].entityType.toLowerCase();if("face"==i){for(var r=0;r<c.length;r++)if(e[t].bodyId==c[r].bodyId&&e[t].entityId==c[r].id){c.splice(r,1),x.remove(h[r]),h[r]=null,h.splice(r,1);break}}else if("edge"==i){for(r=0;r<f.length;r++)if(e[t].bodyId==f[r].bodyId&&e[t].entityId==f[r].id){f.splice(r,1),x.remove(m[r]),m[r]=null,m.splice(r,1);break}}else if("vertex"==i){for(r=0;r<g.length;r++)if(e[t].bodyId==g[r].bodyId&&e[t].entityId==g[r].id){g.splice(r,1),x.remove(v[r]),v[r]=null,v.splice(r,1);break}}else if(("refplane"==i||"refaxis"==i)&&V.viewer.ndsModel){var o=V.viewer.ndsModel.getBodyNodeFromUuid(e[t].bodyId);o.deSelect();for(r=0;r<k.length;r++)if(k[r].uuid==o.uuid){k.splice(r,1);break}}}},this.computeTargetList=function(e){u.length=0,o.length=0,p.length=0,H(e,u)},this.addToTargetList=function(e){H(e,u)},this.getTargetList=function(){return u},this.getTargetLineList=function(){return o},this.getTargetIncludeLineList=function(){return p},this.getLineObjectFromUUid=function(e){for(var t=0,n=o.length;t<n;t++){var i=o[t];if(i&&i.uuid==e)return i}return null},this.getSelectedComponent=function(){if(0<k.length){var e=k[0];if(this.viewer.ndsModel){for(var t=e.parent,n=t?t.parent:null,i=e;null!=t&&null!=n&&("model"!=n.type||"assembly"!=t.type);)n=(t=(i=t).parent)?t.parent:null;return i}}return null},this.findParentElement=function(e){if(null==e)return null;if(e instanceof THREE.Object3D){var t=e.type.toLowerCase();if(V.viewer.isObjectTypeOfElement(e)){if("object"==t)for(var n=e.parent;null!=n;)"instanceobject"==n.type.toLowerCase()&&(e=n),n=n.parent;return _e.selectObjectWithPropertyOnly&&!e.propertyfile?this.findParentElement(e.parent):e}}return this.findParentElement(e.parent)},this.getPickIntersects=function(e,t){var n=V.viewer,i=n.renderer.domElement,r=n.renderer.getPixelRatio(),e=e*r/i.width*2-1,t=2*-(t*r/i.height)+1,r=new THREE.Raycaster;n.camera.setCastRay(r,e,t);return n.ndsModel?n.ndsModel.intersect(r.ray):r.intersectObjects(u)},this.selectBodyByRect=function(s,l,d,c,F){var e=V.viewer,t=(e.selectionManager.clearSelection(),e.renderer.domElement),n=e.renderer.getPixelRatio(),i=(d<s&&(s=(i=[d,s])[0],d=i[1]),c<l&&(l=(i=[c,l])[0],c=i[1]),s*n/t.width*2-1),r=d*n/t.width*2-1,o=2*-(l*n/t.height)+1,n=2*-(c*n/t.height)+1,t=new THREE.Vector2(i,o),o=new THREE.Vector2(r,o),r=new THREE.Vector2(r,n),i=new THREE.Vector2(i,n),n=[],t=(this.viewer.camera.setCastPolytopes(n,t,o,r,i),new THREE.Polytope(n)),a=this.viewer.ndsModel.intersectPolytope(t);if(a&&0<a.length)if(G){if(z&&0<z.length)for(var N=!1,h=0;h<a.length;h++){p=a[h].bodyNode;for(var N=!1,u=0;u<z.length;u++)if(z[u]==p||p.isChildOfNode(z[u])){N=!0;break}N&&(a.splice(h,1),h--)}}else if(W&&Y&&0<Y.length)for(var p,f=!1,h=0;h<a.length;h++){p=a[h].bodyNode;for(f=!1,u=0;u<Y.length;u++)if(Y[u]==p||p.isChildOfNode(Y[u])){f=!0;break}f||(a.splice(h,1),h--)}if(a&&0<a.length)if(V.viewer.outlinePass&&V.viewer.outlinePass.enabled){for(var j=[],m=0;m<a.length;m++){v=a[m].bodyNode;if(_e.selectObjectWithPropertyOnly&&!v.propertyfile){A=v.parent;for(v=null;null!=A;){if(A.propertyfile){v=A;break}A=A.parent}}null!=v&&j.push(v)}this.selectObjectList(j)}else{_e.selectedMaterial.colorWrite=!0,_e.inBIMContext?V.viewer.ndsModel.meshManager.setSelectedMaterial(_e.selectedMaterial,_e.selectedLineMaterial):V.viewer.ndsModel.models.forEach(function(e){e.meshManager.setSelectedMaterial(V.viewer.is2DModel?_e.selectedFace2DMaterial:_e.selectedMaterial,_e.selectedLineMaterial)});for(var g=0;g<a.length;g++){var v=a[g].bodyNode;if(_e.selectObjectWithPropertyOnly&&!v.propertyfile){var A=v.parent;for(v=null;null!=A;){if(A.propertyfile){v=A;break}A=A.parent}}null!=v&&("part"==U&&"Body"==v.type&&(v=v.parent),k.find(function(e){return e.uuid===v.uuid})||(V.viewer.ndsModel.addSelection(v),k.push(v)))}this.selectObjectList([])}if("OpExplode"==V.viewer.controls.getOperator().type&&V.viewer.controls.getOperator().changeSelobject(),this.viewer.pmiObject&&this.viewer.pmiVisible&&(o=t.intersectsPMIObject(this.viewer.pmiObject))&&0<o.length&&o.forEach(function(e){e.parent&&!e.parent.select&&e.parent.visible&&V.viewer.ndsModel.selectPMIObject(e.parent)}),e.controls.staticDrawGeomOp&&e.controls.staticDrawGeomOp.needSelectGeom()){var y=t.intersectsPMIObject(e.controls.staticDrawGeomOp.drawScene);if(y&&0<y.length){for(var E=[],M=0;M<y.length;M++)if(e.controls.staticDrawGeomOp.isTraceMode()){if("Point"!=y[M].objectType){E.push(y[M].uuid);break}}else E.push(y[M].uuid);0<E.length?(e.controls.staticDrawGeomOp.deselectAllMesh(),e.controls.staticDrawGeomOp.selectMesh(E)):e.controls.staticDrawGeomOp.deselectAllMesh(!0)}else e.controls.staticDrawGeomOp.deselectAllMesh(!0)}function w(e,t){var n=e[0],i=n[0],n=n[1],e=e[1],r=e[0],e=e[1],o=t[0],a=o[0],o=o[1],t=t[1],s=t[0],t=t[1],l=(t-o)*(r-i)-(s-a)*(e-n),s=(s-a)*(n-o)-(t-o)*(i-a),t=(r-i)*(n-o)-(e-n)*(i-a);return 0==l?0==s&&0==t:(r=t/l,0<=(o=s/l)&&o<=1&&0<=r&&r<=1)}function b(e,t,n,i){var r,o,a;return s<e&&e<d&&l<t&&t<c||s<n&&n<d&&l<i&&i<c||(r=[[s,l],[d,l]],o=[[d,l],[d,c]],a=[[d,c],[s,c]],!!(w(e=[[e,t],[n,i]],[[s,l],[s,c]])||w(e,r)||w(e,o)||w(e,a)))}if(e.controls.staticAnnotation){for(var x=[],I=0;I<e.controls.staticAnnotation.TextContents.length;++I){var T,S,B,P,C=e.controls.staticAnnotation.TextContents[I];"hidden"!=C.style.visibility&&(T=C.newPoint||C.interPnt,"up"==(S=C.getAttribute("mobile"))||"down"==S?(B=e.controls.staticAnnotation.get2dPoint(T.clone()),P=e.controls.staticAnnotation.get2dPoint(C.pos.clone()),b(B.x,B.y,P.x,P.y)&&x.push(C.id)):("left"==S||"right"==S)&&(B=e.controls.staticAnnotation.get2dPoint(T.clone()),P=e.controls.staticAnnotation.get2dPoint(C.pos.clone()),b(B.x,B.y,Math.round((B.x+P.x)/2),P.y)||b(P.x,P.y,Math.round((B.x+P.x)/2),P.y))&&x.push(C.id))}for(var R=0;R<e.controls.staticAnnotation.PicContents.length;++R){var O,L,D,H,_=e.controls.staticAnnotation.PicContents[R];"hidden"!=_.style.visibility&&(O=(H=_.getBoundingClientRect()).left-V.viewer.container.getBoundingClientRect().left,L=H.top-V.viewer.container.getBoundingClientRect().top,D=O+H.width,H=L+H.height,s<O&&O<d&&l<L&&L<c||s<D&&D<d&&l<H&&H<c||s<D&&D<d&&l<L&&L<c||s<O&&O<d&&l<H&&H<c)&&x.push(_.id)}e.controls.staticAnnotation.setSelectIdArray(x)}V.viewer.dispatchAsyncEvent({type:"selectObjectEvent"})},this.selectByClick=function(e,t,n){if("component"==U){var i=e,r=t,o=n,a=V.viewer,s=O(i,r,!1);if(s&&0<s.length){var l=null;if(a.ndsModel){var d=(l=s[0].bodyNode).parent,c=d?d.parent:null;for(l=null;null!=d&&null!=c&&("model"!=c.type||"assembly"!=d.type);)c=(d=(l=d).parent)?d.parent:null}null!=l&&(null!=o&&1==o?V.isObjectSelected(l)?(V.deselectObject(l),a.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:i,clickPosY:r}),a.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:[{entityType:"component",bodyId:l.uuid,entityId:""}]})):(V.selectObject(l),a.dispatchAsyncEvent({type:"selectObjectEvent",clickPosX:i,clickPosY:r}),a.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"component",bodyId:l.uuid,entityId:""}],removed:[]})):V.isObjectSelected(l)?(V.clearSelection(),a.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:i,clickPosY:r})):(V.clearSelection(),V.selectObject(l),a.dispatchAsyncEvent({type:"selectObjectEvent",clickPosX:i,clickPosY:r}),a.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"component",bodyId:l.uuid,entityId:""}],removed:[]})))}else null!=o&&0!=o||(s=!1,0<k.length&&(s=!0),V.clearSelection(),s&&a.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:i,clickPosY:r}));V.viewer.groundShadowChange()}else if("body"==U){o=e,s=t,a=n,i=V.viewer,r=O(o,s,!1);if(i.controls.staticDrawGeomOp&&i.controls.staticDrawGeomOp.needSelectGeom()&&i.controls.staticDrawGeomOp.isTraceMode()&&(a=!0),r&&0<r.length){var h=null;if(i.ndsModel){if(h=r[0].bodyNode,_e.selectObjectWithPropertyOnly&&!h.propertyfile){var u=h.parent;for(h=null;null!=u;){if(u.propertyfile){h=u;break}u=u.parent}}}else null==(h=V.findParentElement(r[0].object))&&(h=r[0].object);null!=h&&(V.viewer.dispatchEvent({type:"selectObjectMaterialInfoByUUid",uuid:h.uuid}),null!=a&&1==a?V.isObjectSelected(h)?(V.deselectObject(h),i.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:o,clickPosY:s}),i.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:[{entityType:"body",bodyId:h.uuid,entityId:""}]})):(V.selectObject(h),i.dispatchAsyncEvent({type:"selectObjectEvent",clickPosX:o,clickPosY:s}),i.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"body",bodyId:h.uuid,entityId:""}],removed:[]})):(V.isObjectSelected(h)?(V.clearSelection(),i.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:o,clickPosY:s})):(V.clearSelection(),V.selectObject(h),i.dispatchAsyncEvent({type:"selectObjectEvent",clickPosX:o,clickPosY:s}),i.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"body",bodyId:h.uuid,entityId:""}],removed:[]})),i.pmiObject&&i.ndsModel.deselectPMIObject(i.pmiObject),i.controls.staticDrawGeomOp&&i.controls.staticDrawGeomOp.needSelectGeom()&&i.controls.staticDrawGeomOp.deselectAllMesh(!0)))}else null!=a&&0!=a||(r=!1,0<k.length&&(r=!0),V.clearSelection(),r&&i.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:o,clickPosY:s})),F(o,s,a);V.viewer.groundShadowChange()}else"part"==U?(p=e,f=t,m=n,g=V.viewer,(v=O(p,f,!1))&&0<v.length?null!=(v=(v=v[0].bodyNode).parent)&&(null!=m&&1==m?V.isObjectSelected(v)?(V.deselectObject(v),g.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:p,clickPosY:f}),g.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[],removed:[{entityType:"component",bodyId:v.uuid,entityId:""}]})):(V.selectObject(v),g.dispatchAsyncEvent({type:"selectObjectEvent",clickPosX:p,clickPosY:f}),g.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"component",bodyId:v.uuid,entityId:""}],removed:[]})):(V.isObjectSelected(v)?(V.clearSelection(),g.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:p,clickPosY:f})):(V.clearSelection(),V.selectObject(v),g.dispatchAsyncEvent({type:"selectObjectEvent",clickPosX:p,clickPosY:f}),g.dispatchAsyncEvent({type:"SelectionChangeEvent",added:[{entityType:"component",bodyId:v.uuid,entityId:""}],removed:[]})),g.pmiObject&&g.ndsModel.deselectPMIObject(g.pmiObject),g.controls.staticDrawGeomOp&&g.controls.staticDrawGeomOp.needSelectGeom()&&g.controls.staticDrawGeomOp.deselectAllMesh(!0))):(null!=m&&0!=m||(v=!1,0<k.length&&(v=!0),V.clearSelection(),v&&g.dispatchAsyncEvent({type:"deselectObjectEvent",clickPosX:p,clickPosY:f})),F(p,f,m)),V.viewer.groundShadowChange()):"face"==U?Q(e,t,!1,n,!1):"edge"==U?Z(e,t,!1,n):"vertex"==U?J(e,t,!1,n):"plane"==U?Q(e,t,!1,n,!0):"axis"==U?ee(e,t,!1,n):"line"==U?te(e,t,!1,n):"line_plane"==U?ne(e,t,!1,n):"vertex_edge_face"==U&&$(e,t,!1,n);var p,f,m,g,v},this.selectOnMouseMove=function(e,t){"vertex"==U?J(e,t,!0):"edge"==U?Z(e,t,!0):"face"==U?Q(e,t,!0,void 0,!1):"plane"==U?Q(e,t,!0,void 0,!0):"axis"==U?ee(e,t,!0):"line"==U?te(e,t,!0):"line_plane"==U?ne(e,t,!0):"vertex_edge_face"==U&&$(e,t,!0)},this.renderSelectionScene=function(e,t){if(0<x.children.length){for(var n=0;n<x.children.length;n++){var i=x.children[n];null!=i.objectType&&"Point"===i.objectType&&j(i,b)}e?this.viewer.renderer.render(L,this.viewer.camera,e,t):this.viewer.renderer.render(L,this.viewer.camera)}},this.selectObjectByUuid=function(e,t){e=function e(t,n,i){var r=null;var o=n.children;if(null==o)return r;for(var a=0,s=o.length;a<s;++a){var l=o[a];if(l.uuid==t){if(!i){r=l;break}var d=ie(l);if(d&&i==d.uuid){r=l;break}}else if(null!=(r=e(t,l,i)))break}return r}(e,V.scene,t);null!=e&&(V.clearSelection(),V.selectObject(e))},this.EXPORT_SelectGeom=function(e){var t,n,i,r,o=null,a=V.viewer;return o=a.controls.staticDrawGeomOp&&a.controls.staticDrawGeomOp.needSelectGeom()&&(r=a.renderer.domElement,n=a.renderer.getPixelRatio(),t=e.x*n/r.width*2-1,e=2*-(e.y*n/r.height)+1,(n=new THREE.Raycaster).linePrecision=1,r=a.clientCoordToModelCoord([0,0]),r=new THREE.Vector3(r[0],r[1],r[2]),i=a.clientCoordToModelCoord([4,0]),i=new THREE.Vector3(i[0],i[1],i[2]),n.linePrecision=.65*r.distanceTo(i),a.camera.setCastRay(n,t,e),r=n.intersectObjects(a.controls.staticDrawGeomOp.drawScene.children,!0)[0],a.controls.staticDrawGeomOp.isTraceMode()?r&&"Point"!=r.object.objectType:!!r)?r.object.uuid:o},this.EXPORT_SelectGeomPolytope=function(e){var t=[],n=V.viewer;if(n.controls.staticDrawGeomOp&&n.controls.staticDrawGeomOp.needSelectGeom()){var i=n.renderer.domElement,r=n.renderer.getPixelRatio(),o=e[0].x*r/i.width*2-1,a=2*-(e[0].y*r/i.height)+1,s=e[1].x*r/i.width*2-1,l=2*-(e[1].y*r/i.height)+1,d=e[2].x*r/i.width*2-1,c=2*-(e[2].y*r/i.height)+1,h=e[3].x*r/i.width*2-1,e=2*-(e[3].y*r/i.height)+1,r=new THREE.Vector2(o,a),i=new THREE.Vector2(s,l),o=new THREE.Vector2(d,c),a=new THREE.Vector2(h,e),s=[];this.viewer.camera.setCastPolytopes(s,r,i,o,a);var u=new THREE.Polytope(s).intersectsPMIObject(n.controls.staticDrawGeomOp.drawScene);if(u&&0<u.length)for(var p=0;p<u.length;p++)if(n.controls.staticDrawGeomOp.isTraceMode()){if("Point"!=u[p].objectType){t.push(u[p].uuid);break}}else t.push(u[p].uuid)}return t},this.EXPORT_SelectObject=function(e){var e=O(e.x,e.y,!1),t=null;return t=e&&0<e.length&&e[0].bodyNode?e[0].bodyNode.uuid:t},this.EXPORT_SelectBodyPolytope=function(e){var t=V.viewer,n=t.renderer.domElement,t=t.renderer.getPixelRatio(),i=e[0].x*t/n.width*2-1,r=2*-(e[0].y*t/n.height)+1,o=e[1].x*t/n.width*2-1,a=2*-(e[1].y*t/n.height)+1,s=e[2].x*t/n.width*2-1,l=2*-(e[2].y*t/n.height)+1,d=e[3].x*t/n.width*2-1,e=2*-(e[3].y*t/n.height)+1,t=new THREE.Vector2(i,r),n=new THREE.Vector2(o,a),i=new THREE.Vector2(s,l),r=new THREE.Vector2(d,e),o=[],a=(this.viewer.camera.setCastPolytopes(o,t,n,i,r),new THREE.Polytope(o)),c=[],h=this.viewer.ndsModel.intersectPolytope(a);if(h&&0<h.length)for(var u=0;u<h.length;u++)null!=h[u].bodyNode&&c.push(h[u].bodyNode.uuid);return c}}return e.prototype.getSelectedBodyVolumeAndArea=function(){function s(e,t){for(var n=0,i=e.length;n<i;n++){var r=e[n].type.toLowerCase();if(!e[n].unload)if("body"==r){if(e[n]._leafBodyAttri&&0!=e[n]._leafBodyAttri._bodyMeshIds.length){for(var o=!1,a=0;a<l.selectedObjects.length;++a)if(e[n].uuid==l.selectedObjects[a].uuid){o=!0;break}o&&l.selectedObjects!=e||(r=l.viewer.brepManager.GetBodyVolumeAndArea(e[n].uuid))&&(t.volume+=r.volume,t.area+=r.area)}}else{for(o=!1,a=0;a<l.selectedObjects.length;++a)if(e[n].uuid==l.selectedObjects[a].uuid){o=!0;break}(!o||l.selectedObjects==e)&&0<e[n].children.length&&s(e[n].children,t)}}}var e,t,l=this;return this.viewer.hasBrepInfo()&&0<this.selectedObjects.length&&(s(this.selectedObjects,e={volume:0,area:0}),1e-7<e.area)?(t=this.viewer.getDispalyModelUnit(e.volume,e.area),e.volume=e.volume*t.scale*t.scale*t.scale,e.area=e.area*t.scale*t.scale,[e,t.unit]):null},e}();Un.prototype=Object.create(THREE.EventDispatcher.prototype);function gi(e,t){var n,i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){{var n;if(e)return"string"==typeof e?vi(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?vi(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length)return i&&(e=i),n=0,function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}(Ee.prototype=Object.create(g.prototype)).getUUid=function(){var e=new Date;return"cms"+e.getDay()+e.getHours()+e.getMinutes()+e.getSeconds()+e.getMilliseconds()+Math.round(1e4*Math.random())},Ee.prototype.PostInfo=function(e){var t;e&&((t=this).Popup&&(clearTimeout(this.Popup),this.Popup=null),this.prompt.innerHTML=e,this.prompt.style.display="block",Se.isMobileDevice())&&(e=this.viewer.renderer.getSize().height/2-21+"px",this.prompt.style.top=e,this.prompt.style.color="rgba(27,27,27,1)",this.Popup=setTimeout(function(){t.prompt.style.display="none"},2e3))},Ee.prototype.clearMsgInfo=function(){this._clearMsgInfo=!0},Ee.prototype.SetEnableMove=function(e){(this.enableMove=e)||("NoteMove"==this.mode&&(this.mode="normal"),this._isDragging=!1,this._isResizing=!1)},Ee.prototype.createElement=function(e,t){var t=t.slice(0,t.lastIndexOf(".")),d=document.createElement("div"),c=this;function h(e){var t,n;c._isDragging=!1,c._isResizing=!1,c._currentTarget=null,c.state==ve.MOUSE.MIDDLE?(t=e.clientX-c.viewer.container.getBoundingClientRect().left,n=e.clientY-c.viewer.container.getBoundingClientRect().top,c.MouseUp.set(t,n),c.onMMouseUp(e)):c.state==ve.MOUSE.LEFT&&c.onLMouseUp(),document.removeEventListener("mouseup",h)}var n=new Image,i=(n.style.display="none",d.appendChild(n),d.style.position="absolute",d.style.zIndex=20,d.style.border="2px solid rgba(255, 195, 0, 0.0)",this.getUUid()),r=(d.id=i,d.filename=t,n.addEventListener("mousedown",function(e){if(e.ctrlKey)0!=c.picSelectID||0!=c.selectID?(t=[],n=0!=c.picSelectID?c.picSelectID:c.selectID,c.picSelectID!=e.target.parentNode.id&&(t=[n,e.target.parentNode.id]),c.setSelectIdArray(t)):(-1!==(n=c.selectIDs.indexOf(e.target.parentNode.id))?c.selectIDs.splice(n,1):c.selectIDs.push(e.target.parentNode.id),c.setSelectIdArray(c.selectIDs));else{c.setSelectIdArray([]);var t=d.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top,r=n<=15&&i<=15,o=n>=t.width-15&&i<=15,a=n<=15&&i>=t.height-15,n=n>=t.width-15&&i>=t.height-15;if((r||o||a||n)&&c.enableMove)c._isResizing=!0,c.onLMouseDown(e),c.startWidth=e.target.parentNode.children[0].offsetWidth,c.startHeight=e.target.parentNode.children[0].offsetHeight,c.stratLeft=parseInt(e.target.parentNode.style.left),c.startTop=parseInt(e.target.parentNode.style.top),c.startX=e.clientX,c.startY=e.clientY,c._currentTarget=e.target,r&&(c.cornerStyle=0),o&&(c.cornerStyle=1),a&&(c.cornerStyle=2),n&&(c.cornerStyle=3),r||n?d.style.cursor="nwse-resize":(o||a)&&(d.style.cursor="nesw-resize");else{c.enableMove&&(c._isDragging=!0);for(var s=0;s<c.PicContents.length;s++)c.PicContents[s].style.zIndex=19;e.target.parentNode.style.zIndex=21,c.onLMouseDown(e),c._currentTarget=e.target,c.startX=e.clientX-e.target.parentNode.offsetLeft,c.startY=e.clientY-e.target.parentNode.offsetTop,d.style.cursor="default"}for(var l=0;l<c.PicContents.length;l++)c.PicContents[l].style.border="2px solid rgba(255, 195, 0, 0.0)";i={id:e.target.parentNode.id,filename:e.target.parentNode.filename,configNum:c.viewer.ConfigNum,configName:c.viewer.ConfigName,type:"Pic",name:e.target.parentNode.animationName};c.viewer.dispatchEvent({type:"PicSelect",data:[i]}),e.target.parentNode.style.border="2px solid rgba(255, 195, 0, 1.0)",c.picSelectID=e.target.parentNode.id}d.readOnly=!1,d.focus(),d.blur(),c.viewer.dispatchEvent({type:"exitNote"}),c.clearFlag(),c.setMode("Picture"),document.addEventListener("mouseup",h)}),n.addEventListener("mousemove",function(e){var t,n,i,r;c._isResizing&&c.state==ve.MOUSE.LEFT?c.reSize(e):c._isDragging&&c.state==ve.MOUSE.LEFT?(r=Math.round(e.clientX-c.startX),t=Math.round(e.clientY-c.startY),c._currentTarget.parentNode.style.left=r+"px",c._currentTarget.parentNode.style.top=t+"px"):c.state==ve.MOUSE.LEFT?(r=e.clientX-c.viewer.container.getBoundingClientRect().left,t=e.clientY-c.viewer.container.getBoundingClientRect().top,c.pointer.set(r,t),c.onLMouseMove(e),c.pointerOld.set(r,t)):c.state==ve.MOUSE.MIDDLE?c.onMMouseMove(e):(r=d.getBoundingClientRect(),t=e.clientX-r.left,e=e.clientY-r.top,n=t>=r.width-15&&e<=15,i=t<=15&&e>=r.height-15,r=t>=r.width-15&&e>=r.height-15,d.style.cursor=t<=15&&e<=15||r?"nwse-resize":n||i?"nesw-resize":"default"),c.viewer.render()}),n.addEventListener("click",function(){for(var e=0;e<c.TextContents.length;e++){var t=c.TextContents[e];t.childNodes[0].blur(),"NoteEdit"!=c.mode&&(t.childNodes[0].style.cursor="default",t.childNodes[0].style.userSelect="none",t.childNodes[0].readOnly=!0)}}),n.addEventListener("dragstart",function(e){e.preventDefault()}),d.addEventListener("mousemove",function(e){c._isDragging}),{id:i,configNum:c.viewer.ConfigNum,configName:c.viewer.ConfigName,name:t,type:"Pic"});this.viewer.container.appendChild(d),this.PicContents.push(d),n.src=e,n.onload=function(){n.height>n.width?(n.style.height="160px",n.style.width=160*n.width/n.height+"px"):(n.style.height=160*n.height/n.width+"px",n.style.width="160px"),d.aspect=n.width/n.height,n.style.display="block",d.style.top="19px",d.style.left="56px","OpAnnotationNew"==c.viewer.getCurrentOperatorID()&&(c.viewer.dispatchEvent({type:"PicAdd",data:r}),c.viewer.dispatchEvent({type:"PicSelect",data:[]}))},n.onerror=function(){c.deleteNoteAnnotation(i)};for(var o=0;o<c.PicContents.length;o++){var a=c.PicContents[o];a.style.border="2px solid rgba(255, 195, 0, 0.0)",a.style.zIndex=19}c.setSelectId(0),c.picSelectID=0},Ee.prototype.createDiv=function(){var e=this,t=document.createElement("div"),n=document.createElement("textarea"),o=this;function i(e){for(var t=e.value.split("\n"),n=0,i=0;i<t.length;i++){for(var r=t[i],o=0,a=0;a<r.length;a++)o+=8230<=r[a].charAt(0).charCodeAt(0)?2:1;n<o&&(n=o)}var s="en"==Se.getLanguage()||Se.isMobileDevice()?10:8;e.style.width=Math.round(n*s)+"px",Math.round(n*s)<44&&(e.style.width="44px"),Se.isMobileDevice()&&160<Math.round(n*s)&&(e.style.width="160px")}Se.isMobileDevice()&&(n.rows="1"),n.style.height="20px",n.style.width="auto",n.style.overflow="hidden",n.style.fontSize="14px",n.style.lineHeight="20px",n.style.cursor="default",n.style.userSelect="none",n.style.border="1px solid #FF0000",n.style.backgroundColor="hsla(0,0%,100%,.5)",n.setAttribute("autocomplete","off"),n.addEventListener("touchmove",function(e){var t,n,i,r={x:e.touches[0].clientX,y:e.touches[0].clientY};Math.abs(o.startX-e.clientX)<3&&Math.abs(o.startY-e.clientY)<3||("NoteEdit"!=o.mode&&(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),e.target.selectionStart=e.target.selectionEnd=0,e.target.readOnly=!0),"NoteMove"==o.mode&&(e.target.readOnly=!0,e=new THREE.Plane,n=o.viewer.camera.getCameraTarget(),i=o.viewer.camera.position,(t=new THREE.Vector3).subVectors(n,i),n=r,e.setFromNormalAndCoplanarPoint(t.normalize(),o.MoveTarget.interPnt),i=o.clientCoordToModelCoordOnPlane(n.x,n.y,e),o.MoveTarget.pos=i,o.changeAnnotation(o.MoveTarget.interPnt,o.MoveTarget.pos,o.MoveTarget)),o.update2DScene(),o.viewer.render())}),n.addEventListener("touchstart",function(e){o.startX=e.clientX,o.startY=e.clientY,"NotePlace"==o.mode?o.onTouchSingle(e):(o.onLMouseDown(e),o.selectID!=e.target.parentNode.id&&-1==o.selectIDs.indexOf(e.target.parentNode.id)||"NoteEdit"==o.mode||!o.enableMove||(o.oldmode=o.mode,o.mode="NoteMove",o.MoveTarget=e.target.parentNode),e.target.readOnly=!0,e.target.blur())}),n.addEventListener("touchend",function(e){var t,n;"NoteMove"==o.mode&&(o.MoveTarget=null,o.mode=o.oldmode,"NoteMove"==o.mode&&(o.mode="normal"),e.target.readOnly=!1,n={id:(t=e.target.parentNode).id,uuid:t.id,configNum:o.viewer.ConfigNum,configName:o.viewer.ConfigName,interPnt:t.interPnt,projPt:t.pos,text:t.childNodes[0].value,bodyUuid:t.bodyUuid,origiType:"lineNote",name:t.animationName},!t.PointMeasure)&&t.hasAdd&&o.viewer.dispatchEvent({type:"NoteChange",data:{tagId:n.id,text:n.text,state:n,modelName:n.configName},editNote:function(e){e?t.oldText=t.childNodes[0].value:(t.childNodes[0].value=t.oldText,i(t.childNodes[0]),Se.isMobileDevice()&&(t.childNodes[0].style.height="auto",t.childNodes[0].style.height=t.childNodes[0].scrollHeight+"px"))}}),o.onLMouseUp(e)}),n.addEventListener("input",function(e){i(e.target);var t=e.target.value.split("\n").length;Se.isMobileDevice()?(e.target.style.height="auto",e.target.style.height=e.target.scrollHeight+"px"):e.target.style.height=22*t+"px",o.update2DScene(),o.viewer.render()}),n.addEventListener("keydown",function(e){e.stopPropagation(),e.stopImmediatePropagation();var t;e.altKey&&"Enter"===e.key?(e.target.selectionStart==e.target.selectionEnd?(t=e.target.selectionStart,e.target.value=e.target.value.slice(0,t)+"\n"+e.target.value.slice(t),e.target.selectionStart=e.target.selectionEnd=t+1):e.target.value+="\n",i(e.target),Se.isMobileDevice()?(e.target.style.height="auto",e.target.style.height=e.target.scrollHeight+"px"):(t=e.target.value.split("\n").length,e.target.style.height=22*t+"px"),o.update2DScene()):"Enter"===e.key?e.target.blur():"Delete"===e.key&&"NoteEdit"!=o.mode&&o.enableMove&&o.onKeyDown(e)}),n.addEventListener("click",function(e){var t={clientX:e.clientX,clientY:e.clientY};if(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),!(3<Math.abs(o.startX-e.clientX)||3<Math.abs(o.startY-e.clientY))){for(var n,i=0;i<o.PicContents.length;i++)o.PicContents[i].style.border="2px solid rgba(255, 195, 0, 0.0)";0==o.picSelectID||e.ctrlKey||(o.picSelectID=0,o.viewer.dispatchEvent({type:"PicSelect",data:[]})),"NotePlace"==o.mode?(o.onLMouseClick(t),e.target.blur()):"NoteEdit"!=o.mode&&(e.target.parentNode.hasAdd?e.ctrlKey?0!=o.selectID||0!=o.picSelectID?(t=[],n=0!=o.picSelectID?o.picSelectID:o.selectID,o.picSelectID!=e.target.parentNode.id&&(t=[n,e.target.parentNode.id]),o.setSelectIdArray(t)):(-1!==(n=o.selectIDs.indexOf(e.target.parentNode.id))?o.selectIDs.splice(n,1):o.selectIDs.push(e.target.parentNode.id),o.setSelectIdArray(o.selectIDs)):(e.target.parentNode.id&&o.setSelectId(e.target.parentNode.id),e.target.style.border="1px solid #FFC300",e.target.readOnly=!0,e.target.blur(),e.target.style.userSelect="none",e.target.style.cursor="move"):(e.target.readOnly=!1,e.target.focus())),o.update2DScene()}}),n.addEventListener("dblclick",function(e){e.target.readOnly=!1,e.target.focus(),o.selectID!=e.target.parentNode.id&&(e.target.parentNode.id,o.setSelectId(e.target.parentNode.id),e.target.style.border="1px solid #FFC300"),e.target.selectionStart=e.target.selectionEnd=e.target.value.length,e.target.style.userSelect="auto",e.target.style.cursor="default",e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),o.setMode("NoteEdit"),o.viewer.CADViewer&&o._addEditDel()}),n.addEventListener("mousemove",function(e){var t={clientX:e.clientX,clientY:e.clientY};Math.abs(o.startX-e.clientX)<3&&Math.abs(o.startY-e.clientY)<3||("NoteEdit"!=o.mode&&(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),e.target.selectionStart=e.target.selectionEnd=0,e.target.readOnly=!0),"NotePlace"==o.mode?o.onNMouseMove(t):"NoteMove"==o.mode&&o.onLMouseMove(t),o.update2DScene())}),n.addEventListener("mouseover",function(e){!o.Textbox||"单击确定位置"!=o.Textbox.childNodes[0].value&&"Click to choose the location for the comment."!=o.Textbox.childNodes[0].value||(o.Textbox.style.visibility="hidden")}),n.addEventListener("mousedown",function(e){var t={clientX:e.clientX,clientY:e.clientY};o.startX=e.clientX,o.startY=e.clientY,"NotePlace"==o.mode?o.onLMouseClick(t):(o.onLMouseDown(e),o.selectID!=e.target.parentNode.id&&-1==o.selectIDs.indexOf(e.target.parentNode.id)||"NoteEdit"==o.mode||!o.enableMove||(o.oldmode=o.mode,o.mode="NoteMove",o.MoveTarget=e.target.parentNode),e.target.readOnly=!0,e.target.blur())}),n.addEventListener("mouseup",function(e){var t,n;"NoteMove"==o.mode&&(o.MoveTarget=null,o.mode=o.oldmode,"NoteMove"==o.mode&&(o.mode="normal"),e.target.readOnly=!1,n={id:(t=e.target.parentNode).id,uuid:t.id,configNum:o.viewer.ConfigNum,configName:o.viewer.ConfigName,interPnt:t.interPnt,projPt:t.pos,text:t.childNodes[0].value,bodyUuid:t.bodyUuid,origiType:"lineNote",name:t.animationName},!t.PointMeasure)&&t.hasAdd&&o.viewer.dispatchEvent({type:"NoteChange",data:{tagId:n.id,text:n.text,state:n,modelName:n.configName},editNote:function(e){e?t.oldText=t.childNodes[0].value:(t.childNodes[0].value=t.oldText,i(t.childNodes[0]),Se.isMobileDevice()&&(t.childNodes[0].style.height="auto",t.childNodes[0].style.height=t.childNodes[0].scrollHeight+"px"))}}),o.onLMouseUp(e)}),n.addEventListener("mouseleave",function(e){document.addEventListener("mouseup",o.onMouseUp,!1)}),n.addEventListener("mouseenter",function(e){document.removeEventListener("mouseup",o.onMouseUp,!1)}),n.addEventListener("blur",function(e){var t=e.target.parentNode;t.hasAdd||(e={tagId:(e={id:t.id,uuid:t.id,configNum:o.viewer.ConfigNum,configName:o.viewer.ConfigName,interPnt:t.interPnt,projPt:t.pos,text:t.childNodes[0].value,bodyUuid:t.bodyUuid,origiType:"lineNote",name:t.animationName}).id,text:e.text,state:e,modelName:e.configName},t.hasAdd=!0,o.setSelectId(0),"OpAnnotationNew"==o.viewer.getCurrentOperatorID()&&o.viewer.dispatchEvent({type:"NoteAdd",data:e,addNote:function(e){e?t.oldText=t.childNodes[0].value:o.deleteNoteAnnotation(t.id,!1)}})),"OpAnnotationNew"==o.viewer.getCurrentOperatorID()&&"NotePlace"!=o.mode?o.createText():"NoteEdit"==o.mode&&o.setMode("normal")}),n.addEventListener("change",function(e){var t=e.target.parentNode,e={id:t.id,uuid:t.id,configNum:o.viewer.ConfigNum,configName:o.viewer.ConfigName,interPnt:t.interPnt,projPt:t.pos,text:t.childNodes[0].value,bodyUuid:t.bodyUuid,origiType:"lineNote",name:t.animationName};!t.PointMeasure&&t.hasAdd&&o.viewer.dispatchEvent({type:"NoteChange",data:{tagId:e.id,text:e.text,state:e,modelName:e.configName},editNote:function(e){e?t.oldText=t.childNodes[0].value:(t.childNodes[0].value=t.oldText,i(t.childNodes[0]),Se.isMobileDevice()&&(t.childNodes[0].style.height="auto",t.childNodes[0].style.height=t.childNodes[0].scrollHeight+"px"))}})});var r,a="en"==Se.getLanguage();return Se.isMobileDevice()?(t.style.visibility="hidden",r=Se.translateString("ANNOTATION_location"),setTimeout(function(){o._clearMsgInfo||"normal"!=e.mode&&o.PostInfo(r)},50)):(n.value=Se.translateString("ANNOTATION_location"),n.style.width=a?45*8.2+"px":"132px"),n.style.textAlign="left",t.style.position="fixed",t.style.zIndex=Se.isMobileDevice()?2:7,t.Inflection=!0,t.appendChild(n),t},Ee.prototype.createDivPic=function(e,t,n){var a=document.createElement("div"),d=document.createElement("img"),c=this;return d.setAttribute("src",e),d.onload=function(){d.height>d.width?(d.style.height=t+"px",d.style.width=t*d.width/d.height+"px"):(d.style.height=t*d.height/d.width+"px",d.style.width=t+"px"),a.aspect=d.width/d.height,c.setPicTextVisible(n,!0)},d.addEventListener("mousemove",function(e){var t,n,i,r,o={clientX:e.clientX,clientY:e.clientY};c._isResizing&&c.state==ve.MOUSE.LEFT?(c.reSize(e),c.viewer.render()):(c._isDragging&&c.state==ve.MOUSE.LEFT?c.onLMouseMove(o):c.state==ve.MOUSE.LEFT?(o=e.clientX-c.viewer.container.getBoundingClientRect().left,r=e.clientY-c.viewer.container.getBoundingClientRect().top,c.pointer.set(o,r),g.prototype.onLMouseMove.call(c,e),c.pointerOld.set(o,r)):c.state==ve.MOUSE.MIDDLE?c.onMMouseMove(e):(o=a.getBoundingClientRect(),r=e.clientX-o.left,t=e.clientY-o.top,n=r>=o.width-20&&t<=20,i=r<=20&&t>=o.height-20,o=r>=o.width-20&&t>=o.height-20,a.style.cursor!=(r=r<=20&&t<=20||o?"nwse-resize":n||i?"nesw-resize":"default")&&(a.style.cursor=r,d.style.cursor=a.style.cursor)),Math.abs(c.startX-e.clientX)<3&&Math.abs(c.startY-e.clientY)<3||(c.update2DScene(),c.viewer.render()))}),d.addEventListener("mousewheel",function(e){c.onMouseWheel(e),c.viewer.render()}),d.addEventListener("mousedown",function(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),c.startX=e.clientX,c.startY=e.clientY,c.onLMouseDown(e),c.selectID!=e.target.parentNode.id&&-1==c.selectIDs.indexOf(e.target.parentNode.id)||"NoteEdit"==c.mode||!c.enableMove||(c.oldmode=c.mode,c.mode="NoteMove",c.MoveTarget=e.target.parentNode);var t,n=e.target.parentNode,i=e.target.parentNode.getBoundingClientRect(),r=Math.abs(e.clientX-i.left),o=Math.abs(e.clientY-i.top),a=r<=20&&o<=20,s=r>=i.width-20&&o<=20,l=r<=20&&o>=i.height-20,r=r>=i.width-20&&o>=i.height-20;(a||s||l||r)&&c.enableMove?(c._isResizing=!0,c.onLMouseDown(e),c.startWidth=e.target.parentNode.children[0].offsetWidth,c.startHeight=e.target.parentNode.children[0].offsetHeight,c.stratLeft=parseInt(e.target.parentNode.style.left),c.startTop=parseInt(e.target.parentNode.style.top),c.startX=e.clientX,c.startY=e.clientY,c._currentTarget=e.target,a&&(c.cornerStyle=0),s&&(c.cornerStyle=1),l&&(c.cornerStyle=2),r&&(c.cornerStyle=3),a||r?t="nwse-resize":(s||l)&&(t="nesw-resize"),c.setMode("picNote")):(c._isDragging=!0,e.target.parentNode.style.zIndex=21,c._currentTarget=e.target,c.startX=e.clientX-e.target.parentNode.offsetLeft,c.startY=e.clientY-e.target.parentNode.offsetTop,t="default"),n.style.cursor!=t&&(n.style.cursor=t,d.style.cursor=n.style.cursor),n.readOnly=!1,n.focus(),n.blur()}),d.addEventListener("mouseup",function(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),"NoteMove"==c.mode&&(c.mode=c.oldmode,"NoteMove"==c.mode&&(c.mode="normal"),e.target.readOnly=!1),c.onLMouseUp(e)}),d.addEventListener("click",function(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();for(var t,n,i=0;i<c.PicContents.length;i++)c.PicContents[i].style.border="2px solid rgba(255, 195, 0, 0.0)";0==c.picSelectID||e.ctrlKey||(c.picSelectID=0,c.viewer.dispatchEvent({type:"PicSelect",data:[]})),e.ctrlKey?0!=c.selectID||0!=c.picSelectID?(t=[],n=0!=c.picSelectID?c.picSelectID:c.selectID,c.picSelectID!=e.target.parentNode.id&&(t=[n,e.target.parentNode.id]),c.setSelectIdArray(t)):(-1!==(n=c.selectIDs.indexOf(e.target.parentNode.id))?c.selectIDs.splice(n,1):c.selectIDs.push(e.target.parentNode.id),c.setSelectIdArray(c.selectIDs)):(e.target.parentNode.id&&c.setSelectId(e.target.parentNode.id),e.target.style.border="1px solid #FFC300"),c.update2DScene()}),d.addEventListener("mouseleave",function(e){document.addEventListener("mouseup",c.onMouseUp,!1)}),d.addEventListener("mouseenter",function(e){document.removeEventListener("mouseup",c.onMouseUp,!1)}),d.addEventListener("keydown",function(e){e.stopPropagation(),e.stopImmediatePropagation(),"Delete"===e.key&&c.enableMove&&c.onKeyDown(e)}),a.tabIndex=this._tabIndex++,a.style.position="fixed",a.style.zIndex=Se.isMobileDevice()?2:7,a.appendChild(d),a},Ee.prototype.dispatchNoteChange=function(e){var t={id:e.id,interPnt:e.interPnt,projPt:e.pos,text:e.childNodes[0].value,bodyUuid:e.bodyUuid,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,type:"Note"};e.hasAdd&&!e.PointMeasure&&this.viewer.dispatchEvent({type:"NoteChange",data:t}),this.Textbox?"单击确定位置"==this.Textbox.childNodes[0].value||"Click to choose the location for the comment."==this.Textbox.childNodes[0].value?this.setMode("Note"):this.setMode("NotePlace"):this.setMode("normal"),_e.enableBroadcast&&_e.broadcastMajor&&this.viewer.dispatchEvent({type:"broadcastEvent"})},Ee.prototype.createText=function(){var e;this.setMode("Note"),this.Textbox||(this._clearMsgInfo=!1,e=this.createDiv(),this.viewer.container.appendChild(e),this.Textbox=e,this.Textbox.isPic=!1,this.Textbox.style.left=this.pointer.x+8+"px",this.Textbox.style.top=this.pointer.y+20+"px")},Ee.prototype.createPicNote=function(e,t,n,i,r,o){void 0===t&&(t=null),void 0===n&&(n=null),void 0===i&&(i=""),void 0===r&&(r=!1),void 0===o&&(o=160);var a=null,s=this.getUUid();if(n)this.setMode("picNote"),(a=this.createDivPic(n,o,s)).isPic=!0;else{this.setMode("normal"),(a=this.createDiv()).isPic=!1,a.childNodes[0].value=i;for(var l=a.childNodes[0].value.split("\n"),d=0,c=0;c<l.length;c++){for(var h=l[c],u=0,p=0;p<h.length;p++)u+=8230<=h[p].charAt(0).charCodeAt(0)?2:1;d<u&&(d=u)}o="en"==Se.getLanguage()?9:8,o=(a.childNodes[0].style.width=Math.round(d*o)+"px",Math.round(d*o)<44&&(a.childNodes[0].style.width="44px"),l.length);a.childNodes[0].style.height=22*o+"px",a.hasAdd=!0,a.NoEdit=!0,a.childNodes[0].style.backgroundColor="#FFFFFF",a.childNodes[0].style.fontSize="16px",a.childNodes[0].style.lineHeight="22px",a.childNodes[0].style.textAlign="left",a.childNodes[0].style.border="1px solid #FF6302",Se.getLanguage();""==i&&(a.childNodes[0].placeholder=Se.translateString("PMI_Text"))}this.viewer.container.appendChild(a),a.Inflection=r,a.id=s;var f,o=this.viewer.modelRootObject.boundingBox.getCenter(),i=(new THREE.Vector3).subVectors(o,e.clone()).normalize(),r=new THREE.Ray(e.clone(),i),o=this.viewer.ndsModel.intersect(r,null,!0),i=((o&&o.length%2!=0||o&&o[0]&&e.distanceTo(o[0].point)<1e-4)&&(a.bodyUuid=o[0].bodyUuid,a.newPoint=new THREE.Vector3,a.newPos=new THREE.Vector3),a.interPnt=new THREE.Vector3(e.x,e.y,e.z),new THREE.Mesh(new THREE.SphereGeometry(1),this.materialPoint)),r=(i.position.set(a.interPnt.x,a.interPnt.y,a.interPnt.z),this.setPointScale(i,this.POINTSIZE),i.objectType="Point",i.textID=s,i.AnimationEdit=a.AnimationEdit,i.Point=i.position.clone(),this.AnnotationShow||(a.style.visibility="hidden",i.visible=!1),new THREE.Plane),o=this.viewer.camera.getCameraTarget(),e=this.viewer.camera.position,m=new THREE.Vector3;m.subVectors(o,e),r.setFromNormalAndCoplanarPoint(m.normalize(),a.interPnt),t?(f=new THREE.Vector3(t.x,t.y,t.z),0<this.viewer.ndsModel.ModelUpMatrix4.length&&((o=new THREE.Matrix4).fromArray(this.viewer.ndsModel.ModelUpMatrix4),f.applyMatrix4(o))):(e=[a.interPnt.x,a.interPnt.y,a.interPnt.z],f=245<(m=this.viewer.modelCoordToClientCoord(e))[0]&&185<m[1]?this.clientCoordToModelCoordOnPlane(m[0]-45,m[1]-45,r):this.clientCoordToModelCoordOnPlane(200,139,r)),a.pos=f,a.PointMeasure=!0,this.rootObject.add(i),this.TextContents.push(a),n&&(a.readOnly=!1,a.focus(),a.blur(),a.aspect||this.setPicTextVisible(s,!1)),this.viewer.render()},Ee.prototype.setSelectId=function(e,t){(t=void 0===t?!0:t)&&0==e&&(0!=this.selectID||0<this.selectIDs.length)&&(this.selectID=e,this.selectIDs=[],this.viewer.dispatchEvent({type:"NoteSelect",num:0,data:[]})),this.selectID=e,this.selectIDs=[];for(var n=0;n<this.TextContents.length;n++){var i,r=this.TextContents[n];r.hasAdd&&(r.id==e?(r.childNodes[0].style.cursor="move",r.style.zIndex=Se.isMobileDevice()?3:9,i={id:r.id,uuid:r.id,interPnt:r.interPnt,projPt:r.pos,text:r.childNodes[0].value,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,bodyUuid:r.bodyUuid,origiType:"lineNote",name:r.animationName},this.viewer.dispatchEvent({type:"NoteSelect",data:[{tagId:i.id,text:i.text,state:i,modelName:i.configName}],num:1})):(r.childNodes[0].style.cursor="default",r.childNodes[0].readOnly=!0,r.style.zIndex=Se.isMobileDevice()?2:7))}this.viewer.CADViewer&&this._addEditDel(),this.viewer.render(),this.update2DScene()},Ee.prototype.setSelectTextName=function(t,e){var n;Array.isArray(this.TextContents)&&(n=this.TextContents.find(function(e){return e.id==t}))&&(n.animationName=e)},Ee.prototype.setSelectImgName=function(t,e){var n;Array.isArray(this.PicContents)&&(n=this.PicContents.find(function(e){return e.id==t}))&&(n.animationName=e)},Ee.prototype.setSelectIdArray=function(e,t){void 0===t&&(t=!0),this.selectIDs=e,this.selectID=0;for(var n=[],i=[],r=this.picSelectID=0;r<this.TextContents.length;r++){var o=this.TextContents[r];o.hasAdd&&(o.childNodes[0].style.cursor="default",o.childNodes[0].readOnly=!0,o.style.zIndex=Se.isMobileDevice()?2:7,-1!=this.selectIDs.indexOf(o.id))&&(o.childNodes[0].style.cursor="move",o.style.zIndex=Se.isMobileDevice()?3:9,"hidden"!=o.style.visibility)&&(o={tagId:(s={id:o.id,uuid:o.id,interPnt:o.interPnt,projPt:o.pos,text:o.childNodes[0].value,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,bodyUuid:o.bodyUuid,origiType:"lineNote",name:o.animationName}).id,text:s.text,state:s,modelName:s.configName},n.push(o))}for(var a=0;a<this.PicContents.length;a++){var s,l=this.PicContents[a];l.style.border="2px solid rgba(255, 195, 0, 0.0)",-1!=this.selectIDs.indexOf(l.id)&&(s={id:l.id,filename:l.filename,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,type:"Pic",name:l.animationName},l.style.border="2px solid rgba(255, 195, 0, 1.0)","hidden"!=l.style.visibility)&&i.push(s)}t&&(this.viewer.dispatchEvent({type:"NoteSelect",data:n,num:n.length}),this.viewer.dispatchEvent({type:"PicSelect",data:i,num:i.length})),this.viewer.CADViewer&&this._addEditDel(),this.viewer.render(),this.update2DScene()},Ee.prototype.reSize=function(e){var t,n,i,r,o,a=this.stratLeft,s=this.startTop;switch(this.cornerStyle){case 0:t=this.startWidth-(e.clientX-this.startX),n=this.startHeight-(e.clientY-this.startY),a=this.stratLeft+(e.clientX-this.startX),s=this.startTop+(e.clientY-this.startY);break;case 1:t=this.startWidth+(e.clientX-this.startX),n=this.startHeight-(e.clientY-this.startY),s=this.startTop+(e.clientY-this.startY);break;case 2:t=this.startWidth-(e.clientX-this.startX),n=this.startHeight+(e.clientY-this.startY),a=this.stratLeft+(e.clientX-this.startX);break;case 3:t=this.startWidth+(e.clientX-this.startX),n=this.startHeight+(e.clientY-this.startY)}(t<40||n<40||430<n||800<t)&&!this._currentTarget.parentNode.PointMeasure||(i=t,r=n,(o=this._currentTarget.parentNode.aspect)<t/n?r=t/o:i=n*o,this._currentTarget.parentNode.children[0].style.width=i+"px",this._currentTarget.parentNode.children[0].style.height=r+"px",this._currentTarget.parentNode.style.display="flex",this._currentTarget.parentNode.style["justify-content"]="center",this._currentTarget.parentNode.style["align-items"]="center",this._currentTarget.parentNode.style.width=i+4+"px",this._currentTarget.parentNode.style.height=r+4+"px",this._currentTarget.parentNode.style.left=a+"px",this._currentTarget.parentNode.style.top=s+"px")},Ee.prototype.setMode=function(e){this.mode=e},Ee.prototype.get2dPoint=function(e){e.project(this.viewer.camera);var t=this.viewer.renderer.domElement.width/2,n=this.viewer.renderer.domElement.height/2;return{x:Math.round(e.x*t+t),y:Math.round(-e.y*n+n)}},Ee.prototype.changeAnnotation=function(e,t,n){t=this.get2dPoint(t.clone()),e=this.get2dPoint(e.clone()),e=new THREE.Vector2(t.x-e.x,t.y-e.y);e.normalize(),_e.AnimationEdit&&(t.x+=this.viewer.renderer.domElement.getBoundingClientRect().x*this.dpr,t.y+=this.viewer.renderer.domElement.getBoundingClientRect().y*this.dpr),e.y>=2*e.x&&e.y>=2*-e.x?(n.setAttribute("mobile","down"),n.style.left=parseInt((t.x-parseInt(n.childNodes[0].style.width)*this.dpr/2)/this.dpr)+"px",n.style.top=parseInt(t.y/this.dpr)+"px"):e.y>2*e.x&&e.y<2*-e.x?(n.setAttribute("mobile","right"),n.style.left=parseInt((t.x-parseInt(n.childNodes[0].style.width)*this.dpr)/this.dpr)+"px",n.style.top=parseInt((t.y-parseInt(n.childNodes[0].style.height)*this.dpr/2)/this.dpr)+"px"):e.y<2*e.x&&e.y<2*-e.x?(n.setAttribute("mobile","up"),n.style.left=parseInt((t.x-parseInt(n.childNodes[0].style.width)/2)/this.dpr)+"px",n.style.top=parseInt((t.y-parseInt(n.childNodes[0].style.height))/this.dpr)+"px"):e.y<2*e.x&&e.y>2*-e.x&&(n.setAttribute("mobile","left"),n.style.left=parseInt(t.x/this.dpr)+"px",n.style.top=parseInt((t.y-parseInt(n.childNodes[0].style.height)/2)/this.dpr)+"px")},Ee.prototype.clientCoordToModelCoordOnPlane=function(e,t,n){e=[e,t,.99],t=this.viewer.clientCoordToModelCoord(e),t=new THREE.Vector3(t[0],t[1],t[2]),e[2]=-.99,e=this.viewer.clientCoordToModelCoord(e),e=new THREE.Vector3(e[0],e[1],e[2]);return this.intersectLine(t,e,n)},Ee.prototype.intersectLine=function(e,t,n){var i,r;return!(e&&t&&n)||(i=e.clone(),(e=(new THREE.Vector3).subVectors(t,e)).normalize(),r=e.dot(n.normal),Math.abs(r)<=1e-8)?null:(t=n.coplanarPoint(t.clone()),t=(new THREE.Vector3).subVectors(t,i).dot(n.normal)/r,i.add(e.multiplyScalar(t)))},Ee.prototype.update2DScene=function(){var e,t,n,i,r=this.viewer.renderer.getPixelRatio(),o=this.viewer.canvas2D.getContext("2d");if(!this.viewer.controls.staticmeasureOp&&this.viewer.is2DModel&&(o.clearRect(0,0,window.innerWidth*r,window.innerHeight*r),4==this.viewer.Rectangle.length&&(i=this.viewer.Rectangle[0],t=this.viewer.Rectangle[1],e=this.viewer.Rectangle[2],n=this.viewer.Rectangle[3],o.strokeStyle="#00FFFF",o.setLineDash([5,5]),o.beginPath(),o.moveTo(i,e),o.lineTo(t,e),o.lineTo(t,n),o.lineTo(i,n),o.lineTo(i,e),o.closePath(),o.stroke(),o.setLineDash([])),this.viewer.renderWaterMark()),this.rootObject.visible){this.Textbox&&this.intersectPnt&&(o.strokeStyle="#FF6302",o.lineWidth=r,o.beginPath(),"up"==(t=this.Textbox.getAttribute("mobile"))||"down"==t?(l=this.get2dPoint(this.intersectPnt.clone()),d=this.get2dPoint(this.Textbox.pos.clone()),o.moveTo(l.x,l.y),o.lineTo(d.x,d.y)):"left"!=t&&"right"!=t||(n=this.get2dPoint(this.intersectPnt.clone()),i=this.get2dPoint(this.Textbox.pos.clone()),o.moveTo(n.x,n.y),o.lineTo(Math.round((n.x+i.x)/2),i.y),o.lineTo(i.x,i.y)),o.stroke());for(var a=0;a<this.TextContents.length;++a){var s,l,d,c,h,u=this.TextContents[a];"hidden"!=u.style.visibility&&(h=parseFloat(u.style.opacity),o.globalAlpha=""==u.style.opacity?1:h,h=u.newPoint||u.interPnt,s=u.newPos||u.pos,o.strokeStyle="#FF6302",u.Color&&(o.strokeStyle=u.Color),u.id==this.selectID||-1!=this.selectIDs.indexOf(u.id)?(o.strokeStyle="#FFC300",u.childNodes[0].style.border="1px solid #FFC300"):u.childNodes[0].style.border="1px solid #FF6302",o.lineWidth=r,o.beginPath(),c=u.getAttribute("mobile"),Se.isMobileDevice()||"up"==c||"down"==c?(l=this.get2dPoint(h.clone()),d=this.get2dPoint(s.clone()),o.moveTo(l.x,l.y),o.lineTo(d.x,d.y)):"left"!=c&&"right"!=c||(c=this.get2dPoint(h.clone()),h=this.get2dPoint(s.clone()),u.Inflection?(o.moveTo(c.x,c.y),o.lineTo(Math.round((c.x+h.x)/2),h.y)):o.moveTo(c.x,c.y),o.lineTo(h.x,h.y)),o.stroke())}}},Ee.prototype.onNMouseMove=function(e){var t,n,i,r;"Note"==this.mode?this.Textbox&&(this.Textbox.style.left=e.clientX+8+"px",this.Textbox.style.top=e.clientY+20+"px"):"NotePlace"==this.mode&&(t=new THREE.Plane,i=this.viewer.camera.getCameraTarget(),r=this.viewer.camera.position,(n=new THREE.Vector3).subVectors(i,r),i=this.getViewClientCoords(e),t.setFromNormalAndCoplanarPoint(n.normalize(),this.intersectPnt),r=this.clientCoordToModelCoordOnPlane(i.x,i.y,t),this.Textbox.pos=r,this.changeAnnotation(this.intersectPnt,this.Textbox.pos,this.Textbox)),this.Textbox&&(this.Textbox.style.visibility="visible"),this.render()},Ee.prototype.onRMouseMove=function(e){"Note"==this.mode&&this.Textbox&&(this.Textbox.style.left=e.clientX+8+"px",this.Textbox.style.top=e.clientY+20+"px"),g.prototype.onRMouseMove.call(this,e)},Ee.prototype.onLMouseMoveEnable=function(){return!!("NoteMove"==this.mode||"Picture"==this.mode||"picNote"==this.mode&&this._isResizing)},Ee.prototype.onLMouseMove=function(e){if("Picture"==this.mode){if(this._isResizing)return void this.reSize(e);if(this._isDragging)return t=Math.round(e.clientX-this.startX),n=Math.round(e.clientY-this.startY),this._currentTarget.parentNode.style.left=t+"px",void(this._currentTarget.parentNode.style.top=n+"px");g.prototype.onLMouseMove.call(this,e)}else if("NoteMove"==this.mode&&this.MoveTarget){var t=new THREE.Plane,n=this.viewer.camera.getCameraTarget(),i=this.viewer.camera.position,r=new THREE.Vector3,n=(r.subVectors(n,i),this.getViewClientCoords(e)),i=(t.setFromNormalAndCoplanarPoint(r.normalize(),this.MoveTarget.interPnt),this.clientCoordToModelCoordOnPlane(n.x,n.y,t));this.MoveTarget.pos=i,this.changeAnnotation(this.MoveTarget.interPnt,this.MoveTarget.pos,this.MoveTarget),this.update2DScene()}else if("picNote"==this.mode){if(this._isResizing)return void this.reSize(e)}else g.prototype.onLMouseMove.call(this,e);!this.Textbox||"单击确定位置"!=this.Textbox.childNodes[0].value&&"Click to choose the location for the comment."!=this.Textbox.childNodes[0].value||(this.Textbox.style.visibility="hidden"),this.viewer.render()},Ee.prototype.clearFlag=function(e){void 0===e&&(e=!1),this.Textbox&&(this.viewer.container.removeChild(this.Textbox),this.Textbox=null);for(var t=0;t<this.rootObject.children.length;t++){var n=this.rootObject.children[t];n.textID||this.rootObject.remove(n)}"NotePlace"!=this.mode&&"Note"!=this.mode||!e?this.setMode("normal"):this.createText()},Ee.prototype.setPointScale=function(e,t){t=this.getScale(e,t);e.scale.x=t,e.scale.y=t,e.scale.z=t,e.updateMatrixWorld()},Ee.prototype.getScale=function(e,t){var n=5,t=(null!=t&&(n=t),this.viewer.camera.getCameraTarget()),i=this.viewer.camera.position,r=new THREE.Vector3,t=(r.subVectors(t,i),e.position.clone()),e=this.viewer.camera.isPerspective?t.sub(i).dot(r.normalize()):r.length(),t=this.viewer.camera.fov,i=2*e*Math.tan(THREE.Math.degToRad(.5*t)),r=this.viewer.renderer.domElement.height;return n*i*this.viewer.renderer.getPixelRatio()/r},Ee.prototype.renderScale=function(e){for(var n=this,t=0;t<e.children.length;t++){var i=e.children[t];null!=i.objectType&&"Point"===i.objectType&&(i.textID!=this.selectID&&-1==this.selectIDs.indexOf(i.textID)||i.material==this.SelectmaterialPoint||(i.material=this.SelectmaterialPoint),i.textID!=this.selectID&&-1==this.selectIDs.indexOf(i.textID)&&i.material!=this.materialPoint&&(i.material=this.materialPoint),this.TextContents.forEach(function(e){var t;e.id==i.textID&&e.bodyUuid&&((t=n.viewer.ndsModel.getBodyNodeFromUuid(e.bodyUuid))?(t=n.viewer.ndsModel.getBodyTranslate(t),i.position.set(e.interPnt.x+t[0],e.interPnt.y+t[1],e.interPnt.z+t[2]),e.newPos.copy(e.pos),e.newPos.x+=t[0],e.newPos.y+=t[1],e.newPos.z+=t[2],e.newPoint.copy(i.position)):(e.newPos.copy(e.pos),e.newPoint.copy(e.interPnt)))}),this.setPointScale(i,this.POINTSIZE))}},Ee.prototype.createLineMesh=function(e,t){var n=new THREE.Geometry,n=(n.vertices.push(t),n.vertices.push(e),new THREE.Line(n,this.materialLine));return n.updateMatrixWorld(!0),n.objectType="Line",n.Start=e.clone(),n.End=t.clone(),n},Ee.prototype.renderAnnotation=function(){if(this.AnnotationScene){null!=this.rootObject&&this.renderScale(this.rootObject),this.rootObject.visible&&this.viewer.renderer.render(this.AnnotationScene,this.viewer.camera),"NotePlace"==this.mode&&this.Textbox&&this.changeAnnotation(this.intersectPnt,this.Textbox.pos,this.Textbox);for(var e=0;e<this.TextContents.length;++e){var t=this.TextContents[e],n=t.newPoint||t.interPnt,i=t.newPos||t.pos;this.changeAnnotation(n,i,t)}this.update2DScene()}},Ee.prototype.showNoteAnnotation=function(e){e=!!e;for(var t=0;t<this.TextContents.length;++t){var n=this.TextContents[t];n.AnimationEdit&&!_e.AnimationEdit||(n.style.visibility=e?"visible":"hidden")}for(var i=0;i<this.rootObject.children.length;i++){var r=this.rootObject.children[i];r.AnimationEdit&&!_e.AnimationEdit||(r.visible=e)}for(var o=0;o<this.PicContents.length;++o){var a=this.PicContents[o];a.AnimationEdit&&!_e.AnimationEdit||(a.style.visibility=e?"visible":"hidden")}this.viewer.CADViewer&&this._addEditDel(),this.AnnotationShow=e},Ee.prototype.showAnimationNoteAnnotation=function(e){for(var t=0;t<this.TextContents.length;++t){var n=this.TextContents[t];n.AnimationEdit&&(n.style.visibility=e?"visible":"hidden")}for(var i=0;i<this.rootObject.children.length;i++){var r=this.rootObject.children[i];r.AnimationEdit&&(r.visible=e)}for(var o=0;o<this.PicContents.length;++o){var a=this.PicContents[o];a.AnimationEdit&&(a.style.visibility=e?"visible":"hidden")}},Ee.prototype.getViewClientCoords=function(e){var t=e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top;return e.srcElement&&e.srcElement!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),new THREE.Vector2(t,n)},Ee.prototype.updateTextPos=function(e,t){for(var n=0;n<this.TextContents.length;n++){var i=this.TextContents[n];i.bodyUuid==e&&(i.interPnt.applyMatrix4(t),i.pos.applyMatrix4(t))}},Ee.prototype.onTouchSingle=function(e){if("Note"==this.mode){var t=this.singleTouchEndPos,n=t.x,t=t.y,i=this.viewer.renderer.domElement,r=this.viewer.renderer.getPixelRatio(),n=n*r/i.width*2-1,t=2*-(t*r/i.height)+1,r=new THREE.Raycaster,i=(this.viewer.camera.setCastRay(r,n,t),this.viewer.ndsModel.intersect(r.ray)),r=(i&&0<i.length?(o=i[0].point,this.Textbox.bodyUuid=i[0].bodyUuid,this.Textbox.newPoint=new THREE.Vector3,this.Textbox.newPos=new THREE.Vector3):(n=new THREE.Plane,t=this.viewer.camera.getCameraTarget(),r=this.viewer.camera.position,(i=new THREE.Vector3).subVectors(t,r),t=this.singleTouchEndPos,n.setFromNormalAndCoplanarPoint(i.normalize(),this.viewer.controls.getBoundingBox().getCenter()),o=this.clientCoordToModelCoordOnPlane(t.x,t.y,n)),this.setMode("NotePlace"),new THREE.Mesh(new THREE.SphereGeometry(1),this.materialPoint)),i=(r.position.set(o.x,o.y,o.z),this.setPointScale(r,this.POINTSIZE),r.objectType="Point",r.Point=r.position.clone(),this.intersectPnt=r.Point,this.Textbox.pos=r.Point.clone(),this.rootObject.add(r),"en"==Se.getLanguage()),t=(this.Textbox.childNodes[0].placeholder=i?"Text":"文本",this.Textbox.childNodes[0].value="",this.Textbox.childNodes[0].style.backgroundColor="#FFFFFF",this.Textbox.childNodes[0].style.fontSize="16px",this.Textbox.childNodes[0].style.lineHeight="22px",this.Textbox.childNodes[0].style.height="22px",this.Textbox.childNodes[0].style.width="44px",this.Textbox.childNodes[0].style.textAlign="left",this.Textbox.childNodes[0].style.border="1px solid #FF6302",new THREE.Plane),n=this.viewer.camera.getCameraTarget(),o=this.viewer.camera.position,r=new THREE.Vector3,n=(r.subVectors(n,o),this.singleTouchEndPos),o=(t.setFromNormalAndCoplanarPoint(r.normalize(),this.intersectPnt),this.clientCoordToModelCoordOnPlane(n.x,n.y,t)),r=(this.Textbox.pos=o,this.changeAnnotation(this.intersectPnt,this.Textbox.pos,this.Textbox),this.Textbox.style.visibility="hidden",this.viewer.dispatchEvent({type:"infoMsgTips",msg:""}),i?"Please select the text location":"请选择批注文本显示位置");this._clearMsgInfo=!1,this.PostInfo(r)}else{if("NotePlace"==this.mode)return this.Textbox.style.visibility="visible",this.Textbox.childNodes[0].readOnly=!1,this.Textbox.childNodes[0].focus(),n=new THREE.Plane,t=this.viewer.camera.getCameraTarget(),o=this.viewer.camera.position,(i=new THREE.Vector3).subVectors(t,o),r={x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY},n.setFromNormalAndCoplanarPoint(i.normalize(),this.intersectPnt),t=this.clientCoordToModelCoordOnPlane(r.x,r.y,n),this.Textbox.pos=t,this.Textbox.childNodes[0].style.border="1px solid #FFC300",this.Textbox.interPnt=this.intersectPnt,(o=this.viewer.ndsModel.getBodyNodeFromUuid(this.Textbox.bodyUuid))&&(i=this.viewer.ndsModel.getBodyTranslate(o),this.Textbox.interPnt.set(this.Textbox.interPnt.x-i[0],this.Textbox.interPnt.y-i[1],this.Textbox.interPnt.z-i[2])),r=this.getUUid(),this.rootObject.children[this.rootObject.children.length-1].textID=r,this.Textbox.id=r,this.Textbox.childNodes[0].readOnly=!1,this.TextContents.push(this.Textbox),this.Textbox=null,this.intersectPnt=null,this.setSelectId(r),this.setMode("NoteEdit"),e.preventDefault(),e.stopImmediatePropagation(),void e.stopPropagation();"NoteEdit"==this.mode?this.setMode("normal"):"normal"!=this.mode&&"Picture"!=this.mode||"OpAnnotationNew"!=this.viewer.controls.getOperator().type||g.prototype.onLMouseClick.call(this,e)}if(this.Textbox&&this.Textbox.childNodes[0].blur(),!e.ctrlKey){for(var a=0;a<this.TextContents.length;a++){var s=this.TextContents[a];s.childNodes[0].blur(),"NoteEdit"!=this.mode&&(s.childNodes[0].style.cursor="default",s.childNodes[0].style.userSelect="none",s.childNodes[0].readOnly=!0)}for(var l=0;l<this.PicContents.length;l++)this.PicContents[l].style.border="2px solid rgba(255, 195, 0, 0.0)";this._isDragging=!1,this._isResizing=!1,this._currentTarget&&(this._currentTarget.parentNode.style.zIndex=Se.isMobileDevice()?2:7,this._currentTarget.parentNode.style.border="2px solid rgba(255, 195, 0, 0.0)"),this._currentTarget=null,(0!=this.picSelectID||0<this.selectIDs.length)&&(this.picSelectID=0,this.viewer.dispatchEvent({type:"PicSelect",data:[]})),this.setSelectId(0)}this.Textbox&&(this.Textbox.style.left=e.clientX+8+"px",this.Textbox.style.top=e.clientY+20+"px"),this.viewer.render()},Ee.prototype.onLMouseClick=function(e){if("Note"==this.mode){var t=this.getViewClientCoords(e),n=t.x,t=t.y,i=this.viewer.renderer.domElement,r=this.viewer.renderer.getPixelRatio(),n=n*r/i.width*2-1,t=2*-(t*r/i.height)+1,r=new THREE.Raycaster,i=(this.viewer.camera.setCastRay(r,n,t),this.viewer.ndsModel.intersect(r.ray)),r=(i&&0<i.length?(o=i[0].point,this.Textbox.bodyUuid=i[0].bodyUuid,this.Textbox.newPoint=new THREE.Vector3,this.Textbox.newPos=new THREE.Vector3):(n=new THREE.Plane,t=this.viewer.camera.getCameraTarget(),r=this.viewer.camera.position,(i=new THREE.Vector3).subVectors(t,r),t=this.getViewClientCoords(e),n.setFromNormalAndCoplanarPoint(i.normalize(),this.viewer.controls.getBoundingBox().getCenter()),o=this.clientCoordToModelCoordOnPlane(t.x,t.y,n)),this.setMode("NotePlace"),new THREE.Mesh(new THREE.SphereGeometry(1),this.materialPoint));r.position.set(o.x,o.y,o.z),this.setPointScale(r,this.POINTSIZE),r.objectType="Point",r.Point=r.position.clone(),this.intersectPnt=r.Point,this.Textbox.pos=r.Point.clone(),this.rootObject.add(r),this.Textbox.childNodes[0].placeholder=Se.translateString("PMI_Text"),this.Textbox.childNodes[0].value="",this.Textbox.childNodes[0].style.backgroundColor="#FFFFFF",this.Textbox.childNodes[0].style.fontSize="16px",this.Textbox.childNodes[0].style.lineHeight="22px",this.Textbox.childNodes[0].style.height="22px",this.Textbox.childNodes[0].style.width="44px",this.Textbox.childNodes[0].style.textAlign="left",this.Textbox.childNodes[0].style.border="1px solid #FF6302"}else{var o;if("NotePlace"==this.mode)return i=new THREE.Plane,t=this.viewer.camera.getCameraTarget(),n=this.viewer.camera.position,(o=new THREE.Vector3).subVectors(t,n),r=this.getViewClientCoords(e),i.setFromNormalAndCoplanarPoint(o.normalize(),this.intersectPnt),t=this.clientCoordToModelCoordOnPlane(r.x,r.y,i),this.Textbox.pos=t,this.Textbox.childNodes[0].style.border="1px solid #FFC300",this.Textbox.interPnt=this.intersectPnt,(n=this.viewer.ndsModel.getBodyNodeFromUuid(this.Textbox.bodyUuid))&&(o=this.viewer.ndsModel.getBodyTranslate(n),this.Textbox.interPnt.set(this.Textbox.interPnt.x-o[0],this.Textbox.interPnt.y-o[1],this.Textbox.interPnt.z-o[2])),r=this.getUUid(),this.rootObject.children[this.rootObject.children.length-1].textID=r,this.Textbox.id=r,this.Textbox.childNodes[0].readOnly=!1,this.TextContents.push(this.Textbox),this.Textbox=null,this.intersectPnt=null,this.setSelectId(r),void this.setMode("NoteEdit");"NoteEdit"==this.mode?this.setMode("normal"):"normal"!=this.mode&&"Picture"!=this.mode||"OpAnnotationNew"!=this.viewer.controls.getOperator().type||g.prototype.onLMouseClick.call(this,e)}if(this.Textbox&&this.Textbox.childNodes[0].blur(),!e.ctrlKey){for(var a=0;a<this.TextContents.length;a++){var s=this.TextContents[a];s.childNodes[0].blur(),"NoteEdit"!=this.mode&&(s.childNodes[0].style.cursor="default",s.childNodes[0].style.userSelect="none",s.childNodes[0].readOnly=!0)}for(var l=0;l<this.PicContents.length;l++)this.PicContents[l].style.border="2px solid rgba(255, 195, 0, 0.0)";this._isDragging=!1,this._isResizing=!1,this._currentTarget&&(this._currentTarget.parentNode.style.zIndex=Se.isMobileDevice()?2:7,this._currentTarget.parentNode.style.border="2px solid rgba(255, 195, 0, 0.0)"),this._currentTarget=null,(0!=this.picSelectID||0<this.selectIDs.length)&&(this.picSelectID=0,this.viewer.dispatchEvent({type:"PicSelect",data:[]})),this.setSelectId(0)}this.Textbox&&(this.Textbox.style.left=e.clientX+8+"px",this.Textbox.style.top=e.clientY+20+"px")},Ee.prototype.onTouchSingleEnd=function(e){g.prototype.onTouchSingleEnd.call(this,e)},Ee.prototype.setPicTextVisible=function(e,t){for(var n,i=0;i<this.rootObject.children.length;i++){var r=this.rootObject.children[i];r.textID==e&&(r.visible=t)}t?-1!=(n=this.unvisibleIDs.indexOf(e))&&this.unvisibleIDs.splice(n,1):-1==(n=this.unvisibleIDs.indexOf(e))&&this.unvisibleIDs.push(n);for(var o=0;o<this.TextContents.length;o++){var a=this.TextContents[o];a.id==e&&(a.style.visibility=t?"visible":"hidden")}for(var s=0;s<this.PicContents.length;s++){var l=this.PicContents[s];l.id==e&&(l.style.visibility=t?"visible":"hidden")}this.viewer.CADViewer&&this._addEditDel(),this.update2DScene(),this.viewer.render()},Ee.prototype.setNoteAnnotation=function(e){this._clearMsgInfo=!0;for(var t=this.createDiv(),n=(t.childNodes[0].value=e.text,""==e.text&&(t.childNodes[0].placeholder=Se.translateString("PMI_Text")),t.childNodes[0].style.backgroundColor="#FFFFFF",t.childNodes[0].style.fontSize="16px",t.childNodes[0].style.lineHeight="22px",t.childNodes[0].style.height="22px",t.childNodes[0].style.width="44px",t.childNodes[0].style.textAlign="left",t.childNodes[0].style.border="1px solid #FF6302",t.childNodes[0]),i=n.value.split("\n"),r=0,o=0;o<i.length;o++){for(var a=i[o],s=0,l=0;l<a.length;l++)s+=8230<=a[l].charAt(0).charCodeAt(0)?2:1;r<s&&(r=s)}var d="en"==Se.getLanguage()||Se.isIOSDevice()?10:8,d=(n.style.width=Math.round(r*d)+"px",Math.round(r*d)<44&&(n.style.width="44px"),Se.isMobileDevice()&&160<Math.round(r*d)&&(n.style.width="160px"),t.childNodes[0].value.split("\n").length),n=(t.childNodes[0].style.height=22*d+"px",t.pos=new THREE.Vector3(e.projPt.x,e.projPt.y,e.projPt.z),t.id=e.id,t.bodyUuid=e.bodyUuid,t.bodyUuid&&(t.newPoint=new THREE.Vector3,t.newPos=new THREE.Vector3),t.hasAdd=!0,t.interPnt=new THREE.Vector3(e.interPnt.x,e.interPnt.y,e.interPnt.z),t.AnimationEdit=e.AnimationEdit||!1,this.TextContents.push(t),new THREE.Mesh(new THREE.SphereGeometry(1),this.materialPoint));n.position.set(t.interPnt.x,t.interPnt.y,t.interPnt.z),this.setPointScale(n,this.POINTSIZE),n.objectType="Point",n.textID=e.id,n.AnimationEdit=t.AnimationEdit,n.Point=n.position.clone(),this.rootObject.add(n),this.viewer.container.appendChild(t),0==e.visible&&this.setPicTextVisible(t.id,!1),Se.isMobileDevice()&&(t.childNodes[0].style.height="auto",t.childNodes[0].style.height=t.childNodes[0].scrollHeight+"px")},Ee.prototype.setPicAnnotation=function(e){this.createElement(e.base64,e.name);var t=this.PicContents[this.PicContents.length-1];t.id=e.id,t.children[0].style.width=e.width+"px",t.children[0].style.height=e.height+"px",t.style.width=e.width+4+"px",t.style.height=e.height+4+"px",t.style.display="flex",t.style["justify-content"]="center",t.style["align-items"]="center",t.style.left=e.left+"px",t.style.top=e.top+"px",t.style.visibility=e.visible?"visible":"hidden",t.AnimationEdit=e.AnimationEdit||!1},Ee.prototype.clearAnnotation=function(){for(var e=0;e<this.rootObject.children.length;e++){var t=this.rootObject.children[e];this.rootObject.remove(t)}for(var n=0;n<this.TextContents.length;n++){var i=this.TextContents[n];this.viewer.container.removeChild(i)}for(var r=0;r<this.PicContents.length;r++){var o=this.PicContents[r];this.viewer.container.removeChild(o)}this.TextContents=[]},Ee.prototype.EditSelected=function(){for(var e=0;e<this.TextContents.length;e++){var t=this.TextContents[e];if(t.id==this.selectID)return t.childNodes[0].readOnly=!1,void t.childNodes[0].focus()}},Ee.prototype.getAnnotationColorAndOpacity=function(e){var t=!1;e!=this.selectID&&e!=this.picSelectID&&-1==this.selectIDs.indexOf(e)||(t=!0);for(var n=0;n<this.TextContents.length;n++){var i=this.TextContents[n];if(i.id==e)return{id:i.id,opacity:""==i.style.opacity?1:i.style.opacity,Notecolor:""==i.childNodes[0].style.color?"#000000":i.Notecolor,NoteLineColor:i.Color||"#FF6302",selected:t}}for(var r=0;r<this.PicContents.length;r++){var o=this.PicContents[r];if(o.id==e)return{id:o.id,opacity:""==o.childNodes[0].style.opacity?1:o.childNodes[0].style.opacity,selected:t}}},Ee.prototype.setTransparent=function(e,t){for(var n=0;n<this.PicContents.length;n++){var i=this.PicContents[n];i.id==e&&(i.childNodes[0].style.opacity=t)}for(var r=0;r<this.TextContents.length;r++){var o=this.TextContents[r];o.id==e&&(o.style.opacity=t)}},Ee.prototype.setNoteColor=function(e,t){for(var n=0;n<this.TextContents.length;n++){var i=this.TextContents[n];i.id==e&&(i.childNodes[0].style.color=t,i.Notecolor=t)}},Ee.prototype.setNoteLineColor=function(e,t){for(var n=0;n<this.TextContents.length;n++){var i=this.TextContents[n];i.id==e&&(i.Color=t)}},Ee.prototype.deleteNoteAnnotation=function(i,e){void 0===e&&(e=!0);var r=this,o=Array.isArray(i);if(o&&e)for(var t=0;t<i.length;t++)this.deleteNoteAnnotation(i[t]);for(var n=[],a=[],s=[],l=0;l<this.TextContents.length;l++){var d=this.TextContents[l];(o?i.includes(d.id):d.id==i)&&d.PointMeasure&&(a.push(l),s.push(d.id))}s.includes(r.selectID)&&0!=r.selectID&&r.setSelectId(0,!1);for(var c=r.rootObject.children.length-1;0<=c;c--){var h=r.rootObject.children[c];s.includes(h.textID)&&r.rootObject.remove(h)}for(var u=a.length-1;0<=u;u--)r.viewer.container.removeChild(r.TextContents[a[u]]),r.TextContents.splice(a[u],1);for(var a=[],s=[],p=0;p<this.TextContents.length;p++){var f=this.TextContents[p];(o?i.includes(f.id):f.id==i)&&!f.PointMeasure&&(f={tagId:(v={id:f.id,uuid:f.id,interPnt:f.interPnt,projPt:f.pos,text:f.childNodes[0].value,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,bodyUuid:f.bodyUuid,origiType:"lineNote",name:f.animationName}).id,text:v.text,state:v,modelName:v.configName},n.push(f),a.push(p))}function m(){(o?i.includes(r.selectID):r.selectID==i)&&0!=r.selectID&&r.setSelectId(0,!1);for(var e=r.rootObject.children.length-1;0<=e;e--){var t=r.rootObject.children[e];(o?i.includes(t.textID):t.textID==i)&&r.rootObject.remove(t)}for(var n=a.length-1;0<=n;n--)r.viewer.container.removeChild(r.TextContents[a[n]]),r.TextContents.splice(a[n],1)}e&&n.length&&this.viewer.dispatchEvent({type:"NoteDelete",data:n[0],delete:m}),e||m(),(o?i.includes(this.picSelectID):this.picSelectID==i)&&0!=this.picSelectID&&(this.picSelectID=0);for(var g=0;g<this.PicContents.length;g++){var v,A=this.PicContents[g];(o?i.includes(A.id):A.id==i)&&(this.viewer.container.removeChild(A),this.PicContents.splice(g,1),v={id:A.id,name:A.filename,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,type:"Pic"},this.viewer.dispatchEvent({type:"PicDelete",data:v}))}"Note"!=this.mode&&this.setMode("normal"),this.update2DScene(),this.viewer.render()},Ee.prototype.getAllNoteContent=function(){for(var e=[],t=0;t<this.TextContents.length;t++){var n,i=this.TextContents[t];i.PointMeasure||(n={id:i.id,uuid:i.id,interPnt:i.interPnt,projPt:i.pos,text:i.childNodes[0].value,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,bodyUuid:i.bodyUuid,origiType:"lineNote",visible:"hidden"!=i.style.visibility,name:i.animationName},i={tagId:i.id,text:n.text,state:n,modelName:n.configName},e.push(i))}return e},Ee.prototype.GetMeasurePointData=function(){for(var e=[],t=0;t<this.TextContents.length;t++){var n,i,r,o,a=this.TextContents[t];a.PointMeasure&&(n=0,a.isPic&&(n=Math.max(a.childNodes[0].height,a.childNodes[0].width)),i=a.interPnt.clone(),r=a.pos.clone(),0<this.viewer.ndsModel.ModelUpMatrix4.length&&((o=new THREE.Matrix4).fromArray(this.viewer.ndsModel.ModelUpMatrix4),o.invert(),i.applyMatrix4(o),r.applyMatrix4(o)),o={point:i,notePlace:r,url:a.isPic?a.childNodes[0].src:"",text:a.isPic?"":a.childNodes[0].value,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,inflection:a.Inflection,type:"MeasurePoint",picSize:n},e.push(o))}return e},Ee.prototype.getNoteContentByID=function(e){for(var t=0;t<this.TextContents.length;t++){var n=this.TextContents[t];if(n.id==e)return{tagId:(n={id:n.id,uuid:n.id,interPnt:n.interPnt,projPt:n.pos,text:n.childNodes[0].value,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,bodyUuid:n.bodyUuid,origiType:"lineNote",visible:"hidden"!=n.style.visibility,name:n.animationName}).id,text:n.text,state:n,modelName:n.configName}}},Ee.prototype.getSelectContent=function(){for(var e=[],t=0;t<this.PicContents.length;t++){var n,i=this.PicContents[t];i.id!=this.picSelectID&&-1==this.selectIDs.indexOf(i.id)||"hidden"!=i.style.visibility&&((n={id:i.id,name:i.filename,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,base64:i.childNodes[0].src,type:"Pic",width:parseInt(i.childNodes[0].style.width),left:parseInt(i.style.left),height:parseInt(i.childNodes[0].style.height),top:parseInt(i.style.top),visible:"hidden"!=i.style.visibility}).name=i.animationName,o=n,e.push(o))}for(var r=0;r<this.TextContents.length;r++){var o,a=this.TextContents[r];a.id!=this.selectID&&-1==this.selectIDs.indexOf(a.id)||"hidden"!=a.style.visibility&&(a={tagId:(o={id:a.id,uuid:a.id,interPnt:a.interPnt,projPt:a.pos,text:a.childNodes[0].value,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,bodyUuid:a.bodyUuid,origiType:"lineNote",visible:"hidden"!=a.style.visibility,name:a.animationName}).id,text:o.text,state:o,modelName:o.configName},e.push(a))}return e},Ee.prototype.getallPicContent=function(){for(var e=[],t=0;t<this.PicContents.length;t++){var n=this.PicContents[t],n={id:n.id,name:n.filename,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,base64:n.childNodes[0].src,type:"Pic",width:parseInt(n.childNodes[0].style.width),left:parseInt(n.style.left),height:parseInt(n.childNodes[0].style.height),top:parseInt(n.style.top),visible:"hidden"!=n.style.visibility};e.push(n)}return e},Ee.prototype.getPicContentByID=function(e){for(var t=0;t<this.PicContents.length;t++){var n=this.PicContents[t];if(n.id==e)return{id:n.id,name:n.filename,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,base64:n.childNodes[0].src,type:"Pic",width:parseInt(n.childNodes[0].style.width),left:parseInt(n.style.left),height:parseInt(n.childNodes[0].style.height),top:parseInt(n.style.top),visible:"hidden"!=n.style.visibility}}},Ee.prototype.release=function(){var e=this.viewer.renderer.getPixelRatio();this.viewer.canvas2D.getContext("2d").clearRect(0,0,window.innerWidth*e,window.innerHeight*e),this.clearAnnotation(),g.prototype.release.call(this)},Ee.prototype.onLMouseDown=function(e){g.prototype.onLMouseDown.call(this,e)},Ee.prototype.onTouchSingleEnd=function(e){var t,n;g.prototype.onLMouseDown.call(this,e),_e.enableSelect&&(t=Math.abs(this.singleTouchEndPos.x-this.singleTouchStartPos.x),n=Math.abs(this.singleTouchEndPos.y-this.singleTouchStartPos.y),t<3)&&n<3&&this.viewer.is2DModel&&"OpAnnotationNew"==this.type&&this.onTouchSingle(e)},Ee.prototype.onLMouseUp=function(e){var t,n;this._isDragging=!1,this._isResizing=!1,"NoteMove"==this.mode&&(this.MoveTarget=null,this.mode=this.oldmode,"NoteMove"==this.mode&&(this.mode="normal"),n={id:(t=e.target.parentNode).id,uuid:t.id,configNum:this.viewer.ConfigNum,configName:this.viewer.ConfigName,interPnt:t.interPnt,projPt:t.pos,text:t.childNodes[0].value,bodyUuid:t.bodyUuid,origiType:"lineNote",name:t.animationName},!t.PointMeasure)&&t.hasAdd&&this.viewer.dispatchEvent({type:"NoteChange",data:{tagId:n.id,text:n.text,state:n,modelName:n.configName},editNote:function(e){e?t.oldText=t.childNodes[0].value:(t.childNodes[0].value=t.oldText,changeTextWidth(t.childNodes[0]),Se.isMobileDevice()&&(t.childNodes[0].style.height="auto",t.childNodes[0].style.height=t.childNodes[0].scrollHeight+"px"))}}),g.prototype.onLMouseUp.call(this,e)},Ee.prototype._getBase64ByType=function(e){return"delete"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEaSURBVFiF7ZY9bsMwDIVJJ0O3dOhJRA9dc5fkHFHP4R4mYwZRJ8nQbllidhENJ/VP5MgJHPgBBohHi/xMyIIAZj1ZGLvAGLNDRNuUExHrvf8aDaCreVUQce2c299aM4sBUImIZWasPyJiQ24XU+tiAkS0YubfphfrX6/N/hUL+a4pXPfAegIAfmLo79C7QlxMwBhDFRmiS9lRRHKNvffcu4CIhIjk3sZ9dQZtwpSaJgARbQBgUbMWwRsfgIg+AKDI8/xTvRAXITcuADMfAQDKsjypp7HmRgVIrRlgBpgegP7rWZa9VUVC/MhzYOucO6gX4u2Qc2AZuyBAfF9Z5wbvJk1vD7wcQO8eSHEr6lLrBNpuvkOUstas5PoD9pJ5PWI1yesAAAAASUVORK5CYII=":"edit"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAD9SURBVEiJ7dQxTsMwFAbg/zdRF06QY8TJ3vYonIT2ZC0LU/JW1kqII8AU+bHUVWkJcZLXoSi/ZEWWX/zJlm1gzj3Ee/9clqVWVbXqq6UVSHJzmpRc13W976p3lqCqxu/urxVPQs9BkmsR2abAo9FLMG6niGwB7AEghLA0Q7vAOAZgBQDOuZff/h98kPrArrHRqAU4CLUCk1FLMAm1BoGE02sNJqExViAAZKmF8XUJISyngINQVd0dIUwBAeChryDP8wgdYiP5NBac8z9z9SIVRVGZAuSniLx1ot77kmRtiR7z2DTNV+z8uKdt275nWfbqnFtYaar6cQ7OuXm+AX5zoNbbzDxiAAAAAElFTkSuQmCC":null},Ee.prototype._getAppBase64ByType=function(e){return"delete"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEaSURBVFiF7ZY9bsMwDIVJJ0O3dOhJRA9dc5fkHFHP4R4mYwZRJ8nQbllidhENJ/VP5MgJHPgBBohHi/xMyIIAZj1ZGLvAGLNDRNuUExHrvf8aDaCreVUQce2c299aM4sBUImIZWasPyJiQ24XU+tiAkS0YubfphfrX6/N/hUL+a4pXPfAegIAfmLo79C7QlxMwBhDFRmiS9lRRHKNvffcu4CIhIjk3sZ9dQZtwpSaJgARbQBgUbMWwRsfgIg+AKDI8/xTvRAXITcuADMfAQDKsjypp7HmRgVIrRlgBpgegP7rWZa9VUVC/MhzYOucO6gX4u2Qc2AZuyBAfF9Z5wbvJk1vD7wcQO8eSHEr6lLrBNpuvkOUstas5PoD9pJ5PWI1yesAAAAASUVORK5CYII=":"edit"==e?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAF/SURBVGiB7ZZNTsJAGEDfNxrvMGz0CrTsLffQhadwKSy9hYkHARKXtJzBVe/gouMGDBZoS+dvM29FwmS+9wLJfJBIJBIJC25iDc7zfDWZTD601tR1vRl7T5SAPM9XQAEgIoVNRPCAY/kDNhFBA87Ir4EHGB8RLKAtb4xZVFX1orVGRAoYFxEk4IL8EqCu641NhHjw/UeXfNe5siwHuSl7xcsMlc+y7K19bugMb7/ANfIisug7dwkvAaHkwUNASHlwHBBaHhwGxJAHRwGx5MFBQEx5sAyILQ8WD9m5xye0PFgEHHYXiCcPjlYJpdTJ4hVCHjztQm15YO1DHuDWxSVN0zzOZrO/z235siznLuacw0mAiCyMMYfPx195lQe/67R3ebB8B/b/9eLkUpHldrtd29ydSCQSiSD0vgNZlr2LyHMImTbGmM+qql67zvSuEiLyBGhnVlewn90ZMGSV+HKjM4re2YNWiel0eq+U+rH3GU7TNHe73e475MxEIpG4nl/sFCbjdJvargAAAABJRU5ErkJggg==":null},Ee.prototype._addEditDel=function(){for(var n=this,e=0;e<this.TextContents.length;e++){var t,i,r,o,a=this.TextContents[e];!a.hasAdd||a.AnimationEdit||a.NoEdit||(t=a.querySelector(".editDelete"),i=a.querySelector(".editImg"),o=a.querySelector(".delImg"),-1==this.selectIDs.indexOf(a.id)&&this.selectID!=a.id||"visible"!=a.style.visibility?(i&&(i.style.visibility="hidden"),o&&(o.style.visibility="hidden"),t&&(t.style.visibility="hidden")):(t||((t=document.createElement("div")).className="editDelete",t.style.position="absolute",t.style.top=Se.isMobileDevice()?"-30px":"-35px",t.style.display="flex",t.style.marginLeft="0",t.style.backgroundColor="rgba(255,255,255,0.9)",t.style.borderRadius="4px",a.appendChild(t)),i||((i=r=document.createElement("img")).src=Se.isMobileDevice()?this._getAppBase64ByType("edit"):this._getBase64ByType("edit"),r.className="editImg",r.style.cursor="pointer",r.style.width=Se.isMobileDevice()?"16px":"20px",r.style.padding="5px 6px",r.style.display="inline-block",r.style.visibility=this.viewer._editIconVisible?"visible":"hidden",r.addEventListener("click",function(e){var t=e.target.parentNode.previousSibling;t.readOnly=!1,t.focus(),n.selectID!=t.parentNode.id&&(t.parentNode.id,n.setSelectId(t.parentNode.id),t.style.border="1px solid #FFC300"),t.selectionStart=t.selectionEnd=t.value.length,t.style.userSelect="auto",t.style.cursor="default",t.readOnly=!n.enableMove,e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.setMode("NoteEdit")}),t.insertBefore(r,t.firstChild)),o||((o=r=document.createElement("img")).src=Se.isMobileDevice()?this._getAppBase64ByType("delete"):this._getBase64ByType("delete"),r.className="delImg",r.style.cursor="pointer",r.style.width=Se.isMobileDevice()?"16px":"20px",r.style.padding="5px 6px",r.style.display="inline-block",r.style.visibility=this.viewer._deleteIconVisible?"visible":"hidden",r.addEventListener("click",function(e){e=e.target.parentNode.parentNode;n.deleteNoteAnnotation(e.id)}),t.appendChild(r)),this.viewer._editIconVisible?(i.style.visibility=a.style.visibility,t.style.visibility=a.style.visibility):(i.style.visibility="hidden",t.removeChild(i)),this.viewer._deleteIconVisible?(o.style.visibility=a.style.visibility,t.style.visibility=a.style.visibility):(o.style.visibility="hidden",t.removeChild(o)),this.viewer._editIconVisible||this.viewer._deleteIconVisible||(t.style.visibility="hidden")))}},Ee.prototype.EditNote=function(e){for(var t=0;t<this.TextContents.length;t++){var n=this.TextContents[t];!n.hasAdd||n.AnimationEdit||n.NoEdit||n.id==e&&((n=n.childNodes[0]).readOnly=!1,n.focus(),n.selectionStart=n.selectionEnd=n.value.length,n.style.userSelect="auto",n.style.cursor="default",n.readOnly=!this.enableMove,this.setMode("NoteEdit"))}};function Ai(s){g.call(this,s),this.type="OpExplode",this.ExplodeMode="Linear";var e=null,e=s.canvas2D||s.canvas3D,t=new THREE.Object3D,n=new THREE.Object3D,l=(t.add(n),n.visible=!0,n.name="ExplodeObject",n.mode=this.ExplodeMode,this.translateScene=new THREE.Scene,this.TransRotControl=new _(this.viewer.camera,e),this.TransRotControl.setSize(.7),this.TransRotControl.axis=null,this.TransRotControl.setMode("translate"),this.TransRotControl.setSpace("local"),this.TransRotControl.attach(n),this.TransRotControl.children[0].children[0].traverse(function(e){"XY"!=e.name&&"XZ"!=e.name&&"YZ"!=e.name||(e.visible=!1)}),this.offset=new THREE.Vector3,this.changeSelobject(),this.factor=0,this);l.onExplode=!1,this.TransRotControl.addEventListener("objectChange",function(e){var t,n,i,r,o,a;l.MoveObjects&&!e.mouseUp&&(l.MoveObjects.length<2?(l.TransRotControl.position.copy(l.TransRotControl.object.originalPosition),l.TransRotControl.object.position.copy(l.TransRotControl.object.originalPosition),l.TransRotControl.updateMatrixWorld(!0)):(e=l.TransRotControl.object.position.clone().sub(l.TransRotControl.object.originalPosition),n=l.TransRotControl.children[0].children[0].children[1],"Linear"==l.ExplodeMode?(n.matrixAutoUpdate=!0,n.matrixWorldNeedsUpdate=!0):"Normal"==l.ExplodeMode&&(t=l.TransRotControl.scale,t=e.x/t.x,(i=l.TransRotControl.children[0].children[0].children[0].geometry.attributes.position).array[3]=1+t,i.needsUpdate=!0,t<-1?(n.quaternion.set(0,1,0,0),n.position.set(2+t,0,0)):(n.quaternion.set(0,0,0,1),n.position.set(t,0,0)),n.matrixAutoUpdate=!1,n.matrixWorldNeedsUpdate=!1,n.updateMatrix(),n.updateMatrixWorld(!0)),l.TransRotControl.position.copy(l.TransRotControl.object.originalPosition),l.TransRotControl.object.position.copy(l.TransRotControl.object.originalPosition),l.TransRotControl.updateMatrixWorld(!0),(i=[])[0]=l.TransRotControl.position.x,i[1]=l.TransRotControl.position.y,i[2]=l.TransRotControl.position.z,t=l.viewer.modelCoordToClientCoord(i),(n=[])[0]=l.TransRotControl.position.x,n[1]=l.TransRotControl.position.y,n[2]=l.TransRotControl.position.z,i=s.getExplodeMode(),"Linear"==l.ExplodeMode?(r=1,"X"==l.TransRotControl.axis?(n[0]+=e.x,r=0<e.x?1:-1,i!=ve.EXPLODEMODE.X+ve.EXPLODEMODE.SELECTED&&(l.updateNodeMatrix(),l.viewer.setExplodeMode(ve.EXPLODEMODE.X+ve.EXPLODEMODE.SELECTED,0,!1))):"Y"==l.TransRotControl.axis?(n[1]+=e.y,r=0<e.y?1:-1,i!=ve.EXPLODEMODE.Y+ve.EXPLODEMODE.SELECTED&&(l.updateNodeMatrix(),l.viewer.setExplodeMode(ve.EXPLODEMODE.Y+ve.EXPLODEMODE.SELECTED,0,!1))):"Z"==l.TransRotControl.axis&&(n[2]+=e.z,r=0<e.z?1:-1,i!=ve.EXPLODEMODE.Z+ve.EXPLODEMODE.SELECTED)&&(l.updateNodeMatrix(),l.viewer.setExplodeMode(ve.EXPLODEMODE.Z+ve.EXPLODEMODE.SELECTED,0,!1)),o=l.viewer.modelCoordToClientCoord(n),a=Math.abs(o[0]-t[0]+o[1]-t[1]),l.viewer.onExplode((a/=200)*r+l.factor)):"Normal"==l.ExplodeMode&&(r=1,"X"==l.TransRotControl.axis&&(n[0]+=e.x,r=0<e.x?1:-1,i!=ve.EXPLODEMODE.NORMAL+ve.EXPLODEMODE.SELECTED)&&(l.updateNodeMatrix(),l.viewer.setExplodeMode(ve.EXPLODEMODE.NORMAL+ve.EXPLODEMODE.SELECTED,0,!1)),o=l.viewer.modelCoordToClientCoord(n),a=Math.abs(o[0]-t[0]+o[1]-t[1]),l.viewer.onExplode((a/=200)*r+l.factor)),l.onExplode=!0,l.viewer.AnimationEdit&&l.viewer.AnimationEdit.setSelectedBodyNode(l.MoveObjects,"position"),e=0,i&ve.EXPLODEMODE.NORMAL?e=ve.EXPLODEMODE.NORMAL:i&ve.EXPLODEMODE.X?e=ve.EXPLODEMODE.X:i&ve.EXPLODEMODE.Y?e=ve.EXPLODEMODE.Y:i&ve.EXPLODEMODE.Z&&(e=ve.EXPLODEMODE.Z),l.viewer.dispatchEvent({type:"explodeFactor",Factor:40*l.viewer.getExplodeFactor(),axis:e}),l.render()))}),this.TransRotControl.addEventListener("mouseUp",function(){l.changeSelobject()}),this.translateScene.add(this.TransRotControl),this.render()}function yi(l){this.viewer=l,this.pdfInfo={fileName:"temp",colorType:"color",size:"A4",width:297,height:210,orientation:"l",align:0,xAlign:0,yAlign:0,scale:1,xSelMin:0,xSelMax:0,ySelMin:0,ySelMax:0,xLen:0,yLen:0},this.fontSaveArray=[],this.fontArray=[],this.colorArray=[],this.lineStyleArray=[],this.uuidToTextInfo={},this.linePointArray={},this.meshPointArray=[],this.textPointArray=[],this.pointPointArray={},this.totalPointNum=0,this.textInfoArray=[],this.OldLineStyle=null,this.imageInfoArray=[],this.textVersion=1,this.textBufferchunks=null,this.textMaterials=null,this.textObject=null,this.textBufferchunks2=null,this.textFonts=null,this.textFontMap=!1,this.saveTextForPDF=function(e,t){this.textVersion=t,this.textBufferchunks=null,this.textMaterials=null,this.textObject=null,this.textBufferchunks2=null,this.textFonts=null,this.textFontMap=!1,1==this.textVersion?(this.textBufferchunks=e.bufferchunks,this.textMaterials=e.materials,this.textObject=e.object):(this.textBufferchunks2=e.bufferchunks,this.textFonts=e.fonts)},this.getUUidToTextInfo=function(e){var r=this;if(0==this.textFontMap)if(3<this.viewer.modelContentVersion)this.textFontMap=!0;else if(1==this.textVersion){for(var o={},a={},t=0;t<this.textBufferchunks.length;t++)for(var n=0;n<this.textBufferchunks[t].geometries.length;n++){var i,s=this.textBufferchunks[t].geometries[n];"TextGeometry"==s.type&&(i=this.getFontSaveTableId(s.textFont),a[s.uuid]={text:s.text,isChina:s.isChina,fontId:i,colorHex:null,position:null,angle:null})}for(var l=0;l<this.textMaterials.length;l++)o[this.textMaterials[l].uuid]=this.textMaterials[l].color;var d=new THREE.Color;(function e(t){for(var n,i=0;i<t.children.length;i++)t.children[i].children?e(t.children[i]):(d.setHex(parseInt(o[t.children[i].material])),(n=a[t.children[i].geometry])&&(r.uuidToTextInfo[t.children[i].uuid]={text:n.text,isChina:n.isChina,fontId:n.fontId,colorHex:d.clone(),position:t.children[i].position,angle:t.children[i].angle}))})(this.textObject)}else{if(!this.textFonts)return;for(var c={},h=0;h<this.textFonts.length;h++)c[this.textFonts[h].uuid]={uuid:this.textFonts[h].uuid,bigName:this.textFonts[h].bigName,name:this.textFonts[h].name,size:this.textFonts[h].size,width:this.textFonts[h].width,style:this.textFonts[h].style,weight:this.textFonts[h].weight};for(var u=0;u<this.textBufferchunks2.length;u++)for(var p=0;p<this.textBufferchunks2[u].geometries.length;p++){var f,m=this.textBufferchunks2[u].geometries[p];"TextGeometry"==m.type&&(f=c[m.textFont],f=this.getFontSaveTableId(f||m.textFont),this.uuidToTextInfo[m.uuid]={text:m.text,isChina:m.isChina,fontId:f,colorHex:null,position:new THREE.Vector3(m.position.x,m.position.y,m.position.z),angle:m.angle,isMirroredInX:m.isMirroredInX,isMirroredInY:m.isMirroredInY})}}return this.textFontMap=!0,this.uuidToTextInfo[e]},this.setPDFInfo=function(e,t,n,i,r,o){var a,s;this.viewer.is2DModel&&(s=this.viewer.getCameraInfo(),a=new THREE.Vector3(s.up.x,s.up.y,s.up.z),this.rad=-a.angleTo(new THREE.Vector3(0,1,0)),this.matrixWorld=(new THREE.Matrix4).makeRotationAxis(new THREE.Vector3(0,0,1),this.rad),this.transPosition=new THREE.Vector3(s.target.x,s.target.y,0),this.totalPointNum=0,this.pdfInfo.fileName=e||"temp",this.pdfInfo.size=t||"A4",this.pdfInfo.orientation=n||"l",this.pdfInfo.colorType=i||"color",a=new THREE.Matrix4,(s=new THREE.Matrix4).makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),a.premultiply(s),a.premultiply(this.matrixWorld),s.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),a.premultiply(s),e=new THREE.Vector3,t=new THREE.Vector3,"view"==r?(n=l.renderer.getPixelRatio(),i=this.viewer.renderer.domElement.width/n,s=this.viewer.renderer.domElement.height/n,n=this.viewer.clientCoordToModelCoord([0,0]),e.x=n[0],e.y=n[1],n=this.viewer.clientCoordToModelCoord([i,s]),t.x=n[0],t.y=n[1],e.applyMatrix4(a),t.applyMatrix4(a),this.pdfInfo.xSelMin=(e.x>t.x?t:e).x,this.pdfInfo.xSelMax=(e.x<t.x?t:e).x,this.pdfInfo.ySelMin=(e.y>t.y?t:e).y,this.pdfInfo.ySelMax=(e.y<t.y?t:e).y):"select"==r?(o[0]!=o[2]&&o[1]!=o[3]||(o[2]+=.01,o[3]+=.01),i=this.viewer.clientCoordToModelCoord([o[0],o[1]]),e.x=i[0],e.y=i[1],s=this.viewer.clientCoordToModelCoord([o[2],o[3]]),t.x=s[0],t.y=s[1],e.applyMatrix4(a),t.applyMatrix4(a),this.pdfInfo.xSelMin=(e.x>t.x?t:e).x,this.pdfInfo.xSelMax=(e.x<t.x?t:e).x,this.pdfInfo.ySelMin=(e.y>t.y?t:e).y,this.pdfInfo.ySelMax=(e.y<t.y?t:e).y):(this.textflag=!0,n=new THREE.Vector3(0,0,0),r=new THREE.Vector3(0,0,0),this.getBoundingBox(n,r,this.textflag),0<(i=this.calcTextRect()).length&&(this.textflag?(this.textflag=!1,n.x=i[0],n.y=i[1],r.x=i[2],r.y=i[3]):(i[0]<n.x&&(n.x=i[0]),i[1]<n.y&&(n.y=i[1]),i[2]>r.x&&(r.x=i[2]),i[3]>r.y&&(r.y=i[3]))),this.pdfInfo.xSelMin=n.x-.001,this.pdfInfo.ySelMin=n.y-.001,this.pdfInfo.xSelMax=r.x+.001,this.pdfInfo.ySelMax=r.y+.001),this.setPaperSize(this.pdfInfo.size,this.pdfInfo.orientation),this.setAlign(),this.drawPDFInfo())},this.getBoundingBox=function(e,t,F){this.viewer.ndsModel.setDirty();for(var n=0,N=this.viewer.ndsModel.meshManager.getNumInstancedMeshes();n<N;++n){var j=this.viewer.ndsModel.meshManager.getInstancedMesh(n);j&&(j.geometry.updateModelMatrix=!0)}for(var _=this.viewer.ndsModel.getMeshSets(),i=[],r=[],o=!1,a=0;a<_.length;++a)i.push(a);for(var s=0,V=i.length;s<V;++s){for(var l=_[i[s]],d=0,k=l.getNumMeshes();d<k;++d){var c=l.getMesh(d);if(c){var h=c.geometry;if(!(h.bufferLength<=0)){var u=new THREE.Matrix4,p=new THREE.Matrix4;if(0<c.instancedCount)for(var f=0;f<c.instancedCount;f++){c.matrixWorlds?u.fromArray(c.matrixWorlds,16*f):c.geometry.attributes.modelMatrixAttrib&&u.fromArray(c.geometry.attributes.modelMatrixAttrib.array,16*f),p.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),u.premultiply(p),u.premultiply(this.matrixWorld),p.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),u.premultiply(p);var m=h.boundingBox.min.clone().applyMatrix4(u),g=h.boundingBox.max.clone().applyMatrix4(u);this.textflag?(this.textflag=!1,e.x=m.x,e.y=m.y,t.x=g.x,t.y=g.y):(m.x<e.x&&(e.x=m.x),m.y<e.y&&(e.y=m.y),g.x>t.x&&(t.x=g.x),g.y>t.y&&(t.y=g.y))}else{u.copy(c.matrixWorld),p.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),u.premultiply(p),u.premultiply(this.matrixWorld),p.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),u.premultiply(p);var v=h.boundingBox.min.clone().applyMatrix4(u),A=h.boundingBox.max.clone().applyMatrix4(u);this.textflag?(this.textflag=!1,e.x=v.x,e.y=v.y,t.x=A.x,t.y=A.y):(v.x<e.x&&(e.x=v.x),v.y<e.y&&(e.y=v.y),A.x>t.x&&(t.x=A.x),A.y>t.y&&(t.y=A.y))}}}}for(var y=0,U=l.getNumTexts();y<U;++y){var E=l.getText(y);if(E)if(E.geometry&&3<this.viewer.modelContentVersion){var M=new THREE.Matrix4,w=new THREE.Matrix4;M.copy(E.matrixWorld),w.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),M.premultiply(w),M.premultiply(this.matrixWorld),w.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),M.premultiply(w),E.geometry.boundingBox?(w=E.geometry.boundingBox.min.clone().applyMatrix4(M),M=E.geometry.boundingBox.max.clone().applyMatrix4(M),this.textflag?(this.textflag=!1,e.x=w.x,e.y=w.y,t.x=M.x,t.y=M.y):(w.x<e.x&&(e.x=w.x),w.y<e.y&&(e.y=w.y),M.x>t.x&&(t.x=M.x),M.y>t.y&&(t.y=M.y))):console.log("boundingBox is null")}else if(E.geometry){var b=new THREE.Vector3(0,0,0),x=this.getUUidToTextInfo(E.geometry.uuid),G={bigName:this.fontSaveArray[x.fontId].bigName,name:this.fontSaveArray[x.fontId].name,size:this.fontSaveArray[x.fontId].size,style:this.fontSaveArray[x.fontId].style,weight:this.fontSaveArray[x.fontId].weight,width:this.fontSaveArray[x.fontId].width},I=new THREE.Matrix4,T=new THREE.Matrix4,z=new THREE.Vector3,W=new THREE.Quaternion,S=new THREE.Vector3;if(0<E.instancedCount)for(var B=0;B<E.instancedCount;B++)I.fromArray(E.matrixWorlds,16*B),I.decompose(z,W,S),T.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),I.premultiply(T),I.premultiply(this.matrixWorld),T.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),I.premultiply(T),b.set(0,0,0),b.applyMatrix4(I),this.calcRect(x.text,x.angle,G,b,r,o,S.x),o=!0;else I.copy(E.matrixWorld),I.decompose(z,W,S),T.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),I.premultiply(T),I.premultiply(this.matrixWorld),T.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),I.premultiply(T),b.applyMatrix4(I),this.calcRect(x.text,x.angle,G,b,r,o,S.x),o=!0}}}0<r.length&&(this.textflag?(this.textflag=!1,e.x=r[0],e.y=r[1],t.x=r[2],t.y=r[3]):(r[0]<e.x&&(e.x=r[0]),r[1]<e.y&&(e.y=r[1]),r[2]>t.x&&(t.x=r[2]),r[3]>t.y&&(t.y=r[3])));for(var Y=this.viewer.ndsModel.getLineSegmentsSet(),P=0,X=Y.getNumLineSegments();P<X;++P){var C=Y.getLineSegmentsWithState(P);if(C){var R=C.lineSegments;if(R){var O=R.geometry;if(!(O.bufferLength<=0)){var L=new THREE.Matrix4,D=new THREE.Matrix4;if(L.copy(R.matrixWorld),D.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),L.premultiply(D),L.premultiply(this.matrixWorld),D.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),L.premultiply(D),O.isPoints&&O.index)for(var H=new THREE.Vector3,Q=O.getAttribute("position"),Z=O.drawRange.start,q=O.drawRange.start+O.drawRange.count;Z<q;Z+=1)H.fromBufferAttribute(Q,O.index.getX(Z)),H.applyMatrix4(L),this.textflag?(this.textflag=!1,e.x=H.x,e.y=H.y,t.x=H.x,t.y=H.y):(H.x<e.x&&(e.x=H.x),H.y<e.y&&(e.y=H.y),H.x>t.x&&(t.x=H.x),H.y>t.y&&(t.y=H.y));else{var R=O.boundingBox.min.clone().applyMatrix4(L),D=O.boundingBox.max.clone().applyMatrix4(L);this.textflag?(this.textflag=!1,e.x=R.x,e.y=R.y,t.x=D.x,t.y=D.y):(R.x<e.x&&(e.x=R.x),R.y<e.y&&(e.y=R.y),D.x>t.x&&(t.x=D.x),D.y>t.y&&(t.y=D.y)),C.lineStyle&&(R=C.lineStyle.textMesh)&&(R.geometry.computeBoundingBox(),D=R.geometry.boundingBox.min.clone().applyMatrix4(L),C=R.geometry.boundingBox.max.clone().applyMatrix4(L),this.textflag?(this.textflag=!1,e.x=D.x,e.y=D.y,t.x=C.x,t.y=C.y):(D.x<e.x&&(e.x=D.x),D.y<e.y&&(e.y=D.y),C.x>t.x&&(t.x=C.x),C.y>t.y&&(t.y=C.y)))}}}}}},this.setPaperSize=function(e,t){switch(e){case"A5":var n=[210,148];this.pdfInfo.width=n[0],this.pdfInfo.height=n[1];break;case"A4":n=[297,210];this.pdfInfo.width=n[0],this.pdfInfo.height=n[1];break;case"A3":n=[420,297];this.pdfInfo.width=n[0],this.pdfInfo.height=n[1];break;case"A2":n=[594,420];this.pdfInfo.width=n[0],this.pdfInfo.height=n[1];break;case"A1":n=[841,594];this.pdfInfo.width=n[0],this.pdfInfo.height=n[1];break;case"A0":n=[1189,841];this.pdfInfo.width=n[0],this.pdfInfo.height=n[1];break;default:n=[297,210];this.pdfInfo.width=n[0],this.pdfInfo.height=n[1]}"l"!=t&&(e=this.pdfInfo.width,this.pdfInfo.width=this.pdfInfo.height,this.pdfInfo.height=e)},this.getPaperSize=function(){return["A5","A4","A3","A2","A1","A0"]},this.setAlign=function(){this.pdfInfo.xLen=this.pdfInfo.xSelMax-this.pdfInfo.xSelMin,this.pdfInfo.yLen=this.pdfInfo.ySelMax-this.pdfInfo.ySelMin;var e=this.pdfInfo.xLen/this.pdfInfo.yLen;this.pdfInfo.height,this.pdfInfo.width;e>this.pdfInfo.width/this.pdfInfo.height?(this.pdfInfo.xAlign=.02*this.pdfInfo.width,this.pdfInfo.yAlign=(this.pdfInfo.height-(this.pdfInfo.width-2*this.pdfInfo.xAlign)/e)/2,this.pdfInfo.scale=(this.pdfInfo.height-2*this.pdfInfo.yAlign)/this.pdfInfo.yLen):(this.pdfInfo.yAlign=.02*this.pdfInfo.height,this.pdfInfo.xAlign=(this.pdfInfo.width-(this.pdfInfo.height-2*this.pdfInfo.yAlign)*e)/2,this.pdfInfo.scale=(this.pdfInfo.width-2*this.pdfInfo.xAlign)/this.pdfInfo.xLen)},this.normalize=function(e){e.x=(e.x-this.pdfInfo.xSelMin)/this.pdfInfo.xLen,e.y=(e.y-this.pdfInfo.ySelMin)/this.pdfInfo.yLen},this.convertToPDFCood=function(e,t,n){var i,r,o=this.pdfInfo.width-2*this.pdfInfo.xAlign,a=this.pdfInfo.height-2*this.pdfInfo.yAlign,s=e.x*o+this.pdfInfo.xAlign,e=(1-e.y)*a+this.pdfInfo.yAlign;return t&&(i=t.x*o+this.pdfInfo.xAlign,r=(1-t.y)*a+this.pdfInfo.yAlign),n?[s,e,i,r,n.x*o+this.pdfInfo.xAlign,(1-n.y)*a+this.pdfInfo.yAlign]:t?[s,e,i,r]:[s,e]},this.colorTest=function(e){16777215==e.getHex()&&e.setHex(16777215-e.getHex())},this.getFontSaveTableId=function(e){for(var t,n=0;n<this.fontSaveArray.length;n++)if((t=this.fontSaveArray[n]).name==e.name&&t.bigName==e.bigName&&t.style==e.style&&t.weight==e.weight&&Math.abs(t.size-e.size)<1e-8&&Math.abs(t.width-e.width)<1e-8)return n;return this.fontSaveArray.push(e),this.fontSaveArray.length-1},this.getFontTableId=function(e){for(var t,n=0;n<this.fontArray.length;n++)if((t=this.fontArray[n]).name==e.name&&t.bigName==e.bigName&&t.style==e.style&&t.weight==e.weight&&Math.abs(t.size-e.size)<1e-8&&Math.abs(t.width-e.width)<1e-8)return n;return this.fontArray.push({bigName:e.bigName,name:e.name,style:e.style,weight:e.weight,size:e.size,width:e.width}),this.fontArray.length-1},this.getColorTableId=function(e){this.colorTest(e);for(var t=e.getHexString(),n=0;n<this.colorArray.length;n++)if(this.colorArray[n]==t)return n;return this.colorArray.push(t),this.colorArray.length-1},this.getOldLineStyleData=function(e){switch(parseInt(e)){case ve.DASHTYPE.DASH:return[12,-3];case ve.DASHTYPE.DASHSPACE:return[12,-18];case ve.DASHTYPE.LONGDASH_DOT:return[24,-3,.5,-3];case ve.DASHTYPE.LONGDASH_DOUBLEDOT:return[24,-3,.5,-3,.5,-3];case ve.DASHTYPE.LONGDASH_TRIPLEDOT:return[24,-3,.5,-3,.5,-3,.5,-3];case ve.DASHTYPE.DOT0:return[.5,-3];case ve.DASHTYPE.LONGDASH_SHORTDASH:return[24,-3,6,-3];case ve.DASHTYPE.LONGDASH_DOUBLESHORTDASH:return[24,-3,6,-3,6,-3];case ve.DASHTYPE.DASH_DOT:return[12,-3,.5,-3];case ve.DASHTYPE.DOUBLEDASH_DOT:return[12,-3,12,-3,.5,-3];case ve.DASHTYPE.DASH_DOUBLEDOT:return[12,-3,.5,-3,.5,-3];case ve.DASHTYPE.DOUBLEDASH_DOUBLEDOT:return[12,-3,12,-3,.5,-3,.5,-3];case ve.DASHTYPE.DASH_TRIPLEDOT:return[12,-3,.5,-3,.5,-3,.5,-3];case ve.DASHTYPE.DOUBLEDASH_TRIPLEDOT:return[12,-3,12,-3,.5,-3,.5,-3,.5,-3];case ve.DASHTYPE.BATTING:return[12,-3,.5,-3];case ve.DASHTYPE.BORDER:return[12,-3,12,-3,.5,-3];case ve.DASHTYPE.BORDER2:return[6,-3,6,-3,.5,-3];case ve.DASHTYPE.BORDERX2:return[24,-3,24,-3,.5,-3];case ve.DASHTYPE.CENTER:return[24,-6,6,-6];case ve.DASHTYPE.CENTER2:return[12,-3,3,-3];case ve.DASHTYPE.CENTERX2:return[48,-6,6,-6];case ve.DASHTYPE.DASHDOT:return[12,-3,.5,-3];case ve.DASHTYPE.DASHDOT2:return[6,-1.5,.5,-1.5];case ve.DASHTYPE.DASHDOTX2:return[24,-6,.5,-6];case ve.DASHTYPE.DASHED:return[12,-6];case ve.DASHTYPE.DASHED2:return[6,-3];case ve.DASHTYPE.DASHEDX2:return[24,-12,.5,-12,.5,-12];case ve.DASHTYPE.DIVIDE:return[12,-6,.5,-6,.5,-6];case ve.DASHTYPE.DIVIDE2:return[6,-3,.5,-3,.5,-3];case ve.DASHTYPE.DIVIDEX2:return[24,-12,.5,-12,.5,-12];case ve.DASHTYPE.DOT:return[.5,-6];case ve.DASHTYPE.DOT2:return[.5,-3];case ve.DASHTYPE.DOTX2:return[.5,-12];case ve.DASHTYPE.FENCELINE1:case ve.DASHTYPE.FENCELINE2:case ve.DASHTYPE.GAS_LINE:return[12,-3,.5,-3];case ve.DASHTYPE.HIDDEN:return[6,-3];case ve.DASHTYPE.HIDDEN2:return[3,-1.5];case ve.DASHTYPE.HIDDENX2:return[12,-6];case ve.DASHTYPE.HOT_WATER_SUPPLY:return[12,-3,.5,-3];case ve.DASHTYPE.JIS_02_07:return[.84,-.51];case ve.DASHTYPE.JIS_02_10:return[1.2,-.6];case ve.DASHTYPE.JIS_02_12:return[1.44,-.66];case ve.DASHTYPE.JIS_02_20:return[2.4,-.78];case ve.DASHTYPE.JIS_02_40:return[4.8,-1.5];case ve.DASHTYPE.JIS_08_11:return[11,-3,.7,-3];case ve.DASHTYPE.JIS_08_15:return[15,-3,.7,-3];case ve.DASHTYPE.JIS_08_25:return[25,-3,.7,-3];case ve.DASHTYPE.JIS_08_37:return[37,-1,.7,-1];case ve.DASHTYPE.JIS_08_50:return[50,-1.4,.7,-1.4];case ve.DASHTYPE.JIS_09_08:return[8,-.9,.5,-.9,.5,-.9];case ve.DASHTYPE.JIS_09_15:return[15,-.9,.5,-.9,.5,-.9];case ve.DASHTYPE.JIS_09_29:return[29,-.9,.5,-.9,.5,-.9];case ve.DASHTYPE.JIS_09_50:return[50,-.9,.5,-.9,.5,-.9];case ve.DASHTYPE.PHANTOM:return[31,-6,6,-6,6,-6];case ve.DASHTYPE.PHANTOM2:return[15,-3,3,-3,3,-3];case ve.DASHTYPE.PHANTOMX2:return[60,-12,12,-12,12,-12];default:return[12,-3,.5,-3]}},this.getOldLineStyleTableId=function(e){if(e<1||998<e)return-1;for(var t=0;t<this.lineStyleArray.length;t++)if(this.lineStyleArray[t].lineTypeId==e)return t;return this.lineStyleArray.push({lineTypeId:e,data:this.getOldLineStyleData(e),scale:1}),this.lineStyleArray.length-1},this.getLineStyleTableId=function(e,t){for(var n=0;n<this.lineStyleArray.length;n++)if(this.lineStyleArray[n].lineTypeId==e&&Math.abs(this.lineStyleArray[n].scale-t)<1e-8)return n;return this.lineStyleArray.push({lineTypeId:e,data:this.viewer.lineTypes.getLineStyleArray(e),scale:t}),this.lineStyleArray.length-1},this.drawPDFInfo=function(){this.viewer.selectionManager.clearSelection(),this.viewer.ndsModel.setDirty();this.drawMesh();var e=this.drawLine();if(this.viewer.pmiObject)for(var t=this.viewer.ndsModel.getLayerBodies(this.viewer.ndsModel.rootBodyNode),n=0,i=t.length;n<i;++n){var r=t[n];if(r.visible&&r.pmiuuid)for(var o=0;o<r.pmiuuid.length;++o)this.drawText(r.pmiuuid[o])}for(var a=this.viewer.SDFMaker.GetLines(),s=new THREE.Vector3,l=new THREE.Vector3,d=0;d<a.length;d++)for(var c=new THREE.Color(a[d].material.color.getHex()),h=this.getColorTableId(c),u=a[d].geometry.vertices,p=0;p<u.length;p+=2){s.copy(u[p]),l.copy(u[p+1]),s.applyMatrix4(a[d].matrixWorld),l.applyMatrix4(a[d].matrixWorld),this.normalize(s),this.normalize(l);var f,m,g,v,A=this.clipLine(s,l);0<A.length&&(f=(A=this.convertToPDFCood(A[0],A[1]))[0],m=A[1],g=A[2],A=A[3],(v=this.linePointArray[e])||(v=new Array,this.linePointArray[e]=v),v.push(f,m,g,A,h,-1),this.totalPointNum+=6)}},this.drawMesh=function(){for(var e=0,t=0,n=this.viewer.ndsModel.meshManager.getNumInstancedMeshes();t<n;++t){var i=this.viewer.ndsModel.meshManager.getInstancedMesh(t);i&&(i.geometry.updateModelMatrix=!0)}for(var r=this.viewer.ndsModel.getMeshSets(),o=[],a=0;a<r.length;++a)o.push(a);this.viewer.ndsModel.sortMeshSets(o,this.viewer.camera);for(var s=0,l=o.length;s<l;++s){for(var d=r[o[s]],c=0,h=d.getNumMeshes();c<h;++c){var u=d.getMesh(c);if(u&&u.geometry){var p=new THREE.Matrix4,f=new THREE.Matrix4;if(0<u.instancedCount)for(var m=0;m<u.instancedCount;m++)u.matrixWorlds?p.fromArray(u.matrixWorlds,16*m):u.geometry.attributes.modelMatrixAttrib&&p.fromArray(u.geometry.attributes.modelMatrixAttrib.array,16*m),f.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),p.premultiply(f),p.premultiply(this.matrixWorld),f.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),p.premultiply(f),this.draw(3,u.geometry,u.material,e,p);else p.copy(u.matrixWorld),f.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),p.premultiply(f),p.premultiply(this.matrixWorld),f.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),p.premultiply(f),u.material&&u.material.map&&u.material.map.isTexture?this.draw(6,u.geometry,u.material,e,p):this.draw(3,u.geometry,u.material,e,p);e++}}for(var g=0,v=d.getNumTexts();g<v;++g){var A=d.getText(g);if(A&&A.geometry){var y=new THREE.Vector3(0,0,0),E=new THREE.Matrix4,M=new THREE.Matrix4,w=new THREE.Vector3,b=new THREE.Quaternion,x=new THREE.Vector3,I=new THREE.Euler;if(3<this.viewer.modelContentVersion)this.drawMeshText(A,e);else if(0<A.instancedCount)for(var T=0;T<A.instancedCount;T++)E.fromArray(A.matrixWorlds,16*T),E.decompose(w,b,x),M.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),E.premultiply(M),E.premultiply(this.matrixWorld),M.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),E.premultiply(M),y.set(0,0,0),y.applyMatrix4(E),I.setFromQuaternion(b),this.drawText(A.geometry.uuid,A.material.uniforms.diffuse.value,y,x.x,I.z);else E.copy(A.matrixWorld),E.decompose(w,b,x),M.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),E.premultiply(M),E.premultiply(this.matrixWorld),M.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),E.premultiply(M),y.applyMatrix4(E),I.setFromQuaternion(b),this.drawText(A.geometry.uuid,A.material.uniforms.diffuse.value,y,x.x,I.z)}}}return e},this.drawLine=function(){for(var e=this.viewer.ndsModel.getLineSegmentsSet(),t=0,n=0,i=e.getNumLineSegments();n<i;++n){var r=e.getLineSegmentsWithState(n),o=r.lineStyle,a=r.lineSegments;if(a&&a.geometry){var s=a.geometry.geomType?3-a.geometry.geomType:2,l=new THREE.Matrix4,d=new THREE.Matrix4;if(0<a.instancedCount)for(var c=0;c<a.instancedCount;c++)l.fromArray(a.matrixWorlds,16*c),d.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),l.premultiply(d),l.premultiply(this.matrixWorld),d.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),l.premultiply(d),this.draw(s,a.geometry,a.material,t,l),3<this.viewer.modelContentVersion&&o&&this.drawMeshText(o,t,l);else l.copy(a.matrixWorld),d.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),l.premultiply(d),l.premultiply(this.matrixWorld),d.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),l.premultiply(d),this.draw(s,a.geometry,a.material,t,l),3<this.viewer.modelContentVersion&&o&&this.drawMeshText(o,t,l);t++}}return t},this.draw=function(e,t,n,i,r){var o=t.getAttribute("position");if(o&&t.index){for(var F,N,j,_,V,k,U,G,a,s,l,d=new THREE.Vector3,c=new THREE.Vector3,z=new THREE.Vector3,W=e,Y=new THREE.Color(n.color.getHex()),h=this.getColorTableId(Y),u=t.drawRange.start,X=t.drawRange.start+t.drawRange.count;u<X;u+=W)if(1==e){var p=t.index.getX(u);d.fromBufferAttribute(o,p),d.applyMatrix4(r),this.normalize(d),d.x<0||1<d.x||d.y<0||1<d.y||(f=(m=this.convertToPDFCood(d))[0],m=m[1],(M=this.pointPointArray[h])||(M=new Array,this.pointPointArray[h]=M),M.push(f,m),this.totalPointNum+=2)}else if(2==e){p=t.index.getX(u),F=t.index.getX(u+1),d.fromBufferAttribute(o,p),c.fromBufferAttribute(o,F),d.applyMatrix4(r),c.applyMatrix4(r),this.normalize(d),this.normalize(c);var f,m,g,v,A,y,E,M=this.clipLine(d,c);0<M.length&&(m=(f=this.convertToPDFCood(M[0],M[1]))[0],g=f[1],v=f[2],A=f[3],y=-1,null!=n.uniforms&&null!=n.uniforms.lineTypeId?y=this.getLineStyleTableId(n.uniforms.lineTypeId.value,n.uniforms.lineScale.value):null!=n.uniforms&&null!=n.uniforms.lineStyle&&(y=this.getOldLineStyleTableId(n.uniforms.lineStyle.value)),(E=this.linePointArray[i])||(E=new Array,this.linePointArray[i]=E),E.push(m,g,v,A,h,y),this.totalPointNum+=6)}else if(3==e){p=t.index.getX(u),F=t.index.getX(u+1),E=t.index.getX(u+2),d.fromBufferAttribute(o,p),c.fromBufferAttribute(o,F),z.fromBufferAttribute(o,E),d.applyMatrix4(r),c.applyMatrix4(r),z.applyMatrix4(r),this.normalize(d),this.normalize(c),this.normalize(z);for(var Q=this.clipTriangle(d,c,z),w=0;w<Q.length;w+=3){var b=this.convertToPDFCood(Q[w],Q[w+1],Q[w+2]),Z=b[0],q=b[1],K=b[2],J=b[3],$=b[4],b=b[5];this.meshPointArray.push(Z,q,K,J,$,b,h),this.totalPointNum+=7}}else 6==e&&(g=new THREE.Box3,d.fromBufferAttribute(o,t.index.getX(u)),d.applyMatrix4(r),g.expandByPoint(d),d.fromBufferAttribute(o,t.index.getX(u+1)),d.applyMatrix4(r),g.expandByPoint(d),d.fromBufferAttribute(o,t.index.getX(u+2)),d.applyMatrix4(r),g.expandByPoint(d),d.fromBufferAttribute(o,t.index.getX(u+3)),d.applyMatrix4(r),g.expandByPoint(d),d.fromBufferAttribute(o,t.index.getX(u+4)),d.applyMatrix4(r),g.expandByPoint(d),d.fromBufferAttribute(o,t.index.getX(u+5)),d.applyMatrix4(r),g.expandByPoint(d),v=g.min.clone(),A=g.max.clone(),this.normalize(v),this.normalize(A),y=v.clone(),(a=A.clone()).x<0||1<y.x||a.y<0||1<y.y||(y.x<0&&(y.x=0),y.y<0&&(y.y=0),1<a.x&&(a.x=1),1<a.y&&(a.y=1),l=n.map.image,N=(y.x-v.x)/(A.x-v.x)*l.width,j=(y.y-v.y)/(A.y-v.y)*l.height,_=(a.x-v.x)/(A.x-v.x)*l.width,V=(a.y-v.y)/(A.y-v.y)*l.height,k=(a=this.convertToPDFCood(y,a))[0],U=a[1],G=a[2],a=a[3],(s=document.createElement("canvas")).width=_-N,s.height=V-j,s.getContext("2d").drawImage(l,N,j,s.width,s.height,0,0,s.width,s.height),l=s.toDataURL(),this.imageInfoArray.push({data:l,pos:[k,a,G,U],refs:[N,j,_,V]})));if(6!=e&&(this.viewer.modelContentVersion<=3&&this.viewer.lineTypes&&null!=n.uniforms&&null!=n.uniforms.lineTypeId)){var Y=this.viewer.lineTypes.getLineStyleInfoForPDF(t,n.uniforms.lineTypeId.value,n.uniforms.lineScale.value,n.color),ee=Y.styleText;if(ee){var te,x=new THREE.Vector3;for(te in ee)for(var I=ee[te],T={name:I.fontName,size:I.size,isShx:I.isShx,style:"normal",weight:"normal",width:1},S=0;S<I.data.length;S+=3){x.set(I.data[S],I.data[S+1],0),x.applyMatrix4(r),T.size=I.size;for(var B=this.clipText2(te,I.data[S+2],T,x,0<I.shapeId),P=0;P<B.length;P++){T.name=B[P].font,0<I.shapeId&&(T.size=4.5*I.size),x.set(B[P].pos[0],B[P].pos[1],0);var ne=this.convertToPDFCood(x),ie=ne[0],ne=ne[1],re=this.getFontTableId(T);this.addTextInfoArray(B[P].char,I.data[S+2],h,re,ie,ne,I.shapeId)}}}var C=Y.stylePoint;if(C)for(var oe,ae,se,R=new THREE.Vector3,O=0;O<C.length;O+=3)R.set(C[O+0],C[O+1],C[O+2]),R.applyMatrix4(r),this.normalize(R),0<R.x&&R.x<1&&0<R.y&&R.y<1&&(oe=(ae=this.convertToPDFCood(R))[0],ae=ae[1],(se=this.pointPointArray[h])||(se=new Array,this.pointPointArray[h]=se),se.push(oe,ae),this.totalPointNum+=2);var L=Y.styleLine;if(L)for(var le=new THREE.Vector3,de=new THREE.Vector3,D=0;D<L.length;D+=6){le.set(L[D+0],L[D+1],L[D+2]),de.set(L[D+3],L[D+4],L[D+5]),le.applyMatrix4(r),de.applyMatrix4(r),this.normalize(le),this.normalize(de);var ce,he,ue,pe,H=this.clipLine(le,de);0<H.length&&(ce=(H=this.convertToPDFCood(H[0],H[1]))[0],he=H[1],ue=H[2],H=H[3],(pe=this.linePointArray[i])||(pe=new Array,this.linePointArray[i]=pe),pe.push(ce,he,ue,H,h,-1),this.totalPointNum+=6)}}}},this.drawMeshText=function(e,t,n){var i;n?e&&(i=e.textMesh,e.textMesh&&this.drawMeshTextGeom(i.isShx?2:3,i.geometry,i.material,t,n),(i=e.pointMesh)&&this.drawMeshTextGeom(1,i.geometry,i.material,t,n),i=e.lineMesh)&&!i.geometry.isTtfWire&&this.drawMeshTextGeom(2,i.geometry,i.material,t,n):(i=new THREE.Matrix4,n=new THREE.Matrix4,i.copy(e.matrixWorld),n.makeTranslation(-this.transPosition.x,-this.transPosition.y,-this.transPosition.z),i.premultiply(n),i.premultiply(this.matrixWorld),n.makeTranslation(this.transPosition.x,this.transPosition.y,this.transPosition.z),i.premultiply(n),this.drawMeshTextGeom("shxLoad"==e.geometry.textLoad?2:3,e.geometry,e.material,t,i))},this.drawMeshTextGeom=function(e,t,n,i,r){var o=t.getAttribute("position");if(o&&t.index)for(var a,s=new THREE.Vector3,l=new THREE.Vector3,d=new THREE.Vector3,c=e,n=new THREE.Color((n.color||n.uniforms.diffuse.value).getHex()),h=this.getColorTableId(n),u=t.drawRange.start,p=t.drawRange.start+t.drawRange.count;u<p;u+=c)if(1==e){var f,m=t.index.getX(u);s.fromBufferAttribute(o,m),s.applyMatrix4(r),this.normalize(s),s.x<0||1<s.x||s.y<0||1<s.y||(M=(g=this.convertToPDFCood(s))[0],g=g[1],(f=this.pointPointArray[h])||(f=new Array,this.pointPointArray[h]=f),f.push(M,g),this.totalPointNum+=2)}else if(2==e){m=t.index.getX(u),a=t.index.getX(u+1),s.fromBufferAttribute(o,m),l.fromBufferAttribute(o,a),s.applyMatrix4(r),l.applyMatrix4(r),this.normalize(s),this.normalize(l);var g,v,A,y,E,M=this.clipLine(s,l);0<M.length&&(v=(g=this.convertToPDFCood(M[0],M[1]))[0],A=g[1],y=g[2],E=g[3],(f=this.linePointArray[i])||(f=new Array,this.linePointArray[i]=f),f.push(v,A,y,E,h,-1),this.totalPointNum+=6)}else if(3==e){m=t.index.getX(u),a=t.index.getX(u+1),v=t.index.getX(u+2),s.fromBufferAttribute(o,m),l.fromBufferAttribute(o,a),d.fromBufferAttribute(o,v),s.applyMatrix4(r),l.applyMatrix4(r),d.applyMatrix4(r),this.normalize(s),this.normalize(l),this.normalize(d);for(var w=this.clipTriangle(s,l,d),b=0;b<w.length;b+=3){var x=this.convertToPDFCood(w[b],w[b+1],w[b+2]),I=x[0],T=x[1],S=x[2],B=x[3],P=x[4],x=x[5];this.meshPointArray.push(I,T,S,B,P,x,h),this.totalPointNum+=7}}},this.drawText=function(e,t,n,i,r){var o=this.getUUidToTextInfo(e);if(o)for(var a=n||(new THREE.Vector3).fromArray(o.position),e=new THREE.Color(t||o.colorHex),n=i?Math.abs(i):1,s=r||0,l=this.getColorTableId(e),d={bigName:this.fontSaveArray[o.fontId].bigName,name:this.fontSaveArray[o.fontId].name,size:this.fontSaveArray[o.fontId].size*n,style:this.fontSaveArray[o.fontId].style,weight:this.fontSaveArray[o.fontId].weight,width:this.fontSaveArray[o.fontId].width},t=this.viewer.SDFMaker.RegText(o.text),c=(o.text=t.text,this.clipText2(o.text,this.viewer.modelContentVersion<2?o.angle:this.rad+s,d,a)),h=0;h<c.length;h++){d.name=c[h].font,d.width=c[h].width,a.set(c[h].pos[0],c[h].pos[1],0);var u=this.getFontTableId(d),p=this.convertToPDFCood(a),f=p[0],p=p[1];this.addTextInfoArray(c[h].char,this.viewer.modelContentVersion<2?o.angle:this.rad+s,l,u,f,p)}},this.addTextInfoArray=function(e,t,n,i,r,o,a){var s={},e=(s.text=e,s.data=[2,n,i],.001<Math.abs(+t)&&(s.angle=parseFloat((180*(0<t?2*Math.PI-t:Math.abs(t))/Math.PI).toFixed(8))),0<a&&(s.shapeId=a.toString()),this.getTextInfoId(s)),n=this.textPointArray[e];n||(n=new Array,this.textPointArray[e]=n),n.push(parseFloat(r.toFixed(8)),parseFloat(o.toFixed(8))),this.totalPointNum+=2},this.getTextInfoId=function(e){for(var t=0;t<this.textInfoArray.length;t++)if(this.textInfoArray[t].text==e.text&&this.textInfoArray[t].data[1]==e.data[1]&&this.textInfoArray[t].data[2]==e.data[2]&&this.textInfoArray[t].angle==e.angle&&this.textInfoArray[t].shapdId==e.shapdId)return this.textInfoArray[t].data[0]+=2,t;return this.textInfoArray.push(e),this.textInfoArray.length-1},this.clearArray=function(){this.linePointArray={},this.meshPointArray=[],this.textPointArray=[],this.pointPointArray={},this.totalPointNum=0,this.colorArray=[],this.fontArray=[],this.lineStyleArray=[],this.textInfoArray=[],this.imageInfoArray=[]},this.strToUnicode=function(e){for(var t="",n=0;n<e.length;n++){var i=e.charCodeAt(n),r=i.toString(16);t+=i<15?"\\u000"+r:i<255?"\\u00"+r:i<4095?"\\u0"+r:"\\u"+r}return t},this.sendFile=function(e){var t,n={name:this.pdfInfo.fileName,size:this.pdfInfo.size,orientation:this.pdfInfo.orientation,unit:"mm",colorType:this.pdfInfo.colorType,version:this.viewer.modelContentVersion,color:this.colorArray,font:[],lineStyle:[],image:[],meshInfo:{start:0,step:7,data:[]},lineInfo:{start:0,step:6,lineWidth:.1,data:[]},textInfo:{start:0,data:[]},pointInfo:{start:0,step:3,data:[]}},i=new ArrayBuffer(4*this.totalPointNum),r=new Float32Array(i),o=0;for(t in n.meshInfo.start=o,r.set(this.meshPointArray,o),o+=this.meshPointArray.length,n.meshInfo.data.push(this.meshPointArray.length),n.lineInfo.start=o,this.linePointArray){var a=this.linePointArray[t];r.set(a,o),o+=a.length,n.lineInfo.data.push(a.length)}n.textInfo.start=o;for(var s,l=0;l<this.textPointArray.length;l++){var d=this.textPointArray[l];r.set(d,o),o+=d.length}for(s in n.pointInfo.start=o,this.pointPointArray){var c=this.pointPointArray[s];r.set(c,o),o+=c.length,n.pointInfo.data.push(c.length,parseInt(s),.1)}for(var h=0;h<this.lineStyleArray.length;h++){for(var u=this.lineStyleArray[h].data.slice(),p=0;p<u.length;p++)u[p]=parseFloat((u[p]*this.lineStyleArray[h].scale*this.pdfInfo.scale).toFixed(8));n.lineStyle.push(u)}for(var f=0;f<this.fontArray.length;f++){var m,g=this.fontArray[f].name,v=(g=""==g?"YAHEI.ttf":-1==this.fontArray[f].name.search(/\./g)?this.fontArray[f].name+".ttf":this.fontArray[f].name,this.viewer.SDFMaker.IsShxFont(g));this.fontArray[f].isShx?n.font.push({name:g,size:parseFloat((this.fontArray[f].size*this.pdfInfo.scale).toFixed(8)),isShx:this.fontArray[f].isShx,style:this.fontArray[f].style,weight:this.fontArray[f].weight,width:this.fontArray[f].width,index:f}):(m=this.fontArray[f].size*this.pdfInfo.scale,this.viewer.modelContentVersion<=2&&(m*=v?.9:1),this.viewer.modelContentVersion<=2&&"gbcbig.shx"==g&&(m*=.15),n.font.push({name:g,size:parseFloat(m.toFixed(8)),style:this.fontArray[f].style,weight:this.fontArray[f].weight,width:this.fontArray[f].width,index:f}))}for(var A=0;A<this.textInfoArray.length;A++)this.textInfoArray[A].text=this.strToUnicode(this.textInfoArray[A].text);return n.textInfo.data=this.textInfoArray,n.image=this.imageInfoArray,{jsonData:JSON.stringify(n),binData:i}},this.PDFTest=function(){this.totalPointNum=0,this.pdfInfo.fileName="temp",this.pdfInfo.size="A4",this.pdfInfo.orientation="p",this.pdfInfo.colorType="color",this.pdfInfo.xSelMin=0,this.pdfInfo.ySelMin=0,this.pdfInfo.xSelMax=210,this.pdfInfo.ySelMax=297,this.setPaperSize(this.pdfInfo.size,this.pdfInfo.orientation),this.setAlign(),this.colorArray.push("000000"),this.lineStyleArray.push({lineTypeId:0,data:[10,-10],scale:1});var e=this.linePointArray[0];e||(e=new Array,this.linePointArray[0]=e),e.push(10,10,110,10,0,0),this.totalPointNum+=6,e.push(10,20,20,20,0,-1),this.totalPointNum+=6,e.push(30,20,40,20,0,-1),this.totalPointNum+=6,e.push(50,20,60,20,0,-1),this.totalPointNum+=6,e.push(70,20,80,20,0,-1),this.totalPointNum+=6,e.push(90,20,100,20,0,-1),this.totalPointNum+=6,e.push(10,30,110,30,0,-1),this.totalPointNum+=6,(e=this.pointPointArray[0])||(e=new Array,this.pointPointArray[0]=e),e.push(30,8),this.totalPointNum+=2,e.push(70,8),this.totalPointNum+=2,this.sendFile()},this.PDFTestDrawBox=function(){var e=new THREE.LineLoop(new THREE.BufferGeometry,new THREE.LineBasicMaterial({color:255})),t=(e.geometry.addAttribute("position",new THREE.BufferAttribute(new Float32Array(12),3)),[]);t.push(new THREE.Vector3(this.pdfInfo.xSelMin,this.pdfInfo.ySelMin,0)),t.push(new THREE.Vector3(this.pdfInfo.xSelMin,this.pdfInfo.ySelMax,0)),t.push(new THREE.Vector3(this.pdfInfo.xSelMax,this.pdfInfo.ySelMax,0)),t.push(new THREE.Vector3(this.pdfInfo.xSelMax,this.pdfInfo.ySelMin,0)),e.geometry.attributes.position.copyVector3sArray(t),e.geometry.attributes.position.needsUpdate=!0,e.geometry.computeBoundingSphere(),this.viewer.scene.add(e)},this.PDFTestDrawBoundingBox=function(e){var t=new THREE.LineLoop(new THREE.BufferGeometry,new THREE.LineBasicMaterial({color:255})),n=(t.geometry.addAttribute("position",new THREE.BufferAttribute(new Float32Array(12),3)),[]);n.push(new THREE.Vector3(e.min.x,e.min.y,0)),n.push(new THREE.Vector3(e.min.x,e.max.y,0)),n.push(new THREE.Vector3(e.max.x,e.max.y,0)),n.push(new THREE.Vector3(e.max.x,e.min.y,0)),t.geometry.attributes.position.copyVector3sArray(n),t.geometry.attributes.position.needsUpdate=!0,t.geometry.computeBoundingSphere(),this.viewer.scene.add(t)},this.calcTextRect=function(){var e=[],t=!1;if(this.viewer.pmiObject)for(var n=this.viewer.ndsModel.getLayerBodies(this.viewer.ndsModel.rootBodyNode),i=0,r=n.length;i<r;++i){var o=n[i];if(o.visible&&o.pmiuuid)for(var a=0;a<o.pmiuuid.length;++a){var s,l,d=this.getUUidToTextInfo(o.pmiuuid[a]);d&&(s=(new THREE.Vector3).fromArray(d.position),l={bigName:this.fontSaveArray[d.fontId].bigName,name:this.fontSaveArray[d.fontId].name,size:this.fontSaveArray[d.fontId].size,style:this.fontSaveArray[d.fontId].style,weight:this.fontSaveArray[d.fontId].weight,width:this.fontSaveArray[d.fontId].width},this.calcRect(d.text,d.angle,l,s,e,t),t=!0)}}return e},this.calcRect=function(e,t,n,i,r,o,a){for(var s,l=new THREE.Vector3(i.x,i.y,0),d=new THREE.Vector3(i.x,i.y,0),c=new THREE.Vector3(i.x,i.y,0),i=new THREE.Vector3(i.x,i.y,0),h=new THREE.Vector3(Math.cos(t),Math.sin(t),0),u=.001,p=!0,f=a?Math.abs(a):1,m=this.viewer.SDFMaker.GetMaterialStyleId(n.style,n.weight),g=0;g<e.length;g++){var v,A=this.viewer.SDFMaker.GetDimensionsForSize(e[g],n.size*f,m,n.name,n.width,n.bigName);A.discard||(p?(u=2<this.viewer.modelContentVersion?A.height+A.bearingY:A.height,p=!1):u=(v=2<this.viewer.modelContentVersion?A.height+A.bearingY:A.height)<u?u:v,c.addScaledVector(h,2<this.viewer.modelContentVersion?A.advanceX:A.width))}i.copy(c);var t=new THREE.Vector3(0,0,1);t.cross(h).normalize(),d.addScaledVector(t,u),i.addScaledVector(t,u),a=this.min(l.x,d.x,c.x,i.x)-u,t=this.min(l.y,d.y,c.y,i.y)-u,s=this.max(l.x,d.x,c.x,i.x)+u,l=this.max(l.y,d.y,c.y,i.y)+u,o?(r[0]>a&&(r[0]=a),r[1]>t&&(r[1]=t),r[2]<s&&(r[2]=s),r[3]<l&&(r[3]=l)):r.push(a,t,s,l)},this.min=function(e,t,n,i){t=t<e?t:e,e=i<n?i:n;return e<t?e:t},this.max=function(e,t,n,i){t=t<e?e:i,e=i<n?n:i;return e<t?t:e},this.clipText2=function(e,t,n,i,r){for(var o,a,s=[],l=new THREE.Vector3(i.x,i.y,0),d=new THREE.Vector3(Math.cos(t),Math.sin(t),0),c=(l.x-this.pdfInfo.xSelMin)/this.pdfInfo.xLen,h=(l.y-this.pdfInfo.ySelMin)/this.pdfInfo.yLen,u=this.viewer.SDFMaker.GetMaterialStyleId(n.style,n.weight),p=0;p<e.length;p++){var f=r?e:e[p],m=this.viewer.SDFMaker.GetDimensionsForSize(f,n.size,u,n.name,n.width,n.bigName);if(!m.discard&&(o=c,a=h,l.addScaledVector(d,2<this.viewer.modelContentVersion?m.advanceX:m.width),c=(l.x-this.pdfInfo.xSelMin)/this.pdfInfo.xLen,h=(l.y-this.pdfInfo.ySelMin)/this.pdfInfo.yLen,1<=o||o<=0||1<=a||a<=0||1<=c||c<=0||1<=h||h<=0||s.push({font:m.font,width:m.widthScale,char:f,pos:[o,a],clip:!1}),r))break}for(var g=0;g<s.length;g++)for(var v=g+1;v<s.length;v++){if(s[g].font!=s[v].font){g=v-1;break}s[g].char+=s[v].char,s[v].clip=!0}for(var A=[],y=0;y<s.length;y++)s[y].clip||A.push(s[y]);return A},this.clipLine=function(e,t){var n=[];return n=this.cohenSutherlandLineClipAndDraw(e,t)?[e,t]:n},this.computeOutCode=function(e,t){var n=0;return e<0?n|=1:1<e&&(n|=2),t<0?n|=4:1<t&&(n|=8),n},this.cohenSutherlandLineClipAndDraw=function(e,t){for(var n=this.computeOutCode(e.x,e.y),i=this.computeOutCode(t.x,t.y),r=!1;;){if(!(n|i)){r=!0;break}if(n&i)break;var o=void 0,a=void 0,s=n||i;8&s?(o=e.x+(t.x-e.x)*(1-e.y)/(t.y-e.y),a=1):4&s?(o=e.x+(t.x-e.x)*(0-e.y)/(t.y-e.y),a=0):2&s?(a=e.y+(t.y-e.y)*(1-e.x)/(t.x-e.x),o=1):1&s&&(a=e.y+(t.y-e.y)*(0-e.x)/(t.x-e.x),o=0),s==n?(e.x=o,e.y=a,n=this.computeOutCode(e.x,e.y)):(t.x=o,t.y=a,i=this.computeOutCode(t.x,t.y))}return!!r},this.clipTriangle=function(e,t,n){for(var i=[t,e,n],r=[[0,0],[0,1],[1,1],[1,0]],o=0;o<4;o++){var a=(o+1)%4;if(0==(i=this.sutherlandHodgman(i,i.length,r[o][0],r[o][1],r[a][0],r[a][1])).length)break}return 4==i.length&&i.push(i[0],i[2]),5==i.length&&i.push(i[0],i[0],i[2],i[3]),6==i.length&&i.push(i[0],i[2],i[3],i[0],i[3],i[5]),i},this.x_letersect=function(e,t,n,i,r,o,a,s){return((e*i-t*n)*(r-a)-(e-n)*(r*s-o*a))/((e-n)*(o-s)-(t-i)*(r-a))},this.y_letersect=function(e,t,n,i,r,o,a,s){return((e*i-t*n)*(o-s)-(t-i)*(r*s-o*a))/((e-n)*(o-s)-(t-i)*(r-a))},this.sutherlandHodgman=function(e,t,n,i,r,o){for(var a=[],s=0;s<t;s++){var l,d,c=(s+1)%t,h=e[s].x,u=e[s].y,p=e[c].x,c=e[c].y,f=(r-n)*(u-i)-(o-i)*(h-n),m=(r-n)*(c-i)-(o-i)*(p-n);f<0&&m<0?(a.push(new THREE.Vector2(p,c)),0):0<=f&&m<0?(l=this.x_letersect(n,i,r,o,h,u,p,c),d=this.y_letersect(n,i,r,o,h,u,p,c),a.push(new THREE.Vector2(l,d)),a.push(new THREE.Vector2(p,c)),0):f<0&&0<=m&&(l=this.x_letersect(n,i,r,o,h,u,p,c),d=this.y_letersect(n,i,r,o,h,u,p,c),a.push(new THREE.Vector2(l,d)),0)}return a}}function Ei(e,t,n){THREE.Group.call(this),e=e||1e4,t=t||10,this.viewer=n,this.createGird=function(e,t){for(var n=new THREE.Color(16711680),i=new THREE.Color(6710886),r=(t=t<10?10:t)/2,o=e/t,a=e/2,s=[],l=[],d=0,c=0,h=-a;d<=t;d++,h+=o){s.push(-a,0,h,a,0,h),s.push(h,0,-a,h,0,a);var u=d===r?n:i;u.toArray(l,c),c+=3,u.toArray(l,c),c+=3,(u=d==r?new THREE.Color(255):u).toArray(l,c),c+=3,u.toArray(l,c),c+=3}var e=new THREE.BufferGeometry,p=(e.addAttribute("position",new THREE.Float32BufferAttribute(s,3)),e.addAttribute("color",new THREE.Float32BufferAttribute(l,3)),new THREE.LineBasicMaterial({vertexColors:!0})),e=new THREE.LineSegments(e,p);return e.name="GridLine",e};var n=this.createGird(e,t),e=(this.add(n),new THREE.SphereGeometry(.7,20,20)),t=new THREE.MeshPhongMaterial({color:0,depthTest:!0}),e=((n=new THREE.Mesh(e,t)).name="CenterHelp",this.add(n),this.name="GridHelper",null),a=this;e=e||new function(){this.getCameraScale=function(e,t){var n,i,r;return e?(t=null!=t?t:5,n=a.viewer.camera.getCameraTarget(),i=a.viewer.camera.position,(r=new THREE.Vector3).subVectors(n,i),n=e.clone(),e=a.viewer.camera.isPerspective?n.sub(i).dot(r.normalize()):1.2*r.length(),n=a.viewer.camera.fov,i=2*e*Math.tan(THREE.Math.degToRad(.5*n)),r=a.viewer.renderer.domElement.height,t*i*a.viewer.renderer.getPixelRatio()/r):1},this.run=function(){var e,t,n,i,r,o;a.viewer.scene.getObjectByName("GridHelper")&&(o=a.getObjectByName("CenterHelp"),e=a.getObjectByName("GridLine"),t=this.getCameraScale(o.position,7),o.scale.x=o.scale.y=o.scale.z=t,a.updateMatrixWorld(!0),a.matrixWorldNeedsUpdate=!0,e.geometry.computeBoundingBox(),r=e.geometry.boundingBox,i=new THREE.Vector3,r.getCenter(i),r=r.min.distanceTo(r.max),n=a.viewer.camera.position.clone(),i=Math.abs(i.distanceTo(n))+1.2*r,a.viewer.camera.far<i&&a.viewer.camera.adjustNearFar(i,i),n=a.viewer.renderer.domElement.width/20,r=a.viewer.clientCoordToModelCoord([0,0]),i=a.viewer.clientCoordToModelCoord([0,n]),n=new THREE.Vector3(i[0]-r[0],i[1]-r[1],i[2]-r[2]).length(),r=(i=(i=4*Math.max(Math.abs(a.viewer.camera.target.x-o.position.x),Math.abs(a.viewer.camera.target.y-o.position.y))*t)<40*n?40*n:i)/n,r=Math.round(r)%2==0?Math.round(r):Math.round(r)+1,o=a.createGird(i,r),a.remove(e),a.add(o))}},a.viewer.addFrameListener(e)}function n(e){this.viewer=e,this.snappingTool=new An(this.viewer)}function be(e){g.call(this,e),this.type="OpDrawGeom";var t=this;this.OpUtils=new n(e),!this.viewer.hasBrepInfo()&&this.viewer.hasBrepFile()?this.viewer.loadBrepInfo(!1):this.viewer.dispatchEvent({type:"BrepInfoEvent"}),this.drawGeomPrompt=document.createElement("div"),Se.isMobileDevice()?this.drawGeomPrompt.className="app-alert":this.drawGeomPrompt.className="pc-alert",this.createDefaultPlane(),this.drawType="",this.drawArray=[],this.drawCount=0,this.drawGeomVisible=!0,this.drawGeomPosMap=new Map,this.currentMesh=null,this.lastMesh=null,this.needAddScene=!1,this.selectMeshMap=new Map,this.pointIdx=1,this.lineIdx=1,this.arcIdx=1,this.splineIdx=1,this.PointSize=2,this.ARC_SEGMENTS=200,this.selectLineMaterial=_e.selectedLineMaterial,this.selectMeshMaterial=_e.selectedPointMaterial,this.defaultLineMaterial=new THREE.LineBasicMaterial({color:750054,opacity:1,linewidth:1}),this.defaultMeshMaterial=new THREE.MeshBasicMaterial({color:750054,opacity:1,side:THREE.DoubleSide}),this.traceMode=!1,this.needSelectPlane=!1,this.preSelectPlaneInfo=null,this.preSelectPlaneObj=null,this.selectPlaneObj=null,this.useSelectPlane=!1,this.drawScene=new THREE.Group,this.drawScene.name="OpDrawGeom",this.processKey=function(e){if(t.isDrawType())switch(e.keyCode){case 13:case 27:case 108:t.endSpline()}}}function xe(e){g.call(this,e),this.type="OpDrawTrace",this.tempCenterBox=new THREE.Vector3,this.drawTracePrompt=document.createElement("div"),Se.isMobileDevice()?this.drawTracePrompt.className="app-alert":this.drawTracePrompt.className="pc-alert",this.viewer.container.appendChild(this.drawTracePrompt),this.domElement=e.canvas2D||e.canvas3D,this.clipTransRotControl=null,this.objectBox=null,this.objectMove=!1,this.objectForInsert=!1,this.startPoint=new THREE.Vector3,this.endPoint=new THREE.Vector3,this.lineNormal=new THREE.Vector3,this.tEnd=-1,this.tCur=0,this.lastPosition=null,this.selGeomUUid=null,this.updateTransContorlOnce=!0,this.defaultLineMaterial=new THREE.LineDashedMaterial({color:65280,opacity:1,linewidth:1,dashSize:30,gapSize:10}),this.showLine=null,this.drawTraceGroup=new THREE.Group,this.drawTraceGroup.name="OpDrawTrace",this.drawTraceVisible=!1,this.init();var i=this;this.objectMouseUp=function(){i.objectMove=!1},this.objectMouseDown=function(){i.objectForInsert=!0,i.objectMove=!0,i.viewer.dispatchEvent({type:"drawTrace",ready:!0}),i.updateTransContorlOnce=!0,i.setSelectBodyByRect(!1)},this.objectChange=function(){var e,t,n=(new THREE.Vector3).subVectors(i.objectBox.position,i.startPoint).dot(i.lineNormal);0<i.tEnd&&0<=n&&n<=i.tEnd||i.tEnd<0&&n<=0&&n>=i.tEnd?(i.tCur=Math.abs(n/i.tEnd),i.updateModel(i.tCur),i.clipTransRotControl.update(),i.clipTransRotControl.updateMatrixWorld(!0),i.updateTransContorlOnce=!0):0<i.tEnd&&n<0||i.tEnd<0&&0<n?(i.tCur=0,i.updateModel(i.tCur),e=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),i.lineNormal),e=(new THREE.Matrix4).makeRotationFromQuaternion(e),t=(new THREE.Matrix4).makeTranslation(i.startPoint.x,i.startPoint.y,i.startPoint.z),i.objectBox.matrix.identity(),i.objectBox.matrixAutoUpdate=!1,i.objectBox.applyMatrix(e),i.objectBox.applyMatrix(t),i.objectBox.updateMatrixWorld(!0),i.objectBox.matrixAutoUpdate=!0,i.updateTransContorlOnce&&(i.clipTransRotControl.position.copy(i.startPoint),i.clipTransRotControl.update(),i.clipTransRotControl.updateMatrixWorld(!0))):Math.abs(n)>Math.abs(i.tEnd)&&(i.tCur=1,i.updateModel(i.tCur),e=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),i.lineNormal),t=(new THREE.Matrix4).makeRotationFromQuaternion(e),n=(new THREE.Matrix4).makeTranslation(i.endPoint.x,i.endPoint.y,i.endPoint.z),i.objectBox.matrix.identity(),i.objectBox.matrixAutoUpdate=!1,i.objectBox.applyMatrix(t),i.objectBox.applyMatrix(n),i.objectBox.updateMatrixWorld(!0),i.objectBox.matrixAutoUpdate=!0,i.updateTransContorlOnce)&&(i.clipTransRotControl.position.copy(i.endPoint),i.clipTransRotControl.update(),i.clipTransRotControl.updateMatrixWorld(!0))}}function Ie(e){g.call(this,e),this.type="OpPiovt",this.tempCenterBox=new THREE.Vector3,this.OpUtils=new n(e),this.selectedObjectUUID=[],!this.viewer.hasBrepInfo()&&this.viewer.hasBrepFile()?this.viewer.loadBrepInfo(!1):this.viewer.dispatchEvent({type:"BrepInfoEvent"}),this.piovtPrompt=document.createElement("div"),Se.isMobileDevice()?this.piovtPrompt.className="app-alert":this.piovtPrompt.className="pc-alert",this.viewer.container.appendChild(this.piovtPrompt),this.piovtType="",this.PointSize=4,this.allowType=[],this.preSelectInfo=null,this.preSelectObj=null,this.piovtScene=new THREE.Group,this.piovtScene.name="OpPiovt",this.init()}(Ai.prototype=Object.create(g.prototype)).changeSelobject=function(){var e=this.viewer.getExplodeMode();if(this.updateNodeMatrix(),this.TransRotControl){this.MoveObjects=this.viewer.selectionManager.getSelectedleafObjects();for(var t,n,i=new THREE.Box3,r=0;r<this.MoveObjects.length;++r){var o=this.MoveObjects[r],o=this.viewer.ndsModel.getBodyBoundingBox(o);o&&!o.isEmpty()&&(i.expandByPoint(o.max),i.expandByPoint(o.min))}this.TransRotControl.object.position.copy(i.getCenter()),0==this.MoveObjects.length?this.TransRotControl.visible=!1:(this.TransRotControl.visible=!0,(t=this.TransRotControl.children[0].children[0].children[1]).matrixAutoUpdate=!0,t.matrixWorldNeedsUpdate=!0,(n=this.TransRotControl.children[0].children[0].children[0].geometry.attributes.position).array[3]=1,n.needsUpdate=!0,t.quaternion.set(0,0,0,1),t.position.set(0,0,0),t.updateMatrix(),t.updateMatrixWorld(!0)),this.viewer.setExplodeMode(e),this.TransRotControl.object.originalPosition=this.TransRotControl.object.position.clone(),this.TransRotControl.update(),this.offset.set(0,0,0),this.render()}},Ai.prototype.renderModel=function(){this.translateScene&&this.TransRotControl&&(this.TransRotControl.updateMatrixWorld(),this.TransRotControl.update(),this.viewer.renderer.render(this.translateScene,this.viewer.camera))},Ai.prototype.setExplodeMode=function(e){this.ExplodeMode!=e&&(this.ExplodeMode=e,this.TransRotControl.object.mode=this.ExplodeMode,"Linear"==this.ExplodeMode?this.TransRotControl.children[0].children[0].traverse(function(e){"XY"==e.name||"XZ"==e.name||"YZ"==e.name?e.visible=!1:e.visible=!0}):"Normal"==this.ExplodeMode&&this.TransRotControl.children[0].children[0].traverse(function(e){"X"==e.name||""==e.name?e.visible=!0:e.visible=!1}),this.render())},Ai.prototype.onLMouseClick=function(e){1==this.onExplode?this.onExplode=!1:(g.prototype.onLMouseClick.call(this,e),this.MoveObjects=this.viewer.selectionManager.getSelectedleafObjects(),0==this.MoveObjects.length&&this.updateNodeMatrix(),this.changeSelobject())},Ai.prototype.isTransControlSelected=function(){return!!this.TransRotControl&&this.TransRotControl.isSelected()},Ai.prototype.release=function(){this.update(),this.render(),this.TransRotControl&&(this.TransRotControl.dispose(),this.TransRotControl=null),g.prototype.release.call(this),this.updateNodeMatrix()},Ai.prototype.update=function(){this.TransRotControl.update(),g.prototype.update.call(this)},Ai.prototype.updateNodeMatrix=(wi=new THREE.Matrix4,bi=new THREE.Matrix4,xi=new THREE.Matrix4,Ii=new THREE.Matrix4,function(){var n=this,i=new Map;if(0!=this.viewer.getExplodeFactor()){this.viewer.explodeObjects.forEach(function(e){var t,e=(n.viewer.ndsModel.objectidTouuid||n.viewer.ndsModel.meshManager.bodyUuids)[e],e=n.viewer.ndsModel.getBodyNodeFromUuid(e);e&&e.leafBodyAttri&&(t=n.viewer.ndsModel.getBodyTranslate(e),bi.makeTranslation(t[0],t[1],t[2]),wi.copy(e.worldMatrix),wi.premultiply(bi),(t=(new THREE.Matrix4).getInverse(e.worldMatrix)).premultiply(wi),n.viewer.translatePiovt(e.uuid,t),e.worldMatrix=wi,t=e.parent?n.viewer.ndsModel.calculateNodeWorldMatrix(e.parent):new THREE.Matrix4,Ii.getInverse(t),xi=e.worldMatrix.clone().premultiply(Ii),i.set(e.uuid,xi.toArray()))}),this.viewer.onExplode(0);for(var e=gi(i);!(t=e()).done;){var t=t.value,r=t[0],t=t[1];n.viewer.ndsModel.updateNodeMatrix(r,t)}n.viewer.setExplodeMode(ve.EXPLODEMODE.NORMAL,0,!0),this.changeSelobject(),this.render()}}),Ei.prototype=Object.create(THREE.Group.prototype),n.prototype.clientCoordToModelCoordOnPlane=function(e,t,n){e=[e,t,.99],t=this.viewer.clientCoordToModelCoord(e),t=new THREE.Vector3(t[0],t[1],t[2]),e[2]=-.99,e=this.viewer.clientCoordToModelCoord(e),e=new THREE.Vector3(e[0],e[1],e[2]);return this.intersectLine(t,e,n)},n.prototype.intersectLine=function(e,t,n){var i,r;return!(e&&t&&n)||(i=e.clone(),(e=(new THREE.Vector3).subVectors(t,e)).normalize(),r=e.dot(n.normal),Math.abs(r)<=1e-8)?null:(t=n.coplanarPoint(t.clone()),t=(new THREE.Vector3).subVectors(t,i).dot(n.normal)/r,i.add(e.multiplyScalar(t)))},n.prototype.getViewClientCoords=function(e){var t=e.offsetX||e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.offsetY||e.clientY-this.viewer.container.getBoundingClientRect().top;return e.srcElement&&e.srcElement!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),null==e.srcElement&&e.target&&e.target!==this.viewer.renderer.domElement&&(t=e.clientX-this.viewer.container.getBoundingClientRect().left,n=e.clientY-this.viewer.container.getBoundingClientRect().top),new THREE.Vector2(t,n)},n.prototype.doRaycasterPick=function(e,t,n){var i=this.viewer,r=i.renderer.domElement,o=i.renderer.getPixelRatio(),e=e*o/r.width*2-1,t=2*-(t*o/r.height)+1,o=new THREE.Raycaster;i.camera.setCastRay(o,e,t),n&&(o.linePrecision=this.getLinePrecision());return i.ndsModel?n?i.ndsModel.intersect(o.ray,o.linePrecision):i.ndsModel.intersect(o.ray):n?o.intersectObjects(i.selectionManager.getTargetIncludeLineList()):o.intersectObjects(i.selectionManager.getTargetList())},n.prototype.doRaycasterGeomPick=function(e,t){var n,i,r,o=this.viewer;return o.controls.staticDrawGeomOp&&o.controls.staticDrawGeomOp.needSelectGeom()?(i=(o=this.viewer).renderer.domElement,n=e*(e=o.renderer.getPixelRatio())/i.width*2-1,t=2*-(t*e/i.height)+1,(e=new THREE.Raycaster).linePrecision=1,i=o.clientCoordToModelCoord([0,0]),i=new THREE.Vector3(i[0],i[1],i[2]),r=o.clientCoordToModelCoord([4,0]),r=new THREE.Vector3(r[0],r[1],r[2]),e.linePrecision=.65*i.distanceTo(r),o.camera.setCastRay(e,n,t),e.intersectObjects(o.controls.staticDrawGeomOp.drawScene.children,!0)):[]},n.prototype.getLinePrecision=function(){var e=this.viewer.clientCoordToModelCoord([0,0]),e=new THREE.Vector3(e[0],e[1],e[2]),t=this.viewer.clientCoordToModelCoord([4,0]),t=new THREE.Vector3(t[0],t[1],t[2]);return e.distanceTo(t)},n.prototype.getSelectInfoFromIntersect=function(e){if(e&&this.viewer.hasBrepInfo()){var t,n,i,r,o=this.viewer.ndsModel?e.object:this.FindParentElement(e.object);if(o)return o=o.uuid,n=e.object.uuid,this.viewer.ndsModel&&(0<=e.meshId?(e.mesh=this.viewer.ndsModel.meshManager.getSingleMesh(e.meshId),e.mesh&&(i=e.faceIndex-e.mesh.geometry.drawRange.start/3,t="face")):0<=e.lineSegId&&(e.mesh=this.viewer.ndsModel.meshManager.getLineSegments(e.lineSegId),e.mesh)&&(i=.5*(e.index-e.mesh.geometry.drawRange.start),t="edge"),n=e.geomUuid),0<=i&&(r=this.viewer.brepManager.GetBrepInfoByUUidAndTopolIndex(o,n,i,t))&&(r.parentObj=e.mesh,r.geometry=e.mesh.geometry,r.matrixWorld=e.mesh.matrixWorld.clone(),r.intersect=e.point.clone(),r.bodyId=e.bodyId,r.bodyUuid=e.bodyUuid,r.meshId=e.meshId,r.topolIndex=i,r.topolType=t,r.lineSegId=e.lineSegId,"face"==t&&(r.edgeInfos=this.viewer.brepManager.GetEdgeInfoFromFace(o,r.edgeIDS)),r.normal&&null==r.worldNormal&&(n=new THREE.Vector3,i=new THREE.Quaternion,e=new THREE.Vector3,r.parentObj.matrixWorld.decompose(n,i,e),r.worldNormal=new THREE.Vector3(r.normal[0],r.normal[1],r.normal[2]),r.worldNormal.applyQuaternion(i)),r.origin)&&null==r.worldOrigin&&(r.worldOrigin=new THREE.Vector3(r.origin[0],r.origin[1],r.origin[2]),r.worldOrigin.applyMatrix4(r.matrixWorld)),r}},n.prototype.getLineStartEndPoints=function(e){if(("cylinder"==e.type||"cone"==e.type)&&e.origin&&e.axis){var t=e.geometry,n=e.indexRange.concat();if(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/3,n[1]+=t.drawRange.start/3),t.isBufferGeometry){var i=t.index,r=t.attributes.position,o=new THREE.Vector3,a=new THREE.Vector3,s=(o.fromArray(e.origin),a.fromArray(e.axis),new THREE.Quaternion),l=new THREE.Vector3,d=new THREE.Vector3,c=(e.matrixWorld.decompose(l,s,d),a.applyQuaternion(s),a.normalize(),-1/0),h=1/0;o.applyMatrix4(e.matrixWorld);for(var u=n[0],p=n[1];u<=p;u++){var f=3*u,m=i.getX(f),g=i.getX(1+f),f=i.getX(2+f),v=new THREE.Vector3,A=new THREE.Vector3,y=new THREE.Vector3,m=(v.fromBufferAttribute(r,m),A.fromBufferAttribute(r,g),y.fromBufferAttribute(r,f),v.applyMatrix4(e.matrixWorld),A.applyMatrix4(e.matrixWorld),y.applyMatrix4(e.matrixWorld),v.clone().sub(o).dot(a));c<m&&(c=m),m<h&&(h=m),(m=A.clone().sub(o).dot(a))<h&&(h=m),(c=c<m?m:c)<(m=y.clone().sub(o).dot(a))&&(c=m),m<h&&(h=m),y=A=v=null}return 0==Math.abs(c-h)?null:(w=o.clone().add(a.clone().multiplyScalar(c)),{start:o.clone().add(a.clone().multiplyScalar(h)),end:w})}}if("circle"==e.type&&e.center){t=e.geometry,n=e.indexRange.concat();if(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/2,n[1]+=t.drawRange.start/2),t.isBufferGeometry){var i=t.index,E=t.attributes.position.array;if(null!=i)return M=i.array,o=new THREE.Vector3,w=new THREE.Vector3,o.fromArray(E,3*M[2*n[0]]),w.fromArray(E,3*M[2*n[0]+1]),this.viewer.is2DModel&&o.z==w.z&&(e.center[2]=o.z),v=(l=new THREE.Vector3(e.center[0],e.center[1],e.center[2])).clone().sub(o).normalize(),A=w.clone().sub(o).normalize(),o.applyMatrix4(e.matrixWorld),w.applyMatrix4(e.matrixWorld),l.applyMatrix4(e.matrixWorld),o.sub(l),w.sub(l),(a=o.clone().cross(w)).normalize(),o.set(e.center[0],e.center[1],e.center[2]),o.applyMatrix4(e.matrixWorld),w=o.clone().add(a),{start:o,end:w}}}t=e.geometry,n=e.indexRange.concat();if(this.viewer.ndsModel&&(n[0]+=t.drawRange.start/2,n[1]+=t.drawRange.start/2),t.isBufferGeometry){var M,w,i=t.index,E=t.attributes.position.array;if(null!=i)return M=i.array,o=new THREE.Vector3,w=new THREE.Vector3,o.fromArray(E,3*M[2*n[0]]),w.fromArray(E,3*M[2*n[1]+1]),o.applyMatrix4(e.matrixWorld),w.applyMatrix4(e.matrixWorld),{start:o,end:w}}return null},n.prototype.FindParentElement=function(e){if(null==e)return null;if(e instanceof THREE.Object3D||e instanceof NdsBodyNode){var t=e.type.toLowerCase();if(this.viewer.isObjectTypeOfElement(e)){if("object"==t)for(var n=e.parent;null!=n;)"instanceobject"==n.type.toLowerCase()&&(e=n),n=n.parent;return e}}return this.FindParentElement(e.parent)},n.prototype.getFilterDistByBody=function(e){var t,n;return e?(e.boxDiagonalLength||(t=new THREE.Vector3,n=new THREE.Vector3,this.viewer.computeBoundingBox(e,t,n,{flag:!0}),e.boxDiagonalLength=n.distanceTo(t)),.015*e.boxDiagonalLength):.5},n.prototype.getSnappingPntEx=function(e){if(e){var t;if(this.viewer.hasBrepInfo()){var n=this.viewer.ndsModel?e.object:this.FindParentElement(e.object);if(!n)return;var i=n.uuid,r=this.viewer.brepManager.GetEdgesExtremePointsByBodyUUID(i);if(!r||r.length<=0)return;for(var o,i=this.getFilterDistByBody(n),a=i*i,s=e.point.clone(),n=this.viewer.modelCoordToClientCoord([s.x,s.y,s.z]),l=new THREE.Vector3(n[0],n[1],0),d=new THREE.Vector3,c=64,h=0;h<r.length;h++)s.distanceToSquared(r[h])<a&&(o=this.viewer.modelCoordToClientCoord([r[h].x,r[h].y,r[h].z]),d.set(o[0],o[1],0),(o=l.distanceToSquared(d))<c)&&(t=r[h],c=o)}else _e.inBIMContext||(this.snappingTool.doSnapping(e),this.snappingTool.isSnapped()&&this.snappingTool.getSnappedType()==SNAP_VERTEX&&(t=this.snappingTool.getSnappedVertex()));return t}},n.prototype.FindParentElement=function(e){if(null==e)return null;if(e instanceof THREE.Object3D||e instanceof NdsBodyNode){var t=e.type.toLowerCase();if(this.viewer.isObjectTypeOfElement(e)){if("object"==t)for(var n=e.parent;null!=n;)"instanceobject"==n.type.toLowerCase()&&(e=n),n=n.parent;return e}}return this.FindParentElement(e.parent)},n.prototype.setPointScale=function(e,t){t=this.getScale(e,t);e.scale.x=t,e.scale.y=t,e.scale.z=t,e.updateMatrixWorld(!0)},n.prototype.setCylinderScale=function(e,t){COMMON.isMobileDevice()&&(t*=1.5);t=this.getScale(e,t);e.scale.x=t,e.scale.y=t,e.scale.z=t,e.oldPosition&&e.offsetPos&&e.position.addVectors(e.oldPosition,e.offsetPos.clone().multiplyScalar(t)),e.updateMatrixWorld(!0)},n.prototype.getScale=function(e,t){var n=5,t=(null!=t&&(n=t),this.viewer.camera.getCameraTarget()),i=this.viewer.camera.position,r=new THREE.Vector3,t=(r.subVectors(t,i),e.position.clone()),e=this.viewer.camera.isPerspective?t.sub(i).dot(r.normalize()):r.length(),t=this.viewer.camera.fov,i=2*e*Math.tan(THREE.Math.degToRad(.5*t)),r=this.viewer.renderer.domElement.height;return n*i*this.viewer.renderer.getPixelRatio()/r},n.prototype.isTwoTopolInfoTheSame=function(e,t){return!(e&&!t||!e&&t||!e&&!t||this.viewer.ndsModel&&(e.bodyId!=t.bodyId||e.meshId!=t.meshId||e.lineSegId!=t.lineSegId)||e.parentObj!=t.parentObj||e.id!=t.id||e.indexRange[0]!==t.indexRange[0]||e.indexRange[1]!==t.indexRange[1])},n.prototype.createFace=function(e,t){if(e&&e.parentObj instanceof THREE.Mesh){var n,i=e.geometry,r=e.indexRange.concat();if(this.viewer.ndsModel&&(r[0]+=i.drawRange.start/3,r[1]+=i.drawRange.start/3),i.isBufferGeometry){for(var o=i.index,a=i.attributes.position,i=r[1]-r[0]+1,s=new Float32Array(9*i),l=0,d=new THREE.Vector3,c=r[0],h=r[1];c<=h;c++,l+=1){var u=3*c,p=o.getX(u),f=o.getX(1+u),u=o.getX(2+u),m=new THREE.Vector3,g=new THREE.Vector3,v=new THREE.Vector3,p=(m.fromBufferAttribute(a,p),g.fromBufferAttribute(a,f),v.fromBufferAttribute(a,u),(new THREE.Vector3).subVectors(g,m)),f=(new THREE.Vector3).subVectors(v,m);p.cross(f).normalize(),d.add(p),s[9*l]=m.x,s[9*l+1]=m.y,s[9*l+2]=m.z,s[9*l+3]=g.x,s[9*l+4]=g.y,s[9*l+5]=g.z,s[9*l+6]=v.x,s[9*l+7]=v.y,s[9*l+8]=v.z,v=g=m=null}i=new THREE.BufferGeometry,r=(i.addAttribute("position",new THREE.BufferAttribute(s,3)),(n=new THREE.Mesh(i,0==t?_e.selectedFaceMaterial:_e.preSelectedFaceMaterial)).objectType="Face",n.FaceInfo=[],this.viewer.ndsModel.geomManager.uuidToIdMap[e.geometry.uuid][0]),i=(n.FaceInfo.push(this.viewer.ndsModel.bodyUuid2NodeMap[e.bodyUuid].id),n.FaceInfo.push(r),n.FaceInfo.push(e.topolIndex),n.FaceInfo.push(e.meshId),t?1:0);n.FaceInfo.push(i),n.applyMatrix(e.matrixWorld),n.matrixWorldNeedsUpdate=!0,d.normalize(),e.averagenormal=d}return n}},n.prototype.createLine=function(e,t,n){if(e&&e.parentObj instanceof THREE.Line){var i,r=e.geometry,o=e.indexRange.concat();if(this.viewer.ndsModel&&(o[0]+=r.drawRange.start/2,o[1]+=r.drawRange.start/2),r.isBufferGeometry){var a=o[1]-o[0]+1,s=r.index,l=r.attributes.position.array,d=new Float32Array(6*a);if(null!=s){for(var c=s.array,h=0,r=o[0],u=o[1],p=(Math.round(.5*(r+u)),0),f=r,m=u;f<=m;f++,h+=1){var g=c[2*f],v=c[2*f+1],A=new THREE.Vector3,y=new THREE.Vector3;A.fromArray(l,3*g),y.fromArray(l,3*v),d[6*h]=A.x,d[6*h+1]=A.y,d[6*h+2]=A.z,d[6*h+3]=y.x,d[6*h+4]=y.y,d[6*h+5]=y.z,p+=A.clone().distanceTo(y),y=A=null}for(var E=0,f=r;f<=u;f++){g=c[2*f],v=c[2*f+1],A=new THREE.Vector3,y=new THREE.Vector3,A.fromArray(l,3*g),y.fromArray(l,3*v);if(.5*p<(E+=A.clone().distanceTo(y))){y.clone().sub(A).normalize();break}}n=n||(0==t?_e.SelectedEdgeMaterial1:_e.preSelectedEdgeMaterial);a=new THREE.BufferGeometry,s=(a.addAttribute("position",new THREE.BufferAttribute(d,3)),(i=new THREE.LineSegments(a,n)).objectType="SelLine",i.LineInfo=[],i.LineInfo.push(this.viewer.ndsModel.bodyUuid2NodeMap[e.bodyUuid].id),this.viewer.ndsModel.geomManager.uuidToIdMap[e.geometry.uuid][0]),o=(i.LineInfo.push(s),i.LineInfo.push(e.topolIndex),i.LineInfo.push(e.lineSegId),t?1:0);i.LineInfo.push(o),i.applyMatrix(e.matrixWorld),i.matrixWorldNeedsUpdate=!0}}return i}},n.prototype.createPointMesh=function(e,t,n){t=new THREE.Mesh(new THREE.SphereGeometry(1),t);return t.position.set(e.x,e.y,e.z),this.setPointScale(t,n),t.objectType="Point",t.Point=e.clone(),t},(be.prototype=Object.create(g.prototype)).clearFlag=function(){this.clearPreSelectPlane(),this.clearSelectPlane(),this.clearUnCompleteMesh(),this.useSelectPlane=!1,this.drawType="",this.postInfo(0),this.drawGeomPrompt&&this.viewer.container.removeChild(this.drawGeomPrompt),this.viewer.onChangeCursor("OpOrbit"),this.releaseEventListener(),window.removeEventListener("keydown",this.processKey,!1)},be.prototype.init=function(){this.viewer.AnimationEdit&&this.viewer.AnimationEdit.isPlay?this.drawGeomVisible=!1:this.drawGeomVisible=!0,this.useSelectPlane=!1,this.clearPreSelectPlane(),this.clearSelectPlane(),this.clearUnCompleteMesh(),this.viewer.container.appendChild(this.drawGeomPrompt),this.createDefaultPlane(),this.createEventListener(),window.addEventListener("keydown",this.processKey,!1)},be.prototype.release=function(){this.clearPreSelectPlane(),this.clearSelectPlane(),this.clearUnCompleteMesh(),this.selectMeshMap.clear();for(var e=0;e<this.drawScene.children.length;e++){var t=this.drawScene.children[e];this.drawScene.remove(t),t.geometry.dispose()}this.viewer.container.removeChild(this.drawGeomPrompt),this.drawGeomPrompt=null,g.prototype.release.call(this)},be.prototype.setDrawType=function(e){this.drawType=e,this.clearUnCompleteMesh(),this.isDrawType()&&0==this.needSelectPlane?this.viewer.onChangeCursor("OpDrawGeom"):this.needSelectPlane?this.viewer.onChangeCursor("OpDrawGeomPlane"):this.viewer.onChangeCursor("OpOrbit")},be.prototype.setSelectPlane=function(e){this.clearPreSelectPlane(),this.clearSelectPlane(),this.clearUnCompleteMesh(),(this.needSelectPlane=e)?(this.useSelectPlane=!0,this.viewer.onChangeCursor("OpDrawGeomPlane"),this.viewer.selectionManager.clearSelection(),this.viewer.render(),this.postInfo(1)):(this.createDefaultPlane(),this.postInfo(0),this.useSelectPlane=!1,this.isDrawType()?this.viewer.onChangeCursor("OpDrawGeom"):this.viewer.onChangeCursor("OpOrbit"))},be.prototype.rotateViewBox=function(){this.clearUnCompleteMesh(),this.clearSelectPlane(),this.createDefaultPlane(!0)},be.prototype.setTraceMode=function(e){this.traceMode=e},be.prototype.isTraceMode=function(){return this.traceMode},be.prototype.setGeomVisible=function(e){this.drawGeomVisible=e,this.viewer.render()},be.prototype.needSelectGeom=function(){return!!this.drawGeomVisible&&"OpExplode"!=this.viewer.controls.getOperator().type},be.prototype.postInfo=function(e){var t,n,i;this.drawGeomPrompt&&(t="",n="en"==Se.getLanguage(),i=Se.isMobileDevice()?42:22,1===e&&(t=n?"Click to select a plane":"单击确定模型的任意平面"),this.InfoType=e,this.drawGeomPrompt.style.height=i+"px",this.drawGeomPrompt.style.display="none",this.drawGeomPrompt.style.color="#000000",this.drawGeomPrompt.innerHTML=t)},be.prototype.onNMouseMove=function(e){this.needSelectPlane&&this.drawGeomPrompt&&!Se.isMobileDevice()&&(this.drawGeomPrompt.style.display=0<this.InfoType?"block":"none",this.drawGeomPrompt.style.left=e.clientX+16+"px",this.drawGeomPrompt.style.top=e.clientY+18+"px"),!this.isDrawType()&&0==this.needSelectPlane||this.processEvent(e,!0)},be.prototype.onLMouseClick=function(e){e.preventDefault(),this.isDrawType()||0!=this.needSelectPlane||null!=this.selectPlaneObj||"OpDrawGeom"!=this.viewer.controls.getOperator().type?this.processEvent(e,!1):g.prototype.onLMouseClick.call(this,e)},be.prototype.onLMouseMove=function(e){this.needSelectPlane&&this.drawGeomPrompt&&!Se.isMobileDevice()&&(this.drawGeomPrompt.style.display=0<this.InfoType?"block":"none",this.drawGeomPrompt.style.left=e.clientX+16+"px",this.drawGeomPrompt.style.top=e.clientY+18+"px"),this.isDrawType()?null==this.currentMesh&&(this.clearPreSelectPlane(),this.clearSelectPlane(),this.createDefaultPlane(!0),g.prototype.onLMouseMove.call(this,e)):(this.clearSelectPlane(),this.createDefaultPlane(!0),g.prototype.onLMouseMove.call(this,e))},be.prototype.onMMouseMove=function(e){this.needSelectPlane&&this.drawGeomPrompt&&!Se.isMobileDevice()&&(this.drawGeomPrompt.style.display=0<this.InfoType?"block":"none",this.drawGeomPrompt.style.left=e.clientX+16+"px",this.drawGeomPrompt.style.top=e.clientY+18+"px"),g.prototype.onMMouseMove.call(this,e)},be.prototype.onRMouseMove=function(e){this.needSelectPlane&&this.drawGeomPrompt&&!Se.isMobileDevice()&&(this.drawGeomPrompt.style.display=0<this.InfoType?"block":"none",this.drawGeomPrompt.style.left=e.clientX+16+"px",this.drawGeomPrompt.style.top=e.clientY+18+"px"),g.prototype.onRMouseMove.call(this,e)},be.prototype.isDrawType=function(){return"Point"==this.drawType||"Arc"==this.drawType||"Line"==this.drawType||"Spline"==this.drawType},be.prototype.processEvent=function(e,t){var n,i,e=this.OpUtils.getViewClientCoords(e);this.needSelectPlane?(this.drawArray=[],this.drawCount=0,(n=this.OpUtils.doRaycasterPick(e.x,e.y,!1))&&0!=n.length?(n=n[0])&&((n=this.OpUtils.getSelectInfoFromIntersect(n))&&"plane"==n.type?t?null!=this.preSelectPlaneInfo&&this.OpUtils.isTwoTopolInfoTheSame(this.preSelectPlaneInfo,n)||(this.clearPreSelectPlane(),this.preSelectPlaneInfo=n,(i=this.createPlaneFace(n,!0))&&(this.drawScene.add(i),this.preSelectPlaneObj=i)):(this.clearPreSelectPlane(),this.clearSelectPlane(),this.createSelectPlane(n.worldOrigin,n.worldNormal.clone()),this.needSelectPlane=!1,(i=this.createPlaneFace(n,!1))&&(this.drawScene.add(i),this.selectPlaneObj=i),this.postInfo(0)):this.clearPreSelectPlane()):this.clearPreSelectPlane()):!this.isDrawType()||0==this.drawArray.length&&t||!(n=this.OpUtils.clientCoordToModelCoordOnPlane(e.x,e.y,this.projectPlane))||1<=this.drawArray.length&&n.equals(this.drawArray[0])||(t?this.drawArray.length==this.drawCount?this.drawArray.push(n):this.drawArray[this.drawCount]=n:(this.drawArray.length==this.drawCount?this.drawArray.push(n):this.drawArray[this.drawCount]=n,this.drawCount++),"Point"==this.drawType&&1==this.drawArray.length?(this.addPoint(this.drawArray[0],!0),this.drawArray=[],this.drawCount=0):"Arc"==this.drawType?(e=2==(i=this.drawArray.length-1)&&!t,!t&&1==i&&this.drawArray[0].equals(this.drawArray[1])?(this.drawArray.pop(),this.drawCount--):(this.addArc(i,e),e&&(this.drawArray=[],this.drawCount=0))):"Line"==this.drawType?(n=this.drawArray.length-1,this.addLine(this.drawArray[n],n,i=1==n&&!t),i&&(this.drawArray=[],this.drawCount=0)):"Spline"==this.drawType&&(e=this.drawArray.length-1,this.addSpline(e)))},be.prototype.renderGeomScene=function(){this.drawScene&&this.drawGeomVisible&&(this.renderScale(this.drawScene),this.viewer.renderer.render(this.drawScene,this.viewer.camera))},be.prototype.renderScale=function(e){for(var t=0;t<e.children.length;t++){var n=e.children[t];if(null!=n.objectType)switch(n.objectType){case"Point":this.OpUtils.setPointScale(n,this.PointSize);break;case"Group":this.renderScale(n)}}},be.prototype.addGeomItem=function(e){for(var t=0;t<e.length;t++){var n,i,r,o,a=null,s=null;switch(e[t].objectType){case"Point":a=new THREE.Mesh(new THREE.SphereGeometry(this.PointSize),this.defaultMeshMaterial),this.pointIdx++;break;case"Line":this.lineIdx++,s=Float32Array.from(e[t].geometry),(a=new THREE.Line(new THREE.BufferGeometry,this.defaultLineMaterial)).geometry.addAttribute("position",new THREE.BufferAttribute(s,3));break;case"Arc":this.arcIdx++,s=Float32Array.from(e[t].geometry),(a=new THREE.Line(new THREE.BufferGeometry,this.defaultLineMaterial)).geometry.addAttribute("position",new THREE.BufferAttribute(s,3));break;case"Spline":this.splineIdx++,s=Float32Array.from(e[t].geometry),(a=new THREE.Line(new THREE.BufferGeometry,this.defaultLineMaterial)).geometry.addAttribute("position",new THREE.BufferAttribute(s,3))}a&&(n=(new THREE.Matrix4).fromArray(e[t].matrix),i=new THREE.Vector3,r=new THREE.Quaternion,o=new THREE.Vector3,n.decompose(i,r,o),a.uuid=e[t].uuid,a.name=e[t].name,a.objectType=e[t].objectType,a.visible=e[t].visible,a.isDrawGeom=!0,a.position.copy(i),a.quaternion.copy(r),a.scale.copy(o),a.geometry.computeBoundingBox(),a.geometry.computeBoundingSphere(),a.updateMatrixWorld(!0),a.worldMatrix=a.matrix,this.drawScene.add(a))}this.viewer.render(),this.viewer.dispatchEvent({type:"addFileGeom"})},be.prototype.addMesh=function(e){this.viewer.selectionManager.clearSelection(),this.deselectAllMesh(!0),this.selectMesh([e],!1)},be.prototype.addPoint=function(e,t){this.currentMesh=new THREE.Mesh(new THREE.SphereGeometry(this.PointSize),this.defaultMeshMaterial),this.currentMesh.objectType="Point",this.currentMesh.position.set(e.x,e.y,e.z),this.currentMesh.geometry.computeBoundingBox(),this.currentMesh.geometry.computeBoundingSphere(),this.currentMesh.updateMatrixWorld(!0),this.drawScene.add(this.currentMesh),t&&(this.currentMesh.name="点"+this.pointIdx++,this.currentMesh.isDrawGeom=!0,this.currentMesh.worldMatrix=this.currentMesh.matrix,this.lastMesh=this.currentMesh,this.currentMesh=null,this.addMesh(this.lastMesh.uuid),this.notifyCreateMesh(this.lastMesh),this.drawGeomPosMap.set(this.lastMesh.uuid,this.lastMesh.matrix.clone())),this.viewer.render()},be.prototype.addLine=function(e,t,n){0==t?(this.currentMesh=new THREE.Line(new THREE.BufferGeometry,this.defaultLineMaterial),this.currentMesh.objectType="Line",this.currentMesh.geometry.addAttribute("position",new THREE.BufferAttribute(new Float32Array(3*this.ARC_SEGMENTS),3)),this.needAddScene=!0):(t=new THREE.LineCurve3(this.drawArray[0],this.drawArray[1]).getPoints(this.ARC_SEGMENTS),this.currentMesh.geometry.attributes.position.copyVector3sArray(t),this.currentMesh.geometry.attributes.position.needsUpdate=!0,this.currentMesh.geometry.computeBoundingBox(),this.currentMesh.geometry.computeBoundingSphere(),this.needAddScene&&(this.needAddScene=!1,this.drawScene.add(this.currentMesh)),n&&(this.currentMesh.name="直线"+this.lineIdx++,this.currentMesh.isDrawGeom=!0,this.currentMesh.worldMatrix=this.currentMesh.matrix,this.lastMesh=this.currentMesh,this.currentMesh=null,this.addMesh(this.lastMesh.uuid),this.notifyCreateMesh(this.lastMesh)),this.viewer.render())},be.prototype.addArc=function(e,t){0==e?(this.currentMesh=new THREE.Line(new THREE.BufferGeometry,this.defaultLineMaterial),this.currentMesh.objectType="Arc",this.currentMesh.geometry.addAttribute("position",new THREE.BufferAttribute(new Float32Array(3*this.ARC_SEGMENTS),3)),this.needAddScene=!0):(1==e?(e=new THREE.LineCurve3(this.drawArray[0],this.drawArray[1]).getPoints(this.ARC_SEGMENTS),this.currentMesh.geometry.attributes.position.copyVector3sArray(e)):(e=this.cricle3(this.drawArray[0],this.drawArray[1],this.drawArray[2],this.ARC_SEGMENTS),this.currentMesh.geometry.attributes.position.copyVector3sArray(e)),this.currentMesh.geometry.attributes.position.needsUpdate=!0,this.currentMesh.geometry.computeBoundingBox(),this.currentMesh.geometry.computeBoundingSphere(),this.needAddScene&&(this.needAddScene=!1,this.drawScene.add(this.currentMesh)),t&&(this.currentMesh.name="圆弧"+this.arcIdx++,this.currentMesh.isDrawGeom=!0,this.currentMesh.worldMatrix=this.currentMesh.matrix,this.lastMesh=this.currentMesh,this.currentMesh=null,this.addMesh(this.lastMesh.uuid),this.notifyCreateMesh(this.lastMesh)),this.viewer.render())},be.prototype.addSpline=function(e,t){0==e?(this.currentMesh=new THREE.Line(new THREE.BufferGeometry,this.defaultLineMaterial),this.currentMesh.objectType="Spline",this.currentMesh.geometry.addAttribute("position",new THREE.BufferAttribute(new Float32Array(3*this.ARC_SEGMENTS),3)),this.needAddScene=!0):((e=new THREE.CatmullRomCurve3(this.drawArray)).curveType="catmullrom",e=e.getPoints(this.ARC_SEGMENTS),this.currentMesh.geometry.attributes.position.copyVector3sArray(e),this.currentMesh.geometry.attributes.position.needsUpdate=!0,this.currentMesh.geometry.computeBoundingBox(),this.currentMesh.geometry.computeBoundingSphere(),this.needAddScene&&(this.needAddScene=!1,this.drawScene.add(this.currentMesh)),t&&(this.currentMesh.name="样条线"+this.splineIdx++,this.currentMesh.isDrawGeom=!0,this.currentMesh.worldMatrix=this.currentMesh.matrix,this.lastMesh=this.currentMesh,this.currentMesh=null,this.addMesh(this.lastMesh.uuid),this.notifyCreateMesh(this.lastMesh)),this.viewer.render())},be.prototype.endSpline=function(){"Spline"==this.drawType&&this.currentMesh&&(this.drawArray.length>this.drawCount&&this.drawArray.pop(),2<=this.drawArray.length?this.addSpline(1,!0):this.clearUnCompleteMesh(),this.drawArray=[],this.drawCount=0)},be.prototype.cricle3=function(e,t,n,i){var r=(new THREE.Vector3).subVectors(t,e).normalize(),o=(new THREE.Vector3).subVectors(n,t).normalize(),a=(new THREE.Vector3).crossVectors(r,o);if(Math.abs(a.x)<1e-7&&Math.abs(a.y)<1e-7&&Math.abs(a.z)<1e-7)return l=new THREE.LineCurve3(e,t).getPoints(this.ARC_SEGMENTS/2),d=new THREE.LineCurve3(t,n).getPoints(this.ARC_SEGMENTS/2),l.concat(d);for(var s=[i],l=this.projectPlane.normal.clone(),d=l.angleTo(a)<1e-4,c=(new THREE.Vector3).crossVectors(r,a),o=(new THREE.Vector3).crossVectors(o,a),a=(new THREE.Vector3).addVectors(e,t).divideScalar(2),n=(new THREE.Vector3).addVectors(t,n).divideScalar(2),n=(new THREE.Vector3).subVectors(n,a).cross(o),o=(new THREE.Vector3).crossVectors(c,o),n=n.dot(o)/o.dot(o),h=(new THREE.Vector3).copy(a).addScaledVector(c,n),u=h.distanceTo(e),p=(new THREE.Vector3).subVectors(e,h).normalize(),o=(new THREE.Vector3).subVectors(t,h).normalize(),a=(new THREE.Vector3).subVectors(h,t).normalize(),c=(new THREE.Vector3).crossVectors(r,a).normalize(),f=p.angleTo(o),m=(d==l.angleTo(c)<1e-4&&(f=2*Math.PI-f),new THREE.Vector3),g=(new THREE.Vector3).copy(l),v=d?-1:1,A=0;A<i;A++)m.copy(p).applyAxisAngle(g,v*A/(i-1)*f).normalize(),s[A]=(new THREE.Vector3).copy(h).addScaledVector(m,u);return s},be.prototype.createDefaultPlane=function(e){var t=this.viewer.controls.getBoundingBox().getCenter(),n=this.viewer.camera.position.clone(),n=(new THREE.Vector3).subVectors(n,t).normalize();this.projectPlane=(new THREE.Plane).setFromNormalAndCoplanarPoint(n,t),this.useSelectPlane&&0==this.needSelectPlane&&e&&(this.viewer.dispatchEvent({type:"cancelSelPlane"}),this.useSelectPlane=!1)},be.prototype.createSelectPlane=function(e,t){var n=this.viewer.controls.getBoundingBox().getCenter(),i=this.viewer.camera.position.clone();(new THREE.Vector3).subVectors(i,n).normalize().angleTo(t)>=Math.PI/2&&t.negate(),this.projectPlane=(new THREE.Plane).setFromNormalAndCoplanarPoint(t,e),this.viewer.cameraControl.rotateToPlane(this.projectPlane),this.isDrawType()?this.viewer.onChangeCursor("OpDrawGeom"):this.viewer.onChangeCursor("OpOrbit")},be.prototype.createPlaneFace=function(e,t){e=this.OpUtils.createFace(e,t);return e.updateMatrixWorld(!0),e},be.prototype.clearParams=function(){this.drawArray=[],this.drawCount=0,this.needAddScene=!1,this.needSelectPlane=!1},be.prototype.clearUnCompleteMesh=function(){this.currentMesh&&(this.needAddScene||(this.drawScene.remove(this.currentMesh),this.currentMesh.geometry.dispose()),this.clearParams(),this.currentMesh=null)},be.prototype.clearPreSelectPlane=function(){this.preSelectPlaneInfo=null,this.preSelectPlaneObj&&(this.drawScene.remove(this.preSelectPlaneObj),this.preSelectPlaneObj=null,this.viewer.render())},be.prototype.clearSelectPlane=function(){this.selectPlaneObj&&(this.drawScene.remove(this.selectPlaneObj),this.selectPlaneObj=null,this.viewer.render())},be.prototype.notifyCreateMesh=function(e){this.viewer.dispatchEvent({type:"drawGeom",uuid:e.uuid,name:e.name,id:e.objectType}),this.viewer.render()},be.prototype.removeMesh=function(e,t){for(var n=!1,i=0;i<e.length;i++)for(var r=0;r<this.drawScene.children.length;r++){var o=this.drawScene.children[r];if(o.uuid==e[i]){this.selectMeshMap.has(e[i])&&this.selectMeshMap.delete(e[i]),this.drawGeomPosMap.has(e[i])&&this.drawGeomPosMap.delete(e[i]),n=!0,this.drawScene.remove(o),o.geometry.dispose();break}}n&&0!=t&&this.viewer.dispatchEvent({type:"removeGeom"}),n&&(this.viewer.startMove(),this.viewer.drawTraceUpdate(),this.viewer.render())},be.prototype.hideMesh=function(e){for(var t=0;t<this.drawScene.children.length;t++){var n=this.drawScene.children[t];if(n.uuid==e){n.visible=!1,this.deselectMesh([e],!1),this.viewer.render();break}}},be.prototype.showMesh=function(e){for(var t=0;t<this.drawScene.children.length;t++){var n=this.drawScene.children[t];if(n.uuid==e){n.visible=!0,this.viewer.render();break}}},be.prototype.hideAllMesh=function(){this.deselectAllMesh();for(var e=0;e<this.drawScene.children.length;e++)this.drawScene.children[e].isDrawGeom&&(this.drawScene.children[e].visible=!1);this.viewer.render()},be.prototype.showAllMesh=function(){for(var e=0;e<this.drawScene.children.length;e++)this.drawScene.children[e].isDrawGeom&&(this.drawScene.children[e].visible=!0);this.viewer.render()},be.prototype.hasMeshSelected=function(e){return this.selectMeshMap.has(e)},be.prototype.selectMesh=function(e,t){for(var n=!1,i=0;i<e.length;i++)if(!this.selectMeshMap.has(e[i]))for(var r=0;r<this.drawScene.children.length;r++){var o=this.drawScene.children[r];if(o.isDrawGeom&&o.uuid==e[i]&&1==o.visible){"Point"==o.objectType?o.material=this.selectMeshMaterial:o.material=this.selectLineMaterial,this.selectMeshMap.set(e[i],o),n=!0;break}}n&&0!=t&&this.viewer.dispatchEvent({type:"selectGeom"}),n&&(this.viewer.startMove(),this.viewer.drawTraceUpdate(),this.viewer.render())},be.prototype.deselectMesh=function(e,t){for(var n,i=!1,r=0;r<e.length;r++)this.selectMeshMap.has(e[r])&&("Point"==(n=this.selectMeshMap.get(e[r])).objectType?n.material=this.defaultMeshMaterial:n.material=this.defaultLineMaterial,this.selectMeshMap.delete(e[r]),i=!0);i&&0!=t&&this.viewer.dispatchEvent({type:"deselectGeom"}),i&&(this.viewer.startMove(),this.viewer.drawTraceUpdate(),this.viewer.render())},be.prototype.deselectAllMesh=function(e){var n;0<this.selectMeshMap.size&&((n=this).selectMeshMap.forEach(function(e,t){"Point"==e.objectType?e.material=n.defaultMeshMaterial:e.material=n.defaultLineMaterial}),this.selectMeshMap.clear(),e&&this.viewer.dispatchEvent({type:"deselectAllGeom"}),this.viewer.startMove(),this.viewer.drawTraceUpdate(),this.viewer.render())},be.prototype.modifyMeshName=function(e,t){for(var n=0;n<this.drawScene.children.length;n++){var i=this.drawScene.children[n];if(i.uuid==e){i.name=t;break}}},be.prototype.getAllMesh=function(){for(var e=[],t=0;t<this.drawScene.children.length;t++){var n=this.drawScene.children[t];n.isDrawGeom&&e.push({uuid:n.uuid,name:n.name,id:n.objectType,visible:n.visible})}return e},be.prototype.getAllSelectMesh=function(){var n=[];return this.selectMeshMap.forEach(function(e,t){n.push({uuid:e.uuid,name:e.name,id:e.objectType,visible:e.visible})}),n},be.prototype.getAllSelectObject=function(){var n=[];return this.selectMeshMap.forEach(function(e,t){n.push(e)}),n},be.prototype.resetPosition=function(e){for(var t=0;t<e.length;t++)for(var n=e[t].uuid,i=0;i<this.drawScene.children.length;i++){var r,o=this.drawScene.children[i];o.uuid==n&&("Point"==o.objectType?(r=this.drawGeomPosMap.get(n))&&(o.matrix.copy(r),o.matrixAutoUpdate=!1,o.applyMatrix(new THREE.Matrix4),o.matrixAutoUpdate=!0,o.updateMatrixWorld(!0)):(o.matrix.identity(),o.matrixAutoUpdate=!1,o.applyMatrix(new THREE.Matrix4),o.matrixAutoUpdate=!0,o.updateMatrixWorld(!0)))}this.viewer.render()},be.prototype.hasLineGeoms=function(){if(this.drawGeomVisible)for(var e=0;e<this.drawScene.children.length;e++)if(("Line"==this.drawScene.children[e].objectType||"Arc"==this.drawScene.children[e].objectType||"Spline"==this.drawScene.children[e].objectType)&&1==this.drawScene.children[e].visible)return!0;return!1},(xe.prototype=Object.create(g.prototype)).init=function(){this.viewer.selectionManager.clearSelection(),this.viewer.controls.staticDrawGeomOp&&(this.viewer.controls.staticDrawGeomOp.deselectAllMesh(!0),this.viewer.drawGeomSetTraceMode(!0)),this.setSelectBodyByRect(!0),this.postInfo(1),this.viewer.render()},xe.prototype.release=function(){this.postInfo(0),this.viewer.container.removeChild(this.drawTracePrompt),this.drawTracePrompt=null,this.viewer.drawGeomSetTraceMode(!1),this.clipTransRotControl&&(this.clipTransRotControl.removeEventListener("mouseUp",this.objectMouseUp),this.clipTransRotControl.removeEventListener("mouseDown",this.objectMouseDown),this.clipTransRotControl.removeEventListener("objectChange",this.objectChange),this.drawTraceGroup.remove(this.clipTransRotControl),this.clipTransRotControl.visible=!1,this.clipTransRotControl.dispose(),this.clipTransRotControl=null),this.showLine&&(this.drawTraceGroup.remove(this.showLine),this.showLine.geometry.dispose(),this.showLine.material.dispose(),this.showLine=null),this.drawTraceGroup=null,this.viewer.render(),this.setSelectBodyByRect(!0),g.prototype.release.call(this)},xe.prototype.exitWindow=function(){this.viewer.dispatchEvent({type:"drawTrace",ready:!1}),this.objectForInsert=!1,this.objectMove=!1,this.tEnd=-1,this.tCur=0,this.lastPosition=null,this.selGeomUUid=null,this.setSelectBodyByRect(!0)},xe.prototype.exitDrawTrace=function(){this.viewer.dispatchEvent({type:"exitDrawTrace"}),this.setSelectBodyByRect(!0)},xe.prototype.postInfo=function(e){var t,n,i;this.drawTracePrompt&&(t="",n="en"==Se.getLanguage(),i=Se.isMobileDevice()?42:22,1===e&&(t=n?"Click to select geometry":"单击确定模型和几何"),this.InfoType=e,this.drawTracePrompt.style.height=i+"px",this.drawTracePrompt.style.display="none",this.drawTracePrompt.style.color="#000000",this.drawTracePrompt.innerHTML=t)},xe.prototype.renderModel=function(){this.drawTraceVisible&&this.drawTraceGroup&&0<this.drawTraceGroup.children.length&&this.viewer.renderer.render(this.drawTraceGroup,this.viewer.camera)},xe.prototype.onNMouseMove=function(e){this.drawTracePrompt&&!Se.isMobileDevice()&&(this.drawTracePrompt.style.display=0<this.InfoType?"block":"none",this.drawTracePrompt.style.left=e.clientX+16+"px",this.drawTracePrompt.style.top=e.clientY+18+"px"),g.prototype.onNMouseMove.call(this,e)},xe.prototype.onLMouseClick=function(e){this.objectForInsert||(g.prototype.onLMouseClick.call(this,e),this.update())},xe.prototype.onLMouseDbClick=function(e){this.objectForInsert||g.prototype.onLMouseDbClick.call(this,e)},xe.prototype.onLMouseMove=function(e){this.drawTracePrompt&&!Se.isMobileDevice()&&(this.drawTracePrompt.style.display=0<this.InfoType?"block":"none",this.drawTracePrompt.style.left=e.clientX+16+"px",this.drawTracePrompt.style.top=e.clientY+18+"px"),this.objectMove||g.prototype.onLMouseMove.call(this,e)},xe.prototype.onMMouseMove=function(e){this.drawTracePrompt&&!Se.isMobileDevice()&&(this.drawTracePrompt.style.display=0<this.InfoType?"block":"none",this.drawTracePrompt.style.left=e.clientX+16+"px",this.drawTracePrompt.style.top=e.clientY+18+"px"),this.objectForInsert||g.prototype.onMMouseMove.call(this,e)},xe.prototype.onRMouseMove=function(e){this.drawTracePrompt&&!Se.isMobileDevice()&&(this.drawTracePrompt.style.display=0<this.InfoType?"block":"none",this.drawTracePrompt.style.left=e.clientX+16+"px",this.drawTracePrompt.style.top=e.clientY+18+"px"),g.prototype.onRMouseMove.call(this,e)},xe.prototype.update=function(){var e=this.viewer.selectionManager.getSelectedObjects(),t=this.viewer.controls.staticDrawGeomOp?this.viewer.controls.staticDrawGeomOp.getAllSelectObject():[];0<e.length&&1==t.length&&"Point"!=t[0].objectType?(this.drawTraceVisible=!1,this.postInfo(0),this.updateTrace(e,t[0]),this.selGeomUUid=t[0].uuid,this.drawTraceVisible=!0):(this.viewer.controls.staticDrawGeomOp&&!this.viewer.controls.staticDrawGeomOp.hasLineGeoms()||this.viewer.ndsModel.isBodyAllChildHidden(this.viewer.ndsModel.rootBodyNode)?this.exitDrawTrace():this.objectForInsert&&this.exitWindow(),this.postInfo(1),this.drawTraceVisible=!1)},xe.prototype.updateTrace=function(e,t){for(var n=new THREE.Box3,i=null,r=0;r<e.length;r++)(i=this.viewer.ndsModel.getBodyBoundingBox(e[r]))&&!i.isEmpty()&&(n.expandByPoint(i.max),n.expandByPoint(i.min));var o=n.getCenter(),a=(this.startPoint.copy(o),t.geometry.attributes.position.array),s=(new THREE.Vector3).fromArray(a).applyMatrix4(t.matrix),a=(new THREE.Vector3).fromArray(a,a.length-3).applyMatrix4(t.matrix),a=(new THREE.Vector3).subVectors(a,s),l=(new THREE.Vector3).copy(o).add(a),d=(new THREE.Vector3).subVectors(l,o),c=(new THREE.Vector3).copy(d).normalize(),d=(this.tEnd=d.dot(c),this.lineNormal.copy(c),this.endPoint.copy(l),(new THREE.Matrix4).makeTranslation(o.x-s.x,o.y-s.y,o.z-s.z)),l=this.updateShowLine(t,d,a.length()),s=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),c),t=(new THREE.Matrix4).makeRotationFromQuaternion(s),d=(new THREE.Matrix4).makeTranslation(o.x,o.y,o.z);this.updateTRControl(o,t,d,l)},xe.prototype.updateShowLine=function(e,t,n){for(var i=e.geometry.clone(),r=i.attributes.position.array,o=new Float32Array(r.length/3),a=(o[0]=0,new THREE.Vector3),s=new THREE.Vector3,l=1;l<r.length/3;l++){a.fromArray(r,3*(l-1)),s.fromArray(r,3*l);var d=a.distanceTo(s);o[l]+=o[l-1]+d}i.addAttribute("lineDistance",new THREE.BufferAttribute(o,1));var c=o[o.length-1],h=Math.floor(c/100),h=(this.defaultLineMaterial.dashSize=h<10?10:h,this.defaultLineMaterial.gapSize=this.defaultLineMaterial.dashSize/3,null==this.showLine?(this.showLine=new THREE.Line(i,this.defaultLineMaterial),this.showLine.matrixAutoUpdate=!1,this.drawTraceGroup.add(this.showLine)):(this.drawTraceGroup.remove(this.showLine),this.showLine.geometry.dispose(),this.showLine=new THREE.Line(i,this.defaultLineMaterial),this.showLine.matrixAutoUpdate=!1,this.drawTraceGroup.add(this.showLine),this.showLine.matrix.identity()),this.showLine.geometry.computeBoundingBox(),this.showLine.geometry.computeBoundingSphere(),this.showLine.applyMatrix(e.matrix),this.showLine.applyMatrix(t),this.showLine.updateMatrixWorld(!0),n/c);return.01<h?1:.001<h?.2:.01},xe.prototype.updateTRControl=function(e,t,n,i){null==this.objectBox?(this.objectBox=new THREE.Object3D,this.objectBox.visible=!0,this.objectBox.matrixAutoUpdate=!1):(this.objectBox.matrixAutoUpdate=!1,this.objectBox.matrix.identity()),this.objectBox.applyMatrix(t),this.objectBox.applyMatrix(n),this.objectBox.updateMatrixWorld(!0),this.objectBox.matrixAutoUpdate=!0,null==this.clipTransRotControl&&(this.clipTransRotControl=new _(this.viewer.camera,this.domElement,["translateX"],!1),this.clipTransRotControl.setSpace("local"),this.clipTransRotControl.setSize(.6),this.clipTransRotControl.attach(this.objectBox),this.clipTransRotControl.addEventListener("mouseUp",this.objectMouseUp),this.clipTransRotControl.addEventListener("mouseDown",this.objectMouseDown),this.clipTransRotControl.addEventListener("objectChange",this.objectChange),this.drawTraceGroup.add(this.objectBox),this.drawTraceGroup.add(this.clipTransRotControl)),this.clipTransRotControl.setTranslateScale(i),this.clipTransRotControl.visible=!0,this.clipTransRotControl.position.copy(e),this.clipTransRotControl.update(),this.clipTransRotControl.updateMatrixWorld(!0),this.viewer.render()},xe.prototype.updateModel=function(e){if(this.showLine){var t=this.showLine.geometry.attributes.position.array,e=Math.floor((t.length-1)/3*e),t=(new THREE.Vector3).fromArray(t,3*e).applyMatrix4(this.showLine.matrix),n=(null==this.lastPosition&&(this.lastPosition=this.startPoint.clone()),(new THREE.Matrix4).makeTranslation(t.x-this.lastPosition.x,t.y-this.lastPosition.y,t.z-this.lastPosition.z)),i=this.viewer.selectionManager.getSelectedleafObjects();if(this.viewer.ndsModel)for(var r=0;r<i.length;++r){var o=i[r],a=(o.worldMatrix=this.viewer.ndsModel.calculateNodeWorldMatrix(o),o.worldMatrix.premultiply(n),o.parent?this.viewer.ndsModel.calculateNodeWorldMatrix(o.parent):new THREE.Matrix4),s=new THREE.Matrix4,a=(s.getInverse(a),o.worldMatrix.premultiply(s));this.viewer.ndsModel.updateNodeMatrix(o.uuid,a.toArray())}this.lastPosition=t.clone(),this.viewer.render()}},xe.prototype.getPosArray=function(){var e={selUUid:this.selGeomUUid,array:null};if(this.showLine){var t=this.showLine.geometry.attributes.position.array,n=Math.floor(t.length/3*this.tCur),i=new THREE.Vector3;if(0==n||1==n)e.array=new Float32Array(6),i.fromArray(t,0).applyMatrix4(this.showLine.matrix),e.array[0]=i.x,e.array[1]=i.y,e.array[2]=i.z,e.array[3]=i.x,e.array[4]=i.y,e.array[5]=i.z;else{e.array=new Float32Array(3*n);for(var r=0;r<n;r++)i.fromArray(t,3*r).applyMatrix4(this.showLine.matrix),e.array[3*r]=i.x,e.array[3*r+1]=i.y,e.array[3*r+2]=i.z}}return e};function Mi(e){return"("+e.x+";"+e.y+")"}(Ie.prototype=Object.create(g.prototype)).init=function(){this.setSelectBodyByRect(!1)},Ie.prototype.release=function(){this.postInfo(0),this.viewer.container.removeChild(this.piovtPrompt),this.piovtPrompt=null,this.piovtType="",this.setSelectBodyByRect(!0),this.viewer.render(),g.prototype.release.call(this)},Ie.prototype.setPiovtType=function(e){"Point"==(this.piovtType=e)?(this.postInfo(1),this.allowType=["point"]):"Line"==e?(this.postInfo(2),this.allowType=["line","circle","cylinder"]):"Box"==e?(this.allowType=[],this.setObjectPoivtBox()):this.allowType=[]},Ie.prototype.exitPiovt=function(){this.postInfo(0),this.viewer.dispatchEvent({type:"exitPiovt"})},Ie.prototype.postInfo=function(e){if(this.piovtPrompt){var t="",n="en"==Se.getLanguage(),i=Se.isMobileDevice()?42:22;switch(e){case 1:t=n?"Click to select geometry":"单击确定点";break;case 2:t=n?"Click to select geometry":"单击确定直线/轴"}this.InfoType=e,this.piovtPrompt.style.height=i+"px",this.piovtPrompt.style.display="none",this.piovtPrompt.style.color="#000000",this.piovtPrompt.innerHTML=t}},Ie.prototype.renderModel=function(){this.piovtScene&&0<this.piovtScene.children.length&&(this.renderScale(this.piovtScene),this.viewer.renderer.render(this.piovtScene,this.viewer.camera))},Ie.prototype.renderScale=function(e){for(var t=0;t<e.children.length;t++){var n=e.children[t];if(null!=n.objectType)switch(n.objectType){case"Point":this.OpUtils.setPointScale(n,this.PointSize);break;case"Group":this.renderScale(n)}}},Ie.prototype.onNMouseMove=function(e){this.piovtPrompt&&!Se.isMobileDevice()&&(this.piovtPrompt.style.display=0<this.InfoType?"block":"none",this.piovtPrompt.style.left=e.clientX+16+"px",this.piovtPrompt.style.top=e.clientY+18+"px"),this.processEvent(e,!0)},Ie.prototype.onLMouseClick=function(e){this.processEvent(e,!1)},Ie.prototype.onLMouseDbClick=function(e){},Ie.prototype.onLMouseMove=function(e){this.piovtPrompt&&!Se.isMobileDevice()&&(this.piovtPrompt.style.display=0<this.InfoType?"block":"none",this.piovtPrompt.style.left=e.clientX+16+"px",this.piovtPrompt.style.top=e.clientY+18+"px"),g.prototype.onLMouseMove.call(this,e)},Ie.prototype.onMMouseMove=function(e){this.piovtPrompt&&!Se.isMobileDevice()&&(this.piovtPrompt.style.display=0<this.InfoType?"block":"none",this.piovtPrompt.style.left=e.clientX+16+"px",this.piovtPrompt.style.top=e.clientY+18+"px"),g.prototype.onMMouseMove.call(this,e)},Ie.prototype.onRMouseMove=function(e){this.piovtPrompt&&!Se.isMobileDevice()&&(this.piovtPrompt.style.display=0<this.InfoType?"block":"none",this.piovtPrompt.style.left=e.clientX+16+"px",this.piovtPrompt.style.top=e.clientY+18+"px"),g.prototype.onRMouseMove.call(this,e)},Ie.prototype.processEvent=function(e,t){var e=this.OpUtils.getViewClientCoords(e),n=this.OpUtils.doRaycasterPick(e.x,e.y,!0);if(n&&0!=n.length){n=n[0];if(n){var i=this.OpUtils.getSelectInfoFromIntersect(n);if(i){if(-1!=this.allowType.indexOf("point"))return o=this.OpUtils.getSnappingPntEx(n),t?void(o?null!=this.preSelectInfo&&this.isTwoSelectInfoSame(this.preSelectInfo,i)||(this.clearPreSelect(),this.preSelectInfo={isSnap:!0,point:o.clone()},(r=this.OpUtils.createPointMesh(o,_e.preSelectedFaceMaterial,this.PointSize)).updateMatrixWorld(!0),this.piovtScene.add(r),this.preSelectObj=r):this.clearPreSelect()):(this.clearPreSelect(),void this.setObjectPiovtPoint(o||i.intersect));if(-1!=this.allowType.indexOf(i.type))return t?void(null!=this.preSelectInfo&&this.isTwoSelectInfoSame(this.preSelectInfo,i)||(this.clearPreSelect(),r=null,"line"==(this.preSelectInfo=i).type||"circle"==i.type?r=this.OpUtils.createLine(i,!0):"cylinder"==i.type&&(r=this.OpUtils.createFace(i,!0)),r&&(r.updateMatrixWorld(!0),this.piovtScene.add(r),this.preSelectObj=r))):void((o=this.OpUtils.getLineStartEndPoints(i))&&(this.clearPreSelect(),this.setObjectPiovtLine(o.start,o.end)))}else if(-1!=this.allowType.indexOf("point")&&!t)return this.clearPreSelect(),void this.setObjectPiovtPoint(n.point)}}else this.clearPreSelect();var r=this.OpUtils.doRaycasterGeomPick(e.x,e.y);if(r&&0!=r.length){var i=r[0];if(i){var o=i.object;if(-1!=this.allowType.indexOf("point"))return n=null,"Point"==o.objectType&&(n=o.position.clone()),t?void(n?null!=this.preSelectInfo&&this.isTwoSelectInfoSame(this.preSelectInfo,o)||(this.clearPreSelect(),this.preSelectInfo={isSnap:!0,point:n.clone()},(r=this.OpUtils.createPointMesh(n,_e.preSelectedFaceMaterial,this.PointSize)).updateMatrixWorld(!0),this.piovtScene.add(r),this.preSelectObj=r):this.clearPreSelect()):(this.clearPreSelect(),void this.setObjectPiovtPoint(n||i.point));if(-1!=this.allowType.indexOf("line")&&"Line"==o.objectType)if(t){if(null==this.preSelectInfo||!this.isTwoSelectInfoSame(this.preSelectInfo,o))return this.clearPreSelect(),void("Line"==(this.preSelectInfo=o).objectType&&((r=new THREE.Line(o.geometry.clone(),_e.preSelectedEdgeMaterial)).applyMatrix(o.matrix),r.updateMatrixWorld(!0),this.piovtScene.add(r),this.preSelectObj=r))}else if("Line"==o.objectType)return this.clearPreSelect(),n=o.geometry.attributes.position.array,i=(new THREE.Vector3).fromArray(n).applyMatrix4(o.matrix),r=(new THREE.Vector3).fromArray(n,n.length-3).applyMatrix4(o.matrix),void this.setObjectPiovtLine(i,r)}}else this.clearPreSelect();!t&&"Point"==this.piovtType&&(n=this.viewer.controls.getBoundingBox().getCenter(),o=this.viewer.camera.position.clone(),i=(new THREE.Vector3).subVectors(o,n).normalize(),r=(new THREE.Plane).setFromNormalAndCoplanarPoint(i,n),t=this.OpUtils.clientCoordToModelCoordOnPlane(e.x,e.y,r))&&(this.clearPreSelect(),this.setObjectPiovtPoint(t))},Ie.prototype.isTwoSelectInfoSame=function(e,t){return e.isSnap&&t.isSnap?e.point.equals(t.point):!(e.isSnap&&null==t.isSnap||null==e.isSnap&&t.isSnap)&&(e.isDrawGeom&&t.isDrawGeom?e.uuid==t.uuid:!(e.isDrawGeom&&null==t.isDrawGeom||null==e.isDrawGeom&&t.isDrawGeom)&&this.OpUtils.isTwoTopolInfoTheSame(e,t))},Ie.prototype.clearPreSelect=function(){this.preSelectInfo=null,this.preSelectObj&&(this.piovtScene.remove(this.preSelectObj),this.preSelectObj=null,this.viewer.render())},Ie.prototype.setObjectPoivtBox=function(e){var t=e||this.viewer.selectionManager.getSelectedleafObjects();if(this.viewer.ndsModel)for(var n=0;n<t.length;++n){var i=t[n];this.viewer.piovtInfoMap.delete(i.uuid)}this.exitPiovt()},Ie.prototype.setObjectPiovtPoint=function(e){if(this.viewer.ndsModel){if(!this.isObjectsPiovtSame(this.selectedObjectUUID))return void this.setObjectPoivtBox();for(var t=0;t<this.selectedObjectUUID.length;++t){var n=this.selectedObjectUUID[t];this.viewer.piovtInfoMap.set(n,{type:"Point",center:e.clone()})}}this.exitPiovt()},Ie.prototype.setObjectPiovtLine=function(e,t){if(this.viewer.ndsModel){if(!this.isObjectsPiovtSame(this.selectedObjectUUID))return void this.setObjectPoivtBox();for(var n=0;n<this.selectedObjectUUID.length;++n){var i=this.selectedObjectUUID[n];this.viewer.piovtInfoMap.set(i,{type:"Line",center:(new THREE.Vector3).addVectors(t,e).multiplyScalar(.5),normal:(new THREE.Vector3).subVectors(t,e).normalize()})}}this.exitPiovt()},Ie.prototype.isObjectsPiovtSame=function(e){for(var t=[],n=0;n<e.length;++n){var i=this.viewer.piovtInfoMap.get(e[n]);i&&t.push(i)}for(var r=0;r<t.length-1;r++)for(var o=r+1;o<t.length;o++)if(!this.isPiovtSame(t[r],t[o]))return!1;return!0},Ie.prototype.isPiovtSame=function(e,t){return e.type==t.type&&("Point"==e.type?e.center.equals(t.center):"Line"==e.type?e.center.equals(t.center)&&e.normal.equals(t.normal):void 0)},Ie.prototype.isVector3Same=function(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.x-t.x)<1e-6&&Math.abs(e.x-t.x)<1e-6};var wi,bi,xi,Ii,$n=t(3),Ti=t.n($n),e=t(4),Si=t.n(e),Bi=(ve.Element=function(e){this.type="Element",this.domElement=void 0!==(e=e||{}).element?document.createElement(e.element):document.createElement("div");var n=this.domElement,i=(void 0!==e.id&&(n.id=e.id),void 0!==e.name&&(n.name=e.name),void 0!==e.className&&(n.className=e.className),void 0!==e.callbackEvent&&this.addEventListener("event",e.callbackEvent),this.style={},this.subElements={},this.childElements=new Array,this.style),r=this;this.setSize=function(e,t){n.style.width=e+"px",n.style.height=t+"px",i.width=e,i.height=t},this.setWidth=function(e){n.style.width=e+"px",i.width=e},this.setHeight=function(e){n.style.height=e+"px",i.height=e},this.setPos=function(e,t){n.style.left=e+"px",n.style.top=t+"px",i.left=e,i.top=t},this.setLeft=function(e){n.style.left=e+"px",i.left=e},this.setTop=function(e){n.style.top=e+"px",i.top=e},this.setRight=function(e){n.style.right=e+"px",i.right=e},this.setBottom=function(e){n.style.bottom=e+"px",i.bottom=e},this.setBgColor=function(e){n.style.backgroundColor=e,i.opacity=e},this.setOpacity=function(e){n.style.opacity=e,i.opacity=e},this.deleteOpacity=function(){n.style.opacity="",delete i.opacity},this.setPosition=function(e){n.style.position=e,i.position=e},this.setBorder=function(e){n.style.border=e,i.border=e},this.setMargin=function(e){n.style.marginLeft=e.left+"px",n.style.marginRight=e.right+"px",n.style.marginTop=e.top+"px",n.style.marginBottom=e.bottom+"px",i.margin=e},this.setBorderRadius=function(e){n.style.borderRadius=e+"px",i.borderRadius=e},this.setPadding=function(e){n.style.paddingLeft=e.left+"px",n.style.paddingRight=e.right+"px",n.style.paddingTop=e.top+"px",n.style.paddingBottom=e.bottom+"px",i.padding=e},this.setListStyle=function(e){n.style.listStyle=e,i.listStyle=e},this.setTextAlign=function(e){n.style.textAlign=e,i.textAlign=e},this.setFloat=function(e){n.style.styleFloat=e,i.styleFloat=e,n.style.cssFloat=e,i.cssFloat=e},this.setCursor=function(e){n.style.cursor=e,i.cursor=e},this.setVisibility=function(e){n.style.visibility=e?"visible":"hidden",i.visibility=e},this.getVisibility=function(){return!(null==i.visibility||!i.visibility)},this.setDisplay=function(e){n.style.display=e?"":"none",i.display=e},this.setBgImage=function(e){n.style.backgroundImage=e,i.bgImage=e},this.setBgPosition=function(e){n.style.backgroundPosition=e,i.backgroundPosition=e},this.setBgRepeat=function(e){n.style.backgroundRepeat=e,i.backgroundRepeat=e},this.setText=function(e){n.innerHTML=e,i.text=e},this.setTitle=function(e){n.title=e,i.title=e},this.addEvent=function(e,t){n.addEventListener(e,r.onEvent,t)},this.removeEvent=function(e,t){n.removeEventListener(e,r.onEvent,t)},this.onEvent=function(e){r.dispatchEvent({type:"event",event:e})},this.addSubElement=function(e){n.appendChild(e.domElement)},this.addChildElement=function(e){r.childElements.push(new Se.map(e.domElement.id,e))},this.getChildElement=function(e){for(var t=0;t<r.childElements.length;++t)if(r.childElements[t].key==e)return r.childElements[t].value},this.updateChildElement=function(e,t){for(var n=0;n<r.childElements.length;++n)r.childElements[n].key==e&&(r.childElements[n].key=t)},this.getChildElementIndex=function(e){for(var t=0;t<r.childElements.length;++t)if(r.childElements[t].key==e)return t;return-1},this.release=function(){n.parentElement.removeChild(n)},void 0!==e.img&&r.setBgImage(e.img),void 0!==e.text&&r.setText(e.text),void 0!==e.ttTitle&&r.setTitle(e.ttTitle)},ve.Element.prototype=Object.create(THREE.EventDispatcher.prototype),ve.Titlebar=function(e){ve.Element.call(this,e=e||{}),this.addEvent("mouseenter",!1),this.addEvent("mouseleave",!1),this.addEvent("mouseover",!1),this.addEvent("mouseout",!1),this.type="Titlebar";var t=this.domElement,n=this.style,i="titlebar-title",r="titlebar-button",o=(void 0!==e.titleClassName&&(i=e.titleClassName),void 0!==e.buttonClassName&&(r=e.buttonClassName),new ve.Element({className:i})),e=(t.appendChild(o.domElement),this.subElements.title=o,new ve.Button({className:r,text:"x"}));t.appendChild(e.domElement),this.subElements.btnClose=e,this.setTitle=function(e){o.domElement.innerHTML=e,n.text=e}},ve.Titlebar.prototype=Object.create(ve.Element.prototype),ve.Dialog=function(n){n=n||{},ve.Element.call(this,n),this.addEvent("mouseenter",!1),this.addEvent("mouseleave",!1),this.addEvent("mouseover",!1),this.addEvent("mouseout",!1),this.type="Dialog",this.subElements.title=null,this.subElements.content=null,this.subElements.scrollbar=null;var i=this.domElement,r=(this.style,this),e=this.subElements.title,o=this.subElements.content,a=this.subElements.scrollbar;function t(){var e=new ve.Titlebar,t=e.subElements.btnClose.domElement;return 1==n.noCloseButton?e.domElement.removeChild(t):t.addEventListener("click",r.onClose,!1),i.appendChild(e.domElement),r.subElements.title=e}function s(){var e=new ve.Scrollbar({className:"scrollbar right"});return i.appendChild(e.domElement),r.subElements.scrollbar=e}this.onClose=function(e){r.setVisibility(!1),r.dispatchEvent({type:"close",event:e})},null!=(e=void 0===n.noTitlebar||1!=n.noTitlebar?t():e)&&null!=n.title&&e.setTitle(n.title),void 0!==n.noScrollbar&&1==n.noScrollbar||(a=s()),this.setContent=function(e){var t,n=a?a.domElement:i;null!=o&&null!=(t=o.domElement)&&n.removeChild(t),n.appendChild(e.domElement),o=e,r.subElements.content=o}},ve.Dialog.prototype=Object.create(ve.Element.prototype),ve.Button=function(e){ve.Element.call(this,e=e||{}),this.addEvent("mouseenter",!1),this.addEvent("mouseleave",!1),this.addEvent("mouseover",!1),this.addEvent("mouseout",!1),Se.isMobileDevice()?this.addEvent("touchstart",!1):this.addEvent("click",!1),this.type="Button";var i=this.domElement,r=(this.style,this);this.setPopupElement=function(e){var t=i.parentNode,n=r.subElements.popupElement;null!=n&&null!=(n=n.domElement)&&t.removeChild(n),t.appendChild(e.domElement),r.subElements.popupElement=e},this.setTooltip=function(e){var t=i.parentNode,n=r.subElements.tooltip;null!=n&&null!=(n=n.domElement)&&t.removeChild(n),t.appendChild(e.domElement),r.subElements.tooltip=e},this.setPopupDialog=function(e){r.subElements.popupDialog=e}},ve.Button.prototype=Object.create(ve.Element.prototype),ve.Tooltip=function(e){ve.Element.call(this,e),this.type="Tooltip";this.domElement,this.style;void 0!==e.text&&this.setText(e.text)},ve.Tooltip.prototype=Object.create(ve.Element.prototype),ve.Toolbar=function(e){ve.Element.call(this,e=e||{}),this.addEvent("mouseenter",!1),this.addEvent("mouseleave",!1),this.addEvent("mouseover",!1),this.addEvent("mouseout",!1),this.type="Toolbar";var e=this.domElement,n=(this.style,new ve.Element({element:"ul"})),n=e.appendChild(n.domElement);this.addButton=function(e){e=e||{};var t=new ve.Element({element:"li"}),e=(null!=e.float&&(t.domElement.style.float=e.float),t=n.appendChild(t.domElement),new ve.Button(e));return t.appendChild(e.domElement),this.addChildElement(e),e}},ve.Toolbar.prototype=Object.create(ve.Element.prototype),ve.Table=function(e){(e=e||{}).element="table",ve.Element.call(this,e),this.addEvent("mouseenter",!1),this.addEvent("mouseleave",!1),this.addEvent("mouseover",!1),this.addEvent("mouseout",!1),this.type="Table";var t=this.domElement,r=(this.style,this),o=new Array,a=new Array,n=t,i=(null!=e.scrollbar&&(n=e.scrollbar.domElement,t.appendChild(n)),new ve.Element({element:"thead"})),s=(n.appendChild(i.domElement),new ve.Element({element:"tbody"}));n.appendChild(s.domElement),this.addHeadRow=function(){var e=new ve.Element({element:"tr"});return i.domElement.appendChild(e.domElement),a.push({row:e,cols:new Array}),e},this.addHeadCol=function(e){if(null==(e=e||{}).element)return null;a.length<=0&&r.addHeadRow();var t=a[a.length-1].row,n=a[a.length-1].cols,i=new ve.Element({element:"th",className:e.className}),t=(t.domElement.appendChild(i.domElement),n.push(i),e.element);return i.domElement.appendChild(t.domElement),t},this.addRow=function(){var e=new ve.Element({element:"tr"});return s.domElement.appendChild(e.domElement),o.push({row:e,cols:new Array}),e},this.addCol=function(e){if(null==(e=e||{}).element)return null;o.length<=0&&r.addRow();var t=o[o.length-1].row,n=o[o.length-1].cols,i=new ve.Element({element:"td",className:e.className}),t=(t.domElement.appendChild(i.domElement),n.push(i),e.element);return i.domElement.appendChild(t.domElement),t}},ve.Table.prototype=Object.create(ve.Element.prototype),ve.Input=function(e){(e=e||{}).element="input",ve.Element.call(this,e),this.addEvent("click",!1),this.type="Input";var i=this.domElement,r=(this.style,this);void 0!==e.type&&(i.type=e.type),void 0!==e.multiple&&(i.multiple=e.multiple),this.setPopupElement=function(e){var t=i.parentNode,n=r.subElements.popupElement;null!=n&&null!=(n=n.domElement)&&t.removeChild(n),t.appendChild(e.domElement),r.subElements.popupElement=e},this.setTooltip=function(e){var t=i.parentNode,n=r.subElements.tooltip;null!=n&&null!=(n=n.domElement)&&t.removeChild(n),t.appendChild(e.domElement),r.subElements.tooltip=e},this.setPopupDialog=function(e){r.subElements.popupDialog=e}},ve.Input.prototype=Object.create(ve.Element.prototype),ve.Scrollbar=function(e){ve.Element.call(this,e=e||{}),this.type="Scrollbar"},ve.Scrollbar.prototype=Object.create(ve.Element.prototype),ve.Menu=function(e){ve.Element.call(this,e=e||{}),this.type="Menu";var t=this.domElement;this.style;this.addItem=function(e){e=new ve.Element(e=e||{});return e.addEvent("click",!1),this.addChildElement(e),t.appendChild(e.domElement),e}},ve.Menu.prototype=Object.create(ve.Element.prototype),ve.Slider=function(e){(e=e||{}).element="input",ve.Element.call(this,e),this.addEvent("mouseenter",!1),this.addEvent("mouseleave",!1),this.addEvent("mouseover",!1),this.addEvent("mouseout",!1),this.addEvent("click",!1),this.type="Slider";var i=this.domElement,r=(this.style,this);i.type="range",i.min=void 0!==e.min?e.min:"0",i.max=void 0!==e.max?e.max:"1",i.step=void 0!==e.step?e.step:"0.01",i.value=void 0!==e.value?e.value:"0",this.setTooltip=function(e){var t=i.parentNode,n=r.subElements.tooltip;null!=n&&null!=(n=n.domElement)&&t.removeChild(n),t.appendChild(e.domElement),r.subElements.tooltip=e}},ve.Slider.prototype=Object.create(ve.Element.prototype),ve.TextArea=function(e){(e=e||{}).element="textarea",ve.Element.call(this,e),this.addEvent("click",!1),this.type="textarea";var i=this.domElement,r=(this.style,this);void 0!==e.type&&(i.type=e.type),void 0!==e.multiple&&(i.multiple=e.multiple),this.setTooltip=function(e){var t=i.parentNode,n=r.subElements.tooltip;null!=n&&null!=(n=n.domElement)&&t.removeChild(n),t.appendChild(e.domElement),r.subElements.tooltip=e}},ve.TextArea.prototype=Object.create(ve.Element.prototype),1e-12),m={CW:1,CCW:-1,COLLINEAR:0},Pi=function(e,t){this.name="PointError",this.points=t=t||[],this.message=e||"Invalid Points!";for(var n=0;n<t.length;n++)this.message+=" "+Ci.toString(t[n])},Ci={};function Ri(e,t,n,i){t=(e.x-t.x)*(i.y-t.y)-(i.x-t.x)*(e.y-t.y);return!(-Bi<=t||(e.x-n.x)*(i.y-n.y)-(i.x-n.x)*(e.y-n.y)<=Bi)}function Oi(e,t){if(!e)throw new Error(t||"Assert Failed")}function v(e,t,n){e=(e.x-n.x)*(t.y-n.y)-(e.y-n.y)*(t.x-n.x);return-Bi<e&&e<Bi?m.COLLINEAR:0<e?m.CCW:m.CW}function Li(e,t,n){var i=t.x-e.x,t=t.y-e.y;return i*(n.x-e.x)+t*(n.y-e.y)<0}Ci.toString=function(e){var t=e.toString();return"[object Object]"===t?Mi(e):t},Ci.toStringBase=Mi,Ci.compare=function(e,t){return e.y===t.y?e.x-t.x:e.y-t.y},Ci.equals=function(e,t){return e.x===t.x&&e.y===t.y};function Di(e,t){this.head_=e,this.tail_=t,this.search_node_=e}function d(e,t){this.x=+e||0,this.y=+t||0,this._p2t_edge_list=null}var Hi=function(e,t){this.point=e,this.triangle=t||null,this.next=null,this.prev=null,this.value=e.x},Fi=(Di.prototype.head=function(){return this.head_},Di.prototype.setHead=function(e){this.head_=e},Di.prototype.tail=function(){return this.tail_},Di.prototype.setTail=function(e){this.tail_=e},Di.prototype.search=function(){return this.search_node_},Di.prototype.setSearch=function(e){this.search_node_=e},Di.prototype.findSearchNode=function(){return this.search_node_},Di.prototype.locateNode=function(e){var t=this.search_node_;if(e<t.value){for(;t=t.prev;)if(e>=t.value)return this.search_node_=t}else for(;t=t.next;)if(e<t.value)return this.search_node_=t.prev,t.prev;return null},Di.prototype.locatePoint=function(e){var t=e.x,n=this.findSearchNode(t),i=n.point.x;if(t===i){if(e!==n.point)if(e===n.prev.point)n=n.prev;else{if(e!==n.next.point)throw new Error("poly2tri Invalid AdvancingFront.locatePoint() call");n=n.next}}else if(t<i)for(;(n=n.prev)&&e!==n.point;);else for(;(n=n.next)&&e!==n.point;);return n&&(this.search_node_=n),n},d.prototype.toString=function(){return Ci.toStringBase(this)},d.prototype.toJSON=function(){return{x:this.x,y:this.y}},d.prototype.clone=function(){return new d(this.x,this.y)},d.prototype.set_zero=function(){return this.x=0,this.y=0,this},d.prototype.set=function(e,t){return this.x=+e||0,this.y=+t||0,this},d.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},d.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},d.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this},d.prototype.mul=function(e){return this.x*=e,this.y*=e,this},d.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},d.prototype.normalize=function(){var e=this.length();return this.x/=e,this.y/=e,e},d.prototype.equals=function(e){return this.x===e.x&&this.y===e.y},d.negate=function(e){return new d(-e.x,-e.y)},d.add=function(e,t){return new d(e.x+t.x,e.y+t.y)},d.sub=function(e,t){return new d(e.x-t.x,e.y-t.y)},d.mul=function(e,t){return new d(e*t.x,e*t.y)},d.cross=function(e,t){return"number"==typeof e?"number"==typeof t?e*t:new d(-e*t.y,e*t.x):"number"==typeof t?new d(t*e.y,-t*e.x):e.x*t.y-e.y*t.x},d.toString=Ci.toString,d.compare=Ci.compare,d.cmp=Ci.compare,d.equals=Ci.equals,d.dot=function(e,t){return e.x*t.x+e.y*t.y},{triangulate:function(e){e.initTriangulation(),e.createAdvancingFront(),function(e){var t,n=e.pointCount();for(t=1;t<n;++t)for(var i=e.getPoint(t),r=function(e,t){var n=e.locateNode(t),i=function(e,t,n){var i=new s(t,n.point,n.next.point),t=(i.markNeighbor(n.triangle),e.addToMap(i),new Hi(t));t.next=n.next,(t.prev=n).next.prev=t,n.next=t,Vi(e,i)||e.mapTriangleToNodes(i);return t}(e,t,n);t.x<=n.point.x+Bi&&_i(e,n);return function(e,t){var n=t.next;for(;n.next&&!Li(n.point,n.next.point,n.prev.point);)_i(e,n),n=n.next;n=t.prev;for(;n.prev&&!Li(n.point,n.next.point,n.prev.point);)_i(e,n),n=n.prev;t.next&&t.next.next&&(!function(e){var t=e.point.x-e.next.next.point.x,e=e.point.y-e.next.next.point.y;return Oi(0<=e,"unordered y"),0<=t||Math.abs(t)<e}(t)||!function(e,t){v(t.point,t.next.point,t.next.next.point)===m.CCW?e.basin.left_node=t.next.next:e.basin.left_node=t.next;e.basin.bottom_node=e.basin.left_node;for(;e.basin.bottom_node.next&&e.basin.bottom_node.point.y>=e.basin.bottom_node.next.point.y;)e.basin.bottom_node=e.basin.bottom_node.next;if(e.basin.bottom_node!==e.basin.left_node){for(e.basin.right_node=e.basin.bottom_node;e.basin.right_node.next&&e.basin.right_node.point.y<e.basin.right_node.next.point.y;)e.basin.right_node=e.basin.right_node.next;e.basin.right_node!==e.basin.bottom_node&&(e.basin.width=e.basin.right_node.point.x-e.basin.left_node.point.x,e.basin.left_highest=e.basin.left_node.point.y>e.basin.right_node.point.y,function e(t,n){if(Ui(t,n))return;_i(t,n);{if(n.prev===t.basin.left_node&&n.next===t.basin.right_node)return;if(n.prev===t.basin.left_node){if(v(n.point,n.next.point,n.next.next.point)===m.CW)return;n=n.next}else if(n.next===t.basin.right_node){if(v(n.point,n.prev.point,n.prev.prev.point)===m.CCW)return;n=n.prev}else n=n.prev.point.y<n.next.point.y?n.prev:n.next}e(t,n)}(e,e.basin.bottom_node))}}(e,t))}(e,i),i}(e,i),o=i._p2t_edge_list,a=0;o&&a<o.length;++a)!function(e,t,n){if(e.edge_event.constrained_edge=t,e.edge_event.right=t.p.x>t.q.x,!ji(n.triangle,t.p,t.q)){!function(e,t,n){(e.edge_event.right?function(e,t,n){for(;n.next.point.x<t.p.x;)v(t.q,n.next.point,t.p)===m.CCW?function e(t,n,i){i.point.x<n.p.x&&(v(i.point,i.next.point,i.next.next.point)===m.CCW?Gi:(zi(t,n,i),e))(t,n,i)}(e,t,n):n=n.next}:function(e,t,n){for(;n.prev.point.x>t.p.x;)v(t.q,n.prev.point,t.p)===m.CW?function e(t,n,i){i.point.x>n.p.x&&(v(i.point,i.prev.point,i.prev.prev.point)===m.CW?Yi:(Wi(t,n,i),e))(t,n,i)}(e,t,n):n=n.prev})(e,t,n)}(e,t,n);try{Ni(e,t.p,t.q,n.triangle,t.q)}catch(e){}}}(e,o[a],r)}(e),function(e){var t=e.front().head().next.triangle,n=e.front().head().next.point;for(;!t.getConstrainedEdgeCW(n);)t=t.neighborCCW(n);e.meshClean(t)}(e)}});function Ni(e,t,n,i,r){if(!ji(i,t,n)){var o=i.pointCCW(r),a=v(n,o,t);if(a===m.COLLINEAR)throw new Pi("poly2tri EdgeEvent: Collinear not supported!",[n,o,t]);var o=i.pointCW(r),s=v(n,o,t);if(s===m.COLLINEAR)throw new Pi("poly2tri EdgeEvent: Collinear not supported!",[n,o,t]);a===s?Ni(e,t,n,i=a===m.CW?i.neighborCCW(r):i.neighborCW(r),r):Xi(e,t,n,i,r)}}function ji(e,t,n){var i=e.edgeIndex(t,n);if(-1!==i)return e.markConstrainedEdgeByIndex(i),(e=e.getNeighbor(i))&&e.markConstrainedEdgeByPoints(t,n),1}function _i(e,t){var n=new s(t.prev.point,t.point,t.next.point);n.markNeighbor(t.prev.triangle),n.markNeighbor(t.triangle),e.addToMap(n),t.prev.next=t.next,t.next.prev=t.prev,Vi(e,n)||e.mapTriangleToNodes(n)}function Vi(e,t){for(var n=0;n<3;++n)if(!t.delaunay_edge[n]){var i=t.getNeighbor(n);if(i){var r=t.getPoint(n),o=i.oppositePoint(t,r),a=i.index(o);if(i.constrained_edge[a]||i.delaunay_edge[a])t.constrained_edge[n]=i.constrained_edge[a];else if(function(e,t,n,i){var r=e.x-i.x,e=e.y-i.y,o=t.x-i.x,t=t.y-i.y,a=r*t-o*e;if(a<=0)return!1;var s=n.x-i.x,n=n.y-i.y,i=s*e-r*n;if(i<=0)return!1;return 0<(r*r+e*e)*(o*n-s*t)+(o*o+t*t)*i+(s*s+n*n)*a}(r,t.pointCCW(r),t.pointCW(r),o))return t.delaunay_edge[n]=!0,i.delaunay_edge[a]=!0,ki(t,r,i,o),!Vi(e,t)&&e.mapTriangleToNodes(t),!Vi(e,i)&&e.mapTriangleToNodes(i),t.delaunay_edge[n]=!1,i.delaunay_edge[a]=!1,1}}}function ki(e,t,n,i){var r=e.neighborCCW(t),o=e.neighborCW(t),a=n.neighborCCW(i),s=n.neighborCW(i),l=e.getConstrainedEdgeCCW(t),d=e.getConstrainedEdgeCW(t),c=n.getConstrainedEdgeCCW(i),h=n.getConstrainedEdgeCW(i),u=e.getDelaunayEdgeCCW(t),p=e.getDelaunayEdgeCW(t),f=n.getDelaunayEdgeCCW(i),m=n.getDelaunayEdgeCW(i);e.legalize(t,i),n.legalize(i,t),n.setDelaunayEdgeCCW(t,u),e.setDelaunayEdgeCW(t,p),e.setDelaunayEdgeCCW(i,f),n.setDelaunayEdgeCW(i,m),n.setConstrainedEdgeCCW(t,l),e.setConstrainedEdgeCW(t,d),e.setConstrainedEdgeCCW(i,c),n.setConstrainedEdgeCW(i,h),e.clearNeighbors(),n.clearNeighbors(),r&&n.markNeighbor(r),o&&e.markNeighbor(o),a&&e.markNeighbor(a),s&&n.markNeighbor(s),e.markNeighbor(n)}function Ui(e,t){t=e.basin.left_highest?e.basin.left_node.point.y-t.point.y:e.basin.right_node.point.y-t.point.y;return e.basin.width>t}function Gi(e,t,n){_i(e,n.next),n.next.point!==t.p&&v(t.q,n.next.point,t.p)===m.CCW&&v(n.point,n.next.point,n.next.next.point)===m.CCW&&Gi(e,t,n)}function zi(e,t,n){v(n.next.point,n.next.next.point,n.next.next.next.point)===m.CCW?Gi(e,t,n.next):v(t.q,n.next.next.point,t.p)===m.CCW&&zi(e,t,n.next)}function Wi(e,t,n){v(n.prev.point,n.prev.prev.point,n.prev.prev.prev.point)===m.CW?Yi(e,t,n.prev):v(t.q,n.prev.prev.point,t.p)===m.CW&&Wi(e,t,n.prev)}function Yi(e,t,n){_i(e,n.prev),n.prev.point!==t.p&&v(t.q,n.prev.point,t.p)===m.CW&&v(n.point,n.prev.point,n.prev.prev.point)===m.CW&&Yi(e,t,n)}function Xi(e,t,n,i,r){var o,a,s,l,d,c,h,u=i.neighborAcross(r),p=(Oi(u,"FLIP failed due to missing triangle!"),u.oppositePoint(i,r));if(i.getConstrainedEdgeAcross(r))throw o=i.index(r),new Pi("poly2tri Intersecting Constraints",[r,p,i.getPoint((o+1)%3),i.getPoint((o+2)%3)]);Ri(r,i.pointCCW(r),i.pointCW(r),p)?(ki(i,r,u,p),e.mapTriangleToNodes(i),e.mapTriangleToNodes(u),r===n&&p===t?n===e.edge_event.constrained_edge.q&&t===e.edge_event.constrained_edge.p&&(i.markConstrainedEdgeByPoints(t,n),u.markConstrainedEdgeByPoints(t,n),Vi(e,i),Vi(e,u)):(o=v(n,p,t),s=i,l=u,d=r,c=p,Xi(a=e,t,n,i=o!==m.CCW?(h=s.edgeIndex(d,c),s.delaunay_edge[h]=!0,Vi(a,s),s.clearDelaunayEdges(),l):(h=l.edgeIndex(d,c),l.delaunay_edge[h]=!0,Vi(a,l),l.clearDelaunayEdges(),s),r))):(function e(t,n,i,r,o,a){var s=o.neighborAcross(a);Oi(s,"FLIP failed due to missing triangle");o=s.oppositePoint(o,a);Ri(i,r.pointCCW(i),r.pointCW(i),o)?Xi(t,i,o,s,o):(a=Qi(n,i,s,o),e(t,n,i,r,s,a))}(e,t,n,i,u,Qi(t,n,u,p)),Ni(e,t,n,i,r))}function Qi(e,t,n,i){var r=v(t,i,e);if(r===m.CW)return n.pointCCW(i);if(r===m.CCW)return n.pointCW(i);throw new Pi("poly2tri [Unsupported] nextFlipPoint: opposing point on constrained edge!",[t,i,e])}function Zi(e,t){if(this.p=e,this.q=t,e.y>t.y)this.q=e,this.p=t;else if(e.y===t.y)if(e.x>t.x)this.q=e,this.p=t;else if(e.x===t.x)throw new Pi("poly2tri Invalid Edge constructor: repeated points!",[e]);this.q._p2t_edge_list||(this.q._p2t_edge_list=[]),this.q._p2t_edge_list.push(this)}function qi(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1}function Ki(){this.constrained_edge=null,this.right=!1}function p(e,t){t=t||{},this.triangles_=[],this.map_=[],this.points_=t.cloneArrays?e.slice(0):e,this.edge_list=[],this.pmin_=this.pmax_=null,this.front_=null,this.head_=null,this.tail_=null,this.af_head_=null,this.af_middle_=null,this.af_tail_=null,this.basin=new qi,this.edge_event=new Ki,this.initEdges(this.points_)}function Ji(e,t,n){var r,i,o,a,s,l,d,c,h,u,p,f,m=e,g=t,v=!1,A=new THREE.Color,y=this,E={texSize:64,pixScale:1,blurRadius:7,debug:!1};function M(e){return new THREE.ShaderMaterial({uniforms:THREE.UniformsUtils.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,defines:THREE.UniformsUtils.clone(e.defines)})}if(this.setTransform=function(e,t,n,i){r.left=-t.z/2,r.right=t.z/2,r.top=t.x/2,r.bottom=-t.x/2,r.near=1,r.far=t.y+r.near,r.updateProjectionMatrix(),r.position.addVectors(e,n.clone().multiplyScalar(-t.y/2-r.near)),i&&r.up.set(i.x,i.y,i.z),r.lookAt(e),o.position.set(e.x,e.y,e.z),o.rotation.set(r.rotation.x,r.rotation.y,r.rotation.z),o.scale.set(t.z,t.x,t.y),E.debug&&(f.position.set(e.x,e.y,e.z),f.rotation.set(r.rotation.x,r.rotation.y,r.rotation.z),f.scale.set(t.z,t.x,t.y)),p.uniforms.worldSize.value.copy(t)},this.renderIntoShadow=function(e){var t,n;!this.enabled||e.overrideMaterial&&e.overrideMaterial.transparent||(t=e.overrideMaterial,e.overrideMaterial=l,(n=e.getObjectByName("GridHelper"))&&(e.gridvisible=n.visible,n.visible=!1),m.ndsModel&&(m.ndsModel.backupDirty(),m.ndsModel.setDirty(),m.ndsModel.setDrawMode(m.ndsModel.SHADED),m.scene.children.push(m.ndsModel),m.ndsModel.setOverrideMaterial(l,d,!1)),g.render(e,r,a,!1),e.overrideMaterial=t,m.ndsModel&&(m.ndsModel.setOverrideMaterial(null,null,!1),m.ndsModel.resetDirty()),n&&(n.visible=e.gridvisible))},this.renderShadow=function(e,t){this.enabled&&v&&(t?g.render(i,e,t,!1):g.render(i,e))},this.postprocess=function(){this.enabled&&(u.render(g,s,a),h.render(g,a,s),v=!0)},this.clear=function(){var e,t,n;this.enabled&&(e=g.getClearColor(A),t=g.getClearAlpha(),n=g.getRenderTarget(),g.setClearColor(16777215,0),g.setRenderTarget(a),g.clear(!0,!0,!1),g.setClearColor(e,t),v=!1,g.setRenderTarget(n))},this.getRenderTarget=function(){return a},this.setColor=function(e){c.uniforms.uShadowColor.value.x=e.r,c.uniforms.uShadowColor.value.y=e.g,c.uniforms.uShadowColor.value.z=e.b},this.getColor=function(){return new THREE.Color(c.uniforms.uShadowColor.value.x,c.uniforms.uShadowColor.value.y,c.uniforms.uShadowColor.value.z)},this.setAlpha=function(e){c.uniforms.uShadowColor.value.w=e},this.getAlpha=function(){return c.uniforms.uShadowColor.value.w},this.isValid=function(){return v},this.getDepthMaterial=function(){return l},this.updateGroundTransform=function(e,t,n){var i,r,o;y.enabled&&t&&(y.needClear=!0,t=t.clone(),i=new THREE.Vector3(1,0,0),r=t.getCenter(new THREE.Vector3),o=t.getSize(new THREE.Vector3),e.worldUpTransform&&(i.applyMatrix4(e.worldUpTransform),t.applyMatrix4(e.worldUpTransform),o=t.size()),t=o.x>o.z?o.x/o.z:o.z/o.x,o.multiply(new THREE.Vector3(1.25,1.01,1.25)),o.x=o.z=Math.max(o.x,o.z),n?y.setTransform(r,o,n,i):y.setTransform(r,o,e.up,i),--t<5&&(t/=500),0<(t=2/Math.PI*Math.atan(t)))&&(c.defines.DARKNESS_SCALE=1.00001+t)},n)for(var w in E)E[w]=n[w]||E[w];i=new THREE.Scene,r=new THREE.OrthographicCamera,(a=new THREE.WebGLRenderTarget(E.texSize,E.texSize,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1})).texture.generateMipmaps=!1,(s=new THREE.WebGLRenderTarget(E.texSize,E.texSize,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1})).texture.generateMipmaps=!1,(l=M(er)).defines.NUM_CUTPLANES=0,l.side=THREE.DoubleSide,l.blending=THREE.NoBlending,d=(new l.constructor).copy(l),h=new Jt(nr,"tDepth"),u=new Jt(nr,"tDepth"),p=new Jt(tr,"tDepth"),h.material.defines.KERNEL_SCALE=u.material.defines.KERNEL_SCALE=(E.pixScale/E.texSize).toFixed(4),h.material.defines.KERNEL_RADIUS=u.material.defines.KERNEL_RADIUS=E.blurRadius.toFixed(2),p.material.blending=h.material.blending=u.material.blending=THREE.NoBlending,p.material.depthWrite=h.material.depthWrite=u.material.depthWrite=!1,p.material.depthTest=h.material.depthTest=u.material.depthTest=!1,h.material.defines.HORIZONTAL=1,(c=M(ir)).uniforms.tDepth.value=a.texture,c.depthWrite=!1,c.transparent=!0,c.defines.NUM_CUTPLANES=0,(e=new THREE.BufferGeometry).addAttribute("position",new THREE.BufferAttribute(new Float32Array([-.5,-.5,.5,-.5,.5,.5,.5,.5,.5,.5,-.5,.5]),3)),e.addAttribute("uv",new THREE.BufferAttribute(new Float32Array([0,0,0,1,1,1,1,0]),2)),e.setIndex(new THREE.BufferAttribute(new Uint16Array([0,1,2,2,3,0]),1)),o=new THREE.Mesh(e,c),i.add(o),E.debug&&(f=new THREE.Mesh(new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:65280,wireframe:!0})),i.add(f)),this.setTransform(new THREE.Vector3(0,0,0),new THREE.Vector3(1,1,1),new THREE.Vector3(0,1,0))}var s=function(e,t,n){this.points_=[e,t,n],this.neighbors_=[null,null,null],this.interior_=!1,this.constrained_edge=[!1,!1,!1],this.delaunay_edge=[!1,!1,!1]},$i=Ci.toString,$n=(s.prototype.toString=function(){return"["+$i(this.points_[0])+$i(this.points_[1])+$i(this.points_[2])+"]"},s.prototype.getPoint=function(e){return this.points_[e]},s.prototype.GetPoint=s.prototype.getPoint,s.prototype.getPoints=function(){return this.points_},s.prototype.getNeighbor=function(e){return this.neighbors_[e]},s.prototype.containsPoint=function(e){var t=this.points_;return e===t[0]||e===t[1]||e===t[2]},s.prototype.containsEdge=function(e){return this.containsPoint(e.p)&&this.containsPoint(e.q)},s.prototype.containsPoints=function(e,t){return this.containsPoint(e)&&this.containsPoint(t)},s.prototype.isInterior=function(){return this.interior_},s.prototype.setInterior=function(e){return this.interior_=e,this},s.prototype.markNeighborPointers=function(e,t,n){var i=this.points_;if(e===i[2]&&t===i[1]||e===i[1]&&t===i[2])this.neighbors_[0]=n;else if(e===i[0]&&t===i[2]||e===i[2]&&t===i[0])this.neighbors_[1]=n;else{if(!(e===i[0]&&t===i[1]||e===i[1]&&t===i[0]))throw new Error("poly2tri Invalid Triangle.markNeighborPointers() call");this.neighbors_[2]=n}},s.prototype.markNeighbor=function(e){var t=this.points_;e.containsPoints(t[1],t[2])?(this.neighbors_[0]=e).markNeighborPointers(t[1],t[2],this):e.containsPoints(t[0],t[2])?(this.neighbors_[1]=e).markNeighborPointers(t[0],t[2],this):e.containsPoints(t[0],t[1])&&(this.neighbors_[2]=e).markNeighborPointers(t[0],t[1],this)},s.prototype.clearNeighbors=function(){this.neighbors_[0]=null,this.neighbors_[1]=null,this.neighbors_[2]=null},s.prototype.clearDelaunayEdges=function(){this.delaunay_edge[0]=!1,this.delaunay_edge[1]=!1,this.delaunay_edge[2]=!1},s.prototype.pointCW=function(e){var t=this.points_;return e===t[0]?t[2]:e===t[1]?t[0]:e===t[2]?t[1]:null},s.prototype.pointCCW=function(e){var t=this.points_;return e===t[0]?t[1]:e===t[1]?t[2]:e===t[2]?t[0]:null},s.prototype.neighborCW=function(e){return e===this.points_[0]?this.neighbors_[1]:e===this.points_[1]?this.neighbors_[2]:this.neighbors_[0]},s.prototype.neighborCCW=function(e){return e===this.points_[0]?this.neighbors_[2]:e===this.points_[1]?this.neighbors_[0]:this.neighbors_[1]},s.prototype.getConstrainedEdgeCW=function(e){return e===this.points_[0]?this.constrained_edge[1]:e===this.points_[1]?this.constrained_edge[2]:this.constrained_edge[0]},s.prototype.getConstrainedEdgeCCW=function(e){return e===this.points_[0]?this.constrained_edge[2]:e===this.points_[1]?this.constrained_edge[0]:this.constrained_edge[1]},s.prototype.getConstrainedEdgeAcross=function(e){return e===this.points_[0]?this.constrained_edge[0]:e===this.points_[1]?this.constrained_edge[1]:this.constrained_edge[2]},s.prototype.setConstrainedEdgeCW=function(e,t){e===this.points_[0]?this.constrained_edge[1]=t:e===this.points_[1]?this.constrained_edge[2]=t:this.constrained_edge[0]=t},s.prototype.setConstrainedEdgeCCW=function(e,t){e===this.points_[0]?this.constrained_edge[2]=t:e===this.points_[1]?this.constrained_edge[0]=t:this.constrained_edge[1]=t},s.prototype.getDelaunayEdgeCW=function(e){return e===this.points_[0]?this.delaunay_edge[1]:e===this.points_[1]?this.delaunay_edge[2]:this.delaunay_edge[0]},s.prototype.getDelaunayEdgeCCW=function(e){return e===this.points_[0]?this.delaunay_edge[2]:e===this.points_[1]?this.delaunay_edge[0]:this.delaunay_edge[1]},s.prototype.setDelaunayEdgeCW=function(e,t){e===this.points_[0]?this.delaunay_edge[1]=t:e===this.points_[1]?this.delaunay_edge[2]=t:this.delaunay_edge[0]=t},s.prototype.setDelaunayEdgeCCW=function(e,t){e===this.points_[0]?this.delaunay_edge[2]=t:e===this.points_[1]?this.delaunay_edge[0]=t:this.delaunay_edge[1]=t},s.prototype.neighborAcross=function(e){return e===this.points_[0]?this.neighbors_[0]:e===this.points_[1]?this.neighbors_[1]:this.neighbors_[2]},s.prototype.oppositePoint=function(e,t){e=e.pointCW(t);return this.pointCW(e)},s.prototype.legalize=function(e,t){var n=this.points_;if(e===n[0])n[1]=n[0],n[0]=n[2],n[2]=t;else if(e===n[1])n[2]=n[1],n[1]=n[0],n[0]=t;else{if(e!==n[2])throw new Error("poly2tri Invalid Triangle.legalize() call");n[0]=n[2],n[2]=n[1],n[1]=t}},s.prototype.index=function(e){var t=this.points_;if(e===t[0])return 0;if(e===t[1])return 1;if(e===t[2])return 2;throw new Error("poly2tri Invalid Triangle.index() call")},s.prototype.edgeIndex=function(e,t){var n=this.points_;if(e===n[0]){if(t===n[1])return 2;if(t===n[2])return 1}else if(e===n[1]){if(t===n[2])return 0;if(t===n[0])return 2}else if(e===n[2]){if(t===n[0])return 1;if(t===n[1])return 0}return-1},s.prototype.markConstrainedEdgeByIndex=function(e){this.constrained_edge[e]=!0},s.prototype.markConstrainedEdgeByEdge=function(e){this.markConstrainedEdgeByPoints(e.p,e.q)},s.prototype.markConstrainedEdgeByPoints=function(e,t){var n=this.points_;t===n[0]&&e===n[1]||t===n[1]&&e===n[0]?this.constrained_edge[2]=!0:t===n[0]&&e===n[2]||t===n[2]&&e===n[0]?this.constrained_edge[1]=!0:(t===n[1]&&e===n[2]||t===n[2]&&e===n[1])&&(this.constrained_edge[0]=!0)},qi.prototype.clear=function(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1},p.prototype.AddHole=p.prototype.addHole=function(e){this.initEdges(e);for(var t=e.length,n=0;n<t;n++)this.points_.push(e[n]);return this},p.prototype.addHoles=function(e){for(var t=e.length,n=0;n<t;n++)this.initEdges(e[n]);return this.points_=this.points_.concat.apply(this.points_,e),this},p.prototype.AddPoint=p.prototype.addPoint=function(e){return this.points_.push(e),this},p.prototype.addPoints=function(e){return this.points_=this.points_.concat(e),this},p.prototype.triangulate=function(){return Fi.triangulate(this),this},p.prototype.getBoundingBox=function(){return{min:this.pmin_,max:this.pmax_}},p.prototype.GetTriangles=p.prototype.getTriangles=function(){return this.triangles_},p.prototype.front=function(){return this.front_},p.prototype.pointCount=function(){return this.points_.length},p.prototype.head=function(){return this.head_},p.prototype.setHead=function(e){this.head_=e},p.prototype.tail=function(){return this.tail_},p.prototype.setTail=function(e){this.tail_=e},p.prototype.getMap=function(){return this.map_},p.prototype.initTriangulation=function(){for(var e=this.points_[0].x,t=this.points_[0].x,n=this.points_[0].y,i=this.points_[0].y,r=this.points_.length,o=1;o<r;o++){var a=this.points_[o];a.x>e&&(e=a.x),a.x<t&&(t=a.x),a.y>n&&(n=a.y),a.y<i&&(i=a.y)}this.pmin_=new d(t,i),this.pmax_=new d(e,n);var s=.3*(e-t),l=.3*(n-i);this.head_=new d(e+s,i-l),this.tail_=new d(t-s,i-l),this.points_.sort(d.compare)},p.prototype.initEdges=function(e,t){for(var n=e.length,i=t?e.length-1:e.length,r=0;r<i;++r)this.edge_list.push(new Zi(e[r],e[(r+1)%n]))},p.prototype.getPoint=function(e){return this.points_[e]},p.prototype.addToMap=function(e){this.map_.push(e)},p.prototype.locateNode=function(e){return this.front_.locateNode(e.x)},p.prototype.createAdvancingFront=function(){var e,t,n=new s(this.points_[0],this.tail_,this.head_);this.map_.push(n),e=new Hi(n.getPoint(1),n),t=new Hi(n.getPoint(0),n),n=new Hi(n.getPoint(2)),this.front_=new Di(e,n),(e.next=t).next=n,t.prev=e,n.prev=t},p.prototype.removeNode=function(e){},p.prototype.mapTriangleToNodes=function(e){for(var t,n=0;n<3;++n)e.getNeighbor(n)||(t=this.front_.locatePoint(e.pointCW(e.getPoint(n))))&&(t.triangle=e)},p.prototype.removeFromMap=function(e){for(var t=this.map_,n=t.length,i=0;i<n;i++)if(t[i]===e){t.splice(i,1);break}},p.prototype.meshClean=function(e){for(var t,n,i=[e];t=i.pop();)if(!t.isInterior())for(t.setInterior(!0),this.triangles_.push(t),n=0;n<3;n++)t.constrained_edge[n]||i.push(t.getNeighbor(n))},ve.Triangulator=new function(){function s(e,t,n){return n+":"+(e<t?e+":"+t:t+":"+e)}function h(){this.bbox=new THREE.Box2,this.left=null,this.right=null,this.node_edges=[]}function u(e,t,n){this.pts=e,this.edges=t,this.bbox=n,this.pipResult=!1}u.prototype.splitNode=function(e){if(!(e.bbox.min.y>=e.bbox.max.y||e.node_edges.length<3)){for(var t=.5*(e.bbox.min.y+e.bbox.max.y),n=(e.left=new h,e.right=new h,this.pts),i=e.node_edges,r=[],o=new THREE.Vector2,a=0;a<i.length;a++){var s=this.edges[i[a]],l=n[s.p1].y,d=n[s.p2].y,c=(d<l&&(c=l,l=d,d=c),null);d<t?(e.left.node_edges.push(i[a]),c=e.left.bbox):t<l?(e.right.node_edges.push(i[a]),c=e.right.bbox):r.push(i[a]),c&&(o.set(n[s.p1].x,n[s.p1].y),c.expandByPoint(o),o.set(n[s.p2].x,n[s.p2].y),c.expandByPoint(o))}e.node_edges=r,e.left.node_edges.length&&this.splitNode(e.left),e.right.node_edges.length&&this.splitNode(e.right)}},u.prototype.build=function(){this.root=new h;for(var e=this.root.node_edges,t=0;t<this.edges.length;t++)e.push(t);this.root.bbox.copy(this.bbox),this.splitNode(this.root)},u.prototype.pointInPolygonRec=function(e,t,n){if(e.bbox.min.y<=n&&e.bbox.max.y>=n)for(var i=this.pts,r=e.node_edges,o=0,a=r.length;o<a;o++){var s=this.edges[r[o]],l=i[s.p1],d=l.x,l=l.y,s=i[s.p2],c=s.x,s=s.y,h=n<=s;n<=l!=h&&(c-t)*(l-s)<=(s-n)*(d-c)==h&&(this.pipResult=!this.pipResult)}var u=e.left,u=(u&&u.bbox.min.y<=n&&u.bbox.max.y>=n&&this.pointInPolygonRec(u,t,n),e.right);u&&u.bbox.min.y<=n&&u.bbox.max.y>=n&&this.pointInPolygonRec(u,t,n)},u.prototype.pointInPolygon=function(e,t){return this.pipResult=!1,this.pointInPolygonRec(this.root,e,t),this.pipResult};var n=new THREE.Vector3;function e(e,t){this.edges=e,this.bbox=t,this.pts=[],this.idmap={},this.xymap={},this.contours=[],this.scale=1e6/this.bbox.getSize(n).length()}function t(e){this.indices=[],this.cset=e;var t=this.pts=e.pts;this.intervalTree=new u(e.pts,e.edges,e.bbox),this.intervalTree.build();for(var n=0;n<t.length;n++)t[n].id=n;var i=new p([]);if(i.points_=t.slice(),e.contours)for(var r=this.cset.contours,o=0;o<r.length;o++){var a=r[o],s=a[0]!==a[a.length-1];if(!s){for(var l=[],d=0;d<a.length-1;d++)l.push(t[a[d]]);i.initEdges(l,s)}}else for(var c=this.cset.edges,n=0;n<c.length;n++){var h=c[n];h.p1!=h.p2&&(h=[t[h.p1],t[h.p2]],i.initEdges(h,!0))}0<i.edge_list.length&&(this.triangulate(i),this.processResult(i))}e.prototype.getPointIndex=function(e,t,n){var i,r,o=this.idmap[n];return void 0!==o||(o=0|e*this.scale,i=0|t*this.scale,void 0===(o=void 0===(r=this.xymap[o])?void(this.xymap[o]=r={}):r[i])&&(r[i]=o=this.pts.length,this.idmap[n]=o,this.pts.push({x:e,y:t}))),o},e.prototype.snapEdges=function(){for(var e=0;e<this.edges.length;e++){var t=this.edges[e];t.p1=this.getPointIndex(t.pt1.x,t.pt1.y,t.eid1),t.p2=this.getPointIndex(t.pt2.x,t.pt2.y,t.eid2)}},e.prototype.sanitizeEdges=function(){for(var e={},t=[],n=0,i=this.edges.length;n<i;n++){var r,o=this.edges[n];o.p1!==o.p2&&!0!==e[r=Math.min(o.p1,o.p2)+":"+Math.max(o.p1,o.p2)]&&(e[r]=!0,t.push(o))}this.edges=t},e.prototype.stitchContours=function(){for(var e={},t=0;t<this.edges.length;t++){var n=this.edges[t];n.p1!==n.p2&&(void 0!==e[n.p1]?e[n.p1].push(n.p2):e[n.p1]=[n.p2],void 0!==e[n.p2]?e[n.p2].push(n.p1):e[n.p2]=[n.p1])}var i=[];for(o in e)if(2!==e[o].length)break;for(;;){var r=void 0;for(o in e)if(1<e[o].length){r=o;break}if(!r)for(var o in e)if(0<e[o].length){r=o;break}if(!r)break;var a=-1,s=parseInt(r),l=e[r];for(i.push(s);l&&l.length;){var d=l.shift();if(void 0===(d=d===a?l.shift():d)){delete e[s];break}i.push(d),(0==l.length||l[0]===a)&&delete e[s],a=s,l=e[s=d]}i.length&&(this.contours.push(i),i=[])}for(var c=[],t=0;t<this.contours.length;t++)(f=this.contours[t])[0]!==f[f.length-1]&&c.push(f);if(c.length)for(var h=!0;h;){for(var h=!1,u={},p=this.contours,t=0;t<p.length;t++){var f,m=(f=p[t])[0],g=f[f.length-1];m!==g&&(u[m]?u[m].push(-t-1):u[m]=[-t-1],u[g]?u[g].push(t):u[g]=[t])}for(o in u){var v=u[o];if(2==v.length){var A,y,E=void 0;v[0]<0&&v[1]<0&&(A=-v[0]-1,p[y=-v[1]-1].shift(),Array.prototype.push.apply(p[A].reverse(),p[y]),E=y),v[0]<0&&0<v[1]&&(A=-v[0]-1,p[y=v[1]].pop(),Array.prototype.push.apply(p[y],p[A]),E=A),0<v[0]&&v[1]<0&&(A=v[0],y=-v[1]-1,p[A].pop(),Array.prototype.push.apply(p[A],p[y]),E=y),0<v[0]&&0<v[1]&&(A=v[0],y=v[1],p[A].pop(),Array.prototype.push.apply(p[A],p[y].reverse()),E=y),void 0!==E&&(p.splice(E,1),h=!0);break}}}},e.prototype.stitchContoursCheng=function(){for(var e={},t=0;t<this.edges.length;t++){var n=this.edges[t];n.p1!==n.p2&&(void 0!==e[n.p1]?e[n.p1].push(n.p2):e[n.p1]=[n.p2],void 0!==e[n.p2]?e[n.p2].push(n.p1):e[n.p2]=[n.p1])}for(var i=[];;){for(var r in e)if(1==e[r].length)for(var o in delete e[r],e){var a=parseInt(r),s=e[o].indexOf(a);-1!=s&&e[o].splice(s,1)}var l=!1;for(r in e)if(1==e[r].length){l=!0;break}if(!l)break}for(;;){var d=void 0;for(r in e)if(1<e[r].length){d=r;break}if(!d)for(var r in e)if(0<e[r].length){d=r;break}if(!d)break;var c=-1,a=parseInt(d),h=e[d];for(i.push(a);h&&h.length;){var u=h.shift();if(void 0===(u=u===c?h.shift():u)){delete e[a];break}i.push(u);for(l=!1,t=0;t<i.length-1;++t)if(u==i[t]){i=i.slice(t),l=!0;break}if(l)break;(0==h.length||h[0]===c)&&delete e[a],c=a,h=e[a=u]}i.length&&(this.contours.push(i),i=[])}for(var p=[],t=0;t<this.contours.length;t++)(v=this.contours[t])[0]!==v[v.length-1]&&p.push(v);if(p.length)for(var f=!0;f;){for(var f=!1,m={},g=this.contours,t=0;t<g.length;t++){var v,A=(v=g[t])[0],y=v[v.length-1];A!==y&&(m[A]?m[A].push(-t-1):m[A]=[-t-1],m[y]?m[y].push(t):m[y]=[t])}for(r in m){var E=m[r];if(2==E.length){var M,w,b=void 0;E[0]<0&&E[1]<0&&(M=-E[0]-1,g[w=-E[1]-1].shift(),Array.prototype.push.apply(g[M].reverse(),g[w]),b=w),E[0]<0&&0<E[1]&&(M=-E[0]-1,g[w=E[1]].pop(),Array.prototype.push.apply(g[w],g[M]),b=M),0<E[0]&&E[1]<0&&(M=E[0],w=-E[1]-1,g[M].pop(),Array.prototype.push.apply(g[M],g[w]),b=w),0<E[0]&&0<E[1]&&(M=E[0],w=E[1],g[M].pop(),Array.prototype.push.apply(g[M],g[w].reverse()),b=w),void 0!==b&&(g.splice(b,1),f=!0);break}}}},t.prototype.triangulate=function(e){try{e.triangulate()}catch(e){}},t.prototype.processResult=function(e){for(var t=0;t<e.map_.length;t++){var n=e.map_[t],i=n.points_[0],r=n.points_[1],n=n.points_[2];void 0!==i.id&&void 0!==r.id&&void 0!==n.id&&this.filterFace(i.id,r.id,n.id)}},t.prototype.pointInEdgeList=function(e,t){for(var n=this.cset.pts,i=this.cset.edges,r=!1,o=0,a=i.length;o<a;++o){var s,l=i[o],d=n[l.p1].x,c=n[l.p1].y,h=n[l.p2].x;t<=c!=(s=t<=(l=n[l.p2].y))&&(h-e)*(c-l)<=(l-t)*(d-h)==s&&(r=!r)}return r},t.prototype.pointInContour=function(e,t,n){for(var i,r,o,a=!1,s=this.cset.pts,l=s[n[n.length-1]].x,d=s[n[n.length-1]].y,c=t<=d,h=0,u=n.length;h<u;++h)r=s[n[h]].x,c!=(i=t<=(o=s[n[h]].y))&&(r-e)*(d-o)<=(o-t)*(l-r)==i&&(a=!a),c=i,l=r,d=o;return a},t.prototype.pointInPolygon=function(e,t){for(var n=!1,i=0;i<this.cset.contours.length;i++)this.pointInContour(e,t,this.cset.contours[i])&&(n=!n);return n},t.prototype.filterFace=function(e,t,n){var i=this.pts[e],r=this.pts[t],o=this.pts[n],a=(i.x+r.x+o.x)/3,s=(i.y+r.y+o.y)/3;this.intervalTree.pointInPolygon(a,s)&&(a=r.x-i.x,s=r.y-i.y,r=o.x-i.x,0<a*(o.y-i.y)-r*s?this.indices.push(e,t,n):this.indices.push(e,n,t))},this.TriangulatedSurface=t,this.ContourSet=e,this.Edge=function(e,t,n,i,r,o,a){this.pt1=e,this.pt2=t,this.p1=-1,this.p2=-1,this.eid1=s(n,i,a),this.eid2=s(r,o,a)}},ve.Intersector=new function(){var w,b,x,I,T,S=1e-10,B=ve.Triangulator.Edge;function h(e){return Math.abs(e)<S}this.intersectSegmentPlane=function(e,t,n,i,r){var o,a=(new THREE.Vector3).subVectors(n,t);return h(o=e.normal.dot(a))?(i.copy(t),r.copy(n),2):(o=1/o,(r=-(t.dot(e.normal)*o+e.constant*o))<-S||1+S<r?0:(n=a.multiplyScalar(r).add(t),i.copy(n),1))},this.intersectTrianglePlane=function(e,t,n,i,r,o,a,s,l){var d,c,h,u,p,f,m,g,v,A,y=new THREE.Vector3,E=e.distanceToPoint(t),M=e.distanceToPoint(n),e=e.distanceToPoint(i);return E<-S&&M<-S&&e<-S||S<E&&S<M&&S<e||(d=Math.sign(E),A=Math.sign(M),c=Math.sign(e),0===d&&0===A&&0===c)?null:(0==d&&0!=A&&0!=c?(f=p=r,h=t.clone()):0!=d&&0==A&&0!=c?(f=p=o,h=n.clone()):0!=d&&0!=A&&0==c&&(f=p=a,h=i.clone()),void(0==d&&0==A?s.push(new B(t.clone(),n.clone(),r,r,o,o,l)):(E*M<0&&(m=1/(M-E),y=t.clone().multiplyScalar(M*m).sub(n.clone().multiplyScalar(E*m)),h?y.distanceTo(h)>S&&(g=r,v=o,u=y.clone()):(p=r,f=o,h=y)),0==A&&0==c?s.push(new B(n.clone(),i.clone(),o,o,a,a,l)):(M*e<0&&(m=1/(e-M),g=o,v=a,y=n.clone().multiplyScalar(e*m).sub(i.clone().multiplyScalar(M*m)),h?y.distanceTo(h)>S&&(g=o,v=a,u=y.clone()):(p=o,f=a,h=y.clone())),0==d&&0==c?s.push(new B(i.clone(),t.clone(),a,a,r,r,l)):(e*E<0&&(A=1/(E-e),y=i.clone().multiplyScalar(E*A).sub(t.clone().multiplyScalar(e*A)),h?y.distanceTo(h)>S&&(g=a,v=r,u=y.clone()):(p=a,f=r,h=y.clone())),h&&u&&s.push(new B(h,u,p,f,g,v,l)))))))},this.intersectBoxPlane=function(e,t){var n=new THREE.Vector3,i=(n.set(t.min.x,t.min.y,t.min.z),e.distanceToPoint(n)),i=Math.sign(i),r=(n.set(t.min.x,t.min.y,t.max.z),e.distanceToPoint(n));return Math.sign(r)!==i||(n.set(t.min.x,t.max.y,t.min.z),r=e.distanceToPoint(n),Math.sign(r)!==i)||(n.set(t.min.x,t.max.y,t.max.z),r=e.distanceToPoint(n),Math.sign(r)!==i)||(n.set(t.max.x,t.min.y,t.min.z),r=e.distanceToPoint(n),Math.sign(r)!==i)||(n.set(t.max.x,t.min.y,t.max.z),r=e.distanceToPoint(n),Math.sign(r)!==i)||(n.set(t.max.x,t.max.y,t.min.z),r=e.distanceToPoint(n),Math.sign(r)!==i)||(n.set(t.max.x,t.max.y,t.max.z),r=e.distanceToPoint(n),Math.sign(r)!==i)},this.intersectMeshPlane=(w=new THREE.Vector3,b=new THREE.Vector3,x=new THREE.Vector3,I=new THREE.Matrix4,T=new THREE.Plane,function(e,t,n,i,r){var o,a,s,l=r.length,d=t.attributes,c=n;if(I.getInverse(c),T.copy(e).applyMatrix4(I),void 0!==d.index||null!=t.index){var h=(d.index?d:t).index.array,u=t.vb||d.position.array,p=t.vb?t.vbstride:3,f=(d.position&&d.position instanceof THREE.InterleavedBufferAttribute&&(u=d.position.data.array,p=d.position.data.stride),t.groups);f&&0!==f.length||(f=[{start:0,count:h.length,index:0}],t.drawRange&&t.drawRange.count!=1/0&&(f[0].start=t.drawRange.start,f[0].count=t.drawRange.count));for(var m=0,g=f.length;m<g;++m)for(var v=f[m].start,A=f[m].count,y=f[m].index,E=v,M=v+A;E<M;E+=3)o=y+h[E],a=y+h[E+1],s=y+h[E+2],w.x=u[o*p],w.y=u[o*p+1],w.z=u[o*p+2],b.x=u[a*p],b.y=u[a*p+1],b.z=u[a*p+2],x.x=u[s*p],x.y=u[s*p+1],x.z=u[s*p+2],this.intersectTrianglePlane(T,w,b,x,o,a,s,r,i)}else{u=t.vb||d.position.array,p=t.vb?t.vbstride:3;d.position&&d.position instanceof THREE.InterleavedBufferAttribute&&(u=d.position.data.array,p=d.position.data.stride);for(E=0,M=u.length;E<M;E+=3,0)a=(o=E)+1,s=E+2,w.x=u[o*p],w.y=u[o*p+1],w.z=u[o*p+2],b.x=u[a*p],b.y=u[a*p+1],b.z=u[a*p+2],x.x=u[s*p],x.y=u[s*p+1],x.z=u[s*p+2],this.intersectTrianglePlane(T,w,b,x,o,a,s,r,i)}for(E=l,M=r.length;E<M;E++)r[E].pt1.applyMatrix4(c),r[E].pt2.applyMatrix4(c)}),this.makePlaneBasis=function(e){var t,n,i,r,o,a,s,l=new THREE.Vector3(0,0,1),d=(d=e.normal.clone().cross(l)).normalize(),l=l.dot(e.normal),c=new THREE.Matrix4;return h(d.x)&&h(d.y)&&h(d.z)?c.elements[14]=l*e.constant:(d=d,l=l,t=c,n=Math.sqrt(1-l*l),i=1-l,r=d.x,o=d.y,d=d.z,a=i*r,s=i*o,t.set(a*r+l,a*o-n*d,a*d+n*o,0,a*o+n*d,s*o+l,s*d-n*r,0,a*d-n*o,s*d+n*r,i*d*d+l,0,0,0,0,1),c.elements[14]=e.constant),c},this.convertToPlaneCoords=function(e,t,n){for(var i=0,r=t.length;i<r;i++){var o=t[i];o.pt1.applyMatrix4(e),o.pt2.applyMatrix4(e),n.expandByPoint(o.pt1),n.expandByPoint(o.pt2)}}},["#if NUM_CUTPLANES > 0","uniform vec4 cutplanes[NUM_CUTPLANES];","#ifdef CUTPLANES_LINE","uniform vec3 cutplanesOutlineColor;","uniform float cutplanesOutlineThickness;","#endif","bool checkCutPlanes() {","bool isCut = false;","#ifdef CUTPLANES_LINE","bool isCutEdge = false;","float eyeDist = length(vViewPosition);","#endif","for (int i=0; i<NUM_CUTPLANES; i++) {","float dotPlane = dot(vec4(vWorldPosition, 1.0), cutplanes[i]);","isCut = isCut || (dotPlane > 0.0);","#ifdef CUTPLANES_LINE","isCutEdge = isCutEdge || (dotPlane > -cutplanesOutlineThickness*eyeDist);","#endif","}","if (isCut) {","discard;","return true;","}","#ifdef CUTPLANES_LINE","else if (isCutEdge) {","gl_FragColor = vec4(cutplanesOutlineColor, 1.0);","return true;","}","#endif","return false;","}","#endif"].join("\n")),t=["vec4 packDepth( const in float depth ) {","vec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;","enc = fract(enc);","enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);","return enc;","}","float unpackDepth( const in vec4 rgba_depth ) {","return dot( rgba_depth, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/160581375.0) );","}"].join("\n"),er={uniforms:{cutplanes:{type:"v4v",value:[]}},vertexShader:["#ifdef USE_LOGDEPTHBUF"," #ifdef USE_LOGDEPTHBUF_EXT"," varying float vFragDepth;"," #endif"," uniform float logDepthBufFC;","#endif","#if NUM_CUTPLANES > 0","varying vec3 vWorldPosition;","#endif","void main() {","#ifdef USE_MODELMATRIXATTRIB"," mat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;"," gl_Position = projectionMatrix * ndsModelViewMatrix * vec4( position, 1.0 );","#else"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );;","#endif","#if NUM_CUTPLANES > 0"," vec4 worldPosition = modelMatrix * vec4( position, 1.0 );"," vWorldPosition = worldPosition.xyz;","#endif","#ifdef USE_LOGDEPTHBUF"," gl_Position.z = log2(max(1e-6, gl_Position.w + 1.0)) * logDepthBufFC;"," #ifdef USE_LOGDEPTHBUF_EXT"," vFragDepth = 1.0 + gl_Position.w;"," #else"," gl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;"," #endif","#endif","}"].join("\n"),fragmentShader:["#ifdef USE_LOGDEPTHBUF"," uniform float logDepthBufFC;"," #ifdef USE_LOGDEPTHBUF_EXT"," #extension GL_EXT_frag_depth : enable"," varying float vFragDepth;"," #endif","#endif",t,"#if NUM_CUTPLANES > 0","varying vec3 vWorldPosition;","#endif",$n,"void main() {","#if NUM_CUTPLANES > 0","if (checkCutPlanes()) return;","#endif","#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)","gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;","#endif","#ifdef USE_LOGDEPTHBUF_EXT","float depth = gl_FragDepthEXT / gl_FragCoord.w;","#else","float depth = gl_FragCoord.z / gl_FragCoord.w;","#endif","depth = 1.0 - depth;","gl_FragColor = packDepth(depth);","}"].join("\n")},tr={uniforms:{tDepth:{type:"t",value:null},worldSize:{type:"v3",value:new THREE.Vector3(1,1,1)}},defines:{},vertexShader:["varying vec2 vUv;","void main() {","vUv = vec2(uv.x, uv.y);","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#define NUM_SAMPLES 29.0","#define NUM_SPIRAL_TURNS 7.0","uniform sampler2D tDepth;","uniform vec3 worldSize;","varying vec2 vUv;","#ifdef PRESET_2","#define SAMPLE_RADIUS 0.3","#define AO_GAMMA 1.0","#define AO_INTENSITY 1.0","#else","#define SAMPLE_RADIUS 0.2","#define AO_GAMMA 3.0","#define AO_INTENSITY 0.8","#endif",t,"#define PI 3.14159265358979","float rand(vec2 co) {","return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);","}","float getRandomAngle(vec2 pos) {","return rand(pos) * (2.0 * PI);","}","vec2 tapLocation(float sampleNumber, float spinAngle, out float ssR){","float alpha = float(sampleNumber + 0.5) * (1.0 / NUM_SAMPLES);","float angle = alpha * (NUM_SPIRAL_TURNS * PI * 2.0) + spinAngle;","ssR = alpha;","return vec2(cos(angle), sin(angle));","}","vec2 sampleAO(vec2 unitDirection, float radius) {","vec2 sampleOffset = unitDirection * radius;","float idepth = unpackDepth(texture2D(tDepth, vUv + sampleOffset));","float depth = 1.0 - idepth;","if (depth < 1e-6) {","if (radius == 0.0)","return vec2(1.0, 1.0);","else","return vec2(0.0, 1.0);","}","vec3 dir = vec3(sampleOffset.x, depth, sampleOffset.y) * worldSize;","float distance2 = dot(dir,dir);","float idistance = 1.0 / sqrt(distance2);","vec3 ndir = dir * idistance;","#ifdef PRESET_2","float importance = ndir.y * idistance;","#else","float importance = ndir.y / distance2;","#endif","vec2 ret;","ret.x = (idepth == 0.0) ? 0.0 : importance;","ret.y = importance;","return ret;","}","void main() {","vec2 sum = vec2(0.0);","float angle = getRandomAngle(vUv);","for (float i = 0.0; i<NUM_SAMPLES; i+= 1.0) {","float ssR;","vec2 uv = tapLocation(i, angle, ssR);","sum += sampleAO(uv, ssR * SAMPLE_RADIUS);","}","float ao = sum.x / sum.y;","gl_FragColor = packDepth(AO_INTENSITY * clamp(pow(ao, AO_GAMMA), 0.0, 0.9999));","}"].join("\n")},nr={uniforms:{tDepth:{type:"t",value:null}},defines:{},vertexShader:["varying vec2 vUv;","void main() {","vUv = vec2(uv.x, uv.y);","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDepth;","varying vec2 vUv;","#ifdef HORIZONTAL","#define GET_UV(X) vec2(vUv.x + KERNEL_SCALE*(X), vUv.y)","#else","#define GET_UV(Y) vec2(vUv.x, vUv.y + KERNEL_SCALE*(Y))","#endif",t,"#define PI 3.14159265358979","#define SIGMA ((2.0 * KERNEL_RADIUS+1.0) / 6.0)","#define SIGMASQ2 (2.0 * SIGMA * SIGMA)","#ifdef BOX","#define KERNEL_VAL(X) 1.0","#else","#define KERNEL_VAL(X) ( (1.0 / sqrt(PI * SIGMASQ2)) * exp(-(X)*(X)/SIGMASQ2) )","#endif","void main() {","float depthVal = 0.0;","float sum = 0.0;","for (float x=-KERNEL_RADIUS; x<=KERNEL_RADIUS; x+=1.0) {","depthVal += unpackDepth(texture2D(tDepth, GET_UV(x))) * KERNEL_VAL(x);","sum += KERNEL_VAL(x);","}","gl_FragColor = packDepth(depthVal/sum);","}"].join("\n")},ir={uniforms:{tDepth:{type:"t",value:null},uShadowColor:{type:"v4",value:new THREE.Vector4(0,0,0,1)}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = vec2(uv.x, uv.y);"," gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDepth;","uniform vec4 uShadowColor;","varying vec2 vUv;",t,"void main() {","float depthVal = unpackDepth(texture2D(tDepth, vUv));","#ifdef DARKNESS_SCALE","depthVal *= DARKNESS_SCALE;","#endif","gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * depthVal);","}"].join("\n")};function rr(e,t){return(rr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}Ji.prototype.constructor=Ji;var or=function(t){function e(){var e=t.call(this)||this;return e.name="",e.prototypeMap=new Map,e}n=t,(i=e).prototype=Object.create(n.prototype),rr(i.prototype.constructor=i,n);var n,i=e.prototype;return i.overrideValue=function(e,t,n){this.prototypeMap.has(e)||this.prototypeMap.set(e,new Map),this.prototypeMap.get(e).set(t,{type:"value",value:n})},i.overrideFunction=function(e,t,n){this.prototypeMap.has(e)||this.prototypeMap.set(e,new Map),this.prototypeMap.get(e).set(t,{type:"function",value:n})},i.overridePrototype=function(e,t){this.prototypeMap.has(e)||this.prototypeMap.set(e,new Map),this.prototypeMap.get(e).set("",{type:"prototype",value:t})},i.load=function(r){this.isLoad||(this.prototypeMap.forEach(function(e,i,t){e.forEach(function(e,t,n){"prototype"===e.type?(e.lastValue=NDSWebViewer[i].prototype,NDSWebViewer[i].prototype=e.value):("Viewer"===i&&r&&(r[t]=e.value),e.lastValue=NDSWebViewer[i].prototype[t],NDSWebViewer[i].prototype[t]=e.value)})}),this.isLoad=!0)},i.unload=function(r){this.isLoad&&(this.prototypeMap.forEach(function(e,i,t){e.forEach(function(e,t,n){"prototype"===e.type?NDSWebViewer[i].prototype=e.lastValue:("Viewer"===i&&r&&(r[t]=e.lastValue),NDSWebViewer[i].prototype[t]=e.lastValue)})}),this.isLoad=!1)},i.update=function(e){},e}(THREE.EventDispatcher),Te=function(){function e(){}return e.addExtension=function(e){this.extensions.set(e.name,e)},e.removeExtension=function(e){this.extensions.has(e)&&this.extensions.get(e).unload(),this.extensions.delete(e)},e.getExtension=function(e){return this.extensions.get(e)},e.update=function(i){this.extensions.forEach(function(e,t,n){e.update(i)})},e}();function B(){B=function(){return a};var l,a={},e=Object.prototype,d=e.hasOwnProperty,c=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",r=t.toStringTag||"@@toStringTag";function o(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(l){o=function(e,t,n){return e[t]=n}}function s(e,t,n,i){var r,o,a,s,t=t&&t.prototype instanceof v?t:v,t=Object.create(t.prototype),i=new T(i||[]);return c(t,"_invoke",{value:(r=e,o=n,a=i,s=u,function(e,t){if(s===f)throw Error("Generator is already running");if(s===m){if("throw"===e)throw t;return{value:l,done:!0}}for(a.method=e,a.arg=t;;){var n=a.delegate;if(n){n=function e(t,n){var i=n.method,r=t.iterator[i];if(r===l)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=l,e(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;i=h(r,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,g;r=i.arg;return r?r.done?(n[t.resultName]=r.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=l),n.delegate=null,g):r:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}(n,a);if(n){if(n===g)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(s===u)throw s=m,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);s=f;n=h(r,o,a);if("normal"===n.type){if(s=a.done?m:p,n.arg===g)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(s=m,a.method="throw",a.arg=n.arg)}})}),t}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}a.wrap=s;var u="suspendedStart",p="suspendedYield",f="executing",m="completed",g={};function v(){}function A(){}function y(){}var t={},E=(o(t,i,function(){return this}),Object.getPrototypeOf),E=E&&E(E(S([]))),M=(E&&E!==e&&d.call(E,i)&&(t=E),y.prototype=v.prototype=Object.create(t));function w(e){["next","throw","return"].forEach(function(t){o(e,t,function(e){return this._invoke(t,e)})})}function b(a,s){var t;c(this,"_invoke",{value:function(n,i){function e(){return new s(function(e,t){!function t(e,n,i,r){var o,e=h(a[e],a,n);if("throw"!==e.type)return(n=(o=e.arg).value)&&"object"==typeof n&&d.call(n,"__await")?s.resolve(n.__await).then(function(e){t("next",e,i,r)},function(e){t("throw",e,i,r)}):s.resolve(n).then(function(e){o.value=e,i(o)},function(e){return t("throw",e,i,r)});r(e.arg)}(n,i,e,t)})}return t=t?t.then(e,e):e()}})}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(t){if(t||""===t){var n,e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(d.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=l,e.done=!0,e}).next=e}throw new TypeError(typeof t+" is not iterable")}return c(M,"constructor",{value:A.prototype=y,configurable:!0}),c(y,"constructor",{value:A,configurable:!0}),A.displayName=o(y,r,"GeneratorFunction"),a.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===A||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,o(e,r,"GeneratorFunction")),e.prototype=Object.create(M),e},a.awrap=function(e){return{__await:e}},w(b.prototype),o(b.prototype,n,function(){return this}),a.AsyncIterator=b,a.async=function(e,t,n,i,r){void 0===r&&(r=Promise);var o=new b(s(e,t,n,i),r);return a.isGeneratorFunction(t)?o:o.next().then(function(e){return e.done?e.value:o.next()})},w(M),o(M,r,"Generator"),o(M,i,function(){return this}),o(M,"toString",function(){return"[object Generator]"}),a.keys=function(e){var t,n=Object(e),i=[];for(t in n)i.push(t);return i.reverse(),function e(){for(;i.length;){var t=i.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=S,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=l,this.done=!1,this.delegate=null,this.method="next",this.arg=l,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&d.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=l)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var i=this;function e(e,t){return o.type="throw",o.arg=n,i.next=e,t&&(i.method="next",i.arg=l),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t],o=r.completion;if("root"===r.tryLoc)return e("end");if(r.tryLoc<=this.prev){var a=d.call(r,"catchLoc"),s=d.call(r,"finallyLoc");if(a&&s){if(this.prev<r.catchLoc)return e(r.catchLoc,!0);if(this.prev<r.finallyLoc)return e(r.finallyLoc)}else if(a){if(this.prev<r.catchLoc)return e(r.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return e(r.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&d.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}var o=(r=r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc?null:r)?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),I(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,i,r=this.tryEntries[t];if(r.tryLoc===e)return"throw"===(n=r.completion).type&&(i=n.arg,I(r)),i}throw Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=l),g}},a}function ar(e,t,n,i,r,o,a){try{var s=e[o](a),l=s.value}catch(e){return n(e)}s.done?t(l):Promise.resolve(l).then(i,r)}function sr(s){return function(){var e=this,a=arguments;return new Promise(function(t,n){var i=s.apply(e,a);function r(e){ar(i,t,n,r,o,"next",e)}function o(e){ar(i,t,n,r,o,"throw",e)}r(void 0)})}}Te.extensions=new Map;var lr=new THREE.TextureLoader(new THREE.LoadingManager);lr.crossOrigin="anonymous";function dr(){this.m_box=new Y,this.m_leftChild=-1,this.m_nPrims=0,this.m_startPrim=-1}function cr(e,t){this.m_box=e,this.m_triangles=t}var hr=function(){function A(){}return A.loadCommonImage=function(i,r,o){return new Promise(function(e,t){try{var n=lr.load(o,function(){i[r].wrapS=THREE.RepeatWrapping,i[r].wrapT=THREE.RepeatWrapping,i.needsUpdate=!0,e(n)},void 0,function(){i.needsUpdate=!0,i[r]=null,e(n)});i[r]=n,i[r].sourceFile=o}catch(e){t(e)}})},A.setTexture=function(){var i=sr(B().mark(function e(t,n,i){var r;return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&t[n]&&t[n].sourceFile==i)return e.abrupt("return");e.next=2;break;case 2:return r=i,e.next=5,A.loadCommonImage(t,n,r);case 5:case"end":return e.stop()}},e)}));return function(e,t,n){return i.apply(this,arguments)}}(),A.resetTexture=function(){var r=sr(B().mark(function e(t,n,i,r){return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return");case 2:if(i){e.next=6;break}return t.needsUpdate=!0,t[n]=null,e.abrupt("return");case 6:return t.needsUpdate=!0,e.next=9,A.setTexture(t,n,i,r);case 9:case"end":return e.stop()}},e)}));return function(e,t,n,i){return r.apply(this,arguments)}}(),A.paramValid=function(e){return null!=e&&""!==e?!0:!1},A.updatePbrMatInfo=function(){var i=sr(B().mark(function e(t,n,i){return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=1,A.paramValid(n.doubleSided)&&(t.side=THREE.DoubleSide),A.paramValid(n.name)&&(t.name=n.name),A.paramValid(n.color)&&(isNaN(n.color)?t.color.setStyle(n.color):t.color.setHex(n.color)),A.paramValid(n.skinning)&&(t.skinning=n.skinning),A.paramValid(n.emissive)&&(isNaN(n.emissive)?t.emissive.setStyle(n.emissive):t.emissive.setHex(n.emissive)),A.paramValid(n.specularColor)&&(isNaN(n.specularColor)?t.specularColor.setStyle(n.specularColor):t.specularColor.setHex(n.specularColor)),A.paramValid(n.metalness)&&(t.metalness=parseFloat(n.metalness)),A.paramValid(n.roughness)&&(t.roughness=parseFloat(n.roughness)),A.paramValid(n.alphaTest)&&(t.alphaTest=parseFloat(n.alphaTest)),A.paramValid(n.clearcoat)&&(t.clearcoat=parseFloat(n.clearcoat)),A.paramValid(n.clearcoatRoughness)&&(t.clearcoatRoughness=parseFloat(n.clearcoatRoughness)),A.paramValid(n.specularIntensity)&&(t.specularIntensity=parseFloat(n.specularIntensity)),A.paramValid(n.transmission)&&Se.isSupportCanvas2()&&(t.transmission=parseFloat(n.transmission)),A.paramValid(n.reflectivity)&&(t.reflectivity=parseFloat(n.reflectivity)),0==n.reflectivity&&A.paramValid(n.ior)&&(t.ior=parseFloat(n.ior)),A.paramValid(n.opacity)&&(t.opacity=parseFloat(n.opacity),t.opacity<1?t.transparent=!0:t.transparent=!1,i)&&(i.transparentBodyChanged=!0),A.paramValid(n.emissiveIntensity)&&(t.emissiveIntensity=parseFloat(n.emissiveIntensity)),A.paramValid(n.normalScale)&&(n.normalScale=parseFloat(n.normalScale),t.normalScale=new THREE.Vector2(n.normalScale,n.normalScale)),(t.alphaMap&&!n.alphaMap||!t.alphaMap&&n.alphaMap||t.alphaMap&&t.alphaMap.sourceFile!=n.alphaMap)&&i&&(i.transparentBodyChanged=!0),e.next=22,A.resetTexture(t,"map",n.map);case 22:return e.next=24,A.resetTexture(t,"normalMap",n.normalMap);case 24:return e.next=26,A.resetTexture(t,"emissiveMap",n.emissiveMap);case 26:return e.next=28,A.resetTexture(t,"alphaMap",n.alphaMap);case 28:return e.next=30,A.resetTexture(t,"metalnessMap",n.metalnessMap);case 30:return e.next=32,A.resetTexture(t,"roughnessMap",n.roughnessMap);case 32:return e.next=34,A.resetTexture(t,"specularIntensityMap",n.specularIntensityMap);case 34:return e.next=36,A.resetTexture(t,"specularColorMap",n.specularColorMap);case 36:return t.alphaMap&&(t.transparent=!0),e.abrupt("return",t);case 38:case"end":return e.stop()}},e)}));return function(e,t,n){return i.apply(this,arguments)}}(),A.updatePhongMatInfo=function(){var i=sr(B().mark(function e(t,n,i){return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=1,A.paramValid(n.doubleSided)&&(t.side=THREE.DoubleSide),A.paramValid(n.name)&&(t.name=n.name),A.paramValid(n.color)&&(isNaN(n.color)?t.color.setStyle(n.color):t.color.setHex(n.color)),A.paramValid(n.emissive)&&(isNaN(n.emissive)?t.emissive.setStyle(n.emissive):t.emissive.setHex(n.emissive)),A.paramValid(n.skinning)&&(t.skinning=n.skinning),A.paramValid(n.opacity)&&(t.opacity=parseFloat(n.opacity),t.opacity<1?t.transparent=!0:t.transparent=!1,i)&&(i.transparentBodyChanged=!0),A.paramValid(n.emissiveIntensity)&&(t.emissiveIntensity=parseFloat(n.emissiveIntensity)),A.paramValid(n.reflectivity)&&(t.reflectivity=parseFloat(n.reflectivity)),A.paramValid(n.normalScale)&&(n.normalScale=parseFloat(n.normalScale),t.normalScale=new THREE.Vector2(n.normalScale,n.normalScale)),(t.alphaMap&&!n.alphaMap||!t.alphaMap&&n.alphaMap||t.alphaMap&&t.alphaMap.sourceFile!=n.alphaMap)&&i&&(i.transparentBodyChanged=!0),e.next=13,A.resetTexture(t,"map",n.map);case 13:return e.next=15,A.resetTexture(t,"normalMap",n.normalMap);case 15:return e.next=17,A.resetTexture(t,"emissiveMap",n.emissiveMap);case 17:return e.next=19,A.resetTexture(t,"alphaMap",n.alphaMap);case 19:return t.alphaMap&&(t.transparent=!0),e.abrupt("return",t);case 21:case"end":return e.stop()}},e)}));return function(e,t,n){return i.apply(this,arguments)}}(),A.updateStanderMatInfo=function(){var i=sr(B().mark(function e(t,n,i){return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=1,A.paramValid(n.doubleSided)&&(t.side=THREE.DoubleSide),A.paramValid(n.name)&&(t.name=n.name),A.paramValid(n.color)&&(isNaN(n.color)?t.color.setStyle(n.color):t.color.setHex(n.color)),A.paramValid(n.skinning)&&(t.skinning=n.skinning),A.paramValid(n.emissive)&&(isNaN(n.emissive)?t.emissive.setStyle(n.emissive):t.emissive.setHex(n.emissive)),A.paramValid(n.metalness)&&(t.metalness=parseFloat(n.metalness)),A.paramValid(n.roughness)&&(t.roughness=parseFloat(n.roughness)),A.paramValid(n.alphaTest)&&(t.alphaTest=parseFloat(n.alphaTest)),A.paramValid(n.opacity)&&(t.opacity=parseFloat(n.opacity),t.opacity<1?t.transparent=!0:t.transparent=!1,i)&&(i.transparentBodyChanged=!0),A.paramValid(n.emissiveIntensity)&&(t.emissiveIntensity=parseFloat(n.emissiveIntensity)),A.paramValid(n.normalScale)&&(n.normalScale=parseFloat(n.normalScale),t.normalScale=new THREE.Vector2(n.normalScale,n.normalScale)),(t.alphaMap&&!n.alphaMap||!t.alphaMap&&n.alphaMap||t.alphaMap&&t.alphaMap.sourceFile!=n.alphaMap)&&i&&(i.transparentBodyChanged=!0),e.next=15,A.resetTexture(t,"map",n.map);case 15:return e.next=17,A.resetTexture(t,"normalMap",n.normalMap);case 17:return e.next=19,A.resetTexture(t,"emissiveMap",n.emissiveMap);case 19:return e.next=21,A.resetTexture(t,"alphaMap",n.alphaMap);case 21:return e.next=23,A.resetTexture(t,"metalnessMap",n.metalnessMap);case 23:return e.next=25,A.resetTexture(t,"roughnessMap",n.roughnessMap);case 25:return t.alphaMap&&(t.transparent=!0),e.abrupt("return",t);case 27:case"end":return e.stop()}},e)}));return function(e,t,n){return i.apply(this,arguments)}}(),A.updateBasicMatInfo=function(){var i=sr(B().mark(function e(t,n,i){return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=1,A.paramValid(n.doubleSided)&&(t.side=THREE.DoubleSide),A.paramValid(n.name)&&(t.name=n.name),A.paramValid(n.color)&&(isNaN(n.color)?t.color.setStyle(n.color):t.color.setHex(n.color)),A.paramValid(n.skinning)&&(t.skinning=n.skinning),A.paramValid(n.opacity)&&(t.opacity=parseFloat(n.opacity),t.opacity<1?t.transparent=!0:t.transparent=!1,i)&&(i.transparentBodyChanged=!0),(t.alphaMap&&!n.alphaMap||!t.alphaMap&&n.alphaMap||t.alphaMap&&t.alphaMap.sourceFile!=n.alphaMap)&&i&&(i.transparentBodyChanged=!0),e.next=9,A.resetTexture(t,"map",n.map);case 9:return e.next=11,A.resetTexture(t,"alphaMap",n.alphaMap);case 11:return t.alphaMap&&(t.transparent=!0),e.abrupt("return",t);case 13:case"end":return e.stop()}},e)}));return function(e,t,n){return i.apply(this,arguments)}}(),A.parseBodyMaterial=function(){var r=sr(B().mark(function e(t,n,i,r){var o,a,s,l,d,c,h,u;return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n&&i&&t){e.next=3;break}return e.abrupt("return");case 3:o=[],a=0;case 5:if(a<n.length){if(s=n[a],l=s.type,d=void 0,"MeshBasicMaterial"==l)return d=new THREE.MeshBasicMaterial,e.next=13,A.updateBasicMatInfo(d,s,t);e.next=15}else e.next=35;break;case 13:e.next=30;break;case 15:if("MeshPhongMaterial"==l)return d=new THREE.MeshPhongMaterial,e.next=19,A.updatePhongMatInfo(d,s,t);e.next=21;break;case 19:e.next=30;break;case 21:if("MeshStandardMaterial"==l)return d=new THREE.MeshStandardMaterial,e.next=25,A.updateStanderMatInfo(d,s,t);e.next=27;break;case 25:e.next=30;break;case 27:return d=new THREE.MeshPhysicalMaterial,e.next=30,A.updatePbrMatInfo(d,s,t);case 30:d.uuid=s.uuid,o[a]=d;case 32:a++,e.next=5;break;case 35:if(i)for(c in i)u=i[h=c],(u=o[u])&&t.getBodyNodeFromUuid(h)&&t.setBodyNodeMaterial(h,u);r&&r();case 37:case"end":return e.stop()}},e)}));return function(e,t,n,i){return r.apply(this,arguments)}}(),A.parseMeshMaterial=function(){var o=sr(B().mark(function e(t,n,i,r,o){var a,s,l,d,c,h,u,p,f,m,g,v;return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&n&&i){e.next=3;break}return e.abrupt("return");case 3:for(a=[],s=0;s<n.length;s++)l=n[s],d=l.type,c=void 0,"MeshBasicMaterial"==d?(c=new THREE.MeshBasicMaterial,A.updateBasicMatInfo(c,l,t)):"MeshPhongMaterial"==d?(new THREE.MeshPhongMaterial,c=A.updatePhongMatInfo(c,l,t)):"MeshStandardMaterial"==d?(c=new THREE.MeshStandardMaterial,A.updateStanderMatInfo(c,l,t)):(c=new THREE.MeshPhysicalMaterial,A.updatePbrMatInfo(c,l,t)),c.uuid=l.uuid,a[s]=c;if(o&&i){for(h in i){if(u=h,t.meshManager.meshObjectUuids)for(p in t.meshManager.meshObjectUuids)t.meshManager.meshObjectUuids[p]==h&&(u=p);f=i[h],v=n[f],(f=a[f])&&(f.uuid=v.uuid,t.meshManager.bodyNodes[u])&&(m=f.uuid,v=parseFloat(v.refcount)||1,t.meshManager.materialUuids.includes(m)||t.meshManager.materialUuids.push(m),g=t.meshManager.materialUuids.indexOf(m),t.meshManager.materials[m]={mat:f,refCount:v},t.meshManager.materialIdOriginal[u]=g,t.meshManager.materialId[u]=g)}t.meshManager.mapGeomUuidToGeomId()}r&&r();case 7:case"end":return e.stop()}},e)}));return function(e,t,n,i,r){return o.apply(this,arguments)}}(),A.parseMaterialInfo=function(){var i=sr(B().mark(function e(t,n,i){var r,o,a,s,l,d,c,h;return B().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&n){e.next=3;break}return e.abrupt("return");case 3:if(r=t.materials,o=t.bodyMaterialList,a=t.meshMaterialList,r){e.next=9;break}return e.abrupt("return");case 9:s=0;case 10:if(s<n.ndsModel.models.length){if(l=n.ndsModel.models[s],d=r[s],c=o[s],h=a[s],c)return e.next=18,A.parseBodyMaterial(l,d,c);e.next=18}else e.next=24;break;case 18:if(h)return e.next=21,A.parseMeshMaterial(l,d,h,null,!0);e.next=21;break;case 21:s++,e.next=10;break;case 24:n.render(),i&&i();case 26:case"end":return e.stop()}},e)}));return function(e,t,n){return i.apply(this,arguments)}}(),A}(),ur=function(){function e(e,t,n){this.m_value=[],this.m_value[0]=e||0,this.m_value[1]=t||0,this.m_value[2]=n||0}var t=e.prototype;return t.LargestCoordIndex=function(){var e=0;return this.m_value[1]>this.m_value[0]&&(e=1),e=this.m_value[2]>this.m_value[e]?2:e},t.DistanceToPoint=function(e){return Math.sqrt(Math.pow(this.m_value[0]-e.m_value[0],2)+Math.pow(this.m_value[1]-e.m_value[1],2)+Math.pow(this.m_value[2]-e.m_value[2],2))},t.GetValue=function(e){return this.m_value[e]},e}(),Y=function(){function n(){this.m_value=[],this.m_value[0]=this.m_value[1]=this.m_value[2]=1/0,this.m_value[3]=this.m_value[4]=this.m_value[5]=-1/0}var e=n.prototype;return e.Init=function(){this.m_value[0]=this.m_value[1]=this.m_value[2]=1/0,this.m_value[3]=this.m_value[4]=this.m_value[5]=-1/0},e.GetCentriod=function(){return new ur(.5*(this.m_value[0]+this.m_value[3]),.5*(this.m_value[1]+this.m_value[4]),.5*(this.m_value[2]+this.m_value[5]))},e.GetMinMaxPoint=function(e,t){new ur(this.m_value[0],this.m_value[1],this.m_value[2]),new ur(this.m_value[3],this.m_value[4],this.m_value[5])},e.SetMinMaxPoint=function(e,t){this.m_value[0]=e.m_value[0],this.m_value[1]=e.m_value[1],this.m_value[2]=e.m_value[2],this.m_value[3]=t.m_value[0],this.m_value[4]=t.m_value[1],this.m_value[5]=t.m_value[2]},e.SetMinMaxPointFromArray=function(e){this.m_value[0]=e[0],this.m_value[1]=e[1],this.m_value[2]=e[2],this.m_value[3]=e[3],this.m_value[4]=e[4],this.m_value[5]=e[5]},e.GetSize=function(){return new ur(this.m_value[3]-this.m_value[0],this.m_value[4]-this.m_value[1],this.m_value[5]-this.m_value[2])},e.Area=function(){var e=this.m_value[3]-this.m_value[0],t=this.m_value[4]-this.m_value[1],n=this.m_value[5]-this.m_value[2];return e<0||t<0||n<0?0:2*(e*t+t*n+e*n)},e.DiagonalLength=function(){return Math.sqrt(Math.pow(this.m_value[0]-this.m_value[3],2)+Math.pow(this.m_value[1]-this.m_value[4],2)+Math.pow(this.m_value[2]-this.m_value[5],2))},e.AddPoint=function(e){e.m_value[0]<this.m_value[0]&&(this.m_value[0]=e.m_value[0]),e.m_value[0]>this.m_value[3]&&(this.m_value[3]=e.m_value[0]),e.m_value[1]<this.m_value[1]&&(this.m_value[1]=e.m_value[1]),e.m_value[1]>this.m_value[4]&&(this.m_value[4]=e.m_value[1]),e.m_value[2]<this.m_value[2]&&(this.m_value[2]=e.m_value[2]),e.m_value[2]>this.m_value[5]&&(this.m_value[5]=e.m_value[2])},e.AddVector=function(e){this.m_value[0]=Math.min(e.x,this.m_value[0]),this.m_value[1]=Math.min(e.y,this.m_value[1]),this.m_value[2]=Math.min(e.z,this.m_value[2]),this.m_value[3]=Math.max(e.x,this.m_value[3]),this.m_value[4]=Math.max(e.y,this.m_value[4]),this.m_value[5]=Math.max(e.z,this.m_value[5])},e.AddBox=function(e){e.m_value[0]<this.m_value[0]&&(this.m_value[0]=e.m_value[0]),e.m_value[3]>this.m_value[3]&&(this.m_value[3]=e.m_value[3]),e.m_value[1]<this.m_value[1]&&(this.m_value[1]=e.m_value[1]),e.m_value[4]>this.m_value[4]&&(this.m_value[4]=e.m_value[4]),e.m_value[2]<this.m_value[2]&&(this.m_value[2]=e.m_value[2]),e.m_value[5]>this.m_value[5]&&(this.m_value[5]=e.m_value[5])},e.IsIntersectBox=function(e){return!(e.m_value[3]<this.m_value[0]||e.m_value[0]>this.m_value[3]||e.m_value[4]<this.m_value[1]||e.m_value[1]>this.m_value[4]||e.m_value[5]<this.m_value[2]||e.m_value[2]>this.m_value[5])},e.GetValue=function(e){return this.m_value[e]},e.SetFromBox=function(e){this.m_value[0]=e.m_value[0],this.m_value[1]=e.m_value[1],this.m_value[2]=e.m_value[2],this.m_value[3]=e.m_value[3],this.m_value[4]=e.m_value[4],this.m_value[5]=e.m_value[5]},e.MultiplyMatrix=function(e){n.points[0].set(this.m_value[0],this.m_value[1],this.m_value[2]).applyMatrix4(e),n.points[1].set(this.m_value[3],this.m_value[1],this.m_value[2]).applyMatrix4(e),n.points[2].set(this.m_value[3],this.m_value[1],this.m_value[5]).applyMatrix4(e),n.points[3].set(this.m_value[0],this.m_value[1],this.m_value[5]).applyMatrix4(e),n.points[4].set(this.m_value[0],this.m_value[4],this.m_value[2]).applyMatrix4(e),n.points[5].set(this.m_value[3],this.m_value[4],this.m_value[2]).applyMatrix4(e),n.points[6].set(this.m_value[3],this.m_value[4],this.m_value[5]).applyMatrix4(e),n.points[7].set(this.m_value[0],this.m_value[4],this.m_value[5]).applyMatrix4(e),this.Init();for(var t=0;t<8;++t)this.AddVector(n.points[t])},e.toArray=function(){return this.m_value},n}(),pr=(Y.points=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],function(){function e(){this.m_size=0,this.m_nodes=[],this.m_primIds=[]}var t=e.prototype;return t.Reset=function(){this.m_nodes=[],this.m_primIds=[],this.m_size=0},t.SetNumEstimateNodes=function(e){for(var t=0;t<e;++t){var n=new dr;this.m_nodes[t]=n}this.m_size=0},t.GetNode=function(e){return this.m_nodes[e]},t.AllocNode=function(e){var t=this.m_nodes.length;if(this.m_size+e>t){var n=t/4;(n=n<16?16:n)<e&&(n=e);for(var i=0;i<n;++i){var r=new dr;this.m_nodes.push(r)}}t=this.m_size;return this.m_size+=e,t},e}()),fr=function(){function e(e,t){this.m_maxLevel=11,this.m_widthTol=0,this.m_nodeManager=new pr,this.jsonModel=e,this.bvh=t.bvh,this.MeshIndex=0,this.LineIndex=0,this.geometryToPri=[],this.matrixtem=new THREE.Matrix4;var n=new THREE.Matrix4;this.matrixs=[],n.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.matrixs.push(n),this.m_boxes=[],this.m_primIds=[],this.m_nPrimTris=[],this.materials=[],e.materials&&(this.materials=e.materials.concat()),this.ndsModel=t,this.UuidToMaterialID={}}var t=e.prototype;return t.Reset=function(){this.m_boxes=[],this.m_primIds=[],this.m_nPrimTris=[]},t.Build=function(){var e=this.jsonModel.bufferchunks;if(null!=e){for(var t=0;t<e.length;++t)for(var n=0;n<e[t].geometries.length;++n){var i,r=e[t].geometries[n];r.triangles&&((i=new Y).SetMinMaxPointFromArray(r.box),i=new cr(i,r.triangles),this.geometryToPri[r.uuid]=i)}this.bvh.meshManager.setNumMeshes(this.jsonModel.object.meshNum),this.bvh.meshManager.setNumLineSegments(this.jsonModel.object.lineNum),this.deepTree(this.jsonModel.object),this.Create(this.m_primIds,this.m_nPrimTris,this.m_boxes,32,32e3),this.BVHconstruct()}},t.Create=function(e,t,n,i,r){var o=n.length;if(this.m_nodeManager.Reset(),o){for(var a=[],s=0;s<o;++s)a[s]=n[s].GetCentriod();for(var l=2*Math.ceil(o/i),d=1;(d*=2)<l;);this.m_nodeManager.SetNumEstimateNodes(d);for(var c=this.m_nodeManager.AllocNode(1),h=this.m_nodeManager.GetNode(c),u=new Y,p=new Y,f=0;f<o;++f)u.AddBox(n[f]),p.AddPoint(a[f]);for(var m=u.GetSize(),g=(this.m_widthTol=1e-5*m.m_value[m.LargestCoordIndex()],h.m_box=u,h.m_nPrims=o,h.m_startPrim=0,new Array(e.length)),v=0;v<e.length;++v)g[v]=v;this.Subdvide(c,p,n,a,g,t,i,r,0),this.m_nodeManager.m_primIds=g}},t.Subdvide=function(e,t,n,i,r,o,a,s,l){for(var d,c,h,u,p,f=t.GetSize(),m=f.LargestCoordIndex(),g=this.m_nodeManager.GetNode(e),v=0,A=0;A<g.m_nPrims;A++)v+=o[g.m_startPrim+A];g.m_nPrims<a&&v<s||1==g.m_nPrims||l>=this.m_maxLevel||f.m_value[m]<this.m_widthTol||(e=g.m_startPrim,f=g.m_startPrim+g.m_nPrims,u=0,p=new Y,d=new Y,c=new Y,h=new Y,u=this.Partition(t,m,n,i,r,e,f,p,d,c,h),t=this.m_nodeManager.AllocNode(2),g.m_leftChild=t,(m=this.m_nodeManager.GetNode(t)).m_box=p,m.m_nPrims=u-e,m.m_startPrim=e,(m=this.m_nodeManager.GetNode(p=t+1)).m_box=d,m.m_nPrims=f-u,m.m_startPrim=u,this.Subdvide(t,c,n,i,r,o,a,s,l+1),this.Subdvide(p,h,n,i,r,o,a,s,l+1))},t.Partition=function(e,t,F,n,i,r,o,N,j,_,V){for(var a=16,k=.99999*(a=o-r<a?o-r:a)/(e.m_value[3+t]-e.m_value[t]),s=[],l=[],d=new Int32Array(a),c=new Int32Array(o-r),h=0;h<a;++h){var U=new Y,G=new Y;s[h]=U,l[h]=G}for(var u=r;u<o;++u){var p=Math.floor(k*(n[i[u]].m_value[t]-e.m_value[t]));p<0?p=0:a<=p&&(p=a-1),++d[c[u-r]=p],s[p].AddBox(F[i[u]]),l[p].AddPoint(n[i[u]])}var f=[],m=[],g=[],v=[];f[0]=d[0],m[0]=s[0],g[0]=l[0],v[0]=m[0].Area();for(var A=1;A<a-1;++A){f[A]=f[A-1]+d[A];var y=new Y,E=new Y;y.SetFromBox(m[A-1]),m[A]=y,m[A].AddBox(s[A]),E.SetFromBox(g[A-1]),g[A]=E,g[A].AddBox(l[A]),v[A]=m[A].Area()}var M=[],w=[],b=[],x=[];M[a-1]=d[a-1],w[a-1]=s[a-1],b[a-1]=l[a-1],x[a-1]=w[a-1].Area();for(var I=a-2;0<I;--I){M[I]=M[I+1]+d[I];var T=new Y,S=new Y;T.SetFromBox(w[I+1]),w[I]=T,w[I].AddBox(s[I]),S.SetFromBox(b[I+1]),b[I]=S,b[I].AddBox(l[I]),x[I]=w[I].Area()}for(var B=f[0]*v[0]+M[1]*x[1],P=0,C=1;C<a-1;++C){var R=f[C]*v[C]+M[C+1]*x[C+1];R<B&&(B=R,P=C)}for(var O=i.slice(r,o),L=0,D=r;D<o;++D)c[D-r]<=P&&(i[r+L]=O[D-r],++L);for(var z=r+L,W=0,H=r;H<o;++H)c[H-r]>P&&(i[z+W]=O[H-r],++W);return N.SetFromBox(m[P]),j.SetFromBox(w[P+1]),_.SetFromBox(g[P]),V.SetFromBox(b[P+1]),z},t.getMatrixId=function(e){for(var t=0,n=this.matrixs.length;t<n;++t)if(e.equals(this.matrixs[t]))return t;return-1},t.ParesLeafNode=function(e,t,n){var i,r,o=e.geometry,n=null!=n?n:0,a=this.UuidToMaterialID[e.material];"Mesh"===e.type?(i=this.geometryToPri[e.geometry])?((r=new Y).SetFromBox(i.m_box),r.MultiplyMatrix(t),this.m_boxes[this.MeshIndex]=r,this.m_nPrimTris[this.MeshIndex]=i.m_triangles,this.m_primIds[this.MeshIndex]=this.MeshIndex,this.bvh.meshManager.setMeshFromGeomUuid(this.MeshIndex++,r.toArray(),o,0,a,n)):(t=new Y,this.m_boxes[this.MeshIndex]=t,this.m_nPrimTris[this.MeshIndex]=0,this.m_primIds[this.MeshIndex]=this.MeshIndex,this.bvh.meshManager.setMeshFromGeomUuid(this.MeshIndex++,t.toArray(),o,0,a,n)):"LinePieces"===e.type&&this.bvh.meshManager.setLineSegmentsFromGeomUuid(this.LineIndex++,o,n,a)},t.deepTree=function(e){for(var t,n=this.materials.length,i=[],r=0;r<n;++r)t=this.materials[r].uuid,this.UuidToMaterialID[t]=r,i.push(t);this.bvh.meshManager.setMaterialUuids(i);var o=new THREE.Matrix4,a=(o.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),[]);a.push({node:e,nodematrix:o,Parentuuid:null});for(var s=0;s<a.length;++s){var l=a[s];if(null!=l.node.geometry)this.ParesLeafNode(l.node,l.nodematrix,l.Parentuuid);else if(null!=l.node.children&&0<l.node.children.length){l.node.matrix&&(this.matrixtem.fromArray(l.node.matrix),l.nodematrix.multiply(this.matrixtem)),null!=l.node.children[0].geometry&&(l.node.worldMatrix=l.nodematrix);for(var d=0;d<l.node.children.length;++d){var c={node:l.node.children[d],nodematrix:l.nodematrix.clone(),Parentuuid:l.node.uuid};a.push(c)}}}},t.BVHconstruct=function(){for(var e,t,n,i=this.m_nodeManager.m_size,r=(this.bvh.setNumNodes(i),new Float32Array(6)),o=0;o<i;++o){for(var a=0;a<6;++a)r[a]=this.m_nodeManager.m_nodes[o].m_box.m_value[a];e=this.m_nodeManager.m_nodes[o].m_leftChild,t=this.m_nodeManager.m_nodes[o].m_nPrims,n=this.m_nodeManager.m_nodes[o].m_startPrim,this.bvh.setNode(o,r,e,t,n)}this.bvh.setMeshIds(this.m_nodeManager.m_primIds),this.ndsModel.buildMeshSets()},t.Reconstruct=function(e){this.jsonModel=e;for(var t=this.jsonModel.bufferchunks,n=0;n<t.length;++n)for(var i=0;i<t[n].geometries.length;++i){var r,o=t[n].geometries[i];o.triangles&&((r=new Y).SetMinMaxPointFromArray(o.box),r=new cr(r,o.triangles),this.geometryToPri[o.uuid]=r)}this.MeshIndex=this.bvh.meshManager.nMeshes,this.LineIndex=this.bvh.meshManager.nLineSegments,this.bvh.meshManager.expandMeshes(this.jsonModel.object.meshNum),this.bvh.meshManager.expandLineSegments(this.jsonModel.object.lineNum);for(var a=this.materials.length,s=!1,l=0;l<e.materials.length;l++){for(var s=!1,d=0;d<a;d++)if(this.materials[d].uuid==e.materials[l].uuid){s=!0;break}s||this.materials.push(e.materials[l])}this.deepTree(this.jsonModel.object),this.Create(this.m_primIds,this.m_nPrimTris,this.m_boxes,32,32e3),this.BVHconstruct()},t.delete=function(n,e){this.m_primIds=this.m_primIds.filter(function(e,t){if(-1==n.indexOf(t))return!0}),this.m_nPrimTris=this.m_nPrimTris.filter(function(e,t){if(-1==n.indexOf(t))return!0}),this.m_boxes=this.m_boxes.filter(function(e,t){if(-1==n.indexOf(t))return!0}),this.bvh.meshManager.deleteMeshes(n),this.bvh.meshManager.deleteLineSegments(e),this.Rebuild()},t.Rebuild=function(){this.Create(this.m_primIds,this.m_nPrimTris,this.m_boxes,32,32e3),this.BVHconstruct()},e}();function mr(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function(e){e=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof e?e:e+""}(i.key),i)}}function gr(e,t){return(gr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}THREE.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new THREE.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},THREE.ShaderLib.line={uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t#ifdef USE_MODELMATRIXATTRIB\n\t\t\t\tmat4 ndsModelViewMatrix = viewMatrix * modelMatrixAttrib;\n\t\t\t\t// camera space\n\t\t\t\tvec4 start = ndsModelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\t\tvec4 end = ndsModelViewMatrix * vec4( instanceEnd, 1.0 );\n\t\t\t#else\n\t\t\t\t// camera space\n\t\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};var Ar=function(n){function e(e){var t=n.call(this,{type:"LineMaterialOrigin",uniforms:THREE.UniformsUtils.clone(THREE.ShaderLib.line.uniforms),vertexShader:THREE.ShaderLib.line.vertexShader,fragmentShader:THREE.ShaderLib.line.fragmentShader,clipping:!0})||this;return t.isLineMaterial=!0,t.setValues(e),t}var t,i,r;return i=n,(t=e).prototype=Object.create(i.prototype),gr(t.prototype.constructor=t,i),t=e,(i=[{key:"color",get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},{key:"worldUnits",get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},{key:"linewidth",get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}},{key:"dashed",get:function(){return"USE_DASH"in this.defines},set:function(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}},{key:"dashScale",get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},{key:"dashSize",get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},{key:"dashOffset",get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},{key:"gapSize",get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},{key:"opacity",get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms&&(this.uniforms.opacity.value=e)}},{key:"resolution",get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},{key:"alphaToCoverage",get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}])&&mr(t.prototype,i),r&&mr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(THREE.ShaderMaterial);function yr(e,t){var n,i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){{var n;if(e)return"string"==typeof e?Er(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Er(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length)return i&&(e=i),n=0,function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function Mr(e,t){return(Mr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}for(var wr=0,br=["ms","moz","webkit","o"],xr=0;xr<br.length&&!window.requestAnimationFrame;++xr)window.requestAnimationFrame=window[br[xr]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[br[xr]+"CancelAnimationFrame"]||window[br[xr]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e,t){var n=(new Date).getTime(),i=Math.max(0,16-(n-wr)),r=window.setTimeout(function(){e(n+i)},i);return wr=n+i,r}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)}),ve.StartRenderTime=Date.now();var Ir=function(fe){function me(I){var f=fe.call(this)||this,T=(console.log("NDSViewer3D v4.2.198"),Te.getExtension("SceneEditExtension")?Te.getExtension("SceneEditExtension").load(f):(f.ScenarioEditorInfo={},f.ScenarioEditorInfo.folderArray=[],f.ScenarioEditorInfo.nodeMatrix={},f.ScenarioEditorInfo.EulerAngle=new THREE.Vector3),f.jsonMainText=null,document.body.style.cssText="margin: 0; overflow: hidden",document.addEventListener("contextmenu",function(e){e.preventDefault()},!1),f.fontsManager=new On(f),f),m=[],S=(f.animationClock=new THREE.Clock,f.animationsManager=new tn(f),f.pmiObject=null,f.pmiVisible=!0,f.viewerPMIVisible=!0,f.pmiNum=0,f.brepMemory=0,f.haspartPMI=!1,f.hasAssemblyPMI=!1,f.PartPmiVisible=!0,f.AssemblyPMIVisible=!0,f.PartPMIuuid=[],f.explodeObjects=[],f.piovtInfoMap=new Map,f.currentSketchFileUrl="",f.sketchFileUrlQueue=[],f.mergeType=2,f.brepManager=null,f.inWaitProcedure=!1,f.inWheel=!1,f.AssemblyPMIState=null,f.PartPMIState=null,f.exchangeBackImage=null,f.exchangeNodeColor=[],f.Rectangle=[],f.modelRequestor=null,f.redererSide=null,f.requestAnimationFrameId=[],f.maxFPS=120,f.minFPS=40,f.maxFrameTime=1e3/f.minFPS,f.oldClearColor=new THREE.Color,f.emptyCenter=new THREE.Vector3,f.bodyUuid2ClonedNodeMap={},f._editIconVisible=!0,f._deleteIconVisible=!0,Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(e,t){return new Uint8Array(Array.prototype.slice.call(this,e,t))}}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){return e&&(this.filter(e)||[])[0]}}),f.addFrameListener=function(e){for(var t=0,n=m.length;t<n;t++)if(m[t]==e)return;m.push(e)},f.removeFrameListener=function(e){for(var t=0;t<m.length;t++)m[t]==e&&m.splice(t,1)},f.isIn3DViewer=function(){return!(T.is2DModel||T.is2DViewer||_e.inBIMContext||_e.ScenarioEditor||_e.AnimationEdit||_e.isARmodel||_e.isVRmodel)},T.lights=[],T.lightControls=null,T.leafPMIObjects=[],T.PMIUUIDtoPMIObject={},T.PMINDSBodys=[],T.viewer2DInfo={center:new THREE.Vector3(0,0,0),normal:new THREE.Vector3(0,0,1),yDir:new THREE.Vector3(0,1,0),distance:100},new THREE.LoadingManager),j=(T.annotationsManager=void 0,T.materialsSetting=void 0,T.propertyManager=new fi(T),T.containProperty=!1,null),g=(f.trueMapList=null,I.materialsSetting&&(j=I.materialsSetting,I.materialsSetting=void 0),void 0!==(I=I||{}).is2DViewer&&I.is2DViewer);T.is2DViewer=g,T.loadbrepDefault=I.loadbrepDefault,T.testMode=void 0!==I.testMode&&I.testMode,T.is2DModel=void 0!==I.is2DModel&&I.is2DModel,T.renderMode=void 0===I.viewState?"shaded":I.viewState,T.viewerPMIVisible=void 0===I.pmiVisible||I.pmiVisible,T.pmiVisible=T.viewerPMIVisible,T.bBackGroundTransparent=void 0!==I.backGroundTransparent&&I.backGroundTransparent,T.bLinesVisibility=void 0===I.showLines||I.showLines,T.bShowToolTip=void 0===I.showToolTip||I.showToolTip,T.bToolBarAutoHide=void 0===I.toolBarAutoHide||I.toolBarAutoHide,T.bMouseWheelForwardEnlarge=void 0===I.mouseWheelForwardEnlarge||I.mouseWheelForwardEnlarge,T.bHasLoadingWaiter=void 0===I.hasLoadingWaiter||I.hasLoadingWaiter,T.bHasLoadingCoverer=void 0===I.hasLoadingCoverer||I.hasLoadingCoverer,T.bHasLoadingStater=void 0!==I.hasLoadingStater&&I.hasLoadingStater,T.limitEventArea=void 0===I.limitEventArea?void 0:I.limitEventArea,T.convertPhongToPBR=void 0!==I.convertPhongToPBR&&I.convertPhongToPBR,T.reflected=void 0!==I.reflected&&I.reflected,T.enableInternalRMB=void 0!==I.enableInternalRMB&&I.enableInternalRMB,T.hasViewBox=void 0===I.hasViewBox||I.hasViewBox,T.showSectionPlane=void 0!==I.showSectionPlane&&I.showSectionPlane,T.viewBoxSize=I.viewBoxSize,T.workerString=I.singleWorkerSource,T.prepareModelCallBack=I.prepareModelCallBack,T.measuringScale=void 0===I.measuringScale?1:I.measuringScale,I.angles&&0<I.angles.length?T.Euler=new THREE.Euler(THREE.Math.degToRad(I.angles[0]),THREE.Math.degToRad(I.angles[1]),THREE.Math.degToRad(I.angles[2])):T.Euler=null,T.gobalReqHeader=void 0===I.gobalReqHeader?null:I.gobalReqHeader,T.logOperatorTime=!1,T.logOperatorTimeInfo={},T.showLineWidth=!1,T.disratio=void 0===I.disratio?1:I.disratio,T.parameters=I,Se.setMobileDevice(I.from),T.watermark=void 0===I.Arthur?null:I.Arthur,T.excalibur=!0;var v,A,_,y,E,e=function(e){for(var t=new String,n=new Array,i=new Array,r=e.length,o=0;o<r;o++)n[o]=e.charCodeAt(o),i[o]=e.charCodeAt(o+1);for(o=0;o<r;o+=2)t+=String.fromCharCode(n[o]-i[o]);return t},u=(T.watermark&&(T.watermark=e(T.watermark)),T.watermark&&4<T.watermark.length&&"9527"===T.watermark.substr(0,4)&&(T.excalibur=!1),T.turnoffAnimation=void 0!==I.turnoffAnimation&&I.turnoffAnimation,T.defaultStandardView=I.defaultStandardView,T.bDefaultOpRotate=void 0===I.defaultOpRotate||I.defaultOpRotate,void 0!==I.toolbarButtonClickedBkgColor&&(_e.toolbarButtonClickedBkgColor=I.toolbarButtonClickedBkgColor),_e.avoidCaching=void 0===I.avoidCaching||I.avoidCaching,_e.lineColor=void 0===I.lineColor?void 0:I.lineColor,_e.lineSegAnnotationGridCount=void 0===I.lineSegAnnotationGridCount?200:I.lineSegAnnotationGridCount,_e.enableBroadcast=void 0!==I.enableBroadcast&&I.enableBroadcast,_e.broadcastMajor=void 0!==I.broadcastMajor&&I.broadcastMajor,_e.enableSelect=void 0!==I.enableSelect&&I.enableSelect,_e.autoSwitchFirstPersonView=void 0!==I.autoSwitchFirstPersonView&&I.autoSwitchFirstPersonView,_e.tangentEdgeVisible=void 0===I.tangentEdgeVisible||I.tangentEdgeVisible,_e.enableArrowKeyOp=void 0===I.enableArrowKeyOp||I.enableArrowKeyOp,_e.dynamicRotateCenter=void 0===I.dynamicRotateCenter||I.dynamicRotateCenter,_e.enableOutlineEffect=void 0!==I.enableOutlineEffect&&I.enableOutlineEffect,_e.enableBodyVolumeMeasure=void 0!==I.enableBodyVolumeMeasure&&I.enableBodyVolumeMeasure,_e.enablePreSelectBrep=void 0!==I.enablePreSelectBrep&&I.enablePreSelectBrep,_e.selectObjectWithPropertyOnly=void 0!==I.selectObjectWithPropertyOnly&&I.selectObjectWithPropertyOnly,_e.enableDirectMove=void 0!==I.enableDirectMove&&I.enableDirectMove,_e.enableDirectRotate=void 0!==I.enableDirectRotate&&I.enableDirectRotate,_e.inAssemblyContext=void 0!==I.inAssemblyContext&&I.inAssemblyContext,_e.inBIMContext=void 0!==I.inBIMContext&&I.inBIMContext,_e.modelUpDirection=void 0===I.modelUpDirection?"posy":I.modelUpDirection,_e.bodyOpacity=void 0===I.bodyOpacity?.4:I.bodyOpacity,_e.lineOpacity=void 0===I.lineOpacity?.2:I.lineOpacity,_e.ScenarioEditor=void 0!==I.ScenarioEditor&&I.ScenarioEditor,_e.AnimationEdit=void 0!==I.AnimationEdit&&I.AnimationEdit,_e.singleHTML=void 0!==I.singleHTML&&I.singleHTML,_e.isVRmodel=void 0!==I.isVRmodel&&I.isVRmodel,_e.isARmodel=void 0!==I.isARmodel&&I.isARmodel,_e.supportAR=void 0!==I.supportAR&&I.supportAR,_e.HideLeafBody=void 0!==I.structureHideBody&&I.structureHideBody,_e.logarithmicDepthBuffer=void 0!==I.logarithmicDepthBuffer&&I.logarithmicDepthBuffer,T.bBackGroundTransparent=!!_e.isARmodel||T.bBackGroundTransparent,T.hasViewBox=!_e.isARmodel&&T.hasViewBox,_e.ScenarioEditor||_e.AnimationEdit||(T.CADViewer=!0),(I.inAssemblyContext||_e.singleHTML)&&(T.excalibur=!1),void 0!==I.NdsLoadWorkerUrl&&(_e.NdsLoadWorkerUrl=I.NdsLoadWorkerUrl),void 0!==I.serverUrl&&(_e.NdsLoadWorkerUrl=I.serverUrl+_e.NdsLoadWorkerUrl,T.serverUrl=I.serverUrl,"./"==T.serverUrl&&(T.serverUrl=null),console.log(_e.NdsLoadWorkerUrl)),T.oneKeyColor={isActive:!1,color:0},f.broadcastManager=new Sn(f),f.selectionManager=new mi(f),f.brepLoadIndex=0,f.brepInfo={BfaceArea:!1,BbodyVolume:!1,BbodyArea:!1,BtotalArea:!1,BfacePerimeter:!1},f.propertyMap=new Map,!0),B=!0,n=null,p=(void 0!==I.id&&(n=document.getElementById(I.id)),I.toolbar),e=(void 0===p&&(p=!0),T.toolbarInitialVisibility=void 0===I.toolbarInitialVisibility||I.toolbarInitialVisibility,null==n&&(n=new ve.Element,n=document.body.appendChild(n.domElement)),new ve.Element({className:"container"})),V=(e.domElement.style.width=n.style.width,e.domElement.style.height=n.style.height,f.container=n.appendChild(e.domElement),f.container.id="t_container",0),P=0,C=0,e=f.container.getBoundingClientRect(),k=(f.isRunning=!1,f.enableProgressiveRender=!0,T.bBackGroundTransparent?f.renderer=new rn({antialias:!0,alpha:!0,is2DModel:f.is2DModel,logarithmicDepthBuffer:_e.logarithmicDepthBuffer}):f.renderer=new rn({alpha:!0,antialias:!0,is2DModel:f.is2DModel,logarithmicDepthBuffer:_e.logarithmicDepthBuffer}),me.renderer=f.renderer,f.isiPhone=!1,f.deviceMemory=2,navigator&&-1!==navigator.userAgent.toLowerCase().indexOf("iphone")&&(f.isiPhone=!0,t=f.renderer.getContext().getExtension("WEBGL_debug_renderer_info"))&&(-1!==(t=f.renderer.getContext().getParameter(t.UNMASKED_RENDERER_WEBGL)).indexOf("A8")?f.deviceMemory=1:-1!==t.indexOf("A1")&&3<=window.devicePixelRatio&&(f.deviceMemory=3)),!!f.renderer.getContext().getContextAttributes().antialias),t=f.renderer.extensions,t=(_e.OES_element_index_uint=!(!f.renderer.capabilities.isWebGL2&&!t.get("OES_element_index_uint")),f.renderer.setPixelRatio(window.devicePixelRatio),f.renderer.setSize(e.width,e.height),T.bBackGroundTransparent?f.renderer.setClearColor(11912911,0):f.renderer.setClearColor(11912911,1),void 0===I.backGroundColor?16777215:I.backGroundColor),t=(T.bBackGroundTransparent?f.renderer.setClearColor(t,0):f.renderer.setClearColor(t,1),f.clearColor="0xb5c6cf",f.renderer.autoClear=!1,f.renderer.domElement),R=(t.className="canvas3DBIM",t.id="canvas3D_"+Date.now(),f.canvas3D=t,f.container.appendChild(t),I.has2DCover&&(f.canvas2D=document.createElement("canvas"),f.canvas2D.className="canvas2DBIM",f.canvas2D.id="canvas2D_"+Date.now(),f.container.appendChild(f.canvas2D),f.canvas2DLayer=document.createElement("canvas"),f.canvas2DLayer.className="canvas2DLayer",f.canvas2DLayer.id="canvas2DLayer_"+Date.now(),f.container.appendChild(f.canvas2DLayer)),f.progressBar=document.createElement("div"),f.progressBar.style.cssText="display: block; position: absolute; z-index: 2;left: 2px; bottom: 2px; height: 4px; width: 200px;background: rgba(0,0,0,1);visibility: hidden;",f.progressBarFrontground=document.createElement("div"),f.progressBarFrontground.style.cssText="height: 4px; width: 200px;background: #04d83a;",f.progressBar.appendChild(f.progressBarFrontground),f.container.appendChild(f.progressBar),f.progressBarWidth=200,f.scene=new THREE.Scene,f.scene.matrixWorldAutoUpdate=!1,f.meshLoadedUUIDs=void 0,f.modelRootObject=void 0,f.additionalObjectsScene=new THREE.Scene,void 0),O=0,U=0,M=null,i=f.scene,G=0,z=!1,i=(f.camera=new ge(e.width,e.height,f),I.cameraInfo&&f.camera.setOrginalCameraInfo({center:new THREE.Vector3(I.cameraInfo.target.x,I.cameraInfo.target.y,I.cameraInfo.target.z),up:new THREE.Vector3(I.cameraInfo.up.x,I.cameraInfo.up.y,I.cameraInfo.up.z),position:new THREE.Vector3(I.cameraInfo.position.x,I.cameraInfo.position.y,I.cameraInfo.position.z),fov:I.cameraInfo.fov,near:I.cameraInfo.near,far:I.cameraInfo.far,isPerspective:I.cameraInfo.isPerspective,width:I.cameraInfo.width,height:I.cameraInfo.height,modelScreenBBox:I.cameraInfo.modelScreenBBox}),(null!=I.projectionMode&&"Orthographic"==I.projectionMode||null!=I.cameraInfo&&0==I.cameraInfo.isPerspective)&&f.camera.toOrthographic(),f.cameraControl=new De(f),f.cameraControl.setAutoRotateSpeed(.5),g&&(r=new THREE.AmbientLight(16777215),i.add(r),g)&&(T.camera.near=.1,T.camera.far=6e3,T.camera.position.set(0,0,100),T.camera.lookAt(new THREE.Vector3(0,0,0))),.25),r=.45,W=(null!=T.convertPhongToPBR&&1==T.convertPhongToPBR&&(i=.45,r=.2,T.reflected)&&(i=1,r=1.2),void 0===I.directionLightIntensity?i:I.directionLightIntensity),Y=(void 0===I.directionLightColor||I.directionLightColor,void 0===I.hemiSphereLightIntensity?r:I.hemiSphereLightIntensity),w=(void 0===I.hemiSphereLightColor||I.hemiSphereLightColor,f.groundShadow=new Ji(f,f.renderer),f.groundShadow.enabled=!_e.isVRmodel&&!_e.isARmodel,f.backGroundScene=void 0,f.backGroundCamera=void 0,f.backGroundMesh=void 0,f.envMapCamera=void 0,f.envMapScene=void 0,f.envMapTexture=void 0,(f.envMapMaterial=void 0)!==I.hideEnvMap&&I.hideEnvMap),L=void 0!==I.enableEnvMap&&I.enableEnvMap,d=(d=void 0===I.envMapMode?"reflection":I.envMapMode).toLowerCase(),b=(void 0===I.envMapReflectionRatio||I.envMapReflectionRatio,f.envMapBlurTargetH=void 0,f.envMapBlurTargetV=void 0,f.envMapBlurPassH=void 0,(f.envMapBlurPassV=void 0)!==I.enableEnvMapBlur&&I.enableEnvMapBlur),o=void 0===I.envMapBlurVersion?2:I.envMapBlurVersion,a=2,s=void 0===I.envMapBlurLevel?0:I.envMapBlurLevel,i=(0==s&&(b=!1,s=1),k||(c=f.renderer.getPixelRatio(),f.effectRenderTarget=new THREE.WebGLRenderTarget(e.width*c,e.height*c,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),void 0===I.fxaaVersion&&(I.fxaaVersion=1),1==I.fxaaVersion?f.effectFXAA=new Re(Ge):f.effectFXAA=new Re(ze),f.effectFXAA.renderToScreen=!0),f.selectionOutlinePass=null,_e.enableOutlineEffect?f.outlinePass=new qt(f,new THREE.Vector2(e.width*c,e.height*c),f.scene,f.camera):f.isIn3DViewer()&&(f.selectionOutlinePass=new Kt(f,new THREE.Vector2(e.width*c,e.height*c),f.scene,f.camera)),new He(f)),X=(g||!1===f.bDefaultOpRotate?i.setOperator(new Yn(f)):i.setOperator(new Wn(f)),f.controls=i,f.originalMeshes=new Array,f.isolateMeshes=new Array,f.modelInfo=[],f.modelUnit=null,f.userModelUnit=null,f.draggedObjects=void 0,new THREE.Vector2(-1,-1)),x=(new THREE.Vector3(1,1.5,1),new THREE.Vector3(0,2e3,0),!0),Q=!1,Z=!1,D=void 0===I.enableGroundShadow||I.enableGroundShadow,H=0,F=!1,q=!1,K=void 0===I.enableSmoothTranslation||I.enableSmoothTranslation,J=void 0===I.enableAutoRotation||I.enableAutoRotation,e=void 0===I.clipPlaneShaderVersion?1:I.clipPlaneShaderVersion,N=(f.clipPlaneManager=new Pn(f,e,T.showSectionPlane),f.clipBoxManager=new Bn(f),null==I.modelOperationMode?"normal":I.modelOperationMode),l=(f.originalModelOperationMode=N,void 0),$=(null!=I.modelOperationVerticalRotationRange&&Array.isArray(I.modelOperationVerticalRotationRange)&&2<=I.modelOperationVerticalRotationRange.length&&(l=new THREE.Vector2).fromArray(I.modelOperationVerticalRotationRange),f.commentManager=new Cn(f),f.ndsModel=null,f.ndsModelBvhLoaded=!1,f.ndsModelPMILoaded=!1,f.ndsModelObjectTreeLoaded=!1,f.nBufferChunks=0,f.nBufferChunksLoaded=0,f.windowResize=!0,new Jt(je)),ee=($.material.blending=THREE.NoBlending,$.material.depthWrite=!1,$.material.depthTest=!1,!(f.forceClear=!0)),c=(f.composer=new Oe(T.renderer,void 0,T.renderer.colorTarget),new Le(T.scene,T.camera,T)),e=(f.composer.addPass(c),new Re(Ye)),c=(e.uniforms.resolution.value.x=T.renderer.getSize().width*T.renderer.getPixelRatio(),e.uniforms.resolution.value.y=T.renderer.getSize().height*T.renderer.getPixelRatio(),f.composer.addPass(e),new Re(We)),e=(c.uniforms.texSize.value.x=T.renderer.getSize().width*T.renderer.getPixelRatio(),c.uniforms.texSize.value.y=T.renderer.getSize().height*T.renderer.getPixelRatio(),c.uniforms.direction.value=new THREE.Vector2(1,0),c.uniforms.kernelRadius.value=.1,f.composer.addPass(c),new Re(We)),c=(e.uniforms.texSize.value.x=T.renderer.getSize().width*T.renderer.getPixelRatio(),e.uniforms.texSize.value.y=T.renderer.getSize().height*T.renderer.getPixelRatio(),e.uniforms.direction.value=new THREE.Vector2(0,1),e.uniforms.kernelRadius.value=.1,f.composer.addPass(e),new Re(Xe));function te(){var e;T.btnSelected?h(T.btnSelected.domElement.id):null!=T.prevCursor&&(null!=(e=T.renderer.domElement)&&(1==T.inWaitProcedure?e.oldCursor=T.prevCursor:e.style.cursor=T.prevCursor),null!=(e=T.canvas2D)&&(1==T.inWaitProcedure?e.oldCursor=T.prevCursor:e.style.cursor=T.prevCursor),null!=T.canvas2DLayer)&&(1==T.inWaitProcedure?T.canvas2DLayer.oldCursor=T.prevCursor:T.canvas2DLayer.style.cursor=T.prevCursor)}function ne(){T.prevCursor=T.renderer.domElement.style.cursor}function h(e){var t="",n=("coordinate"==T.getCurrentMeasureType()&&"MeasureType"!=e&&(e="coordinate"),"");if(T.serverUrl&&(n=T.serverUrl),_e.singleHTML)switch(e){case"btnOrbit":case"OpOrbit":t="url('data:image/vnd.microsoft.icon;base64,AAACAAEAGBgAAAAAAACICQAAFgAAACgAAAAYAAAAMAAAAAEAIAAAAAAAYAkAABMLAAATCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAsQAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYRERH/sbGx/wAAALEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQcHB/9/f3///////wAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAdCAgI/3p6ev///////////wAAAP8AAADWAAAAqAAAAHwAAABKAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHQAAAHQEBAT/AAAABAAAABQUFBT/hoaG/////////////////+Hh4f/W1tb/qKio/3x8fP9KSkr/EhIS/wAAAHQAAAAdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEHR0d/3R0dP9nZ2f/AAAAdgAAABQUFBT/sbGx//////////////////z8/P//////////////////////x8fH/3R0dP8dHR3/AAAARAAAAAAAAAAAAAAAAAAAADQ0NDT/ra2t///////f39//VFRU/wQEBP8BAQH/MDAw/7q6uv///////////4iIiP9mZmb/g4OD/7W1tf/t7e3///////////+tra3/NDQ0/wAAADQAAAAAAAAAAAAAAJ2dnZ3//////+Li4v+Li4v/MTEx/wAAADEAAAABAAAAUScnJ/+5ubn//////wAAAP8AAABmAAAAgwAAALU4ODj/i4uL/+Li4v//////nZ2d/wAAAJ0AAAAAAAAAAAAAAO/v7+///////2JiYv8AAACLAAAAOAAAAAEAAAAJAAAAAAAAAFAsLCz/uLi4/wAAALgAAAAAAAAAAAAAAAAAAAA4AAAAi2JiYv//////7+/v/wAAAO8AAAAAAAAAAAAAAJ2dnZ3//////+Li4v+Li4v/ODg4/wEBAf8JCQn/AAAAVwAAADMAAABPCwsL/wAAAE8AAABXAAAAgwAAALU4ODj/i4uL/+Li4v//////nZ2d/wAAAJ0AAAAAAAAAAAAAADQ0NDT/ra2t////////////7e3t/7W1tf+Dg4P/V1dX/zMzM/8YGBj/FxcX/zMzM/9XV1f/g4OD/7W1tf/t7e3///////////+tra3/NDQ0/wAAADQAAAAAAAAAAAAAAAAAAABEHR0d/3R0dP/Hx8f/////////////////////////////////////////////////////////////////x8fH/3R0dP8dHR3/AAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHQAAAHQSEhL/SkpK/3x8fP+oqKj/zMzM/+jo6P/5+fn/+fn5/+jo6P/MzMz/qKio/3x8fP9KSkr/EhIS/wAAAHQAAAAdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASAAAASgAAAHwAAACoAAAAzAAAAOgAAAD5AAAA+QAAAOgAAADMAAAAqAAAAHwAAABKAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAA9gAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD29vb2/0hISP8AAACQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////n5+f9OTk7/AAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////////////5+fn/Tk5O/wAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////+fn5/wAAAPkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWAAAA/wAAAP8AAAD/AAAA+QAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8x////O////1D/8f9y/+H/Rv/B/3P9gA9k8AADXOAAAVzAAABnwAAAIMAhwGXAAAB4wAAAXOAAAWPwAANt/AAPVP///3Qf//87D///cAf//28D//9cA///XAP//2c='), wait";break;case"btnPan":case"OpPan":t="url('data:image/vnd.microsoft.icon;base64,AAACAAEAGBgAAAAAAACICQAAFgAAACgAAAAYAAAAMAAAAAEAIAAAAAAAYAkAABMLAAATCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0NDUsNDA2zMjEy31lZWfNQUFDrKysrwwkJCZAMDAxgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPDw8ZDQ0NoVxcXfbLy8v/4ODh//b29//y8fL/3Nzc/8nJyf98e3z/FRUWuQ0NDSYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkJCT0mJSbSlpaW//7+/v//////////////////////////////////////uLe4/zc2N+MNDQ00AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUFBQFCgoJcD4+P/HMzM3//////////////////////////////////////////////////////8/Pz/8kJCTCEREREwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8PD0oTExOPcXFy//Ly8v//////8/Pz//v7+/////////////////////////////////////////////////+AgID/BAQEQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwcHLpNTU36+vr6/+fn5/99e33/Ly8v83d3eP3///////////////////////////////////////////////+bm5v/CQkJXQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABISElIbGxuaZGRk/zIyMusODg6GCQkJXVFRUvj8/Pz///////////////////////////////////////////+dnZ3/DAwMaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUFBQKBwcHPA8PDykAAAAADg4OUnBvcP7///////////////////////////////////////////////+BgYH/BAQEQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhYWqcPDw////////////////////////////////////////////+Xl5f8tLS2+Dw8PDgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEBA4Pz8/6/////+7u7z/1dXW///////4+Pj//////////////////////6Ojo/8HBwdwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABUVFQELCwuTsLCw//39/v+Dg4T/19fX/+Li4v+ZmJr//////9vb2/+6urv//////zMzM94SEhIUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwMDCc7Ozzx8fDx/8zMzf+SkZP//////5qam/+np6f//////5mYm//Hx8j/ubm5/xEREZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkJCWqSkpL//////5iXmf/P0ND/8/Pz/3h3ef/o6Oj/7e3u/3Fxc///////Tk5O+woKChwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADg4OBy0tLeri4eL/9/f3/29tcP//////qqqr/5qZmv//////mZma/8zMzf/Kysr/HR0engAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQByMjI8+mpqb/mZiZ/8LCw//6+vr/fn6A/9LS0v/8/P3/a2pu//////92dnb4BAQEOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUFBwHBweAGhoa5f/////Kysr/i4qM//////+vr7D/MC8x/3x8fP8mJiawERERCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhYWok5OTvY0NDT1Pj4++aGhof86OjvNCQkJTAgICGATExMnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAA9gAAAI0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFRUVCAoKCg8NDQ0KEBEQKxQUFH4SEhIpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD29vb2/0hISP8AAACQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////n5+f9OTk7/AAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////////////5+fn/Tk5O/wAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////+fn5/wAAAPkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWAAAA/wAAAP8AAAD/AAAA+QAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8x/+AfO/+AB1D/AANy/AABRvgAAXP4AAFk+AABXPxAAVz/wAFn/4ADIP8AA2X/AAd4/wAHXP4AD2P+AA9t/wAPVP/AH3QfwP87D///cAf//28D//9cA///XAP//2c='), wait";break;case"btnZoom":case"OpZoom":t="url('data:image/vnd.microsoft.icon;base64,AAACAAEAGBgAAAAAAACICQAAFgAAACgAAAAYAAAAMAAAAAEAIAAAAAAAYAkAABMLAAATCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANQAAAJ4AAACeAAAANQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5CQkJ/56env+enp7/CQkJ/wAAADkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8JCQn/oqKi////////////oqKi/wkJCf8AAAA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATQsLC/+oqKj//////////////////////6ioqP8LCwv/AAAATQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYDg4O/7a2tv////////////////////////////////+2trb/Dg4O/wAAAFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQMDAz/wcHB////////////////////////////////////////////wcHB/wwMDP8AAABkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYxoaGv/Nzc3//////////////////////////////////////////////////////83Nzf8aGhr/AAAAYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoKCgo/8zMzP/////////////////////////////////////////////////////////////////MzMz/KCgo/wAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7Ozs7/2lpaf9qamr/gICA/76+vv////////////////////////////////++vr7/gICA/2pqav9paWn/Ozs7/wAAADsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOwAAAGkAAABqAAAAgE5OTv////////////////////////////////9OTk7/AAAAgAAAAGoAAABpAAAAOwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQkJP////////////////////////////////8kJCT/AAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICAv/29vb///////////////////////b29v8CAgL/AAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMzMzMz//////////////////////8zMzP8AAADMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ2dnZ3//////////////////////52dnf8AAACdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhoaGj//////////////////////2hoaP8AAABoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAADs7Ozv//////////////////////zs7O/8AAAA7AAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGBgYG/wAAAGQAAAD7+/v7////////////+/v7/wAAAPsAAABkBgYG/wAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQEBA/2RkZP9RUVH/8vLy////////////8vLy/1FRUf9kZGT/QEBA/wAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNAAAA9gAAAI0AAAAAAAAAEQAAAAAAAAAmJiYm/6mpqf////////////////////////////////+pqan/JiYm/wAAACYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD29vb2/0hISP8AAACQAAAAAAAAABEAAAAAAAAAQAAAAKlZWVn/6enp////////////6enp/1lZWf8AAACpAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////n5+f9OTk7/AAAAkAAAAAAAAAADAAAAAAAAAAAAAACAJycn/729vf+9vb3/Jycn/wAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////////////5+fn/Tk5O/wAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAVAAAAL0AAAC9AAAAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////+fn5/wAAAPkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWAAAA/wAAAP8AAAD/AAAA+QAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8x////O8A8A1CAGAFyAAAARgAAAHMPAPBkDwDwXA8A8FwPAPBnAAAAIAAAAGWAAAF4gAABXMAAA2PAAANt4AAHVOAAB3QQAA87CBgPcAQ8H28D//9cA///XAP//2c='), wait";break;case"OpZoomWindow":case"OpSelectWindow":t="url('data:image/vnd.microsoft.icon;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAASlJREFUSIntkjFLA0EQhb/JBoRkoyCkFCwEm0CEU+tr/SuCYsjF2loPjP9Af4DY2ca0XoQ0AQvB/2AuiUhu1yJgcRzmFhIQzOve8HbezLyFFeZAXMSV82jXGnkF6cah5+sg8kE6WRzMRRwePC1lagAd9CxAweVR9Xigy63nvXxq6TobjMtfO2JVO482Dj3f2UBNTYy1/TzaWR5LxK8Z6CCq6SCqpesLy0AoXBrLVrr+JzMouhh8XHtvwFk+tXQAcTJYbww2jZrcWzGN0dVhXzd7bYR6FsfOMnDbYKM01vH4ZGTX3gGUJDcJhXImD+s+gOhW7wGLl+pVRRhi+fxZGMww3N92GQigmCTmNF1USt3ZZHprZndcPCrBy2OpGR0topfTN/2fBivMxTcQ8oGCNKbXHQAAAABJRU5ErkJggg==') 6 16, wait";break;case"coordinate":t="url('img/cursorCross.ico'), crosshair";break;case"OpDrawGeom":t="url('"+n+"img/drawGeom.ico') 4 4, wait";break;case"OpDrawGeomPlane":t="url('"+n+"img/drawGeomPlane.ico') 1 1, wait"}else switch(e){case"btnOrbit":case"OpOrbit":t="url('"+n+"img/cursorOrbit.ico'), wait";break;case"btnPan":case"OpPan":t="url('"+n+"img/cursorPan.ico'), wait";break;case"btnZoom":case"OpZoom":t="url('"+n+"img/cursorZoom.ico'), wait";break;case"OpZoomWindow":case"OpSelectWindow":t="url('"+n+"img/zoomWindow.ico') 6 16, wait";break;case"coordinate":t="url('"+n+"img/cursorCross.ico'), crosshair";break;case"OpDrawGeom":t="url('"+n+"img/drawGeom.ico') 4 4, wait";break;case"OpDrawGeomPlane":t="url('"+n+"img/drawGeomPlane.ico') 1 1, wait"}e=T.renderer.domElement,null!=e&&(1==T.inWaitProcedure?e.oldCursor=t:e.style.cursor=t),e=T.canvas2D;null!=e&&(1==T.inWaitProcedure?e.oldCursor=t:e.style.cursor=t),null!=T.canvas2DLayer&&(1==T.inWaitProcedure?T.canvas2DLayer.oldCursor=t:T.canvas2DLayer.style.cursor=t)}function ie(e,t){for(var n=0,i=t.length;n<i;++n)if(e==t[n].key)return 1}c.uniforms.resolution.value.x=T.renderer.getSize().width*T.renderer.getPixelRatio(),c.uniforms.resolution.value.y=T.renderer.getSize().height*T.renderer.getPixelRatio(),c.uniforms.selectColor.value=_e.selectedLineMaterial.color,c.renderToColor=!0,f.composer.addPass(c),f.getEnableSmoothTranslation=function(){return K},f.getLoadingManager=function(){return S},f.getCommentsManager=function(){return T.commentManager},Object.defineProperties(f,{bGeoBufferChunkLoaded:{get:function(){return R},set:function(e){R=e}},loadingManager:{get:function(){return S}}}),f.drawCenterCross=function(){var e,t,n,i,r;T.canvas2D&&(e=T.canvas2D.getContext("2d"),t=Math.round(T.canvas2D.width/2),n=Math.round(T.canvas2D.height/2),e.clearRect(t-15,n-15,30,30),i=e.strokeStyle,r=e.lineWidth,e.strokeStyle="#FFFFFF",e.lineWidth=1,e.beginPath(),e.moveTo(t-15,n),e.lineTo(t+15,n),e.moveTo(t,n-15),e.lineTo(t,n+15),e.stroke(),e.strokeStyle=i,e.lineWidth=r)},f.clearCenterCross=function(){var e,t,n;T.canvas2D&&(e=T.canvas2D.getContext("2d"),t=Math.round(T.canvas2D.width/2),n=Math.round(T.canvas2D.height/2),e.clearRect(t-15,n-15,30,30))},f.addPMIObject=function(e){T.pmiObject||(T.pmiObject=new THREE.Object3D,T.pmiObject.name="pmiobject",T.pmiVisible&&T.scene.add(T.pmiObject)),this.pmiObject.add(e)},f.addToScene=function(e){T.scene.add(e),e instanceof THREE.Light||g&&T.selectionManager.addToTargetList(e)},f.displayViewBox=function(e){this.viewBoxDiv?this.viewBoxDiv.style.visibility=e?"visible":"hidden":this.initViewBox()},f.initViewBox=function(){this.is2DModel||(this.viewBoxDiv=document.createElement("div"),this.viewBoxDiv.className="viewbox",this.container.appendChild(this.viewBoxDiv),this.viewBox=new Ce(this,T.viewBoxSize),this.cameraControl.setViewBox(this.viewBox))},f.render=function(e){var t=!!e&&!!e.forceRenderAll;T.broadcastManager&&(e&&null!=e.needBroadcast&&null!=e.needBroadcast?T.broadcastManager.needBroadcast=e.needBroadcast:T.broadcastManager.needBroadcast=!0),T.ndsModel?(T.forceClear=!0,ve.StartRenderTime=Date.now(),T.ndsModel.forceRenderAll=!!T.enableProgressiveRender&&t):T.renderNew()},f.setMaxandMinFrame=function(e,t){void 0===t&&(t=20),this.maxFPS=e=void 0===e?60:e,this.minFPS=t,this.maxFrameTime=1e3/t},f.isNdsModelInWireframeMode=function(e){return 2==e||6==e||7==e},f.renderNew=(_=A=v=0,y=[],E=[],function(e,t){if(void 0===e&&(e=performance.now()),void 0===t&&(t=!0),!T.loaderror)if(0===e?v=performance.now():e-v<1?(A=T.maxFPS/2,_=T.maxFPS/2):A=((_=e?1e3/(e-v):A)+A)/2,E.length<y.length&&E.push(A),A>=T.maxFPS+5)A=T.maxFPS;else{1<=e-v&&(v=e);var n=0===e?100:A/T.minFPS*T.maxFrameTime;if((_<T.minFPS||!f.enableProgressiveRender)&&(E.length=y.length=0),10<=y.length){for(var i=0,r=y.length;i<r;++i){var o=E[i]*y[i]/T.minFPS;E[i]>T.minFPS&&o>T.renderer.maxPrimitivesPerFrame&&(T.renderer.maxPrimitivesPerFrame=o)}E.length=y.length=0}e={timeStamp:e,fps:A,needsRedraw:!1};if(f.modelRequestor&&f.modelRequestor.request(),f.ndsModel&&!f.ndsModel.isEmpty()&&f.ndsModel.update(e),Te.update(e),t){if(f.enableProgressiveRender||(n=1e4),null!=m)for(var a=0,s=m.length;a<s;a++)m[a].run();Te.getExtension("NDSAnimationExtension")?T.animationRun=Te.getExtension("NDSAnimationExtension").isrunning():T.animationRun=!1,T.animationRun?T.setMaxandMinFrame(35):T.setMaxandMinFrame(60),T.additionalObjectsScene&&T.updateAdditionalObjectsScene(),T.envMapCamera&&F&&T.envMapCamera.rotation.copy(T.camera.rotation);var l=T.selectionManager.getSelectedMeshes(),e=(M&&(T.scene.remove(T.lightControls._scene),T.scene.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(ie(e,l)||(e.materialWhiteMold=e.material,e.material=M))}),T.scene.add(T.lightControls._scene)),!1);if(T.forceClear&&(e=!0),T.ndsModel||(e=!0),Q=!(x=!1),T.renderer.clear(),T.renderer.clearTarget(null,!0,!0,!1),T.preparedForRender){t=T.renderer.clippingPlanes;if(T.renderer.clippingPlanes=[],x)T.ndsModel?(T.forceClear&&(T.positionMaterial.uniforms.cameraNear.value=T.camera.near,T.positionMaterial.uniforms.cameraFar.value=T.camera.far,T.positionMaterialCopy||(T.positionMaterialCopy=(new T.positionMaterial.constructor).copy(T.positionMaterial)),T.positionMaterialCopy.uniforms.cameraNear.value=T.positionMaterial.uniforms.cameraNear.value,T.positionMaterialCopy.uniforms.cameraFar.value=T.positionMaterial.uniforms.cameraFar.value,T.ndsModel.setDirty(),T.ndsModel.setDrawMode(T.ndsModel.SHADED),T.scene.children.push(T.ndsModel),T.ndsModel.setOverrideMaterial(T.positionMaterial,T.positionMaterialCopy,!1),T.renderer.render(T.scene,T.camera,T.positionTarget,!0),T.ndsModel.setOverrideMaterial(null,null,!1),T.normalMaterialCopy||(T.normalMaterialCopy=(new T.normalMaterial.constructor).copy(T.normalMaterial)),T.ndsModel.setDirty(),T.ndsModel.setDrawMode(T.ndsModel.SHADED),T.scene.children.push(T.ndsModel),T.ndsModel.setOverrideMaterial(T.normalMaterial,T.normalMaterialCopy,!1),T.renderer.render(T.scene,T.camera,T.normalTarget,!0),T.ndsModel.setOverrideMaterial(null,null,!1),T.renderer.clearTarget(T.normalRenderTarget,!0,!0,!1),T.ndsModel.setDirty(),T.forceClear=!1),c=T.ndsModel.SHADED_WITH_EDGES,4===O?c=T.ndsModel.SHADED_WITH_EDGES:5===O?c=T.ndsModel.SHADED:2===O?c=T.ndsModel.WIREFRAME:6===O?c=T.ndsModel.HIDDEN_LINE_REMOVE:7===O?c=T.ndsModel.HIDDEN_LINE_VISIBLE:8===O&&(c=T.ndsModel.TRANSPARENT),c!==T.ndsModel.SHADED_WITH_EDGES||T.bLinesVisibility||(c=T.ndsModel.SHADED),T.ndsModel.setDrawMode(c),T.scene.children.push(T.ndsModel),T.renderer.render(T.scene,T.camera,T.normalRenderTarget,!1,!1,!1,n),d=T.renderer.info.render.triangles+T.renderer.info.render.lines,24<A&&0<n&&d>=T.renderer.maxPrimitivesPerFrame&&y.push(d)):(T.showLineObjects(T.scene,!1),T.positionMaterial.uniforms.cameraNear.value=T.camera.near,T.positionMaterial.uniforms.cameraFar.value=T.camera.far,T.scene.overrideMaterial=T.positionMaterial,T.renderer.render(T.scene,T.camera,T.positionTarget,!0),T.scene.overrideMaterial=T.normalMaterial,T.renderer.render(T.scene,T.camera,T.normalTarget,!0),T.scene.overrideMaterial=null,T.showLineObjects(T.scene,!0),T.renderer.render(T.scene,T.camera,T.normalRenderTarget,!0)),T.ssaoComposer.render();else if(T.ndsModel){if(T.forceClear&&(T.renderer.clearTarget(T.renderer.colorTarget,!0,!0,!1),T.ndsModel.setDirty()),void 0!==T.backGroundScene&&!g&&T.forceClear&&T.renderer.render(T.backGroundScene,T.backGroundCamera,T.renderer.colorTarget),T.envMapScene&&!w&&T.forceClear&&(b?(T.renderer.render(T.envMapScene,T.envMapCamera,T.envMapBlurTargetH),T.envMapBlurPassV.render(T.renderer,T.envMapBlurTargetV,T.envMapBlurTargetH),T.envMapBlurPassH.render(T.renderer,T.renderer.colorTarget,T.envMapBlurTargetV)):T.renderer.render(T.envMapScene,T.envMapCamera,T.renderer.colorTarget)),D&&T.groundShadow.needClear&&(T.groundShadow.clear(),T.groundShadow.needClear=!1),D&&!T.groundShadow.isValid()&&F&&(T.groundShadow.renderIntoShadow(T.scene),T.groundShadow.postprocess()),F||g){T.clipPlaneManager.renderClipPlane(),T.renderer.clippingPlanes=t;for(var d=0,c=T.ndsModel.SHADED_WITH_EDGES,h=(4===O?c=T.ndsModel.SHADED_WITH_EDGES:5===O?c=T.ndsModel.SHADED:2===O?c=T.ndsModel.WIREFRAME:6===O?c=T.ndsModel.HIDDEN_LINE_REMOVE:7===O?c=T.ndsModel.HIDDEN_LINE_VISIBLE:8===O&&(c=T.ndsModel.TRANSPARENT),c!==T.ndsModel.SHADED_WITH_EDGES||T.bLinesVisibility||(c=T.ndsModel.SHADED),T.ndsModel.setDrawMode(c),T.scene.children.push(T.ndsModel),T.renderer.render(T.scene,T.camera,T.renderer.colorTarget,!1,!1,!1,n),d+=T.renderer.info.render.triangles+T.renderer.info.render.lines,_e.enableOutlineEffect&&T.forceClear?f.outlinePass.render(T.renderer,null,T.renderer.colorTarget):f.selectionOutlinePass&&T.selectionManager.shouldApplySelectedMaterial&&!f.isNdsModelInWireframeMode(O)&&T.forceClear&&f.selectionOutlinePass.render(T.renderer,null,T.renderer.colorTarget),ee&&f.isNdsModelInWireframeMode(O)&&!T.is2DModel&&(T.composer.colorTarget.uuid!=T.renderer.colorTarget.uuid&&T.composer.setColorTarget(T.renderer.colorTarget),T.composer.render()),T.renderer.clippingPlanes=[],T.renderer.colorTarget&&T.forceClear&&D&&T.groundShadow.isValid()&&T.groundShadow.renderShadow(T.camera,T.renderer.colorTarget),T.forceClear&&(T.clipPlaneManager.renderClipScene(T.renderer.colorTarget),T.clipBoxManager.renderClipBox(T.renderer.colorTarget),T.selectionManager.renderSelectionScene(T.renderer.colorTarget),T.additionalObjectsScene)&&(T.renderer.render(T.additionalObjectsScene,T.camera,T.renderer.colorTarget),d+=T.renderer.info.render.triangles+T.renderer.info.render.lines),T.ndsModel.referenceEntityDirty&&0<T.ndsModel.wholeRefEntityNodes.length&&(T.scene.children.push(T.ndsModel),T.renderer.render(T.scene,T.camera,T.renderer.colorTarget,!1,!1,!0)),24<A&&0<n&&d>=T.renderer.maxPrimitivesPerFrame&&y.push(d),T.renderer.colorTarget&&(T.forceClear||F)&&$.render(T.renderer,null,T.renderer.colorTarget.texture),T.forceClear=!1,T.controls.staticDrawGeomOp&&T.controls.staticDrawGeomOp.renderGeomScene(),f.renderWaterMark(),T.controls.staticmeasureOp&&T.controls.staticmeasureOp.renderMeasureScene(),T.controls.staticAnnotation&&T.controls.staticAnnotation.renderAnnotation(),T.ndsModel.getMeshSets()),u=0,p=0,s=h.length;p<s;++p)h[p].dirty&&h[p].visible||(u+=1);z&&(c=1,0<h.length&&(c=u/h.length),2!==O&&0!==h.length||(c=1),T.dispatchEvent({type:"updateProgress",userData:{precent:c}})),T.controls.getOperator().renderModel(),T.lightControls.renderLight()}}else k?D?(void 0===T.backGroundScene||g||T.renderer.render(T.backGroundScene,T.backGroundCamera),T.envMapScene&&!w&&(b?(T.renderer.render(T.envMapScene,T.envMapCamera,T.envMapBlurTargetH),T.envMapBlurPassV.render(T.renderer,T.envMapBlurTargetV,T.envMapBlurTargetH),T.envMapBlurPassH.render(T.renderer,void 0,T.envMapBlurTargetV)):T.renderer.render(T.envMapScene,T.envMapCamera)),T.groundShadow.needClear&&(T.groundShadow.clear(),T.groundShadow.needClear=!1),!T.groundShadow.isValid()&&F&&(T.groundShadow.renderIntoShadow(T.scene),T.groundShadow.postprocess()),(F||g)&&(T.clipPlaneManager.renderClipPlane(),T.renderer.clippingPlanes=t,7==O?T.renderHiddenLinesVisible():T.renderer.render(T.scene,T.camera),T.renderer.clippingPlanes=[],T.additionalObjectsScene&&T.renderer.render(T.additionalObjectsScene,T.camera),T.selectionManager.renderSelectionScene(),_e.enableOutlineEffect&&f.outlinePass.render(T.renderer),T.clipPlaneManager.renderClipScene(),T.clipBoxManager.renderClipBox(),T.groundShadow.isValid()&&T.groundShadow.renderShadow(T.camera),T.controls.staticmeasureOp&&T.controls.staticmeasureOp.renderMeasureScene(),T.controls.staticAnnotation&&T.controls.staticAnnotation.renderAnnotation(),T.controls.getOperator().renderModel())):(void 0===T.backGroundScene||g||T.renderer.render(T.backGroundScene,T.backGroundCamera),T.envMapScene&&!w&&(b?(T.renderer.render(T.envMapScene,T.envMapCamera,T.envMapBlurTargetH),T.envMapBlurPassV.render(T.renderer,T.envMapBlurTargetV,T.envMapBlurTargetH),T.envMapBlurPassH.render(T.renderer,void 0,T.envMapBlurTargetV)):T.renderer.render(T.envMapScene,T.envMapCamera)),(F||g)&&(T.clipPlaneManager.renderClipPlane(),T.renderer.clippingPlanes=t,7==O?T.renderHiddenLinesVisible():T.renderer.render(T.scene,T.camera),T.renderer.clippingPlanes=[],T.additionalObjectsScene&&T.renderer.render(T.additionalObjectsScene,T.camera),T.selectionManager.renderSelectionScene(),_e.enableOutlineEffect&&f.outlinePass.render(T.renderer),T.clipPlaneManager.renderClipScene(),T.clipBoxManager.renderClipBox(),T.controls.staticmeasureOp&&T.controls.staticmeasureOp.renderMeasureScene(),T.controls.staticAnnotation&&T.controls.staticAnnotation.renderAnnotation(),T.controls.getOperator().renderModel())):(D?(T.groundShadow.needClear&&(T.groundShadow.clear(),T.groundShadow.needClear=!1),!T.groundShadow.isValid()&&F&&(T.groundShadow.renderIntoShadow(T.scene),T.groundShadow.postprocess()),void 0!==T.envMapScene&&!w||void 0!==T.backGroundScene?(void 0===T.backGroundScene||g||T.renderer.render(T.backGroundScene,T.backGroundCamera,T.effectRenderTarget,!0),T.envMapScene&&!w&&(b?(T.renderer.render(T.envMapScene,T.envMapCamera,T.envMapBlurTargetH),T.envMapBlurPassV.render(T.renderer,T.envMapBlurTargetV,T.envMapBlurTargetH),T.envMapBlurPassH.clear=!0,T.envMapBlurPassH.render(T.renderer,T.effectRenderTarget,T.envMapBlurTargetV)):T.renderer.render(T.envMapScene,T.envMapCamera,T.effectRenderTarget,!0)),(F||g)&&(T.clipPlaneManager.renderClipPlane(T.effectRenderTarget,!1),T.renderer.clippingPlanes=t,T.renderer.render(T.scene,T.camera,T.effectRenderTarget,!1),T.renderer.clippingPlanes=[],T.additionalObjectsScene&&T.renderer.render(T.additionalObjectsScene,T.camera,T.effectRenderTarget,!1),T.selectionManager.renderSelectionScene(T.effectRenderTarget,!1),T.clipPlaneManager.renderClipScene(T.effectRenderTarget,!1),T.clipBoxManager.renderClipBox(f.effectRenderTarget,!1),T.controls.staticmeasureOp)&&T.controls.staticmeasureOp.renderMeasureScene(T.effectRenderTarget,!1)):(F||g)&&(T.clipPlaneManager.renderClipPlane(T.effectRenderTarget,!0),T.renderer.clippingPlanes=t,T.renderer.render(T.scene,T.camera,T.effectRenderTarget,T.clipPlaneManager.hasClipCapScene()),T.renderer.clippingPlanes=[],T.additionalObjectsScene&&T.renderer.render(T.additionalObjectsScene,T.camera,T.effectRenderTarget,!1),T.selectionManager.renderSelectionScene(T.effectRenderTarget,!1),T.clipPlaneManager.renderClipScene(T.effectRenderTarget,!1),T.clipBoxManager.renderClipBox(T.effectRenderTarget,!1),T.controls.staticmeasureOp)&&T.controls.staticmeasureOp.renderMeasureScene(T.effectRenderTarget,!1),T.groundShadow.isValid()&&F&&T.groundShadow.renderShadow(T.camera,T.effectRenderTarget)):void 0!==T.envMapScene&&!w||void 0!==T.backGroundScene?(void 0===T.backGroundScene||g||T.renderer.render(T.backGroundScene,T.backGroundCamera,T.effectRenderTarget,!0),T.envMapScene&&!w&&(b?(T.renderer.render(T.envMapScene,T.envMapCamera,T.envMapBlurTargetH),T.envMapBlurPassV.render(T.renderer,T.envMapBlurTargetV,T.envMapBlurTargetH),T.envMapBlurPassH.clear=!0,T.envMapBlurPassH.render(T.renderer,T.effectRenderTarget,T.envMapBlurTargetV)):T.renderer.render(T.envMapScene,T.envMapCamera,T.effectRenderTarget,!0)),(F||g)&&(T.clipPlaneManager.renderClipPlane(T.effectRenderTarget,!1),T.renderer.clippingPlanes=t,T.renderer.render(T.scene,T.camera,T.effectRenderTarget,!1),T.renderer.clippingPlanes=[],T.additionalObjectsScene&&T.renderer.render(T.additionalObjectsScene,T.camera,T.effectRenderTarget,!1),T.selectionManager.renderSelectionScene(T.effectRenderTarget,!1),T.clipPlaneManager.renderClipScene(T.effectRenderTarget,!1),T.clipBoxManager.renderClipBox(T.effectRenderTarget,!1),T.controls.staticmeasureOp)&&T.controls.staticmeasureOp.renderMeasureScene(T.effectRenderTarget,!1)):(F||g)&&(T.clipPlaneManager.renderClipPlane(T.effectRenderTarget,!0),T.renderer.clippingPlanes=t,T.renderer.render(T.scene,T.camera,T.effectRenderTarget,T.clipPlaneManager.hasClipCapScene()),T.renderer.clippingPlanes=[],T.additionalObjectsScene&&T.renderer.render(T.additionalObjectsScene,T.camera,T.effectRenderTarget,!1),T.selectionManager.renderSelectionScene(T.effectRenderTarget,!1),T.clipPlaneManager.renderClipScene(T.effectRenderTarget,!1),T.clipBoxManager.renderClipBox(T.effectRenderTarget,!1),T.controls.staticmeasureOp)&&T.controls.staticmeasureOp.renderMeasureScene(T.effectRenderTarget,!1),T.effectFXAA.render(T.renderer,void 0,T.effectRenderTarget));T.annotationsManager&&(n=!1,T.animationsManager&&T.annotationsManager.hasAnnotationsForAnimation(T.animationsManager.getCurrentAnimationUuid())&&(n=!0,T.annotationsManager.updateAnnotationsVisiblilityForAnimation(T.animationsManager.getCurrentAnimationUuid(),T.animationsManager.getCurrentAnimationTime())),null==T.animationsManager||T.animationsManager&&T.animationsManager.isAnimationsExited()||n)&&e&&T.annotationsManager.renderAnnotations(),e&&"FirstPerson"==N&&"OpOrbit"==T.controls.getOperator().type&&T.drawCenterCross(),M&&(T.scene.remove(T.lightControls._scene),T.scene.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(ie(e,l)||(e.material=e.materialWhiteMold,e.materialWhiteMold=void 0))}),T.scene.add(T.lightControls._scene)),T.renderer.clippingPlanes=t,_e.enableBroadcast&&_e.broadcastMajor&&e&&T.broadcastManager.needBroadcast&&T.ndsModel&&30<(d=Date.now())-G&&(G=d,T.dispatchEvent({type:"broadcastEvent"})),null!=T.commentManager&&T.commentManager.renderComments(),f.logOperatorTime&&f.logOperatorTimeShow(null,null,!0),T.findTextIconUpdate()}}}}),f.prepareModelForRendering=function(){T.ndsModel.fuseData(),T.preparedForRender||(T.preparedForRender=!0,T.is2DModel&&(T.renderMode="shadedWithEdges"),T.setRenderMode(T.renderMode,!1))},f.preLoadAnimationFile=function(e,t,n){var i;T.animationFile?Te.getExtension("NDSAnimationExtension")&&((i=Te.getExtension("NDSAnimationExtension")).relativePath=e,i.animationFileData=t,i.animationMorphAttri=n,T.AnimationExtension=i):(Te.getExtension("NDSAnimationExtension")&&(e=Te.getExtension("NDSAnimationExtension"))&&(e.animationFileData=null,e.animationMorphAttri=null,e.relativePath=null),T.dispatchAsyncEvent({type:"NoAnimationLoaded"}))},f.loadAnimationFile=function(e,t){T.AnimationExtension.load(T),t&&0<t.length&&T.AnimationExtension.addMorphAnimation(e,t);for(var n=0;n<e.animations.length;++n){var i=e.animations[n];setTimeout(function(){T.AnimationExtension.addAnimation(i,e)},0)}T.AnimationExtension.animationData={isInit:!0,data:e},T.dispatchAsyncEvent({type:"AnimationLoaded"}),T.animationFile=void 0},f.getExtension=function(e){return Te.getExtension(e)},f.setGridHelperVisible=function(e){var t=T.scene.getObjectByName("GridHelper");t&&(t.visible=e),T.render()},f.getGridHelperVisible=function(){var e=T.scene.getObjectByName("GridHelper");if(e)return e.visible},f.getBackgroundstate=function(){var e={};return T.envmapUrls?(e.backgroundtype="envmap",e.index=T.envmapUrlsindex):T.backGroundImage?(e.backgroundtype="Image",e.index=T.backGroundImageindex):(e.backgroundtype="Color",e.clearColor=T.clearColor),e},f.BloadreleaseModel=function(){return!!T.loadrelease},f.onResize=function(e){T.windowResize&&setTimeout(function(){T.dispatchEvent({type:"windowResize"})},300)},f.enableWindowResize=function(e){T.windowResize=e},f.onWindowResize=function(e,t,n){T.viewBox&&T.viewBox.refreshCube();var i=T.container.getBoundingClientRect(),r=i.width,i=i.height,t=(null!=T.container.clientWidth&&null!=T.container.clientHeight&&(10<Math.abs(r-T.container.clientWidth)&&(r=T.container.clientWidth),10<Math.abs(i-T.container.clientHeight))&&(i=T.container.clientHeight),T.renderer.setSize(r=null!=t?t:r,i=null!=n?n:i),p&&T.tlbOperator.onResize(r,i),T.renderer.getPixelRatio());r*=t,i*=t,T.canvas2D&&(T.canvas2D.width=r,T.canvas2D.height=i,T.canvas2D.style.width=r/t+"px",T.canvas2D.style.height=i/t+"px"),T.canvas2DLayer&&(T.canvas2DLayer.width=r,T.canvas2DLayer.height=i,T.canvas2DLayer.style.width=r/t+"px",T.canvas2DLayer.style.height=i/t+"px"),T.annotationsManager&&T.annotationsManager.setSize(r,i),T.cameraControl.setCameraSize(r,i),T.envMapCamera&&(T.envMapCamera.aspect=r/i,T.envMapCamera.updateProjectionMatrix()),b&&T.envMapBlurTargetH&&(n=.5*r,t=.5*i,T.envMapBlurTargetH.dispose(),T.envMapBlurTargetH=new THREE.WebGLRenderTarget(n,t,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat,stencilBuffer:!1}),T.envMapBlurTargetH.texture.generateMipmaps=!1,T.envMapBlurTargetV&&T.envMapBlurTargetV.dispose(),T.envMapBlurTargetV=new THREE.WebGLRenderTarget(n,t,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat,stencilBuffer:!1}),T.envMapBlurTargetV.texture.generateMipmaps=!1,1==o||2==o||3<o)&&(T.envMapBlurPassH&&(T.envMapBlurPassH.material.defines.RESOLUTION=(a/n).toFixed(4),T.envMapBlurPassH.material.needsUpdate=!0),T.envMapBlurPassV)&&(T.envMapBlurPassV.material.defines.RESOLUTION=(a/t).toFixed(4),T.envMapBlurPassV.material.needsUpdate=!0),T.backGroundMesh&&T.backGroundMesh.material&&T.updateBackGroudImageRatio(T.backGroundMesh.material),T.ssaoComposer&&(T.renderTarget&&T.renderTarget.dispose(),T.renderTarget=new THREE.WebGLRenderTarget(r,i,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),T.ssaoComposer.reset(T.renderTarget),T.fxaaPass.uniforms.resolution.value.set(1/r,1/i),T.positionTarget&&T.positionTarget.dispose(),T.positionTarget=new THREE.WebGLRenderTarget(r,i,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType}),T.ssaoPass.uniforms.tPosition.value=T.positionTarget,T.normalTarget&&T.normalTarget.dispose(),T.normalTarget=new THREE.WebGLRenderTarget(r,i,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType}),T.ssaoPass.uniforms.tNormal.value=T.normalTarget,n=Math.sqrt(r*r+i*i),T.ssaoPass.uniforms.fRadiusNear.value=Math.max(.01*n,2),T.ssaoPass.uniforms.fRadiusFar.value=Math.max(.01*n,2),T.normalRenderTarget&&T.normalRenderTarget.dispose(),T.normalRenderTarget=new THREE.WebGLRenderTarget(r,i,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),T.ssaoFilterPass.uniforms.tSSAOMap.value=T.renderTarget,T.ssaoFilterPass.uniforms.tDiffuseOrginal.value=T.normalRenderTarget,T.ssaoFilterPass.uniforms.vSize.value.set(r,i)),k||(T.effectRenderTarget&&T.effectRenderTarget.dispose(),T.effectRenderTarget=new THREE.WebGLRenderTarget(r,i,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),T.effectFXAA.uniforms.resolution.value.set(1/r,1/i)),this.outlinePass?this.outlinePass.setSize(r,i):this.selectionOutlinePass&&this.selectionOutlinePass.setSize(r,i),T.render(),T.ndsModel&&T.renderNew()},f.onMouseDown=function(e){_e.enableBroadcast&&!_e.broadcastMajor||(X.set(e.clientX,e.clientY),_e.enableSelect&&T.enableInternalRMB&&T.showViewMenu(!1),x&&(Z=!(x=!1)),ee&&4!==O&&5!==O&&8!==O&&(Z=!(ee=!1)),Q=!1,T.toggleAutoRotation(!1))},f.onMouseUp=function(e){_e.enableBroadcast&&!_e.broadcastMajor||(2===e.button&&(e=new THREE.Vector2(e.clientX,e.clientY)).equals(X)&&0<T.modelInfo.length&&"js"===T.modelInfo[0].type&&_e.enableSelect&&T.enableInternalRMB&&T.showViewMenu(!0,e.x,e.y),ee=!(x=!0),Q&&Z&&(T.render(),Z=!1))},f.showModelBroserMenu=function(e,t,n){e?(T.menuView.getChildElement("itemIsolate").setDisplay(!0),T.menuView.getChildElement("itemHide").setDisplay(!0),T.menuView.getChildElement("itemShowAll").setDisplay(!0),T.menuView.getChildElement("itemProperty").setDisplay(!0),T.menuView.setPos(t,n),T.menuView.setVisibility(!0)):T.menuView.setVisibility(!1)},f.showprompt=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0),this.promptshow=e,this.promptstring=t,!this.prompt&&this.promptshow&&(this.prompt=document.createElement("div"),this.prompt.className="pc-alert",this.container.appendChild(this.prompt)),this.prompt&&!this.promptshow&&(this.container.removeChild(this.prompt),this.prompt=null),this.prompt&&(this.prompt.clientoffsetX=n,this.prompt.clientoffsetY=i)},f.getSelectedBodyVolumeAndArea=function(){var e,t=T.selectionManager.getSelectedBodyVolumeAndArea();return t?((e=t[0]).modelUnit=t[1],e):null},f.showViewMenu=function(e,t,n){e?(0<(e=T.selectionManager.getSelectedObjects()).length?(T.menuView.getChildElement("itemIsolate").setDisplay(!0),T.menuView.getChildElement("itemHide").setDisplay(!0),T.menuView.getChildElement("itemShowAll").setDisplay(!0),1==e.length?T.menuView.getChildElement("itemProperty").setDisplay(!0):T.menuView.getChildElement("itemProperty").setDisplay(!1)):(T.menuView.getChildElement("itemIsolate").setDisplay(!1),T.menuView.getChildElement("itemHide").setDisplay(!1),T.menuView.getChildElement("itemShowAll").setDisplay(!0),T.menuView.getChildElement("itemProperty").setDisplay(!1)),T.menuView.setPos(t,n),T.menuView.setVisibility(!0)):T.menuView.setVisibility(!1)},f.showSvgMenu=function(e,t,n){e?(T.menuView.getChildElement("itemIsolate").setDisplay(!1),T.menuView.getChildElement("itemSelectObject").setDisplay(!1),T.menuView.setPos(t,n),T.menuView.setVisibility(!0)):T.menuView.setVisibility(!1)},f.onControlsEvent=function(e){if(!(T.controls instanceof Fe)){var t,n,i,r,e=e.event;if("select"==e.subType)t=e.uuid,n=e.userData,i=e.linkID,r=e.linkInstanceID,T.dispatchEvent({type:"selectEvent",uuid:t,userData:n,linkID:i,linkInstanceID:r});else{var o,a=e.event;switch(a.type){case"mousedown":var s=a.button;switch(ne(),s){case 1:case 2:h("btnPan")}break;case"mouseup":te();break;case"mousewheel":0==a.buttons&&(clearTimeout(o),0==T.inWheel&&(T.inWheel=!0,ne()),h("btnZoom"),o=setTimeout(function(){te(),T.inWheel=!1},200))}}}},f.startWaitProcedure=function(){T.inWaitProcedure=!0,T.restoreToolbarCursor(),T.setToolbarCursor("wait")},f.onChangeCursor=function(e){h(e)},f.exitWaitProcedure=function(){T.inWaitProcedure=!1,T.backToolbarCursor()},f.restoreToolbarCursor=function(){if(T.tlbOperator){T.tlbOperator.oldCursor=T.tlbOperator.domElement.style.cursor;for(var e=0;e<T.tlbOperator.childElements.length;e++){var t=T.tlbOperator.childElements[e];t.value.oldCursor=t.value.domElement.style.cursor}}var n=T.renderer.domElement,n=(null!=n&&(n.oldCursor=n.style.cursor),T.canvas2D);null!=n&&(n.oldCursor=n.style.cursor),null!=T.canvas2DLayer&&(T.canvas2DLayer.oldCursor=T.canvas2DLayer.style.cursor)},f.setToolbarCursor=function(e){if(T.tlbOperator){T.tlbOperator.setCursor(e);for(var t=0;t<T.tlbOperator.childElements.length;t++)T.tlbOperator.childElements[t].value.setCursor(e)}var n=T.renderer.domElement,n=(null!=n&&(n.style.cursor=e),T.canvas2D);null!=n&&(n.style.cursor=e),null!=T.canvas2DLayer&&(T.canvas2DLayer.style.cursor=e)},f.backToolbarCursor=function(){if(T.tlbOperator){T.tlbOperator.setCursor(T.tlbOperator.oldCursor);for(var e=0;e<T.tlbOperator.childElements.length;e++){var t=T.tlbOperator.childElements[e];t.value.setCursor(t.value.oldCursor)}}var n=T.renderer.domElement,n=(null!=n&&(n.style.cursor=n.oldCursor),T.canvas2D);null!=n&&(n.style.cursor=n.oldCursor),null!=T.canvas2DLayer&&(T.canvas2DLayer.style.cursor=T.canvas2DLayer.oldCursor)},f.onOpChanged=function(e){var t,n=null!=e?e.target:null;null!=n?(null!=(t=T.btnSelected)&&(t.setBorder(""),t.setBgColor("")),n.setBorder("1px solid rgba(150,150,150,0.8)"),n.setBgColor(_e.toolbarButtonClickedBkgColor),h((T.btnSelected=n).domElement.id)):null!=e&&null!=e.id&&h(e.id),T.Optoolbar&&T.Optoolbar.onOpChanged(e)},f.onShowTooltip=function(e){var t=e.event.type,n=e.target.subElements.tooltip;switch(t){case"mouseenter":n.setVisibility(!0);break;case"mouseleave":n.setVisibility(!1)}},f.computeMeshesBoundingBox=function(e,t,n,i){for(var r=0,o=e.length;r<o;++r)T.computeBoundingBox(e[r].key,t,n,i)},f.computeVisibleBoundingBox=function(e,t,n,i,r,o){var a;if(null!=e)if(this.ndsModel)e===this.scene?(this.ndsModel instanceof NDSWebViewer.NdsModelSet&&null==r&&!(a=this.ndsModel.getTotalVisibleBoundingBox(o)).isEmpty()||(a=this.modelRootObject.boundingBox.clone()),this.modelRootObject.boundingBox.copy(a),_e.inBIMContext&&0<this.ndsModel.ModelUpMatrix4.length&&((r=new THREE.Matrix4).fromArray(this.ndsModel.ModelUpMatrix4),a.applyMatrix4(r)),this.is2DModel&&(a.max.z=a.min.z)):a=this.ndsModel.getVisibleBodyBoundingBox(e,o),a&&(t.copy(a.min),n.copy(a.max));else if(e instanceof THREE.Object3D&&(!o||e.visible)&&!(e instanceof THREE.Light||"lightctrls"==e.name)&&(e.hasOwnProperty("geometry")&&(r=!1,(a=e.geometry)instanceof THREE.Geometry?r=null!=a.vertices&&0!=a.vertices.count:a instanceof THREE.BufferGeometry&&(r=null!=e.geometry.attributes.position),r||a.boundingBox)&&(null==a.boundingBox&&a.computeBoundingBox(),isFinite(a.boundingBox.min.x))&&((o=new THREE.Vector3).copy(a.boundingBox.min),(r=new THREE.Vector3).copy(a.boundingBox.max),(a=new THREE.Box3(o,r)).applyMatrix4(e.matrixWorld),1==i.flag?(t.copy(a.min),n.copy(a.max),i.flag=!1):(t.x=Math.min(t.x,a.min.x),t.y=Math.min(t.y,a.min.y),t.z=Math.min(t.z,a.min.z),n.x=Math.max(n.x,a.max.x),n.y=Math.max(n.y,a.max.y),n.z=Math.max(n.z,a.max.z))),null!=e.children))for(var s=0,l=e.children.length;s<l;++s)T.computeBoundingBox(e.children[s],t,n,i)},f.computeBoundingBox=function(e,t,n,i){var r,o,a;if(null!=e)if(this.ndsModel)e===this.scene?(!T.is2DModel&&this.ndsModel instanceof NDSWebViewer.NdsModelSet&&!(a=this.ndsModel.getTotalBodyBoundingBox()).isEmpty()||(a=this.modelRootObject.boundingBox.clone()),this.modelRootObject.boundingBox.copy(a),_e.inBIMContext&&0<this.ndsModel.ModelUpMatrix4.length&&((r=new THREE.Matrix4).fromArray(this.ndsModel.ModelUpMatrix4),a.applyMatrix4(r)),this.is2DModel&&(a.max.z=a.min.z)):a=this.ndsModel.getBodyBoundingBox(e),a&&(t.copy(a.min),n.copy(a.max));else if(e instanceof THREE.Object3D&&!(e instanceof THREE.Light||"lightctrls"==e.name)&&(e.hasOwnProperty("geometry")&&(r=!1,(a=e.geometry)instanceof THREE.Geometry?r=null!=a.vertices&&0!=a.vertices.count:a instanceof THREE.BufferGeometry&&(r=null!=e.geometry.attributes.position),r||a.boundingBox)&&(null==a.boundingBox&&a.computeBoundingBox(),isFinite(a.boundingBox.min.x))&&((r=new THREE.Vector3).copy(a.boundingBox.min),(o=new THREE.Vector3).copy(a.boundingBox.max),(a=new THREE.Box3(r,o)).applyMatrix4(e.matrixWorld),1==i.flag?(t.copy(a.min),n.copy(a.max),i.flag=!1):(t.x=Math.min(t.x,a.min.x),t.y=Math.min(t.y,a.min.y),t.z=Math.min(t.z,a.min.z),n.x=Math.max(n.x,a.max.x),n.y=Math.max(n.y,a.max.y),n.z=Math.max(n.z,a.max.z))),null!=e.children))for(var s=0,l=e.children.length;s<l;++s)T.computeBoundingBox(e.children[s],t,n,i)},f.calculatePMIBoundingBox=function(){var r;return this.pmiObject?this.pmiObject.box3||(r=new THREE.Box3,this.pmiObject.children[0].traverse(function(e){var t,n,i;e.hasOwnProperty("geometry")&&(t=!1,(i=e.geometry)instanceof THREE.Geometry?t=null!=i.vertices&&0!=i.vertices.count:i instanceof THREE.BufferGeometry&&(t=null!=e.geometry.attributes.position),t||i.boundingBox)&&(null==i.boundingBox&&i.computeBoundingBox(),isFinite(i.boundingBox.min.x))&&((t=new THREE.Vector3).copy(i.boundingBox.min),(n=new THREE.Vector3).copy(i.boundingBox.max),(i=new THREE.Box3(t,n)).applyMatrix4(e.matrixWorld),r.expandByPoint(i.min),r.expandByPoint(i.max))}),isFinite(r.min.x)?this.pmiObject.box3=r:null):null},f.switchRotateCenterBySelection=function(e){void 0===e&&(e=!1);var t=T.selectionManager.getSelectedObjects();if(0<t.length&&e){for(var n=new THREE.Box3,i=0;i<t.length;++i){var r=t[i],r=T.ndsModel.getBodyBoundingBox(r);r&&(n.expandByPoint(r.max),n.expandByPoint(r.min))}e=n.getCenter();T.cameraControl.setRotateCenter(e)}else{T.emptyCenter.set(0,0,0);e=T.controls.getBoundingBox().getCenter(T.emptyCenter);T.cameraControl.setRotateCenter(e)}e=T.controls.getOperator();e&&e.updateRotateCenterHelper()},f.zoomExtents=function(e,t,n){this.cameraControl.zoomExtents(e,t,n)},f.zoomToObject=function(e,t){this.cameraControl.zoomToObject(e,t)},f.setCameraFromEulerDis=function(e,t){if(e){if(Math.abs(T.ScenarioEditorInfo.EulerAngle.x-THREE.Math.degToRad(e.x))<.01&&Math.abs(T.ScenarioEditorInfo.EulerAngle.y-THREE.Math.degToRad(e.y))<.01&&Math.abs(T.ScenarioEditorInfo.EulerAngle.z-THREE.Math.degToRad(e.z))<.01)return;var n=T.camera.position.clone().sub(T.cameraControl.center()).length(),i={smoothTranslation:!1,useOrginal:!0},i=(T.defaultStandardView="",i.type="",T.look(i),this.getCameraInfo()),r=new THREE.Euler(THREE.Math.degToRad(e.x),THREE.Math.degToRad(e.y),0),o=new THREE.Euler(0,0,THREE.Math.degToRad(e.z)),a={smoothTranslation:!1},s=new THREE.Vector3(0,0,1),s=(s.applyEuler(r).applyEuler(o).normalize(),a.from=s.toArray(),new THREE.Vector3(0,1,0)),r=(s.applyEuler(r).applyEuler(o).normalize(),a.up=s.toArray(),T.resetCamera(a),T.getCameraInfo()),o=new THREE.Vector3(r.target.x,r.target.y,r.target.z),s=new THREE.Vector3(r.position.x,r.position.y,r.position.z).sub(o).normalize().multiplyScalar(n);T.camera.position.copy(s.add(o)),(a=T.cameraControl.calFarthestDistToCamera())>T.camera.far&&(T.camera.far=a),T.viewBox&&T.cameraControl.updateViewBoxCamDir(),T.camera.updateProjectionMatrix(),T.camera.updateMatrixWorld(!0),T.ScenarioEditorInfo.EulerAngle.set(THREE.Math.degToRad(e.x),THREE.Math.degToRad(e.y),THREE.Math.degToRad(e.z))}t&&(i=T.camera.getOrginalCameraInfo(),n=new THREE.Vector3(i.position.x-i.center.x,i.position.y-i.center.y,i.position.z-i.center.z).length(),r=T.getCameraInfo(),o=new THREE.Vector3(r.target.x,r.target.y,r.target.z),s=new THREE.Vector3(r.position.x,r.position.y,r.position.z).sub(o).normalize().multiplyScalar(n/20*t),T.camera.position.copy(s.add(o)),(a=T.cameraControl.calFarthestDistToCamera())>T.camera.far&&(T.camera.far=a),T.camera.updateProjectionMatrix(),T.camera.updateMatrixWorld(!0)),T.groundShadowChange(),T.render()},f.getDwgScale=function(){return this.dwgScale},f.getScreenCapture=function(e,t,n){return this.getScreenCapture2(e,!1,!1,t,n),"111"},f.getScreenCapture2=function(a,s,e,l,d,t,c){function h(e,t,n,i){t&&t(e),n&&T.dispatchEvent({type:"snapEvent",cameraInfo:T.getCameraInfo(),imgData:e}),i&&(t="<div align='center'><img src='"+e+"'></img></div>",(n=window.open()).document.open(),n.document.write(t),n.document.close())}void 0===c&&(c=!1);var u,p=!0===t,f=e&&T.watermark&&T.excalibur,m=(T.lightControls.getVisible()&&(u=!0),null!=d&&d||u&&T.lightControls.setVisible(!1),!1),g=!1,v=!1,A=!1,y=!1,E=!1;function M(e){var t,n,i,r,e=e.userData.precent,o=T.ndsModel.getLineSegmentsSet();e<.99||4===O&&o.dirty||(t=document.createElement("canvas"),n=t.getContext("2d"),e=T.renderer.domElement.toDataURL(),i=T.canvas2D.toDataURL(),t.width=T.renderer.domElement.width,t.height=T.renderer.domElement.height,n.fillStyle=T.container.style.backgroundColor,n.fillRect(0,0,t.width,t.height),(r=new Image).onload=function(){var e;n.globalAlpha=1,n.drawImage(r,0,0),f||p?((e=new Image).onload=function(){c||n.drawImage(e,0,0),h(t.toDataURL(),a,s,l)},e.src=i):h(t.toDataURL(),a,s,l)},r.src=e,T.removeEventListener("updateProgress",M),T.isSectionViewEnabled()&&(m&&T.clipPlaneManager.hideShowClipPlane(!0),g)&&T.clipPlaneManager.onOpenClipControl(),v&&T.isSectionBoxViewEnabled()&&T.clipBoxManager.displaySectionBox(!0),A&&T.controls.staticmeasureOp&&T.controls.staticmeasureOp.setMeasureVisible(!0),E&&T.controls.staticAnnotation&&(T.controls.staticAnnotation.rootObject.visible=!0),y&&T.ndsModel.explodeObject&&T.explodeAxis&&this.setExplodeAxisVisible(!0,T.explodeAxis),null!=d&&d||u&&T.lightControls.setVisible(!0),T.render())}!c&&this.isSectionViewEnabled()&&(this.clipPlaneManager.getClipPlaneVisible()&&(this.clipPlaneManager.hideShowClipPlane(!1),m=!0),this.clipPlaneManager.getClipControlVisible())&&(this.clipPlaneManager.onCloseClipControl(),g=!0),!c&&this.isSectionBoxViewEnabled()&&this.clipBoxManager.getSectionBoxVisible()&&(this.clipBoxManager.displaySectionBox(!1),v=!0),!c&&T.controls.staticmeasureOp&&!p&&T.controls.staticmeasureOp.getMeasureVisible()&&(T.controls.staticmeasureOp.setMeasureVisible(!1),A=!0),!c&&T.controls.staticAnnotation&&(T.controls.staticAnnotation.rootObject.visible=!1,E=!0),!c&&this.ndsModel.explodeObject&&this.ndsModel.explodeObject.visible&&this.explodeAxis&&this.ndsModel.explodeObject.getAxisVisible(this.explodeAxis)&&(this.setExplodeAxisVisible(!1),y=!0),T.render(),T.addEventListener("updateProgress",M,!1)},f.getImagePortion=function(e,t,n,i,r,o){var a=document.createElement("canvas"),s=a.getContext("2d"),l=(a.width=t,a.height=n,document.createElement("canvas")),d=l.getContext("2d");return l.width=e.width,l.height=e.height,d.drawImage(e,0,0),s.drawImage(l,i,r,t*o,n*o,0,0,t,n),a.toDataURL()},f.getScreenCapturethumbnailByData=function(a,e){var s,l=1280,d=768,c=(e&&(l=e.width||l,d=e.height||d,s=e.backgroundColor,t=e.opacity,f=e.cameraPosition,m=e.cameraTarget),this.getBackgroundstate()),h=(c.alpha=this.renderer.getClearAlpha(),c.alpha),e=(void 0!==s&&s&&("envmap"==c.backgroundtype?(c.envmapUrls=this.envmapUrls,c.envmapUrlsindex=this.envmapUrlsindex,c.envMapCamera=this.envMapCamera,c.envMapScene=this.envMapScene,this.envMapTexture&&(c.envMapTexture=this.envMapTexture.clone()),this.envMapMaterial&&(c.envMapMaterial=this.envMapMaterial.clone()),c.exchangeBackImage=this.exchangeBackImage):"Image"==c.backgroundtype&&(c.backGroundScene=this.backGroundScene,c.backGroundCamera=this.backGroundCamera,c.backGroundMesh=this.backGroundMesh,this.backGroundMesh)&&this.backGroundMesh.material&&this.backGroundMesh.material.map&&(c.backGroundMesh.material.map=this.backGroundMesh.material.map.clone()),(e=new THREE.Color).set(s),this.setBackGroundColor(e.getHex())),void 0!==t&&(h=t,this.bBackGroundTransparent?this.renderer.setClearAlpha(0):this.renderer.setClearAlpha(t)),this.onWindowResize(null,2*l,2*d),new THREE.Vector3),t=new THREE.Vector3,n={flag:!0},i=(this.is2DModel?(p=this.modelRootObject.boundingBox.clone(),this.computeVisibleBoundingBox(this.scene,e,t,n,void 0,!0),i=p.max.x-p.min.x,o=p.max.y-p.min.y,r=this.modelRootObject.boundingBox.max.x-this.modelRootObject.boundingBox.min.x,u=this.modelRootObject.boundingBox.max.y-this.modelRootObject.boundingBox.min.y,(i<r||o<u)&&this.modelRootObject.boundingBox.copy(p)):this.computeVisibleBoundingBox(this.scene,e,t,n,void 0,!0),e=this.modelRootObject.boundingBox.min,t=this.modelRootObject.boundingBox.max,new THREE.Vector3),r=(i.x=.5*(t.x+e.x),i.y=.5*(t.y+e.y),i.z=.5*(t.z+e.z),new THREE.Vector3);(r=r.subVectors(t,e)).length()<1e-6&&r.set(1,1,1);var o=.5*r.length()/Math.sin(Math.PI/180*this.camera.fov*.5),u=(this.camera.IsPerspective()&&this.camera.aspect<1&&(o/=this.camera.aspect),this.camera.far=5*(o=0==o?1e-4:o),this.camera.setZoomToFitRatio(5),this.camera.far<1e3&&(this.camera.setZoomToFitRatio(1e3/o),this.camera.far=1e3),2e3<this.camera.far/this.camera.near&&(this.camera.near=this.camera.far/2e3),this.camera.near>.25*r.length()&&(this.camera.near=.25*r.length()),this.camera.perpNear>.25*r.length()&&(this.camera.perpNear=.25*r.length()),new THREE.Vector3(0,0,0).sub(new THREE.Vector3(1,1,1))),t=(this.camera.getOrginalCameraInfo()&&(p=new THREE.Vector3,n=new THREE.Vector3,p.copy(this.camera.getOrginalCameraInfo().center),n.copy(this.camera.getOrginalCameraInfo().position),p.sub(n),p.normalize(),u.copy(p)),u.normalize(),u.multiplyScalar(o),i.clone().sub(u)),e=(this.groundShadow.updateGroundTransform(this.camera,this.modelRootObject.boundingBox),this.camera.setOrthoNear(this.modelRootObject.boundingBox),f?this.camera.position.set(f.x,f.y,f.z):this.camera.position.copy(t),m?this.camera.setCameraTarget(new THREE.Vector3(m.x,m.y,m.z)):this.camera.setCameraTarget(i),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0),this.render(),this.modelRootObject.boundingBox),r=[],n=(r[0]=e.max.x,r[1]=e.max.y,r[2]=e.max.z,this.modelCoordToClientCoord(r)),p=((r=[])[0]=e.min.x,r[1]=e.max.y,r[2]=e.min.z,this.modelCoordToClientCoord(r)),o=((r=[])[0]=e.min.x,r[1]=e.max.y,r[2]=e.max.z,this.modelCoordToClientCoord(r)),u=((r=[])[0]=e.max.x,r[1]=e.max.y,r[2]=e.min.z,this.modelCoordToClientCoord(r)),f=((r=[])[0]=e.min.x,r[1]=e.min.y,r[2]=e.min.z,this.modelCoordToClientCoord(r)),t=((r=[])[0]=e.min.x,r[1]=e.min.y,r[2]=e.max.z,this.modelCoordToClientCoord(r)),m=((r=[])[0]=e.max.x,r[1]=e.min.y,r[2]=e.min.z,this.modelCoordToClientCoord(r)),i=((r=[])[0]=e.max.x,r[1]=e.min.y,r[2]=e.max.z,this.modelCoordToClientCoord(r)),e=Math.max(n[0],p[0],o[0],u[0],f[0],t[0],m[0],i[0]),r=Math.min(n[0],p[0],o[0],u[0],f[0],t[0],m[0],i[0]),g=Math.max(n[1],p[1],o[1],u[1],f[1],t[1],m[1],i[1]),n=Math.min(n[1],p[1],o[1],u[1],f[1],t[1],m[1],i[1]),v=(e*=this.renderer.getPixelRatio(),r*=this.renderer.getPixelRatio(),g*=this.renderer.getPixelRatio(),n*=this.renderer.getPixelRatio(),e-r),A=g-n,y=0,E=0,M=(d<A*(.9*l/v)?y=v*((E=.9*d)/A):E=A*((y=.9*l)/v),E=E||1,y=y||1,(e+r)/2-v/2),w=(g+n)/2-A/2,b=this;this.getScreenCapture(function(e){var o=new Image;o.src=e,o.onload=function(){var e="rgb("+(255*(e=b.renderer.getClearColor()).r|0)+","+(255*e.g|0)+","+(255*e.b|0)+")",t=(b.bBackGroundTransparent||(new THREE.Color).setStyle(e),document.createElement("canvas")),n=t.getContext("2d"),i=(t.width=l,t.height=d,document.createElement("canvas")),r=i.getContext("2d"),r=(i.width=y,i.height=E,r.fillStyle=e,r.drawImage(o,M,w,v,A,0,0,y,E),n.fillStyle=e,b.bBackGroundTransparent&&(n.globalAlpha=h),n.fillRect(0,0,l,d),n.globalAlpha=1,n.drawImage(i,0,0,y,E,(l-y)/2,(d-E)/2,y,E),t.toDataURL());a&&a(r),b.onWindowResize();b.look({smoothTranslation:!1,useOrginal:!0}),void 0!==s&&s&&("envmap"==c.backgroundtype?(b.envmapUrls=c.envmapUrls,b.envmapUrlsindex=c.envmapUrlsindex,b.envMapCamera=c.envMapCamera,b.envMapScene=c.envMapScene,c.envMapTexture&&(b.envMapTexture=c.envMapTexture),c.envMapMaterial&&(b.envMapMaterial=c.envMapMaterial),b.exchangeBackImage=c.exchangeBackImage):"Image"==c.backgroundtype?(b.backGroundScene=c.backGroundScene,b.backGroundCamera=c.backGroundCamera,b.backGroundMesh=c.backGroundMesh,b.setBackGroundImage(c.backGroundImage)):"Color"==c.backgroundtype&&b.setBackGroundColor(c.clearColor),b.renderer.setClearAlpha(c.alpha),b.renderNew())}},null,null)},f.getBackgroundstate=function(){var e={};return T.envmapUrls?(e.backgroundtype="envmap",e.index=T.envmapUrlsindex):T.backGroundImage?(e.backgroundtype="Image",e.backGroundImage=T.backGroundImage):(e.backgroundtype="Color",e.clearColor=T.clearColor),e},f.getScreenCapturethumbnail=function(i){var e=this.modelRootObject.boundingBox,t=[],n=(t[0]=e.max.x,t[1]=e.max.y,t[2]=e.max.z,this.modelCoordToClientCoord(t)),r=((t=[])[0]=e.min.x,t[1]=e.max.y,t[2]=e.min.z,this.modelCoordToClientCoord(t)),o=((t=[])[0]=e.min.x,t[1]=e.max.y,t[2]=e.max.z,this.modelCoordToClientCoord(t)),a=((t=[])[0]=e.max.x,t[1]=e.max.y,t[2]=e.min.z,this.modelCoordToClientCoord(t)),s=((t=[])[0]=e.min.x,t[1]=e.min.y,t[2]=e.min.z,this.modelCoordToClientCoord(t)),l=((t=[])[0]=e.min.x,t[1]=e.min.y,t[2]=e.max.z,this.modelCoordToClientCoord(t)),d=((t=[])[0]=e.max.x,t[1]=e.min.y,t[2]=e.min.z,this.modelCoordToClientCoord(t)),e=((t=[])[0]=e.max.x,t[1]=e.min.y,t[2]=e.max.z,this.modelCoordToClientCoord(t)),t=Math.max(n[0],r[0],o[0],a[0],s[0],l[0],d[0],e[0]),c=Math.min(n[0],r[0],o[0],a[0],s[0],l[0],d[0],e[0]),h=Math.max(n[1],r[1],o[1],a[1],s[1],l[1],d[1],e[1]),n=Math.min(n[1],r[1],o[1],a[1],s[1],l[1],d[1],e[1]);t*=this.renderer.getPixelRatio(),c*=this.renderer.getPixelRatio(),h*=this.renderer.getPixelRatio(),n*=this.renderer.getPixelRatio();var r=Math.max(t-c,h-n),u=r/360,p=(t+c)/2-r/2,f=(h+n)/2-r/2;this.getScreenCapture(function(e){var t=new Image,n=(t.src=e,T);t.onload=function(){var e=n.getImagePortion(t,400,400,p,f,u);i&&i(e)}},null,null)},f.getScreenCaptureByParams=function(e,t,n,i,r){var o,a=T.container.getBoundingClientRect(),s=a.width,a=a.height,l=(T.lightControls.getVisible()&&(o=!0),null!=r&&r||o&&T.lightControls.setVisible(!1),s!=e||a!=t?T.onWindowResize(null,e,t):T.render(),T.renderer.domElement.toDataURL());return s==e&&a==t||T.onWindowResize(null,s,a),n&&n(l),i&&window.open(l),null!=r&&r||o&&T.lightControls.setVisible(!0),l},f.getCameraInfo=function(){return this.cameraControl.getCameraInfo()},f.getlightInfo=function(){for(var e=[],t=T.lightControls.getLightsCount(),n=0;n<t;n++){var i=T.lightControls.getLight(n),r={};switch(i.type){case"DirectionalLight":r=T.lightControls.getDirLightParam(i);break;case"PointLight":r=T.lightControls.getPointLightParam(i);break;case"HemisphereLight":r=T.lightControls.getHemiLightParam(i);break;case"SpotLight":r=T.lightControls.getSpotLightParam(i);break;case"None":r=T.lightControls.getDirLightParam(i)}r.type=i.type,e.push(r)}return e},f.resetSvgViewBox=function(){T.svgViewer.resetSvgViewBox()},f.resetCamera=function(e){g?(T.cameraControl.set2DViewerInfo(T.viewer2DInfo),T.render()):(e.type=T.defaultStandardView,T.look(e)),_e.autoSwitchFirstPersonView&&"FirstPerson"==N&&(N=this.originalModelOperationMode)},f.look=function(e){var t=e.type;e.callback=function(){var e=T.getCameraInfo(),e=new THREE.Vector3(e.position.x-e.target.x,e.position.y-e.target.y,e.position.z-e.target.z),e=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1).normalize(),e.normalize()),e=(new THREE.Euler).setFromQuaternion(e);T.ScenarioEditorInfo.EulerAngle.set(e.x,e.y,e.z),t?(T.dispatchEvent({type:"Eulerchangedir",x:180*e.x/Math.PI,y:180*e.y/Math.PI,z:180*e.z/Math.PI}),T.dispatchEvent({type:"dischangedir",distance:20})):(T.dispatchEvent({type:"Eulerchange",x:180*e.x/Math.PI,y:180*e.y/Math.PI,z:180*e.z/Math.PI}),T.dispatchEvent({type:"dischange",distance:20}))},e.sphericalTransition=!T.CADViewer,this.cameraControl.look(e)},f.getSvgScreenCapture=function(n){var i=T.svgViewer.svgCanvas,e=T.svgViewer.svgObj.style.width,t=T.svgViewer.svgObj.style.height,r=(i.domElement.width=e,i.domElement.height=t,T.svgViewer.getSvgElement());r.getAttribute("width")&&r.setAttribute("width",e);r.getAttribute("height")&&r.setAttribute("height",t);var e=r.outerHTML,o=(void 0===e&&(e=(new XMLSerializer).serializeToString(r)),window.URL||window.webkitURL||window),a=new Image,t=(a.crossOrigin="Anonymous",new Blob([e],{type:"image/svg+xml;charset=utf-8"})),s=o.createObjectURL(t);a.onload=function(){var e=i.domElement.getContext("2d"),t=(e.drawImage(a,0,0),o.revokeObjectURL(s),i.domElement.toDataURL());n&&n(t),window.open(t),e.clearRect(0,0,i.domElement.width,i.domElement.height)},a.src=s,0},f.getSvgViewportInfo=function(){return{type:"SvgCamera",width:T.svgViewer.svgObj.style.width,height:T.svgViewer.svgObj.style.height,viewBox:T.svgViewer.getSvgElement().getAttribute("viewBox")}},f.showWaiterCoverStater=function(e,t,n){T.showWaiter(e=null==e||e),T.showCoverer(t=null!=t?t:e),T.showStater(n=null!=n?n:e)},f.showWaiter=function(e){T.bHasLoadingWaiter&&(e?(T.waiter||new zn(T,I.loadingWaiterColor),T.waiter.setVisibility(e)):T.waiter&&(T.container.removeChild(T.waiter.domElement),T.waiter=null))},f.showCoverer=function(e){T.bHasLoadingCoverer&&(e?(T.coverer||new Rn(T,I.loadingCovererColor),T.coverer.setVisibility(e)):T.coverer&&(T.container.removeChild(T.coverer.domElement),T.coverer=null))},f.showStater=function(e){T.bHasLoadingStater&&T.stater.show(e)},f.addButton=function(e,t){this.Optoolbar&&this.Optoolbar.addButton(e,t)},f.setPmiVisible=function(e){null!=e&&T.pmiVisible!=e&&null!=T.pmiObject&&(T.pmiVisible=e,(T.isPartPmi()||T.isAssemblyPmi())&&(T.setAssemblyPMIVisible(e),T.setPartPMIVisible(e)),e?T.scene.getObjectByName("pmiobject")||T.scene.add(T.pmiObject):T.scene.getObjectByName("pmiobject")&&T.scene.remove(T.pmiObject),Se.isMobileDevice()&&T.setPMIObjectVisible(T.pmiObject.children[0],e),T.render())},f.setPmiVisible2=function(e){var t,n,i;null!=e&&T.pmiVisible!=e&&null!=T.pmiObject&&(T.pmiVisible=e,(T.PartPmiVisible=this.AssemblyPMIVisible=e)?(T.scene.getObjectByName("pmiobject")||T.scene.add(T.pmiObject),t=this.controls.getBoundingBox().clone(),(n=this.calculatePMIBoundingBox())&&!t.containsBox(n)&&(t.union(n),n=new THREE.Vector3,t.getCenter(n),t=t.min.distanceTo(t.max),i=this.camera.position.clone(),n=Math.abs(n.distanceTo(i))+1.2*t,this.camera.adjustNearFar(n,n))):T.scene.getObjectByName("pmiobject")&&T.scene.remove(T.pmiObject),1==(i=T.pmiObject.children[0]).version&&T.setPMIObjectVisible(i,e),T.render())},f.isPmiVisible=function(){return T.pmiVisible},f.isAssemblyPmi=function(){return T.hasAssemblyPMI},f.isPartPmi=function(){return T.haspartPMI},f.setAssemblyPMIVisible=function(t){if(null!=t&&T.isAssemblyPmi()&&T.AssemblyPMIVisible!=t){T.scene.getObjectByName("pmiobject")||(T.scene.add(T.pmiObject),T.setPartPMIVisible(T.PartPmiVisible)),this.AssemblyPMIState={visible:t},T.AssemblyPMIVisible=t,T.AssemblyPMIVisible==T.PartPmiVisible&&(T.pmiVisible=T.AssemblyPMIVisible);var e=T.ndsModel.rootBodyNode.pmiuuid;if(!T.is2DModel&&T.pmiObject)for(var n=0;n<e.length;++n){var i=e[n],i=T.PMIUUIDtoPMIObject[i];i&&(i.visible=t,i.traverse(function(e){e.visible=t}))}T.render()}},f.setPartPMIVisible=function(t){if(null!=t&&T.isPartPmi()&&T.PartPmiVisible!=t){if(T.scene.getObjectByName("pmiobject")||(T.scene.add(T.pmiObject),T.setAssemblyPMIVisible(T.AssemblyPMIVisible)),this.PartPMIState={visible:t},T.PartPmiVisible=t,T.AssemblyPMIVisible==T.PartPmiVisible&&(T.pmiVisible=T.AssemblyPMIVisible),T.PartPMIuuid&&!T.is2DModel&&T.pmiObject)for(var e=0;e<T.PartPMIuuid.length;++e)for(var n=T.PartPMIuuid[e],i=0;i<n.length;++i){var r=n[i],r=T.PMIUUIDtoPMIObject[r];r&&(r.visible=t,r.traverse(function(e){e.visible=t}))}T.render()}},f.setAssemblyPMIVisible2=function(e){T.AssemblyPMIVisible=e,this.setPMIObjectVisible(T.ndsModel.AssemblyPMI,T.AssemblyPMIVisible)},f.setPartPMIVisible2=function(e){T.PartPmiVisible=e,T.AssemblyPMIVisible==T.PartPmiVisible?this.setPMIObjectVisible(T.pmiObject.children[0],T.AssemblyPMIVisible):(this.setPMIObjectVisible(T.pmiObject.children[0],T.PartPmiVisible),this.setPMIObjectVisible(T.ndsModel.AssemblyPMI,T.AssemblyPMIVisible))},f.isAssemblyPMIVisible=function(){return T.AssemblyPMIVisible},f.isPartPmiVisible=function(){return T.PartPmiVisible},f.loadModel=function(e,t,n,i,r,o,a,s,l,d){if(-1!=_e.ScenarioEditorid&&(U=O),null==e||null==t)return!1;var c;switch(T.ndsModel||(T.ndsModel=new Xt,T.currentSketchFileUrl=""),T.ndsModel&&!T.ndsModel.isEmpty()&&0<T.ndsModel.meshManager.nMeshes?B=!1:(B=!0,T.ndsModel&&T.camera.setOrginalCameraInfo(void 0)),"./"!==(t=t.trim()).substr(0,2)&&-1===t.indexOf(":/")&&"../"!==t.substr(0,3)&&"/"!==t.substr(0,1)&&-1===t.indexOf(":\\")&&(t="./"+t),l=l||{},T.initViewer(!0),T.ConfigNum=void 0===l.configNum?0:l.configNum,T.ConfigName=void 0===l.configName?"":l.configName,H=l.explodeFactor||0,T.explodeMode=l.explodeMode||ve.EXPLODEMODE.NORMAL,T.explodeLevel=l.explodeLevel||1,T.explodeObjects=l.explodeObjects||[],T.useUnvisibleList=void 0!==l.useUnvisibleList&&l.useUnvisibleList,T.useTransparentList=void 0!==l.useTransparentList&&l.useTransparentList,T.unvisibleList=l.unvisibleList,T.transparentList=l.transparentList,T.clipPlaneInfo=l.clipPlaneInfo,T.clipBoxInfo=l.clipBoxInfo,T.pmiVisible=void 0===l.pmiVisible?T.viewerPMIVisible:l.pmiVisible,T.AssemblyPMIVisible=T.pmiVisible,T.PartPmiVisible=T.pmiVisible,T.measuringScale=void 0===l.measuringScale?1:l.measuringScale,T.is2DModel||(T.measuringScale=1),T.trueMapList=s,T.bodyNodeUUidToMaterial=d,-1==_e.ScenarioEditorid&&((c=t.split("/")).pop(),c.pop(),this.folderPath=c.join("/")+"/"),T.parameter={id:e,url:t,binUrl:n,contentFileUrl:i,type:r,cameraInfo:o,loadCallBack:a,trueTextureFileList:s,params:l,bodyNodeUUidToMaterial:d},r){case"js":case"obj":case"obj_json":T.load3D(Se.encodeURL(t),Se.encodeURL(n),i,o,r,a);break;case"svg":T.svgViewer.loadSvg(Se.encodeURL(t),o)}T.modelInfo.push({id:e,type:r,url:t})},f.loadFlateDate=function(e,i){this.initViewer(!0);e=Si()(e);(new Ti.a).loadAsync(e,{base64:!1}).then(function(t){T.ZIPData=t,T.zipMutiModel=!0;var n="Configurations.json";i&&(i.endsWith("/")||(i+="/"),n=i+n),Object.keys(t.files).forEach(function(e){e=t.files[e];n==e.name&&t.file(e.name).async("string").then(function(e){T.dispatchEvent({type:"Configurations",userData:e})})})}).catch(function(e){console.error("解压失败:",e)})},f.loadModelFlate=function(e,t){T.modelInfo.push({id:0,type:"Flate",url:e}),T.ndsModel||(T.ndsModel=new Xt),T.initViewer(!0),T.load3D(e,null,null,null,T.zipMutiModel?"js_zip":"zip",t)},f.allowshow=function(e,s){var e=Se.encodeURL(e),t=new oi;t.setCrossOrigin(this.crossOrigin),t.load(T.gobalReqHeader,e,function(e){var t=null,n=1;if((t=JSON.parse(e)).fileID){for(var i=t.fileID.slice(4),r="",o=0;o<i.length/4;o++){var a=i.slice(4*o,4*(o+1));r+=String.fromCharCode(parseInt(a,16))}"Viewer版本过低,请升级"==r&&(n=2)}s(n)},function(){},function(){s(3)})},f.allowRenderModel=function(e,t){var n=new JSEncrypt,n=(n.setPrivateKey("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCxl/XzEMiiYrLq prR5BxAY+IPkPdOtiEt7fP3jtxac0m5S1FAT/3jiQb+bTmqeffsl5gw7LaMMOkAj 5h+HzH/TbTmxYn4dIUkGFvvZHAiwMuDA+7fORjhTaz1hmQi1gUNX9Qu985ys2jFb eXAg5XV2orovM+qY3regbNkWwVk3iJ1Kk3rk2ZBw26AVvs+ujVvAE8cGP/LgAAOe CvNDTiA//agCTajQo1xSkAIcLSNKdUfn5OdTlx0sifXcw5NUmBZKbQ7Q7tC0Xpa1 RanG+5riOzLcw6zOKwHn62Hp3Twosc/hLATaOmz/ru5rnNe+bDBndp3iRo/zCiL8 8iwmg+s7AgMBAAECggEBAJnBWusKSOpuUUDe+7kc6E72OhpNfQrsyY0sdhPE3AsC FQoZTwtBT8Nz8RPhHGYD5IC3XzeNF3DqrcVm4z2LS9Ac7Koq/8zwmGxxUbJylwMV yYjLZiNsoC941Te+as/aDhgEzBm05Jyye7Eavn18q+n+kPt1E1Mu4ARAuOL+muN8 LNqNFOMSYzocXRJqnKSXnnIQQa6FvA6UiM8DaJcXJ83V24tF0vaLfCOOFvfNQwGN gNapppvJGSqE1QjrNwllO8O8cBmiC0PIW0lff2qeXH6bfhzUiaMa70sDEEHcZlW5 WmoJABjYwEH5xvjCqieK5SOGKwQkwFj0gcqBKGWZPYECgYEA6xAV4UqvvIlRvlMI eKAlJJwS10M9avScyq9W+fJk0KVqstGGdIDklRy4pd1SALDwKU4C58I/5Gsky+S+ iPwUaZySWjwgdBl4icv3cbUdu61gUUdHfDh+d+hZcnRKa9EzQEPReOkcVpSlfxnJ oaS7psozL3nUfJrTH+QlflesQXECgYEAwWl1dpcCJkmuacUhzCsZ29BljREjlPK6 6qnjUEY/IWqddH2ZWrJBB+6ZSNYSniNqpsjnFPccQdEfk2kxWLjeCCNb42Lukm6F rrJt7Kit7KW0VDyN7+etkzGRfM0QQl9mhX4wUxWyCKdgq7+Ut/nwlYhZi7TN86n7 qRBN1HPlIWsCgYEA0Q43R20TKoy+RJS4Xf+fyRV9tDE6+Fqg76pNonIvs1jKskqi WA8iPHOUzP8vJSo4DaQx9UjPZijcSvIfetkmll8H0nTTMC5PA86BPYGk9ftWRDMu oo3j/GSK2L4QSh9+g1NNg0lfSKlfHtEigD5wHgCK0Vh64G8aAaz4o4r5yiECgYBH G93K5wQsTYSpcIfXh7UvIvRjI/0AAyoDoshnOBx3zbnsHU1nkgfkwa1roQEhUQYi IdUL2TpzXE6OpOs2omlHdrCO7k2mWqodq45Mp0uiqN2e5tCMdpJTfrLtvnsO3AJW bCmaMmzNT7R0ELC930+7unCps6TQxBs5cjwbMyz31wKBgF1wlS2cWsuOQ76t8LPn jXC6nsU2eisWN5KFbxhNphCnqxgYBJth5Vk3OIby2nmvNGqO12p1bUZpbVEBttyj JcXR+iuasOWWev0SuUFZvp3bYEiX/sCjWZbB9mBjg/s6QW5z4ZW9rF6UdOr7ISQ8 6g9cU4ontroPvD52Jcffyr3f"),n.decrypt(e));return n?(e=JSON.parse(n),t?!0===e.visit?(T.excalibur=!1,2):!1===e.visit?1:3:(console.log("公司信息比对"),void 0===e.company?3:1)):3};var re=function(e,t){T.ndsModel&&1!=e.isPmi&&T.modelRootObject&&T.modelRootObject.boundingBox.copy(e.boundingBox),e instanceof THREE.Scene?(T.scene=e,T.modelRootObject=e):e.isPmi||T.modelRootObject||(T.ndsModel||T.scene.add(e),T.modelRootObject=e),(0==_e.ScenarioEditorid||T.sceneInfo&&T.sceneInfo.setScene)&&T.addLights(T.scene)},oe=function(e){e&&e.render&&(void 0!==e.render.showLines&&T.setLinesVisibility(e.render.showLines,!1),void 0!==e.render.enableAutoRotation&&(J=e.render.enableAutoRotation),void 0!==e.render.enableGroundShadow&&(D=e.render.enableGroundShadow),void 0!==e.render.enableSmoothTranslation&&(K=e.render.enableSmoothTranslation),void 0!==e.render.enableEnvMap&&(L=e.render.enableEnvMap),void 0!==e.render.envMapReflectionRatio&&e.render.envMapReflectionRatio,void 0!==e.render.envMapTextures?T.setEnvMapTextures(e.render.envMapTextures):void 0!==e.render.backGroundImage&&T.setBackGroundImage(e.render.backGroundImage),void 0!==e.render.envMapBlurLevel&&(s=e.render.envMapBlurLevel),void 0!==e.render.enableEnvMapBlur&&T.setEnvMapBlurEnabled(e.render.enableEnvMapBlur),void 0!==e.render.renderMode&&T.setRenderMode(e.render.renderMode,!1),void 0!==e.render.modelUpDirection)&&T.initModelUpDirection(e.render.modelUpDirection)},ae=function(e,t){if(t&&T.ndsModel&&((!e||!T.ndsModel||T.ndsModel.rootBodyNode)&&(ve.StartRenderTime=Date.now(),T.nBufferChunksLoaded+=1,T.ndsModel&&T.nBufferChunksLoaded%10==0&&T.render(),T.ndsModel&&5<T.nBufferChunksLoaded&&(t=T.nBufferChunksLoaded/T.nBufferChunks,T.dispatchEvent({type:"updateProgress",userData:{precent:t}})),F=R=!0,q||(S.onLoad(),B&&T.resetCamera({useOrginal:!0,smoothTranslation:!1})),q=!0,T.groundShadow.needClear=!0,_e.enableBroadcast&&T.render(),e))){T.ndsModel instanceof NDSWebViewer.NdsModel&&((t=new Xt).addModel(T.ndsModel),T.ndsModel=t,T.ndsModel.fuseData(),_e.ScenarioEditorid=0),T.AnimationExtension&&(e=T.AnimationExtension.animationFileData,t=T.AnimationExtension.animationMorphAttri,e)&&T.loadAnimationFile(e,t),8==T.getRenderMode()&&T.setRenderMode("transparent"),T.animationsManager&&T.animationsManager.hasAnimations()?_e.enableBroadcast||0!=T.turnoffAnimation||T.startAnimationByUUID(I.animationUUID,!0):S.onSmoothTranslationDone=function(){S.onSmoothTranslationDone=void 0,T.ndsModel&&0!=T.ndsModel.geomManager.bufferChunksToLoad.length||T.toggleAutoRotation(!0)},B&&(A={useOrginal:!0,smoothTranslation:!!T.CADViewer},T.Euler&&((x=new THREE.Vector3(0,0,1)).applyEuler(T.Euler),A.from=x.toArray(),(b=new THREE.Vector3(0,1,0)).applyEuler(T.Euler),A.up=b.toArray()),T.resetCamera(A)),!T.backGroundScene&&T.is2DModel&&(e="0x"+T.renderer.getClearColor(this.oldClearColor).getHexString(),T.clearColor=null,T.setBackGroundColor(e)),T.sketchFileUrlQueue.length||(n=T.currentSketchFileUrl?T.ndsModel?T.ndsModel.getStaticGeometriesCount():le(T.scene):T.ndsModel?T.ndsModel.getGeometriesCount():le(T.scene),console.log("Mesh count : "+n.Mesh.count+" triangles : "+n.Mesh.triangles+" points : "+n.Mesh.points),console.log("Line count : "+n.Line.count+" points : "+n.Line.points)),_e.enableBroadcast&&_e.broadcastMajor&&(document.addEventListener("mousemove",T.broadcastManager.onBroadcastMouseMove,!1),document.addEventListener("touchmove",T.broadcastManager.onTouchMove,!1));var n,t=(performance||Date).now();T.sketchFileUrlQueue.length||(C=(t-V)/1e3,console.log("All load time : "+C.toFixed(2))),j&&T.updateAllMateriaslInfo(j,O),T.hasViewBox&&null==T.viewBox&&T.initViewBox(),T.isExploded()&&(i=H,H=0,T.setExplodeMode(T.explodeMode,T.explodeLevel,!0),T.explodeModel(i)),T.clipPlaneInfo&&(T.isSectionViewEnabled()||T.onSectionView(!0,!1),T.clipPlaneManager.setClipPlaneInfor(T.clipPlaneInfo));var i={useOrginal:!0,smoothTranslation:!!T.CADViewer};if(T.Euler&&((e=new THREE.Vector3(0,0,1)).applyEuler(T.Euler),i.from=e.toArray(),(e=new THREE.Vector3(0,1,0)).applyEuler(T.Euler),i.up=e.toArray()),T.resetCamera(i),_e.enableBroadcast=T.oldenableBroadcast,T.ndsModel&&T.ndsModel.pureLineBody&&0<T.ndsModel.pureLineBody.length){for(var r=0;r<T.ndsModel.pureLineBody.length;r++)!T.ndsModel.pureLineBody[r].leafBodyAttri||6==T.ndsModel.pureLineBody[r].leafBodyAttri.bodyBbox.length&&Number.isFinite(T.ndsModel.pureLineBody[r].leafBodyAttri.bodyBbox[0])||T.ndsModel.calculateLineBodyBoundingBox(T.ndsModel.pureLineBody[r]);T.ndsModel.pureLineBody=[]}T.dispatchEvent({type:"updateProgress",userData:{precent:1}}),T.ndsModel&&!T.hasBrepFile()&&T.ndsModel.meshManager.mergeLineSegments(),T.hasBrepFile()||T.dispatchEvent({type:"BrepInfoEvent",faceArea:!1,bodyVolume:!1,totalVolume:!1,bodyArea:!1,totalArea:!1,boundingbox:!1,facePerimeter:!1}),z=!0,T.sceneInfo||T.sketchFileUrlQueue.length||T.dispatchAsyncEvent({type:"geometryAllLoadedEvent",modelLoadedTime:P,wholeModelLoadedTime:C,modelInfo:n}),!T.sceneInfo||T.sceneInfo.folderArray||T.sceneInfo.WasmMerge||T.sketchFileUrlQueue.length||T.dispatchAsyncEvent({type:"geometryAllLoadedEvent",modelLoadedTime:P,wholeModelLoadedTime:C,modelInfo:n});var o,a=T.sceneInfo;if((0==_e.ScenarioEditorid||T.sceneInfo&&T.sceneInfo.setScene)&&T.lightControls.loadTextures(function(){if(T.lightControls.resetPosition(),a&&a.setScene){T.lightControls.getLightList().forEach(function(e){T.lightControls.removeLight(e)});for(var e=a.lightInfo.length,t=0;t<e;t++)T.lightControls.addLight("None");a.maxLightDistance&&T.lightControls.setMaxdistance(a.maxLightDistance),a.lightInfo.forEach(function(e,t){T.lightControls.switchLight(t,e.type);var n=T.lightControls.getLight(t);switch(e.type){case"DirectionalLight":T.lightControls.setDirLightParam(n,e);break;case"PointLight":T.lightControls.setPointLightParam(n,e);break;case"HemisphereLight":T.lightControls.setHemiLightParam(n,e);break;case"SpotLight":T.lightControls.setSpotLightParam(n,e)}}),T.lightControls.setVisible(!0),T.lightControls.setVisible(!1),a=null,T.dispatchEvent({type:"lightLoadEnd"})}}),_e.inBIMContext&&(t=/neg/g.test(_e.modelUpDirection)?_e.modelUpDirection.replace("neg","pos"):_e.modelUpDirection.replace("pos","neg"),e=_e.modelUpDirection,T.initModelUpDirection(t),T.initModelUpDirection(e)),"posy"==_e.modelUpDirection||_e.inBIMContext||(T.CADViewer&&T.sketchIsSub&&T.sketchRootBodyNode?T.sketchRootBodyNode.ndsModel.updateSubSketchNodeMatrix(T.sketchRootBodyNode.uuid):T.setModelUpDirection(_e.modelUpDirection,!0),A={useOrginal:!0,smoothTranslation:!!T.CADViewer},T.Euler&&((x=new THREE.Vector3(0,0,1)).applyEuler(T.Euler),A.from=x.toArray(),(b=new THREE.Vector3(0,1,0)).applyEuler(T.Euler),A.up=b.toArray()),T.resetCamera(A)),T.dispatchBrepEvent(),T.hasBodyRepeat()&&(o=document.createElement("div"),Se.isMobileDevice()&&(i=T.renderer.getSize().height/2-21+"px",o.style.top=i),o.className="app-alert",T.container.appendChild(o),o.style.color="#f76700",o.style.backgroundColor="#ffdcc3",t="en"==Se.getLanguage(),o.innerHTML=t?"Entity already exist please<br/>modify the model and try again":"存在重复实体<br/>请修改后重新上传",o.style.height="84px",o.style.display="block",Se.isMobileDevice()||(o.innerHTML=t?"Entity already exist please modify the model and try again":"提示:存在重复实体请修改后重新上传",o.style.height="42px"),setTimeout(function(){T.container.removeChild(o)},3e3)),T.is2DModel||!T.sceneInfo&&T.CADViewer||(y=T.ndsModel.rootBodyNode,T.camera.setOrginalCameraInfo(void 0),m=new THREE.Vector3,g=new THREE.Vector3,T.computeBoundingBox(T.scene,m,g,v={flag:!0}),T.controls.setBoundingBox(m,g),T.selectionManager.clearSelection(),T.switchRotateCenterBySelection(),T.resetCamera(A={smoothTranslation:!1}),e=T.getCameraInfo(),T.camera.setOrginalCameraInfo({center:new THREE.Vector3(e.target.x,e.target.y,e.target.z),up:new THREE.Vector3(e.up.x,e.up.y,e.up.z),position:new THREE.Vector3(e.position.x,e.position.y,e.position.z)}),1<T.ndsModel.models.length&&T.selectionManager.selectObject(y),T.startMove(),T.groundShadowChange(),T.controls.SetBoundingBoxUpdated(!1),x=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1).normalize(),new THREE.Vector3(1,1,1).normalize()),b=(new THREE.Euler).setFromQuaternion(x),T.ScenarioEditorInfo.EulerAngle.set(b.x,b.y,b.z),T.dispatchEvent({type:"Eulerchange",x:180*b.x/Math.PI,y:180*b.y/Math.PI,z:180*b.z/Math.PI}),T.dispatchEvent({type:"dischange",distance:20}),T.render()),T.CADViewer||_e.AnimationEdit||T.scene.getObjectByName("GridHelper")||(t=new Ei(null,null,T),T.scene.add(t)),0<_e.ScenarioEditorid){var s="";switch(U){case 0:s="lighting";break;case 1:s="primarycolor";break;case 2:s="wireframe";break;case 3:s="whitemold";break;case 4:s="shadedWithEdges";break;case 5:s="shaded";break;case 6:s="hiddenLineRemove";break;case 7:s="hiddenLineVisible";break;case 8:s="transparent";break;default:s="shaded"}if(T.setRenderMode(s,!0),_e.ScenarioEditor&&T.ndsModel.rootBodyNode.fileUnit!=T.modelUnit){for(var l=T.getUnitTransfrom(T.modelUnit,T.ndsModel.rootBodyNode.fileUnit),d=(T.ndsModel.rootBodyNode.matrix||(T.ndsModel.rootBodyNode.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),T.ndsModel.rootBodyNode.matrix[0]*=l,T.ndsModel.rootBodyNode.matrix[1]*=l,T.ndsModel.rootBodyNode.matrix[2]*=l,T.ndsModel.rootBodyNode.matrix[4]*=l,T.ndsModel.rootBodyNode.matrix[5]*=l,T.ndsModel.rootBodyNode.matrix[6]*=l,T.ndsModel.rootBodyNode.matrix[8]*=l,T.ndsModel.rootBodyNode.matrix[9]*=l,T.ndsModel.rootBodyNode.matrix[10]*=l,T.ndsModel.updateNodeMatrix(T.ndsModel.rootBodyNode.uuid,T.ndsModel.rootBodyNode.matrix),new THREE.Box3),c=[T.ndsModel.sptIndex.root],h=0,u=c.length;h<u;++h){var p=c[h],f=(d.copy(p.boundingBox),new THREE.Matrix4);d.applyMatrix4(f.makeScale(l,l,l)),p.boundingBox.copy(d),0<p.children.length&&p.children.forEach(function(e){c.push(e)})}var m=new THREE.Vector3,g=new THREE.Vector3,v={flag:!0},A=(T.computeBoundingBox(T.scene,m,g,v),T.controls.setBoundingBox(m,g),T.selectionManager.clearSelection(),T.switchRotateCenterBySelection(),{smoothTranslation:!1}),e=(T.resetCamera(A),T.getCameraInfo());T.camera.setOrginalCameraInfo({center:new THREE.Vector3(e.target.x,e.target.y,e.target.z),up:new THREE.Vector3(e.up.x,e.up.y,e.up.z),position:new THREE.Vector3(e.position.x,e.position.y,e.position.z)}),T.cameraControl.adjustNearAndFar()}}if(T.sceneInfo){var y,E=_e.ScenarioEditorid+1;if(T.sceneInfo.folderArray)for(;E<T.sceneInfo.folderArray.length;){if(0<T.sceneInfo.folderArray[E]){setTimeout(function(){var e=T.folderPath+E+"/model.js";T.loadModel(T.parameter.id,e,T.parameter.binUrl,T.parameter.contentFileUrl,T.parameter.type,T.parameter.cameraInfo,T.parameter.loadCallBack,T.parameter.trueTextureFileList,T.parameter.params,T.parameter.bodyNodeUUidToMaterial)},300);break}E++,_e.ScenarioEditorid++}if(T.sceneInfo.WasmMerge||T.sceneInfo.folderArray.length<=_e.ScenarioEditorid-T.sceneInfo.ScenarioEditorid){for(var M in T.sceneInfo.nodeMatrix)(y=T.ndsModel.getBodyNodeFromUuid(M))&&(M=T.sceneInfo.nodeMatrix[M],T.ndsModel.updateNodeMatrix(y.uuid,M));if(T.sceneInfo.setScene){var w,b,x={center:new THREE.Vector3(T.sceneInfo.cameraInfo.target.x,T.sceneInfo.cameraInfo.target.y,T.sceneInfo.cameraInfo.target.z),up:new THREE.Vector3(T.sceneInfo.cameraInfo.up.x,T.sceneInfo.cameraInfo.up.y,T.sceneInfo.cameraInfo.up.z),position:new THREE.Vector3(T.sceneInfo.cameraInfo.position.x,T.sceneInfo.cameraInfo.position.y,T.sceneInfo.cameraInfo.position.z)},s=(T.sceneInfo.cameraInfo.isPerspective?T.camera.toPerspective():T.camera.toOrthographic(),T.CADViewer?(m=new THREE.Vector3,g=new THREE.Vector3,T.computeBoundingBox(T.scene,m,g,v={flag:!0}),T.controls.setBoundingBox(m,g),T.selectionManager.clearSelection(),T.switchRotateCenterBySelection(),T.camera.setOrginalCameraInfo(x),T.resetCamera(A={smoothTranslation:!1,useOrginal:!0})):(w=T.sceneInfo.EulerAngle,b={center:new THREE.Vector3(T.sceneInfo.originalcameraInfo.center.x,T.sceneInfo.originalcameraInfo.center.y,T.sceneInfo.originalcameraInfo.center.z),up:new THREE.Vector3(T.sceneInfo.originalcameraInfo.up.x,T.sceneInfo.originalcameraInfo.up.y,T.sceneInfo.originalcameraInfo.up.z),position:new THREE.Vector3(T.sceneInfo.originalcameraInfo.position.x,T.sceneInfo.originalcameraInfo.position.y,T.sceneInfo.originalcameraInfo.position.z)},T.camera.setOrginalCameraInfo(b),T.startSmoothTranslation(x,function(){T.dispatchEvent({type:"Eulerchange",x:180*w.x/Math.PI,y:180*w.y/Math.PI,z:180*w.z/Math.PI});var e=T.camera.getOrginalCameraInfo(),e=20/new THREE.Vector3(e.position.x-e.center.x,e.position.y-e.center.y,e.position.z-e.center.z).length()*T.camera.position.clone().sub(T.cameraControl.center()).length(),e=(T.dispatchEvent({type:"dischange",distance:e=(e=100<e?100:e)<.1?.1:e}),new THREE.Vector3),t=new THREE.Vector3;T.computeBoundingBox(T.scene,e,t,{flag:!0}),T.controls.setBoundingBox(e,t),T.selectionManager.clearSelection(),T.switchRotateCenterBySelection()})),"");switch(T.sceneInfo.renderMode){case 0:s="lighting";break;case 1:s="primarycolor";break;case 2:s="wireframe";break;case 3:s="whitemold";break;case 4:s="shadedWithEdges";break;case 5:s="shaded";break;case 6:s="hiddenLineRemove";break;case 7:s="hiddenLineVisible";break;case 8:s="transparent";break;default:s="shaded"}T.setRenderMode(s),T.setGridHelperVisible(T.sceneInfo.GridHelper),T.CADViewer?T.setGroundShadowVisibility(!1):T.setGroundShadowVisibility(T.sceneInfo.enableGroundShadow),T.setBackGroundColor(T.sceneInfo.clearColor),T.sceneInfo.backGroundImage&&(T.setBackGroundImage(T.folderPath+"backGroundImage.jpeg"),T.backGroundImageindex=T.sceneInfo.backGroundImageindex),T.sceneInfo.envmapUrls&&((t=[]).push(T.folderPath+"0.jpeg"),t.push(T.folderPath+"1.jpeg"),t.push(T.folderPath+"2.jpeg"),t.push(T.folderPath+"3.jpeg"),t.push(T.folderPath+"4.jpeg"),t.push(T.folderPath+"5.jpeg"),L=!0,T.setEnvMapTextures(t),T.envmapUrlsindex=T.sceneInfo.envmapUrlsindex),T.setEnvMapBlurEnabled(T.sceneInfo.bEnableEnvMapBlur)}T.sketchFileUrlQueue.length||T.dispatchAsyncEvent({type:"geometryAllLoadedEvent",modelLoadedTime:P,wholeModelLoadedTime:C,modelInfo:n}),T.selectionManager.clearSelection(),T.lightControls.setVisible(!0),T.lightControls.setVisible(!1),T.rootBodyNodeName=T.sceneInfo.rootName,T.loadrelease=!0,T.loadMergeRelease=!0===T.sceneInfo.WasmMerge,T.loadreleasecount=T.ndsModel.models.length,T.sceneInfo=null}}else T.lightControls.computeMaxdistance();_e.ScenarioEditor||T.sceneInfo||!T.hasPbrMaterial||T.setDefaultEnvMap(),_e.ScenarioEditor&&(e=Te.getExtension("SceneEditExtension"))&&e.reApplyTransparentMaterial()}},se=function(e,t){T.showWaiterCoverStater(!1),t?console.log("loadError"):(T.loaderror=!0,T.dispatchAsyncEvent({type:"loadError",errorInfo:e||"objectloader error"}))};function le(e){var t={Mesh:{count:0,triangles:0,points:0},Line:{count:0,points:0}};if(void 0!==e&&(e.hasOwnProperty("geometry")&&(e.geometry instanceof THREE.Geometry?(t.Mesh.count+=1,t.Mesh.points+=e.geometry.vertices.length,t.Mesh.triangles+=e.geometry.faces.length):e.geometry instanceof THREE.BufferGeometry&&(e instanceof THREE.Mesh?(t.Mesh.count+=1,e.geometry.attributes.position&&(t.Mesh.points+=e.geometry.attributes.position.count),e.geometry.index&&(t.Mesh.triangles+=e.geometry.index.count/3)):(e instanceof THREE.Line||e instanceof THREE.LineSegments)&&(t.Line.count+=1,e.geometry.attributes.position)&&(t.Line.points+=e.geometry.attributes.position.count))),void 0!==e.children))for(var n=0,i=e.children.length;n<i;++n){var r=le(e.children[n]);t.Mesh.triangles+=r.Mesh.triangles,t.Mesh.points+=r.Mesh.points,t.Mesh.count+=r.Mesh.count,t.Line.points+=r.Line.points,t.Line.count+=r.Line.count}return t}function de(e){if(!e||0!=e.selectfromtree){var t=T.selectionManager.getSelectedObjects();if(1!=e){T.explodeObjects=[];for(var n=new THREE.Box3,i=0;i<t.length;++i){var r,o=t[i];(u=T.ndsModel.getBodyBoundingBox(o))&&!u.isEmpty()&&(n.expandByPoint(u.max),n.expandByPoint(u.min)),o.leafBodyAttri||null!=(r=T.ndsModel.objectidTouuid?o.objectid:T.ndsModel.meshManager.bodyUuid2IdMap[o.uuid])&&-1==T.explodeObjects.indexOf(r)&&T.explodeObjects.push(r)}for(var a=(n.isEmpty()?T.controls.getBoundingBox():n).getCenter(),s=new THREE.Box3,i=0;i<t.length;++i)for(var o=t[i],l=0,d=(h=T.ndsModel.getLeafBodies(o)).length;l<d;l++)h[l].leafBodyAttri&&(T.ndsModel.objectidTouuid?T.explodeObjects.push(h[l].objectid):T.explodeObjects.push(h[l].id),s.min.fromArray(h[l].leafBodyAttri.bodyBbox,0),s.max.fromArray(h[l].leafBodyAttri.bodyBbox,3),h[l].leafBodyAttri.bodyTranslate[0]=.5*(s.min.x+s.max.x)-a.x,h[l].leafBodyAttri.bodyTranslate[1]=.5*(s.min.y+s.max.y)-a.y,h[l].leafBodyAttri.bodyTranslate[2]=.5*(s.min.z+s.max.z)-a.z)}else{for(n=new THREE.Box3,i=0;i<T.explodeObjects.length;++i){var c=(T.ndsModel.objectidTouuid||T.ndsModel.meshManager.bodyUuids)[T.explodeObjects[i]],o=T.ndsModel.getBodyNodeFromUuid(c);if(o||(c=T.ndsModel.meshManager.lineSegBodyUuids[T.explodeObjects[i]],o=T.ndsModel.getBodyNodeFromUuid(c)),o.leafBodyAttri)(u=T.ndsModel.getBodyBoundingBox(o))&&!u.isEmpty()&&(n.expandByPoint(u.max),n.expandByPoint(u.min));else for(var h,u,l=0,d=(h=T.ndsModel.getLeafBodies(o)).length;l<d;l++)h[l].leafBodyAttri&&(u=T.ndsModel.getBodyBoundingBox(h[l]))&&!u.isEmpty()&&(n.expandByPoint(u.max),n.expandByPoint(u.min))}for(a=n.getCenter(),s=new THREE.Box3,i=0;i<T.explodeObjects.length;++i)c=(T.ndsModel.objectidTouuid||T.ndsModel.meshManager.bodyUuids)[T.explodeObjects[i]],(o=T.ndsModel.getBodyNodeFromUuid(c))||(c=T.ndsModel.meshManager.lineSegBodyUuids[T.explodeObjects[i]],o=T.ndsModel.getBodyNodeFromUuid(c)),o.leafBodyAttri&&(s.min.fromArray(o.leafBodyAttri.bodyBbox,0),s.max.fromArray(o.leafBodyAttri.bodyBbox,3),o.leafBodyAttri.bodyTranslate[0]=.5*(s.min.x+s.max.x)-a.x,o.leafBodyAttri.bodyTranslate[1]=.5*(s.min.y+s.max.y)-a.y,o.leafBodyAttri.bodyTranslate[2]=.5*(s.min.z+s.max.z)-a.z)}}}function ce(){T.dispatchEvent({type:"fullScreenEvent",isFullScreen:T.isFullScreen()})}function he(e,t){for(var n=T.ndsModel.meshManager.oriGeomUuid2MeshPosMap,i=[],r=0,o=0;o<e.length;o++){var a=e[o],s=a.start,a=a.uuid;s<=t&&i.push(a)}for(var l=0;l<i.length;l++){if(i.length<=l+1)return r;var d=n.get(i[l]);r+=n.get(i[l+1])[0].x-d[1].x}return r}function ue(e,t,n){for(var i=0;i<t.length;i++){var r=t[i];if(e>=r.start&&e<=r.end&&r.start!=r.end)return n.end=r.end,1}}function pe(e){for(var t=[],n=null,i=null,r=0;r<e.length;r++)i=(null===n?n=e[r].subInd:e[r].subInd!==i+1&&(t.push({start:n,end:i}),n=e[r].subInd),e[r].subInd);return null!==n&&t.push({start:n,end:i}),t}return Object.defineProperties(f,{loadCallback:{get:function(){return re},set:function(e){re=e}},renderSettingCallback:{get:function(){return oe},set:function(e){oe=e}},bufferChunkCallback:{get:function(){return ae},set:function(e){ae=e}},loadErrorCallback:{get:function(){return se},set:function(e){se=e}}}),ve.TextureLoadingManager=new THREE.LoadingManager,ve.TextureLoadingManager.onProgress=function(e,t,n){F&&T.render()},ve.TextureLoadingManager.onError=function(){ve.TextureLoadingManager.itemEnd(),F&&T.render()},f.load3D=function(a,e,t,o,n,s){T.showWaiterCoverStater(!0),T.controls.SetBoundingBoxUpdated(!1),T.currentSketchFileUrl||(V=(performance||Date).now()),ve.StartRenderTime=Date.now(),q=!1,R=void 0,T.meshLoadedUUIDs=[];try{var i,r,l,d,c,h,u,p;S.onProgress=function(e,t,n){},S.onError=function(){S.itemEnd()},S.onLoad=function(){if(T.sceneInfo&&hr.parseMaterialInfo(T.sceneInfo,T),!1!==R){T.dispatchEvent({type:"loadBegin"}),T.showWaiterCoverStater(!1),T.initModelUpDirection(I.modelUpDirection),T.scene.updateMatrixWorld(!0),T.getLinesVisibility()||T.showLineObjects(T.scene,!1),F=void 0===R||R,T.selectionManager.computeTargetList(T.scene),L&&T.updateEnvMap(T.envMapTexture),null==o?B&&(e={smoothTranslation:!1},T.camera.getOrginalCameraInfo()&&(e.useOrginal=!0),T.cameraInfoFile&&T.is2DModel&&!T.cameraInfoFile.hasSet&&(e.up=T.cameraInfoFile.up,T.cameraInfoFile.hasSet=!0),T.Euler&&((t=new THREE.Vector3(0,0,1)).applyEuler(T.Euler),e.from=t.toArray(),(t=new THREE.Vector3(0,1,0)).applyEuler(T.Euler),e.up=t.toArray()),T.resetCamera(e)):(o.smoothTranslation=!1,T.setCameraInfo(o)),T.recordOriginalMeshes(),T.isolateMeshes.length=0;var e,t=(performance||Date).now();if(T.currentSketchFileUrl||(P=(t-V)/1e3,console.log("Load time : "+P.toFixed(2))),T.dispatchAsyncEvent({type:"geometryLoadedEvent"}),void 0===R&&(T.setRenderMode(T.renderMode,!1),T.currentSketchFileUrl||(e=le(T.scene),console.log("Mesh count : "+e.Mesh.count+" triangles : "+e.Mesh.triangles+" points : "+e.Mesh.points),console.log("Line count : "+e.Line.count+" points : "+e.Line.points)),T.animationsManager&&T.animationsManager.hasAnimations()?_e.enableBroadcast||0!=T.turnoffAnimation||T.startAnimationByUUID(I.animationUUID,!0):T.toggleAutoRotation(!0),_e.enableBroadcast)&&(T.render(),_e.broadcastMajor)&&document.addEventListener("mousemove",T.broadcastManager.onBroadcastMouseMove,!1),s&&s(T.meshLoadedUUIDs),T.useTransparentList&&T.transparentList){for(var n=[],i=0;i<T.transparentList.length;++i){var r=(r=T.ndsModel.meshManager.bodyUuids[T.transparentList[i]])||T.ndsModel.objectidTouuid[T.transparentList[i]];T.ndsModel.bodyUuid2NodeMap[r]&&n.push(T.ndsModel.bodyUuid2NodeMap[r])}8===O?(T.ndsModel.isolateBodiesOnly([T.ndsModel.rootBodyNode]),T.ndsModel.transparentModeBodiesMap.clear(),T.ndsModel.transparentizeBodiesOnly(n),T.ndsModel.transparentModeBodiesMap.clear()):0<n.length&&T.ndsModel.transparentizeBodies(n)}}},"js"===n||null==n?Array.isArray(a)?(Te.getExtension("RefModelModeExtension")&&Te.getExtension("RefModelModeExtension").unload(T),(u=new NDSModelParser(S,T)).load(I,a,e,t,re,oe,ae,void 0,se)):_e.ScenarioEditor?(i=Se.extractUrlBase(a)+"sceneInfo.js",(r=new oi).setCrossOrigin(this.crossOrigin),r.load(T.gobalReqHeader,i,function(t){try{if(T.sceneInfo=JSON.parse(t),T.sceneInfo.status||-1!=_e.ScenarioEditorid&&T.sceneInfo.WasmMerge||!T.sceneInfo.folderArray)T.sceneInfo=null;else{var e,n,i;if(-1!=_e.ScenarioEditorid)return e=document.createElement("div"),Se.isMobileDevice()&&(n=T.renderer.getSize().height/2-21+"px",e.style.top=n),e.className="app-alert",T.container.appendChild(e),e.style.color="#f76700",e.style.backgroundColor="#ffdcc3",i="en"==Se.getLanguage(),e.innerHTML=i?"Entity already exist please<br/>modify the model and try again":"当前模型暂不支持插入",e.style.height="84px",e.style.display="block",Se.isMobileDevice()||(e.innerHTML=i?"Entity already exist please modify the model and try again":"当前模型暂不支持插入",e.style.height="42px"),setTimeout(function(){T.container.removeChild(e)},3e3),T.dispatchEvent({type:"loadBegin"}),T.dispatchEvent({type:"BrepInfoEvent",faceArea:!1,bodyVolume:!1,totalVolume:!1,bodyArea:!1,totalArea:!1,boundingbox:!1,facePerimeter:!1}),T.dispatchEvent({type:"BVHInfoEvent",hasbvh:!1}),T.dispatchEvent({type:"PMIInfoEvent",PMI:!1}),T.dispatchAsyncEvent({type:"geometryAllLoadedEvent",modelLoadedTime:-1,wholeModelLoadedTime:-1,modelInfo:{}}),T.dispatchEvent({type:"insertfailed",ModelLength:T.ndsModel.models.length}),F=!0,void(T.sceneInfo=null);T.sceneInfo.setScene=!0,T.sceneInfo.ScenarioEditorid=_e.ScenarioEditorid}if(T.sceneInfo)for(var r=0;r<T.sceneInfo.folderArray.length;r++)if(0<T.sceneInfo.folderArray[r]){_e.ScenarioEditorid=r-1;break}var o=new zt(T,a,{nodeRequestor:T.modelRequestor,keepSourceFile:!!_e.ScenarioEditor});T.ndsModel.addModel(o),T.run()}catch(e){t=new zt(T,a,{nodeRequestor:T.modelRequestor,keepSourceFile:!!_e.ScenarioEditor});T.ndsModel.addModel(t),T.run()}},void 0,function(e){var t=new zt(T,a,{nodeRequestor:T.modelRequestor,keepSourceFile:!!_e.ScenarioEditor});T.ndsModel.addModel(t),T.run()})):(l=new zt(T,a,{nodeRequestor:T.modelRequestor,keepSourceFile:!!_e.ScenarioEditor}),T.ndsModel.addModel(l),T.run()):"obj"===n?(u=new en(S),d=a.lastIndexOf("|"),h=c=null,0<d?(c=a.substr(0,d),h=a.substr(d+1,a.length)):c=a,S.itemStart(),u.load(c,h,function(e){T.clearScene(T.scene),T.scene.add(e),T.modelRootObject=e,T.addLights(T.scene),S.itemEnd()},function(){},function(){S.itemEnd()})):"obj_json"===n?(u=new THREE.JSONLoader(S),S.itemStart(),u.load(a,function(e,t){e=new THREE.Mesh(e,new THREE.MeshFaceMaterial(t));T.clearScene(T.scene),T.scene.add(e),T.modelRootObject=e,T.addLights(T.scene),S.itemEnd()})):"zip"!==n&&"js_zip"!==n||(p=new zt(T,a,{nodeRequestor:T.modelRequestor,keepSourceFile:!1,type:n}),T.ndsModel.addModel(p),T.run())}catch(e){T.showWaiterCoverStater(!1),T.dispatchAsyncEvent({type:"loadError",errorInfo:"load3d error"})}},f.getSceneInfoMaterialUtils=function(){return hr},f.run=function(e,t){_e.isVRmodel||_e.isARmodel&&_e.supportAR||(n=requestAnimationFrame(T.run),T.cacheAnimationFrameRequestId(n));var n=Date.now()-ve.StartRenderTime;T.renderNew(e,!!(_e.isVRmodel||_e.isARmodel&&_e.supportAR)||n<15e3),T.isRunning=!0},f.resetForReload=function(){if(T.clearScene(T.scene),0<T.requestAnimationFrameId.length)for(var e=0;e<T.requestAnimationFrameId.length;++e)cancelAnimationFrame(T.requestAnimationFrameId[e]);T.requestAnimationFrameId=[],T.ndsModel=null,T.modelRootObject=null,T.GeomEmpty=!1,T.modelInfo.length=0,_e.ScenarioEditorid=-1,T.camera.setOrginalCameraInfo(void 0),T.originalMeshes.length=0,T.brepManager=null,T.pmiObject=null,T.ndsModelObjectTreeLoaded=!1,T.additionalObjectsScene.children.length=0,T.selectionManager.clearSelection(),T.controls.staticAnnotation&&(T.controls.staticAnnotation.release(),T.controls.staticAnnotation=null),T.annotationsManager&&(T.annotationsManager.removeAllAnnotations(),T.annotationsManager=void 0),T.ndsModelPMILoaded=!1,T.ndsModelBvhLoaded=!1,F=!1;var t=_e.enableSelect;T.onSectionView(!1),T.onBoxSectionView(!1),_e.enableSelect=t,T.bDefaultOpRotate?T.setOperatorByID("OpOrbit"):T.setOperatorByID("OpPan"),T.controls.update(),T.modelRequestor&&T.modelRequestor.initRequest(),T.render(),T.loaderror=!1,T._loaded=!1},f.cacheAnimationFrameRequestId=function(e){100<T.requestAnimationFrameId.length&&(T.requestAnimationFrameId=[]),T.requestAnimationFrameId.push(e)},f.clearScene=function(e){for(var t=0;t<e.children.length;t++)"lightctrls"===e.children[t].name||e.children[t]instanceof THREE.Light||(e.remove(e.children[t]),t--);T.controls.update(),T.render()},f.showLineObjects=function(e,t){for(var n=e.children,i=0;i<n.length;i++)n[i]instanceof THREE.Line||n[i]instanceof THREE.LineSegments?(!T.materialsSetting||T.materialsSetting&&T.materialsSetting.getMaterialsMarkersMat()!=n[i].material)&&(n[i].visible=t,null!=n[i].tangentEdgeObject)&&0==_e.tangentEdgeVisible&&(n[i].visible=!1):0<n[i].children.length&&"lightctrls"!=n[i].name&&this.showLineObjects(n[i],t)},f.renderHiddenLinesVisible=function(){T.modelRootObject&&(T.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments)&&void 0!==e.material.oldOpacity&&(e.material.opacity=e.material.oldOpacity,e.material.depthFunc=e.material.oldDepthFunc,e.material.transparent=e.material.oldTransparent,e.material.needsUpdate=!0)}),T.renderer.render(T.scene,T.camera),T.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments)&&(void 0===e.material.oldOpacity&&(e.material.oldOpacity=e.material.opacity,e.material.oldDepthFunc=e.material.depthFunc,e.material.oldTransparent=e.material.transparent),e.material.opacity=.2,e.material.depthFunc=THREE.GreaterDepth,e.material.transparent=!0,e.material.needsUpdate=!0)}),T.renderer.render(T.scene,T.camera),T.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments)&&void 0!==e.material.oldOpacity&&(e.material.opacity=e.material.oldOpacity,e.material.depthFunc=e.material.oldDepthFunc,e.material.transparent=e.material.oldTransparent,e.material.needsUpdate=!0)}))},f.getLightControls=function(){return T.lightControls},f.addLights=function(e){var t,n,i;0<T.lights.length||(T.ambientLight,t=new THREE.AmbientLight(16777215,.4),(n=new THREE.HemisphereLight(16777215,5592405,Y)).position.set(0,5,0),(i=new THREE.DirectionalLight(16777215,W)).position.set(1,2,0),i._followCamera=!0,_e.ScenarioEditor||(T.lights.push(t),T.lights.push(n)),T.lights.push(i),T.lightControls=new Pe(this))},f.changeLights=function(e){if(void 0!==e)switch(e){case"0":T.hemiSphereLight.intensity=.12;break;case"1":T.hemiSphereLight.intensity=.28;break;case"2":T.hemiSphereLight.intensity=.58;break;case"3":T.hemiSphereLight.intensity=.8;break;default:T.hemiSphereLight.intensity=.12}},f.showObjectAtObjectLevel=function(e,t){if(T.ndsModel&&e===T.scene&&t)return T.showAllModel();T.ndsModel?t?T.ndsModel.showBody(e):T.ndsModel.hideBody(e):e instanceof THREE.Light||(e.visible=t,T.selectionManager.computeTargetList(T.modelRootObject))},f.showObject=function(e,t,n,i){if(void 0===i&&(i=!0),T.ndsModel&&e===T.scene&&t)return T.showAllModel();if(T.ndsModel)e=this.getObjectByUUID(e.uuid),t?T.ndsModel.showBody(e):(T.ndsModel.hideBody(e),i&&T.selectionManager.deselectObject(e,n)),T.groundShadowChange();else{if(e instanceof THREE.Light)return;t&&(e.visible=t);var r=e.children;if(null==r||r.length<=0||e instanceof THREE.SkinnedMesh)return void(e instanceof THREE.Line||e instanceof THREE.LineSegments?T.bLinesVisibility&&(!T.materialsSetting||T.materialsSetting&&T.materialsSetting.getMaterialsMarkersMat()!=e.material)&&(e.visible=t,null!=e.tangentEdgeObject)&&0==_e.tangentEdgeVisible&&(e.visible=!1):e.visible=t);for(var o=0,a=r.length;o<a;++o)T.showObject(r[o],t)}T.startMove(),T.drawTraceUpdate()},f.showObjectList=function(e,t){if(T.showObject(T.scene,!t),e&&0<e.length)for(var n=0;n<e.length;++n){var i=T.ndsModel.getBodyNodeFromUuid(e[n]);T.showObject(i,t)}T.zoomExtents()},f.showObjectReversed=function(e){if(T.ndsModel&&e===T.scene)return T.ndsModel.reverseBodyVisibility();if(T.ndsModel)T.ndsModel.showBodyReversed(e);else if(!(e instanceof THREE.Light||"lightctrls"==e.name)){var t=e.children;if(null==t||t.length<=0||e instanceof THREE.SkinnedMesh)e instanceof THREE.Line||e instanceof THREE.LineSegments?T.bLinesVisibility&&(!T.materialsSetting||T.materialsSetting&&T.materialsSetting.getMaterialsMarkersMat()!=e.material)&&(e.visible=!e.visible,null!=e.tangentEdgeObject)&&0==_e.tangentEdgeVisible&&(e.visible=!1):e.visible=!e.visible;else for(var n=0,i=t.length;n<i;++n)T.showObjectReversed(t[n])}},f.fixObjectByUUID=function(e,t){T.ndsModel&&(T.ndsModel.getBodyNodeFromUuid(e).fixed=t)},f.setRefPlaneVisibilityByComponent=function(e,t){T.ndsModel&&(e=T.ndsModel.getBodyNodeFromUuid(e))&&(e.setComponentRefPlaneVisibility(t),T.render())},f.setRefAxisVisibilityByComponent=function(e,t){T.ndsModel&&(e=T.ndsModel.getBodyNodeFromUuid(e))&&(e.setComponentRefAxisVisibility(t),T.render())},f.setCoordinateSysVisibilityByComponent=function(e,t){T.ndsModel&&(e=T.ndsModel.getBodyNodeFromUuid(e))&&(e.setComponentCoordinateSysVisibility(t),T.render())},f.setBodyVisibilityByComponent=function(e,t){T.ndsModel&&(e=T.ndsModel.getBodyNodeFromUuid(e))&&(e.setComponentBodyVisibility(t),T.render())},f.setObjectOpacity=function(e,t){if(T.ndsModel)t<.98?T.ndsModel.transparentBody(e,t):T.ndsModel.opaqueBody(e);else if(!(e instanceof THREE.Light)){var n=e.children;if((null==n||n.length<=0)&&e.material)e.material.opacity=t,e.material.transparent=1!=e.material.opacity;else for(var i=0,r=n.length;i<r;++i)T.setObjectOpacity(n[i],t)}},f.setObjectOpacityOnly=function(e,t,n){var i,r=this;void 0===n&&(n=!1),Number.isNaN(t)||Array.isArray(e)&&e.length&&(e.forEach(function(e){r.ndsModel.changeBodyOpactiy(e,t)}),n||(i=[],e.map(function(e){e=r.ndsModel.getLeafBodies(e);i.push.apply(i,e)}),this.dispatchEvent({type:"opacityChange",objects:i})),this.render())},f.getObjectOpacityOnly=function(e){var t,i,n,r,o,a;return e instanceof Ae?(t=e.getUserMaterial())?t.opacities?(i=!0,r=t.opacities.map(function(e,t,n){return i&&n[0].value!=e.value&&(i=!1),e.value}),i?r.slice(0,1):r):[t.opacity]:e&&e.leafBodyAttri?(n=[],r=e.leafBodyAttri.bodyMeshIds,o=!0,a=null,r.forEach(function(e,t){e=T.ndsModel.meshManager.materialId[e],e=T.ndsModel.meshManager.mats[e];e&&(n.push(e.opacity),0==t&&(a=e.opacity),o)&&a!=e.opacity&&(o=!1)}),o?n.slice(0,1):n):null:null},f.transparentRenderMode=function(e){if(1==e){var t=T.ndsModel.getTransparentizedBodies().slice();T.ndsModel.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.transparentizeBodiesOnly([e.rootBodyNode])}),T.render(),T.ndsModel.transparentModeBodiesMap.clear();for(var n=0;n<t.length;n++)T.ndsModel.transparentModeBodiesMap.set(t[n].uuid,!1)}else if(0==e){var i=new Map;T.ndsModel.transparentModeBodiesMap.forEach(function(e,t){i.set(t,e)}),T.ndsModel.models.forEach(function(e){if(e.sketchFileUrl)return!0;e.transparentizeBodiesOnly([e.rootBodyNode])}),T.render(),T.ndsModel.transparentModeBodiesMap=i}else if(-1==e){var r=T.ndsModel.getTransparentizedBodies();if(r){for(var o=[],a=0;a<r.length;a++)T.ndsModel.transparentModeBodiesMap.has(r[a].uuid)||o.push(r[a]);T.ndsModel.isolateBodiesOnly(o),T.ndsModel.transparentModeBodiesMap.clear(),T.render()}}},f.setObjectOpacityIsolate=function(e,t,n){if(!(e instanceof THREE.Light||"lightctrls"==e.name)){var i=e.children;if((null==i||i.length<=0||e instanceof THREE.SkinnedMesh)&&e.material)return ie(e,n)?void 0:(e.material.opacity=t,e.material.transparent=1!=e.material.opacity,void(e.material.needsUpdate=!0));for(var r=0,o=i.length;r<o;++r)T.setObjectOpacityIsolate(i[r],t,n)}},f.changeObjectColor=function(e,t,n){var i;void 0===t&&(t=null),void 0===n&&(n=!1),T.ndsModel&&(i=T.ndsModel.getBodyNodeFromUuid(e))&&(T.ndsModel.changeBodyColor(i,t,!1),this.exchangeNodeColor.push({objectUUID:e,color:t}),n||this.dispatchEvent({type:"colorChange",object:i})),T.render()},f.getObjectColor=function(e){if(T.ndsModel){e=T.ndsModel.getBodyNodeFromUuid(e);if(e&&e.getUserMaterial()){e=e.getUserMaterial().color.getHex();if(e)return e}}return null},f.getObjectColorHexString=function(e){if(T.ndsModel){var i,n,t,r,o,e=T.ndsModel.getBodyNodeFromUuid(e),a=e.getUserMaterial();if(e&&a)return i=!0,a.colors?(t=a.colors.map(function(e,t,n){return i&&!n[0].value.equals(e.value)&&(i=!1),e.value.getHexString()}),i?t.slice(0,1):t):[a.color.getHexString()];if(e&&e.leafBodyAttri)return n=[],t=e.leafBodyAttri.bodyMeshIds,r=!0,o=null,t.forEach(function(e,t){var e=T.ndsModel.meshManager.materialId[e],e=T.ndsModel.meshManager.mats[e];e&&(e=e.color.getHexString(),n.push(e),0==t&&(o=e),r)&&o!=e&&(r=!1)}),r?n.slice(0,1):n}return null},f.getObjectColorRGB=function(e){if(T.ndsModel){var t,e=T.ndsModel.getBodyNodeFromUuid(e),n=e.getUserMaterial();if(e&&n)return n.colors?n.colors.map(function(e){return e.value}):n.color;if(e&&e.leafBodyAttri)return n=e.leafBodyAttri.bodyMeshIds,t=[],n.forEach(function(e){var e=T.ndsModel.meshManager.materialId[e],e=T.ndsModel.meshManager.mats[e];e&&(e=e.color,t.push(e))}),t}return null},f.autoChangeObjectColor=function(e,t){var n=t?!1:!0;if(T.ndsModel)for(var i=0;i<T.ndsModel.models.length;i++){T.ndsModel.setActiveModel(i);var r=T.ndsModel.rootBodyNode;e?(n&&(t=T.materialsSetting.randColor()),T.oneKeyColor.isActive=!0,T.oneKeyColor.color=t,T.ndsModel.changeBodyColor(r,t,!0)):(this.exchangeNodeColor=[],T.oneKeyColor.isActive=!1,T.ndsModel.changeBodyColor(r,!1,!1))}var o=setInterval(function(){T.render()},100);return setTimeout(function(){clearInterval(o)},1e3),T.render(),t},f.getBodyNodeFromUuid=function(e){return T.ndsModel.getBodyNodeFromUuid(e)},f.recordOriginalMeshes=function(){T.originalMeshes.length=0,function e(t,n){if(t instanceof THREE.Light||"lightctrls"==t.name)return;var i=t.children;if((null==i||i.length<=0||t instanceof THREE.SkinnedMesh)&&t.material)return void n.push(new Se.map(t,{opacity:t.material.opacity,transparent:t.material.transparent,oriMat:t.material}));for(var r=0,o=i.length;r<o;++r)e(i[r],n)}(T.scene,T.originalMeshes)},f.restoreOriginalMeshes1=function(){for(var e=0,t=T.originalMeshes.length;e<t;++e){var n=T.originalMeshes[e].key,i=T.originalMeshes[e].value;n.material!=_e.selectedMaterial&&(n.material.opacity=i.opacity,n.material.transparent=i.transparent)}},f.restoreOriginalMeshes=function(){for(var e=0,t=T.originalMeshes.length;e<t;++e){var n=T.originalMeshes[e].key,i=T.originalMeshes[e].value;n.material!=_e.selectedMaterial&&(n.material=i.oriMat,n.material.opacity=i.opacity,n.material.transparent=i.transparent)}},f.restoreObjectOpacity=function(e){var t=function(e,t){for(var n=0,i=t.length;n<i;++n)if(e==t[n].key)return t[n].value}(e,T.originalMeshes);t&&(e.material.opacity=t.opacity,e.material.transparent=t.transparent)},f.isLeaf=function(e){var t=e.children.length;if(t<=0)return!0;var n=!1;if(T.ndsModel){for(var i=0;i<t;i++)if("mesh"==(r=e.children[i]).type.toLowerCase()||"line"==r.type.toLowerCase()||"linepieces"==r.type.toLowerCase())return!0}else for(var r,i=0;i<t;i++)if((r=e.children[i])instanceof THREE.Mesh||r instanceof THREE.Line||r instanceof THREE.LineSegments||r instanceof THREE.SkinnedMesh){n=!0;break}return n},f.getAllLoadModel=function(){var t=[];return T.ndsModel.models.forEach(function(e){t.push(e)}),t},f.groundShadowChange=function(){var e,t;T.groundShadow&&D&&(T.groundShadow.clear(),e=new THREE.Vector3,t=new THREE.Vector3,T.computeBoundingBox(T.scene,e,t,{flag:!0}),T.groundShadow.updateGroundTransform(T.camera,new THREE.Box3(e,t),T.camera.worldup)),setTimeout(function(){T.render()},50)},f.unloadModel=function(e,t){if(void 0===t&&(t=!1),0==e&&!t&&T.loadrelease)for(var n=T.loadreleasecount-1;-1<n;n--)T.unloadModel(n,!0);else{if(!t&&0!=e&&T.loadrelease&&(e+=this.loadreleasecount-1),0==e)for(var i in T.zip.files)if(1==T.zip.files[i].dir){T.firstfolder=T.zip.folder(i);break}for(var r,o=-1,a=-1,s=0;s<T.ScenarioEditorInfo.folderArray.length;s++)if(-1!=T.ScenarioEditorInfo.folderArray[s]&&o++,o==e){T.ScenarioEditorInfo.folderArray[s]=-1,a=s;break}T.zip.remove(a.toString()),T.selectionManager.clearSelection(),T.ndsModel.unloadModel(e),0<T.ndsModel.models.length&&(t=new THREE.Vector3,r=new THREE.Vector3,T.computeBoundingBox(T.scene,t,r,{flag:!0}),T.controls.setBoundingBox(t,r),T.switchRotateCenterBySelection(),T.controls.SetBoundingBoxUpdated(!1)),T.startMove(),T.groundShadowChange(),T.render()}},f.getModelCount=function(){return T.ndsModel.models.length},f.getModelTree=function(e,t,n){if(void 0===n&&(n=!1),T.ndsModel.newrootBodyNode)return T.ndsModel.newrootBodyNode;var i,r,o=null;if(-1!=(t=void 0===t?-1:t))return this.loadrelease&&-1!=t&&0==n&&(t+=this.loadreleasecount-1),T.ndsModel&&(T.ndsModel instanceof Xt&&T.ndsModel.setActiveModel(t),o=T.ndsModel.rootBodyNode.clone()),o?(i=function e(t,n){if((T.bodyUuid2ClonedNodeMap[t.uuid]=t).fullpath=""!=n?n+"/"+t.name:t.name,0<t.children.length)for(var i=0;i<t.children.length;++i)"PMI"==t.children[i].type||"views"==t.children[i].type||"captures"==t.children[i].type?(t.remove(t.children[i]),i--):e(t.children[i],t.fullpath)},n=function e(t){var n;return 1<t.children.length||1!=t.children.length||null!=t.type&&("model"==t.type.toLowerCase()||"part"==t.type.toLowerCase()||"assembly"==t.type.toLowerCase())||(n=t.children[0])instanceof THREE.Mesh||n instanceof THREE.Line||n instanceof THREE.LineSegments||n instanceof THREE.SkinnedMesh?(i(t,""),t):null==n.type||"model"!=n.type.toLowerCase()&&"object3d"!=n.type.toLowerCase()?e(t.children[0]):(i(n,""),n)},t=function e(t){if(!0===t.unload)return null;if(t.children.length)for(var n=t.children.length-1;0<=n;n--)!0===t.children[n].unload?t.children.splice(n,1):e(t.children[n]);return t},e?(r=n(o),T.ndsModel.newrootBodyNode=t(r)):T.ndsModel.newrootBodyNode=n(o),T.ndsModel.newrootBodyNode):void 0;if(!this.loadrelease||this.loadMergeRelease)return this.getModelTree(e,0);var a=new Ae;a.uuid=function(){for(var e=[],t="0123456789abcdef",n=0;n<36;n++){var i=Math.floor(16*Math.random());e[n]=t.substring(i,i+1)}e[14]="4";var r=3&e[19]|8;return e[19]=t.substring(r,1+r),e[8]=e[13]=e[18]=e[23]="-",e.join("")}();for(var s=0;s<T.ndsModel.models.length;s++){var l=this.getModelTree(e,s,!0);0==s&&(T.rootBodyNodeName?a.name=T.rootBodyNodeName:a.name=l.name+".asm",this.ndsModel.models[0].bodyUuid2NodeMap[a.uuid]=a),(l.parent=a).children.push(l)}return a.type="parentNode",a},f.getModelTotalTree=function(){if(T.ndsModel.newrootBodyNode)return T.ndsModel.newrootBodyNode;this.PMINDSBodys=[];var e=new THREE.Vector3,t=new THREE.Vector3,E=(T.computeBoundingBox(T.scene,e,t,{flag:!0}),new THREE.Box3),M=(E.expandByPoint(t),E.expandByPoint(e),new THREE.Plane),w=new THREE.Matrix4,n={};if(T.pmiObject&&1!=T.pmiObject.children[0].version){if(n=this.getModelTree(!0)){!function e(t){if(t.pmiuuid&&0<t.pmiuuid.length){var n,i,r=new Ae;r.name="PMI",r.type="PMI",(r.parent=t).children.unshift(r),t.worldMatrix=T.ndsModel.calculateNodeWorldMatrix(t),w.extractRotation(t.worldMatrix),T.PMINDSBodys.push(r);for(var o=0;o<t.pmiuuid.length;++o){var a,s=t.pmiuuid[o];(a=T.PMIUUIDtoPMIObject[s])&&((s=new Ae).parent=r,s.uuid=a.uuid,s.name=a.name,s.type=a.type,a.NdsBodyNode=s,r.children.push(s),T.PMINDSBodys.push(s))}if(a&&a.parent&&a.parent.views){(n=new Ae).name=Se.translateString("PMI_VIEW"),n.type="views",n.parent=t;for(var l=0;l<a.parent.views.length;l++){var d=a.parent.views[l],c=new Ae,h=(c.parent=n,c.name=d.name,c.type="view",c.matrix=d.matrix,c.pmiuuids=d.pmiuuid,null),u=(d.clip&&(h=new THREE.Vector3(d.clipPlane[3],d.clipPlane[4],d.clipPlane[5]).applyMatrix4(w)),new THREE.Vector3(d.matrix[0],d.matrix[1],d.matrix[2]).applyMatrix4(w)),p=new THREE.Vector3(d.matrix[4],d.matrix[5],d.matrix[6]).applyMatrix4(w),f=new THREE.Vector3(d.matrix[8],d.matrix[9],d.matrix[10]).applyMatrix4(w),m=new THREE.Vector3(d.matrix[12],d.matrix[13],d.matrix[14]).applyMatrix4(t.worldMatrix);d.matrix[0]=u.x,d.matrix[1]=u.y,d.matrix[2]=u.z,d.matrix[4]=p.x,d.matrix[5]=p.y,d.matrix[6]=p.z,d.matrix[8]=f.x,d.matrix[9]=f.y,d.matrix[10]=f.z,d.matrix[12]=m.x,d.matrix[13]=m.y,d.matrix[14]=m.z,d.clip&&h?(1e-8<h.dot(f)&&h.negate(),M.setFromNormalAndCoplanarPoint(h.normalize(),m),M.intersectsBox(E)?c.hasSection=!0:c.hasSection=!1,c.normal=h.clone()):(M.setFromNormalAndCoplanarPoint(f.normalize().negate(),m),M.intersectsBox(E)?c.hasSection=!0:c.hasSection=!1,c.normal=f.clone()),n.children.push(c)}t.children.unshift(n)}if(a&&a.parent&&a.parent.captures){(i=new Ae).name=Se.translateString("PMI_Capture"),i.type="captures",i.parent=t;for(var g=0;g<a.parent.captures.length;g++){var v=a.parent.captures[g],A=new Ae,h=(A.parent=i,A.name=v.name,A.type="capture",A.matrix=v.matrix,A.pmiuuids=v.pmiuuid,null),u=(v.clip&&(h=new THREE.Vector3(v.clipPlane[3],v.clipPlane[4],v.clipPlane[5]).applyMatrix4(w)),new THREE.Vector3(v.matrix[0],v.matrix[1],v.matrix[2]).applyMatrix4(w)),p=new THREE.Vector3(v.matrix[4],v.matrix[5],v.matrix[6]).applyMatrix4(w),f=new THREE.Vector3(v.matrix[8],v.matrix[9],v.matrix[10]).applyMatrix4(w),m=new THREE.Vector3(v.matrix[12],v.matrix[13],v.matrix[14]).applyMatrix4(t.worldMatrix);v.matrix[0]=u.x,v.matrix[1]=u.y,v.matrix[2]=u.z,v.matrix[4]=p.x,v.matrix[5]=p.y,v.matrix[6]=p.z,v.matrix[8]=f.x,v.matrix[9]=f.y,v.matrix[10]=f.z,v.matrix[12]=m.x,v.matrix[13]=m.y,v.matrix[14]=m.z,v.clip&&h?(1e-8<h.dot(f)&&h.negate(),M.setFromNormalAndCoplanarPoint(h.normalize(),m),M.intersectsBox(E)?A.hasSection=!0:A.hasSection=!1,A.normal=h.clone()):(M.setFromNormalAndCoplanarPoint(f.normalize().negate(),m),M.intersectsBox(E)?A.hasSection=!0:A.hasSection=!1,A.normal=f.clone()),i.children.push(A)}t.children.unshift(i)}}for(var y=0;y<t.children.length;y++)e(t.children[y])}(n);for(var i=0;i<n.children.length;i++){var r=n.children[i];if("PMI"==r.type){T.ndsModel.AssemblyPMI=r;break}}T.setPMIObjectVisible(T.pmiObject.children[0],!1),T.ndsModel.AssemblyPMI&&T.setAssemblyPMIVisible2(!0),T.ndsModel.newrootBodyNode=n}}else(n=T.getModelTree(!0))&&(T.ndsModel.newrootBodyNode=n);return n},f.NodeChange=function(e,t){return 0==t?this.getBodyNodeFromUuid(e.uuid):1==t?this.bodyUuid2ClonedNodeMap[e.uuid]:void 0},f.MoveFromTextValue=function(e){"OpBall"==T.controls.getOperator().type&&T.controls.getOperator().MoveFromTextValue(e)},f.MoveFromTextValueByDelta=function(e){"OpBall"==T.controls.getOperator().type&&T.controls.getOperator().MoveFromTextValueByDelta(e)},f.copyMeshes=function(e,t){for(var n=e.length=0,i=t.length;n<i;++n)e.push(new Se.map(t[n].key,t[n].value.clone()))},f.getObjectByUUID=function(e){return T.ndsModel?T.ndsModel.getBodyNodeFromUuid(e):T.modelRootObject.getObjectByProperty("uuid",e)},f.isolateObjectsByUUID=function(e){for(var t=[],n=0;n<e.length;n++){var i=null;(i=T.ndsModel?T.ndsModel.getBodyNodeFromUuid(e[n]):T.modelRootObject.getObjectByProperty("uuid",e[n]))&&t.push(i)}0<t.length&&T.isolateObjects(t)},f.isolateObjects=function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];0==i.children.length&&!i.leafBodyAttri||t.push(i)}if(0!=t.length)if(T.ndsModel)T.ndsModel.inIsolate()&&T.exitIsolate(),T.ndsModel.isolateBodies(t,_e.bodyOpacity,_e.lineOpacity),T.selectionManager.clearSelection(),T.render();else{for(var r=[],o=0,a=t.length;o<a;o++)t[o].traverse(function(e){var t;(null==e.children||e.children.length<=0||e instanceof THREE.SkinnedMesh||e.material)&&(r.push(new Se.map(e,e.material)),t=e.material.clone(),e.material=t)});r.length<=0||(T.copyMeshes(T.isolateMeshes,r),T.selectionManager.clearSelection(),T.setObjectOpacityIsolate(T.modelRootObject,_e.bodyOpacity,T.isolateMeshes),T.render())}},f.getIsolateMeshes=function(){for(var e=[],t=0,n=T.isolateMeshes.length;t<n;t++)e.push(T.isolateMeshes[t].key);return e},f.setShouldApplySelectionMaterialState=function(e){void 0===e&&(e=!0),T.selectionManager&&T.isIn3DViewer()&&(T.selectionManager.shouldApplySelectedMaterial=e)},f.isAllwhiteforline=function(){for(var e in T.ndsModel.meshManager.materials)if(!T.ndsModel.meshManager.materials[e].mat.color.equals(new THREE.Color(1,1,1)))return!1;return!0},f.isolateObject=function(e){e=[e];T.hasObjectIsolated()?(T.dispatchEvent({type:"isolateSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.isolateBodiesOnly(e),T.selectionManager.clearSelection(),T.render())):(T.dispatchEvent({type:"isolateSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.isolateBodies(e,_e.bodyOpacity,_e.lineOpacity),T.selectionManager.clearSelection(),T.render()))},f.isolateSelectedObjects=function(){var e=T.selectionManager.getSelectedObjects();T.hasObjectIsolated()?(T.dispatchEvent({type:"isolateSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.isolateBodiesOnly(e),T.selectionManager.clearSelection(),T.render())):(T.dispatchEvent({type:"isolateSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.isolateBodies(e,_e.bodyOpacity,_e.lineOpacity),T.selectionManager.clearSelection(),T.render()))},f.exitIsolate=function(){if(T.ndsModel){if(!T.ndsModel.inIsolate())return;T.ndsModel.exitIsolate()}else{if(T.isolateMeshes.length<=0)return;T.restoreOriginalMeshes(),T.isolateMeshes.length=0}T.render(),T.dispatchEvent({type:"exitIsolate"})},f.transparentSelectedObjects=function(){T.selectionManager.getSelectedObjects();for(var e,t=[],n=0;n<T.selectionManager.getSelectedObjects().length;n++){var i=T.selectionManager.getSelectedObjects()[n];0==i.children.length&&!i.leafBodyAttri||t.push(i)}0!=t.length&&(e=t,T.ndsModel.inIsolate()?(T.dispatchEvent({type:"transparentSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.transparentizeBodiesOnly(e),T.selectionManager.clearSelection(),T.render())):(T.dispatchEvent({type:"transparentSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.transparentizeBodies(e),T.selectionManager.clearSelection(),T.render())))},f.transparentObject=function(e){e=[e];T.ndsModel.inIsolate()?(T.dispatchEvent({type:"transparentSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.transparentizeBodiesOnly(e),T.selectionManager.clearSelection(),T.render())):(T.dispatchEvent({type:"transparentSelectedObjects",objects:e}),e.length<=0||(T.ndsModel.transparentizeBodies(e),T.selectionManager.clearSelection(),T.render()))},f.transparentOrisolateSelectObjects=function(){var e;!T.ndsModel||(e=T.selectionManager.getSelectedleafObjects()).length<=0||(e[0].isTransparent()?(T.dispatchEvent({type:"isolateSelectedObjects",objects:e}),T.ndsModel.isolateBodiesOnly(e)):(T.dispatchEvent({type:"transparentSelectedObjects",objects:e}),T.ndsModel.transparentizeBodiesOnly(e)),T.selectionManager.clearSelection(),T.render())},f.getSelectedObjectsstatus=function(){if(T.ndsModel){for(var e=T.ndsModel.getSelectedBodies(),t=0,n=0;n<e.length;++n)t+=e[n].isTransparent();return 0==t?{num:e.length,status:"show"}:t==e.length?{num:e.length,status:"transparent"}:{num:e.length,status:"other"}}},f.opaqueSelectedObjects=function(){for(var e=T.selectionManager.getSelectedObjects(),t=0,n=e.length;t<n;++t)T.ndsModel.opaqueBody(e[t])},f.hideSelectedObjects=function(){T.selectionManager.getSelectedObjects();for(var e=[],t=0;t<T.selectionManager.getSelectedObjects().length;t++){var n=T.selectionManager.getSelectedObjects()[t];0==n.children.length&&!n.leafBodyAttri||e.push(n)}if(0!=e.length){for(var i,r=0,o=(i=e).length;r<o;++r)T.ndsModel.hideBody(i[r]),T.modelBrowserDlg&&T.modelBrowserDlg.hideTreeNodeByObject(i[r]);T.selectionManager.clearSelection(),T.render()}},f.showSelectedObjects=function(){T.selectionManager.getSelectedObjects();for(var e=[],t=0;t<T.selectionManager.getSelectedObjects().length;t++){var n=T.selectionManager.getSelectedObjects()[t];0==n.children.length&&!n.leafBodyAttri||e.push(n)}if(0!=e.length){for(var i,r=0,o=(i=e).length;r<o;++r)T.ndsModel.showBody(i[r]);T.render()}},f.hideObject=function(e){for(var t=[e],n=0,i=t.length;n<i;++n)T.ndsModel.hideBody(t[n]),T.selectionManager.deselectObject(t[n]),T.modelBrowserDlg&&T.modelBrowserDlg.hideTreeNodeByObject(t[n]);T.render()},f.hideUnloadbodies=function(e){if(T.ndsModel)if(e.unload)T.ndsModel.hideBody(e);else if(e.children)for(var t=0;t<e.children.length;t++){var n=e.children[t];T.hideUnloadbodies(n)}},f.hideOtherObjects=function(){if(0!=T.selectionManager.getSelectedObjects().length){for(var e=[],t=0;t<T.selectionManager.getSelectedObjects().length;t++){var n=T.selectionManager.getSelectedObjects()[t];0==n.children.length&&!n.leafBodyAttri||e.push(n)}if(0!=e.length){if(T.ndsModel){T.ndsModel.sketchModel&&(T.ndsModel.sketchModel.outCall=!0),T.ndsModel.hideAllBodies();for(var i=T.selectionManager.getSelectedObjects(),r=0,o=i.length;r<o;++r)T.ndsModel.showBody(i[r]),T.hideUnloadbodies(i[r])}T.selectionManager.clearSelection(),T.render()}}},f.hideOtherObjectsfrombody=function(e){if(T.ndsModel){T.ndsModel.hideAllBodies();for(var t=[e],n=0,i=t.length;n<i;++n)T.ndsModel.showBody(t[n]),T.hideUnloadbodies(t[n])}T.render()},f.showAllModel=function(){if(T.exitIsolate(),T.ndsModel)for(var e in T.ndsModel.showAllBodies(),T.ndsModel.bodyUuid2NodeMap)T.ndsModel.bodyUuid2NodeMap[e].unload&&T.ndsModel.hideBody(T.ndsModel.bodyUuid2NodeMap[e]);else T.showObject(T.scene,!0);T.modelBrowserDlg&&T.modelBrowserDlg.showAllTreeNode(),T.render(),T.dispatchEvent({type:"showAllModel"})},f.getSelectedObjectProperty=function(e){var t=T.selectionManager.getSelectedObjects();if(t.length<=0)return null;null==T.propertyManager&&(T.propertyManager=new fi(T));var n=null;if(T.ndsModel){for(var i=[],r=[],o=0;o<t.length;++o){var a=T.ndsModel.getBodyNodeFromUuid(t[o].uuid);r.push(a)}for(var s=0,o=0;o<r.length;++o){if(0<=r[o].id&&!r[o].isHidden())-1==i.indexOf(r[o])&&i.push(r[o]);else for(var l=0,d=r[o].children.length;l<d;++l)r.push(r[o].children[l]);0<r[o].children.length&&"Body"==r[o].children[0].type&&!this.ndsModel.isBodyAllChildHidden(r[o])&&s++}var n={area:0,volume:0,boundingbox:new THREE.Vector3,meshNum:s,bodyNum:0,unit:T.modelUnit,boundingboxVolume:0},c=new THREE.Box3;if(T.brepManager)for(l=0;l<i.length;++l){var h,u=i[l],p=T.brepManager.GetBodyVolumeAndArea(u.uuid),f=T.ndsModel.getBodyBoundingBox(u),m=u.isHidden();p?m||(n.area+=p.area,n.volume+=p.volume,f&&(c.expandByPoint(f.max),c.expandByPoint(f.min))):(p={area:u.area,volume:u.volume},(h=T.getBodyNodeFileUnit(u))&&T.ndsModel.rootBodyNode.fileUnit&&(h=T.getUnitTransfrom(T.ndsModel.rootBodyNode.fileUnit,h),p.area*=h*h,p.volume*=h*h*h),f&&(c.expandByPoint(f.max),c.expandByPoint(f.min)),p&&!m&&(n.area+=p.area,n.volume+=p.volume))}else for(l=0;l<i.length;++l){var p={area:(u=i[l]).area,volume:u.volume},g=T.getBodyNodeFileUnit(u);g&&T.ndsModel.rootBodyNode.fileUnit&&(g=T.getUnitTransfrom(T.ndsModel.rootBodyNode.fileUnit,g),p.area*=g*g,p.volume*=g*g*g);m=((f=this.ndsModel.getBodyBoundingBox(u))&&(c.expandByPoint(f.max),c.expandByPoint(f.min)),u.isHidden());p&&!m&&(n.area+=p.area,n.volume+=p.volume)}n.boundingboxVolume=Math.abs(c.max.x-c.min.x)*Math.abs(c.max.y-c.min.y)*Math.abs(c.max.z-c.min.z),n.boundingbox.x=Math.abs(c.max.x-c.min.x),n.boundingbox.y=Math.abs(c.max.y-c.min.y),n.boundingbox.z=Math.abs(c.max.z-c.min.z);var v=T.getDispalyModelUnit(n.volume,n.area);v&&(n.volume=n.volume*v.scale*v.scale*v.scale,n.area=n.area*v.scale*v.scale,n.boundingbox.x*=v.scale,n.boundingbox.y*=v.scale,n.boundingbox.z*=v.scale,n.boundingboxVolume=n.boundingboxVolume*v.scale*v.scale*v.scale,n.unit=v.unit)}return T.propertyManager.getObjectProperty(t[0],e,n),n},f.getBrepMemory=function(){return(this.productData?this.productData.datas[0]:this).brepMemory},f.getPmiNum=function(){return(this.productData&&this.productData.datas[0].pmiNum?this.productData.datas[0]:this).pmiNum},f.getObjectProperty=function(e,t,n){null==T.propertyManager&&(T.propertyManager=new fi(T)),e=this.getObjectByUUID(e.uuid),n=n||!1;for(var i,r=!1,o=(T.ndsModel.setActiveModel(0),e.uuid!=T.ndsModel.rootBodyNode.uuid||e.RootArea||0!=T.getObjectOrSomeChildVisibleStatus(e)||(r=!0),[]),a=[e],s=0,l=0;l<a.length;++l){if(i=a[l].type.toLowerCase(),a[l].unload||!(0<=a[l].id)||a[l].isReferenceEntity()||a[l].isCoordinate()||a[l].isHidden()&&!r)for(var d=0,c=a[l].children.length;d<c;++d)a.push(a[l].children[d]);else o.push(a[l]);0<a[l].children.length&&"part"==i&&"Body"==a[l].children[0].type&&!this.ndsModel.isBodyAllChildHidden(a[l])&&s++}var h={area:0,volume:0,boundingbox:new THREE.Vector3,meshNum:s,bodyNum:_e.HideLeafBody?s:o.length,unit:T.modelUnit,boundingboxVolume:0},u=new THREE.Box3;if(T.brepManager)for(d=0;d<o.length;++d){var p,f=o[d],m=T.brepManager.GetBodyVolumeAndArea(f.uuid),g=T.ndsModel.getBodyBoundingBox(f),v=f.isHidden();m?f._leafBodyAttri&&(v?r&&(h.area+=m.area,h.volume+=m.volume):(h.area+=m.area,h.volume+=m.volume,g&&!isNaN(g.max.x)&&(u.expandByPoint(g.max),u.expandByPoint(g.min)))):(m={area:(f=o[d]).area,volume:f.volume},(p=T.getBodyNodeFileUnit(f))&&T.ndsModel.rootBodyNode.fileUnit&&(p=T.getUnitTransfrom(T.ndsModel.rootBodyNode.fileUnit,p),m.area*=p*p,m.volume*=p*p*p),!g||isNaN(g.max.x)||v||(u.expandByPoint(g.max),u.expandByPoint(g.min)),!m||v&&!r||(h.area+=m.area,h.volume+=m.volume))}else for(var A=0;A<o.length;++A){var m={area:(f=o[A]).area,volume:f.volume},y=T.getBodyNodeFileUnit(f),g=(y&&T.ndsModel.rootBodyNode.fileUnit&&(y=T.getUnitTransfrom(T.ndsModel.rootBodyNode.fileUnit,y),m.area*=y*y,m.volume*=y*y*y),this.ndsModel.getBodyBoundingBox(f)),v=f.isHidden();!g||isNaN(g.max.x)||v||(u.expandByPoint(g.max),u.expandByPoint(g.min)),!m||v&&!r||(h.area+=m.area,h.volume+=m.volume)}e.uuid!=T.ndsModel.rootBodyNode.uuid&&!n||this.ndsModel.isBodyOrSomeChildHidden(e)?e.uuid!=T.ndsModel.rootBodyNode.uuid&&(h.pmiNum=e.pmiuuid?e.pmiuuid.length:0):(h.pmiNum=this.getPmiNum(),u=this.modelRootObject.boundingBox),0==h.area&&0==h.volume&&0!=e.area&&(h.area=e.area,h.volume=e.volume),r&&0==e.area&&(e.area=h.area,e.volume=h.volume,e.RootArea=!0),h.boundingboxVolume=Math.abs(u.max.x-u.min.x)*Math.abs(u.max.y-u.min.y)*Math.abs(u.max.z-u.min.z),h.boundingbox.x=Math.abs(u.max.x-u.min.x),h.boundingbox.y=Math.abs(u.max.y-u.min.y),h.boundingbox.z=Math.abs(u.max.z-u.min.z);n=T.getDispalyModelUnit(h.volume,h.area);return n&&(h.volume=h.volume*n.scale*n.scale*n.scale,h.area=h.area*n.scale*n.scale,h.boundingbox.x*=n.scale,h.boundingbox.y*=n.scale,h.boundingbox.z*=n.scale,h.boundingboxVolume=h.boundingboxVolume*n.scale*n.scale*n.scale,h.unit=n.unit),T.propertyManager.getObjectProperty(e,t,h),h},f.getfileProperty=function(e,t){var n=!1;for(e.uuid==T.ndsModel.rootBodyNode.uuid&&(n=!0),"Model"!=(e=this.getObjectByUUID(e.uuid)).type||1!=e.children.length||"Part"!=e.children[0].type||null!=e.parent||e.children[0].fileguid||(e=e.children[0]);(null==e.propertyfile||null==e.propertyfile)&&e.parent;)e=e.parent;this.getObjectProperty(e,t,n)},f.getStaticProperty=function(){return{meshNum:le(T.scene).Mesh.count,bodyNum:this.ndsModel.wholeLeafBodyNodes.length,box:this.modelRootObject.boundingBox,pmiNum:this.productData.datas[0].pmiNum}},f.getUnvisibleList=function(e){if(T.ndsModel){for(var t=T.ndsModel.hideBodies,n=[],i=0;i<t.length;++i){var r=t[i];if(r&&!r.unload)for(e?-1==n.indexOf(r.uuid)&&n.push(r.uuid):T.ndsModel.objectidTouuid?-1==n.indexOf(r.objectid)&&n.push(r.objectid):(o=this.ndsModel.meshManager.bodyUuid2IdMap[r.uuid],-1==n.indexOf(o)&&n.push(o));r.parent;){if(e){if(-1!=n.indexOf(r.parent.uuid))break}else if(T.ndsModel.objectidTouuid){if(-1!=n.indexOf(r.parent.objectid))break}else if(null!=(o=this.ndsModel.meshManager.bodyUuid2IdMap[r.parent.uuid])&&-1!=n.indexOf(o))break;if(!T.ndsModel.isBodyAllChildHidden(r.parent))break;e?n.push(r.parent.uuid):T.ndsModel.objectidTouuid?n.push(r.parent.objectid):null!=(o=this.ndsModel.meshManager.bodyUuid2IdMap[r.parent.uuid])&&n.push(o),r=r.parent}}for(var o,t=T.ndsModel.UnloadNodes,i=0;i<t.length;++i)(r=t[i])&&(e?-1==n.indexOf(r.uuid)&&n.push(r.uuid):T.ndsModel.objectidTouuid?-1==n.indexOf(r.objectid)&&n.push(r.objectid):(o=this.ndsModel.meshManager.bodyUuid2IdMap[r.uuid],-1==n.indexOf(o)&&n.push(o)));return n}},f.hasObjectHidden=function(){if(T.ndsModel)return T.ndsModel.hasHiddenBodies},f.hasObjectIsolated=function(){if(T.ndsModel)return 0<T.getTransparentList().length},f.getTransparentList=function(){if(T.ndsModel){for(var e=T.ndsModel.getTransparentizedBodies(),t=[],n=0;n<e.length;++n){var i=e[n];i&&-1!=i.id&&(T.ndsModel.objectidTouuid?t.push(i.objectid):t.push(i.id))}return t}},f.hasObjectHiddenOrIsolated=function(){var e;return T.ndsModel?!(!T.ndsModel.hasHiddenBodies&&!T.hasObjectIsolated()):0<T.isolateMeshes.length||((e=new Object).hidden=!1,0<T.scene.children.length&&function e(t,n){var i=t.children;if(null==i||i.length<=0||t instanceof THREE.SkinnedMesh){if(t instanceof THREE.Line||t instanceof THREE.LineSegments){if(T.bLinesVisibility)if(null!=t.tangentEdgeObject){if(1==_e.tangentEdgeVisible&&0==t.visible)return void(n.hidden=!0)}else if(0==t.visible)return void(n.hidden=!0)}else if(0==t.visible)return void(n.hidden=!0)}else if(0==t.visible)return void(n.hidden=!0);if(i)for(var r=0,o=i.length;r<o;++r){if(n.hidden)return;e(i[r],n)}}(T.scene.children[0],e),!!e.hidden)},f.isAllHidden=function(){var e;return 0<this.scene.children.length&&((e=new Object).visible=!1,function e(t,n){if(0!=t.visible){var i=t.children;if((null==i||i.length<=0||t instanceof THREE.SkinnedMesh)&&t.visible)n.visible=!0;else for(var r=0,o=i.length;r<o;++r){if(n.visible)return;e(i[r],n)}}}(this.scene.children[0],e),!e.visible)},f.isObjectOrSomeChildHidden=function(e){var t=this.getObjectByUUID(e.uuid);if((t=t||e)instanceof Ae&&T.ndsModel)return 0!=t.children.length||t.leafBodyAttri||"Body"==t.type?T.ndsModel.isBodyOrSomeChildHidden(t):!t.visible},f.getSelectedObjectsAllHidden=function(){if(T.ndsModel){for(var e=T.ndsModel.getSelectedBodies(),t=0;t<e.length;++t)if(e[t]&&!e[t].isHidden())return!1;for(t=0;t<e.length;++t)if(e[t]&&!T.ndsModel.isBodyAllChildHidden(e[t]))return!1}return!0},f.getObjectOrSomeChildVisibleStatus=function(e){var t=this.getObjectByUUID(e.uuid);if((t=t||e)instanceof Ae&&T.ndsModel)return 0!=t.children.length||t.leafBodyAttri||"Body"==t.type?T.ndsModel.getBodyOrSomeChildVisibleStatus(t):t.visible?1:0},f.isBodyAllChildTransparent=function(e){if(e instanceof Ae&&T.ndsModel)return T.ndsModel.isBodyAllChildTransparent(e)},f.isEmptyNode=function(e){var t=this.getObjectByUUID(e.uuid);if((t=t||e).isOtherNode()||t.parent&&t.parent.isOtherNode())return!1;if(t instanceof Ae&&T.ndsModel){if("Body"!=t.type||0!=t.children.length||t.leafBodyAttri){if(0<t.children.length){for(var n=0;n<t.children.length;++n){var i=t.children[n];if(!this.isEmptyNode(i))return!1}return!0}return!1}return!0}},f.getModelCenter=function(){var e=new THREE.Vector3,t=new THREE.Vector3,n=(T.computeBoundingBox(T.scene,e,t,{flag:!0}),new THREE.Vector3);return n.x=.5*(t.x+e.x),n.y=.5*(t.y+e.y),n.z=.5*(t.z+e.z),n},f.stopReadingModel=function(e){T.fileUpload&&(T.fileUpload.stopReadingModel(),T.showWaiterCoverStater(!1))},f.setLinesVisibility=function(e,t){T.bLinesVisibility=void 0===e||e,T.showLineObjects(T.modelRootObject,T.bLinesVisibility),!1!==t&&T.render()},f.getLinesVisibility=function(e){return T.bLinesVisibility},f.setZoomSpeed=function(e){T.cameraControl.setZoomSpeed(e)},f.setRotateSpeed=function(e){T.cameraControl.setRotateSpeed(e)},f.getShowToolTipFlag=function(e){return e&&T.bShowToolTip&&(T.isFullScreen()?e.domElement.innerHTML=Se.translateString("IDS_EXITFULLSCREEN"):e.domElement.innerHTML=Se.translateString("IDS_FULLSCREEN")),T.bShowToolTip},f.getToolBarAutoHideFlag=function(){return T.bToolBarAutoHide},f.getMouseWheelForwardEnlargeFlag=function(){return T.bMouseWheelForwardEnlarge},f.isObjectTypeOfElement=function(e){return null!=e&&("element"==(e=e.type.toLowerCase())||"revitelement"==e||"body"==e||"object"==e||"instanceobject"==e||"acdblayertablerecord"==e)},f.traverseBodyForExplosion=function(i,e,t,n,r,o,a,s){if(null!=i&&i instanceof THREE.Object3D&&!(i instanceof THREE.Light||"lightctrls"==i.name))if(e=T.isObjectTypeOfElement(i)?!0:e){var l=void 0,d=void 0,c=new THREE.Vector3;i.traverse(function(e){var t,n;(e instanceof THREE.Mesh||e instanceof THREE.Line)&&e.hasOwnProperty("geometry")&&(null==(t=e.geometry).boundingBox&&t.computeBoundingBox(),n=!1,t instanceof THREE.Geometry?n=null!=t.vertices&&0!=t.vertices.length:t instanceof THREE.BufferGeometry&&(n=null!=t.attributes.position),n)&&(n=t.boundingBox.clone(),e.matrixWorldTransOrginal?(c.setFromMatrixPosition(e.matrixWorld),e.matrixWorld.setPosition(e.matrixWorldTransOrginal),n.applyMatrix4(e.matrixWorld),e.matrixWorld.setPosition(c)):n.applyMatrix4(i.matrixWorld),void 0===l||void 0===d?(l=new THREE.Vector3,d=new THREE.Vector3,l.copy(n.min),d.copy(n.max)):(l.x=Math.min(l.x,n.min.x),l.y=Math.min(l.y,n.min.y),l.z=Math.min(l.z,n.min.z),d.x=Math.max(d.x,n.max.x),d.y=Math.max(d.y,n.max.y),d.z=Math.max(d.z,n.max.z)))}),null!=d&&null!=l&&(c.x=.5*(d.x+l.x),c.y=.5*(d.y+l.y),c.z=.5*(d.z+l.z),o+=(c.x-t.x)*(u=4*r),a+=(c.y-t.y)*u,s+=(c.z-t.z)*u,i.traverse(function(e){var t;e.hasOwnProperty("geometry")&&(void 0===e.matrixWorldTransOrginal&&(e.matrixWorldTransOrginal=new THREE.Vector3,e.matrixWorldTransOrginal.setFromMatrixPosition(e.matrixWorld)),0==r?(c.copy(e.matrixWorldTransOrginal),e.matrixWorldTransOrginalDrag&&c.add(e.matrixWorldTransOrginalDrag),e.matrixWorld.setPosition(c),(e.matrixWorldTransExplode=void 0)===e.matrixWorldTransOrginalDrag&&(e.matrixWorldTransOrginal=void 0)):((t=e.matrixWorldTransOrginal.clone()).x+=o,t.y+=a,t.z+=s,void 0===e.matrixWorldTransExplode&&(e.matrixWorldTransExplode=new THREE.Vector3),e.matrixWorldTransExplode.copy(t),e.matrixWorldTransOrginalDrag&&t.add(e.matrixWorldTransOrginalDrag),e.matrixWorld.setPosition(t)))}))}else{var h,u,p;if(i.hasOwnProperty("geometry")&&(null==(p=i.geometry).boundingBox&&p.computeBoundingBox(),h=!1,p instanceof THREE.Geometry?h=null!=p.vertices&&0!=p.vertices.length:p instanceof THREE.BufferGeometry&&(h=null!=p.attributes.position),h)&&(h=p.boundingBox.clone(),c=new THREE.Vector3,i.matrixWorldTransOrginal?(c.setFromMatrixPosition(i.matrixWorld),i.matrixWorld.setPosition(i.matrixWorldTransOrginal),h.applyMatrix4(i.matrixWorld),i.matrixWorld.setPosition(c)):h.applyMatrix4(i.matrixWorld),c.x=.5*(h.max.x+h.min.x),c.y=.5*(h.max.y+h.min.y),c.z=.5*(h.max.z+h.min.z),o+=(c.x-t.x)*(u=4*r),a+=(c.y-t.y)*u,s+=(c.z-t.z)*u,void 0===i.matrixWorldTransOrginal&&(i.matrixWorldTransOrginal=new THREE.Vector3,i.matrixWorldTransOrginal.setFromMatrixPosition(i.matrixWorld)),0==r?(c.copy(i.matrixWorldTransOrginal),i.matrixWorldTransOrginalDrag&&c.add(i.matrixWorldTransOrginalDrag),i.matrixWorld.setPosition(c),(i.matrixWorldTransExplode=void 0)===i.matrixWorldTransOrginalDrag&&(i.matrixWorldTransOrginal=void 0)):((p=i.matrixWorldTransOrginal.clone()).x+=o,p.y+=a,p.z+=s,void 0===i.matrixWorldTransExplode&&(i.matrixWorldTransExplode=new THREE.Vector3),i.matrixWorldTransExplode.copy(p),i.matrixWorldTransOrginalDrag&&p.add(i.matrixWorldTransOrginalDrag),i.matrixWorld.setPosition(p))),null!=i.children)for(var f=i.children,m=0;m<f.length;++m)T.traverseBodyForExplosion(i.children[m],e,t,n+1,r,o,a,s)}},f.explodeModel=function(){var a=this,s=new THREE.Vector3;return function(e,t){var n,i,r,o=Date.now();e!=H&&(T.toggleAutoRotation(!1),s=T.controls.getBoundingBox().getCenter(s),T.ndsModel?T.ndsModel.setExplodeFactor(s,4*e):a.traverseBodyForExplosion(T.modelRootObject,!1,s,0,e,0,0,0),0==(H=e)?(T.controls.resetExplosionBoundingBox(),n={flag:!0},i=new THREE.Vector3,r=new THREE.Vector3,T.computeBoundingBox(T.scene,i,r,n),T.groundShadow.updateGroundTransform(T.camera,T.controls.getBoundingBox(),T.camera.worldup),T.camera.setOrthoNear(T.controls.getBoundingBox())):(n={flag:!0},i=new THREE.Vector3,r=new THREE.Vector3,T.computeBoundingBox(T.scene,i,r,n),T.controls.setExplosionBoundingBox(i,r),T.groundShadow.updateGroundTransform(T.camera,T.controls.getExplosionBoundingBox(),T.camera.worldup),T.camera.setOrthoNear(T.controls.getExplosionBoundingBox())),0!=t&&T.render(),T.dispatchEvent({type:"explodingModel"}),T.logOperatorTime)&&T.logOperatorTimeShow("[爆炸-缩放]",o)}}(),f.setExplodeMode=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=!1);var i=Date.now(),r=(0==(e&ve.EXPLODEMODE.NORMAL)&&0==(e&ve.EXPLODEMODE.X)&&0==(e&ve.EXPLODEMODE.Y)&&0==(e&ve.EXPLODEMODE.Z)&&(e+=ve.EXPLODEMODE.NORMAL),this.isExploded()&&this.onExplode(0),this.ndsModel.explodeMode=e,this.ndsModel.explodeLevel=t,[]),o=(T.ndsModel.models.forEach(function(e){if(e.sketchFileUrl)return!0;r.push(e.rootBodyNode)}),[]);if(e&ve.EXPLODEMODE.LEVEL){for(var a=0;a<r.length;++a){var s=r[a].getLevel();if(s==t)o.push(r[a]);else if(s<t&&0==r[a].children.length&&0<=r[a].id&&!r[a].isReferenceEntity())o.push(r[a]);else if(s<t&&0<r[a].children.length)for(var l=0,d=r[a].children.length;l<d;++l)r.push(r[a].children[l])}for(var c=this.controls.getBoundingBox().getCenter(),a=(new THREE.Box3,0);a<o.length;++a){var h=o[a],u=this.ndsModel.getBodyBoundingBox(h),p=this.ndsModel.getLeafBodies(h);if(u)for(var f=0,m=p.length;f<m;f++)p[f].leafBodyAttri&&(p[f].leafBodyAttri.bodyTranslate[0]=.5*(u.min.x+u.max.x)-c.x,p[f].leafBodyAttri.bodyTranslate[1]=.5*(u.min.y+u.max.y)-c.y,p[f].leafBodyAttri.bodyTranslate[2]=.5*(u.min.z+u.max.z)-c.z)}for(var a=0,g=this.ndsModel.geomManager.geoms.length;a<g;++a)this.ndsModel.geomManager.geoms[a].updateModelMatrix=!0}e&ve.EXPLODEMODE.NORMAL&&(this.ndsModel.explodeMode&=~ve.EXPLODEMODE.X,this.ndsModel.explodeMode&=~ve.EXPLODEMODE.Y,this.ndsModel.explodeMode&=~ve.EXPLODEMODE.Z,this.ndsModel.explodeObject)&&this.ndsModel.explodeObject.detach(),e&ve.EXPLODEMODE.SELECTED?(de(n),this.addEventListener("selectObject",de)):(this.explodeObjects=[],this.removeEventListener("selectObject",de)),(e&ve.EXPLODEMODE.X||e&ve.EXPLODEMODE.Y||e&ve.EXPLODEMODE.Z)&&(this.ndsModel.explodeObject?(this.ndsModel.explodeObject.attach(this.ndsModel.rootBodyNode),this.ndsModel.explodeObject.visible=!1,this.ndsModel.explodeObject.name="explodeObject"):(n=null,n=this.canvas2D||this.canvas3D,(e=new Ne(this.camera,n)).name="explodeObject",e.attach(this.ndsModel.rootBodyNode),this.ndsModel.explodeObject=e,this.scene.add(e),this.ndsModel.explodeObject.visible=!1)),this.render(),this.logOperatorTime&&this.logOperatorTimeShow("[爆炸-设置]",i)},f.setExplodeAxisVisible=function(e,t){t&&(t=t.toUpperCase(),this.explodeAxis=t),this.ndsModel.explodeObject&&(this.ndsModel.explodeObject.visible=!0,this.ndsModel.explodeObject.axisVisible(e,t)),this.render()},f.selectExplodeEvent=function(e){0!=(this.ndsModel.explodeMode&ve.EXPLODEMODE.SELECTED)&&(e?this.addEventListener("selectObject",de):this.removeEventListener("selectObject",de))},f.isExploded=function(){return 1e-6<H},f.isFullScreen=function(){return!!(document.fullscreenEnabled||document.mozFullScreenElement||document.webkitIsFullScreen||document.msFullscreenElement)},f.executeFullScreen=function(){var e,t;T.isFullScreen()?document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen():(e=n).requestFullscreen?e.requestFullscreen(t):e.mozRequestFullScreen?e.mozRequestFullScreen(t):e.webkitRequestFullscreen?e.webkitRequestFullscreen(t):e.msRequestFullscreen&&e.msRequestFullscreen(t)},f.startSmoothTranslation=function(e,t){this.cameraControl.startSmoothTranslation(e,t)},f.isSmoothTranslationDone=function(){return this.cameraControl.isSmoothTranslationDone()},f.smoothTranslation=function(e,t){this.cameraControl.smoothTranslation(e,t)},f.updateBackGroudImageRatio=function(e){var t,n,i,r,o,a;null!=e&&null!=e.map&&(e.map.imageOriginal instanceof HTMLImageElement||e.map.imageOriginal instanceof HTMLCanvasElement)&&(i=+T.renderer.domElement.width/T.renderer.domElement.height,a=+(t=e.map.imageOriginal.width)/(n=e.map.imageOriginal.height),r=t,o=n,.25<Math.abs(a-i)&&(i<a?(o=n,r=Math.floor(i*o)):(r=t,o=Math.floor(r/i))),t<r&&(r=t),n<o&&(o=n),10<Math.abs(r-e.map.image.width)||10<Math.abs(o-e.map.image.height))&&((a=document.createElement("canvas")).width=r,a.height=o,a.getContext("2d").drawImage(e.map.imageOriginal,Math.floor(.5*(t-r)),Math.floor(.5*(n-o)),r,o,0,0,a.width,a.height),e.map.image=a,e.map.needsUpdate=!0)},f.setBackGroundImage=function(e,t,n,i){if(void 0===i&&(i=-1),this.backGroundImage=e,this.backGroundImageindex=i,e){if(this.setEnvMapTextures(null),this.backGroundScene||(this.backGroundScene=new THREE.Scene,this.backGroundScene.matrixWorldAutoUpdate=!1,this.backGroundCamera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),this.backGroundMesh=new THREE.Mesh(new THREE.PlaneGeometry(2,2),new THREE.MeshBasicMaterial),this.backGroundMesh.material.depthTest=!1,this.backGroundMesh.material.depthWrite=!1,this.backGroundScene.add(this.backGroundCamera),this.backGroundScene.add(this.backGroundMesh),this.backGroundScene.updateMatrixWorld(!0)),t&&t(.2),this.exchangeBackImage){i=!1;if(this.exchangeBackImage.value!==e&&(this.exchangeBackImage={type:"EnvMap",value:e},i=!0),!i)return}this.exchangeBackImage={type:"Image",value:e},_e.avoidCaching&&(e=e+"?time="+Date.now());var i=new THREE.TextureLoader,r=(i.crossOrigin="anonymous",i.load(e,function(){r.imageOriginal=r.image,T.backGroundMesh.material.map&&T.backGroundMesh.material.map.dispose(),T.backGroundMesh.material.map=r,T.backGroundMesh.material.needsUpdate=!0,T.updateBackGroudImageRatio(T.backGroundMesh.material),t&&t(1),T.render(),T.dispatchEvent({type:"backGroundImageLoaded"})},void 0,function(e){n&&n(e),T.dispatchEvent({type:"backGroundImageLoaded"}),T.dispatchEvent({type:"loadError",errorInfo:"background image error"})}))}else this.backGroundScene=void 0,this.backGroundCamera=void 0,this.backGroundMesh&&this.backGroundMesh.material&&this.backGroundMesh.material.map&&this.backGroundMesh.material.map.dispose(),this.backGroundMesh=void 0,this.render()},f.setGroundShadowVisibility=function(e){D=e,T.groundShadowChange(),this.render()},f.getGroundShadowVisibility=function(){return D},f.setSmoothTranslationEnabled=function(e){K=e},f.setAutoRotationEnabled=function(e){J=e,this.cameraControl.setAutoRotationEnabled(e)},f.toggleAutoRotation=function(e){J&&this.cameraControl.toggleAutoRotation(e)},f.autoRotation=function(){this.cameraControl.autoRotation()},f.getCameraViewInfo=function(){var e=[9];return e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z,e[3]=this.camera.up.x,e[4]=this.camera.up.y,e[5]=this.camera.up.z,e[6]=this.camera.target.x,e[7]=this.camera.target.y,e[8]=this.camera.target.z,e},f.setCameraViewInfo=function(e){e={position:new THREE.Vector3(e[0],e[1],e[2]),up:new THREE.Vector3(e[3],e[4],e[5]),center:new THREE.Vector3(e[6],e[7],e[8])};this.startSmoothTranslation(e,function(){})},f.fixCameraViewInfo=function(e){e?(this.fixedViewInfo={position:new THREE.Vector3(e[0],e[1],e[2]),up:new THREE.Vector3(e[3],e[4],e[5]),center:new THREE.Vector3(e[6],e[7],e[8])},this.startSmoothTranslation(this.fixedViewInfo,function(){})):this.fixedViewInfo=null},f.setCameraInfo=function(e,t){this.cameraControl.setCameraInfo(e,t)},f.setViewBoxDir=function(e){var t={smoothTranslation:!0,useOrginal:!1};null!=(T.defaultStandardView=e)&&""!=e||(t.useOrginal=!0),g||(t.type=e,T.look(t))},f.hideEnvMapTextures=function(e,t){w!=e&&(w=e,0!=t)&&this.render()},f.setEnvMapTextures=function(e,t,n,i){if(void 0===i&&(i=-1),this.envmapUrls=e,this.envmapUrlsindex=i,e){if(this.exchangeBackImage){for(var r=!1,o=0;o<e.length;o++)if(this.exchangeBackImage.value[o]!==e[o]){this.exchangeBackImage={type:"EnvMap",value:e},r=!0;break}if(!r)return}this.exchangeBackImage={type:"EnvMap",value:e},this.envMapScene||(i=this.container.getBoundingClientRect(),this.envMapCamera=new THREE.PerspectiveCamera(60,i.width/i.height,1,1e5),this.envMapScene=new THREE.Scene,this.envMapScene.matrixWorldAutoUpdate=!1,i=THREE.ShaderLib.cube,this.envMapMaterial=new THREE.ShaderMaterial({fragmentShader:i.fragmentShader,vertexShader:i.vertexShader,uniforms:i.uniforms,depthWrite:!1,depthTest:!1,blending:THREE.NoBlending,side:THREE.BackSide}),this.envMapMaterial.requireModelMatrix=!0,this.envMapMaterial.uniforms.tCube.value=this.envMapTexture,i=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),this.envMapMaterial),this.envMapScene.add(i)),t&&t(.2);var a=[];if(_e.avoidCaching)for(var s=0;s<e.length;++s)a.push(e[s]+"?time="+Date.now());else a=e;var i=new THREE.CubeTextureLoader,l=(i.crossOrigin="anonymous",i.load(a,function(){T.envMapTexture&&T.envMapTexture.dispose(),T.envMapTexture=l,T.envMapTexture.format=THREE.RGBFormat,T.envMapTexture.minFilter=THREE.LinearFilter,T.envMapTexture.magFilter=THREE.LinearFilter,T.envMapTexture.mapping="reflection"==d?THREE.CubeReflectionMapping:THREE.CubeRefractionMapping,T.envMapMaterial&&(T.envMapMaterial.uniforms.tCube.value=T.envMapTexture,T.envMapMaterial.needsUpdate=!0,L&&T.updateEnvMap(l),t&&t(1),setTimeout(function(){T.render()},100),T.dispatchEvent({type:"envMapTexturesLoaded"}))},void 0,function(e){n&&n(e),T.dispatchEvent({type:"envMapTexturesLoaded"}),T.dispatchEvent({type:"loadError",errorInfo:"envMap error"})}))}else this.updateEnvMap(null),this.envMapCamera=void 0,this.envMapScene=void 0,this.envMapTexture&&this.envMapTexture.dispose(),this.envMapTexture=void 0,this.envMapMaterial&&this.envMapMaterial.dispose(),this.envMapMaterial=void 0,this.exchangeBackImage=null,this.render()},f.updateEnvMap=function(e){this.scene.environment!=e&&(this.scene.environment=this.hasPbrMaterial&&!e?this.defaultEnvMapTexture:e,this.forceClear=!0,this.render())},f.setEnvMapEnabled=function(e){L!=(L=e)&&(L?this.updateEnvMap(this.envMapTexture):this.updateEnvMap(),this.render())},f.setEnvMapMode=function(e){"reflection"!=(e=e.toLowerCase())&&"refraction"!=e||d!=(d=e)&&this.envMapTexture&&(this.envMapTexture.mapping="reflection"==d?THREE.CubeReflectionMapping:THREE.CubeRefractionMapping,L&&this.updateEnvMap(this.envMapTexture),this.render())},f.updateEnvMapBlur=function(){if(b){var e=T.container.getBoundingClientRect(),t=e.width,e=e.height,n=T.renderer.getPixelRatio(),t=t*n*.5,e=e*n*.5;if(this.envMapBlurTargetH&&this.envMapBlurTargetH.dispose(),this.envMapBlurTargetH=new THREE.WebGLRenderTarget(t,e,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat,stencilBuffer:!1}),this.envMapBlurTargetH.texture.generateMipmaps=!1,this.envMapBlurTargetV&&this.envMapBlurTargetV.dispose(),this.envMapBlurTargetV=new THREE.WebGLRenderTarget(t,e,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat,stencilBuffer:!1}),this.envMapBlurTargetV.texture.generateMipmaps=!1,1==o||3<o){this.envMapBlurPassH&&this.envMapBlurPassH.dispose(),this.envMapBlurPassV&&this.envMapBlurPassV.dispose(),this.envMapBlurPassH=new Jt(ke,"tDiffuse"),this.envMapBlurPassV=new Jt(ke,"tDiffuse");var i=this.envMapBlurPassH.material.defines.HORIZONTAL=1;switch(s){case 1:i=2,a=1;break;case 2:i=3.5,a=1.5;break;case 3:i=6.5,a=2}this.envMapBlurPassH.material.defines.RESOLUTION=(a/t).toFixed(4),this.envMapBlurPassV.material.defines.RESOLUTION=(a/e).toFixed(4),this.envMapBlurPassH.material.defines.SIGMA=this.envMapBlurPassV.material.defines.SIGMA=i.toFixed(3)}else if(2==o){switch(s){case 1:a=1;break;case 2:a=1.5;break;case 3:a=2}this.envMapBlurPassH&&this.envMapBlurPassH.dispose(),this.envMapBlurPassV&&this.envMapBlurPassV.dispose(),this.envMapBlurPassH=new Jt(Ue,"tDiffuse"),this.envMapBlurPassV=new Jt(Ue,"tDiffuse"),this.envMapBlurPassH.material.defines.BLUR_LEVEL=this.envMapBlurPassV.material.defines.BLUR_LEVEL=s,this.envMapBlurPassH.material.defines.HORIZONTAL=1,this.envMapBlurPassH.material.defines.RESOLUTION=(a/t).toFixed(4),this.envMapBlurPassV.material.defines.RESOLUTION=(a/e).toFixed(4)}else if(3==o){this.envMapBlurPassH&&this.envMapBlurPassH.dispose(),this.envMapBlurPassV&&this.envMapBlurPassV.dispose(),this.envMapBlurPassH=new Jt(Ue,"tDiffuse"),this.envMapBlurPassV=new Jt(Ue,"tDiffuse");var r=.02;switch(s){case 1:r=.01;break;case 2:r=.03;break;case 3:r=.1}this.envMapBlurPassH.material.defines.BLUR_AMOUNT=this.envMapBlurPassV.material.defines.BLUR_AMOUNT=r.toFixed(4)}this.envMapBlurPassH.material.blending=this.envMapBlurPassV.material.blending=THREE.NoBlending,this.envMapBlurPassH.material.depthWrite=this.envMapBlurPassV.material.depthWrite=!1,this.envMapBlurPassH.material.depthTest=this.envMapBlurPassV.material.depthTest=!1}else this.envMapBlurTargetH&&this.envMapBlurTargetH.dispose(),this.envMapBlurTargetH=void 0,this.envMapBlurTargetV&&this.envMapBlurTargetV.dispose(),this.envMapBlurTargetV=void 0,this.envMapBlurPassH&&this.envMapBlurPassH.dispose(),this.envMapBlurPassH=void 0,this.envMapBlurPassV&&this.envMapBlurPassV.dispose(),this.envMapBlurPassV=void 0;this.render()},f.setEnvMapBlurLevel=function(e){if(s=e,b){if(1==o||3<o){var t=1;switch(s){case 1:t=2,a=1;break;case 2:t=3.5,a=1.5;break;case 3:t=6.5,a=2}this.envMapBlurPassH.material.defines.RESOLUTION=(a/this.envMapBlurTargetH.width).toFixed(4),this.envMapBlurPassV.material.defines.RESOLUTION=(a/this.envMapBlurTargetH.height).toFixed(4),this.envMapBlurPassH.material.defines.SIGMA=this.envMapBlurPassV.material.defines.SIGMA=t.toFixed(3)}else if(2==o){switch(s){case 1:a=1;break;case 2:a=1.5;break;case 3:a=2}this.envMapBlurPassH.material.defines.RESOLUTION=(a/this.envMapBlurTargetH.width).toFixed(4),this.envMapBlurPassV.material.defines.RESOLUTION=(a/this.envMapBlurTargetH.height).toFixed(4),this.envMapBlurPassH.material.defines.BLUR_LEVEL=this.envMapBlurPassV.material.defines.BLUR_LEVEL=s}else if(3==o){var n=.02;switch(s){case 1:n=.01;break;case 2:n=.03;break;case 3:n=.1}this.envMapBlurPassH.material.defines.BLUR_AMOUNT=this.envMapBlurPassV.material.defines.BLUR_AMOUNT=n.toFixed(4)}this.envMapBlurPassH.material.needsUpdate=this.envMapBlurPassV.material.needsUpdate=!0,this.render()}},f.setEnvMapBlurEnabled=function(e){b!=(b=e)&&this.updateEnvMapBlur()},f.getEnvMapBlurEnabled=function(){return b},f.setHemisphereLightIntensity=function(e){for(var t=0;t<this.lights.length;t++)this.lights[t]instanceof THREE.HemisphereLight&&(this.lights[t].intensity=e);Y=e,this.render()},f.setHemisphereLightColorHex=function(e){this.hemiSphereLight&&(this.hemiSphereLight.color.setHex(e),this.hemiSphereLight.groundColor.setHex(e),this.render())},f.setHemisphereLightColorRGB=function(e,t,n){this.hemiSphereLight&&(this.hemiSphereLight.color.setRGB(e,t,n),this.hemiSphereLight.groundColor.setRGB(e,t,n),this.hemiSphereLight.color.getHex(),this.render())},f.setDirectionalLightIntensity=function(e){for(var t=0;t<this.lights.length;t++)this.lights[t]instanceof THREE.DirectionalLight&&(this.lights[t].intensity=e);W=e,this.render()},f.setDirectionalLightColorHex=function(e){this.drectionalLight&&(this.drectionalLight.color.setHex(e),this.render())},f.setDirectionalLightColorRGB=function(e,t,n){this.drectionalLight&&(this.drectionalLight.color.setRGB(e,t,n),this.drectionalLight.color.getHex(),this.render())},f.getBodyUuids=function(){return Object.keys(T.ndsModel.bodyUuid2NodeMap)},f.initModelUpDirection=function(e){if(void 0!==e){_e.modelUpDirection=e;var t=new THREE.Matrix4,n=new THREE.Matrix4,i=new THREE.Matrix4,r=new THREE.Matrix4,o=(this.ndsModel.rootBodyNode.matrix&&t.fromArray(this.ndsModel.rootBodyNode.matrix),this.modelRootObject.boundingBox.getCenter());switch(1==T.sketchStartLoad&&T.sketchModelCenter?o=T.sketchModelCenter:T.sketchModelCenter=o.clone(),i.makeTranslation(-o.x,-o.y,-o.z),t.premultiply(i),n.premultiply(i),e){case"posx":i.makeRotationAxis(new THREE.Vector3(0,0,1),.5*Math.PI);break;case"negx":i.makeRotationAxis(new THREE.Vector3(0,0,1),.5*-Math.PI);break;case"posy":break;case"negy":i.makeRotationAxis(new THREE.Vector3(1,0,0),Math.PI);break;case"posz":i.makeRotationAxis(new THREE.Vector3(1,0,0),.5*-Math.PI);break;case"posz1":i.makeRotationAxis(new THREE.Vector3(1,0,0),.5*-Math.PI),r.makeRotationAxis(new THREE.Vector3(0,1,0),.5*-Math.PI),i.premultiply(r);break;case"negz":i.makeRotationAxis(new THREE.Vector3(1,0,0),.5*Math.PI)}t.premultiply(i),n.premultiply(i),i.makeTranslation(o.x,o.y,o.z),t.premultiply(i),n.premultiply(i),this.ndsModel.ModelUpMatrix4=n.toArray(),this.ndsModel.updateNodeMatrix(this.ndsModel.rootBodyNode.uuid,t.toArray())}},f.setModelUpDirection=function(e,t){this.cameraControl.setModelUpDirection(e,t)},f.hasLineGeometry=function(){var e=this.selectionManager.getTargetLineList();return e&&0<e.length},f.getviewState=function(){return this.renderMode},f.getfileguid=function(e){function t(e){return e.parent&&e.parent.fileguid?e.parent.fileguid:e.parent?t(e.parent):null}e=T.ndsModel.getBodyNodeFromUuid(e);return e?e.fileguid||t(e):null},f.init2dTextFind=function(){var c=this,h=new THREE.Object3D,u=this.ndsModel.meshManager;u.textGeomId.forEach(function(e,t){e=u.geomManager.getGeomFromId(e);if(h.position.copy(e.position),h.quaternion.copy(e.quaternion),h.updateMatrix(),u.matrixes)for(var n=0;n<16;++n)h.matrixWorld.elements[n]=u.matrixes[16*u.textMatrixId[t]+n];var i=h.matrixWorld.clone().multiply(h.matrix),i={x:i.elements[12],y:i.elements[13],z:i.elements[14]},r={worldMatrix:[h.matrixWorld.clone()],matrix:h.matrix.clone(),oriPoint:[i],position:e.position},o=(u.geomUuid2MeshMtMap.has(e.uuid)?(o=(s=u.geomUuid2MeshMtMap.get(e.uuid)).worldMatrix.concat(r.worldMatrix),s.worldMatrix=o,o=s.oriPoint.concat(r.oriPoint),s.oriPoint=o,u.geomUuid2MeshMtMap.set(e.uuid,s)):u.geomUuid2MeshMtMap.set(e.uuid,r),[]),a=[],s={x:h.position.x+e.rectBearingX,y:h.position.y+e.rectBearingY,z:h.position.z},r={x:h.position.x+e.rectBearingX+e.rectWidth,y:h.position.y+e.rectBearingY,z:h.position.z},l={x:h.position.x+e.rectBearingX+e.rectWidth,y:h.position.y+e.rectHeight,z:h.position.z},d={x:h.position.x+e.rectBearingX,y:h.position.y+e.rectHeight,z:h.position.z},s=(o.push(s,r,l,d),u.oriGeomUuid2MeshPosMap.has(e.uuid)||u.oriGeomUuid2MeshPosMap.set(e.uuid,o),o.forEach(function(e){h.matrix.elements[12]=e.x,h.matrix.elements[13]=e.y,h.matrix.elements[14]=e.z;e=h.matrixWorld.clone().multiply(h.matrix);a.push({x:e.elements[12],y:e.elements[13],z:e.elements[14]})}),c._transMt2(a,i,h.matrix));u.geomUuid2MeshPosMap.has(e.uuid)?(r=u.geomUuid2MeshPosMap.get(e.uuid).concat(s),u.geomUuid2MeshPosMap.set(e.uuid,r)):u.geomUuid2MeshPosMap.set(e.uuid,s)})},f._transMt2=function(e,t,n){var i=new THREE.Vector3(t.x,t.y,t.z),r=new THREE.Quaternion;return r.setFromRotationMatrix(n),e.map(function(e){e=new THREE.Vector3(e.x,e.y,e.z);return e.sub(i),e.applyQuaternion(r),e.add(i),{x:e.x,y:e.y,z:e.z}})},f.findText=function(R,O){var L=this,D=(void 0===O&&(O=!1),this.textId2FlagRect&&this.textId2FlagRect.clear(),this.ndsModel.meshManager.oriGeomUuid2MeshPosMap),H=this.ndsModel.meshManager.geomUuid2MeshMtMap,F=this.ndsModel.meshManager.geomUuid2IndexMap,N=this.ndsModel.meshManager.lineStyleGeomUuid2MeshPosMap,j=new THREE.Matrix4,_=new THREE.Matrix4,V=[],k=0,U=[],e=O?this.ndsModel.getMeshManager().spliceTextRowSelectArea:this.ndsModel.getMeshManager().spliceTextRow;return e.forEach(function(r){if(r.text){var e=r.text.indexOf(R);if(-1<e){L.textId2FlagRect||(L.textId2FlagRect=new Map);for(var t=r.uuid.split("-"),n=t[0],o=F.get(n),a=H.get(n),i=r.geomStartEnd?he(r.geomStartEnd,e+R.length-1):0,s=r.geomStartEnd?he(r.geomStartEnd,e):0,l=0,d=0,c=0,h=0;h<R.length+e;h++)h==e&&(d=l),l+=r.characterWidthHeight[2*h],e<=h&&(c=c>r.characterWidthHeight[2*h+1]?c:r.characterWidthHeight[2*h+1]);if(r.mirrorX&&"number"==typeof r.rectWidth&&(p=d,d=r.rectWidth-l,l=r.rectWidth-p),D.has(n)){var u=[],p={},f={},m=1/0,g=1/0,v=1/0,A=1/0,y=-1/0,E=1/0;if(t.forEach(function(e){var t=D.get(e)[0],t=(m=Math.min(t.x,m),g=Math.min(t.y,g),v=Math.min(t.z,v),D.get(e)[3]);A=Math.min(t.x,A),y=Math.max(t.y,y),E=Math.min(t.z,E)}),p.x=m,p.y=g,p.z=v,f.x=A,f.y=y,f.z=E,u.push(b={x:p.x+d+s,y:p.y,z:0},I={x:p.x+l+i,y:p.y,z:0},T={x:f.x+l+i,y:f.y,z:0},x={x:f.x+d+s,y:f.y,z:0}),a.worldMatrix&&a.worldMatrix.length)for(var M=0;M<a.worldMatrix.length;M++)!function(){var e,t,n,i;(!O||o&&o.includes(M))&&(e={},k++,j.copy(a.matrix),_.copy(a.worldMatrix[M]),t=[],u.forEach(function(e){j.elements[12]=e.x,j.elements[13]=e.y,j.elements[14]=e.z;e=_.clone().multiply(j);t.push({x:e.elements[12],y:e.elements[13],z:e.elements[14]})}),n=L._transMt2(t,a.oriPoint[M],j),i=L._transMt2(u,a.position,j),e.flag=n[3],e.points=i,e.matrixWorld=a.worldMatrix[M],U.push((e.flagPos=n)[3]),V.push({index:k,content:r.text}),L.textId2FlagRect.set(k,e))}()}else if(N.has(n))for(var w,b,x,I,T,S,B,P=N.get(n),C=0;C<P.length;C+=4)(!O||o&&o.includes(C/4))&&(w=P[C],B=P[C+3],b={x:w.x+d+s,y:w.y,z:0},x={x:B.x+d+s,y:B.y,z:0},I={x:w.x+l+i,y:w.y,z:0},T={x:B.x+l+i,y:B.y,z:0},(B=[]).push(b,I,T,x),S={},k++,B=L._transMt2(B,w,a),S.flag=B[3],S.flagPos=B,U.push((S.points=B)[3]),V.push({index:k,content:r.text}),L.textId2FlagRect.set(k,S))}}}),U.length&&this._creatFindTextMesh(U),0==V.length&&this.exitTextFind(),V},f.selectArea=function(e,t){var l=this;if(this.is2DModel&&e&&t&&e.x&&e.y&&t.x&&t.y){this.ndsModel.meshManager.geomUuid2IndexMap.clear(),this.clearSelectArea();for(var n=e.x,i=t.x,e=e.y,t=t.y,r=this.renderer.domElement,o=this.renderer.getPixelRatio(),a=(i<n&&(n=(a=[i,n])[0],i=a[1]),t<e&&(e=(a=[t,e])[0],t=a[1]),n*o/r.width*2-1),n=i*o/r.width*2-1,i=2*-(e*o/r.height)+1,e=2*-(t*o/r.height)+1,t=new THREE.Vector3(0,0,0),o=(t.copy(this.camera.target),t.project(this.camera),new THREE.Vector3(a,i,t.z)),r=new THREE.Vector3(n,i,t.z),i=new THREE.Vector3(n,e,t.z),n=new THREE.Vector3(a,e,t.z),d=[],c=(d.push(o.unproject(this.camera)),d.push(r.unproject(this.camera)),d.push(i.unproject(this.camera)),d.push(n.unproject(this.camera)),this._drawTextRect("#1880E3",d,"selectArea"),this.ndsModel.getMeshManager().geomManager.geoms),h=this.ndsModel.meshManager.geomUuid2MeshPosMap,a=this.ndsModel.getMeshManager().lineTypeUuid2ParamsMap,u=[],p=[],f=0;f<c.length;f++)!function(){var t,n,i,r,o,a,e,s=c[f];if(!s.text||0==s._visible)return;s.textIndex?p.includes(s.textIndex)||(e=c.filter(function(e){var t=h.get(e.uuid);return!(e.textIndex!=s.textIndex||!l._isInnerRect(t,d,e.uuid))})).length&&(e.sort(function(e,t){return e.subInd-t.subInd}),t=pe(e),i=n="",r=[],o={},a=[],e.forEach(function(e){ue(e.subInd,t,o)?(n=n?n+"-"+e.uuid:e.uuid,a.push({start:i.length,uuid:e.uuid}),i+=e.text,r=r.concat(e.characterWidthHeight),o.end==e.subInd&&(u.push({uuid:n,text:i,characterWidthHeight:r,geomStartEnd:a,rectBearingY:e.rectBearingY||0,rectBearingX:e.rectBearingX||0,mirrorX:e.mirrorX,mirrorY:e.mirrorY,rectWidth:e.rectWidth,rectHeight:e.rectHeight}),i=n="",r=[])):u.push({uuid:e.uuid,text:e.text,characterWidthHeight:e.characterWidthHeight,rectBearingY:e.rectBearingY||0,rectBearingX:e.rectBearingX||0,mirrorX:e.mirrorX,mirrorY:e.mirrorY,rectWidth:e.rectWidth,rectHeight:e.rectHeight})}),p.push(s.textIndex)):(e=h.get(s.uuid))&&l._isInnerRect(e,d,s.uuid)&&u.push({uuid:s.uuid,text:s.text,characterWidthHeight:s.characterWidthHeight,rectBearingY:s.rectBearingY||0,rectBearingX:s.rectBearingX||0,mirrorX:s.mirrorX,mirrorY:s.mirrorY,rectWidth:s.rectWidth,rectHeight:s.rectHeight})}();for(var s=yr(a);!(m=s()).done;){var m=m.value,g=m[0],m=m[1],v=h.get(g);v&&this._isInnerRect(v,d,g)&&m.visible&&u.push({uuid:g,text:m.text,characterWidthHeight:m.characterWidthHeight,rectBearingY:m.rectBearingY||0,rectBearingX:m.rectBearingX||0,mirrorX:m.mirrorX,mirrorY:m.mirrorY,rectWidth:m.rectWidth,rectHeight:m.rectHeight})}this.ndsModel.getMeshManager().spliceTextRowSelectArea=u}},f._filterTextByShowHide=function(){if(this._loaded){for(var l=this.ndsModel.getMeshManager().geomManager.geoms,e=this.ndsModel.getMeshManager().lineTypeUuid2ParamsMap,d=[],c=[],h=0;h<l.length;h++)!function(){var e,t,n,i,r,o,a,s=l[h];if(!s.text||0==s._visible)return;s.textIndex?c.includes(s.textIndex)||(e=l.filter(function(e){return e.textIndex==s.textIndex})).length&&(e.sort(function(e,t){return e.subInd-t.subInd}),t=pe(e),i=n="",r=[],o={},a=[],e.forEach(function(e){ue(e.subInd,t,o)?(n=n?n+"-"+e.uuid:e.uuid,a.push({start:i.length,uuid:e.uuid}),i+=e.text,r=r.concat(e.characterWidthHeight),o.end==e.subInd&&(d.push({uuid:n,text:i,characterWidthHeight:r,geomStartEnd:a,rectBearingY:e.rectBearingY||0,rectBearingX:e.rectBearingX||0,mirrorX:e.mirrorX,mirrorY:e.mirrorY,rectWidth:e.rectWidth,rectHeight:e.rectHeight}),i=n="",r=[])):d.push({uuid:e.uuid,text:e.text,characterWidthHeight:e.characterWidthHeight,rectBearingY:e.rectBearingY||0,rectBearingX:e.rectBearingX||0,mirrorX:e.mirrorX,mirrorY:e.mirrorY,rectWidth:e.rectWidth,rectHeight:e.rectHeight})}),c.push(s.textIndex)):d.push({uuid:s.uuid,text:s.text,characterWidthHeight:s.characterWidthHeight,rectBearingY:s.rectBearingY||0,rectBearingX:s.rectBearingX||0,mirrorX:s.mirrorX,mirrorY:s.mirrorY,rectWidth:s.rectWidth,rectHeight:s.rectHeight})}();for(var t=yr(e);!(n=t()).done;){var n=n.value,i=n[0],n=n[1];n.visible&&d.push({uuid:i,text:n.text,characterWidthHeight:n.characterWidthHeight,rectBearingY:n.rectBearingY||0,rectBearingX:n.rectBearingX||0,rectWidth:n.rectWidth,rectHeight:n.rectHeight})}this.ndsModel.getMeshManager().spliceTextRow=d}},f._drawTextRect=function(e,t,n,i){void 0===n&&(n="selectArea");e=new THREE.LineBasicMaterial({color:e}),t=(new THREE.BufferGeometry).setFromPoints(t),t=new THREE.LineLoop(t,e);i&&(t.matrixWorld.copy(i),t.matrixWorldNeedsUpdate=!0),t.name=n,this.scene.add(t),this.render()},f.textLocation=function(e){var t,n;this.is2DModel&&this.textId2FlagRect&&this.textId2FlagRect.has(e)&&(this.clearSelectFindArea(),e=this.textId2FlagRect.get(e),this._drawTextRect("#E66C1C",e.points,"selectFindArea",e.matrixWorld),n=Math.abs(e.flagPos[0].y-e.flagPos[3].y),t=Math.abs(e.flagPos[0].y-e.flagPos[1].y),n=(.001<n?n:t)/Math.tan(Math.PI/180*this.camera.fov*.5)*4,(t=new THREE.Vector3).set(e.flag.x+n/7,e.flag.y-n/8,e.flag.z),(e=this.camera.target.clone().sub(this.camera.position).normalize()).multiplyScalar(n),n=t.clone().sub(e),this.camera.position.set(n.x,n.y,n.z),this.camera.setCameraTarget(t),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0),this.findTextIconUpdate(),this.render())},f.clearSelectFindArea=function(){var e=this.scene.children.findIndex(function(e){return"selectFindArea"==e.name});-1<e&&(this.scene.children.splice(e,1),this.render())},f._switchDebugFindArea=function(){var e=this.scene.children.filter(function(e){return"selectFindArea2"==e.name});e.length&&(e.forEach(function(e){e.visible=!e.visible}),this.render())},f.clearSelectArea=function(){this.ndsModel.meshManager.geomUuid2IndexMap.clear();var e=this.scene.children.findIndex(function(e){return"selectArea"==e.name});-1<e&&(this.scene.children.splice(e,1),this.render())},f.exitTextFind=function(){var e=this.scene.children.findIndex(function(e){return"textGroup"==e.name});-1<e&&(this.scene.children.splice(e,1),this.render()),this.clearSelectFindArea()},f._isInnerRect=function(e,t,n){if(!e.length||!t.length)return!1;for(var i=this.ndsModel.meshManager.geomUuid2IndexMap,r=t[0].x,o=t[0].y,a=t[1].x,s=t[1].y,l=t[2].x,d=t[2].y,c=t[3].x,t=t[3].y,h=Math.min(r,a,l,c),u=Math.max(r,a,l,c),p=Math.min(o,s,d,t),f=Math.max(o,s,d,t),m=[],g=0;g<e.length;g+=4){for(var v=null,A=0;A<4;A++){var y=e[g+A],E=y.x,y=y.y;if(!(h<=E&&E<=u&&p<=y&&y<=f)){v=!1;break}v=!0}1==v&&m.push(g/4)}return n&&m.length&&i.set(n,m),!!m.length},f._creatFindTextMesh=function(e){this.exitTextFind();var t=new THREE.MeshBasicMaterial({color:"#FF0000"}),n=new THREE.CircleGeometry(2,32),n=new THREE.InstancedMesh(n,t,e.length),i=(n.name="circle",new THREE.PlaneGeometry(.5,6)),i=new THREE.InstancedMesh(i,t,e.length),t=(i.name="plane",new THREE.Group);t.name="textGroup",t.posArr=e,t.add(n),t.add(i),t.visible=!1,this.scene.add(t),this.render()},f.findTextIconUpdate=function(){var i,e,t,n,r,o,a,s,l,d,c=this.scene.children.findIndex(function(e){return"textGroup"==e.name});-1!=c&&(i=new THREE.Object3D,(e=this.scene.children[c]).visible=!0,c=this.ndsModel.viewer.controls.getBoundingBox())&&(t=c.getCenter(new THREE.Vector3))&&(c=t.clone(),t=this.camera.getCameraTarget(),n=this.camera.position,(r=new THREE.Vector3).subVectors(t,n),t=c.clone(),c=this.camera.isPerspective?t.sub(n).dot(r.normalize()):1.2*r.length(),t=this.camera.fov,n=2*c*Math.tan(THREE.Math.degToRad(.5*t)),r=this.ndsModel.viewer.renderer.domElement.height,(o=5*n*this.ndsModel.viewer.renderer.getPixelRatio()/r)<1e-5&&(o=1e-5),c=this.camera.up.angleTo(new THREE.Vector3(0,1,0)),(a=new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(0,0,1),c),(s=new THREE.Matrix4).makeRotationFromQuaternion(a),l=new THREE.Matrix4,d=new THREE.Matrix4,e.children.forEach(function(n){e.posArr.forEach(function(e,t){l.makeTranslation(-e.x,-e.y,-e.z),d.makeTranslation(e.x,e.y,e.z),i.position.set(e.x,e.y,e.z),i.quaternion.copy(a),i.scale.set(o,o,o),i.updateMatrix(),"circle"==n.name&&(i.matrix.elements[13]=i.matrix.elements[13]+3*o,i.matrix.premultiply(l),i.matrix.premultiply(s),i.matrix.premultiply(d)),n.setMatrixAt(t,i.matrix)}),n.instanceMatrix.needsUpdate=!0,n.computeBoundingSphere()}))},f.loadSketch=function(){var t;T.sketchIsSub?T.sketchFileUrlQueue.length?(T.sketchStartLoad=!0,t=new zt(T,"",{nodeRequestor:T.modelRequestor,keepSourceFile:!!_e.ScenarioEditor}),T.ndsModel.addModel(t),T.sketchRootBodyNode=function e(t){t.propertyfile&&(t.propertyfile=""),t.pmiuuid&&(t.pmiuuid=[]);for(var n=0;n<t.children.length;n++)e(t.children[n]);return t}(T.ndsModel.models[0].rootBodyNode.cloneNew()),t.rootBodyNode=T.sketchRootBodyNode,(T.sketchRootBodyNode.ndsModel=t).hasRefModel=!0,t.state=1,T.sketchFileUrlQueue.forEach(function(e){_e.singleHTML&&T.modelRequestor.zipModelWorker.set(t.id,T.modelRequestor.zipModelWorker.get(0)),t.nodeRequestor.addRequest(e,null,"loadModelData",{modelId:t.id,keepSourceFile:!1})}),T.sketchFileUrlQueue=[]):(T.ndsModel.setStaticModel(0),T.sketchStartLoad=!1,T.setAuxiliaryLineVisible(!1)):T.sketchFileUrlQueue.length?(T.currentSketchFileUrl=T.sketchFileUrlQueue.splice(0,1)[0],T.sketchStartLoad=!0,_e.singleHTML?T.loadModelFlate(T.currentSketchFileUrl,function(){T.setAuxiliaryLineVisible(!1)}):T.loadModel(T.parameter.id,T.currentSketchFileUrl,null,null,"js",null,function(){T.setAuxiliaryLineVisible(!1)},null,{})):(T.ndsModel.setStaticModel(0),T.sketchStartLoad=!1)},f.getHasAuxiliaryLine=function(){return!!this.currentSketchFileUrl},f.setAuxiliaryLineVisible=function(t){this.ndsModel.models.forEach(function(e){e.sketchFileUrl&&(t?T.ndsModel.showBody(e.rootBodyNode):T.ndsModel.hideBody(e.rootBodyNode))}),T.render()},f.setRenderMode=function(e,t){if(this.ndsModel){for(var n=this.currentSketchFileUrl?this.ndsModel.getStaticMeshSets():this.ndsModel.getMeshSets(),i=0,r=0;r<n.length;r++)i+=n[r].getNumMeshes();0==i&&(e="shadedWithEdges")}if(void 0!==e){this.renderMode=e;var o=O;switch(e){case"lighting":o=0;break;case"primarycolor":o=1;break;case"wireframe":o=2;break;case"whitemold":o=3;break;case"shadedWithEdges":o=4;break;case"shaded":o=5;break;case"hiddenLineRemove":o=6;break;case"hiddenLineVisible":o=7;break;case"transparent":o=8;break;default:o=this.is2DModel?(this.renderMode="shadedWithEdges",4):(this.renderMode="shaded",5)}if(o!=O){if(this.modelRootObject){switch(O){case 0:break;case 1:this.modelRootObject.traverse(function(e){e instanceof THREE.Line||e instanceof THREE.LineSegments||!e.hasOwnProperty("geometry")||!e.hasOwnProperty("material")||void 0!==e.material.orginalSpecular&&(e.material.specular.copy(e.material.orginalSpecular),e.material.orginalSpecular=void 0,e.material.needsUpdate=!0)});break;case 2:var a=this.hasLineGeometry();this.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments||(a?e.visible=!0:void 0!==e.material.wireframe&&(e.material.wireframe=!1,e.material.needsUpdate=!0)))});break;case 3:M=null;break;case 4:case 5:break;case 6:this.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments?e.renderOrder=0:(e.material.depthTest=!0,e.material.depthWrite=!0,void(e.renderOrder=0)!==e.material.colorWrite&&(e.material.colorWrite=!0,e.material.needsUpdate=!0)))});break;case 7:this.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments?(e.renderOrder=0,null!=e.material.oldOpacity&&(e.material.opacity=e.material.oldOpacity,e.material.depthFunc=e.material.oldDepthFunc,e.material.transparent=e.material.oldTransparent,e.material.needsUpdate=!0)):(e.material.depthTest=!0,e.material.depthWrite=!0,void(e.renderOrder=0)!==e.material.colorWrite&&(e.material.colorWrite=!0,e.material.needsUpdate=!0)))});break;case 8:this.transparentRenderMode(-1)}switch(o){case 0:break;case 1:this.scene.traverse(function(e){e instanceof THREE.Line||e instanceof THREE.LineSegments||!e.hasOwnProperty("geometry")||!e.hasOwnProperty("material")||void 0!==e.material.specular&&(e.material.orginalSpecular=e.material.specular.clone(),e.material.specular.setRGB(0,0,0),e.material.needsUpdate=!0)});break;case 2:a=this.hasLineGeometry();this.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments?(e.visible=!0,null!=e.tangentEdgeObject&&0==_e.tangentEdgeVisible&&(e.visible=!1)):a?e.visible=!1:void 0!==e.material.wireframe&&(e.material.wireframe=!0,e.material.needsUpdate=!0))});break;case 3:(M=new THREE.MeshPhongMaterial).side=THREE.DoubleSide,M.skinning=!0,M.color.setRGB(.65,.65,.65),M.specular.setRGB(.4,.4,.4),M.shininess=60;break;case 4:this.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e.visible=!0,e instanceof THREE.Line||e instanceof THREE.LineSegments)&&null!=e.tangentEdgeObject&&0==_e.tangentEdgeVisible&&(e.visible=!1)});break;case 5:this.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments?e.visible=!1:e.visible=!0)});break;case 6:this.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments?(e.visible=!0,e.renderOrder=1e4,0==e.material.colorWrite&&(e.material=e.material.clone(),e.material.colorWrite=!0),null!=e.tangentEdgeObject&&0==_e.tangentEdgeVisible&&(e.visible=!1)):(e.visible=!0,e.material.depthTest=!0,e.material.depthWrite=!0,void(e.renderOrder=0)!==e.material.colorWrite&&(e.material.colorWrite=!1,e.material.needsUpdate=!0)))});break;case 7:T.modelRootObject.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(e instanceof THREE.Line||e instanceof THREE.LineSegments?(0==e.material.colorWrite&&(e.material=e.material.clone(),e.material.colorWrite=!0),e.material.oldOpacity=e.material.opacity,e.material.oldDepthFunc=e.material.depthFunc,e.material.oldTransparent=e.material.transparent,e.material.needsUpdate=!0,e.renderOrder=1e4,e.visible=!0,null!=e.tangentEdgeObject&&0==_e.tangentEdgeVisible&&(e.visible=!1)):(e.visible=!0,e.material.depthTest=!0,e.material.depthWrite=!0,void(e.renderOrder=0)!==e.material.colorWrite&&(e.material.colorWrite=!1,e.material.needsUpdate=!0)))});break;case 8:this.transparentRenderMode(1)}}null!=this.modelSceneOrgin&&this.modelSceneOrgin!=this.scene&&(this.modelSceneOrgin.overrideMaterial=this.scene.overrideMaterial),O=o}else switch(o){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break;case 8:this.transparentRenderMode(0)}!1!==t&&this.render(),this.isIn3DViewer()&&(_e.selectedColor=4===O?new THREE.Color(16776960):new THREE.Color(16233729),T.selectionManager.overrideMeshSelectionMaterialIn3DViewer())}},f.setDefaultEnvMap=function(){var e=document.createElement("canvas"),t=(e.width=256,e.height=256,e.getContext("2d")),t=(t.fillStyle="rgb(225,225,225)",t.fillRect(0,0,256,256),e.toDataURL()),n=(L=!0,this),e=new THREE.CubeTextureLoader;this.defaultEnvMapTexture=e.load([t,t,t,t,t,t],function(){n.defaultEnvMapTexture.format=THREE.RGBFormat,n.defaultEnvMapTexture.minFilter=THREE.LinearFilter,n.defaultEnvMapTexture.magFilter=THREE.LinearFilter,n.defaultEnvMapTexture.needsUpdate=!0,T.updateEnvMap(n.defaultEnvMapTexture,!0),T.dispatchEvent({type:"envMapTexturesLoaded"})})},f.setBackGroundColor=function(e){if(this.setBackGroundImage(null),this.setEnvMapTextures(null),this.exchangeBackImage={type:"Color",value:e},null==this.clearColor||this.clearColor!==e){this.clearColor=e;var t=(new THREE.Color).setHex(parseInt(e));if(this.renderer.setClearColor(parseInt(e),0),this.ndsModel&&this.is2DModel)if(this.controls.staticmeasureOp&&this.controls.staticmeasureOp.setBackGroundColor(t),2<=this.modelContentVersion){var n=new THREE.Color(1,1,1),i=new THREE.Color(0,0,0);if(t.equals(i)){for(var r in T.ndsModel.meshManager.materials){var o=T.ndsModel.meshManager.materials[r].mat;"ShaderMaterial"!=o.type&&o.color.equals(i)?o.color.copy(n):"ShaderMaterial"==o.type&&o.uniforms.diffuse.value.equals(i)&&(o.color&&o.color.copy(n),o.uniforms.diffuse.value.copy(n))}for(var a=0,s=T.ndsModel.meshManager.mats.length;a<s;++a){var l=T.ndsModel.meshManager.mats[a];l&&("ShaderMaterial"!=l.type&&l.color.equals(i)?l.color.copy(n):"ShaderMaterial"==l.type&&l.uniforms.diffuse.value.equals(i)&&(l.color&&l.color.copy(n),l.uniforms.diffuse.value.copy(n)))}}else{for(var r in T.ndsModel.meshManager.materials){var d=T.ndsModel.meshManager.materials[r].mat;"ShaderMaterial"!=d.type&&d.color.equals(n)?d.color.copy(i):"ShaderMaterial"==d.type&&d.uniforms.diffuse.value.equals(n)&&(d.color&&d.color.copy(i),d.uniforms.diffuse.value.copy(i))}for(var c=0,h=T.ndsModel.meshManager.mats.length;c<h;++c){var u=T.ndsModel.meshManager.mats[c];u&&("ShaderMaterial"!=u.type&&u.color.equals(n)?u.color.copy(i):"ShaderMaterial"==u.type&&u.uniforms.diffuse.value.equals(n)&&(u.color&&u.color.copy(i),u.uniforms.diffuse.value.copy(i)))}}T.lineTypes&&T.lineTypes.setBackGroundColor(t.equals(i)?t:n)}else{if(this.renderer.getClearColor(this.oldClearColor).equals(new THREE.Color(0,0,0))){for(var r in T.ndsModel.meshManager.materials)T.ndsModel.meshManager.materials[r].mat.color.equals(new THREE.Color(0,0,0))&&("ShaderMaterial"!=T.ndsModel.meshManager.materials[r].mat.type?T.ndsModel.meshManager.materials[r].mat.color.setRGB(1,1,1):"ShaderMaterial"==T.ndsModel.meshManager.materials[r].mat.type&&(T.ndsModel.meshManager.materials[r].mat.color.setRGB(1,1,1),T.ndsModel.meshManager.materials[r].mat.uniforms.diffuse.value.setRGB(1,1,1)));if(T.pmiObject){if(g=this.pmiObject.getObjectByName("TextGroup"))for(var p=0;p<g.children.length;++p){for(var f=g.children[p].geometry.attributes.position.data,m=0;m<f.count;++m)0==f.array[m*f.stride+3]&&0==f.array[m*f.stride+4]&&0==f.array[m*f.stride+5]&&(f.array[m*f.stride+3]=1,f.array[m*f.stride+4]=1,f.array[m*f.stride+5]=1);f.needsUpdate=!0,f.updateRange.count=f.count*f.stride}this.pmiObject.traverse(function(e){"LineSegments"==e.type&&e.material.color.equals(new THREE.Color(0,0,0))&&e.material.color.setRGB(1,1,1)})}}else{for(var r in T.ndsModel.meshManager.materials)T.ndsModel.meshManager.materials[r].mat.color.equals(new THREE.Color(1,1,1))&&("ShaderMaterial"!=T.ndsModel.meshManager.materials[r].mat.type?T.ndsModel.meshManager.materials[r].mat.color.setRGB(0,0,0):"ShaderMaterial"==T.ndsModel.meshManager.materials[r].mat.type&&(T.ndsModel.meshManager.materials[r].mat.color.setRGB(0,0,0),T.ndsModel.meshManager.materials[r].mat.uniforms.diffuse.value.setRGB(0,0,0)));if(this.pmiObject){for(var g=this.pmiObject.getObjectByName("TextGroup"),p=0;p<g.children.length;++p){for(f=g.children[p].geometry.attributes.position.data,m=0;m<f.count;++m)1==f.array[m*f.stride+3]&&1==f.array[m*f.stride+4]&&1==f.array[m*f.stride+5]&&(f.array[m*f.stride+3]=0,f.array[m*f.stride+4]=0,f.array[m*f.stride+5]=0);f.needsUpdate=!0,f.updateRange.count=f.count*f.stride}this.pmiObject.traverse(function(e){"LineSegments"==e.type&&e.material.color.equals(new THREE.Color(1,1,1))&&e.material.color.setRGB(0,0,0)})}}T.lineTypes&&T.lineTypes.setBackGroundColor(t)}e="#"+T.renderer.getClearColor(this.oldClearColor).getHexString();this.container.style.backgroundColor=e,this.render()}},f.getMaterialsInfo=function(){if(T.materialsSetting)return T.materialsSetting.getMaterialsInfo()},f.getRenderMode=function(){return O},f.getMapList=function(){if(T.materialsSetting)return T.materialsSetting.getMapList()},f.removeMap=function(e,t){if(T.materialsSetting)return T.materialsSetting.removeMap(e,t,O)},f.isMapWorking=function(e){if(T.materialsSetting)return T.materialsSetting.isMapWorking(e)},f.removeObjectMaterial=function(e){T.materialsSetting.removeObjectMaterial(e)},f.getObjectMaterialInfo=function(e){return T.materialsSetting.getObjectMaterialInfo(e)},f.updateMaterialInfo=function(e,t){T.materialsSetting&&null!=e&&(T.materialsSetting.updateMaterialInfo(e,O,t),this.render())},f.updateAllMateriaslInfo=function(e,t){T.materialsSetting&&T.materialsSetting.updateAllMateriaslInfo(e,O,t)},f.autoSetBodyNodeMaterial=function(e){T.materialsSetting&&T.materialsSetting.autoSetBodyNodeMaterial(e||T.ndsModel.rootBodyNode.uuid)},f.getBodyNodeMaterialsInfo=function(){return T.ndsModel.getBodyNodeUUidToMaterial()},f.setBodyNodeMaterialsInfo=function(e){if(e){for(var t in T.bodyNodeUUidToMaterial){var n=T.bodyNodeUUidToMaterial[t],n=T.materialsSetting.jsonToMaterial(n);n&&(T.bodyNodeUUidToMaterial[t]=n)}T.ndsModel.setBodyNodeMaterials(T.bodyNodeUUidToMaterial)}},f.convertMaterialInfo=function(e,t){if(T.materialsSetting){var n=T.materialsSetting.convertMaterialInfo(e,t,O);if(n.matJson&&n.matObj){if(this.traverseAndReplaceMaterialMeshes(this.scene,n.matObj),this.animationsManager){var i=this.animationsManager.getAllAnimationScenes();if(i)for(var r=0;r<i.length;++r)this.traverseAndReplaceMaterialMeshes(i[r],n.matObj);this.animationsManager.setMaterialsUpdated(!0)}return this.modelSceneOrgin&&this.scene!=this.modelSceneOrgin&&this.traverseAndReplaceMaterialMeshes(this.modelSceneOrgin,n.matObj),this.render(),n.matJson}}},f.convertAllMaterialsInfo=function(e,t){if(T.materialsSetting){for(var n={materials:[]},i=!1,r=0,o=e.materials.length;r<o;++r){var a=T.materialsSetting.convertMaterialInfo(e.materials[r],t,O);if(a.matJson&&a.matObj){if(i=!0,n.materials.push(a.matJson),this.traverseAndReplaceMaterialMeshes(this.scene,a.matObj),this.animationsManager){var s=this.animationsManager.getAllAnimationScenes();if(s)for(var l=0;l<s.length;++l)this.traverseAndReplaceMaterialMeshes(s[l],a.matObj);this.animationsManager.setMaterialsUpdated(!0)}this.modelSceneOrgin&&this.scene!=this.modelSceneOrgin&&this.traverseAndReplaceMaterialMeshes(this.modelSceneOrgin,a.matObj)}else n.materials.push(e.materials[r])}return i&&(this.scene.overrideMaterial&&(this.scene.overrideMaterial.needsUpdate=!0),M&&(M.needsUpdate=!0),this.render()),n}},f.traverseAndReplaceMaterialMeshes=function(e,t){if(null!=e&&e instanceof THREE.Object3D&&!(e instanceof THREE.Light)&&(e.hasOwnProperty("geometry")&&e.material&&e.material.uuid==t.uuid&&(e.material=t,e.geometry instanceof THREE.BufferGeometry)&&null!=e.geometry.attributes.color&&(e.material.vertexColors=!0),null!=e.children))for(var n=e.children,i=0,r=n.length;i<r;++i)this.traverseAndReplaceMaterialMeshes(n[i],t)},f.traverseMaterialMeshes=function(e,t,n,i){var r,o,a,s,l;if(null!=e&&(e instanceof THREE.Object3D&&!(e instanceof THREE.Light)))if(e.hasOwnProperty("geometry"))e.material&&e.material.uuid==i.uuid&&(r=!1,(s=e.geometry)instanceof THREE.Geometry?r=null!=s.vertices&&0!=s.vertices.count:s instanceof THREE.BufferGeometry&&(r=null!=e.geometry.attributes.position),r||s.boundingBox)&&(null==s.boundingBox&&s.computeBoundingBox(),isFinite(s.boundingBox.min.x))&&(r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),o=new Float32Array(24),(a=new THREE.BufferGeometry).setIndex(new THREE.BufferAttribute(r,1)),a.addAttribute("position",new THREE.BufferAttribute(o,3)),r=new THREE.LineSegments(a,n),o=s.boundingBox.min,a=s.boundingBox.max,(l=(s=r.geometry.attributes.position).array)[0]=a.x,l[1]=a.y,l[2]=a.z,l[3]=o.x,l[4]=a.y,l[5]=a.z,l[6]=o.x,l[7]=o.y,l[8]=a.z,l[9]=a.x,l[10]=o.y,l[11]=a.z,l[12]=a.x,l[13]=a.y,l[14]=o.z,l[15]=o.x,l[16]=a.y,l[17]=o.z,l[18]=o.x,l[19]=o.y,l[20]=o.z,l[21]=a.x,l[22]=o.y,l[23]=o.z,s.needsUpdate=!0,r.geometry.computeBoundingSphere(),e.add(r),r.updateMatrixWorld(!0),t.push({parent:e,marker:r}));else if(null!=e.children)for(var d=e.children,c=0,h=d.length;c<h;++c)this.traverseMaterialMeshes(d[c],t,n,i)},f.showMaterialMarkers=function(e,t,n){var i;T.materialsSetting&&null!=e&&(T.materialsSetting.cleanMaterialsMarkers(),"LineBasicMaterial"!=e.type&&(i=new THREE.LineBasicMaterial({color:16776960}),t&&i.color.setHex(t),n&&(i.lineWidth=n),this.traverseMaterialMeshes(this.scene,t=[],i,e),T.materialsSetting.setMaterialsMarkers(t),T.materialsSetting.setMaterialsMarkersMat(i)),this.render())},f.cleanMaterialMarkers=function(){T.materialsSetting&&(T.materialsSetting.cleanMaterialsMarkers(),this.render())},f.setLineWidth=function(e){T.showLineWidth=e,this.render()},f.getObjectWorldMatrixByIds=function(e){for(var t={},n=0;n<e.length;n++){var i,r=T.ndsModel.objectidTouuid[e[n]],r=T.getBodyNodeFromUuid(r),r=T.ndsModel.calculateNodeWorldMatrix4D(r);0<this.ndsModel.ModelUpMatrix4.length&&((i=new THREE.Matrix4D).fromArray(this.ndsModel.ModelUpMatrix4),i.invert(),r.premultiply(i)),t[e[n]]=r.toArray()}return t},f.saveTextForPDF=function(e,t){void 0===t&&(t=1),this.printPDF||(this.printPDF=new yi(this)),this.printPDF.saveTextForPDF(e,t)},f.getPrintDataCallback=function(i,r,o,a,s,l,d){this.printPDF||(this.printPDF=new yi(this)),this.renderNew();var c=this;T.addEventListener("updateProgress",function e(t){var t=t.userData.precent,n=T.ndsModel.getLineSegmentsSet();t<.99||4===O&&n.dirty||(T.removeEventListener("updateProgress",e),c.printPDF.setPDFInfo(r,o,a,s,l,d),t=c.printPDF.sendFile(),c.printPDF.clearArray(),i&&i(t))},!1)},f.getPrintData=function(e,t,n,i,r,o){console.warn("getPrintData has been discard,use getPrintDataCallback"),this.printPDF||(this.printPDF=new yi(this)),this.printPDF.setPDFInfo(e,t,n,i,r,o);e=this.printPDF.sendFile();return this.printPDF.clearArray(),e},f.getBodyNodeFileUnit=function(e){for(;e&&!e.fileUnit;)e=e.parent;return e?e.fileUnit:null},f.getUnitScale=function(e){var t=1;return"millimeter"==e||"mm"==e?"centimeter"==this.modelUnit?t=10:"meter"==this.modelUnit?t=1e3:"inch"==this.modelUnit?t=25.4:"feet"==this.modelUnit&&(t=304.8):"centimeter"==e||"cm"==e?"millimeter"==this.modelUnit?t=.1:"meter"==this.modelUnit?t=100:"inch"==this.modelUnit?t=2.54:"feet"==this.modelUnit&&(t=30.48):"meter"==e||"m"==e?"millimeter"==this.modelUnit?t=.001:"centimeter"==this.modelUnit?t=.01:"inch"==this.modelUnit?t=.0254:"feet"==this.modelUnit&&(t=.3048):"inch"==e||"in"==e?"millimeter"==this.modelUnit?t=1/25.4:"centimeter"==this.modelUnit?t=10/25.4:"meter"==this.modelUnit?t=1e3/25.4:"feet"==this.modelUnit&&(t=12):"feet"!=e&&"ft"!=e||("millimeter"==this.modelUnit?t=1/304.8:"centimeter"==this.modelUnit?t=10/304.8:"meter"==this.modelUnit?t=1e3/304.8:"inch"==this.modelUnit&&(t=1/12)),t},f.getUnitTransfrom=function(e,t){var n=1;return"millimeter"==e||"mm"==e?"centimeter"==t||"cm"==t?n=10:"micrometer"==t||"um"==t?n=.001:"meter"==t||"m"==t?n=1e3:"inch"==t||"in"==t?n=25.4:"feet"!=t&&"ft"!=t||(n=304.8):"centimeter"==e||"cm"==e?"millimeter"==t||"mm"==t?n=.1:"micrometer"==t||"um"==t?n=1e5:"meter"==t||"m"==t?n=100:"inch"==t||"in"==t?n=2.54:"feet"!=t&&"ft"!=t||(n=30.48):"meter"==e||"m"==e?"millimeter"==t||"mm"==t?n=.001:"micrometer"==t||"um"==t?n=1e-6:"centimeter"==t||"cm"==t?n=.01:"inch"==t||"in"==t?n=.0254:"feet"!=t&&"ft"!=t||(n=.3048):"inch"==e||"in"==e?"millimeter"==t||"mm"==t?n=1/25.4:"micrometer"==t||"um"==t?n=1/25400:"centimeter"==t||"cm"==t?n=10/25.4:"meter"==t||"m"==t?n=1e3/25.4:"feet"!=t&&"ft"!=t||(n=12):"feet"==e||"ft"==e?"millimeter"==t||"mm"==t?n=1/304.8:"micrometer"==t||"um"==t?n=1/304800:"centimeter"==t||"cm"==t?n=10/304.8:"meter"==t||"m"==t?n=1e3/304.8:"inch"!=t&&"in"!=t||(n=1/12):"micrometer"!=e&&"um"!=e||("millimeter"==t||"mm"==t?n=1e3:"meter"==t||"m"==t?n=1e5:"centimeter"==t||"cm"==t?n=1e4:"inch"==t||"in"==t?n=25400:"feet"!=t&&"ft"!=t||(n=304800)),n},f.getDispalyModelUnit=function(e,t){var n={unit:this.userModelUnit||this.modelUnit,scale:this.getUnitScale(this.userModelUnit||this.modelUnit)};return this.userModelUnit||(e<1||t&&t<1?"meter"==this.modelUnit?(n.unit="millimeter",n.scale=1e3):"feet"==this.modelUnit&&(n.unit="inch",n.scale=12):"centimeter"==this.modelUnit&&10<e&&_e.inBIMContext?(n.unit="meter",n.scale=.01):"millimeter"==this.modelUnit&&100<e&&_e.inBIMContext&&(n.unit="meter",n.scale=.001)),n},f.getModelUnit=function(){return this.modelUnit},f.setDispalyModelUnit=function(e){this.userModelUnit="millimeter"==e||"mm"==e?"millimeter":"centimeter"==e||"cm"==e?"centimeter":"meter"==e||"m"==e?"meter":"inch"==e||"in"==e?"inch":"feet"==e||"ft"==e?"feet":null,this.controls.staticmeasureOp&&this.controls.staticmeasureOp.setMeasureDisplayUnit(),T.dispatchEvent({type:"broadcastEvent"})},f.setAnnotationMode=function(e){T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.setAnnotationMode(e)},f.getAnnotationMode=function(){return T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.getAnnotationMode()},f.resetSelectAnnotation=function(){T.annotationsManager&&T.annotationsManager.resetSelectAnnotation()},f.setLineSegAnnotationStyle=function(e){T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.setLineSegAnnotationStyle(e)},f.getLineSegAnnotationStyle=function(){return T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.getLineSegAnnotationStyle()},f.selectAnnotation=function(e){T.annotationsManager&&(T.annotationsManager.selectAnnotation(e),T.render())},f.addAnnotationPicText=function(e,t){T.annotationsManager||(T.annotationsManager=new nn(T));var n;T.ndsModel&&(!!((n=T.ndsModel.fileguidTouuid[e.fileguid])&&0<n.length)&&e.bOnModel&&e.rootfileguid!=T.ndsModel.rootBodyNode.fileguid&&e.fileguid?T.annotationsManager.addAnnotation(e,null,!0):(e.rootfileguid!=T.ndsModel.rootBodyNode.fileguid&&(e.other=!0),T.annotationsManager.addAnnotation(e))),0!=t&&T.render()},f.addAnnotation=function(e,t){"lineNote"==e.state.origiType?this.setNoteAnnotation(e.state):this.addAnnotationPicText(e.state,t)},f.addAnnotationSave=function(e){this.CorrectPosition(e),e.state&&this.addAnnotation(e.state)},f.CorrectPosition=function(t){var e,n;T.ndsModel&&t.state.rootfileguid&&(e=T.ndsModel.explodeFactor,T.ndsModel&&(n=T.controls.getBoundingBox().getCenter(),T.ndsModel.setExplodeFactor(n,0)),t.state.rootfileguid!=T.ndsModel.rootBodyNode.fileguid&&t.state.bOnModel&&t.state.fileguid&&(T.getposFromFileGuid(t.state,t,!0),t.list)&&t.list.forEach(function(e){T.getposFromFileGuid(t.state,e,!0),e.points&&e.points.forEach(function(e){T.getposFromFileGuid(t.state,e,!0)})}),T.ndsModel)&&(n=T.controls.getBoundingBox().getCenter(),T.ndsModel.setExplodeFactor(n,e))},f.getposFromFileGuid=function(e,t,n){T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.getposFromFileGuid(e,t,n)},f.addAnnotations=function(e,t){T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.addAnnotations(e),0!=t&&T.render()},f.setAnnotationsVisibility=function(e){T.annotationsManager&&T.annotationsManager.setAnnotationsVisibility(e),this.showNoteAnnotation(e),e&&this.setSelectIdArray([])},f.setAnnotationType=function(e,t){T.annotationsManager&&T.annotationsManager.setAnnotationType(e,t)},f.setAnnotationsVisibilityByUuid=function(e,t){T.annotationsManager&&T.annotationsManager.setAnnotationsVisibilityByUuid(e,t)},f.showAnnotation=function(e,t,n){T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.addAnnotation(e,t),0!=n&&T.render()},f.showAnnotations=function(e,t){T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.addAnnotations(e),0!=t&&T.render()},f.removeAnnotation=function(e,t){T.annotationsManager&&(T.annotationsManager.removeAnnotation(e),0!=t)&&T.render(),this.deleteNoteAnnotation(e)},f.removeAnnotations=function(e,t){if(T.annotationsManager){for(var n=0,i=e.length;n<i;++n)T.annotationsManager.removeAnnotation(e[n]);0!=t&&T.render()}},f.removeAllAnnotations=function(e){if(T.annotationsManager&&(T.annotationsManager.removeAllAnnotations(),0!=e)&&T.render(),T.controls.staticAnnotation)for(var t=T.controls.staticAnnotation.getAllNoteContent(),n=0;n<t.length;n++)T.controls.staticAnnotation.deleteNoteAnnotation(t[n].tagId,!1)},f.listenAnnotation=function(e){T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.listenAnnotation(e)},f.getHotPoint=function(e,t){return T.annotationsManager||(T.annotationsManager=new nn(T)),T.annotationsManager.getHotPoint(e,t)},f.setOperator=function(e){e&&(T.controls.setOperator(e),T.controls.addEventListener("change",T.render),T.onOpChanged({id:e.type}))},f.setOperatorByID=function(e){switch(e){case"OpOrbit":T.controls.setOperator(new Wn(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpOrbit"});break;case"OpPan":T.controls.setOperator(new Yn(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpPan"});break;case"OpZoom":T.controls.setOperator(new Xn(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpZoom"});break;case"OpZoomWindow":T.controls.setOperator(new Qn(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpZoomWindow"});break;case"OpSelectWindow":T.controls.setOperator(new Zn(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpSelectWindow"});break;case"OpDrawGeom":T.controls.setOperator(new be(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpDrawGeom"});break;case"OpDrawTrace":T.controls.setOperator(new xe(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpDrawTrace"});break;case"OpPiovt":T.controls.setOperator(new Ie(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpPiovt"});break;case"OpSelect":break;case"OpBall":T.controls.setOperator(new we(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpBall"}),_e.ScenarioEditor&&T.controls.getOperator().setModel("both");break;case"OpExplode":T.controls.setOperator(new Ai(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpExplode"});break;case"OpSectionView":break;case"OpDrag":T.controls.setOperator(new ye(T)),T.onOpChanged({id:"OpDrag"});break;case"OpAnnotation":T.controls.setOperator(new li(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpAnnotation"});break;case"OpAnnotationNew":T.controls.setOperator(new Ee(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpAnnotation"});break;case"OpMeasure":T.controls.setOperator(new Me(T)),T.controls.addEventListener("change",T.render),T.onOpChanged({id:"OpMeasure"})}},f.setOperatorExplodeMode=function(e){"OpExplode"==T.controls.getOperator().type&&T.controls.getOperator().setExplodeMode(e)},f.startMove=function(){"OpBall"==T.controls.getOperator().type&&T.controls.getOperator().startMove()},f.getCurrentOperatorID=function(){return T.controls.getOperator().type},f.getCurrentOperatorState=function(){return T.controls.getOperator().state},f.getCurrentMeasureType=function(){return"OpMeasure"==T.controls.getOperator().type?T.controls.getOperator().measureType:null},f.onFitToView=function(){T.zoomExtents()},f.onResetCamera=function(){T.resetCamera({useOrginal:!0})},f.onExplode=function(e){T.explodeModel(e)},f.onFullScreen=function(){T.executeFullScreen()},f.onLineVisibility=function(e){T.setLinesVisibility(e)},f.isClipTransformControlSelected=function(){var e=T.clipPlaneManager.isClipTransformControlSelected(),t=T.clipBoxManager.isClipTransformControlSelected(),n=!1;return"OpExplode"==T.controls.getOperator().type&&(n=T.controls.getOperator().isTransControlSelected()),0<T.renderer.clippingPlanes.length&&e||t||n},f.isLightEditControlSelected=function(){return!(null==T.lightControls||!T.lightControls.getVisible())&&T.lightControls.isLightEditControlSelected()},f.onLightEditor=function(){null==T.lightControls||T.lightControls.getVisible()?null!=T.lightControls&&T.lightControls.getVisible()&&T.lightControls.setVisible(!1):T.lightControls.setVisible(!0)},f.onModelBrowser=function(){this.modelBrowserDlg||(this.modelBrowserDlg=new Be(this)),this.modelBrowserDlg.show("模型结构")},f.setLogOperatorTime=function(e){this.logOperatorTime=e},f.logOperatorTimeShow=function(e,t,n){if(1==n){var i,r=Date.now();for(i in this.logOperatorTimeInfo){var o=this.logOperatorTimeInfo[i];console.log(i+"["+o+"-"+r+"]",r-o+"ms")}this.logOperatorTimeInfo={}}else this.logOperatorTimeInfo[e]=t},f.onBoxSectionView=function(e,t){var n=Date.now();this.clipBoxManager&&(this.clipBoxManager.onBoxSectionView(e),_e.enableSelect=!e),e?(T.redererSide=T.renderer.getNdsModelRenderSide(),T.redererSide!=THREE.DoubleSide?T.renderer.setNdsModelRenderSide(THREE.DoubleSide):T.redererSide=null,T.logOperatorTime&&T.logOperatorTimeShow("[盒剖切][开]",n)):(null!=T.redererSide&&(T.renderer.setNdsModelRenderSide(T.redererSide),T.redererSide=null),T.logOperatorTime&&T.logOperatorTimeShow("[盒剖切][关]",n))},f.onSectionView=function(e,t){var n=Date.now();T.clipPlaneManager.onSectionView(e,t),e?(T.redererSide=T.renderer.getNdsModelRenderSide(),T.redererSide!=THREE.DoubleSide?T.renderer.setNdsModelRenderSide(THREE.DoubleSide):T.redererSide=null,T.logOperatorTime&&T.logOperatorTimeShow("[剖切][开]",n)):(null!=T.redererSide&&(T.renderer.setNdsModelRenderSide(T.redererSide),T.redererSide=null),T.logOperatorTime&&T.logOperatorTimeShow("[剖切][关]",n))},f.setActiveSectionPlane=function(e){var t=Date.now();T.clipPlaneManager&&T.clipPlaneManager.setActiveSectionPlane(e.toUpperCase()),T.logOperatorTime&&T.logOperatorTimeShow("[剖切][显示投影面"+e+"]",t)},f.setSectionImageFlag=function(e){T.clipPlaneManager.showSectionImage=e},f.deleteSectionPlane=function(e){var t=Date.now();T.clipPlaneManager&&T.clipPlaneManager.deleteSectionPlane(e.toUpperCase()),T.logOperatorTime&&T.logOperatorTimeShow("[剖切][删除投影面"+e+"]",t)},f.addSectionPlane=function(e){var t=Date.now();T.clipPlaneManager&&T.clipPlaneManager.addSectionPlane(e.toUpperCase()),T.logOperatorTime&&T.logOperatorTimeShow("[剖切][增加投影面"+e+"]",t)},f.isSectionViewEnabled=function(){return T.clipPlaneManager.isSectionViewEnabled()},f.isSectionBoxViewEnabled=function(){return T.clipBoxManager.isSectionBoxEnabled()},f.onCloseViewSection=function(){return T.clipPlaneManager.onCloseViewSection()},f.getClipPlaneInfo=function(){return T.clipPlaneManager.getClipPlaneInfor()},f.getBoxClipInfo=function(){return T.clipBoxManager.getBoxClipInfo()},f.setClipPlaneInfor=function(e){T.clipPlaneManager.setClipPlaneInfor(e)},f.showSectionImage=function(e){T.clipPlaneManager.showSectionImage=e},f.onSelectAndMoveModel=function(e){"OpDrag"==T.controls.getOperator().type&&(e?T.controls.getOperator().setMoveMode():T.controls.getOperator().setDefaultMode())},f.isModelMoved=function(){var t=!1;return T.scene.traverse(function(e){e.hasOwnProperty("geometry")&&"lightctrls"!=e.name&&null!=e.matrixWorldTransOrginalDrag&&(t=!0)}),t},f.onSelectAndRestoreModel=function(e){"OpDrag"==T.controls.getOperator().type&&(e?T.controls.getOperator().setRestoreMode():T.controls.getOperator().setDefaultMode())},f.restoreAllDraggedObjects=function(e){if(null!=T.draggedObjects){for(var t=0,n=T.draggedObjects.length;t<n;++t){var i=T.draggedObjects[t];T.ndsModel.restoreDraggedBody(i)}T.draggedObjects=void 0,T.selectionManager.clearSelection(),"OpDrag"==T.controls.getOperator().type&&T.controls.getOperator().setDefaultMode(),T.cameraControl.setBoundingBoxCenter(null),null!=e&&1!=e||T.render()}},f.onHideModel=function(){"OpDrag"==T.controls.getOperator().type&&T.controls.getOperator().hideSelectedModel()},f.onReverseVisibleAndHidingModel=function(){"OpDrag"==T.controls.getOperator().type&&T.controls.getOperator().reverseVisibleAndHidingModel()},f.onShowAllModel=function(){"OpDrag"==T.controls.getOperator().type&&T.controls.getOperator().showAllModel()},f.setSelectBodyByRect=function(e){var t=T.controls.getOperator();t&&t.setSelectBodyByRect(e),T.controls.staticAnnotation&&T.controls.staticAnnotation.setSelectBodyByRect(e),T.controls.staticmeasureOp&&T.controls.staticmeasureOp.setSelectBodyByRect(e)},f.opDrawGeomCreate=function(){null==T.controls.staticDrawGeomOp&&(T.controls.staticDrawGeomOp=new be(T))},f.opDrawGeomRelease=function(){T.controls.staticDrawGeomOp&&(T.controls.staticDrawGeomOp.release(),T.controls.staticDrawGeomOp=null,T.render())},f.drawGeomSetType=function(e){"OpDrawGeom"==T.controls.getOperator().type&&T.controls.getOperator().setDrawType(e)},f.drawGeomEndSpline=function(){this.controls.staticDrawGeomOp&&T.controls.staticDrawGeomOp.endSpline()},f.drawGeomSetSelectPlane=function(e){this.controls.staticDrawGeomOp&&T.controls.staticDrawGeomOp.setSelectPlane(e)},f.drawGeomSetGeomVisible=function(e){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.setGeomVisible(e)},f.drawGeomModifyMeshName=function(e,t){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.modifyMeshName(e,t)},f.drawGeomRemoveMesh=function(e){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.removeMesh(e)},f.drawGeomSelectMesh=function(e){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.selectMesh(e,!1)},f.drawGeomDeselectMesh=function(e){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.deselectMesh(e,!1)},f.drawGeomDeselectAllMesh=function(e){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.deselectAllMesh(e)},f.drawGeomHideMesh=function(e){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.hideMesh(e)},f.drawGeomShowMesh=function(e){this.controls.staticDrawGeomOp&&this.controls.staticDrawGeomOp.showMesh(e)},f.drawGeomGetAllMesh=function(){return this.controls.staticDrawGeomOp?this.controls.staticDrawGeomOp.getAllMesh():[]},f.drawGeomGetAllSelectMesh=function(){return this.controls.staticDrawGeomOp?this.controls.staticDrawGeomOp.getAllSelectMesh():[]},f.drawGeomResetPosition=function(e){if(this.controls.staticDrawGeomOp)return this.controls.staticDrawGeomOp.resetPosition(e)},f.drawGeomSetTraceMode=function(e){if(this.controls.staticDrawGeomOp)return this.controls.staticDrawGeomOp.setTraceMode(e)},f.drawTraceUpdate=function(){"OpDrawTrace"==T.controls.getOperator().type&&T.controls.getOperator().update()},f.drawTaceGetPosArray=function(){return"OpDrawTrace"==T.controls.getOperator().type?T.controls.getOperator().getPosArray():null},f.piovtSetType=function(e){var t;return"OpPiovt"==T.controls.getOperator().type?(t=this.selectionManager.getSelectedleafObjects(),Array.isArray(t)&&(T.controls.getOperator().selectedObjectUUID=t.map(function(e){return e.uuid})),T.controls.getOperator().setPiovtType(e)):null},f.translatePiovt=function(e,t){this.piovtInfoMap.has(e)&&this.piovtInfoMap.get(e).center.applyMatrix4(t)},f.rotateOnlyPiovt=function(e,t){this.piovtInfoMap.has(e)&&"Line"==(e=this.piovtInfoMap.get(e)).type&&e.normal.applyMatrix4(t).normalize()},f.rotatePiovt=function(e,t,n,i){var r,o;this.piovtInfoMap.has(e)&&(e=this.piovtInfoMap.get(e),r=(new THREE.Vector3).subVectors(e.center,t),o=(new THREE.Vector3).copy(r).normalize(),i&&o.applyQuaternion(i),o.applyQuaternion(n),e.center.copy(t).addScaledVector(o,r.length()),"Line"==e.type)&&(i&&e.normal.applyQuaternion(i).normalize(),e.normal.applyQuaternion(n).normalize())},f.clearPiovtInfoMap=function(e){for(var t=0;t<e.length;t++)this.piovtInfoMap.delete(e[t])},f.isSelectObjectsPiovtLine=function(e,t){for(var n,i,r=0<e.length,o=[],a=0;a<e.length;++a){var s=e[a],s=this.piovtInfoMap.get(s.uuid);if(!s){r=!1;break}o.push(s)}if(r)for(var l=0;r&&l<o.length-1;l++)for(var d=l+1;d<o.length;d++)if(i=o[d],(n=o[l]).type!=i.type||!("Point"==n.type?n.center.equals(i.center):"Line"==n.type?n.center.equals(i.center)&&n.normal.equals(i.normal):void 0)){r=!1;break}return r&&(t?t.push(o[0]):r="Line"==o[0].type),r},f.setMeasureProjectPlane=function(e){"OpMeasure"==T.controls.getOperator().type&&T.controls.getOperator().setMeasureProjectPlane(e)},f.setMeasureProjectDirection=function(e){"OpMeasure"==T.controls.getOperator().type&&T.controls.getOperator().setMeasureProjectDirection(e)},f.setMeasureOpType=function(e){"OpMeasure"==T.controls.getOperator().type&&T.controls.getOperator().setMeasureType(e)},f.setMeasuringScale=function(e){this.is2DModel&&(this.measuringScale=e,"OpMeasure"==T.controls.getOperator().type)&&T.controls.getOperator().setMeasureScale(e)},f.getMeasuringScale=function(){return this.measuringScale},f.onMoveForward=function(){var e=T.controls.getOperator();null!=e&&e.moveForwardBack(!0,!0)},f.onMoveBack=function(){var e=T.controls.getOperator();null!=e&&e.moveForwardBack(!1,!0)},f.onMoveLeft=function(){var e=T.controls.getOperator();null!=e&&e.pan(new THREE.Vector3(-20,0,0),!0)},f.onMoveRight=function(){var e=T.controls.getOperator();null!=e&&e.pan(new THREE.Vector3(20,0,0),!0)},f.startAnimationByUUID=function(e,t){var n;T.animationsManager&&(T.toggleAutoRotation(!1),T.animationsManager.startSolidAnimationByUUID(e,t),t&&(null==T.modelSceneOrgin&&(T.modelSceneOrgin=T.scene),null==T.modelRootObjectOrgin&&(T.modelRootObjectOrgin=T.modelRootObject),T.ndsModelBackup=T.ndsModel,T.ndsModel=null,(n=T.animationsManager.getCurrentAnimationScene())&&n!=T.scene&&(n.add(T.ambientLight),n.add(T.lightControls._scene),T.scene=n,T.modelRootObject=T.scene.children[0],T.modelRootObject.rotation.copy(T.modelRootObjectOrgin.rotation),T.modelRootObject.updateMatrix(),n.updateMatrixWorld(!0),T.showLineObjects(n,T.getLinesVisibility()),n.overrideMaterial=T.modelSceneOrgin.overrideMaterial,n.overrideMaterial&&(n.overrideMaterial.needsUpdate=!0),M)&&(M.needsUpdate=!0),T.animationsManager.isMaterialsUpdated()&&this.scene.traverse(function(e){e instanceof THREE.Line||e instanceof THREE.LineSegments||!e.hasOwnProperty("geometry")||!e.hasOwnProperty("material")||(e.material.needsUpdate=!0)}),T.annotationsManager)&&T.annotationsManager.hideAllAnnotations(T.animationsManager.getCurrentAnimationUuid()),T.animationsManager.bHasSkeletonAnimation&&(T.animationsManager.initSkeletonAnimation(),T.animationsManager.startSkeletonAnimationByUUID(e,t)),T.animationsManager.bHasMorph&&(T.animationsManager.initMorphAnimations(),T.animationsManager.startMorphAnimationByUUID(e,t)),T.runAnimation())},f.getAnimationLoopModeByUUID=function(e){return this.animationsManager?this.animationsManager.getAnimationLoopModeByUUID(e):null},f.setAnimationLoopModeByUUID=function(e,t){this.animationsManager&&this.animationsManager.setAnimationLoopModeByUUID(e,t)},f.setAnimationTimeByUUID=function(e,t){this.animationsManager&&this.animationsManager.setAnimationTimeByUUID(e,t)},f.getAnimationScaleByUUID=function(e){return this.animationsManager?this.animationsManager.getAnimationScaleByUUID(e):null},f.setAnimationScaleByUUID=function(e,t){this.animationsManager&&this.animationsManager.setAnimationScaleByUUID(e,t)},f.getAllAnimationsInfo=function(){return this.animationsManager?this.animationsManager.getAllAnimationsInfo():null},f.getAnimationInfoByUUID=function(e){return this.animationsManager?this.animationsManager.getAnimationInfoByUUID(e):null},f.hasAnimations=function(){return!!this.animationsManager&&this.animationsManager.hasAnimations()},f.runAnimation=function(){var e,t;T.animationsManager&&!T.animationsManager.isAnimationsExited()&&(requestAnimationFrame(function(){T.runAnimation()}),e=!1,T.animationsManager&&(e=T.animationsManager.update())&&(T.dispatchEvent({type:"animationFrame",time:T.animationsManager.getCurrentAnimationTime()}),T.modelRootObject.traverse(function(e){e.updateMatrix()}),T.modelRootObject.updateMatrixWorld(!0)),e)&&(D&&(e=new THREE.Vector3,t=new THREE.Vector3,T.computeBoundingBox(T.scene,e,t,{flag:!0}),T.groundShadow.updateGroundTransform(T.camera,new THREE.Box3(e,t),T.camera.worldup)),this.render(),T.animationsManager)&&T.animationsManager.getAnimationFinishedFlag()&&T.dispatchEvent({type:"animationFinished"})},f.exitAnimations=function(){var e;T.animationsManager&&(T.animationsManager.exitAnimations(),this.modelRootObject.traverse(function(e){e.updateMatrix()}),this.modelRootObject.updateMatrixWorld(!0),null!=T.modelSceneOrgin&&T.scene!=T.modelSceneOrgin&&(T.ndsModel=T.ndsModelBackup,T.showLineObjects(T.modelSceneOrgin,T.getLinesVisibility()),T.scene=T.modelSceneOrgin,T.scene.add(T.ambientLight),T.scene.add(T.lightControls._scene),T.scene.overrideMaterial&&(T.scene.overrideMaterial.needsUpdate=!0),M)&&(M.needsUpdate=!0),null!=T.modelRootObjectOrgin&&(T.modelRootObject=T.modelRootObjectOrgin),T.animationsManager.isMaterialsUpdated()&&this.scene.traverse(function(e){e instanceof THREE.Line||e instanceof THREE.LineSegments||!e.hasOwnProperty("geometry")||!e.hasOwnProperty("material")||(e.material.needsUpdate=!0)}),T.annotationsManager&&(T.annotationsManager.restoreAllAnnotations(),T.annotationsManager.setAnnotationsVisiblilityForAnimation(!1)),e=H,H=-1,this.explodeModel(e),T.toggleAutoRotation(),1==T.animationsManager.getAnimationsExitCount())&&J&&T.toggleAutoRotation(!0)},f.setModelOperationModeInternal=function(e){N=e,T.clearCenterCross()},f.setModelOperationMode=function(e,t){N!=(N=e)&&"hall"==N&&F&&(this.scene.updateMatrixWorld(!0),this.controls.SetBoundingBoxUpdated(!1),this.scene.traverse(function(e){e.hasOwnProperty("geometry")&&"lightctrls"!=e.name&&(e.matrixWorldTransOrginal&&(e.matrixWorldTransOrginal=void 0),e.matrixWorldTransOrginalDrag)&&(e.matrixWorldTransOrginalDrag=void 0)}),null!=T.modelSceneOrgin&&T.modelSceneOrgin!=this.scene&&(T.modelSceneOrgin.updateMatrixWorld(!0),T.modelSceneOrgin.traverse(function(e){e.hasOwnProperty("geometry")&&(e.matrixWorldTransOrginal&&(e.matrixWorldTransOrginal=void 0),e.matrixWorldTransOrginalDrag)&&(e.matrixWorldTransOrginalDrag=void 0)})),this.cameraControl.onOperationModeChange(t)),T.clearCenterCross(),"FirstPerson"==N&&T.drawCenterCross()},f.hasBodyRepeat=function(){if(T.ndsModel&&!T.is2DModel)for(var e=0,t=T.ndsModel.meshManager.getNumInstancedMeshes();e<t;++e){var n=T.ndsModel.meshManager.instancedMeshIds[e],i=T.ndsModel.meshManager.geomManager.getGeomFromId(T.ndsModel.meshManager.geomId[n]),n=i.refMeshes[0],r=T.ndsModel.meshManager.getBodyNode(n),o=T.ndsModel.meshManager.matrixId?T.ndsModel.meshManager.matrixId[n]:-1,i=(n=i.refMeshes[1],T.ndsModel.meshManager.getBodyNode(n));if(o===(T.ndsModel.meshManager.matrixId?T.ndsModel.meshManager.matrixId[n]:-1)&&r.worldMatrix.equals(i.worldMatrix))return!0}return!1},f.getModelOperationMode=function(e){return N},f.setModelOperationVerticalRotationRange=function(e,t){null!=t&&null!=e&&(null!=l?l.set(e,t):l=new THREE.Vector2(e,t),"hall"==N)&&F&&(e=this.camera.position.clone().sub(this.camera.getCameraTarget()).angleTo(THREE.Object3D.DefaultUp),t=.5*Math.PI-e>=Math.abs(l.y)*Math.PI/180,e=0<e-.5*Math.PI&&e-.5*Math.PI>=Math.abs(l.x)*Math.PI/180,t||e)&&(this.scene.updateMatrixWorld(!0),this.controls.SetBoundingBoxUpdated(!1),this.scene.traverse(function(e){e.hasOwnProperty("geometry")&&"lightctrls"!=e.name&&(e.matrixWorldTransOrginal&&(e.matrixWorldTransOrginal=void 0),e.matrixWorldTransOrginalDrag)&&(e.matrixWorldTransOrginalDrag=void 0)}),null!=T.modelSceneOrgin&&T.modelSceneOrgin!=this.scene&&(T.modelSceneOrgin.updateMatrixWorld(!0),T.modelSceneOrgin.traverse(function(e){e.hasOwnProperty("geometry")&&"lightctrls"!=e.name&&(e.matrixWorldTransOrginal&&(e.matrixWorldTransOrginal=void 0),e.matrixWorldTransOrginalDrag)&&(e.matrixWorldTransOrginalDrag=void 0)})),this.camera.setOrginalCameraInfo(void 0),this.camera.up.set(0,1,0),t=new THREE.Matrix4,Math.abs(l.y)<4.5?t.lookAt(new THREE.Vector3(1,0,1),new THREE.Vector3,this.camera.up):t.lookAt(new THREE.Vector3(1,.1,1),new THREE.Vector3,this.camera.up),this.camera.quaternion.setFromRotationMatrix(t),this.resetCamera({useOrginal:!0}))},f.getModelOperationVerticalRotationRange=function(){return l},f.isLineExisted=function(){var t=!1;return this.scene.traverse(function(e){(e instanceof THREE.Line||e instanceof THREE.LineSegments)&&e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(T.materialsSetting&&T.materialsSetting.getMaterialsMarkersMat()==e.material||(t=!0))}),t},f.isModelExplosionAbled=function(){void 0===THREE.Object3D.prototype.tranverseWithCondition&&(THREE.Object3D.prototype.tranverseWithCondition=function(e){if(!e(this))for(var t=this.children,n=0,i=t.length;n<i;n++)"lightctrls"!=t[n].name&&t[n].tranverseWithCondition(e)});var t=0;return this.scene.tranverseWithCondition(function(e){return T.isObjectTypeOfElement(e)?(++t,!0):(e instanceof THREE.Line||e instanceof THREE.LineSegments||!e.hasOwnProperty("geometry")||!e.hasOwnProperty("material")||++t,!1)}),1<t},f.getExplodeFactor=function(){return H},f.setExplodeFactor=function(e){H=e},f.getExplodeMode=function(){return this.ndsModel.explodeMode},f.getExplodeLevel=function(){return this.ndsModel.explodeLevel},f.getBroadcastInfo=function(){return T.broadcastManager.getBroadcastInfo()},f.setToolbarVisibility=function(e){T.Optoolbar&&T.Optoolbar.setVisibility(e)},f.getToolbarVisibility=function(){return!!T.Optoolbar&&T.Optoolbar.getVisibility()},f.startBroadcast=function(e){T.broadcastManager.startBroadcast(e)},f.exitBroadcast=function(){T.broadcastManager.exitBroadcast()},f.setBroadcastInfo=function(e){T.broadcastManager.setBroadcastInfo(e)},f.getIntersectionPtByScreenPt=function(e,t){T.rayCaster||(T.rayCaster=new kn(this));var n,i=null;return T.ndsModel?(n=T.selectionManager.getPickIntersects(e[0],e[1]))&&0<n.length&&(i={coords:[n[0].point.x,n[0].point.y,n[0].point.z],locationObjectUUID:n[0].bodyNode.uuid,locationObject:n[0].bodyNode}):i=T.rayCaster.convertPointScreen(e,t),i},f.stopPMIOcclusion=function(e){for(var t in _e.StopPMIOcclusion=e,this.PMIUUIDtoPMIObject){t=this.PMIUUIDtoPMIObject[t];t.material&&(t.material.depthTest=!e)}this.render()},f.clientCoordToModelCoord=function(e){var t,n=T.renderer.getPixelRatio(),i=T.renderer.domElement,r=(3==e.length?t=e[2]:(r=new THREE.Vector3,T.controls.getBoundingBox().getCenter(r),r.project(T.camera),(t=r.z)<-1&&(t=-.99)),new THREE.Vector3),e=(r.set(e[0]*n/i.width*2-1,2*-(e[1]*n/i.height)+1,t),r.unproject(T.camera),[]);return e[0]=r.x,e[1]=r.y,e[2]=r.z,e},f.modelCoordToClientCoord=function(e){var t=T.renderer.getPixelRatio(),n=T.renderer.domElement,i=n.width/2,n=n.height/2,e=new THREE.Vector3(e[0],e[1],e[2]),i=(e.project(T.camera),(e.x*i+i)/t),n=(-e.y*n+n)/t,t=[];return t[0]=Math.round(i),t[1]=Math.round(n),t[2]=e.z,t},f.computeModelScreenBBox=function(){for(var e=T.controls.getBoundingBox(),t=e.min,e=e.max,n=[],i=t.clone(),r=(n.push(i),(i=t.clone()).set(e.x,t.y,t.z),n.push(i),(i=t.clone()).set(e.x,e.y,t.z),n.push(i),(i=t.clone()).set(t.x,e.y,t.z),n.push(i),(i=t.clone()).set(t.x,t.y,e.z),n.push(i),(i=t.clone()).set(e.x,t.y,e.z),n.push(i),(i=t.clone()).set(e.x,e.y,e.z),n.push(i),(i=t.clone()).set(t.x,e.y,e.z),n.push(i),new THREE.Vector2),o=new THREE.Vector2,a=0;a<n.length;a++){var s=[],s=(s[0]=n[a].x,s[1]=n[a].y,s[2]=n[a].z,T.modelCoordToClientCoord(s));0==a?(r.x=s[0],r.y=s[1],o.x=s[0],o.y=s[1]):(r.x=Math.min(r.x,s[0]),r.y=Math.min(r.y,s[1]),o.x=Math.max(o.x,s[0]),o.y=Math.max(o.y,s[1]))}return{min:r,max:o}},f.createScaledSphere=function(e,t){var n=new THREE.Mesh(new THREE.SphereBufferGeometry(1,24,24),new THREE.MeshBasicMaterial({color:16776960}));return n.cameraScale=.005,t&&(null!=t.color&&n.material.color.setHex(t.color),null!=t.scale)&&(n.cameraScale=t.scale),n.name="scaledSphere",n.position.set(e[0],e[1],e[2]),this.additionalObjectsScene&&this.additionalObjectsScene.add(n),this.render(),{uuid:n.uuid}},f.updateAdditionalObjectsScene=function(){this.additionalObjectsScene&&this.additionalObjectsScene.traverse(function(e){var t;"scaledSphere"==e.name&&(t=e.position.distanceTo(T.camera.position)*e.cameraScale,e.scale.set(t,t,t))})},f.setObjectVisibilityByUuid=function(e,t){this.additionalObjectsScene&&(e=this.additionalObjectsScene.getObjectByProperty("uuid",e))&&(e.visible=t,this.render())},f.removeObjectByUuid=function(e){var t,n=!1;if(T.additionalObjectsScene&&(t=T.additionalObjectsScene.getObjectByProperty("uuid",e))&&(t.parent.remove(t),n=!0,T.render()),!n)if(T.ndsModel){var i=T.ndsModel.getBodyNodeFromUuid(e);i&&(T.selectionManager.isObjectSelected(i)&&T.selectionManager.deselectObject(i),T.ndsModel.delete(i),T.render())}else if(t=T.scene.getObjectByProperty("uuid",e)){t.parent.remove(t),n=!0,t==T.modelRootObject&&(T.modelRootObject=null),T.selectionManager.computeTargetList(T.scene);var r=[];if(!function e(t,n){var i=t.children;if((null==i||i.length<=0||t instanceof THREE.SkinnedMesh)&&t.material)n.push(t);else for(var r=0,o=i.length;r<o;++r)e(i[r],n)}(t,r),0<r.length)for(var o=0;o<r.length;o++)for(var a=0;a<T.originalMeshes.length;a++)if(T.originalMeshes[a].key==r[o]){T.originalMeshes[a]=null,T.originalMeshes.splice(a,1);break}T.render()}n&&T.controls.SetBoundingBoxUpdated(!1)},f.createPlaneByWorldPoints=function(e,t,n,i){if(!t){if(null==i)return null;if(i.length<9)return null}var r,o=T.controls.getBoundingBox().min,o=T.controls.getBoundingBox().max.distanceTo(o),a=new THREE.Plane,s=new THREE.Vector3(i[0],i[1],i[2]),l=new THREE.Vector3(i[3],i[4],i[5]),i=new THREE.Vector3(i[6],i[7],i[8]),i=(a.setFromCoplanarPoints(s,l,i),t?r=new THREE.Vector3(0,0,0):(s=T.controls.getBoundingBox().getCenter(),l=a.distanceToPoint(s),(r=s.clone()).sub(a.normal.clone().multiplyScalar(l))),{uuid:"",normal:[a.normal.x,a.normal.y,a.normal.z],point:[r.x,r.y,r.z]});if("square"==e){var t=new THREE.PlaneGeometry(o,o,1,1),s=new THREE.Mesh(t,new THREE.MeshBasicMaterial({color:16776960,side:THREE.DoubleSide,opacity:.4})),d=(i.uuid=s.uuid,new THREE.BufferGeometry),c=((u=new Float32Array(15))[0]=-.5*o,u[1]=-.5*o,u[3]=.5*o,u[4]=-.5*o,u[6]=.5*o,u[7]=.5*o,u[9]=-.5*o,u[10]=.5*o,u[12]=-.5*o,u[13]=-.5*o,d.addAttribute("position",new THREE.BufferAttribute(u,3)),new THREE.Line(d,new THREE.LineBasicMaterial({color:0})));s.add(c),n&&(null!=n.planeColor&&s.material.color.setHex(n.planeColor),null!=n.lineColor&&c.material.color.setHex(n.lineColor),null!=n.opacity)&&(s.material.opacity=n.opacity),s.position.copy(r),s.material.transparent=!0,(f=new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),a.normal),s.quaternion.copy(f),this.additionalObjectsScene&&this.additionalObjectsScene.add(s)}else if("circle"==e){for(var h=new THREE.CircleBufferGeometry(.5*o,32),l=new THREE.Mesh(h,new THREE.MeshBasicMaterial({color:16776960,side:THREE.DoubleSide,opacity:.4})),d=(i.uuid=l.uuid,new THREE.BufferGeometry),u=new Float32Array(99),p=0;p<33;p++)u[3*p]=h.attributes.position.array[3*(p+1)],u[3*p+1]=h.attributes.position.array[3*(p+1)+1],u[3*p+2]=h.attributes.position.array[3*(p+1)+2];d.addAttribute("position",new THREE.BufferAttribute(u,3));var f,c=new THREE.Line(d,new THREE.LineBasicMaterial({color:0}));l.add(c),n&&(null!=n.planeColor&&l.material.color.setHex(n.planeColor),null!=n.lineColor&&c.material.color.setHex(n.lineColor),null!=n.opacity)&&(l.material.opacity=n.opacity),l.material.transparent=!0,l.position.copy(r),(f=new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),a.normal),l.quaternion.copy(f),this.additionalObjectsScene&&this.additionalObjectsScene.add(l)}return this.render(),i},f.OpMeasureRelease=function(){T.controls.staticmeasureOp&&(T.controls.staticmeasureOp.release(),T.controls.staticmeasureOp=null,T.render())},f.onCloseClipControl=function(){T.clipPlaneManager.onCloseClipControl(),T.clipBoxManager.SetRenderBox(!1),T.render()},f.onOpenClipControl=function(){T.clipPlaneManager.isSectionViewEnabled()&&T.clipPlaneManager.onOpenClipControl(),T.clipBoxManager.SetRenderBox(!0),T.render()},f.createPlaneByScreenPoints=function(e,t,n){var i,r,o,a,s;return null==t||t.length<4?null:((i=new THREE.Matrix4).multiplyMatrices(this.camera.matrixWorld,i.getInverse(this.camera.projectionMatrix)),r=this.renderer.getPixelRatio(),o=this.renderer.domElement,a=[],(s=new THREE.Vector3).set(t[0]*r/o.width*2-1,2*-(t[1]*r/o.height)+1,0),s.applyMatrix4(i),a.push(s.x),a.push(s.y),a.push(s.z),s.set(t[2]*r/o.width*2-1,2*-(t[3]*r/o.height)+1,0),s.applyMatrix4(i),a.push(s.x),a.push(s.y),a.push(s.z),s.set(t[0]*r/o.width*2-1,2*-(t[1]*r/o.height)+1,.1),s.applyMatrix4(i),a.push(s.x),a.push(s.y),a.push(s.z),this.createPlaneByWorldPoints(e,a,n))},f.setMeshVertexColorByUuid=function(e,t,n){if(e&&t){var i=this.scene.getObjectByProperty("uuid",e);if(i&&i.geometry&&i.geometry instanceof THREE.BufferGeometry&&null!=i.geometry.attributes.position){var r=i.geometry.attributes.position.count;if(i.material&&i.material.color){for(var o=new Float32Array(3*r),a=0;a<r;++a)o[3*a+0]=i.material.color.r,o[3*a+1]=i.material.color.g,o[3*a+2]=i.material.color.b;for(var s=new THREE.Color,a=0,l=t.length;a<l;++a){var d=t[a].index;d<r&&(s.setHex(t[a].color),o[3*d+0]=s.r,o[3*d+1]=s.g,o[3*d+2]=s.b)}i.geometry.addAttribute("color",new THREE.BufferAttribute(o,3)),i.material=i.material.clone(),i.material.vertexColors=!0,i.material.needsUpdate=!0,0!=n&&this.render()}}}},f.getReleaseInfo=function(e,t,n){var i;Te.getExtension("SceneEditExtension")&&(i=Te.getExtension("SceneEditExtension"),T._enableGroundShadow=D,T._bEnableEnvMapBlur=b,i.getReleaseInfo(e,t,n))},f.removeMeshVertexColorByUuid=function(e,t){e=this.scene.getObjectByProperty("uuid",e);e&&e.geometry&&e.geometry instanceof THREE.BufferGeometry&&null!=e.geometry.attributes.color&&(e.geometry.removeAttribute("color"),e.material&&(e.material.vertexColors=!1,e.material.needsUpdate=!0),0!=t)&&this.render()},f.clear=function(){this.ndsModel&&(this.ndsModel.dispose(),this.scene.remove(this.ndsModel),this.ndsModel=null),this.pmiObject&&(this.pmiObject.traverse(function(e){e.geometry&&e.geometry.dispose()}),this.scene.remove(this.pmiObject),this.pmiObject=null),this.animationsManager=new tn(this),this.pmiObject=null,this.haspartPMI=!1,this.hasAssemblyPMI=!1,this.PartPMIuuid=[],this.explodeObjects=[],this.brepManager=null,this.inWaitProcedure=!1,this.inWheel=!1,this.viewer2DInfo={center:new THREE.Vector3(0,0,0),normal:new THREE.Vector3(0,0,1),yDir:new THREE.Vector3(0,1,0),distance:100},this.annotationsManager=void 0,this.materialsSetting=void 0,this.propertyManager=void 0,this.containProperty=!1,this.trueMapList=null,this.commentManager.clear(),this.ndsModel=null,this.ndsModelBvhLoaded=!1,this.ndsModelPMILoaded=!1,this.ndsModelObjectTreeLoaded=!1,this.nBufferChunks=0,this.nBufferChunksLoaded=0},f.onUpdateProgress=function(e){e=e.userData.precent;.99<=e?T.progressBar.style.visibility="hidden":(T.progressBarFrontground.style.width=T.progressBarWidth*e+"px",T.progressBar.style.visibility="visible")},f.loadBrepInfo=function(e){this.brepManager||(this.brepManager=new Tt(this,this.modelRequestor)),this.brepManager.loadBreps(e)},f.dispatchBrepEvent=function(){var e;this.brepLoadIndex++,2==this.brepLoadIndex&&(e=!!(this.ndsModel&&this.modelRootObject&&this.modelRootObject.boundingBox),this.dispatchEvent({type:"BrepInfoEvent",faceArea:this.brepInfo.BfaceArea,bodyVolume:this.brepInfo.BbodyVolume,totalVolume:this.brepInfo.BbodyVolume,bodyArea:this.brepInfo.BbodyArea,totalArea:this.brepInfo.BtotalArea,boundingbox:!(!this.brepInfo.BfaceArea||!e),facePerimeter:this.brepInfo.BfacePerimeter}))},f.hasBrepInfo=function(){return!!this.brepManager&&this.brepManager.hasBrepInfo()},f.hasBrepFile=function(){return!!this.brepManager&&this.brepManager.hasBrepFile()},f.enableRotation=function(e){u=e,T.viewBox&&T.viewBox.enableViewBox(e)},f.isRotationEnable=function(){return u},f.enablePreSelection=function(e){0==(_e.enablePreSelectBrep=e)&&this.selectionManager.clearPreSelection()},f.enableDirectMoveAndRotate=function(e){_e.enableDirectMove=e,_e.enableDirectRotate=e},f.enableDirectMove=function(e){_e.enableDirectMove=e},f.enableDirectRotate=function(e){_e.enableDirectRotate=e},f.getSelectList=function(){var e=T.ndsModel.getSelectedBodies(),t=[],n=(e.forEach(function(e){return t.push(e.objectid)}),[]);return t.forEach(function(e){for(var t=T.getObjectByUUID(T.ndsModel.objectidTouuid[e]);t.parent&&T.ndsModel.isBodyAllChildSelected(t.parent)&&-1==n.indexOf(t.parent.objectid);)n.push(t.parent.objectid),t=t.parent}),_e.HideLeafBody?n:t.concat(n)},f.showObjectbyId=function(e,t,n){for(var i=0;i<e.length;i++){var r=T.ndsModel.objectidTouuid[e[i]];T.showObject(T.getObjectByUUID(r),t,n&&i==e.length-1)}},f.ObjectIdTouuid=function(e){return T.ndsModel.objectidTouuid[e]},f.ObjectuuidToId=function(e){return T.getBodyNodeFromUuid(e).objectid},f.addSelectList=function(e,t,n){if(t)T.selectionManager.selectObjectByList(e,n);else{var i=[];if(e.forEach(function(e){e=T.ndsModel.objectidTouuid[e],e=T.getObjectByUUID(e);e&&(!0===n?i.push(e):T.selectionManager.deselectObject(e))}),!0===n)for(var r=0;r<i.length;r++)T.selectionManager.deselectObject(i[r],r==i.length-1)}T.render()},f.setTransparentState=function(e,t){var n=[];e.forEach(function(e){return n.push(T.getBodyNodeFromUuid(T.ndsModel.objectidTouuid[e]))}),n.length<=0||(t?(T.ndsModel.inIsolate()?T.ndsModel.transparentizeBodiesOnly(n):T.ndsModel.transparentizeBodies(n),T.render()):T.hasObjectIsolated()&&(T.ndsModel.isolateBodiesOnly(n),T.render()))},f.changeObjectColorByid=function(e,t){e.forEach(function(e){e=T.ndsModel.objectidTouuid[e];T.changeObjectColor(e,t)})},f.zoomToObjectById=function(e){e=T.ndsModel.objectidTouuid[e],e=T.getBodyNodeFromUuid(e);T.zoomToObject(e,!0)},f.dispatchAsyncEvent=function(e){setTimeout(function(){T.dispatchEvent(e)},.5)},f.addIconToContainer=function(e,t,n){this.container.appendChild(e)},f.removeIconFromContainer=function(e,t){this.container.removeChild(e)},f.syncSendMsg=function(e){e.UnitState=this.userModelUnit,this.AssemblyPMIState&&(e.AssemblyPMIState=this.AssemblyPMIState,this.AssemblyPMIState=null),this.PartPMIState&&(e.PartPMIState=this.PartPMIState,this.PartPMIState=null),this.PartPMIState||this.AssemblyPMIState||(e.pmiVisible=this.pmiVisible),this.exchangeBackImage&&(e.exchangeBackImage=this.exchangeBackImage),null!=this.oneKeyColor.isActive&&!0===this.oneKeyColor.isActive?(e.useRandomColor=!0,e.randColor=this.oneKeyColor.color,this.oneKeyColor.isActive=!0):null!=this.oneKeyColor.isActive&&!1===this.oneKeyColor.isActive&&(e.useRandomColor=!1,e.randColor=null,this.oneKeyColor.isActive=null),0<this.exchangeNodeColor.length&&(e.exchangeNodeColor=this.exchangeNodeColor),this.isSectionViewEnabled()&&(e.ClipPlaneVisible=this.clipPlaneManager.getClipPlaneVisible(),e.showClipControl=this.clipPlaneManager.getClipControlVisible())},f.syncGetMsg=function(e){e.ClearColor!=T.renderer.getClearColor(this.oldClearColor).getHex()&&this.setBackGroundColor(e.ClearColor),e.UnitState!=this.userModelUnit&&this.setDispalyModelUnit(e.UnitState);var t=!1;if(e.AssemblyPMIState&&null!=e.AssemblyPMIState.visible&&(t=!0,this.setAssemblyPMIVisible(e.AssemblyPMIState.visible)),e.PartPMIState&&null!=e.PartPMIState.visible&&(t=!0,this.setPartPMIVisible(e.PartPMIState.visible)),t||this.setPmiVisible(e.pmiVisible),e.exchangeBackImage&&("Image"===e.exchangeBackImage.type?(this.setEnvMapTextures(null),this.setBackGroundImage(e.exchangeBackImage.value)):"EnvMap"===e.exchangeBackImage.type?this.setEnvMapTextures(e.exchangeBackImage.value):"Color"===e.exchangeBackImage.type&&(this.setEnvMapTextures(null),this.setBackGroundImage(null),this.setBackGroundColor(e.exchangeBackImage.value))),null!=e.useRandomColor&&!0===e.useRandomColor?this.autoChangeObjectColor(!0,e.randColor):null!=e.useRandomColor&&!1===e.useRandomColor&&(this.autoChangeObjectColor(!1,null),e.useRandomColor=null),e.exchangeNodeColor)for(var n=0;n<e.exchangeNodeColor.length;n++)this.changeObjectColor(e.exchangeNodeColor[n].objectUUID,e.exchangeNodeColor[n].color);this.isSectionViewEnabled()&&e.showClipControl!=this.clipPlaneManager.getClipControlVisible()&&(e.showClipControl?this.clipPlaneManager.onOpenClipControl():this.clipPlaneManager.onCloseClipControl())},f.Countermand=function(){this.countermandarray=[],this.countermandflag=-1},f.CountermandRecode=function(){for(var e=[],t=[],n=[],i=[],r={},o=0,a=T.ndsModel.wholeLeafBodyNodes.length;o<a;++o){var s=T.ndsModel.wholeLeafBodyNodes[o];s.leafBodyAttri&&(s.isHidden()?T.ndsModel.objectidTouuid?t.push(s.objectid):t.push(s.id):T.ndsModel.objectidTouuid?e.push(s.objectid):e.push(s.id),T.ndsModel.inIsolate())&&(!s.isIsolated()&&s.isTransparent()?T.ndsModel.objectidTouuid?n.push(s.objectid):n.push(s.id):T.ndsModel.objectidTouuid?i.push(s.objectid):i.push(s.id))}if(0==t.length?r.meshInvisible=[]:0==e.length&&0<t.length?r.meshVisible=[]:t.length<=e.length?r.meshInvisible=t:r.meshVisible=e,n.length<=i.length?r.meshTrans=n:r.meshNoTrans=i,this.countermandflag==this.countermandarray.length-1)if(this.countermandarray.length<11)this.countermandarray.push(r);else{for(o=0;o<10;++o)this.countermandarray[o]=this.countermandarray[o+1];this.countermandarray[10]=r}else{this.countermandarray[this.countermandflag+1]=r;for(var l=this.countermandarray.length-this.countermandflag-2;0<l;)this.countermandarray.pop(),l--}this.countermandflag=this.countermandarray.length-1},f.CountermandStep=function(e){if(!(e&&this.countermandflag>this.countermandarray.length-2||!e&&this.countermandflag<1||this.countermandarray.length<2)){e?this.countermandflag++:this.countermandflag--;var t=this.countermandarray[this.countermandflag];if(t.meshVisible&&T.ndsModel){T.ndsModel.hideBody(T.ndsModel.rootBodyNode);for(var n=0;n<t.meshVisible.length;++n)r=this.ndsModel.objectidTouuid?(o=T.ndsModel.objectidTouuid[t.meshVisible[n]],T.ndsModel.getBodyNodeFromUuid(o)):T.ndsModel.getBodyNode(t.meshVisible[n]),T.ndsModel.hasHiddenBodies=!0,r.show()}if(t.meshInvisible&&T.ndsModel){T.ndsModel.showBody(T.ndsModel.rootBodyNode);for(n=0;n<t.meshInvisible.length;++n)r=this.ndsModel.objectidTouuid?(o=T.ndsModel.objectidTouuid[t.meshInvisible[n]],T.ndsModel.getBodyNodeFromUuid(o)):T.ndsModel.getBodyNode(t.meshInvisible[n]),T.ndsModel.hasHiddenBodies=!0,r.hide(),T.ndsModel.meshManager.setGeomSameMaterialFlag(r)}if(T.ndsModel&&T.ndsModel.inIsolate()&&T.ndsModel.exitIsolate(),t.meshTrans&&0<t.meshTrans.length&&T.ndsModel){for(var i=[],n=0;n<t.meshTrans.length;++n)r=this.ndsModel.objectidTouuid?(o=T.ndsModel.objectidTouuid[t.meshTrans[n]],T.ndsModel.getBodyNodeFromUuid(o)):T.ndsModel.getBodyNode(t.meshTrans[n]),i.push(r);T.ndsModel.transparentizeBodies(i)}if(t.meshNoTrans)if(0<t.meshNoTrans.length){for(var r,o,i=[],n=0;n<t.meshNoTrans.length;++n)r=this.ndsModel.objectidTouuid?(o=T.ndsModel.objectidTouuid[t.meshNoTrans[n]],T.ndsModel.getBodyNodeFromUuid(o)):T.ndsModel.getBodyNode(t.meshNoTrans[n]),i.push(r);T.ndsModel.isolateBodies(i,_e.bodyOpacity,_e.lineOpacity)}else 0==t.meshNoTrans.length&&((e=[]).push(T.ndsModel.rootBodyNode),T.ndsModel.transparentizeBodies(e));T.render()}},f.CountermandTest=function(e){return!(e&&this.countermandflag>this.countermandarray.length-2||!e&&this.countermandflag<1||this.countermandarray.length<2)},f.getObjectProByName=function(e,o){var t,a=new Array(o.length);return"string"!=typeof e&&(e=e.toString()),T.bodyUuid2ClonedNodeMap[e]&&T.bodyUuid2ClonedNodeMap[e].propertyfile&&T.bodyUuid2ClonedNodeMap[e].propertyList?(T.bodyUuid2ClonedNodeMap[e].propertyList.forEach(function(e){for(var t in e)for(var n=e[t],i=0;i<n.length;i+=2){var r=n[i],r=o.indexOf(r);-1!=r&&(a[r]=n[i+1])}}),t=[],a.forEach(function(e){e&&t.push(e)}),t):[]},f.getPMIInfo=function(){var e,t=[];for(e in T.PMIUUIDtoPMIObject){var n=T.PMIUUIDtoPMIObject[e];n.children&&0<n.children.length&&("Mesh"==n.children[0].type||"Line"==n.children[0].type||"LineSegments"==n.children[0].type)&&(n={id:n.uuid,name:n.name,type:n.type,bodyNodeName:n.NdsBodyNode.parent.parent.name,bodyNodeID:n.NdsBodyNode.parent.parent.objectid},t.push(n))}return t},f.getPMIObject=function(){return T.pmiObject?T.pmiObject.children[0]:null},f.selectPMIObject=function(e,t){if(void 0===t&&(t=!0),e instanceof Ae){if("PMI"==e.name&&"PMI"==e.type){for(var n=0;n<e.children.length;n++){var i=e.children[n];this.selectPMIObject(i,t)}return}e=this.PMIUUIDtoPMIObject[e.uuid]}this.ndsModel.selectPMIObject(e,t)},f.deselectPMIObject=function(e,t){if(void 0===t&&(t=!0),e instanceof Ae){if("PMI"==e.name&&"PMI"==e.type){for(var n=0;n<e.children.length;n++){var i=e.children[n];this.deselectPMIObject(i,t)}return}e=this.PMIUUIDtoPMIObject[e.uuid]}this.ndsModel.deselectPMIObject(e,t)},f.setCaptureView=function(e,t){void 0===t&&(t=!1),this.setPMIObjectVisible(T.pmiObject.children[0],!1),this.deselectPMIObject(T.pmiObject.children[0],!0),T.dispatchAsyncEvent({type:"deselPMI",object:T.pmiObject.children[0]}),e.pmiuuids&&0<e.pmiuuids.length&&e.pmiuuids.forEach(function(e){e=T.PMIUUIDtoPMIObject[e];e&&(T.setPMIObjectVisible(e,!0),T.dispatchAsyncEvent({type:"selPMI",object:e}))});var n,i,r=new THREE.Vector3(e.matrix[8],e.matrix[9],e.matrix[10]),o=(r.normalize(),new THREE.Vector3(e.matrix[4],e.matrix[5],e.matrix[6])),e=(o.normalize(),t?(this.onSectionView(!0,!1),t={clipGlobalPlaneObjects:[]},n=new THREE.Plane(new THREE.Vector3(0,0,-1),0),i=new THREE.Vector3(e.matrix[12],e.matrix[13],e.matrix[14]),n.setFromNormalAndCoplanarPoint(e.normal.clone(),i),(e=new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,-1),n.normal),i={position:i,quaternion:new THREE.Quaternion,meshquaternion:e},t.clipGlobalPlaneObjects.push(i),t.planeNameToId={},t.planeNameToId.YZ=-1,t.planeNameToId.XY=0,t.planeNameToId.XZ=-1,t.clippingPlanes=[n],t.clipActiveId=0,t.planeVisible=!1,t.clipModeState="both",t.fromView=!0,this.setClipPlaneInfor(t),this.onCloseClipControl()):this.onSectionView(!1,!1),{smoothTranslation:!0});e.from=r.toArray(),e.up=o.toArray(),T.look(e)},f.isPMIObjectOrSomeChildHidden=function(e){if(e instanceof Ae){if("PMI"==e.name&&"PMI"==e.type){for(var t=0;t<e.children.length;t++){var n=e.children[t];if(!this.isPMIObjectOrSomeChildHidden(n))return!1}return!0}e=this.PMIUUIDtoPMIObject[e.uuid]}var i=!0;return e.traverse(function(e){0!=e.visible&&!e.SelectVisible||(i=!1)}),i},f.getPMIObjectOrSomeChildVisibleStatus=function(e){var t=0,n=0;if(e instanceof Ae){if("PMI"==e.name&&"PMI"==e.type){for(var i=0;i<e.children.length;i++){var r=e.children[i];t++,this.isPMIObjectOrSomeChildHidden(r)&&n++}if(n<t&&0!=n)return 2}e=this.PMIUUIDtoPMIObject[e.uuid]}return e&&e.traverse&&e.traverse(function(e){e.visible&&!e.SelectVisible&&n++,t++}),0==t?0:n==t?1:0!=n&&n<t?2:0},f.isPMIObjectSelect=function(e){if(e instanceof Ae){if("PMI"==e.name&&"PMI"==e.type){for(var t=0;t<e.children.length;t++){var n=e.children[t];this.isPMIObjectSelect(n)}return}e=this.PMIUUIDtoPMIObject[e.uuid]}var i=!0;return e.traverse(function(e){e.select||"Mesh"!=e.type&&"Line"!=e.type&&"LineSegments"!=e.type||(i=!1)}),i},f.getPMISelectList=function(){var t;if(T.pmiObject)return t=[],T.pmiObject.traverse(function(e){e.select&&0<e.children.length&&("Mesh"==e.children[0].type||"Line"==e.children[0].type||"LineSegments"==e.children[0].type)&&t.push(e)}),t},f.getPMINDSBodySelectList=function(){var t;if(T.pmiObject)return t=[],T.PMINDSBodys.forEach(function(e){T.isPMIObjectSelect(e)&&t.push(e)}),t},f.setPMIObjectVisible=function(e,t){if(e instanceof Ae){if("PMI"==e.name&&"PMI"==e.type){for(var n=0;n<e.children.length;n++){var i=e.children[n];this.setPMIObjectVisible(i,t)}return}e=this.PMIUUIDtoPMIObject[e.uuid]}var r=T.pmiObject.children[0];if(0==r.visible&&(r.visible=!0),!t&&e.select&&e.visible)e.SelectVisible=!0,e.traverse(function(e){e.SelectVisible=!0});else{r.uuid!=e.uuid&&(e.visible=t)&&e.SelectVisible&&(e.SelectVisible=!1),e.traverse(function(e){(e.visible=t)&&e.SelectVisible&&(e.SelectVisible=!1)});for(var o=e;o&&o.parent;)t&&(o.parent.visible=t),o=o.parent;this.render()}},f.shwoFollowCameraPmi=function(){T.pmiObject.children[0].traverse(function(e){e.followCamera&&T.setPMIObjectVisible(e,!0)})},f.renderWaterMark=function(){if((l=this.watermark)&&this.excalibur)if(Se.isMobileDevice()){l=l.substr(0,20);var e=Math.cos(45*Math.PI/180),t=Math.sin(45*Math.PI/180),n=(s=this.canvas2D.width/2)*e-(a=this.canvas2D.height/2)*t,t=s*t+a*e,i=l.length+1;(d=this.canvas2D.getContext("2d")).rotate(-45*Math.PI/180),d.clearRect(n-24*i,t-48,48*i,60),d.font="bold 48px Arial",d.textAlign="center",d.fillStyle="#137FE2",d.globalAlpha=this.is2DModel?.2:.05,d.fillText(l,n,t),d.rotate(45*Math.PI/180),d.globalAlpha=1}else{var r=0,o=0,a=0,s=0,r=-this.canvas2D.width;for(s=0;r<this.canvas2D.width;r+=150,s++){for(a=o=0;o<2*this.canvas2D.height;o+=100,a++){var l,d,i=(l=l.substr(0,20)).length+1;(d=this.canvas2D.getContext("2d")).rotate(-25*Math.PI/180),d.clearRect(r-18*i/2,o-18,18*i,27),d.font="bold 18px Arial",d.textAlign="center",d.fillStyle="#000000",d.globalAlpha=.1,d.fillText(l,r,o),d.rotate(25*Math.PI/180),d.globalAlpha=1}r+=18*i}}},f.createPicNote=function(){"OpAnnotationNew"==T.controls.getOperator().type&&(document.getElementById("picLoad").click(),T.controls.getOperator().setMode("Picture"))},f.createPicNote2=function(e,t,n,i,r,o){T.controls.staticAnnotation||(a=T.controls.getOperator().type,T.setOperatorByID("OpAnnotationNew"),T.setOperatorByID(a));var a=new THREE.Vector3(e.x,e.y,e.z);0<this.ndsModel.ModelUpMatrix4.length&&((e=new THREE.Matrix4).fromArray(this.ndsModel.ModelUpMatrix4),a.applyMatrix4(e)),T.controls.staticAnnotation.createPicNote(a,t,n,i,r,o)},f.setPicTextVisible=function(e,t){T.controls.staticAnnotation&&T.controls.staticAnnotation.setPicTextVisible(e,t)},f.setSelectIdArray=function(e,t){T.controls.staticAnnotation&&T.controls.staticAnnotation.setSelectIdArray(e,t)},f.getSelectContent=function(){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.getSelectContent()},f.getAnnotationColorAndOpacity=function(e){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.getAnnotationColorAndOpacity(e)},f.createNote=function(){T.controls.staticAnnotation&&T.controls.staticAnnotation.createText()},f.showNoteAnnotation=function(e){T.controls.staticAnnotation&&T.controls.staticAnnotation.showNoteAnnotation(e),this.render()},f.getShowNoteAnnotation=function(){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.AnnotationShow},f.getAllAnnotation=function(){var e,t=[],n=this.getAllNoteContent(),i=(n&&0<n.length&&(t=t.concat(n)),(n=this.GetMeasurePointData())&&0<n.length&&(t=t.concat(n)),[]);for(e in n=this.annotationsManager.getAnnotationsArray()){var r=n[e];i.push(function(e){var t,n=e,i={};for(t in n)"locationObject"!=t&&(i[t]=n[t]);return i.type="Annotation",i.configNum=T.ConfigNum,i.configName=T.ConfigName,i}(r))}return t=t.concat(i)},f.changeAnnotationIndex=function(e,t){var n;this.annotationsManager&&(n=this.annotationsManager.getAnnotationsArray())[e]&&(n[e].index=t),this.render()},f.getAllNoteContent=function(){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.getAllNoteContent()},f.GetMeasurePointData=function(){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.GetMeasurePointData()},f.deleteNoteAnnotation=function(e){T.controls.staticAnnotation&&T.controls.staticAnnotation.deleteNoteAnnotation(e,!1),this.render()},f.showEditIcon=function(e){this._editIconVisible=e},f.showDeleteIcon=function(e){this._deleteIconVisible=e},f.clearAnnotation=function(){T.controls.staticAnnotation&&T.controls.staticAnnotation.clearAnnotation(),this.render()},f.setTransparent=function(e,t){T.controls.staticAnnotation&&T.controls.staticAnnotation.setTransparent(e,t),this.render()},f.setNoteColor=function(e,t){T.controls.staticAnnotation&&T.controls.staticAnnotation.setNoteColor(e,t),this.render()},f.setNoteLineColor=function(e,t){T.controls.staticAnnotation&&T.controls.staticAnnotation.setNoteLineColor(e,t),this.render()},f.getNoteContentByID=function(e){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.getNoteContentByID(e)},f.getPicContentByID=function(e){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.getPicContentByID(e)},f.getallPicContent=function(){if(T.controls.staticAnnotation)return T.controls.staticAnnotation.getallPicContent()},f.setNoteAnnotation=function(e){var t;T.controls.staticAnnotation||(t=T.controls.getOperator().type,T.setOperatorByID("OpAnnotationNew"),T.setOperatorByID(t)),T.controls.staticAnnotation.setNoteAnnotation(e),this.render()},f.setPicAnnotation=function(e){var t;T.controls.staticAnnotation||(t=T.controls.getOperator().type,T.setOperatorByID("OpAnnotationNew"),T.setOperatorByID(t)),T.controls.staticAnnotation.setPicAnnotation(e),this.render()},f.setMeasureVisible=function(e){T.controls.staticmeasureOp&&T.controls.staticmeasureOp.getMeasureVisible()!==e&&(T.controls.staticmeasureOp.setMeasureVisible(e),T.render(),_e.broadcastMajor)&&T.dispatchEvent({type:"broadcastEvent"})},f.getMeasureContent=function(){var e;if(T.controls.staticmeasureOp)return(e={}).content=T.controls.staticmeasureOp.getMeasureContent(!0),e.unsteadyData=T.controls.staticmeasureOp.unsteadyData,0==Object.keys(e.unsteadyData).length?null:e},f.setMeasureContent=function(e,t,n){var i;function r(){T.removeEventListener("BrepInfoEvent",r),T.controls.staticmeasureOp.unsteadyData=e.unsteadyData||{},T.controls.staticmeasureOp.CreateVector3(T.controls.staticmeasureOp.unsteadyData),T.controls.staticmeasureOp.setMeasureContent(e.content,t,!0),T.controls.staticmeasureOp.setMeasureVisible(n),T.controls.staticmeasureOp.setMeasureDisplayUnit()}e&&(T.controls.staticmeasureOp||(i=this.getCurrentOperatorID(),this.setOperatorByID("OpMeasure"),this.setOperatorByID(i)),!T.hasBrepInfo()&&T.hasBrepFile()?this.addEventListener("BrepInfoEvent",r):(T.controls.staticmeasureOp.unsteadyData=e.unsteadyData||{},T.controls.staticmeasureOp.CreateVector3(T.controls.staticmeasureOp.unsteadyData),T.controls.staticmeasureOp.setMeasureContent(e.content,t,!0),T.controls.staticmeasureOp.setMeasureVisible(n),T.controls.staticmeasureOp.setMeasureDisplayUnit()))},I.language?Se.setLanguage(I.language,f.serverUrl):Se.setLanguage(navigator.language,f.serverUrl),p&&(f.Optoolbar=new Vn(f,I)),new zn(f,I.loadingWaiterColor),new Rn(f,I.loadingCovererColor),_e.enableSelect&&f.enableInternalRMB&&new Gn(f),T.bHasLoadingStater&&(f.stater=new Un(f),f.stater.addEventListener("cancel",f.stopReadingModel)),i.addEventListener("render",f.render),i.addEventListener("event",f.onControlsEvent),window.addEventListener("keydown",function(e){_e.enableBroadcast&&!_e.broadcastMajor||32==e.keyCode&&T.toggleAutoRotation()},!1),f.canvas2D?(f.canvas2D.addEventListener("contextmenu",function(e){e.preventDefault()},!1),Se.isMobileDevice()?(f.canvas2D.addEventListener("touchstart",f.onMouseDown,!1),f.canvas2D.addEventListener("touchend",f.onMouseUp,!1)):(f.canvas2D.addEventListener("mousedown",f.onMouseDown,!1),f.canvas2D.addEventListener("mouseup",f.onMouseUp,!1))):(t.addEventListener("contextmenu",function(e){e.preventDefault()},!1),Se.isMobileDevice()?(t.addEventListener("touchstart",f.onMouseDown,!1),t.addEventListener("touchend",f.onMouseUp,!1)):(t.addEventListener("mousedown",f.onMouseDown,!1),t.addEventListener("mouseup",f.onMouseUp,!1))),window.addEventListener("resize",f.onResize,!1),f.onWindowResize(),te(),document.addEventListener("fullscreenchange",ce),document.addEventListener("webkitfullscreenchange",ce),document.addEventListener("mozfullscreenchange",ce),document.addEventListener("MSFullscreenChange",ce),void 0!==I.envMapTextures&&(f.setEnvMapTextures(I.envMapTextures),f.updateEnvMapBlur()),void 0!==I.backGroundImage&&f.setBackGroundImage(I.backGroundImage),f.addEventListener("updateProgress",f.onUpdateProgress,!1),f.addEventListener("windowResize",f.onWindowResize,!1),_e.isVRmodel&&(e=Te.getExtension("WebVRExtension"))&&e.load(f),_e.isARmodel&&(c=Te.getExtension("WebARExtension"))&&c.load(f,_e.supportAR),f.initViewer=function(e){void 0===e&&(e=!1),f.inited&&!e||(f.brepLoadIndex=0,f.oldenableBroadcast=_e.enableBroadcast,_e.enableBroadcast=!1,f.explodeObjects=[],f.SDFMaker&&f.SDFMaker.clear(),f.AnimationExtension&&f.AnimationExtension.clearAnimations(),f.inited=!0,f.modelneedLoad=!0,f.ndsModelObjectTreeLoaded=!1,f.ndsModelBvhLoaded=!1,f.ndsModelPMILoaded=!1,_e.ScenarioEditorid=-1);var p=f;f.loadCallback=function(e,t,n){if(p.ndsModel&&1!=e.isPmi&&(p.ndsModelObjectTreeLoaded=!0,p.ndsModelBvhLoaded&&(p.prepareModelForRendering(e),p.setBodyNodeMaterialsInfo(p.bodyNodeUUidToMaterial)),p.modelRootObject)&&p.modelRootObject.boundingBox.copy(e.boundingBox),e instanceof THREE.Scene)p.scene=e,p.modelRootObject=e;else if(e.isPmi){e.name="pmiobject",p.pmiObject=e,p.pmiVisible&&p.scene.add(e);var i=!(p.ndsModelPMILoaded=!0);if(p.pmiObject&&0<p.pmiObject.children.length&&(i="modelPMI"==p.pmiObject.children[0].name),p.ndsModelBvhLoaded&&p.ndsModelObjectTreeLoaded){for(var r=[p.ndsModel.rootBodyNode],o=0;o<r.length;++o){var a=r[o];if(a.pmiuuid&&!p.is2DModel&&p.pmiObject){null==a.worldMatrix&&(a.worldMatrix=p.ndsModel.calculateNodeWorldMatrix(a));for(var s=0;s<a.pmiuuid.length;++s){var l=a.pmiuuid[s],d=p.PMIUUIDtoPMIObject[l];if(d&&"PMI"==d.type)if(i)d.matrix.multiply(a.worldMatrix),d.updateMatrixWorld(!0);else if(0<d.children.length)for(var c=0;c<d.children.length;c++){var h=d.children[c];"PMI"!=h.type&&(h.matrix.multiply(a.worldMatrix),h.updateMatrixWorld(!0))}}}!a.visible&&a.pmiuuid&&p.pmiObject&&p.ndsModel.hideBody(a);for(var s=0,u=a.children.length;s<u;++s)r.push(a.children[s])}p.setBodyNodeMaterialsInfo(p.bodyNodeUUidToMaterial)}p.dispatchEvent({type:"PMIInfoEvent",PMI:!0})}else p.modelRootObject?(p.ndsModel||e.children[0].children[0]&&p.modelRootObject.children[0].children[0].add(e.children[0].children[0]),p.selectionManager.computeTargetList(p.scene)):(p.ndsModel||p.scene.add(e),p.modelRootObject=e);e.traverse(function(e){e.hasOwnProperty("geometry")&&e.hasOwnProperty("material")&&(null!=e.urlIndex?p.meshLoadedUUIDs.push({uuid:e.uuid,urlIndex:e.urlIndex}):p.meshLoadedUUIDs.push({uuid:e.uuid,urlIndex:0}))}),(0==_e.ScenarioEditorid||p.sceneInfo&&p.sceneInfo.setScene)&&p.addLights(p.scene),void 0!==n&&(p.bGeoBufferChunkLoaded=n)},f.modelRequestor||(f.modelRequestor=new Lt(f,{loadingManager:S,onLoadCallback:re,onRenderSettingCallback:oe,onBufferChunkCallback:ae,onLoadErrorCallback:se}))},f}var e,t;return t=fe,(e=me).prototype=Object.create(t.prototype),Mr(e.prototype.constructor=e,t),me}(THREE.EventDispatcher)}],i={},r.m=n,r.c=i,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=25);function r(e){var t;return(i[e]||(t=i[e]={i:e,l:!1,exports:{}},n[e].call(t.exports,t,t.exports,r),t.l=!0,t)).exports}var n,i});
|