UNPKG

mapv-cloudrenderengine

Version:

CloudRenderEngine 是百度地图开放平台推出的 UE5 像素流三维数字孪生前端 SDK。 它通过 WebRTC 将 Unreal Engine 5 场景实时推流到浏览器,并提供统一 JavaScript API 完成场景渲染、交互控制、对象管理和行业可视化能力接入。

1 lines 330 kB
import{Vector2 as e,Vector3 as t,Quaternion as i,Matrix4 as n,MathUtils as a,Euler as r,Matrix3 as o,Layers as s,FileLoader as l,Color as u,Group as c,MeshBasicMaterial as d,PlaneBufferGeometry as h,Mesh as f,SpriteMaterial as p,Sprite as m}from"three";import g from"earcut";import*as v from"@tweenjs/tween.js";import y from"axios";import b from"@mars3d/heatmap.js";function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function S(e,t,i,n,a,r,o){try{var s=e[r](o),l=s.value}catch(e){return void i(e)}s.done?t(l):Promise.resolve(l).then(n,a)}function w(e){return function(){var t=this,i=arguments;return new Promise((function(n,a){var r=e.apply(t,i);function o(e){S(r,n,a,o,s,"next",e)}function s(e){S(r,n,a,o,s,"throw",e)}o(void 0)}))}}function N(e,t,i){return t=E(t),D(e,A()?Reflect.construct(t,i||[],E(e).constructor):t.apply(e,i))}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function U(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,H(n.key),n)}}function C(e,t,i){return t&&U(e.prototype,t),i&&U(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=V(e))||t){i&&(e=i);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return o=e.done,e},e:function(e){s=!0,r=e},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw r}}}}function R(e,t,i){return(t=H(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function O(){return O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=E(e)););return e}(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(arguments.length<3?e:i):a.value}},O.apply(null,arguments)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function z(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P(e,t)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(A=function(){return!!e})()}function M(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function I(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?M(Object(i),!0).forEach((function(t){R(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):M(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function _(e,t){if(null==e)return{};var i,n,a=function(e,t){if(null==e)return{};var i={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;i[n]=e[n]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)i=r[n],t.includes(i)||{}.propertyIsEnumerable.call(e,i)&&(a[i]=e[i])}return a}function D(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function L(){L=function(){return t};var e,t={},i=Object.prototype,n=i.hasOwnProperty,a=Object.defineProperty||function(e,t,i){e[t]=i.value},r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",l=r.toStringTag||"@@toStringTag";function u(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,i){return e[t]=i}}function c(e,t,i,n){var r=t&&t.prototype instanceof v?t:v,o=Object.create(r.prototype),s=new E(n||[]);return a(o,"_invoke",{value:C(e,i,s)}),o}function d(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",f="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var x={};u(x,o,(function(){return this}));var S=Object.getPrototypeOf,w=S&&S(S(z([])));w&&w!==i&&n.call(w,o)&&(x=w);var N=b.prototype=v.prototype=Object.create(x);function k(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function U(e,t){function i(a,r,o,s){var l=d(e[a],e,r);if("throw"!==l.type){var u=l.arg,c=u.value;return c&&"object"==typeof c&&n.call(c,"__await")?t.resolve(c.__await).then((function(e){i("next",e,o,s)}),(function(e){i("throw",e,o,s)})):t.resolve(c).then((function(e){u.value=e,o(u)}),(function(e){return i("throw",e,o,s)}))}s(l.arg)}var r;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){i(e,n,t,a)}))}return r=r?r.then(a,a):a()}})}function C(t,i,n){var a=h;return function(r,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===r)throw o;return{value:e,done:!0}}for(n.method=r,n.arg=o;;){var s=n.delegate;if(s){var l=T(s,n);if(l){if(l===g)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=d(t,i,n);if("normal"===u.type){if(a=n.done?m:f,u.arg===g)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function T(t,i){var n=i.method,a=t.iterator[n];if(a===e)return i.delegate=null,"throw"===n&&t.iterator.return&&(i.method="return",i.arg=e,T(t,i),"throw"===i.method)||"return"!==n&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var r=d(a,t.iterator,i.arg);if("throw"===r.type)return i.method="throw",i.arg=r.arg,i.delegate=null,g;var o=r.arg;return o?o.done?(i[t.resultName]=o.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=e),i.delegate=null,g):o:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,g)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function z(t){if(t||""===t){var i=t[o];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,r=function i(){for(;++a<t.length;)if(n.call(t,a))return i.value=t[a],i.done=!1,i;return i.value=e,i.done=!0,i};return r.next=r}}throw new TypeError(typeof t+" is not iterable")}return y.prototype=b,a(N,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:y,configurable:!0}),y.displayName=u(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,l,"GeneratorFunction")),e.prototype=Object.create(N),e},t.awrap=function(e){return{__await:e}},k(U.prototype),u(U.prototype,s,(function(){return this})),t.AsyncIterator=U,t.async=function(e,i,n,a,r){void 0===r&&(r=Promise);var o=new U(c(e,i,n,a),r);return t.isGeneratorFunction(i)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},k(N),u(N,l,"Generator"),u(N,o,(function(){return this})),u(N,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),i=[];for(var n in t)i.push(n);return i.reverse(),function e(){for(;i.length;){var n=i.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=z,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var i=this;function a(n,a){return s.type="throw",s.arg=t,i.next=n,a&&(i.method="next",i.arg=e),!!a}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var l=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(l&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var r=a;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),O(i),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var n=i.completion;if("throw"===n.type){var a=n.arg;O(i)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,i,n){return this.delegate={iterator:z(t),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function P(e,t){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},P(e,t)}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,a,r,o,s=[],l=!0,u=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(n=r.call(i)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(e,t)||V(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t,i,n){var a=O(E(e.prototype),t,i);return"function"==typeof a?function(e){return a.apply(i,e)}:a}function W(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||V(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function G(e){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G(e)}function V(e,t){if(e){if("string"==typeof e)return x(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?x(e,t):void 0}}var J={CLEAR_SKIES:"clearSkies",PARTLY_CLOUDY:"partlyCloudy",CLOUDY:"cloudy",FOGGY:"foggy",OVERCAST:"overcast",RAIN:"rain",LIGHT_RAIN:"lightRain",THUNDER_STORM:"thunderstorm",SNOW:"snow",LIGHT_SNOW:"lightSnow",BLIZZARD:"blizzard",SAND_DUST_CALM:"sandDustCalm",SAND_DUST_STORM:"sandDustStorm"},q={VOLUMETRIC_CLOUDS:"Volumetric Clouds",STATIC_CLOUDS:"Static Clouds",DYNAMIC_CLOUDS:"2D Dynamic Clouds",NO_CLOUDS:"No Clouds",VOLUMETRIC_AURORA:"Volumetric Aurora"},Y={SKY_ATMOSPHERE:"Sky Atmosphere",SIMPLIFIED_COLOR:"Simplified Color"},K={SET_MOUSE_CURSOR_SHOW:"setMouseCursorShow",SET_CLICK_EVENT:"setClickEvent",SET_EDIT_STATUS:"setEditStatus",SWITCH_EDIT_MODE:"switchEditMode",SAVE_EDIT_RESULT:"saveEditResult",ZOOM_IN:"zoomIn",ZOOM_OUT:"zoomOut",EXIT:"exitClient",ENABLE_TERRAIN:"enableTerrain",ENABLE_POI:"enablePOIByTag",PRELOAD_LOCATION:"preLoadLocation",FOCUS_ACTOR_BY_ID:"focusActorByID",ENABLE_DATALAYER:"Scene_enableDataLayerByName",ENABLE_FPS:"Scene_setFPS",OBJECT_BOUNDINGBOX:"Interact_objectBoundingBox",ASSET_MODEL:"Gis_generateAssetModel",BUILD_GROWTHANIMATE:"Interact_buildGrowth",ENABLE_L2_BUILDING_SELECT:"Interact_enableBuildingL2Select"},X={NAVIGATION:"Camera_navigation",NAVIGATION_PAUSE:"Camera_navigationPause",NAVIGATION_STOP:"Camera_navigationStop",MOVE_TO:"Camera_moveTo",ZOOM_IN:"Camera_zoomIn",ZOOM_OUT:"Camera_zoomOut",PROJECT:"Camera_project",UNPROJECT:"Camera_unproject",UPDATE:"Camera_update",FOCUS_ON:"Camera_focusOn",Constrain_Shape:"Camera_constrainShape",MOVE:"Camera_move",ROTATE:"Camera_rotate",RESET_CAMERA_FOCUS:"Camera_resetCameraFocus"},Q={ENABLE_3DTILES_BY_NAME:"Scene_enableTilesByName",SWITCH_TERRAIN_MODE:"Scene_switchTerrainMode",HIDDEN_3DTILES_ITEM:"Scene_hiddenTilesItem",EVENT_LAYER_BUILDING:"Scene_eventLayerBuilding",UPDATA_SLOPE_ANALYSIS:"Scene_updateSlopeAnalysis",GET_ALTITUDE:"Scene_getAltitude",SET_PLANE_POI_MODE:"Scene_setPlanePoiMode"},Z={EXIT_CLIENT:"Application_exitClient",RESTART_LEVEL:"Application_restartLevel",OPEN_LEVEL:"Application_openLevel",RESTART_GAME:"Application_restartGame",CREATE_TRAFFIC_STREAM:"Application_createTrafficStream",CLOSE_TRAFFIC_STREAM:"Application_closeTrafficStream",FOLLOW_TRAFFIC_STREAM_ITEM:"Application_followTrafficStreamItem",ADD_EVENT_LISTENER:"Application_addEvent",REMOVE_EVENT_LISTENER:"Application_removeEvent",RESET_WORLD_CENTER:"Application_resetWorldCenter",CONSOLE_COMMAND:"Application_ConsoleCommand"},ee={ADD:"Gis_AddCommonGISLayer",REMOVE:"Gis_RemoveCommonGISLayer",DESTORY:"Gis_DestoryCommonGISLayer",DESTORY_ALL:"Gis_DestoryAllGenerationLayer",UPDATE:"Gis_UpdateCommonGISLayer",VISIBLE:"Gis_VisibleCommonGISLayer"},te={ENABLE_DRAW:"Gis_enableDraw",CLOSE_DRAW:"Gis_closeDraw",ENABLE_MEASURE:"Gis_enableMeasure",CLOSE_MEASURE:"Gis_closeMeasure",DESTORY_DRAW:"Gis_clearDraw",DESTORY_MEASURE:"Gis_clearMeasure"},ie={SOLID:"solid",DASHED:"dashed",ARROW:"arrow",GRADIENT:"gradient"},ne=R({CENTER:"Ground_Center",STAND:"Stand",SIDE:"Ground_Side"},"SIDE","Cylinder"),ae={LINEAR:"Linear",CURVE:"Curve",CONSTANT:"Constant"},re={QualityControlOwnership:0,Response:1,Command:2,FreezeFrame:3,UnfreezeFrame:4,VideoEncoderAvgQP:5,LatencyTest:6,InitialSettings:7,FileExtension:8,FileMimeType:9,FileContents:10,Mouse:21,Keyboard:22,InputControlOwnership:12,Protocol:255,AckV2:102,TextureMissingNack:103},oe={LockedMouse:0,HoveringMouse:1},se={controlScheme:oe.HoveringMouse,suppressBrowserKeys:!1,fakeMouseWithTouches:!1},le={IFrameRequest:0,RequestQualityControl:1,FpsRequest:2,AverageBitrateRequest:3,StartStreaming:4,StopStreaming:5,LatencyTest:6,RequestInitialSettings:7,UIInteraction:50,Command:51,KeyDown:60,KeyUp:61,KeyPress:62,MouseEnter:70,MouseLeave:71,MouseDown:72,MouseUp:73,MouseMove:74,MouseWheel:75,TouchStart:80,TouchEnd:81,TouchMove:82,GamepadButtonPressed:90,GamepadButtonReleased:91,GamepadAnalog:92,UIInteractionV2:100,BinaryAsset:101,AckV2:102,TextureMissingNack:103},ce={MainButton:0,AuxiliaryButton:1,SecondaryButton:2,FourthButton:3,FifthButton:4},de={PrimaryButton:1,SecondaryButton:2,AuxiliaryButton:4,FourthButton:8,FifthButton:16},he={BackSpace:8,Shift:16,Control:17,Alt:18,RightShift:253,RightControl:254,RightAlt:255},fe={FIRE_BIG:"P_Fire_Big",FIRE_SMALL:"P_Fire_Small",FIRE_FLAMETHROWER:"P_Flamethrower",SMOKE_SMALL_BLACK:"P_Smoke_A",SMOKE_BIG_BLACK:"P_Smoke_B",SMOKE_SMALL_YELLOW:"P_Smoke_C",SMOKE_BIG_YELLOW:"P_Smoke_D",SPARK_A:"P_Sparks_E",FOG_MASS:"P_Mass_Fog",NS_Spark:"NS_Spark",NS_Firefly:"NS_Firefly"},pe=Object.freeze({__proto__:null,ApplicationControl:Z,CameraControl:X,ControlSchemeType:oe,DrawAndMeasureControl:te,GisControl:ee,InteractMOD:K,LineDirectionOptions:ne,LineSplineTypeOptions:ae,LineTypeOptions:ie,MessageType:le,MouseButton:ce,MouseButtonsMask:de,ParticleKind:fe,SceneControl:Q,SkyColorMode:Y,SkyMode:q,SpecialKeyCodes:he,ToClientMessageType:re,UDS:J,WS_OPEN_STATE:1,inputOptions:se}),me=function(){return C((function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k(this,e),this.cloudRender=t,this.weather=i.weather||J.PARTLY_CLOUDY,this.hour=i.hour||14,this.minute=i.minute||30,this.weatherType=J,this.init()}),[{key:"changeWeather",value:function(e){e&&(Object.values(J).indexOf(e)<0||(this.weather=e,this.cloudRender.emitUIInteraction({excuteName:"Scene_changeWeather",params:{WeatherType:e}})))}},{key:"changeTime",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;this.hour=e,this.minute=Math.floor(10*t/6);var i=(this.hour<10?"0"+this.hour:""+this.hour)+(this.minute<10?"0"+this.minute:""+this.minute);this.cloudRender.emitUIInteraction({excuteName:"Scene_changeTime",params:{Time:i}})}},{key:"setVolumeFog",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,i=Math.max(Math.min(1e5,t),10);this.cloudRender.emitUIInteraction({excuteName:"Scene_setVolumenFog",params:{Enable:e,Distance:100*i}})}},{key:"setAtmosphericFog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.0075,t=Math.max(Math.min(1,e),0);this.cloudRender.emitUIInteraction({excuteName:"Scene_setBaseFog",params:{BaseFogDensity:t}})}},{key:"setSkyMode",value:function(e){return!!e&&(!(Object.values(q).indexOf(e)<0)&&void this.cloudRender.emitUIInteraction({excuteName:"Scene_setSkyMode",params:{SkyMode:e}}))}},{key:"setSkyColorMode",value:function(e){return!!e&&(!(Object.values(Y).indexOf(e)<0)&&void this.cloudRender.emitUIInteraction({excuteName:"Scene_setSkyColorMode",params:{SkyColorMode:e}}))}},{key:"changeWeatherEffectParameters",value:function(e){this.cloudRender.emitUIInteraction({excuteName:"Scene_changeWeatherEffects",params:JSON.stringify(e)})}},{key:"init",value:function(){this.changeWeather(this.weather),this.changeTime(this.hour,this.minute)}}])}(),ge=["BMap","Sentinel2","NaturalEarth"],ve=function(){return C((function e(t){k(this,e),this.cloudRender=t,this.earthCloud={VisMode:"Auto"},this.earthRoadNetwork={VisMode:"Auto",Opacity:.2,Color:"rgb(255, 255, 255)",Brightness:6},this.earthTiles={TilesType:"BMap"}}),[{key:"_changeEnvironment",value:function(e,t,i){t?(this[i]=I(I({},this[i]),t),this.cloudRender&&this.cloudRender.emitUIInteraction({excuteName:"Scene_SeqEnvironment",params:{environment:e,properties:I({},this[i])}})):console.warn("".concat(e," params is required"))}},{key:"changeEarthCloud",value:function(e){this._changeEnvironment("EarthCloud",e,"earthCloud")}},{key:"changeEarthRoadNetwork",value:function(e){this._changeEnvironment("EarthRoadNetwork",e,"earthRoadNetwork")}},{key:"changeEarthTiles",value:function(e){e&&e.TilesType&&!ge.includes(e.TilesType)?console.warn("TilesType ".concat(e.TilesType," is not supported")):this._changeEnvironment("EarthTiles",e,"earthTiles")}}])}(),ye=function(e){e=void 0!==e?e:{},this.forceTURN=e.forceTURN;var t=this,i=new URLSearchParams(window.location.search);this.cfg=void 0!==e.peerConnectionOptions?e.peerConnectionOptions:{},this.cfg.sdpSemantics="unified-plan",this.cfg.offerExtmapAllowMixed=!1,i.has("ForceTURN")&&(this.forceTURN=i.has("ForceTURN")),this.forceTURN&&(console.log("Forcing TURN usage by setting ICE Transport Policy in peer connection config."),this.cfg.iceTransportPolicy="relay"),this.cfg.bundlePolicy="balanced",this.forceMaxBundle=i.has("ForceMaxBundle"),this.forceMaxBundle&&(this.cfg.bundlePolicy="max-bundle"),this.pcClient=null,this.dcClient=null,this.dcBulk=null,this.dcTexture=null,this.tnClient=null,this.enableBulkChannel=!0===e.enableBulkChannel,this.enableTextureChannel=!0===e.enableTextureChannel,this.sdpConstraints={offerToReceiveAudio:1,offerToReceiveVideo:1,voiceActivityDetection:!1},this.dataChannelOptions={ordered:!0,maxPacketLifeTime:3e3},this.bulkDataChannelOptions={ordered:!0},this.textureDataChannelOptions={ordered:!0},this.startVideoMuted=void 0!==e.startVideoMuted&&e.startVideoMuted,this.autoPlayAudio=void 0===e.autoPlayAudio||e.autoPlayAudio,this.useMic=i.has("useMic"),this.useMic||console.log("Microphone access is not enabled. Pass ?useMic in the url to enable it.");var n="localhost"===location.hostname||"127.0.0.1"===location.hostname,a="https:"===location.protocol;!this.useMic||n||a||(this.useMic=!1,console.error("Microphone access in the browser will not work if you are not on HTTPS or localhost. Disabling mic access."),console.error("For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'")),this.preferSFU=i.has("preferSFU"),console.log(this.preferSFU?"The browser will signal it would prefer an SFU connection. Remove ?preferSFU from the url to signal for P2P usage.":"The browser will signal for a P2P connection. Pass ?preferSFU in the url to signal for SFU usage."),this.latencyTestTimings={TestStartTimeMs:null,UEReceiptTimeMs:null,UEEncodeMs:null,UECaptureToSendMs:null,UETransmissionTimeMs:null,BrowserReceiptTimeMs:null,FrameDisplayDeltaTimeMs:null,Reset:function(){this.TestStartTimeMs=null,this.UEReceiptTimeMs=null,this.UEEncodeMs=null,this.UECaptureToSendMs=null,this.UETransmissionTimeMs=null,this.BrowserReceiptTimeMs=null,this.FrameDisplayDeltaTimeMs=null},SetUETimings:function(e){this.UEReceiptTimeMs=e.ReceiptTimeMs,this.UEEncodeMs=e.EncodeMs,this.UECaptureToSendMs=e.CaptureToSendMs,this.UETransmissionTimeMs=e.TransmissionTimeMs,this.BrowserReceiptTimeMs=Date.now(),this.OnAllLatencyTimingsReady(this)},SetFrameDisplayDeltaTime:function(e){null==this.FrameDisplayDeltaTimeMs&&(this.FrameDisplayDeltaTimeMs=Math.round(e),this.OnAllLatencyTimingsReady(this))},OnAllLatencyTimingsReady:function(e){}},this.createWebRtcVideo=function(){var e=document.createElement("video");if(e.id="streamingVideo",e.playsInline=!0,e.disablepictureinpicture=!0,e.muted=t.startVideoMuted,e.addEventListener("loadedmetadata",(function(e){t.onVideoInitialised&&t.onVideoInitialised()}),!0),"requestVideoFrameCallback"in HTMLVideoElement.prototype){var i=function(n,a){if(a.receiveTime&&a.expectedDisplayTime){var r=a.presentationTime-a.receiveTime;t.aggregatedStats||(t.aggregatedStats={}),t.aggregatedStats.receiveToCompositeMs=r}e.requestVideoFrameCallback(i)};e.requestVideoFrameCallback(i)}return e},this.video=this.createWebRtcVideo(),this.availableVideoStreams=new Map;var r=function(e){console.info("Signaling state change. |",e.srcElement.signalingState,"|")},o=function(e){console.info("Browser ICE connection |",e.srcElement.iceConnectionState,"|")},s=function(e){console.info("Browser ICE gathering |",e.srcElement.iceGatheringState,"|")},l=function(e){if(e.track&&console.log("Got track. | Kind="+e.track.kind+" | Id="+e.track.id+" | readyState="+e.track.readyState+" |"),"audio"!=e.track.kind){e.track.kind;var i,n=T(e.streams);try{for(n.s();!(i=n.n()).done;){var a=i.value;t.availableVideoStreams.has(a.id)||t.availableVideoStreams.set(a.id,a)}}catch(e){n.e(e)}finally{n.f()}t.video.srcObject=e.streams[0],e.track.onunmute=function(){t.video.srcObject=e.streams[0],t.onNewVideoTrack(e.streams)}}else u(e.streams[0])},u=function(e){if(t.video.srcObject!=e&&t.video.srcObject&&t.video.srcObject!==e){var i=document.createElement("Audio");if(i.srcObject=e,t.autoPlayAudio)i.play();else{var n=function(){i.play(),t.video.removeEventListener("click",n)};t.video.addEventListener("click",n)}console.log("Created new audio element to play seperate audio stream.")}},c=function(e){var i=e.channel;console.log("Data channel created for us by browser (label=".concat(i&&i.label,")")),!i||"cre-bulk"!==i.label&&"cre-texture"!==i.label?(t.dcClient=i,d(i,!1)):console.warn("[webRtcPlayer] extra DataChannel '".concat(i.label,"' ignored (PS1 single-channel constraint)"))},d=function(e,i){try{return e.binaryType="arraybuffer",e.onopen=function(n){console.log("Data channel connected (label=".concat(e.label,")")),i?t.onBulkChannelConnected&&t.onBulkChannelConnected():t.onDataChannelConnected&&t.onDataChannelConnected()},e.onclose=function(t){console.log("Data channel closed (label=".concat(e.label,")"),t)},e.onmessage=function(e){var n=e.data;"string"==typeof n&&(n=function(e){var t,i,n=new Array;t=e.length;for(var a=0;a<t;a++)(i=e.charCodeAt(a))>=65536&&i<=1114111?(n.push(i>>18&7|240),n.push(i>>12&63|128),n.push(i>>6&63|128),n.push(63&i|128)):i>=2048&&i<=65535?(n.push(i>>12&15|224),n.push(i>>6&63|128),n.push(63&i|128)):i>=128&&i<=2047?(n.push(i>>6&31|192),n.push(63&i|128)):n.push(255&i);return new Uint8Array(n).buffer}(n)),i&&t.onBulkChannelMessage?t.onBulkChannelMessage(n):t.onDataChannelMessage&&t.onDataChannelMessage(n)},e.onerror=function(t){console.error("Data channel error (label=".concat(e.label,")"),t)},e}catch(e){return console.warn("No data channel",e),null}},h=function(e){var i=e.candidate;i&&i.candidate&&(console.log("%c[Browser ICE candidate]","background: violet; color: black","| Type=",i.type,"| Protocol=",i.protocol,"| Address=",i.address,"| Port=",i.port,"|"),t.onWebRtcCandidate(i))},f=function(e){e.sdp=e.sdp.replace("useinbandfec=1","useinbandfec=1;stereo=1;sprop-maxcapturerate=48000")},p=function(e){e.onsignalingstatechange=r,e.oniceconnectionstatechange=o,e.onicegatheringstatechange=s,e.ontrack=l,e.onicecandidate=h,e.ondatachannel=c},m=function(){var e=w(L().mark((function e(i){var n,a,r,o,s,l,u,c,d,h,f,p;return L().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.getTransceivers().length>0,i.addTransceiver("video",{direction:"recvonly"}),t.useMic){e.next=6;break}i.addTransceiver("audio",{direction:"recvonly"}),e.next=11;break;case 6:return a=!!t.useMic&&{autoGainControl:!1,channelCount:1,echoCancellation:!1,latency:0,noiseSuppression:!1,sampleRate:48e3,volume:1},e.next=9,navigator.mediaDevices.getUserMedia({video:!1,audio:a});case 9:if(r=e.sent)if(n){o=T(i.getTransceivers());try{for(o.s();!(s=o.n()).done;)if((l=s.value)&&l.receiver&&l.receiver.track&&"audio"===l.receiver.track.kind){u=T(r.getTracks());try{for(u.s();!(c=u.n()).done;)(d=c.value).kind&&"audio"==d.kind&&(l.sender.replaceTrack(d),l.direction="sendrecv")}catch(e){u.e(e)}finally{u.f()}}}catch(e){o.e(e)}finally{o.f()}}else{h=T(r.getTracks());try{for(h.s();!(f=h.n()).done;)(p=f.value).kind&&"audio"==p.kind&&i.addTransceiver(p,{direction:"sendrecv"})}catch(e){h.e(e)}finally{h.f()}}else i.addTransceiver("audio",{direction:"recvonly"});case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();this.setVideoEnabled=function(e){t.video.srcObject.getTracks().forEach((function(t){return t.enabled=e}))},this.startLatencyTest=function(e){t.video&&(t.latencyTestTimings.Reset(),t.latencyTestTimings.TestStartTimeMs=Date.now(),e(t.latencyTestTimings.TestStartTimeMs))},this.handleCandidateFromServer=function(e){var i=new RTCIceCandidate(e);console.log("%c[Unreal ICE candidate]","background: pink; color: black","| Type=",i.type,"| Protocol=",i.protocol,"| Address=",i.address,"| Port=",i.port,"|"),t.forceTURN&&i.candidate.indexOf("relay")<0?console.warn("Dropping candidate because it was not TURN relay.","| Type=",i.type,"| Protocol=",i.protocol,"| Address=",i.address,"| Port=",i.port,"|"):t.pcClient.addIceCandidate(i).catch((function(e){console.error("Failed to add ICE candidate",e)}))},this.createOffer=function(){t.pcClient&&(console.log("Closing existing PeerConnection"),t.pcClient.close(),t.pcClient=null),t.pcClient=new RTCPeerConnection(t.cfg),p(t.pcClient),m(t.pcClient).finally((function(){var e;t.dcClient=function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.createDataChannel(t,i);return console.log("Created datachannel (".concat(t,")")),d(a,n),a}(t.pcClient,"cirrus",t.dataChannelOptions,!1),(t.enableBulkChannel||t.enableTextureChannel)&&console.info("[webRtcPlayer] cre-bulk/cre-texture physical channels disabled (PS1 single-channel); JS-side priority queues still active"),(e=t.pcClient).createOffer(t.sdpConstraints).then((function(i){f(i),e.setLocalDescription(i),t.onWebRtcOffer&&t.onWebRtcOffer(i)}),(function(){console.warn("Couldn't create offer")}))}))},this.receiveOffer=function(e){var i=new RTCSessionDescription(e);t.pcClient||(console.log("Creating a new PeerConnection in the browser.",t.cfg),t.pcClient=new RTCPeerConnection(t.cfg),p(t.pcClient),t.pcClient.setRemoteDescription(i).then((function(){m(t.pcClient).finally((function(){t.pcClient.createAnswer().then((function(e){return t.pcClient.setLocalDescription(e)})).then((function(){t.onWebRtcAnswer&&t.onWebRtcAnswer(t.pcClient.currentLocalDescription)})).then((function(){var e,i=T(t.pcClient.getReceivers());try{for(i.s();!(e=i.n()).done;)e.value.playoutDelayHint=0}catch(e){i.e(e)}finally{i.f()}})).catch((function(e){return console.error("createAnswer() failed:",e)}))}))})))},this.receiveAnswer=function(e){var i=new RTCSessionDescription(e);t.pcClient.setRemoteDescription(i);var n,a=T(t.pcClient.getReceivers());try{for(a.s();!(n=a.n()).done;)n.value.playoutDelayHint=0}catch(e){a.e(e)}finally{a.f()}},this.close=function(){t.pcClient&&(console.log("Closing existing peerClient"),t.pcClient.close(),t.pcClient=null),t.dcClient=null,t.dcBulk=null,t.dcTexture=null,t.aggregateStatsIntervalId&&clearInterval(t.aggregateStatsIntervalId)},this.send=function(e){if(t.dcClient&&"open"==t.dcClient.readyState)try{t.dcClient.send(e)}catch(e){console.error("dcClient.send error: ",e)}},this.sendBulk=function(e){var i=t.dcBulk&&"open"===t.dcBulk.readyState?t.dcBulk:t.dcClient;if(i&&"open"===i.readyState)try{i.send(e)}catch(e){console.error("bulk send error: ",e)}},this.getBulkChannel=function(){return t.dcBulk&&"open"===t.dcBulk.readyState?t.dcBulk:t.dcClient},this.getStats=function(e){t.pcClient&&e&&t.pcClient.getStats(null).then((function(t){e(t)}))},this.aggregateStats=function(e){var i=(t.aggregatedStats||(t.aggregatedStats={}),function(e){var i={};e.forEach((function(e){if("inbound-rtp"==e.type&&!e.isRemote&&("video"==e.mediaType||e.id.toLowerCase().includes("video"))&&(i.timestamp=e.timestamp,i.bytesReceived=e.bytesReceived,i.framesDecoded=e.framesDecoded,i.packetsLost=e.packetsLost,i.framesReceivedRtp=e.framesReceived,i.totalDecodeTime=e.totalDecodeTime,i.jitterBufferDelay=e.jitterBufferDelay,i.jitterBufferEmittedCount=e.jitterBufferEmittedCount,i.processingDelay=e.processingDelay,i.framesAssembledFromMultiplePackets=e.framesAssembledFromMultiplePackets,i.bytesReceivedStart=t.aggregatedStats&&t.aggregatedStats.bytesReceivedStart?t.aggregatedStats.bytesReceivedStart:e.bytesReceived,i.framesDecodedStart=t.aggregatedStats&&t.aggregatedStats.framesDecodedStart?t.aggregatedStats.framesDecodedStart:e.framesDecoded,i.timestampStart=t.aggregatedStats&&t.aggregatedStats.timestampStart?t.aggregatedStats.timestampStart:e.timestamp,t.aggregatedStats&&t.aggregatedStats.timestamp)){t.aggregatedStats.bytesReceived&&(i.bitrate=8*(i.bytesReceived-t.aggregatedStats.bytesReceived)/(i.timestamp-t.aggregatedStats.timestamp),i.bitrate=Math.floor(i.bitrate),i.lowBitrate=t.aggregatedStats.lowBitrate&&t.aggregatedStats.lowBitrate<i.bitrate?t.aggregatedStats.lowBitrate:i.bitrate,i.highBitrate=t.aggregatedStats.highBitrate&&t.aggregatedStats.highBitrate>i.bitrate?t.aggregatedStats.highBitrate:i.bitrate),t.aggregatedStats.bytesReceivedStart&&(i.avgBitrate=8*(i.bytesReceived-t.aggregatedStats.bytesReceivedStart)/(i.timestamp-t.aggregatedStats.timestampStart),i.avgBitrate=Math.floor(i.avgBitrate)),t.aggregatedStats.framesDecoded&&(i.framerate=(i.framesDecoded-t.aggregatedStats.framesDecoded)/((i.timestamp-t.aggregatedStats.timestamp)/1e3),i.framerate=Math.floor(i.framerate),i.lowFramerate=t.aggregatedStats.lowFramerate&&t.aggregatedStats.lowFramerate<i.framerate?t.aggregatedStats.lowFramerate:i.framerate,i.highFramerate=t.aggregatedStats.highFramerate&&t.aggregatedStats.highFramerate>i.framerate?t.aggregatedStats.highFramerate:i.framerate),t.aggregatedStats.framesDecodedStart&&(i.avgframerate=(i.framesDecoded-t.aggregatedStats.framesDecodedStart)/((i.timestamp-t.aggregatedStats.timestampStart)/1e3),i.avgframerate=Math.floor(i.avgframerate));var n=i.timestamp-t.aggregatedStats.timestamp;if(void 0!==i.framesReceivedRtp&&void 0!==t.aggregatedStats.framesReceivedRtp&&n>0){var a=i.framesReceivedRtp-t.aggregatedStats.framesReceivedRtp;a>0&&(i.frameInterArrivalMs=n/a)}if(void 0!==i.totalDecodeTime&&void 0!==t.aggregatedStats.totalDecodeTime){var r=i.framesDecoded-t.aggregatedStats.framesDecoded;r>0&&(i.decodeDurationMs=1e3*(i.totalDecodeTime-t.aggregatedStats.totalDecodeTime)/r)}if(void 0!==i.jitterBufferDelay&&void 0!==t.aggregatedStats.jitterBufferDelay){var o=(i.jitterBufferEmittedCount||0)-(t.aggregatedStats.jitterBufferEmittedCount||0);o>0&&(i.jitterBufferDelayMs=1e3*(i.jitterBufferDelay-t.aggregatedStats.jitterBufferDelay)/o)}if(void 0!==i.processingDelay&&void 0!==t.aggregatedStats.processingDelay){var s=void 0!==i.framesAssembledFromMultiplePackets&&void 0!==t.aggregatedStats.framesAssembledFromMultiplePackets?i.framesAssembledFromMultiplePackets-t.aggregatedStats.framesAssembledFromMultiplePackets:i.framesDecoded-t.aggregatedStats.framesDecoded;s>0&&(i.processingDelayMs=1e3*(i.processingDelay-t.aggregatedStats.processingDelay)/s)}}"track"!=e.type||"video_label"!=e.trackIdentifier&&"video"!=e.kind||(i.framesDropped=e.framesDropped,i.framesReceived=e.framesReceived,i.framesDroppedPercentage=e.framesReceived>0?e.framesDropped/e.framesReceived*100:0,i.frameHeight=e.frameHeight,i.frameWidth=e.frameWidth,i.frameHeightStart=t.aggregatedStats&&t.aggregatedStats.frameHeightStart?t.aggregatedStats.frameHeightStart:e.frameHeight,i.frameWidthStart=t.aggregatedStats&&t.aggregatedStats.frameWidthStart?t.aggregatedStats.frameWidthStart:e.frameWidth),"inbound-rtp"!=e.type||"video"!=e.mediaType&&"video"!=e.kind||(e.frameHeight&&!i.frameHeight&&(i.frameHeight=e.frameHeight),e.frameWidth&&!i.frameWidth&&(i.frameWidth=e.frameWidth),void 0!==e.framesDropped&&void 0===i.framesDropped&&(i.framesDropped=e.framesDropped),void 0!==e.framesReceived&&void 0===i.framesReceived&&(i.framesReceived=e.framesReceived,i.framesReceived>0&&void 0!==i.framesDropped&&(i.framesDroppedPercentage=i.framesDropped/i.framesReceived*100))),"candidate-pair"==e.type&&e.hasOwnProperty("currentRoundTripTime")&&0!=e.currentRoundTripTime&&(i.currentRoundTripTime=e.currentRoundTripTime)})),t.aggregatedStats.receiveToCompositeMs&&(i.receiveToCompositeMs=t.aggregatedStats.receiveToCompositeMs,t.latencyTestTimings.SetFrameDisplayDeltaTime(t.aggregatedStats.receiveToCompositeMs)),t.aggregatedStats=i,t.onAggregatedStats&&t.onAggregatedStats(i)});t.aggregateStatsIntervalId=setInterval((function(){t.getStats(i)}),e)}};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}("/* 视频流送的视频组件样式 */\nvideo {\n position: absolute;\n width: 100%;\n height: 100%;\n}\n\n/* 视频流送的整体根组件属性 */\n#player {\n width: 100%;\n height: 100%;\n position: relative;\n background-color: #000;\n}\n\n/* 如果不是链接后直接加载(即connect_on_load: false)那么便会显示该画面,用于配置显示蒙版的样式 */\n#videoPlayOverlay {\n z-index: 30;\n position: absolute;\n font-size: 1.8em;\n width: 100%;\n height: 100%;\n color: white;\n background-color: rgba(100, 100, 100, .7);\n}\n\n/* State for element to be clickable */\n/* 待开始页面显示状态的样式 */\n.clickableState {\n align-items: center;\n justify-content: center;\n display: flex;\n cursor: pointer;\n}\n\n.textDisplayState {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n/* State to hide overlay, WebRTC communication is in progress and or is playing */\n/* 待开始页面隐藏 */\n.hiddenState {\n display: none;\n}\n\n/* 如果不是链接后直接加载(即connect_on_load: false)那么便会显示该按钮文字,用于配置显示样式 */\n#playButton {\n display: inline-block;\n height: auto;\n}");var be=function(){return C((function e(){k(this,e)}),[{key:"addEventListener",value:function(e,t){void 0===this._listeners&&(this._listeners={}),this._needsDispatchedToUE=!1;var i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&(i[e].push(t),this._needsDispatchedToUE=!0,this._dispatchAddListenerTypes||(this._dispatchAddListenerTypes=[]),this._dispatchAddListenerTypes.push(e))}},{key:"hasEventListener",value:function(e,t){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}},{key:"removeEventListener",value:function(e,t){if(void 0!==this._listeners){this._needsDispatchedToUE=!1;var i=this._listeners[e];if(void 0!==i){var n=i.indexOf(t);-1!==n&&(i.splice(n,1),this._needsDispatchedToUE=!0,this._dispatchRemoveListenerTypes||(this._dispatchRemoveListenerTypes=[]),this._dispatchRemoveListenerTypes.push(e))}}}},{key:"dispatchEvent",value:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var i=t.slice(0),n=0,a=i.length;n<a;n++)e.index=n,i[n].call(this,e);e.target=null}}}},{key:"_silentlyRemoveEventListener",value:function(e,t,i){if(e&&i&&void 0!==e._listeners){var n=e._listeners[t];if(void 0!==n){var a=n.indexOf(i);-1!==a&&n.splice(a,1)}}}}])}(),xe=function(){function t(i){var n;return k(this,t),(n=N(this,t)).haveEvents="GamepadEvent"in window,n.haveWebkitEvents="WebKitGamepadEvent"in window,n.cloudRenderEngine=i,n.playerElement=document.getElementById("player"),n.promiseResponses=[],n.scene=n.cloudRenderEngine.scene,n.interactiveObjects=new Map,n.blacklist=new Set,n.mousedownTime=null,n.mouse=new e(0,0),n.selection=[],n.logMessages=!1,n.inputOptions=i.inputOptions,n.playerElement&&(n.playerElement.tabIndex<10&&(n.playerElement.tabIndex=1e3),n.playerElement.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1)),n}return z(t,be),C(t,[{key:"updateObjectsWithEvent",value:function(){var e=new Map;this.scene&&this.scene.children.length&&this.scene.children.forEach((function(t,i){t._listeners&&e.set(t.uuid,t)})),this.interactiveObjects.clear(),this.interactiveObjects=e}},{key:"isKeyCodeBrowserKey",value:function(e){return e>=112&&e<=123||9===e}},{key:"getKeyCode",value:function(e){return e.keyCode===he.Shift&&"ShiftRight"===e.code?he.RightShift:e.keyCode===he.Control&&"ControlRight"===e.code?he.RightControl:e.keyCode===he.Alt&&"AltRight"===e.code?he.RightAlt:e.keyCode}},{key:"registerKeyboardEvents",value:function(){var e=this;document.onkeydown=function(t){e.print_inputs&&console.log("key down ".concat(t.keyCode,", repeat = ").concat(t.repeat)),e.cloudRenderEngine.sendInputData(new Uint8Array([le.KeyDown,e.getKeyCode(t),t.repeat]).buffer),t.keyCode===he.BackSpace&&document.onkeypress({charCode:he.BackSpace}),e.inputOptions.suppressBrowserKeys&&e.isKeyCodeBrowserKey(t.keyCode)&&t.preventDefault()},document.onkeyup=function(t){e.print_inputs&&console.log("key up ".concat(t.keyCode)),e.cloudRenderEngine.sendInputData(new Uint8Array([le.KeyUp,e.getKeyCode(t)]).buffer),e.inputOptions.suppressBrowserKeys&&e.isKeyCodeBrowserKey(t.keyCode)&&t.preventDefault()},document.onkeypress=function(t){e.print_inputs&&console.log("key press ".concat(t.charCode));var i=new DataView(new ArrayBuffer(3));i.setUint8(0,le.KeyPress),i.setUint16(1,t.charCode,!0),e.cloudRenderEngine.sendInputData(i.buffer)}}},{key:"resizePlayerStyleToFillWindow",value:function(e){var t=e.getElementsByTagName("VIDEO"),i=window.innerHeight/window.innerWidth,n=e.clientHeight/e.clientWidth,a=t.videoHeight/t.videoWidth;isNaN(a)?(this.styleWidth=window.innerWidth,this.styleHeight=window.innerHeight,this.styleTop=0,this.styleLeft=0,e.style="top: "+this.styleTop+"px; left: "+this.styleLeft+"px; width: "+this.styleWidth+"px; height: "+this.styleHeight+"px; cursor: "+this.styleCursor+"; "+this.styleAdditional):i<n?(this.styleWidth=Math.floor(window.innerHeight/a),this.styleHeight=window.innerHeight,this.styleTop=0,this.styleLeft=Math.floor(.5*(window.innerWidth-this.styleWidth)),e.style="top: "+this.styleTop+"px; left: "+this.styleLeft+"px; width: "+this.styleWidth+"px; height: "+this.styleHeight+"px; cursor: "+this.styleCursor+"; "+this.styleAdditional):(this.styleWidth=window.innerWidth,this.styleHeight=Math.floor(window.innerWidth*a),this.styleTop=Math.floor(.5*(window.innerHeight-this.styleHeight)),this.styleLeft=0,e.style="top: "+this.styleTop+"px; left: "+this.styleLeft+"px; width: "+this.styleWidth+"px; height: "+this.styleHeight+"px; cursor: "+this.styleCursor+"; "+this.styleAdditional)}},{key:"resizePlayerStyleToActualSize",value:function(e){var t=e.getElementsByTagName("VIDEO");if(t.length>0){this.styleWidth=t[0].videoWidth,this.styleHeight=t[0].videoHeight;var i=Math.floor(.5*(window.innerHeight-this.styleHeight)),n=Math.floor(.5*(window.innerWidth-this.styleWidth));this.styleTop=i>0?i:0,this.styleLeft=n>0?n:0,e.style="top: "+this.styleTop+"px; left: "+this.styleLeft+"px; width: "+this.styleWidth+"px; height: "+this.styleHeight+"px; cursor: "+this.styleCursor+"; "+this.styleAdditional}}},{key:"resizePlayerStyleToArbitrarySize",value:function(e){e.style="top: 0px; left: 0px; width: "+this.styleWidth+"px; height: "+this.styleHeight+"px; cursor: "+this.styleCursor+"; "+this.styleAdditional}},{key:"setupFreezeFrameOverlay",value:function(){this.cloudRenderEngine.freezeFrameOverlay=document.createElement("div"),this.cloudRenderEngine.freezeFrameOverlay.id="this.cloudRenderEngine.freezeFrameOverlay",this.cloudRenderEngine.freezeFrameOverlay.style.display="none",this.cloudRenderEngine.freezeFrameOverlay.style.pointerEvents="none",this.cloudRenderEngine.freezeFrameOverlay.style.position="absolute",this.cloudRenderEngine.freezeFrameOverlay.style.zIndex="20";var e=document.createElement("img");e.style.position="absolute",this.cloudRenderEngine.freezeFrameOverlay.appendChild(e)}},{key:"showFreezeFrameOverlay",value:function(){this.cloudRenderEngine.freezeFrame.valid&&(this.cloudRenderEngine.freezeFrameOverlay.classList.add("freezeframeBackground"),this.cloudRenderEngine.freezeFrameOverlay.style.display="block")}},{key:"invalidateFreezeFrameOverlay",value:function(){this.cloudRenderEngine.freezeFrameOverlay.style.display="none",this.cloudRenderEngine.freezeFrame.valid=!1,this.cloudRenderEngine.freezeFrameOverlay.classList.remove("freezeframeBackground"),this.cloudRenderEngine.webRtcPlayerObj&&this.cloudRenderEngine.webRtcPlayerObj.setVideoEnabled(!0)}},{key:"resizeFreezeFrameOverlay",value:function(){if(0!==this.cloudRenderEngine.freezeFrame.width&&0!==this.cloudRenderEngine.freezeFrame.height){var e=0,t=0,i=0,n=0,a=document.getElementById("enlarge-display-to-fill-window-tgl"),r=document.getElementById("player");if(null!==a&&a.checked){var o=window.innerWidth/window.innerHeight,s=this.cloudRenderEngine.freezeFrame.width/this.cloudRenderEngine.freezeFrame.height;o<s?(e=window.innerWidth,t=Math.floor(window.innerWidth/s),i=Math.floor(.5*(window.innerHeight-t)),n=0):(e=Math.floor(window.innerHeight*s),t=window.innerHeight,i=0,n=Math.floor(.5*(window.innerWidth-e)))}else{var l=r.offsetWidth/r.offsetHeight,u=this.cloudRenderEngine.freezeFrame.width/this.cloudRenderEngine.freezeFrame.height;l<u?(e=r.offsetWidth,t=Math.floor(r.offsetWidth/u),i=Math.floor(.5*(r.offsetHeight-t)),n=0):(e=Math.floor(r.offsetHeight*u),t=r.offsetHeight,i=0,n=Math.floor(.5*(r.offsetWidth-e)))}var c=document.getElementById("this.cloudRenderEngine.freezeFrameOverlay").childNodes[0];this.cloudRenderEngine.freezeFrameOverlay.style.width=r.offsetWidth+"px",this.cloudRenderEngine.freezeFrameOverlay.style.height=r.offsetHeight+"px",this.cloudRenderEngine.freezeFrameOverlay.style.left="0px",this.cloudRenderEngine.freezeFrameOverlay.style.top="0px",c.style.width=e+"px",c.style.height=t+"px",c.style.left=n+"px",c.style.top=i+"px"}}},{key:"resizePlayerStyle",value:function(e){var t=document.getElementById("player");if(t)if(this.cloudRenderEngine.updateVideoStreamSize(),t.classList.contains("fixed-size"))this.setupMouseAndFreezeFrame(t);else{var i=document.getElementById("enlarge-display-to-fill-window-tgl"),n=window.innerWidth<t.videoWidth||window.innerHeight<t.videoHeight;null!==i?i.checked||n?this.resizePlayerStyleToFillWindow(t):this.resizePlayerStyleToActualSize(t):this.resizePlayerStyleToArbitrarySize(t),this.setupMouseAndFreezeFrame(t)}}},{key:"setupMouseAndFreezeFrame",value:function(e){this.playerElementClientRect=e.getBoundingClientRect(),this.cloudRenderEngine.setupNormalizeAndQuantize(),this.resizeFreezeFrameOverlay()}},{key:"onOrientationChange",value:function(e){var t=this;clearTimeout(this._orientationChangeTimeout),this._orientationChangeTimeout=setTimeout((function(){t.resizePlayerStyle()}),500)}},{key:"setupHtmlEvents",value:function(){var e=this,t=this;if(window.addEventListener("resize",(function(t){e.resizePlayerStyle(t)}),!0),window.addEventListener("orientationchange",(function(t){e.onOrientationChange(t)})),this.haveEvents?(window.addEventListener("gamepadconnected",(function(t){e.gamepadConnectHandler(t)})),window.addEventListener("gamepaddisconnected",(function(t){e.gamepadDisconnectHandler(t)}))):this.haveWebkitEvents&&(window.addEventListener("webkitgamepadconnected",(function(t){e.gamepadConnectHandler(t)})),window.addEventListener("webkitgamepaddisconnected",(function(t){e.gamepadDisconnectHandler(t)}))),this.cloudRenderEngine.isShowTestUI){document.getElementById("overlayButton").addEventListener("click",(function(t){e.onExpandOverlay_Click(t)}));var i=document.getElementById("enlarge-display-to-fill-window-tgl");null!==i&&(i.onchange=function(e){t.resizePlayerStyle()}),this.cloudRenderEngine.qualityControlOwnershipCheckBox=document.getElementById("quality-control-ownership-tgl"),null!==this.cloudRenderEngine.qualityControlOwnershipCheckBox&&(this.cloudRenderEngine.qualityControlOwnershipCheckBox.onchange=function(e){t.cloudRenderEngine.requestQualityControl()});var n=document.getElementById("encoder-params-submit");null!==n&&(n.onclick=function(e){var i=document.getElementById("encoder-min-qp-text").value,n=document.getElementById("encoder-max-qp-text").value;t.cloudRenderEngine.emitCommand({ConsoleCommand:"PixelStreaming.Encoder.MinQP "+i}),t.cloudRenderEngine.emitCommand({ConsoleCommand:"PixelStreaming.Encoder.MaxQP "+n})});var a=document.getElementById("webrtc-params-submit");null!==a&&(a.onclick=function(e){var i=document.getElementById("webrtc-fps-text").value,n=1e3*document.getElementById("webrtc-min-bitrate-text").value,a=1e3*document.getElementById("webrtc-max-bitrate-text").value;t.cloudRenderEngine.emitCommand({ConsoleCommand:"PixelStreaming.WebRTC.Fps "+i}),t.cloudRenderEngine.emitCommand({ConsoleCommand:"PixelStreaming.WebRTC.MinBitrate "+n}),t.cloudRenderEngine.emitCommand({ConsoleCommand:"PixelStreaming.WebRTC.MaxBitrate "+a})});var r=document.getElementById("show-fps-button");null!==r&&(r.onclick=function(e){t.cloudRenderEngine.emitCommand({ConsoleCommand:"Stat FPS"})});var o=document.getElementById("match-viewport-res-tgl");null!==o&&(o.onchange=function(e){t.cloudRenderEngine.matchViewportResolution=o.checked});var s=document.getElementById("show-stats-tgl");null!==s&&(s.onchange=function(e){document.getElementById("statsContainer").style.display=e.target.checked?"block":"none"});var l=document.getElementById("test-latency-button");l&&(l.onclick=function(){e.sendStartLatencyTest()}),this.cloudRenderEngine.setupToggleWithUrlParams("prefer-sfu-tgl","preferSFU"),this.cloudRenderEngine.setupToggleWithUrlParams("use-mic-tgl","useMic"),this.cloudRenderEngine.setupToggleWithUrlParams("force-turn-tgl","ForceTURN");var u=document.getElementById("stream-select"),c=document.getElementById("track-select");u&&(u.onchange=function(e){var i=t.cloudRenderEngine.webRtcPlayerObj.availableVideoStreams.get(u.value);t.cloudRenderEngine.webRtcPlayerObj.video.srcObject=i,t.cloudRenderEngine.streamTrackSource=i,t.cloudRenderEngine.webRtcPlayerObj.video.play(),t.cloudRenderEngine.updateTrackList()},c&&(c.onchange=function(e){if(t.cloudRenderEngine.streamTrackSource||(t.cloudRenderEngine.streamTrackSource=t.cloudRenderEngine.webRtcPlayerObj.availableVideoStreams.get(u.value)),t.cloudRenderEngine.streamTrackSource){var i,n=T(t.cloudRenderEngine.streamTrackSource.getVideoTracks());try{for(n.s();!(i=n.n()).done;){var a=i.value;if(a.id===c.value){t.cloudRenderEngine.webRtcPlayerObj.video.srcObject=new MediaStream([a]),t.cloudRenderEngine.webRtcPlaye