@galacean/engine-core 2.0.0-alpha.14 → 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 +1432 -1240
- package/dist/main.js.map +1 -1
- package/dist/module.js +1431 -1241
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Signal.d.ts +58 -0
- package/types/clone/CloneUtils.d.ts +1 -0
- package/types/index.d.ts +2 -0
package/dist/main.js
CHANGED
|
@@ -22294,1378 +22294,1390 @@ PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
|
22294
22294
|
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
22295
22295
|
PrimitiveMesh._spherePoleIdx = 0;
|
|
22296
22296
|
|
|
22297
|
-
|
|
22298
|
-
|
|
22299
|
-
|
|
22300
|
-
|
|
22301
|
-
|
|
22302
|
-
|
|
22303
|
-
|
|
22304
|
-
|
|
22305
|
-
|
|
22306
|
-
}
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
|
|
22316
|
-
var
|
|
22317
|
-
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
return instance;
|
|
22324
|
-
};
|
|
22325
|
-
}
|
|
22326
|
-
|
|
22327
|
-
return _construct.apply(null, arguments);
|
|
22328
|
-
}
|
|
22329
|
-
|
|
22330
|
-
var ComponentCloner = /*#__PURE__*/ function() {
|
|
22331
|
-
function ComponentCloner() {}
|
|
22332
|
-
/**
|
|
22333
|
-
* Clone component.
|
|
22334
|
-
* @param source - Clone source
|
|
22335
|
-
* @param target - Clone target
|
|
22336
|
-
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
22337
|
-
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
22338
|
-
for(var k in source){
|
|
22339
|
-
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;
|
|
22340
22322
|
}
|
|
22341
|
-
|
|
22342
|
-
|
|
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]];
|
|
22343
22329
|
}
|
|
22330
|
+
return entity;
|
|
22344
22331
|
};
|
|
22345
|
-
return
|
|
22332
|
+
return CloneUtils;
|
|
22346
22333
|
}();
|
|
22334
|
+
CloneUtils._tempRemapPath = [];
|
|
22347
22335
|
|
|
22348
22336
|
/**
|
|
22349
|
-
*
|
|
22350
|
-
*/ var
|
|
22351
|
-
|
|
22352
|
-
|
|
22353
|
-
return EntityModifyFlags;
|
|
22354
|
-
}({});
|
|
22355
|
-
|
|
22356
|
-
/**
|
|
22357
|
-
* Entity, be used as components container.
|
|
22358
|
-
*/ var Entity = /*#__PURE__*/ function(EngineObject) {
|
|
22359
|
-
_inherits(Entity, EngineObject);
|
|
22360
|
-
function Entity(engine, name) {
|
|
22361
|
-
for(var _len = arguments.length, components = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
22362
|
-
components[_key - 2] = arguments[_key];
|
|
22363
|
-
}
|
|
22337
|
+
* Skin used for skinned mesh renderer.
|
|
22338
|
+
*/ var Skin = /*#__PURE__*/ function(EngineObject) {
|
|
22339
|
+
_inherits(Skin, EngineObject);
|
|
22340
|
+
function Skin(name) {
|
|
22364
22341
|
var _this;
|
|
22365
|
-
_this = EngineObject.call(this,
|
|
22366
|
-
_this._invModelMatrix = new engineMath.Matrix();
|
|
22367
|
-
_this.name = name != null ? name : "Entity";
|
|
22368
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
22369
|
-
_this.addComponent(components[i]);
|
|
22370
|
-
}
|
|
22371
|
-
!_this._transform && _this.addComponent(Transform);
|
|
22372
|
-
_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 = [];
|
|
22373
22343
|
return _this;
|
|
22374
22344
|
}
|
|
22375
|
-
var _proto =
|
|
22376
|
-
/**
|
|
22377
|
-
* Add component based on the component type.
|
|
22378
|
-
* @param type - The type of the component
|
|
22379
|
-
* @param args - The arguments of the component
|
|
22380
|
-
* @returns The component which has been added
|
|
22381
|
-
*/ _proto.addComponent = function addComponent(type) {
|
|
22382
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
22383
|
-
args[_key - 1] = arguments[_key];
|
|
22384
|
-
}
|
|
22385
|
-
ComponentsDependencies._addCheck(this, type);
|
|
22386
|
-
var component = _construct(type, [].concat([
|
|
22387
|
-
this
|
|
22388
|
-
], args));
|
|
22389
|
-
this._components.push(component);
|
|
22390
|
-
// @todo: temporary solution
|
|
22391
|
-
if (_instanceof(component, Transform)) this._setTransform(component);
|
|
22392
|
-
component._setActive(true, ActiveChangeFlag.All);
|
|
22393
|
-
return component;
|
|
22394
|
-
};
|
|
22345
|
+
var _proto = Skin.prototype;
|
|
22395
22346
|
/**
|
|
22396
|
-
*
|
|
22397
|
-
|
|
22398
|
-
|
|
22399
|
-
|
|
22400
|
-
var components = this._components;
|
|
22401
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
22402
|
-
var component = components[i];
|
|
22403
|
-
if (_instanceof(component, type)) {
|
|
22404
|
-
return component;
|
|
22405
|
-
}
|
|
22347
|
+
* @internal
|
|
22348
|
+
*/ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
|
|
22349
|
+
if (this._updateMark === renderer.engine.time.frameCount) {
|
|
22350
|
+
return;
|
|
22406
22351
|
}
|
|
22407
|
-
|
|
22408
|
-
|
|
22409
|
-
|
|
22410
|
-
|
|
22411
|
-
|
|
22412
|
-
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
|
|
22416
|
-
|
|
22417
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
22418
|
-
var component = components[i];
|
|
22419
|
-
if (_instanceof(component, type)) {
|
|
22420
|
-
results.push(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);
|
|
22421
22362
|
}
|
|
22363
|
+
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
22422
22364
|
}
|
|
22423
|
-
|
|
22424
|
-
};
|
|
22425
|
-
/**
|
|
22426
|
-
* Get the components which match the type of the entity and it's children.
|
|
22427
|
-
* @param type - The component type
|
|
22428
|
-
* @param results - The components collection
|
|
22429
|
-
* @returns The components collection which match the type
|
|
22430
|
-
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
22431
|
-
results.length = 0;
|
|
22432
|
-
this._getComponentsInChildren(type, results);
|
|
22433
|
-
return results;
|
|
22434
|
-
};
|
|
22435
|
-
_proto.addChild = function addChild(indexOrChild, child) {
|
|
22436
|
-
var index;
|
|
22437
|
-
if (typeof indexOrChild === "number") {
|
|
22438
|
-
index = indexOrChild;
|
|
22439
|
-
} else {
|
|
22440
|
-
index = undefined;
|
|
22441
|
-
child = indexOrChild;
|
|
22442
|
-
}
|
|
22443
|
-
child._setParent(this, index);
|
|
22444
|
-
};
|
|
22445
|
-
/**
|
|
22446
|
-
* Remove child entity.
|
|
22447
|
-
* @param child - The child entity which want to be removed
|
|
22448
|
-
*/ _proto.removeChild = function removeChild(child) {
|
|
22449
|
-
if (child._parent !== this) return;
|
|
22450
|
-
child._setParent(null);
|
|
22451
|
-
};
|
|
22452
|
-
/**
|
|
22453
|
-
* @deprecated Please use `children` property instead.
|
|
22454
|
-
* Find child entity by index.
|
|
22455
|
-
* @param index - The index of the child entity
|
|
22456
|
-
* @returns The component which be found
|
|
22457
|
-
*/ _proto.getChild = function getChild(index) {
|
|
22458
|
-
return this._children[index];
|
|
22365
|
+
this._updateMark = renderer.engine.time.frameCount;
|
|
22459
22366
|
};
|
|
22460
22367
|
/**
|
|
22461
|
-
*
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
|
|
22465
|
-
if (
|
|
22466
|
-
|
|
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);
|
|
22467
22374
|
}
|
|
22468
|
-
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
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]);
|
|
22473
22382
|
}
|
|
22383
|
+
target.bones = destBones;
|
|
22474
22384
|
}
|
|
22475
|
-
return null;
|
|
22476
|
-
};
|
|
22477
|
-
/**
|
|
22478
|
-
* Find the entity by path.
|
|
22479
|
-
* @param path - The path of the entity eg: /entity
|
|
22480
|
-
* @returns The component which be found
|
|
22481
|
-
*/ _proto.findByPath = function findByPath(path) {
|
|
22482
|
-
var splits = path.split("/").filter(Boolean);
|
|
22483
|
-
if (!splits.length) {
|
|
22484
|
-
return this;
|
|
22485
|
-
}
|
|
22486
|
-
return Entity._findChildByName(this, 0, splits, 0);
|
|
22487
|
-
};
|
|
22488
|
-
/**
|
|
22489
|
-
* Create child entity.
|
|
22490
|
-
* @param name - The child entity's name
|
|
22491
|
-
* @returns The child entity
|
|
22492
|
-
*/ _proto.createChild = function createChild(name) {
|
|
22493
|
-
var transform = this._transform;
|
|
22494
|
-
var child = transform ? new Entity(this.engine, name, transform.constructor) : new Entity(this.engine, name);
|
|
22495
|
-
child.layer = this.layer;
|
|
22496
|
-
child.parent = this;
|
|
22497
|
-
return child;
|
|
22498
|
-
};
|
|
22499
|
-
/**
|
|
22500
|
-
* Clear children entities.
|
|
22501
|
-
*/ _proto.clearChildren = function clearChildren() {
|
|
22502
|
-
var children = this._children;
|
|
22503
|
-
for(var i = children.length - 1; i >= 0; i--){
|
|
22504
|
-
var child = children[i];
|
|
22505
|
-
child._parent = null;
|
|
22506
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
22507
|
-
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
22508
|
-
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
22509
|
-
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
22510
|
-
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
22511
|
-
}
|
|
22512
|
-
children.length = 0;
|
|
22513
|
-
};
|
|
22514
|
-
/**
|
|
22515
|
-
* Clone this entity include children and components.
|
|
22516
|
-
* @returns Cloned entity
|
|
22517
|
-
*/ _proto.clone = function clone() {
|
|
22518
|
-
var cloneEntity = this._createCloneEntity();
|
|
22519
|
-
this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
|
|
22520
|
-
return cloneEntity;
|
|
22521
22385
|
};
|
|
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
|
+
}
|
|
22435
|
+
}
|
|
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;
|
|
22522
22488
|
/**
|
|
22523
|
-
*
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
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;
|
|
22527
22499
|
};
|
|
22528
22500
|
/**
|
|
22529
22501
|
* @internal
|
|
22530
|
-
*/ _proto.
|
|
22531
|
-
this
|
|
22532
|
-
this.
|
|
22533
|
-
|
|
22534
|
-
_proto._createCloneEntity = function _createCloneEntity() {
|
|
22535
|
-
var componentConstructors = Entity._tempComponentConstructors;
|
|
22536
|
-
var components = this._components;
|
|
22537
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
22538
|
-
componentConstructors[i] = components[i].constructor;
|
|
22539
|
-
}
|
|
22540
|
-
var cloneEntity = _construct(Entity, [].concat([
|
|
22541
|
-
this.engine,
|
|
22542
|
-
this.name
|
|
22543
|
-
], componentConstructors));
|
|
22544
|
-
componentConstructors.length = 0;
|
|
22545
|
-
var templateResource = this._templateResource;
|
|
22546
|
-
if (templateResource) {
|
|
22547
|
-
cloneEntity._templateResource = templateResource;
|
|
22548
|
-
templateResource._addReferCount(1);
|
|
22549
|
-
}
|
|
22550
|
-
cloneEntity.layer = this.layer;
|
|
22551
|
-
cloneEntity._isActive = this._isActive;
|
|
22552
|
-
var srcChildren = this._children;
|
|
22553
|
-
for(var i1 = 0, n1 = srcChildren.length; i1 < n1; i1++){
|
|
22554
|
-
cloneEntity.addChild(srcChildren[i1]._createCloneEntity());
|
|
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);
|
|
22555
22506
|
}
|
|
22556
|
-
|
|
22507
|
+
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
22557
22508
|
};
|
|
22558
|
-
_proto.
|
|
22559
|
-
var
|
|
22560
|
-
|
|
22561
|
-
|
|
22562
|
-
this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot, deepInstanceMap);
|
|
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);
|
|
22563
22513
|
}
|
|
22564
|
-
var
|
|
22565
|
-
|
|
22566
|
-
|
|
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);
|
|
22554
|
+
}
|
|
22567
22555
|
}
|
|
22556
|
+
MeshRenderer.prototype._update.call(this, context);
|
|
22568
22557
|
};
|
|
22569
22558
|
/**
|
|
22570
|
-
*
|
|
22571
|
-
*/ _proto.
|
|
22572
|
-
|
|
22573
|
-
|
|
22574
|
-
|
|
22575
|
-
|
|
22576
|
-
|
|
22577
|
-
|
|
22578
|
-
this._templateResource = null;
|
|
22579
|
-
}
|
|
22580
|
-
var components = this._components;
|
|
22581
|
-
for(var i = components.length - 1; i >= 0; i--){
|
|
22582
|
-
components[i].destroy();
|
|
22583
|
-
}
|
|
22584
|
-
this._components.length = 0;
|
|
22585
|
-
var children = this._children;
|
|
22586
|
-
while(children.length > 0){
|
|
22587
|
-
children[0].destroy();
|
|
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);
|
|
22588
22567
|
}
|
|
22589
|
-
|
|
22590
|
-
|
|
22568
|
+
};
|
|
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
|
+
}
|
|
22591
22586
|
} else {
|
|
22592
|
-
this.
|
|
22587
|
+
this._blendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
22593
22588
|
}
|
|
22594
|
-
this.isActive = false;
|
|
22595
22589
|
};
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
22599
|
-
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
22600
|
-
var components = this._components;
|
|
22601
|
-
components.splice(components.indexOf(component), 1);
|
|
22602
|
-
};
|
|
22603
|
-
/**
|
|
22604
|
-
* @internal
|
|
22605
|
-
*/ _proto._addScript = function _addScript(script) {
|
|
22606
|
-
script._entityScriptsIndex = this._scripts.length;
|
|
22607
|
-
this._scripts.add(script);
|
|
22608
|
-
};
|
|
22609
|
-
/**
|
|
22610
|
-
* @internal
|
|
22611
|
-
*/ _proto._removeScript = function _removeScript(script) {
|
|
22612
|
-
var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
|
|
22613
|
-
replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
|
|
22614
|
-
script._entityScriptsIndex = -1;
|
|
22590
|
+
_proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
|
|
22591
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
22615
22592
|
};
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
|
-
|
|
22623
|
-
|
|
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;
|
|
22624
22608
|
}
|
|
22625
22609
|
};
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22630
|
-
|
|
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);
|
|
22631
22624
|
}
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
this._setActiveComponents(true, activeChangeFlag);
|
|
22635
|
-
};
|
|
22636
|
-
/**
|
|
22637
|
-
* @internal
|
|
22638
|
-
*/ _proto._processInActive = function _processInActive(activeChangeFlag) {
|
|
22639
|
-
if (this._activeChangedComponents) {
|
|
22640
|
-
throw "Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";
|
|
22625
|
+
if (lastRootBone !== rootBone) {
|
|
22626
|
+
this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
|
|
22641
22627
|
}
|
|
22642
|
-
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
22643
|
-
this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
22644
|
-
this._setActiveComponents(false, activeChangeFlag);
|
|
22645
|
-
};
|
|
22646
|
-
/**
|
|
22647
|
-
* @internal
|
|
22648
|
-
*/ _proto._setParentChange = function _setParentChange() {
|
|
22649
|
-
this._transform._parentChange();
|
|
22650
|
-
this._dispatchModify(EntityModifyFlags.Parent, this);
|
|
22651
|
-
};
|
|
22652
|
-
/**
|
|
22653
|
-
* @internal
|
|
22654
|
-
*/ _proto._registerModifyListener = function _registerModifyListener(onChange) {
|
|
22655
|
-
(this._modifyFlagManager || (this._modifyFlagManager = new UpdateFlagManager())).addListener(onChange);
|
|
22656
|
-
};
|
|
22657
|
-
/**
|
|
22658
|
-
* @internal
|
|
22659
|
-
*/ _proto._unRegisterModifyListener = function _unRegisterModifyListener(onChange) {
|
|
22660
|
-
var _this__modifyFlagManager;
|
|
22661
|
-
(_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.removeListener(onChange);
|
|
22662
|
-
};
|
|
22663
|
-
_proto._dispatchModify = function _dispatchModify(flag, param) {
|
|
22664
|
-
var _this__modifyFlagManager;
|
|
22665
|
-
(_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.dispatch(flag, param);
|
|
22666
|
-
};
|
|
22667
|
-
_proto._addToChildrenList = function _addToChildrenList(index, child) {
|
|
22668
|
-
Entity._addToChildren(this._children, child, index);
|
|
22669
|
-
this._dispatchModify(EntityModifyFlags.Child, this);
|
|
22670
22628
|
};
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
22675
|
-
|
|
22676
|
-
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
var oldScene = this._scene;
|
|
22685
|
-
var parentScene = parent._scene;
|
|
22686
|
-
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
22687
|
-
if (!parent._isActiveInHierarchy) {
|
|
22688
|
-
this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
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;
|
|
22689
22642
|
}
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
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);
|
|
22693
22659
|
} else {
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
|
|
22697
|
-
if (oldScene !== parentScene) {
|
|
22698
|
-
Entity._traverseSetOwnerScene(this, parentScene);
|
|
22699
|
-
}
|
|
22700
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
22701
|
-
if (this._isActive) {
|
|
22702
|
-
if (parent._isActiveInHierarchy) {
|
|
22703
|
-
!this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
22704
|
-
}
|
|
22705
|
-
if (parent._isActiveInScene) {
|
|
22706
|
-
(!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
22660
|
+
for(var i = 0, n = blendShapeWeights.length; i < n; i++){
|
|
22661
|
+
blendShapeWeights[i] = value[i];
|
|
22707
22662
|
}
|
|
22708
22663
|
}
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
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);
|
|
22717
22676
|
}
|
|
22718
22677
|
}
|
|
22719
|
-
|
|
22720
|
-
|
|
22721
|
-
|
|
22722
|
-
|
|
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;
|
|
22723
22688
|
}
|
|
22724
|
-
}
|
|
22725
|
-
|
|
22726
|
-
|
|
22727
|
-
|
|
22728
|
-
|
|
22729
|
-
|
|
22730
|
-
|
|
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;
|
|
22731
22699
|
}
|
|
22732
22700
|
}
|
|
22733
|
-
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
22739
|
-
|
|
22740
|
-
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
|
|
22753
|
-
|
|
22754
|
-
|
|
22755
|
-
|
|
22756
|
-
|
|
22757
|
-
|
|
22758
|
-
|
|
22759
|
-
|
|
22760
|
-
|
|
22761
|
-
|
|
22762
|
-
|
|
22763
|
-
|
|
22764
|
-
|
|
22765
|
-
|
|
22766
|
-
|
|
22767
|
-
|
|
22768
|
-
|
|
22769
|
-
|
|
22770
|
-
|
|
22771
|
-
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
|
|
22776
|
-
|
|
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);
|
|
22777
22803
|
}
|
|
22778
|
-
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
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);
|
|
22785
22866
|
}
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
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;
|
|
22791
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);
|
|
22792
23124
|
}
|
|
22793
23125
|
}
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
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
|
+
}
|
|
22799
23171
|
var children = this._children;
|
|
22800
23172
|
for(var i = 0, n = children.length; i < n; i++){
|
|
22801
|
-
var
|
|
22802
|
-
(
|
|
23173
|
+
var target = children[i].findByName(name);
|
|
23174
|
+
if (target) {
|
|
23175
|
+
return target;
|
|
23176
|
+
}
|
|
22803
23177
|
}
|
|
23178
|
+
return null;
|
|
22804
23179
|
};
|
|
22805
23180
|
/**
|
|
22806
|
-
*
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
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;
|
|
22811
23188
|
}
|
|
22812
|
-
return this
|
|
23189
|
+
return Entity._findChildByName(this, 0, splits, 0);
|
|
22813
23190
|
};
|
|
22814
23191
|
/**
|
|
22815
|
-
*
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
|
|
22819
|
-
var
|
|
22820
|
-
|
|
22821
|
-
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
return isEndPath ? child : Entity._findChildByName(child, 0, paths, pathIndex + 1);
|
|
22825
|
-
}
|
|
22826
|
-
}
|
|
22827
|
-
// Search failed if first path, or upward search
|
|
22828
|
-
return pathIndex === 0 ? null : Entity._findChildByName(entity.parent, entity.siblingIndex + 1, paths, pathIndex - 1);
|
|
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;
|
|
22829
23201
|
};
|
|
22830
23202
|
/**
|
|
22831
|
-
*
|
|
22832
|
-
*/
|
|
22833
|
-
|
|
22834
|
-
var children = entity._children;
|
|
23203
|
+
* Clear children entities.
|
|
23204
|
+
*/ _proto.clearChildren = function clearChildren() {
|
|
23205
|
+
var children = this._children;
|
|
22835
23206
|
for(var i = children.length - 1; i >= 0; i--){
|
|
22836
|
-
|
|
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().
|
|
22837
23214
|
}
|
|
23215
|
+
children.length = 0;
|
|
22838
23216
|
};
|
|
22839
23217
|
/**
|
|
22840
|
-
*
|
|
22841
|
-
|
|
22842
|
-
|
|
22843
|
-
|
|
22844
|
-
|
|
22845
|
-
|
|
22846
|
-
return false;
|
|
22847
|
-
}
|
|
22848
|
-
inversePath.push(searchEntity.siblingIndex);
|
|
22849
|
-
searchEntity = parent;
|
|
22850
|
-
}
|
|
22851
|
-
return true;
|
|
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;
|
|
22852
23224
|
};
|
|
22853
23225
|
/**
|
|
22854
|
-
*
|
|
22855
|
-
|
|
22856
|
-
|
|
22857
|
-
|
|
22858
|
-
entity = entity.children[inversePath[i]];
|
|
22859
|
-
}
|
|
22860
|
-
return entity;
|
|
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);
|
|
22861
23230
|
};
|
|
22862
23231
|
/**
|
|
22863
23232
|
* @internal
|
|
22864
|
-
*/
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
var child = children[i + 1];
|
|
22868
|
-
children[i] = child;
|
|
22869
|
-
child._siblingIndex = i;
|
|
22870
|
-
}
|
|
22871
|
-
children.length = count;
|
|
22872
|
-
entity._siblingIndex = -1;
|
|
23233
|
+
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
23234
|
+
this._isTemplate = true;
|
|
23235
|
+
this._templateResource = templateResource;
|
|
22873
23236
|
};
|
|
22874
|
-
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
var
|
|
22878
|
-
|
|
22879
|
-
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
|
|
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());
|
|
22893
23258
|
}
|
|
23259
|
+
return cloneEntity;
|
|
22894
23260
|
};
|
|
22895
|
-
|
|
22896
|
-
|
|
22897
|
-
|
|
22898
|
-
|
|
22899
|
-
|
|
22900
|
-
|
|
22901
|
-
|
|
22902
|
-
|
|
22903
|
-
|
|
22904
|
-
{
|
|
22905
|
-
key: "isActive",
|
|
22906
|
-
get: /**
|
|
22907
|
-
* Whether to activate locally.
|
|
22908
|
-
*/ function get() {
|
|
22909
|
-
return this._isActive;
|
|
22910
|
-
},
|
|
22911
|
-
set: function set(value) {
|
|
22912
|
-
if (value !== this._isActive) {
|
|
22913
|
-
this._isActive = value;
|
|
22914
|
-
if (value) {
|
|
22915
|
-
var parent = this._parent;
|
|
22916
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
22917
|
-
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
22918
|
-
activeChangeFlag |= ActiveChangeFlag.All;
|
|
22919
|
-
} else {
|
|
22920
|
-
(parent == null ? void 0 : parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
22921
|
-
(parent == null ? void 0 : parent._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
22922
|
-
}
|
|
22923
|
-
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
22924
|
-
} else {
|
|
22925
|
-
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
22926
|
-
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
22927
|
-
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
22928
|
-
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
22929
|
-
}
|
|
22930
|
-
}
|
|
22931
|
-
}
|
|
22932
|
-
},
|
|
22933
|
-
{
|
|
22934
|
-
key: "isActiveInHierarchy",
|
|
22935
|
-
get: /**
|
|
22936
|
-
* Whether it is active in the hierarchy.
|
|
22937
|
-
*/ function get() {
|
|
22938
|
-
return this._isActiveInHierarchy;
|
|
22939
|
-
}
|
|
22940
|
-
},
|
|
22941
|
-
{
|
|
22942
|
-
key: "parent",
|
|
22943
|
-
get: /**
|
|
22944
|
-
* The parent entity.
|
|
22945
|
-
*/ function get() {
|
|
22946
|
-
return this._parent;
|
|
22947
|
-
},
|
|
22948
|
-
set: function set(value) {
|
|
22949
|
-
this._setParent(value);
|
|
22950
|
-
}
|
|
22951
|
-
},
|
|
22952
|
-
{
|
|
22953
|
-
key: "children",
|
|
22954
|
-
get: /**
|
|
22955
|
-
* The children entities
|
|
22956
|
-
*/ function get() {
|
|
22957
|
-
return this._children;
|
|
22958
|
-
}
|
|
22959
|
-
},
|
|
22960
|
-
{
|
|
22961
|
-
key: "childCount",
|
|
22962
|
-
get: /**
|
|
22963
|
-
* @deprecated Please use `children.length` property instead.
|
|
22964
|
-
* Number of the children entities
|
|
22965
|
-
*/ function get() {
|
|
22966
|
-
return this._children.length;
|
|
22967
|
-
}
|
|
22968
|
-
},
|
|
22969
|
-
{
|
|
22970
|
-
key: "scene",
|
|
22971
|
-
get: /**
|
|
22972
|
-
* The scene the entity belongs to.
|
|
22973
|
-
*/ function get() {
|
|
22974
|
-
return this._scene;
|
|
22975
|
-
}
|
|
22976
|
-
},
|
|
22977
|
-
{
|
|
22978
|
-
key: "siblingIndex",
|
|
22979
|
-
get: /**
|
|
22980
|
-
* The sibling index.
|
|
22981
|
-
*/ function get() {
|
|
22982
|
-
return this._siblingIndex;
|
|
22983
|
-
},
|
|
22984
|
-
set: function set(value) {
|
|
22985
|
-
if (this._siblingIndex === -1) {
|
|
22986
|
-
throw "The entity " + this.name + " is not in the hierarchy";
|
|
22987
|
-
}
|
|
22988
|
-
if (this._isRoot) {
|
|
22989
|
-
this._setSiblingIndex(this._scene._rootEntities, value);
|
|
22990
|
-
} else {
|
|
22991
|
-
var parent = this._parent;
|
|
22992
|
-
this._setSiblingIndex(parent._children, value);
|
|
22993
|
-
parent._dispatchModify(EntityModifyFlags.Child, parent);
|
|
22994
|
-
}
|
|
22995
|
-
}
|
|
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++){
|
|
23269
|
+
ComponentCloner.cloneComponent(components[i1], target._components[i1], srcRoot, targetRoot, deepInstanceMap);
|
|
22996
23270
|
}
|
|
22997
|
-
|
|
22998
|
-
return Entity;
|
|
22999
|
-
}(EngineObject);
|
|
23000
|
-
/** @internal */ Entity._tempComponentConstructors = [];
|
|
23001
|
-
|
|
23002
|
-
/**
|
|
23003
|
-
* Skin used for skinned mesh renderer.
|
|
23004
|
-
*/ var Skin = /*#__PURE__*/ function(EngineObject) {
|
|
23005
|
-
_inherits(Skin, EngineObject);
|
|
23006
|
-
function Skin(name) {
|
|
23007
|
-
var _this;
|
|
23008
|
-
_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 = [];
|
|
23009
|
-
return _this;
|
|
23010
|
-
}
|
|
23011
|
-
var _proto = Skin.prototype;
|
|
23271
|
+
};
|
|
23012
23272
|
/**
|
|
23013
|
-
*
|
|
23014
|
-
*/ _proto.
|
|
23015
|
-
|
|
23273
|
+
* Destroy self.
|
|
23274
|
+
*/ _proto.destroy = function destroy() {
|
|
23275
|
+
EngineObject.prototype.destroy.call(this);
|
|
23276
|
+
if (!this._destroyed) {
|
|
23016
23277
|
return;
|
|
23017
23278
|
}
|
|
23018
|
-
|
|
23019
|
-
|
|
23020
|
-
|
|
23021
|
-
for(var i = bones.length - 1; i >= 0; i--){
|
|
23022
|
-
var bone = bones[i];
|
|
23023
|
-
var offset = i * 16;
|
|
23024
|
-
if (bone) {
|
|
23025
|
-
Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
|
|
23026
|
-
} else {
|
|
23027
|
-
skinMatrices.set(bindMatrices[i].elements, offset);
|
|
23028
|
-
}
|
|
23029
|
-
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
23279
|
+
if (this._templateResource) {
|
|
23280
|
+
this._isTemplate || this._templateResource._addReferCount(-1);
|
|
23281
|
+
this._templateResource = null;
|
|
23030
23282
|
}
|
|
23031
|
-
|
|
23283
|
+
var components = this._components;
|
|
23284
|
+
for(var i = components.length - 1; i >= 0; i--){
|
|
23285
|
+
components[i].destroy();
|
|
23286
|
+
}
|
|
23287
|
+
this._components.length = 0;
|
|
23288
|
+
var children = this._children;
|
|
23289
|
+
while(children.length > 0){
|
|
23290
|
+
children[0].destroy();
|
|
23291
|
+
}
|
|
23292
|
+
if (this._isRoot) {
|
|
23293
|
+
this._scene.removeRootEntity(this);
|
|
23294
|
+
} else {
|
|
23295
|
+
this._setParent(null);
|
|
23296
|
+
}
|
|
23297
|
+
this.isActive = false;
|
|
23032
23298
|
};
|
|
23033
23299
|
/**
|
|
23034
23300
|
* @internal
|
|
23035
|
-
*/ _proto.
|
|
23036
|
-
|
|
23037
|
-
|
|
23038
|
-
|
|
23039
|
-
if (rootBone) {
|
|
23040
|
-
var success = Entity._getEntityHierarchyPath(srcRoot, rootBone, paths);
|
|
23041
|
-
target.rootBone = success ? Entity._getEntityByHierarchyPath(targetRoot, paths) : rootBone;
|
|
23042
|
-
}
|
|
23043
|
-
// Clone bones
|
|
23044
|
-
var bones = this.bones;
|
|
23045
|
-
if (bones.length > 0) {
|
|
23046
|
-
var boneCount = bones.length;
|
|
23047
|
-
var destBones = new Array(boneCount);
|
|
23048
|
-
for(var i = 0; i < boneCount; i++){
|
|
23049
|
-
var bone = bones[i];
|
|
23050
|
-
var success1 = Entity._getEntityHierarchyPath(srcRoot, bone, paths);
|
|
23051
|
-
destBones[i] = success1 ? Entity._getEntityByHierarchyPath(targetRoot, paths) : bone;
|
|
23052
|
-
}
|
|
23053
|
-
target.bones = destBones;
|
|
23054
|
-
}
|
|
23301
|
+
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
23302
|
+
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
23303
|
+
var components = this._components;
|
|
23304
|
+
components.splice(components.indexOf(component), 1);
|
|
23055
23305
|
};
|
|
23056
|
-
_create_class(Skin, [
|
|
23057
|
-
{
|
|
23058
|
-
key: "rootBone",
|
|
23059
|
-
get: /**
|
|
23060
|
-
* Root bone.
|
|
23061
|
-
*/ function get() {
|
|
23062
|
-
return this._rootBone;
|
|
23063
|
-
},
|
|
23064
|
-
set: function set(value) {
|
|
23065
|
-
if (this._rootBone !== value) {
|
|
23066
|
-
this._updatedManager.dispatch(1, value);
|
|
23067
|
-
this._rootBone = value;
|
|
23068
|
-
}
|
|
23069
|
-
}
|
|
23070
|
-
},
|
|
23071
|
-
{
|
|
23072
|
-
key: "bones",
|
|
23073
|
-
get: /**
|
|
23074
|
-
* Bones of the skin.
|
|
23075
|
-
*/ function get() {
|
|
23076
|
-
return this._bones;
|
|
23077
|
-
},
|
|
23078
|
-
set: function set(value) {
|
|
23079
|
-
var bones = this._bones;
|
|
23080
|
-
var _value_length;
|
|
23081
|
-
var boneCount = (_value_length = value == null ? void 0 : value.length) != null ? _value_length : 0;
|
|
23082
|
-
var lastBoneCount = bones.length;
|
|
23083
|
-
bones.length = boneCount;
|
|
23084
|
-
for(var i = 0; i < boneCount; i++){
|
|
23085
|
-
bones[i] = value[i];
|
|
23086
|
-
}
|
|
23087
|
-
if (lastBoneCount !== boneCount) {
|
|
23088
|
-
this._skinMatrices = new Float32Array(boneCount * 16);
|
|
23089
|
-
this._updatedManager.dispatch(0, boneCount);
|
|
23090
|
-
}
|
|
23091
|
-
}
|
|
23092
|
-
},
|
|
23093
|
-
{
|
|
23094
|
-
key: "skeleton",
|
|
23095
|
-
get: /** @deprecated Please use `rootBone` instead. */ function get() {
|
|
23096
|
-
var _this_rootBone;
|
|
23097
|
-
return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
|
|
23098
|
-
},
|
|
23099
|
-
set: function set(value) {
|
|
23100
|
-
var rootBone = this._rootBone;
|
|
23101
|
-
if (rootBone) {
|
|
23102
|
-
rootBone.name = value;
|
|
23103
|
-
}
|
|
23104
|
-
}
|
|
23105
|
-
}
|
|
23106
|
-
]);
|
|
23107
|
-
return Skin;
|
|
23108
|
-
}(EngineObject);
|
|
23109
|
-
__decorate([
|
|
23110
|
-
deepClone
|
|
23111
|
-
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
23112
|
-
__decorate([
|
|
23113
|
-
ignoreClone
|
|
23114
|
-
], Skin.prototype, "_skinMatrices", void 0);
|
|
23115
|
-
__decorate([
|
|
23116
|
-
ignoreClone
|
|
23117
|
-
], Skin.prototype, "_updatedManager", void 0);
|
|
23118
|
-
__decorate([
|
|
23119
|
-
ignoreClone
|
|
23120
|
-
], Skin.prototype, "_rootBone", void 0);
|
|
23121
|
-
__decorate([
|
|
23122
|
-
ignoreClone
|
|
23123
|
-
], Skin.prototype, "_bones", void 0);
|
|
23124
|
-
__decorate([
|
|
23125
|
-
ignoreClone
|
|
23126
|
-
], Skin.prototype, "_updateMark", void 0);
|
|
23127
|
-
var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
|
|
23128
|
-
SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
|
|
23129
|
-
SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
|
|
23130
|
-
return SkinUpdateFlag;
|
|
23131
|
-
}({});
|
|
23132
|
-
|
|
23133
|
-
/**
|
|
23134
|
-
* SkinnedMeshRenderer.
|
|
23135
|
-
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer) {
|
|
23136
|
-
_inherits(SkinnedMeshRenderer, MeshRenderer);
|
|
23137
|
-
function SkinnedMeshRenderer(entity) {
|
|
23138
|
-
var _this;
|
|
23139
|
-
_this = MeshRenderer.call(this, entity) || this, _this._localBounds = new engineMath.BoundingBox(), _this._jointDataCreateCache = new engineMath.Vector2(-1, -1);
|
|
23140
|
-
_this._skin = null;
|
|
23141
|
-
var rhi = _this.entity.engine._hardwareRenderer;
|
|
23142
|
-
var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
|
|
23143
|
-
// Limit size to 256 to avoid some problem:
|
|
23144
|
-
// 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!
|
|
23145
|
-
// 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.
|
|
23146
|
-
maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
|
|
23147
|
-
_this._maxVertexUniformVectors = maxVertexUniformVectors;
|
|
23148
|
-
_this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_this);
|
|
23149
|
-
_this._onSkinUpdated = _this._onSkinUpdated.bind(_this);
|
|
23150
|
-
var localBounds = _this._localBounds;
|
|
23151
|
-
// @ts-ignore
|
|
23152
|
-
localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
|
|
23153
|
-
// @ts-ignore
|
|
23154
|
-
localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
|
|
23155
|
-
return _this;
|
|
23156
|
-
}
|
|
23157
|
-
var _proto = SkinnedMeshRenderer.prototype;
|
|
23158
23306
|
/**
|
|
23159
23307
|
* @internal
|
|
23160
|
-
*/ _proto.
|
|
23161
|
-
|
|
23162
|
-
|
|
23163
|
-
this._jointDataCreateCache = null;
|
|
23164
|
-
this._skin = null;
|
|
23165
|
-
this._blendShapeWeights = null;
|
|
23166
|
-
this._localBounds = null;
|
|
23167
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
23168
|
-
this._jointTexture = null;
|
|
23308
|
+
*/ _proto._addScript = function _addScript(script) {
|
|
23309
|
+
script._entityScriptsIndex = this._scripts.length;
|
|
23310
|
+
this._scripts.add(script);
|
|
23169
23311
|
};
|
|
23170
23312
|
/**
|
|
23171
23313
|
* @internal
|
|
23172
|
-
*/ _proto.
|
|
23173
|
-
|
|
23174
|
-
|
|
23175
|
-
|
|
23176
|
-
}
|
|
23177
|
-
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
23314
|
+
*/ _proto._removeScript = function _removeScript(script) {
|
|
23315
|
+
var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
|
|
23316
|
+
replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
|
|
23317
|
+
script._entityScriptsIndex = -1;
|
|
23178
23318
|
};
|
|
23179
|
-
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
|
|
23319
|
+
/**
|
|
23320
|
+
* @internal
|
|
23321
|
+
*/ _proto._removeFromParent = function _removeFromParent() {
|
|
23322
|
+
var oldParent = this._parent;
|
|
23323
|
+
if (oldParent != null) {
|
|
23324
|
+
Entity._removeFromChildren(oldParent._children, this);
|
|
23325
|
+
this._parent = null;
|
|
23326
|
+
oldParent._dispatchModify(EntityModifyFlags.Child, oldParent);
|
|
23183
23327
|
}
|
|
23184
|
-
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
|
|
23190
|
-
var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
|
|
23191
|
-
var boneCount = bones.length;
|
|
23192
|
-
var boneDataCreateCache = this._jointDataCreateCache;
|
|
23193
|
-
var boneCountChange = boneCount !== boneDataCreateCache.x;
|
|
23194
|
-
if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
|
|
23195
|
-
// directly use max joint count to avoid shader recompile
|
|
23196
|
-
var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) / 4);
|
|
23197
|
-
if (boneCount > remainUniformJointCount) {
|
|
23198
|
-
var engine = this.engine;
|
|
23199
|
-
if (engine._hardwareRenderer.canIUseMoreJoints) {
|
|
23200
|
-
if (boneCountChange) {
|
|
23201
|
-
var _this__jointTexture;
|
|
23202
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
23203
|
-
this._jointTexture = new Texture2D(engine, 4, boneCount, TextureFormat.R32G32B32A32, false, false);
|
|
23204
|
-
this._jointTexture.filterMode = TextureFilterMode.Point;
|
|
23205
|
-
this._jointTexture.isGCIgnored = true;
|
|
23206
|
-
}
|
|
23207
|
-
shaderData.disableMacro("RENDERER_JOINTS_NUM");
|
|
23208
|
-
shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
23209
|
-
shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
|
|
23210
|
-
} else {
|
|
23211
|
-
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);
|
|
23212
|
-
}
|
|
23213
|
-
} else {
|
|
23214
|
-
var _this__jointTexture1;
|
|
23215
|
-
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
23216
|
-
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
23217
|
-
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
23218
|
-
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
|
|
23219
|
-
}
|
|
23220
|
-
boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
|
|
23221
|
-
}
|
|
23222
|
-
if (this._jointTexture) {
|
|
23223
|
-
this._jointTexture.setPixelBuffer(skin._skinMatrices);
|
|
23224
|
-
}
|
|
23328
|
+
};
|
|
23329
|
+
/**
|
|
23330
|
+
* @internal
|
|
23331
|
+
*/ _proto._processActive = function _processActive(activeChangeFlag) {
|
|
23332
|
+
if (this._activeChangedComponents) {
|
|
23333
|
+
throw "Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";
|
|
23225
23334
|
}
|
|
23226
|
-
|
|
23335
|
+
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
23336
|
+
this._setActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
23337
|
+
this._setActiveComponents(true, activeChangeFlag);
|
|
23227
23338
|
};
|
|
23228
23339
|
/**
|
|
23229
23340
|
* @internal
|
|
23230
|
-
*/ _proto.
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
if (rootBone) {
|
|
23234
|
-
engineMath.BoundingBox.transform(this._localBounds, this._transformEntity.transform.worldMatrix, worldBounds);
|
|
23235
|
-
} else {
|
|
23236
|
-
MeshRenderer.prototype._updateBounds.call(this, worldBounds);
|
|
23341
|
+
*/ _proto._processInActive = function _processInActive(activeChangeFlag) {
|
|
23342
|
+
if (this._activeChangedComponents) {
|
|
23343
|
+
throw "Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";
|
|
23237
23344
|
}
|
|
23345
|
+
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
23346
|
+
this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
23347
|
+
this._setActiveComponents(false, activeChangeFlag);
|
|
23238
23348
|
};
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
|
|
23247
|
-
|
|
23248
|
-
|
|
23349
|
+
/**
|
|
23350
|
+
* @internal
|
|
23351
|
+
*/ _proto._setParentChange = function _setParentChange() {
|
|
23352
|
+
this._transform._parentChange();
|
|
23353
|
+
this._dispatchModify(EntityModifyFlags.Parent, this);
|
|
23354
|
+
};
|
|
23355
|
+
/**
|
|
23356
|
+
* @internal
|
|
23357
|
+
*/ _proto._registerModifyListener = function _registerModifyListener(onChange) {
|
|
23358
|
+
(this._modifyFlagManager || (this._modifyFlagManager = new UpdateFlagManager())).addListener(onChange);
|
|
23359
|
+
};
|
|
23360
|
+
/**
|
|
23361
|
+
* @internal
|
|
23362
|
+
*/ _proto._unRegisterModifyListener = function _unRegisterModifyListener(onChange) {
|
|
23363
|
+
var _this__modifyFlagManager;
|
|
23364
|
+
(_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.removeListener(onChange);
|
|
23365
|
+
};
|
|
23366
|
+
_proto._dispatchModify = function _dispatchModify(flag, param) {
|
|
23367
|
+
var _this__modifyFlagManager;
|
|
23368
|
+
(_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.dispatch(flag, param);
|
|
23369
|
+
};
|
|
23370
|
+
_proto._addToChildrenList = function _addToChildrenList(index, child) {
|
|
23371
|
+
Entity._addToChildren(this._children, child, index);
|
|
23372
|
+
this._dispatchModify(EntityModifyFlags.Child, this);
|
|
23373
|
+
};
|
|
23374
|
+
_proto._setParent = function _setParent(parent, siblingIndex) {
|
|
23375
|
+
var oldParent = this._parent;
|
|
23376
|
+
if (parent !== oldParent) {
|
|
23377
|
+
if (this._isRoot) {
|
|
23378
|
+
Entity._removeFromChildren(this._scene._rootEntities, this);
|
|
23379
|
+
this._isRoot = false;
|
|
23380
|
+
} else {
|
|
23381
|
+
this._removeFromParent();
|
|
23382
|
+
}
|
|
23383
|
+
this._parent = parent;
|
|
23384
|
+
if (parent) {
|
|
23385
|
+
this._isRoot = false;
|
|
23386
|
+
parent._addToChildrenList(siblingIndex, this);
|
|
23387
|
+
var oldScene = this._scene;
|
|
23388
|
+
var parentScene = parent._scene;
|
|
23389
|
+
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
23390
|
+
if (!parent._isActiveInHierarchy) {
|
|
23391
|
+
this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
23392
|
+
}
|
|
23393
|
+
if (parent._isActiveInScene) {
|
|
23394
|
+
// cross scene should inActive first and then active
|
|
23395
|
+
this._isActiveInScene && oldScene !== parentScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
23249
23396
|
} else {
|
|
23250
|
-
|
|
23251
|
-
|
|
23397
|
+
this._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
23398
|
+
}
|
|
23399
|
+
inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
|
|
23400
|
+
if (oldScene !== parentScene) {
|
|
23401
|
+
Entity._traverseSetOwnerScene(this, parentScene);
|
|
23402
|
+
}
|
|
23403
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
23404
|
+
if (this._isActive) {
|
|
23405
|
+
if (parent._isActiveInHierarchy) {
|
|
23406
|
+
!this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
23407
|
+
}
|
|
23408
|
+
if (parent._isActiveInScene) {
|
|
23409
|
+
(!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
23252
23410
|
}
|
|
23253
23411
|
}
|
|
23254
|
-
this.
|
|
23412
|
+
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
23413
|
+
} else {
|
|
23414
|
+
var inActiveChangeFlag1 = ActiveChangeFlag.None;
|
|
23415
|
+
this._isActiveInHierarchy && (inActiveChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
23416
|
+
this._isActiveInScene && (inActiveChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
23417
|
+
inActiveChangeFlag1 && this._processInActive(inActiveChangeFlag1);
|
|
23418
|
+
if (oldParent) {
|
|
23419
|
+
Entity._traverseSetOwnerScene(this, null);
|
|
23420
|
+
}
|
|
23255
23421
|
}
|
|
23422
|
+
this._setParentChange();
|
|
23256
23423
|
} else {
|
|
23257
|
-
|
|
23424
|
+
if (parent && siblingIndex !== undefined) {
|
|
23425
|
+
this.siblingIndex = siblingIndex;
|
|
23426
|
+
}
|
|
23258
23427
|
}
|
|
23259
23428
|
};
|
|
23260
|
-
_proto.
|
|
23261
|
-
this.
|
|
23429
|
+
_proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
|
|
23430
|
+
for(var i = this._components.length - 1; i >= 0; i--){
|
|
23431
|
+
var component = this._components[i];
|
|
23432
|
+
if (_instanceof(component, type)) {
|
|
23433
|
+
results.push(component);
|
|
23434
|
+
}
|
|
23435
|
+
}
|
|
23436
|
+
for(var i1 = this._children.length - 1; i1 >= 0; i1--){
|
|
23437
|
+
this._children[i1]._getComponentsInChildren(type, results);
|
|
23438
|
+
}
|
|
23262
23439
|
};
|
|
23263
|
-
_proto.
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
|
|
23267
|
-
if (value > 0) {
|
|
23268
|
-
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
23269
|
-
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
|
|
23270
|
-
} else {
|
|
23271
|
-
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
23272
|
-
}
|
|
23273
|
-
break;
|
|
23274
|
-
case SkinUpdateFlag.RootBoneChanged:
|
|
23275
|
-
this._setTransformEntity(value);
|
|
23276
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
23277
|
-
break;
|
|
23440
|
+
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
23441
|
+
var activeChangedComponents = this._activeChangedComponents;
|
|
23442
|
+
for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
|
|
23443
|
+
activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
|
|
23278
23444
|
}
|
|
23445
|
+
this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
|
|
23446
|
+
this._activeChangedComponents = null;
|
|
23279
23447
|
};
|
|
23280
|
-
_proto.
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
var
|
|
23284
|
-
var
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
var _value_bones_length;
|
|
23288
|
-
var skinBoneCount = (_value_bones_length = value == null ? void 0 : (_value_bones = value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
|
|
23289
|
-
var _value_rootBone;
|
|
23290
|
-
var rootBone = (_value_rootBone = value == null ? void 0 : value.rootBone) != null ? _value_rootBone : this.entity;
|
|
23291
|
-
value == null ? void 0 : value._updatedManager.addListener(this._onSkinUpdated);
|
|
23292
|
-
if (lastSkinBoneCount !== skinBoneCount) {
|
|
23293
|
-
this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
|
|
23448
|
+
_proto._setActiveInHierarchy = function _setActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
23449
|
+
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = true);
|
|
23450
|
+
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = true);
|
|
23451
|
+
var components = this._components;
|
|
23452
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
23453
|
+
var component = components[i];
|
|
23454
|
+
(component.enabled || !component._awoken) && activeChangedComponents.push(component);
|
|
23294
23455
|
}
|
|
23295
|
-
|
|
23296
|
-
|
|
23456
|
+
var children = this._children;
|
|
23457
|
+
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
23458
|
+
var child = children[i1];
|
|
23459
|
+
child.isActive && child._setActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
23297
23460
|
}
|
|
23298
23461
|
};
|
|
23299
|
-
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
|
|
23306
|
-
|
|
23307
|
-
|
|
23308
|
-
|
|
23309
|
-
|
|
23310
|
-
|
|
23311
|
-
|
|
23312
|
-
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
{
|
|
23316
|
-
|
|
23317
|
-
|
|
23318
|
-
|
|
23319
|
-
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
|
|
23324
|
-
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
}
|
|
23333
|
-
}
|
|
23334
|
-
}
|
|
23335
|
-
},
|
|
23336
|
-
{
|
|
23337
|
-
key: "localBounds",
|
|
23338
|
-
get: /**
|
|
23339
|
-
* Local bounds.
|
|
23340
|
-
*/ function get() {
|
|
23341
|
-
return this._localBounds;
|
|
23342
|
-
},
|
|
23343
|
-
set: function set(value) {
|
|
23344
|
-
if (this._localBounds !== value) {
|
|
23345
|
-
this._localBounds.copyFrom(value);
|
|
23346
|
-
}
|
|
23347
|
-
}
|
|
23348
|
-
},
|
|
23349
|
-
{
|
|
23350
|
-
key: "rootBone",
|
|
23351
|
-
get: /**
|
|
23352
|
-
* @deprecated use {@link SkinnedMeshRenderer.skin.rootBone} instead.
|
|
23353
|
-
*/ function get() {
|
|
23354
|
-
return this.skin.rootBone;
|
|
23355
|
-
},
|
|
23356
|
-
set: function set(value) {
|
|
23357
|
-
this.skin.rootBone = value;
|
|
23358
|
-
}
|
|
23359
|
-
},
|
|
23360
|
-
{
|
|
23361
|
-
key: "bones",
|
|
23362
|
-
get: /**
|
|
23363
|
-
* @deprecated use {@link SkinnedMeshRenderer.skin.bones} instead.
|
|
23364
|
-
*/ function get() {
|
|
23365
|
-
return this.skin.bones;
|
|
23366
|
-
},
|
|
23367
|
-
set: function set(value) {
|
|
23368
|
-
this.skin.bones = value;
|
|
23462
|
+
_proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
23463
|
+
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
|
|
23464
|
+
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
|
|
23465
|
+
var components = this._components;
|
|
23466
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
23467
|
+
var component = components[i];
|
|
23468
|
+
component.enabled && activeChangedComponents.push(component);
|
|
23469
|
+
}
|
|
23470
|
+
var children = this._children;
|
|
23471
|
+
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
23472
|
+
var child = children[i1];
|
|
23473
|
+
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
23474
|
+
}
|
|
23475
|
+
};
|
|
23476
|
+
_proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
|
|
23477
|
+
target = Math.min(target, sibling.length - 1);
|
|
23478
|
+
if (target < 0) {
|
|
23479
|
+
throw "Sibling index " + target + " should large than 0";
|
|
23480
|
+
}
|
|
23481
|
+
if (this._siblingIndex !== target) {
|
|
23482
|
+
var oldIndex = this._siblingIndex;
|
|
23483
|
+
if (target < oldIndex) {
|
|
23484
|
+
for(var i = oldIndex; i >= target; i--){
|
|
23485
|
+
var child = i == target ? this : sibling[i - 1];
|
|
23486
|
+
sibling[i] = child;
|
|
23487
|
+
child._siblingIndex = i;
|
|
23488
|
+
}
|
|
23489
|
+
} else {
|
|
23490
|
+
for(var i1 = oldIndex; i1 <= target; i1++){
|
|
23491
|
+
var child1 = i1 == target ? this : sibling[i1 + 1];
|
|
23492
|
+
sibling[i1] = child1;
|
|
23493
|
+
child1._siblingIndex = i1;
|
|
23494
|
+
}
|
|
23369
23495
|
}
|
|
23370
23496
|
}
|
|
23371
|
-
|
|
23372
|
-
|
|
23373
|
-
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
ignoreClone
|
|
23381
|
-
], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
|
|
23382
|
-
__decorate([
|
|
23383
|
-
deepClone
|
|
23384
|
-
], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
|
|
23385
|
-
__decorate([
|
|
23386
|
-
ignoreClone
|
|
23387
|
-
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
23388
|
-
__decorate([
|
|
23389
|
-
ignoreClone
|
|
23390
|
-
], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
|
|
23391
|
-
__decorate([
|
|
23392
|
-
ignoreClone
|
|
23393
|
-
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
23394
|
-
__decorate([
|
|
23395
|
-
ignoreClone
|
|
23396
|
-
], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
|
|
23397
|
-
__decorate([
|
|
23398
|
-
deepClone
|
|
23399
|
-
], SkinnedMeshRenderer.prototype, "_skin", void 0);
|
|
23400
|
-
__decorate([
|
|
23401
|
-
ignoreClone
|
|
23402
|
-
], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
|
|
23403
|
-
__decorate([
|
|
23404
|
-
ignoreClone
|
|
23405
|
-
], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
|
|
23406
|
-
|
|
23407
|
-
/**
|
|
23408
|
-
* @internal
|
|
23409
|
-
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
23410
|
-
function BasicResources(engine) {
|
|
23411
|
-
this.engine = engine;
|
|
23412
|
-
// prettier-ignore
|
|
23413
|
-
var vertices = new Float32Array([
|
|
23414
|
-
-1,
|
|
23415
|
-
-1,
|
|
23416
|
-
0,
|
|
23417
|
-
1,
|
|
23418
|
-
3,
|
|
23419
|
-
-1,
|
|
23420
|
-
2,
|
|
23421
|
-
1,
|
|
23422
|
-
-1,
|
|
23423
|
-
3,
|
|
23424
|
-
0,
|
|
23425
|
-
-1
|
|
23426
|
-
]); // left-top
|
|
23427
|
-
// prettier-ignore
|
|
23428
|
-
var flipYVertices = new Float32Array([
|
|
23429
|
-
3,
|
|
23430
|
-
-1,
|
|
23431
|
-
2,
|
|
23432
|
-
0,
|
|
23433
|
-
-1,
|
|
23434
|
-
-1,
|
|
23435
|
-
0,
|
|
23436
|
-
0,
|
|
23437
|
-
-1,
|
|
23438
|
-
3,
|
|
23439
|
-
0,
|
|
23440
|
-
2
|
|
23441
|
-
]); // left-top
|
|
23442
|
-
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
23443
|
-
blitMaterial._addReferCount(1);
|
|
23444
|
-
blitMaterial.renderState.depthState.enabled = false;
|
|
23445
|
-
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
23446
|
-
var blitScreenMaterial = new Material(engine, Shader.find("blit-screen"));
|
|
23447
|
-
blitScreenMaterial._addReferCount(1);
|
|
23448
|
-
blitScreenMaterial.renderState.depthState.enabled = false;
|
|
23449
|
-
blitScreenMaterial.renderState.depthState.writeEnabled = false;
|
|
23450
|
-
this.blitMaterial = blitMaterial;
|
|
23451
|
-
this.blitScreenMaterial = blitScreenMaterial;
|
|
23452
|
-
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
23453
|
-
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
23454
|
-
// Create white and magenta textures
|
|
23455
|
-
var whitePixel = new Uint8Array([
|
|
23456
|
-
255,
|
|
23457
|
-
255,
|
|
23458
|
-
255,
|
|
23459
|
-
255
|
|
23460
|
-
]);
|
|
23461
|
-
this.whiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
23462
|
-
this.whiteTextureCube = this._create1x1Texture(engine, 1, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
23463
|
-
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
23464
|
-
if (isWebGL2) {
|
|
23465
|
-
this.whiteTexture2DArray = this._create1x1Texture(engine, 2, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
23466
|
-
var whitePixel32 = new Uint32Array([
|
|
23467
|
-
255,
|
|
23468
|
-
255,
|
|
23469
|
-
255,
|
|
23470
|
-
255
|
|
23471
|
-
]);
|
|
23472
|
-
this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
|
|
23497
|
+
};
|
|
23498
|
+
_proto._setTransform = function _setTransform(value) {
|
|
23499
|
+
var _this__transform;
|
|
23500
|
+
(_this__transform = this._transform) == null ? void 0 : _this__transform.destroy();
|
|
23501
|
+
this._transform = value;
|
|
23502
|
+
var children = this._children;
|
|
23503
|
+
for(var i = 0, n = children.length; i < n; i++){
|
|
23504
|
+
var _children_i_transform;
|
|
23505
|
+
(_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._parentChange();
|
|
23473
23506
|
}
|
|
23474
|
-
|
|
23475
|
-
this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
|
|
23476
|
-
this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
|
|
23477
|
-
this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
|
|
23478
|
-
this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
|
|
23479
|
-
}
|
|
23480
|
-
var _proto = BasicResources.prototype;
|
|
23507
|
+
};
|
|
23481
23508
|
/**
|
|
23482
|
-
* @
|
|
23483
|
-
*/ _proto.
|
|
23484
|
-
|
|
23509
|
+
* @deprecated
|
|
23510
|
+
*/ _proto.getInvModelMatrix = function getInvModelMatrix() {
|
|
23511
|
+
if (this._inverseWorldMatFlag.flag) {
|
|
23512
|
+
engineMath.Matrix.invert(this._transform.worldMatrix, this._invModelMatrix);
|
|
23513
|
+
this._inverseWorldMatFlag.flag = false;
|
|
23514
|
+
}
|
|
23515
|
+
return this._invModelMatrix;
|
|
23485
23516
|
};
|
|
23486
23517
|
/**
|
|
23487
23518
|
* @internal
|
|
23488
|
-
*/
|
|
23489
|
-
var
|
|
23490
|
-
|
|
23491
|
-
|
|
23492
|
-
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
23498
|
-
var mesh = new ModelMesh(engine);
|
|
23499
|
-
mesh._addReferCount(1);
|
|
23500
|
-
mesh.setVertexElements([
|
|
23501
|
-
new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
|
|
23502
|
-
]);
|
|
23503
|
-
var buffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
|
|
23504
|
-
mesh.setVertexBufferBinding(buffer, 16);
|
|
23505
|
-
mesh.addSubMesh(0, 3, MeshTopology.Triangles);
|
|
23506
|
-
engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
|
|
23507
|
-
_inherits(_class, ContentRestorer);
|
|
23508
|
-
function _class() {
|
|
23509
|
-
return ContentRestorer.call(this, mesh) || this;
|
|
23519
|
+
*/ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {
|
|
23520
|
+
var searchPath = paths[pathIndex];
|
|
23521
|
+
var isEndPath = pathIndex === paths.length - 1;
|
|
23522
|
+
var children = entity._children;
|
|
23523
|
+
for(var n = children.length; childIndex < n; childIndex++){
|
|
23524
|
+
var child = children[childIndex];
|
|
23525
|
+
if (child.name === searchPath) {
|
|
23526
|
+
// Search success if end path, or downward search
|
|
23527
|
+
return isEndPath ? child : Entity._findChildByName(child, 0, paths, pathIndex + 1);
|
|
23510
23528
|
}
|
|
23511
|
-
var _proto = _class.prototype;
|
|
23512
|
-
_proto.restoreContent = function restoreContent() {
|
|
23513
|
-
buffer.setData(buffer.data);
|
|
23514
|
-
};
|
|
23515
|
-
return _class;
|
|
23516
|
-
}(ContentRestorer))());
|
|
23517
|
-
return mesh;
|
|
23518
|
-
};
|
|
23519
|
-
_proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel, isSRGBColorSpace) {
|
|
23520
|
-
var texture;
|
|
23521
|
-
switch(type){
|
|
23522
|
-
case 0:
|
|
23523
|
-
var texture2D = new Texture2D(engine, 1, 1, format, false, isSRGBColorSpace);
|
|
23524
|
-
texture2D.setPixelBuffer(pixel);
|
|
23525
|
-
texture = texture2D;
|
|
23526
|
-
break;
|
|
23527
|
-
case 2:
|
|
23528
|
-
var texture2DArray = new Texture2DArray(engine, 1, 1, 1, format, false, isSRGBColorSpace);
|
|
23529
|
-
texture2DArray.setPixelBuffer(0, pixel);
|
|
23530
|
-
texture = texture2DArray;
|
|
23531
|
-
break;
|
|
23532
|
-
case 1:
|
|
23533
|
-
var textureCube = new TextureCube(engine, 1, format, false, isSRGBColorSpace);
|
|
23534
|
-
for(var i = 0; i < 6; i++){
|
|
23535
|
-
textureCube.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
23536
|
-
}
|
|
23537
|
-
texture = textureCube;
|
|
23538
|
-
break;
|
|
23539
|
-
default:
|
|
23540
|
-
throw "Invalid texture type";
|
|
23541
23529
|
}
|
|
23542
|
-
|
|
23543
|
-
|
|
23544
|
-
_inherits(_class, ContentRestorer);
|
|
23545
|
-
function _class() {
|
|
23546
|
-
return ContentRestorer.call(this, texture) || this;
|
|
23547
|
-
}
|
|
23548
|
-
var _proto = _class.prototype;
|
|
23549
|
-
_proto.restoreContent = function restoreContent() {
|
|
23550
|
-
switch(type){
|
|
23551
|
-
case 0:
|
|
23552
|
-
this.resource.setPixelBuffer(pixel);
|
|
23553
|
-
break;
|
|
23554
|
-
case 2:
|
|
23555
|
-
this.resource.setPixelBuffer(0, pixel);
|
|
23556
|
-
break;
|
|
23557
|
-
case 1:
|
|
23558
|
-
for(var i = 0; i < 6; i++){
|
|
23559
|
-
this.resource.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
23560
|
-
}
|
|
23561
|
-
break;
|
|
23562
|
-
}
|
|
23563
|
-
};
|
|
23564
|
-
return _class;
|
|
23565
|
-
}(ContentRestorer))());
|
|
23566
|
-
return texture;
|
|
23567
|
-
};
|
|
23568
|
-
_proto._create2DMaterial = function _create2DMaterial(engine, shader) {
|
|
23569
|
-
var material = new Material(engine, shader);
|
|
23570
|
-
var renderState = material.renderState;
|
|
23571
|
-
var target = renderState.blendState.targetBlendState;
|
|
23572
|
-
target.enabled = true;
|
|
23573
|
-
target.sourceColorBlendFactor = BlendFactor.SourceAlpha;
|
|
23574
|
-
target.destinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
23575
|
-
target.sourceAlphaBlendFactor = BlendFactor.One;
|
|
23576
|
-
target.destinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
23577
|
-
target.colorBlendOperation = target.alphaBlendOperation = BlendOperation.Add;
|
|
23578
|
-
renderState.depthState.writeEnabled = false;
|
|
23579
|
-
renderState.rasterState.cullMode = CullMode.Off;
|
|
23580
|
-
renderState.renderQueueType = RenderQueueType.Transparent;
|
|
23581
|
-
material.isGCIgnored = true;
|
|
23582
|
-
return material;
|
|
23530
|
+
// Search failed if first path, or upward search
|
|
23531
|
+
return pathIndex === 0 ? null : Entity._findChildByName(entity.parent, entity.siblingIndex + 1, paths, pathIndex - 1);
|
|
23583
23532
|
};
|
|
23584
|
-
|
|
23585
|
-
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
|
|
23533
|
+
/**
|
|
23534
|
+
* @internal
|
|
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);
|
|
23540
|
+
}
|
|
23589
23541
|
};
|
|
23590
|
-
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
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;
|
|
23550
|
+
}
|
|
23551
|
+
children.length = count;
|
|
23552
|
+
entity._siblingIndex = -1;
|
|
23594
23553
|
};
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
var
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
}
|
|
23604
|
-
BasicResources._maskReadInsideRenderStates = renderStates = {};
|
|
23605
|
-
compareFunction = CompareFunction.LessEqual;
|
|
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;
|
|
23606
23562
|
} else {
|
|
23607
|
-
|
|
23608
|
-
|
|
23609
|
-
return renderStates;
|
|
23563
|
+
if (index < 0 || index > childCount) {
|
|
23564
|
+
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
23610
23565
|
}
|
|
23611
|
-
|
|
23612
|
-
|
|
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;
|
|
23613
23573
|
}
|
|
23614
|
-
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
23615
|
-
renderStates[RenderStateElementKey.StencilStateWriteMask] = 0x00;
|
|
23616
|
-
renderStates[RenderStateElementKey.StencilStateReferenceValue] = 1;
|
|
23617
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = compareFunction;
|
|
23618
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = compareFunction;
|
|
23619
|
-
return renderStates;
|
|
23620
23574
|
};
|
|
23621
|
-
|
|
23622
|
-
|
|
23623
|
-
|
|
23624
|
-
|
|
23625
|
-
|
|
23626
|
-
|
|
23627
|
-
|
|
23628
|
-
return renderStates;
|
|
23575
|
+
_create_class(Entity, [
|
|
23576
|
+
{
|
|
23577
|
+
key: "transform",
|
|
23578
|
+
get: /**
|
|
23579
|
+
* The transform of this entity.
|
|
23580
|
+
*/ function get() {
|
|
23581
|
+
return this._transform;
|
|
23629
23582
|
}
|
|
23630
|
-
|
|
23631
|
-
|
|
23632
|
-
|
|
23633
|
-
|
|
23634
|
-
|
|
23635
|
-
|
|
23583
|
+
},
|
|
23584
|
+
{
|
|
23585
|
+
key: "isActive",
|
|
23586
|
+
get: /**
|
|
23587
|
+
* Whether to activate locally.
|
|
23588
|
+
*/ function get() {
|
|
23589
|
+
return this._isActive;
|
|
23590
|
+
},
|
|
23591
|
+
set: function set(value) {
|
|
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);
|
|
23609
|
+
}
|
|
23610
|
+
}
|
|
23636
23611
|
}
|
|
23637
|
-
|
|
23638
|
-
passOperation = StencilOperation.DecrementSaturate;
|
|
23639
|
-
}
|
|
23640
|
-
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
23641
|
-
renderStates[RenderStateElementKey.StencilStatePassOperationFront] = passOperation;
|
|
23642
|
-
renderStates[RenderStateElementKey.StencilStatePassOperationBack] = passOperation;
|
|
23643
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = CompareFunction.Always;
|
|
23644
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = CompareFunction.Always;
|
|
23645
|
-
var failStencilOperation = StencilOperation.Keep;
|
|
23646
|
-
renderStates[RenderStateElementKey.StencilStateFailOperationFront] = failStencilOperation;
|
|
23647
|
-
renderStates[RenderStateElementKey.StencilStateFailOperationBack] = failStencilOperation;
|
|
23648
|
-
renderStates[RenderStateElementKey.StencilStateZFailOperationFront] = failStencilOperation;
|
|
23649
|
-
renderStates[RenderStateElementKey.StencilStateZFailOperationBack] = failStencilOperation;
|
|
23650
|
-
renderStates[RenderStateElementKey.BlendStateColorWriteMask0] = ColorWriteMask.None;
|
|
23651
|
-
renderStates[RenderStateElementKey.DepthStateEnabled] = false;
|
|
23652
|
-
renderStates[RenderStateElementKey.RasterStateCullMode] = CullMode.Off;
|
|
23653
|
-
return renderStates;
|
|
23654
|
-
};
|
|
23655
|
-
_create_class(BasicResources, [
|
|
23612
|
+
},
|
|
23656
23613
|
{
|
|
23657
|
-
key: "
|
|
23658
|
-
get:
|
|
23659
|
-
|
|
23614
|
+
key: "isActiveInHierarchy",
|
|
23615
|
+
get: /**
|
|
23616
|
+
* Whether it is active in the hierarchy.
|
|
23617
|
+
*/ function get() {
|
|
23618
|
+
return this._isActiveInHierarchy;
|
|
23619
|
+
}
|
|
23620
|
+
},
|
|
23621
|
+
{
|
|
23622
|
+
key: "parent",
|
|
23623
|
+
get: /**
|
|
23624
|
+
* The parent entity.
|
|
23625
|
+
*/ function get() {
|
|
23626
|
+
return this._parent;
|
|
23627
|
+
},
|
|
23628
|
+
set: function set(value) {
|
|
23629
|
+
this._setParent(value);
|
|
23630
|
+
}
|
|
23631
|
+
},
|
|
23632
|
+
{
|
|
23633
|
+
key: "children",
|
|
23634
|
+
get: /**
|
|
23635
|
+
* The children entities
|
|
23636
|
+
*/ function get() {
|
|
23637
|
+
return this._children;
|
|
23638
|
+
}
|
|
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;
|
|
23647
|
+
}
|
|
23648
|
+
},
|
|
23649
|
+
{
|
|
23650
|
+
key: "scene",
|
|
23651
|
+
get: /**
|
|
23652
|
+
* The scene the entity belongs to.
|
|
23653
|
+
*/ function get() {
|
|
23654
|
+
return this._scene;
|
|
23655
|
+
}
|
|
23656
|
+
},
|
|
23657
|
+
{
|
|
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
|
+
}
|
|
23660
23675
|
}
|
|
23661
23676
|
}
|
|
23662
23677
|
]);
|
|
23663
|
-
return
|
|
23664
|
-
}();
|
|
23665
|
-
|
|
23666
|
-
BasicResources._maskReadOutsideRenderStates = null;
|
|
23667
|
-
BasicResources._maskWriteIncrementRenderStates = null;
|
|
23668
|
-
BasicResources._maskWriteDecrementRenderStates = null;
|
|
23678
|
+
return Entity;
|
|
23679
|
+
}(EngineObject);
|
|
23680
|
+
/** @internal */ Entity._tempComponentConstructors = [];
|
|
23669
23681
|
|
|
23670
23682
|
var ObjectPool = /*#__PURE__*/ function() {
|
|
23671
23683
|
function ObjectPool(type) {
|
|
@@ -29030,6 +29042,184 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
29030
29042
|
return PointerMethods;
|
|
29031
29043
|
}({});
|
|
29032
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
|
+
|
|
29033
29223
|
/**
|
|
29034
29224
|
* Loader abstract class.
|
|
29035
29225
|
*/ var Loader = /*#__PURE__*/ function() {
|
|
@@ -38402,6 +38592,7 @@ exports.CharacterController = CharacterController;
|
|
|
38402
38592
|
exports.CircleShape = CircleShape;
|
|
38403
38593
|
exports.ClearableObjectPool = ClearableObjectPool;
|
|
38404
38594
|
exports.CloneManager = CloneManager;
|
|
38595
|
+
exports.CloneUtils = CloneUtils;
|
|
38405
38596
|
exports.ColliderShape = ColliderShape;
|
|
38406
38597
|
exports.ColliderShapeUpAxis = ColliderShapeUpAxis;
|
|
38407
38598
|
exports.Collision = Collision;
|
|
@@ -38555,6 +38746,7 @@ exports.ShaderTagKey = ShaderTagKey;
|
|
|
38555
38746
|
exports.ShadowCascadesMode = ShadowCascadesMode;
|
|
38556
38747
|
exports.ShadowResolution = ShadowResolution;
|
|
38557
38748
|
exports.ShadowType = ShadowType;
|
|
38749
|
+
exports.Signal = Signal;
|
|
38558
38750
|
exports.SizeOverLifetimeModule = SizeOverLifetimeModule;
|
|
38559
38751
|
exports.Skin = Skin;
|
|
38560
38752
|
exports.SkinnedMeshRenderer = SkinnedMeshRenderer;
|