index.html 23 KB

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