Files
apt-nl-map/static/Magic4/ros2djs/ros2d.min.js

9 lines
32 KiB
JavaScript
Raw Normal View History

2024-12-03 16:40:54 +08:00
var ROS2D=function(e,t,i){"use strict";function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var n=s(t),r=s(i);n.Stage.prototype.globalToRos=function(e,t){var i=(e-this.x)/this.scaleX,s=(this.y-t)/this.scaleY;return new r.Vector3({x:i,y:s})},n.Stage.prototype.rosToGlobal=function(e){return{x:e.x*this.scaleX+this.x,y:e.y*this.scaleY+this.y}},n.Stage.prototype.rosQuaternionToGlobalTheta=function(e){var t=e.w,i=e.x,s=e.y,n=e.z;return 180*-Math.atan2(2*(t*n+i*s),1-2*(s*s+n*n))/Math.PI};class o extends n.Bitmap{constructor(e){var t=(e=e||{}).message;super(e.image),this.pose=new r.Pose({position:t.origin.position,orientation:t.origin.orientation}),this.width=t.width,this.height=t.height,this.y=-this.height*t.resolution,this.scaleX=t.resolution,this.scaleY=t.resolution,this.width*=this.scaleX,this.height*=this.scaleY,this.x+=this.pose.position.x,this.y-=this.pose.position.y}}function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h,l={exports:{}};
/*!
* EventEmitter2
* https://github.com/hij1nx/EventEmitter2
*
* Copyright (c) 2013 hij1nx
* Licensed under the MIT license.
*/h=l,function(e){var t=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},s="object"==typeof process&&"function"==typeof process.nextTick,n="function"==typeof Symbol,r="object"==typeof Reflect,o="function"==typeof setImmediate?setImmediate:setTimeout,a=n?r&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function l(){this._events={},this._conf&&c.call(this,this._conf)}function c(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function p(e,t){var i="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(i+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var s=new Error(i);s.name="MaxListenersExceededWarning",s.emitter=this,s.count=e,process.emitWarning(s)}else console.error(i),console.trace&&console.trace()}var u=function(e,t,i){var s=arguments.length;switch(s){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,i];default:for(var n=new Array(s);s--;)n[s]=arguments[s];return n}};function f(t,i){for(var s={},n=t.length,r=i?value.length:0,o=0;o<n;o++)s[t[o]]=o<r?i[o]:e;return s}function d(e,t,i){var s,n;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(i.on||i.off)&&(s=i.on,n=i.off),t.addEventListener?(s=t.addEventListener,n=t.removeEventListener):t.addListener?(s=t.addListener,n=t.removeListener):t.on&&(s=t.on,n=t.off),!s&&!n)throw Error("target does not implement any known event API");if("function"!=typeof s)throw TypeError("on method must be a function");if("function"!=typeof n)throw TypeError("off method must be a function");this._on=s,this._off=n;var r=e._observers;r?r.push(this):e._observers=[this]}function v(i,s,n,r){var o=Object.assign({},s);if(!i)return o;if("object"!=typeof i)throw TypeError("options must be an object");var a,h,l,c=Object.keys(i),p=c.length;function u(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<p;f++){if(a=c[f],!r&&!t.call(s,a))throw Error('Unknown "'+a+'" option');(h=i[a])!==e&&(l=n[a],o[a]=l?l(h,u):h)}return o}function g(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),i=e.length,s=e[0],n=e[1];return 1===i?function(e,i){if(typeof e===s)return e;i(t)}:2===i?function(e,i){var r=typeof e;if(r===s||r===n)return e;i(t)}:function(s,n){for(var r=typeof s,o=i;o-- >0;)if(r===e[o])return s;n(t)}}Object.assign(d.prototype,{subscribe:function(e,t,i){var s=this,n=this._target,r=this._emitter,o=this._listeners,a=function(){var s=u.apply(null,arguments),o={data:s,name:t,original:e};if(i){var a=i.call(n,o);!1!==a&&r.emit.apply(r,[o.name].concat(s))}else r.emit.apply(r,[t].concat(s))};if(o[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,r._newListener&&r._removeListener&&!s._onNewListener?(this._onNewListener=function(i){i===t&&null===o[e]&&(o[e]=a,s._on.call(n,e,a))},r.on("newListener",this._onNewListener),this._onRemoveListener=function(i){i===t&&!r.hasListeners(i)&&o[e]&&(o[e]=null,s._off.call(n,e,a))},o[e]=null,r.on("removeListener",this._onRemoveListener)):(o[e]=a,s._on.call(n,e,a))},unsubscribe:function(e){var t,i,s,n=this,r=this._listeners,o=this._emitter,h=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function c(){n._onNewListener&&(o.off("newListener",n._onNewListener),o.off("removeListener",n._onRemoveListener),n._onNewListener=null,n._onRemoveListener=n