index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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="./webrtc//adapter-7.4.0.min.js"></script>
  34. <script src="./webrtc/srs.sdk.js"></script> -->
  35. <link rel="stylesheet" href="./css/index.cb1a6e05.css" />
  36. <script>
  37. const SERVER_URLS = {
  38. DEV: "wss://sit-eks.xverse.cn/ws",
  39. PROD: "wss://eks.xverse.cn/ws"
  40. }
  41. , REPORT_URL = {
  42. DEV: "https://xa.xverse.cn:6680/collect",
  43. PROD: "https://xa.xverse.cn/collect"
  44. }
  45. , MAX_RECONNECT_COUNT = 3
  46. , DEFAULT_JOINROOM_TIMEOUT = 15e3
  47. , DEFAULT_MAIN_CAMERA_FOV = 50
  48. , DEFAULT_AVATAR_SCALE = 1
  49. , REPORT_NUM_PER_REQUEST = 20
  50. , DEFAULT_OPEN_TIMEOUT_MS = 6e3
  51. , WS_CLOSE_NORMAL = 1e3
  52. , WS_CLOSE_RECONNECT = 3008
  53. , PING_INTERVAL_MS = 1e3
  54. , TEXTURE_URL = "https://static.xverse.cn/qqktv/texture.png"
  55. , REPORT_MODULE_TYPE = "xverse-js"
  56. , authenticationErrorCodes = [3001, 3002, 3003, 3005]
  57. , RTT_MAX_VALUE = 200
  58. , HB_MAX_VALUE = 500
  59. , DURATION = 10
  60. , NET_INTERVAL = 1;
  61. const VERSION$1 = "1.0.75"
  62. , ENV = "production";
  63. const COMPONENT_LIST_PREFIX = "./assets/component_list.json";
  64. const isFunction = i=>typeof i == "function";
  65. const blobToDataURI = async i=>new Promise((e,t)=>{
  66. const r = new FileReader;
  67. r.readAsDataURL(i),
  68. r.onload = function(n) {
  69. var o;
  70. e((o = n.target) == null ? void 0 : o.result)
  71. }
  72. ,
  73. r.onerror = function(n) {
  74. t(n)
  75. }
  76. });
  77. const avatarSetting = {
  78. fileType: ".glb",
  79. lodType: "_lod",
  80. lod: [{
  81. level: "lod0",
  82. fileName: ".glb",
  83. quota: 5,
  84. dist: 1e3
  85. }, {
  86. level: "lod1",
  87. fileName: "_lod2.glb",
  88. quota: 5,
  89. dist: 2e3
  90. }, {
  91. level: "lod2",
  92. fileName: "_lod4.glb",
  93. quota: 0,
  94. dist: 7500
  95. }],
  96. isRayCastEnable: !0,
  97. maxAvatarNum: 40,
  98. maxBillBoardDist: 7500,
  99. body: "body",
  100. head: "head",
  101. hair: "hair",
  102. suit: "suit",
  103. pants: "pants",
  104. shoes: "shoes",
  105. clothes: "clothes",
  106. animations: "animations",
  107. defaultIdle: "Idle",
  108. cullingDistance: 200,
  109. defaultMove: "Walking"
  110. }
  111. , avatarResources = {
  112. ygb: {
  113. name: "ygb",
  114. mat: "NM_ygb",
  115. mesh: "ygb"
  116. }
  117. }
  118. , action = {
  119. GiftClap: {
  120. animName: "GiftClap",
  121. keyTime: 1760
  122. },
  123. Cheering: {
  124. animName: "Cheering",
  125. attachPair: [{
  126. bone: "mixamorig_MiddleFinger2_R",
  127. obj: "ygb",
  128. offset: {
  129. x: 0,
  130. y: 0,
  131. z: 0
  132. },
  133. rotate: {
  134. x: 0,
  135. y: 3.84,
  136. z: 0
  137. },
  138. scale: {
  139. x: 1,
  140. y: 1,
  141. z: 1
  142. }
  143. }, {
  144. bone: "mixamorig_MiddleFinger2_L",
  145. obj: "ygb",
  146. offset: {
  147. x: 0,
  148. y: 0,
  149. z: 0
  150. },
  151. rotate: {
  152. x: 0,
  153. y: 3.49,
  154. z: 0
  155. },
  156. scale: {
  157. x: 1,
  158. y: 1,
  159. z: 1
  160. }
  161. }]
  162. }
  163. }
  164. const checkOS = ()=>{
  165. const i = navigator.userAgent
  166. , e = /(?:Windows Phone)/.test(i)
  167. , t = /(?:SymbianOS)/.test(i) || e
  168. , r = /(?:Android)/.test(i)
  169. , n = /(?:Firefox)/.test(i);
  170. /(?:Chrome|CriOS)/.test(i);
  171. const o = /(?:iPad|PlayBook)/.test(i) || r && !/(?:Mobile)/.test(i) || n && /(?:Tablet)/.test(i)
  172. , a = /(?:iPhone|ipad|ipod)/.test(i) && !o
  173. , s = !a && !r && !t;
  174. return {
  175. isTablet: o,
  176. isPhone: a,
  177. isIOS: /iPhone|iPod|iPad/.test(navigator.userAgent),
  178. isAndroid: r,
  179. isPc: s
  180. }
  181. }
  182. , ue4Rotation2Xverse = i=>isRotationCorrect() ? (i.pitch >= 89.5 ? i.pitch = 89.5 : i.pitch <= -89.5 && (i.pitch = -89.5),
  183. new 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
  184. , ue4Rotation2Xverse_mesh = i=>isRotationCorrect() ? new 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
  185. , scaleFromUE4toXverse = 100
  186. , ue4Scaling2Xverse = i=>isScalingCorrect() ? new Vector3(i.x,i.z,-1 * i.y) : null
  187. , ue4Position2Xverse = i=>isPositionCorrect() ? new Vector3(i.x * .01,i.z * .01,-1 * i.y * .01) : null
  188. , xversePosition2Ue4 = i=>isPositionCorrect() ? {
  189. x: i.x * 100,
  190. y: -1 * i.z * 100,
  191. z: i.y * 100
  192. } : null
  193. , xverseRotation2Ue4 = i=>{
  194. if (isPositionCorrect()) {
  195. let e = 0;
  196. return i.z == 0 ? e = 0 : e = 180 * i.z / Math.PI,
  197. {
  198. pitch: 180 * i.x * -1 / Math.PI,
  199. yaw: (i.y + Math.PI * 27 / 18) * 180 / Math.PI,
  200. roll: e
  201. }
  202. } else
  203. return null
  204. }
  205. , 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))
  206. , 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))
  207. , isPositionCorrect = i=>!0
  208. , isScalingCorrect = i=>!0
  209. , 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))
  210. , isRotationCorrect = i=>!0
  211. , getStringBoundaries = (i,e,t=new Map)=>{
  212. let r = 0
  213. , n = ""
  214. , o = -1
  215. , a = 0;
  216. const s = [0];
  217. for (let l = 0; l < i.length; l++) {
  218. const u = i.codePointAt(l);
  219. let c = t.get(u);
  220. if (c)
  221. r += c,
  222. n += i[l],
  223. u > 64 && u < 91 || u > 96 && u < 123 ? (o == -1 && (o = l),
  224. a += c) : (o = -1,
  225. a = 0);
  226. else if (u < 975 || u > 1024 && u < 1920)
  227. c = 1,
  228. r++,
  229. n += i[l],
  230. u > 64 && u < 91 || u > 96 && u < 123 ? (o == -1 && (o = l),
  231. a += c) : (o = -1,
  232. a = 0);
  233. 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)
  234. c = 2,
  235. r += 2,
  236. o = -1,
  237. a = 0,
  238. n += i[l];
  239. else if (u > 9311 && u < 11158) {
  240. c = 2,
  241. r += 2,
  242. o = -1,
  243. a = 0,
  244. n += i[l];
  245. const h = i.codePointAt(l + 1);
  246. h > 65023 && h < 65040 && (n += i[l + 1],
  247. l++)
  248. } else
  249. u > 126979 && u < 129783 && (c = 2,
  250. r += 2,
  251. o = -1,
  252. a = 0,
  253. l++,
  254. n += String.fromCodePoint(u));
  255. if (l == s[s.length - 1] + 1 && o > 0 ? (s[s.length - 1] = o,
  256. r = 0 + a) : r > e && (s.push(l),
  257. a >= r && (a = 0 + c,
  258. o = 0),
  259. r = 0 + c),
  260. l >= i.length - 1)
  261. break
  262. }
  263. return s[s.length - 1] != i.length && s.push(i.length),
  264. [n, s]
  265. }
  266. const WASM_Version = "h264"
  267. , DECODER_VERSION = "v0.9.3"
  268. , WASM_URLS = {
  269. h264: "https://static.xverse.cn/wasm/v15/lib_ff264dec_no_idb_with_wasm_tbundle.js?tbundle=tmeland_base",
  270. xv265: "https://static.xverse.cn/wasm/codec-release/h265-dec-sw-wasm/v-0-9-1/libxv265dec.js",
  271. h265: ""
  272. }
  273. , STUCK_STAGE_GOOD = 45
  274. , STUCK_STAGE_WELL = 85
  275. , STUCK_STAGE_FAIR = 125
  276. , STUCK_STAGE_BAD = 165
  277. , DECODER_PASSIVE_JITTER = 0;
  278. var De = Object.defineProperty
  279. , Ne = Object.defineProperties;
  280. var we = Object.getOwnPropertyDescriptors;
  281. var be = Object.getOwnPropertySymbols;
  282. var Me = Object.prototype.hasOwnProperty
  283. , Ie = Object.prototype.propertyIsEnumerable;
  284. var Se = (i,e,t)=>e in i ? De(i, e, {
  285. enumerable: !0,
  286. configurable: !0,
  287. writable: !0,
  288. value: t
  289. }) : i[e] = t
  290. , oe = (i,e)=>{
  291. for (var t in e || (e = {}))
  292. Me.call(e, t) && Se(i, t, e[t]);
  293. if (be)
  294. for (var t of be(e))
  295. Ie.call(e, t) && Se(i, t, e[t]);
  296. return i
  297. }
  298. , le = (i,e)=>Ne(i, we(e));
  299. var Oe = (i,e)=>{
  300. var t = {};
  301. for (var r in i)
  302. Me.call(i, r) && e.indexOf(r) < 0 && (t[r] = i[r]);
  303. if (i != null && be)
  304. for (var r of be(i))
  305. e.indexOf(r) < 0 && Ie.call(i, r) && (t[r] = i[r]);
  306. return t
  307. };
  308. </script>
  309. <div id="root">
  310. <div class = "App">
  311. <canvas id = "canvas" class = "stream unselect">
  312. </canvas>
  313. </div>
  314. <div class="debug_control_btns">
  315. <button class="debugger1">Toggle Stats</button>
  316. <button class="debugger2">取消低模着色</button>
  317. <button class="debugger3">画质:高</button>
  318. <button class="font-size-small debugger4" onclick="room.debug.toggleNearbyBreathPoint">Toggle周边呼吸点</button>
  319. <button class="font-size-small debugger5" onclick="room.debug.toggleTapBreathPoint">Toggle点击呼吸点</button>
  320. <button class="font-size-small debugger6" >录制码流(10s)</button>
  321. </div>
  322. </div>
  323. <script type="module">
  324. document.querySelector('.debugger1').onclick = ()=>{
  325. var y, b;
  326. (y = room.stats) != null && y.isShow
  327. ? room.stats.hide()
  328. : (b = room.stats) == null || b.show();
  329. }
  330. document.querySelector('.debugger2').onclick = ()=>{
  331. room.debug.toggleSceneshading(), r(room.debug.isSceneShading);
  332. }
  333. document.querySelector('.debugger3').onclick = ()=>{
  334. let y = "average";
  335. n === "high"
  336. ? (y = "average")
  337. : n === "average"
  338. ? (y = "low")
  339. : n === "low"
  340. ? (y = "high")
  341. : (y = "average"),
  342. o(y),
  343. room.setPictureQualityLevel(y);
  344. }
  345. document.querySelector('.debugger4').onclick = ()=>{
  346. room.debug.toggleNearbyBreathPoint();
  347. }
  348. document.querySelector('.debugger5').onclick = ()=>{
  349. room.debug.toggleTapBreathPoint();
  350. }
  351. document.querySelector('.debugger6').onclick = ()=>{
  352. room.debug.dumpStream(() => {
  353. // toast("\u5F55\u5236\u5B8C\u6210");
  354. });
  355. // toast("\u5F00\u59CB\u5F55\u5236");
  356. }
  357. </script>
  358. <script src="js/index.js"></script>
  359. </body>
  360. </html>