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