EngineProxy.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. const log$a = new Logger("xverse-bus")
  2. class EngineProxy{
  3. constructor(e) {
  4. E(this, "_tvs", []);
  5. E(this, "isRenderFirstFrame", !1);
  6. E(this, "_idleTime", 0);
  7. E(this, "renderTimer");
  8. E(this, "lightManager");
  9. E(this, "_checkSceneNotReadyCount", 0);
  10. E(this, "_checkSceneDurationFrameNum", 0);
  11. E(this, "_checkSceneFrameCount", 0);
  12. E(this, "timeoutCircularArray", new CircularArray(120,!1,[]));
  13. E(this, "frameCircularArray", new CircularArray(120,!1,[]));
  14. E(this, "interFrameCircularArray", new CircularArray(120,!1,[]));
  15. E(this, "drawCallCntCircularArray", new CircularArray(120,!1,[]));
  16. E(this, "activeFacesCircularArray", new CircularArray(120,!1,[]));
  17. E(this, "renderTimeCircularArray", new CircularArray(120,!1,[]));
  18. E(this, "drawCallTimeCircularArray", new CircularArray(120,!1,[]));
  19. E(this, "animationCircularArray", new CircularArray(120,!1,[]));
  20. E(this, "meshSelectCircularArray", new CircularArray(120,!1,[]));
  21. E(this, "renderTargetCircularArray", new CircularArray(120,!1,[]));
  22. E(this, "regBeforeRenderCircularArray", new CircularArray(120,!1,[]));
  23. E(this, "regAfterRenderCircularArray", new CircularArray(120,!1,[]));
  24. E(this, "renderCnt", 0);
  25. E(this, "renderErrorCount", 0);
  26. E(this, "engineSloppyCnt", 0);
  27. E(this, "systemStuckCnt", 0);
  28. E(this, "frameRenderNumber", 0);
  29. E(this, "_setFPS", (e,t=25)=>{
  30. log$a.info("Set fps to", t);
  31. const r = t > 60 ? 60 : t < 24 ? 24 : t;
  32. e.Engine.stopRenderLoop();
  33. const n = 1e3 / r;
  34. let o = Date.now()
  35. , a = Date.now()
  36. , s = n
  37. , l = 1;
  38. const u = ()=>{
  39. var T;
  40. const c = Date.now()
  41. , h = c - o
  42. , f = c - a;
  43. a = c,
  44. this.frameCircularArray.add(f),
  45. h - s > n && (this.systemStuckCnt += 1);
  46. const d = h / s;
  47. l = .9 * l + .1 * d;
  48. const _ = Date.now();
  49. let g = 0
  50. , m = 0;
  51. if (this.room.isUpdatedRawYUVData || this.room.isPano) {
  52. if (this.isRenderFirstFrame = !0,
  53. this._checkSceneDurationFrameNum > 0)
  54. this._checkSceneFrameCount++,
  55. this.room.sceneManager.isReadyToRender({}) && this._checkSceneDurationFrameNum--,
  56. this._checkSceneFrameCount > ye._CHECK_DURATION && (this._checkSceneDurationFrameNum = ye._CHECK_DURATION,
  57. this._checkSceneFrameCount = 0,
  58. this._checkSceneNotReadyCount++,
  59. (this._checkSceneNotReadyCount == 1 || this._checkSceneNotReadyCount % 100 == 0) && log$a.error(`[SDK] Scene not ready, skip render. loop: ${this._checkSceneNotReadyCount}`),
  60. this._checkSceneNotReadyCount > 10 && (log$a.error("[SDK] Scene not ready, reload later"),
  61. this.room.proxyEvents("renderError", {
  62. error: new Error("[SDK] Scene not ready, skip render and reload.")
  63. })),
  64. this.room.stats.assign({
  65. renderErrorCount: this._checkSceneNotReadyCount
  66. }),
  67. log$a.infoAndReportMeasurement({
  68. value: 0,
  69. startTime: Date.now(),
  70. metric: "renderError",
  71. error: new Error("[SDK] Scene not ready, skip render and reload."),
  72. reportOptions: {
  73. sampleRate: .1
  74. }
  75. }));
  76. else
  77. try {
  78. e.render()
  79. } catch (C) {
  80. this.renderErrorCount++,
  81. this.renderErrorCount > 10 && this.room.proxyEvents("renderError", {
  82. error: C
  83. }),
  84. this.room.stats.assign({
  85. renderErrorCount: this.renderErrorCount
  86. }),
  87. log$a.infoAndReportMeasurement({
  88. value: 0,
  89. startTime: Date.now(),
  90. metric: "renderError",
  91. error: C,
  92. reportOptions: {
  93. sampleRate: .1
  94. }
  95. })
  96. }
  97. g = Date.now() - _,
  98. this.frameRenderNumber < 1e3 && this.frameRenderNumber++,
  99. this.room.networkController.rtcp.workers.UpdateYUV(),
  100. m = Date.now() - _ - g
  101. }
  102. this.isRenderFirstFrame || this.room.networkController.rtcp.workers.UpdateYUV();
  103. const y = Date.now() - _;
  104. o = c + y,
  105. s = Math.min(Math.max((n - y) / l, 5), 200),
  106. y > n && (s = 10,
  107. this.engineSloppyCnt += 1),
  108. this._idleTime = s;
  109. const b = s;
  110. if (s > 150 && console.log("lastGap is ", s, ", ratio is ", l, ", usedTimeMs is ", y, ", cpuRenderTime is ", g, ", cpuUpdateYUVTime is ", m),
  111. this.timeoutCircularArray.add(b),
  112. this.renderCnt % 25 == 0) {
  113. const C = this.frameCircularArray.getAvg()
  114. , A = this.timeoutCircularArray.getAvg()
  115. , S = this.frameCircularArray.getMax()
  116. , P = this.timeoutCircularArray.getMax();
  117. (T = this.room.stats) == null || T.assign({
  118. avgFrameTime: C,
  119. avgTimeoutTime: A,
  120. maxFrameTime: S,
  121. maxTimeoutTime: P,
  122. systemStuckCnt: this.systemStuckCnt
  123. })
  124. }
  125. this.renderTimer = window.setTimeout(u, s)
  126. }
  127. ;
  128. this.renderTimer = window.setTimeout(u, n / l)
  129. }
  130. );
  131. E(this, "updateStats", ()=>{
  132. var e;
  133. (e = this.room.stats) == null || e.assign({
  134. renderFrameTime: this.renderTimeCircularArray.getAvg(),
  135. maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
  136. interFrameTime: this.interFrameCircularArray.getAvg(),
  137. animationTime: this.animationCircularArray.getAvg(),
  138. meshSelectTime: this.meshSelectCircularArray.getAvg(),
  139. drawcallTime: this.drawCallTimeCircularArray.getAvg(),
  140. idleTime: this._idleTime,
  141. registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
  142. registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
  143. renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
  144. fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
  145. drawcall: this.drawCallCntCircularArray.getAvg(),
  146. engineSloppyCnt: this.engineSloppyCnt,
  147. maxInterFrameTime: this.interFrameCircularArray.getMax(),
  148. maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
  149. maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
  150. maxAnimationTime: this.animationCircularArray.getMax(),
  151. maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
  152. maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
  153. maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
  154. avgFrameTime: this.frameCircularArray.getAvg(),
  155. avgTimeoutTime: this.timeoutCircularArray.getAvg(),
  156. maxFrameTime: this.frameCircularArray.getMax(),
  157. maxTimeoutTime: this.timeoutCircularArray.getMax()
  158. })
  159. }
  160. );
  161. this.room = e
  162. }
  163. async initEngine(e) {
  164. await this.updateBillboard(),
  165. log$a.info("engine version:", VERSION$1);
  166. const t = new Logger("engine");
  167. t.setLevel(LoggerLevels.Warn);
  168. const r = {
  169. videoResOriArray: [{
  170. width: 720,
  171. height: 1280
  172. }, {
  173. width: 1280,
  174. height: 720
  175. }, {
  176. width: 480,
  177. height: 654
  178. }, {
  179. width: 654,
  180. height: 480
  181. }, {
  182. width: 1920,
  183. height: 1080
  184. }, {
  185. width: 1080,
  186. height: 1920
  187. }, {
  188. width: 414,
  189. height: 896
  190. }],
  191. forceKeepVertical: this.room.options.objectFit !== "cover",
  192. panoInfo: {
  193. dynamicRange: 1,
  194. width: 4096,
  195. height: 2048
  196. },
  197. shaderMode: EShaderMode.videoAndPano,
  198. yuvInfo: {
  199. width: 1280,
  200. height: 720,
  201. fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
  202. },
  203. cameraParam: {
  204. maxZ: 1e4
  205. },
  206. urlTransformer,
  207. logger: t,
  208. disableWebGL2: this.room.options.disableWebGL2 || !1
  209. }
  210. , n = this.room.options.resolution;
  211. n && (r.videoResOriArray.some(l=>l.width === n.width && l.height === n.height) || r.videoResOriArray.push(n));
  212. const o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
  213. this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high"),
  214. this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]),
  215. this.room.scene = o.Scene,
  216. this.room.breathPointManager = o.breathPointComponent,
  217. this.lightManager = o.lightComponent,
  218. this.registerStats(),
  219. this.setEnv(e),
  220. await this.room.avatarManager.init();
  221. const a = this._createAssetList(e);
  222. await this.loadAssets(a, ""),
  223. this._setFPS(o)
  224. }
  225. pause() {
  226. clearTimeout(this.renderTimer),
  227. log$a.info("Invoke room.pause to pause render");
  228. const e = {
  229. roomId: this.room.id,
  230. effects: [],
  231. lowPolyModels: [],
  232. breathPointsConfig: [],
  233. skinId: this.room.skinId
  234. };
  235. return this.loadAssets(e, this.room.skinId)
  236. }
  237. async resume() {
  238. this._setFPS(this.room.sceneManager),
  239. this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo),
  240. log$a.info("Invoke room.resume to render");
  241. const e = this._createAssetList(this.room.skin);
  242. await this.loadAssets(e, "")
  243. }
  244. setEnv(e) {
  245. var r;
  246. this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent),
  247. e = e || this.room.skin;
  248. const t = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
  249. return t ? (r = this.lightManager) == null ? void 0 : r.setIBL(t.modelUrl) : (log$a.error("env file not found"),
  250. Promise.resolve())
  251. }
  252. async _parseModelsAndLoad(e, t, r) {
  253. log$a.info("Invoke _parseModelsAndLoad start", t);
  254. const n = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"]
  255. , o = new Map;
  256. r == null && (r = "xxxx");
  257. let a = !0;
  258. for (let u = 0; u < e.length; ++u) {
  259. a = !0;
  260. for (let c = 0; c < n.length; ++c)
  261. if (e[u].modelUrl.toLowerCase().indexOf(n[c]) >= 0) {
  262. const h = o.get(n[c]);
  263. h ? (h.push(e[u]),
  264. o.set(n[c], h)) : o.set(n[c], [e[u]]),
  265. a = !1;
  266. break
  267. }
  268. if (a) {
  269. const c = o.get("default");
  270. c ? (c.push(e[u]),
  271. o.set("default", c)) : o.set("default", [e[u]])
  272. }
  273. }
  274. let s = o.get(t) || [];
  275. if (this.room.viewMode === "simple" && (s = s.filter(u=>!u.modelUrl.endsWith("zip"))),
  276. !s)
  277. return Promise.reject(`no invalid scene model with group name: ${t}`);
  278. const l = [];
  279. for (let u = 0; u < s.length; ++u) {
  280. const c = s[u];
  281. if (c.modelUrl.toLowerCase().endsWith("zip"))
  282. c.modelUrl.toLowerCase().endsWith("zip") && l.push(this.room.sceneManager.addNewLowPolyMesh({
  283. url: c.modelUrl,
  284. skinInfo: r
  285. }));
  286. else {
  287. const h = t;
  288. l.push(this.room.sceneManager.addNewLowPolyMesh({
  289. url: c.modelUrl,
  290. group: h,
  291. pick: !0,
  292. skinInfo: r
  293. }))
  294. }
  295. }
  296. return Promise.all(l)
  297. }
  298. async _deleteAssetsLowpolyModel(e) {
  299. this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e),
  300. this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e),
  301. this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
  302. const t = [];
  303. this.room.sceneManager.Scene.meshes.forEach(r=>{
  304. r.xskinInfo == e && t.push(r)
  305. }
  306. ),
  307. t.forEach(r=>{
  308. r.dispose(!1, !1)
  309. }
  310. )
  311. }
  312. async loadLandAssets() {
  313. const e = this._createAssetList(this.room.skin);
  314. return this.loadAssets(e, this.room.skinId).catch(()=>this.loadAssets(e, this.room.skinId))
  315. }
  316. async loadAssets(e, t="", r=8e3) {
  317. const n = Date.now();
  318. return this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError(`loadAssets timeout(${r}ms)`)).then(o=>(log$a.infoAndReportMeasurement({
  319. tag: "loadAssets",
  320. startTime: n,
  321. metric: "loadAssets"
  322. }),
  323. o)).catch(o=>(log$a.infoAndReportMeasurement({
  324. tag: "loadAssets",
  325. startTime: n,
  326. metric: "loadAssets",
  327. error: o
  328. }),
  329. Promise.reject(o)))
  330. }
  331. async _loadAssets(e, t="") {
  332. try {
  333. const r = [];
  334. r.push(this._loadAssetsLowpolyModel(e, t)),
  335. await Promise.all(r),
  336. await this.setEnv(),
  337. this._checkSceneDurationFrameNum = ye._CHECK_DURATION,
  338. this._checkSceneNotReadyCount = 0,
  339. this._checkSceneFrameCount = 0,
  340. this.updateAnimationList(),
  341. this.room.loadAssetsHook()
  342. } catch (r) {
  343. return Promise.reject(r)
  344. }
  345. }
  346. updateAnimationList() {
  347. if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
  348. const e = this.room.skin.animationList;
  349. if (!e)
  350. return;
  351. e.forEach(t=>{
  352. this.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId)
  353. }
  354. )
  355. }
  356. }
  357. async _loadAssetsLowpolyModel(e, t="") {
  358. const r = []
  359. , n = []
  360. , o = [];
  361. e.lowPolyModels.forEach(f=>{
  362. f.group === "TV" ? n.push({
  363. id: "",
  364. name: "",
  365. thumbnailUrl: "",
  366. typeName: AssetTypeName.Model,
  367. className: AssetClassName.Tv,
  368. modelUrl: f.url
  369. }) : f.group === "\u544A\u767D\u5899" ? o.push({
  370. id: "",
  371. name: "",
  372. thumbnailUrl: "",
  373. typeName: AssetTypeName.Model,
  374. className: AssetClassName.Lpm,
  375. modelUrl: f.url
  376. }) : r.push({
  377. id: "",
  378. name: "",
  379. thumbnailUrl: "",
  380. typeName: AssetTypeName.Model,
  381. className: AssetClassName.Lpm,
  382. modelUrl: f.url
  383. })
  384. }
  385. ),
  386. t != "" && t != null && this._deleteAssetsLowpolyModel(t);
  387. const a = e.skinId;
  388. log$a.info("====> from ", t, " to ", a),
  389. this._tvs.forEach(f=>f.clean()),
  390. this._tvs = [];
  391. let s = EFitMode.cover;
  392. a == "10048" && (s = EFitMode.contain),
  393. Array.isArray(n) && n.forEach((f,d)=>{
  394. this._tvs.push(new TV("squareTv" + d,f.modelUrl,this.room,{
  395. fitMode: s
  396. }))
  397. }
  398. ),
  399. e.breathPointsConfig.forEach(async f=>{
  400. let d;
  401. try {
  402. d = await urlTransformer(f.imageUrl)
  403. } catch (_) {
  404. d = f.imageUrl,
  405. log$a.error("urlTransformer error", _)
  406. }
  407. this.room.breathPointManager.addBreathPoint({
  408. id: f.id,
  409. position: f.position,
  410. spriteSheet: d,
  411. rotation: f.rotation || {
  412. pitch: 0,
  413. yaw: 270,
  414. roll: 0
  415. },
  416. billboardMode: !0,
  417. type: f.type || "no_type",
  418. spriteWidthNumber: f.spriteWidthNum || 1,
  419. spriteHeightNumber: f.spriteHeightNum || 1,
  420. maxVisibleRegion: f.maxVisibleRegion || 150,
  421. width: f.width,
  422. height: f.height,
  423. skinInfo: f.skinId
  424. })
  425. }
  426. ),
  427. o.forEach(f=>{
  428. this.room.sceneManager.decalComponent.addDecal({
  429. id: f.id || "gbq",
  430. meshPath: f.modelUrl,
  431. skinInfo: a
  432. })
  433. }
  434. );
  435. const u = this.room.sceneManager.staticmeshComponent.lowModel_group
  436. , c = Array.from(u.keys()).filter(f=>!f.startsWith("region_"))
  437. , h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
  438. return new Promise((f,d)=>{
  439. Promise.all(h.map(_=>this._parseModelsAndLoad(r, _, a))).then(()=>{
  440. let _ = !1;
  441. r.forEach(v=>{
  442. v.modelUrl.endsWith("zip") && (_ = !0)
  443. }
  444. ),
  445. _ == !1 && this.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(),
  446. this.room.sceneManager.staticmeshComponent.lowModel_group;
  447. const g = Array.from(u.keys()).filter(v=>!v.startsWith("region_"))
  448. , m = c.filter(v=>g.indexOf(v) < 0);
  449. m.length > 0 && m.forEach(v=>{
  450. this.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(v)
  451. }
  452. ),
  453. f(!0)
  454. }
  455. ).catch(_=>{
  456. d(_)
  457. }
  458. )
  459. }
  460. )
  461. }
  462. async _updateSkinAssets(e) {
  463. const t = this.room.lastSkinId
  464. , r = await this.room.getSkin(e)
  465. , n = this._createAssetList(r);
  466. try {
  467. await this.loadAssets(n, t),
  468. this.room.updateCurrentState({
  469. versionId: r.versionId,
  470. skinId: r.id,
  471. skin: r
  472. })
  473. } catch {
  474. await this.loadAssets(n, t),
  475. this.room.updateCurrentState({
  476. versionId: r.versionId,
  477. skinId: r.id,
  478. skin: r
  479. })
  480. }
  481. this.setEnv(r)
  482. }
  483. _createAssetList(e) {
  484. const t = []
  485. , r = []
  486. , n = [];
  487. let o = e.models;
  488. const a = this.room.modelManager.config.preload;
  489. return this.room.viewMode === "simple" ? a && (o = a.baseUrls.map(l=>(l.modelUrl = l.url,
  490. l))) : this.room.viewMode,
  491. ModelManager.findModels(o, AssetTypeName.Effects, AssetClassName.Effects).forEach(l=>{
  492. t.push({
  493. url: l.modelUrl,
  494. group: l.className,
  495. name: l.name
  496. })
  497. }
  498. ),
  499. ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Lpm).forEach(l=>{
  500. r.push({
  501. url: l.modelUrl,
  502. group: l.className
  503. })
  504. }
  505. ),
  506. ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Gbq).forEach(l=>{
  507. r.push({
  508. url: l.modelUrl,
  509. group: l.className
  510. })
  511. }
  512. ),
  513. ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Tv).forEach(l=>{
  514. r.push({
  515. url: l.modelUrl,
  516. group: l.className
  517. })
  518. }
  519. ),
  520. [].forEach(l=>{
  521. l.skinId == e.id && n.push(l)
  522. }
  523. ),
  524. {
  525. roomId: this.room.id,
  526. effects: t,
  527. lowPolyModels: r,
  528. breathPointsConfig: n,
  529. skinId: e.id
  530. }
  531. }
  532. registerStats() {
  533. const e = this.room.sceneManager;
  534. this.room.scene.registerAfterRender(()=>{
  535. var I;
  536. const t = e.statisticComponent.getInterFrameTimeCounter()
  537. , r = e.statisticComponent.getDrawCall()
  538. , n = e.statisticComponent.getActiveFaces()
  539. , o = e.statisticComponent.getFrameTimeCounter()
  540. , a = e.statisticComponent.getDrawCallTime()
  541. , s = e.statisticComponent.getAnimationTime()
  542. , l = e.statisticComponent.getActiveMeshEvaluationTime()
  543. , u = e.statisticComponent.getRenderTargetRenderTime()
  544. , c = e.statisticComponent.getRegisterBeforeRenderTime()
  545. , h = e.statisticComponent.getRegisterAfterRenderTime()
  546. , f = e.statisticComponent.getActiveParticles()
  547. , d = e.statisticComponent.getActiveBones()
  548. , _ = e.Scene._activeAnimatables.length
  549. , g = e.statisticComponent.getTotalRootNodes()
  550. , m = e.Scene.geometries.length
  551. , v = e.Scene.onBeforeRenderObservable.observers.length
  552. , y = e.Scene.onAfterRenderObservable.observers.length
  553. , b = e.statisticComponent.getTotalMeshes()
  554. , T = e.statisticComponent.getTotalTextures()
  555. , C = e.statisticComponent.getTotalMaterials()
  556. , A = e.statisticComponent.getSystemInfo()
  557. , S = A.resolution
  558. , P = A.driver;
  559. A.vender;
  560. const R = A.version
  561. , M = A.hardwareScalingLevel
  562. , x = S + "_" + P + "_" + R + "_" + M;
  563. this.interFrameCircularArray.add(t),
  564. this.renderTimeCircularArray.add(o),
  565. this.animationCircularArray.add(s),
  566. this.meshSelectCircularArray.add(l),
  567. this.drawCallTimeCircularArray.add(a),
  568. this.regAfterRenderCircularArray.add(h),
  569. this.regBeforeRenderCircularArray.add(c),
  570. this.renderTargetCircularArray.add(u),
  571. this.drawCallCntCircularArray.add(r),
  572. this.renderCnt += 1,
  573. this.renderCnt % 25 == 0 && ((I = this.room.stats) == null || I.assign({
  574. renderFrameTime: this.renderTimeCircularArray.getAvg(),
  575. maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
  576. interFrameTime: this.interFrameCircularArray.getAvg(),
  577. animationTime: this.animationCircularArray.getAvg(),
  578. meshSelectTime: this.meshSelectCircularArray.getAvg(),
  579. drawcallTime: this.drawCallTimeCircularArray.getAvg(),
  580. idleTime: this._idleTime,
  581. registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
  582. registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
  583. renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
  584. fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
  585. drawcall: this.drawCallCntCircularArray.getAvg(),
  586. triangle: n.toString(),
  587. engineSloppyCnt: this.engineSloppyCnt,
  588. maxInterFrameTime: this.interFrameCircularArray.getMax(),
  589. maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
  590. maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
  591. maxAnimationTime: this.animationCircularArray.getMax(),
  592. maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
  593. maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
  594. maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
  595. activeParticles: f,
  596. activeBones: d,
  597. activeAnimation: _,
  598. totalMeshes: b,
  599. totalRootNodes: g,
  600. totalGeometries: m,
  601. totalTextures: T,
  602. totalMaterials: C,
  603. registerBeforeCount: v,
  604. registerAfterCount: y,
  605. hardwareInfo: x
  606. }))
  607. }
  608. )
  609. }
  610. async updateBillboard() {
  611. const {options: {skinId: e}} = this.room
  612. , r = (await this.room.modelManager.findAssetList(e)).filter(a=>a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble)
  613. , n = ["bubble01", "bubble02", "bubble03"]
  614. , o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
  615. if (r.length) {
  616. const a = r.filter(l=>n.includes(l.name)).map(l=>l.url)
  617. , s = r.filter(l=>o.includes(l.name)).map(l=>l.url);
  618. a.length && (XBillboardManager.userBubbleUrls = a),
  619. s.length && (XBillboardManager.npcBubbleUrls = s)
  620. }
  621. }
  622. }
  623. ;