XSequence.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. class XSubSequence {
  2. constructor(e, t, r=DefaultUrlTransformer$1) {
  3. E(this, "_scene");
  4. E(this, "_meshGroups");
  5. E(this, "_animGroup");
  6. E(this, "_particleGroups");
  7. E(this, "_materialGroups");
  8. E(this, "_spriteGroups");
  9. E(this, "_glowGroups");
  10. E(this, "_highLightGroups");
  11. E(this, "_endFrame");
  12. E(this, "_centerNode");
  13. E(this, "_rootDir");
  14. E(this, "_abosoluteUrl");
  15. E(this, "_name");
  16. E(this, "_pickable", !1);
  17. E(this, "urlTransformer");
  18. E(this, "onLoadedObserverable", new Observable);
  19. E(this, "onSubSequenceTransformationChangeObservable", new Observable);
  20. E(this, "onIntersectionObservable", new Observable);
  21. E(this, "_loaded");
  22. E(this, "_isStarted");
  23. E(this, "_isPaused");
  24. E(this, "_isDisposing", !1);
  25. E(this, "init", ()=>new Promise((e,t)=>{
  26. this.urlTransformer(this._abosoluteUrl).then(r=>{
  27. const n = new XMLHttpRequest;
  28. n.open("get", r),
  29. n.send(null),
  30. n.onload = ()=>{
  31. if (n.status == 200) {
  32. const o = JSON.parse(n.responseText);
  33. this.load(o).then(()=>{
  34. this.onLoadedObserverable.notifyObservers(this),
  35. this._loaded = !0,
  36. e()
  37. }
  38. , ()=>{
  39. t(),
  40. log$A.error("subSequence: Load ${jsonBlob} json fail")
  41. }
  42. )
  43. }
  44. }
  45. ,
  46. n.onerror = ()=>{
  47. log$A.error("http: Get ${jsonBlob} json fail"),
  48. t()
  49. }
  50. }
  51. )
  52. }
  53. ));
  54. E(this, "play", async(e=!0)=>new Promise(t=>{
  55. if (this._animGroup.isPlaying && this._animGroup.stop(),
  56. this._particleGroups.forEach(r=>{
  57. var n;
  58. ((n = r.emitterNode) == null ? void 0 : n.getClassName()) == "Mesh" && r.emitterNode instanceof Mesh ? r.emitterNode.isEnabled() && r.start() : r.start()
  59. }
  60. ),
  61. this._animGroup.targetedAnimations.length == 0) {
  62. this.show();
  63. let r = 0;
  64. this._spriteGroups.forEach(n=>{
  65. n.sprites.forEach(o=>{
  66. o.toIndex > r && (r = o.toIndex)
  67. }
  68. )
  69. }
  70. ),
  71. this._spriteGroups.forEach(n=>{
  72. n.sprites.forEach(o=>{
  73. o.playAnimation(o.fromIndex, o.toIndex, e, o.delay, ()=>{
  74. o.toIndex == r && (this._isPaused = !0,
  75. this.hide(),
  76. t())
  77. }
  78. )
  79. }
  80. )
  81. }
  82. )
  83. } else
  84. this._animGroup.play(e),
  85. this._spriteGroups.forEach(r=>{
  86. r.sprites.forEach(n=>{
  87. n.playAnimation(n.fromIndex, n.toIndex, e, n.delay)
  88. }
  89. )
  90. }
  91. ),
  92. e ? this._animGroup.onAnimationGroupLoopObservable.addOnce(()=>{
  93. t()
  94. }
  95. ) : this._animGroup.onAnimationGroupEndObservable.addOnce(()=>{
  96. this._spriteGroups.forEach(r=>{
  97. r.sprites.forEach(n=>{
  98. n.isVisible = !1,
  99. n.isPickable = !1,
  100. n.stopAnimation()
  101. }
  102. )
  103. }
  104. ),
  105. t()
  106. }
  107. );
  108. this._isStarted = !0,
  109. this._isPaused = !1
  110. }
  111. ));
  112. E(this, "stop", ()=>{
  113. this._animGroup.stop(),
  114. this._particleGroups.forEach(e=>{
  115. e.systems.forEach(t=>{
  116. t.stop()
  117. }
  118. )
  119. }
  120. ),
  121. this._spriteGroups.forEach(e=>{
  122. e.sprites.forEach(t=>{
  123. t.stopAnimation()
  124. }
  125. )
  126. }
  127. ),
  128. this._isStarted = !1
  129. }
  130. );
  131. E(this, "clone", (e="Clone")=>{
  132. const t = new XSubSequence(this._scene,this._abosoluteUrl);
  133. return t._centerNode.name = e + "_" + this._centerNode.name,
  134. t._animGroup.name = e + "_" + this._animGroup.name,
  135. this._meshGroups.forEach(r=>{
  136. const n = r.clone(e + "_", t._centerNode)
  137. , o = n.getChildren(void 0, !1);
  138. if (o.forEach(a=>{
  139. a.setEnabled(!0)
  140. }
  141. ),
  142. o.push(n),
  143. n) {
  144. const a = r.getChildren(void 0, !1);
  145. a.push(r),
  146. this.animGroup.targetedAnimations.forEach(s=>{
  147. if (s.target instanceof Node$2) {
  148. const l = a.indexOf(s.target);
  149. l != -1 && t._animGroup.addTargetedAnimation(s.animation, o[l])
  150. }
  151. }
  152. )
  153. }
  154. }
  155. ),
  156. t._loaded = !0,
  157. t
  158. }
  159. );
  160. E(this, "goToFrame", e=>{
  161. this._animGroup.start(!0, 1, e, e)
  162. }
  163. );
  164. E(this, "pause", ()=>{
  165. this._isPaused = !0,
  166. this._animGroup.pause()
  167. }
  168. );
  169. E(this, "reset", ()=>{
  170. this._animGroup.reset()
  171. }
  172. );
  173. E(this, "loadTrackToAnim", e=>{
  174. const t = Array();
  175. let r = !0;
  176. e.keyFrame.forEach(o=>{
  177. if (o.frame > this._endFrame && (this._endFrame = o.frame),
  178. o.value instanceof Array) {
  179. const a = {
  180. frame: o.frame,
  181. value: new Vector3(0,0,0)
  182. }
  183. , s = new Vector3(o.value[0],o.value[1],o.value[2]);
  184. a.value = s,
  185. t.push(a)
  186. } else
  187. t.push(o),
  188. r = !1
  189. }
  190. ),
  191. e.loop == null && (e.loop = !1),
  192. e.index == null && (e.index = 0);
  193. let n = null;
  194. if ("blockName"in e) {
  195. const o = {
  196. keyFrame: t,
  197. blockName: e.blockName,
  198. property: e.property,
  199. targetName: e.targetName,
  200. index: e.index,
  201. loop: e.loop
  202. };
  203. n = this.transferTrackToAnim(o, r)
  204. } else {
  205. const o = {
  206. keyFrame: t,
  207. property: e.property,
  208. targetName: e.targetName,
  209. index: e.index,
  210. loop: e.loop
  211. };
  212. n = this.transferTrackToAnim(o, r)
  213. }
  214. return n
  215. }
  216. );
  217. E(this, "transferTrackToAnim", (e,t)=>{
  218. let r = null;
  219. t ? (r = new Animation(e.targetName + "_" + e.property,e.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CYCLE),
  220. r.setKeys(e.keyFrame)) : (r = new Animation(e.targetName + "_" + e.property,e.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE),
  221. r.setKeys(e.keyFrame));
  222. let n = null;
  223. return "blockName"in e ? n = {
  224. animation: r,
  225. blockName: e.blockName,
  226. targetName: e.targetName,
  227. nodeIndex: e.index,
  228. loop: e.loop
  229. } : n = {
  230. animation: r,
  231. targetName: e.targetName,
  232. nodeIndex: e.index,
  233. loop: e.loop
  234. },
  235. n
  236. }
  237. );
  238. t.indexOf("./") == 0 && (t = t.slice(2)),
  239. this._abosoluteUrl = t,
  240. this._name = t.split("/").slice(-1)[0].split(".")[0].split("_")[1],
  241. this._rootDir = t.split("/").slice(0, -1).join("/") + "/",
  242. this._scene = e,
  243. this._meshGroups = new Map,
  244. this._animGroup = new AnimationGroup("SubSeqAnim_",this._scene),
  245. this._particleGroups = new Map,
  246. this._materialGroups = new Map,
  247. this._glowGroups = new Map,
  248. this._highLightGroups = new Map,
  249. this._spriteGroups = new Map,
  250. this._endFrame = 0,
  251. this._centerNode = new TransformNode("__rootSubSeq__",e),
  252. this._loaded = !1,
  253. this._isPaused = !0,
  254. this._isStarted = !1,
  255. this._centerNode.setEnabled(!1),
  256. this.urlTransformer = r,
  257. this._centerNode.onAfterWorldMatrixUpdateObservable.add(()=>{
  258. this.onSubSequenceTransformationChangeObservable.notifyObservers(this)
  259. }
  260. ),
  261. this._animGroup.onAnimationGroupPlayObservable.add(()=>{
  262. this._particleGroups.forEach(n=>{
  263. n.systems.forEach(o=>{
  264. o.isStarted() || o.start()
  265. }
  266. )
  267. }
  268. ),
  269. this.show()
  270. }
  271. ),
  272. this._animGroup.onAnimationGroupLoopObservable.add(()=>{
  273. this._particleGroups.forEach(n=>{
  274. n.systems.forEach(o=>{
  275. o.isStarted() || o.start()
  276. }
  277. )
  278. }
  279. ),
  280. this.show()
  281. }
  282. ),
  283. this._animGroup.onAnimationGroupEndObservable.add(()=>{
  284. this.hide()
  285. }
  286. )
  287. }
  288. dispose() {
  289. this._isDisposing = !0,
  290. this._spriteGroups.forEach(e=>{
  291. e.dispose()
  292. }
  293. ),
  294. this._glowGroups.forEach(e=>{
  295. e.dispose()
  296. }
  297. ),
  298. this._highLightGroups.forEach(e=>{
  299. e.dispose()
  300. }
  301. ),
  302. this._particleGroups.forEach(e=>{
  303. XParticleManager.disposeParticleSysSet(e)
  304. }
  305. ),
  306. this._animGroup.stop(),
  307. this._animGroup.dispose(),
  308. this._meshGroups.forEach(e=>{
  309. e.getChildren(void 0, !1).forEach(t=>{
  310. var r, n;
  311. (t.getClassName() === "AbstractMesh" || t.getClassName() === "Mesh") && ((r = t.skeleton) == null || r.dispose(),
  312. (n = t.material) == null || n.dispose(!0, !0)),
  313. t.dispose(!0, !0)
  314. }
  315. ),
  316. e.dispose(!1, !0)
  317. }
  318. ),
  319. this._centerNode.dispose(!1, !0),
  320. this._materialGroups.forEach(e=>{}
  321. ),
  322. this._materialGroups.clear(),
  323. this._spriteGroups.clear(),
  324. this._glowGroups.clear(),
  325. this._highLightGroups.clear(),
  326. this._meshGroups.clear(),
  327. this._particleGroups.clear(),
  328. this._loaded = !1
  329. }
  330. get animGroup() {
  331. return this._animGroup
  332. }
  333. get name() {
  334. return this._name
  335. }
  336. get path() {
  337. return this._abosoluteUrl
  338. }
  339. get position() {
  340. return xversePosition2Ue4(this.pos)
  341. }
  342. get rotation() {
  343. return xverseRotation2Ue4(this.rot)
  344. }
  345. get scaling() {
  346. return this.scal
  347. }
  348. get pos() {
  349. return this._centerNode.position
  350. }
  351. get rot() {
  352. return this._centerNode.rotation
  353. }
  354. get scal() {
  355. return this._centerNode.scaling
  356. }
  357. get root() {
  358. return this._centerNode
  359. }
  360. get loaded() {
  361. return this._loaded
  362. }
  363. get isPlaying() {
  364. return this._animGroup ? this._animGroup.isPlaying : this._isStarted && !this._isPaused
  365. }
  366. get isStarted() {
  367. return this._animGroup ? this._animGroup.isStarted : this._isStarted
  368. }
  369. get isPickable() {
  370. return this._pickable
  371. }
  372. set isPickable(e) {
  373. this._meshGroups.forEach(t=>{
  374. t.getChildMeshes().forEach(r=>{
  375. r.isPickable = e
  376. }
  377. )
  378. }
  379. ),
  380. this._spriteGroups.forEach(t=>{
  381. t.isPickable = e,
  382. t.sprites.forEach(r=>{
  383. r.isPickable = e
  384. }
  385. )
  386. }
  387. ),
  388. this._pickable = e
  389. }
  390. addAnimation(e) {
  391. this._animGroup.addTargetedAnimation(e, this._centerNode),
  392. this._spriteGroups.forEach(t=>{
  393. t.sprites.forEach(r=>{
  394. this._animGroup.addTargetedAnimation(e, r)
  395. }
  396. )
  397. }
  398. )
  399. }
  400. setStartFrame(e) {
  401. this._animGroup.stop(),
  402. this._animGroup.targetedAnimations.forEach(t=>{
  403. const r = t.animation.getKeys();
  404. r.forEach(n=>{
  405. e + r[0].frame > 0 ? n.frame += e : n.frame -= r[0].frame
  406. }
  407. )
  408. }
  409. )
  410. }
  411. lookAt(e) {
  412. ue4Position2Xverse(e) && this.root.lookAt(ue4Position2Xverse(e))
  413. }
  414. setPosition(e) {
  415. this.setPositionVector(ue4Position2Xverse(e))
  416. }
  417. setPositionVector(e) {
  418. this._centerNode.position = e,
  419. this._particleGroups.forEach(t=>{
  420. t.emitterNode == null || t.emitterNode instanceof Vector3 ? t.emitterNode = e : this._scene.getMeshByName(t.emitterNode.name) || (t.emitterNode = e)
  421. }
  422. ),
  423. this._spriteGroups.forEach(t=>{
  424. t.sprites.forEach((r,n)=>{
  425. r.position = e
  426. }
  427. )
  428. }
  429. )
  430. }
  431. setScaling(e) {
  432. this.setScalingVector(ue4Scaling2Xverse(e))
  433. }
  434. setScalingVector(e) {
  435. var t;
  436. this._centerNode.scaling = e,
  437. (t = this._particleGroups) == null || t.forEach(r=>{
  438. r.systems.forEach(n=>{
  439. XParticleManager.scalingInPlace(n, e.x)
  440. }
  441. )
  442. }
  443. ),
  444. this._spriteGroups.forEach(r=>{
  445. r.sprites.forEach(n=>{
  446. n.size *= e.x
  447. }
  448. )
  449. }
  450. )
  451. }
  452. setRotation(e) {
  453. this.setRotationVector(ue4Rotation2Xverse(e))
  454. }
  455. setRotationVector(e) {
  456. this._centerNode.rotation = e
  457. }
  458. hide() {
  459. this._centerNode.setEnabled(!1),
  460. this._particleGroups.forEach(e=>{
  461. e.systems.forEach(t=>{
  462. t.isStarted() && t.stop()
  463. }
  464. )
  465. }
  466. ),
  467. this._spriteGroups.forEach(e=>{
  468. e.sprites.forEach(t=>{
  469. t.isVisible = !1
  470. }
  471. )
  472. }
  473. )
  474. }
  475. show() {
  476. this._centerNode.setEnabled(!0),
  477. this._centerNode.getChildren().forEach(e=>{
  478. e.setEnabled(!0),
  479. e.getChildMeshes().forEach(t=>{
  480. t.setEnabled(!0)
  481. }
  482. )
  483. }
  484. ),
  485. this._particleGroups.forEach(e=>{
  486. e.systems.forEach(t=>{
  487. t.start()
  488. }
  489. )
  490. }
  491. ),
  492. this._spriteGroups.forEach(e=>{
  493. e.sprites.forEach(t=>{
  494. t.isVisible = !0
  495. }
  496. )
  497. }
  498. )
  499. }
  500. get totalFrame() {
  501. return this._endFrame
  502. }
  503. load(e) {
  504. return new Promise((t,r)=>{
  505. const n = e.Mesh
  506. , o = e.Sprite
  507. , a = e.Material
  508. , s = e.Glow
  509. , l = e.HighLight
  510. , u = e.Particle
  511. , c = e.MeshTrack
  512. , h = e.ParticleTrack
  513. , f = e.MaterialTrack;
  514. this._animGroup.name += e.Type;
  515. const d = Date.now();
  516. this._centerNode.name += e.Type;
  517. const _ = new Array
  518. , g = new Array;
  519. n != null && n.forEach(m=>{
  520. _.push(this.loadMesh(m))
  521. }
  522. ),
  523. o != null && o.forEach(m=>{
  524. g.push(this.loadSprite(m))
  525. }
  526. ),
  527. Promise.all(_).then(()=>{
  528. a != null && a.forEach(m=>{
  529. g.push(this.loadMaterial(m))
  530. }
  531. ),
  532. u != null && u.forEach(m=>{
  533. g.push(this.loadParticle(m))
  534. }
  535. ),
  536. Promise.all(g).then(()=>{
  537. if (this._isDisposing) {
  538. const v = Date.now() - d;
  539. log$A.info(`subSequence: Load ${e.Type} takes ${v} ms`),
  540. t(this);
  541. return
  542. }
  543. if (s != null)
  544. for (const v of s)
  545. this.loadGlow(v);
  546. if (l != null)
  547. for (const v of l)
  548. this.loadHighLight(v);
  549. c != null && c.forEach(v=>{
  550. const y = this._meshGroups.get(v.targetName);
  551. if (y != null) {
  552. const b = this.loadTrackToAnim(v);
  553. ROOT_MESH_ANIM_PROPERTY.indexOf(b.animation.targetProperty) == -1 ? y.getChildMeshes().forEach(T=>{
  554. b.animation.targetProperty in T && this._animGroup.addTargetedAnimation(b.animation, T)
  555. }
  556. ) : this._animGroup.addTargetedAnimation(b.animation, y)
  557. }
  558. }
  559. ),
  560. h != null && h.forEach(v=>{
  561. var C;
  562. const y = v.index
  563. , b = v.targetName
  564. , T = (C = this._particleGroups.get(b)) == null ? void 0 : C.systems[y];
  565. if (T != null) {
  566. const A = this.loadTrackToAnim(v);
  567. this._animGroup.addTargetedAnimation(A.animation, T)
  568. }
  569. }
  570. ),
  571. f != null && f.forEach(v=>{
  572. const y = this._materialGroups.get(v.targetName);
  573. if (y) {
  574. const b = y[0];
  575. if (b != null)
  576. if (b.getBlockByName(v.blockName) != null) {
  577. const T = this.loadTrackToAnim(v);
  578. y == null || y.forEach(C=>{
  579. this._animGroup.addTargetedAnimation(T.animation, C.getBlockByName(v.blockName))
  580. }
  581. )
  582. } else
  583. console.error("property " + v.property + "is not in " + b.name)
  584. }
  585. }
  586. );
  587. const m = Date.now() - d;
  588. log$A.info(`subSequence: Load ${e.Type} takes ${m} ms`),
  589. t(this)
  590. }
  591. , ()=>{
  592. log$A.error(`subSequence: Load ${e.Type} fail`),
  593. r()
  594. }
  595. )
  596. }
  597. , ()=>{
  598. r()
  599. }
  600. )
  601. }
  602. )
  603. }
  604. loadMesh(e) {
  605. return new Promise((t,r)=>{
  606. const n = this._rootDir + e.uri;
  607. this.urlTransformer(n).then(o=>{
  608. if (this._isDisposing) {
  609. t();
  610. return
  611. }
  612. SceneLoader.LoadAssetContainer("", o, this._scene, a=>{
  613. if (this._isDisposing) {
  614. a.removeAllFromScene(),
  615. t();
  616. return
  617. }
  618. a.animationGroups.forEach(l=>{
  619. l.stop()
  620. }
  621. ),
  622. a.animationGroups.length != 0 && (a.animationGroups.forEach(l=>{
  623. l.targetedAnimations.forEach(u=>{
  624. this._animGroup.addTargetedAnimation(u.animation, u.target)
  625. }
  626. ),
  627. l.dispose()
  628. }
  629. ),
  630. a.animationGroups = [],
  631. a.animations = [],
  632. a.materials = []);
  633. const s = new TransformNode("__root__" + e.name,this._scene);
  634. if (e.uri.split(".")[1] == "glb")
  635. a.meshes[0].parent = s;
  636. else if (e.uri.split(".")[1] == "obj") {
  637. const l = new TransformNode("__root__",this._scene);
  638. a.meshes.forEach(u=>{
  639. u.parent = l,
  640. u.Type = MESH_TAG
  641. }
  642. ),
  643. l.parent = s
  644. }
  645. s.getChildMeshes().forEach(l=>{
  646. e.isPickable != null ? l.isPickable = e.isPickable : l.isPickable = !1,
  647. l.xtype = "XSubSequence"
  648. }
  649. ),
  650. this._meshGroups.set(e.name, s),
  651. s.parent = this._centerNode,
  652. a.addAllToScene(),
  653. t()
  654. }
  655. , ()=>{}
  656. , ()=>{
  657. log$A.error("subSequence:Load effect mesh fail"),
  658. log$A.error(`Effect Mesh ${e.name} load error`),
  659. r()
  660. }
  661. , ".glb")
  662. }
  663. , ()=>{
  664. log$A.error("http:Get effect mesh fail"),
  665. log$A.error(`Effect Mesh ${e.name} load error`),
  666. r()
  667. }
  668. )
  669. }
  670. )
  671. }
  672. loadSprite(e) {
  673. return new Promise((t,r)=>{
  674. if (this._isDisposing) {
  675. t();
  676. return
  677. }
  678. const n = this._rootDir + e.uri;
  679. if (e.uri !== "") {
  680. e.name;
  681. const o = new XMLHttpRequest;
  682. o.open("get", n),
  683. o.send(null),
  684. o.onload = ()=>{
  685. if (o.status == 200) {
  686. const a = JSON.parse(o.responseText)
  687. , s = XSpriteManager.Parse(a, this._scene, this._rootDir);
  688. s.sprites.forEach(l=>{
  689. l.stopAnimation()
  690. }
  691. ),
  692. this._spriteGroups.set(e.name, s),
  693. t()
  694. } else
  695. log$A.error("subSequence:Load effect sprite fail"),
  696. log$A.error(`Effect Sprite ${e.name} load error`),
  697. r()
  698. }
  699. }
  700. }
  701. )
  702. }
  703. loadMaterial(e) {
  704. return new Promise((t,r)=>{
  705. if (this._isDisposing) {
  706. t();
  707. return
  708. }
  709. const n = this._rootDir + e.uri;
  710. if (e.uri !== "") {
  711. const o = e.name
  712. , a = new NodeMaterial(`material_${o}`,this._scene,{
  713. emitComments: !1
  714. });
  715. a.backFaceCulling = !1,
  716. this.urlTransformer(n).then(s=>{
  717. if (this._isDisposing) {
  718. a.dispose(!1, !0, !1),
  719. t();
  720. return
  721. }
  722. a.loadAsync(s).then(()=>{
  723. if (this._isDisposing) {
  724. a.dispose(!0, !0, !1),
  725. t();
  726. return
  727. }
  728. a.build(!1);
  729. const l = new Array;
  730. let u = !1;
  731. for (let c = 0; c < e.meshName.length; c++)
  732. this._meshGroups.forEach(h=>{
  733. h.getChildMeshes().forEach(f=>{
  734. var d;
  735. if (f.name === e.meshName[c]) {
  736. u = !0,
  737. (d = f.material) == null || d.dispose(!0, !0);
  738. const _ = f;
  739. if (_.skeleton == null) {
  740. const g = a;
  741. _.material = g,
  742. l.push(g)
  743. } else if (_.numBoneInfluencers = 4,
  744. _.computeBonesUsingShaders = !0,
  745. c == 0) {
  746. const g = a;
  747. _.material = g,
  748. l.push(g)
  749. } else {
  750. const g = a.clone(`material_${o}` + String(c), !1);
  751. _.material = g,
  752. l.push(g)
  753. }
  754. }
  755. }
  756. )
  757. }
  758. );
  759. u ? this._materialGroups.set(e.name, l) : a.dispose(!0, !0),
  760. t()
  761. }
  762. , ()=>{
  763. log$A.error("http:Get effect Material fail"),
  764. log$A.error(`Effect NodeMaterial ${o} load error`),
  765. r()
  766. }
  767. )
  768. }
  769. )
  770. }
  771. }
  772. )
  773. }
  774. async loadGlow(e) {
  775. const t = new GlowLayer(e.name,this._scene,{
  776. blurKernelSize: e.blurKernelSize
  777. });
  778. t.intensity = e.intensity,
  779. e.meshName.forEach(r=>{
  780. const n = this._scene.getMeshByName(r);
  781. n != null && t.addIncludedOnlyMesh(n)
  782. }
  783. ),
  784. this._glowGroups.set(e.name, t)
  785. }
  786. loadHighLight(e) {
  787. const t = new HighlightLayer(e.name,this._scene);
  788. e.meshName.forEach(r=>{
  789. const n = this._scene.getMeshByName(r);
  790. if (n != null) {
  791. const o = new Color3(e.color[0],e.color[1],e.color[2]);
  792. t.addMesh(n, o)
  793. }
  794. }
  795. ),
  796. this._highLightGroups.set(e.name, t)
  797. }
  798. loadParticle(e) {
  799. return new Promise((t,r)=>{
  800. const n = this._rootDir + e.rootDir
  801. , o = new XParticleManager(this._scene);
  802. this.urlTransformer(n + e.uri).then(a=>{
  803. if (this._isDisposing) {
  804. t();
  805. return
  806. }
  807. o.load(n, e.uri, e.name).then(s=>{
  808. if (this._isDisposing) {
  809. r();
  810. return
  811. }
  812. this._particleGroups.set(e.name, s),
  813. t()
  814. }
  815. , ()=>{
  816. log$A.error(`SubSequence: ${e.name} particle load fail`),
  817. r()
  818. }
  819. )
  820. }
  821. , ()=>{
  822. log$A.error(`http: ${n + e.uri} load fail`),
  823. r()
  824. }
  825. )
  826. }
  827. )
  828. }
  829. }