@galacean/engine-core 1.2.0-beta.4 → 1.2.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1335 -1236
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1335 -1236
- package/dist/module.js +1335 -1236
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Entity.d.ts +1 -1
- package/types/RenderPipeline/batcher/MeshBuffer.d.ts +1 -0
- package/types/clone/ComponentCloner.d.ts +1 -1
- package/types/mesh/Skin.d.ts +25 -9
- package/types/mesh/SkinnedMeshRenderer.d.ts +15 -24
package/dist/main.js
CHANGED
|
@@ -254,7 +254,7 @@ function _instanceof(left, right) {
|
|
|
254
254
|
}
|
|
255
255
|
return cloneModes;
|
|
256
256
|
};
|
|
257
|
-
CloneManager.cloneProperty = function cloneProperty(source, target, k, cloneMode) {
|
|
257
|
+
CloneManager.cloneProperty = function cloneProperty(source, target, k, cloneMode, srcRoot, targetRoot, deepInstanceMap) {
|
|
258
258
|
if (cloneMode === CloneMode.Ignore) {
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
@@ -290,22 +290,33 @@ function _instanceof(left, right) {
|
|
|
290
290
|
targetPropertyA.length = length;
|
|
291
291
|
}
|
|
292
292
|
for(var i = 0; i < length; i++){
|
|
293
|
-
CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode);
|
|
293
|
+
CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode, srcRoot, targetRoot, deepInstanceMap);
|
|
294
294
|
}
|
|
295
295
|
break;
|
|
296
296
|
default:
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
297
|
+
var targetProperty = target[k];
|
|
298
|
+
// If the target property is undefined, create new instance and keep reference sharing like the source
|
|
299
|
+
if (!targetProperty) {
|
|
300
|
+
targetProperty = deepInstanceMap.get(sourceProperty);
|
|
301
|
+
if (!targetProperty) {
|
|
302
|
+
targetProperty = new sourceProperty.constructor();
|
|
303
|
+
deepInstanceMap.set(sourceProperty, targetProperty);
|
|
304
|
+
}
|
|
305
|
+
target[k] = targetProperty;
|
|
306
306
|
}
|
|
307
307
|
if (sourceProperty.copyFrom) {
|
|
308
|
-
|
|
308
|
+
// Custom clone
|
|
309
|
+
targetProperty.copyFrom(sourceProperty);
|
|
310
|
+
} else {
|
|
311
|
+
// Universal clone
|
|
312
|
+
var cloneModes = CloneManager.getCloneMode(sourceProperty.constructor);
|
|
313
|
+
for(var _$k in sourceProperty){
|
|
314
|
+
CloneManager.cloneProperty(sourceProperty, targetProperty, _$k, cloneModes[_$k], srcRoot, targetRoot, deepInstanceMap);
|
|
315
|
+
}
|
|
316
|
+
// Custom incremental clone
|
|
317
|
+
if (sourceProperty._cloneTo) {
|
|
318
|
+
sourceProperty._cloneTo(targetProperty, srcRoot, targetRoot);
|
|
319
|
+
}
|
|
309
320
|
}
|
|
310
321
|
break;
|
|
311
322
|
}
|
|
@@ -314,9 +325,9 @@ function _instanceof(left, right) {
|
|
|
314
325
|
target[k] = sourceProperty;
|
|
315
326
|
}
|
|
316
327
|
};
|
|
317
|
-
CloneManager.deepCloneObject = function deepCloneObject(source, target) {
|
|
328
|
+
CloneManager.deepCloneObject = function deepCloneObject(source, target, deepInstanceMap) {
|
|
318
329
|
for(var k in source){
|
|
319
|
-
CloneManager.cloneProperty(source, target, k, CloneMode.Deep);
|
|
330
|
+
CloneManager.cloneProperty(source, target, k, CloneMode.Deep, null, null, deepInstanceMap);
|
|
320
331
|
}
|
|
321
332
|
};
|
|
322
333
|
return CloneManager;
|
|
@@ -5580,7 +5591,7 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
|
|
|
5580
5591
|
return shaderData;
|
|
5581
5592
|
};
|
|
5582
5593
|
_proto.cloneTo = function cloneTo(target) {
|
|
5583
|
-
CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
|
|
5594
|
+
CloneManager.deepCloneObject(this._macroCollection, target._macroCollection, new Map());
|
|
5584
5595
|
Object.assign(target._macroMap, this._macroMap);
|
|
5585
5596
|
var referCount = target._getReferCount();
|
|
5586
5597
|
var propertyValueMap = this._propertyValueMap;
|
|
@@ -10960,454 +10971,1191 @@ var PrimitiveType;
|
|
|
10960
10971
|
})();
|
|
10961
10972
|
|
|
10962
10973
|
/**
|
|
10963
|
-
*
|
|
10964
|
-
*/
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10974
|
+
* Layer, used for bit operations.
|
|
10975
|
+
*/ exports.Layer = void 0;
|
|
10976
|
+
(function(Layer) {
|
|
10977
|
+
Layer[Layer[/** Layer 0. */ "Layer0"] = 0x1] = "Layer0";
|
|
10978
|
+
Layer[Layer[/** Layer 1. */ "Layer1"] = 0x2] = "Layer1";
|
|
10979
|
+
Layer[Layer[/** Layer 2. */ "Layer2"] = 0x4] = "Layer2";
|
|
10980
|
+
Layer[Layer[/** Layer 3. */ "Layer3"] = 0x8] = "Layer3";
|
|
10981
|
+
Layer[Layer[/** Layer 4. */ "Layer4"] = 0x10] = "Layer4";
|
|
10982
|
+
Layer[Layer[/** Layer 5. */ "Layer5"] = 0x20] = "Layer5";
|
|
10983
|
+
Layer[Layer[/** Layer 6. */ "Layer6"] = 0x40] = "Layer6";
|
|
10984
|
+
Layer[Layer[/** Layer 7. */ "Layer7"] = 0x80] = "Layer7";
|
|
10985
|
+
Layer[Layer[/** Layer 8. */ "Layer8"] = 0x100] = "Layer8";
|
|
10986
|
+
Layer[Layer[/** Layer 9. */ "Layer9"] = 0x200] = "Layer9";
|
|
10987
|
+
Layer[Layer[/** Layer 10. */ "Layer10"] = 0x400] = "Layer10";
|
|
10988
|
+
Layer[Layer[/** Layer 11. */ "Layer11"] = 0x800] = "Layer11";
|
|
10989
|
+
Layer[Layer[/** Layer 12. */ "Layer12"] = 0x1000] = "Layer12";
|
|
10990
|
+
Layer[Layer[/** Layer 13. */ "Layer13"] = 0x2000] = "Layer13";
|
|
10991
|
+
Layer[Layer[/** Layer 14. */ "Layer14"] = 0x4000] = "Layer14";
|
|
10992
|
+
Layer[Layer[/** Layer 15. */ "Layer15"] = 0x8000] = "Layer15";
|
|
10993
|
+
Layer[Layer[/** Layer 16. */ "Layer16"] = 0x10000] = "Layer16";
|
|
10994
|
+
Layer[Layer[/** Layer 17. */ "Layer17"] = 0x20000] = "Layer17";
|
|
10995
|
+
Layer[Layer[/** Layer 18. */ "Layer18"] = 0x40000] = "Layer18";
|
|
10996
|
+
Layer[Layer[/** Layer 19. */ "Layer19"] = 0x80000] = "Layer19";
|
|
10997
|
+
Layer[Layer[/** Layer 20. */ "Layer20"] = 0x100000] = "Layer20";
|
|
10998
|
+
Layer[Layer[/** Layer 21. */ "Layer21"] = 0x200000] = "Layer21";
|
|
10999
|
+
Layer[Layer[/** Layer 22. */ "Layer22"] = 0x400000] = "Layer22";
|
|
11000
|
+
Layer[Layer[/** Layer 23. */ "Layer23"] = 0x800000] = "Layer23";
|
|
11001
|
+
Layer[Layer[/** Layer 24. */ "Layer24"] = 0x1000000] = "Layer24";
|
|
11002
|
+
Layer[Layer[/** Layer 25. */ "Layer25"] = 0x2000000] = "Layer25";
|
|
11003
|
+
Layer[Layer[/** Layer 26. */ "Layer26"] = 0x4000000] = "Layer26";
|
|
11004
|
+
Layer[Layer[/** Layer 27. */ "Layer27"] = 0x8000000] = "Layer27";
|
|
11005
|
+
Layer[Layer[/** Layer 28. */ "Layer28"] = 0x10000000] = "Layer28";
|
|
11006
|
+
Layer[Layer[/** Layer 29. */ "Layer29"] = 0x20000000] = "Layer29";
|
|
11007
|
+
Layer[Layer[/** Layer 30. */ "Layer30"] = 0x40000000] = "Layer30";
|
|
11008
|
+
Layer[Layer[/** Layer 31. */ "Layer31"] = 0x80000000] = "Layer31";
|
|
11009
|
+
Layer[Layer[/** All layers. */ "Everything"] = 0xffffffff] = "Everything";
|
|
11010
|
+
Layer[Layer[/** None layer. */ "Nothing"] = 0x0] = "Nothing";
|
|
11011
|
+
})(exports.Layer || (exports.Layer = {}));
|
|
11012
|
+
|
|
11013
|
+
var ComponentCloner = /*#__PURE__*/ function() {
|
|
11014
|
+
function ComponentCloner() {}
|
|
11015
|
+
/**
|
|
11016
|
+
* Clone component.
|
|
11017
|
+
* @param source - Clone source
|
|
11018
|
+
* @param target - Clone target
|
|
11019
|
+
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
11020
|
+
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
11021
|
+
for(var k in source){
|
|
11022
|
+
CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
|
|
11023
|
+
}
|
|
11024
|
+
if (source._cloneTo) {
|
|
11025
|
+
source._cloneTo(target, srcRoot, targetRoot);
|
|
11026
|
+
}
|
|
11027
|
+
};
|
|
11028
|
+
return ComponentCloner;
|
|
11029
|
+
}();
|
|
10978
11030
|
|
|
10979
11031
|
/**
|
|
10980
|
-
*
|
|
10981
|
-
*/ var
|
|
10982
|
-
_inherits(
|
|
10983
|
-
function
|
|
11032
|
+
* Entity, be used as components container.
|
|
11033
|
+
*/ var Entity = /*#__PURE__*/ function(EngineObject1) {
|
|
11034
|
+
_inherits(Entity, EngineObject1);
|
|
11035
|
+
function Entity(engine, name) {
|
|
10984
11036
|
var _this;
|
|
10985
|
-
_this =
|
|
10986
|
-
_this.
|
|
10987
|
-
_this.
|
|
10988
|
-
_this.
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
_this.
|
|
10996
|
-
_this.
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11037
|
+
_this = EngineObject1.call(this, engine) || this;
|
|
11038
|
+
/** The layer the entity belongs to. */ _this.layer = exports.Layer.Layer0;
|
|
11039
|
+
/** @internal */ _this._isActiveInHierarchy = false;
|
|
11040
|
+
/** @internal */ _this._isActiveInScene = false;
|
|
11041
|
+
/** @internal */ _this._components = [];
|
|
11042
|
+
/** @internal */ _this._scripts = new DisorderedArray();
|
|
11043
|
+
/** @internal */ _this._children = [];
|
|
11044
|
+
/** @internal */ _this._isRoot = false;
|
|
11045
|
+
/** @internal */ _this._isActive = true;
|
|
11046
|
+
/** @internal */ _this._siblingIndex = -1;
|
|
11047
|
+
/** @internal */ _this._isTemplate = false;
|
|
11048
|
+
_this._parent = null;
|
|
11049
|
+
//--------------------------------------------------------------deprecated----------------------------------------------------------------
|
|
11050
|
+
_this._invModelMatrix = new engineMath.Matrix();
|
|
11051
|
+
_this.name = name;
|
|
11052
|
+
_this.transform = _this.addComponent(Transform);
|
|
11053
|
+
_this._inverseWorldMatFlag = _this.transform.registerWorldChangeFlag();
|
|
11002
11054
|
return _this;
|
|
11003
11055
|
}
|
|
11004
|
-
var _proto =
|
|
11056
|
+
var _proto = Entity.prototype;
|
|
11005
11057
|
/**
|
|
11006
|
-
*
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11058
|
+
* Add component based on the component type.
|
|
11059
|
+
* @param type - The type of the component
|
|
11060
|
+
* @returns The component which has been added
|
|
11061
|
+
*/ _proto.addComponent = function addComponent(type) {
|
|
11062
|
+
ComponentsDependencies._addCheck(this, type);
|
|
11063
|
+
var component = new type(this);
|
|
11064
|
+
this._components.push(component);
|
|
11065
|
+
component._setActive(true, ActiveChangeFlag.All);
|
|
11066
|
+
return component;
|
|
11067
|
+
};
|
|
11068
|
+
/**
|
|
11069
|
+
* Get component which match the type.
|
|
11070
|
+
* @param type - The type of the component
|
|
11071
|
+
* @returns The first component which match type
|
|
11072
|
+
*/ _proto.getComponent = function getComponent(type) {
|
|
11073
|
+
var components = this._components;
|
|
11074
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
11075
|
+
var component = components[i];
|
|
11076
|
+
if (_instanceof(component, type)) {
|
|
11077
|
+
return component;
|
|
11024
11078
|
}
|
|
11025
11079
|
}
|
|
11080
|
+
return null;
|
|
11026
11081
|
};
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11082
|
+
/**
|
|
11083
|
+
* Get components which match the type.
|
|
11084
|
+
* @param type - The type of the component
|
|
11085
|
+
* @param results - The components which match type
|
|
11086
|
+
* @returns The components which match type
|
|
11087
|
+
*/ _proto.getComponents = function getComponents(type, results) {
|
|
11088
|
+
results.length = 0;
|
|
11089
|
+
var components = this._components;
|
|
11090
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
11091
|
+
var component = components[i];
|
|
11092
|
+
if (_instanceof(component, type)) {
|
|
11093
|
+
results.push(component);
|
|
11094
|
+
}
|
|
11034
11095
|
}
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11096
|
+
return results;
|
|
11097
|
+
};
|
|
11098
|
+
/**
|
|
11099
|
+
* Get the components which match the type of the entity and it's children.
|
|
11100
|
+
* @param type - The component type
|
|
11101
|
+
* @param results - The components collection
|
|
11102
|
+
* @returns The components collection which match the type
|
|
11103
|
+
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
11104
|
+
results.length = 0;
|
|
11105
|
+
this._getComponentsInChildren(type, results);
|
|
11106
|
+
return results;
|
|
11107
|
+
};
|
|
11108
|
+
_proto.addChild = function addChild(indexOrChild, child) {
|
|
11109
|
+
var index;
|
|
11110
|
+
if (typeof indexOrChild === "number") {
|
|
11111
|
+
index = indexOrChild;
|
|
11112
|
+
} else {
|
|
11113
|
+
index = undefined;
|
|
11114
|
+
child = indexOrChild;
|
|
11115
|
+
}
|
|
11116
|
+
if (child._isRoot) {
|
|
11117
|
+
child._scene._removeFromEntityList(child);
|
|
11118
|
+
child._isRoot = false;
|
|
11119
|
+
this._addToChildrenList(index, child);
|
|
11120
|
+
child._parent = this;
|
|
11121
|
+
var oldScene = child._scene;
|
|
11122
|
+
var newScene = this._scene;
|
|
11123
|
+
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
11124
|
+
if (!this._isActiveInHierarchy) {
|
|
11125
|
+
child._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
11126
|
+
}
|
|
11127
|
+
if (child._isActiveInScene) {
|
|
11128
|
+
if (this._isActiveInScene) {
|
|
11129
|
+
// Cross scene should inActive first and then active
|
|
11130
|
+
oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
11066
11131
|
} else {
|
|
11067
|
-
|
|
11068
|
-
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
11069
|
-
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
11070
|
-
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
11071
|
-
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, this._jointMatrices);
|
|
11132
|
+
inActiveChangeFlag |= ActiveChangeFlag.Scene;
|
|
11072
11133
|
}
|
|
11073
|
-
jointDataCreateCache.set(jointCount, bsUniformOccupiesCount);
|
|
11074
11134
|
}
|
|
11075
|
-
|
|
11076
|
-
|
|
11135
|
+
inActiveChangeFlag && child._processInActive(inActiveChangeFlag);
|
|
11136
|
+
if (child._scene !== newScene) {
|
|
11137
|
+
Entity._traverseSetOwnerScene(child, newScene);
|
|
11138
|
+
}
|
|
11139
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
11140
|
+
if (child._isActive) {
|
|
11141
|
+
if (this._isActiveInHierarchy) {
|
|
11142
|
+
!child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
11143
|
+
}
|
|
11144
|
+
if (this._isActiveInScene) {
|
|
11145
|
+
(!child._isActiveInScene || oldScene !== newScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
11146
|
+
}
|
|
11077
11147
|
}
|
|
11148
|
+
activeChangeFlag && child._processActive(activeChangeFlag);
|
|
11149
|
+
child._setTransformDirty();
|
|
11150
|
+
} else {
|
|
11151
|
+
child._setParent(this, index);
|
|
11078
11152
|
}
|
|
11079
|
-
var layer = entity.layer;
|
|
11080
|
-
this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
|
|
11081
11153
|
};
|
|
11082
11154
|
/**
|
|
11083
|
-
*
|
|
11084
|
-
|
|
11085
|
-
|
|
11086
|
-
|
|
11087
|
-
this._rootBone = null;
|
|
11088
|
-
this._jointDataCreateCache = null;
|
|
11089
|
-
this._skin = null;
|
|
11090
|
-
this._blendShapeWeights = null;
|
|
11091
|
-
this._localBounds = null;
|
|
11092
|
-
this._jointMatrices = null;
|
|
11093
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
11094
|
-
this._jointTexture = null;
|
|
11095
|
-
this._bones = null;
|
|
11155
|
+
* Remove child entity.
|
|
11156
|
+
* @param child - The child entity which want to be removed
|
|
11157
|
+
*/ _proto.removeChild = function removeChild(child) {
|
|
11158
|
+
child._setParent(null);
|
|
11096
11159
|
};
|
|
11097
11160
|
/**
|
|
11098
|
-
* @
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11161
|
+
* @deprecated Please use `children` property instead.
|
|
11162
|
+
* Find child entity by index.
|
|
11163
|
+
* @param index - The index of the child entity
|
|
11164
|
+
* @returns The component which be found
|
|
11165
|
+
*/ _proto.getChild = function getChild(index) {
|
|
11166
|
+
return this._children[index];
|
|
11167
|
+
};
|
|
11168
|
+
/**
|
|
11169
|
+
* Find entity by name.
|
|
11170
|
+
* @param name - The name of the entity which want to be found
|
|
11171
|
+
* @returns The component which be found
|
|
11172
|
+
*/ _proto.findByName = function findByName(name) {
|
|
11173
|
+
if (name === this.name) {
|
|
11174
|
+
return this;
|
|
11106
11175
|
}
|
|
11107
|
-
|
|
11108
|
-
var
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
for(var i = 0; i < boneCount; i++){
|
|
11113
|
-
var bone = bones[i];
|
|
11114
|
-
var success1 = this._getEntityHierarchyPath(srcRoot, bone, paths);
|
|
11115
|
-
destBones[i] = success1 ? this._getEntityByHierarchyPath(targetRoot, paths) : bone;
|
|
11176
|
+
var children = this._children;
|
|
11177
|
+
for(var i = 0, n = children.length; i < n; i++){
|
|
11178
|
+
var target = children[i].findByName(name);
|
|
11179
|
+
if (target) {
|
|
11180
|
+
return target;
|
|
11116
11181
|
}
|
|
11117
|
-
target.bones = destBones;
|
|
11118
11182
|
}
|
|
11119
|
-
|
|
11183
|
+
return null;
|
|
11120
11184
|
};
|
|
11121
11185
|
/**
|
|
11122
|
-
*
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11186
|
+
* Find the entity by path.
|
|
11187
|
+
* @param path - The path fo the entity eg: /entity
|
|
11188
|
+
* @returns The component which be found
|
|
11189
|
+
*/ _proto.findByPath = function findByPath(path) {
|
|
11190
|
+
var splits = path.split("/");
|
|
11191
|
+
var entity = this;
|
|
11192
|
+
for(var i = 0, length = splits.length; i < length; ++i){
|
|
11193
|
+
var split = splits[i];
|
|
11194
|
+
if (split) {
|
|
11195
|
+
entity = Entity._findChildByName(entity, split);
|
|
11196
|
+
if (!entity) {
|
|
11197
|
+
return null;
|
|
11198
|
+
}
|
|
11199
|
+
}
|
|
11200
|
+
}
|
|
11201
|
+
return entity;
|
|
11126
11202
|
};
|
|
11127
11203
|
/**
|
|
11128
|
-
*
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11204
|
+
* Create child entity.
|
|
11205
|
+
* @param name - The child entity's name
|
|
11206
|
+
* @returns The child entity
|
|
11207
|
+
*/ _proto.createChild = function createChild(name) {
|
|
11208
|
+
var child = new Entity(this.engine, name);
|
|
11209
|
+
child.layer = this.layer;
|
|
11210
|
+
child.parent = this;
|
|
11211
|
+
return child;
|
|
11212
|
+
};
|
|
11213
|
+
/**
|
|
11214
|
+
* Clear children entities.
|
|
11215
|
+
*/ _proto.clearChildren = function clearChildren() {
|
|
11216
|
+
var children = this._children;
|
|
11217
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
11218
|
+
var child = children[i];
|
|
11219
|
+
child._parent = null;
|
|
11220
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
11221
|
+
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
11222
|
+
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
11223
|
+
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
11224
|
+
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
11225
|
+
}
|
|
11226
|
+
children.length = 0;
|
|
11227
|
+
};
|
|
11228
|
+
/**
|
|
11229
|
+
* Clone this entity include children and components.
|
|
11230
|
+
* @returns Cloned entity
|
|
11231
|
+
*/ _proto.clone = function clone() {
|
|
11232
|
+
var cloneEntity = this._createCloneEntity(this);
|
|
11233
|
+
this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
|
|
11234
|
+
return cloneEntity;
|
|
11132
11235
|
};
|
|
11133
11236
|
/**
|
|
11134
11237
|
* @internal
|
|
11135
|
-
*/ _proto.
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
|
|
11238
|
+
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
11239
|
+
this._isTemplate = true;
|
|
11240
|
+
this._templateResource = templateResource;
|
|
11241
|
+
};
|
|
11242
|
+
_proto._createCloneEntity = function _createCloneEntity(srcEntity) {
|
|
11243
|
+
var cloneEntity = new Entity(srcEntity._engine, srcEntity.name);
|
|
11244
|
+
var templateResource = this._templateResource;
|
|
11245
|
+
if (templateResource) {
|
|
11246
|
+
cloneEntity._templateResource = templateResource;
|
|
11247
|
+
templateResource._addReferCount(1);
|
|
11248
|
+
}
|
|
11249
|
+
cloneEntity.layer = srcEntity.layer;
|
|
11250
|
+
cloneEntity._isActive = srcEntity._isActive;
|
|
11251
|
+
var cloneTransform = cloneEntity.transform;
|
|
11252
|
+
var srcTransform = srcEntity.transform;
|
|
11253
|
+
cloneTransform.position = srcTransform.position;
|
|
11254
|
+
cloneTransform.rotation = srcTransform.rotation;
|
|
11255
|
+
cloneTransform.scale = srcTransform.scale;
|
|
11256
|
+
var children = srcEntity._children;
|
|
11257
|
+
for(var i = 0, n = srcEntity._children.length; i < n; i++){
|
|
11258
|
+
cloneEntity.addChild(this._createCloneEntity(children[i]));
|
|
11142
11259
|
}
|
|
11260
|
+
return cloneEntity;
|
|
11143
11261
|
};
|
|
11144
|
-
_proto.
|
|
11145
|
-
var
|
|
11146
|
-
var
|
|
11147
|
-
var
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
11157
|
-
}
|
|
11158
|
-
}
|
|
11159
|
-
this._blendShapeWeights = newBlendShapeWeights;
|
|
11262
|
+
_proto._parseCloneEntity = function _parseCloneEntity(src, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
11263
|
+
var srcChildren = src._children;
|
|
11264
|
+
var targetChildren = target._children;
|
|
11265
|
+
for(var i = 0, n = srcChildren.length; i < n; i++){
|
|
11266
|
+
this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot, deepInstanceMap);
|
|
11267
|
+
}
|
|
11268
|
+
var components = src._components;
|
|
11269
|
+
for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
|
|
11270
|
+
var sourceComp = components[i1];
|
|
11271
|
+
if (!_instanceof(sourceComp, Transform)) {
|
|
11272
|
+
var targetComp = target.addComponent(sourceComp.constructor);
|
|
11273
|
+
ComponentCloner.cloneComponent(sourceComp, targetComp, srcRoot, targetRoot, deepInstanceMap);
|
|
11160
11274
|
}
|
|
11275
|
+
}
|
|
11276
|
+
};
|
|
11277
|
+
/**
|
|
11278
|
+
* Destroy self.
|
|
11279
|
+
*/ _proto.destroy = function destroy() {
|
|
11280
|
+
if (this._destroyed) {
|
|
11281
|
+
return;
|
|
11282
|
+
}
|
|
11283
|
+
EngineObject1.prototype.destroy.call(this);
|
|
11284
|
+
if (this._templateResource) {
|
|
11285
|
+
this._isTemplate || this._templateResource._addReferCount(-1);
|
|
11286
|
+
this._templateResource = null;
|
|
11287
|
+
}
|
|
11288
|
+
var components = this._components;
|
|
11289
|
+
for(var i = components.length - 1; i >= 0; i--){
|
|
11290
|
+
components[i].destroy();
|
|
11291
|
+
}
|
|
11292
|
+
this._components.length = 0;
|
|
11293
|
+
var children = this._children;
|
|
11294
|
+
while(children.length > 0){
|
|
11295
|
+
children[0].destroy();
|
|
11296
|
+
}
|
|
11297
|
+
if (this._isRoot) {
|
|
11298
|
+
this._scene.removeRootEntity(this);
|
|
11161
11299
|
} else {
|
|
11162
|
-
this.
|
|
11300
|
+
this._setParent(null);
|
|
11163
11301
|
}
|
|
11302
|
+
this.isActive = false;
|
|
11164
11303
|
};
|
|
11165
|
-
|
|
11166
|
-
|
|
11304
|
+
/**
|
|
11305
|
+
* @internal
|
|
11306
|
+
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
11307
|
+
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
11308
|
+
var components = this._components;
|
|
11309
|
+
components.splice(components.indexOf(component), 1);
|
|
11167
11310
|
};
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11311
|
+
/**
|
|
11312
|
+
* @internal
|
|
11313
|
+
*/ _proto._addScript = function _addScript(script) {
|
|
11314
|
+
script._entityScriptsIndex = this._scripts.length;
|
|
11315
|
+
this._scripts.add(script);
|
|
11316
|
+
};
|
|
11317
|
+
/**
|
|
11318
|
+
* @internal
|
|
11319
|
+
*/ _proto._removeScript = function _removeScript(script) {
|
|
11320
|
+
var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
|
|
11321
|
+
replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
|
|
11322
|
+
script._entityScriptsIndex = -1;
|
|
11323
|
+
};
|
|
11324
|
+
/**
|
|
11325
|
+
* @internal
|
|
11326
|
+
*/ _proto._removeFromParent = function _removeFromParent() {
|
|
11327
|
+
var oldParent = this._parent;
|
|
11328
|
+
if (oldParent != null) {
|
|
11329
|
+
var oldSibling = oldParent._children;
|
|
11330
|
+
var index = this._siblingIndex;
|
|
11331
|
+
oldSibling.splice(index, 1);
|
|
11332
|
+
for(var n = oldSibling.length; index < n; index++){
|
|
11333
|
+
oldSibling[index]._siblingIndex--;
|
|
11174
11334
|
}
|
|
11175
|
-
|
|
11176
|
-
|
|
11335
|
+
this._parent = null;
|
|
11336
|
+
this._siblingIndex = -1;
|
|
11177
11337
|
}
|
|
11178
|
-
return true;
|
|
11179
11338
|
};
|
|
11180
11339
|
/**
|
|
11181
11340
|
* @internal
|
|
11182
|
-
*/ _proto.
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
entity = entity.children[inversePath[i]];
|
|
11341
|
+
*/ _proto._processActive = function _processActive(activeChangeFlag) {
|
|
11342
|
+
if (this._activeChangedComponents) {
|
|
11343
|
+
throw "Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";
|
|
11186
11344
|
}
|
|
11187
|
-
|
|
11345
|
+
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
11346
|
+
this._setActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
11347
|
+
this._setActiveComponents(true, activeChangeFlag);
|
|
11188
11348
|
};
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
}
|
|
11209
|
-
}
|
|
11210
|
-
},
|
|
11211
|
-
{
|
|
11212
|
-
key: "localBounds",
|
|
11213
|
-
get: /**
|
|
11214
|
-
* Local bounds.
|
|
11215
|
-
*/ function get() {
|
|
11216
|
-
return this._localBounds;
|
|
11217
|
-
},
|
|
11218
|
-
set: function set(value) {
|
|
11219
|
-
if (this._localBounds !== value) {
|
|
11220
|
-
this._localBounds.copyFrom(value);
|
|
11221
|
-
}
|
|
11349
|
+
/**
|
|
11350
|
+
* @internal
|
|
11351
|
+
*/ _proto._processInActive = function _processInActive(activeChangeFlag) {
|
|
11352
|
+
if (this._activeChangedComponents) {
|
|
11353
|
+
throw "Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";
|
|
11354
|
+
}
|
|
11355
|
+
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
11356
|
+
this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
11357
|
+
this._setActiveComponents(false, activeChangeFlag);
|
|
11358
|
+
};
|
|
11359
|
+
_proto._addToChildrenList = function _addToChildrenList(index, child) {
|
|
11360
|
+
var children = this._children;
|
|
11361
|
+
var childCount = children.length;
|
|
11362
|
+
if (index === undefined) {
|
|
11363
|
+
child._siblingIndex = childCount;
|
|
11364
|
+
children.push(child);
|
|
11365
|
+
} else {
|
|
11366
|
+
if (index < 0 || index > childCount) {
|
|
11367
|
+
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
11222
11368
|
}
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11369
|
+
child._siblingIndex = index;
|
|
11370
|
+
children.splice(index, 0, child);
|
|
11371
|
+
for(var i = index + 1, n = childCount + 1; i < n; i++){
|
|
11372
|
+
children[i]._siblingIndex++;
|
|
11373
|
+
}
|
|
11374
|
+
}
|
|
11375
|
+
};
|
|
11376
|
+
_proto._setParent = function _setParent(parent, siblingIndex) {
|
|
11377
|
+
var oldParent = this._parent;
|
|
11378
|
+
if (parent !== oldParent) {
|
|
11379
|
+
this._removeFromParent();
|
|
11380
|
+
this._parent = parent;
|
|
11381
|
+
if (parent) {
|
|
11382
|
+
parent._addToChildrenList(siblingIndex, this);
|
|
11383
|
+
var oldScene = this._scene;
|
|
11384
|
+
var parentScene = parent._scene;
|
|
11385
|
+
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
11386
|
+
if (!parent._isActiveInHierarchy) {
|
|
11387
|
+
this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
11388
|
+
}
|
|
11389
|
+
if (parent._isActiveInScene) {
|
|
11390
|
+
// cross scene should inActive first and then active
|
|
11391
|
+
this._isActiveInScene && oldScene !== parentScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
11392
|
+
} else {
|
|
11393
|
+
this._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
11394
|
+
}
|
|
11395
|
+
inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
|
|
11396
|
+
if (oldScene !== parentScene) {
|
|
11397
|
+
Entity._traverseSetOwnerScene(this, parentScene);
|
|
11398
|
+
}
|
|
11399
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
11400
|
+
if (this._isActive) {
|
|
11401
|
+
if (parent._isActiveInHierarchy) {
|
|
11402
|
+
!this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
11403
|
+
}
|
|
11404
|
+
if (parent._isActiveInScene) {
|
|
11405
|
+
(!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
11406
|
+
}
|
|
11407
|
+
}
|
|
11408
|
+
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
11409
|
+
} else {
|
|
11410
|
+
var inActiveChangeFlag1 = ActiveChangeFlag.None;
|
|
11411
|
+
this._isActiveInHierarchy && (inActiveChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
11412
|
+
this._isActiveInScene && (inActiveChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
11413
|
+
inActiveChangeFlag1 && this._processInActive(inActiveChangeFlag1);
|
|
11414
|
+
if (oldParent) {
|
|
11415
|
+
Entity._traverseSetOwnerScene(this, null);
|
|
11237
11416
|
}
|
|
11238
11417
|
}
|
|
11239
|
-
|
|
11418
|
+
this._setTransformDirty();
|
|
11419
|
+
}
|
|
11420
|
+
};
|
|
11421
|
+
_proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
|
|
11422
|
+
for(var i = this._components.length - 1; i >= 0; i--){
|
|
11423
|
+
var component = this._components[i];
|
|
11424
|
+
if (_instanceof(component, type)) {
|
|
11425
|
+
results.push(component);
|
|
11426
|
+
}
|
|
11427
|
+
}
|
|
11428
|
+
for(var i1 = this._children.length - 1; i1 >= 0; i1--){
|
|
11429
|
+
this._children[i1]._getComponentsInChildren(type, results);
|
|
11430
|
+
}
|
|
11431
|
+
};
|
|
11432
|
+
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
11433
|
+
var activeChangedComponents = this._activeChangedComponents;
|
|
11434
|
+
for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
|
|
11435
|
+
activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
|
|
11436
|
+
}
|
|
11437
|
+
this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
|
|
11438
|
+
this._activeChangedComponents = null;
|
|
11439
|
+
};
|
|
11440
|
+
_proto._setActiveInHierarchy = function _setActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
11441
|
+
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = true);
|
|
11442
|
+
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = true);
|
|
11443
|
+
var components = this._components;
|
|
11444
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
11445
|
+
var component = components[i];
|
|
11446
|
+
(component.enabled || !component._awoken) && activeChangedComponents.push(component);
|
|
11447
|
+
}
|
|
11448
|
+
var children = this._children;
|
|
11449
|
+
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
11450
|
+
var child = children[i1];
|
|
11451
|
+
child.isActive && child._setActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
11452
|
+
}
|
|
11453
|
+
};
|
|
11454
|
+
_proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
11455
|
+
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
|
|
11456
|
+
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
|
|
11457
|
+
var components = this._components;
|
|
11458
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
11459
|
+
var component = components[i];
|
|
11460
|
+
component.enabled && activeChangedComponents.push(component);
|
|
11461
|
+
}
|
|
11462
|
+
var children = this._children;
|
|
11463
|
+
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
11464
|
+
var child = children[i1];
|
|
11465
|
+
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
11466
|
+
}
|
|
11467
|
+
};
|
|
11468
|
+
_proto._setTransformDirty = function _setTransformDirty() {
|
|
11469
|
+
if (this.transform) {
|
|
11470
|
+
this.transform._parentChange();
|
|
11471
|
+
} else {
|
|
11472
|
+
for(var i = 0, len = this._children.length; i < len; i++){
|
|
11473
|
+
this._children[i]._setTransformDirty();
|
|
11474
|
+
}
|
|
11475
|
+
}
|
|
11476
|
+
};
|
|
11477
|
+
_proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
|
|
11478
|
+
target = Math.min(target, sibling.length - 1);
|
|
11479
|
+
if (target < 0) {
|
|
11480
|
+
throw "Sibling index " + target + " should large than 0";
|
|
11481
|
+
}
|
|
11482
|
+
if (this._siblingIndex !== target) {
|
|
11483
|
+
var oldIndex = this._siblingIndex;
|
|
11484
|
+
if (target < oldIndex) {
|
|
11485
|
+
for(var i = oldIndex; i >= target; i--){
|
|
11486
|
+
var child = i == target ? this : sibling[i - 1];
|
|
11487
|
+
sibling[i] = child;
|
|
11488
|
+
child._siblingIndex = i;
|
|
11489
|
+
}
|
|
11490
|
+
} else {
|
|
11491
|
+
for(var i1 = oldIndex; i1 <= target; i1++){
|
|
11492
|
+
var child1 = i1 == target ? this : sibling[i1 + 1];
|
|
11493
|
+
sibling[i1] = child1;
|
|
11494
|
+
child1._siblingIndex = i1;
|
|
11495
|
+
}
|
|
11496
|
+
}
|
|
11497
|
+
}
|
|
11498
|
+
};
|
|
11499
|
+
/**
|
|
11500
|
+
* @deprecated
|
|
11501
|
+
*/ _proto.getInvModelMatrix = function getInvModelMatrix() {
|
|
11502
|
+
if (this._inverseWorldMatFlag.flag) {
|
|
11503
|
+
engineMath.Matrix.invert(this.transform.worldMatrix, this._invModelMatrix);
|
|
11504
|
+
this._inverseWorldMatFlag.flag = false;
|
|
11505
|
+
}
|
|
11506
|
+
return this._invModelMatrix;
|
|
11507
|
+
};
|
|
11508
|
+
/**
|
|
11509
|
+
* @internal
|
|
11510
|
+
*/ Entity._findChildByName = function _findChildByName(root, name) {
|
|
11511
|
+
var children = root._children;
|
|
11512
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
11513
|
+
var child = children[i];
|
|
11514
|
+
if (child.name === name) {
|
|
11515
|
+
return child;
|
|
11516
|
+
}
|
|
11517
|
+
}
|
|
11518
|
+
return null;
|
|
11519
|
+
};
|
|
11520
|
+
/**
|
|
11521
|
+
* @internal
|
|
11522
|
+
*/ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
|
|
11523
|
+
entity._scene = scene;
|
|
11524
|
+
var children = entity._children;
|
|
11525
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
11526
|
+
this._traverseSetOwnerScene(children[i], scene);
|
|
11527
|
+
}
|
|
11528
|
+
};
|
|
11529
|
+
/**
|
|
11530
|
+
* @internal
|
|
11531
|
+
*/ Entity._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
|
|
11532
|
+
inversePath.length = 0;
|
|
11533
|
+
while(searchEntity !== rootEntity){
|
|
11534
|
+
var parent = searchEntity.parent;
|
|
11535
|
+
if (!parent) {
|
|
11536
|
+
return false;
|
|
11537
|
+
}
|
|
11538
|
+
inversePath.push(searchEntity.siblingIndex);
|
|
11539
|
+
searchEntity = parent;
|
|
11540
|
+
}
|
|
11541
|
+
return true;
|
|
11542
|
+
};
|
|
11543
|
+
/**
|
|
11544
|
+
* @internal
|
|
11545
|
+
*/ Entity._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
|
|
11546
|
+
var entity = rootEntity;
|
|
11547
|
+
for(var i = inversePath.length - 1; i >= 0; i--){
|
|
11548
|
+
entity = entity.children[inversePath[i]];
|
|
11549
|
+
}
|
|
11550
|
+
return entity;
|
|
11551
|
+
};
|
|
11552
|
+
_create_class(Entity, [
|
|
11240
11553
|
{
|
|
11241
|
-
key: "
|
|
11554
|
+
key: "isActive",
|
|
11242
11555
|
get: /**
|
|
11243
|
-
*
|
|
11556
|
+
* Whether to activate locally.
|
|
11244
11557
|
*/ function get() {
|
|
11245
|
-
return this.
|
|
11558
|
+
return this._isActive;
|
|
11246
11559
|
},
|
|
11247
11560
|
set: function set(value) {
|
|
11248
|
-
if (
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
var shaderData = this.shaderData;
|
|
11256
|
-
if (boneCount > 0) {
|
|
11257
|
-
this._jointMatrices = new Float32Array(boneCount * 16);
|
|
11258
|
-
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
11259
|
-
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, boneCount);
|
|
11561
|
+
if (value !== this._isActive) {
|
|
11562
|
+
this._isActive = value;
|
|
11563
|
+
if (value) {
|
|
11564
|
+
var parent = this._parent;
|
|
11565
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
11566
|
+
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
11567
|
+
activeChangeFlag |= ActiveChangeFlag.All;
|
|
11260
11568
|
} else {
|
|
11261
|
-
|
|
11262
|
-
|
|
11569
|
+
var _parent, _parent1;
|
|
11570
|
+
((_parent = parent) == null ? void 0 : _parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
11571
|
+
((_parent1 = parent) == null ? void 0 : _parent1._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
11263
11572
|
}
|
|
11573
|
+
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
11574
|
+
} else {
|
|
11575
|
+
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
11576
|
+
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
11577
|
+
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
11578
|
+
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
11264
11579
|
}
|
|
11265
|
-
this._bones = value;
|
|
11266
11580
|
}
|
|
11267
11581
|
}
|
|
11268
11582
|
},
|
|
11269
11583
|
{
|
|
11270
|
-
key: "
|
|
11584
|
+
key: "isActiveInHierarchy",
|
|
11271
11585
|
get: /**
|
|
11272
|
-
*
|
|
11273
|
-
* Skin Object.
|
|
11274
|
-
*
|
|
11275
|
-
* If you want get `skeleton`, use {@link SkinnedMeshRenderer.rootBone} instead.
|
|
11276
|
-
* If you want get `bones`, use {@link SkinnedMeshRenderer.bones} instead.
|
|
11277
|
-
* `inverseBindMatrices` will migrate to mesh in the future.
|
|
11278
|
-
*
|
|
11279
|
-
* @remarks `rootBone` and `bones` will not update when `skin` changed.
|
|
11586
|
+
* Whether it is active in the hierarchy.
|
|
11280
11587
|
*/ function get() {
|
|
11281
|
-
return this.
|
|
11588
|
+
return this._isActiveInHierarchy;
|
|
11589
|
+
}
|
|
11590
|
+
},
|
|
11591
|
+
{
|
|
11592
|
+
key: "parent",
|
|
11593
|
+
get: /**
|
|
11594
|
+
* The parent entity.
|
|
11595
|
+
*/ function get() {
|
|
11596
|
+
return this._parent;
|
|
11282
11597
|
},
|
|
11283
11598
|
set: function set(value) {
|
|
11284
|
-
this.
|
|
11599
|
+
this._setParent(value);
|
|
11285
11600
|
}
|
|
11286
|
-
}
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11601
|
+
},
|
|
11602
|
+
{
|
|
11603
|
+
key: "children",
|
|
11604
|
+
get: /**
|
|
11605
|
+
* The children entities
|
|
11606
|
+
*/ function get() {
|
|
11607
|
+
return this._children;
|
|
11608
|
+
}
|
|
11609
|
+
},
|
|
11610
|
+
{
|
|
11611
|
+
key: "childCount",
|
|
11612
|
+
get: /**
|
|
11613
|
+
* @deprecated Please use `children.length` property instead.
|
|
11614
|
+
* Number of the children entities
|
|
11615
|
+
*/ function get() {
|
|
11616
|
+
return this._children.length;
|
|
11617
|
+
}
|
|
11618
|
+
},
|
|
11619
|
+
{
|
|
11620
|
+
key: "scene",
|
|
11621
|
+
get: /**
|
|
11622
|
+
* The scene the entity belongs to.
|
|
11623
|
+
*/ function get() {
|
|
11624
|
+
return this._scene;
|
|
11625
|
+
}
|
|
11626
|
+
},
|
|
11627
|
+
{
|
|
11628
|
+
key: "siblingIndex",
|
|
11629
|
+
get: /**
|
|
11630
|
+
* The sibling index.
|
|
11631
|
+
*/ function get() {
|
|
11632
|
+
return this._siblingIndex;
|
|
11633
|
+
},
|
|
11634
|
+
set: function set(value) {
|
|
11635
|
+
if (this._siblingIndex === -1) {
|
|
11636
|
+
throw "The entity " + this.name + " is not in the hierarchy";
|
|
11637
|
+
}
|
|
11638
|
+
this._setSiblingIndex(this._isRoot ? this._scene._rootEntities : this._parent._children, value);
|
|
11639
|
+
}
|
|
11640
|
+
}
|
|
11641
|
+
]);
|
|
11642
|
+
return Entity;
|
|
11643
|
+
}(EngineObject);
|
|
11644
|
+
|
|
11645
|
+
/**
|
|
11646
|
+
* Skin used for skinned mesh renderer.
|
|
11647
|
+
*/ var Skin = /*#__PURE__*/ function(EngineObject1) {
|
|
11648
|
+
_inherits(Skin, EngineObject1);
|
|
11649
|
+
function Skin(name) {
|
|
11650
|
+
var _this;
|
|
11651
|
+
_this = EngineObject1.call(this, null) || this;
|
|
11652
|
+
_this.name = name;
|
|
11653
|
+
_this.inverseBindMatrices = new Array();
|
|
11654
|
+
_this._updatedManager = new UpdateFlagManager();
|
|
11655
|
+
_this._bones = new Array();
|
|
11656
|
+
_this._updateMark = -1;
|
|
11657
|
+
_this.joints = [];
|
|
11658
|
+
return _this;
|
|
11659
|
+
}
|
|
11660
|
+
var _proto = Skin.prototype;
|
|
11661
|
+
/**
|
|
11662
|
+
* @internal
|
|
11663
|
+
*/ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
|
|
11664
|
+
if (this._updateMark === renderer.engine.time.frameCount) {
|
|
11665
|
+
return;
|
|
11666
|
+
}
|
|
11667
|
+
var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
|
|
11668
|
+
var _this_rootBone;
|
|
11669
|
+
var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
|
|
11670
|
+
for(var i = bones.length - 1; i >= 0; i--){
|
|
11671
|
+
var bone = bones[i];
|
|
11672
|
+
var offset = i * 16;
|
|
11673
|
+
if (bone) {
|
|
11674
|
+
Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
|
|
11675
|
+
} else {
|
|
11676
|
+
skinMatrices.set(bindMatrices[i].elements, offset);
|
|
11677
|
+
}
|
|
11678
|
+
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
11679
|
+
}
|
|
11680
|
+
this._updateMark = renderer.engine.time.frameCount;
|
|
11681
|
+
};
|
|
11682
|
+
/**
|
|
11683
|
+
* @internal
|
|
11684
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
11685
|
+
var paths = new Array();
|
|
11686
|
+
// Clone rootBone
|
|
11687
|
+
var rootBone = this.rootBone;
|
|
11688
|
+
if (rootBone) {
|
|
11689
|
+
var success = Entity._getEntityHierarchyPath(srcRoot, rootBone, paths);
|
|
11690
|
+
target.rootBone = success ? Entity._getEntityByHierarchyPath(targetRoot, paths) : rootBone;
|
|
11691
|
+
}
|
|
11692
|
+
// Clone bones
|
|
11693
|
+
var bones = this.bones;
|
|
11694
|
+
if (bones.length > 0) {
|
|
11695
|
+
var boneCount = bones.length;
|
|
11696
|
+
var destBones = new Array(boneCount);
|
|
11697
|
+
for(var i = 0; i < boneCount; i++){
|
|
11698
|
+
var bone = bones[i];
|
|
11699
|
+
var success1 = Entity._getEntityHierarchyPath(srcRoot, bone, paths);
|
|
11700
|
+
destBones[i] = success1 ? Entity._getEntityByHierarchyPath(targetRoot, paths) : bone;
|
|
11701
|
+
}
|
|
11702
|
+
target.bones = destBones;
|
|
11703
|
+
}
|
|
11704
|
+
};
|
|
11705
|
+
_create_class(Skin, [
|
|
11706
|
+
{
|
|
11707
|
+
key: "rootBone",
|
|
11708
|
+
get: /**
|
|
11709
|
+
* Root bone.
|
|
11710
|
+
*/ function get() {
|
|
11711
|
+
return this._rootBone;
|
|
11712
|
+
},
|
|
11713
|
+
set: function set(value) {
|
|
11714
|
+
if (this._rootBone !== value) {
|
|
11715
|
+
this._updatedManager.dispatch(1, value);
|
|
11716
|
+
this._rootBone = value;
|
|
11717
|
+
}
|
|
11718
|
+
}
|
|
11719
|
+
},
|
|
11720
|
+
{
|
|
11721
|
+
key: "bones",
|
|
11722
|
+
get: /**
|
|
11723
|
+
* Bones of the skin.
|
|
11724
|
+
*/ function get() {
|
|
11725
|
+
return this._bones;
|
|
11726
|
+
},
|
|
11727
|
+
set: function set(value) {
|
|
11728
|
+
var _value;
|
|
11729
|
+
var bones = this._bones;
|
|
11730
|
+
var _value_length;
|
|
11731
|
+
var boneCount = (_value_length = (_value = value) == null ? void 0 : _value.length) != null ? _value_length : 0;
|
|
11732
|
+
var lastBoneCount = bones.length;
|
|
11733
|
+
bones.length = boneCount;
|
|
11734
|
+
for(var i = 0; i < boneCount; i++){
|
|
11735
|
+
bones[i] = value[i];
|
|
11736
|
+
}
|
|
11737
|
+
if (lastBoneCount !== boneCount) {
|
|
11738
|
+
this._skinMatrices = new Float32Array(boneCount * 16);
|
|
11739
|
+
this._updatedManager.dispatch(0, boneCount);
|
|
11740
|
+
}
|
|
11741
|
+
}
|
|
11742
|
+
},
|
|
11743
|
+
{
|
|
11744
|
+
key: "skeleton",
|
|
11745
|
+
get: /** @deprecated Please use `rootBone` instead. */ function get() {
|
|
11746
|
+
var _this_rootBone;
|
|
11747
|
+
return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
|
|
11748
|
+
},
|
|
11749
|
+
set: function set(value) {
|
|
11750
|
+
var rootBone = this._rootBone;
|
|
11751
|
+
if (rootBone) {
|
|
11752
|
+
rootBone.name = value;
|
|
11753
|
+
}
|
|
11754
|
+
}
|
|
11755
|
+
}
|
|
11756
|
+
]);
|
|
11757
|
+
return Skin;
|
|
11758
|
+
}(EngineObject);
|
|
11759
|
+
__decorate([
|
|
11760
|
+
deepClone
|
|
11761
|
+
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
11314
11762
|
__decorate([
|
|
11315
11763
|
ignoreClone
|
|
11316
|
-
],
|
|
11764
|
+
], Skin.prototype, "_skinMatrices", void 0);
|
|
11317
11765
|
__decorate([
|
|
11318
11766
|
ignoreClone
|
|
11319
|
-
],
|
|
11767
|
+
], Skin.prototype, "_updatedManager", void 0);
|
|
11320
11768
|
__decorate([
|
|
11321
11769
|
ignoreClone
|
|
11322
|
-
],
|
|
11770
|
+
], Skin.prototype, "_rootBone", void 0);
|
|
11323
11771
|
__decorate([
|
|
11324
11772
|
ignoreClone
|
|
11325
|
-
],
|
|
11773
|
+
], Skin.prototype, "_bones", void 0);
|
|
11326
11774
|
__decorate([
|
|
11327
11775
|
ignoreClone
|
|
11328
|
-
],
|
|
11776
|
+
], Skin.prototype, "_updateMark", void 0);
|
|
11777
|
+
var SkinUpdateFlag;
|
|
11778
|
+
(function(SkinUpdateFlag) {
|
|
11779
|
+
SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
|
|
11780
|
+
SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
|
|
11781
|
+
})(SkinUpdateFlag || (SkinUpdateFlag = {}));
|
|
11329
11782
|
|
|
11330
11783
|
/**
|
|
11331
|
-
*
|
|
11332
|
-
*/ var
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11784
|
+
* SkinnedMeshRenderer.
|
|
11785
|
+
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer1) {
|
|
11786
|
+
_inherits(SkinnedMeshRenderer, MeshRenderer1);
|
|
11787
|
+
function SkinnedMeshRenderer(entity) {
|
|
11788
|
+
var _this;
|
|
11789
|
+
_this = MeshRenderer1.call(this, entity) || this;
|
|
11790
|
+
_this._localBounds = new engineMath.BoundingBox();
|
|
11791
|
+
_this._jointDataCreateCache = new engineMath.Vector2(-1, -1);
|
|
11792
|
+
_this._skin = null;
|
|
11793
|
+
var rhi = _this.entity.engine._hardwareRenderer;
|
|
11794
|
+
var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
|
|
11795
|
+
// Limit size to 256 to avoid some problem:
|
|
11796
|
+
// 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!
|
|
11797
|
+
// 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.
|
|
11798
|
+
maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
|
|
11799
|
+
_this._maxVertexUniformVectors = maxVertexUniformVectors;
|
|
11800
|
+
_this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_assert_this_initialized(_this));
|
|
11801
|
+
_this._onSkinUpdated = _this._onSkinUpdated.bind(_assert_this_initialized(_this));
|
|
11802
|
+
var localBounds = _this._localBounds;
|
|
11803
|
+
// @ts-ignore
|
|
11804
|
+
localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
|
|
11805
|
+
// @ts-ignore
|
|
11806
|
+
localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
|
|
11807
|
+
return _this;
|
|
11337
11808
|
}
|
|
11338
|
-
var _proto =
|
|
11809
|
+
var _proto = SkinnedMeshRenderer.prototype;
|
|
11339
11810
|
/**
|
|
11340
|
-
*
|
|
11341
|
-
*/ _proto.
|
|
11342
|
-
var
|
|
11343
|
-
this.
|
|
11344
|
-
if (
|
|
11345
|
-
|
|
11346
|
-
pool.push(element);
|
|
11347
|
-
return element;
|
|
11348
|
-
} else {
|
|
11349
|
-
return pool[index];
|
|
11811
|
+
* @internal
|
|
11812
|
+
*/ _proto.update = function update() {
|
|
11813
|
+
var _skin;
|
|
11814
|
+
var skin = this._skin;
|
|
11815
|
+
if (((_skin = skin) == null ? void 0 : _skin.bones.length) > 0) {
|
|
11816
|
+
skin._updateSkinMatrices(this);
|
|
11350
11817
|
}
|
|
11351
11818
|
};
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11360
|
-
pool[i].dispose && pool[i].dispose();
|
|
11819
|
+
_proto._updateShaderData = function _updateShaderData(context, onlyMVP) {
|
|
11820
|
+
var _skin, _skin1;
|
|
11821
|
+
var _this = this, entity = _this.entity, skin = _this.skin;
|
|
11822
|
+
var _skin_rootBone;
|
|
11823
|
+
var worldMatrix = ((_skin_rootBone = (_skin = skin) == null ? void 0 : _skin.rootBone) != null ? _skin_rootBone : entity).transform.worldMatrix;
|
|
11824
|
+
if (onlyMVP) {
|
|
11825
|
+
this._updateMVPShaderData(context, worldMatrix);
|
|
11826
|
+
return;
|
|
11361
11827
|
}
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11828
|
+
this._updateTransformShaderData(context, worldMatrix);
|
|
11829
|
+
var shaderData = this.shaderData;
|
|
11830
|
+
var mesh = this.mesh;
|
|
11831
|
+
var blendShapeManager = mesh._blendShapeManager;
|
|
11832
|
+
blendShapeManager._updateShaderData(shaderData, this);
|
|
11833
|
+
var bones = (_skin1 = skin) == null ? void 0 : _skin1.bones;
|
|
11834
|
+
if (bones) {
|
|
11835
|
+
var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
|
|
11836
|
+
var boneCount = bones.length;
|
|
11837
|
+
var boneDataCreateCache = this._jointDataCreateCache;
|
|
11838
|
+
var boneCountChange = boneCount !== boneDataCreateCache.x;
|
|
11839
|
+
if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
|
|
11840
|
+
// directly use max joint count to avoid shader recompile
|
|
11841
|
+
// @TODO: different shader type should use different count, not always 44
|
|
11842
|
+
var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (44 + bsUniformOccupiesCount)) / 4);
|
|
11843
|
+
if (boneCount > remainUniformJointCount) {
|
|
11844
|
+
var engine = this.engine;
|
|
11845
|
+
if (engine._hardwareRenderer.canIUseMoreJoints) {
|
|
11846
|
+
if (boneCountChange) {
|
|
11847
|
+
var _this__jointTexture;
|
|
11848
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
11849
|
+
this._jointTexture = new Texture2D(engine, 4, boneCount, exports.TextureFormat.R32G32B32A32, false);
|
|
11850
|
+
this._jointTexture.filterMode = exports.TextureFilterMode.Point;
|
|
11851
|
+
this._jointTexture.isGCIgnored = true;
|
|
11852
|
+
}
|
|
11853
|
+
shaderData.disableMacro("RENDERER_JOINTS_NUM");
|
|
11854
|
+
shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
11855
|
+
shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
|
|
11856
|
+
} else {
|
|
11857
|
+
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);
|
|
11858
|
+
}
|
|
11859
|
+
} else {
|
|
11860
|
+
var _this__jointTexture1;
|
|
11861
|
+
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
11862
|
+
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
11863
|
+
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
11864
|
+
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
|
|
11865
|
+
}
|
|
11866
|
+
boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
|
|
11867
|
+
}
|
|
11868
|
+
if (this._jointTexture) {
|
|
11869
|
+
this._jointTexture.setPixelBuffer(skin._skinMatrices);
|
|
11390
11870
|
}
|
|
11391
|
-
} else {
|
|
11392
|
-
this._drawSubElement(element, camera);
|
|
11393
11871
|
}
|
|
11872
|
+
var layer = entity.layer;
|
|
11873
|
+
this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
|
|
11394
11874
|
};
|
|
11395
11875
|
/**
|
|
11396
11876
|
* @internal
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
this.
|
|
11401
|
-
this.
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11877
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
11878
|
+
var _this__jointTexture;
|
|
11879
|
+
MeshRenderer1.prototype._onDestroy.call(this);
|
|
11880
|
+
this._jointDataCreateCache = null;
|
|
11881
|
+
this._skin = null;
|
|
11882
|
+
this._blendShapeWeights = null;
|
|
11883
|
+
this._localBounds = null;
|
|
11884
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
11885
|
+
this._jointTexture = null;
|
|
11406
11886
|
};
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11887
|
+
/**
|
|
11888
|
+
* @internal
|
|
11889
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
11890
|
+
MeshRenderer1.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
|
|
11891
|
+
if (this.skin) {
|
|
11892
|
+
target._applySkin(null, target.skin);
|
|
11893
|
+
}
|
|
11894
|
+
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
11895
|
+
};
|
|
11896
|
+
/**
|
|
11897
|
+
* @internal
|
|
11898
|
+
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
11899
|
+
var _this_skin;
|
|
11900
|
+
var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
|
|
11901
|
+
if (rootBone) {
|
|
11902
|
+
engineMath.BoundingBox.transform(this._localBounds, rootBone.transform.worldMatrix, worldBounds);
|
|
11903
|
+
} else {
|
|
11904
|
+
MeshRenderer1.prototype._updateBounds.call(this, worldBounds);
|
|
11905
|
+
}
|
|
11906
|
+
};
|
|
11907
|
+
_proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
|
|
11908
|
+
var mesh = this._mesh;
|
|
11909
|
+
var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
|
|
11910
|
+
var lastBlendShapeWeights = this._blendShapeWeights;
|
|
11911
|
+
if (lastBlendShapeWeights) {
|
|
11912
|
+
var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
|
|
11913
|
+
if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
|
|
11914
|
+
var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
11915
|
+
if (newBlendShapeCount > lastBlendShapeWeightsCount) {
|
|
11916
|
+
newBlendShapeWeights.set(lastBlendShapeWeights);
|
|
11917
|
+
} else {
|
|
11918
|
+
for(var i = 0; i < newBlendShapeCount; i++){
|
|
11919
|
+
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
11920
|
+
}
|
|
11921
|
+
}
|
|
11922
|
+
this._blendShapeWeights = newBlendShapeWeights;
|
|
11923
|
+
}
|
|
11924
|
+
} else {
|
|
11925
|
+
this._blendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
11926
|
+
}
|
|
11927
|
+
};
|
|
11928
|
+
_proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
|
|
11929
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11930
|
+
};
|
|
11931
|
+
_proto._onSkinUpdated = function _onSkinUpdated(type, value) {
|
|
11932
|
+
switch(type){
|
|
11933
|
+
case SkinUpdateFlag.BoneCountChanged:
|
|
11934
|
+
var shaderData = this.shaderData;
|
|
11935
|
+
if (value > 0) {
|
|
11936
|
+
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
11937
|
+
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
|
|
11938
|
+
} else {
|
|
11939
|
+
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
11940
|
+
}
|
|
11941
|
+
break;
|
|
11942
|
+
case SkinUpdateFlag.RootBoneChanged:
|
|
11943
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
11944
|
+
break;
|
|
11945
|
+
}
|
|
11946
|
+
};
|
|
11947
|
+
_proto._applySkin = function _applySkin(lastSkin, value) {
|
|
11948
|
+
var _lastSkin_bones, _lastSkin, _lastSkin1, _lastSkin2, _value_bones, _value, _value1, _value2;
|
|
11949
|
+
var _lastSkin_bones_length;
|
|
11950
|
+
var lastSkinBoneCount = (_lastSkin_bones_length = (_lastSkin = lastSkin) == null ? void 0 : (_lastSkin_bones = _lastSkin.bones) == null ? void 0 : _lastSkin_bones.length) != null ? _lastSkin_bones_length : 0;
|
|
11951
|
+
var _lastSkin_rootBone;
|
|
11952
|
+
var lastRootBone = (_lastSkin_rootBone = (_lastSkin1 = lastSkin) == null ? void 0 : _lastSkin1.rootBone) != null ? _lastSkin_rootBone : this.entity;
|
|
11953
|
+
(_lastSkin2 = lastSkin) == null ? void 0 : _lastSkin2._updatedManager.removeListener(this._onSkinUpdated);
|
|
11954
|
+
var _value_bones_length;
|
|
11955
|
+
var skinBoneCount = (_value_bones_length = (_value = value) == null ? void 0 : (_value_bones = _value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
|
|
11956
|
+
var _value_rootBone;
|
|
11957
|
+
var rootBone = (_value_rootBone = (_value1 = value) == null ? void 0 : _value1.rootBone) != null ? _value_rootBone : this.entity;
|
|
11958
|
+
(_value2 = value) == null ? void 0 : _value2._updatedManager.addListener(this._onSkinUpdated);
|
|
11959
|
+
if (lastSkinBoneCount !== skinBoneCount) {
|
|
11960
|
+
this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
|
|
11961
|
+
}
|
|
11962
|
+
if (lastRootBone !== rootBone) {
|
|
11963
|
+
this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
|
|
11964
|
+
}
|
|
11965
|
+
};
|
|
11966
|
+
_create_class(SkinnedMeshRenderer, [
|
|
11967
|
+
{
|
|
11968
|
+
key: "skin",
|
|
11969
|
+
get: /**
|
|
11970
|
+
* Skin of the SkinnedMeshRenderer.
|
|
11971
|
+
*/ function get() {
|
|
11972
|
+
return this._skin;
|
|
11973
|
+
},
|
|
11974
|
+
set: function set(value) {
|
|
11975
|
+
var lastSkin = this._skin;
|
|
11976
|
+
if (lastSkin !== value) {
|
|
11977
|
+
this._applySkin(lastSkin, value);
|
|
11978
|
+
this._skin = value;
|
|
11979
|
+
}
|
|
11980
|
+
}
|
|
11981
|
+
},
|
|
11982
|
+
{
|
|
11983
|
+
key: "blendShapeWeights",
|
|
11984
|
+
get: /**
|
|
11985
|
+
* The weights of the BlendShapes.
|
|
11986
|
+
* @remarks Array index is BlendShape index.
|
|
11987
|
+
*/ function get() {
|
|
11988
|
+
this._checkBlendShapeWeightLength();
|
|
11989
|
+
return this._blendShapeWeights;
|
|
11990
|
+
},
|
|
11991
|
+
set: function set(value) {
|
|
11992
|
+
this._checkBlendShapeWeightLength();
|
|
11993
|
+
var blendShapeWeights = this._blendShapeWeights;
|
|
11994
|
+
if (value.length <= blendShapeWeights.length) {
|
|
11995
|
+
blendShapeWeights.set(value);
|
|
11996
|
+
} else {
|
|
11997
|
+
for(var i = 0, n = blendShapeWeights.length; i < n; i++){
|
|
11998
|
+
blendShapeWeights[i] = value[i];
|
|
11999
|
+
}
|
|
12000
|
+
}
|
|
12001
|
+
}
|
|
12002
|
+
},
|
|
12003
|
+
{
|
|
12004
|
+
key: "localBounds",
|
|
12005
|
+
get: /**
|
|
12006
|
+
* Local bounds.
|
|
12007
|
+
*/ function get() {
|
|
12008
|
+
return this._localBounds;
|
|
12009
|
+
},
|
|
12010
|
+
set: function set(value) {
|
|
12011
|
+
if (this._localBounds !== value) {
|
|
12012
|
+
this._localBounds.copyFrom(value);
|
|
12013
|
+
}
|
|
12014
|
+
}
|
|
12015
|
+
},
|
|
12016
|
+
{
|
|
12017
|
+
key: "rootBone",
|
|
12018
|
+
get: /**
|
|
12019
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.rootBone} instead.
|
|
12020
|
+
*/ function get() {
|
|
12021
|
+
return this.skin.rootBone;
|
|
12022
|
+
},
|
|
12023
|
+
set: function set(value) {
|
|
12024
|
+
this.skin.rootBone = value;
|
|
12025
|
+
}
|
|
12026
|
+
},
|
|
12027
|
+
{
|
|
12028
|
+
key: "bones",
|
|
12029
|
+
get: /**
|
|
12030
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.bones} instead.
|
|
12031
|
+
*/ function get() {
|
|
12032
|
+
return this.skin.bones;
|
|
12033
|
+
},
|
|
12034
|
+
set: function set(value) {
|
|
12035
|
+
this.skin.bones = value;
|
|
12036
|
+
}
|
|
12037
|
+
}
|
|
12038
|
+
]);
|
|
12039
|
+
return SkinnedMeshRenderer;
|
|
12040
|
+
}(MeshRenderer);
|
|
12041
|
+
(function() {
|
|
12042
|
+
SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
|
|
12043
|
+
})();
|
|
12044
|
+
(function() {
|
|
12045
|
+
SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
|
|
12046
|
+
})();
|
|
12047
|
+
(function() {
|
|
12048
|
+
SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
|
|
12049
|
+
})();
|
|
12050
|
+
__decorate([
|
|
12051
|
+
ignoreClone
|
|
12052
|
+
], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
|
|
12053
|
+
__decorate([
|
|
12054
|
+
deepClone
|
|
12055
|
+
], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
|
|
12056
|
+
__decorate([
|
|
12057
|
+
ignoreClone
|
|
12058
|
+
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
12059
|
+
__decorate([
|
|
12060
|
+
ignoreClone
|
|
12061
|
+
], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
|
|
12062
|
+
__decorate([
|
|
12063
|
+
ignoreClone
|
|
12064
|
+
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
12065
|
+
__decorate([
|
|
12066
|
+
ignoreClone
|
|
12067
|
+
], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
|
|
12068
|
+
__decorate([
|
|
12069
|
+
deepClone
|
|
12070
|
+
], SkinnedMeshRenderer.prototype, "_skin", void 0);
|
|
12071
|
+
__decorate([
|
|
12072
|
+
ignoreClone
|
|
12073
|
+
], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
|
|
12074
|
+
__decorate([
|
|
12075
|
+
ignoreClone
|
|
12076
|
+
], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
|
|
12077
|
+
|
|
12078
|
+
/**
|
|
12079
|
+
* Class pool utils.
|
|
12080
|
+
*/ var ClassPool = /*#__PURE__*/ function() {
|
|
12081
|
+
function ClassPool(type) {
|
|
12082
|
+
this._elementPoolIndex = 0;
|
|
12083
|
+
this._elementPool = [];
|
|
12084
|
+
this._type = type;
|
|
12085
|
+
}
|
|
12086
|
+
var _proto = ClassPool.prototype;
|
|
12087
|
+
/**
|
|
12088
|
+
* Get element from pool.
|
|
12089
|
+
*/ _proto.getFromPool = function getFromPool() {
|
|
12090
|
+
var _this = this, index = _this._elementPoolIndex, pool = _this._elementPool;
|
|
12091
|
+
this._elementPoolIndex++;
|
|
12092
|
+
if (pool.length === index) {
|
|
12093
|
+
var element = new this._type();
|
|
12094
|
+
pool.push(element);
|
|
12095
|
+
return element;
|
|
12096
|
+
} else {
|
|
12097
|
+
return pool[index];
|
|
12098
|
+
}
|
|
12099
|
+
};
|
|
12100
|
+
/**
|
|
12101
|
+
* Reset pool.
|
|
12102
|
+
*/ _proto.resetPool = function resetPool() {
|
|
12103
|
+
this._elementPoolIndex = 0;
|
|
12104
|
+
};
|
|
12105
|
+
_proto.garbageCollection = function garbageCollection() {
|
|
12106
|
+
var _this = this, pool = _this._elementPool;
|
|
12107
|
+
for(var i = pool.length - 1; i >= 0; i--){
|
|
12108
|
+
pool[i].dispose && pool[i].dispose();
|
|
12109
|
+
}
|
|
12110
|
+
};
|
|
12111
|
+
return ClassPool;
|
|
12112
|
+
}();
|
|
12113
|
+
|
|
12114
|
+
var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
12115
|
+
function Basic2DBatcher(engine) {
|
|
12116
|
+
/** @internal */ this._subMeshPool = new ClassPool(SubMesh);
|
|
12117
|
+
/** @internal */ this._batchedQueue = [];
|
|
12118
|
+
/** @internal */ this._meshes = [];
|
|
12119
|
+
/** @internal */ this._meshCount = 1;
|
|
12120
|
+
/** @internal */ this._vertexBuffers = [];
|
|
12121
|
+
/** @internal */ this._indiceBuffers = [];
|
|
12122
|
+
/** @internal */ this._flushId = 0;
|
|
12123
|
+
/** @internal */ this._vertexCount = 0;
|
|
12124
|
+
/** @internal */ this._elementCount = 0;
|
|
12125
|
+
this._engine = engine;
|
|
12126
|
+
this._initMeshes(engine);
|
|
12127
|
+
}
|
|
12128
|
+
var _proto = Basic2DBatcher.prototype;
|
|
12129
|
+
_proto.drawElement = function drawElement(element, camera) {
|
|
12130
|
+
var data = element.data;
|
|
12131
|
+
if (data.multiRenderData) {
|
|
12132
|
+
var charsData = data.charsData;
|
|
12133
|
+
var pool = camera.engine._renderElementPool;
|
|
12134
|
+
for(var i = 0, n = charsData.length; i < n; ++i){
|
|
12135
|
+
var charRenderElement = pool.getFromPool();
|
|
12136
|
+
charRenderElement.set(charsData[i], element.shaderPasses);
|
|
12137
|
+
this._drawSubElement(charRenderElement, camera);
|
|
12138
|
+
}
|
|
12139
|
+
} else {
|
|
12140
|
+
this._drawSubElement(element, camera);
|
|
12141
|
+
}
|
|
12142
|
+
};
|
|
12143
|
+
/**
|
|
12144
|
+
* @internal
|
|
12145
|
+
* Standalone for canvas 2d renderer plugin.
|
|
12146
|
+
*/ _proto._initMeshes = function _initMeshes(engine) {
|
|
12147
|
+
var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
|
|
12148
|
+
this._vertices = new Float32Array(MAX_VERTEX_COUNT * 9);
|
|
12149
|
+
this._indices = new Uint16Array(MAX_VERTEX_COUNT * 3);
|
|
12150
|
+
var _this = this, _meshes = _this._meshes, _meshCount = _this._meshCount;
|
|
12151
|
+
for(var i = 0; i < _meshCount; i++){
|
|
12152
|
+
_meshes[i] = this._createMesh(engine, i);
|
|
12153
|
+
}
|
|
12154
|
+
};
|
|
12155
|
+
_proto.flush = function flush(camera) {
|
|
12156
|
+
var batchedQueue = this._batchedQueue;
|
|
12157
|
+
if (batchedQueue.length === 0) {
|
|
12158
|
+
return;
|
|
11411
12159
|
}
|
|
11412
12160
|
this._updateData(this._engine);
|
|
11413
12161
|
this.drawBatches(camera);
|
|
@@ -13970,7 +14718,7 @@ var DirtyFlag;
|
|
|
13970
14718
|
*/ _proto.cloneTo = function cloneTo(target) {
|
|
13971
14719
|
target.shader = this.shader;
|
|
13972
14720
|
this.shaderData.cloneTo(target.shaderData);
|
|
13973
|
-
CloneManager.deepCloneObject(this.renderStates, target.renderStates);
|
|
14721
|
+
CloneManager.deepCloneObject(this.renderStates, target.renderStates, new Map());
|
|
13974
14722
|
};
|
|
13975
14723
|
_proto._addReferCount = function _addReferCount(value) {
|
|
13976
14724
|
if (this._destroyed) return;
|
|
@@ -14877,904 +15625,255 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
|
|
|
14877
15625
|
key: "anisotropyTexture",
|
|
14878
15626
|
get: /**
|
|
14879
15627
|
* The anisotropy texture.
|
|
14880
|
-
* @remarks
|
|
14881
|
-
* Red and green channels represent the anisotropy direction in [-1, 1] tangent, bitangent space, to be rotated by anisotropyRotation.
|
|
14882
|
-
* The blue channel contains strength as [0, 1] to be multiplied by anisotropy.
|
|
14883
|
-
*/ function get() {
|
|
14884
|
-
return this.shaderData.getTexture(PBRMaterial._anisotropyTextureProp);
|
|
14885
|
-
},
|
|
14886
|
-
set: function set(value) {
|
|
14887
|
-
this.shaderData.setTexture(PBRMaterial._anisotropyTextureProp, value);
|
|
14888
|
-
if (value) {
|
|
14889
|
-
this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
14890
|
-
} else {
|
|
14891
|
-
this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
14892
|
-
}
|
|
14893
|
-
}
|
|
14894
|
-
}
|
|
14895
|
-
]);
|
|
14896
|
-
return PBRMaterial;
|
|
14897
|
-
}(PBRBaseMaterial);
|
|
14898
|
-
(function() {
|
|
14899
|
-
PBRMaterial._metallicProp = ShaderProperty.getByName("material_Metal");
|
|
14900
|
-
})();
|
|
14901
|
-
(function() {
|
|
14902
|
-
PBRMaterial._roughnessProp = ShaderProperty.getByName("material_Roughness");
|
|
14903
|
-
})();
|
|
14904
|
-
(function() {
|
|
14905
|
-
PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
|
|
14906
|
-
})();
|
|
14907
|
-
(function() {
|
|
14908
|
-
PBRMaterial._iorProp = ShaderProperty.getByName("material_IOR");
|
|
14909
|
-
})();
|
|
14910
|
-
(function() {
|
|
14911
|
-
PBRMaterial._anisotropyInfoProp = ShaderProperty.getByName("material_AnisotropyInfo");
|
|
14912
|
-
})();
|
|
14913
|
-
(function() {
|
|
14914
|
-
PBRMaterial._anisotropyTextureProp = ShaderProperty.getByName("material_AnisotropyTexture");
|
|
14915
|
-
})();
|
|
14916
|
-
|
|
14917
|
-
/**
|
|
14918
|
-
* PBR (Specular-Glossiness Workflow) Material.
|
|
14919
|
-
*/ var PBRSpecularMaterial = /*#__PURE__*/ function(PBRBaseMaterial1) {
|
|
14920
|
-
_inherits(PBRSpecularMaterial, PBRBaseMaterial1);
|
|
14921
|
-
function PBRSpecularMaterial(engine) {
|
|
14922
|
-
var _this;
|
|
14923
|
-
_this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr-specular")) || this;
|
|
14924
|
-
_this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new engineMath.Color(1, 1, 1, 1));
|
|
14925
|
-
_this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, 1.0);
|
|
14926
|
-
return _this;
|
|
14927
|
-
}
|
|
14928
|
-
var _proto = PBRSpecularMaterial.prototype;
|
|
14929
|
-
/**
|
|
14930
|
-
* @inheritdoc
|
|
14931
|
-
*/ _proto.clone = function clone() {
|
|
14932
|
-
var dest = new PBRSpecularMaterial(this._engine);
|
|
14933
|
-
this.cloneTo(dest);
|
|
14934
|
-
return dest;
|
|
14935
|
-
};
|
|
14936
|
-
_create_class(PBRSpecularMaterial, [
|
|
14937
|
-
{
|
|
14938
|
-
key: "specularColor",
|
|
14939
|
-
get: /**
|
|
14940
|
-
* Specular color.
|
|
14941
|
-
*/ function get() {
|
|
14942
|
-
return this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
14943
|
-
},
|
|
14944
|
-
set: function set(value) {
|
|
14945
|
-
var specularColor = this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
14946
|
-
if (value !== specularColor) {
|
|
14947
|
-
specularColor.copyFrom(value);
|
|
14948
|
-
}
|
|
14949
|
-
}
|
|
14950
|
-
},
|
|
14951
|
-
{
|
|
14952
|
-
key: "glossiness",
|
|
14953
|
-
get: /**
|
|
14954
|
-
* Glossiness.
|
|
14955
|
-
*/ function get() {
|
|
14956
|
-
return this.shaderData.getFloat(PBRSpecularMaterial._glossinessProp);
|
|
14957
|
-
},
|
|
14958
|
-
set: function set(value) {
|
|
14959
|
-
this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, value);
|
|
14960
|
-
}
|
|
14961
|
-
},
|
|
14962
|
-
{
|
|
14963
|
-
key: "specularGlossinessTexture",
|
|
14964
|
-
get: /**
|
|
14965
|
-
* Specular glossiness texture.
|
|
14966
|
-
* @remarks RGB is specular, A is glossiness
|
|
14967
|
-
*/ function get() {
|
|
14968
|
-
return this.shaderData.getTexture(PBRSpecularMaterial._specularGlossinessTextureProp);
|
|
14969
|
-
},
|
|
14970
|
-
set: function set(value) {
|
|
14971
|
-
this.shaderData.setTexture(PBRSpecularMaterial._specularGlossinessTextureProp, value);
|
|
14972
|
-
if (value) {
|
|
14973
|
-
this.shaderData.enableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
14974
|
-
} else {
|
|
14975
|
-
this.shaderData.disableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
14976
|
-
}
|
|
14977
|
-
}
|
|
14978
|
-
}
|
|
14979
|
-
]);
|
|
14980
|
-
return PBRSpecularMaterial;
|
|
14981
|
-
}(PBRBaseMaterial);
|
|
14982
|
-
(function() {
|
|
14983
|
-
PBRSpecularMaterial._specularColorProp = ShaderProperty.getByName("material_PBRSpecularColor");
|
|
14984
|
-
})();
|
|
14985
|
-
(function() {
|
|
14986
|
-
PBRSpecularMaterial._glossinessProp = ShaderProperty.getByName("material_Glossiness");
|
|
14987
|
-
})();
|
|
14988
|
-
(function() {
|
|
14989
|
-
PBRSpecularMaterial._specularGlossinessTextureProp = ShaderProperty.getByName("material_SpecularGlossinessTexture");
|
|
14990
|
-
})();
|
|
14991
|
-
(function() {
|
|
14992
|
-
PBRSpecularMaterial._specularGlossinessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");
|
|
14993
|
-
})();
|
|
14994
|
-
|
|
14995
|
-
/**
|
|
14996
|
-
* Unlit Material.
|
|
14997
|
-
*/ var UnlitMaterial = /*#__PURE__*/ function(BaseMaterial1) {
|
|
14998
|
-
_inherits(UnlitMaterial, BaseMaterial1);
|
|
14999
|
-
function UnlitMaterial(engine) {
|
|
15000
|
-
var _this;
|
|
15001
|
-
_this = BaseMaterial1.call(this, engine, Shader.find("unlit")) || this;
|
|
15002
|
-
var shaderData = _this.shaderData;
|
|
15003
|
-
shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
|
|
15004
|
-
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
15005
|
-
shaderData.setColor(UnlitMaterial._baseColorProp, new engineMath.Color(1, 1, 1, 1));
|
|
15006
|
-
shaderData.setVector4(UnlitMaterial._tilingOffsetProp, new engineMath.Vector4(1, 1, 0, 0));
|
|
15007
|
-
return _this;
|
|
15008
|
-
}
|
|
15009
|
-
var _proto = UnlitMaterial.prototype;
|
|
15010
|
-
/**
|
|
15011
|
-
* @inheritdoc
|
|
15012
|
-
*/ _proto.clone = function clone() {
|
|
15013
|
-
var dest = new UnlitMaterial(this._engine);
|
|
15014
|
-
this.cloneTo(dest);
|
|
15015
|
-
return dest;
|
|
15016
|
-
};
|
|
15017
|
-
_create_class(UnlitMaterial, [
|
|
15018
|
-
{
|
|
15019
|
-
key: "baseColor",
|
|
15020
|
-
get: /**
|
|
15021
|
-
* Base color.
|
|
15022
|
-
*/ function get() {
|
|
15023
|
-
return this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
15024
|
-
},
|
|
15025
|
-
set: function set(value) {
|
|
15026
|
-
var baseColor = this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
15027
|
-
if (value !== baseColor) {
|
|
15028
|
-
baseColor.copyFrom(value);
|
|
15029
|
-
}
|
|
15030
|
-
}
|
|
15031
|
-
},
|
|
15032
|
-
{
|
|
15033
|
-
key: "baseTexture",
|
|
15034
|
-
get: /**
|
|
15035
|
-
* Base texture.
|
|
15036
|
-
*/ function get() {
|
|
15037
|
-
return this.shaderData.getTexture(UnlitMaterial._baseTextureProp);
|
|
15038
|
-
},
|
|
15039
|
-
set: function set(value) {
|
|
15040
|
-
this.shaderData.setTexture(UnlitMaterial._baseTextureProp, value);
|
|
15041
|
-
if (value) {
|
|
15042
|
-
this.shaderData.enableMacro(UnlitMaterial._baseTextureMacro);
|
|
15043
|
-
} else {
|
|
15044
|
-
this.shaderData.disableMacro(UnlitMaterial._baseTextureMacro);
|
|
15045
|
-
}
|
|
15046
|
-
}
|
|
15047
|
-
},
|
|
15048
|
-
{
|
|
15049
|
-
key: "tilingOffset",
|
|
15050
|
-
get: /**
|
|
15051
|
-
* Tiling and offset of main textures.
|
|
15052
|
-
*/ function get() {
|
|
15053
|
-
return this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
15054
|
-
},
|
|
15055
|
-
set: function set(value) {
|
|
15056
|
-
var tilingOffset = this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
15057
|
-
if (value !== tilingOffset) {
|
|
15058
|
-
tilingOffset.copyFrom(value);
|
|
15059
|
-
}
|
|
15060
|
-
}
|
|
15061
|
-
}
|
|
15062
|
-
]);
|
|
15063
|
-
return UnlitMaterial;
|
|
15064
|
-
}(BaseMaterial);
|
|
15065
|
-
|
|
15066
|
-
/**
|
|
15067
|
-
* @internal
|
|
15068
|
-
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
15069
|
-
function BasicResources(engine) {
|
|
15070
|
-
// prettier-ignore
|
|
15071
|
-
var vertices = new Float32Array([
|
|
15072
|
-
-1,
|
|
15073
|
-
-1,
|
|
15074
|
-
0,
|
|
15075
|
-
1,
|
|
15076
|
-
1,
|
|
15077
|
-
-1,
|
|
15078
|
-
1,
|
|
15079
|
-
1,
|
|
15080
|
-
-1,
|
|
15081
|
-
1,
|
|
15082
|
-
0,
|
|
15083
|
-
0,
|
|
15084
|
-
1,
|
|
15085
|
-
1,
|
|
15086
|
-
1,
|
|
15087
|
-
0
|
|
15088
|
-
]); // right-top
|
|
15089
|
-
// prettier-ignore
|
|
15090
|
-
var flipYVertices = new Float32Array([
|
|
15091
|
-
1,
|
|
15092
|
-
-1,
|
|
15093
|
-
1,
|
|
15094
|
-
0,
|
|
15095
|
-
-1,
|
|
15096
|
-
-1,
|
|
15097
|
-
0,
|
|
15098
|
-
0,
|
|
15099
|
-
1,
|
|
15100
|
-
1,
|
|
15101
|
-
1,
|
|
15102
|
-
1,
|
|
15103
|
-
-1,
|
|
15104
|
-
1,
|
|
15105
|
-
0,
|
|
15106
|
-
1
|
|
15107
|
-
]); // left-top
|
|
15108
|
-
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
15109
|
-
blitMaterial._addReferCount(1);
|
|
15110
|
-
blitMaterial.renderState.depthState.enabled = false;
|
|
15111
|
-
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
15112
|
-
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
15113
|
-
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
15114
|
-
this.blitMaterial = blitMaterial;
|
|
15115
|
-
}
|
|
15116
|
-
var _proto = BasicResources.prototype;
|
|
15117
|
-
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
15118
|
-
var mesh = new ModelMesh(engine);
|
|
15119
|
-
mesh._addReferCount(1);
|
|
15120
|
-
mesh.setVertexElements([
|
|
15121
|
-
new VertexElement("POSITION_UV", 0, exports.VertexElementFormat.Vector4, 0)
|
|
15122
|
-
]);
|
|
15123
|
-
mesh.setVertexBufferBinding(new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static), 16);
|
|
15124
|
-
mesh.addSubMesh(0, 4, exports.MeshTopology.TriangleStrip);
|
|
15125
|
-
return mesh;
|
|
15126
|
-
};
|
|
15127
|
-
return BasicResources;
|
|
15128
|
-
}();
|
|
15129
|
-
|
|
15130
|
-
/**
|
|
15131
|
-
* Layer, used for bit operations.
|
|
15132
|
-
*/ exports.Layer = void 0;
|
|
15133
|
-
(function(Layer) {
|
|
15134
|
-
Layer[Layer[/** Layer 0. */ "Layer0"] = 0x1] = "Layer0";
|
|
15135
|
-
Layer[Layer[/** Layer 1. */ "Layer1"] = 0x2] = "Layer1";
|
|
15136
|
-
Layer[Layer[/** Layer 2. */ "Layer2"] = 0x4] = "Layer2";
|
|
15137
|
-
Layer[Layer[/** Layer 3. */ "Layer3"] = 0x8] = "Layer3";
|
|
15138
|
-
Layer[Layer[/** Layer 4. */ "Layer4"] = 0x10] = "Layer4";
|
|
15139
|
-
Layer[Layer[/** Layer 5. */ "Layer5"] = 0x20] = "Layer5";
|
|
15140
|
-
Layer[Layer[/** Layer 6. */ "Layer6"] = 0x40] = "Layer6";
|
|
15141
|
-
Layer[Layer[/** Layer 7. */ "Layer7"] = 0x80] = "Layer7";
|
|
15142
|
-
Layer[Layer[/** Layer 8. */ "Layer8"] = 0x100] = "Layer8";
|
|
15143
|
-
Layer[Layer[/** Layer 9. */ "Layer9"] = 0x200] = "Layer9";
|
|
15144
|
-
Layer[Layer[/** Layer 10. */ "Layer10"] = 0x400] = "Layer10";
|
|
15145
|
-
Layer[Layer[/** Layer 11. */ "Layer11"] = 0x800] = "Layer11";
|
|
15146
|
-
Layer[Layer[/** Layer 12. */ "Layer12"] = 0x1000] = "Layer12";
|
|
15147
|
-
Layer[Layer[/** Layer 13. */ "Layer13"] = 0x2000] = "Layer13";
|
|
15148
|
-
Layer[Layer[/** Layer 14. */ "Layer14"] = 0x4000] = "Layer14";
|
|
15149
|
-
Layer[Layer[/** Layer 15. */ "Layer15"] = 0x8000] = "Layer15";
|
|
15150
|
-
Layer[Layer[/** Layer 16. */ "Layer16"] = 0x10000] = "Layer16";
|
|
15151
|
-
Layer[Layer[/** Layer 17. */ "Layer17"] = 0x20000] = "Layer17";
|
|
15152
|
-
Layer[Layer[/** Layer 18. */ "Layer18"] = 0x40000] = "Layer18";
|
|
15153
|
-
Layer[Layer[/** Layer 19. */ "Layer19"] = 0x80000] = "Layer19";
|
|
15154
|
-
Layer[Layer[/** Layer 20. */ "Layer20"] = 0x100000] = "Layer20";
|
|
15155
|
-
Layer[Layer[/** Layer 21. */ "Layer21"] = 0x200000] = "Layer21";
|
|
15156
|
-
Layer[Layer[/** Layer 22. */ "Layer22"] = 0x400000] = "Layer22";
|
|
15157
|
-
Layer[Layer[/** Layer 23. */ "Layer23"] = 0x800000] = "Layer23";
|
|
15158
|
-
Layer[Layer[/** Layer 24. */ "Layer24"] = 0x1000000] = "Layer24";
|
|
15159
|
-
Layer[Layer[/** Layer 25. */ "Layer25"] = 0x2000000] = "Layer25";
|
|
15160
|
-
Layer[Layer[/** Layer 26. */ "Layer26"] = 0x4000000] = "Layer26";
|
|
15161
|
-
Layer[Layer[/** Layer 27. */ "Layer27"] = 0x8000000] = "Layer27";
|
|
15162
|
-
Layer[Layer[/** Layer 28. */ "Layer28"] = 0x10000000] = "Layer28";
|
|
15163
|
-
Layer[Layer[/** Layer 29. */ "Layer29"] = 0x20000000] = "Layer29";
|
|
15164
|
-
Layer[Layer[/** Layer 30. */ "Layer30"] = 0x40000000] = "Layer30";
|
|
15165
|
-
Layer[Layer[/** Layer 31. */ "Layer31"] = 0x80000000] = "Layer31";
|
|
15166
|
-
Layer[Layer[/** All layers. */ "Everything"] = 0xffffffff] = "Everything";
|
|
15167
|
-
Layer[Layer[/** None layer. */ "Nothing"] = 0x0] = "Nothing";
|
|
15168
|
-
})(exports.Layer || (exports.Layer = {}));
|
|
15169
|
-
|
|
15170
|
-
var ComponentCloner = /*#__PURE__*/ function() {
|
|
15171
|
-
function ComponentCloner() {}
|
|
15172
|
-
/**
|
|
15173
|
-
* Clone component.
|
|
15174
|
-
* @param source - Clone source
|
|
15175
|
-
* @param target - Clone target
|
|
15176
|
-
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot) {
|
|
15177
|
-
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
15178
|
-
for(var k in source){
|
|
15179
|
-
CloneManager.cloneProperty(source, target, k, cloneModes[k]);
|
|
15180
|
-
}
|
|
15181
|
-
if (source._cloneTo) {
|
|
15182
|
-
source._cloneTo(target, srcRoot, targetRoot);
|
|
15183
|
-
}
|
|
15184
|
-
};
|
|
15185
|
-
return ComponentCloner;
|
|
15186
|
-
}();
|
|
15187
|
-
|
|
15188
|
-
/**
|
|
15189
|
-
* Entity, be used as components container.
|
|
15190
|
-
*/ var Entity = /*#__PURE__*/ function(EngineObject1) {
|
|
15191
|
-
_inherits(Entity, EngineObject1);
|
|
15192
|
-
function Entity(engine, name) {
|
|
15193
|
-
var _this;
|
|
15194
|
-
_this = EngineObject1.call(this, engine) || this;
|
|
15195
|
-
/** The layer the entity belongs to. */ _this.layer = exports.Layer.Layer0;
|
|
15196
|
-
/** @internal */ _this._isActiveInHierarchy = false;
|
|
15197
|
-
/** @internal */ _this._isActiveInScene = false;
|
|
15198
|
-
/** @internal */ _this._components = [];
|
|
15199
|
-
/** @internal */ _this._scripts = new DisorderedArray();
|
|
15200
|
-
/** @internal */ _this._children = [];
|
|
15201
|
-
/** @internal */ _this._isRoot = false;
|
|
15202
|
-
/** @internal */ _this._isActive = true;
|
|
15203
|
-
/** @internal */ _this._siblingIndex = -1;
|
|
15204
|
-
/** @internal */ _this._isTemplate = false;
|
|
15205
|
-
_this._parent = null;
|
|
15206
|
-
//--------------------------------------------------------------deprecated----------------------------------------------------------------
|
|
15207
|
-
_this._invModelMatrix = new engineMath.Matrix();
|
|
15208
|
-
_this.name = name;
|
|
15209
|
-
_this.transform = _this.addComponent(Transform);
|
|
15210
|
-
_this._inverseWorldMatFlag = _this.transform.registerWorldChangeFlag();
|
|
15211
|
-
return _this;
|
|
15212
|
-
}
|
|
15213
|
-
var _proto = Entity.prototype;
|
|
15214
|
-
/**
|
|
15215
|
-
* Add component based on the component type.
|
|
15216
|
-
* @param type - The type of the component
|
|
15217
|
-
* @returns The component which has been added
|
|
15218
|
-
*/ _proto.addComponent = function addComponent(type) {
|
|
15219
|
-
ComponentsDependencies._addCheck(this, type);
|
|
15220
|
-
var component = new type(this);
|
|
15221
|
-
this._components.push(component);
|
|
15222
|
-
component._setActive(true, ActiveChangeFlag.All);
|
|
15223
|
-
return component;
|
|
15224
|
-
};
|
|
15225
|
-
/**
|
|
15226
|
-
* Get component which match the type.
|
|
15227
|
-
* @param type - The type of the component
|
|
15228
|
-
* @returns The first component which match type
|
|
15229
|
-
*/ _proto.getComponent = function getComponent(type) {
|
|
15230
|
-
var components = this._components;
|
|
15231
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
15232
|
-
var component = components[i];
|
|
15233
|
-
if (_instanceof(component, type)) {
|
|
15234
|
-
return component;
|
|
15235
|
-
}
|
|
15236
|
-
}
|
|
15237
|
-
return null;
|
|
15238
|
-
};
|
|
15239
|
-
/**
|
|
15240
|
-
* Get components which match the type.
|
|
15241
|
-
* @param type - The type of the component
|
|
15242
|
-
* @param results - The components which match type
|
|
15243
|
-
* @returns The components which match type
|
|
15244
|
-
*/ _proto.getComponents = function getComponents(type, results) {
|
|
15245
|
-
results.length = 0;
|
|
15246
|
-
var components = this._components;
|
|
15247
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
15248
|
-
var component = components[i];
|
|
15249
|
-
if (_instanceof(component, type)) {
|
|
15250
|
-
results.push(component);
|
|
15251
|
-
}
|
|
15252
|
-
}
|
|
15253
|
-
return results;
|
|
15254
|
-
};
|
|
15255
|
-
/**
|
|
15256
|
-
* Get the components which match the type of the entity and it's children.
|
|
15257
|
-
* @param type - The component type
|
|
15258
|
-
* @param results - The components collection
|
|
15259
|
-
* @returns The components collection which match the type
|
|
15260
|
-
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
15261
|
-
results.length = 0;
|
|
15262
|
-
this._getComponentsInChildren(type, results);
|
|
15263
|
-
return results;
|
|
15264
|
-
};
|
|
15265
|
-
_proto.addChild = function addChild(indexOrChild, child) {
|
|
15266
|
-
var index;
|
|
15267
|
-
if (typeof indexOrChild === "number") {
|
|
15268
|
-
index = indexOrChild;
|
|
15269
|
-
} else {
|
|
15270
|
-
index = undefined;
|
|
15271
|
-
child = indexOrChild;
|
|
15272
|
-
}
|
|
15273
|
-
if (child._isRoot) {
|
|
15274
|
-
child._scene._removeFromEntityList(child);
|
|
15275
|
-
child._isRoot = false;
|
|
15276
|
-
this._addToChildrenList(index, child);
|
|
15277
|
-
child._parent = this;
|
|
15278
|
-
var oldScene = child._scene;
|
|
15279
|
-
var newScene = this._scene;
|
|
15280
|
-
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
15281
|
-
if (!this._isActiveInHierarchy) {
|
|
15282
|
-
child._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15283
|
-
}
|
|
15284
|
-
if (child._isActiveInScene) {
|
|
15285
|
-
if (this._isActiveInScene) {
|
|
15286
|
-
// Cross scene should inActive first and then active
|
|
15287
|
-
oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
15288
|
-
} else {
|
|
15289
|
-
inActiveChangeFlag |= ActiveChangeFlag.Scene;
|
|
15290
|
-
}
|
|
15291
|
-
}
|
|
15292
|
-
inActiveChangeFlag && child._processInActive(inActiveChangeFlag);
|
|
15293
|
-
if (child._scene !== newScene) {
|
|
15294
|
-
Entity._traverseSetOwnerScene(child, newScene);
|
|
15295
|
-
}
|
|
15296
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
15297
|
-
if (child._isActive) {
|
|
15298
|
-
if (this._isActiveInHierarchy) {
|
|
15299
|
-
!child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15300
|
-
}
|
|
15301
|
-
if (this._isActiveInScene) {
|
|
15302
|
-
(!child._isActiveInScene || oldScene !== newScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
15303
|
-
}
|
|
15304
|
-
}
|
|
15305
|
-
activeChangeFlag && child._processActive(activeChangeFlag);
|
|
15306
|
-
child._setTransformDirty();
|
|
15307
|
-
} else {
|
|
15308
|
-
child._setParent(this, index);
|
|
15309
|
-
}
|
|
15310
|
-
};
|
|
15311
|
-
/**
|
|
15312
|
-
* Remove child entity.
|
|
15313
|
-
* @param child - The child entity which want to be removed
|
|
15314
|
-
*/ _proto.removeChild = function removeChild(child) {
|
|
15315
|
-
child._setParent(null);
|
|
15316
|
-
};
|
|
15317
|
-
/**
|
|
15318
|
-
* @deprecated Please use `children` property instead.
|
|
15319
|
-
* Find child entity by index.
|
|
15320
|
-
* @param index - The index of the child entity
|
|
15321
|
-
* @returns The component which be found
|
|
15322
|
-
*/ _proto.getChild = function getChild(index) {
|
|
15323
|
-
return this._children[index];
|
|
15324
|
-
};
|
|
15325
|
-
/**
|
|
15326
|
-
* Find entity by name.
|
|
15327
|
-
* @param name - The name of the entity which want to be found
|
|
15328
|
-
* @returns The component which be found
|
|
15329
|
-
*/ _proto.findByName = function findByName(name) {
|
|
15330
|
-
if (name === this.name) {
|
|
15331
|
-
return this;
|
|
15332
|
-
}
|
|
15333
|
-
var children = this._children;
|
|
15334
|
-
for(var i = 0, n = children.length; i < n; i++){
|
|
15335
|
-
var target = children[i].findByName(name);
|
|
15336
|
-
if (target) {
|
|
15337
|
-
return target;
|
|
15338
|
-
}
|
|
15339
|
-
}
|
|
15340
|
-
return null;
|
|
15341
|
-
};
|
|
15342
|
-
/**
|
|
15343
|
-
* Find the entity by path.
|
|
15344
|
-
* @param path - The path fo the entity eg: /entity
|
|
15345
|
-
* @returns The component which be found
|
|
15346
|
-
*/ _proto.findByPath = function findByPath(path) {
|
|
15347
|
-
var splits = path.split("/");
|
|
15348
|
-
var entity = this;
|
|
15349
|
-
for(var i = 0, length = splits.length; i < length; ++i){
|
|
15350
|
-
var split = splits[i];
|
|
15351
|
-
if (split) {
|
|
15352
|
-
entity = Entity._findChildByName(entity, split);
|
|
15353
|
-
if (!entity) {
|
|
15354
|
-
return null;
|
|
15355
|
-
}
|
|
15356
|
-
}
|
|
15357
|
-
}
|
|
15358
|
-
return entity;
|
|
15359
|
-
};
|
|
15360
|
-
/**
|
|
15361
|
-
* Create child entity.
|
|
15362
|
-
* @param name - The child entity's name
|
|
15363
|
-
* @returns The child entity
|
|
15364
|
-
*/ _proto.createChild = function createChild(name) {
|
|
15365
|
-
var child = new Entity(this.engine, name);
|
|
15366
|
-
child.layer = this.layer;
|
|
15367
|
-
child.parent = this;
|
|
15368
|
-
return child;
|
|
15369
|
-
};
|
|
15370
|
-
/**
|
|
15371
|
-
* Clear children entities.
|
|
15372
|
-
*/ _proto.clearChildren = function clearChildren() {
|
|
15373
|
-
var children = this._children;
|
|
15374
|
-
for(var i = children.length - 1; i >= 0; i--){
|
|
15375
|
-
var child = children[i];
|
|
15376
|
-
child._parent = null;
|
|
15377
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
15378
|
-
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15379
|
-
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
15380
|
-
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
15381
|
-
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
15382
|
-
}
|
|
15383
|
-
children.length = 0;
|
|
15384
|
-
};
|
|
15385
|
-
/**
|
|
15386
|
-
* Clone.
|
|
15387
|
-
* @returns Cloned entity
|
|
15388
|
-
*/ _proto.clone = function clone() {
|
|
15389
|
-
var cloneEntity = this._createCloneEntity(this);
|
|
15390
|
-
this._parseCloneEntity(this, cloneEntity, this, cloneEntity);
|
|
15391
|
-
return cloneEntity;
|
|
15392
|
-
};
|
|
15393
|
-
/**
|
|
15394
|
-
* @internal
|
|
15395
|
-
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
15396
|
-
this._isTemplate = true;
|
|
15397
|
-
this._templateResource = templateResource;
|
|
15398
|
-
};
|
|
15399
|
-
_proto._createCloneEntity = function _createCloneEntity(srcEntity) {
|
|
15400
|
-
var cloneEntity = new Entity(srcEntity._engine, srcEntity.name);
|
|
15401
|
-
var templateResource = this._templateResource;
|
|
15402
|
-
if (templateResource) {
|
|
15403
|
-
cloneEntity._templateResource = templateResource;
|
|
15404
|
-
templateResource._addReferCount(1);
|
|
15405
|
-
}
|
|
15406
|
-
cloneEntity.layer = srcEntity.layer;
|
|
15407
|
-
cloneEntity._isActive = srcEntity._isActive;
|
|
15408
|
-
var cloneTransform = cloneEntity.transform;
|
|
15409
|
-
var srcTransform = srcEntity.transform;
|
|
15410
|
-
cloneTransform.position = srcTransform.position;
|
|
15411
|
-
cloneTransform.rotation = srcTransform.rotation;
|
|
15412
|
-
cloneTransform.scale = srcTransform.scale;
|
|
15413
|
-
var children = srcEntity._children;
|
|
15414
|
-
for(var i = 0, n = srcEntity._children.length; i < n; i++){
|
|
15415
|
-
cloneEntity.addChild(this._createCloneEntity(children[i]));
|
|
15416
|
-
}
|
|
15417
|
-
return cloneEntity;
|
|
15418
|
-
};
|
|
15419
|
-
_proto._parseCloneEntity = function _parseCloneEntity(srcEntity, targetEntity, srcRoot, targetRoot) {
|
|
15420
|
-
var srcChildren = srcEntity._children;
|
|
15421
|
-
var targetChildren = targetEntity._children;
|
|
15422
|
-
for(var i = 0, n = srcChildren.length; i < n; i++){
|
|
15423
|
-
this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot);
|
|
15424
|
-
}
|
|
15425
|
-
var components = srcEntity._components;
|
|
15426
|
-
for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
|
|
15427
|
-
var sourceComp = components[i1];
|
|
15428
|
-
if (!_instanceof(sourceComp, Transform)) {
|
|
15429
|
-
var targetComp = targetEntity.addComponent(sourceComp.constructor);
|
|
15430
|
-
ComponentCloner.cloneComponent(sourceComp, targetComp, srcRoot, targetRoot);
|
|
15431
|
-
}
|
|
15432
|
-
}
|
|
15433
|
-
};
|
|
15434
|
-
/**
|
|
15435
|
-
* Destroy self.
|
|
15436
|
-
*/ _proto.destroy = function destroy() {
|
|
15437
|
-
if (this._destroyed) {
|
|
15438
|
-
return;
|
|
15439
|
-
}
|
|
15440
|
-
EngineObject1.prototype.destroy.call(this);
|
|
15441
|
-
if (this._templateResource) {
|
|
15442
|
-
this._isTemplate || this._templateResource._addReferCount(-1);
|
|
15443
|
-
this._templateResource = null;
|
|
15444
|
-
}
|
|
15445
|
-
var components = this._components;
|
|
15446
|
-
for(var i = components.length - 1; i >= 0; i--){
|
|
15447
|
-
components[i].destroy();
|
|
15448
|
-
}
|
|
15449
|
-
this._components.length = 0;
|
|
15450
|
-
var children = this._children;
|
|
15451
|
-
while(children.length > 0){
|
|
15452
|
-
children[0].destroy();
|
|
15453
|
-
}
|
|
15454
|
-
if (this._isRoot) {
|
|
15455
|
-
this._scene.removeRootEntity(this);
|
|
15456
|
-
} else {
|
|
15457
|
-
this._setParent(null);
|
|
15458
|
-
}
|
|
15459
|
-
this.isActive = false;
|
|
15460
|
-
};
|
|
15461
|
-
/**
|
|
15462
|
-
* @internal
|
|
15463
|
-
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
15464
|
-
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
15465
|
-
var components = this._components;
|
|
15466
|
-
components.splice(components.indexOf(component), 1);
|
|
15467
|
-
};
|
|
15468
|
-
/**
|
|
15469
|
-
* @internal
|
|
15470
|
-
*/ _proto._addScript = function _addScript(script) {
|
|
15471
|
-
script._entityScriptsIndex = this._scripts.length;
|
|
15472
|
-
this._scripts.add(script);
|
|
15473
|
-
};
|
|
15474
|
-
/**
|
|
15475
|
-
* @internal
|
|
15476
|
-
*/ _proto._removeScript = function _removeScript(script) {
|
|
15477
|
-
var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
|
|
15478
|
-
replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
|
|
15479
|
-
script._entityScriptsIndex = -1;
|
|
15480
|
-
};
|
|
15481
|
-
/**
|
|
15482
|
-
* @internal
|
|
15483
|
-
*/ _proto._removeFromParent = function _removeFromParent() {
|
|
15484
|
-
var oldParent = this._parent;
|
|
15485
|
-
if (oldParent != null) {
|
|
15486
|
-
var oldSibling = oldParent._children;
|
|
15487
|
-
var index = this._siblingIndex;
|
|
15488
|
-
oldSibling.splice(index, 1);
|
|
15489
|
-
for(var n = oldSibling.length; index < n; index++){
|
|
15490
|
-
oldSibling[index]._siblingIndex--;
|
|
15491
|
-
}
|
|
15492
|
-
this._parent = null;
|
|
15493
|
-
this._siblingIndex = -1;
|
|
15494
|
-
}
|
|
15495
|
-
};
|
|
15496
|
-
/**
|
|
15497
|
-
* @internal
|
|
15498
|
-
*/ _proto._processActive = function _processActive(activeChangeFlag) {
|
|
15499
|
-
if (this._activeChangedComponents) {
|
|
15500
|
-
throw "Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";
|
|
15501
|
-
}
|
|
15502
|
-
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
15503
|
-
this._setActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
15504
|
-
this._setActiveComponents(true, activeChangeFlag);
|
|
15505
|
-
};
|
|
15506
|
-
/**
|
|
15507
|
-
* @internal
|
|
15508
|
-
*/ _proto._processInActive = function _processInActive(activeChangeFlag) {
|
|
15509
|
-
if (this._activeChangedComponents) {
|
|
15510
|
-
throw "Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";
|
|
15511
|
-
}
|
|
15512
|
-
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
15513
|
-
this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
15514
|
-
this._setActiveComponents(false, activeChangeFlag);
|
|
15515
|
-
};
|
|
15516
|
-
_proto._addToChildrenList = function _addToChildrenList(index, child) {
|
|
15517
|
-
var children = this._children;
|
|
15518
|
-
var childCount = children.length;
|
|
15519
|
-
if (index === undefined) {
|
|
15520
|
-
child._siblingIndex = childCount;
|
|
15521
|
-
children.push(child);
|
|
15522
|
-
} else {
|
|
15523
|
-
if (index < 0 || index > childCount) {
|
|
15524
|
-
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
15525
|
-
}
|
|
15526
|
-
child._siblingIndex = index;
|
|
15527
|
-
children.splice(index, 0, child);
|
|
15528
|
-
for(var i = index + 1, n = childCount + 1; i < n; i++){
|
|
15529
|
-
children[i]._siblingIndex++;
|
|
15530
|
-
}
|
|
15531
|
-
}
|
|
15532
|
-
};
|
|
15533
|
-
_proto._setParent = function _setParent(parent, siblingIndex) {
|
|
15534
|
-
var oldParent = this._parent;
|
|
15535
|
-
if (parent !== oldParent) {
|
|
15536
|
-
this._removeFromParent();
|
|
15537
|
-
this._parent = parent;
|
|
15538
|
-
if (parent) {
|
|
15539
|
-
parent._addToChildrenList(siblingIndex, this);
|
|
15540
|
-
var oldScene = this._scene;
|
|
15541
|
-
var parentScene = parent._scene;
|
|
15542
|
-
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
15543
|
-
if (!parent._isActiveInHierarchy) {
|
|
15544
|
-
this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15545
|
-
}
|
|
15546
|
-
if (parent._isActiveInScene) {
|
|
15547
|
-
// cross scene should inActive first and then active
|
|
15548
|
-
this._isActiveInScene && oldScene !== parentScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
15549
|
-
} else {
|
|
15550
|
-
this._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
15551
|
-
}
|
|
15552
|
-
inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
|
|
15553
|
-
if (oldScene !== parentScene) {
|
|
15554
|
-
Entity._traverseSetOwnerScene(this, parentScene);
|
|
15555
|
-
}
|
|
15556
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
15557
|
-
if (this._isActive) {
|
|
15558
|
-
if (parent._isActiveInHierarchy) {
|
|
15559
|
-
!this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15560
|
-
}
|
|
15561
|
-
if (parent._isActiveInScene) {
|
|
15562
|
-
(!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
15563
|
-
}
|
|
15564
|
-
}
|
|
15565
|
-
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
15566
|
-
} else {
|
|
15567
|
-
var inActiveChangeFlag1 = ActiveChangeFlag.None;
|
|
15568
|
-
this._isActiveInHierarchy && (inActiveChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
15569
|
-
this._isActiveInScene && (inActiveChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
15570
|
-
inActiveChangeFlag1 && this._processInActive(inActiveChangeFlag1);
|
|
15571
|
-
if (oldParent) {
|
|
15572
|
-
Entity._traverseSetOwnerScene(this, null);
|
|
15573
|
-
}
|
|
15574
|
-
}
|
|
15575
|
-
this._setTransformDirty();
|
|
15576
|
-
}
|
|
15577
|
-
};
|
|
15578
|
-
_proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
|
|
15579
|
-
for(var i = this._components.length - 1; i >= 0; i--){
|
|
15580
|
-
var component = this._components[i];
|
|
15581
|
-
if (_instanceof(component, type)) {
|
|
15582
|
-
results.push(component);
|
|
15583
|
-
}
|
|
15584
|
-
}
|
|
15585
|
-
for(var i1 = this._children.length - 1; i1 >= 0; i1--){
|
|
15586
|
-
this._children[i1]._getComponentsInChildren(type, results);
|
|
15587
|
-
}
|
|
15588
|
-
};
|
|
15589
|
-
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
15590
|
-
var activeChangedComponents = this._activeChangedComponents;
|
|
15591
|
-
for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
|
|
15592
|
-
activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
|
|
15593
|
-
}
|
|
15594
|
-
this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
|
|
15595
|
-
this._activeChangedComponents = null;
|
|
15596
|
-
};
|
|
15597
|
-
_proto._setActiveInHierarchy = function _setActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
15598
|
-
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = true);
|
|
15599
|
-
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = true);
|
|
15600
|
-
var components = this._components;
|
|
15601
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
15602
|
-
var component = components[i];
|
|
15603
|
-
(component.enabled || !component._awoken) && activeChangedComponents.push(component);
|
|
15604
|
-
}
|
|
15605
|
-
var children = this._children;
|
|
15606
|
-
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
15607
|
-
var child = children[i1];
|
|
15608
|
-
child.isActive && child._setActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
15609
|
-
}
|
|
15610
|
-
};
|
|
15611
|
-
_proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
15612
|
-
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
|
|
15613
|
-
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
|
|
15614
|
-
var components = this._components;
|
|
15615
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
15616
|
-
var component = components[i];
|
|
15617
|
-
component.enabled && activeChangedComponents.push(component);
|
|
15618
|
-
}
|
|
15619
|
-
var children = this._children;
|
|
15620
|
-
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
15621
|
-
var child = children[i1];
|
|
15622
|
-
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
15623
|
-
}
|
|
15624
|
-
};
|
|
15625
|
-
_proto._setTransformDirty = function _setTransformDirty() {
|
|
15626
|
-
if (this.transform) {
|
|
15627
|
-
this.transform._parentChange();
|
|
15628
|
-
} else {
|
|
15629
|
-
for(var i = 0, len = this._children.length; i < len; i++){
|
|
15630
|
-
this._children[i]._setTransformDirty();
|
|
15631
|
-
}
|
|
15632
|
-
}
|
|
15633
|
-
};
|
|
15634
|
-
_proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
|
|
15635
|
-
target = Math.min(target, sibling.length - 1);
|
|
15636
|
-
if (target < 0) {
|
|
15637
|
-
throw "Sibling index " + target + " should large than 0";
|
|
15638
|
-
}
|
|
15639
|
-
if (this._siblingIndex !== target) {
|
|
15640
|
-
var oldIndex = this._siblingIndex;
|
|
15641
|
-
if (target < oldIndex) {
|
|
15642
|
-
for(var i = oldIndex; i >= target; i--){
|
|
15643
|
-
var child = i == target ? this : sibling[i - 1];
|
|
15644
|
-
sibling[i] = child;
|
|
15645
|
-
child._siblingIndex = i;
|
|
15646
|
-
}
|
|
15647
|
-
} else {
|
|
15648
|
-
for(var i1 = oldIndex; i1 <= target; i1++){
|
|
15649
|
-
var child1 = i1 == target ? this : sibling[i1 + 1];
|
|
15650
|
-
sibling[i1] = child1;
|
|
15651
|
-
child1._siblingIndex = i1;
|
|
15652
|
-
}
|
|
15653
|
-
}
|
|
15654
|
-
}
|
|
15655
|
-
};
|
|
15656
|
-
/**
|
|
15657
|
-
* @deprecated
|
|
15658
|
-
*/ _proto.getInvModelMatrix = function getInvModelMatrix() {
|
|
15659
|
-
if (this._inverseWorldMatFlag.flag) {
|
|
15660
|
-
engineMath.Matrix.invert(this.transform.worldMatrix, this._invModelMatrix);
|
|
15661
|
-
this._inverseWorldMatFlag.flag = false;
|
|
15662
|
-
}
|
|
15663
|
-
return this._invModelMatrix;
|
|
15664
|
-
};
|
|
15665
|
-
/**
|
|
15666
|
-
* @internal
|
|
15667
|
-
*/ Entity._findChildByName = function _findChildByName(root, name) {
|
|
15668
|
-
var children = root._children;
|
|
15669
|
-
for(var i = children.length - 1; i >= 0; i--){
|
|
15670
|
-
var child = children[i];
|
|
15671
|
-
if (child.name === name) {
|
|
15672
|
-
return child;
|
|
15673
|
-
}
|
|
15674
|
-
}
|
|
15675
|
-
return null;
|
|
15676
|
-
};
|
|
15677
|
-
/**
|
|
15678
|
-
* @internal
|
|
15679
|
-
*/ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
|
|
15680
|
-
entity._scene = scene;
|
|
15681
|
-
var children = entity._children;
|
|
15682
|
-
for(var i = children.length - 1; i >= 0; i--){
|
|
15683
|
-
this._traverseSetOwnerScene(children[i], scene);
|
|
15684
|
-
}
|
|
15685
|
-
};
|
|
15686
|
-
_create_class(Entity, [
|
|
15687
|
-
{
|
|
15688
|
-
key: "isActive",
|
|
15689
|
-
get: /**
|
|
15690
|
-
* Whether to activate locally.
|
|
15628
|
+
* @remarks
|
|
15629
|
+
* Red and green channels represent the anisotropy direction in [-1, 1] tangent, bitangent space, to be rotated by anisotropyRotation.
|
|
15630
|
+
* The blue channel contains strength as [0, 1] to be multiplied by anisotropy.
|
|
15691
15631
|
*/ function get() {
|
|
15692
|
-
return this.
|
|
15632
|
+
return this.shaderData.getTexture(PBRMaterial._anisotropyTextureProp);
|
|
15693
15633
|
},
|
|
15694
15634
|
set: function set(value) {
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
15701
|
-
activeChangeFlag |= ActiveChangeFlag.All;
|
|
15702
|
-
} else {
|
|
15703
|
-
var _parent, _parent1;
|
|
15704
|
-
((_parent = parent) == null ? void 0 : _parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15705
|
-
((_parent1 = parent) == null ? void 0 : _parent1._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
15706
|
-
}
|
|
15707
|
-
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
15708
|
-
} else {
|
|
15709
|
-
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
15710
|
-
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
15711
|
-
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
15712
|
-
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
15713
|
-
}
|
|
15635
|
+
this.shaderData.setTexture(PBRMaterial._anisotropyTextureProp, value);
|
|
15636
|
+
if (value) {
|
|
15637
|
+
this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
15638
|
+
} else {
|
|
15639
|
+
this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
15714
15640
|
}
|
|
15715
15641
|
}
|
|
15716
|
-
}
|
|
15642
|
+
}
|
|
15643
|
+
]);
|
|
15644
|
+
return PBRMaterial;
|
|
15645
|
+
}(PBRBaseMaterial);
|
|
15646
|
+
(function() {
|
|
15647
|
+
PBRMaterial._metallicProp = ShaderProperty.getByName("material_Metal");
|
|
15648
|
+
})();
|
|
15649
|
+
(function() {
|
|
15650
|
+
PBRMaterial._roughnessProp = ShaderProperty.getByName("material_Roughness");
|
|
15651
|
+
})();
|
|
15652
|
+
(function() {
|
|
15653
|
+
PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
|
|
15654
|
+
})();
|
|
15655
|
+
(function() {
|
|
15656
|
+
PBRMaterial._iorProp = ShaderProperty.getByName("material_IOR");
|
|
15657
|
+
})();
|
|
15658
|
+
(function() {
|
|
15659
|
+
PBRMaterial._anisotropyInfoProp = ShaderProperty.getByName("material_AnisotropyInfo");
|
|
15660
|
+
})();
|
|
15661
|
+
(function() {
|
|
15662
|
+
PBRMaterial._anisotropyTextureProp = ShaderProperty.getByName("material_AnisotropyTexture");
|
|
15663
|
+
})();
|
|
15664
|
+
|
|
15665
|
+
/**
|
|
15666
|
+
* PBR (Specular-Glossiness Workflow) Material.
|
|
15667
|
+
*/ var PBRSpecularMaterial = /*#__PURE__*/ function(PBRBaseMaterial1) {
|
|
15668
|
+
_inherits(PBRSpecularMaterial, PBRBaseMaterial1);
|
|
15669
|
+
function PBRSpecularMaterial(engine) {
|
|
15670
|
+
var _this;
|
|
15671
|
+
_this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr-specular")) || this;
|
|
15672
|
+
_this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new engineMath.Color(1, 1, 1, 1));
|
|
15673
|
+
_this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, 1.0);
|
|
15674
|
+
return _this;
|
|
15675
|
+
}
|
|
15676
|
+
var _proto = PBRSpecularMaterial.prototype;
|
|
15677
|
+
/**
|
|
15678
|
+
* @inheritdoc
|
|
15679
|
+
*/ _proto.clone = function clone() {
|
|
15680
|
+
var dest = new PBRSpecularMaterial(this._engine);
|
|
15681
|
+
this.cloneTo(dest);
|
|
15682
|
+
return dest;
|
|
15683
|
+
};
|
|
15684
|
+
_create_class(PBRSpecularMaterial, [
|
|
15717
15685
|
{
|
|
15718
|
-
key: "
|
|
15686
|
+
key: "specularColor",
|
|
15719
15687
|
get: /**
|
|
15720
|
-
*
|
|
15688
|
+
* Specular color.
|
|
15721
15689
|
*/ function get() {
|
|
15722
|
-
return this.
|
|
15690
|
+
return this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
15691
|
+
},
|
|
15692
|
+
set: function set(value) {
|
|
15693
|
+
var specularColor = this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
15694
|
+
if (value !== specularColor) {
|
|
15695
|
+
specularColor.copyFrom(value);
|
|
15696
|
+
}
|
|
15723
15697
|
}
|
|
15724
15698
|
},
|
|
15725
15699
|
{
|
|
15726
|
-
key: "
|
|
15700
|
+
key: "glossiness",
|
|
15727
15701
|
get: /**
|
|
15728
|
-
*
|
|
15702
|
+
* Glossiness.
|
|
15729
15703
|
*/ function get() {
|
|
15730
|
-
return this.
|
|
15704
|
+
return this.shaderData.getFloat(PBRSpecularMaterial._glossinessProp);
|
|
15731
15705
|
},
|
|
15732
15706
|
set: function set(value) {
|
|
15733
|
-
this.
|
|
15707
|
+
this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, value);
|
|
15734
15708
|
}
|
|
15735
15709
|
},
|
|
15736
15710
|
{
|
|
15737
|
-
key: "
|
|
15711
|
+
key: "specularGlossinessTexture",
|
|
15738
15712
|
get: /**
|
|
15739
|
-
*
|
|
15713
|
+
* Specular glossiness texture.
|
|
15714
|
+
* @remarks RGB is specular, A is glossiness
|
|
15740
15715
|
*/ function get() {
|
|
15741
|
-
return this.
|
|
15716
|
+
return this.shaderData.getTexture(PBRSpecularMaterial._specularGlossinessTextureProp);
|
|
15717
|
+
},
|
|
15718
|
+
set: function set(value) {
|
|
15719
|
+
this.shaderData.setTexture(PBRSpecularMaterial._specularGlossinessTextureProp, value);
|
|
15720
|
+
if (value) {
|
|
15721
|
+
this.shaderData.enableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
15722
|
+
} else {
|
|
15723
|
+
this.shaderData.disableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
15724
|
+
}
|
|
15742
15725
|
}
|
|
15743
|
-
}
|
|
15726
|
+
}
|
|
15727
|
+
]);
|
|
15728
|
+
return PBRSpecularMaterial;
|
|
15729
|
+
}(PBRBaseMaterial);
|
|
15730
|
+
(function() {
|
|
15731
|
+
PBRSpecularMaterial._specularColorProp = ShaderProperty.getByName("material_PBRSpecularColor");
|
|
15732
|
+
})();
|
|
15733
|
+
(function() {
|
|
15734
|
+
PBRSpecularMaterial._glossinessProp = ShaderProperty.getByName("material_Glossiness");
|
|
15735
|
+
})();
|
|
15736
|
+
(function() {
|
|
15737
|
+
PBRSpecularMaterial._specularGlossinessTextureProp = ShaderProperty.getByName("material_SpecularGlossinessTexture");
|
|
15738
|
+
})();
|
|
15739
|
+
(function() {
|
|
15740
|
+
PBRSpecularMaterial._specularGlossinessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");
|
|
15741
|
+
})();
|
|
15742
|
+
|
|
15743
|
+
/**
|
|
15744
|
+
* Unlit Material.
|
|
15745
|
+
*/ var UnlitMaterial = /*#__PURE__*/ function(BaseMaterial1) {
|
|
15746
|
+
_inherits(UnlitMaterial, BaseMaterial1);
|
|
15747
|
+
function UnlitMaterial(engine) {
|
|
15748
|
+
var _this;
|
|
15749
|
+
_this = BaseMaterial1.call(this, engine, Shader.find("unlit")) || this;
|
|
15750
|
+
var shaderData = _this.shaderData;
|
|
15751
|
+
shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
|
|
15752
|
+
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
15753
|
+
shaderData.setColor(UnlitMaterial._baseColorProp, new engineMath.Color(1, 1, 1, 1));
|
|
15754
|
+
shaderData.setVector4(UnlitMaterial._tilingOffsetProp, new engineMath.Vector4(1, 1, 0, 0));
|
|
15755
|
+
return _this;
|
|
15756
|
+
}
|
|
15757
|
+
var _proto = UnlitMaterial.prototype;
|
|
15758
|
+
/**
|
|
15759
|
+
* @inheritdoc
|
|
15760
|
+
*/ _proto.clone = function clone() {
|
|
15761
|
+
var dest = new UnlitMaterial(this._engine);
|
|
15762
|
+
this.cloneTo(dest);
|
|
15763
|
+
return dest;
|
|
15764
|
+
};
|
|
15765
|
+
_create_class(UnlitMaterial, [
|
|
15744
15766
|
{
|
|
15745
|
-
key: "
|
|
15767
|
+
key: "baseColor",
|
|
15746
15768
|
get: /**
|
|
15747
|
-
*
|
|
15748
|
-
* Number of the children entities
|
|
15769
|
+
* Base color.
|
|
15749
15770
|
*/ function get() {
|
|
15750
|
-
return this.
|
|
15771
|
+
return this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
15772
|
+
},
|
|
15773
|
+
set: function set(value) {
|
|
15774
|
+
var baseColor = this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
15775
|
+
if (value !== baseColor) {
|
|
15776
|
+
baseColor.copyFrom(value);
|
|
15777
|
+
}
|
|
15751
15778
|
}
|
|
15752
15779
|
},
|
|
15753
15780
|
{
|
|
15754
|
-
key: "
|
|
15781
|
+
key: "baseTexture",
|
|
15755
15782
|
get: /**
|
|
15756
|
-
*
|
|
15783
|
+
* Base texture.
|
|
15757
15784
|
*/ function get() {
|
|
15758
|
-
return this.
|
|
15785
|
+
return this.shaderData.getTexture(UnlitMaterial._baseTextureProp);
|
|
15786
|
+
},
|
|
15787
|
+
set: function set(value) {
|
|
15788
|
+
this.shaderData.setTexture(UnlitMaterial._baseTextureProp, value);
|
|
15789
|
+
if (value) {
|
|
15790
|
+
this.shaderData.enableMacro(UnlitMaterial._baseTextureMacro);
|
|
15791
|
+
} else {
|
|
15792
|
+
this.shaderData.disableMacro(UnlitMaterial._baseTextureMacro);
|
|
15793
|
+
}
|
|
15759
15794
|
}
|
|
15760
15795
|
},
|
|
15761
15796
|
{
|
|
15762
|
-
key: "
|
|
15797
|
+
key: "tilingOffset",
|
|
15763
15798
|
get: /**
|
|
15764
|
-
*
|
|
15799
|
+
* Tiling and offset of main textures.
|
|
15765
15800
|
*/ function get() {
|
|
15766
|
-
return this.
|
|
15801
|
+
return this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
15767
15802
|
},
|
|
15768
15803
|
set: function set(value) {
|
|
15769
|
-
|
|
15770
|
-
|
|
15804
|
+
var tilingOffset = this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
15805
|
+
if (value !== tilingOffset) {
|
|
15806
|
+
tilingOffset.copyFrom(value);
|
|
15771
15807
|
}
|
|
15772
|
-
this._setSiblingIndex(this._isRoot ? this._scene._rootEntities : this._parent._children, value);
|
|
15773
15808
|
}
|
|
15774
15809
|
}
|
|
15775
15810
|
]);
|
|
15776
|
-
return
|
|
15777
|
-
}(
|
|
15811
|
+
return UnlitMaterial;
|
|
15812
|
+
}(BaseMaterial);
|
|
15813
|
+
|
|
15814
|
+
/**
|
|
15815
|
+
* @internal
|
|
15816
|
+
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
15817
|
+
function BasicResources(engine) {
|
|
15818
|
+
// prettier-ignore
|
|
15819
|
+
var vertices = new Float32Array([
|
|
15820
|
+
-1,
|
|
15821
|
+
-1,
|
|
15822
|
+
0,
|
|
15823
|
+
1,
|
|
15824
|
+
1,
|
|
15825
|
+
-1,
|
|
15826
|
+
1,
|
|
15827
|
+
1,
|
|
15828
|
+
-1,
|
|
15829
|
+
1,
|
|
15830
|
+
0,
|
|
15831
|
+
0,
|
|
15832
|
+
1,
|
|
15833
|
+
1,
|
|
15834
|
+
1,
|
|
15835
|
+
0
|
|
15836
|
+
]); // right-top
|
|
15837
|
+
// prettier-ignore
|
|
15838
|
+
var flipYVertices = new Float32Array([
|
|
15839
|
+
1,
|
|
15840
|
+
-1,
|
|
15841
|
+
1,
|
|
15842
|
+
0,
|
|
15843
|
+
-1,
|
|
15844
|
+
-1,
|
|
15845
|
+
0,
|
|
15846
|
+
0,
|
|
15847
|
+
1,
|
|
15848
|
+
1,
|
|
15849
|
+
1,
|
|
15850
|
+
1,
|
|
15851
|
+
-1,
|
|
15852
|
+
1,
|
|
15853
|
+
0,
|
|
15854
|
+
1
|
|
15855
|
+
]); // left-top
|
|
15856
|
+
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
15857
|
+
blitMaterial._addReferCount(1);
|
|
15858
|
+
blitMaterial.renderState.depthState.enabled = false;
|
|
15859
|
+
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
15860
|
+
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
15861
|
+
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
15862
|
+
this.blitMaterial = blitMaterial;
|
|
15863
|
+
}
|
|
15864
|
+
var _proto = BasicResources.prototype;
|
|
15865
|
+
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
15866
|
+
var mesh = new ModelMesh(engine);
|
|
15867
|
+
mesh._addReferCount(1);
|
|
15868
|
+
mesh.setVertexElements([
|
|
15869
|
+
new VertexElement("POSITION_UV", 0, exports.VertexElementFormat.Vector4, 0)
|
|
15870
|
+
]);
|
|
15871
|
+
mesh.setVertexBufferBinding(new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static), 16);
|
|
15872
|
+
mesh.addSubMesh(0, 4, exports.MeshTopology.TriangleStrip);
|
|
15873
|
+
return mesh;
|
|
15874
|
+
};
|
|
15875
|
+
return BasicResources;
|
|
15876
|
+
}();
|
|
15778
15877
|
|
|
15779
15878
|
/**
|
|
15780
15879
|
* @internal
|