@galacean/engine 2.0.0-alpha.13 → 2.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1294 -1033
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/bundled.module.js +1293 -1034
- package/dist/bundled.module.js.map +1 -1
- package/dist/bundled.module.min.js +1 -1
- package/dist/bundled.module.min.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/bundled.module.js
CHANGED
|
@@ -982,11 +982,15 @@ BoundingBox._tempVec31 = new Vector3();
|
|
|
982
982
|
var normal = plane.normal;
|
|
983
983
|
var zeroTolerance = MathUtil.zeroTolerance;
|
|
984
984
|
var dir = Vector3.dot(normal, ray.direction);
|
|
985
|
+
var position = Vector3.dot(normal, ray.origin);
|
|
985
986
|
// Parallel
|
|
986
987
|
if (Math.abs(dir) < zeroTolerance) {
|
|
988
|
+
// Check if ray origin is on the plane
|
|
989
|
+
if (Math.abs(position + plane.distance) < zeroTolerance) {
|
|
990
|
+
return 0;
|
|
991
|
+
}
|
|
987
992
|
return -1;
|
|
988
993
|
}
|
|
989
|
-
var position = Vector3.dot(normal, ray.origin);
|
|
990
994
|
var distance = (-plane.distance - position) / dir;
|
|
991
995
|
if (distance < 0) {
|
|
992
996
|
if (distance < -zeroTolerance) {
|
|
@@ -6729,6 +6733,14 @@ SystemInfo._initialize();
|
|
|
6729
6733
|
return this._height;
|
|
6730
6734
|
}
|
|
6731
6735
|
},
|
|
6736
|
+
{
|
|
6737
|
+
key: "colorTextures",
|
|
6738
|
+
get: /**
|
|
6739
|
+
* Render color textures.
|
|
6740
|
+
*/ function get() {
|
|
6741
|
+
return this._colorTextures;
|
|
6742
|
+
}
|
|
6743
|
+
},
|
|
6732
6744
|
{
|
|
6733
6745
|
key: "colorTextureCount",
|
|
6734
6746
|
get: /**
|
|
@@ -27082,274 +27094,973 @@ PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
|
27082
27094
|
]);
|
|
27083
27095
|
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
27084
27096
|
PrimitiveMesh._spherePoleIdx = 0;
|
|
27085
|
-
|
|
27086
|
-
|
|
27087
|
-
|
|
27088
|
-
|
|
27089
|
-
|
|
27090
|
-
|
|
27091
|
-
|
|
27092
|
-
|
|
27093
|
-
|
|
27094
|
-
}
|
|
27095
|
-
|
|
27096
|
-
|
|
27097
|
-
|
|
27098
|
-
|
|
27099
|
-
|
|
27100
|
-
|
|
27101
|
-
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27105
|
-
|
|
27106
|
-
|
|
27107
|
-
|
|
27108
|
-
|
|
27109
|
-
|
|
27110
|
-
return instance;
|
|
27111
|
-
};
|
|
27112
|
-
}
|
|
27113
|
-
return _construct$1.apply(null, arguments);
|
|
27114
|
-
}
|
|
27115
|
-
var ComponentCloner = /*#__PURE__*/ function() {
|
|
27116
|
-
function ComponentCloner() {}
|
|
27117
|
-
/**
|
|
27118
|
-
* Clone component.
|
|
27119
|
-
* @param source - Clone source
|
|
27120
|
-
* @param target - Clone target
|
|
27121
|
-
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
27122
|
-
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
27123
|
-
for(var k in source){
|
|
27124
|
-
CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
|
|
27097
|
+
/**
|
|
27098
|
+
* @internal
|
|
27099
|
+
* Utility functions for remapping Entity/Component references during cloning.
|
|
27100
|
+
*/ var CloneUtils = /*#__PURE__*/ function() {
|
|
27101
|
+
function CloneUtils() {}
|
|
27102
|
+
CloneUtils.remapEntity = function remapEntity(srcRoot, targetRoot, entity) {
|
|
27103
|
+
var paths = CloneUtils._tempRemapPath;
|
|
27104
|
+
var success = CloneUtils._getEntityHierarchyPath(srcRoot, entity, paths);
|
|
27105
|
+
return success ? CloneUtils._getEntityByHierarchyPath(targetRoot, paths) : entity;
|
|
27106
|
+
};
|
|
27107
|
+
CloneUtils.remapComponent = function remapComponent(srcRoot, targetRoot, component) {
|
|
27108
|
+
var _CloneUtils__getEntityByHierarchyPath;
|
|
27109
|
+
var paths = CloneUtils._tempRemapPath;
|
|
27110
|
+
var success = CloneUtils._getEntityHierarchyPath(srcRoot, component.entity, paths);
|
|
27111
|
+
return success ? (_CloneUtils__getEntityByHierarchyPath = CloneUtils._getEntityByHierarchyPath(targetRoot, paths)) == null ? void 0 : _CloneUtils__getEntityByHierarchyPath.getComponent(component.constructor) : component;
|
|
27112
|
+
};
|
|
27113
|
+
CloneUtils._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
|
|
27114
|
+
inversePath.length = 0;
|
|
27115
|
+
while(searchEntity !== rootEntity){
|
|
27116
|
+
var parent = searchEntity.parent;
|
|
27117
|
+
if (!parent) {
|
|
27118
|
+
return false;
|
|
27119
|
+
}
|
|
27120
|
+
inversePath.push(searchEntity.siblingIndex);
|
|
27121
|
+
searchEntity = parent;
|
|
27125
27122
|
}
|
|
27126
|
-
|
|
27127
|
-
|
|
27123
|
+
return true;
|
|
27124
|
+
};
|
|
27125
|
+
CloneUtils._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
|
|
27126
|
+
var entity = rootEntity;
|
|
27127
|
+
for(var i = inversePath.length - 1; i >= 0; i--){
|
|
27128
|
+
entity = entity.children[inversePath[i]];
|
|
27128
27129
|
}
|
|
27130
|
+
return entity;
|
|
27129
27131
|
};
|
|
27130
|
-
return
|
|
27132
|
+
return CloneUtils;
|
|
27131
27133
|
}();
|
|
27134
|
+
CloneUtils._tempRemapPath = [];
|
|
27132
27135
|
/**
|
|
27133
|
-
*
|
|
27134
|
-
*/ var
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
return EntityModifyFlags;
|
|
27138
|
-
}({});
|
|
27139
|
-
/**
|
|
27140
|
-
* Entity, be used as components container.
|
|
27141
|
-
*/ var Entity = /*#__PURE__*/ function(EngineObject) {
|
|
27142
|
-
_inherits$2(Entity, EngineObject);
|
|
27143
|
-
function Entity(engine, name) {
|
|
27144
|
-
for(var _len = arguments.length, components = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
27145
|
-
components[_key - 2] = arguments[_key];
|
|
27146
|
-
}
|
|
27136
|
+
* Skin used for skinned mesh renderer.
|
|
27137
|
+
*/ var Skin = /*#__PURE__*/ function(EngineObject) {
|
|
27138
|
+
_inherits$2(Skin, EngineObject);
|
|
27139
|
+
function Skin(name) {
|
|
27147
27140
|
var _this;
|
|
27148
|
-
_this = EngineObject.call(this,
|
|
27149
|
-
_this.name = name != null ? name : "Entity";
|
|
27150
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
27151
|
-
_this.addComponent(components[i]);
|
|
27152
|
-
}
|
|
27153
|
-
!_this._transform && _this.addComponent(Transform);
|
|
27154
|
-
_this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
|
|
27141
|
+
_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 = [];
|
|
27155
27142
|
return _this;
|
|
27156
27143
|
}
|
|
27157
|
-
var _proto =
|
|
27144
|
+
var _proto = Skin.prototype;
|
|
27158
27145
|
/**
|
|
27159
|
-
*
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
|
|
27163
|
-
*/ _proto.addComponent = function addComponent(type) {
|
|
27164
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
27165
|
-
args[_key - 1] = arguments[_key];
|
|
27146
|
+
* @internal
|
|
27147
|
+
*/ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
|
|
27148
|
+
if (this._updateMark === renderer.engine.time.frameCount) {
|
|
27149
|
+
return;
|
|
27166
27150
|
}
|
|
27167
|
-
|
|
27168
|
-
var
|
|
27169
|
-
|
|
27170
|
-
|
|
27171
|
-
|
|
27172
|
-
|
|
27173
|
-
|
|
27174
|
-
|
|
27175
|
-
|
|
27176
|
-
|
|
27177
|
-
/**
|
|
27178
|
-
* Get component which match the type.
|
|
27179
|
-
* @param type - The type of the component
|
|
27180
|
-
* @returns The first component which match type
|
|
27181
|
-
*/ _proto.getComponent = function getComponent(type) {
|
|
27182
|
-
var components = this._components;
|
|
27183
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
27184
|
-
var component = components[i];
|
|
27185
|
-
if (_instanceof1$2(component, type)) {
|
|
27186
|
-
return component;
|
|
27151
|
+
var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
|
|
27152
|
+
var _this_rootBone;
|
|
27153
|
+
var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
|
|
27154
|
+
for(var i = bones.length - 1; i >= 0; i--){
|
|
27155
|
+
var bone = bones[i];
|
|
27156
|
+
var offset = i * 16;
|
|
27157
|
+
if (bone) {
|
|
27158
|
+
Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
|
|
27159
|
+
} else {
|
|
27160
|
+
skinMatrices.set(bindMatrices[i].elements, offset);
|
|
27187
27161
|
}
|
|
27162
|
+
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
27188
27163
|
}
|
|
27189
|
-
|
|
27164
|
+
this._updateMark = renderer.engine.time.frameCount;
|
|
27190
27165
|
};
|
|
27191
27166
|
/**
|
|
27192
|
-
*
|
|
27193
|
-
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27167
|
+
* @internal
|
|
27168
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
27169
|
+
// Clone rootBone
|
|
27170
|
+
var rootBone = this.rootBone;
|
|
27171
|
+
if (rootBone) {
|
|
27172
|
+
target.rootBone = CloneUtils.remapEntity(srcRoot, targetRoot, rootBone);
|
|
27173
|
+
}
|
|
27174
|
+
// Clone bones
|
|
27175
|
+
var bones = this.bones;
|
|
27176
|
+
if (bones.length > 0) {
|
|
27177
|
+
var boneCount = bones.length;
|
|
27178
|
+
var destBones = new Array(boneCount);
|
|
27179
|
+
for(var i = 0; i < boneCount; i++){
|
|
27180
|
+
destBones[i] = CloneUtils.remapEntity(srcRoot, targetRoot, bones[i]);
|
|
27203
27181
|
}
|
|
27182
|
+
target.bones = destBones;
|
|
27204
27183
|
}
|
|
27205
|
-
return results;
|
|
27206
|
-
};
|
|
27207
|
-
/**
|
|
27208
|
-
* Get the components which match the type of the entity and it's children.
|
|
27209
|
-
* @param type - The component type
|
|
27210
|
-
* @param results - The components collection
|
|
27211
|
-
* @returns The components collection which match the type
|
|
27212
|
-
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
27213
|
-
results.length = 0;
|
|
27214
|
-
this._getComponentsInChildren(type, results);
|
|
27215
|
-
return results;
|
|
27216
27184
|
};
|
|
27217
|
-
|
|
27218
|
-
|
|
27219
|
-
|
|
27220
|
-
|
|
27221
|
-
|
|
27222
|
-
|
|
27223
|
-
|
|
27185
|
+
_create_class$2(Skin, [
|
|
27186
|
+
{
|
|
27187
|
+
key: "rootBone",
|
|
27188
|
+
get: /**
|
|
27189
|
+
* Root bone.
|
|
27190
|
+
*/ function get() {
|
|
27191
|
+
return this._rootBone;
|
|
27192
|
+
},
|
|
27193
|
+
set: function set(value) {
|
|
27194
|
+
if (this._rootBone !== value) {
|
|
27195
|
+
this._updatedManager.dispatch(1, value);
|
|
27196
|
+
this._rootBone = value;
|
|
27197
|
+
}
|
|
27198
|
+
}
|
|
27199
|
+
},
|
|
27200
|
+
{
|
|
27201
|
+
key: "bones",
|
|
27202
|
+
get: /**
|
|
27203
|
+
* Bones of the skin.
|
|
27204
|
+
*/ function get() {
|
|
27205
|
+
return this._bones;
|
|
27206
|
+
},
|
|
27207
|
+
set: function set(value) {
|
|
27208
|
+
var bones = this._bones;
|
|
27209
|
+
var _value_length;
|
|
27210
|
+
var boneCount = (_value_length = value == null ? void 0 : value.length) != null ? _value_length : 0;
|
|
27211
|
+
var lastBoneCount = bones.length;
|
|
27212
|
+
bones.length = boneCount;
|
|
27213
|
+
for(var i = 0; i < boneCount; i++){
|
|
27214
|
+
bones[i] = value[i];
|
|
27215
|
+
}
|
|
27216
|
+
if (lastBoneCount !== boneCount) {
|
|
27217
|
+
this._skinMatrices = new Float32Array(boneCount * 16);
|
|
27218
|
+
this._updatedManager.dispatch(0, boneCount);
|
|
27219
|
+
}
|
|
27220
|
+
}
|
|
27221
|
+
},
|
|
27222
|
+
{
|
|
27223
|
+
key: "skeleton",
|
|
27224
|
+
get: /** @deprecated Please use `rootBone` instead. */ function get() {
|
|
27225
|
+
var _this_rootBone;
|
|
27226
|
+
return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
|
|
27227
|
+
},
|
|
27228
|
+
set: function set(value) {
|
|
27229
|
+
var rootBone = this._rootBone;
|
|
27230
|
+
if (rootBone) {
|
|
27231
|
+
rootBone.name = value;
|
|
27232
|
+
}
|
|
27233
|
+
}
|
|
27224
27234
|
}
|
|
27225
|
-
|
|
27226
|
-
|
|
27235
|
+
]);
|
|
27236
|
+
return Skin;
|
|
27237
|
+
}(EngineObject);
|
|
27238
|
+
__decorate$1([
|
|
27239
|
+
deepClone
|
|
27240
|
+
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
27241
|
+
__decorate$1([
|
|
27242
|
+
ignoreClone
|
|
27243
|
+
], Skin.prototype, "_skinMatrices", void 0);
|
|
27244
|
+
__decorate$1([
|
|
27245
|
+
ignoreClone
|
|
27246
|
+
], Skin.prototype, "_updatedManager", void 0);
|
|
27247
|
+
__decorate$1([
|
|
27248
|
+
ignoreClone
|
|
27249
|
+
], Skin.prototype, "_rootBone", void 0);
|
|
27250
|
+
__decorate$1([
|
|
27251
|
+
ignoreClone
|
|
27252
|
+
], Skin.prototype, "_bones", void 0);
|
|
27253
|
+
__decorate$1([
|
|
27254
|
+
ignoreClone
|
|
27255
|
+
], Skin.prototype, "_updateMark", void 0);
|
|
27256
|
+
var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
|
|
27257
|
+
SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
|
|
27258
|
+
SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
|
|
27259
|
+
return SkinUpdateFlag;
|
|
27260
|
+
}({});
|
|
27261
|
+
/**
|
|
27262
|
+
* SkinnedMeshRenderer.
|
|
27263
|
+
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer) {
|
|
27264
|
+
_inherits$2(SkinnedMeshRenderer, MeshRenderer);
|
|
27265
|
+
function SkinnedMeshRenderer(entity) {
|
|
27266
|
+
var _this;
|
|
27267
|
+
_this = MeshRenderer.call(this, entity) || this, _this._localBounds = new BoundingBox(), _this._jointDataCreateCache = new Vector2(-1, -1);
|
|
27268
|
+
_this._skin = null;
|
|
27269
|
+
var rhi = _this.entity.engine._hardwareRenderer;
|
|
27270
|
+
var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
|
|
27271
|
+
// Limit size to 256 to avoid some problem:
|
|
27272
|
+
// 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!
|
|
27273
|
+
// 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.
|
|
27274
|
+
maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
|
|
27275
|
+
_this._maxVertexUniformVectors = maxVertexUniformVectors;
|
|
27276
|
+
_this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_this);
|
|
27277
|
+
_this._onSkinUpdated = _this._onSkinUpdated.bind(_this);
|
|
27278
|
+
var localBounds = _this._localBounds;
|
|
27279
|
+
// @ts-ignore
|
|
27280
|
+
localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
|
|
27281
|
+
// @ts-ignore
|
|
27282
|
+
localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
|
|
27283
|
+
return _this;
|
|
27284
|
+
}
|
|
27285
|
+
var _proto = SkinnedMeshRenderer.prototype;
|
|
27227
27286
|
/**
|
|
27228
|
-
*
|
|
27229
|
-
|
|
27230
|
-
|
|
27231
|
-
|
|
27232
|
-
|
|
27287
|
+
* @internal
|
|
27288
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
27289
|
+
var _this__jointTexture;
|
|
27290
|
+
MeshRenderer.prototype._onDestroy.call(this);
|
|
27291
|
+
this._jointDataCreateCache = null;
|
|
27292
|
+
this._skin = null;
|
|
27293
|
+
this._blendShapeWeights = null;
|
|
27294
|
+
this._localBounds = null;
|
|
27295
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
27296
|
+
this._jointTexture = null;
|
|
27233
27297
|
};
|
|
27234
27298
|
/**
|
|
27235
|
-
* @
|
|
27236
|
-
|
|
27237
|
-
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
|
|
27299
|
+
* @internal
|
|
27300
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
27301
|
+
MeshRenderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
|
|
27302
|
+
if (this.skin) {
|
|
27303
|
+
target._applySkin(null, target.skin);
|
|
27304
|
+
}
|
|
27305
|
+
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
27241
27306
|
};
|
|
27242
|
-
|
|
27243
|
-
|
|
27244
|
-
|
|
27245
|
-
|
|
27246
|
-
*/ _proto.findByName = function findByName(name) {
|
|
27247
|
-
if (name === this.name) {
|
|
27248
|
-
return this;
|
|
27307
|
+
_proto._update = function _update(context) {
|
|
27308
|
+
var skin = this.skin;
|
|
27309
|
+
if ((skin == null ? void 0 : skin.bones.length) > 0) {
|
|
27310
|
+
skin._updateSkinMatrices(this);
|
|
27249
27311
|
}
|
|
27250
|
-
var
|
|
27251
|
-
|
|
27252
|
-
|
|
27253
|
-
|
|
27254
|
-
|
|
27312
|
+
var shaderData = this.shaderData;
|
|
27313
|
+
var mesh = this.mesh;
|
|
27314
|
+
var blendShapeManager = mesh._blendShapeManager;
|
|
27315
|
+
blendShapeManager._updateShaderData(shaderData, this);
|
|
27316
|
+
var bones = skin == null ? void 0 : skin.bones;
|
|
27317
|
+
if (bones) {
|
|
27318
|
+
var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
|
|
27319
|
+
var boneCount = bones.length;
|
|
27320
|
+
var boneDataCreateCache = this._jointDataCreateCache;
|
|
27321
|
+
var boneCountChange = boneCount !== boneDataCreateCache.x;
|
|
27322
|
+
if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
|
|
27323
|
+
// directly use max joint count to avoid shader recompile
|
|
27324
|
+
var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) / 4);
|
|
27325
|
+
if (boneCount > remainUniformJointCount) {
|
|
27326
|
+
var engine = this.engine;
|
|
27327
|
+
if (engine._hardwareRenderer.canIUseMoreJoints) {
|
|
27328
|
+
if (boneCountChange) {
|
|
27329
|
+
var _this__jointTexture;
|
|
27330
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
27331
|
+
this._jointTexture = new Texture2D(engine, 4, boneCount, TextureFormat.R32G32B32A32, false, false);
|
|
27332
|
+
this._jointTexture.filterMode = TextureFilterMode.Point;
|
|
27333
|
+
this._jointTexture.isGCIgnored = true;
|
|
27334
|
+
}
|
|
27335
|
+
shaderData.disableMacro("RENDERER_JOINTS_NUM");
|
|
27336
|
+
shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
27337
|
+
shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
|
|
27338
|
+
} else {
|
|
27339
|
+
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);
|
|
27340
|
+
}
|
|
27341
|
+
} else {
|
|
27342
|
+
var _this__jointTexture1;
|
|
27343
|
+
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
27344
|
+
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
27345
|
+
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
27346
|
+
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
|
|
27347
|
+
}
|
|
27348
|
+
boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
|
|
27349
|
+
}
|
|
27350
|
+
if (this._jointTexture) {
|
|
27351
|
+
this._jointTexture.setPixelBuffer(skin._skinMatrices);
|
|
27255
27352
|
}
|
|
27256
27353
|
}
|
|
27257
|
-
|
|
27354
|
+
MeshRenderer.prototype._update.call(this, context);
|
|
27258
27355
|
};
|
|
27259
27356
|
/**
|
|
27260
|
-
*
|
|
27261
|
-
|
|
27262
|
-
|
|
27263
|
-
|
|
27264
|
-
|
|
27265
|
-
|
|
27266
|
-
|
|
27357
|
+
* @internal
|
|
27358
|
+
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
27359
|
+
var _this_skin;
|
|
27360
|
+
var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
|
|
27361
|
+
if (rootBone) {
|
|
27362
|
+
BoundingBox.transform(this._localBounds, this._transformEntity.transform.worldMatrix, worldBounds);
|
|
27363
|
+
} else {
|
|
27364
|
+
MeshRenderer.prototype._updateBounds.call(this, worldBounds);
|
|
27267
27365
|
}
|
|
27268
|
-
return Entity._findChildByName(this, 0, splits, 0);
|
|
27269
|
-
};
|
|
27270
|
-
/**
|
|
27271
|
-
* Create child entity.
|
|
27272
|
-
* @param name - The child entity's name
|
|
27273
|
-
* @returns The child entity
|
|
27274
|
-
*/ _proto.createChild = function createChild(name) {
|
|
27275
|
-
var transform = this._transform;
|
|
27276
|
-
var child = transform ? new Entity(this.engine, name, transform.constructor) : new Entity(this.engine, name);
|
|
27277
|
-
child.layer = this.layer;
|
|
27278
|
-
child.parent = this;
|
|
27279
|
-
return child;
|
|
27280
27366
|
};
|
|
27281
|
-
|
|
27282
|
-
|
|
27283
|
-
|
|
27284
|
-
var
|
|
27285
|
-
|
|
27286
|
-
var
|
|
27287
|
-
|
|
27288
|
-
|
|
27289
|
-
|
|
27290
|
-
|
|
27291
|
-
|
|
27292
|
-
|
|
27367
|
+
_proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
|
|
27368
|
+
var mesh = this._mesh;
|
|
27369
|
+
var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
|
|
27370
|
+
var lastBlendShapeWeights = this._blendShapeWeights;
|
|
27371
|
+
if (lastBlendShapeWeights) {
|
|
27372
|
+
var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
|
|
27373
|
+
if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
|
|
27374
|
+
var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
27375
|
+
if (newBlendShapeCount > lastBlendShapeWeightsCount) {
|
|
27376
|
+
newBlendShapeWeights.set(lastBlendShapeWeights);
|
|
27377
|
+
} else {
|
|
27378
|
+
for(var i = 0; i < newBlendShapeCount; i++){
|
|
27379
|
+
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
27380
|
+
}
|
|
27381
|
+
}
|
|
27382
|
+
this._blendShapeWeights = newBlendShapeWeights;
|
|
27383
|
+
}
|
|
27384
|
+
} else {
|
|
27385
|
+
this._blendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
27293
27386
|
}
|
|
27294
|
-
children.length = 0;
|
|
27295
|
-
};
|
|
27296
|
-
/**
|
|
27297
|
-
* Clone this entity include children and components.
|
|
27298
|
-
* @returns Cloned entity
|
|
27299
|
-
*/ _proto.clone = function clone() {
|
|
27300
|
-
var cloneEntity = this._createCloneEntity();
|
|
27301
|
-
this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
|
|
27302
|
-
return cloneEntity;
|
|
27303
|
-
};
|
|
27304
|
-
/**
|
|
27305
|
-
* Listen for changes in the world pose of this `Entity`.
|
|
27306
|
-
* @returns Change flag
|
|
27307
|
-
*/ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
|
|
27308
|
-
return this._updateFlagManager.createFlag(BoolUpdateFlag);
|
|
27309
27387
|
};
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
27313
|
-
this._isTemplate = true;
|
|
27314
|
-
this._templateResource = templateResource;
|
|
27388
|
+
_proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
|
|
27389
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
27315
27390
|
};
|
|
27316
|
-
_proto.
|
|
27317
|
-
|
|
27318
|
-
|
|
27319
|
-
|
|
27320
|
-
|
|
27321
|
-
|
|
27322
|
-
|
|
27323
|
-
|
|
27324
|
-
|
|
27325
|
-
|
|
27326
|
-
|
|
27327
|
-
|
|
27328
|
-
|
|
27329
|
-
|
|
27330
|
-
|
|
27331
|
-
}
|
|
27332
|
-
cloneEntity.layer = this.layer;
|
|
27333
|
-
cloneEntity._isActive = this._isActive;
|
|
27334
|
-
var srcChildren = this._children;
|
|
27335
|
-
for(var i1 = 0, n1 = srcChildren.length; i1 < n1; i1++){
|
|
27336
|
-
cloneEntity.addChild(srcChildren[i1]._createCloneEntity());
|
|
27391
|
+
_proto._onSkinUpdated = function _onSkinUpdated(type, value) {
|
|
27392
|
+
switch(type){
|
|
27393
|
+
case SkinUpdateFlag.BoneCountChanged:
|
|
27394
|
+
var shaderData = this.shaderData;
|
|
27395
|
+
if (value > 0) {
|
|
27396
|
+
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
27397
|
+
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
|
|
27398
|
+
} else {
|
|
27399
|
+
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
27400
|
+
}
|
|
27401
|
+
break;
|
|
27402
|
+
case SkinUpdateFlag.RootBoneChanged:
|
|
27403
|
+
this._setTransformEntity(value);
|
|
27404
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
27405
|
+
break;
|
|
27337
27406
|
}
|
|
27338
|
-
return cloneEntity;
|
|
27339
27407
|
};
|
|
27340
|
-
_proto.
|
|
27341
|
-
var
|
|
27342
|
-
var
|
|
27343
|
-
|
|
27344
|
-
|
|
27408
|
+
_proto._applySkin = function _applySkin(lastSkin, value) {
|
|
27409
|
+
var _lastSkin_bones, _value_bones;
|
|
27410
|
+
var _lastSkin_bones_length;
|
|
27411
|
+
var lastSkinBoneCount = (_lastSkin_bones_length = lastSkin == null ? void 0 : (_lastSkin_bones = lastSkin.bones) == null ? void 0 : _lastSkin_bones.length) != null ? _lastSkin_bones_length : 0;
|
|
27412
|
+
var _lastSkin_rootBone;
|
|
27413
|
+
var lastRootBone = (_lastSkin_rootBone = lastSkin == null ? void 0 : lastSkin.rootBone) != null ? _lastSkin_rootBone : this.entity;
|
|
27414
|
+
lastSkin == null ? void 0 : lastSkin._updatedManager.removeListener(this._onSkinUpdated);
|
|
27415
|
+
var _value_bones_length;
|
|
27416
|
+
var skinBoneCount = (_value_bones_length = value == null ? void 0 : (_value_bones = value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
|
|
27417
|
+
var _value_rootBone;
|
|
27418
|
+
var rootBone = (_value_rootBone = value == null ? void 0 : value.rootBone) != null ? _value_rootBone : this.entity;
|
|
27419
|
+
value == null ? void 0 : value._updatedManager.addListener(this._onSkinUpdated);
|
|
27420
|
+
if (lastSkinBoneCount !== skinBoneCount) {
|
|
27421
|
+
this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
|
|
27345
27422
|
}
|
|
27346
|
-
|
|
27347
|
-
|
|
27348
|
-
ComponentCloner.cloneComponent(components[i1], target._components[i1], srcRoot, targetRoot, deepInstanceMap);
|
|
27423
|
+
if (lastRootBone !== rootBone) {
|
|
27424
|
+
this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
|
|
27349
27425
|
}
|
|
27350
27426
|
};
|
|
27351
|
-
|
|
27352
|
-
|
|
27427
|
+
_create_class$2(SkinnedMeshRenderer, [
|
|
27428
|
+
{
|
|
27429
|
+
key: "skin",
|
|
27430
|
+
get: /**
|
|
27431
|
+
* Skin of the SkinnedMeshRenderer.
|
|
27432
|
+
*/ function get() {
|
|
27433
|
+
return this._skin;
|
|
27434
|
+
},
|
|
27435
|
+
set: function set(value) {
|
|
27436
|
+
var lastSkin = this._skin;
|
|
27437
|
+
if (lastSkin !== value) {
|
|
27438
|
+
this._applySkin(lastSkin, value);
|
|
27439
|
+
this._skin = value;
|
|
27440
|
+
}
|
|
27441
|
+
}
|
|
27442
|
+
},
|
|
27443
|
+
{
|
|
27444
|
+
key: "blendShapeWeights",
|
|
27445
|
+
get: /**
|
|
27446
|
+
* The weights of the BlendShapes.
|
|
27447
|
+
* @remarks Array index is BlendShape index.
|
|
27448
|
+
*/ function get() {
|
|
27449
|
+
this._checkBlendShapeWeightLength();
|
|
27450
|
+
return this._blendShapeWeights;
|
|
27451
|
+
},
|
|
27452
|
+
set: function set(value) {
|
|
27453
|
+
this._checkBlendShapeWeightLength();
|
|
27454
|
+
var blendShapeWeights = this._blendShapeWeights;
|
|
27455
|
+
if (value.length <= blendShapeWeights.length) {
|
|
27456
|
+
blendShapeWeights.set(value);
|
|
27457
|
+
} else {
|
|
27458
|
+
for(var i = 0, n = blendShapeWeights.length; i < n; i++){
|
|
27459
|
+
blendShapeWeights[i] = value[i];
|
|
27460
|
+
}
|
|
27461
|
+
}
|
|
27462
|
+
}
|
|
27463
|
+
},
|
|
27464
|
+
{
|
|
27465
|
+
key: "localBounds",
|
|
27466
|
+
get: /**
|
|
27467
|
+
* Local bounds.
|
|
27468
|
+
*/ function get() {
|
|
27469
|
+
return this._localBounds;
|
|
27470
|
+
},
|
|
27471
|
+
set: function set(value) {
|
|
27472
|
+
if (this._localBounds !== value) {
|
|
27473
|
+
this._localBounds.copyFrom(value);
|
|
27474
|
+
}
|
|
27475
|
+
}
|
|
27476
|
+
},
|
|
27477
|
+
{
|
|
27478
|
+
key: "rootBone",
|
|
27479
|
+
get: /**
|
|
27480
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.rootBone} instead.
|
|
27481
|
+
*/ function get() {
|
|
27482
|
+
return this.skin.rootBone;
|
|
27483
|
+
},
|
|
27484
|
+
set: function set(value) {
|
|
27485
|
+
this.skin.rootBone = value;
|
|
27486
|
+
}
|
|
27487
|
+
},
|
|
27488
|
+
{
|
|
27489
|
+
key: "bones",
|
|
27490
|
+
get: /**
|
|
27491
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.bones} instead.
|
|
27492
|
+
*/ function get() {
|
|
27493
|
+
return this.skin.bones;
|
|
27494
|
+
},
|
|
27495
|
+
set: function set(value) {
|
|
27496
|
+
this.skin.bones = value;
|
|
27497
|
+
}
|
|
27498
|
+
}
|
|
27499
|
+
]);
|
|
27500
|
+
return SkinnedMeshRenderer;
|
|
27501
|
+
}(MeshRenderer);
|
|
27502
|
+
// @TODO: different shader type should use different count, not always 48
|
|
27503
|
+
/** @internal */ SkinnedMeshRenderer._baseVertexUniformVectorCount = 48;
|
|
27504
|
+
SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
|
|
27505
|
+
SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
|
|
27506
|
+
SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
|
|
27507
|
+
__decorate$1([
|
|
27508
|
+
ignoreClone
|
|
27509
|
+
], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
|
|
27510
|
+
__decorate$1([
|
|
27511
|
+
deepClone
|
|
27512
|
+
], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
|
|
27513
|
+
__decorate$1([
|
|
27514
|
+
ignoreClone
|
|
27515
|
+
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
27516
|
+
__decorate$1([
|
|
27517
|
+
ignoreClone
|
|
27518
|
+
], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
|
|
27519
|
+
__decorate$1([
|
|
27520
|
+
ignoreClone
|
|
27521
|
+
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
27522
|
+
__decorate$1([
|
|
27523
|
+
ignoreClone
|
|
27524
|
+
], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
|
|
27525
|
+
__decorate$1([
|
|
27526
|
+
deepClone
|
|
27527
|
+
], SkinnedMeshRenderer.prototype, "_skin", void 0);
|
|
27528
|
+
__decorate$1([
|
|
27529
|
+
ignoreClone
|
|
27530
|
+
], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
|
|
27531
|
+
__decorate$1([
|
|
27532
|
+
ignoreClone
|
|
27533
|
+
], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
|
|
27534
|
+
/**
|
|
27535
|
+
* @internal
|
|
27536
|
+
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
27537
|
+
function BasicResources(engine) {
|
|
27538
|
+
this.engine = engine;
|
|
27539
|
+
// prettier-ignore
|
|
27540
|
+
var vertices = new Float32Array([
|
|
27541
|
+
-1,
|
|
27542
|
+
-1,
|
|
27543
|
+
0,
|
|
27544
|
+
1,
|
|
27545
|
+
3,
|
|
27546
|
+
-1,
|
|
27547
|
+
2,
|
|
27548
|
+
1,
|
|
27549
|
+
-1,
|
|
27550
|
+
3,
|
|
27551
|
+
0,
|
|
27552
|
+
-1
|
|
27553
|
+
]); // left-top
|
|
27554
|
+
// prettier-ignore
|
|
27555
|
+
var flipYVertices = new Float32Array([
|
|
27556
|
+
3,
|
|
27557
|
+
-1,
|
|
27558
|
+
2,
|
|
27559
|
+
0,
|
|
27560
|
+
-1,
|
|
27561
|
+
-1,
|
|
27562
|
+
0,
|
|
27563
|
+
0,
|
|
27564
|
+
-1,
|
|
27565
|
+
3,
|
|
27566
|
+
0,
|
|
27567
|
+
2
|
|
27568
|
+
]); // left-top
|
|
27569
|
+
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
27570
|
+
blitMaterial._addReferCount(1);
|
|
27571
|
+
blitMaterial.renderState.depthState.enabled = false;
|
|
27572
|
+
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
27573
|
+
var blitScreenMaterial = new Material(engine, Shader.find("blit-screen"));
|
|
27574
|
+
blitScreenMaterial._addReferCount(1);
|
|
27575
|
+
blitScreenMaterial.renderState.depthState.enabled = false;
|
|
27576
|
+
blitScreenMaterial.renderState.depthState.writeEnabled = false;
|
|
27577
|
+
this.blitMaterial = blitMaterial;
|
|
27578
|
+
this.blitScreenMaterial = blitScreenMaterial;
|
|
27579
|
+
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
27580
|
+
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
27581
|
+
// Create white and magenta textures
|
|
27582
|
+
var whitePixel = new Uint8Array([
|
|
27583
|
+
255,
|
|
27584
|
+
255,
|
|
27585
|
+
255,
|
|
27586
|
+
255
|
|
27587
|
+
]);
|
|
27588
|
+
this.whiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
27589
|
+
this.whiteTextureCube = this._create1x1Texture(engine, 1, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
27590
|
+
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
27591
|
+
if (isWebGL2) {
|
|
27592
|
+
this.whiteTexture2DArray = this._create1x1Texture(engine, 2, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
27593
|
+
var whitePixel32 = new Uint32Array([
|
|
27594
|
+
255,
|
|
27595
|
+
255,
|
|
27596
|
+
255,
|
|
27597
|
+
255
|
|
27598
|
+
]);
|
|
27599
|
+
this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
|
|
27600
|
+
}
|
|
27601
|
+
this.spriteDefaultMaterial = this._create2DMaterial(engine, Shader.find("Sprite"));
|
|
27602
|
+
this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
|
|
27603
|
+
this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
|
|
27604
|
+
this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
|
|
27605
|
+
this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
|
|
27606
|
+
}
|
|
27607
|
+
var _proto = BasicResources.prototype;
|
|
27608
|
+
/**
|
|
27609
|
+
* @internal
|
|
27610
|
+
*/ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
|
|
27611
|
+
return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
|
|
27612
|
+
};
|
|
27613
|
+
/**
|
|
27614
|
+
* @internal
|
|
27615
|
+
*/ _proto._initialize = function _initialize() {
|
|
27616
|
+
var _this = this;
|
|
27617
|
+
return new Promise(function(resolve, reject) {
|
|
27618
|
+
PrefilteredDFG.create(_this.engine).then(function(texture) {
|
|
27619
|
+
_this._prefilteredDFGTexture = texture;
|
|
27620
|
+
resolve(_this);
|
|
27621
|
+
}).catch(reject);
|
|
27622
|
+
});
|
|
27623
|
+
};
|
|
27624
|
+
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
27625
|
+
var mesh = new ModelMesh(engine);
|
|
27626
|
+
mesh._addReferCount(1);
|
|
27627
|
+
mesh.setVertexElements([
|
|
27628
|
+
new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
|
|
27629
|
+
]);
|
|
27630
|
+
var buffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
|
|
27631
|
+
mesh.setVertexBufferBinding(buffer, 16);
|
|
27632
|
+
mesh.addSubMesh(0, 3, MeshTopology.Triangles);
|
|
27633
|
+
engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
|
|
27634
|
+
_inherits$2(_class, ContentRestorer);
|
|
27635
|
+
function _class() {
|
|
27636
|
+
return ContentRestorer.call(this, mesh) || this;
|
|
27637
|
+
}
|
|
27638
|
+
var _proto = _class.prototype;
|
|
27639
|
+
_proto.restoreContent = function restoreContent() {
|
|
27640
|
+
buffer.setData(buffer.data);
|
|
27641
|
+
};
|
|
27642
|
+
return _class;
|
|
27643
|
+
}(ContentRestorer))());
|
|
27644
|
+
return mesh;
|
|
27645
|
+
};
|
|
27646
|
+
_proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel, isSRGBColorSpace) {
|
|
27647
|
+
var texture;
|
|
27648
|
+
switch(type){
|
|
27649
|
+
case 0:
|
|
27650
|
+
var texture2D = new Texture2D(engine, 1, 1, format, false, isSRGBColorSpace);
|
|
27651
|
+
texture2D.setPixelBuffer(pixel);
|
|
27652
|
+
texture = texture2D;
|
|
27653
|
+
break;
|
|
27654
|
+
case 2:
|
|
27655
|
+
var texture2DArray = new Texture2DArray(engine, 1, 1, 1, format, false, isSRGBColorSpace);
|
|
27656
|
+
texture2DArray.setPixelBuffer(0, pixel);
|
|
27657
|
+
texture = texture2DArray;
|
|
27658
|
+
break;
|
|
27659
|
+
case 1:
|
|
27660
|
+
var textureCube = new TextureCube(engine, 1, format, false, isSRGBColorSpace);
|
|
27661
|
+
for(var i = 0; i < 6; i++){
|
|
27662
|
+
textureCube.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
27663
|
+
}
|
|
27664
|
+
texture = textureCube;
|
|
27665
|
+
break;
|
|
27666
|
+
default:
|
|
27667
|
+
throw "Invalid texture type";
|
|
27668
|
+
}
|
|
27669
|
+
texture.isGCIgnored = true;
|
|
27670
|
+
engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
|
|
27671
|
+
_inherits$2(_class, ContentRestorer);
|
|
27672
|
+
function _class() {
|
|
27673
|
+
return ContentRestorer.call(this, texture) || this;
|
|
27674
|
+
}
|
|
27675
|
+
var _proto = _class.prototype;
|
|
27676
|
+
_proto.restoreContent = function restoreContent() {
|
|
27677
|
+
switch(type){
|
|
27678
|
+
case 0:
|
|
27679
|
+
this.resource.setPixelBuffer(pixel);
|
|
27680
|
+
break;
|
|
27681
|
+
case 2:
|
|
27682
|
+
this.resource.setPixelBuffer(0, pixel);
|
|
27683
|
+
break;
|
|
27684
|
+
case 1:
|
|
27685
|
+
for(var i = 0; i < 6; i++){
|
|
27686
|
+
this.resource.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
27687
|
+
}
|
|
27688
|
+
break;
|
|
27689
|
+
}
|
|
27690
|
+
};
|
|
27691
|
+
return _class;
|
|
27692
|
+
}(ContentRestorer))());
|
|
27693
|
+
return texture;
|
|
27694
|
+
};
|
|
27695
|
+
_proto._create2DMaterial = function _create2DMaterial(engine, shader) {
|
|
27696
|
+
var material = new Material(engine, shader);
|
|
27697
|
+
var renderState = material.renderState;
|
|
27698
|
+
var target = renderState.blendState.targetBlendState;
|
|
27699
|
+
target.enabled = true;
|
|
27700
|
+
target.sourceColorBlendFactor = BlendFactor.SourceAlpha;
|
|
27701
|
+
target.destinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
27702
|
+
target.sourceAlphaBlendFactor = BlendFactor.One;
|
|
27703
|
+
target.destinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
27704
|
+
target.colorBlendOperation = target.alphaBlendOperation = BlendOperation.Add;
|
|
27705
|
+
renderState.depthState.writeEnabled = false;
|
|
27706
|
+
renderState.rasterState.cullMode = CullMode.Off;
|
|
27707
|
+
renderState.renderQueueType = RenderQueueType.Transparent;
|
|
27708
|
+
material.isGCIgnored = true;
|
|
27709
|
+
return material;
|
|
27710
|
+
};
|
|
27711
|
+
_proto._createMagentaMaterial = function _createMagentaMaterial(engine, shaderName) {
|
|
27712
|
+
var material = new Material(engine, Shader.find(shaderName));
|
|
27713
|
+
material.isGCIgnored = true;
|
|
27714
|
+
material.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
27715
|
+
return material;
|
|
27716
|
+
};
|
|
27717
|
+
_proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
|
|
27718
|
+
var material = new Material(engine, Shader.find("SpriteMask"));
|
|
27719
|
+
material.isGCIgnored = true;
|
|
27720
|
+
return material;
|
|
27721
|
+
};
|
|
27722
|
+
BasicResources.getMaskInteractionRenderStates = function getMaskInteractionRenderStates(maskInteraction) {
|
|
27723
|
+
var visibleInsideMask = maskInteraction === SpriteMaskInteraction.VisibleInsideMask;
|
|
27724
|
+
var renderStates;
|
|
27725
|
+
var compareFunction;
|
|
27726
|
+
if (visibleInsideMask) {
|
|
27727
|
+
renderStates = BasicResources._maskReadInsideRenderStates;
|
|
27728
|
+
if (renderStates) {
|
|
27729
|
+
return renderStates;
|
|
27730
|
+
}
|
|
27731
|
+
BasicResources._maskReadInsideRenderStates = renderStates = {};
|
|
27732
|
+
compareFunction = CompareFunction.LessEqual;
|
|
27733
|
+
} else {
|
|
27734
|
+
renderStates = BasicResources._maskReadOutsideRenderStates;
|
|
27735
|
+
if (renderStates) {
|
|
27736
|
+
return renderStates;
|
|
27737
|
+
}
|
|
27738
|
+
BasicResources._maskReadOutsideRenderStates = renderStates = {};
|
|
27739
|
+
compareFunction = CompareFunction.Greater;
|
|
27740
|
+
}
|
|
27741
|
+
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
27742
|
+
renderStates[RenderStateElementKey.StencilStateWriteMask] = 0x00;
|
|
27743
|
+
renderStates[RenderStateElementKey.StencilStateReferenceValue] = 1;
|
|
27744
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = compareFunction;
|
|
27745
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = compareFunction;
|
|
27746
|
+
return renderStates;
|
|
27747
|
+
};
|
|
27748
|
+
BasicResources.getMaskTypeRenderStates = function getMaskTypeRenderStates(maskType) {
|
|
27749
|
+
var isIncrement = maskType === RenderQueueMaskType.Increment;
|
|
27750
|
+
var renderStates;
|
|
27751
|
+
var passOperation;
|
|
27752
|
+
if (isIncrement) {
|
|
27753
|
+
renderStates = BasicResources._maskWriteIncrementRenderStates;
|
|
27754
|
+
if (renderStates) {
|
|
27755
|
+
return renderStates;
|
|
27756
|
+
}
|
|
27757
|
+
BasicResources._maskWriteIncrementRenderStates = renderStates = {};
|
|
27758
|
+
passOperation = StencilOperation.IncrementSaturate;
|
|
27759
|
+
} else {
|
|
27760
|
+
renderStates = BasicResources._maskWriteDecrementRenderStates;
|
|
27761
|
+
if (renderStates) {
|
|
27762
|
+
return renderStates;
|
|
27763
|
+
}
|
|
27764
|
+
BasicResources._maskWriteDecrementRenderStates = renderStates = {};
|
|
27765
|
+
passOperation = StencilOperation.DecrementSaturate;
|
|
27766
|
+
}
|
|
27767
|
+
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
27768
|
+
renderStates[RenderStateElementKey.StencilStatePassOperationFront] = passOperation;
|
|
27769
|
+
renderStates[RenderStateElementKey.StencilStatePassOperationBack] = passOperation;
|
|
27770
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = CompareFunction.Always;
|
|
27771
|
+
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = CompareFunction.Always;
|
|
27772
|
+
var failStencilOperation = StencilOperation.Keep;
|
|
27773
|
+
renderStates[RenderStateElementKey.StencilStateFailOperationFront] = failStencilOperation;
|
|
27774
|
+
renderStates[RenderStateElementKey.StencilStateFailOperationBack] = failStencilOperation;
|
|
27775
|
+
renderStates[RenderStateElementKey.StencilStateZFailOperationFront] = failStencilOperation;
|
|
27776
|
+
renderStates[RenderStateElementKey.StencilStateZFailOperationBack] = failStencilOperation;
|
|
27777
|
+
renderStates[RenderStateElementKey.BlendStateColorWriteMask0] = ColorWriteMask.None;
|
|
27778
|
+
renderStates[RenderStateElementKey.DepthStateEnabled] = false;
|
|
27779
|
+
renderStates[RenderStateElementKey.RasterStateCullMode] = CullMode.Off;
|
|
27780
|
+
return renderStates;
|
|
27781
|
+
};
|
|
27782
|
+
_create_class$2(BasicResources, [
|
|
27783
|
+
{
|
|
27784
|
+
key: "prefilteredDFGTexture",
|
|
27785
|
+
get: function get() {
|
|
27786
|
+
return this._prefilteredDFGTexture;
|
|
27787
|
+
}
|
|
27788
|
+
}
|
|
27789
|
+
]);
|
|
27790
|
+
return BasicResources;
|
|
27791
|
+
}();
|
|
27792
|
+
BasicResources._maskReadInsideRenderStates = null;
|
|
27793
|
+
BasicResources._maskReadOutsideRenderStates = null;
|
|
27794
|
+
BasicResources._maskWriteIncrementRenderStates = null;
|
|
27795
|
+
BasicResources._maskWriteDecrementRenderStates = null;
|
|
27796
|
+
function _is_native_reflect_construct$1() {
|
|
27797
|
+
// Since Reflect.construct can't be properly polyfilled, some
|
|
27798
|
+
// implementations (e.g. core-js@2) don't set the correct internal slots.
|
|
27799
|
+
// Those polyfills don't allow us to subclass built-ins, so we need to
|
|
27800
|
+
// use our fallback implementation.
|
|
27801
|
+
try {
|
|
27802
|
+
// If the internal slots aren't set, this throws an error similar to
|
|
27803
|
+
// TypeError: this is not a Boolean object.
|
|
27804
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
27805
|
+
} catch (_) {}
|
|
27806
|
+
return (_is_native_reflect_construct$1 = function _is_native_reflect_construct() {
|
|
27807
|
+
return !!result;
|
|
27808
|
+
})();
|
|
27809
|
+
}
|
|
27810
|
+
function _construct$1(Parent, args, Class) {
|
|
27811
|
+
if (_is_native_reflect_construct$1()) _construct$1 = Reflect.construct;
|
|
27812
|
+
else {
|
|
27813
|
+
_construct$1 = function construct(Parent, args, Class) {
|
|
27814
|
+
var a = [
|
|
27815
|
+
null
|
|
27816
|
+
];
|
|
27817
|
+
a.push.apply(a, args);
|
|
27818
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
27819
|
+
var instance = new Constructor();
|
|
27820
|
+
if (Class) _set_prototype_of$2(instance, Class.prototype);
|
|
27821
|
+
return instance;
|
|
27822
|
+
};
|
|
27823
|
+
}
|
|
27824
|
+
return _construct$1.apply(null, arguments);
|
|
27825
|
+
}
|
|
27826
|
+
var ComponentCloner = /*#__PURE__*/ function() {
|
|
27827
|
+
function ComponentCloner() {}
|
|
27828
|
+
/**
|
|
27829
|
+
* Clone component.
|
|
27830
|
+
* @param source - Clone source
|
|
27831
|
+
* @param target - Clone target
|
|
27832
|
+
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
27833
|
+
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
27834
|
+
for(var k in source){
|
|
27835
|
+
CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
|
|
27836
|
+
}
|
|
27837
|
+
if (source._cloneTo) {
|
|
27838
|
+
source._cloneTo(target, srcRoot, targetRoot);
|
|
27839
|
+
}
|
|
27840
|
+
};
|
|
27841
|
+
return ComponentCloner;
|
|
27842
|
+
}();
|
|
27843
|
+
/**
|
|
27844
|
+
* The entity modify flags.
|
|
27845
|
+
*/ var EntityModifyFlags = /*#__PURE__*/ function(EntityModifyFlags) {
|
|
27846
|
+
/** The parent changes. */ EntityModifyFlags[EntityModifyFlags["Parent"] = 1] = "Parent";
|
|
27847
|
+
/** The child changes. */ EntityModifyFlags[EntityModifyFlags["Child"] = 2] = "Child";
|
|
27848
|
+
return EntityModifyFlags;
|
|
27849
|
+
}({});
|
|
27850
|
+
/**
|
|
27851
|
+
* Entity, be used as components container.
|
|
27852
|
+
*/ var Entity = /*#__PURE__*/ function(EngineObject) {
|
|
27853
|
+
_inherits$2(Entity, EngineObject);
|
|
27854
|
+
function Entity(engine, name) {
|
|
27855
|
+
for(var _len = arguments.length, components = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
27856
|
+
components[_key - 2] = arguments[_key];
|
|
27857
|
+
}
|
|
27858
|
+
var _this;
|
|
27859
|
+
_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, _this._invModelMatrix = new Matrix();
|
|
27860
|
+
_this.name = name != null ? name : "Entity";
|
|
27861
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
27862
|
+
_this.addComponent(components[i]);
|
|
27863
|
+
}
|
|
27864
|
+
!_this._transform && _this.addComponent(Transform);
|
|
27865
|
+
_this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
|
|
27866
|
+
return _this;
|
|
27867
|
+
}
|
|
27868
|
+
var _proto = Entity.prototype;
|
|
27869
|
+
/**
|
|
27870
|
+
* Add component based on the component type.
|
|
27871
|
+
* @param type - The type of the component
|
|
27872
|
+
* @param args - The arguments of the component
|
|
27873
|
+
* @returns The component which has been added
|
|
27874
|
+
*/ _proto.addComponent = function addComponent(type) {
|
|
27875
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
27876
|
+
args[_key - 1] = arguments[_key];
|
|
27877
|
+
}
|
|
27878
|
+
ComponentsDependencies._addCheck(this, type);
|
|
27879
|
+
var component = _construct$1(type, [].concat([
|
|
27880
|
+
this
|
|
27881
|
+
], args));
|
|
27882
|
+
this._components.push(component);
|
|
27883
|
+
// @todo: temporary solution
|
|
27884
|
+
if (_instanceof1$2(component, Transform)) this._setTransform(component);
|
|
27885
|
+
component._setActive(true, ActiveChangeFlag.All);
|
|
27886
|
+
return component;
|
|
27887
|
+
};
|
|
27888
|
+
/**
|
|
27889
|
+
* Get component which match the type.
|
|
27890
|
+
* @param type - The type of the component
|
|
27891
|
+
* @returns The first component which match type
|
|
27892
|
+
*/ _proto.getComponent = function getComponent(type) {
|
|
27893
|
+
var components = this._components;
|
|
27894
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
27895
|
+
var component = components[i];
|
|
27896
|
+
if (_instanceof1$2(component, type)) {
|
|
27897
|
+
return component;
|
|
27898
|
+
}
|
|
27899
|
+
}
|
|
27900
|
+
return null;
|
|
27901
|
+
};
|
|
27902
|
+
/**
|
|
27903
|
+
* Get components which match the type.
|
|
27904
|
+
* @param type - The type of the component
|
|
27905
|
+
* @param results - The components which match type
|
|
27906
|
+
* @returns The components which match type
|
|
27907
|
+
*/ _proto.getComponents = function getComponents(type, results) {
|
|
27908
|
+
results.length = 0;
|
|
27909
|
+
var components = this._components;
|
|
27910
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
27911
|
+
var component = components[i];
|
|
27912
|
+
if (_instanceof1$2(component, type)) {
|
|
27913
|
+
results.push(component);
|
|
27914
|
+
}
|
|
27915
|
+
}
|
|
27916
|
+
return results;
|
|
27917
|
+
};
|
|
27918
|
+
/**
|
|
27919
|
+
* Get the components which match the type of the entity and it's children.
|
|
27920
|
+
* @param type - The component type
|
|
27921
|
+
* @param results - The components collection
|
|
27922
|
+
* @returns The components collection which match the type
|
|
27923
|
+
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
27924
|
+
results.length = 0;
|
|
27925
|
+
this._getComponentsInChildren(type, results);
|
|
27926
|
+
return results;
|
|
27927
|
+
};
|
|
27928
|
+
_proto.addChild = function addChild(indexOrChild, child) {
|
|
27929
|
+
var index;
|
|
27930
|
+
if (typeof indexOrChild === "number") {
|
|
27931
|
+
index = indexOrChild;
|
|
27932
|
+
} else {
|
|
27933
|
+
index = undefined;
|
|
27934
|
+
child = indexOrChild;
|
|
27935
|
+
}
|
|
27936
|
+
child._setParent(this, index);
|
|
27937
|
+
};
|
|
27938
|
+
/**
|
|
27939
|
+
* Remove child entity.
|
|
27940
|
+
* @param child - The child entity which want to be removed
|
|
27941
|
+
*/ _proto.removeChild = function removeChild(child) {
|
|
27942
|
+
if (child._parent !== this) return;
|
|
27943
|
+
child._setParent(null);
|
|
27944
|
+
};
|
|
27945
|
+
/**
|
|
27946
|
+
* @deprecated Please use `children` property instead.
|
|
27947
|
+
* Find child entity by index.
|
|
27948
|
+
* @param index - The index of the child entity
|
|
27949
|
+
* @returns The component which be found
|
|
27950
|
+
*/ _proto.getChild = function getChild(index) {
|
|
27951
|
+
return this._children[index];
|
|
27952
|
+
};
|
|
27953
|
+
/**
|
|
27954
|
+
* Find entity by name.
|
|
27955
|
+
* @param name - The name of the entity which want to be found
|
|
27956
|
+
* @returns The component which be found
|
|
27957
|
+
*/ _proto.findByName = function findByName(name) {
|
|
27958
|
+
if (name === this.name) {
|
|
27959
|
+
return this;
|
|
27960
|
+
}
|
|
27961
|
+
var children = this._children;
|
|
27962
|
+
for(var i = 0, n = children.length; i < n; i++){
|
|
27963
|
+
var target = children[i].findByName(name);
|
|
27964
|
+
if (target) {
|
|
27965
|
+
return target;
|
|
27966
|
+
}
|
|
27967
|
+
}
|
|
27968
|
+
return null;
|
|
27969
|
+
};
|
|
27970
|
+
/**
|
|
27971
|
+
* Find the entity by path.
|
|
27972
|
+
* @param path - The path of the entity eg: /entity
|
|
27973
|
+
* @returns The component which be found
|
|
27974
|
+
*/ _proto.findByPath = function findByPath(path) {
|
|
27975
|
+
var splits = path.split("/").filter(Boolean);
|
|
27976
|
+
if (!splits.length) {
|
|
27977
|
+
return this;
|
|
27978
|
+
}
|
|
27979
|
+
return Entity._findChildByName(this, 0, splits, 0);
|
|
27980
|
+
};
|
|
27981
|
+
/**
|
|
27982
|
+
* Create child entity.
|
|
27983
|
+
* @param name - The child entity's name
|
|
27984
|
+
* @returns The child entity
|
|
27985
|
+
*/ _proto.createChild = function createChild(name) {
|
|
27986
|
+
var transform = this._transform;
|
|
27987
|
+
var child = transform ? new Entity(this.engine, name, transform.constructor) : new Entity(this.engine, name);
|
|
27988
|
+
child.layer = this.layer;
|
|
27989
|
+
child.parent = this;
|
|
27990
|
+
return child;
|
|
27991
|
+
};
|
|
27992
|
+
/**
|
|
27993
|
+
* Clear children entities.
|
|
27994
|
+
*/ _proto.clearChildren = function clearChildren() {
|
|
27995
|
+
var children = this._children;
|
|
27996
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
27997
|
+
var child = children[i];
|
|
27998
|
+
child._parent = null;
|
|
27999
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
28000
|
+
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
28001
|
+
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
28002
|
+
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
28003
|
+
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
28004
|
+
}
|
|
28005
|
+
children.length = 0;
|
|
28006
|
+
};
|
|
28007
|
+
/**
|
|
28008
|
+
* Clone this entity include children and components.
|
|
28009
|
+
* @returns Cloned entity
|
|
28010
|
+
*/ _proto.clone = function clone() {
|
|
28011
|
+
var cloneEntity = this._createCloneEntity();
|
|
28012
|
+
this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
|
|
28013
|
+
return cloneEntity;
|
|
28014
|
+
};
|
|
28015
|
+
/**
|
|
28016
|
+
* Listen for changes in the world pose of this `Entity`.
|
|
28017
|
+
* @returns Change flag
|
|
28018
|
+
*/ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
|
|
28019
|
+
return this._updateFlagManager.createFlag(BoolUpdateFlag);
|
|
28020
|
+
};
|
|
28021
|
+
/**
|
|
28022
|
+
* @internal
|
|
28023
|
+
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
28024
|
+
this._isTemplate = true;
|
|
28025
|
+
this._templateResource = templateResource;
|
|
28026
|
+
};
|
|
28027
|
+
_proto._createCloneEntity = function _createCloneEntity() {
|
|
28028
|
+
var componentConstructors = Entity._tempComponentConstructors;
|
|
28029
|
+
var components = this._components;
|
|
28030
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
28031
|
+
componentConstructors[i] = components[i].constructor;
|
|
28032
|
+
}
|
|
28033
|
+
var cloneEntity = _construct$1(Entity, [].concat([
|
|
28034
|
+
this.engine,
|
|
28035
|
+
this.name
|
|
28036
|
+
], componentConstructors));
|
|
28037
|
+
componentConstructors.length = 0;
|
|
28038
|
+
var templateResource = this._templateResource;
|
|
28039
|
+
if (templateResource) {
|
|
28040
|
+
cloneEntity._templateResource = templateResource;
|
|
28041
|
+
templateResource._addReferCount(1);
|
|
28042
|
+
}
|
|
28043
|
+
cloneEntity.layer = this.layer;
|
|
28044
|
+
cloneEntity._isActive = this._isActive;
|
|
28045
|
+
var srcChildren = this._children;
|
|
28046
|
+
for(var i1 = 0, n1 = srcChildren.length; i1 < n1; i1++){
|
|
28047
|
+
cloneEntity.addChild(srcChildren[i1]._createCloneEntity());
|
|
28048
|
+
}
|
|
28049
|
+
return cloneEntity;
|
|
28050
|
+
};
|
|
28051
|
+
_proto._parseCloneEntity = function _parseCloneEntity(src, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
28052
|
+
var srcChildren = src._children;
|
|
28053
|
+
var targetChildren = target._children;
|
|
28054
|
+
for(var i = 0, n = srcChildren.length; i < n; i++){
|
|
28055
|
+
this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot, deepInstanceMap);
|
|
28056
|
+
}
|
|
28057
|
+
var components = src._components;
|
|
28058
|
+
for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
|
|
28059
|
+
ComponentCloner.cloneComponent(components[i1], target._components[i1], srcRoot, targetRoot, deepInstanceMap);
|
|
28060
|
+
}
|
|
28061
|
+
};
|
|
28062
|
+
/**
|
|
28063
|
+
* Destroy self.
|
|
27353
28064
|
*/ _proto.destroy = function destroy() {
|
|
27354
28065
|
EngineObject.prototype.destroy.call(this);
|
|
27355
28066
|
if (!this._destroyed) {
|
|
@@ -27620,29 +28331,6 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
27620
28331
|
};
|
|
27621
28332
|
/**
|
|
27622
28333
|
* @internal
|
|
27623
|
-
*/ Entity._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
|
|
27624
|
-
inversePath.length = 0;
|
|
27625
|
-
while(searchEntity !== rootEntity){
|
|
27626
|
-
var parent = searchEntity.parent;
|
|
27627
|
-
if (!parent) {
|
|
27628
|
-
return false;
|
|
27629
|
-
}
|
|
27630
|
-
inversePath.push(searchEntity.siblingIndex);
|
|
27631
|
-
searchEntity = parent;
|
|
27632
|
-
}
|
|
27633
|
-
return true;
|
|
27634
|
-
};
|
|
27635
|
-
/**
|
|
27636
|
-
* @internal
|
|
27637
|
-
*/ Entity._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
|
|
27638
|
-
var entity = rootEntity;
|
|
27639
|
-
for(var i = inversePath.length - 1; i >= 0; i--){
|
|
27640
|
-
entity = entity.children[inversePath[i]];
|
|
27641
|
-
}
|
|
27642
|
-
return entity;
|
|
27643
|
-
};
|
|
27644
|
-
/**
|
|
27645
|
-
* @internal
|
|
27646
28334
|
*/ Entity._removeFromChildren = function _removeFromChildren(children, entity) {
|
|
27647
28335
|
var count = children.length - 1;
|
|
27648
28336
|
for(var i = entity._siblingIndex; i < count; i++){
|
|
@@ -27652,799 +28340,134 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
27652
28340
|
}
|
|
27653
28341
|
children.length = count;
|
|
27654
28342
|
entity._siblingIndex = -1;
|
|
27655
|
-
};
|
|
27656
|
-
/**
|
|
27657
|
-
* @internal
|
|
27658
|
-
*/ Entity._addToChildren = function _addToChildren(children, entity, index) {
|
|
27659
|
-
var childCount = children.length;
|
|
27660
|
-
children.length = childCount + 1;
|
|
27661
|
-
if (index === undefined) {
|
|
27662
|
-
children[childCount] = entity;
|
|
27663
|
-
entity._siblingIndex = childCount;
|
|
27664
|
-
} else {
|
|
27665
|
-
if (index < 0 || index > childCount) {
|
|
27666
|
-
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
27667
|
-
}
|
|
27668
|
-
for(var i = childCount; i > index; i--){
|
|
27669
|
-
var swapChild = children[i - 1];
|
|
27670
|
-
swapChild._siblingIndex = i;
|
|
27671
|
-
children[i] = swapChild;
|
|
27672
|
-
}
|
|
27673
|
-
entity._siblingIndex = index;
|
|
27674
|
-
children[index] = entity;
|
|
27675
|
-
}
|
|
27676
|
-
};
|
|
27677
|
-
_create_class$2(Entity, [
|
|
27678
|
-
{
|
|
27679
|
-
key: "transform",
|
|
27680
|
-
get: /**
|
|
27681
|
-
* The transform of this entity.
|
|
27682
|
-
*/ function get() {
|
|
27683
|
-
return this._transform;
|
|
27684
|
-
}
|
|
27685
|
-
},
|
|
27686
|
-
{
|
|
27687
|
-
key: "isActive",
|
|
27688
|
-
get: /**
|
|
27689
|
-
* Whether to activate locally.
|
|
27690
|
-
*/ function get() {
|
|
27691
|
-
return this._isActive;
|
|
27692
|
-
},
|
|
27693
|
-
set: function set(value) {
|
|
27694
|
-
if (value !== this._isActive) {
|
|
27695
|
-
this._isActive = value;
|
|
27696
|
-
if (value) {
|
|
27697
|
-
var parent = this._parent;
|
|
27698
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
27699
|
-
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
27700
|
-
activeChangeFlag |= ActiveChangeFlag.All;
|
|
27701
|
-
} else {
|
|
27702
|
-
(parent == null ? void 0 : parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
27703
|
-
(parent == null ? void 0 : parent._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
27704
|
-
}
|
|
27705
|
-
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
27706
|
-
} else {
|
|
27707
|
-
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
27708
|
-
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
27709
|
-
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
27710
|
-
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
27711
|
-
}
|
|
27712
|
-
}
|
|
27713
|
-
}
|
|
27714
|
-
},
|
|
27715
|
-
{
|
|
27716
|
-
key: "isActiveInHierarchy",
|
|
27717
|
-
get: /**
|
|
27718
|
-
* Whether it is active in the hierarchy.
|
|
27719
|
-
*/ function get() {
|
|
27720
|
-
return this._isActiveInHierarchy;
|
|
27721
|
-
}
|
|
27722
|
-
},
|
|
27723
|
-
{
|
|
27724
|
-
key: "parent",
|
|
27725
|
-
get: /**
|
|
27726
|
-
* The parent entity.
|
|
27727
|
-
*/ function get() {
|
|
27728
|
-
return this._parent;
|
|
27729
|
-
},
|
|
27730
|
-
set: function set(value) {
|
|
27731
|
-
this._setParent(value);
|
|
27732
|
-
}
|
|
27733
|
-
},
|
|
27734
|
-
{
|
|
27735
|
-
key: "children",
|
|
27736
|
-
get: /**
|
|
27737
|
-
* The children entities
|
|
27738
|
-
*/ function get() {
|
|
27739
|
-
return this._children;
|
|
27740
|
-
}
|
|
27741
|
-
},
|
|
27742
|
-
{
|
|
27743
|
-
key: "childCount",
|
|
27744
|
-
get: /**
|
|
27745
|
-
* @deprecated Please use `children.length` property instead.
|
|
27746
|
-
* Number of the children entities
|
|
27747
|
-
*/ function get() {
|
|
27748
|
-
return this._children.length;
|
|
27749
|
-
}
|
|
27750
|
-
},
|
|
27751
|
-
{
|
|
27752
|
-
key: "scene",
|
|
27753
|
-
get: /**
|
|
27754
|
-
* The scene the entity belongs to.
|
|
27755
|
-
*/ function get() {
|
|
27756
|
-
return this._scene;
|
|
27757
|
-
}
|
|
27758
|
-
},
|
|
27759
|
-
{
|
|
27760
|
-
key: "siblingIndex",
|
|
27761
|
-
get: /**
|
|
27762
|
-
* The sibling index.
|
|
27763
|
-
*/ function get() {
|
|
27764
|
-
return this._siblingIndex;
|
|
27765
|
-
},
|
|
27766
|
-
set: function set(value) {
|
|
27767
|
-
if (this._siblingIndex === -1) {
|
|
27768
|
-
throw "The entity " + this.name + " is not in the hierarchy";
|
|
27769
|
-
}
|
|
27770
|
-
if (this._isRoot) {
|
|
27771
|
-
this._setSiblingIndex(this._scene._rootEntities, value);
|
|
27772
|
-
} else {
|
|
27773
|
-
var parent = this._parent;
|
|
27774
|
-
this._setSiblingIndex(parent._children, value);
|
|
27775
|
-
parent._dispatchModify(EntityModifyFlags.Child, parent);
|
|
27776
|
-
}
|
|
27777
|
-
}
|
|
27778
|
-
}
|
|
27779
|
-
]);
|
|
27780
|
-
return Entity;
|
|
27781
|
-
}(EngineObject);
|
|
27782
|
-
/** @internal */ Entity._tempComponentConstructors = [];
|
|
27783
|
-
/**
|
|
27784
|
-
* Skin used for skinned mesh renderer.
|
|
27785
|
-
*/ var Skin = /*#__PURE__*/ function(EngineObject) {
|
|
27786
|
-
_inherits$2(Skin, EngineObject);
|
|
27787
|
-
function Skin(name) {
|
|
27788
|
-
var _this;
|
|
27789
|
-
_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 = [];
|
|
27790
|
-
return _this;
|
|
27791
|
-
}
|
|
27792
|
-
var _proto = Skin.prototype;
|
|
27793
|
-
/**
|
|
27794
|
-
* @internal
|
|
27795
|
-
*/ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
|
|
27796
|
-
if (this._updateMark === renderer.engine.time.frameCount) {
|
|
27797
|
-
return;
|
|
27798
|
-
}
|
|
27799
|
-
var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
|
|
27800
|
-
var _this_rootBone;
|
|
27801
|
-
var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
|
|
27802
|
-
for(var i = bones.length - 1; i >= 0; i--){
|
|
27803
|
-
var bone = bones[i];
|
|
27804
|
-
var offset = i * 16;
|
|
27805
|
-
if (bone) {
|
|
27806
|
-
Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
|
|
27807
|
-
} else {
|
|
27808
|
-
skinMatrices.set(bindMatrices[i].elements, offset);
|
|
27809
|
-
}
|
|
27810
|
-
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
27811
|
-
}
|
|
27812
|
-
this._updateMark = renderer.engine.time.frameCount;
|
|
27813
|
-
};
|
|
27814
|
-
/**
|
|
27815
|
-
* @internal
|
|
27816
|
-
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
27817
|
-
var paths = new Array();
|
|
27818
|
-
// Clone rootBone
|
|
27819
|
-
var rootBone = this.rootBone;
|
|
27820
|
-
if (rootBone) {
|
|
27821
|
-
var success = Entity._getEntityHierarchyPath(srcRoot, rootBone, paths);
|
|
27822
|
-
target.rootBone = success ? Entity._getEntityByHierarchyPath(targetRoot, paths) : rootBone;
|
|
27823
|
-
}
|
|
27824
|
-
// Clone bones
|
|
27825
|
-
var bones = this.bones;
|
|
27826
|
-
if (bones.length > 0) {
|
|
27827
|
-
var boneCount = bones.length;
|
|
27828
|
-
var destBones = new Array(boneCount);
|
|
27829
|
-
for(var i = 0; i < boneCount; i++){
|
|
27830
|
-
var bone = bones[i];
|
|
27831
|
-
var success1 = Entity._getEntityHierarchyPath(srcRoot, bone, paths);
|
|
27832
|
-
destBones[i] = success1 ? Entity._getEntityByHierarchyPath(targetRoot, paths) : bone;
|
|
27833
|
-
}
|
|
27834
|
-
target.bones = destBones;
|
|
27835
|
-
}
|
|
27836
|
-
};
|
|
27837
|
-
_create_class$2(Skin, [
|
|
27838
|
-
{
|
|
27839
|
-
key: "rootBone",
|
|
27840
|
-
get: /**
|
|
27841
|
-
* Root bone.
|
|
27842
|
-
*/ function get() {
|
|
27843
|
-
return this._rootBone;
|
|
27844
|
-
},
|
|
27845
|
-
set: function set(value) {
|
|
27846
|
-
if (this._rootBone !== value) {
|
|
27847
|
-
this._updatedManager.dispatch(1, value);
|
|
27848
|
-
this._rootBone = value;
|
|
27849
|
-
}
|
|
27850
|
-
}
|
|
27851
|
-
},
|
|
27852
|
-
{
|
|
27853
|
-
key: "bones",
|
|
27854
|
-
get: /**
|
|
27855
|
-
* Bones of the skin.
|
|
27856
|
-
*/ function get() {
|
|
27857
|
-
return this._bones;
|
|
27858
|
-
},
|
|
27859
|
-
set: function set(value) {
|
|
27860
|
-
var bones = this._bones;
|
|
27861
|
-
var _value_length;
|
|
27862
|
-
var boneCount = (_value_length = value == null ? void 0 : value.length) != null ? _value_length : 0;
|
|
27863
|
-
var lastBoneCount = bones.length;
|
|
27864
|
-
bones.length = boneCount;
|
|
27865
|
-
for(var i = 0; i < boneCount; i++){
|
|
27866
|
-
bones[i] = value[i];
|
|
27867
|
-
}
|
|
27868
|
-
if (lastBoneCount !== boneCount) {
|
|
27869
|
-
this._skinMatrices = new Float32Array(boneCount * 16);
|
|
27870
|
-
this._updatedManager.dispatch(0, boneCount);
|
|
27871
|
-
}
|
|
27872
|
-
}
|
|
27873
|
-
},
|
|
27874
|
-
{
|
|
27875
|
-
key: "skeleton",
|
|
27876
|
-
get: /** @deprecated Please use `rootBone` instead. */ function get() {
|
|
27877
|
-
var _this_rootBone;
|
|
27878
|
-
return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
|
|
27879
|
-
},
|
|
27880
|
-
set: function set(value) {
|
|
27881
|
-
var rootBone = this._rootBone;
|
|
27882
|
-
if (rootBone) {
|
|
27883
|
-
rootBone.name = value;
|
|
27884
|
-
}
|
|
27885
|
-
}
|
|
27886
|
-
}
|
|
27887
|
-
]);
|
|
27888
|
-
return Skin;
|
|
27889
|
-
}(EngineObject);
|
|
27890
|
-
__decorate$1([
|
|
27891
|
-
deepClone
|
|
27892
|
-
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
27893
|
-
__decorate$1([
|
|
27894
|
-
ignoreClone
|
|
27895
|
-
], Skin.prototype, "_skinMatrices", void 0);
|
|
27896
|
-
__decorate$1([
|
|
27897
|
-
ignoreClone
|
|
27898
|
-
], Skin.prototype, "_updatedManager", void 0);
|
|
27899
|
-
__decorate$1([
|
|
27900
|
-
ignoreClone
|
|
27901
|
-
], Skin.prototype, "_rootBone", void 0);
|
|
27902
|
-
__decorate$1([
|
|
27903
|
-
ignoreClone
|
|
27904
|
-
], Skin.prototype, "_bones", void 0);
|
|
27905
|
-
__decorate$1([
|
|
27906
|
-
ignoreClone
|
|
27907
|
-
], Skin.prototype, "_updateMark", void 0);
|
|
27908
|
-
var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
|
|
27909
|
-
SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
|
|
27910
|
-
SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
|
|
27911
|
-
return SkinUpdateFlag;
|
|
27912
|
-
}({});
|
|
27913
|
-
/**
|
|
27914
|
-
* SkinnedMeshRenderer.
|
|
27915
|
-
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer) {
|
|
27916
|
-
_inherits$2(SkinnedMeshRenderer, MeshRenderer);
|
|
27917
|
-
function SkinnedMeshRenderer(entity) {
|
|
27918
|
-
var _this;
|
|
27919
|
-
_this = MeshRenderer.call(this, entity) || this, _this._localBounds = new BoundingBox(), _this._jointDataCreateCache = new Vector2(-1, -1);
|
|
27920
|
-
_this._skin = null;
|
|
27921
|
-
var rhi = _this.entity.engine._hardwareRenderer;
|
|
27922
|
-
var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
|
|
27923
|
-
// Limit size to 256 to avoid some problem:
|
|
27924
|
-
// 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!
|
|
27925
|
-
// 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.
|
|
27926
|
-
maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
|
|
27927
|
-
_this._maxVertexUniformVectors = maxVertexUniformVectors;
|
|
27928
|
-
_this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_this);
|
|
27929
|
-
_this._onSkinUpdated = _this._onSkinUpdated.bind(_this);
|
|
27930
|
-
var localBounds = _this._localBounds;
|
|
27931
|
-
// @ts-ignore
|
|
27932
|
-
localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
|
|
27933
|
-
// @ts-ignore
|
|
27934
|
-
localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
|
|
27935
|
-
return _this;
|
|
27936
|
-
}
|
|
27937
|
-
var _proto = SkinnedMeshRenderer.prototype;
|
|
27938
|
-
/**
|
|
27939
|
-
* @internal
|
|
27940
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
27941
|
-
var _this__jointTexture;
|
|
27942
|
-
MeshRenderer.prototype._onDestroy.call(this);
|
|
27943
|
-
this._jointDataCreateCache = null;
|
|
27944
|
-
this._skin = null;
|
|
27945
|
-
this._blendShapeWeights = null;
|
|
27946
|
-
this._localBounds = null;
|
|
27947
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
27948
|
-
this._jointTexture = null;
|
|
27949
|
-
};
|
|
27950
|
-
/**
|
|
27951
|
-
* @internal
|
|
27952
|
-
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
27953
|
-
MeshRenderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
|
|
27954
|
-
if (this.skin) {
|
|
27955
|
-
target._applySkin(null, target.skin);
|
|
27956
|
-
}
|
|
27957
|
-
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
27958
|
-
};
|
|
27959
|
-
_proto._update = function _update(context) {
|
|
27960
|
-
var skin = this.skin;
|
|
27961
|
-
if ((skin == null ? void 0 : skin.bones.length) > 0) {
|
|
27962
|
-
skin._updateSkinMatrices(this);
|
|
27963
|
-
}
|
|
27964
|
-
var shaderData = this.shaderData;
|
|
27965
|
-
var mesh = this.mesh;
|
|
27966
|
-
var blendShapeManager = mesh._blendShapeManager;
|
|
27967
|
-
blendShapeManager._updateShaderData(shaderData, this);
|
|
27968
|
-
var bones = skin == null ? void 0 : skin.bones;
|
|
27969
|
-
if (bones) {
|
|
27970
|
-
var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
|
|
27971
|
-
var boneCount = bones.length;
|
|
27972
|
-
var boneDataCreateCache = this._jointDataCreateCache;
|
|
27973
|
-
var boneCountChange = boneCount !== boneDataCreateCache.x;
|
|
27974
|
-
if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
|
|
27975
|
-
// directly use max joint count to avoid shader recompile
|
|
27976
|
-
var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) / 4);
|
|
27977
|
-
if (boneCount > remainUniformJointCount) {
|
|
27978
|
-
var engine = this.engine;
|
|
27979
|
-
if (engine._hardwareRenderer.canIUseMoreJoints) {
|
|
27980
|
-
if (boneCountChange) {
|
|
27981
|
-
var _this__jointTexture;
|
|
27982
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
27983
|
-
this._jointTexture = new Texture2D(engine, 4, boneCount, TextureFormat.R32G32B32A32, false, false);
|
|
27984
|
-
this._jointTexture.filterMode = TextureFilterMode.Point;
|
|
27985
|
-
this._jointTexture.isGCIgnored = true;
|
|
27986
|
-
}
|
|
27987
|
-
shaderData.disableMacro("RENDERER_JOINTS_NUM");
|
|
27988
|
-
shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
27989
|
-
shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
|
|
27990
|
-
} else {
|
|
27991
|
-
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);
|
|
27992
|
-
}
|
|
27993
|
-
} else {
|
|
27994
|
-
var _this__jointTexture1;
|
|
27995
|
-
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
27996
|
-
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
27997
|
-
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
27998
|
-
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
|
|
27999
|
-
}
|
|
28000
|
-
boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
|
|
28001
|
-
}
|
|
28002
|
-
if (this._jointTexture) {
|
|
28003
|
-
this._jointTexture.setPixelBuffer(skin._skinMatrices);
|
|
28004
|
-
}
|
|
28005
|
-
}
|
|
28006
|
-
MeshRenderer.prototype._update.call(this, context);
|
|
28007
|
-
};
|
|
28008
|
-
/**
|
|
28009
|
-
* @internal
|
|
28010
|
-
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
28011
|
-
var _this_skin;
|
|
28012
|
-
var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
|
|
28013
|
-
if (rootBone) {
|
|
28014
|
-
BoundingBox.transform(this._localBounds, this._transformEntity.transform.worldMatrix, worldBounds);
|
|
28015
|
-
} else {
|
|
28016
|
-
MeshRenderer.prototype._updateBounds.call(this, worldBounds);
|
|
28017
|
-
}
|
|
28018
|
-
};
|
|
28019
|
-
_proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
|
|
28020
|
-
var mesh = this._mesh;
|
|
28021
|
-
var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
|
|
28022
|
-
var lastBlendShapeWeights = this._blendShapeWeights;
|
|
28023
|
-
if (lastBlendShapeWeights) {
|
|
28024
|
-
var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
|
|
28025
|
-
if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
|
|
28026
|
-
var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
28027
|
-
if (newBlendShapeCount > lastBlendShapeWeightsCount) {
|
|
28028
|
-
newBlendShapeWeights.set(lastBlendShapeWeights);
|
|
28029
|
-
} else {
|
|
28030
|
-
for(var i = 0; i < newBlendShapeCount; i++){
|
|
28031
|
-
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
28032
|
-
}
|
|
28033
|
-
}
|
|
28034
|
-
this._blendShapeWeights = newBlendShapeWeights;
|
|
28035
|
-
}
|
|
28036
|
-
} else {
|
|
28037
|
-
this._blendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
28038
|
-
}
|
|
28039
|
-
};
|
|
28040
|
-
_proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
|
|
28041
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
28042
|
-
};
|
|
28043
|
-
_proto._onSkinUpdated = function _onSkinUpdated(type, value) {
|
|
28044
|
-
switch(type){
|
|
28045
|
-
case SkinUpdateFlag.BoneCountChanged:
|
|
28046
|
-
var shaderData = this.shaderData;
|
|
28047
|
-
if (value > 0) {
|
|
28048
|
-
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
28049
|
-
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
|
|
28050
|
-
} else {
|
|
28051
|
-
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
28052
|
-
}
|
|
28053
|
-
break;
|
|
28054
|
-
case SkinUpdateFlag.RootBoneChanged:
|
|
28055
|
-
this._setTransformEntity(value);
|
|
28056
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
28057
|
-
break;
|
|
28058
|
-
}
|
|
28059
|
-
};
|
|
28060
|
-
_proto._applySkin = function _applySkin(lastSkin, value) {
|
|
28061
|
-
var _lastSkin_bones, _value_bones;
|
|
28062
|
-
var _lastSkin_bones_length;
|
|
28063
|
-
var lastSkinBoneCount = (_lastSkin_bones_length = lastSkin == null ? void 0 : (_lastSkin_bones = lastSkin.bones) == null ? void 0 : _lastSkin_bones.length) != null ? _lastSkin_bones_length : 0;
|
|
28064
|
-
var _lastSkin_rootBone;
|
|
28065
|
-
var lastRootBone = (_lastSkin_rootBone = lastSkin == null ? void 0 : lastSkin.rootBone) != null ? _lastSkin_rootBone : this.entity;
|
|
28066
|
-
lastSkin == null ? void 0 : lastSkin._updatedManager.removeListener(this._onSkinUpdated);
|
|
28067
|
-
var _value_bones_length;
|
|
28068
|
-
var skinBoneCount = (_value_bones_length = value == null ? void 0 : (_value_bones = value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
|
|
28069
|
-
var _value_rootBone;
|
|
28070
|
-
var rootBone = (_value_rootBone = value == null ? void 0 : value.rootBone) != null ? _value_rootBone : this.entity;
|
|
28071
|
-
value == null ? void 0 : value._updatedManager.addListener(this._onSkinUpdated);
|
|
28072
|
-
if (lastSkinBoneCount !== skinBoneCount) {
|
|
28073
|
-
this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
|
|
28074
|
-
}
|
|
28075
|
-
if (lastRootBone !== rootBone) {
|
|
28076
|
-
this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
|
|
28343
|
+
};
|
|
28344
|
+
/**
|
|
28345
|
+
* @internal
|
|
28346
|
+
*/ Entity._addToChildren = function _addToChildren(children, entity, index) {
|
|
28347
|
+
var childCount = children.length;
|
|
28348
|
+
children.length = childCount + 1;
|
|
28349
|
+
if (index === undefined) {
|
|
28350
|
+
children[childCount] = entity;
|
|
28351
|
+
entity._siblingIndex = childCount;
|
|
28352
|
+
} else {
|
|
28353
|
+
if (index < 0 || index > childCount) {
|
|
28354
|
+
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
28355
|
+
}
|
|
28356
|
+
for(var i = childCount; i > index; i--){
|
|
28357
|
+
var swapChild = children[i - 1];
|
|
28358
|
+
swapChild._siblingIndex = i;
|
|
28359
|
+
children[i] = swapChild;
|
|
28360
|
+
}
|
|
28361
|
+
entity._siblingIndex = index;
|
|
28362
|
+
children[index] = entity;
|
|
28077
28363
|
}
|
|
28078
28364
|
};
|
|
28079
|
-
_create_class$2(
|
|
28365
|
+
_create_class$2(Entity, [
|
|
28080
28366
|
{
|
|
28081
|
-
key: "
|
|
28367
|
+
key: "transform",
|
|
28082
28368
|
get: /**
|
|
28083
|
-
*
|
|
28369
|
+
* The transform of this entity.
|
|
28084
28370
|
*/ function get() {
|
|
28085
|
-
return this.
|
|
28086
|
-
},
|
|
28087
|
-
set: function set(value) {
|
|
28088
|
-
var lastSkin = this._skin;
|
|
28089
|
-
if (lastSkin !== value) {
|
|
28090
|
-
this._applySkin(lastSkin, value);
|
|
28091
|
-
this._skin = value;
|
|
28092
|
-
}
|
|
28371
|
+
return this._transform;
|
|
28093
28372
|
}
|
|
28094
28373
|
},
|
|
28095
28374
|
{
|
|
28096
|
-
key: "
|
|
28375
|
+
key: "isActive",
|
|
28097
28376
|
get: /**
|
|
28098
|
-
*
|
|
28099
|
-
* @remarks Array index is BlendShape index.
|
|
28377
|
+
* Whether to activate locally.
|
|
28100
28378
|
*/ function get() {
|
|
28101
|
-
this.
|
|
28102
|
-
return this._blendShapeWeights;
|
|
28379
|
+
return this._isActive;
|
|
28103
28380
|
},
|
|
28104
28381
|
set: function set(value) {
|
|
28105
|
-
this.
|
|
28106
|
-
|
|
28107
|
-
|
|
28108
|
-
|
|
28109
|
-
|
|
28110
|
-
|
|
28111
|
-
|
|
28382
|
+
if (value !== this._isActive) {
|
|
28383
|
+
this._isActive = value;
|
|
28384
|
+
if (value) {
|
|
28385
|
+
var parent = this._parent;
|
|
28386
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
28387
|
+
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
28388
|
+
activeChangeFlag |= ActiveChangeFlag.All;
|
|
28389
|
+
} else {
|
|
28390
|
+
(parent == null ? void 0 : parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
28391
|
+
(parent == null ? void 0 : parent._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
28392
|
+
}
|
|
28393
|
+
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
28394
|
+
} else {
|
|
28395
|
+
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
28396
|
+
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
28397
|
+
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
28398
|
+
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
28112
28399
|
}
|
|
28113
28400
|
}
|
|
28114
28401
|
}
|
|
28115
28402
|
},
|
|
28116
28403
|
{
|
|
28117
|
-
key: "
|
|
28404
|
+
key: "isActiveInHierarchy",
|
|
28118
28405
|
get: /**
|
|
28119
|
-
*
|
|
28406
|
+
* Whether it is active in the hierarchy.
|
|
28120
28407
|
*/ function get() {
|
|
28121
|
-
return this.
|
|
28122
|
-
},
|
|
28123
|
-
set: function set(value) {
|
|
28124
|
-
if (this._localBounds !== value) {
|
|
28125
|
-
this._localBounds.copyFrom(value);
|
|
28126
|
-
}
|
|
28408
|
+
return this._isActiveInHierarchy;
|
|
28127
28409
|
}
|
|
28128
28410
|
},
|
|
28129
28411
|
{
|
|
28130
|
-
key: "
|
|
28412
|
+
key: "parent",
|
|
28131
28413
|
get: /**
|
|
28132
|
-
*
|
|
28414
|
+
* The parent entity.
|
|
28133
28415
|
*/ function get() {
|
|
28134
|
-
return this.
|
|
28416
|
+
return this._parent;
|
|
28135
28417
|
},
|
|
28136
28418
|
set: function set(value) {
|
|
28137
|
-
this.
|
|
28419
|
+
this._setParent(value);
|
|
28138
28420
|
}
|
|
28139
28421
|
},
|
|
28140
28422
|
{
|
|
28141
|
-
key: "
|
|
28423
|
+
key: "children",
|
|
28142
28424
|
get: /**
|
|
28143
|
-
*
|
|
28425
|
+
* The children entities
|
|
28144
28426
|
*/ function get() {
|
|
28145
|
-
return this.
|
|
28146
|
-
},
|
|
28147
|
-
set: function set(value) {
|
|
28148
|
-
this.skin.bones = value;
|
|
28149
|
-
}
|
|
28150
|
-
}
|
|
28151
|
-
]);
|
|
28152
|
-
return SkinnedMeshRenderer;
|
|
28153
|
-
}(MeshRenderer);
|
|
28154
|
-
// @TODO: different shader type should use different count, not always 48
|
|
28155
|
-
/** @internal */ SkinnedMeshRenderer._baseVertexUniformVectorCount = 48;
|
|
28156
|
-
SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
|
|
28157
|
-
SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
|
|
28158
|
-
SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
|
|
28159
|
-
__decorate$1([
|
|
28160
|
-
ignoreClone
|
|
28161
|
-
], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
|
|
28162
|
-
__decorate$1([
|
|
28163
|
-
deepClone
|
|
28164
|
-
], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
|
|
28165
|
-
__decorate$1([
|
|
28166
|
-
ignoreClone
|
|
28167
|
-
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
28168
|
-
__decorate$1([
|
|
28169
|
-
ignoreClone
|
|
28170
|
-
], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
|
|
28171
|
-
__decorate$1([
|
|
28172
|
-
ignoreClone
|
|
28173
|
-
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
28174
|
-
__decorate$1([
|
|
28175
|
-
ignoreClone
|
|
28176
|
-
], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
|
|
28177
|
-
__decorate$1([
|
|
28178
|
-
deepClone
|
|
28179
|
-
], SkinnedMeshRenderer.prototype, "_skin", void 0);
|
|
28180
|
-
__decorate$1([
|
|
28181
|
-
ignoreClone
|
|
28182
|
-
], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
|
|
28183
|
-
__decorate$1([
|
|
28184
|
-
ignoreClone
|
|
28185
|
-
], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
|
|
28186
|
-
/**
|
|
28187
|
-
* @internal
|
|
28188
|
-
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
28189
|
-
function BasicResources(engine) {
|
|
28190
|
-
this.engine = engine;
|
|
28191
|
-
// prettier-ignore
|
|
28192
|
-
var vertices = new Float32Array([
|
|
28193
|
-
-1,
|
|
28194
|
-
-1,
|
|
28195
|
-
0,
|
|
28196
|
-
1,
|
|
28197
|
-
3,
|
|
28198
|
-
-1,
|
|
28199
|
-
2,
|
|
28200
|
-
1,
|
|
28201
|
-
-1,
|
|
28202
|
-
3,
|
|
28203
|
-
0,
|
|
28204
|
-
-1
|
|
28205
|
-
]); // left-top
|
|
28206
|
-
// prettier-ignore
|
|
28207
|
-
var flipYVertices = new Float32Array([
|
|
28208
|
-
3,
|
|
28209
|
-
-1,
|
|
28210
|
-
2,
|
|
28211
|
-
0,
|
|
28212
|
-
-1,
|
|
28213
|
-
-1,
|
|
28214
|
-
0,
|
|
28215
|
-
0,
|
|
28216
|
-
-1,
|
|
28217
|
-
3,
|
|
28218
|
-
0,
|
|
28219
|
-
2
|
|
28220
|
-
]); // left-top
|
|
28221
|
-
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
28222
|
-
blitMaterial._addReferCount(1);
|
|
28223
|
-
blitMaterial.renderState.depthState.enabled = false;
|
|
28224
|
-
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
28225
|
-
var blitScreenMaterial = new Material(engine, Shader.find("blit-screen"));
|
|
28226
|
-
blitScreenMaterial._addReferCount(1);
|
|
28227
|
-
blitScreenMaterial.renderState.depthState.enabled = false;
|
|
28228
|
-
blitScreenMaterial.renderState.depthState.writeEnabled = false;
|
|
28229
|
-
this.blitMaterial = blitMaterial;
|
|
28230
|
-
this.blitScreenMaterial = blitScreenMaterial;
|
|
28231
|
-
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
28232
|
-
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
28233
|
-
// Create white and magenta textures
|
|
28234
|
-
var whitePixel = new Uint8Array([
|
|
28235
|
-
255,
|
|
28236
|
-
255,
|
|
28237
|
-
255,
|
|
28238
|
-
255
|
|
28239
|
-
]);
|
|
28240
|
-
this.whiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
28241
|
-
this.whiteTextureCube = this._create1x1Texture(engine, 1, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
28242
|
-
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
28243
|
-
if (isWebGL2) {
|
|
28244
|
-
this.whiteTexture2DArray = this._create1x1Texture(engine, 2, TextureFormat.R8G8B8A8, whitePixel, true);
|
|
28245
|
-
var whitePixel32 = new Uint32Array([
|
|
28246
|
-
255,
|
|
28247
|
-
255,
|
|
28248
|
-
255,
|
|
28249
|
-
255
|
|
28250
|
-
]);
|
|
28251
|
-
this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
|
|
28252
|
-
}
|
|
28253
|
-
this.spriteDefaultMaterial = this._create2DMaterial(engine, Shader.find("Sprite"));
|
|
28254
|
-
this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
|
|
28255
|
-
this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
|
|
28256
|
-
this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
|
|
28257
|
-
this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
|
|
28258
|
-
}
|
|
28259
|
-
var _proto = BasicResources.prototype;
|
|
28260
|
-
/**
|
|
28261
|
-
* @internal
|
|
28262
|
-
*/ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
|
|
28263
|
-
return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
|
|
28264
|
-
};
|
|
28265
|
-
/**
|
|
28266
|
-
* @internal
|
|
28267
|
-
*/ _proto._initialize = function _initialize() {
|
|
28268
|
-
var _this = this;
|
|
28269
|
-
return new Promise(function(resolve, reject) {
|
|
28270
|
-
PrefilteredDFG.create(_this.engine).then(function(texture) {
|
|
28271
|
-
_this._prefilteredDFGTexture = texture;
|
|
28272
|
-
resolve(_this);
|
|
28273
|
-
}).catch(reject);
|
|
28274
|
-
});
|
|
28275
|
-
};
|
|
28276
|
-
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
28277
|
-
var mesh = new ModelMesh(engine);
|
|
28278
|
-
mesh._addReferCount(1);
|
|
28279
|
-
mesh.setVertexElements([
|
|
28280
|
-
new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
|
|
28281
|
-
]);
|
|
28282
|
-
var buffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
|
|
28283
|
-
mesh.setVertexBufferBinding(buffer, 16);
|
|
28284
|
-
mesh.addSubMesh(0, 3, MeshTopology.Triangles);
|
|
28285
|
-
engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
|
|
28286
|
-
_inherits$2(_class, ContentRestorer);
|
|
28287
|
-
function _class() {
|
|
28288
|
-
return ContentRestorer.call(this, mesh) || this;
|
|
28289
|
-
}
|
|
28290
|
-
var _proto = _class.prototype;
|
|
28291
|
-
_proto.restoreContent = function restoreContent() {
|
|
28292
|
-
buffer.setData(buffer.data);
|
|
28293
|
-
};
|
|
28294
|
-
return _class;
|
|
28295
|
-
}(ContentRestorer))());
|
|
28296
|
-
return mesh;
|
|
28297
|
-
};
|
|
28298
|
-
_proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel, isSRGBColorSpace) {
|
|
28299
|
-
var texture;
|
|
28300
|
-
switch(type){
|
|
28301
|
-
case 0:
|
|
28302
|
-
var texture2D = new Texture2D(engine, 1, 1, format, false, isSRGBColorSpace);
|
|
28303
|
-
texture2D.setPixelBuffer(pixel);
|
|
28304
|
-
texture = texture2D;
|
|
28305
|
-
break;
|
|
28306
|
-
case 2:
|
|
28307
|
-
var texture2DArray = new Texture2DArray(engine, 1, 1, 1, format, false, isSRGBColorSpace);
|
|
28308
|
-
texture2DArray.setPixelBuffer(0, pixel);
|
|
28309
|
-
texture = texture2DArray;
|
|
28310
|
-
break;
|
|
28311
|
-
case 1:
|
|
28312
|
-
var textureCube = new TextureCube(engine, 1, format, false, isSRGBColorSpace);
|
|
28313
|
-
for(var i = 0; i < 6; i++){
|
|
28314
|
-
textureCube.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
28315
|
-
}
|
|
28316
|
-
texture = textureCube;
|
|
28317
|
-
break;
|
|
28318
|
-
default:
|
|
28319
|
-
throw "Invalid texture type";
|
|
28320
|
-
}
|
|
28321
|
-
texture.isGCIgnored = true;
|
|
28322
|
-
engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
|
|
28323
|
-
_inherits$2(_class, ContentRestorer);
|
|
28324
|
-
function _class() {
|
|
28325
|
-
return ContentRestorer.call(this, texture) || this;
|
|
28326
|
-
}
|
|
28327
|
-
var _proto = _class.prototype;
|
|
28328
|
-
_proto.restoreContent = function restoreContent() {
|
|
28329
|
-
switch(type){
|
|
28330
|
-
case 0:
|
|
28331
|
-
this.resource.setPixelBuffer(pixel);
|
|
28332
|
-
break;
|
|
28333
|
-
case 2:
|
|
28334
|
-
this.resource.setPixelBuffer(0, pixel);
|
|
28335
|
-
break;
|
|
28336
|
-
case 1:
|
|
28337
|
-
for(var i = 0; i < 6; i++){
|
|
28338
|
-
this.resource.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
|
|
28339
|
-
}
|
|
28340
|
-
break;
|
|
28341
|
-
}
|
|
28342
|
-
};
|
|
28343
|
-
return _class;
|
|
28344
|
-
}(ContentRestorer))());
|
|
28345
|
-
return texture;
|
|
28346
|
-
};
|
|
28347
|
-
_proto._create2DMaterial = function _create2DMaterial(engine, shader) {
|
|
28348
|
-
var material = new Material(engine, shader);
|
|
28349
|
-
var renderState = material.renderState;
|
|
28350
|
-
var target = renderState.blendState.targetBlendState;
|
|
28351
|
-
target.enabled = true;
|
|
28352
|
-
target.sourceColorBlendFactor = BlendFactor.SourceAlpha;
|
|
28353
|
-
target.destinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
28354
|
-
target.sourceAlphaBlendFactor = BlendFactor.One;
|
|
28355
|
-
target.destinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
28356
|
-
target.colorBlendOperation = target.alphaBlendOperation = BlendOperation.Add;
|
|
28357
|
-
renderState.depthState.writeEnabled = false;
|
|
28358
|
-
renderState.rasterState.cullMode = CullMode.Off;
|
|
28359
|
-
renderState.renderQueueType = RenderQueueType.Transparent;
|
|
28360
|
-
material.isGCIgnored = true;
|
|
28361
|
-
return material;
|
|
28362
|
-
};
|
|
28363
|
-
_proto._createMagentaMaterial = function _createMagentaMaterial(engine, shaderName) {
|
|
28364
|
-
var material = new Material(engine, Shader.find(shaderName));
|
|
28365
|
-
material.isGCIgnored = true;
|
|
28366
|
-
material.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
28367
|
-
return material;
|
|
28368
|
-
};
|
|
28369
|
-
_proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
|
|
28370
|
-
var material = new Material(engine, Shader.find("SpriteMask"));
|
|
28371
|
-
material.isGCIgnored = true;
|
|
28372
|
-
return material;
|
|
28373
|
-
};
|
|
28374
|
-
BasicResources.getMaskInteractionRenderStates = function getMaskInteractionRenderStates(maskInteraction) {
|
|
28375
|
-
var visibleInsideMask = maskInteraction === SpriteMaskInteraction.VisibleInsideMask;
|
|
28376
|
-
var renderStates;
|
|
28377
|
-
var compareFunction;
|
|
28378
|
-
if (visibleInsideMask) {
|
|
28379
|
-
renderStates = BasicResources._maskReadInsideRenderStates;
|
|
28380
|
-
if (renderStates) {
|
|
28381
|
-
return renderStates;
|
|
28382
|
-
}
|
|
28383
|
-
BasicResources._maskReadInsideRenderStates = renderStates = {};
|
|
28384
|
-
compareFunction = CompareFunction.LessEqual;
|
|
28385
|
-
} else {
|
|
28386
|
-
renderStates = BasicResources._maskReadOutsideRenderStates;
|
|
28387
|
-
if (renderStates) {
|
|
28388
|
-
return renderStates;
|
|
28427
|
+
return this._children;
|
|
28389
28428
|
}
|
|
28390
|
-
|
|
28391
|
-
|
|
28392
|
-
|
|
28393
|
-
|
|
28394
|
-
|
|
28395
|
-
|
|
28396
|
-
|
|
28397
|
-
|
|
28398
|
-
return renderStates;
|
|
28399
|
-
};
|
|
28400
|
-
BasicResources.getMaskTypeRenderStates = function getMaskTypeRenderStates(maskType) {
|
|
28401
|
-
var isIncrement = maskType === RenderQueueMaskType.Increment;
|
|
28402
|
-
var renderStates;
|
|
28403
|
-
var passOperation;
|
|
28404
|
-
if (isIncrement) {
|
|
28405
|
-
renderStates = BasicResources._maskWriteIncrementRenderStates;
|
|
28406
|
-
if (renderStates) {
|
|
28407
|
-
return renderStates;
|
|
28429
|
+
},
|
|
28430
|
+
{
|
|
28431
|
+
key: "childCount",
|
|
28432
|
+
get: /**
|
|
28433
|
+
* @deprecated Please use `children.length` property instead.
|
|
28434
|
+
* Number of the children entities
|
|
28435
|
+
*/ function get() {
|
|
28436
|
+
return this._children.length;
|
|
28408
28437
|
}
|
|
28409
|
-
|
|
28410
|
-
|
|
28411
|
-
|
|
28412
|
-
|
|
28413
|
-
|
|
28414
|
-
|
|
28438
|
+
},
|
|
28439
|
+
{
|
|
28440
|
+
key: "scene",
|
|
28441
|
+
get: /**
|
|
28442
|
+
* The scene the entity belongs to.
|
|
28443
|
+
*/ function get() {
|
|
28444
|
+
return this._scene;
|
|
28415
28445
|
}
|
|
28416
|
-
|
|
28417
|
-
passOperation = StencilOperation.DecrementSaturate;
|
|
28418
|
-
}
|
|
28419
|
-
renderStates[RenderStateElementKey.StencilStateEnabled] = true;
|
|
28420
|
-
renderStates[RenderStateElementKey.StencilStatePassOperationFront] = passOperation;
|
|
28421
|
-
renderStates[RenderStateElementKey.StencilStatePassOperationBack] = passOperation;
|
|
28422
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = CompareFunction.Always;
|
|
28423
|
-
renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = CompareFunction.Always;
|
|
28424
|
-
var failStencilOperation = StencilOperation.Keep;
|
|
28425
|
-
renderStates[RenderStateElementKey.StencilStateFailOperationFront] = failStencilOperation;
|
|
28426
|
-
renderStates[RenderStateElementKey.StencilStateFailOperationBack] = failStencilOperation;
|
|
28427
|
-
renderStates[RenderStateElementKey.StencilStateZFailOperationFront] = failStencilOperation;
|
|
28428
|
-
renderStates[RenderStateElementKey.StencilStateZFailOperationBack] = failStencilOperation;
|
|
28429
|
-
renderStates[RenderStateElementKey.BlendStateColorWriteMask0] = ColorWriteMask.None;
|
|
28430
|
-
renderStates[RenderStateElementKey.DepthStateEnabled] = false;
|
|
28431
|
-
renderStates[RenderStateElementKey.RasterStateCullMode] = CullMode.Off;
|
|
28432
|
-
return renderStates;
|
|
28433
|
-
};
|
|
28434
|
-
_create_class$2(BasicResources, [
|
|
28446
|
+
},
|
|
28435
28447
|
{
|
|
28436
|
-
key: "
|
|
28437
|
-
get:
|
|
28438
|
-
|
|
28448
|
+
key: "siblingIndex",
|
|
28449
|
+
get: /**
|
|
28450
|
+
* The sibling index.
|
|
28451
|
+
*/ function get() {
|
|
28452
|
+
return this._siblingIndex;
|
|
28453
|
+
},
|
|
28454
|
+
set: function set(value) {
|
|
28455
|
+
if (this._siblingIndex === -1) {
|
|
28456
|
+
throw "The entity " + this.name + " is not in the hierarchy";
|
|
28457
|
+
}
|
|
28458
|
+
if (this._isRoot) {
|
|
28459
|
+
this._setSiblingIndex(this._scene._rootEntities, value);
|
|
28460
|
+
} else {
|
|
28461
|
+
var parent = this._parent;
|
|
28462
|
+
this._setSiblingIndex(parent._children, value);
|
|
28463
|
+
parent._dispatchModify(EntityModifyFlags.Child, parent);
|
|
28464
|
+
}
|
|
28439
28465
|
}
|
|
28440
28466
|
}
|
|
28441
28467
|
]);
|
|
28442
|
-
return
|
|
28443
|
-
}();
|
|
28444
|
-
|
|
28445
|
-
BasicResources._maskReadOutsideRenderStates = null;
|
|
28446
|
-
BasicResources._maskWriteIncrementRenderStates = null;
|
|
28447
|
-
BasicResources._maskWriteDecrementRenderStates = null;
|
|
28468
|
+
return Entity;
|
|
28469
|
+
}(EngineObject);
|
|
28470
|
+
/** @internal */ Entity._tempComponentConstructors = [];
|
|
28448
28471
|
var ObjectPool = /*#__PURE__*/ function() {
|
|
28449
28472
|
function ObjectPool(type) {
|
|
28450
28473
|
this._type = type;
|
|
@@ -28931,6 +28954,7 @@ PrimitiveChunk.subMeshPool = new ReturnableObjectPool(SubMesh, 10);
|
|
|
28931
28954
|
/** AudioClip, include ogg, wav and mp3. */ AssetType["Audio"] = "Audio";
|
|
28932
28955
|
/** Project asset. */ AssetType["Project"] = "project";
|
|
28933
28956
|
/** PhysicsMaterial. */ AssetType["PhysicsMaterial"] = "PhysicsMaterial";
|
|
28957
|
+
/** RenderTarget. */ AssetType["RenderTarget"] = "RenderTarget";
|
|
28934
28958
|
return AssetType;
|
|
28935
28959
|
}({});
|
|
28936
28960
|
var SafeLoopArray = /*#__PURE__*/ function() {
|
|
@@ -33720,6 +33744,183 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
|
|
|
33720
33744
|
PointerMethods["onPointerDrop"] = "onPointerDrop";
|
|
33721
33745
|
return PointerMethods;
|
|
33722
33746
|
}({});
|
|
33747
|
+
/**
|
|
33748
|
+
* Signal is a typed event mechanism for Galacean Engine.
|
|
33749
|
+
* @typeParam T - Tuple type of the signal arguments
|
|
33750
|
+
*/ var Signal = /*#__PURE__*/ function() {
|
|
33751
|
+
function Signal() {
|
|
33752
|
+
this._listeners = new SafeLoopArray();
|
|
33753
|
+
}
|
|
33754
|
+
var _proto = Signal.prototype;
|
|
33755
|
+
_proto.on = function on(fnOrTarget, targetOrMethodName) {
|
|
33756
|
+
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
33757
|
+
args[_key - 2] = arguments[_key];
|
|
33758
|
+
}
|
|
33759
|
+
this._addListener.apply(this, [].concat([
|
|
33760
|
+
fnOrTarget,
|
|
33761
|
+
targetOrMethodName,
|
|
33762
|
+
false
|
|
33763
|
+
], args));
|
|
33764
|
+
};
|
|
33765
|
+
_proto.once = function once(fnOrTarget, targetOrMethodName) {
|
|
33766
|
+
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
33767
|
+
args[_key - 2] = arguments[_key];
|
|
33768
|
+
}
|
|
33769
|
+
this._addListener.apply(this, [].concat([
|
|
33770
|
+
fnOrTarget,
|
|
33771
|
+
targetOrMethodName,
|
|
33772
|
+
true
|
|
33773
|
+
], args));
|
|
33774
|
+
};
|
|
33775
|
+
_proto.off = function off(fnOrTarget, targetOrMethodName) {
|
|
33776
|
+
if (typeof fnOrTarget === "function") {
|
|
33777
|
+
var target = targetOrMethodName != null ? targetOrMethodName : null;
|
|
33778
|
+
this._listeners.findAndRemove(function(listener) {
|
|
33779
|
+
if (listener.fn === fnOrTarget && listener.target === target) {
|
|
33780
|
+
listener.destroyed = true;
|
|
33781
|
+
return true;
|
|
33782
|
+
}
|
|
33783
|
+
return false;
|
|
33784
|
+
});
|
|
33785
|
+
} else {
|
|
33786
|
+
var target1 = fnOrTarget;
|
|
33787
|
+
var methodName = targetOrMethodName;
|
|
33788
|
+
this._listeners.findAndRemove(function(listener) {
|
|
33789
|
+
if (listener.target === target1 && listener.methodName === methodName) {
|
|
33790
|
+
listener.destroyed = true;
|
|
33791
|
+
return true;
|
|
33792
|
+
}
|
|
33793
|
+
return false;
|
|
33794
|
+
});
|
|
33795
|
+
}
|
|
33796
|
+
};
|
|
33797
|
+
/**
|
|
33798
|
+
* Remove all listeners, or all listeners for a specific target.
|
|
33799
|
+
* @param target - If provided, only remove listeners bound to this target
|
|
33800
|
+
*/ _proto.removeAll = function removeAll(target) {
|
|
33801
|
+
if (target !== undefined) {
|
|
33802
|
+
this._listeners.findAndRemove(function(listener) {
|
|
33803
|
+
if (listener.target === target) {
|
|
33804
|
+
return listener.destroyed = true;
|
|
33805
|
+
}
|
|
33806
|
+
return false;
|
|
33807
|
+
});
|
|
33808
|
+
} else {
|
|
33809
|
+
this._listeners.findAndRemove(function(listener) {
|
|
33810
|
+
return listener.destroyed = true;
|
|
33811
|
+
});
|
|
33812
|
+
}
|
|
33813
|
+
};
|
|
33814
|
+
/**
|
|
33815
|
+
* Invoke the signal, calling all listeners in order.
|
|
33816
|
+
* @param args - Arguments to pass to each listener
|
|
33817
|
+
*/ _proto.invoke = function invoke() {
|
|
33818
|
+
var _this, _loop = function _loop(i, n) {
|
|
33819
|
+
var listener = listeners[i];
|
|
33820
|
+
if (listener.destroyed) return "continue";
|
|
33821
|
+
if (listener.methodName && listener.target.destroyed) {
|
|
33822
|
+
listener.destroyed = true;
|
|
33823
|
+
_this._listeners.findAndRemove(function(l) {
|
|
33824
|
+
return l === listener;
|
|
33825
|
+
});
|
|
33826
|
+
return "continue";
|
|
33827
|
+
}
|
|
33828
|
+
listener.fn.apply(listener.target, args);
|
|
33829
|
+
if (listener.once) {
|
|
33830
|
+
listener.destroyed = true;
|
|
33831
|
+
_this._listeners.findAndRemove(function(l) {
|
|
33832
|
+
return l === listener;
|
|
33833
|
+
});
|
|
33834
|
+
}
|
|
33835
|
+
};
|
|
33836
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
33837
|
+
args[_key] = arguments[_key];
|
|
33838
|
+
}
|
|
33839
|
+
var listeners = this._listeners.getLoopArray();
|
|
33840
|
+
for(var i = 0, n = listeners.length; i < n; i++)_this = this, _loop(i);
|
|
33841
|
+
};
|
|
33842
|
+
/**
|
|
33843
|
+
* @internal
|
|
33844
|
+
* Clone listeners to target signal, remapping entity/component references.
|
|
33845
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
33846
|
+
var listeners = this._listeners.getLoopArray();
|
|
33847
|
+
for(var i = 0, n = listeners.length; i < n; i++){
|
|
33848
|
+
var listener = listeners[i];
|
|
33849
|
+
if (listener.destroyed || !listener.methodName) continue;
|
|
33850
|
+
var clonedTarget = CloneUtils.remapComponent(srcRoot, targetRoot, listener.target);
|
|
33851
|
+
if (clonedTarget) {
|
|
33852
|
+
var clonedArgs = this._cloneArguments(listener.arguments, srcRoot, targetRoot);
|
|
33853
|
+
if (listener.once) {
|
|
33854
|
+
var _target;
|
|
33855
|
+
(_target = target).once.apply(_target, [].concat([
|
|
33856
|
+
clonedTarget,
|
|
33857
|
+
listener.methodName
|
|
33858
|
+
], clonedArgs));
|
|
33859
|
+
} else {
|
|
33860
|
+
var _target1;
|
|
33861
|
+
(_target1 = target).on.apply(_target1, [].concat([
|
|
33862
|
+
clonedTarget,
|
|
33863
|
+
listener.methodName
|
|
33864
|
+
], clonedArgs));
|
|
33865
|
+
}
|
|
33866
|
+
}
|
|
33867
|
+
}
|
|
33868
|
+
};
|
|
33869
|
+
_proto._cloneArguments = function _cloneArguments(args, srcRoot, targetRoot) {
|
|
33870
|
+
if (!args || args.length === 0) return [];
|
|
33871
|
+
var len = args.length;
|
|
33872
|
+
var clonedArgs = new Array(len);
|
|
33873
|
+
for(var i = 0; i < len; i++){
|
|
33874
|
+
var arg = args[i];
|
|
33875
|
+
if (_instanceof1$2(arg, Entity)) {
|
|
33876
|
+
clonedArgs[i] = CloneUtils.remapEntity(srcRoot, targetRoot, arg);
|
|
33877
|
+
} else if (_instanceof1$2(arg, Component)) {
|
|
33878
|
+
clonedArgs[i] = CloneUtils.remapComponent(srcRoot, targetRoot, arg);
|
|
33879
|
+
} else {
|
|
33880
|
+
clonedArgs[i] = arg;
|
|
33881
|
+
}
|
|
33882
|
+
}
|
|
33883
|
+
return clonedArgs;
|
|
33884
|
+
};
|
|
33885
|
+
_proto._addListener = function _addListener(fnOrTarget, targetOrMethodName, once) {
|
|
33886
|
+
for(var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
|
|
33887
|
+
args[_key - 3] = arguments[_key];
|
|
33888
|
+
}
|
|
33889
|
+
if (typeof fnOrTarget === "function") {
|
|
33890
|
+
this._listeners.push({
|
|
33891
|
+
fn: fnOrTarget,
|
|
33892
|
+
target: targetOrMethodName != null ? targetOrMethodName : null,
|
|
33893
|
+
once: once
|
|
33894
|
+
});
|
|
33895
|
+
} else {
|
|
33896
|
+
var _target, _target1;
|
|
33897
|
+
var target = fnOrTarget;
|
|
33898
|
+
var methodName = targetOrMethodName;
|
|
33899
|
+
var fn = args.length > 0 ? function fn() {
|
|
33900
|
+
for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
33901
|
+
signalArgs[_key] = arguments[_key];
|
|
33902
|
+
}
|
|
33903
|
+
return (_target = target)[methodName].apply(_target, [].concat(args, signalArgs));
|
|
33904
|
+
} : function() {
|
|
33905
|
+
for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
33906
|
+
signalArgs[_key] = arguments[_key];
|
|
33907
|
+
}
|
|
33908
|
+
return (_target1 = target)[methodName].apply(_target1, [].concat(signalArgs));
|
|
33909
|
+
};
|
|
33910
|
+
this._listeners.push({
|
|
33911
|
+
fn: fn,
|
|
33912
|
+
target: target,
|
|
33913
|
+
once: once,
|
|
33914
|
+
methodName: methodName,
|
|
33915
|
+
arguments: args
|
|
33916
|
+
});
|
|
33917
|
+
}
|
|
33918
|
+
};
|
|
33919
|
+
return Signal;
|
|
33920
|
+
}();
|
|
33921
|
+
__decorate$1([
|
|
33922
|
+
ignoreClone
|
|
33923
|
+
], Signal.prototype, "_listeners", void 0);
|
|
33723
33924
|
/**
|
|
33724
33925
|
* Loader abstract class.
|
|
33725
33926
|
*/ var Loader = /*#__PURE__*/ function() {
|
|
@@ -42994,6 +43195,7 @@ var CoreObjects = /*#__PURE__*/Object.freeze({
|
|
|
42994
43195
|
CircleShape: CircleShape,
|
|
42995
43196
|
ClearableObjectPool: ClearableObjectPool,
|
|
42996
43197
|
CloneManager: CloneManager,
|
|
43198
|
+
CloneUtils: CloneUtils,
|
|
42997
43199
|
get Collider () { return Collider; },
|
|
42998
43200
|
ColliderShape: ColliderShape,
|
|
42999
43201
|
ColliderShapeUpAxis: ColliderShapeUpAxis,
|
|
@@ -43150,6 +43352,7 @@ var CoreObjects = /*#__PURE__*/Object.freeze({
|
|
|
43150
43352
|
ShadowCascadesMode: ShadowCascadesMode,
|
|
43151
43353
|
ShadowResolution: ShadowResolution,
|
|
43152
43354
|
ShadowType: ShadowType,
|
|
43355
|
+
Signal: Signal,
|
|
43153
43356
|
get SimpleSpriteAssembler () { return SimpleSpriteAssembler; },
|
|
43154
43357
|
SizeOverLifetimeModule: SizeOverLifetimeModule,
|
|
43155
43358
|
Skin: Skin,
|
|
@@ -44106,7 +44309,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
44106
44309
|
return {
|
|
44107
44310
|
internalFormat: isSRGBColorSpace ? gl.SRGB8 : isWebGL2 ? gl.RGB8 : gl.RGB,
|
|
44108
44311
|
baseFormat: isSRGBColorSpace ? isWebGL2 ? gl.RGB : gl.SRGB8 : gl.RGB,
|
|
44109
|
-
readFormat: gl.RGB,
|
|
44312
|
+
readFormat: isWebGL2 ? gl.RGBA : gl.RGB,
|
|
44110
44313
|
dataType: gl.UNSIGNED_BYTE,
|
|
44111
44314
|
isCompressed: false,
|
|
44112
44315
|
alignment: 1
|
|
@@ -44181,6 +44384,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
44181
44384
|
return {
|
|
44182
44385
|
internalFormat: gl.R11F_G11F_B10F,
|
|
44183
44386
|
baseFormat: gl.RGB,
|
|
44387
|
+
readFormat: gl.RGBA,
|
|
44184
44388
|
dataType: gl.FLOAT,
|
|
44185
44389
|
isCompressed: false,
|
|
44186
44390
|
alignment: 4
|
|
@@ -46231,9 +46435,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
46231
46435
|
for(var key in item.props)_this = this, _loop(key);
|
|
46232
46436
|
}
|
|
46233
46437
|
return Promise.all(promises).then(function() {
|
|
46234
|
-
|
|
46235
|
-
if (handle) return handle(instance, item);
|
|
46236
|
-
else return instance;
|
|
46438
|
+
return instance;
|
|
46237
46439
|
});
|
|
46238
46440
|
};
|
|
46239
46441
|
_proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
|
|
@@ -46252,6 +46454,29 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
46252
46454
|
}
|
|
46253
46455
|
});
|
|
46254
46456
|
};
|
|
46457
|
+
_proto.parseSignal = function parseSignal(signalRef) {
|
|
46458
|
+
var _this = this;
|
|
46459
|
+
var signal = new Signal();
|
|
46460
|
+
return Promise.all(signalRef.listeners.map(function(listener) {
|
|
46461
|
+
return Promise.all([
|
|
46462
|
+
_this.parseBasicType(listener.target),
|
|
46463
|
+
listener.arguments ? Promise.all(listener.arguments.map(function(a) {
|
|
46464
|
+
return _this.parseBasicType(a);
|
|
46465
|
+
})) : Promise.resolve([])
|
|
46466
|
+
]).then(function(param) {
|
|
46467
|
+
var target = param[0], resolvedArgs = param[1];
|
|
46468
|
+
if (target) {
|
|
46469
|
+
var _signal;
|
|
46470
|
+
(_signal = signal).on.apply(_signal, [].concat([
|
|
46471
|
+
target,
|
|
46472
|
+
listener.methodName
|
|
46473
|
+
], resolvedArgs));
|
|
46474
|
+
}
|
|
46475
|
+
});
|
|
46476
|
+
})).then(function() {
|
|
46477
|
+
return signal;
|
|
46478
|
+
});
|
|
46479
|
+
};
|
|
46255
46480
|
_proto.parseBasicType = function parseBasicType(value, originValue) {
|
|
46256
46481
|
var _this = this;
|
|
46257
46482
|
if (Array.isArray(value)) {
|
|
@@ -46281,6 +46506,8 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
46281
46506
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
46282
46507
|
// entity reference
|
|
46283
46508
|
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
46509
|
+
} else if (ReflectionParser._isSignalRef(value)) {
|
|
46510
|
+
return this.parseSignal(value);
|
|
46284
46511
|
} else if (originValue) {
|
|
46285
46512
|
var _this2, _loop = function _loop(key) {
|
|
46286
46513
|
if (key === "methods") {
|
|
@@ -46336,9 +46563,6 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
46336
46563
|
return Promise.resolve(entity);
|
|
46337
46564
|
}
|
|
46338
46565
|
};
|
|
46339
|
-
ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
|
|
46340
|
-
this.customParseComponentHandles[componentType] = handle;
|
|
46341
|
-
};
|
|
46342
46566
|
ReflectionParser._isClass = function _isClass(value) {
|
|
46343
46567
|
return value["class"] !== undefined;
|
|
46344
46568
|
};
|
|
@@ -46354,12 +46578,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
46354
46578
|
ReflectionParser._isComponentRef = function _isComponentRef(value) {
|
|
46355
46579
|
return value["ownerId"] !== undefined && value["componentId"] !== undefined;
|
|
46356
46580
|
};
|
|
46581
|
+
ReflectionParser._isSignalRef = function _isSignalRef(value) {
|
|
46582
|
+
return value["listeners"] !== undefined;
|
|
46583
|
+
};
|
|
46357
46584
|
ReflectionParser._isMethodObject = function _isMethodObject(value) {
|
|
46358
46585
|
return Array.isArray(value == null ? void 0 : value.params);
|
|
46359
46586
|
};
|
|
46360
46587
|
return ReflectionParser;
|
|
46361
46588
|
}();
|
|
46362
|
-
ReflectionParser.customParseComponentHandles = new Map();
|
|
46363
46589
|
var Texture2DDecoder = /*#__PURE__*/ function() {
|
|
46364
46590
|
function Texture2DDecoder() {}
|
|
46365
46591
|
Texture2DDecoder.decode = function decode(engine, bufferReader, restoredTexture) {
|
|
@@ -52013,6 +52239,53 @@ PhysicsMaterialLoader = __decorate([
|
|
|
52013
52239
|
"physMat"
|
|
52014
52240
|
])
|
|
52015
52241
|
], PhysicsMaterialLoader);
|
|
52242
|
+
var RenderTargetLoader = /*#__PURE__*/ function(Loader) {
|
|
52243
|
+
_inherits(RenderTargetLoader, Loader);
|
|
52244
|
+
function RenderTargetLoader() {
|
|
52245
|
+
return Loader.apply(this, arguments) || this;
|
|
52246
|
+
}
|
|
52247
|
+
var _proto = RenderTargetLoader.prototype;
|
|
52248
|
+
_proto.load = function load(item, resourceManager) {
|
|
52249
|
+
var engine = resourceManager.engine;
|
|
52250
|
+
return resourceManager // @ts-ignore
|
|
52251
|
+
._request(item.url, _extends({}, item, {
|
|
52252
|
+
type: "json"
|
|
52253
|
+
})).then(function(data) {
|
|
52254
|
+
var width = data.width, height = data.height, colorFormats = data.colorFormats, depthFormat = data.depthFormat, antiAliasing = data.antiAliasing, autoGenerateMipmaps = data.autoGenerateMipmaps;
|
|
52255
|
+
var colorTextureProps = data.colorTextures;
|
|
52256
|
+
var colorTextures = colorFormats.map(function(format, i) {
|
|
52257
|
+
var props = colorTextureProps == null ? void 0 : colorTextureProps[i];
|
|
52258
|
+
var _props_mipmap;
|
|
52259
|
+
var mipmap = (_props_mipmap = props == null ? void 0 : props.mipmap) != null ? _props_mipmap : true;
|
|
52260
|
+
var _props_isSRGBColorSpace;
|
|
52261
|
+
var isSRGB = (_props_isSRGBColorSpace = props == null ? void 0 : props.isSRGBColorSpace) != null ? _props_isSRGBColorSpace : format === TextureFormat.R8G8B8A8;
|
|
52262
|
+
var texture = new Texture2D(engine, width, height, format, mipmap, isSRGB);
|
|
52263
|
+
if (props) {
|
|
52264
|
+
if (props.filterMode != null) texture.filterMode = props.filterMode;
|
|
52265
|
+
if (props.wrapModeU != null) texture.wrapModeU = props.wrapModeU;
|
|
52266
|
+
if (props.wrapModeV != null) texture.wrapModeV = props.wrapModeV;
|
|
52267
|
+
if (props.anisoLevel != null) texture.anisoLevel = props.anisoLevel;
|
|
52268
|
+
}
|
|
52269
|
+
return texture;
|
|
52270
|
+
});
|
|
52271
|
+
var depth = depthFormat === -1 ? null : depthFormat;
|
|
52272
|
+
var rt = new RenderTarget(engine, width, height, colorTextures, depth, antiAliasing);
|
|
52273
|
+
if (autoGenerateMipmaps != null) rt.autoGenerateMipmaps = autoGenerateMipmaps;
|
|
52274
|
+
// Notify pending sub-asset requests for colorTextures
|
|
52275
|
+
for(var i = 0, n = colorTextures.length; i < n; i++){
|
|
52276
|
+
// @ts-ignore
|
|
52277
|
+
resourceManager._onSubAssetSuccess(item.url, "colorTextures[" + i + "]", colorTextures[i]);
|
|
52278
|
+
}
|
|
52279
|
+
return rt;
|
|
52280
|
+
});
|
|
52281
|
+
};
|
|
52282
|
+
return RenderTargetLoader;
|
|
52283
|
+
}(Loader);
|
|
52284
|
+
RenderTargetLoader = __decorate([
|
|
52285
|
+
resourceLoader(AssetType.RenderTarget, [
|
|
52286
|
+
"renderTarget"
|
|
52287
|
+
])
|
|
52288
|
+
], RenderTargetLoader);
|
|
52016
52289
|
var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
52017
52290
|
_inherits(SceneLoader, Loader);
|
|
52018
52291
|
function SceneLoader() {
|
|
@@ -52153,20 +52426,6 @@ SceneLoader = __decorate([
|
|
|
52153
52426
|
"scene"
|
|
52154
52427
|
], true)
|
|
52155
52428
|
], SceneLoader);
|
|
52156
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item) {
|
|
52157
|
-
var props;
|
|
52158
|
-
return __generator(this, function(_state) {
|
|
52159
|
-
props = item.props;
|
|
52160
|
-
if (!props.font) {
|
|
52161
|
-
// @ts-ignore
|
|
52162
|
-
instance.font = Font.createFromOS(instance.engine, props.fontFamily || "Arial");
|
|
52163
|
-
}
|
|
52164
|
-
return [
|
|
52165
|
-
2,
|
|
52166
|
-
instance
|
|
52167
|
-
];
|
|
52168
|
-
});
|
|
52169
|
-
}));
|
|
52170
52429
|
var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser) {
|
|
52171
52430
|
_inherits(KHR_lights_punctual, GLTFExtensionParser);
|
|
52172
52431
|
function KHR_lights_punctual() {
|
|
@@ -52661,11 +52920,11 @@ EXT_texture_webp = __decorate([
|
|
|
52661
52920
|
], EXT_texture_webp);
|
|
52662
52921
|
|
|
52663
52922
|
//@ts-ignore
|
|
52664
|
-
var version = "2.0.0-alpha.
|
|
52923
|
+
var version = "2.0.0-alpha.15";
|
|
52665
52924
|
console.log("Galacean Engine Version: " + version);
|
|
52666
52925
|
for(var key in CoreObjects){
|
|
52667
52926
|
Loader.registerClass(key, CoreObjects[key]);
|
|
52668
52927
|
}
|
|
52669
52928
|
|
|
52670
|
-
export { AccessorType, AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationClipDecoder, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoundingBox, BoundingFrustum, BoundingSphere, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferInfo, BufferMesh, BufferReader, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType$1 as CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, CollisionUtil, Color, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContainmentType, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FileHeader, FinalPass, FixedJoint, FogMode, Font, FontStyle, FrustumFace, GLCapabilityType, GLCompressedTextureInternalFormat, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, GradientAlphaKey, GradientColorKey, HDRDecoder, HemisphereShape, HierarchyParser, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolableValueType, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, KTX2Loader, KTX2TargetFormat, Keyframe, Keys, Layer, LayerPathMask, Light, Loader, Logger, MSAASamples, MainModule, Material, MaterialLoaderType, MathUtil, Matrix, Matrix3x3, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshDecoder, MeshRenderer, MeshShape, MeshTopology, ModelMesh, OverflowMode, PBRMaterial, ParserContext, ParserType, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, Plane, PlaneColliderShape, PlaneIntersectionType, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, PrefabResource, Primitive, PrimitiveMesh, Probe, Quaternion, Rand, RasterState, Ray, Rect, ReferResource, ReflectionParser, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, SceneParser, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SpecularMode, SphereColliderShape, SphereShape, SphericalHarmonics3, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, Texture2DDecoder, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode$1 as TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, Vector2, Vector3, Vector4, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WebCanvas, WebGLEngine, WebGLGraphicDevice, WebGLMode, WrapMode, XRManager, assignmentClone, decode, decoder, decoderMap, deepClone, dependentComponents, ignoreClone, parseSingleKTX, registerGLTFExtension, registerGLTFParser, registerPointerEventEmitter, request, resourceLoader, shallowClone, version };
|
|
52929
|
+
export { AccessorType, AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationClipDecoder, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoundingBox, BoundingFrustum, BoundingSphere, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferInfo, BufferMesh, BufferReader, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType$1 as CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, CloneUtils, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, CollisionUtil, Color, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContainmentType, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FileHeader, FinalPass, FixedJoint, FogMode, Font, FontStyle, FrustumFace, GLCapabilityType, GLCompressedTextureInternalFormat, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, GradientAlphaKey, GradientColorKey, HDRDecoder, HemisphereShape, HierarchyParser, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolableValueType, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, KTX2Loader, KTX2TargetFormat, Keyframe, Keys, Layer, LayerPathMask, Light, Loader, Logger, MSAASamples, MainModule, Material, MaterialLoaderType, MathUtil, Matrix, Matrix3x3, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshDecoder, MeshRenderer, MeshShape, MeshTopology, ModelMesh, OverflowMode, PBRMaterial, ParserContext, ParserType, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, Plane, PlaneColliderShape, PlaneIntersectionType, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, PrefabResource, Primitive, PrimitiveMesh, Probe, Quaternion, Rand, RasterState, Ray, Rect, ReferResource, ReflectionParser, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, SceneParser, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SpecularMode, SphereColliderShape, SphereShape, SphericalHarmonics3, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, Texture2DDecoder, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode$1 as TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, Vector2, Vector3, Vector4, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WebCanvas, WebGLEngine, WebGLGraphicDevice, WebGLMode, WrapMode, XRManager, assignmentClone, decode, decoder, decoderMap, deepClone, dependentComponents, ignoreClone, parseSingleKTX, registerGLTFExtension, registerGLTFParser, registerPointerEventEmitter, request, resourceLoader, shallowClone, version };
|
|
52671
52930
|
//# sourceMappingURL=bundled.module.js.map
|