@zhongguo168a/yxeditor-common 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, Component, ISchedulable, Vec2, Vec3, Vec4, AssetManager, SpriteAtlas } from 'cc';
1
+ import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, Component, ISchedulable, AssetManager, Asset, SpriteAtlas, Vec2, Vec3, Vec4 } from 'cc';
2
2
 
3
3
  interface error {
4
4
  isCancel(): boolean;
@@ -1289,6 +1289,95 @@ declare class Dispatcher implements ISchedulable {
1289
1289
  protected typeToList: Dictionary<string, CallbackList<any>>;
1290
1290
  }
1291
1291
 
1292
+ declare class AssetURI {
1293
+ name: string;
1294
+ constructor(name: string);
1295
+ loadType: number;
1296
+ uuid: string;
1297
+ path: string;
1298
+ bundle: string;
1299
+ }
1300
+ declare class XAssetManager {
1301
+ getAsset(uri: string): any;
1302
+ getAssetByUUID(uuid: string): any;
1303
+ getRoot(): AssetManager;
1304
+ }
1305
+ declare let assetx: XAssetManager;
1306
+
1307
+ declare class LoaderItem {
1308
+ onComplete?: (err: any, asset: any) => void;
1309
+ callHandler(err: any, asset: any): void;
1310
+ getBundle(): AssetManager.Bundle;
1311
+ type: string;
1312
+ bundle: AssetManager.Bundle;
1313
+ uri: AssetURI;
1314
+ preload: boolean;
1315
+ error: any;
1316
+ }
1317
+ /**
1318
+ * uri格式:path, uuid://uuid, https://url
1319
+ */
1320
+ declare class AssetLoader extends Dispatcher {
1321
+ /**
1322
+ *
1323
+ * @param bundleName
1324
+ * @param otherConfig preload:是预加载-否-加载, 包中的资源
1325
+ */
1326
+ loadBundle(bundleName: string, otherConfig?: {
1327
+ onComplete?: (err: any, asset: any) => void;
1328
+ preload?: boolean;
1329
+ }): this;
1330
+ /**
1331
+ * @param uri
1332
+ * @param otherConfig
1333
+ */
1334
+ loadAtlas(uri: string, otherConfig?: {
1335
+ onComplete?: (err: any, asset: any) => void;
1336
+ preload?: boolean;
1337
+ }): this;
1338
+ loadPrefab(uri: string, otherConfig?: {
1339
+ onComplete?: (err: any, asset: any) => void;
1340
+ preload?: boolean;
1341
+ }): this;
1342
+ loadConfig(uri: string): this;
1343
+ loadSpriteFrame(uri: string, otherConfig?: {
1344
+ onComplete?: (err: any, asset: any) => void;
1345
+ uuid?: string;
1346
+ }): this;
1347
+ loadImageAsset(uri: string, otherConfig?: {
1348
+ onHandler?: (err: any, asset: any) => void;
1349
+ }): this;
1350
+ protected _loadSpriteFrameByBundle(uri: string, bundle: AssetManager.Bundle): void;
1351
+ /**
1352
+ * 等待发送的结果
1353
+ * 如果返回 null,表示主动取消 [cancel]
1354
+ */
1355
+ wait(): Promise<this>;
1356
+ start(): this;
1357
+ onComplete(val: (loader: AssetLoader) => void): this;
1358
+ onProgress(val: (loader: AssetLoader) => void): this;
1359
+ isComplete(): boolean;
1360
+ protected validComplete(): void;
1361
+ protected parseBundleToAssetsLoader(bundle: AssetManager.Bundle, loaderItem: LoaderItem): AssetLoader;
1362
+ protected handleAtlas(item: LoaderItem, atlasAsset: Asset): void;
1363
+ protected _loadByItem(item: LoaderItem, type: any, onComplate: (err: any, asset: any) => void): void;
1364
+ getLoaded(): number;
1365
+ getTotle(): number;
1366
+ getSucceed(): number;
1367
+ getFail(): number;
1368
+ getFailList(): List<LoaderItem>;
1369
+ protected _handleFailList(err: any, item: any): void;
1370
+ stop(): void;
1371
+ protected _stop: boolean;
1372
+ protected _onCompleteHandler: Function;
1373
+ protected _onProgressHandler: Function;
1374
+ protected _loaded: number;
1375
+ protected _loaderList: List<LoaderItem>;
1376
+ protected _failList: List<LoaderItem>;
1377
+ }
1378
+
1379
+ declare function parseAtlas(name: any, plist: any, texture: any): SpriteAtlas;
1380
+
1292
1381
  type CreatorFunction = (...args: any[]) => {};
1293
1382
  /**
1294
1383
  * 回收的方法
@@ -1760,5 +1849,5 @@ declare const pathutil: PathUtil;
1760
1849
  declare function parsePlist(plist: any, texture: any): SpriteAtlas;
1761
1850
  declare function loadAtlas(url: any, callback: any): void;
1762
1851
 
1763
- export { ArrayUtil, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SamplePool, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, XEvent, arrayutil, bitutil, convertutil, ctrlrepo, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, maputil, mathutil, netutil, pagerepo, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timeutil, uidict, uimgr, uiutil };
1852
+ export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SamplePool, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, XAssetManager, XEvent, arrayutil, assetx, bitutil, convertutil, ctrlrepo, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timeutil, uidict, uimgr, uiutil };
1764
1853
  export type { CreatorFunction, DisposeFunction, IController, IEventManager, IExtend, IListItem, IModel, IModule, IModuleSample, ITreeListItem, RecycleFunction, error };
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, macro, director, instantiate, math, Component, Vec2, Vec3, UITransform, Vec4, SpriteAtlas, SpriteFrame, path, assetManager, Texture2D, Rect, Size, resources } from 'cc';
1
+ import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, macro, director, instantiate, math, Component, SpriteAtlas, Size, Vec2, Rect, SpriteFrame, path, assetManager, ImageAsset, JsonAsset, TextAsset, Asset, Texture2D, Vec3, UITransform, Vec4, resources } from 'cc';
2
2
 
3
3
  class NetUtil {
4
4
  // 获取URL的参数对象
@@ -4327,6 +4327,509 @@ class Dispatcher {
4327
4327
  }
4328
4328
  }
4329
4329
 
4330
+ function parseAtlas(name, plist, texture) {
4331
+ plist.meta;
4332
+ let frames = plist.frames;
4333
+ let atlas = new SpriteAtlas();
4334
+ atlas.name = name;
4335
+ atlas._nativeAsset = plist;
4336
+ let spriteFrames = atlas.spriteFrames;
4337
+ // 1/1_1_0.png:{
4338
+ // frame: {x: 137, y: 302, w: 18, h: 24}
4339
+ // rotated: false
4340
+ // sourceSize: {w: 32, h: 32}
4341
+ // spriteSourceSize: {x: 7, y: 0, w: 18, h: 24}
4342
+ // trimmed: true
4343
+ // }
4344
+ let maxWidth = 0;
4345
+ let maxHeight = 0;
4346
+ for (let key in frames) {
4347
+ let frame = frames[key];
4348
+ let rotated = false, sourceSize, offset, textureRect;
4349
+ rotated = frame.rotated;
4350
+ {
4351
+ let size = frame.sourceSize;
4352
+ sourceSize = new Size(size.w, size.h);
4353
+ maxWidth = Math.max(maxWidth, size.w);
4354
+ maxHeight = Math.max(maxHeight, size.h);
4355
+ }
4356
+ { // 需要转化成以sourceSize的中心点为原点,cocos坐标系的偏移量
4357
+ let pos = frame.spriteSourceSize;
4358
+ offset = new Vec2(pos.x + pos.w * 0.5, pos.y + pos.h * 0.5);
4359
+ offset.x -= sourceSize.width * 0.5;
4360
+ offset.y -= sourceSize.height * 0.5;
4361
+ offset.y = -offset.y; // y轴相反
4362
+ }
4363
+ {
4364
+ let rect = frame.frame;
4365
+ textureRect = new Rect(rect.x, rect.y, rect.w, rect.h);
4366
+ }
4367
+ var sprite = new SpriteFrame();
4368
+ sprite.name = key;
4369
+ sprite.reset({
4370
+ originalSize: sourceSize,
4371
+ rect: textureRect,
4372
+ offset: offset,
4373
+ isRotate: !!rotated,
4374
+ texture: texture
4375
+ });
4376
+ let name = path.mainFileName(key);
4377
+ spriteFrames[name] = sprite;
4378
+ }
4379
+ //
4380
+ plist.meta.maxSize = { w: maxWidth, h: maxHeight };
4381
+ return atlas;
4382
+ }
4383
+
4384
+ class AssetURI {
4385
+ constructor(name) {
4386
+ this.name = name;
4387
+ // 0-bundle+path 1-uuid 2-remote
4388
+ this.loadType = 0;
4389
+ let arr = name.split("://");
4390
+ if (arr.length == 2) {
4391
+ let head = arr[0];
4392
+ if (head == "uuid") {
4393
+ this.loadType = 1;
4394
+ this.uuid = arr[1];
4395
+ }
4396
+ else if (head == "http" || head == "https") {
4397
+ this.loadType = 2;
4398
+ }
4399
+ else {
4400
+ this.bundle = head;
4401
+ this.path = arr[1];
4402
+ }
4403
+ }
4404
+ else {
4405
+ this.bundle = "resources";
4406
+ this.path = name;
4407
+ }
4408
+ }
4409
+ }
4410
+ class XAssetManager {
4411
+ getAsset(uri) {
4412
+ let obj = new AssetURI(uri);
4413
+ switch (obj.loadType) {
4414
+ case 1:
4415
+ return assetManager.assets.get(obj.uuid);
4416
+ case 2:
4417
+ return assetManager.assets.get(obj.name);
4418
+ default:
4419
+ let bundle = assetManager.getBundle(obj.bundle);
4420
+ if (!bundle) {
4421
+ return null;
4422
+ }
4423
+ return bundle.get(obj.path);
4424
+ }
4425
+ }
4426
+ getAssetByUUID(uuid) {
4427
+ return assetManager.assets.get(uuid);
4428
+ }
4429
+ getRoot() {
4430
+ return assetManager;
4431
+ }
4432
+ }
4433
+ let assetx = new XAssetManager();
4434
+
4435
+ class LoaderItem {
4436
+ constructor() {
4437
+ this.preload = false;
4438
+ }
4439
+ callHandler(err, asset) {
4440
+ if (this.onComplete) {
4441
+ this.onComplete(err, asset);
4442
+ }
4443
+ }
4444
+ getBundle() {
4445
+ let bundle = this.bundle;
4446
+ if (!bundle) {
4447
+ bundle = assetManager.getBundle(this.uri.bundle);
4448
+ this.bundle = bundle;
4449
+ }
4450
+ return bundle;
4451
+ }
4452
+ }
4453
+ /**
4454
+ * uri格式:path, uuid://uuid, https://url
4455
+ */
4456
+ class AssetLoader extends Dispatcher {
4457
+ constructor() {
4458
+ super(...arguments);
4459
+ this._stop = false;
4460
+ this._loaded = 0;
4461
+ this._loaderList = new List();
4462
+ this._failList = new List();
4463
+ }
4464
+ /**
4465
+ *
4466
+ * @param bundleName
4467
+ * @param otherConfig preload:是预加载-否-加载, 包中的资源
4468
+ */
4469
+ loadBundle(bundleName, otherConfig) {
4470
+ let item = new LoaderItem();
4471
+ item.type = "Bundle";
4472
+ item.uri = new AssetURI(`${bundleName}://bundle`);
4473
+ if (otherConfig) {
4474
+ item.preload = otherConfig.preload;
4475
+ item.onComplete = otherConfig.onComplete;
4476
+ }
4477
+ this._loaderList.push(item);
4478
+ return this;
4479
+ }
4480
+ /**
4481
+ * @param uri
4482
+ * @param otherConfig
4483
+ */
4484
+ loadAtlas(uri, otherConfig) {
4485
+ let item = new LoaderItem();
4486
+ item.type = "Atlas";
4487
+ // 加载json文件
4488
+ item.uri = new AssetURI(uri);
4489
+ if (otherConfig) {
4490
+ item.onComplete = otherConfig.onComplete;
4491
+ item.preload = otherConfig.preload != undefined ? otherConfig.preload : false;
4492
+ }
4493
+ this._loaderList.push(item);
4494
+ return this;
4495
+ }
4496
+ loadPrefab(uri, otherConfig) {
4497
+ let item = new LoaderItem();
4498
+ item.type = "Prefab";
4499
+ // 加载json文件
4500
+ item.uri = new AssetURI(uri);
4501
+ if (otherConfig) {
4502
+ item.onComplete = otherConfig.onComplete;
4503
+ item.preload = otherConfig.preload != undefined ? otherConfig.preload : false;
4504
+ }
4505
+ this._loaderList.push(item);
4506
+ return this;
4507
+ }
4508
+ loadConfig(uri) {
4509
+ let item = new LoaderItem();
4510
+ item.type = "Config";
4511
+ item.uri = new AssetURI(uri);
4512
+ this._loaderList.push(item);
4513
+ return this;
4514
+ }
4515
+ loadSpriteFrame(uri, otherConfig) {
4516
+ let item = new LoaderItem();
4517
+ item.type = "SpriteFrame";
4518
+ item.uri = new AssetURI(uri);
4519
+ if (otherConfig) {
4520
+ item.onComplete = otherConfig.onComplete;
4521
+ }
4522
+ this._loaderList.push(item);
4523
+ return this;
4524
+ }
4525
+ loadImageAsset(uri, otherConfig) {
4526
+ let item = new LoaderItem();
4527
+ item.type = "ImageAsset";
4528
+ item.uri = new AssetURI(uri);
4529
+ if (otherConfig) {
4530
+ item.onComplete = otherConfig.onHandler;
4531
+ }
4532
+ this._loaderList.push(item);
4533
+ return this;
4534
+ }
4535
+ _loadSpriteFrameByBundle(uri, bundle) {
4536
+ let item = new LoaderItem();
4537
+ item.type = "SpriteFrame";
4538
+ item.uri = new AssetURI(`${bundle.name}://${uri}`);
4539
+ item.bundle = bundle;
4540
+ this._loaderList.push(item);
4541
+ }
4542
+ /**
4543
+ * 等待发送的结果
4544
+ * 如果返回 null,表示主动取消 [cancel]
4545
+ */
4546
+ wait() {
4547
+ return new Promise((resolve, reject) => {
4548
+ if (this.isComplete()) {
4549
+ resolve(this);
4550
+ }
4551
+ else {
4552
+ let listener = Listener.create();
4553
+ let succeed = () => {
4554
+ listener.off();
4555
+ resolve(this);
4556
+ };
4557
+ listener.setCaller(this).setHandler(succeed).on();
4558
+ this.create("complete", listener);
4559
+ }
4560
+ });
4561
+ }
4562
+ start() {
4563
+ this._loaderList.forEach((index, item) => {
4564
+ switch (item.type) {
4565
+ case "Bundle": {
4566
+ assetManager.loadBundle(item.uri.bundle, (err, bundle) => {
4567
+ if (err) {
4568
+ return;
4569
+ }
4570
+ let loader = this.parseBundleToAssetsLoader(bundle, item);
4571
+ loader.onComplete(() => {
4572
+ this._loaded++;
4573
+ this.validComplete();
4574
+ });
4575
+ loader.start();
4576
+ });
4577
+ break;
4578
+ }
4579
+ case "Config": {
4580
+ assetManager.loadBundle(item.uri.bundle, (err, bundle) => {
4581
+ if (this._stop) {
4582
+ return;
4583
+ }
4584
+ if (err) {
4585
+ return;
4586
+ }
4587
+ this._loaded++;
4588
+ this.validComplete();
4589
+ });
4590
+ break;
4591
+ }
4592
+ case "Atlas": {
4593
+ let asset = assetx.getAsset(item.uri.name);
4594
+ if (asset) {
4595
+ if (asset instanceof SpriteAtlas) {
4596
+ this._loaded++;
4597
+ item.callHandler(null, asset);
4598
+ this.validComplete();
4599
+ }
4600
+ else {
4601
+ this.handleAtlas(item, asset);
4602
+ }
4603
+ }
4604
+ else {
4605
+ // json文件
4606
+ this._loadByItem(item, null, (err, asset) => {
4607
+ if (!err) {
4608
+ this.handleAtlas(item, asset);
4609
+ }
4610
+ else {
4611
+ this._loaded++;
4612
+ this.validComplete();
4613
+ }
4614
+ });
4615
+ }
4616
+ break;
4617
+ }
4618
+ case "Prefab": {
4619
+ let asset = assetx.getAsset(item.uri.name);
4620
+ if (asset) {
4621
+ this._loaded++;
4622
+ item.callHandler(null, asset);
4623
+ this.validComplete();
4624
+ }
4625
+ else {
4626
+ this._loadByItem(item, null, (err, asset) => {
4627
+ this._loaded++;
4628
+ item.callHandler(err, asset);
4629
+ this.validComplete();
4630
+ });
4631
+ }
4632
+ break;
4633
+ }
4634
+ case "SpriteFrame": {
4635
+ this._loadByItem(item, SpriteFrame, (err, asset) => {
4636
+ this._loaded++;
4637
+ this.validComplete();
4638
+ });
4639
+ break;
4640
+ }
4641
+ case "ImageAsset": {
4642
+ this._loadByItem(item, ImageAsset, (err, asset) => {
4643
+ this._loaded++;
4644
+ this.validComplete();
4645
+ });
4646
+ break;
4647
+ }
4648
+ }
4649
+ });
4650
+ return this;
4651
+ }
4652
+ onComplete(val) {
4653
+ this._onCompleteHandler = val;
4654
+ return this;
4655
+ }
4656
+ onProgress(val) {
4657
+ this._onProgressHandler = val;
4658
+ return this;
4659
+ }
4660
+ isComplete() {
4661
+ return this._loaded == this._loaderList.length;
4662
+ }
4663
+ validComplete() {
4664
+ if (this._stop) {
4665
+ return;
4666
+ }
4667
+ if (this._onProgressHandler) {
4668
+ this._onProgressHandler(this);
4669
+ }
4670
+ if (this._loaded == this._loaderList.length) {
4671
+ if (this._onCompleteHandler) {
4672
+ this._onCompleteHandler(this);
4673
+ }
4674
+ this.dispatch("complete");
4675
+ }
4676
+ }
4677
+ parseBundleToAssetsLoader(bundle, loaderItem) {
4678
+ let loader = new AssetLoader();
4679
+ // @ts-ignore
4680
+ let map = bundle._config.assetInfos._map;
4681
+ for (const mapKey in map) {
4682
+ let assetInfo = map[mapKey];
4683
+ if (!assetInfo.ctor) {
4684
+ continue;
4685
+ }
4686
+ switch (assetInfo.ctor.name) {
4687
+ case "ImageAsset":
4688
+ break;
4689
+ case "Prefab":
4690
+ break;
4691
+ case "SpriteFrame":
4692
+ loader._loadSpriteFrameByBundle(assetInfo.path, bundle);
4693
+ break;
4694
+ }
4695
+ }
4696
+ return loader;
4697
+ }
4698
+ handleAtlas(item, atlasAsset) {
4699
+ let content = (() => {
4700
+ if (atlasAsset instanceof JsonAsset) {
4701
+ return atlasAsset.json;
4702
+ }
4703
+ else if (atlasAsset instanceof TextAsset) {
4704
+ return JSON.parse(atlasAsset.text);
4705
+ }
4706
+ else if (atlasAsset instanceof Asset) {
4707
+ return JSON.parse(atlasAsset.nativeAsset);
4708
+ }
4709
+ })();
4710
+ let textureUrl = "";
4711
+ let textureItem = new LoaderItem();
4712
+ switch (item.uri.loadType) {
4713
+ case 2:
4714
+ textureItem.type = "ImageAsset";
4715
+ textureUrl = path.join(path.dirname(item.uri.name), content.meta.image);
4716
+ break;
4717
+ case 1:
4718
+ textureItem.type = "ImageAsset";
4719
+ textureUrl = atlasAsset._nativeUrl;
4720
+ break;
4721
+ case 0:
4722
+ textureItem.type = "ImageAsset";
4723
+ textureUrl = item.uri.name;
4724
+ break;
4725
+ }
4726
+ textureItem.uri = new AssetURI(textureUrl);
4727
+ //
4728
+ this._loadByItem(textureItem, ImageAsset, (err, asset) => {
4729
+ if (!err) {
4730
+ let tex = new Texture2D();
4731
+ tex.image = asset;
4732
+ tex.setFilters(1, 1);
4733
+ let atlasSprite = parseAtlas(item.uri, content, tex);
4734
+ let uuid = atlasAsset.uuid;
4735
+ assetManager.assets.remove(uuid);
4736
+ assetManager.assets.add(uuid, atlasSprite);
4737
+ //
4738
+ item.callHandler(null, atlasSprite);
4739
+ }
4740
+ this._loaded++;
4741
+ this.validComplete();
4742
+ });
4743
+ }
4744
+ _loadByItem(item, type, onComplate) {
4745
+ switch (item.uri.loadType) {
4746
+ case 0: {
4747
+ let bundle = item.getBundle();
4748
+ if (!bundle) ;
4749
+ else {
4750
+ if (item.preload) {
4751
+ bundle.preload(item.uri.path, type, (err, asset) => {
4752
+ if (this._stop) {
4753
+ return;
4754
+ }
4755
+ this._handleFailList(err, item);
4756
+ onComplate(err, asset);
4757
+ });
4758
+ }
4759
+ else {
4760
+ bundle.load(item.uri.path, type, (err, asset) => {
4761
+ if (this._stop) {
4762
+ return;
4763
+ }
4764
+ this._handleFailList(err, item);
4765
+ onComplate(err, asset);
4766
+ });
4767
+ }
4768
+ }
4769
+ break;
4770
+ }
4771
+ case 1: {
4772
+ if (item.preload) {
4773
+ assetManager.preloadAny({ uuid: item.uri.uuid }, { type: type }, (err, asset) => {
4774
+ if (this._stop) {
4775
+ return;
4776
+ }
4777
+ this._handleFailList(err, item);
4778
+ onComplate(err, asset);
4779
+ });
4780
+ }
4781
+ else {
4782
+ assetManager.loadAny({ uuid: item.uri.uuid }, { type: type }, (err, asset) => {
4783
+ if (this._stop) {
4784
+ return;
4785
+ }
4786
+ this._handleFailList(err, item);
4787
+ onComplate(err, asset);
4788
+ });
4789
+ }
4790
+ break;
4791
+ }
4792
+ case 2: {
4793
+ assetManager.loadRemote(item.uri.name, (err, asset) => {
4794
+ this._handleFailList(err, item);
4795
+ if (this._stop) {
4796
+ return;
4797
+ }
4798
+ onComplate(err, asset);
4799
+ });
4800
+ }
4801
+ }
4802
+ }
4803
+ // 获取已经加载的数量,报错加载失败的
4804
+ getLoaded() {
4805
+ return this._loaded;
4806
+ }
4807
+ getTotle() {
4808
+ return this._loaderList.length;
4809
+ }
4810
+ // 获取成功的数量
4811
+ getSucceed() {
4812
+ return this._loaded - this.getFail();
4813
+ }
4814
+ // 获取失败的数量
4815
+ getFail() {
4816
+ return this._failList.length;
4817
+ }
4818
+ getFailList() {
4819
+ return this._failList;
4820
+ }
4821
+ _handleFailList(err, item) {
4822
+ if (err) {
4823
+ console.error(err.toString());
4824
+ item.error = err;
4825
+ this._failList.push(item);
4826
+ }
4827
+ }
4828
+ stop() {
4829
+ this._stop = true;
4830
+ }
4831
+ }
4832
+
4330
4833
  class UIUtil {
4331
4834
  /**
4332
4835
  * 格式化节点的uuid,用于树结构
@@ -5491,5 +5994,5 @@ class PathUtil {
5491
5994
  }
5492
5995
  const pathutil = new PathUtil();
5493
5996
 
5494
- export { ArrayUtil, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SamplePool, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, XEvent, arrayutil, bitutil, convertutil, ctrlrepo, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, maputil, mathutil, netutil, pagerepo, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timeutil, uidict, uimgr, uiutil };
5997
+ export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SamplePool, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, XAssetManager, XEvent, arrayutil, assetx, bitutil, convertutil, ctrlrepo, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timeutil, uidict, uimgr, uiutil };
5495
5998
  //# sourceMappingURL=index.esm.js.map