index.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <!-- <link rel="stylesheet" href="./index.css" /> -->
  9. <link rel="stylesheet" href="./css/toastify.min.css" />
  10. </head>
  11. <body>
  12. <!-- Babylon.js -->
  13. <script src="./libs/jquery-1.10.2.min.js"></script>
  14. <script src="./libs/dat.gui.min.js"></script>
  15. <script src="./libs/ammo.js"></script>
  16. <script src="./libs/cannon.js"></script>
  17. <script src="./libs/Oimo.js"></script>
  18. <script src="./libs/earcut.min.js"></script>
  19. <script src="./libs/recast.js"></script>
  20. <script src="./libs/babylon.js"></script>
  21. <script src="./libs/babylonjs.materials.min.js"></script>
  22. <script src="./libs/babylonjs.proceduralTextures.min.js"></script>
  23. <script src="./libs/babylonjs.postProcess.min.js"></script>
  24. <script src="./libs/babylonjs.loaders.js"></script>
  25. <script src="./libs/babylonjs.serializers.min.js"></script>
  26. <script src="./libs/babylon.gui.min.js"></script>
  27. <script src="./libs/babylon.inspector.bundle.js"></script>
  28. <script src="./libs/socket.2.3.js"></script>
  29. <script src="./libs/events.js"></script>
  30. <script src="./libs/axios.min.js"></script>
  31. <script src="./libs/VisibilityChangeHandler.js"></script>
  32. <script src="./libs/decoder.js"></script>
  33. <script src="./libs/nipplejs.min.js"></script>
  34. <script src="./shader.js"></script>
  35. <!-- <script src="./webrtc//adapter-7.4.0.min.js"></script>
  36. <script src="./webrtc/srs.sdk.js"></script> -->
  37. <link rel="stylesheet" href="./css/index.cb1a6e05.css" />
  38. <script>
  39. const SERVER_URLS = {
  40. DEV: "wss://sit-eks.xverse.cn/ws",
  41. PROD: "wss://eks.xverse.cn/ws"
  42. }
  43. , REPORT_URL = {
  44. DEV: "https://xa.xverse.cn:6680/collect",
  45. PROD: "https://xa.xverse.cn/collect"
  46. }
  47. , MAX_RECONNECT_COUNT = 3
  48. , DEFAULT_JOINROOM_TIMEOUT = 15e3
  49. , DEFAULT_MAIN_CAMERA_FOV = 50
  50. , DEFAULT_AVATAR_SCALE = 1
  51. , REPORT_NUM_PER_REQUEST = 20
  52. , DEFAULT_OPEN_TIMEOUT_MS = 6e3
  53. , WS_CLOSE_NORMAL = 1e3
  54. , WS_CLOSE_RECONNECT = 3008
  55. , PING_INTERVAL_MS = 1e3
  56. , TEXTURE_URL = "https://static.xverse.cn/qqktv/texture.png"
  57. , REPORT_MODULE_TYPE = "xverse-js"
  58. , authenticationErrorCodes = [3001, 3002, 3003, 3005]
  59. , RTT_MAX_VALUE = 200
  60. , HB_MAX_VALUE = 500
  61. , DURATION = 10
  62. , NET_INTERVAL = 1;
  63. const VERSION$1 = "1.0.75"
  64. , ENV = "production";
  65. const COMPONENT_LIST_PREFIX = "/component_list.json";
  66. const avatarSetting = {
  67. fileType: ".glb",
  68. lodType: "_lod",
  69. lod: [{
  70. level: "lod0",
  71. fileName: ".glb",
  72. quota: 5,
  73. dist: 1e3
  74. }, {
  75. level: "lod1",
  76. fileName: "_lod2.glb",
  77. quota: 5,
  78. dist: 2e3
  79. }, {
  80. level: "lod2",
  81. fileName: "_lod4.glb",
  82. quota: 0,
  83. dist: 7500
  84. }],
  85. isRayCastEnable: !0,
  86. maxAvatarNum: 40,
  87. maxBillBoardDist: 7500,
  88. body: "body",
  89. head: "head",
  90. hair: "hair",
  91. suit: "suit",
  92. pants: "pants",
  93. shoes: "shoes",
  94. clothes: "clothes",
  95. animations: "animations",
  96. defaultIdle: "Idle",
  97. cullingDistance: 200,
  98. defaultMove: "Walking"
  99. }
  100. , avatarResources = {
  101. ygb: {
  102. name: "ygb",
  103. mat: "NM_ygb",
  104. mesh: "ygb"
  105. }
  106. }
  107. , action = {
  108. GiftClap: {
  109. animName: "GiftClap",
  110. keyTime: 1760
  111. },
  112. Cheering: {
  113. animName: "Cheering",
  114. attachPair: [{
  115. bone: "mixamorig_MiddleFinger2_R",
  116. obj: "ygb",
  117. offset: {
  118. x: 0,
  119. y: 0,
  120. z: 0
  121. },
  122. rotate: {
  123. x: 0,
  124. y: 3.84,
  125. z: 0
  126. },
  127. scale: {
  128. x: 1,
  129. y: 1,
  130. z: 1
  131. }
  132. }, {
  133. bone: "mixamorig_MiddleFinger2_L",
  134. obj: "ygb",
  135. offset: {
  136. x: 0,
  137. y: 0,
  138. z: 0
  139. },
  140. rotate: {
  141. x: 0,
  142. y: 3.49,
  143. z: 0
  144. },
  145. scale: {
  146. x: 1,
  147. y: 1,
  148. z: 1
  149. }
  150. }]
  151. }
  152. }
  153. const WASM_Version = "h264"
  154. , DECODER_VERSION = "v0.9.3"
  155. , WASM_URLS = {
  156. h264: "https://static.xverse.cn/wasm/v15/lib_ff264dec_no_idb_with_wasm_tbundle.js?tbundle=tmeland_base",
  157. xv265: "https://static.xverse.cn/wasm/codec-release/h265-dec-sw-wasm/v-0-9-1/libxv265dec.js",
  158. h265: ""
  159. }
  160. , STUCK_STAGE_GOOD = 45
  161. , STUCK_STAGE_WELL = 85
  162. , STUCK_STAGE_FAIR = 125
  163. , STUCK_STAGE_BAD = 165
  164. , DECODER_PASSIVE_JITTER = 0;
  165. /**
  166. * 公共方法
  167. **/
  168. const isFunction = i=>typeof i == "function";
  169. const isSuit = i=>i === "suit"
  170. // 随机获取数组内某一元素,或字符串内某一字符
  171. const getRandomItem = (i) =>i.length === 0 ? null : i[Math.floor(Math.random() * i.length)]
  172. const getAnimationKey = (i,e)=>e + "_" + i
  173. const blobToDataURI = async i=>new Promise((e,t)=>{
  174. const r = new FileReader;
  175. r.readAsDataURL(i),
  176. r.onload = function(n) {
  177. var o;
  178. e((o = n.target) == null ? void 0 : o.result)
  179. }
  180. ,
  181. r.onerror = function(n) {
  182. t(n)
  183. }
  184. });
  185. // 系统检测
  186. const checkOS = ()=>{
  187. const i = navigator.userAgent
  188. , e = /(?:Windows Phone)/.test(i)
  189. , t = /(?:SymbianOS)/.test(i) || e
  190. , r = /(?:Android)/.test(i)
  191. , n = /(?:Firefox)/.test(i);
  192. /(?:Chrome|CriOS)/.test(i);
  193. const o = /(?:iPad|PlayBook)/.test(i) || r && !/(?:Mobile)/.test(i) || n && /(?:Tablet)/.test(i)
  194. , a = /(?:iPhone|ipad|ipod)/.test(i) && !o
  195. , s = !a && !r && !t;
  196. return {
  197. isTablet: o,
  198. isPhone: a,
  199. isIOS: /iPhone|iPod|iPad/.test(navigator.userAgent),
  200. isAndroid: r,
  201. isPc: s
  202. }
  203. }
  204. var De = Object.defineProperty
  205. , Ne = Object.defineProperties;
  206. var we = Object.getOwnPropertyDescriptors;
  207. var be = Object.getOwnPropertySymbols;
  208. var Me = Object.prototype.hasOwnProperty
  209. , Ie = Object.prototype.propertyIsEnumerable;
  210. var Se = (obj, key, value) =>
  211. key in obj ? Object.defineProperty(obj, key, {
  212. enumerable: true,
  213. configurable: true,
  214. writable: true,
  215. value: value
  216. }) : obj[key] = value
  217. , oe = (obj, propsObj)=>{
  218. for (var t in propsObj || (propsObj = {}))
  219. Me.call(propsObj, t) && Se(obj, t, propsObj[t]);
  220. if (Object.getOwnPropertySymbols) {
  221. for (var t of Object.getOwnPropertySymbols(propsObj))
  222. Ie.call(propsObj, t) && Se(obj, t, propsObj[t]);
  223. }
  224. return obj
  225. }
  226. // 将propsObj的所有属性拷贝到obj
  227. , le = (obj, propsObj) => Object.defineProperties(obj, Object.getOwnPropertyDescriptors(propsObj));
  228. var Oe = (i,e)=>{
  229. var t = {};
  230. for (var r in i)
  231. Me.call(i, r) && e.indexOf(r) < 0 && (t[r] = i[r]);
  232. if (i != null && be)
  233. for (var r of be(i))
  234. e.indexOf(r) < 0 && Ie.call(i, r) && (t[r] = i[r]);
  235. return t
  236. };
  237. var E = (i,e,t)=>(Se(i, typeof e != "symbol" ? e + "" : e, t),t);
  238. Promise.prototype._timeout = function(i, e) {
  239. let t;
  240. return new Promise((r,n)=>(t = window.setTimeout(()=>{
  241. n(e)
  242. }
  243. , i),
  244. this.then(o=>{
  245. clearTimeout(t),
  246. r(o)
  247. }
  248. , o=>{
  249. clearTimeout(t),
  250. n(o)
  251. }
  252. )))
  253. };
  254. function toast(i, e) {
  255. const {onClick: t, duration: r} = e || {};
  256. return window.Toastify({
  257. text: i,
  258. duration: r || 3e3,
  259. position: "center",
  260. onClick: function() {
  261. t && t()
  262. }
  263. }).showToast()
  264. }
  265. // 将原json里的值全部转成float,并返回一个新json
  266. const objectParseFloat = (i) => {
  267. const e = {};
  268. i && Object.keys(i).forEach((t) => {
  269. e[t] = parseFloat(i[t]);
  270. })
  271. return e;
  272. }
  273. const safelyJsonParse = i=> {
  274. let e = {};
  275. try {
  276. e = JSON.parse(i)
  277. } catch {}
  278. return e
  279. }
  280. const safeParseComponents = i=>{
  281. let e = [];
  282. try {
  283. e = JSON.parse(i || "[]")
  284. } catch {
  285. e = [],
  286. log$2.error(`avatarComponents parse error: ${i}`)
  287. }
  288. return e
  289. }
  290. const safeDecodeURIComponent = i=>{
  291. let e = "";
  292. try {
  293. e = decodeURIComponent(i)
  294. } catch {
  295. e = i
  296. }
  297. return e
  298. }
  299. // 坐标和旋转数值保护,保留2位小数
  300. const positionPrecisionProtect = i=>{
  301. const {x: e, y: t, z: r} = i;
  302. return {
  303. x: +e.toFixed(2),
  304. y: +t.toFixed(2),
  305. z: +r.toFixed(2)
  306. }
  307. }
  308. const rotationPrecisionProtect = i=>{
  309. const {pitch: e, yaw: t, roll: r} = i;
  310. return {
  311. pitch: +e.toFixed(2),
  312. yaw: +t.toFixed(2),
  313. roll: +r.toFixed(2)
  314. }
  315. }
  316. const avatarComponentsModify = (i,e)=>new Promise((t,r)=>{
  317. var l;
  318. let n = [];
  319. const o = []
  320. , a = [];
  321. let s = e.some(u=>isSuit(u.type));
  322. if ((l = i == null ? void 0 : i.components) == null || l.forEach(u=>{
  323. var f;
  324. const c = e.find(d=>d.type === u.type)
  325. , h = c && ((f = i == null ? void 0 : i.components) == null ? void 0 : f.find(d=>d.type === c.type && d.units.some(_=>_.id === c.id))) !== void 0;
  326. if (c)
  327. if (h)
  328. n.push(c);
  329. else {
  330. const d = u.units.find(_=>_.isDefault) || u.units[0];
  331. d ? n.push({
  332. type: u.type,
  333. id: d.id
  334. }) : o.push(`component with type: ${u.type} without default and available unit`)
  335. }
  336. else if (isSuit(u.type)) {
  337. const d = u.units.find(_=>_.isDefault);
  338. d && n.push({
  339. type: u.type,
  340. id: d.id
  341. })
  342. } else {
  343. const d = u.units.find(_=>_.isDefault) || u.units[0];
  344. d ? n.push({
  345. type: u.type,
  346. id: d.id
  347. }) : o.push(`component with type: ${u.type} without default and available unit`)
  348. }
  349. }
  350. ),
  351. s = n.some(u=>isSuit(u.type)),
  352. s) {
  353. const u = i == null ? void 0 : i.components.find(c=>isSuit(c.type));
  354. n = n.filter(c=>(u == null ? void 0 : u.suitComb.indexOf(c.type)) === -1)
  355. }
  356. o.length > 0 && (log$2.error(o.join(", ")),
  357. r(o.join(", "))),
  358. a.length > 0 && log$2.warn(a.join(", ")),
  359. t(n)
  360. })
  361. const avatarComponentsParser = async(i=null,e,t=[])=>new Promise(async(r,n)=>{
  362. var u, c;
  363. if (e.find(h=>isSuit(h.type))) {
  364. const h = (c = (u = i == null ? void 0 : i.components) == null ? void 0 : u.find(f=>isSuit(f.type))) == null ? void 0 : c.suitComb;
  365. e = e.filter(f=>(h == null ? void 0 : h.indexOf(f.type)) === -1)
  366. }
  367. const a = e.filter(h=>!t.some(f=>f.id === h.id));
  368. a.length === 0 && r([]);
  369. const s = [];
  370. a.forEach(async h=>{
  371. var _;
  372. let f = (_ = i == null ? void 0 : i.components) == null ? void 0 : _.find(g=>g.type === h.type);
  373. if (!f) {
  374. const g = `changeComponents, no such component with type: ${h.type}`;
  375. log$2.error(g),
  376. n(g)
  377. }
  378. f = JSON.parse(JSON.stringify(f));
  379. let d = f == null ? void 0 : f.units.find(g=>g.id === h.id);
  380. d || (log$2.warn(`changeComponents, no unit with type: ${h.type}, id: ${h.id}`),
  381. d = f == null ? void 0 : f.units.find(g=>g.isDefault),
  382. !d && log$2.warn(`changeComponents, no default unit with type: ${h.type}`)),
  383. d && s.push({
  384. id: d.id,
  385. url: d.url,
  386. suitComb: (f == null ? void 0 : f.suitComb) || [],
  387. type: h.type
  388. })
  389. });
  390. const l = [];
  391. Promise.all(l).then(h=>{
  392. s.forEach((f,d)=>{
  393. var _, g;
  394. if (!isSuit(f.type)) {
  395. const m = ((g = (_ = i == null ? void 0 : i.components) == null ? void 0 : _.find(v=>isSuit(v.type))) == null ? void 0 : g.suitComb) || [];
  396. m.length > 0 && (m == null ? void 0 : m.indexOf(f.type)) !== -1 && (f.suitComb = ["suit"])
  397. }
  398. f.url = h[d]
  399. }
  400. ),
  401. r(s)
  402. }).catch(h=>{
  403. n(h)
  404. })
  405. })
  406. /**
  407. * 坐标转换相关
  408. **/
  409. // UE4 to Xverse
  410. const ue4Rotation2Xverse = i=>isRotationCorrect() ? (
  411. i.pitch >= 89.5 ? i.pitch = 89.5 : i.pitch <= -89.5 && (i.pitch = -89.5),
  412. new BABYLON.Vector3(-1 * Math.PI * i.pitch / 180,Math.PI * i.yaw / 180 - Math.PI * 27 / 18,Math.PI * i.roll / 180 < .001 ? 0 : Math.PI * i.roll / 180)
  413. ) : null
  414. const ue4Rotation2Xverse_mesh = i=>isRotationCorrect() ? new BABYLON.Vector3(Math.PI * i.pitch / 180,Math.PI * i.yaw / 180,Math.abs(Math.PI * i.roll) / 180 < .001 ? 0 : -1 * (Math.PI * i.roll) / 180) : null
  415. const scaleFromUE4toXverse = 100;
  416. const ue4Scaling2Xverse = i=>isScalingCorrect() ? new BABYLON.Vector3(i.x,i.z,-1 * i.y) : null
  417. const ue4Position2Xverse = i=>isPositionCorrect() ? new BABYLON.Vector3(i.x * .01,i.z * .01,-1 * i.y * .01) : null
  418. // Xverse to Ue4
  419. const xversePosition2Ue4 = i=>isPositionCorrect() ? {
  420. x: i.x * 100,
  421. y: -1 * i.z * 100,
  422. z: i.y * 100
  423. } : null
  424. const xverseRotation2Ue4 = i=>{
  425. if (isPositionCorrect()) {
  426. let e = 0;
  427. return i.z == 0 ? e = 0 : e = 180 * i.z / Math.PI,
  428. {
  429. pitch: 180 * i.x * -1 / Math.PI,
  430. yaw: (i.y + Math.PI * 27 / 18) * 180 / Math.PI,
  431. roll: e
  432. }
  433. } else
  434. return null
  435. }
  436. // 计算两个向量间的距离或角度
  437. const calcDistance3D = (i,e)=>Math.sqrt((i.x - e.x) * (i.x - e.x) + (i.y - e.y) * (i.y - e.y) + (i.z - e.z) * (i.z - e.z))
  438. const calcDistance3DVector = (i,e)=>Math.sqrt((i.x - e.x) * (i.x - e.x) + (i.y - e.y) * (i.y - e.y) + (i.z - e.z) * (i.z - e.z))
  439. const calcDistance3DAngle = (i,e)=>Math.sqrt((i.roll - e.roll) * (i.roll - e.roll) + (i.pitch - e.pitch) * (i.pitch - e.pitch) + (i.yaw - e.yaw) * (i.yaw - e.yaw))
  440. const isPositionCorrect = i=>!0
  441. const isScalingCorrect = i=>!0
  442. const isRotationCorrect = i=>!0
  443. const getStringBoundaries = (i,e,t=new Map)=>{
  444. let r = 0
  445. , n = ""
  446. , o = -1
  447. , a = 0;
  448. const s = [0];
  449. for (let l = 0; l < i.length; l++) {
  450. const u = i.codePointAt(l);
  451. let c = t.get(u);
  452. if (c)
  453. r += c,
  454. n += i[l],
  455. u > 64 && u < 91 || u > 96 && u < 123 ? (o == -1 && (o = l),
  456. a += c) : (o = -1,
  457. a = 0);
  458. else if (u < 975 || u > 1024 && u < 1920)
  459. c = 1,
  460. r++,
  461. n += i[l],
  462. u > 64 && u < 91 || u > 96 && u < 123 ? (o == -1 && (o = l),
  463. a += c) : (o = -1,
  464. a = 0);
  465. else if (u > 4499 && u < 4600 || u > 8207 && u < 8232 || u > 8238 && u < 8287 || u > 8238 && u < 8287 || u > 8304 && u < 8384 || u > 8447 && u < 9211 || u > 11263 && u < 11624 || u > 11646 && u < 11671 || u > 11679 && u < 11845 || u > 11903 && u < 12020 || u > 12031 && u < 12246 || u > 12287 && u < 12544 || u > 12548 && u < 12728 || u > 12735 && u < 12772 || u > 12783 && u < 19894 || u > 19967 && u < 40918 || u > 42191 && u < 42240 || u > 44031 && u < 55204 || u > 59276 && u < 59287 || u > 59412 && u < 59493 || u > 63743 && u < 64207 || u > 65039 && u < 65050 || u > 65071 && u < 65510)
  466. c = 2,
  467. r += 2,
  468. o = -1,
  469. a = 0,
  470. n += i[l];
  471. else if (u > 9311 && u < 11158) {
  472. c = 2,
  473. r += 2,
  474. o = -1,
  475. a = 0,
  476. n += i[l];
  477. const h = i.codePointAt(l + 1);
  478. h > 65023 && h < 65040 && (n += i[l + 1],
  479. l++)
  480. } else
  481. u > 126979 && u < 129783 && (c = 2,
  482. r += 2,
  483. o = -1,
  484. a = 0,
  485. l++,
  486. n += String.fromCodePoint(u));
  487. if (l == s[s.length - 1] + 1 && o > 0 ? (s[s.length - 1] = o,
  488. r = 0 + a) : r > e && (s.push(l),
  489. a >= r && (a = 0 + c,
  490. o = 0),
  491. r = 0 + c),
  492. l >= i.length - 1)
  493. break
  494. }
  495. return s[s.length - 1] != i.length && s.push(i.length),
  496. [n, s]
  497. }
  498. var Observer = function() {
  499. function i(e, t, r) {
  500. r === void 0 && (r = null),
  501. this.callback = e,
  502. this.mask = t,
  503. this.scope = r,
  504. this._willBeUnregistered = !1,
  505. this.unregisterOnNextCall = !1
  506. }
  507. return i
  508. }()
  509. var Observable = function() {
  510. function i(e) {
  511. this._observers = new Array,
  512. this._eventState = new BABYLON.EventState(0),
  513. e && (this._onObserverAdded = e)
  514. }
  515. i.FromPromise = function(e, t) {
  516. var r = new i;
  517. return e.then(function(n) {
  518. r.notifyObservers(n)
  519. }).catch(function(n) {
  520. if (t)
  521. t.notifyObservers(n);
  522. else
  523. throw n
  524. }),
  525. r
  526. }
  527. ,
  528. Object.defineProperty(i.prototype, "observers", {
  529. get: function() {
  530. return this._observers
  531. },
  532. enumerable: !1,
  533. configurable: !0
  534. }),
  535. i.prototype.add = function(e, t, r, n, o) {
  536. if (t === void 0 && (t = -1),
  537. r === void 0 && (r = !1),
  538. n === void 0 && (n = null),
  539. o === void 0 && (o = !1),
  540. !e)
  541. return null;
  542. var a = new Observer(e,t,n);
  543. return a.unregisterOnNextCall = o,
  544. r ? this._observers.unshift(a) : this._observers.push(a),
  545. this._onObserverAdded && this._onObserverAdded(a),
  546. a
  547. }
  548. ,
  549. i.prototype.addOnce = function(e) {
  550. return this.add(e, void 0, void 0, void 0, !0)
  551. }
  552. ,
  553. i.prototype.remove = function(e) {
  554. if (!e)
  555. return !1;
  556. var t = this._observers.indexOf(e);
  557. return t !== -1 ? (this._deferUnregister(e),
  558. !0) : !1
  559. }
  560. ,
  561. i.prototype.removeCallback = function(e, t) {
  562. for (var r = 0; r < this._observers.length; r++) {
  563. var n = this._observers[r];
  564. if (!n._willBeUnregistered && n.callback === e && (!t || t === n.scope))
  565. return this._deferUnregister(n),
  566. !0
  567. }
  568. return !1
  569. }
  570. ,
  571. i.prototype._deferUnregister = function(e) {
  572. var t = this;
  573. e.unregisterOnNextCall = !1,
  574. e._willBeUnregistered = !0,
  575. setTimeout(function() {
  576. t._remove(e)
  577. }, 0)
  578. }
  579. ,
  580. i.prototype._remove = function(e) {
  581. if (!e)
  582. return !1;
  583. var t = this._observers.indexOf(e);
  584. return t !== -1 ? (this._observers.splice(t, 1),
  585. !0) : !1
  586. }
  587. ,
  588. i.prototype.makeObserverTopPriority = function(e) {
  589. this._remove(e),
  590. this._observers.unshift(e)
  591. }
  592. ,
  593. i.prototype.makeObserverBottomPriority = function(e) {
  594. this._remove(e),
  595. this._observers.push(e)
  596. }
  597. ,
  598. i.prototype.notifyObservers = function(e, t, r, n, o) {
  599. if (t === void 0 && (t = -1),
  600. !this._observers.length)
  601. return !0;
  602. var a = this._eventState;
  603. a.mask = t,
  604. a.target = r,
  605. a.currentTarget = n,
  606. a.skipNextObservers = !1,
  607. a.lastReturnValue = e,
  608. a.userInfo = o;
  609. for (var s = 0, l = this._observers; s < l.length; s++) {
  610. var u = l[s];
  611. if (!u._willBeUnregistered && (u.mask & t && (u.scope ? a.lastReturnValue = u.callback.apply(u.scope, [e, a]) : a.lastReturnValue = u.callback(e, a),
  612. u.unregisterOnNextCall && this._deferUnregister(u)),
  613. a.skipNextObservers))
  614. return !1
  615. }
  616. return !0
  617. }
  618. ,
  619. i.prototype.notifyObserversWithPromise = function(e, t, r, n, o) {
  620. var a = this;
  621. t === void 0 && (t = -1);
  622. var s = Promise.resolve(e);
  623. if (!this._observers.length)
  624. return s;
  625. var l = this._eventState;
  626. return l.mask = t,
  627. l.target = r,
  628. l.currentTarget = n,
  629. l.skipNextObservers = !1,
  630. l.userInfo = o,
  631. this._observers.forEach(function(u) {
  632. l.skipNextObservers || u._willBeUnregistered || u.mask & t && (u.scope ? s = s.then(function(c) {
  633. return l.lastReturnValue = c,
  634. u.callback.apply(u.scope, [e, l])
  635. }) : s = s.then(function(c) {
  636. return l.lastReturnValue = c,
  637. u.callback(e, l)
  638. }),
  639. u.unregisterOnNextCall && a._deferUnregister(u))
  640. }),
  641. s.then(function() {
  642. return e
  643. })
  644. }
  645. ,
  646. i.prototype.notifyObserver = function(e, t, r) {
  647. if (r === void 0 && (r = -1),
  648. !e._willBeUnregistered) {
  649. var n = this._eventState;
  650. n.mask = r,
  651. n.skipNextObservers = !1,
  652. e.callback(t, n),
  653. e.unregisterOnNextCall && this._deferUnregister(e)
  654. }
  655. }
  656. ,
  657. i.prototype.hasObservers = function() {
  658. return this._observers.length > 0
  659. }
  660. ,
  661. i.prototype.clear = function() {
  662. this._observers = new Array,
  663. this._onObserverAdded = null
  664. }
  665. ,
  666. i.prototype.clone = function() {
  667. var e = new i;
  668. return e._observers = this._observers.slice(0),
  669. e
  670. }
  671. ,
  672. i.prototype.hasSpecificMask = function(e) {
  673. e === void 0 && (e = -1);
  674. for (var t = 0, r = this._observers; t < r.length; t++) {
  675. var n = r[t];
  676. if (n.mask & e || n.mask === e)
  677. return !0
  678. }
  679. return !1
  680. }
  681. return i
  682. }();
  683. </script>
  684. <div id="root">
  685. <div class = "App">
  686. <canvas id = "canvas" class = "stream unselect">
  687. </canvas>
  688. </div>
  689. <div class="debug_control_btns">
  690. <button class="debugger1">Toggle Stats</button>
  691. <button class="debugger2">取消低模着色</button>
  692. <button class="debugger3">画质:高</button>
  693. <button class="font-size-small debugger4" onclick="room.debug.toggleNearbyBreathPoint">Toggle周边呼吸点</button>
  694. <button class="font-size-small debugger5" onclick="room.debug.toggleTapBreathPoint">Toggle点击呼吸点</button>
  695. <button class="font-size-small debugger6" >录制码流(10s)</button>
  696. </div>
  697. </div>
  698. <script type="module">
  699. document.querySelector('.debugger1').onclick = ()=>{
  700. var y, b;
  701. (y = room.stats) != null && y.isShow
  702. ? room.stats.hide()
  703. : (b = room.stats) == null || b.show();
  704. }
  705. document.querySelector('.debugger2').onclick = ()=>{
  706. room.debug.toggleSceneshading(), r(room.debug.isSceneShading);
  707. }
  708. document.querySelector('.debugger3').onclick = ()=>{
  709. let y = "average";
  710. n === "high"
  711. ? (y = "average")
  712. : n === "average"
  713. ? (y = "low")
  714. : n === "low"
  715. ? (y = "high")
  716. : (y = "average"),
  717. o(y),
  718. room.setPictureQualityLevel(y);
  719. }
  720. document.querySelector('.debugger4').onclick = ()=>{
  721. room.debug.toggleNearbyBreathPoint();
  722. }
  723. document.querySelector('.debugger5').onclick = ()=>{
  724. room.debug.toggleTapBreathPoint();
  725. }
  726. document.querySelector('.debugger6').onclick = ()=>{
  727. room.debug.dumpStream(() => {
  728. // toast("\u5F55\u5236\u5B8C\u6210");
  729. });
  730. // toast("\u5F00\u59CB\u5F55\u5236");
  731. }
  732. </script>
  733. <script src="js/index.js"></script>
  734. </body>
  735. </html>