@galacean/engine-core 2.0.0-alpha.13 → 2.0.0-alpha.15
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/main.js +1229 -1028
- package/dist/main.js.map +1 -1
- package/dist/module.js +1228 -1029
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Signal.d.ts +58 -0
- package/types/asset/AssetType.d.ts +3 -1
- package/types/clone/CloneUtils.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/texture/RenderTarget.d.ts +4 -0
package/dist/main.js
CHANGED
|
@@ -1654,6 +1654,14 @@ SystemInfo._initialize();
|
|
|
1654
1654
|
return this._height;
|
|
1655
1655
|
}
|
|
1656
1656
|
},
|
|
1657
|
+
{
|
|
1658
|
+
key: "colorTextures",
|
|
1659
|
+
get: /**
|
|
1660
|
+
* Render color textures.
|
|
1661
|
+
*/ function get() {
|
|
1662
|
+
return this._colorTextures;
|
|
1663
|
+
}
|
|
1664
|
+
},
|
|
1657
1665
|
{
|
|
1658
1666
|
key: "colorTextureCount",
|
|
1659
1667
|
get: /**
|
|
@@ -22286,275 +22294,978 @@ PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
|
22286
22294
|
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
22287
22295
|
PrimitiveMesh._spherePoleIdx = 0;
|
|
22288
22296
|
|
|
22289
|
-
|
|
22290
|
-
|
|
22291
|
-
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
|
|
22296
|
-
|
|
22297
|
-
|
|
22298
|
-
}
|
|
22299
|
-
|
|
22300
|
-
|
|
22301
|
-
|
|
22302
|
-
|
|
22303
|
-
|
|
22304
|
-
|
|
22305
|
-
|
|
22306
|
-
|
|
22307
|
-
|
|
22308
|
-
var
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
return instance;
|
|
22316
|
-
};
|
|
22317
|
-
}
|
|
22318
|
-
|
|
22319
|
-
return _construct.apply(null, arguments);
|
|
22320
|
-
}
|
|
22321
|
-
|
|
22322
|
-
var ComponentCloner = /*#__PURE__*/ function() {
|
|
22323
|
-
function ComponentCloner() {}
|
|
22324
|
-
/**
|
|
22325
|
-
* Clone component.
|
|
22326
|
-
* @param source - Clone source
|
|
22327
|
-
* @param target - Clone target
|
|
22328
|
-
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
22329
|
-
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
22330
|
-
for(var k in source){
|
|
22331
|
-
CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
|
|
22297
|
+
/**
|
|
22298
|
+
* @internal
|
|
22299
|
+
* Utility functions for remapping Entity/Component references during cloning.
|
|
22300
|
+
*/ var CloneUtils = /*#__PURE__*/ function() {
|
|
22301
|
+
function CloneUtils() {}
|
|
22302
|
+
CloneUtils.remapEntity = function remapEntity(srcRoot, targetRoot, entity) {
|
|
22303
|
+
var paths = CloneUtils._tempRemapPath;
|
|
22304
|
+
var success = CloneUtils._getEntityHierarchyPath(srcRoot, entity, paths);
|
|
22305
|
+
return success ? CloneUtils._getEntityByHierarchyPath(targetRoot, paths) : entity;
|
|
22306
|
+
};
|
|
22307
|
+
CloneUtils.remapComponent = function remapComponent(srcRoot, targetRoot, component) {
|
|
22308
|
+
var _CloneUtils__getEntityByHierarchyPath;
|
|
22309
|
+
var paths = CloneUtils._tempRemapPath;
|
|
22310
|
+
var success = CloneUtils._getEntityHierarchyPath(srcRoot, component.entity, paths);
|
|
22311
|
+
return success ? (_CloneUtils__getEntityByHierarchyPath = CloneUtils._getEntityByHierarchyPath(targetRoot, paths)) == null ? void 0 : _CloneUtils__getEntityByHierarchyPath.getComponent(component.constructor) : component;
|
|
22312
|
+
};
|
|
22313
|
+
CloneUtils._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
|
|
22314
|
+
inversePath.length = 0;
|
|
22315
|
+
while(searchEntity !== rootEntity){
|
|
22316
|
+
var parent = searchEntity.parent;
|
|
22317
|
+
if (!parent) {
|
|
22318
|
+
return false;
|
|
22319
|
+
}
|
|
22320
|
+
inversePath.push(searchEntity.siblingIndex);
|
|
22321
|
+
searchEntity = parent;
|
|
22332
22322
|
}
|
|
22333
|
-
|
|
22334
|
-
|
|
22323
|
+
return true;
|
|
22324
|
+
};
|
|
22325
|
+
CloneUtils._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
|
|
22326
|
+
var entity = rootEntity;
|
|
22327
|
+
for(var i = inversePath.length - 1; i >= 0; i--){
|
|
22328
|
+
entity = entity.children[inversePath[i]];
|
|
22335
22329
|
}
|
|
22330
|
+
return entity;
|
|
22336
22331
|
};
|
|
22337
|
-
return
|
|
22332
|
+
return CloneUtils;
|
|
22338
22333
|
}();
|
|
22334
|
+
CloneUtils._tempRemapPath = [];
|
|
22339
22335
|
|
|
22340
22336
|
/**
|
|
22341
|
-
*
|
|
22342
|
-
*/ var
|
|
22343
|
-
|
|
22344
|
-
|
|
22345
|
-
return EntityModifyFlags;
|
|
22346
|
-
}({});
|
|
22347
|
-
|
|
22348
|
-
/**
|
|
22349
|
-
* Entity, be used as components container.
|
|
22350
|
-
*/ var Entity = /*#__PURE__*/ function(EngineObject) {
|
|
22351
|
-
_inherits(Entity, EngineObject);
|
|
22352
|
-
function Entity(engine, name) {
|
|
22353
|
-
for(var _len = arguments.length, components = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
22354
|
-
components[_key - 2] = arguments[_key];
|
|
22355
|
-
}
|
|
22337
|
+
* Skin used for skinned mesh renderer.
|
|
22338
|
+
*/ var Skin = /*#__PURE__*/ function(EngineObject) {
|
|
22339
|
+
_inherits(Skin, EngineObject);
|
|
22340
|
+
function Skin(name) {
|
|
22356
22341
|
var _this;
|
|
22357
|
-
_this = EngineObject.call(this,
|
|
22358
|
-
_this._invModelMatrix = new engineMath.Matrix();
|
|
22359
|
-
_this.name = name != null ? name : "Entity";
|
|
22360
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
22361
|
-
_this.addComponent(components[i]);
|
|
22362
|
-
}
|
|
22363
|
-
!_this._transform && _this.addComponent(Transform);
|
|
22364
|
-
_this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
|
|
22342
|
+
_this = EngineObject.call(this, null) || this, _this.name = name, _this.inverseBindMatrices = new Array(), _this._updatedManager = new UpdateFlagManager(), _this._bones = new Array(), _this._updateMark = -1, _this.joints = [];
|
|
22365
22343
|
return _this;
|
|
22366
22344
|
}
|
|
22367
|
-
var _proto =
|
|
22345
|
+
var _proto = Skin.prototype;
|
|
22368
22346
|
/**
|
|
22369
|
-
*
|
|
22370
|
-
|
|
22371
|
-
|
|
22372
|
-
|
|
22373
|
-
*/ _proto.addComponent = function addComponent(type) {
|
|
22374
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
22375
|
-
args[_key - 1] = arguments[_key];
|
|
22347
|
+
* @internal
|
|
22348
|
+
*/ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
|
|
22349
|
+
if (this._updateMark === renderer.engine.time.frameCount) {
|
|
22350
|
+
return;
|
|
22376
22351
|
}
|
|
22377
|
-
|
|
22378
|
-
var
|
|
22379
|
-
|
|
22380
|
-
|
|
22381
|
-
|
|
22382
|
-
|
|
22383
|
-
|
|
22384
|
-
|
|
22385
|
-
|
|
22386
|
-
|
|
22387
|
-
/**
|
|
22388
|
-
* Get component which match the type.
|
|
22389
|
-
* @param type - The type of the component
|
|
22390
|
-
* @returns The first component which match type
|
|
22391
|
-
*/ _proto.getComponent = function getComponent(type) {
|
|
22392
|
-
var components = this._components;
|
|
22393
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
22394
|
-
var component = components[i];
|
|
22395
|
-
if (_instanceof(component, type)) {
|
|
22396
|
-
return component;
|
|
22352
|
+
var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
|
|
22353
|
+
var _this_rootBone;
|
|
22354
|
+
var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
|
|
22355
|
+
for(var i = bones.length - 1; i >= 0; i--){
|
|
22356
|
+
var bone = bones[i];
|
|
22357
|
+
var offset = i * 16;
|
|
22358
|
+
if (bone) {
|
|
22359
|
+
Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
|
|
22360
|
+
} else {
|
|
22361
|
+
skinMatrices.set(bindMatrices[i].elements, offset);
|
|
22397
22362
|
}
|
|
22363
|
+
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
22398
22364
|
}
|
|
22399
|
-
|
|
22365
|
+
this._updateMark = renderer.engine.time.frameCount;
|
|
22400
22366
|
};
|
|
22401
22367
|
/**
|
|
22402
|
-
*
|
|
22403
|
-
|
|
22404
|
-
|
|
22405
|
-
|
|
22406
|
-
|
|
22407
|
-
|
|
22408
|
-
|
|
22409
|
-
|
|
22410
|
-
|
|
22411
|
-
|
|
22412
|
-
|
|
22368
|
+
* @internal
|
|
22369
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
22370
|
+
// Clone rootBone
|
|
22371
|
+
var rootBone = this.rootBone;
|
|
22372
|
+
if (rootBone) {
|
|
22373
|
+
target.rootBone = CloneUtils.remapEntity(srcRoot, targetRoot, rootBone);
|
|
22374
|
+
}
|
|
22375
|
+
// Clone bones
|
|
22376
|
+
var bones = this.bones;
|
|
22377
|
+
if (bones.length > 0) {
|
|
22378
|
+
var boneCount = bones.length;
|
|
22379
|
+
var destBones = new Array(boneCount);
|
|
22380
|
+
for(var i = 0; i < boneCount; i++){
|
|
22381
|
+
destBones[i] = CloneUtils.remapEntity(srcRoot, targetRoot, bones[i]);
|
|
22413
22382
|
}
|
|
22383
|
+
target.bones = destBones;
|
|
22414
22384
|
}
|
|
22415
|
-
return results;
|
|
22416
|
-
};
|
|
22417
|
-
/**
|
|
22418
|
-
* Get the components which match the type of the entity and it's children.
|
|
22419
|
-
* @param type - The component type
|
|
22420
|
-
* @param results - The components collection
|
|
22421
|
-
* @returns The components collection which match the type
|
|
22422
|
-
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
22423
|
-
results.length = 0;
|
|
22424
|
-
this._getComponentsInChildren(type, results);
|
|
22425
|
-
return results;
|
|
22426
22385
|
};
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
|
|
22433
|
-
|
|
22386
|
+
_create_class(Skin, [
|
|
22387
|
+
{
|
|
22388
|
+
key: "rootBone",
|
|
22389
|
+
get: /**
|
|
22390
|
+
* Root bone.
|
|
22391
|
+
*/ function get() {
|
|
22392
|
+
return this._rootBone;
|
|
22393
|
+
},
|
|
22394
|
+
set: function set(value) {
|
|
22395
|
+
if (this._rootBone !== value) {
|
|
22396
|
+
this._updatedManager.dispatch(1, value);
|
|
22397
|
+
this._rootBone = value;
|
|
22398
|
+
}
|
|
22399
|
+
}
|
|
22400
|
+
},
|
|
22401
|
+
{
|
|
22402
|
+
key: "bones",
|
|
22403
|
+
get: /**
|
|
22404
|
+
* Bones of the skin.
|
|
22405
|
+
*/ function get() {
|
|
22406
|
+
return this._bones;
|
|
22407
|
+
},
|
|
22408
|
+
set: function set(value) {
|
|
22409
|
+
var bones = this._bones;
|
|
22410
|
+
var _value_length;
|
|
22411
|
+
var boneCount = (_value_length = value == null ? void 0 : value.length) != null ? _value_length : 0;
|
|
22412
|
+
var lastBoneCount = bones.length;
|
|
22413
|
+
bones.length = boneCount;
|
|
22414
|
+
for(var i = 0; i < boneCount; i++){
|
|
22415
|
+
bones[i] = value[i];
|
|
22416
|
+
}
|
|
22417
|
+
if (lastBoneCount !== boneCount) {
|
|
22418
|
+
this._skinMatrices = new Float32Array(boneCount * 16);
|
|
22419
|
+
this._updatedManager.dispatch(0, boneCount);
|
|
22420
|
+
}
|
|
22421
|
+
}
|
|
22422
|
+
},
|
|
22423
|
+
{
|
|
22424
|
+
key: "skeleton",
|
|
22425
|
+
get: /** @deprecated Please use `rootBone` instead. */ function get() {
|
|
22426
|
+
var _this_rootBone;
|
|
22427
|
+
return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
|
|
22428
|
+
},
|
|
22429
|
+
set: function set(value) {
|
|
22430
|
+
var rootBone = this._rootBone;
|
|
22431
|
+
if (rootBone) {
|
|
22432
|
+
rootBone.name = value;
|
|
22433
|
+
}
|
|
22434
|
+
}
|
|
22434
22435
|
}
|
|
22435
|
-
|
|
22436
|
-
|
|
22436
|
+
]);
|
|
22437
|
+
return Skin;
|
|
22438
|
+
}(EngineObject);
|
|
22439
|
+
__decorate([
|
|
22440
|
+
deepClone
|
|
22441
|
+
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
22442
|
+
__decorate([
|
|
22443
|
+
ignoreClone
|
|
22444
|
+
], Skin.prototype, "_skinMatrices", void 0);
|
|
22445
|
+
__decorate([
|
|
22446
|
+
ignoreClone
|
|
22447
|
+
], Skin.prototype, "_updatedManager", void 0);
|
|
22448
|
+
__decorate([
|
|
22449
|
+
ignoreClone
|
|
22450
|
+
], Skin.prototype, "_rootBone", void 0);
|
|
22451
|
+
__decorate([
|
|
22452
|
+
ignoreClone
|
|
22453
|
+
], Skin.prototype, "_bones", void 0);
|
|
22454
|
+
__decorate([
|
|
22455
|
+
ignoreClone
|
|
22456
|
+
], Skin.prototype, "_updateMark", void 0);
|
|
22457
|
+
var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
|
|
22458
|
+
SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
|
|
22459
|
+
SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
|
|
22460
|
+
return SkinUpdateFlag;
|
|
22461
|
+
}({});
|
|
22462
|
+
|
|
22463
|
+
/**
|
|
22464
|
+
* SkinnedMeshRenderer.
|
|
22465
|
+
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer) {
|
|
22466
|
+
_inherits(SkinnedMeshRenderer, MeshRenderer);
|
|
22467
|
+
function SkinnedMeshRenderer(entity) {
|
|
22468
|
+
var _this;
|
|
22469
|
+
_this = MeshRenderer.call(this, entity) || this, _this._localBounds = new engineMath.BoundingBox(), _this._jointDataCreateCache = new engineMath.Vector2(-1, -1);
|
|
22470
|
+
_this._skin = null;
|
|
22471
|
+
var rhi = _this.entity.engine._hardwareRenderer;
|
|
22472
|
+
var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
|
|
22473
|
+
// Limit size to 256 to avoid some problem:
|
|
22474
|
+
// For renderer is "Apple GPU", when uniform is large than 256 the skeleton matrix array access in shader very slow in Safari or WKWebview. This may be a apple bug, Chrome and Firefox is OK!
|
|
22475
|
+
// For renderer is "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3011 vs_5_0 ps_5_0, D3011)", compile shader si very slow because of max uniform is 4096.
|
|
22476
|
+
maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
|
|
22477
|
+
_this._maxVertexUniformVectors = maxVertexUniformVectors;
|
|
22478
|
+
_this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_this);
|
|
22479
|
+
_this._onSkinUpdated = _this._onSkinUpdated.bind(_this);
|
|
22480
|
+
var localBounds = _this._localBounds;
|
|
22481
|
+
// @ts-ignore
|
|
22482
|
+
localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
|
|
22483
|
+
// @ts-ignore
|
|
22484
|
+
localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
|
|
22485
|
+
return _this;
|
|
22486
|
+
}
|
|
22487
|
+
var _proto = SkinnedMeshRenderer.prototype;
|
|
22437
22488
|
/**
|
|
22438
|
-
*
|
|
22439
|
-
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
|
|
22489
|
+
* @internal
|
|
22490
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
22491
|
+
var _this__jointTexture;
|
|
22492
|
+
MeshRenderer.prototype._onDestroy.call(this);
|
|
22493
|
+
this._jointDataCreateCache = null;
|
|
22494
|
+
this._skin = null;
|
|
22495
|
+
this._blendShapeWeights = null;
|
|
22496
|
+
this._localBounds = null;
|
|
22497
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
22498
|
+
this._jointTexture = null;
|
|
22443
22499
|
};
|
|
22444
22500
|
/**
|
|
22445
|
-
* @
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22501
|
+
* @internal
|
|
22502
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
22503
|
+
MeshRenderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
|
|
22504
|
+
if (this.skin) {
|
|
22505
|
+
target._applySkin(null, target.skin);
|
|
22506
|
+
}
|
|
22507
|
+
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
22451
22508
|
};
|
|
22452
|
-
|
|
22453
|
-
|
|
22454
|
-
|
|
22455
|
-
|
|
22456
|
-
*/ _proto.findByName = function findByName(name) {
|
|
22457
|
-
if (name === this.name) {
|
|
22458
|
-
return this;
|
|
22509
|
+
_proto._update = function _update(context) {
|
|
22510
|
+
var skin = this.skin;
|
|
22511
|
+
if ((skin == null ? void 0 : skin.bones.length) > 0) {
|
|
22512
|
+
skin._updateSkinMatrices(this);
|
|
22459
22513
|
}
|
|
22460
|
-
var
|
|
22461
|
-
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
|
|
22514
|
+
var shaderData = this.shaderData;
|
|
22515
|
+
var mesh = this.mesh;
|
|
22516
|
+
var blendShapeManager = mesh._blendShapeManager;
|
|
22517
|
+
blendShapeManager._updateShaderData(shaderData, this);
|
|
22518
|
+
var bones = skin == null ? void 0 : skin.bones;
|
|
22519
|
+
if (bones) {
|
|
22520
|
+
var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
|
|
22521
|
+
var boneCount = bones.length;
|
|
22522
|
+
var boneDataCreateCache = this._jointDataCreateCache;
|
|
22523
|
+
var boneCountChange = boneCount !== boneDataCreateCache.x;
|
|
22524
|
+
if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
|
|
22525
|
+
// directly use max joint count to avoid shader recompile
|
|
22526
|
+
var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) / 4);
|
|
22527
|
+
if (boneCount > remainUniformJointCount) {
|
|
22528
|
+
var engine = this.engine;
|
|
22529
|
+
if (engine._hardwareRenderer.canIUseMoreJoints) {
|
|
22530
|
+
if (boneCountChange) {
|
|
22531
|
+
var _this__jointTexture;
|
|
22532
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
22533
|
+
this._jointTexture = new Texture2D(engine, 4, boneCount, TextureFormat.R32G32B32A32, false, false);
|
|
22534
|
+
this._jointTexture.filterMode = TextureFilterMode.Point;
|
|
22535
|
+
this._jointTexture.isGCIgnored = true;
|
|
22536
|
+
}
|
|
22537
|
+
shaderData.disableMacro("RENDERER_JOINTS_NUM");
|
|
22538
|
+
shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
22539
|
+
shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
|
|
22540
|
+
} else {
|
|
22541
|
+
Logger.error("component's joints count(" + boneCount + ") greater than device's MAX_VERTEX_UNIFORM_VECTORS number " + this._maxVertexUniformVectors + ", and don't support jointTexture in this device. suggest joint count less than " + remainUniformJointCount + ".", this);
|
|
22542
|
+
}
|
|
22543
|
+
} else {
|
|
22544
|
+
var _this__jointTexture1;
|
|
22545
|
+
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
22546
|
+
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
22547
|
+
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
22548
|
+
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
|
|
22549
|
+
}
|
|
22550
|
+
boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
|
|
22551
|
+
}
|
|
22552
|
+
if (this._jointTexture) {
|
|
22553
|
+
this._jointTexture.setPixelBuffer(skin._skinMatrices);
|
|
22465
22554
|
}
|
|
22466
22555
|
}
|
|
22467
|
-
|
|
22556
|
+
MeshRenderer.prototype._update.call(this, context);
|
|
22468
22557
|
};
|
|
22469
22558
|
/**
|
|
22470
|
-
*
|
|
22471
|
-
|
|
22472
|
-
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22559
|
+
* @internal
|
|
22560
|
+
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
22561
|
+
var _this_skin;
|
|
22562
|
+
var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
|
|
22563
|
+
if (rootBone) {
|
|
22564
|
+
engineMath.BoundingBox.transform(this._localBounds, this._transformEntity.transform.worldMatrix, worldBounds);
|
|
22565
|
+
} else {
|
|
22566
|
+
MeshRenderer.prototype._updateBounds.call(this, worldBounds);
|
|
22477
22567
|
}
|
|
22478
|
-
return Entity._findChildByName(this, 0, splits, 0);
|
|
22479
|
-
};
|
|
22480
|
-
/**
|
|
22481
|
-
* Create child entity.
|
|
22482
|
-
* @param name - The child entity's name
|
|
22483
|
-
* @returns The child entity
|
|
22484
|
-
*/ _proto.createChild = function createChild(name) {
|
|
22485
|
-
var transform = this._transform;
|
|
22486
|
-
var child = transform ? new Entity(this.engine, name, transform.constructor) : new Entity(this.engine, name);
|
|
22487
|
-
child.layer = this.layer;
|
|
22488
|
-
child.parent = this;
|
|
22489
|
-
return child;
|
|
22490
22568
|
};
|
|
22491
|
-
|
|
22492
|
-
|
|
22493
|
-
|
|
22494
|
-
var
|
|
22495
|
-
|
|
22496
|
-
var
|
|
22497
|
-
|
|
22498
|
-
|
|
22499
|
-
|
|
22500
|
-
|
|
22501
|
-
|
|
22502
|
-
|
|
22569
|
+
_proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
|
|
22570
|
+
var mesh = this._mesh;
|
|
22571
|
+
var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
|
|
22572
|
+
var lastBlendShapeWeights = this._blendShapeWeights;
|
|
22573
|
+
if (lastBlendShapeWeights) {
|
|
22574
|
+
var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
|
|
22575
|
+
if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
|
|
22576
|
+
var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
22577
|
+
if (newBlendShapeCount > lastBlendShapeWeightsCount) {
|
|
22578
|
+
newBlendShapeWeights.set(lastBlendShapeWeights);
|
|
22579
|
+
} else {
|
|
22580
|
+
for(var i = 0; i < newBlendShapeCount; i++){
|
|
22581
|
+
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
22582
|
+
}
|
|
22583
|
+
}
|
|
22584
|
+
this._blendShapeWeights = newBlendShapeWeights;
|
|
22585
|
+
}
|
|
22586
|
+
} else {
|
|
22587
|
+
this._blendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
22503
22588
|
}
|
|
22504
|
-
children.length = 0;
|
|
22505
|
-
};
|
|
22506
|
-
/**
|
|
22507
|
-
* Clone this entity include children and components.
|
|
22508
|
-
* @returns Cloned entity
|
|
22509
|
-
*/ _proto.clone = function clone() {
|
|
22510
|
-
var cloneEntity = this._createCloneEntity();
|
|
22511
|
-
this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
|
|
22512
|
-
return cloneEntity;
|
|
22513
|
-
};
|
|
22514
|
-
/**
|
|
22515
|
-
* Listen for changes in the world pose of this `Entity`.
|
|
22516
|
-
* @returns Change flag
|
|
22517
|
-
*/ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
|
|
22518
|
-
return this._updateFlagManager.createFlag(BoolUpdateFlag);
|
|
22519
22589
|
};
|
|
22520
|
-
|
|
22521
|
-
|
|
22522
|
-
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
22523
|
-
this._isTemplate = true;
|
|
22524
|
-
this._templateResource = templateResource;
|
|
22590
|
+
_proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
|
|
22591
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
22525
22592
|
};
|
|
22526
|
-
_proto.
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22593
|
+
_proto._onSkinUpdated = function _onSkinUpdated(type, value) {
|
|
22594
|
+
switch(type){
|
|
22595
|
+
case SkinUpdateFlag.BoneCountChanged:
|
|
22596
|
+
var shaderData = this.shaderData;
|
|
22597
|
+
if (value > 0) {
|
|
22598
|
+
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
22599
|
+
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
|
|
22600
|
+
} else {
|
|
22601
|
+
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
22602
|
+
}
|
|
22603
|
+
break;
|
|
22604
|
+
case SkinUpdateFlag.RootBoneChanged:
|
|
22605
|
+
this._setTransformEntity(value);
|
|
22606
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
22607
|
+
break;
|
|
22531
22608
|
}
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
var
|
|
22538
|
-
|
|
22539
|
-
|
|
22540
|
-
|
|
22609
|
+
};
|
|
22610
|
+
_proto._applySkin = function _applySkin(lastSkin, value) {
|
|
22611
|
+
var _lastSkin_bones, _value_bones;
|
|
22612
|
+
var _lastSkin_bones_length;
|
|
22613
|
+
var lastSkinBoneCount = (_lastSkin_bones_length = lastSkin == null ? void 0 : (_lastSkin_bones = lastSkin.bones) == null ? void 0 : _lastSkin_bones.length) != null ? _lastSkin_bones_length : 0;
|
|
22614
|
+
var _lastSkin_rootBone;
|
|
22615
|
+
var lastRootBone = (_lastSkin_rootBone = lastSkin == null ? void 0 : lastSkin.rootBone) != null ? _lastSkin_rootBone : this.entity;
|
|
22616
|
+
lastSkin == null ? void 0 : lastSkin._updatedManager.removeListener(this._onSkinUpdated);
|
|
22617
|
+
var _value_bones_length;
|
|
22618
|
+
var skinBoneCount = (_value_bones_length = value == null ? void 0 : (_value_bones = value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
|
|
22619
|
+
var _value_rootBone;
|
|
22620
|
+
var rootBone = (_value_rootBone = value == null ? void 0 : value.rootBone) != null ? _value_rootBone : this.entity;
|
|
22621
|
+
value == null ? void 0 : value._updatedManager.addListener(this._onSkinUpdated);
|
|
22622
|
+
if (lastSkinBoneCount !== skinBoneCount) {
|
|
22623
|
+
this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
|
|
22541
22624
|
}
|
|
22542
|
-
|
|
22543
|
-
|
|
22544
|
-
var srcChildren = this._children;
|
|
22545
|
-
for(var i1 = 0, n1 = srcChildren.length; i1 < n1; i1++){
|
|
22546
|
-
cloneEntity.addChild(srcChildren[i1]._createCloneEntity());
|
|
22625
|
+
if (lastRootBone !== rootBone) {
|
|
22626
|
+
this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
|
|
22547
22627
|
}
|
|
22548
|
-
return cloneEntity;
|
|
22549
22628
|
};
|
|
22550
|
-
|
|
22551
|
-
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
|
|
22556
|
-
|
|
22557
|
-
|
|
22629
|
+
_create_class(SkinnedMeshRenderer, [
|
|
22630
|
+
{
|
|
22631
|
+
key: "skin",
|
|
22632
|
+
get: /**
|
|
22633
|
+
* Skin of the SkinnedMeshRenderer.
|
|
22634
|
+
*/ function get() {
|
|
22635
|
+
return this._skin;
|
|
22636
|
+
},
|
|
22637
|
+
set: function set(value) {
|
|
22638
|
+
var lastSkin = this._skin;
|
|
22639
|
+
if (lastSkin !== value) {
|
|
22640
|
+
this._applySkin(lastSkin, value);
|
|
22641
|
+
this._skin = value;
|
|
22642
|
+
}
|
|
22643
|
+
}
|
|
22644
|
+
},
|
|
22645
|
+
{
|
|
22646
|
+
key: "blendShapeWeights",
|
|
22647
|
+
get: /**
|
|
22648
|
+
* The weights of the BlendShapes.
|
|
22649
|
+
* @remarks Array index is BlendShape index.
|
|
22650
|
+
*/ function get() {
|
|
22651
|
+
this._checkBlendShapeWeightLength();
|
|
22652
|
+
return this._blendShapeWeights;
|
|
22653
|
+
},
|
|
22654
|
+
set: function set(value) {
|
|
22655
|
+
this._checkBlendShapeWeightLength();
|
|
22656
|
+
var blendShapeWeights = this._blendShapeWeights;
|
|
22657
|
+
if (value.length <= blendShapeWeights.length) {
|
|
22658
|
+
blendShapeWeights.set(value);
|
|
22659
|
+
} else {
|
|
22660
|
+
for(var i = 0, n = blendShapeWeights.length; i < n; i++){
|
|
22661
|
+
blendShapeWeights[i] = value[i];
|
|
22662
|
+
}
|
|
22663
|
+
}
|
|
22664
|
+
}
|
|
22665
|
+
},
|
|
22666
|
+
{
|
|
22667
|
+
key: "localBounds",
|
|
22668
|
+
get: /**
|
|
22669
|
+
* Local bounds.
|
|
22670
|
+
*/ function get() {
|
|
22671
|
+
return this._localBounds;
|
|
22672
|
+
},
|
|
22673
|
+
set: function set(value) {
|
|
22674
|
+
if (this._localBounds !== value) {
|
|
22675
|
+
this._localBounds.copyFrom(value);
|
|
22676
|
+
}
|
|
22677
|
+
}
|
|
22678
|
+
},
|
|
22679
|
+
{
|
|
22680
|
+
key: "rootBone",
|
|
22681
|
+
get: /**
|
|
22682
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.rootBone} instead.
|
|
22683
|
+
*/ function get() {
|
|
22684
|
+
return this.skin.rootBone;
|
|
22685
|
+
},
|
|
22686
|
+
set: function set(value) {
|
|
22687
|
+
this.skin.rootBone = value;
|
|
22688
|
+
}
|
|
22689
|
+
},
|
|
22690
|
+
{
|
|
22691
|
+
key: "bones",
|
|
22692
|
+
get: /**
|
|
22693
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.bones} instead.
|
|
22694
|
+
*/ function get() {
|
|
22695
|
+
return this.skin.bones;
|
|
22696
|
+
},
|
|
22697
|
+
set: function set(value) {
|
|
22698
|
+
this.skin.bones = value;
|
|
22699
|
+
}
|
|
22700
|
+
}
|
|
22701
|
+
]);
|
|
22702
|
+
return SkinnedMeshRenderer;
|
|
22703
|
+
}(MeshRenderer);
|
|
22704
|
+
// @TODO: different shader type should use different count, not always 48
|
|
22705
|
+
/** @internal */ SkinnedMeshRenderer._baseVertexUniformVectorCount = 48;
|
|
22706
|
+
SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
|
|
22707
|
+
SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
|
|
22708
|
+
SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
|
|
22709
|
+
__decorate([
|
|
22710
|
+
ignoreClone
|
|
22711
|
+
], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
|
|
22712
|
+
__decorate([
|
|
22713
|
+
deepClone
|
|
22714
|
+
], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
|
|
22715
|
+
__decorate([
|
|
22716
|
+
ignoreClone
|
|
22717
|
+
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
22718
|
+
__decorate([
|
|
22719
|
+
ignoreClone
|
|
22720
|
+
], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
|
|
22721
|
+
__decorate([
|
|
22722
|
+
ignoreClone
|
|
22723
|
+
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
22724
|
+
__decorate([
|
|
22725
|
+
ignoreClone
|
|
22726
|
+
], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
|
|
22727
|
+
__decorate([
|
|
22728
|
+
deepClone
|
|
22729
|
+
], SkinnedMeshRenderer.prototype, "_skin", void 0);
|
|
22730
|
+
__decorate([
|
|
22731
|
+
ignoreClone
|
|
22732
|
+
], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
|
|
22733
|
+
__decorate([
|
|
22734
|
+
ignoreClone
|
|
22735
|
+
], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
|
|
22736
|
+
|
|
22737
|
+
/**
|
|
22738
|
+
* @internal
|
|
22739
|
+
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
22740
|
+
function BasicResources(engine) {
|
|
22741
|
+
this.engine = engine;
|
|
22742
|
+
// prettier-ignore
|
|
22743
|
+
var vertices = new Float32Array([
|
|
22744
|
+
-1,
|
|
22745
|
+
-1,
|
|
22746
|
+
0,
|
|
22747
|
+
1,
|
|
22748
|
+
3,
|
|
22749
|
+
-1,
|
|
22750
|
+
2,
|
|
22751
|
+
1,
|
|
22752
|
+
-1,
|
|
22753
|
+
3,
|
|
22754
|
+
0,
|
|
22755
|
+
-1
|
|
22756
|
+
]); // left-top
|
|
22757
|
+
// prettier-ignore
|
|
22758
|
+
var flipYVertices = new Float32Array([
|
|
22759
|
+
3,
|
|
22760
|
+
-1,
|
|
22761
|
+
2,
|
|
22762
|
+
0,
|
|
22763
|
+
-1,
|
|
22764
|
+
-1,
|
|
22765
|
+
0,
|
|
22766
|
+
0,
|
|
22767
|
+
-1,
|
|
22768
|
+
3,
|
|
22769
|
+
0,
|
|
22770
|
+
2
|
|
22771
|
+
]); // left-top
|
|
22772
|
+
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
22773
|
+
blitMaterial._addReferCount(1);
|
|
22774
|
+
blitMaterial.renderState.depthState.enabled = false;
|
|
22775
|
+
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
22776
|
+
var blitScreenMaterial = new Material(engine, Shader.find("blit-screen"));
|
|
22777
|
+
blitScreenMaterial._addReferCount(1);
|
|
22778
|
+
blitScreenMaterial.renderState.depthState.enabled = false;
|
|
22779
|
+
blitScreenMaterial.renderState.depthState.writeEnabled = false;
|
|
22780
|
+
this.blitMaterial = blitMaterial;
|
|
22781
|
+
this.blitScreenMaterial = blitScreenMaterial;
|
|
22782
|
+
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
22783
|
+
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
22784
|
+
// Create white and magenta textures
|
|
22785
|
+
var whitePixel = new Uint8Array([
|
|
22786
|
+
255,
|
|
22787
|
+
255,
|
|
22788
|
+
255,
|
|
22789
|
+
255
|
|
22790
|
+
]);
|
|
22791
|
+
this.whiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
22792
|
+
this.whiteTextureCube = this._create1x1Texture(engine, 1, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
22793
|
+
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
22794
|
+
if (isWebGL2) {
|
|
22795
|
+
this.whiteTexture2DArray = this._create1x1Texture(engine, 2, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
22796
|
+
var whitePixel32 = new Uint32Array([
|
|
22797
|
+
255,
|
|
22798
|
+
255,
|
|
22799
|
+
255,
|
|
22800
|
+
255
|
|
22801
|
+
]);
|
|
22802
|
+
this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
|
|
22803
|
+
}
|
|
22804
|
+
this.spriteDefaultMaterial = this._create2DMaterial(engine, Shader.find("Sprite"));
|
|
22805
|
+
this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
|
|
22806
|
+
this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
|
|
22807
|
+
this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
|
|
22808
|
+
this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
|
|
22809
|
+
}
|
|
22810
|
+
var _proto = BasicResources.prototype;
|
|
22811
|
+
/**
|
|
22812
|
+
* @internal
|
|
22813
|
+
*/ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
|
|
22814
|
+
return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
|
|
22815
|
+
};
|
|
22816
|
+
/**
|
|
22817
|
+
* @internal
|
|
22818
|
+
*/ _proto._initialize = function _initialize() {
|
|
22819
|
+
var _this = this;
|
|
22820
|
+
return new Promise(function(resolve, reject) {
|
|
22821
|
+
PrefilteredDFG.create(_this.engine).then(function(texture) {
|
|
22822
|
+
_this._prefilteredDFGTexture = texture;
|
|
22823
|
+
resolve(_this);
|
|
22824
|
+
}).catch(reject);
|
|
22825
|
+
});
|
|
22826
|
+
};
|
|
22827
|
+
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
22828
|
+
var mesh = new ModelMesh(engine);
|
|
22829
|
+
mesh._addReferCount(1);
|
|
22830
|
+
mesh.setVertexElements([
|
|
22831
|
+
new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
|
|
22832
|
+
]);
|
|
22833
|
+
var buffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
|
|
22834
|
+
mesh.setVertexBufferBinding(buffer, 16);
|
|
22835
|
+
mesh.addSubMesh(0, 3, MeshTopology.Triangles);
|
|
22836
|
+
engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
|
|
22837
|
+
_inherits(_class, ContentRestorer);
|
|
22838
|
+
function _class() {
|
|
22839
|
+
return ContentRestorer.call(this, mesh) || this;
|
|
22840
|
+
}
|
|
22841
|
+
var _proto = _class.prototype;
|
|
22842
|
+
_proto.restoreContent = function restoreContent() {
|
|
22843
|
+
buffer.setData(buffer.data);
|
|
22844
|
+
};
|
|
22845
|
+
return _class;
|
|
22846
|
+
}(ContentRestorer))());
|
|
22847
|
+
return mesh;
|
|
22848
|
+
};
|
|
22849
|
+
_proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel, isSRGBColorSpace) {
|
|
22850
|
+
var texture;
|
|
22851
|
+
switch(type){
|
|
22852
|
+
case 0:
|
|
22853
|
+
var texture2D = new Texture2D(engine, 1, 1, format, false, isSRGBColorSpace);
|
|
22854
|
+
texture2D.setPixelBuffer(pixel);
|
|
22855
|
+
texture = texture2D;
|
|
22856
|
+
break;
|
|
22857
|
+
case 2:
|
|
22858
|
+
var texture2DArray = new Texture2DArray(engine, 1, 1, 1, format, false, isSRGBColorSpace);
|
|
22859
|
+
texture2DArray.setPixelBuffer(0, pixel);
|
|
22860
|
+
texture = texture2DArray;
|
|
22861
|
+
break;
|
|
22862
|
+
case 1:
|
|
22863
|
+
var textureCube = new TextureCube(engine, 1, format, false, isSRGBColorSpace);
|
|
22864
|
+
for(var i = 0; i < 6; i++){
|
|
22865
|
+
textureCube.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
22866
|
+
}
|
|
22867
|
+
texture = textureCube;
|
|
22868
|
+
break;
|
|
22869
|
+
default:
|
|
22870
|
+
throw "Invalid texture type";
|
|
22871
|
+
}
|
|
22872
|
+
texture.isGCIgnored = true;
|
|
22873
|
+
engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
|
|
22874
|
+
_inherits(_class, ContentRestorer);
|
|
22875
|
+
function _class() {
|
|
22876
|
+
return ContentRestorer.call(this, texture) || this;
|
|
22877
|
+
}
|
|
22878
|
+
var _proto = _class.prototype;
|
|
22879
|
+
_proto.restoreContent = function restoreContent() {
|
|
22880
|
+
switch(type){
|
|
22881
|
+
case 0:
|
|
22882
|
+
this.resource.setPixelBuffer(pixel);
|
|
22883
|
+
break;
|
|
22884
|
+
case 2:
|
|
22885
|
+
this.resource.setPixelBuffer(0, pixel);
|
|
22886
|
+
break;
|
|
22887
|
+
case 1:
|
|
22888
|
+
for(var i = 0; i < 6; i++){
|
|
22889
|
+
this.resource.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
22890
|
+
}
|
|
22891
|
+
break;
|
|
22892
|
+
}
|
|
22893
|
+
};
|
|
22894
|
+
return _class;
|
|
22895
|
+
}(ContentRestorer))());
|
|
22896
|
+
return texture;
|
|
22897
|
+
};
|
|
22898
|
+
_proto._create2DMaterial = function _create2DMaterial(engine, shader) {
|
|
22899
|
+
var material = new Material(engine, shader);
|
|
22900
|
+
var renderState = material.renderState;
|
|
22901
|
+
var target = renderState.blendState.targetBlendState;
|
|
22902
|
+
target.enabled = true;
|
|
22903
|
+
target.sourceColorBlendFactor = BlendFactor.SourceAlpha;
|
|
22904
|
+
target.destinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
22905
|
+
target.sourceAlphaBlendFactor = BlendFactor.One;
|
|
22906
|
+
target.destinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
22907
|
+
target.colorBlendOperation = target.alphaBlendOperation = BlendOperation.Add;
|
|
22908
|
+
renderState.depthState.writeEnabled = false;
|
|
22909
|
+
renderState.rasterState.cullMode = CullMode.Off;
|
|
22910
|
+
renderState.renderQueueType = RenderQueueType.Transparent;
|
|
22911
|
+
material.isGCIgnored = true;
|
|
22912
|
+
return material;
|
|
22913
|
+
};
|
|
22914
|
+
_proto._createMagentaMaterial = function _createMagentaMaterial(engine, shaderName) {
|
|
22915
|
+
var material = new Material(engine, Shader.find(shaderName));
|
|
22916
|
+
material.isGCIgnored = true;
|
|
22917
|
+
material.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
22918
|
+
return material;
|
|
22919
|
+
};
|
|
22920
|
+
_proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
|
|
22921
|
+
var material = new Material(engine, Shader.find("SpriteMask"));
|
|
22922
|
+
material.isGCIgnored = true;
|
|
22923
|
+
return material;
|
|
22924
|
+
};
|
|
22925
|
+
BasicResources.getMaskInteractionRenderStates = function getMaskInteractionRenderStates(maskInteraction) {
|
|
22926
|
+
var visibleInsideMask = maskInteraction === SpriteMaskInteraction.VisibleInsideMask;
|
|
22927
|
+
var renderStates;
|
|
22928
|
+
var compareFunction;
|
|
22929
|
+
if (visibleInsideMask) {
|
|
22930
|
+
renderStates = BasicResources._maskReadInsideRenderStates;
|
|
22931
|
+
if (renderStates) {
|
|
22932
|
+
return renderStates;
|
|
22933
|
+
}
|
|
22934
|
+
BasicResources._maskReadInsideRenderStates = renderStates = {};
|
|
22935
|
+
compareFunction = CompareFunction.LessEqual;
|
|
22936
|
+
} else {
|
|
22937
|
+
renderStates = BasicResources._maskReadOutsideRenderStates;
|
|
22938
|
+
if (renderStates) {
|
|
22939
|
+
return renderStates;
|
|
22940
|
+
}
|
|
22941
|
+
BasicResources._maskReadOutsideRenderStates = renderStates = {};
|
|
22942
|
+
compareFunction = CompareFunction.Greater;
|
|
22943
|
+
}
|
|
22944
|
+
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
22945
|
+
renderStates[RenderStateElementKey.StencilStateWriteMask] = 0x00;
|
|
22946
|
+
renderStates[RenderStateElementKey.StencilStateReferenceValue] = 1;
|
|
22947
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = compareFunction;
|
|
22948
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = compareFunction;
|
|
22949
|
+
return renderStates;
|
|
22950
|
+
};
|
|
22951
|
+
BasicResources.getMaskTypeRenderStates = function getMaskTypeRenderStates(maskType) {
|
|
22952
|
+
var isIncrement = maskType === RenderQueueMaskType.Increment;
|
|
22953
|
+
var renderStates;
|
|
22954
|
+
var passOperation;
|
|
22955
|
+
if (isIncrement) {
|
|
22956
|
+
renderStates = BasicResources._maskWriteIncrementRenderStates;
|
|
22957
|
+
if (renderStates) {
|
|
22958
|
+
return renderStates;
|
|
22959
|
+
}
|
|
22960
|
+
BasicResources._maskWriteIncrementRenderStates = renderStates = {};
|
|
22961
|
+
passOperation = StencilOperation.IncrementSaturate;
|
|
22962
|
+
} else {
|
|
22963
|
+
renderStates = BasicResources._maskWriteDecrementRenderStates;
|
|
22964
|
+
if (renderStates) {
|
|
22965
|
+
return renderStates;
|
|
22966
|
+
}
|
|
22967
|
+
BasicResources._maskWriteDecrementRenderStates = renderStates = {};
|
|
22968
|
+
passOperation = StencilOperation.DecrementSaturate;
|
|
22969
|
+
}
|
|
22970
|
+
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
22971
|
+
renderStates[RenderStateElementKey.StencilStatePassOperationFront] = passOperation;
|
|
22972
|
+
renderStates[RenderStateElementKey.StencilStatePassOperationBack] = passOperation;
|
|
22973
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = CompareFunction.Always;
|
|
22974
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = CompareFunction.Always;
|
|
22975
|
+
var failStencilOperation = StencilOperation.Keep;
|
|
22976
|
+
renderStates[RenderStateElementKey.StencilStateFailOperationFront] = failStencilOperation;
|
|
22977
|
+
renderStates[RenderStateElementKey.StencilStateFailOperationBack] = failStencilOperation;
|
|
22978
|
+
renderStates[RenderStateElementKey.StencilStateZFailOperationFront] = failStencilOperation;
|
|
22979
|
+
renderStates[RenderStateElementKey.StencilStateZFailOperationBack] = failStencilOperation;
|
|
22980
|
+
renderStates[RenderStateElementKey.BlendStateColorWriteMask0] = ColorWriteMask.None;
|
|
22981
|
+
renderStates[RenderStateElementKey.DepthStateEnabled] = false;
|
|
22982
|
+
renderStates[RenderStateElementKey.RasterStateCullMode] = CullMode.Off;
|
|
22983
|
+
return renderStates;
|
|
22984
|
+
};
|
|
22985
|
+
_create_class(BasicResources, [
|
|
22986
|
+
{
|
|
22987
|
+
key: "prefilteredDFGTexture",
|
|
22988
|
+
get: function get() {
|
|
22989
|
+
return this._prefilteredDFGTexture;
|
|
22990
|
+
}
|
|
22991
|
+
}
|
|
22992
|
+
]);
|
|
22993
|
+
return BasicResources;
|
|
22994
|
+
}();
|
|
22995
|
+
BasicResources._maskReadInsideRenderStates = null;
|
|
22996
|
+
BasicResources._maskReadOutsideRenderStates = null;
|
|
22997
|
+
BasicResources._maskWriteIncrementRenderStates = null;
|
|
22998
|
+
BasicResources._maskWriteDecrementRenderStates = null;
|
|
22999
|
+
|
|
23000
|
+
function _is_native_reflect_construct() {
|
|
23001
|
+
// Since Reflect.construct can't be properly polyfilled, some
|
|
23002
|
+
// implementations (e.g. core-js@2) don't set the correct internal slots.
|
|
23003
|
+
// Those polyfills don't allow us to subclass built-ins, so we need to
|
|
23004
|
+
// use our fallback implementation.
|
|
23005
|
+
try {
|
|
23006
|
+
// If the internal slots aren't set, this throws an error similar to
|
|
23007
|
+
// TypeError: this is not a Boolean object.
|
|
23008
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
23009
|
+
} catch (_) {}
|
|
23010
|
+
return (_is_native_reflect_construct = function() {
|
|
23011
|
+
return !!result;
|
|
23012
|
+
})();
|
|
23013
|
+
}
|
|
23014
|
+
|
|
23015
|
+
function _construct(Parent, args, Class) {
|
|
23016
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
23017
|
+
else {
|
|
23018
|
+
_construct = function construct(Parent, args, Class) {
|
|
23019
|
+
var a = [null];
|
|
23020
|
+
a.push.apply(a, args);
|
|
23021
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
23022
|
+
var instance = new Constructor();
|
|
23023
|
+
|
|
23024
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
23025
|
+
|
|
23026
|
+
return instance;
|
|
23027
|
+
};
|
|
23028
|
+
}
|
|
23029
|
+
|
|
23030
|
+
return _construct.apply(null, arguments);
|
|
23031
|
+
}
|
|
23032
|
+
|
|
23033
|
+
var ComponentCloner = /*#__PURE__*/ function() {
|
|
23034
|
+
function ComponentCloner() {}
|
|
23035
|
+
/**
|
|
23036
|
+
* Clone component.
|
|
23037
|
+
* @param source - Clone source
|
|
23038
|
+
* @param target - Clone target
|
|
23039
|
+
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
23040
|
+
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
23041
|
+
for(var k in source){
|
|
23042
|
+
CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
|
|
23043
|
+
}
|
|
23044
|
+
if (source._cloneTo) {
|
|
23045
|
+
source._cloneTo(target, srcRoot, targetRoot);
|
|
23046
|
+
}
|
|
23047
|
+
};
|
|
23048
|
+
return ComponentCloner;
|
|
23049
|
+
}();
|
|
23050
|
+
|
|
23051
|
+
/**
|
|
23052
|
+
* The entity modify flags.
|
|
23053
|
+
*/ var EntityModifyFlags = /*#__PURE__*/ function(EntityModifyFlags) {
|
|
23054
|
+
/** The parent changes. */ EntityModifyFlags[EntityModifyFlags["Parent"] = 1] = "Parent";
|
|
23055
|
+
/** The child changes. */ EntityModifyFlags[EntityModifyFlags["Child"] = 2] = "Child";
|
|
23056
|
+
return EntityModifyFlags;
|
|
23057
|
+
}({});
|
|
23058
|
+
|
|
23059
|
+
/**
|
|
23060
|
+
* Entity, be used as components container.
|
|
23061
|
+
*/ var Entity = /*#__PURE__*/ function(EngineObject) {
|
|
23062
|
+
_inherits(Entity, EngineObject);
|
|
23063
|
+
function Entity(engine, name) {
|
|
23064
|
+
for(var _len = arguments.length, components = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
23065
|
+
components[_key - 2] = arguments[_key];
|
|
23066
|
+
}
|
|
23067
|
+
var _this;
|
|
23068
|
+
_this = EngineObject.call(this, engine) || this, /** The layer the entity belongs to. */ _this.layer = Layer.Layer0, /** @internal */ _this._isActiveInHierarchy = false, /** @internal */ _this._isActiveInScene = false, /** @internal */ _this._components = [], /** @internal */ _this._scripts = new DisorderedArray(), /** @internal */ _this._children = [], /** @internal */ _this._isRoot = false, /** @internal */ _this._isActive = true, /** @internal */ _this._siblingIndex = -1, /** @internal */ _this._isTemplate = false, /** @internal */ _this._updateFlagManager = new UpdateFlagManager(), _this._parent = null, //--------------------------------------------------------------deprecated----------------------------------------------------------------
|
|
23069
|
+
_this._invModelMatrix = new engineMath.Matrix();
|
|
23070
|
+
_this.name = name != null ? name : "Entity";
|
|
23071
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
23072
|
+
_this.addComponent(components[i]);
|
|
23073
|
+
}
|
|
23074
|
+
!_this._transform && _this.addComponent(Transform);
|
|
23075
|
+
_this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
|
|
23076
|
+
return _this;
|
|
23077
|
+
}
|
|
23078
|
+
var _proto = Entity.prototype;
|
|
23079
|
+
/**
|
|
23080
|
+
* Add component based on the component type.
|
|
23081
|
+
* @param type - The type of the component
|
|
23082
|
+
* @param args - The arguments of the component
|
|
23083
|
+
* @returns The component which has been added
|
|
23084
|
+
*/ _proto.addComponent = function addComponent(type) {
|
|
23085
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
23086
|
+
args[_key - 1] = arguments[_key];
|
|
23087
|
+
}
|
|
23088
|
+
ComponentsDependencies._addCheck(this, type);
|
|
23089
|
+
var component = _construct(type, [].concat([
|
|
23090
|
+
this
|
|
23091
|
+
], args));
|
|
23092
|
+
this._components.push(component);
|
|
23093
|
+
// @todo: temporary solution
|
|
23094
|
+
if (_instanceof(component, Transform)) this._setTransform(component);
|
|
23095
|
+
component._setActive(true, ActiveChangeFlag.All);
|
|
23096
|
+
return component;
|
|
23097
|
+
};
|
|
23098
|
+
/**
|
|
23099
|
+
* Get component which match the type.
|
|
23100
|
+
* @param type - The type of the component
|
|
23101
|
+
* @returns The first component which match type
|
|
23102
|
+
*/ _proto.getComponent = function getComponent(type) {
|
|
23103
|
+
var components = this._components;
|
|
23104
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
23105
|
+
var component = components[i];
|
|
23106
|
+
if (_instanceof(component, type)) {
|
|
23107
|
+
return component;
|
|
23108
|
+
}
|
|
23109
|
+
}
|
|
23110
|
+
return null;
|
|
23111
|
+
};
|
|
23112
|
+
/**
|
|
23113
|
+
* Get components which match the type.
|
|
23114
|
+
* @param type - The type of the component
|
|
23115
|
+
* @param results - The components which match type
|
|
23116
|
+
* @returns The components which match type
|
|
23117
|
+
*/ _proto.getComponents = function getComponents(type, results) {
|
|
23118
|
+
results.length = 0;
|
|
23119
|
+
var components = this._components;
|
|
23120
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
23121
|
+
var component = components[i];
|
|
23122
|
+
if (_instanceof(component, type)) {
|
|
23123
|
+
results.push(component);
|
|
23124
|
+
}
|
|
23125
|
+
}
|
|
23126
|
+
return results;
|
|
23127
|
+
};
|
|
23128
|
+
/**
|
|
23129
|
+
* Get the components which match the type of the entity and it's children.
|
|
23130
|
+
* @param type - The component type
|
|
23131
|
+
* @param results - The components collection
|
|
23132
|
+
* @returns The components collection which match the type
|
|
23133
|
+
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
23134
|
+
results.length = 0;
|
|
23135
|
+
this._getComponentsInChildren(type, results);
|
|
23136
|
+
return results;
|
|
23137
|
+
};
|
|
23138
|
+
_proto.addChild = function addChild(indexOrChild, child) {
|
|
23139
|
+
var index;
|
|
23140
|
+
if (typeof indexOrChild === "number") {
|
|
23141
|
+
index = indexOrChild;
|
|
23142
|
+
} else {
|
|
23143
|
+
index = undefined;
|
|
23144
|
+
child = indexOrChild;
|
|
23145
|
+
}
|
|
23146
|
+
child._setParent(this, index);
|
|
23147
|
+
};
|
|
23148
|
+
/**
|
|
23149
|
+
* Remove child entity.
|
|
23150
|
+
* @param child - The child entity which want to be removed
|
|
23151
|
+
*/ _proto.removeChild = function removeChild(child) {
|
|
23152
|
+
if (child._parent !== this) return;
|
|
23153
|
+
child._setParent(null);
|
|
23154
|
+
};
|
|
23155
|
+
/**
|
|
23156
|
+
* @deprecated Please use `children` property instead.
|
|
23157
|
+
* Find child entity by index.
|
|
23158
|
+
* @param index - The index of the child entity
|
|
23159
|
+
* @returns The component which be found
|
|
23160
|
+
*/ _proto.getChild = function getChild(index) {
|
|
23161
|
+
return this._children[index];
|
|
23162
|
+
};
|
|
23163
|
+
/**
|
|
23164
|
+
* Find entity by name.
|
|
23165
|
+
* @param name - The name of the entity which want to be found
|
|
23166
|
+
* @returns The component which be found
|
|
23167
|
+
*/ _proto.findByName = function findByName(name) {
|
|
23168
|
+
if (name === this.name) {
|
|
23169
|
+
return this;
|
|
23170
|
+
}
|
|
23171
|
+
var children = this._children;
|
|
23172
|
+
for(var i = 0, n = children.length; i < n; i++){
|
|
23173
|
+
var target = children[i].findByName(name);
|
|
23174
|
+
if (target) {
|
|
23175
|
+
return target;
|
|
23176
|
+
}
|
|
23177
|
+
}
|
|
23178
|
+
return null;
|
|
23179
|
+
};
|
|
23180
|
+
/**
|
|
23181
|
+
* Find the entity by path.
|
|
23182
|
+
* @param path - The path of the entity eg: /entity
|
|
23183
|
+
* @returns The component which be found
|
|
23184
|
+
*/ _proto.findByPath = function findByPath(path) {
|
|
23185
|
+
var splits = path.split("/").filter(Boolean);
|
|
23186
|
+
if (!splits.length) {
|
|
23187
|
+
return this;
|
|
23188
|
+
}
|
|
23189
|
+
return Entity._findChildByName(this, 0, splits, 0);
|
|
23190
|
+
};
|
|
23191
|
+
/**
|
|
23192
|
+
* Create child entity.
|
|
23193
|
+
* @param name - The child entity's name
|
|
23194
|
+
* @returns The child entity
|
|
23195
|
+
*/ _proto.createChild = function createChild(name) {
|
|
23196
|
+
var transform = this._transform;
|
|
23197
|
+
var child = transform ? new Entity(this.engine, name, transform.constructor) : new Entity(this.engine, name);
|
|
23198
|
+
child.layer = this.layer;
|
|
23199
|
+
child.parent = this;
|
|
23200
|
+
return child;
|
|
23201
|
+
};
|
|
23202
|
+
/**
|
|
23203
|
+
* Clear children entities.
|
|
23204
|
+
*/ _proto.clearChildren = function clearChildren() {
|
|
23205
|
+
var children = this._children;
|
|
23206
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
23207
|
+
var child = children[i];
|
|
23208
|
+
child._parent = null;
|
|
23209
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
23210
|
+
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
23211
|
+
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
23212
|
+
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
23213
|
+
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
23214
|
+
}
|
|
23215
|
+
children.length = 0;
|
|
23216
|
+
};
|
|
23217
|
+
/**
|
|
23218
|
+
* Clone this entity include children and components.
|
|
23219
|
+
* @returns Cloned entity
|
|
23220
|
+
*/ _proto.clone = function clone() {
|
|
23221
|
+
var cloneEntity = this._createCloneEntity();
|
|
23222
|
+
this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
|
|
23223
|
+
return cloneEntity;
|
|
23224
|
+
};
|
|
23225
|
+
/**
|
|
23226
|
+
* Listen for changes in the world pose of this `Entity`.
|
|
23227
|
+
* @returns Change flag
|
|
23228
|
+
*/ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
|
|
23229
|
+
return this._updateFlagManager.createFlag(BoolUpdateFlag);
|
|
23230
|
+
};
|
|
23231
|
+
/**
|
|
23232
|
+
* @internal
|
|
23233
|
+
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
23234
|
+
this._isTemplate = true;
|
|
23235
|
+
this._templateResource = templateResource;
|
|
23236
|
+
};
|
|
23237
|
+
_proto._createCloneEntity = function _createCloneEntity() {
|
|
23238
|
+
var componentConstructors = Entity._tempComponentConstructors;
|
|
23239
|
+
var components = this._components;
|
|
23240
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
23241
|
+
componentConstructors[i] = components[i].constructor;
|
|
23242
|
+
}
|
|
23243
|
+
var cloneEntity = _construct(Entity, [].concat([
|
|
23244
|
+
this.engine,
|
|
23245
|
+
this.name
|
|
23246
|
+
], componentConstructors));
|
|
23247
|
+
componentConstructors.length = 0;
|
|
23248
|
+
var templateResource = this._templateResource;
|
|
23249
|
+
if (templateResource) {
|
|
23250
|
+
cloneEntity._templateResource = templateResource;
|
|
23251
|
+
templateResource._addReferCount(1);
|
|
23252
|
+
}
|
|
23253
|
+
cloneEntity.layer = this.layer;
|
|
23254
|
+
cloneEntity._isActive = this._isActive;
|
|
23255
|
+
var srcChildren = this._children;
|
|
23256
|
+
for(var i1 = 0, n1 = srcChildren.length; i1 < n1; i1++){
|
|
23257
|
+
cloneEntity.addChild(srcChildren[i1]._createCloneEntity());
|
|
23258
|
+
}
|
|
23259
|
+
return cloneEntity;
|
|
23260
|
+
};
|
|
23261
|
+
_proto._parseCloneEntity = function _parseCloneEntity(src, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
23262
|
+
var srcChildren = src._children;
|
|
23263
|
+
var targetChildren = target._children;
|
|
23264
|
+
for(var i = 0, n = srcChildren.length; i < n; i++){
|
|
23265
|
+
this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot, deepInstanceMap);
|
|
23266
|
+
}
|
|
23267
|
+
var components = src._components;
|
|
23268
|
+
for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
|
|
22558
23269
|
ComponentCloner.cloneComponent(components[i1], target._components[i1], srcRoot, targetRoot, deepInstanceMap);
|
|
22559
23270
|
}
|
|
22560
23271
|
};
|
|
@@ -22821,843 +23532,152 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
22821
23532
|
};
|
|
22822
23533
|
/**
|
|
22823
23534
|
* @internal
|
|
22824
|
-
*/ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
|
|
22825
|
-
entity._scene = scene;
|
|
22826
|
-
var children = entity._children;
|
|
22827
|
-
for(var i = children.length - 1; i >= 0; i--){
|
|
22828
|
-
this._traverseSetOwnerScene(children[i], scene);
|
|
22829
|
-
}
|
|
22830
|
-
};
|
|
22831
|
-
/**
|
|
22832
|
-
* @internal
|
|
22833
|
-
*/ Entity._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
|
|
22834
|
-
inversePath.length = 0;
|
|
22835
|
-
while(searchEntity !== rootEntity){
|
|
22836
|
-
var parent = searchEntity.parent;
|
|
22837
|
-
if (!parent) {
|
|
22838
|
-
return false;
|
|
22839
|
-
}
|
|
22840
|
-
inversePath.push(searchEntity.siblingIndex);
|
|
22841
|
-
searchEntity = parent;
|
|
22842
|
-
}
|
|
22843
|
-
return true;
|
|
22844
|
-
};
|
|
22845
|
-
/**
|
|
22846
|
-
* @internal
|
|
22847
|
-
*/ Entity._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
|
|
22848
|
-
var entity = rootEntity;
|
|
22849
|
-
for(var i = inversePath.length - 1; i >= 0; i--){
|
|
22850
|
-
entity = entity.children[inversePath[i]];
|
|
22851
|
-
}
|
|
22852
|
-
return entity;
|
|
22853
|
-
};
|
|
22854
|
-
/**
|
|
22855
|
-
* @internal
|
|
22856
|
-
*/ Entity._removeFromChildren = function _removeFromChildren(children, entity) {
|
|
22857
|
-
var count = children.length - 1;
|
|
22858
|
-
for(var i = entity._siblingIndex; i < count; i++){
|
|
22859
|
-
var child = children[i + 1];
|
|
22860
|
-
children[i] = child;
|
|
22861
|
-
child._siblingIndex = i;
|
|
22862
|
-
}
|
|
22863
|
-
children.length = count;
|
|
22864
|
-
entity._siblingIndex = -1;
|
|
22865
|
-
};
|
|
22866
|
-
/**
|
|
22867
|
-
* @internal
|
|
22868
|
-
*/ Entity._addToChildren = function _addToChildren(children, entity, index) {
|
|
22869
|
-
var childCount = children.length;
|
|
22870
|
-
children.length = childCount + 1;
|
|
22871
|
-
if (index === undefined) {
|
|
22872
|
-
children[childCount] = entity;
|
|
22873
|
-
entity._siblingIndex = childCount;
|
|
22874
|
-
} else {
|
|
22875
|
-
if (index < 0 || index > childCount) {
|
|
22876
|
-
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
22877
|
-
}
|
|
22878
|
-
for(var i = childCount; i > index; i--){
|
|
22879
|
-
var swapChild = children[i - 1];
|
|
22880
|
-
swapChild._siblingIndex = i;
|
|
22881
|
-
children[i] = swapChild;
|
|
22882
|
-
}
|
|
22883
|
-
entity._siblingIndex = index;
|
|
22884
|
-
children[index] = entity;
|
|
22885
|
-
}
|
|
22886
|
-
};
|
|
22887
|
-
_create_class(Entity, [
|
|
22888
|
-
{
|
|
22889
|
-
key: "transform",
|
|
22890
|
-
get: /**
|
|
22891
|
-
* The transform of this entity.
|
|
22892
|
-
*/ function get() {
|
|
22893
|
-
return this._transform;
|
|
22894
|
-
}
|
|
22895
|
-
},
|
|
22896
|
-
{
|
|
22897
|
-
key: "isActive",
|
|
22898
|
-
get: /**
|
|
22899
|
-
* Whether to activate locally.
|
|
22900
|
-
*/ function get() {
|
|
22901
|
-
return this._isActive;
|
|
22902
|
-
},
|
|
22903
|
-
set: function set(value) {
|
|
22904
|
-
if (value !== this._isActive) {
|
|
22905
|
-
this._isActive = value;
|
|
22906
|
-
if (value) {
|
|
22907
|
-
var parent = this._parent;
|
|
22908
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
22909
|
-
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
22910
|
-
activeChangeFlag |= ActiveChangeFlag.All;
|
|
22911
|
-
} else {
|
|
22912
|
-
(parent == null ? void 0 : parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
22913
|
-
(parent == null ? void 0 : parent._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
22914
|
-
}
|
|
22915
|
-
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
22916
|
-
} else {
|
|
22917
|
-
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
22918
|
-
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
22919
|
-
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
22920
|
-
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
22921
|
-
}
|
|
22922
|
-
}
|
|
22923
|
-
}
|
|
22924
|
-
},
|
|
22925
|
-
{
|
|
22926
|
-
key: "isActiveInHierarchy",
|
|
22927
|
-
get: /**
|
|
22928
|
-
* Whether it is active in the hierarchy.
|
|
22929
|
-
*/ function get() {
|
|
22930
|
-
return this._isActiveInHierarchy;
|
|
22931
|
-
}
|
|
22932
|
-
},
|
|
22933
|
-
{
|
|
22934
|
-
key: "parent",
|
|
22935
|
-
get: /**
|
|
22936
|
-
* The parent entity.
|
|
22937
|
-
*/ function get() {
|
|
22938
|
-
return this._parent;
|
|
22939
|
-
},
|
|
22940
|
-
set: function set(value) {
|
|
22941
|
-
this._setParent(value);
|
|
22942
|
-
}
|
|
22943
|
-
},
|
|
22944
|
-
{
|
|
22945
|
-
key: "children",
|
|
22946
|
-
get: /**
|
|
22947
|
-
* The children entities
|
|
22948
|
-
*/ function get() {
|
|
22949
|
-
return this._children;
|
|
22950
|
-
}
|
|
22951
|
-
},
|
|
22952
|
-
{
|
|
22953
|
-
key: "childCount",
|
|
22954
|
-
get: /**
|
|
22955
|
-
* @deprecated Please use `children.length` property instead.
|
|
22956
|
-
* Number of the children entities
|
|
22957
|
-
*/ function get() {
|
|
22958
|
-
return this._children.length;
|
|
22959
|
-
}
|
|
22960
|
-
},
|
|
22961
|
-
{
|
|
22962
|
-
key: "scene",
|
|
22963
|
-
get: /**
|
|
22964
|
-
* The scene the entity belongs to.
|
|
22965
|
-
*/ function get() {
|
|
22966
|
-
return this._scene;
|
|
22967
|
-
}
|
|
22968
|
-
},
|
|
22969
|
-
{
|
|
22970
|
-
key: "siblingIndex",
|
|
22971
|
-
get: /**
|
|
22972
|
-
* The sibling index.
|
|
22973
|
-
*/ function get() {
|
|
22974
|
-
return this._siblingIndex;
|
|
22975
|
-
},
|
|
22976
|
-
set: function set(value) {
|
|
22977
|
-
if (this._siblingIndex === -1) {
|
|
22978
|
-
throw "The entity " + this.name + " is not in the hierarchy";
|
|
22979
|
-
}
|
|
22980
|
-
if (this._isRoot) {
|
|
22981
|
-
this._setSiblingIndex(this._scene._rootEntities, value);
|
|
22982
|
-
} else {
|
|
22983
|
-
var parent = this._parent;
|
|
22984
|
-
this._setSiblingIndex(parent._children, value);
|
|
22985
|
-
parent._dispatchModify(EntityModifyFlags.Child, parent);
|
|
22986
|
-
}
|
|
22987
|
-
}
|
|
22988
|
-
}
|
|
22989
|
-
]);
|
|
22990
|
-
return Entity;
|
|
22991
|
-
}(EngineObject);
|
|
22992
|
-
/** @internal */ Entity._tempComponentConstructors = [];
|
|
22993
|
-
|
|
22994
|
-
/**
|
|
22995
|
-
* Skin used for skinned mesh renderer.
|
|
22996
|
-
*/ var Skin = /*#__PURE__*/ function(EngineObject) {
|
|
22997
|
-
_inherits(Skin, EngineObject);
|
|
22998
|
-
function Skin(name) {
|
|
22999
|
-
var _this;
|
|
23000
|
-
_this = EngineObject.call(this, null) || this, _this.name = name, _this.inverseBindMatrices = new Array(), _this._updatedManager = new UpdateFlagManager(), _this._bones = new Array(), _this._updateMark = -1, _this.joints = [];
|
|
23001
|
-
return _this;
|
|
23002
|
-
}
|
|
23003
|
-
var _proto = Skin.prototype;
|
|
23004
|
-
/**
|
|
23005
|
-
* @internal
|
|
23006
|
-
*/ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
|
|
23007
|
-
if (this._updateMark === renderer.engine.time.frameCount) {
|
|
23008
|
-
return;
|
|
23009
|
-
}
|
|
23010
|
-
var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
|
|
23011
|
-
var _this_rootBone;
|
|
23012
|
-
var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
|
|
23013
|
-
for(var i = bones.length - 1; i >= 0; i--){
|
|
23014
|
-
var bone = bones[i];
|
|
23015
|
-
var offset = i * 16;
|
|
23016
|
-
if (bone) {
|
|
23017
|
-
Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
|
|
23018
|
-
} else {
|
|
23019
|
-
skinMatrices.set(bindMatrices[i].elements, offset);
|
|
23020
|
-
}
|
|
23021
|
-
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
23022
|
-
}
|
|
23023
|
-
this._updateMark = renderer.engine.time.frameCount;
|
|
23024
|
-
};
|
|
23025
|
-
/**
|
|
23026
|
-
* @internal
|
|
23027
|
-
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
23028
|
-
var paths = new Array();
|
|
23029
|
-
// Clone rootBone
|
|
23030
|
-
var rootBone = this.rootBone;
|
|
23031
|
-
if (rootBone) {
|
|
23032
|
-
var success = Entity._getEntityHierarchyPath(srcRoot, rootBone, paths);
|
|
23033
|
-
target.rootBone = success ? Entity._getEntityByHierarchyPath(targetRoot, paths) : rootBone;
|
|
23034
|
-
}
|
|
23035
|
-
// Clone bones
|
|
23036
|
-
var bones = this.bones;
|
|
23037
|
-
if (bones.length > 0) {
|
|
23038
|
-
var boneCount = bones.length;
|
|
23039
|
-
var destBones = new Array(boneCount);
|
|
23040
|
-
for(var i = 0; i < boneCount; i++){
|
|
23041
|
-
var bone = bones[i];
|
|
23042
|
-
var success1 = Entity._getEntityHierarchyPath(srcRoot, bone, paths);
|
|
23043
|
-
destBones[i] = success1 ? Entity._getEntityByHierarchyPath(targetRoot, paths) : bone;
|
|
23044
|
-
}
|
|
23045
|
-
target.bones = destBones;
|
|
23046
|
-
}
|
|
23047
|
-
};
|
|
23048
|
-
_create_class(Skin, [
|
|
23049
|
-
{
|
|
23050
|
-
key: "rootBone",
|
|
23051
|
-
get: /**
|
|
23052
|
-
* Root bone.
|
|
23053
|
-
*/ function get() {
|
|
23054
|
-
return this._rootBone;
|
|
23055
|
-
},
|
|
23056
|
-
set: function set(value) {
|
|
23057
|
-
if (this._rootBone !== value) {
|
|
23058
|
-
this._updatedManager.dispatch(1, value);
|
|
23059
|
-
this._rootBone = value;
|
|
23060
|
-
}
|
|
23061
|
-
}
|
|
23062
|
-
},
|
|
23063
|
-
{
|
|
23064
|
-
key: "bones",
|
|
23065
|
-
get: /**
|
|
23066
|
-
* Bones of the skin.
|
|
23067
|
-
*/ function get() {
|
|
23068
|
-
return this._bones;
|
|
23069
|
-
},
|
|
23070
|
-
set: function set(value) {
|
|
23071
|
-
var bones = this._bones;
|
|
23072
|
-
var _value_length;
|
|
23073
|
-
var boneCount = (_value_length = value == null ? void 0 : value.length) != null ? _value_length : 0;
|
|
23074
|
-
var lastBoneCount = bones.length;
|
|
23075
|
-
bones.length = boneCount;
|
|
23076
|
-
for(var i = 0; i < boneCount; i++){
|
|
23077
|
-
bones[i] = value[i];
|
|
23078
|
-
}
|
|
23079
|
-
if (lastBoneCount !== boneCount) {
|
|
23080
|
-
this._skinMatrices = new Float32Array(boneCount * 16);
|
|
23081
|
-
this._updatedManager.dispatch(0, boneCount);
|
|
23082
|
-
}
|
|
23083
|
-
}
|
|
23084
|
-
},
|
|
23085
|
-
{
|
|
23086
|
-
key: "skeleton",
|
|
23087
|
-
get: /** @deprecated Please use `rootBone` instead. */ function get() {
|
|
23088
|
-
var _this_rootBone;
|
|
23089
|
-
return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
|
|
23090
|
-
},
|
|
23091
|
-
set: function set(value) {
|
|
23092
|
-
var rootBone = this._rootBone;
|
|
23093
|
-
if (rootBone) {
|
|
23094
|
-
rootBone.name = value;
|
|
23095
|
-
}
|
|
23096
|
-
}
|
|
23097
|
-
}
|
|
23098
|
-
]);
|
|
23099
|
-
return Skin;
|
|
23100
|
-
}(EngineObject);
|
|
23101
|
-
__decorate([
|
|
23102
|
-
deepClone
|
|
23103
|
-
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
23104
|
-
__decorate([
|
|
23105
|
-
ignoreClone
|
|
23106
|
-
], Skin.prototype, "_skinMatrices", void 0);
|
|
23107
|
-
__decorate([
|
|
23108
|
-
ignoreClone
|
|
23109
|
-
], Skin.prototype, "_updatedManager", void 0);
|
|
23110
|
-
__decorate([
|
|
23111
|
-
ignoreClone
|
|
23112
|
-
], Skin.prototype, "_rootBone", void 0);
|
|
23113
|
-
__decorate([
|
|
23114
|
-
ignoreClone
|
|
23115
|
-
], Skin.prototype, "_bones", void 0);
|
|
23116
|
-
__decorate([
|
|
23117
|
-
ignoreClone
|
|
23118
|
-
], Skin.prototype, "_updateMark", void 0);
|
|
23119
|
-
var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
|
|
23120
|
-
SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
|
|
23121
|
-
SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
|
|
23122
|
-
return SkinUpdateFlag;
|
|
23123
|
-
}({});
|
|
23124
|
-
|
|
23125
|
-
/**
|
|
23126
|
-
* SkinnedMeshRenderer.
|
|
23127
|
-
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer) {
|
|
23128
|
-
_inherits(SkinnedMeshRenderer, MeshRenderer);
|
|
23129
|
-
function SkinnedMeshRenderer(entity) {
|
|
23130
|
-
var _this;
|
|
23131
|
-
_this = MeshRenderer.call(this, entity) || this, _this._localBounds = new engineMath.BoundingBox(), _this._jointDataCreateCache = new engineMath.Vector2(-1, -1);
|
|
23132
|
-
_this._skin = null;
|
|
23133
|
-
var rhi = _this.entity.engine._hardwareRenderer;
|
|
23134
|
-
var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
|
|
23135
|
-
// Limit size to 256 to avoid some problem:
|
|
23136
|
-
// For renderer is "Apple GPU", when uniform is large than 256 the skeleton matrix array access in shader very slow in Safari or WKWebview. This may be a apple bug, Chrome and Firefox is OK!
|
|
23137
|
-
// For renderer is "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3011 vs_5_0 ps_5_0, D3011)", compile shader si very slow because of max uniform is 4096.
|
|
23138
|
-
maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
|
|
23139
|
-
_this._maxVertexUniformVectors = maxVertexUniformVectors;
|
|
23140
|
-
_this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_this);
|
|
23141
|
-
_this._onSkinUpdated = _this._onSkinUpdated.bind(_this);
|
|
23142
|
-
var localBounds = _this._localBounds;
|
|
23143
|
-
// @ts-ignore
|
|
23144
|
-
localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
|
|
23145
|
-
// @ts-ignore
|
|
23146
|
-
localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
|
|
23147
|
-
return _this;
|
|
23148
|
-
}
|
|
23149
|
-
var _proto = SkinnedMeshRenderer.prototype;
|
|
23150
|
-
/**
|
|
23151
|
-
* @internal
|
|
23152
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
23153
|
-
var _this__jointTexture;
|
|
23154
|
-
MeshRenderer.prototype._onDestroy.call(this);
|
|
23155
|
-
this._jointDataCreateCache = null;
|
|
23156
|
-
this._skin = null;
|
|
23157
|
-
this._blendShapeWeights = null;
|
|
23158
|
-
this._localBounds = null;
|
|
23159
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
23160
|
-
this._jointTexture = null;
|
|
23161
|
-
};
|
|
23162
|
-
/**
|
|
23163
|
-
* @internal
|
|
23164
|
-
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
23165
|
-
MeshRenderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
|
|
23166
|
-
if (this.skin) {
|
|
23167
|
-
target._applySkin(null, target.skin);
|
|
23168
|
-
}
|
|
23169
|
-
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
23170
|
-
};
|
|
23171
|
-
_proto._update = function _update(context) {
|
|
23172
|
-
var skin = this.skin;
|
|
23173
|
-
if ((skin == null ? void 0 : skin.bones.length) > 0) {
|
|
23174
|
-
skin._updateSkinMatrices(this);
|
|
23175
|
-
}
|
|
23176
|
-
var shaderData = this.shaderData;
|
|
23177
|
-
var mesh = this.mesh;
|
|
23178
|
-
var blendShapeManager = mesh._blendShapeManager;
|
|
23179
|
-
blendShapeManager._updateShaderData(shaderData, this);
|
|
23180
|
-
var bones = skin == null ? void 0 : skin.bones;
|
|
23181
|
-
if (bones) {
|
|
23182
|
-
var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
|
|
23183
|
-
var boneCount = bones.length;
|
|
23184
|
-
var boneDataCreateCache = this._jointDataCreateCache;
|
|
23185
|
-
var boneCountChange = boneCount !== boneDataCreateCache.x;
|
|
23186
|
-
if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
|
|
23187
|
-
// directly use max joint count to avoid shader recompile
|
|
23188
|
-
var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) / 4);
|
|
23189
|
-
if (boneCount > remainUniformJointCount) {
|
|
23190
|
-
var engine = this.engine;
|
|
23191
|
-
if (engine._hardwareRenderer.canIUseMoreJoints) {
|
|
23192
|
-
if (boneCountChange) {
|
|
23193
|
-
var _this__jointTexture;
|
|
23194
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
23195
|
-
this._jointTexture = new Texture2D(engine, 4, boneCount, TextureFormat.R32G32B32A32, false, false);
|
|
23196
|
-
this._jointTexture.filterMode = TextureFilterMode.Point;
|
|
23197
|
-
this._jointTexture.isGCIgnored = true;
|
|
23198
|
-
}
|
|
23199
|
-
shaderData.disableMacro("RENDERER_JOINTS_NUM");
|
|
23200
|
-
shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
23201
|
-
shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
|
|
23202
|
-
} else {
|
|
23203
|
-
Logger.error("component's joints count(" + boneCount + ") greater than device's MAX_VERTEX_UNIFORM_VECTORS number " + this._maxVertexUniformVectors + ", and don't support jointTexture in this device. suggest joint count less than " + remainUniformJointCount + ".", this);
|
|
23204
|
-
}
|
|
23205
|
-
} else {
|
|
23206
|
-
var _this__jointTexture1;
|
|
23207
|
-
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
23208
|
-
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
23209
|
-
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
23210
|
-
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
|
|
23211
|
-
}
|
|
23212
|
-
boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
|
|
23213
|
-
}
|
|
23214
|
-
if (this._jointTexture) {
|
|
23215
|
-
this._jointTexture.setPixelBuffer(skin._skinMatrices);
|
|
23216
|
-
}
|
|
23217
|
-
}
|
|
23218
|
-
MeshRenderer.prototype._update.call(this, context);
|
|
23219
|
-
};
|
|
23220
|
-
/**
|
|
23221
|
-
* @internal
|
|
23222
|
-
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
23223
|
-
var _this_skin;
|
|
23224
|
-
var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
|
|
23225
|
-
if (rootBone) {
|
|
23226
|
-
engineMath.BoundingBox.transform(this._localBounds, this._transformEntity.transform.worldMatrix, worldBounds);
|
|
23227
|
-
} else {
|
|
23228
|
-
MeshRenderer.prototype._updateBounds.call(this, worldBounds);
|
|
23229
|
-
}
|
|
23230
|
-
};
|
|
23231
|
-
_proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
|
|
23232
|
-
var mesh = this._mesh;
|
|
23233
|
-
var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
|
|
23234
|
-
var lastBlendShapeWeights = this._blendShapeWeights;
|
|
23235
|
-
if (lastBlendShapeWeights) {
|
|
23236
|
-
var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
|
|
23237
|
-
if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
|
|
23238
|
-
var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
23239
|
-
if (newBlendShapeCount > lastBlendShapeWeightsCount) {
|
|
23240
|
-
newBlendShapeWeights.set(lastBlendShapeWeights);
|
|
23241
|
-
} else {
|
|
23242
|
-
for(var i = 0; i < newBlendShapeCount; i++){
|
|
23243
|
-
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
23244
|
-
}
|
|
23245
|
-
}
|
|
23246
|
-
this._blendShapeWeights = newBlendShapeWeights;
|
|
23247
|
-
}
|
|
23248
|
-
} else {
|
|
23249
|
-
this._blendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
23250
|
-
}
|
|
23251
|
-
};
|
|
23252
|
-
_proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
|
|
23253
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
23254
|
-
};
|
|
23255
|
-
_proto._onSkinUpdated = function _onSkinUpdated(type, value) {
|
|
23256
|
-
switch(type){
|
|
23257
|
-
case SkinUpdateFlag.BoneCountChanged:
|
|
23258
|
-
var shaderData = this.shaderData;
|
|
23259
|
-
if (value > 0) {
|
|
23260
|
-
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
23261
|
-
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
|
|
23262
|
-
} else {
|
|
23263
|
-
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
23264
|
-
}
|
|
23265
|
-
break;
|
|
23266
|
-
case SkinUpdateFlag.RootBoneChanged:
|
|
23267
|
-
this._setTransformEntity(value);
|
|
23268
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
23269
|
-
break;
|
|
23535
|
+
*/ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
|
|
23536
|
+
entity._scene = scene;
|
|
23537
|
+
var children = entity._children;
|
|
23538
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
23539
|
+
this._traverseSetOwnerScene(children[i], scene);
|
|
23270
23540
|
}
|
|
23271
23541
|
};
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
var
|
|
23276
|
-
var
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
var skinBoneCount = (_value_bones_length = value == null ? void 0 : (_value_bones = value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
|
|
23281
|
-
var _value_rootBone;
|
|
23282
|
-
var rootBone = (_value_rootBone = value == null ? void 0 : value.rootBone) != null ? _value_rootBone : this.entity;
|
|
23283
|
-
value == null ? void 0 : value._updatedManager.addListener(this._onSkinUpdated);
|
|
23284
|
-
if (lastSkinBoneCount !== skinBoneCount) {
|
|
23285
|
-
this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
|
|
23542
|
+
/**
|
|
23543
|
+
* @internal
|
|
23544
|
+
*/ Entity._removeFromChildren = function _removeFromChildren(children, entity) {
|
|
23545
|
+
var count = children.length - 1;
|
|
23546
|
+
for(var i = entity._siblingIndex; i < count; i++){
|
|
23547
|
+
var child = children[i + 1];
|
|
23548
|
+
children[i] = child;
|
|
23549
|
+
child._siblingIndex = i;
|
|
23286
23550
|
}
|
|
23287
|
-
|
|
23288
|
-
|
|
23551
|
+
children.length = count;
|
|
23552
|
+
entity._siblingIndex = -1;
|
|
23553
|
+
};
|
|
23554
|
+
/**
|
|
23555
|
+
* @internal
|
|
23556
|
+
*/ Entity._addToChildren = function _addToChildren(children, entity, index) {
|
|
23557
|
+
var childCount = children.length;
|
|
23558
|
+
children.length = childCount + 1;
|
|
23559
|
+
if (index === undefined) {
|
|
23560
|
+
children[childCount] = entity;
|
|
23561
|
+
entity._siblingIndex = childCount;
|
|
23562
|
+
} else {
|
|
23563
|
+
if (index < 0 || index > childCount) {
|
|
23564
|
+
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
23565
|
+
}
|
|
23566
|
+
for(var i = childCount; i > index; i--){
|
|
23567
|
+
var swapChild = children[i - 1];
|
|
23568
|
+
swapChild._siblingIndex = i;
|
|
23569
|
+
children[i] = swapChild;
|
|
23570
|
+
}
|
|
23571
|
+
entity._siblingIndex = index;
|
|
23572
|
+
children[index] = entity;
|
|
23289
23573
|
}
|
|
23290
23574
|
};
|
|
23291
|
-
_create_class(
|
|
23575
|
+
_create_class(Entity, [
|
|
23292
23576
|
{
|
|
23293
|
-
key: "
|
|
23577
|
+
key: "transform",
|
|
23294
23578
|
get: /**
|
|
23295
|
-
*
|
|
23579
|
+
* The transform of this entity.
|
|
23296
23580
|
*/ function get() {
|
|
23297
|
-
return this.
|
|
23298
|
-
},
|
|
23299
|
-
set: function set(value) {
|
|
23300
|
-
var lastSkin = this._skin;
|
|
23301
|
-
if (lastSkin !== value) {
|
|
23302
|
-
this._applySkin(lastSkin, value);
|
|
23303
|
-
this._skin = value;
|
|
23304
|
-
}
|
|
23581
|
+
return this._transform;
|
|
23305
23582
|
}
|
|
23306
23583
|
},
|
|
23307
23584
|
{
|
|
23308
|
-
key: "
|
|
23585
|
+
key: "isActive",
|
|
23309
23586
|
get: /**
|
|
23310
|
-
*
|
|
23311
|
-
* @remarks Array index is BlendShape index.
|
|
23587
|
+
* Whether to activate locally.
|
|
23312
23588
|
*/ function get() {
|
|
23313
|
-
this.
|
|
23314
|
-
return this._blendShapeWeights;
|
|
23589
|
+
return this._isActive;
|
|
23315
23590
|
},
|
|
23316
23591
|
set: function set(value) {
|
|
23317
|
-
this.
|
|
23318
|
-
|
|
23319
|
-
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
|
|
23592
|
+
if (value !== this._isActive) {
|
|
23593
|
+
this._isActive = value;
|
|
23594
|
+
if (value) {
|
|
23595
|
+
var parent = this._parent;
|
|
23596
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
23597
|
+
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
23598
|
+
activeChangeFlag |= ActiveChangeFlag.All;
|
|
23599
|
+
} else {
|
|
23600
|
+
(parent == null ? void 0 : parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
23601
|
+
(parent == null ? void 0 : parent._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
23602
|
+
}
|
|
23603
|
+
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
23604
|
+
} else {
|
|
23605
|
+
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
23606
|
+
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
23607
|
+
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
23608
|
+
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
23324
23609
|
}
|
|
23325
23610
|
}
|
|
23326
23611
|
}
|
|
23327
23612
|
},
|
|
23328
23613
|
{
|
|
23329
|
-
key: "
|
|
23614
|
+
key: "isActiveInHierarchy",
|
|
23330
23615
|
get: /**
|
|
23331
|
-
*
|
|
23616
|
+
* Whether it is active in the hierarchy.
|
|
23332
23617
|
*/ function get() {
|
|
23333
|
-
return this.
|
|
23334
|
-
},
|
|
23335
|
-
set: function set(value) {
|
|
23336
|
-
if (this._localBounds !== value) {
|
|
23337
|
-
this._localBounds.copyFrom(value);
|
|
23338
|
-
}
|
|
23618
|
+
return this._isActiveInHierarchy;
|
|
23339
23619
|
}
|
|
23340
23620
|
},
|
|
23341
23621
|
{
|
|
23342
|
-
key: "
|
|
23622
|
+
key: "parent",
|
|
23343
23623
|
get: /**
|
|
23344
|
-
*
|
|
23624
|
+
* The parent entity.
|
|
23345
23625
|
*/ function get() {
|
|
23346
|
-
return this.
|
|
23626
|
+
return this._parent;
|
|
23347
23627
|
},
|
|
23348
23628
|
set: function set(value) {
|
|
23349
|
-
this.
|
|
23629
|
+
this._setParent(value);
|
|
23350
23630
|
}
|
|
23351
23631
|
},
|
|
23352
23632
|
{
|
|
23353
|
-
key: "
|
|
23633
|
+
key: "children",
|
|
23354
23634
|
get: /**
|
|
23355
|
-
*
|
|
23635
|
+
* The children entities
|
|
23356
23636
|
*/ function get() {
|
|
23357
|
-
return this.
|
|
23358
|
-
},
|
|
23359
|
-
set: function set(value) {
|
|
23360
|
-
this.skin.bones = value;
|
|
23361
|
-
}
|
|
23362
|
-
}
|
|
23363
|
-
]);
|
|
23364
|
-
return SkinnedMeshRenderer;
|
|
23365
|
-
}(MeshRenderer);
|
|
23366
|
-
// @TODO: different shader type should use different count, not always 48
|
|
23367
|
-
/** @internal */ SkinnedMeshRenderer._baseVertexUniformVectorCount = 48;
|
|
23368
|
-
SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
|
|
23369
|
-
SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
|
|
23370
|
-
SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
|
|
23371
|
-
__decorate([
|
|
23372
|
-
ignoreClone
|
|
23373
|
-
], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
|
|
23374
|
-
__decorate([
|
|
23375
|
-
deepClone
|
|
23376
|
-
], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
|
|
23377
|
-
__decorate([
|
|
23378
|
-
ignoreClone
|
|
23379
|
-
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
23380
|
-
__decorate([
|
|
23381
|
-
ignoreClone
|
|
23382
|
-
], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
|
|
23383
|
-
__decorate([
|
|
23384
|
-
ignoreClone
|
|
23385
|
-
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
23386
|
-
__decorate([
|
|
23387
|
-
ignoreClone
|
|
23388
|
-
], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
|
|
23389
|
-
__decorate([
|
|
23390
|
-
deepClone
|
|
23391
|
-
], SkinnedMeshRenderer.prototype, "_skin", void 0);
|
|
23392
|
-
__decorate([
|
|
23393
|
-
ignoreClone
|
|
23394
|
-
], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
|
|
23395
|
-
__decorate([
|
|
23396
|
-
ignoreClone
|
|
23397
|
-
], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
|
|
23398
|
-
|
|
23399
|
-
/**
|
|
23400
|
-
* @internal
|
|
23401
|
-
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
23402
|
-
function BasicResources(engine) {
|
|
23403
|
-
this.engine = engine;
|
|
23404
|
-
// prettier-ignore
|
|
23405
|
-
var vertices = new Float32Array([
|
|
23406
|
-
-1,
|
|
23407
|
-
-1,
|
|
23408
|
-
0,
|
|
23409
|
-
1,
|
|
23410
|
-
3,
|
|
23411
|
-
-1,
|
|
23412
|
-
2,
|
|
23413
|
-
1,
|
|
23414
|
-
-1,
|
|
23415
|
-
3,
|
|
23416
|
-
0,
|
|
23417
|
-
-1
|
|
23418
|
-
]); // left-top
|
|
23419
|
-
// prettier-ignore
|
|
23420
|
-
var flipYVertices = new Float32Array([
|
|
23421
|
-
3,
|
|
23422
|
-
-1,
|
|
23423
|
-
2,
|
|
23424
|
-
0,
|
|
23425
|
-
-1,
|
|
23426
|
-
-1,
|
|
23427
|
-
0,
|
|
23428
|
-
0,
|
|
23429
|
-
-1,
|
|
23430
|
-
3,
|
|
23431
|
-
0,
|
|
23432
|
-
2
|
|
23433
|
-
]); // left-top
|
|
23434
|
-
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
23435
|
-
blitMaterial._addReferCount(1);
|
|
23436
|
-
blitMaterial.renderState.depthState.enabled = false;
|
|
23437
|
-
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
23438
|
-
var blitScreenMaterial = new Material(engine, Shader.find("blit-screen"));
|
|
23439
|
-
blitScreenMaterial._addReferCount(1);
|
|
23440
|
-
blitScreenMaterial.renderState.depthState.enabled = false;
|
|
23441
|
-
blitScreenMaterial.renderState.depthState.writeEnabled = false;
|
|
23442
|
-
this.blitMaterial = blitMaterial;
|
|
23443
|
-
this.blitScreenMaterial = blitScreenMaterial;
|
|
23444
|
-
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
23445
|
-
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
23446
|
-
// Create white and magenta textures
|
|
23447
|
-
var whitePixel = new Uint8Array([
|
|
23448
|
-
255,
|
|
23449
|
-
255,
|
|
23450
|
-
255,
|
|
23451
|
-
255
|
|
23452
|
-
]);
|
|
23453
|
-
this.whiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
23454
|
-
this.whiteTextureCube = this._create1x1Texture(engine, 1, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
23455
|
-
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
23456
|
-
if (isWebGL2) {
|
|
23457
|
-
this.whiteTexture2DArray = this._create1x1Texture(engine, 2, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
23458
|
-
var whitePixel32 = new Uint32Array([
|
|
23459
|
-
255,
|
|
23460
|
-
255,
|
|
23461
|
-
255,
|
|
23462
|
-
255
|
|
23463
|
-
]);
|
|
23464
|
-
this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
|
|
23465
|
-
}
|
|
23466
|
-
this.spriteDefaultMaterial = this._create2DMaterial(engine, Shader.find("Sprite"));
|
|
23467
|
-
this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
|
|
23468
|
-
this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
|
|
23469
|
-
this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
|
|
23470
|
-
this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
|
|
23471
|
-
}
|
|
23472
|
-
var _proto = BasicResources.prototype;
|
|
23473
|
-
/**
|
|
23474
|
-
* @internal
|
|
23475
|
-
*/ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
|
|
23476
|
-
return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
|
|
23477
|
-
};
|
|
23478
|
-
/**
|
|
23479
|
-
* @internal
|
|
23480
|
-
*/ _proto._initialize = function _initialize() {
|
|
23481
|
-
var _this = this;
|
|
23482
|
-
return new Promise(function(resolve, reject) {
|
|
23483
|
-
PrefilteredDFG.create(_this.engine).then(function(texture) {
|
|
23484
|
-
_this._prefilteredDFGTexture = texture;
|
|
23485
|
-
resolve(_this);
|
|
23486
|
-
}).catch(reject);
|
|
23487
|
-
});
|
|
23488
|
-
};
|
|
23489
|
-
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
23490
|
-
var mesh = new ModelMesh(engine);
|
|
23491
|
-
mesh._addReferCount(1);
|
|
23492
|
-
mesh.setVertexElements([
|
|
23493
|
-
new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
|
|
23494
|
-
]);
|
|
23495
|
-
var buffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
|
|
23496
|
-
mesh.setVertexBufferBinding(buffer, 16);
|
|
23497
|
-
mesh.addSubMesh(0, 3, MeshTopology.Triangles);
|
|
23498
|
-
engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
|
|
23499
|
-
_inherits(_class, ContentRestorer);
|
|
23500
|
-
function _class() {
|
|
23501
|
-
return ContentRestorer.call(this, mesh) || this;
|
|
23502
|
-
}
|
|
23503
|
-
var _proto = _class.prototype;
|
|
23504
|
-
_proto.restoreContent = function restoreContent() {
|
|
23505
|
-
buffer.setData(buffer.data);
|
|
23506
|
-
};
|
|
23507
|
-
return _class;
|
|
23508
|
-
}(ContentRestorer))());
|
|
23509
|
-
return mesh;
|
|
23510
|
-
};
|
|
23511
|
-
_proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel, isSRGBColorSpace) {
|
|
23512
|
-
var texture;
|
|
23513
|
-
switch(type){
|
|
23514
|
-
case 0:
|
|
23515
|
-
var texture2D = new Texture2D(engine, 1, 1, format, false, isSRGBColorSpace);
|
|
23516
|
-
texture2D.setPixelBuffer(pixel);
|
|
23517
|
-
texture = texture2D;
|
|
23518
|
-
break;
|
|
23519
|
-
case 2:
|
|
23520
|
-
var texture2DArray = new Texture2DArray(engine, 1, 1, 1, format, false, isSRGBColorSpace);
|
|
23521
|
-
texture2DArray.setPixelBuffer(0, pixel);
|
|
23522
|
-
texture = texture2DArray;
|
|
23523
|
-
break;
|
|
23524
|
-
case 1:
|
|
23525
|
-
var textureCube = new TextureCube(engine, 1, format, false, isSRGBColorSpace);
|
|
23526
|
-
for(var i = 0; i < 6; i++){
|
|
23527
|
-
textureCube.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
23528
|
-
}
|
|
23529
|
-
texture = textureCube;
|
|
23530
|
-
break;
|
|
23531
|
-
default:
|
|
23532
|
-
throw "Invalid texture type";
|
|
23533
|
-
}
|
|
23534
|
-
texture.isGCIgnored = true;
|
|
23535
|
-
engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
|
|
23536
|
-
_inherits(_class, ContentRestorer);
|
|
23537
|
-
function _class() {
|
|
23538
|
-
return ContentRestorer.call(this, texture) || this;
|
|
23539
|
-
}
|
|
23540
|
-
var _proto = _class.prototype;
|
|
23541
|
-
_proto.restoreContent = function restoreContent() {
|
|
23542
|
-
switch(type){
|
|
23543
|
-
case 0:
|
|
23544
|
-
this.resource.setPixelBuffer(pixel);
|
|
23545
|
-
break;
|
|
23546
|
-
case 2:
|
|
23547
|
-
this.resource.setPixelBuffer(0, pixel);
|
|
23548
|
-
break;
|
|
23549
|
-
case 1:
|
|
23550
|
-
for(var i = 0; i < 6; i++){
|
|
23551
|
-
this.resource.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
23552
|
-
}
|
|
23553
|
-
break;
|
|
23554
|
-
}
|
|
23555
|
-
};
|
|
23556
|
-
return _class;
|
|
23557
|
-
}(ContentRestorer))());
|
|
23558
|
-
return texture;
|
|
23559
|
-
};
|
|
23560
|
-
_proto._create2DMaterial = function _create2DMaterial(engine, shader) {
|
|
23561
|
-
var material = new Material(engine, shader);
|
|
23562
|
-
var renderState = material.renderState;
|
|
23563
|
-
var target = renderState.blendState.targetBlendState;
|
|
23564
|
-
target.enabled = true;
|
|
23565
|
-
target.sourceColorBlendFactor = BlendFactor.SourceAlpha;
|
|
23566
|
-
target.destinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
23567
|
-
target.sourceAlphaBlendFactor = BlendFactor.One;
|
|
23568
|
-
target.destinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
23569
|
-
target.colorBlendOperation = target.alphaBlendOperation = BlendOperation.Add;
|
|
23570
|
-
renderState.depthState.writeEnabled = false;
|
|
23571
|
-
renderState.rasterState.cullMode = CullMode.Off;
|
|
23572
|
-
renderState.renderQueueType = RenderQueueType.Transparent;
|
|
23573
|
-
material.isGCIgnored = true;
|
|
23574
|
-
return material;
|
|
23575
|
-
};
|
|
23576
|
-
_proto._createMagentaMaterial = function _createMagentaMaterial(engine, shaderName) {
|
|
23577
|
-
var material = new Material(engine, Shader.find(shaderName));
|
|
23578
|
-
material.isGCIgnored = true;
|
|
23579
|
-
material.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
23580
|
-
return material;
|
|
23581
|
-
};
|
|
23582
|
-
_proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
|
|
23583
|
-
var material = new Material(engine, Shader.find("SpriteMask"));
|
|
23584
|
-
material.isGCIgnored = true;
|
|
23585
|
-
return material;
|
|
23586
|
-
};
|
|
23587
|
-
BasicResources.getMaskInteractionRenderStates = function getMaskInteractionRenderStates(maskInteraction) {
|
|
23588
|
-
var visibleInsideMask = maskInteraction === SpriteMaskInteraction.VisibleInsideMask;
|
|
23589
|
-
var renderStates;
|
|
23590
|
-
var compareFunction;
|
|
23591
|
-
if (visibleInsideMask) {
|
|
23592
|
-
renderStates = BasicResources._maskReadInsideRenderStates;
|
|
23593
|
-
if (renderStates) {
|
|
23594
|
-
return renderStates;
|
|
23595
|
-
}
|
|
23596
|
-
BasicResources._maskReadInsideRenderStates = renderStates = {};
|
|
23597
|
-
compareFunction = CompareFunction.LessEqual;
|
|
23598
|
-
} else {
|
|
23599
|
-
renderStates = BasicResources._maskReadOutsideRenderStates;
|
|
23600
|
-
if (renderStates) {
|
|
23601
|
-
return renderStates;
|
|
23637
|
+
return this._children;
|
|
23602
23638
|
}
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23608
|
-
|
|
23609
|
-
|
|
23610
|
-
|
|
23611
|
-
return renderStates;
|
|
23612
|
-
};
|
|
23613
|
-
BasicResources.getMaskTypeRenderStates = function getMaskTypeRenderStates(maskType) {
|
|
23614
|
-
var isIncrement = maskType === RenderQueueMaskType.Increment;
|
|
23615
|
-
var renderStates;
|
|
23616
|
-
var passOperation;
|
|
23617
|
-
if (isIncrement) {
|
|
23618
|
-
renderStates = BasicResources._maskWriteIncrementRenderStates;
|
|
23619
|
-
if (renderStates) {
|
|
23620
|
-
return renderStates;
|
|
23639
|
+
},
|
|
23640
|
+
{
|
|
23641
|
+
key: "childCount",
|
|
23642
|
+
get: /**
|
|
23643
|
+
* @deprecated Please use `children.length` property instead.
|
|
23644
|
+
* Number of the children entities
|
|
23645
|
+
*/ function get() {
|
|
23646
|
+
return this._children.length;
|
|
23621
23647
|
}
|
|
23622
|
-
|
|
23623
|
-
|
|
23624
|
-
|
|
23625
|
-
|
|
23626
|
-
|
|
23627
|
-
|
|
23648
|
+
},
|
|
23649
|
+
{
|
|
23650
|
+
key: "scene",
|
|
23651
|
+
get: /**
|
|
23652
|
+
* The scene the entity belongs to.
|
|
23653
|
+
*/ function get() {
|
|
23654
|
+
return this._scene;
|
|
23628
23655
|
}
|
|
23629
|
-
|
|
23630
|
-
passOperation = StencilOperation.DecrementSaturate;
|
|
23631
|
-
}
|
|
23632
|
-
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
23633
|
-
renderStates[RenderStateElementKey.StencilStatePassOperationFront] = passOperation;
|
|
23634
|
-
renderStates[RenderStateElementKey.StencilStatePassOperationBack] = passOperation;
|
|
23635
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = CompareFunction.Always;
|
|
23636
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = CompareFunction.Always;
|
|
23637
|
-
var failStencilOperation = StencilOperation.Keep;
|
|
23638
|
-
renderStates[RenderStateElementKey.StencilStateFailOperationFront] = failStencilOperation;
|
|
23639
|
-
renderStates[RenderStateElementKey.StencilStateFailOperationBack] = failStencilOperation;
|
|
23640
|
-
renderStates[RenderStateElementKey.StencilStateZFailOperationFront] = failStencilOperation;
|
|
23641
|
-
renderStates[RenderStateElementKey.StencilStateZFailOperationBack] = failStencilOperation;
|
|
23642
|
-
renderStates[RenderStateElementKey.BlendStateColorWriteMask0] = ColorWriteMask.None;
|
|
23643
|
-
renderStates[RenderStateElementKey.DepthStateEnabled] = false;
|
|
23644
|
-
renderStates[RenderStateElementKey.RasterStateCullMode] = CullMode.Off;
|
|
23645
|
-
return renderStates;
|
|
23646
|
-
};
|
|
23647
|
-
_create_class(BasicResources, [
|
|
23656
|
+
},
|
|
23648
23657
|
{
|
|
23649
|
-
key: "
|
|
23650
|
-
get:
|
|
23651
|
-
|
|
23658
|
+
key: "siblingIndex",
|
|
23659
|
+
get: /**
|
|
23660
|
+
* The sibling index.
|
|
23661
|
+
*/ function get() {
|
|
23662
|
+
return this._siblingIndex;
|
|
23663
|
+
},
|
|
23664
|
+
set: function set(value) {
|
|
23665
|
+
if (this._siblingIndex === -1) {
|
|
23666
|
+
throw "The entity " + this.name + " is not in the hierarchy";
|
|
23667
|
+
}
|
|
23668
|
+
if (this._isRoot) {
|
|
23669
|
+
this._setSiblingIndex(this._scene._rootEntities, value);
|
|
23670
|
+
} else {
|
|
23671
|
+
var parent = this._parent;
|
|
23672
|
+
this._setSiblingIndex(parent._children, value);
|
|
23673
|
+
parent._dispatchModify(EntityModifyFlags.Child, parent);
|
|
23674
|
+
}
|
|
23652
23675
|
}
|
|
23653
23676
|
}
|
|
23654
23677
|
]);
|
|
23655
|
-
return
|
|
23656
|
-
}();
|
|
23657
|
-
|
|
23658
|
-
BasicResources._maskReadOutsideRenderStates = null;
|
|
23659
|
-
BasicResources._maskWriteIncrementRenderStates = null;
|
|
23660
|
-
BasicResources._maskWriteDecrementRenderStates = null;
|
|
23678
|
+
return Entity;
|
|
23679
|
+
}(EngineObject);
|
|
23680
|
+
/** @internal */ Entity._tempComponentConstructors = [];
|
|
23661
23681
|
|
|
23662
23682
|
var ObjectPool = /*#__PURE__*/ function() {
|
|
23663
23683
|
function ObjectPool(type) {
|
|
@@ -24153,6 +24173,7 @@ PrimitiveChunk.subMeshPool = new ReturnableObjectPool(SubMesh, 10);
|
|
|
24153
24173
|
/** AudioClip, include ogg, wav and mp3. */ AssetType["Audio"] = "Audio";
|
|
24154
24174
|
/** Project asset. */ AssetType["Project"] = "project";
|
|
24155
24175
|
/** PhysicsMaterial. */ AssetType["PhysicsMaterial"] = "PhysicsMaterial";
|
|
24176
|
+
/** RenderTarget. */ AssetType["RenderTarget"] = "RenderTarget";
|
|
24156
24177
|
return AssetType;
|
|
24157
24178
|
}({});
|
|
24158
24179
|
|
|
@@ -29021,6 +29042,184 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
29021
29042
|
return PointerMethods;
|
|
29022
29043
|
}({});
|
|
29023
29044
|
|
|
29045
|
+
/**
|
|
29046
|
+
* Signal is a typed event mechanism for Galacean Engine.
|
|
29047
|
+
* @typeParam T - Tuple type of the signal arguments
|
|
29048
|
+
*/ var Signal = /*#__PURE__*/ function() {
|
|
29049
|
+
function Signal() {
|
|
29050
|
+
this._listeners = new SafeLoopArray();
|
|
29051
|
+
}
|
|
29052
|
+
var _proto = Signal.prototype;
|
|
29053
|
+
_proto.on = function on(fnOrTarget, targetOrMethodName) {
|
|
29054
|
+
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
29055
|
+
args[_key - 2] = arguments[_key];
|
|
29056
|
+
}
|
|
29057
|
+
this._addListener.apply(this, [].concat([
|
|
29058
|
+
fnOrTarget,
|
|
29059
|
+
targetOrMethodName,
|
|
29060
|
+
false
|
|
29061
|
+
], args));
|
|
29062
|
+
};
|
|
29063
|
+
_proto.once = function once(fnOrTarget, targetOrMethodName) {
|
|
29064
|
+
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
29065
|
+
args[_key - 2] = arguments[_key];
|
|
29066
|
+
}
|
|
29067
|
+
this._addListener.apply(this, [].concat([
|
|
29068
|
+
fnOrTarget,
|
|
29069
|
+
targetOrMethodName,
|
|
29070
|
+
true
|
|
29071
|
+
], args));
|
|
29072
|
+
};
|
|
29073
|
+
_proto.off = function off(fnOrTarget, targetOrMethodName) {
|
|
29074
|
+
if (typeof fnOrTarget === "function") {
|
|
29075
|
+
var target = targetOrMethodName != null ? targetOrMethodName : null;
|
|
29076
|
+
this._listeners.findAndRemove(function(listener) {
|
|
29077
|
+
if (listener.fn === fnOrTarget && listener.target === target) {
|
|
29078
|
+
listener.destroyed = true;
|
|
29079
|
+
return true;
|
|
29080
|
+
}
|
|
29081
|
+
return false;
|
|
29082
|
+
});
|
|
29083
|
+
} else {
|
|
29084
|
+
var target1 = fnOrTarget;
|
|
29085
|
+
var methodName = targetOrMethodName;
|
|
29086
|
+
this._listeners.findAndRemove(function(listener) {
|
|
29087
|
+
if (listener.target === target1 && listener.methodName === methodName) {
|
|
29088
|
+
listener.destroyed = true;
|
|
29089
|
+
return true;
|
|
29090
|
+
}
|
|
29091
|
+
return false;
|
|
29092
|
+
});
|
|
29093
|
+
}
|
|
29094
|
+
};
|
|
29095
|
+
/**
|
|
29096
|
+
* Remove all listeners, or all listeners for a specific target.
|
|
29097
|
+
* @param target - If provided, only remove listeners bound to this target
|
|
29098
|
+
*/ _proto.removeAll = function removeAll(target) {
|
|
29099
|
+
if (target !== undefined) {
|
|
29100
|
+
this._listeners.findAndRemove(function(listener) {
|
|
29101
|
+
if (listener.target === target) {
|
|
29102
|
+
return listener.destroyed = true;
|
|
29103
|
+
}
|
|
29104
|
+
return false;
|
|
29105
|
+
});
|
|
29106
|
+
} else {
|
|
29107
|
+
this._listeners.findAndRemove(function(listener) {
|
|
29108
|
+
return listener.destroyed = true;
|
|
29109
|
+
});
|
|
29110
|
+
}
|
|
29111
|
+
};
|
|
29112
|
+
/**
|
|
29113
|
+
* Invoke the signal, calling all listeners in order.
|
|
29114
|
+
* @param args - Arguments to pass to each listener
|
|
29115
|
+
*/ _proto.invoke = function invoke() {
|
|
29116
|
+
var _this, _loop = function(i, n) {
|
|
29117
|
+
var listener = listeners[i];
|
|
29118
|
+
if (listener.destroyed) return "continue";
|
|
29119
|
+
if (listener.methodName && listener.target.destroyed) {
|
|
29120
|
+
listener.destroyed = true;
|
|
29121
|
+
_this._listeners.findAndRemove(function(l) {
|
|
29122
|
+
return l === listener;
|
|
29123
|
+
});
|
|
29124
|
+
return "continue";
|
|
29125
|
+
}
|
|
29126
|
+
listener.fn.apply(listener.target, args);
|
|
29127
|
+
if (listener.once) {
|
|
29128
|
+
listener.destroyed = true;
|
|
29129
|
+
_this._listeners.findAndRemove(function(l) {
|
|
29130
|
+
return l === listener;
|
|
29131
|
+
});
|
|
29132
|
+
}
|
|
29133
|
+
};
|
|
29134
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
29135
|
+
args[_key] = arguments[_key];
|
|
29136
|
+
}
|
|
29137
|
+
var listeners = this._listeners.getLoopArray();
|
|
29138
|
+
for(var i = 0, n = listeners.length; i < n; i++)_this = this, _loop(i);
|
|
29139
|
+
};
|
|
29140
|
+
/**
|
|
29141
|
+
* @internal
|
|
29142
|
+
* Clone listeners to target signal, remapping entity/component references.
|
|
29143
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
29144
|
+
var listeners = this._listeners.getLoopArray();
|
|
29145
|
+
for(var i = 0, n = listeners.length; i < n; i++){
|
|
29146
|
+
var listener = listeners[i];
|
|
29147
|
+
if (listener.destroyed || !listener.methodName) continue;
|
|
29148
|
+
var clonedTarget = CloneUtils.remapComponent(srcRoot, targetRoot, listener.target);
|
|
29149
|
+
if (clonedTarget) {
|
|
29150
|
+
var clonedArgs = this._cloneArguments(listener.arguments, srcRoot, targetRoot);
|
|
29151
|
+
if (listener.once) {
|
|
29152
|
+
var _target;
|
|
29153
|
+
(_target = target).once.apply(_target, [].concat([
|
|
29154
|
+
clonedTarget,
|
|
29155
|
+
listener.methodName
|
|
29156
|
+
], clonedArgs));
|
|
29157
|
+
} else {
|
|
29158
|
+
var _target1;
|
|
29159
|
+
(_target1 = target).on.apply(_target1, [].concat([
|
|
29160
|
+
clonedTarget,
|
|
29161
|
+
listener.methodName
|
|
29162
|
+
], clonedArgs));
|
|
29163
|
+
}
|
|
29164
|
+
}
|
|
29165
|
+
}
|
|
29166
|
+
};
|
|
29167
|
+
_proto._cloneArguments = function _cloneArguments(args, srcRoot, targetRoot) {
|
|
29168
|
+
if (!args || args.length === 0) return [];
|
|
29169
|
+
var len = args.length;
|
|
29170
|
+
var clonedArgs = new Array(len);
|
|
29171
|
+
for(var i = 0; i < len; i++){
|
|
29172
|
+
var arg = args[i];
|
|
29173
|
+
if (_instanceof(arg, Entity)) {
|
|
29174
|
+
clonedArgs[i] = CloneUtils.remapEntity(srcRoot, targetRoot, arg);
|
|
29175
|
+
} else if (_instanceof(arg, Component)) {
|
|
29176
|
+
clonedArgs[i] = CloneUtils.remapComponent(srcRoot, targetRoot, arg);
|
|
29177
|
+
} else {
|
|
29178
|
+
clonedArgs[i] = arg;
|
|
29179
|
+
}
|
|
29180
|
+
}
|
|
29181
|
+
return clonedArgs;
|
|
29182
|
+
};
|
|
29183
|
+
_proto._addListener = function _addListener(fnOrTarget, targetOrMethodName, once) {
|
|
29184
|
+
for(var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
|
|
29185
|
+
args[_key - 3] = arguments[_key];
|
|
29186
|
+
}
|
|
29187
|
+
if (typeof fnOrTarget === "function") {
|
|
29188
|
+
this._listeners.push({
|
|
29189
|
+
fn: fnOrTarget,
|
|
29190
|
+
target: targetOrMethodName != null ? targetOrMethodName : null,
|
|
29191
|
+
once: once
|
|
29192
|
+
});
|
|
29193
|
+
} else {
|
|
29194
|
+
var _target, _target1;
|
|
29195
|
+
var target = fnOrTarget;
|
|
29196
|
+
var methodName = targetOrMethodName;
|
|
29197
|
+
var fn = args.length > 0 ? function() {
|
|
29198
|
+
for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
29199
|
+
signalArgs[_key] = arguments[_key];
|
|
29200
|
+
}
|
|
29201
|
+
return (_target = target)[methodName].apply(_target, [].concat(args, signalArgs));
|
|
29202
|
+
} : function() {
|
|
29203
|
+
for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
29204
|
+
signalArgs[_key] = arguments[_key];
|
|
29205
|
+
}
|
|
29206
|
+
return (_target1 = target)[methodName].apply(_target1, [].concat(signalArgs));
|
|
29207
|
+
};
|
|
29208
|
+
this._listeners.push({
|
|
29209
|
+
fn: fn,
|
|
29210
|
+
target: target,
|
|
29211
|
+
once: once,
|
|
29212
|
+
methodName: methodName,
|
|
29213
|
+
arguments: args
|
|
29214
|
+
});
|
|
29215
|
+
}
|
|
29216
|
+
};
|
|
29217
|
+
return Signal;
|
|
29218
|
+
}();
|
|
29219
|
+
__decorate([
|
|
29220
|
+
ignoreClone
|
|
29221
|
+
], Signal.prototype, "_listeners", void 0);
|
|
29222
|
+
|
|
29024
29223
|
/**
|
|
29025
29224
|
* Loader abstract class.
|
|
29026
29225
|
*/ var Loader = /*#__PURE__*/ function() {
|
|
@@ -38393,6 +38592,7 @@ exports.CharacterController = CharacterController;
|
|
|
38393
38592
|
exports.CircleShape = CircleShape;
|
|
38394
38593
|
exports.ClearableObjectPool = ClearableObjectPool;
|
|
38395
38594
|
exports.CloneManager = CloneManager;
|
|
38595
|
+
exports.CloneUtils = CloneUtils;
|
|
38396
38596
|
exports.ColliderShape = ColliderShape;
|
|
38397
38597
|
exports.ColliderShapeUpAxis = ColliderShapeUpAxis;
|
|
38398
38598
|
exports.Collision = Collision;
|
|
@@ -38546,6 +38746,7 @@ exports.ShaderTagKey = ShaderTagKey;
|
|
|
38546
38746
|
exports.ShadowCascadesMode = ShadowCascadesMode;
|
|
38547
38747
|
exports.ShadowResolution = ShadowResolution;
|
|
38548
38748
|
exports.ShadowType = ShadowType;
|
|
38749
|
+
exports.Signal = Signal;
|
|
38549
38750
|
exports.SizeOverLifetimeModule = SizeOverLifetimeModule;
|
|
38550
38751
|
exports.Skin = Skin;
|
|
38551
38752
|
exports.SkinnedMeshRenderer = SkinnedMeshRenderer;
|