@zhongguo168a/yxeditor-common 0.0.9 → 0.0.11
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 +22 -24
- package/dist/index.esm.js +123 -126
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, Component, ISchedulable, AssetManager, Asset, SpriteAtlas, Vec2, Vec3, Vec4 } from 'cc';
|
|
2
|
-
import { Dispatcher as Dispatcher$1 } from 'db://assets/core/libs/event';
|
|
3
|
-
import { List as List$1 } from 'db://assets/core/libs/ds';
|
|
4
|
-
import { AssetURI as AssetURI$1 } from 'db://assets/core/libs/loader/AssetManager';
|
|
5
2
|
|
|
6
3
|
interface error {
|
|
7
4
|
isCancel(): boolean;
|
|
@@ -208,6 +205,7 @@ declare class Timer {
|
|
|
208
205
|
recycle(): void;
|
|
209
206
|
dispose(): void;
|
|
210
207
|
}
|
|
208
|
+
declare const timer: Timer;
|
|
211
209
|
|
|
212
210
|
declare class ControllerSet {
|
|
213
211
|
constructor(mod: IModule);
|
|
@@ -1292,20 +1290,35 @@ declare class Dispatcher implements ISchedulable {
|
|
|
1292
1290
|
protected typeToList: Dictionary<string, CallbackList<any>>;
|
|
1293
1291
|
}
|
|
1294
1292
|
|
|
1293
|
+
declare class AssetURI {
|
|
1294
|
+
name: string;
|
|
1295
|
+
constructor(name: string);
|
|
1296
|
+
loadType: number;
|
|
1297
|
+
uuid: string;
|
|
1298
|
+
path: string;
|
|
1299
|
+
bundle: string;
|
|
1300
|
+
}
|
|
1301
|
+
declare class XAssetManager {
|
|
1302
|
+
getAsset(uri: string): any;
|
|
1303
|
+
getAssetByUUID(uuid: string): any;
|
|
1304
|
+
getRoot(): AssetManager;
|
|
1305
|
+
}
|
|
1306
|
+
declare let assetx: XAssetManager;
|
|
1307
|
+
|
|
1295
1308
|
declare class LoaderItem {
|
|
1296
1309
|
onComplete?: (err: any, asset: any) => void;
|
|
1297
1310
|
callHandler(err: any, asset: any): void;
|
|
1298
1311
|
getBundle(): AssetManager.Bundle;
|
|
1299
1312
|
type: string;
|
|
1300
1313
|
bundle: AssetManager.Bundle;
|
|
1301
|
-
uri: AssetURI
|
|
1314
|
+
uri: AssetURI;
|
|
1302
1315
|
preload: boolean;
|
|
1303
1316
|
error: any;
|
|
1304
1317
|
}
|
|
1305
1318
|
/**
|
|
1306
1319
|
* uri格式:path, uuid://uuid, https://url
|
|
1307
1320
|
*/
|
|
1308
|
-
declare class AssetLoader extends Dispatcher
|
|
1321
|
+
declare class AssetLoader extends Dispatcher {
|
|
1309
1322
|
/**
|
|
1310
1323
|
*
|
|
1311
1324
|
* @param bundleName
|
|
@@ -1353,32 +1366,17 @@ declare class AssetLoader extends Dispatcher$1 {
|
|
|
1353
1366
|
getTotle(): number;
|
|
1354
1367
|
getSucceed(): number;
|
|
1355
1368
|
getFail(): number;
|
|
1356
|
-
getFailList(): List
|
|
1369
|
+
getFailList(): List<LoaderItem>;
|
|
1357
1370
|
protected _handleFailList(err: any, item: any): void;
|
|
1358
1371
|
stop(): void;
|
|
1359
1372
|
protected _stop: boolean;
|
|
1360
1373
|
protected _onCompleteHandler: Function;
|
|
1361
1374
|
protected _onProgressHandler: Function;
|
|
1362
1375
|
protected _loaded: number;
|
|
1363
|
-
protected _loaderList:
|
|
1364
|
-
protected _failList:
|
|
1376
|
+
protected _loaderList: List<LoaderItem>;
|
|
1377
|
+
protected _failList: List<LoaderItem>;
|
|
1365
1378
|
}
|
|
1366
1379
|
|
|
1367
|
-
declare class AssetURI {
|
|
1368
|
-
name: string;
|
|
1369
|
-
constructor(name: string);
|
|
1370
|
-
loadType: number;
|
|
1371
|
-
uuid: string;
|
|
1372
|
-
path: string;
|
|
1373
|
-
bundle: string;
|
|
1374
|
-
}
|
|
1375
|
-
declare class XAssetManager {
|
|
1376
|
-
getAsset(uri: string): any;
|
|
1377
|
-
getAssetByUUID(uuid: string): any;
|
|
1378
|
-
getRoot(): AssetManager;
|
|
1379
|
-
}
|
|
1380
|
-
declare let assetx: XAssetManager;
|
|
1381
|
-
|
|
1382
1380
|
declare function parseAtlas(name: any, plist: any, texture: any): SpriteAtlas;
|
|
1383
1381
|
|
|
1384
1382
|
type CreatorFunction = (...args: any[]) => {};
|
|
@@ -1852,5 +1850,5 @@ declare const pathutil: PathUtil;
|
|
|
1852
1850
|
declare function parsePlist(plist: any, texture: any): SpriteAtlas;
|
|
1853
1851
|
declare function loadAtlas(url: any, callback: any): void;
|
|
1854
1852
|
|
|
1855
|
-
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 };
|
|
1853
|
+
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, timer, timeutil, uidict, uimgr, uiutil };
|
|
1856
1854
|
export type { CreatorFunction, DisposeFunction, IController, IEventManager, IExtend, IListItem, IModel, IModule, IModuleSample, ITreeListItem, RecycleFunction, error };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, macro, director, instantiate, math, Component,
|
|
2
|
-
import { parseAtlas as parseAtlas$1 } from 'db://assets/core/libs/loader/ParseAtlas';
|
|
3
|
-
import { Dispatcher as Dispatcher$1, Listener as Listener$1 } from 'db://assets/core/libs/event';
|
|
4
|
-
import { List as List$1 } from 'db://assets/core/libs/ds';
|
|
5
|
-
import { AssetURI as AssetURI$1, assetx as assetx$1 } from 'db://assets/core/libs/loader/AssetManager';
|
|
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';
|
|
6
2
|
|
|
7
3
|
class NetUtil {
|
|
8
4
|
// 获取URL的参数对象
|
|
@@ -432,6 +428,7 @@ class Timer {
|
|
|
432
428
|
this._scheduler = null;
|
|
433
429
|
}
|
|
434
430
|
}
|
|
431
|
+
const timer = new Timer();
|
|
435
432
|
|
|
436
433
|
class ControllerSet {
|
|
437
434
|
constructor(mod) {
|
|
@@ -4331,6 +4328,111 @@ class Dispatcher {
|
|
|
4331
4328
|
}
|
|
4332
4329
|
}
|
|
4333
4330
|
|
|
4331
|
+
function parseAtlas(name, plist, texture) {
|
|
4332
|
+
plist.meta;
|
|
4333
|
+
let frames = plist.frames;
|
|
4334
|
+
let atlas = new SpriteAtlas();
|
|
4335
|
+
atlas.name = name;
|
|
4336
|
+
atlas._nativeAsset = plist;
|
|
4337
|
+
let spriteFrames = atlas.spriteFrames;
|
|
4338
|
+
// 1/1_1_0.png:{
|
|
4339
|
+
// frame: {x: 137, y: 302, w: 18, h: 24}
|
|
4340
|
+
// rotated: false
|
|
4341
|
+
// sourceSize: {w: 32, h: 32}
|
|
4342
|
+
// spriteSourceSize: {x: 7, y: 0, w: 18, h: 24}
|
|
4343
|
+
// trimmed: true
|
|
4344
|
+
// }
|
|
4345
|
+
let maxWidth = 0;
|
|
4346
|
+
let maxHeight = 0;
|
|
4347
|
+
for (let key in frames) {
|
|
4348
|
+
let frame = frames[key];
|
|
4349
|
+
let rotated = false, sourceSize, offset, textureRect;
|
|
4350
|
+
rotated = frame.rotated;
|
|
4351
|
+
{
|
|
4352
|
+
let size = frame.sourceSize;
|
|
4353
|
+
sourceSize = new Size(size.w, size.h);
|
|
4354
|
+
maxWidth = Math.max(maxWidth, size.w);
|
|
4355
|
+
maxHeight = Math.max(maxHeight, size.h);
|
|
4356
|
+
}
|
|
4357
|
+
{ // 需要转化成以sourceSize的中心点为原点,cocos坐标系的偏移量
|
|
4358
|
+
let pos = frame.spriteSourceSize;
|
|
4359
|
+
offset = new Vec2(pos.x + pos.w * 0.5, pos.y + pos.h * 0.5);
|
|
4360
|
+
offset.x -= sourceSize.width * 0.5;
|
|
4361
|
+
offset.y -= sourceSize.height * 0.5;
|
|
4362
|
+
offset.y = -offset.y; // y轴相反
|
|
4363
|
+
}
|
|
4364
|
+
{
|
|
4365
|
+
let rect = frame.frame;
|
|
4366
|
+
textureRect = new Rect(rect.x, rect.y, rect.w, rect.h);
|
|
4367
|
+
}
|
|
4368
|
+
var sprite = new SpriteFrame();
|
|
4369
|
+
sprite.name = key;
|
|
4370
|
+
sprite.reset({
|
|
4371
|
+
originalSize: sourceSize,
|
|
4372
|
+
rect: textureRect,
|
|
4373
|
+
offset: offset,
|
|
4374
|
+
isRotate: !!rotated,
|
|
4375
|
+
texture: texture
|
|
4376
|
+
});
|
|
4377
|
+
let name = path.mainFileName(key);
|
|
4378
|
+
spriteFrames[name] = sprite;
|
|
4379
|
+
}
|
|
4380
|
+
//
|
|
4381
|
+
plist.meta.maxSize = { w: maxWidth, h: maxHeight };
|
|
4382
|
+
return atlas;
|
|
4383
|
+
}
|
|
4384
|
+
|
|
4385
|
+
class AssetURI {
|
|
4386
|
+
constructor(name) {
|
|
4387
|
+
this.name = name;
|
|
4388
|
+
// 0-bundle+path 1-uuid 2-remote
|
|
4389
|
+
this.loadType = 0;
|
|
4390
|
+
let arr = name.split("://");
|
|
4391
|
+
if (arr.length == 2) {
|
|
4392
|
+
let head = arr[0];
|
|
4393
|
+
if (head == "uuid") {
|
|
4394
|
+
this.loadType = 1;
|
|
4395
|
+
this.uuid = arr[1];
|
|
4396
|
+
}
|
|
4397
|
+
else if (head == "http" || head == "https") {
|
|
4398
|
+
this.loadType = 2;
|
|
4399
|
+
}
|
|
4400
|
+
else {
|
|
4401
|
+
this.bundle = head;
|
|
4402
|
+
this.path = arr[1];
|
|
4403
|
+
}
|
|
4404
|
+
}
|
|
4405
|
+
else {
|
|
4406
|
+
this.bundle = "resources";
|
|
4407
|
+
this.path = name;
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
}
|
|
4411
|
+
class XAssetManager {
|
|
4412
|
+
getAsset(uri) {
|
|
4413
|
+
let obj = new AssetURI(uri);
|
|
4414
|
+
switch (obj.loadType) {
|
|
4415
|
+
case 1:
|
|
4416
|
+
return assetManager.assets.get(obj.uuid);
|
|
4417
|
+
case 2:
|
|
4418
|
+
return assetManager.assets.get(obj.name);
|
|
4419
|
+
default:
|
|
4420
|
+
let bundle = assetManager.getBundle(obj.bundle);
|
|
4421
|
+
if (!bundle) {
|
|
4422
|
+
return null;
|
|
4423
|
+
}
|
|
4424
|
+
return bundle.get(obj.path);
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
getAssetByUUID(uuid) {
|
|
4428
|
+
return assetManager.assets.get(uuid);
|
|
4429
|
+
}
|
|
4430
|
+
getRoot() {
|
|
4431
|
+
return assetManager;
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
let assetx = new XAssetManager();
|
|
4435
|
+
|
|
4334
4436
|
class LoaderItem {
|
|
4335
4437
|
constructor() {
|
|
4336
4438
|
this.preload = false;
|
|
@@ -4352,13 +4454,13 @@ class LoaderItem {
|
|
|
4352
4454
|
/**
|
|
4353
4455
|
* uri格式:path, uuid://uuid, https://url
|
|
4354
4456
|
*/
|
|
4355
|
-
class AssetLoader extends Dispatcher
|
|
4457
|
+
class AssetLoader extends Dispatcher {
|
|
4356
4458
|
constructor() {
|
|
4357
4459
|
super(...arguments);
|
|
4358
4460
|
this._stop = false;
|
|
4359
4461
|
this._loaded = 0;
|
|
4360
|
-
this._loaderList = new List
|
|
4361
|
-
this._failList = new List
|
|
4462
|
+
this._loaderList = new List();
|
|
4463
|
+
this._failList = new List();
|
|
4362
4464
|
}
|
|
4363
4465
|
/**
|
|
4364
4466
|
*
|
|
@@ -4368,7 +4470,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4368
4470
|
loadBundle(bundleName, otherConfig) {
|
|
4369
4471
|
let item = new LoaderItem();
|
|
4370
4472
|
item.type = "Bundle";
|
|
4371
|
-
item.uri = new AssetURI
|
|
4473
|
+
item.uri = new AssetURI(`${bundleName}://bundle`);
|
|
4372
4474
|
if (otherConfig) {
|
|
4373
4475
|
item.preload = otherConfig.preload;
|
|
4374
4476
|
item.onComplete = otherConfig.onComplete;
|
|
@@ -4384,7 +4486,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4384
4486
|
let item = new LoaderItem();
|
|
4385
4487
|
item.type = "Atlas";
|
|
4386
4488
|
// 加载json文件
|
|
4387
|
-
item.uri = new AssetURI
|
|
4489
|
+
item.uri = new AssetURI(uri);
|
|
4388
4490
|
if (otherConfig) {
|
|
4389
4491
|
item.onComplete = otherConfig.onComplete;
|
|
4390
4492
|
item.preload = otherConfig.preload != undefined ? otherConfig.preload : false;
|
|
@@ -4396,7 +4498,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4396
4498
|
let item = new LoaderItem();
|
|
4397
4499
|
item.type = "Prefab";
|
|
4398
4500
|
// 加载json文件
|
|
4399
|
-
item.uri = new AssetURI
|
|
4501
|
+
item.uri = new AssetURI(uri);
|
|
4400
4502
|
if (otherConfig) {
|
|
4401
4503
|
item.onComplete = otherConfig.onComplete;
|
|
4402
4504
|
item.preload = otherConfig.preload != undefined ? otherConfig.preload : false;
|
|
@@ -4407,14 +4509,14 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4407
4509
|
loadConfig(uri) {
|
|
4408
4510
|
let item = new LoaderItem();
|
|
4409
4511
|
item.type = "Config";
|
|
4410
|
-
item.uri = new AssetURI
|
|
4512
|
+
item.uri = new AssetURI(uri);
|
|
4411
4513
|
this._loaderList.push(item);
|
|
4412
4514
|
return this;
|
|
4413
4515
|
}
|
|
4414
4516
|
loadSpriteFrame(uri, otherConfig) {
|
|
4415
4517
|
let item = new LoaderItem();
|
|
4416
4518
|
item.type = "SpriteFrame";
|
|
4417
|
-
item.uri = new AssetURI
|
|
4519
|
+
item.uri = new AssetURI(uri);
|
|
4418
4520
|
if (otherConfig) {
|
|
4419
4521
|
item.onComplete = otherConfig.onComplete;
|
|
4420
4522
|
}
|
|
@@ -4424,7 +4526,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4424
4526
|
loadImageAsset(uri, otherConfig) {
|
|
4425
4527
|
let item = new LoaderItem();
|
|
4426
4528
|
item.type = "ImageAsset";
|
|
4427
|
-
item.uri = new AssetURI
|
|
4529
|
+
item.uri = new AssetURI(uri);
|
|
4428
4530
|
if (otherConfig) {
|
|
4429
4531
|
item.onComplete = otherConfig.onHandler;
|
|
4430
4532
|
}
|
|
@@ -4434,7 +4536,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4434
4536
|
_loadSpriteFrameByBundle(uri, bundle) {
|
|
4435
4537
|
let item = new LoaderItem();
|
|
4436
4538
|
item.type = "SpriteFrame";
|
|
4437
|
-
item.uri = new AssetURI
|
|
4539
|
+
item.uri = new AssetURI(`${bundle.name}://${uri}`);
|
|
4438
4540
|
item.bundle = bundle;
|
|
4439
4541
|
this._loaderList.push(item);
|
|
4440
4542
|
}
|
|
@@ -4448,7 +4550,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4448
4550
|
resolve(this);
|
|
4449
4551
|
}
|
|
4450
4552
|
else {
|
|
4451
|
-
let listener = Listener
|
|
4553
|
+
let listener = Listener.create();
|
|
4452
4554
|
let succeed = () => {
|
|
4453
4555
|
listener.off();
|
|
4454
4556
|
resolve(this);
|
|
@@ -4489,7 +4591,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4489
4591
|
break;
|
|
4490
4592
|
}
|
|
4491
4593
|
case "Atlas": {
|
|
4492
|
-
let asset = assetx
|
|
4594
|
+
let asset = assetx.getAsset(item.uri.name);
|
|
4493
4595
|
if (asset) {
|
|
4494
4596
|
if (asset instanceof SpriteAtlas) {
|
|
4495
4597
|
this._loaded++;
|
|
@@ -4515,7 +4617,7 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4515
4617
|
break;
|
|
4516
4618
|
}
|
|
4517
4619
|
case "Prefab": {
|
|
4518
|
-
let asset = assetx
|
|
4620
|
+
let asset = assetx.getAsset(item.uri.name);
|
|
4519
4621
|
if (asset) {
|
|
4520
4622
|
this._loaded++;
|
|
4521
4623
|
item.callHandler(null, asset);
|
|
@@ -4622,14 +4724,14 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4622
4724
|
textureUrl = item.uri.name;
|
|
4623
4725
|
break;
|
|
4624
4726
|
}
|
|
4625
|
-
textureItem.uri = new AssetURI
|
|
4727
|
+
textureItem.uri = new AssetURI(textureUrl);
|
|
4626
4728
|
//
|
|
4627
4729
|
this._loadByItem(textureItem, ImageAsset, (err, asset) => {
|
|
4628
4730
|
if (!err) {
|
|
4629
4731
|
let tex = new Texture2D();
|
|
4630
4732
|
tex.image = asset;
|
|
4631
4733
|
tex.setFilters(1, 1);
|
|
4632
|
-
let atlasSprite = parseAtlas
|
|
4734
|
+
let atlasSprite = parseAtlas(item.uri, content, tex);
|
|
4633
4735
|
let uuid = atlasAsset.uuid;
|
|
4634
4736
|
assetManager.assets.remove(uuid);
|
|
4635
4737
|
assetManager.assets.add(uuid, atlasSprite);
|
|
@@ -4729,111 +4831,6 @@ class AssetLoader extends Dispatcher$1 {
|
|
|
4729
4831
|
}
|
|
4730
4832
|
}
|
|
4731
4833
|
|
|
4732
|
-
class AssetURI {
|
|
4733
|
-
constructor(name) {
|
|
4734
|
-
this.name = name;
|
|
4735
|
-
// 0-bundle+path 1-uuid 2-remote
|
|
4736
|
-
this.loadType = 0;
|
|
4737
|
-
let arr = name.split("://");
|
|
4738
|
-
if (arr.length == 2) {
|
|
4739
|
-
let head = arr[0];
|
|
4740
|
-
if (head == "uuid") {
|
|
4741
|
-
this.loadType = 1;
|
|
4742
|
-
this.uuid = arr[1];
|
|
4743
|
-
}
|
|
4744
|
-
else if (head == "http" || head == "https") {
|
|
4745
|
-
this.loadType = 2;
|
|
4746
|
-
}
|
|
4747
|
-
else {
|
|
4748
|
-
this.bundle = head;
|
|
4749
|
-
this.path = arr[1];
|
|
4750
|
-
}
|
|
4751
|
-
}
|
|
4752
|
-
else {
|
|
4753
|
-
this.bundle = "resources";
|
|
4754
|
-
this.path = name;
|
|
4755
|
-
}
|
|
4756
|
-
}
|
|
4757
|
-
}
|
|
4758
|
-
class XAssetManager {
|
|
4759
|
-
getAsset(uri) {
|
|
4760
|
-
let obj = new AssetURI(uri);
|
|
4761
|
-
switch (obj.loadType) {
|
|
4762
|
-
case 1:
|
|
4763
|
-
return assetManager.assets.get(obj.uuid);
|
|
4764
|
-
case 2:
|
|
4765
|
-
return assetManager.assets.get(obj.name);
|
|
4766
|
-
default:
|
|
4767
|
-
let bundle = assetManager.getBundle(obj.bundle);
|
|
4768
|
-
if (!bundle) {
|
|
4769
|
-
return null;
|
|
4770
|
-
}
|
|
4771
|
-
return bundle.get(obj.path);
|
|
4772
|
-
}
|
|
4773
|
-
}
|
|
4774
|
-
getAssetByUUID(uuid) {
|
|
4775
|
-
return assetManager.assets.get(uuid);
|
|
4776
|
-
}
|
|
4777
|
-
getRoot() {
|
|
4778
|
-
return assetManager;
|
|
4779
|
-
}
|
|
4780
|
-
}
|
|
4781
|
-
let assetx = new XAssetManager();
|
|
4782
|
-
|
|
4783
|
-
function parseAtlas(name, plist, texture) {
|
|
4784
|
-
plist.meta;
|
|
4785
|
-
let frames = plist.frames;
|
|
4786
|
-
let atlas = new SpriteAtlas();
|
|
4787
|
-
atlas.name = name;
|
|
4788
|
-
atlas._nativeAsset = plist;
|
|
4789
|
-
let spriteFrames = atlas.spriteFrames;
|
|
4790
|
-
// 1/1_1_0.png:{
|
|
4791
|
-
// frame: {x: 137, y: 302, w: 18, h: 24}
|
|
4792
|
-
// rotated: false
|
|
4793
|
-
// sourceSize: {w: 32, h: 32}
|
|
4794
|
-
// spriteSourceSize: {x: 7, y: 0, w: 18, h: 24}
|
|
4795
|
-
// trimmed: true
|
|
4796
|
-
// }
|
|
4797
|
-
let maxWidth = 0;
|
|
4798
|
-
let maxHeight = 0;
|
|
4799
|
-
for (let key in frames) {
|
|
4800
|
-
let frame = frames[key];
|
|
4801
|
-
let rotated = false, sourceSize, offset, textureRect;
|
|
4802
|
-
rotated = frame.rotated;
|
|
4803
|
-
{
|
|
4804
|
-
let size = frame.sourceSize;
|
|
4805
|
-
sourceSize = new Size(size.w, size.h);
|
|
4806
|
-
maxWidth = Math.max(maxWidth, size.w);
|
|
4807
|
-
maxHeight = Math.max(maxHeight, size.h);
|
|
4808
|
-
}
|
|
4809
|
-
{ // 需要转化成以sourceSize的中心点为原点,cocos坐标系的偏移量
|
|
4810
|
-
let pos = frame.spriteSourceSize;
|
|
4811
|
-
offset = new Vec2(pos.x + pos.w * 0.5, pos.y + pos.h * 0.5);
|
|
4812
|
-
offset.x -= sourceSize.width * 0.5;
|
|
4813
|
-
offset.y -= sourceSize.height * 0.5;
|
|
4814
|
-
offset.y = -offset.y; // y轴相反
|
|
4815
|
-
}
|
|
4816
|
-
{
|
|
4817
|
-
let rect = frame.frame;
|
|
4818
|
-
textureRect = new Rect(rect.x, rect.y, rect.w, rect.h);
|
|
4819
|
-
}
|
|
4820
|
-
var sprite = new SpriteFrame();
|
|
4821
|
-
sprite.name = key;
|
|
4822
|
-
sprite.reset({
|
|
4823
|
-
originalSize: sourceSize,
|
|
4824
|
-
rect: textureRect,
|
|
4825
|
-
offset: offset,
|
|
4826
|
-
isRotate: !!rotated,
|
|
4827
|
-
texture: texture
|
|
4828
|
-
});
|
|
4829
|
-
let name = path.mainFileName(key);
|
|
4830
|
-
spriteFrames[name] = sprite;
|
|
4831
|
-
}
|
|
4832
|
-
//
|
|
4833
|
-
plist.meta.maxSize = { w: maxWidth, h: maxHeight };
|
|
4834
|
-
return atlas;
|
|
4835
|
-
}
|
|
4836
|
-
|
|
4837
4834
|
class UIUtil {
|
|
4838
4835
|
/**
|
|
4839
4836
|
* 格式化节点的uuid,用于树结构
|
|
@@ -5998,5 +5995,5 @@ class PathUtil {
|
|
|
5998
5995
|
}
|
|
5999
5996
|
const pathutil = new PathUtil();
|
|
6000
5997
|
|
|
6001
|
-
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 };
|
|
5998
|
+
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, timer, timeutil, uidict, uimgr, uiutil };
|
|
6002
5999
|
//# sourceMappingURL=index.esm.js.map
|