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