index.html 26 KB

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