index.html 23 KB

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