XStaticMeshComponent.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. const log$u = new Logger$1("XStaticMeshComponent")
  2. class XStaticMeshComponent{
  3. constructor(e) {
  4. E(this, "scene");
  5. E(this, "_staticmeshes");
  6. E(this, "_lowModel_group");
  7. E(this, "_CgPlane");
  8. E(this, "_rootDir");
  9. E(this, "_abosoluteUrl");
  10. E(this, "_partMeshSkinInfo");
  11. E(this, "_meshInfoJson");
  12. E(this, "_orijson");
  13. E(this, "_notUsedRegionLists");
  14. E(this, "_meshInfoKeys");
  15. E(this, "_currentUpdateRegionCount");
  16. E(this, "_currentMeshUsedLod");
  17. E(this, "_currentPartGroup");
  18. E(this, "_allowRegionUpdate");
  19. E(this, "_allowRegionForceLod");
  20. E(this, "_forceLod");
  21. E(this, "_scenemanager");
  22. E(this, "regionIdInCamera");
  23. E(this, "regionIdInCameraConst");
  24. E(this, "_cameraInRegionId");
  25. E(this, "_meshVis");
  26. E(this, "_doMeshVisChangeNumber");
  27. E(this, "_meshVisTypeName");
  28. E(this, "_visCheckDurationFrameNumber");
  29. E(this, "_regionLodRule");
  30. E(this, "reg_staticmesh_partupdate", ()=>{
  31. if (this._allowRegionUpdate && (this.scene.getFrameId(),
  32. this._meshUpdateFrame()),
  33. this._allowRegionForceLod) {
  34. this.scene.getFrameId() % 2 == 0 && this.setOneRegionLod(this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length].toString(), this._forceLod);
  35. let t = !0;
  36. const r = Array.from(this._currentMeshUsedLod.keys());
  37. if (r.length > 0) {
  38. for (let n = 0; n < r.length; ++n)
  39. this._currentMeshUsedLod.get(r[n]) != this._forceLod && (t = !1);
  40. t && (this._allowRegionForceLod = !1)
  41. }
  42. }
  43. }
  44. );
  45. E(this, "setMeshInfo", (e,t="")=>{
  46. this._abosoluteUrl != e && (this._abosoluteUrl.length > 0 && this.deleteLastRegionMesh(),
  47. this._partMeshSkinInfo = t,
  48. this._abosoluteUrl = e,
  49. this._rootDir = this._abosoluteUrl.slice(0, -4) + "/",
  50. this.parseJson(this._rootDir + "meshInfo.json").then(()=>{
  51. this.startMeshUpdate()
  52. }
  53. ))
  54. }
  55. );
  56. E(this, "_meshUpdateFrame", ()=>{
  57. {
  58. let e = this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length];
  59. const t = !0;
  60. let r = 3;
  61. if (this._scenemanager != null && this._scenemanager.cameraComponent != null) {
  62. const n = this._getMainPlayerPosition();
  63. if (n != null) {
  64. if (this._cameraInRegionId >= 0) {
  65. const a = this.getRegionIdWhichIncludeCamera(n);
  66. (this._cameraInRegionId != a || this.regionIdInCamera.length == 0) && (this._cameraInRegionId = a,
  67. this.regionIdInCamera = this._getNeighborId(this._cameraInRegionId.toString()),
  68. this.regionIdInCameraConst = this.regionIdInCamera.slice());
  69. let s = this.regionIdInCamera.pop();
  70. for (; s != null; )
  71. if (this._notUsedRegionLists.indexOf(s) >= 0)
  72. s = this.regionIdInCamera.pop();
  73. else
  74. break;
  75. s != null && (e = s.toString())
  76. } else
  77. this._cameraInRegionId = this.getRegionIdWhichIncludeCamera(n);
  78. if (this._currentMeshUsedLod.size == 0 || this._notUsedRegionLists.indexOf(parseInt(e)) >= 0) {
  79. e = this._cameraInRegionId.toString();
  80. const a = this._getNeighborId(e);
  81. for (; a.length == 0 && (e = this.getNearestRegionIdWithCamera(n).toString()),
  82. this._notUsedRegionLists.indexOf(parseInt(e)) >= 0; )
  83. e = a.pop().toString()
  84. }
  85. const o = this._meshInfoJson[this._cameraInRegionId.toString()].lod;
  86. r = 3,
  87. this._cameraInRegionId.toString() == e ? r = this._regionLodRule[0] : o[0].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[1] : o[1].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[2] : o[2].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[3] : r = this._regionLodRule[4]
  88. }
  89. }
  90. this.setOneRegionLod(e, r, t),
  91. this.updateRegionNotInLocalNeighbor(),
  92. this.cleanRootNodes()
  93. }
  94. }
  95. );
  96. E(this, "updateRegionNotInLocalNeighbor", ()=>{
  97. Array.from(this._currentMeshUsedLod.keys()).forEach(t=>{
  98. this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && this.setOneRegionLod(t, -1)
  99. }
  100. )
  101. }
  102. );
  103. E(this, "cleanRootNodes", ()=>{
  104. if (this.scene.getFrameId() % 3 == 0) {
  105. const e = [];
  106. this.scene.rootNodes.forEach(t=>{
  107. (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && e.push(t)
  108. }
  109. ),
  110. e.forEach(t=>{
  111. t.dispose()
  112. }
  113. )
  114. }
  115. }
  116. );
  117. E(this, "setOneRegionLod", (e,t,r=!0)=>{
  118. this._currentUpdateRegionCount++;
  119. const n = this._calHashCode(this._rootDir)
  120. , o = "region_" + n + "_" + e;
  121. if (t < 0) {
  122. this._currentMeshUsedLod.has(e) && (this._currentMeshUsedLod.delete(e),
  123. this._currentPartGroup.delete(o),
  124. this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
  125. return
  126. }
  127. const a = this._rootDir + e + "_lod" + t + "_xverse.glb"
  128. , s = this._currentMeshUsedLod.get(e);
  129. this._currentPartGroup.add(o),
  130. s != null ? s != t && (this._currentMeshUsedLod.set(e, t),
  131. this._scenemanager.addNewLowPolyMesh({
  132. url: a,
  133. group: "region_" + n + "_" + e,
  134. pick: !0,
  135. lod: t,
  136. skinInfo: this._partMeshSkinInfo
  137. }, [{
  138. group: "region_" + n + "_" + e,
  139. mode: 0
  140. }])) : (this._currentMeshUsedLod.set(e, t),
  141. this._scenemanager.addNewLowPolyMesh({
  142. url: a,
  143. group: "region_" + n + "_" + e,
  144. pick: !0,
  145. lod: t,
  146. skinInfo: this._partMeshSkinInfo
  147. }))
  148. }
  149. );
  150. E(this, "checkPointInView", ({x: e, y: t, z: r})=>{
  151. const n = ue4Position2Xverse({
  152. x: e,
  153. y: t,
  154. z: r
  155. });
  156. if (!n)
  157. return !1;
  158. for (let o = 0; o < 6; o++)
  159. if (this.scene.frustumPlanes[o].dotCoordinate(n) < 0)
  160. return !1;
  161. return !0
  162. }
  163. );
  164. E(this, "addNewLowPolyMesh", (e,t,r)=>{
  165. if (!e.url.endsWith("glb") && !e.url.startsWith("blob:"))
  166. return e.url.endsWith("zip") ? (this.setMeshInfo(e.url, e.skinInfo),
  167. Promise.resolve(!0)) : (log$u.error("[Engine] input model path is error! ", e.url),
  168. Promise.reject(new XLowpolyModelError("[Engine] input model path is error! " + e.url)));
  169. {
  170. const n = e.url;
  171. return new Promise((o,a)=>this._scenemanager.urlTransformer(e.url).then(s=>{
  172. e.url = s;
  173. const l = new XStaticMeshFromOneGltf(this.scene,e)
  174. , u = Date.now();
  175. return new Promise((c,h)=>{
  176. l.loadMesh(r, !0).then(f=>{
  177. const d = Date.now();
  178. if (this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(d - u),
  179. f == !0) {
  180. const _ = this.getLowModelType(e);
  181. let g = 0;
  182. if (this._lowModel_group.has(_) && (g = this._lowModel_group.get(_).length),
  183. r != null && this._scenemanager.currentShader != null && this._scenemanager.currentShader.name != r.name && l.setMaterial(this._scenemanager.currentShader),
  184. this._allowRegionUpdate == !1 && _.startsWith("region_"))
  185. l.dispose();
  186. else if (this._staticmeshes.push(l),
  187. this.lowmodelGroupMapAddValue(_, l),
  188. t != null && t.length > 0) {
  189. const m = [];
  190. for (let v = 0; v < t.length; ++v)
  191. m.push(t[v].group),
  192. this.updateLowModelGroup(t[v], _, g)
  193. }
  194. this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - d),
  195. c(!0)
  196. } else
  197. h(new XLowpolyModelError("[Engine] after lowmodel error!"))
  198. }
  199. ).catch(f=>{
  200. log$u.error("[Engine] load Mesh [" + n + "] error! " + f),
  201. h(new XLowpolyModelError(`[Engine] load Mesh [${n}] error! ${f}`))
  202. }
  203. )
  204. }
  205. )
  206. }
  207. ).then(s=>{
  208. s == !0 ? (log$u.info(`[Engine] load Mesh [${n}] successfully.`),
  209. o(!0)) : a(!1)
  210. }
  211. ).catch(s=>{
  212. log$u.error("[Engine] addNewLowPolyMesh [" + n + "] error! " + s),
  213. a(new XLowpolyModelError(`[Engine] addNewLowPolyMesh [${n}] error! ${s}`))
  214. }
  215. ))
  216. }
  217. }
  218. );
  219. E(this, "toggleLowModelVisibility", e=>{
  220. const {vis: t, groupName: r="", skinInfo: n=""} = e;
  221. this._meshVis = t,
  222. this._meshVisTypeName = {
  223. groupName: r,
  224. skinInfo: n
  225. },
  226. this._doMeshVisChangeNumber = 0,
  227. r == Te.ALL_MESHES || this._currentPartGroup.has(r) == !0 || this._partMeshSkinInfo == n ? t == !1 ? (this._visCheckDurationFrameNumber = 100,
  228. this.stopMeshUpdate()) : (this._visCheckDurationFrameNumber = 1,
  229. this.startMeshUpdate()) : this._visCheckDurationFrameNumber = 1
  230. }
  231. );
  232. E(this, "reg_staticmesh_visibility", ()=>{
  233. if (this._doMeshVisChangeNumber >= 0)
  234. if (this._doMeshVisChangeNumber < this._visCheckDurationFrameNumber)
  235. if (this._doMeshVisChangeNumber = this._doMeshVisChangeNumber + 1,
  236. this._meshVisTypeName.groupName == Te.ALL_MESHES)
  237. this._lowModel_group.forEach((e,t)=>{
  238. for (let r = 0, n = e.length; r < n; ++r)
  239. e[r].toggleVisibility(this._meshVis)
  240. }
  241. );
  242. else {
  243. if (this._lowModel_group.has(this._meshVisTypeName.groupName))
  244. for (let e = 0; e < this._lowModel_group.get(this._meshVisTypeName.groupName).length; ++e)
  245. this._lowModel_group.get(this._meshVisTypeName.groupName)[e].toggleVisibility(this._meshVis);
  246. if (this._meshVisTypeName.skinInfo != "")
  247. for (let e = 0; e < this._staticmeshes.length; ++e)
  248. this._staticmeshes[e].skinInfo == this._meshVisTypeName.skinInfo && this._staticmeshes[e].toggleVisibility(this._meshVis)
  249. }
  250. else
  251. this._meshVis = !0,
  252. this._meshVisTypeName = {
  253. groupName: "",
  254. skinInfo: ""
  255. },
  256. this._doMeshVisChangeNumber = -1
  257. }
  258. );
  259. E(this, "_getMeshesByCustomProperty", (e,t)=>{
  260. let r = [];
  261. return this._staticmeshes.forEach(n=>{
  262. n[e] != null && n[e] == t && (r = r.concat(n.meshes))
  263. }
  264. ),
  265. r
  266. }
  267. );
  268. this._lowModel_group = new Map,
  269. this._staticmeshes = [],
  270. this._meshInfoJson = null,
  271. this._meshInfoKeys = [],
  272. this._currentUpdateRegionCount = 0,
  273. this._abosoluteUrl = "",
  274. this._partMeshSkinInfo = "",
  275. this._forceLod = 3,
  276. this._allowRegionUpdate = !1,
  277. this._allowRegionForceLod = !1,
  278. this._currentMeshUsedLod = new Map,
  279. this._currentPartGroup = new Set,
  280. this._scenemanager = e,
  281. this.scene = e.Scene,
  282. this.regionIdInCamera = [],
  283. this.regionIdInCameraConst = [],
  284. this._cameraInRegionId = -1,
  285. this._rootDir = "",
  286. this._meshVis = !0,
  287. this._meshVisTypeName = {
  288. groupName: "",
  289. skinInfo: ""
  290. },
  291. this._doMeshVisChangeNumber = -1,
  292. this._visCheckDurationFrameNumber = -1,
  293. this._regionLodRule = [0, 1, 3, 3, -1],
  294. this.initCgLowModel(),
  295. this._regionPartLoop()
  296. }
  297. get cameraInRegionId() {
  298. return this._cameraInRegionId
  299. }
  300. setRegionLodRule(e) {
  301. return e.length != 5 ? !1 : (e.forEach(t=>{}
  302. ),
  303. this._regionLodRule = e,
  304. !0)
  305. }
  306. get lowModel_group() {
  307. return this._lowModel_group
  308. }
  309. _regionPartLoop() {
  310. this.scene.registerBeforeRender(this.reg_staticmesh_partupdate),
  311. this.scene.registerAfterRender(this.reg_staticmesh_visibility)
  312. }
  313. _globalSearchCameraInWhichRegion(e, t) {
  314. let r = -1;
  315. for (let n = 0; n < t.length; ++n) {
  316. const o = this._meshInfoJson[t[n].toString()].boundingbox
  317. , a = o[0]
  318. , s = o[1];
  319. if (e.x >= a[0] && e.x <= s[0] && e.y >= a[1] && e.y <= s[1] && e.z >= a[2] && e.z <= s[2] || e.x >= s[0] && e.x <= a[0] && e.y >= s[1] && e.y <= a[1] && e.z >= s[2] && e.z <= a[2]) {
  320. r = parseInt(t[n].toString());
  321. break
  322. }
  323. }
  324. return r
  325. }
  326. getRegionIdByPosition(e) {
  327. return this.getRegionIdWhichIncludeCamera(e)
  328. }
  329. getRegionIdWhichIncludeCamera(e) {
  330. let t = -1;
  331. if (this._allowRegionUpdate == !1)
  332. return t;
  333. if (this._cameraInRegionId == -1 ? t = this._globalSearchCameraInWhichRegion(e, this._meshInfoKeys) : (t = this._globalSearchCameraInWhichRegion(e, this.regionIdInCameraConst),
  334. t == -1 && (t = this._globalSearchCameraInWhichRegion(e, this._meshInfoKeys))),
  335. t == -1) {
  336. let r = 1e7;
  337. for (let n = 0; n < this._meshInfoKeys.length; ++n) {
  338. const o = this._meshInfoJson[this._meshInfoKeys[n]].center
  339. , a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  340. r > a && (r = a,
  341. t = parseInt(this._meshInfoKeys[n]))
  342. }
  343. }
  344. return t
  345. }
  346. getNearestRegionIdWithCamera(e) {
  347. let t = 1
  348. , r = 1e7;
  349. for (let n = 0; n < this._meshInfoKeys.length; ++n) {
  350. if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[n])) >= 0)
  351. continue;
  352. const o = this._meshInfoJson[this._meshInfoKeys[n]].center
  353. , a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  354. r > a && (r = a,
  355. t = parseInt(this._meshInfoKeys[n]))
  356. }
  357. return t
  358. }
  359. _getNeighborId(e) {
  360. const t = this._meshInfoJson[e].lod;
  361. let r = [];
  362. const n = Object.keys(t);
  363. for (let o = n.length - 1; o >= 0; --o)
  364. r = r.concat(t[n[o]]);
  365. return r.push(parseInt(e)),
  366. r
  367. }
  368. _getMainPlayerPosition() {
  369. const e = this._scenemanager.cameraComponent.getCameraPose().position
  370. , t = this._scenemanager.avatarComponent.getMainAvatar();
  371. if (t != null && t != null) {
  372. const r = t.position;
  373. if (r != null)
  374. return r
  375. }
  376. return e
  377. }
  378. _calHashCode(e) {
  379. return hashCode(e) + "_" + this._partMeshSkinInfo
  380. }
  381. forceAllRegionLod(e=3) {
  382. e < 0 && (e = 0),
  383. e > 3 && (e = 3),
  384. this.stopMeshUpdate(),
  385. this._allowRegionForceLod = !0,
  386. this._forceLod = e
  387. }
  388. deleteLastRegionMesh() {
  389. if (this._rootDir != "") {
  390. const e = this._calHashCode(this._rootDir);
  391. this._currentMeshUsedLod.clear(),
  392. this._currentPartGroup.clear(),
  393. this._meshInfoJson = null,
  394. this._meshInfoKeys = [],
  395. this._currentUpdateRegionCount = 0,
  396. this._orijson = null,
  397. this._notUsedRegionLists = [],
  398. this._partMeshSkinInfo = "",
  399. this._abosoluteUrl = "",
  400. this.stopMeshUpdate(),
  401. this.deleteMeshesByCustomProperty("group", "region_" + e, !0)
  402. }
  403. }
  404. startMeshUpdate() {
  405. this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0)
  406. }
  407. stopMeshUpdate() {
  408. this._allowRegionUpdate = !1
  409. }
  410. parseJson(e) {
  411. return new Promise((t,r)=>this._scenemanager.urlTransformer(e).then(n=>{
  412. const o = new XMLHttpRequest;
  413. o.open("get", n),
  414. o.send(null),
  415. o.onload = ()=>{
  416. if (o.status == 200) {
  417. const a = JSON.parse(o.responseText);
  418. this._orijson = a,
  419. this._meshInfoJson = this._orijson.usedRegion,
  420. this._notUsedRegionLists = this._orijson.notUsedRegion,
  421. this._meshInfoKeys = Object.keys(this._meshInfoJson),
  422. log$u.info("[Engine] parse zip mesh info successful"),
  423. t()
  424. }
  425. }
  426. ,
  427. o.onerror = ()=>{
  428. log$u.error(`[Engine] load zip mesh info json error, (provided by blob): ${n}`),
  429. r(new XLowpolyJsonError(`[Engine] load zip mesh info json error, (provided by blob): ${n}`))
  430. }
  431. }
  432. ).catch(n=>{
  433. log$u.error(`[Engine] load zip mesh info json error: ${n}, link:${e}`),
  434. r(new XLowpolyJsonError(`[Engine] load zip mesh info json error: ${n}, link: ${e}`))
  435. }
  436. ))
  437. }
  438. initCgLowModel() {
  439. const e = MeshBuilder.CreatePlane("CgPlane", {
  440. size: 400
  441. });
  442. e.position = new Vector3(0,1010,0),
  443. e.rotation = new Vector3(3 * Math.PI / 2,0,0),
  444. this._CgPlane = new XStaticMesh({
  445. id: "CgPlane",
  446. mesh: e,
  447. xtype: EMeshType.Cgplane
  448. }),
  449. this._CgPlane.hide()
  450. }
  451. getLowModelType(e) {
  452. let t = "";
  453. return e.group != null ? t = e.group : t = "default",
  454. t
  455. }
  456. lowmodelGroupMapAddValue(e, t) {
  457. const r = this._lowModel_group.get(e);
  458. r != null ? (r.push(t),
  459. this._lowModel_group.set(e, r)) : this._lowModel_group.set(e, [t])
  460. }
  461. updateLowModelGroup(e, t, r) {
  462. let n = r;
  463. e.group == t || (n = -1),
  464. e.mode == 0 ? this.deleteLowModelGroup(e.group, n) : e.mode == 1 ? this.toggleVisibleLowModelGroup(!1, e.group, n) : e.mode == 2 && this.toggleVisibleLowModelGroup(!0, e.group, n)
  465. }
  466. toggleVisibleLowModelGroup(e, t, r=-1) {
  467. if (this._lowModel_group.has(t)) {
  468. const n = this._lowModel_group.get(t);
  469. let o = n.length;
  470. r >= 0 && o >= r && (o = r);
  471. for (let a = 0; a < o; ++a)
  472. n[a].toggleVisibility(e)
  473. }
  474. }
  475. deleteLowModelGroup(e, t=-1) {
  476. if (this._lowModel_group.has(e)) {
  477. const o = this._lowModel_group.get(e);
  478. let a = o.length;
  479. t >= 0 && a >= t && (a = t);
  480. for (let s = 0; s < a; ++s)
  481. o[s].dispose();
  482. t >= 0 ? this._lowModel_group.set(e, this._lowModel_group.get(e).slice(a)) : this._lowModel_group.delete(e)
  483. }
  484. const r = this._lowModel_group.get(e)
  485. , n = [];
  486. r != null && r.length > 0 ? this._staticmeshes.forEach(o=>{
  487. if (o.group != e)
  488. n.push(o);
  489. else
  490. for (let a = 0; a < r.length; ++a)
  491. o.groupUuid == r[a].groupUuid && n.push(o)
  492. }
  493. ) : this._staticmeshes.forEach(o=>{
  494. o.group != e && n.push(o)
  495. }
  496. ),
  497. this._staticmeshes = n
  498. }
  499. deleteMeshesByGroup(e) {
  500. this.deleteLowModelGroup(e)
  501. }
  502. deleteMeshesById(e) {
  503. this.deleteMeshesByCustomProperty("id", e)
  504. }
  505. deleteMeshesByLoD(e) {
  506. this.deleteMeshesByCustomProperty("lod", e)
  507. }
  508. deleteMeshesBySkinInfo(e) {
  509. this.deleteMeshesByCustomProperty("skinInfo", e)
  510. }
  511. removeMeshesFromSceneByGroup(e) {
  512. this.removeMeshesFromSceneByCustomProperty("group", e)
  513. }
  514. removeMeshesFromSceneById(e) {
  515. this.removeMeshesFromSceneByCustomProperty("id", e)
  516. }
  517. addMeshesToSceneByGroup(e) {
  518. this.addMeshesToSceneByCustomProperty("group", e)
  519. }
  520. addMeshesToSceneById(e) {
  521. this.addMeshesToSceneByCustomProperty("id", e)
  522. }
  523. removeMeshesFromSceneByCustomProperty(e, t, r=!1) {
  524. this._staticmeshes.forEach(n=>{
  525. n.isinscene && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.removeFromScene() : n[e] != t || n.removeFromScene())
  526. }
  527. )
  528. }
  529. addMeshesToSceneByCustomProperty(e, t, r=!1) {
  530. this._staticmeshes.forEach(n=>{
  531. n.isinscene == !1 && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.addToScene() : n[e] != t || n.addToScene())
  532. }
  533. )
  534. }
  535. deleteMeshesByCustomProperty(e, t, r=!1) {
  536. const n = [];
  537. this._staticmeshes.forEach(a=>{
  538. a[e] != null && (r ? a[e].indexOf(t) < 0 ? n.push(a) : a.dispose() : a[e] != t ? n.push(a) : a.dispose())
  539. }
  540. ),
  541. this._staticmeshes = n;
  542. const o = Array.from(this._lowModel_group.keys());
  543. for (let a = 0; a < o.length; ++a) {
  544. const s = o[a]
  545. , l = this._lowModel_group.get(s);
  546. if (l != null) {
  547. const u = [];
  548. for (let c = 0; c < l.length; ++c)
  549. l[c][e] != null && (r ? l[c][e].indexOf(t) < 0 && u.push(l[c]) : l[c][e] != t && u.push(l[c]));
  550. u.length > 0 ? this._lowModel_group.set(s, u) : this._lowModel_group.delete(s)
  551. }
  552. }
  553. }
  554. getMeshes() {
  555. let e = [];
  556. for (let t = 0; t < this._staticmeshes.length; ++t)
  557. e = e.concat(this._staticmeshes[t].meshes);
  558. return e
  559. }
  560. getCgMesh() {
  561. return this._CgPlane
  562. }
  563. getMeshesByGroup(e="default") {
  564. const t = this._lowModel_group.get(e);
  565. if (t != null) {
  566. let r = [];
  567. for (let n = 0; n < t.length; ++n)
  568. r = r.concat(t[n].meshes);
  569. return r
  570. } else
  571. return null
  572. }
  573. getMeshesByGroup2(e="default") {
  574. return this._getMeshesByCustomProperty("group", e)
  575. }
  576. }