@galacean/engine-core 2.0.0-alpha.45 → 2.0.0-alpha.47
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 +115 -39
- package/dist/main.js.map +1 -1
- package/dist/module.js +115 -39
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/ComponentsDependencies.d.ts +5 -1
- package/types/Entity.d.ts +3 -1
- package/types/Transform.d.ts +6 -0
- package/types/input/InputManager.d.ts +6 -6
- package/types/input/pointer/Pointer.d.ts +1 -1
- package/types/mesh/ModelMesh.d.ts +3 -2
package/dist/module.js
CHANGED
|
@@ -5018,10 +5018,25 @@ registerDefaultCloneMode(Component, CloneMode.Remap);
|
|
|
5018
5018
|
};
|
|
5019
5019
|
/**
|
|
5020
5020
|
* @internal
|
|
5021
|
-
*/ ComponentsDependencies.
|
|
5021
|
+
*/ ComponentsDependencies._hasDependencies = function _hasDependencies(type) {
|
|
5022
|
+
while(type !== Component){
|
|
5023
|
+
if (ComponentsDependencies._dependenciesMap.has(type)) {
|
|
5024
|
+
return true;
|
|
5025
|
+
}
|
|
5026
|
+
type = Object.getPrototypeOf(type);
|
|
5027
|
+
}
|
|
5028
|
+
return false;
|
|
5029
|
+
};
|
|
5030
|
+
/**
|
|
5031
|
+
* @internal
|
|
5032
|
+
*/ ComponentsDependencies._removeCheck = function _removeCheck(entity, type, replace) {
|
|
5022
5033
|
var components = entity._components;
|
|
5023
5034
|
var n = components.length;
|
|
5024
5035
|
while(type !== Component){
|
|
5036
|
+
// The replacement still satisfies this type and all of its base types
|
|
5037
|
+
if (replace && (replace === type || _instanceof(replace.prototype, type))) {
|
|
5038
|
+
return;
|
|
5039
|
+
}
|
|
5025
5040
|
var count = 0;
|
|
5026
5041
|
for(var i = 0; i < n; i++){
|
|
5027
5042
|
if (_instanceof(components[i], type) && ++count > 1) return;
|
|
@@ -5138,6 +5153,7 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5138
5153
|
|
|
5139
5154
|
/**
|
|
5140
5155
|
* Used to implement transformation related functions.
|
|
5156
|
+
* @remarks A `Transform` subclass must not declare component dependencies.
|
|
5141
5157
|
*/ var Transform = /*#__PURE__*/ function(Component) {
|
|
5142
5158
|
_inherits(Transform, Component);
|
|
5143
5159
|
function Transform(entity) {
|
|
@@ -5167,6 +5183,13 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5167
5183
|
return _this;
|
|
5168
5184
|
}
|
|
5169
5185
|
var _proto = Transform.prototype;
|
|
5186
|
+
_proto.destroy = function destroy() {
|
|
5187
|
+
var entity = this._entity;
|
|
5188
|
+
if (entity.transform === this && !entity.destroyed) {
|
|
5189
|
+
throw "Transform cannot be destroyed directly; replace it by adding another Transform-compatible component";
|
|
5190
|
+
}
|
|
5191
|
+
Component.prototype.destroy.call(this);
|
|
5192
|
+
};
|
|
5170
5193
|
/**
|
|
5171
5194
|
* Set local position by X, Y, Z value.
|
|
5172
5195
|
* @param x - X coordinate
|
|
@@ -5305,22 +5328,35 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
|
|
|
5305
5328
|
return isInvert;
|
|
5306
5329
|
};
|
|
5307
5330
|
/**
|
|
5331
|
+
* @internal
|
|
5332
|
+
*/ _proto._copyLocalPoseFrom = function _copyLocalPoseFrom(source) {
|
|
5333
|
+
var _this = this, position = _this._position, rotation = _this._rotation, rotationQuaternion = _this._rotationQuaternion, scale = _this._scale;
|
|
5334
|
+
//@ts-ignore
|
|
5335
|
+
position._onValueChanged = rotation._onValueChanged = scale._onValueChanged = null;
|
|
5336
|
+
//@ts-ignore
|
|
5337
|
+
rotationQuaternion._onValueChanged = null;
|
|
5338
|
+
position.copyFrom(source._position);
|
|
5339
|
+
scale.copyFrom(source._scale);
|
|
5340
|
+
rotation.copyFrom(source._rotation);
|
|
5341
|
+
rotationQuaternion.copyFrom(source._rotationQuaternion);
|
|
5342
|
+
//@ts-ignore
|
|
5343
|
+
position._onValueChanged = this._onPositionChanged;
|
|
5344
|
+
//@ts-ignore
|
|
5345
|
+
rotation._onValueChanged = this._onRotationChanged;
|
|
5346
|
+
//@ts-ignore
|
|
5347
|
+
rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
|
|
5348
|
+
//@ts-ignore
|
|
5349
|
+
scale._onValueChanged = this._onScaleChanged;
|
|
5350
|
+
this._localUniformScaling = source._localUniformScaling;
|
|
5351
|
+
var rotationDirtyBits = 1 | 2;
|
|
5352
|
+
this._dirtyFlag = this._dirtyFlag & ~rotationDirtyBits | source._dirtyFlag & rotationDirtyBits;
|
|
5353
|
+
this._setDirtyFlagTrue(64);
|
|
5354
|
+
this._updateAllWorldFlag(444);
|
|
5355
|
+
};
|
|
5356
|
+
/**
|
|
5308
5357
|
* @inheritdoc
|
|
5309
5358
|
*/ _proto._onClone = function _onClone(target) {
|
|
5310
|
-
|
|
5311
|
-
// @ts-ignore
|
|
5312
|
-
position._onValueChanged = rotation._onValueChanged = scale._onValueChanged = null;
|
|
5313
|
-
position.copyFrom(this.position);
|
|
5314
|
-
rotation.copyFrom(this.rotation);
|
|
5315
|
-
scale.copyFrom(this.scale);
|
|
5316
|
-
// @ts-ignore
|
|
5317
|
-
position._onValueChanged = target._onPositionChanged;
|
|
5318
|
-
// @ts-ignore
|
|
5319
|
-
rotation._onValueChanged = target._onRotationChanged;
|
|
5320
|
-
// @ts-ignore
|
|
5321
|
-
scale._onValueChanged = target._onScaleChanged;
|
|
5322
|
-
// When cloning, other components may obtain properties such as `rotationQuaternion` in the constructor, local related dirty flags need to be corrected
|
|
5323
|
-
target._setDirtyFlagTrue(2 | 64);
|
|
5359
|
+
target._copyLocalPoseFrom(this);
|
|
5324
5360
|
};
|
|
5325
5361
|
_proto._onLocalMatrixChanging = function _onLocalMatrixChanging() {
|
|
5326
5362
|
this._setDirtyFlagFalse(64);
|
|
@@ -6171,10 +6207,27 @@ function _construct(Parent, args, Class) {
|
|
|
6171
6207
|
_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._scriptsVersion = 0, /** @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----------------------------------------------------------------
|
|
6172
6208
|
_this._invModelMatrix = new Matrix();
|
|
6173
6209
|
_this.name = name != null ? name : "Entity";
|
|
6174
|
-
|
|
6175
|
-
|
|
6210
|
+
var transformType = Transform;
|
|
6211
|
+
var n = components.length;
|
|
6212
|
+
for(var i = n - 1; i >= 0; i--){
|
|
6213
|
+
var componentType = components[i];
|
|
6214
|
+
if (Entity._isTransformType(componentType)) {
|
|
6215
|
+
transformType = componentType;
|
|
6216
|
+
break;
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
Entity._checkTransformDependencies(transformType);
|
|
6220
|
+
var transform = new transformType(_this);
|
|
6221
|
+
// Constructors may add components, but Transform always owns slot zero
|
|
6222
|
+
_this._components.unshift(transform);
|
|
6223
|
+
_this._transform = transform;
|
|
6224
|
+
transform._setActive(true, ActiveChangeFlag.All);
|
|
6225
|
+
for(var i1 = 0; i1 < n; i1++){
|
|
6226
|
+
var componentType1 = components[i1];
|
|
6227
|
+
if (!Entity._isTransformType(componentType1)) {
|
|
6228
|
+
_this.addComponent(componentType1);
|
|
6229
|
+
}
|
|
6176
6230
|
}
|
|
6177
|
-
!_this._transform && _this.addComponent(Transform);
|
|
6178
6231
|
_this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
|
|
6179
6232
|
return _this;
|
|
6180
6233
|
}
|
|
@@ -6188,13 +6241,21 @@ function _construct(Parent, args, Class) {
|
|
|
6188
6241
|
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
6189
6242
|
args[_key - 1] = arguments[_key];
|
|
6190
6243
|
}
|
|
6191
|
-
|
|
6244
|
+
var isTransform = Entity._isTransformType(type);
|
|
6245
|
+
if (isTransform) {
|
|
6246
|
+
Entity._checkTransformDependencies(type);
|
|
6247
|
+
ComponentsDependencies._removeCheck(this, this._transform.constructor, type);
|
|
6248
|
+
} else {
|
|
6249
|
+
ComponentsDependencies._addCheck(this, type);
|
|
6250
|
+
}
|
|
6192
6251
|
var component = _construct(type, [].concat([
|
|
6193
6252
|
this
|
|
6194
6253
|
], args));
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6254
|
+
if (isTransform) {
|
|
6255
|
+
this._replaceTransform(component);
|
|
6256
|
+
} else {
|
|
6257
|
+
this._components.push(component);
|
|
6258
|
+
}
|
|
6198
6259
|
component._setActive(true, ActiveChangeFlag.All);
|
|
6199
6260
|
return component;
|
|
6200
6261
|
};
|
|
@@ -6342,6 +6403,7 @@ function _construct(Parent, args, Class) {
|
|
|
6342
6403
|
_proto._createCloneEntity = function _createCloneEntity(cloneMap) {
|
|
6343
6404
|
var componentConstructors = Entity._tempComponentConstructors;
|
|
6344
6405
|
var components = this._components;
|
|
6406
|
+
componentConstructors.length = components.length;
|
|
6345
6407
|
for(var i = 0, n = components.length; i < n; i++){
|
|
6346
6408
|
componentConstructors[i] = components[i].constructor;
|
|
6347
6409
|
}
|
|
@@ -6409,9 +6471,13 @@ function _construct(Parent, args, Class) {
|
|
|
6409
6471
|
/**
|
|
6410
6472
|
* @internal
|
|
6411
6473
|
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
6412
|
-
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
6413
6474
|
var components = this._components;
|
|
6414
|
-
components.
|
|
6475
|
+
var index = components.indexOf(component);
|
|
6476
|
+
// A replaced Transform is detached from the component slot immediately but
|
|
6477
|
+
// can still reach here later because object destruction may be deferred
|
|
6478
|
+
if (index < 0) return;
|
|
6479
|
+
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
6480
|
+
components.splice(index, 1);
|
|
6415
6481
|
};
|
|
6416
6482
|
/**
|
|
6417
6483
|
* @internal
|
|
@@ -6613,15 +6679,16 @@ function _construct(Parent, args, Class) {
|
|
|
6613
6679
|
}
|
|
6614
6680
|
}
|
|
6615
6681
|
};
|
|
6616
|
-
_proto.
|
|
6617
|
-
var
|
|
6618
|
-
|
|
6619
|
-
this.
|
|
6682
|
+
_proto._replaceTransform = function _replaceTransform(replacement) {
|
|
6683
|
+
var previous = this._transform;
|
|
6684
|
+
replacement._copyLocalPoseFrom(previous);
|
|
6685
|
+
this._components[0] = replacement;
|
|
6686
|
+
this._transform = replacement;
|
|
6620
6687
|
var children = this._children;
|
|
6621
6688
|
for(var i = 0, n = children.length; i < n; i++){
|
|
6622
|
-
|
|
6623
|
-
(_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._parentChange();
|
|
6689
|
+
children[i].transform._parentChange();
|
|
6624
6690
|
}
|
|
6691
|
+
previous.destroy();
|
|
6625
6692
|
};
|
|
6626
6693
|
/**
|
|
6627
6694
|
* @deprecated
|
|
@@ -6632,6 +6699,14 @@ function _construct(Parent, args, Class) {
|
|
|
6632
6699
|
}
|
|
6633
6700
|
return this._invModelMatrix;
|
|
6634
6701
|
};
|
|
6702
|
+
Entity._isTransformType = function _isTransformType(type) {
|
|
6703
|
+
return type === Transform || _instanceof(type.prototype, Transform);
|
|
6704
|
+
};
|
|
6705
|
+
Entity._checkTransformDependencies = function _checkTransformDependencies(type) {
|
|
6706
|
+
if (ComponentsDependencies._hasDependencies(type)) {
|
|
6707
|
+
throw "Transform-compatible component " + type.name + " cannot declare component dependencies";
|
|
6708
|
+
}
|
|
6709
|
+
};
|
|
6635
6710
|
/**
|
|
6636
6711
|
* @internal
|
|
6637
6712
|
*/ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {
|
|
@@ -14747,6 +14822,7 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
14747
14822
|
|
|
14748
14823
|
/**
|
|
14749
14824
|
* Mesh containing common vertex elements of the model.
|
|
14825
|
+
* Define draw ranges with `addSubMesh()` and assign a material to each corresponding MeshRenderer slot.
|
|
14750
14826
|
*/ var ModelMesh = /*#__PURE__*/ function(Mesh) {
|
|
14751
14827
|
_inherits(ModelMesh, Mesh);
|
|
14752
14828
|
function ModelMesh(engine, name) {
|
|
@@ -15080,8 +15156,8 @@ BlendShapeManager._blendShapeTextureInfoProperty = ShaderProperty.getByName("ren
|
|
|
15080
15156
|
return blendShapes[index].name;
|
|
15081
15157
|
};
|
|
15082
15158
|
/**
|
|
15083
|
-
* Upload data to GPU
|
|
15084
|
-
*
|
|
15159
|
+
* Upload mesh data to the GPU, generating vertex elements and buffer bindings as needed.
|
|
15160
|
+
* Bounds must be set separately for culling.
|
|
15085
15161
|
*
|
|
15086
15162
|
* @param releaseData - Whether to release the data cache, release data can reduce memory usage.
|
|
15087
15163
|
*/ _proto.uploadData = function uploadData(releaseData) {
|
|
@@ -19505,7 +19581,7 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
19505
19581
|
* Pointer.
|
|
19506
19582
|
*/ var Pointer = /*#__PURE__*/ function() {
|
|
19507
19583
|
function Pointer(id) {
|
|
19508
|
-
/** The phase of pointer. */ this.phase = PointerPhase.Leave;
|
|
19584
|
+
/** The current phase of this pointer. */ this.phase = PointerPhase.Leave;
|
|
19509
19585
|
/** The position of the pointer in screen space pixel coordinates. */ this.position = new Vector2();
|
|
19510
19586
|
/** The change of the pointer. */ this.deltaPosition = new Vector2();
|
|
19511
19587
|
/** @internal */ this._events = [];
|
|
@@ -22984,9 +23060,9 @@ PointerEventEmitter._tempRay = new Ray();
|
|
|
22984
23060
|
}
|
|
22985
23061
|
};
|
|
22986
23062
|
/**
|
|
22987
|
-
* Whether
|
|
22988
|
-
* @param pointerButton - The
|
|
22989
|
-
* @returns
|
|
23063
|
+
* Whether any pointer was pressed this frame.
|
|
23064
|
+
* @param pointerButton - The button to query; omit to include all buttons
|
|
23065
|
+
* @returns The result remains true for the frame, even if a release also occurred
|
|
22990
23066
|
*/ _proto.isPointerDown = function isPointerDown(pointerButton) {
|
|
22991
23067
|
if (this._initialized) {
|
|
22992
23068
|
if (pointerButton === undefined) {
|
|
@@ -22999,9 +23075,9 @@ PointerEventEmitter._tempRay = new Ray();
|
|
|
22999
23075
|
}
|
|
23000
23076
|
};
|
|
23001
23077
|
/**
|
|
23002
|
-
* Whether
|
|
23003
|
-
* @param pointerButton - The
|
|
23004
|
-
* @returns
|
|
23078
|
+
* Whether any pointer was released this frame.
|
|
23079
|
+
* @param pointerButton - The button to query; omit to include all buttons
|
|
23080
|
+
* @returns The result remains true for the frame, even if a press also occurred
|
|
23005
23081
|
*/ _proto.isPointerUp = function isPointerUp(pointerButton) {
|
|
23006
23082
|
if (this._initialized) {
|
|
23007
23083
|
if (pointerButton === undefined) {
|