index.html 12 KB

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