index.html 26 KB

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