XStaticMeshComponent.js 22 KB

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