forked from RobotWebTools/ros3djs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathros3d.min.js
1 lines (1 loc) · 99.3 KB
/
ros3d.min.js
1
var ROS3D=function(e,t,i,s){"use strict";s=s&&s.hasOwnProperty("default")?s.default:s;var r=Object.assign({},t),o=0,n=1,a=2,c=3,h=4,l=5,d=6,u=7,p=8,m=9,f=10,v=11,g=1,b=2,y=3,w=4,x=5,T=0,E=2,M=3,k=4,C=5,A=7,N=9,O=0,_=1,R=2,S=function(e,t,i,s){var o=new r.Color;return o.setRGB(e,t,i),s<=.99?new r.MeshBasicMaterial({color:o.getHex(),opacity:s+.1,transparent:!0,depthWrite:!0,blendSrc:r.SrcAlphaFactor,blendDst:r.OneMinusSrcAlphaFactor,blendEquation:r.ReverseSubtractEquation,blending:r.NormalBlending}):new r.MeshPhongMaterial({color:o.getHex(),opacity:s,blending:r.NormalBlending})},D=function(e,t,i){var s=new r.Vector3,o=new r.Vector3;s.subVectors(t,e.origin);var n=e.direction.dot(i);if(!(Math.abs(n)<e.precision)){var a=i.dot(s)/n;return o.addVectors(e.origin,e.direction.clone().multiplyScalar(a)),o}},j=function(e,t){var i=new r.Vector3;i.subVectors(e.origin,t.origin);var s=t.direction.clone(),o=e.direction.clone(),n=i.dot(s),a=s.dot(o),c=i.dot(o),h=s.dot(s),l=o.dot(o)*h-a*a;if(!(Math.abs(l)<=1e-4))return(n*a-c*h)/l},P=function(e,t,i){var s=e.origin.clone();s.project(t);var o=e.direction.clone().add(e.origin);o.project(t);var n=o.clone().sub(s),a=(new r.Vector2).subVectors(i,s).dot(n)/n.dot(n),c=new r.Vector2;c.addVectors(s,n.clone().multiplyScalar(a));var h=new r.Vector3(c.x,c.y,.5);h.unproject(t);var l=new r.Ray(t.position,h.sub(t.position).normalize());return j(e,l)};class L extends r.Mesh{constructor(e){var t=(e=e||{}).origin||new r.Vector3(0,0,0),i=e.direction||new r.Vector3(1,0,0),s=e.length||1,o=e.headLength||.2,n=e.shaftDiameter||.05,a=e.headDiameter||.1,c=e.material||new r.MeshBasicMaterial,h=s-o,l=new r.CylinderGeometry(.5*n,.5*n,h,12,1),d=new r.Matrix4;d.setPosition(new r.Vector3(0,.5*h,0)),l.applyMatrix(d);var u=new r.CylinderGeometry(0,.5*a,o,12,1);d.setPosition(new r.Vector3(0,h+.5*o,0)),u.applyMatrix(d),l.merge(u),super(l,c),this.position.copy(t),this.setDirection(i)}setDirection(e){var t=new r.Vector3(0,1,0).cross(e),i=Math.acos(new r.Vector3(0,1,0).dot(e.clone().normalize()));this.matrix=(new r.Matrix4).makeRotationAxis(t.normalize(),i),this.rotation.setFromRotationMatrix(this.matrix,this.rotation.order)}setLength(e){this.scale.set(e,e,e)}setColor(e){this.material.color.setHex(e)}dispose(){void 0!==this.geometry&&this.geometry.dispose(),void 0!==this.material&&this.material.dispose()}}r.STLLoader=function(e){this.manager=void 0!==e?e:r.DefaultLoadingManager},r.STLLoader.prototype={constructor:r.STLLoader,load:function(e,t,i,s){var o=this,n=new r.FileLoader(o.manager);n.setResponseType("arraybuffer"),n.load(e,function(e){t(o.parse(e))},i,s)},parse:function(e){var t=function(e){if("string"==typeof e){for(var t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=255&e.charCodeAt(i);return t.buffer||t}return e}(e);return function(e){var t;if(84+50*(t=new DataView(e)).getUint32(80,!0)===t.byteLength)return!0;for(var i=[115,111,108,105,100],s=0;s<5;s++)if(i[s]!=t.getUint8(s,!1))return!0;return!1}(t)?function(e){for(var t,i,s,o,n,a,c,h,l=new DataView(e),d=l.getUint32(80,!0),u=!1,p=0;p<70;p++)1129270351==l.getUint32(p,!1)&&82==l.getUint8(p+4)&&61==l.getUint8(p+5)&&(u=!0,o=[],n=l.getUint8(p+6)/255,a=l.getUint8(p+7)/255,c=l.getUint8(p+8)/255,h=l.getUint8(p+9)/255);for(var m=new r.BufferGeometry,f=[],v=[],g=0;g<d;g++){var b=84+50*g,y=l.getFloat32(b,!0),w=l.getFloat32(b+4,!0),x=l.getFloat32(b+8,!0);if(u){var T=l.getUint16(b+48,!0);0==(32768&T)?(t=(31&T)/31,i=(T>>5&31)/31,s=(T>>10&31)/31):(t=n,i=a,s=c)}for(var E=1;E<=3;E++){var M=b+12*E;f.push(l.getFloat32(M,!0)),f.push(l.getFloat32(M+4,!0)),f.push(l.getFloat32(M+8,!0)),v.push(y,w,x),u&&o.push(t,i,s)}}return m.addAttribute("position",new r.BufferAttribute(new Float32Array(f),3)),m.addAttribute("normal",new r.BufferAttribute(new Float32Array(v),3)),u&&(m.addAttribute("color",new r.BufferAttribute(new Float32Array(o),3)),m.hasColors=!0,m.alpha=h),m}(t):function(e){for(var t,i=new r.BufferGeometry,s=/facet([\s\S]*?)endfacet/g,o=0,n=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,a=new RegExp("vertex"+n+n+n,"g"),c=new RegExp("normal"+n+n+n,"g"),h=[],l=[],d=new r.Vector3;null!==(t=s.exec(e));){for(var u=0,p=0,m=t[0];null!==(t=c.exec(m));)d.x=parseFloat(t[1]),d.y=parseFloat(t[2]),d.z=parseFloat(t[3]),p++;for(;null!==(t=a.exec(m));)h.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),l.push(d.x,d.y,d.z),u++;1!==p&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+o),3!==u&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+o),o++}return i.addAttribute("position",new r.Float32BufferAttribute(h,3)),i.addAttribute("normal",new r.Float32BufferAttribute(l,3)),i}(function(e){if("string"!=typeof e){var t=new Uint8Array(e);if(void 0!==window.TextDecoder)return(new TextDecoder).decode(t);for(var i="",s=0,r=e.byteLength;s<r;s++)i+=String.fromCharCode(t[s]);return i}return e}(e))}},r.ColladaLoader=function(e){this.manager=void 0!==e?e:r.DefaultLoadingManager},r.ColladaLoader.prototype={constructor:r.ColladaLoader,crossOrigin:"Anonymous",load:function(e,t,i,s){var o=this,n=r.Loader.prototype.extractUrlBase(e);new r.FileLoader(o.manager).load(e,function(e){t(o.parse(e,n))},i,s)},options:{set convertUpAxis(e){console.warn("THREE.ColladaLoader: options.convertUpAxis() has been removed. Up axis is converted automatically.")}},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){function i(e,t){for(var i=[],s=e.childNodes,r=0,o=s.length;r<o;r++){var n=s[r];n.nodeName===t&&i.push(n)}return i}function s(e){if(0===e.length)return[];for(var t=e.trim().split(/\s+/),i=new Array(t.length),s=0,r=t.length;s<r;s++)i[s]=t[s];return i}function o(e){if(0===e.length)return[];for(var t=e.trim().split(/\s+/),i=new Array(t.length),s=0,r=t.length;s<r;s++)i[s]=parseFloat(t[s]);return i}function n(e){if(0===e.length)return[];for(var t=e.trim().split(/\s+/),i=new Array(t.length),s=0,r=t.length;s<r;s++)i[s]=parseInt(t[s]);return i}function a(e){return e.substring(1)}function c(e){return 0===Object.keys(e).length}function h(e,t,s,r){var o=i(e,t)[0];if(void 0!==o)for(var n=i(o,s),a=0;a<n.length;a++)r(n[a])}function l(e,t){for(var i in e){e[i].build=t(e[i])}}function d(e,t){return void 0!==e.build?e.build:(e.build=t(e),e.build)}function u(e){for(var t={inputs:{}},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"input":var o=a(r.getAttribute("source")),n=r.getAttribute("semantic");t.inputs[n]=o}}return t}function p(e){var t={},i=e.getAttribute("target").split("/"),s=i.shift(),r=i.shift(),o=-1!==r.indexOf("("),n=-1!==r.indexOf(".");if(n)r=(i=r.split(".")).shift(),t.member=i.shift();else if(o){var c=r.split("(");r=c.shift();for(var h=0;h<c.length;h++)c[h]=parseInt(c[h].replace(/\)/,""));t.indices=c}return t.id=s,t.sid=r,t.arraySyntax=o,t.memberSyntax=n,t.sampler=a(e.getAttribute("source")),t}function m(e){var t=[],i=e.channels,s=e.samplers,r=e.sources;for(var o in i)if(i.hasOwnProperty(o)){var n=i[o],a=s[n.sampler],c=a.inputs.INPUT,h=a.inputs.OUTPUT;w(v(n,r[c],r[h]),t)}return t}function f(e){return d(je.animations[e],m)}function v(e,t,i){var s,r,o,n,a,c,h=je.nodes[e.id],l=Ee(h.id),d=h.transforms[e.sid],u=h.matrix.clone().transpose(),p={};switch(d){case"matrix":for(o=0,n=t.array.length;o<n;o++)if(s=t.array[o],r=o*i.stride,void 0===p[s]&&(p[s]={}),!0===e.arraySyntax){var m=i.array[r],f=e.indices[0]+4*e.indices[1];p[s][f]=m}else for(a=0,c=i.stride;a<c;a++)p[s][a]=i.array[r+a];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',d)}var v=function(e,t){var i=[];for(var s in e)i.push({time:parseFloat(s),value:e[s]});i.sort(function(e,t){return e.time-t.time});for(var r=0;r<16;r++)x(i,r,t.elements[r]);return i}(p,u);return{name:l.uuid,keyframes:v}}var g=new r.Vector3,b=new r.Vector3,y=new r.Quaternion;function w(e,t){for(var i=e.keyframes,s=e.name,o=[],n=[],a=[],c=[],h=0,l=i.length;h<l;h++){var d=i[h],u=d.time,p=d.value;me.fromArray(p).transpose(),me.decompose(g,y,b),o.push(u),n.push(g.x,g.y,g.z),a.push(y.x,y.y,y.z,y.w),c.push(b.x,b.y,b.z)}return n.length>0&&t.push(new r.VectorKeyframeTrack(s+".position",o,n)),a.length>0&&t.push(new r.QuaternionKeyframeTrack(s+".quaternion",o,a)),c.length>0&&t.push(new r.VectorKeyframeTrack(s+".scale",o,c)),t}function x(e,t,i){var s,r,o,n=!0;for(r=0,o=e.length;r<o;r++)void 0===(s=e[r]).value[t]?s.value[t]=null:n=!1;if(!0===n)for(r=0,o=e.length;r<o;r++)(s=e[r]).value[t]=i;else!function(e,t){for(var i,s,r=0,o=e.length;r<o;r++){var n=e[r];if(null===n.value[t]){if(i=T(e,r,t),s=E(e,r,t),null===i){n.value[t]=s.value[t];continue}if(null===s){n.value[t]=i.value[t];continue}M(n,i,s,t)}}}(e,t)}function T(e,t,i){for(;t>=0;){var s=e[t];if(null!==s.value[i])return s;t--}return null}function E(e,t,i){for(;t<e.length;){var s=e[t];if(null!==s.value[i])return s;t++}return null}function M(e,t,i,s){i.time-t.time!=0?e.value[s]=(e.time-t.time)*(i.value[s]-t.value[s])/(i.time-t.time)+t.value[s]:e.value[s]=t.value[s]}function k(e){for(var t=[],i=e.name,s=e.end-e.start||-1,o=e.animations,n=0,a=o.length;n<a;n++)for(var c=f(o[n]),h=0,l=c.length;h<l;h++)t.push(c[h]);return new r.AnimationClip(i,s,t)}function C(e){return d(je.clips[e],k)}function A(e){for(var t={sources:{}},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=o(r.textContent);break;case"source":var n=r.getAttribute("id");t.sources[n]=J(r);break;case"joints":t.joints=N(r);break;case"vertex_weights":t.vertexWeights=O(r)}}return t}function N(e){for(var t={inputs:{}},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"input":var o=r.getAttribute("semantic"),n=a(r.getAttribute("source"));t.inputs[o]=n}}return t}function O(e){for(var t={inputs:{}},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"input":var o=r.getAttribute("semantic"),c=a(r.getAttribute("source")),h=parseInt(r.getAttribute("offset"));t.inputs[o]={id:c,offset:h};break;case"vcount":t.vcount=n(r.textContent);break;case"v":t.v=n(r.textContent)}}return t}function _(e){var t={id:e.id},i=je.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){var t,i,s,o={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},n=e.sources,a=e.vertexWeights,c=a.vcount,h=a.v,l=a.inputs.JOINT.offset,d=a.inputs.WEIGHT.offset,u=e.sources[e.joints.inputs.JOINT],p=e.sources[e.joints.inputs.INV_BIND_MATRIX],m=n[a.inputs.WEIGHT.id].array,f=0;for(t=0,s=c.length;t<s;t++){var v=c[t],g=[];for(i=0;i<v;i++){var b=h[f+l],y=h[f+d],w=m[y];g.push({index:b,weight:w}),f+=2}for(g.sort(M),i=0;i<4;i++){var x=g[i];void 0!==x?(o.indices.array.push(x.index),o.weights.array.push(x.weight)):(o.indices.array.push(0),o.weights.array.push(0))}}for(o.bindMatrix=(new r.Matrix4).fromArray(e.bindShapeMatrix).transpose(),t=0,s=u.array.length;t<s;t++){var T=u.array[t],E=(new r.Matrix4).fromArray(p.array,t*p.stride).transpose();o.joints.push({name:T,boneInverse:E})}return o;function M(e,t){return t.weight-e.weight}}(e.skin),i.sources.skinIndices=t.skin.indices,i.sources.skinWeights=t.skin.weights),t}function R(e){return void 0!==e.build?e.build:e.init_from}function S(e){for(var t={surfaces:{},samplers:{}},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"newparam":D(r,t);break;case"technique":t.technique=L(r)}}return t}function D(e,t){for(var i=e.getAttribute("sid"),s=0,r=e.childNodes.length;s<r;s++){var o=e.childNodes[s];if(1===o.nodeType)switch(o.nodeName){case"surface":t.surfaces[i]=j(o);break;case"sampler2D":t.samplers[i]=P(o)}}}function j(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"init_from":t.init_from=r.textContent}}return t}function P(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"source":t.source=r.textContent}}return t}function L(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=r.nodeName,t.parameters=V(r)}}return t}function V(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"emission":case"diffuse":case"specular":case"shininess":case"transparent":case"transparency":t[r.nodeName]=I(r)}}return t}function I(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"color":t[r.nodeName]=o(r.textContent);break;case"float":t[r.nodeName]=parseFloat(r.textContent);break;case"texture":t[r.nodeName]={id:r.getAttribute("texture"),extra:z(r)}}}return t}function z(e){for(var t={technique:{}},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"extra":F(r,t)}}return t}function F(e,t){for(var i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"technique":B(r,t)}}}function B(e,t){for(var i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[r.nodeName]=parseFloat(r.textContent);break;case"wrapU":case"wrapV":"TRUE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=1:"FALSE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=0:t.technique[r.nodeName]=parseInt(r.textContent)}}}function U(e){return e}function q(e){var t,i,s=(t=e.url,d(je.effects[t],U)),o=s.profile.technique;switch(o.type){case"phong":case"blinn":i=new r.MeshPhongMaterial;break;case"lambert":i=new r.MeshLambertMaterial;break;default:i=new r.MeshBasicMaterial}function n(e){var t,i=s.profile.samplers[e.id];if(void 0!==i){var o=s.profile.surfaces[i.source],n=_e.load((t=o.init_from,d(je.images[t],R))),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===c(a.technique)){var h=a.technique;n.wrapS=h.wrapU?r.RepeatWrapping:r.ClampToEdgeWrapping,n.wrapT=h.wrapV?r.RepeatWrapping:r.ClampToEdgeWrapping,n.offset.set(h.offsetU||0,h.offsetV||0),n.repeat.set(h.repeatU||1,h.repeatV||1)}else n.wrapS=r.RepeatWrapping,n.wrapT=r.RepeatWrapping;return n}return console.error("THREE.ColladaLoader: Undefined sampler",e.id),null}i.name=e.name;var a=o.parameters;for(var h in a){var l=a[h];switch(h){case"diffuse":l.color&&i.color.fromArray(l.color),l.texture&&(i.map=n(l.texture));break;case"specular":l.color&&i.specular&&i.specular.fromArray(l.color),l.texture&&(i.specularMap=n(l.texture));break;case"shininess":l.float&&i.shininess&&(i.shininess=l.float);break;case"emission":l.color&&i.emissive&&i.emissive.fromArray(l.color);break;case"transparent":i.transparent=!0;break;case"transparency":void 0!==l.float&&(i.opacity=l.float),i.transparent=!0}}return i}function G(e){return d(je.materials[e],q)}function H(e){for(var t=0;t<e.childNodes.length;t++){var i=e.childNodes[t];switch(i.nodeName){case"technique_common":return W(i)}}return{}}function W(e){for(var t={},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];switch(s.nodeName){case"perspective":case"orthographic":t.technique=s.nodeName,t.parameters=K(s)}}return t}function K(e){for(var t={},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];switch(s.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[s.nodeName]=parseFloat(s.textContent)}}return t}function Q(e){var t;switch(e.optics.technique){case"perspective":t=new r.PerspectiveCamera(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":var i=e.optics.parameters.ymag,s=e.optics.parameters.xmag,o=e.optics.parameters.aspect_ratio;s=void 0===s?i*o:s,i=void 0===i?s/o:i,s*=.5,i*=.5,t=new r.OrthographicCamera(-s,s,i,-i,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new r.PerspectiveCamera}return t.name=e.name,t}function X(e){var t=je.cameras[e];return void 0!==t?d(t,Q):null}function Z(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=r.nodeName,t.parameters=Y(r)}}return t}function Y(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"color":var a=o(n.textContent);t.color=(new r.Color).fromArray(a);break;case"falloff_angle":t.falloffAngle=parseFloat(n.textContent);break;case"quadratic_attenuation":var c=parseFloat(n.textContent);t.distance=c?Math.sqrt(1/c):0}}return t}function J(e){for(var t={array:[],stride:3},r=0;r<e.childNodes.length;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"float_array":t.array=o(n.textContent);break;case"Name_array":t.array=s(n.textContent);break;case"technique_common":var a=i(n,"accessor")[0];void 0!==a&&(t.stride=parseInt(a.getAttribute("stride")))}}return t}function $(e){for(var t={},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];1===s.nodeType&&(t[s.getAttribute("semantic")]=a(s.getAttribute("source")))}return t}function ee(e){for(var t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"input":var o=a(r.getAttribute("source")),c=r.getAttribute("semantic"),h=parseInt(r.getAttribute("offset"));t.inputs[c]={id:o,offset:h},t.stride=Math.max(t.stride,h+1);break;case"vcount":t.vcount=n(r.textContent);break;case"p":t.p=n(r.textContent)}}return t}function te(e){var t={},i=e.sources,s=e.vertices,r=e.primitives;if(0===r.length)return{};var o=function(e){for(var t={},i=0;i<e.length;i++){var s=e[i];void 0===t[s.type]&&(t[s.type]=[]),t[s.type].push(s)}return t}(r);for(var n in o)t[n]=ie(o[n],i,s);return t}function ie(e,t,i){for(var s={},o={array:[],stride:0},n={array:[],stride:0},a={array:[],stride:0},c={array:[],stride:0},h=[],l=4,d=[],u=4,p=new r.BufferGeometry,m=[],f=0,v=0,g=0;g<e.length;g++){var b=e[g],y=b.inputs,w=1;for(var x in b.vcount&&4===b.vcount[0]&&(w=2),v="lines"===b.type||"linestrips"===b.type?2*b.count:3*b.count*w,p.addGroup(f,v,g),f+=v,b.material&&m.push(b.material),y){var T=y[x];switch(x){case"VERTEX":for(var E in i){var M=i[E];switch(E){case"POSITION":se(b,t[M],T.offset,o.array),o.stride=t[M].stride,t.skinWeights&&t.skinIndices&&(se(b,t.skinIndices,T.offset,h),se(b,t.skinWeights,T.offset,d));break;case"NORMAL":se(b,t[M],T.offset,n.array),n.stride=t[M].stride;break;case"COLOR":se(b,t[M],T.offset,c.array),c.stride=t[M].stride;break;case"TEXCOORD":se(b,t[M],T.offset,a.array),a.stride=t[M].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',E)}}break;case"NORMAL":se(b,t[T.id],T.offset,n.array),n.stride=t[T.id].stride;break;case"COLOR":se(b,t[T.id],T.offset,c.array),c.stride=t[T.id].stride;break;case"TEXCOORD":se(b,t[T.id],T.offset,a.array),a.stride=t[T.id].stride}}}return o.array.length>0&&p.addAttribute("position",new r.Float32BufferAttribute(o.array,o.stride)),n.array.length>0&&p.addAttribute("normal",new r.Float32BufferAttribute(n.array,n.stride)),c.array.length>0&&p.addAttribute("color",new r.Float32BufferAttribute(c.array,c.stride)),a.array.length>0&&p.addAttribute("uv",new r.Float32BufferAttribute(a.array,a.stride)),h.length>0&&p.addAttribute("skinIndex",new r.Float32BufferAttribute(h,l)),d.length>0&&p.addAttribute("skinWeight",new r.Float32BufferAttribute(d,u)),s.data=p,s.type=e[0].type,s.materialKeys=m,s}function se(e,t,i,s){var r=e.p,o=e.stride,n=e.vcount;function a(e){for(var t=r[e+i]*l,o=t+l;t<o;t++)s.push(h[t])}var c=0,h=t.array,l=t.stride;if(void 0!==e.vcount){for(var d=0,u=0,p=n.length;u<p;u++){var m=n[u];if(4===m){var f=d+1*o,v=d+2*o,g=d+3*o;a(d+0*o),a(f),a(g),a(f),a(v),a(g)}else if(3===m){f=d+1*o,v=d+2*o;a(d+0*o),a(f),a(v)}else c=Math.max(c,m);d+=o*m}c>0&&console.log("THREE.ColladaLoader: Geometry has faces with more than 4 vertices.")}else for(u=0,p=r.length;u<p;u+=o)a(u)}function re(e){return d(je.geometries[e],te)}function oe(e){return void 0!==e.build?e.build:e}function ne(e,t){for(var i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"joint":t.joints[s.getAttribute("sid")]=ae(s);break;case"link":t.links.push(he(s))}}}function ae(e){for(var t,i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"prismatic":case"revolute":t=ce(s)}}return t}function ce(e,t){t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new r.Vector3,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(var i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"axis":var n=o(s.textContent);t.axis.fromArray(n);break;case"limits":var a=s.getElementsByTagName("max")[0],c=s.getElementsByTagName("min")[0];t.limits.max=parseFloat(a.textContent),t.limits.min=parseFloat(c.textContent)}}return t.limits.min>=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function he(e){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"attachment_full":t.attachments.push(le(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(de(s))}}return t}function le(e){for(var t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"link":t.links.push(he(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(de(s))}}return t}function de(e){var t={type:e.nodeName},i=o(e.textContent);switch(t.type){case"matrix":t.obj=new r.Matrix4,t.obj.fromArray(i).transpose();break;case"translate":t.obj=new r.Vector3,t.obj.fromArray(i);break;case"rotate":t.obj=new r.Vector3,t.obj.fromArray(i),t.angle=r.Math.degToRad(i[3])}return t}function ue(e){for(var t={target:e.getAttribute("target").split("/").pop()},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"axis":var r=s.getElementsByTagName("param")[0];t.axis=r.textContent;var o=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=o.substr(0,o.length-1)}}return t}function pe(e){return void 0!==e.build?e.build:e}var me=new r.Matrix4,fe=new r.Vector3;function ve(e){for(var t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new r.Matrix4,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"node":t.nodes.push(s.getAttribute("id")),ve(s);break;case"instance_camera":t.instanceCameras.push(a(s.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(ge(s));break;case"instance_light":t.instanceLights.push(a(s.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(ge(s));break;case"instance_node":t.instanceNodes.push(a(s.getAttribute("url")));break;case"matrix":var n=o(s.textContent);t.matrix.multiply(me.fromArray(n).transpose()),t.transforms[s.getAttribute("sid")]=s.nodeName;break;case"translate":n=o(s.textContent);fe.fromArray(n),t.matrix.multiply(me.makeTranslation(fe.x,fe.y,fe.z)),t.transforms[s.getAttribute("sid")]=s.nodeName;break;case"rotate":n=o(s.textContent);var c=r.Math.degToRad(n[3]);t.matrix.multiply(me.makeRotationAxis(fe.fromArray(n),c)),t.transforms[s.getAttribute("sid")]=s.nodeName;break;case"scale":n=o(s.textContent);t.matrix.scale(fe.fromArray(n)),t.transforms[s.getAttribute("sid")]=s.nodeName;break;case"extra":break;default:console.log(s)}}return je.nodes[t.id]=t,t}function ge(e){for(var t={id:a(e.getAttribute("url")),materials:{},skeletons:[]},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];switch(s.nodeName){case"bind_material":for(var r=s.getElementsByTagName("instance_material"),o=0;o<r.length;o++){var n=r[o],c=n.getAttribute("symbol"),h=n.getAttribute("target");t.materials[c]=a(h)}break;case"skeleton":t.skeletons.push(a(s.textContent))}}return t}function be(e,t){var i,s,o,n=[],a=[];for(i=0;i<e.length;i++){ye(Ee(e[i]),t,n)}for(i=0;i<t.length;i++)for(s=0;s<n.length;s++)if((o=n[s]).bone.name===t[i].name){a[i]=o,o.processed=!0;break}for(i=0;i<n.length;i++)!1===(o=n[i]).processed&&(a.push(o),o.processed=!0);var c=[],h=[];for(i=0;i<a.length;i++)o=a[i],c.push(o.bone),h.push(o.boneInverse);return new r.Skeleton(c,h)}function ye(e,t,i){e.traverse(function(e){if(!0===e.isBone){for(var s,o=0;o<t.length;o++){var n=t[o];if(n.name===e.name){s=n.boneInverse;break}}void 0===s&&(s=new r.Matrix4),i.push({bone:e,boneInverse:s,processed:!1})}})}function we(e){for(var t,i=[],s=e.matrix,o=e.nodes,n=e.type,a=e.instanceCameras,c=e.instanceControllers,h=e.instanceLights,l=e.instanceGeometries,u=e.instanceNodes,p=0,m=o.length;p<m;p++)i.push(Ee(o[p]));for(p=0,m=a.length;p<m;p++){null!==(T=X(a[p]))&&i.push(T.clone())}for(p=0,m=c.length;p<m;p++)for(var f=c[p],v=(t=f.id,d(je.controllers[t],_)),g=Te(re(v.id),f.materials),b=be(f.skeletons,v.skin.joints),y=0,w=g.length;y<w;y++){var x;(x=g[y]).isSkinnedMesh&&(x.bind(b,v.skin.bindMatrix),x.normalizeSkinWeights()),i.push(x)}for(p=0,m=h.length;p<m;p++){var T;null!==(T=X(a[p]))&&i.push(T.clone())}for(p=0,m=l.length;p<m;p++)for(y=0,w=(g=Te(re((f=l[p]).id),f.materials)).length;y<w;y++)i.push(g[y]);for(p=0,m=u.length;p<m;p++)i.push(Ee(u[p]).clone());if(0===o.length&&1===i.length)x=i[0];else{x="JOINT"===n?new r.Bone:new r.Group;for(p=0;p<i.length;p++)x.add(i[p])}return x.name="JOINT"===n?e.sid:e.name,x.matrix.copy(s),x.matrix.decompose(x.position,x.quaternion,x.scale),x}function xe(e,t){for(var i=[],s=0,r=e.length;s<r;s++){var o=t[e[s]];i.push(G(o))}return i}function Te(e,t){var i=[];for(var s in e){var o=e[s],n=xe(o.materialKeys,t);0===n.length&&("lines"===s||"linestrips"===s?n.push(new r.LineBasicMaterial):n.push(new r.MeshPhongMaterial));var a=void 0!==o.data.attributes.skinIndex;if(a)for(var c=0,h=n.length;c<h;c++)n[c].skinning=!0;var l,d=1===n.length?n[0]:n;switch(s){case"lines":l=new r.LineSegments(o.data,d);break;case"linestrips":l=new r.Line(o.data,d);break;case"triangles":case"polylist":l=a?new r.SkinnedMesh(o.data,d):new r.Mesh(o.data,d)}i.push(l)}return i}function Ee(e){return d(je.nodes[e],we)}function Me(e){var t=new r.Group;t.name=e.name;for(var i=e.children,s=0;s<i.length;s++){var o=i[s];null===o.id?t.add(we(o)):t.add(Ee(o.id))}return t}function ke(e){return d(je.visualScenes[e],Me)}if(console.time("THREE.ColladaLoader"),0===e.length)return{scene:new r.Scene};console.time("THREE.ColladaLoader: DOMParser");var Ce=(new DOMParser).parseFromString(e,"application/xml");console.timeEnd("THREE.ColladaLoader: DOMParser");var Ae=i(Ce,"COLLADA")[0],Ne=Ae.getAttribute("version");console.log("THREE.ColladaLoader: File version",Ne);var Oe=function(e){return{unit:function(e){return void 0!==e?parseFloat(e.getAttribute("meter")):1}(i(e,"unit")[0]),upAxis:function(e){return void 0!==e?e.textContent:"Y_UP"}(i(e,"up_axis")[0])}}(i(Ae,"asset")[0]),_e=new r.TextureLoader(this.manager);_e.setPath(t).setCrossOrigin(this.crossOrigin);var Re=[],Se={},De=0,je={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},kinematicsScenes:{}};console.time("THREE.ColladaLoader: Parse"),h(Ae,"library_animations","animation",function(e){for(var t={sources:{},samplers:{},channels:{}},i=0,s=e.childNodes.length;i<s;i++){var r,o=e.childNodes[i];if(1===o.nodeType)switch(o.nodeName){case"source":r=o.getAttribute("id"),t.sources[r]=J(o);break;case"sampler":r=o.getAttribute("id"),t.samplers[r]=u(o);break;case"channel":r=o.getAttribute("target"),t.channels[r]=p(o);break;default:console.log(o)}}je.animations[e.getAttribute("id")]=t}),h(Ae,"library_animation_clips","animation_clip",function(e){for(var t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"instance_animation":t.animations.push(a(r.getAttribute("url")))}}je.clips[e.getAttribute("id")]=t}),h(Ae,"library_controllers","controller",function(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"skin":t.id=a(r.getAttribute("source")),t.skin=A(r);break;case"morph":t.id=a(r.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}je.controllers[e.getAttribute("id")]=t}),h(Ae,"library_images","image",function(e){var t={init_from:i(e,"init_from")[0].textContent};je.images[e.getAttribute("id")]=t}),h(Ae,"library_effects","effect",function(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"profile_COMMON":t.profile=S(r)}}je.effects[e.getAttribute("id")]=t}),h(Ae,"library_materials","material",function(e){for(var t={name:e.getAttribute("name")},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"instance_effect":t.url=a(r.getAttribute("url"))}}je.materials[e.getAttribute("id")]=t}),h(Ae,"library_cameras","camera",function(e){for(var t={name:e.getAttribute("name")},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"optics":t.optics=H(r)}}je.cameras[e.getAttribute("id")]=t}),h(Ae,"library_lights","light",function(e){for(var t={},i=0,s=e.childNodes.length;i<s;i++){var r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"technique_common":t=Z(r)}}je.lights[e.getAttribute("id")]=t}),h(Ae,"library_geometries","geometry",function(e){for(var t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},s=i(e,"mesh")[0],r=0;r<s.childNodes.length;r++){var o=s.childNodes[r];if(1===o.nodeType){var n=o.getAttribute("id");switch(o.nodeName){case"source":t.sources[n]=J(o);break;case"vertices":t.vertices=$(o);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",o.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(ee(o));break;default:console.log(o)}}}je.geometries[e.getAttribute("id")]=t}),h(Ae,"library_nodes","node",ve),h(Ae,"library_visual_scenes","visual_scene",function(e){var t={name:e.getAttribute("name"),children:[]};!function(e){for(var t=e.getElementsByTagName("node"),i=0;i<t.length;i++){var s=t[i];!1===s.hasAttribute("id")&&s.setAttribute("id","three_default_"+De++)}}(e);for(var s=i(e,"node"),r=0;r<s.length;r++)t.children.push(ve(s[r]));je.visualScenes[e.getAttribute("id")]=t}),h(Ae,"library_kinematics_models","kinematics_model",function(e){for(var t={name:e.getAttribute("name")||"",joints:{},links:[]},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"technique_common":ne(s,t)}}je.kinematicsModels[e.getAttribute("id")]=t}),h(Ae,"scene","instance_kinematics_scene",function(e){for(var t={bindJointAxis:[]},i=0;i<e.childNodes.length;i++){var s=e.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"bind_joint_axis":t.bindJointAxis.push(ue(s))}}je.kinematicsScenes[a(e.getAttribute("url"))]=t}),console.timeEnd("THREE.ColladaLoader: Parse"),console.time("THREE.ColladaLoader: Build"),l(je.animations,m),l(je.clips,k),l(je.controllers,_),l(je.images,R),l(je.effects,U),l(je.materials,q),l(je.cameras,Q),l(je.lights,function(e){var t;switch(e.technique){case"directional":t=new r.DirectionalLight;break;case"point":t=new r.PointLight;break;case"spot":t=new r.SpotLight;break;case"ambient":t=new r.AmbientLight}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}),l(je.geometries,te),l(je.visualScenes,Me),console.timeEnd("THREE.ColladaLoader: Build"),function(){var e=je.clips;if(!0===c(e)){if(!1===c(je.animations)){var t=[];for(var i in je.animations)for(var s=f(i),o=0,n=s.length;o<n;o++)t.push(s[o]);Re.push(new r.AnimationClip("default",-1,t))}}else for(var i in e)Re.push(C(i))}(),function(){var e=Object.keys(je.kinematicsModels)[0],t=Object.keys(je.kinematicsScenes)[0],i=Object.keys(je.visualScenes)[0];if(void 0!==e&&void 0!==t){for(var s,n=(s=e,d(je.kinematicsModels[s],oe)),a=function(e){return d(je.kinematicsScenes[e],pe)}(t),c=ke(i),h=a.bindJointAxis,l={},u=0,p=h.length;u<p;u++){var m=h[u],f=Ae.querySelector('[sid="'+m.target+'"]');if(f){var v=f.parentElement;b(m.jointIndex,v)}}var g=new r.Matrix4;Se={joints:n&&n.joints,getJointValue:function(e){var t=l[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(e,t){var i=l[e];if(i){var s=i.joint;if(t>s.limits.max||t<s.limits.min)console.warn("THREE.ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+s.limits.min+", max: "+s.limits.max+").");else if(s.static)console.warn("THREE.ColladaLoader: Joint "+e+" is static.");else{var o=i.object,n=s.axis,a=i.transforms;me.identity();for(var c=0;c<a.length;c++){var h=a[c];if(h.sid&&-1!==h.sid.indexOf(e))switch(s.type){case"revolute":me.multiply(g.makeRotationAxis(n,r.Math.degToRad(t)));break;case"prismatic":me.multiply(g.makeTranslation(n.x*t,n.y*t,n.z*t));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+s.type)}else switch(h.type){case"matrix":me.multiply(h.obj);break;case"translate":me.multiply(g.makeTranslation(h.obj.x,h.obj.y,h.obj.z));break;case"scale":me.scale(h.obj);break;case"rotate":me.multiply(g.makeRotationAxis(h.obj,h.angle))}}o.matrix.copy(me),o.matrix.decompose(o.position,o.quaternion,o.scale),l[e].position=t}}else console.log("THREE.ColladaLoader: "+e+" does not exist.")}}}function b(e,t){var i=t.getAttribute("name"),s=n.joints[e];c.traverse(function(n){n.name===i&&(l[e]={object:n,transforms:function(e){for(var t=[],i=Ae.querySelector('[id="'+e.id+'"]'),s=0;s<i.childNodes.length;s++){var n=i.childNodes[s];if(1===n.nodeType)switch(n.nodeName){case"matrix":var a=o(n.textContent),c=(new r.Matrix4).fromArray(a).transpose();t.push({sid:n.getAttribute("sid"),type:n.nodeName,obj:c});break;case"translate":case"scale":var a=o(n.textContent),h=(new r.Vector3).fromArray(a);t.push({sid:n.getAttribute("sid"),type:n.nodeName,obj:h});break;case"rotate":var a=o(n.textContent),h=(new r.Vector3).fromArray(a),l=r.Math.degToRad(a[3]);t.push({sid:n.getAttribute("sid"),type:n.nodeName,obj:h,angle:l})}}return t}(t),joint:s,position:s.zeroPosition})})}}();var Pe=function(e){return ke(a(i(e,"instance_visual_scene")[0].getAttribute("url")))}(i(Ae,"scene")[0]);return Pe.scale.multiplyScalar(Oe.unit),console.timeEnd("THREE.ColladaLoader"),{animations:Re,kinematics:Se,library:je,scene:Pe}}};class V extends r.Object3D{constructor(e){super();var t=this,i=(e=e||{}).path||"/",s=e.resource,o=e.material||null;this.warnings=e.warnings,"/"!==i.substr(i.length-1)&&(i+="/");var n,a=i+s,c=a.substr(-4).toLowerCase();".dae"===c?((n=new r.ColladaLoader).log=function(e){t.warnings&&console.warn(e)},n.load(a,function(e){null!==o&&e.scene.traverse(function(e){e instanceof r.Mesh&&void 0===e.material&&(e.material=o)}),t.add(e.scene)},null,function(e){console.error(e)})):".stl"===c&&(n=new r.STLLoader).load(a,function(e){var i;e.computeFaceNormals(),i=null!==o?new r.Mesh(e,o):new r.Mesh(e,new r.MeshBasicMaterial({color:10066329})),t.add(i)},null,function(e){console.error(e)})}}class I extends r.Object3D{constructor(e){var t=(e=e||{}).material||new r.MeshBasicMaterial,i=e.vertices,s=e.colors;super(),t.side=r.DoubleSide;var o,n,a=new r.Geometry;for(o=0;o<i.length;o++)a.vertices.push(new r.Vector3(i[o].x,i[o].y,i[o].z));if(s.length===i.length){for(o=0;o<i.length;o+=3){var c=new r.Face3(o,o+1,o+2);for(n=3*o;n<3*o+3;o++){var h=new r.Color;h.setRGB(s[o].r,s[o].g,s[o].b),c.vertexColors.push(h)}a.faces.push(c)}t.vertexColors=r.VertexColors}else if(s.length===i.length/3){for(o=0;o<i.length;o+=3){var l=new r.Face3(o,o+1,o+2);l.color.setRGB(s[o/3].r,s[o/3].g,s[o/3].b),a.faces.push(l)}t.vertexColors=r.FaceColors}else for(o=0;o<i.length;o+=3){var d=new r.Face3(o,o+1,o+2);a.faces.push(d)}a.computeBoundingBox(),a.computeBoundingSphere(),a.computeFaceNormals(),this.add(new r.Mesh(a,t))}setColor(e){this.mesh.material.color.setHex(e)}}class z extends r.Object3D{constructor(e){super();var t=(e=e||{}).path||"/",i=e.message;"/"!==t.substr(t.length-1)&&(t+="/"),i.scale?this.msgScale=[i.scale.x,i.scale.y,i.scale.z]:this.msgScale=[1,1,1],this.msgColor=i.color,this.msgMesh=void 0,this.setPose(i.pose);var s=S(this.msgColor.r,this.msgColor.g,this.msgColor.b,this.msgColor.a);switch(i.type){case o:var g,b=i.scale.x,y=.23*b,w=i.scale.y,x=.5*w,T=null;if(2===i.points.length){T=new r.Vector3(i.points[0].x,i.points[0].y,i.points[0].z);var E=new r.Vector3(i.points[1].x,i.points[1].y,i.points[1].z);b=(g=T.clone().negate().add(E)).length(),w=i.scale.y,x=i.scale.x,0!==i.scale.z&&(y=i.scale.z)}this.add(new L({direction:g,origin:T,length:b,headLength:y,shaftDiameter:x,headDiameter:w,material:s}));break;case n:var M=new r.BoxGeometry(i.scale.x,i.scale.y,i.scale.z);this.add(new r.Mesh(M,s));break;case a:var k=new r.SphereGeometry(.5),C=new r.Mesh(k,s);C.scale.x=i.scale.x,C.scale.y=i.scale.y,C.scale.z=i.scale.z,this.add(C);break;case c:var A=new r.CylinderGeometry(.5,.5,1,16,1,!1),N=new r.Mesh(A,s);N.quaternion.setFromAxisAngle(new r.Vector3(1,0,0),.5*Math.PI),N.scale.set(i.scale.x,i.scale.z,i.scale.y),this.add(N);break;case h:var O,_=new r.Geometry,R=new r.LineBasicMaterial({size:i.scale.x});for(O=0;O<i.points.length;O++){var D=new r.Vector3;D.x=i.points[O].x,D.y=i.points[O].y,D.z=i.points[O].z,_.vertices.push(D)}if(i.colors.length===i.points.length)for(R.vertexColors=!0,O=0;O<i.points.length;O++){var j=new r.Color;j.setRGB(i.colors[O].r,i.colors[O].g,i.colors[O].b),_.colors.push(j)}else R.color.setRGB(i.color.r,i.color.g,i.color.b);this.add(new r.Line(_,R));break;case l:var P,z=new r.Geometry,F=new r.LineBasicMaterial({size:i.scale.x});for(P=0;P<i.points.length;P++){var B=new r.Vector3;B.x=i.points[P].x,B.y=i.points[P].y,B.z=i.points[P].z,z.vertices.push(B)}if(i.colors.length===i.points.length)for(F.vertexColors=!0,P=0;P<i.points.length;P++){var U=new r.Color;U.setRGB(i.colors[P].r,i.colors[P].g,i.colors[P].b),z.colors.push(U)}else F.color.setRGB(i.color.r,i.color.g,i.color.b);this.add(new r.Line(z,F,r.LinePieces));break;case d:var q,G,H,W,K=new r.Object3D,Q=i.points.length,X=Q===i.colors.length,Z=Math.ceil(Q/1250);for(q=0;q<Q;q+=Z)G=new r.BoxGeometry(i.scale.x,i.scale.y,i.scale.z),H=X?S(i.colors[q].r,i.colors[q].g,i.colors[q].b,i.colors[q].a):s,(W=new r.Mesh(G,H)).position.x=i.points[q].x,W.position.y=i.points[q].y,W.position.z=i.points[q].z,K.add(W);this.add(K);break;case u:var Y,J,$,ee,te=new r.Object3D,ie=i.points.length,se=ie===i.colors.length,re=Math.ceil(ie/1250);for(Y=0;Y<ie;Y+=re)J=new r.SphereGeometry(.5,8,8),$=se?S(i.colors[Y].r,i.colors[Y].g,i.colors[Y].b,i.colors[Y].a):s,(ee=new r.Mesh(J,$)).scale.x=i.scale.x,ee.scale.y=i.scale.y,ee.scale.z=i.scale.z,ee.position.x=i.points[Y].x,ee.position.y=i.points[Y].y,ee.position.z=i.points[Y].z,te.add(ee);this.add(te);break;case p:var oe,ne=new r.Geometry,ae=new r.ParticleBasicMaterial({size:i.scale.x});for(oe=0;oe<i.points.length;oe++){var ce=new r.Vector3;ce.x=i.points[oe].x,ce.y=i.points[oe].y,ce.z=i.points[oe].z,ne.vertices.push(ce)}if(i.colors.length===i.points.length)for(ae.vertexColors=!0,oe=0;oe<i.points.length;oe++){var he=new r.Color;he.setRGB(i.colors[oe].r,i.colors[oe].g,i.colors[oe].b),ne.colors.push(he)}else ae.color.setRGB(i.color.r,i.color.g,i.color.b);this.add(new r.ParticleSystem(ne,ae));break;case m:if(i.text.length>0){var le=this.msgColor,de=document.createElement("canvas"),ue=de.getContext("2d");ue.font="normal 100px sans-serif";var pe=ue.measureText(i.text).width;de.width=pe,de.height=150,ue.font="normal 100px sans-serif",ue.fillStyle="rgba("+Math.round(255*le.r)+", "+Math.round(255*le.g)+", "+Math.round(255*le.b)+", "+le.a+")",ue.textAlign="left",ue.textBaseline="middle",ue.fillText(i.text,0,de.height/2);var me=new r.Texture(de);me.needsUpdate=!0;var fe=new r.SpriteMaterial({map:me,useScreenCoordinates:!1}),ve=new r.Sprite(fe),ge=i.scale.x;ve.scale.set(pe/de.height*ge,ge,1),this.add(ve)}break;case f:var be=null;0===i.color.r&&0===i.color.g&&0===i.color.b&&0===i.color.a||(be=s),this.msgMesh=i.mesh_resource.substr(10);var ye=new V({path:t,resource:this.msgMesh,material:be});this.add(ye);break;case v:var we=new I({material:s,vertices:i.points,colors:i.colors});we.scale.set(i.scale.x,i.scale.y,i.scale.z),this.add(we);break;default:console.error("Currently unsupported marker type: "+i.type)}}setPose(e){this.position.x=e.position.x,this.position.y=e.position.y,this.position.z=e.position.z,this.quaternion.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w),this.quaternion.normalize(),this.updateMatrixWorld()}update(e){if(this.setPose(e.pose),e.color.r!==this.msgColor.r||e.color.g!==this.msgColor.g||e.color.b!==this.msgColor.b||e.color.a!==this.msgColor.a){var t=S(e.color.r,e.color.g,e.color.b,e.color.a);switch(e.type){case h:case l:case p:break;case o:case n:case a:case c:case v:case m:this.traverse(function(e){e instanceof r.Mesh&&(e.material=t)});break;case f:var i=null;0===e.color.r&&0===e.color.g&&0===e.color.b&&0===e.color.a||(i=this.colorMaterial),this.traverse(function(e){e instanceof r.Mesh&&(e.material=i)});break;case d:case u:default:return!1}this.msgColor=e.color}var s=Math.abs(this.msgScale[0]-e.scale.x)>1e-6||Math.abs(this.msgScale[1]-e.scale.y)>1e-6||Math.abs(this.msgScale[2]-e.scale.z)>1e-6;switch(this.msgScale=[e.scale.x,e.scale.y,e.scale.z],e.type){case n:case a:case c:if(s)return!1;break;case m:if(s||this.text!==e.text)return!1;break;case f:if(e.mesh_resource.substr(10)!==this.msgMesh)return!1;if(s)return!1;break;case o:case h:case l:case d:case u:case p:case v:return!1}return!0}dispose(){this.children.forEach(function(e){e instanceof V?e.children.forEach(function(t){void 0!==t.material&&t.material.dispose(),t.children.forEach(function(e){void 0!==e.geometry&&e.geometry.dispose(),void 0!==e.material&&e.material.dispose(),t.remove(e)}),e.remove(t)}):(void 0!==e.geometry&&e.geometry.dispose(),void 0!==e.material&&e.material.dispose()),e.parent.remove(e)})}}class F extends r.Object3D{constructor(e){super();var t=this;e=e||{},this.parent=e.parent;var s=e.handle,o=e.message;this.message=o,this.name=o.name,this.camera=e.camera,this.path=e.path||"/",this.loader=e.loader,this.dragging=!1,this.startMousePos=new r.Vector2,this.isShift=!1;var n=new r.Quaternion(o.orientation.x,o.orientation.y,o.orientation.z,o.orientation.w);n.normalize();var a=new r.Vector3(1,0,0);switch(a.applyQuaternion(n),this.currentControlOri=new r.Quaternion,o.interaction_mode){case N:case A:this.addEventListener("mousemove",this.parent.move3d.bind(this.parent,this,a));case M:this.addEventListener("mousemove",this.parent.moveAxis.bind(this.parent,this,a)),this.addEventListener("touchmove",this.parent.moveAxis.bind(this.parent,this,a));break;case C:this.addEventListener("mousemove",this.parent.rotateAxis.bind(this.parent,this,n));break;case k:this.addEventListener("mousemove",this.parent.movePlane.bind(this.parent,this,a));break;case E:this.addEventListener("click",this.parent.buttonClick.bind(this.parent,this))}function c(e){e.stopPropagation()}o.interaction_mode!==T&&(this.addEventListener("mousedown",this.parent.startDrag.bind(this.parent,this)),this.addEventListener("mouseup",this.parent.stopDrag.bind(this.parent,this)),this.addEventListener("contextmenu",this.parent.showMenu.bind(this.parent,this)),this.addEventListener("mouseup",function(e){0===t.startMousePos.distanceToSquared(e.mousePos)&&(e.type="contextmenu",t.dispatchEvent(e))}),this.addEventListener("mouseover",c),this.addEventListener("mouseout",c),this.addEventListener("click",c),this.addEventListener("mousedown",function(e){t.startMousePos=e.mousePos}),this.addEventListener("touchstart",function(e){1===e.domEvent.touches.length&&(e.type="mousedown",e.domEvent.button=0,t.dispatchEvent(e))}),this.addEventListener("touchmove",function(e){1===e.domEvent.touches.length&&(e.type="mousemove",e.domEvent.button=0,t.dispatchEvent(e))}),this.addEventListener("touchend",function(e){0===e.domEvent.touches.length&&(e.domEvent.button=0,e.type="mouseup",t.dispatchEvent(e),e.type="click",t.dispatchEvent(e))}),window.addEventListener("keydown",function(e){16===e.keyCode&&(t.isShift=!0)}),window.addEventListener("keyup",function(e){16===e.keyCode&&(t.isShift=!1)}));var h=new r.Quaternion,l=this.parent.position.clone().multiplyScalar(-1);switch(o.orientation_mode){case O:h=this.parent.quaternion.clone().inverse();break;case _:case R:break;default:console.error("Unkown orientation mode: "+o.orientation_mode)}var d=new i.TFClient({ros:s.tfClient.ros,fixedFrame:s.message.header.frame_id,serverName:s.tfClient.serverName});o.markers.forEach(function(e){var s=function(s){var o=new z({message:e,path:t.path,loader:t.loader});if(null!==s){var n=new i.Pose({position:o.position,orientation:o.quaternion});n.applyTransform(new i.Transform(s));var a=new z({message:e,path:t.path,loader:t.loader});a.position.add(l),a.position.applyQuaternion(h),a.quaternion.multiplyQuaternions(h,a.quaternion);var c=new r.Vector3(a.position.x,a.position.y,a.position.z),u=new i.Transform({translation:c,orientation:a.quaternion});n.applyTransform(u),o.setPose(n),o.updateMatrixWorld(),d.unsubscribe(e.header.frame_id)}t.add(o)};""!==e.header.frame_id?d.subscribe(e.header.frame_id,s):s(null)})}updateMatrixWorld(e){var t=this.message;switch(t.orientation_mode){case O:super.updateMatrixWorld(e),this.currentControlOri.copy(this.quaternion),this.currentControlOri.normalize();break;case _:this.quaternion.copy(this.parent.quaternion.clone().inverse()),this.updateMatrix(),this.matrixWorldNeedsUpdate=!0,super.updateMatrixWorld(e),this.currentControlOri.copy(this.quaternion);break;case R:this.camera.updateMatrixWorld();var i=(new r.Matrix4).extractRotation(this.camera.matrixWorld),s=new r.Matrix4,o=.5*Math.PI,n=new r.Euler(-o,0,o);s.makeRotationFromEuler(n);var a=new r.Matrix4;a.getInverse(this.parent.matrixWorld),i.multiplyMatrices(i,s),i.multiplyMatrices(a,i),this.currentControlOri.setFromRotationMatrix(i),t.independent_marker_orientation||(this.quaternion.copy(this.currentControlOri),this.updateMatrix(),this.matrixWorldNeedsUpdate=!0),super.updateMatrixWorld(e);break;default:console.error("Unkown orientation mode: "+t.orientation_mode)}}}class B extends r.EventDispatcher{constructor(e){super();var t,i,s,r=this,o=(e=e||{}).menuEntries,n=e.className||"default-interactive-marker-menu",a=(e.entryClassName,e.overlayClassName||"default-interactive-marker-overlay"),c=e.menuFontSize||"0.8em",h=[];if(h[0]={children:[]},null===document.getElementById("default-interactive-marker-menu-css")){var l=document.createElement("style");l.id="default-interactive-marker-menu-css",l.type="text/css",l.innerHTML=".default-interactive-marker-menu {background-color: #444444;border: 1px solid #888888;border: 1px solid #888888;padding: 0px 0px 0px 0px;color: #FFFFFF;font-family: sans-serif;font-size: "+c+";z-index: 1002;}.default-interactive-marker-menu ul {padding: 0px 0px 5px 0px;margin: 0px;list-style-type: none;}.default-interactive-marker-menu ul li div {-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;cursor: default;padding: 3px 10px 3px 10px;}.default-interactive-marker-menu-entry:hover { background-color: #666666; cursor: pointer;}.default-interactive-marker-menu ul ul { font-style: italic; padding-left: 10px;}.default-interactive-marker-overlay { position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index: 1001; -moz-opacity: 0.0; opacity: .0; filter: alpha(opacity = 0);}",document.getElementsByTagName("head")[0].appendChild(l)}for(this.menuDomElem=document.createElement("div"),this.menuDomElem.style.position="absolute",this.menuDomElem.className=n,this.menuDomElem.addEventListener("contextmenu",function(e){e.preventDefault()}),this.overlayDomElem=document.createElement("div"),this.overlayDomElem.className=a,this.hideListener=this.hide.bind(this),this.overlayDomElem.addEventListener("contextmenu",this.hideListener),this.overlayDomElem.addEventListener("click",this.hideListener),this.overlayDomElem.addEventListener("touchstart",this.hideListener),t=0;t<o.length;t++)h[s=(i=o[t]).id]={title:i.title,id:s,children:[]};for(t=0;t<o.length;t++){var d=h[s=(i=o[t]).id];h[i.parent_id].children.push(d)}function u(e,t){this.dispatchEvent({type:"menu-select",domEvent:t,id:e.id,controlName:this.controlName}),this.hide(t)}!function e(t,i){var s=document.createElement("ul");t.appendChild(s);for(var o=i.children,n=0;n<o.length;n++){var a=document.createElement("li"),c=document.createElement("div");c.appendChild(document.createTextNode(o[n].title)),s.appendChild(a),a.appendChild(c),o[n].children.length>0?(e(a,o[n]),c.addEventListener("click",r.hide.bind(r)),c.addEventListener("touchstart",r.hide.bind(r))):(c.addEventListener("click",u.bind(r,o[n])),c.addEventListener("touchstart",u.bind(r,o[n])),c.className="default-interactive-marker-menu-entry")}}(this.menuDomElem,h[0])}show(e,t){t&&t.preventDefault&&t.preventDefault(),this.controlName=e.name,void 0!==t.domEvent.changedTouches?(this.menuDomElem.style.left=t.domEvent.changedTouches[0].pageX+"px",this.menuDomElem.style.top=t.domEvent.changedTouches[0].pageY+"px"):(this.menuDomElem.style.left=t.domEvent.clientX+"px",this.menuDomElem.style.top=t.domEvent.clientY+"px"),document.body.appendChild(this.overlayDomElem),document.body.appendChild(this.menuDomElem)}hide(e){e&&e.preventDefault&&e.preventDefault(),document.body.removeChild(this.overlayDomElem),document.body.removeChild(this.menuDomElem)}}class U extends r.Object3D{constructor(e){super();var t=this,i=(e=e||{}).handle;this.name=i.name;var s=e.camera,o=e.path||"/",n=e.loader;this.dragging=!1,this.onServerSetPose({pose:i.pose}),this.dragStart={position:new r.Vector3,orientation:new r.Quaternion,positionWorld:new r.Vector3,orientationWorld:new r.Quaternion,event3d:{}},i.controls.forEach(function(e){t.add(new F({parent:t,handle:i,message:e,camera:s,path:o,loader:n}))}),i.menuEntries.length>0&&(this.menu=new B({menuEntries:i.menuEntries,menuFontSize:i.menuFontSize}),this.menu.addEventListener("menu-select",function(e){t.dispatchEvent(e)}))}showMenu(e,t){this.menu&&this.menu.show(e,t)}moveAxis(e,t,i){if(this.dragging){var s=e.currentControlOri,o=t.clone().applyQuaternion(s),n=this.dragStart.event3d.intersection.point,a=o.clone().applyQuaternion(this.dragStart.orientationWorld.clone()),c=new r.Ray(n,a),h=P(c,i.camera,i.mousePos),l=new r.Vector3;l.addVectors(this.dragStart.position,o.clone().applyQuaternion(this.dragStart.orientation).multiplyScalar(h)),this.setPosition(e,l),i.stopPropagation()}}move3d(e,t,i){if(this.dragging)if(e.isShift);else{var s=e.camera.getWorldDirection(),o=Math.abs(s.x),n=Math.abs(s.y),a=Math.abs(s.z),c=new r.Quaternion(1,0,0,1);n>o&&n>a?c=new r.Quaternion(0,0,1,1):a>o&&a>n&&(c=new r.Quaternion(0,1,0,1)),c.normalize(),(t=new r.Vector3(1,0,0)).applyQuaternion(c),this.movePlane(e,t,i)}}movePlane(e,t,i){if(this.dragging){var s=e.currentControlOri,o=t.clone().applyQuaternion(s),n=this.dragStart.event3d.intersection.point,a=o.clone().applyQuaternion(this.dragStart.orientationWorld),c=D(i.mouseRay,n,a),h=new r.Vector3;h.subVectors(c,n),h.add(this.dragStart.positionWorld),this.setPosition(e,h),i.stopPropagation()}}rotateAxis(e,t,i){if(this.dragging){e.updateMatrixWorld();var s=e.currentControlOri.clone().multiply(t.clone()),o=new r.Vector3(1,0,0).applyQuaternion(s),n=this.dragStart.event3d.intersection.point,a=o.applyQuaternion(this.dragStart.orientationWorld),c=D(i.mouseRay,n,a),h=new r.Ray(this.dragStart.positionWorld,a),l=D(h,n,a),d=this.dragStart.orientationWorld.clone().multiply(s).clone().inverse();c.sub(l),c.applyQuaternion(d);var u=this.dragStart.event3d.intersection.point.clone();u.sub(l),u.applyQuaternion(d);var p=Math.atan2(c.y,c.z),m=Math.atan2(u.y,u.z)-p,f=new r.Quaternion;f.setFromAxisAngle(o,m),this.setOrientation(e,f.multiply(this.dragStart.orientationWorld)),i.stopPropagation()}}feedbackEvent(e,t){this.dispatchEvent({type:e,position:this.position.clone(),orientation:this.quaternion.clone(),controlName:t.name})}startDrag(e,t){if(0===t.domEvent.button){t.stopPropagation(),this.dragging=!0,this.updateMatrixWorld(!0);var i=new r.Vector3;this.matrixWorld.decompose(this.dragStart.positionWorld,this.dragStart.orientationWorld,i),this.dragStart.position=this.position.clone(),this.dragStart.orientation=this.quaternion.clone(),this.dragStart.event3d=t,this.feedbackEvent("user-mousedown",e)}}stopDrag(e,t){0===t.domEvent.button&&(t.stopPropagation(),this.dragging=!1,this.dragStart.event3d={},this.onServerSetPose(this.bufferedPoseEvent),this.bufferedPoseEvent=void 0,this.feedbackEvent("user-mouseup",e))}buttonClick(e,t){t.stopPropagation(),this.feedbackEvent("user-button-click",e)}setPosition(e,t){this.position.copy(t),this.feedbackEvent("user-pose-change",e)}setOrientation(e,t){t.normalize(),this.quaternion.copy(t),this.feedbackEvent("user-pose-change",e)}onServerSetPose(e){if(void 0!==e)if(this.dragging)this.bufferedPoseEvent=e;else{var t=e.pose;this.position.copy(t.position),this.quaternion.copy(t.orientation),this.updateMatrixWorld(!0)}}dispose(){var e=this;this.children.forEach(function(t){t.children.forEach(function(e){e.dispose(),t.remove(e)}),e.remove(t)})}}class q extends s{constructor(e){super(),e=e||{},this.message=e.message,this.feedbackTopic=e.feedbackTopic,this.tfClient=e.tfClient,this.menuFontSize=e.menuFontSize||"0.8em",this.name=this.message.name,this.header=this.message.header,this.controls=this.message.controls,this.menuEntries=this.message.menu_entries,this.dragging=!1,this.timeoutHandle=null,this.tfTransform=new i.Transform,this.pose=new i.Pose,this.setPoseFromClientBound=this.setPoseFromClient.bind(this),this.onMouseDownBound=this.onMouseDown.bind(this),this.onMouseUpBound=this.onMouseUp.bind(this),this.onButtonClickBound=this.onButtonClick.bind(this),this.onMenuSelectBound=this.onMenuSelect.bind(this),this.setPoseFromServer(this.message.pose),this.tfUpdateBound=this.tfUpdate.bind(this)}subscribeTf(){0===this.message.header.stamp.secs&&0===this.message.header.stamp.nsecs&&this.tfClient.subscribe(this.message.header.frame_id,this.tfUpdateBound)}unsubscribeTf(){this.tfClient.unsubscribe(this.message.header.frame_id,this.tfUpdateBound)}emitServerPoseUpdate(){var e=new i.Pose(this.pose);e.applyTransform(this.tfTransform),this.emit("pose",e)}setPoseFromServer(e){this.pose=new i.Pose(e),this.emitServerPoseUpdate()}tfUpdate(e){this.tfTransform=new i.Transform(e),this.emitServerPoseUpdate()}setPoseFromClient(e){this.pose=new i.Pose(e);var t=this.tfTransform.clone();t.rotation.invert(),t.translation.multiplyQuaternion(t.rotation),t.translation.x*=-1,t.translation.y*=-1,t.translation.z*=-1,this.pose.applyTransform(t),this.sendFeedback(g,void 0,0,e.controlName),this.dragging&&(this.timeoutHandle&&clearTimeout(this.timeoutHandle),this.timeoutHandle=setTimeout(this.setPoseFromClient.bind(this,e),250))}onButtonClick(e){this.sendFeedback(y,e.clickPosition,0,e.controlName)}onMouseDown(e){this.sendFeedback(w,e.clickPosition,0,e.controlName),this.dragging=!0}onMouseUp(e){this.sendFeedback(x,e.clickPosition,0,e.controlName),this.dragging=!1,this.timeoutHandle&&clearTimeout(this.timeoutHandle)}onMenuSelect(e){this.sendFeedback(b,void 0,e.id,e.controlName)}sendFeedback(e,t,i,s){var r=void 0!==t;t=t||{x:0,y:0,z:0};var o={header:this.header,client_id:this.clientID,marker_name:this.name,control_name:s,event_type:e,pose:this.pose,mouse_point:t,mouse_point_valid:r,menu_entry_id:i};this.feedbackTopic.publish(o)}}class G extends r.Object3D{constructor(e){super(),e=e||{};var t=this;this.tfClient=e.tfClient,this.frameID=e.frameID;var s=e.object;this.pose=e.pose||new i.Pose,this.visible=!1,this.add(s),this.updatePose(this.pose),this.tfUpdate=function(e){var s=new i.Transform(e),r=new i.Pose(t.pose);r.applyTransform(s),t.updatePose(r),t.visible=!0},this.tfClient.subscribe(this.frameID,this.tfUpdate)}updatePose(e){this.position.set(e.position.x,e.position.y,e.position.z),this.quaternion.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w),this.updateMatrixWorld(!0)}unsubscribeTf(){this.tfClient.unsubscribe(this.frameID,this.tfUpdate)}}class H extends r.Object3D{constructor(e){super();var t=this,i=(e=e||{}).shaftRadius||.008,s=e.headRadius||.023,o=e.headLength||.1,n=e.scale||1,a=e.lineType||"full",c=e.lineDashLength||.1;function h(e){var s=new r.Color;s.setRGB(e.x,e.y,e.z);var o=new r.MeshBasicMaterial({color:s.getHex()}),n=new r.Vector3;n.crossVectors(e,new r.Vector3(0,-1,0));var h=new r.Quaternion;h.setFromAxisAngle(n,.5*Math.PI);var l,d=new r.Mesh(t.headGeom,o);if(d.position.copy(e),d.position.multiplyScalar(.95),d.quaternion.copy(h),d.updateMatrix(),t.add(d),"dashed"===a)for(var u=c,p=0;u/2+3*u*p+u/2<=1;++p){var m=new r.CylinderGeometry(i,i,u);(l=new r.Mesh(m,o)).position.copy(e),l.position.multiplyScalar(u/2+3*u*p),l.quaternion.copy(h),l.updateMatrix(),t.add(l)}else"full"===a?((l=new r.Mesh(t.lineGeom,o)).position.copy(e),l.position.multiplyScalar(.45),l.quaternion.copy(h),l.updateMatrix(),t.add(l)):console.warn("[Axes]: Unsupported line type. Not drawing any axes.")}this.scale.set(n,n,n),this.lineGeom=new r.CylinderGeometry(i,i,1-o),this.headGeom=new r.CylinderGeometry(0,s,o),h(new r.Vector3(1,0,0)),h(new r.Vector3(0,1,0)),h(new r.Vector3(0,0,1))}}class W extends r.Mesh{constructor(e){for(var t=(e=e||{}).message,i=e.color||{r:255,g:255,b:255},s=e.opacity||1,o=t.info.width,n=t.info.height,a=new r.PlaneBufferGeometry(o,n),c=new Uint8Array(o*n*3),h=0;h<n;h++)for(var l=0;l<o;l++){var d,u=l+(n-h-1)*o,p=t.data[u];d=100===p?0:0===p?255:127;var m=3*(l+h*o);c[m]=d*i.r/255,c[++m]=d*i.g/255,c[++m]=d*i.b/255}var f=new r.DataTexture(c,o,n,r.RGBFormat);f.flipY=!0,f.minFilter=r.LinearFilter,f.magFilter=r.LinearFilter,f.needsUpdate=!0;var v=new r.MeshBasicMaterial({map:f,transparent:s<1,opacity:s});v.side=r.DoubleSide,super(a,v),this.quaternion.copy(new r.Quaternion(t.info.origin.orientation.x,t.info.origin.orientation.y,t.info.origin.orientation.z,t.info.origin.orientation.w)),this.position.x=o*t.info.resolution/2+t.info.origin.position.x,this.position.y=n*t.info.resolution/2+t.info.origin.position.y,this.position.z=t.info.origin.position.z,this.scale.x=t.info.resolution,this.scale.y=t.info.resolution}}class K extends r.Object3D{constructor(e){super(),e=e||{},this.tfClient=e.tfClient,this.rootObject=e.rootObject||new r.Object3D,this.max_pts=e.max_pts||1e4,this.pointRatio=e.pointRatio||1,this.messageRatio=e.messageRatio||1,this.messageCount=0,this.material=e.material||{},this.colorsrc=e.colorsrc,this.colormap=e.colormap,("color"in e||"size"in e||"texture"in e)&&console.warn('toplevel "color", "size" and "texture" options are deprecated.They should beprovided within a "material" option, e.g. : { tfClient, material : { color: mycolor, size: mysize, map: mytexture }, ... }'),this.sn=null}setup(e,t,i){if(null===this.sn){i=i||[],this.fields={};for(var s=0;s<i.length;s++)this.fields[i[s].name]=i[s];if(this.geom=new r.BufferGeometry,this.positions=new r.BufferAttribute(new Float32Array(3*this.max_pts),3,!1),this.geom.addAttribute("position",this.positions.setDynamic(!0)),!this.colorsrc&&this.fields.rgb&&(this.colorsrc="rgb"),this.colorsrc){var o=this.fields[this.colorsrc];if(o){this.colors=new r.BufferAttribute(new Float32Array(3*this.max_pts),3,!1),this.geom.addAttribute("color",this.colors.setDynamic(!0));var n=o.offset;this.getColor=[function(e,t,i){return e.getInt8(t+n,i)},function(e,t,i){return e.getUint8(t+n,i)},function(e,t,i){return e.getInt16(t+n,i)},function(e,t,i){return e.getUint16(t+n,i)},function(e,t,i){return e.getInt32(t+n,i)},function(e,t,i){return e.getUint32(t+n,i)},function(e,t,i){return e.getFloat32(t+n,i)},function(e,t,i){return e.getFloat64(t+n,i)}][o.datatype-1],this.colormap=this.colormap||function(e){return new r.Color(e)}}else console.warn('unavailable field "'+this.colorsrc+'" for coloring.')}this.material.isMaterial||(this.colors&&void 0===this.material.vertexColors&&(this.material.vertexColors=r.VertexColors),this.material=new r.PointsMaterial(this.material)),this.object=new r.Points(this.geom,this.material),this.sn=new G({frameID:e,tfClient:this.tfClient,object:this.object}),this.rootObject.add(this.sn)}return this.messageCount++%this.messageRatio==0}update(e){this.geom.setDrawRange(0,e),this.positions.needsUpdate=!0,this.positions.updateRange.count=e*this.positions.itemSize,this.colors&&(this.colors.needsUpdate=!0,this.colors.updateRange.count=e*this.colors.itemSize)}}function Q(e,t,i,s){var r,o=0,n=0,a=0,c=e.length,h=t.length;i=i||h;var l=((s=s||1)-1)*i*8;for(r=0;r<c&&a<h;r++)o=(o<<6)+Q.e[e.charAt(r)],(n+=6)>=8&&(n-=8,t[a++]=o>>>n&255,a%i==0&&(r+=Math.ceil((l-n)/6),(n%=8)>0&&(o=Q.e[e.charAt(r)])));return Math.floor(a/i)}Q.S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Q.e={};for(var X=0;X<64;X++)Q.e[Q.S.charAt(X)]=X;class Z extends r.Object3D{constructor(e){var t=(e=e||{}).urdfModel,s=e.path||"/",o=e.tfClient,n=e.tfPrefix||"",a=e.loader;super();var c=t.links;for(var h in c)for(var l=c[h],d=0;d<l.visuals.length;d++){var u=l.visuals[d];if(u&&u.geometry){var p=n+"/"+l.name,m=null;if(u.material&&u.material.color){var f=u.material&&u.material.color;m=S(f.r,f.g,f.b,f.a)}if(u.geometry.type===i.URDF_MESH){var v=u.geometry.filename,g=v.indexOf("package://");-1!==g&&(v=v.substr(g+"package://".length));var b=v.substr(-4).toLowerCase();if(".dae"===b||".stl"===b){var y=new V({path:s,resource:v,loader:a,material:m});l.visuals[d].geometry.scale&&y.scale.copy(u.geometry.scale);var w=new G({frameID:p,pose:u.origin,tfClient:o,object:y});this.add(w)}else console.warn("Could not load geometry mesh: "+v)}else{var x;switch(m||(m=S(0,0,0,1)),u.geometry.type){case i.URDF_BOX:var T=u.geometry.dimension,E=new r.BoxGeometry(T.x,T.y,T.z);x=new r.Mesh(E,m);break;case i.URDF_CYLINDER:var M=u.geometry.radius,k=u.geometry.length,C=new r.CylinderGeometry(M,M,k,16,1,!1);(x=new r.Mesh(C,m)).quaternion.setFromAxisAngle(new r.Vector3(1,0,0),.5*Math.PI);break;case i.URDF_SPHERE:var A=new r.SphereGeometry(u.geometry.radius,16);x=new r.Mesh(A,m)}var N=new G({frameID:p,pose:u.origin,tfClient:o,object:x});this.add(N)}}}}unsubscribeTf(){this.children.forEach(function(e){"function"==typeof e.unsubscribeTf&&e.unsubscribeTf()})}}class Y{constructor(e){e=e||{},this.mouseHandler=e.mouseHandler,this.hoverObjs={},this.mouseHandler.addEventListener("mouseover",this.onMouseOver.bind(this)),this.mouseHandler.addEventListener("mouseout",this.onMouseOut.bind(this))}onMouseOver(e){this.hoverObjs[e.currentTarget.uuid]=e.currentTarget}onMouseOut(e){var t=e.currentTarget.uuid;t in this.hoverObjs&&delete this.hoverObjs[t]}renderHighlights(e,t,i){this.makeEverythingInvisible(e),this.makeHighlightedVisible(e);var s=e.overrideMaterial;e.overrideMaterial=new r.MeshBasicMaterial({fog:!1,opacity:.5,transparent:!0,depthTest:!0,depthWrite:!1,polygonOffset:!0,polygonOffsetUnits:-1,side:r.DoubleSide}),t.render(e,i),e.overrideMaterial=s,this.restoreVisibility(e)}makeEverythingInvisible(e){e.traverse(function(e){(e instanceof r.Mesh||e instanceof r.Line||e instanceof r.Sprite)&&(e.previousVisibility=e.visible,e.visible=!1)})}makeHighlightedVisible(e){var t=function(e){(e instanceof r.Mesh||e instanceof r.Line||e instanceof r.Sprite)&&(e.visible=!0)};for(var i in this.hoverObjs){var s=this.hoverObjs[i];s.visible=!0,s.traverse(t)}}restoreVisibility(e){e.traverse(function(e){e.hasOwnProperty("previousVisibility")&&(e.visible=e.previousVisibility)}.bind(this))}}class J extends r.EventDispatcher{constructor(e){super(),this.renderer=e.renderer,this.camera=e.camera,this.rootObject=e.rootObject,this.fallbackTarget=e.fallbackTarget,this.lastTarget=this.fallbackTarget,this.dragging=!1;this.listeners={},["contextmenu","click","dblclick","mouseout","mousedown","mouseup","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchcancel","touchleave","touchmove"].forEach(function(e){this.listeners[e]=this.processDomEvent.bind(this),this.renderer.domElement.addEventListener(e,this.listeners[e],!1)},this)}processDomEvent(e){e.preventDefault();var t,i,s=e.target,o=s.getBoundingClientRect();if(-1!==e.type.indexOf("touch")){t=0,i=0;for(var n=0;n<e.touches.length;++n)t+=e.touches[n].clientX,i+=e.touches[n].clientY;t/=e.touches.length,i/=e.touches.length}else t=e.clientX,i=e.clientY;var a=t-o.left-s.clientLeft+s.scrollLeft,c=i-o.top-s.clientTop+s.scrollTop,h=a/s.clientWidth*2-1,l=-c/s.clientHeight*2+1,d=new r.Vector3(h,l,.5);d.unproject(this.camera);var u=new r.Raycaster(this.camera.position.clone(),d.sub(this.camera.position).normalize());u.linePrecision=.001;var p=u.ray,m={mousePos:new r.Vector2(h,l),mouseRay:p,domEvent:e,camera:this.camera,intersection:this.lastIntersection};if("mouseout"===e.type)return this.dragging&&(this.notify(this.lastTarget,"mouseup",m),this.dragging=!1),this.notify(this.lastTarget,"mouseout",m),void(this.lastTarget=null);if("touchleave"===e.type||"touchend"===e.type)return this.dragging&&(this.notify(this.lastTarget,"mouseup",m),this.dragging=!1),this.notify(this.lastTarget,"touchend",m),void(this.lastTarget=null);if(this.dragging)return this.notify(this.lastTarget,e.type,m),void(("mouseup"===e.type&&2===e.button||"click"===e.type||"touchend"===e.type)&&(this.dragging=!1));s=this.lastTarget;var f;if((f=u.intersectObject(this.rootObject,!0)).length>0?(s=f[0].object,m.intersection=this.lastIntersection=f[0]):s=this.fallbackTarget,s!==this.lastTarget&&e.type.match(/mouse/)){var v=this.notify(s,"mouseover",m);0===v?this.notify(this.lastTarget,"mouseout",m):1===v&&(s=this.fallbackTarget)!==this.lastTarget&&(this.notify(s,"mouseover",m),this.notify(this.lastTarget,"mouseout",m))}s!==this.lastTarget&&e.type.match(/touch/)&&(this.notify(s,e.type,m)?(this.notify(this.lastTarget,"touchleave",m),this.notify(this.lastTarget,"touchend",m)):(s=this.fallbackTarget)!==this.lastTarget&&(this.notify(this.lastTarget,"touchmove",m),this.notify(this.lastTarget,"touchend",m)));this.notify(s,e.type,m),"mousedown"!==e.type&&"touchstart"!==e.type&&"touchmove"!==e.type||(this.dragging=!0),this.lastTarget=s}notify(e,t,i){for(i.type=t,i.cancelBubble=!1,i.continueBubble=!1,i.stopPropagation=function(){i.cancelBubble=!0},i.continuePropagation=function(){i.continueBubble=!0},i.currentTarget=e;i.currentTarget;){if(i.currentTarget.dispatchEvent&&i.currentTarget.dispatchEvent instanceof Function){if(i.currentTarget.dispatchEvent(i),i.cancelBubble)return this.dispatchEvent(i),0;if(i.continueBubble)return 2}i.currentTarget=i.currentTarget.parent}return 1}}class $ extends r.EventDispatcher{constructor(e){super();var t=this,i=(e=e||{}).scene;this.camera=e.camera,this.center=new r.Vector3,this.userZoom=!0,this.userZoomSpeed=e.userZoomSpeed||1,this.userRotate=!0,this.userRotateSpeed=e.userRotateSpeed||1,this.autoRotate=e.autoRotate,this.autoRotateSpeed=e.autoRotateSpeed||2,this.displayPanAndZoomFrame=void 0===e.displayPanAndZoomFrame||!!e.displayPanAndZoomFrame,this.lineTypePanAndZoomFrame=e.dashedPanAndZoomFrame||"full",this.camera.up=new r.Vector3(0,0,1);var s=1800,o=10,n=new r.Vector2,a=new r.Vector2,c=new r.Vector2,h=new r.Vector2,l=new r.Vector2,d=new r.Vector2,u=new r.Vector3,p=new r.Vector3,m=new r.Vector3,f=new r.Vector3,v=new Array(2),g=new Array(2);this.phiDelta=0,this.thetaDelta=0,this.scale=1,this.lastPosition=new r.Vector3;var b={NONE:-1,ROTATE:0,ZOOM:1,MOVE:2},y=b.NONE;function w(e,t,i){var s=new r.Vector3;new r.Vector3;s.subVectors(t,e.origin);var o=e.direction.dot(i);if(Math.abs(o)<e.precision)return null;var n=i.dot(s)/o;return e.direction.clone().multiplyScalar(n)}function x(e){if(t.userZoom){var i=e.domEvent;(void 0!==i.wheelDelta?i.wheelDelta:-i.detail)>0?t.zoomIn():t.zoomOut(),this.showAxes()}}this.axes=new H({shaftRadius:.025,headRadius:.07,headLength:.2,lineType:this.lineTypePanAndZoomFrame}),this.displayPanAndZoomFrame&&(i.add(this.axes),this.axes.traverse(function(e){e.visible=!1})),this.addEventListener("mousedown",function(e){var i=e.domEvent;switch(i.preventDefault(),i.button){case 0:y=b.ROTATE,n.set(i.clientX,i.clientY);break;case 1:y=b.MOVE,p=new r.Vector3(0,0,1);var s=(new r.Matrix4).extractRotation(this.camera.matrix);p.applyMatrix4(s),u=t.center.clone(),m=t.camera.position.clone(),f=w(e.mouseRay,u,p);break;case 2:y=b.ZOOM,h.set(i.clientX,i.clientY)}this.showAxes()}),this.addEventListener("mouseup",function(e){t.userRotate&&(y=b.NONE)}),this.addEventListener("mousemove",function(e){var i=e.domEvent;if(y===b.ROTATE)a.set(i.clientX,i.clientY),c.subVectors(a,n),t.rotateLeft(2*Math.PI*c.x/s*t.userRotateSpeed),t.rotateUp(2*Math.PI*c.y/s*t.userRotateSpeed),n.copy(a),this.showAxes();else if(y===b.ZOOM)l.set(i.clientX,i.clientY),d.subVectors(l,h),d.y>0?t.zoomIn():t.zoomOut(),h.copy(l),this.showAxes();else if(y===b.MOVE){var o=w(e.mouseRay,t.center,p);if(!o)return;var v=(new r.Vector3).subVectors(f.clone(),o.clone());t.center.addVectors(u.clone(),v.clone()),t.camera.position.addVectors(m.clone(),v.clone()),t.update(),t.camera.updateMatrixWorld(),this.showAxes()}}),this.addEventListener("touchstart",function(e){var i=e.domEvent;switch(i.touches.length){case 1:y=b.ROTATE,n.set(i.touches[0].pageX-window.scrollX,i.touches[0].pageY-window.scrollY);break;case 2:y=b.NONE,p=new r.Vector3(0,0,1);var s=(new r.Matrix4).extractRotation(this.camera.matrix);p.applyMatrix4(s),u=t.center.clone(),m=t.camera.position.clone(),f=w(e.mouseRay,u,p),v[0]=new r.Vector2(i.touches[0].pageX,i.touches[0].pageY),v[1]=new r.Vector2(i.touches[1].pageX,i.touches[1].pageY),g[0]=new r.Vector2(0,0),g[1]=new r.Vector2(0,0)}this.showAxes(),i.preventDefault()}),this.addEventListener("touchmove",function(e){var i=e.domEvent;if(y===b.ROTATE)a.set(i.touches[0].pageX-window.scrollX,i.touches[0].pageY-window.scrollY),c.subVectors(a,n),t.rotateLeft(2*Math.PI*c.x/s*t.userRotateSpeed),t.rotateUp(2*Math.PI*c.y/s*t.userRotateSpeed),n.copy(a),this.showAxes();else{if(g[0].set(v[0].x-i.touches[0].pageX,v[0].y-i.touches[0].pageY),g[1].set(v[1].x-i.touches[1].pageX,v[1].y-i.touches[1].pageY),g[0].lengthSq()>o&&g[1].lengthSq()>o&&(v[0].set(i.touches[0].pageX,i.touches[0].pageY),v[1].set(i.touches[1].pageX,i.touches[1].pageY),g[0].dot(g[1])>0&&y!==b.ZOOM?y=b.MOVE:g[0].dot(g[1])<0&&y!==b.MOVE&&(y=b.ZOOM),y===b.ZOOM)){var h=new r.Vector2;h.subVectors(v[0],v[1]),g[0].dot(h)<0&&g[1].dot(h)>0?t.zoomOut():g[0].dot(h)>0&&g[1].dot(h)<0&&t.zoomIn()}if(y===b.MOVE){var l=w(e.mouseRay,t.center,p);if(!l)return;var d=(new r.Vector3).subVectors(f.clone(),l.clone());t.center.addVectors(u.clone(),d.clone()),t.camera.position.addVectors(m.clone(),d.clone()),t.update(),t.camera.updateMatrixWorld()}this.showAxes(),i.preventDefault()}}),this.addEventListener("touchend",function(e){var t=e.domEvent;1===t.touches.length&&y!==b.ROTATE?(y=b.ROTATE,n.set(t.touches[0].pageX-window.scrollX,t.touches[0].pageY-window.scrollY)):y=b.NONE}),this.addEventListener("mousewheel",x),this.addEventListener("DOMMouseScroll",x)}showAxes(){var e=this;this.axes.traverse(function(e){e.visible=!0}),this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(function(){e.axes.traverse(function(e){e.visible=!1}),e.hideTimeout=!1},1e3)}rotateLeft(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.thetaDelta-=e}rotateRight(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.thetaDelta+=e}rotateUp(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.phiDelta-=e}rotateDown(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.phiDelta+=e}zoomIn(e){void 0===e&&(e=Math.pow(.95,this.userZoomSpeed)),this.scale/=e}zoomOut(e){void 0===e&&(e=Math.pow(.95,this.userZoomSpeed)),this.scale*=e}update(){var e=this.camera.position,t=e.clone().sub(this.center),i=Math.atan2(t.y,t.x),s=Math.atan2(Math.sqrt(t.y*t.y+t.x*t.x),t.z);this.autoRotate&&this.rotateLeft(2*Math.PI/60/60*this.autoRotateSpeed),i+=this.thetaDelta,s+=this.phiDelta;s=Math.max(1e-6,Math.min(Math.PI-1e-6,s));var r=t.length();t.set(r*Math.sin(s)*Math.cos(i),r*Math.sin(s)*Math.sin(i),r*Math.cos(s)),t.multiplyScalar(this.scale),e.copy(this.center).add(t),this.camera.lookAt(this.center),r=t.length(),this.axes.position.copy(this.center),this.axes.scale.set(.05*r,.05*r,.05*r),this.axes.updateMatrixWorld(!0),this.thetaDelta=0,this.phiDelta=0,this.scale=1,this.lastPosition.distanceTo(this.camera.position)>0&&(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.camera.position))}}return e.MARKER_ARROW=o,e.MARKER_CUBE=n,e.MARKER_SPHERE=a,e.MARKER_CYLINDER=c,e.MARKER_LINE_STRIP=h,e.MARKER_LINE_LIST=l,e.MARKER_CUBE_LIST=d,e.MARKER_SPHERE_LIST=u,e.MARKER_POINTS=p,e.MARKER_TEXT_VIEW_FACING=m,e.MARKER_MESH_RESOURCE=f,e.MARKER_TRIANGLE_LIST=v,e.INTERACTIVE_MARKER_KEEP_ALIVE=0,e.INTERACTIVE_MARKER_POSE_UPDATE=g,e.INTERACTIVE_MARKER_MENU_SELECT=b,e.INTERACTIVE_MARKER_BUTTON_CLICK=y,e.INTERACTIVE_MARKER_MOUSE_DOWN=w,e.INTERACTIVE_MARKER_MOUSE_UP=x,e.INTERACTIVE_MARKER_NONE=T,e.INTERACTIVE_MARKER_MENU=1,e.INTERACTIVE_MARKER_BUTTON=E,e.INTERACTIVE_MARKER_MOVE_AXIS=M,e.INTERACTIVE_MARKER_MOVE_PLANE=k,e.INTERACTIVE_MARKER_ROTATE_AXIS=C,e.INTERACTIVE_MARKER_MOVE_ROTATE=6,e.INTERACTIVE_MARKER_MOVE_3D=A,e.INTERACTIVE_MARKER_ROTATE_3D=8,e.INTERACTIVE_MARKER_MOVE_ROTATE_3D=N,e.INTERACTIVE_MARKER_INHERIT=O,e.INTERACTIVE_MARKER_FIXED=_,e.INTERACTIVE_MARKER_VIEW_FACING=R,e.makeColorMaterial=S,e.intersectPlane=D,e.findClosestPoint=j,e.closestAxisPoint=P,e.DepthCloud=class extends r.Object3D{constructor(e){super(),e=e||{},this.url=e.url,this.streamType=e.streamType||"vp8",this.f=e.f||526,this.maxDepthPerTile=e.maxDepthPerTile||1,this.pointSize=e.pointSize||3,this.width=e.width||1024,this.height=e.height||1024,this.resolutionFactor=Math.max(this.width,this.height)/1024,this.whiteness=e.whiteness||0,this.varianceThreshold=e.varianceThreshold||16667e-9,this.isMjpeg="mjpeg"===this.streamType.toLowerCase(),this.video=document.createElement(this.isMjpeg?"img":"video"),this.video.addEventListener(this.isMjpeg?"load":"loadedmetadata",this.metaLoaded.bind(this),!1),this.isMjpeg||(this.video.loop=!0),this.video.src=this.url,this.video.crossOrigin="Anonymous",this.video.setAttribute("crossorigin","Anonymous"),this.vertex_shader=["uniform sampler2D map;","","uniform float width;","uniform float height;","uniform float nearClipping, farClipping;","","uniform float pointSize;","uniform float zOffset;","","uniform float focallength;","uniform float maxDepthPerTile;","uniform float resolutionFactor;","","varying vec2 vUvP;","varying vec2 colorP;","","varying float depthVariance;","varying float maskVal;","","float sampleDepth(vec2 pos)"," {"," float depth;"," "," vec2 vUv = vec2( pos.x / (width*2.0), pos.y / (height*2.0)+0.5 );"," vec2 vUv2 = vec2( pos.x / (width*2.0)+0.5, pos.y / (height*2.0)+0.5 );"," "," vec4 depthColor = texture2D( map, vUv );"," "," depth = ( depthColor.r + depthColor.g + depthColor.b ) / 3.0 ;"," "," if (depth>0.99)"," {"," vec4 depthColor2 = texture2D( map, vUv2 );"," float depth2 = ( depthColor2.r + depthColor2.g + depthColor2.b ) / 3.0 ;"," depth = 0.99+depth2;"," }"," "," return depth;"," }","","float median(float a, float b, float c)"," {"," float r=a;"," "," if ( (a<b) && (b<c) )"," {"," r = b;"," }"," if ( (a<c) && (c<b) )"," {"," r = c;"," }"," return r;"," }","","float variance(float d1, float d2, float d3, float d4, float d5, float d6, float d7, float d8, float d9)"," {"," float mean = (d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9) / 9.0;"," float t1 = (d1-mean);"," float t2 = (d2-mean);"," float t3 = (d3-mean);"," float t4 = (d4-mean);"," float t5 = (d5-mean);"," float t6 = (d6-mean);"," float t7 = (d7-mean);"," float t8 = (d8-mean);"," float t9 = (d9-mean);"," float v = (t1*t1+t2*t2+t3*t3+t4*t4+t5*t5+t6*t6+t7*t7+t8*t8+t9*t9)/9.0;"," return v;"," }","","vec2 decodeDepth(vec2 pos)"," {"," vec2 ret;"," "," "," float depth1 = sampleDepth(vec2(position.x-1.0, position.y-1.0));"," float depth2 = sampleDepth(vec2(position.x, position.y-1.0));"," float depth3 = sampleDepth(vec2(position.x+1.0, position.y-1.0));"," float depth4 = sampleDepth(vec2(position.x-1.0, position.y));"," float depth5 = sampleDepth(vec2(position.x, position.y));"," float depth6 = sampleDepth(vec2(position.x+1.0, position.y));"," float depth7 = sampleDepth(vec2(position.x-1.0, position.y+1.0));"," float depth8 = sampleDepth(vec2(position.x, position.y+1.0));"," float depth9 = sampleDepth(vec2(position.x+1.0, position.y+1.0));"," "," float median1 = median(depth1, depth2, depth3);"," float median2 = median(depth4, depth5, depth6);"," float median3 = median(depth7, depth8, depth9);"," "," ret.x = median(median1, median2, median3);"," ret.y = variance(depth1, depth2, depth3, depth4, depth5, depth6, depth7, depth8, depth9);"," "," return ret;"," "," }","","","void main() {"," "," vUvP = vec2( position.x / (width*2.0), position.y / (height*2.0)+0.5 );"," colorP = vec2( position.x / (width*2.0)+0.5 , position.y / (height*2.0) );"," "," vec4 pos = vec4(0.0,0.0,0.0,0.0);"," depthVariance = 0.0;"," "," if ( (vUvP.x<0.0)|| (vUvP.x>0.5) || (vUvP.y<0.5) || (vUvP.y>0.0))"," {"," vec2 smp = decodeDepth(vec2(position.x, position.y));"," float depth = smp.x;"," depthVariance = smp.y;"," "," float z = -depth;"," "," pos = vec4("," ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength) * -1.0,"," ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength),"," (- z + zOffset / 1000.0) * maxDepthPerTile,"," 1.0);"," "," vec2 maskP = vec2( position.x / (width*2.0), position.y / (height*2.0) );"," vec4 maskColor = texture2D( map, maskP );"," maskVal = ( maskColor.r + maskColor.g + maskColor.b ) / 3.0 ;"," }"," "," gl_PointSize = pointSize;"," gl_Position = projectionMatrix * modelViewMatrix * pos;"," ","}"].join("\n"),this.fragment_shader=["uniform sampler2D map;","uniform float varianceThreshold;","uniform float whiteness;","","varying vec2 vUvP;","varying vec2 colorP;","","varying float depthVariance;","varying float maskVal;","","","void main() {"," "," vec4 color;"," "," if ( (depthVariance>varianceThreshold) || (maskVal>0.5) ||(vUvP.x<0.0)|| (vUvP.x>0.5) || (vUvP.y<0.5) || (vUvP.y>1.0))"," { "," discard;"," }"," else "," {"," color = texture2D( map, colorP );"," "," float fader = whiteness /100.0;"," "," color.r = color.r * (1.0-fader)+ fader;"," "," color.g = color.g * (1.0-fader)+ fader;"," "," color.b = color.b * (1.0-fader)+ fader;"," "," color.a = 1.0;//smoothstep( 20000.0, -20000.0, gl_FragCoord.z / gl_FragCoord.w );"," }"," "," gl_FragColor = vec4( color.r, color.g, color.b, color.a );"," ","}"].join("\n")}metaLoaded(){this.metaLoaded=!0,this.initStreamer()}initStreamer(){if(this.metaLoaded){this.texture=new r.Texture(this.video),this.geometry=new r.Geometry;for(var e=0,t=this.width*this.height;e<t;e++){var i=new r.Vector3;i.x=e%this.width,i.y=Math.floor(e/this.width),this.geometry.vertices.push(i)}this.material=new r.ShaderMaterial({uniforms:{map:{type:"t",value:this.texture},width:{type:"f",value:this.width},height:{type:"f",value:this.height},focallength:{type:"f",value:this.f},pointSize:{type:"f",value:this.pointSize},zOffset:{type:"f",value:0},whiteness:{type:"f",value:this.whiteness},varianceThreshold:{type:"f",value:this.varianceThreshold},maxDepthPerTile:{type:"f",value:this.maxDepthPerTile},resolutionFactor:{type:"f",value:this.resolutionFactor}},vertexShader:this.vertex_shader,fragmentShader:this.fragment_shader}),this.mesh=new r.ParticleSystem(this.geometry,this.material),this.mesh.position.x=0,this.mesh.position.y=0,this.add(this.mesh);var s=this;setInterval(function(){(s.isMjpeg||s.video.readyState===s.video.HAVE_ENOUGH_DATA)&&(s.texture.needsUpdate=!0)},1e3/30)}}startStream(){this.isMjpeg||this.video.play()}stopStream(){this.isMjpeg||this.video.pause()}},e.InteractiveMarker=U,e.InteractiveMarkerClient=class{constructor(e){e=e||{},this.ros=e.ros,this.tfClient=e.tfClient,this.topicName=e.topic,this.path=e.path||"/",this.camera=e.camera,this.rootObject=e.rootObject||new r.Object3D,this.loader=e.loader,this.menuFontSize=e.menuFontSize||"0.8em",this.interactiveMarkers={},this.updateTopic=null,this.feedbackTopic=null,this.topicName&&this.subscribe(this.topicName)}subscribe(e){this.unsubscribe(),this.updateTopic=new i.Topic({ros:this.ros,name:e+"/tunneled/update",messageType:"visualization_msgs/InteractiveMarkerUpdate",compression:"png"}),this.updateTopic.subscribe(this.processUpdate.bind(this)),this.feedbackTopic=new i.Topic({ros:this.ros,name:e+"/feedback",messageType:"visualization_msgs/InteractiveMarkerFeedback",compression:"png"}),this.feedbackTopic.advertise(),this.initService=new i.Service({ros:this.ros,name:e+"/tunneled/get_init",serviceType:"demo_interactive_markers/GetInit"});var t=new i.ServiceRequest({});this.initService.callService(t,this.processInit.bind(this))}unsubscribe(){for(var e in this.updateTopic&&this.updateTopic.unsubscribe(),this.feedbackTopic&&this.feedbackTopic.unadvertise(),this.interactiveMarkers)this.eraseIntMarker(e);this.interactiveMarkers={}}processInit(e){var t=e.msg;for(var i in t.erases=[],this.interactiveMarkers)t.erases.push(i);t.poses=[],this.processUpdate(t)}processUpdate(e){var t=this;e.erases.forEach(function(e){t.eraseIntMarker(e)}),e.poses.forEach(function(e){var i=t.interactiveMarkers[e.name];i&&i.setPoseFromServer(e.pose)}),e.markers.forEach(function(e){var i=t.interactiveMarkers[e.name];i&&t.eraseIntMarker(i.name);var s=new q({message:e,feedbackTopic:t.feedbackTopic,tfClient:t.tfClient,menuFontSize:t.menuFontSize});t.interactiveMarkers[e.name]=s;var r=new U({handle:s,camera:t.camera,path:t.path,loader:t.loader});r.name=e.name,t.rootObject.add(r),s.on("pose",function(e){r.onServerSetPose({pose:e})}),r.addEventListener("user-pose-change",s.setPoseFromClientBound),r.addEventListener("user-mousedown",s.onMouseDownBound),r.addEventListener("user-mouseup",s.onMouseUpBound),r.addEventListener("user-button-click",s.onButtonClickBound),r.addEventListener("menu-select",s.onMenuSelectBound),s.subscribeTf()})}eraseIntMarker(e){if(this.interactiveMarkers[e]){var t=this.rootObject.getObjectByName(e);this.rootObject.remove(t);var i=this.interactiveMarkers[e];i.unsubscribeTf(),t.removeEventListener("user-pose-change",i.setPoseFromClientBound),t.removeEventListener("user-mousedown",i.onMouseDownBound),t.removeEventListener("user-mouseup",i.onMouseUpBound),t.removeEventListener("user-button-click",i.onButtonClickBound),t.removeEventListener("menu-select",i.onMenuSelectBound),delete this.interactiveMarkers[e],t.dispose()}}},e.InteractiveMarkerControl=F,e.InteractiveMarkerHandle=q,e.InteractiveMarkerMenu=B,e.Marker=z,e.MarkerArrayClient=class extends s{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic,this.tfClient=e.tfClient,this.rootObject=e.rootObject||new r.Object3D,this.path=e.path||"/",this.markers={},this.rosTopic=void 0,this.subscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,messageType:"visualization_msgs/MarkerArray",compression:"png"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){e.markers.forEach(function(e){if(0===e.action){var t=!1;if(e.ns+e.id in this.markers&&((t=this.markers[e.ns+e.id].children[0].update(e))||(this.markers[e.ns+e.id].unsubscribeTf(),this.rootObject.remove(this.markers[e.ns+e.id]))),!t){var i=new z({message:e,path:this.path});this.markers[e.ns+e.id]=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:i}),this.rootObject.add(this.markers[e.ns+e.id])}}else if(1===e.action)console.warn('Received marker message with deprecated action identifier "1"');else if(2===e.action)this.markers[e.ns+e.id].unsubscribeTf(),this.rootObject.remove(this.markers[e.ns+e.id]),delete this.markers[e.ns+e.id];else if(3===e.action){for(var s in this.markers)this.markers[s].unsubscribeTf(),this.rootObject.remove(this.markers[s]);this.markers={}}else console.warn('Received marker message with unknown action identifier "'+e.action+'"')}.bind(this)),this.emit("change")}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}},e.MarkerClient=class extends s{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic,this.tfClient=e.tfClient,this.rootObject=e.rootObject||new r.Object3D,this.path=e.path||"/",this.lifetime=e.lifetime||0,this.markers={},this.rosTopic=void 0,this.updatedTime={},this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}checkTime(e){if((new Date).getTime()-this.updatedTime[e]>this.lifetime){var t=this.markers[e];t.unsubscribeTf(),this.rootObject.remove(t),this.emit("change")}else{var i=this;setTimeout(function(){i.checkTime(e)},100)}}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,messageType:"visualization_msgs/Marker",compression:"png"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){var t=new z({message:e,path:this.path}),i=this.markers[e.ns+e.id];this.updatedTime[e.ns+e.id]=(new Date).getTime(),i?(i.unsubscribeTf(),this.rootObject.remove(i)):this.lifetime&&this.checkTime(e.ns+e.id),this.markers[e.ns+e.id]=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:t}),this.rootObject.add(this.markers[e.ns+e.id]),this.emit("change")}},e.Arrow=L,e.Arrow2=class extends r.ArrowHelper{constructor(e){var t=(e=e||{}).origin||new r.Vector3(0,0,0),i=e.direction||new r.Vector3(1,0,0),s=e.length||1;e.headLength,e.shaftDiameter,e.headDiameter,e.material||new r.MeshBasicMaterial,super(i,t,s,16711680)}dispose(){void 0!==this.line&&(this.line.material.dispose(),this.line.geometry.dispose()),void 0!==this.cone&&(this.cone.material.dispose(),this.cone.geometry.dispose())}},e.Axes=H,e.Grid=class extends r.Object3D{constructor(e){var t=(e=e||{}).num_cells||10,i=e.color||"#cccccc",s=e.lineWidth||1,o=e.cellSize||1;super();for(var n=new r.LineBasicMaterial({color:i,linewidth:s}),a=0;a<=t;++a){var c=o*t/2,h=c-a*o,l=new r.Geometry;l.vertices.push(new r.Vector3(-c,h,0),new r.Vector3(c,h,0));var d=new r.Geometry;d.vertices.push(new r.Vector3(h,-c,0),new r.Vector3(h,c,0)),this.add(new r.Line(l,n)),this.add(new r.Line(d,n))}}},e.MeshResource=V,e.TriangleList=I,e.OccupancyGrid=W,e.OccupancyGridClient=class extends s{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/map",this.compression=e.compression||"cbor",this.continuous=e.continuous,this.tfClient=e.tfClient,this.rootObject=e.rootObject||new r.Object3D,this.offsetPose=e.offsetPose||new i.Pose,this.color=e.color||{r:255,g:255,b:255},this.opacity=e.opacity||1,this.currentGrid=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,messageType:"nav_msgs/OccupancyGrid",queue_length:1,compression:this.compression}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){this.currentGrid&&(this.currentGrid.tfClient&&this.currentGrid.unsubscribeTf(),this.rootObject.remove(this.currentGrid));var t=new W({message:e,color:this.color,opacity:this.opacity});this.tfClient?(this.currentGrid=t,this.sceneNode=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:t,pose:this.offsetPose})):this.sceneNode=this.currentGrid=t,this.rootObject.add(this.sceneNode),this.emit("change"),this.continuous||this.rosTopic.unsubscribe()}},e.Odometry=class extends r.Object3D{constructor(e){super(),this.options=e||{},this.ros=e.ros,this.topicName=e.topic||"/particlecloud",this.tfClient=e.tfClient,this.color=e.color||13369599,this.length=e.length||1,this.rootObject=e.rootObject||new r.Object3D,this.keep=e.keep||1,this.sns=[],this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,queue_length:1,messageType:"nav_msgs/Odometry"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){this.sns.length>=this.keep&&(this.sns[0].unsubscribeTf(),this.rootObject.remove(this.sns[0]),this.sns.shift()),this.options.origin=new r.Vector3(e.pose.pose.position.x,e.pose.pose.position.y,e.pose.pose.position.z);var t=new r.Quaternion(e.pose.pose.orientation.x,e.pose.pose.orientation.y,e.pose.pose.orientation.z,e.pose.pose.orientation.w);this.options.direction=new r.Vector3(1,0,0),this.options.direction.applyQuaternion(t),this.options.material=new r.MeshBasicMaterial({color:this.color});var i=new L(this.options);this.sns.push(new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:i})),this.rootObject.add(this.sns[this.sns.length-1])}},e.Path=class extends r.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/path",this.tfClient=e.tfClient,this.color=e.color||13369599,this.rootObject=e.rootObject||new r.Object3D,this.sn=null,this.line=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,queue_length:1,messageType:"nav_msgs/Path"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn));for(var t=new r.Geometry,i=0;i<e.poses.length;i++){var s=new r.Vector3(e.poses[i].pose.position.x,e.poses[i].pose.position.y,e.poses[i].pose.position.z);t.vertices.push(s)}t.computeLineDistances();var o=new r.LineBasicMaterial({color:this.color}),n=new r.Line(t,o);this.sn=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:n}),this.rootObject.add(this.sn)}},e.Point=class extends r.Object3D{constructor(e){super(),this.options=e||{},this.ros=e.ros,this.topicName=e.topic||"/point",this.tfClient=e.tfClient,this.color=e.color||13369599,this.rootObject=e.rootObject||new r.Object3D,this.radius=e.radius||.2,this.sn=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,queue_length:1,messageType:"geometry_msgs/PointStamped"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn));var t=new r.SphereGeometry(this.radius),i=new r.MeshBasicMaterial({color:this.color}),s=new r.Mesh(t,i);s.position.set(e.point.x,e.point.y,e.point.z),this.sn=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:s}),this.rootObject.add(this.sn)}},e.Polygon=class extends r.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/path",this.tfClient=e.tfClient,this.color=e.color||13369599,this.rootObject=e.rootObject||new r.Object3D,this.sn=null,this.line=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,queue_length:1,messageType:"geometry_msgs/PolygonStamped"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn));for(var t,i=new r.Geometry,s=0;s<e.polygon.points.length;s++)t=new r.Vector3(e.polygon.points[s].x,e.polygon.points[s].y,e.polygon.points[s].z),i.vertices.push(t);t=new r.Vector3(e.polygon.points[0].x,e.polygon.points[0].y,e.polygon.points[0].z),i.vertices.push(t),i.computeLineDistances();var o=new r.LineBasicMaterial({color:this.color}),n=new r.Line(i,o);this.sn=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:n}),this.rootObject.add(this.sn)}},e.Pose=class extends r.Object3D{constructor(e){super(),this.options=e||{},this.ros=e.ros,this.topicName=e.topic||"/pose",this.tfClient=e.tfClient,this.color=e.color||13369599,this.rootObject=e.rootObject||new r.Object3D,this.sn=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,queue_length:1,messageType:"geometry_msgs/PoseStamped"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn)),this.options.origin=new r.Vector3(e.pose.position.x,e.pose.position.y,e.pose.position.z);var t=new r.Quaternion(e.pose.orientation.x,e.pose.orientation.y,e.pose.orientation.z,e.pose.orientation.w);this.options.direction=new r.Vector3(1,0,0),this.options.direction.applyQuaternion(t),this.options.material=new r.MeshBasicMaterial({color:this.color});var i=new L(this.options);this.sn=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:i}),this.rootObject.add(this.sn)}},e.PoseArray=class extends r.Object3D{constructor(e){super(),this.options=e||{},this.ros=e.ros,this.topicName=e.topic||"/particlecloud",this.tfClient=e.tfClient,this.color=e.color||13369599,this.length=e.length||1,this.rootObject=e.rootObject||new r.Object3D,this.sn=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,queue_length:1,messageType:"geometry_msgs/PoseArray"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn));for(var t,i=new r.Object3D,s=0;s<e.poses.length;s++){var o=new r.Geometry,n=new r.Vector3(e.poses[s].position.x,e.poses[s].position.y,e.poses[s].position.z);o.vertices.push(n);var a=new r.Quaternion(e.poses[s].orientation.x,e.poses[s].orientation.y,e.poses[s].orientation.z,e.poses[s].orientation.w),c=new r.Vector3(this.length,0,0),h=new r.Vector3(.8*this.length,.2*this.length,0),l=new r.Vector3(.8*this.length,.2*-this.length,0);c.applyQuaternion(a),h.applyQuaternion(a),l.applyQuaternion(a),o.vertices.push(c.add(n)),o.vertices.push(h.add(n)),o.vertices.push(l.add(n)),o.vertices.push(c),o.computeLineDistances();var d=new r.LineBasicMaterial({color:this.color});t=new r.Line(o,d),i.add(t)}this.sn=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:i}),this.rootObject.add(this.sn)}},e.PoseWithCovariance=class extends r.Object3D{constructor(e){super(),this.options=e||{},this.ros=e.ros,this.topicName=e.topic||"/PoseWithCovariance",this.tfClient=e.tfClient,this.color=e.color||13369599,this.rootObject=e.rootObject||new r.Object3D,this.sn=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,queue_length:1,messageType:"geometry_msgs/PoseWithCovarianceStamped"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn)),this.options.origin=new r.Vector3(e.pose.pose.position.x,e.pose.pose.position.y,e.pose.pose.position.z);var t=new r.Quaternion(e.pose.pose.orientation.x,e.pose.pose.orientation.y,e.pose.pose.orientation.z,e.pose.pose.orientation.w);this.options.direction=new r.Vector3(1,0,0),this.options.direction.applyQuaternion(t),this.options.material=new r.MeshBasicMaterial({color:this.color});var i=new L(this.options);this.sn=new G({frameID:e.header.frame_id,tfClient:this.tfClient,object:i}),this.rootObject.add(this.sn)}},e.LaserScan=class extends r.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/scan",this.compression=e.compression||"cbor",this.points=new K(e),this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,compression:this.compression,queue_length:1,messageType:"sensor_msgs/LaserScan"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){if(this.points.setup(e.header.frame_id)){for(var t=e.ranges.length,i=0,s=0;s<t;s+=this.points.pointRatio){var r=e.ranges[s];if(r>=e.range_min&&r<=e.range_max){var o=e.angle_min+s*e.angle_increment;this.points.positions.array[i++]=r*Math.cos(o),this.points.positions.array[i++]=r*Math.sin(o),this.points.positions.array[i++]=0}}this.points.update(i/3)}}},e.Points=K,e.PointCloud2=class extends r.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/points",this.compression=e.compression||"cbor",this.max_pts=e.max_pts||1e4,this.points=new K(e),this.rosTopic=void 0,this.buffer=null,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new i.Topic({ros:this.ros,name:this.topicName,messageType:"sensor_msgs/PointCloud2",queue_length:1,compression:this.compression}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){if(this.points.setup(e.header.frame_id,e.point_step,e.fields)){var t,i=this.points.pointRatio,s=this.max_pts*e.point_step;e.data.buffer?(this.buffer=e.data.slice(0,Math.min(e.data.byteLength,s)),t=Math.min(e.height*e.width/i,this.points.positions.array.length/3)):((!this.buffer||this.buffer.byteLength<s)&&(this.buffer=new Uint8Array(s)),t=Q(e.data,this.buffer,e.point_step,i),i=1);for(var r,o,n=new DataView(this.buffer.buffer),a=!e.is_bigendian,c=this.points.fields.x.offset,h=this.points.fields.y.offset,l=this.points.fields.z.offset,d=0;d<t;d++)r=d*i*e.point_step,this.points.positions.array[3*d]=n.getFloat32(r+c,a),this.points.positions.array[3*d+1]=n.getFloat32(r+h,a),this.points.positions.array[3*d+2]=n.getFloat32(r+l,a),this.points.colors&&(o=this.points.colormap(this.points.getColor(n,r,a)),this.points.colors.array[3*d]=o.r,this.points.colors.array[3*d+1]=o.g,this.points.colors.array[3*d+2]=o.b);this.points.update(t)}}},e.TFAxes=class extends r.Object3D{constructor(e){super(),e=e||{},this.frame_id=e.frame_id,this.tfClient=e.tfClient,this.rootObject=e.rootObject||new r.Object3D,this.axes=new H({shaftRadius:e.shaftRadius||.025,headRadius:e.headRaidus||.07,headLength:e.headLength||.2,scale:e.scale||1,lineType:e.lineType||"full",lineDashLength:e.lineDashLength||.1}),this.sn=new G({frameID:this.frame_id,tfClient:this.tfClient,object:this.axes}),this.rootObject.add(this.sn)}},e.Urdf=Z,e.UrdfClient=class{constructor(e){var t=this,s=(e=e||{}).ros;this.param=e.param||"robot_description",this.path=e.path||"/",this.tfClient=e.tfClient,this.rootObject=e.rootObject||new r.Object3D,this.tfPrefix=e.tfPrefix||"",this.loader=e.loader,new i.Param({ros:s,name:this.param}).get(function(e){var s=new i.UrdfModel({string:e});t.urdf=new Z({urdfModel:s,path:t.path,tfClient:t.tfClient,tfPrefix:t.tfPrefix,loader:t.loader}),t.rootObject.add(t.urdf)})}},e.Highlighter=Y,e.MouseHandler=J,e.OrbitControls=$,e.SceneNode=G,e.Viewer=class{constructor(e){var t=(e=e||{}).divID,i=e.width,s=e.height,o=e.background||"#111111",n=e.antialias,a=e.intensity||.66,c=e.near||.01,h=e.far||1e3,l=e.alpha||1,d=e.cameraPose||{x:3,y:3,z:3},u=e.cameraZoomSpeed||.5,p=void 0===e.displayPanAndZoomFrame||!!e.displayPanAndZoomFrame,m=e.lineTypePanAndZoomFrame||"full";this.renderer=new r.WebGLRenderer({antialias:n,alpha:!0}),this.renderer.setClearColor(parseInt(o.replace("#","0x"),16),l),this.renderer.sortObjects=!1,this.renderer.setSize(i,s),this.renderer.shadowMap.enabled=!1,this.renderer.autoClear=!1,this.scene=new r.Scene,this.camera=new r.PerspectiveCamera(40,i/s,c,h),this.camera.position.x=d.x,this.camera.position.y=d.y,this.camera.position.z=d.z,this.cameraControls=new $({scene:this.scene,camera:this.camera,displayPanAndZoomFrame:p,lineTypePanAndZoomFrame:m}),this.cameraControls.userZoomSpeed=u,this.scene.add(new r.AmbientLight(5592405)),this.directionalLight=new r.DirectionalLight(16777215,a),this.scene.add(this.directionalLight),this.selectableObjects=new r.Object3D,this.scene.add(this.selectableObjects);var f=new J({renderer:this.renderer,camera:this.camera,rootObject:this.selectableObjects,fallbackTarget:this.cameraControls});this.highlighter=new Y({mouseHandler:f}),this.stopped=!0,this.animationRequestId=void 0,document.getElementById(t).appendChild(this.renderer.domElement),this.start()}start(){this.stopped=!1,this.draw()}draw(){this.stopped||(this.cameraControls.update(),this.directionalLight.position.normalize(),this.renderer.clear(!0,!0,!0),this.renderer.render(this.scene,this.camera),this.highlighter.renderHighlights(this.scene,this.renderer,this.camera),this.animationRequestId=requestAnimationFrame(this.draw.bind(this)))}stop(){this.stopped||cancelAnimationFrame(this.animationRequestId),this.stopped=!0}addObject(e,t){t?this.selectableObjects.add(e):this.scene.add(e)}resize(e,t){this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t)}},e}({},THREE,ROSLIB,EVENTEMITTER);