@galacean/engine 1.2.0-beta.3 → 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/LICENSE +2 -2
- package/dist/browser.js +1611 -1477
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -5232,7 +5232,7 @@
|
|
|
5232
5232
|
}
|
|
5233
5233
|
return cloneModes;
|
|
5234
5234
|
};
|
|
5235
|
-
CloneManager.cloneProperty = function cloneProperty(source, target, k, cloneMode) {
|
|
5235
|
+
CloneManager.cloneProperty = function cloneProperty(source, target, k, cloneMode, srcRoot, targetRoot, deepInstanceMap) {
|
|
5236
5236
|
if (cloneMode === CloneMode.Ignore) {
|
|
5237
5237
|
return;
|
|
5238
5238
|
}
|
|
@@ -5268,22 +5268,33 @@
|
|
|
5268
5268
|
targetPropertyA.length = length;
|
|
5269
5269
|
}
|
|
5270
5270
|
for(var i = 0; i < length; i++){
|
|
5271
|
-
CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode);
|
|
5271
|
+
CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode, srcRoot, targetRoot, deepInstanceMap);
|
|
5272
5272
|
}
|
|
5273
5273
|
break;
|
|
5274
5274
|
default:
|
|
5275
|
-
var
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5275
|
+
var targetProperty = target[k];
|
|
5276
|
+
// If the target property is undefined, create new instance and keep reference sharing like the source
|
|
5277
|
+
if (!targetProperty) {
|
|
5278
|
+
targetProperty = deepInstanceMap.get(sourceProperty);
|
|
5279
|
+
if (!targetProperty) {
|
|
5280
|
+
targetProperty = new sourceProperty.constructor();
|
|
5281
|
+
deepInstanceMap.set(sourceProperty, targetProperty);
|
|
5282
|
+
}
|
|
5283
|
+
target[k] = targetProperty;
|
|
5284
5284
|
}
|
|
5285
5285
|
if (sourceProperty.copyFrom) {
|
|
5286
|
-
|
|
5286
|
+
// Custom clone
|
|
5287
|
+
targetProperty.copyFrom(sourceProperty);
|
|
5288
|
+
} else {
|
|
5289
|
+
// Universal clone
|
|
5290
|
+
var cloneModes = CloneManager.getCloneMode(sourceProperty.constructor);
|
|
5291
|
+
for(var _$k in sourceProperty){
|
|
5292
|
+
CloneManager.cloneProperty(sourceProperty, targetProperty, _$k, cloneModes[_$k], srcRoot, targetRoot, deepInstanceMap);
|
|
5293
|
+
}
|
|
5294
|
+
// Custom incremental clone
|
|
5295
|
+
if (sourceProperty._cloneTo) {
|
|
5296
|
+
sourceProperty._cloneTo(targetProperty, srcRoot, targetRoot);
|
|
5297
|
+
}
|
|
5287
5298
|
}
|
|
5288
5299
|
break;
|
|
5289
5300
|
}
|
|
@@ -5292,9 +5303,9 @@
|
|
|
5292
5303
|
target[k] = sourceProperty;
|
|
5293
5304
|
}
|
|
5294
5305
|
};
|
|
5295
|
-
CloneManager.deepCloneObject = function deepCloneObject(source, target) {
|
|
5306
|
+
CloneManager.deepCloneObject = function deepCloneObject(source, target, deepInstanceMap) {
|
|
5296
5307
|
for(var k in source){
|
|
5297
|
-
CloneManager.cloneProperty(source, target, k, CloneMode.Deep);
|
|
5308
|
+
CloneManager.cloneProperty(source, target, k, CloneMode.Deep, null, null, deepInstanceMap);
|
|
5298
5309
|
}
|
|
5299
5310
|
};
|
|
5300
5311
|
return CloneManager;
|
|
@@ -9794,7 +9805,8 @@
|
|
|
9794
9805
|
}
|
|
9795
9806
|
var shaderInfo = Shader._shaderLab.parseShader(nameOrShaderSource);
|
|
9796
9807
|
if (shaderMap[shaderInfo.name]) {
|
|
9797
|
-
|
|
9808
|
+
console.error('Shader named "' + shaderInfo.name + '" already exists.');
|
|
9809
|
+
return;
|
|
9798
9810
|
}
|
|
9799
9811
|
var subShaderList = shaderInfo.subShaders.map(function(subShaderInfo) {
|
|
9800
9812
|
var passList = subShaderInfo.passes.map(function(passInfo) {
|
|
@@ -9833,7 +9845,8 @@
|
|
|
9833
9845
|
return shader;
|
|
9834
9846
|
} else {
|
|
9835
9847
|
if (shaderMap[nameOrShaderSource]) {
|
|
9836
|
-
|
|
9848
|
+
console.error('Shader named "' + nameOrShaderSource + '" already exists.');
|
|
9849
|
+
return;
|
|
9837
9850
|
}
|
|
9838
9851
|
if (typeof vertexSourceOrShaderPassesOrSubShaders === "string") {
|
|
9839
9852
|
var shaderPass = new ShaderPass(vertexSourceOrShaderPassesOrSubShaders, fragmentSource);
|
|
@@ -10427,7 +10440,7 @@
|
|
|
10427
10440
|
return shaderData;
|
|
10428
10441
|
};
|
|
10429
10442
|
_proto.cloneTo = function cloneTo(target) {
|
|
10430
|
-
CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
|
|
10443
|
+
CloneManager.deepCloneObject(this._macroCollection, target._macroCollection, new Map());
|
|
10431
10444
|
Object.assign(target._macroMap, this._macroMap);
|
|
10432
10445
|
var referCount = target._getReferCount();
|
|
10433
10446
|
var propertyValueMap = this._propertyValueMap;
|
|
@@ -15762,267 +15775,736 @@
|
|
|
15762
15775
|
PrimitiveMesh._spherePoleIdx = 0;
|
|
15763
15776
|
})();
|
|
15764
15777
|
/**
|
|
15765
|
-
*
|
|
15766
|
-
*/
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15772
|
-
|
|
15773
|
-
|
|
15774
|
-
|
|
15775
|
-
|
|
15778
|
+
* Layer, used for bit operations.
|
|
15779
|
+
*/ exports.Layer = void 0;
|
|
15780
|
+
(function(Layer) {
|
|
15781
|
+
Layer[Layer[/** Layer 0. */ "Layer0"] = 0x1] = "Layer0";
|
|
15782
|
+
Layer[Layer[/** Layer 1. */ "Layer1"] = 0x2] = "Layer1";
|
|
15783
|
+
Layer[Layer[/** Layer 2. */ "Layer2"] = 0x4] = "Layer2";
|
|
15784
|
+
Layer[Layer[/** Layer 3. */ "Layer3"] = 0x8] = "Layer3";
|
|
15785
|
+
Layer[Layer[/** Layer 4. */ "Layer4"] = 0x10] = "Layer4";
|
|
15786
|
+
Layer[Layer[/** Layer 5. */ "Layer5"] = 0x20] = "Layer5";
|
|
15787
|
+
Layer[Layer[/** Layer 6. */ "Layer6"] = 0x40] = "Layer6";
|
|
15788
|
+
Layer[Layer[/** Layer 7. */ "Layer7"] = 0x80] = "Layer7";
|
|
15789
|
+
Layer[Layer[/** Layer 8. */ "Layer8"] = 0x100] = "Layer8";
|
|
15790
|
+
Layer[Layer[/** Layer 9. */ "Layer9"] = 0x200] = "Layer9";
|
|
15791
|
+
Layer[Layer[/** Layer 10. */ "Layer10"] = 0x400] = "Layer10";
|
|
15792
|
+
Layer[Layer[/** Layer 11. */ "Layer11"] = 0x800] = "Layer11";
|
|
15793
|
+
Layer[Layer[/** Layer 12. */ "Layer12"] = 0x1000] = "Layer12";
|
|
15794
|
+
Layer[Layer[/** Layer 13. */ "Layer13"] = 0x2000] = "Layer13";
|
|
15795
|
+
Layer[Layer[/** Layer 14. */ "Layer14"] = 0x4000] = "Layer14";
|
|
15796
|
+
Layer[Layer[/** Layer 15. */ "Layer15"] = 0x8000] = "Layer15";
|
|
15797
|
+
Layer[Layer[/** Layer 16. */ "Layer16"] = 0x10000] = "Layer16";
|
|
15798
|
+
Layer[Layer[/** Layer 17. */ "Layer17"] = 0x20000] = "Layer17";
|
|
15799
|
+
Layer[Layer[/** Layer 18. */ "Layer18"] = 0x40000] = "Layer18";
|
|
15800
|
+
Layer[Layer[/** Layer 19. */ "Layer19"] = 0x80000] = "Layer19";
|
|
15801
|
+
Layer[Layer[/** Layer 20. */ "Layer20"] = 0x100000] = "Layer20";
|
|
15802
|
+
Layer[Layer[/** Layer 21. */ "Layer21"] = 0x200000] = "Layer21";
|
|
15803
|
+
Layer[Layer[/** Layer 22. */ "Layer22"] = 0x400000] = "Layer22";
|
|
15804
|
+
Layer[Layer[/** Layer 23. */ "Layer23"] = 0x800000] = "Layer23";
|
|
15805
|
+
Layer[Layer[/** Layer 24. */ "Layer24"] = 0x1000000] = "Layer24";
|
|
15806
|
+
Layer[Layer[/** Layer 25. */ "Layer25"] = 0x2000000] = "Layer25";
|
|
15807
|
+
Layer[Layer[/** Layer 26. */ "Layer26"] = 0x4000000] = "Layer26";
|
|
15808
|
+
Layer[Layer[/** Layer 27. */ "Layer27"] = 0x8000000] = "Layer27";
|
|
15809
|
+
Layer[Layer[/** Layer 28. */ "Layer28"] = 0x10000000] = "Layer28";
|
|
15810
|
+
Layer[Layer[/** Layer 29. */ "Layer29"] = 0x20000000] = "Layer29";
|
|
15811
|
+
Layer[Layer[/** Layer 30. */ "Layer30"] = 0x40000000] = "Layer30";
|
|
15812
|
+
Layer[Layer[/** Layer 31. */ "Layer31"] = 0x80000000] = "Layer31";
|
|
15813
|
+
Layer[Layer[/** All layers. */ "Everything"] = 0xffffffff] = "Everything";
|
|
15814
|
+
Layer[Layer[/** None layer. */ "Nothing"] = 0x0] = "Nothing";
|
|
15815
|
+
})(exports.Layer || (exports.Layer = {}));
|
|
15816
|
+
var ComponentCloner = /*#__PURE__*/ function() {
|
|
15817
|
+
var ComponentCloner = function ComponentCloner() {};
|
|
15818
|
+
/**
|
|
15819
|
+
* Clone component.
|
|
15820
|
+
* @param source - Clone source
|
|
15821
|
+
* @param target - Clone target
|
|
15822
|
+
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
15823
|
+
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
15824
|
+
for(var k in source){
|
|
15825
|
+
CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
|
|
15826
|
+
}
|
|
15827
|
+
if (source._cloneTo) {
|
|
15828
|
+
source._cloneTo(target, srcRoot, targetRoot);
|
|
15829
|
+
}
|
|
15776
15830
|
};
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
}(EngineObject);
|
|
15831
|
+
return ComponentCloner;
|
|
15832
|
+
}();
|
|
15780
15833
|
/**
|
|
15781
|
-
*
|
|
15782
|
-
*/ var
|
|
15783
|
-
var
|
|
15834
|
+
* Entity, be used as components container.
|
|
15835
|
+
*/ var Entity = /*#__PURE__*/ function(EngineObject1) {
|
|
15836
|
+
var Entity = function Entity(engine, name1) {
|
|
15784
15837
|
var _this;
|
|
15785
|
-
_this =
|
|
15786
|
-
_this.
|
|
15787
|
-
_this.
|
|
15788
|
-
_this.
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
_this.
|
|
15796
|
-
_this.
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15838
|
+
_this = EngineObject1.call(this, engine) || this;
|
|
15839
|
+
/** The layer the entity belongs to. */ _this.layer = exports.Layer.Layer0;
|
|
15840
|
+
/** @internal */ _this._isActiveInHierarchy = false;
|
|
15841
|
+
/** @internal */ _this._isActiveInScene = false;
|
|
15842
|
+
/** @internal */ _this._components = [];
|
|
15843
|
+
/** @internal */ _this._scripts = new DisorderedArray();
|
|
15844
|
+
/** @internal */ _this._children = [];
|
|
15845
|
+
/** @internal */ _this._isRoot = false;
|
|
15846
|
+
/** @internal */ _this._isActive = true;
|
|
15847
|
+
/** @internal */ _this._siblingIndex = -1;
|
|
15848
|
+
/** @internal */ _this._isTemplate = false;
|
|
15849
|
+
_this._parent = null;
|
|
15850
|
+
//--------------------------------------------------------------deprecated----------------------------------------------------------------
|
|
15851
|
+
_this._invModelMatrix = new Matrix();
|
|
15852
|
+
_this.name = name1;
|
|
15853
|
+
_this.transform = _this.addComponent(Transform);
|
|
15854
|
+
_this._inverseWorldMatFlag = _this.transform.registerWorldChangeFlag();
|
|
15802
15855
|
return _this;
|
|
15803
15856
|
};
|
|
15804
|
-
_inherits$2(
|
|
15805
|
-
var _proto =
|
|
15857
|
+
_inherits$2(Entity, EngineObject1);
|
|
15858
|
+
var _proto = Entity.prototype;
|
|
15806
15859
|
/**
|
|
15807
|
-
*
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15824
|
-
|
|
15860
|
+
* Add component based on the component type.
|
|
15861
|
+
* @param type - The type of the component
|
|
15862
|
+
* @returns The component which has been added
|
|
15863
|
+
*/ _proto.addComponent = function addComponent(type) {
|
|
15864
|
+
ComponentsDependencies._addCheck(this, type);
|
|
15865
|
+
var component = new type(this);
|
|
15866
|
+
this._components.push(component);
|
|
15867
|
+
component._setActive(true, ActiveChangeFlag.All);
|
|
15868
|
+
return component;
|
|
15869
|
+
};
|
|
15870
|
+
/**
|
|
15871
|
+
* Get component which match the type.
|
|
15872
|
+
* @param type - The type of the component
|
|
15873
|
+
* @returns The first component which match type
|
|
15874
|
+
*/ _proto.getComponent = function getComponent(type) {
|
|
15875
|
+
var components = this._components;
|
|
15876
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
15877
|
+
var component = components[i];
|
|
15878
|
+
if (_instanceof1$2(component, type)) {
|
|
15879
|
+
return component;
|
|
15825
15880
|
}
|
|
15826
15881
|
}
|
|
15882
|
+
return null;
|
|
15827
15883
|
};
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15884
|
+
/**
|
|
15885
|
+
* Get components which match the type.
|
|
15886
|
+
* @param type - The type of the component
|
|
15887
|
+
* @param results - The components which match type
|
|
15888
|
+
* @returns The components which match type
|
|
15889
|
+
*/ _proto.getComponents = function getComponents(type, results) {
|
|
15890
|
+
results.length = 0;
|
|
15891
|
+
var components = this._components;
|
|
15892
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
15893
|
+
var component = components[i];
|
|
15894
|
+
if (_instanceof1$2(component, type)) {
|
|
15895
|
+
results.push(component);
|
|
15896
|
+
}
|
|
15835
15897
|
}
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15856
|
-
|
|
15857
|
-
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15898
|
+
return results;
|
|
15899
|
+
};
|
|
15900
|
+
/**
|
|
15901
|
+
* Get the components which match the type of the entity and it's children.
|
|
15902
|
+
* @param type - The component type
|
|
15903
|
+
* @param results - The components collection
|
|
15904
|
+
* @returns The components collection which match the type
|
|
15905
|
+
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
15906
|
+
results.length = 0;
|
|
15907
|
+
this._getComponentsInChildren(type, results);
|
|
15908
|
+
return results;
|
|
15909
|
+
};
|
|
15910
|
+
_proto.addChild = function addChild(indexOrChild, child) {
|
|
15911
|
+
var index;
|
|
15912
|
+
if (typeof indexOrChild === "number") {
|
|
15913
|
+
index = indexOrChild;
|
|
15914
|
+
} else {
|
|
15915
|
+
index = undefined;
|
|
15916
|
+
child = indexOrChild;
|
|
15917
|
+
}
|
|
15918
|
+
if (child._isRoot) {
|
|
15919
|
+
child._scene._removeFromEntityList(child);
|
|
15920
|
+
child._isRoot = false;
|
|
15921
|
+
this._addToChildrenList(index, child);
|
|
15922
|
+
child._parent = this;
|
|
15923
|
+
var oldScene = child._scene;
|
|
15924
|
+
var newScene = this._scene;
|
|
15925
|
+
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
15926
|
+
if (!this._isActiveInHierarchy) {
|
|
15927
|
+
child._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15928
|
+
}
|
|
15929
|
+
if (child._isActiveInScene) {
|
|
15930
|
+
if (this._isActiveInScene) {
|
|
15931
|
+
// Cross scene should inActive first and then active
|
|
15932
|
+
oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
15867
15933
|
} else {
|
|
15868
|
-
|
|
15869
|
-
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
15870
|
-
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
15871
|
-
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
15872
|
-
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, this._jointMatrices);
|
|
15934
|
+
inActiveChangeFlag |= ActiveChangeFlag.Scene;
|
|
15873
15935
|
}
|
|
15874
|
-
jointDataCreateCache.set(jointCount, bsUniformOccupiesCount);
|
|
15875
15936
|
}
|
|
15876
|
-
|
|
15877
|
-
|
|
15937
|
+
inActiveChangeFlag && child._processInActive(inActiveChangeFlag);
|
|
15938
|
+
if (child._scene !== newScene) {
|
|
15939
|
+
Entity._traverseSetOwnerScene(child, newScene);
|
|
15940
|
+
}
|
|
15941
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
15942
|
+
if (child._isActive) {
|
|
15943
|
+
if (this._isActiveInHierarchy) {
|
|
15944
|
+
!child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
15945
|
+
}
|
|
15946
|
+
if (this._isActiveInScene) {
|
|
15947
|
+
(!child._isActiveInScene || oldScene !== newScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
15948
|
+
}
|
|
15878
15949
|
}
|
|
15950
|
+
activeChangeFlag && child._processActive(activeChangeFlag);
|
|
15951
|
+
child._setTransformDirty();
|
|
15952
|
+
} else {
|
|
15953
|
+
child._setParent(this, index);
|
|
15879
15954
|
}
|
|
15880
|
-
var layer = entity.layer;
|
|
15881
|
-
this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
|
|
15882
15955
|
};
|
|
15883
15956
|
/**
|
|
15884
|
-
*
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
this._rootBone = null;
|
|
15889
|
-
this._jointDataCreateCache = null;
|
|
15890
|
-
this._skin = null;
|
|
15891
|
-
this._blendShapeWeights = null;
|
|
15892
|
-
this._localBounds = null;
|
|
15893
|
-
this._jointMatrices = null;
|
|
15894
|
-
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
15895
|
-
this._jointTexture = null;
|
|
15896
|
-
this._bones = null;
|
|
15957
|
+
* Remove child entity.
|
|
15958
|
+
* @param child - The child entity which want to be removed
|
|
15959
|
+
*/ _proto.removeChild = function removeChild(child) {
|
|
15960
|
+
child._setParent(null);
|
|
15897
15961
|
};
|
|
15898
15962
|
/**
|
|
15899
|
-
* @
|
|
15900
|
-
|
|
15901
|
-
|
|
15902
|
-
|
|
15903
|
-
|
|
15904
|
-
|
|
15905
|
-
|
|
15906
|
-
|
|
15963
|
+
* @deprecated Please use `children` property instead.
|
|
15964
|
+
* Find child entity by index.
|
|
15965
|
+
* @param index - The index of the child entity
|
|
15966
|
+
* @returns The component which be found
|
|
15967
|
+
*/ _proto.getChild = function getChild(index) {
|
|
15968
|
+
return this._children[index];
|
|
15969
|
+
};
|
|
15970
|
+
/**
|
|
15971
|
+
* Find entity by name.
|
|
15972
|
+
* @param name - The name of the entity which want to be found
|
|
15973
|
+
* @returns The component which be found
|
|
15974
|
+
*/ _proto.findByName = function findByName(name1) {
|
|
15975
|
+
if (name1 === this.name) {
|
|
15976
|
+
return this;
|
|
15907
15977
|
}
|
|
15908
|
-
|
|
15909
|
-
var
|
|
15910
|
-
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
for(var i = 0; i < boneCount; i++){
|
|
15914
|
-
var bone = bones[i];
|
|
15915
|
-
var success1 = this._getEntityHierarchyPath(srcRoot, bone, paths);
|
|
15916
|
-
destBones[i] = success1 ? this._getEntityByHierarchyPath(targetRoot, paths) : bone;
|
|
15978
|
+
var children = this._children;
|
|
15979
|
+
for(var i = 0, n = children.length; i < n; i++){
|
|
15980
|
+
var target = children[i].findByName(name1);
|
|
15981
|
+
if (target) {
|
|
15982
|
+
return target;
|
|
15917
15983
|
}
|
|
15918
|
-
target.bones = destBones;
|
|
15919
15984
|
}
|
|
15920
|
-
|
|
15985
|
+
return null;
|
|
15921
15986
|
};
|
|
15922
15987
|
/**
|
|
15923
|
-
*
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15988
|
+
* Find the entity by path.
|
|
15989
|
+
* @param path - The path fo the entity eg: /entity
|
|
15990
|
+
* @returns The component which be found
|
|
15991
|
+
*/ _proto.findByPath = function findByPath(path) {
|
|
15992
|
+
var splits = path.split("/");
|
|
15993
|
+
var entity = this;
|
|
15994
|
+
for(var i = 0, length = splits.length; i < length; ++i){
|
|
15995
|
+
var split = splits[i];
|
|
15996
|
+
if (split) {
|
|
15997
|
+
entity = Entity._findChildByName(entity, split);
|
|
15998
|
+
if (!entity) {
|
|
15999
|
+
return null;
|
|
16000
|
+
}
|
|
16001
|
+
}
|
|
16002
|
+
}
|
|
16003
|
+
return entity;
|
|
15927
16004
|
};
|
|
15928
16005
|
/**
|
|
15929
|
-
*
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
16006
|
+
* Create child entity.
|
|
16007
|
+
* @param name - The child entity's name
|
|
16008
|
+
* @returns The child entity
|
|
16009
|
+
*/ _proto.createChild = function createChild(name1) {
|
|
16010
|
+
var child = new Entity(this.engine, name1);
|
|
16011
|
+
child.layer = this.layer;
|
|
16012
|
+
child.parent = this;
|
|
16013
|
+
return child;
|
|
16014
|
+
};
|
|
16015
|
+
/**
|
|
16016
|
+
* Clear children entities.
|
|
16017
|
+
*/ _proto.clearChildren = function clearChildren() {
|
|
16018
|
+
var children = this._children;
|
|
16019
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
16020
|
+
var child = children[i];
|
|
16021
|
+
child._parent = null;
|
|
16022
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
16023
|
+
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
16024
|
+
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
16025
|
+
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
16026
|
+
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
16027
|
+
}
|
|
16028
|
+
children.length = 0;
|
|
16029
|
+
};
|
|
16030
|
+
/**
|
|
16031
|
+
* Clone this entity include children and components.
|
|
16032
|
+
* @returns Cloned entity
|
|
16033
|
+
*/ _proto.clone = function clone() {
|
|
16034
|
+
var cloneEntity = this._createCloneEntity(this);
|
|
16035
|
+
this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
|
|
16036
|
+
return cloneEntity;
|
|
15933
16037
|
};
|
|
15934
16038
|
/**
|
|
15935
16039
|
* @internal
|
|
15936
|
-
*/ _proto.
|
|
15937
|
-
|
|
15938
|
-
|
|
15939
|
-
|
|
15940
|
-
|
|
15941
|
-
|
|
15942
|
-
|
|
16040
|
+
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
16041
|
+
this._isTemplate = true;
|
|
16042
|
+
this._templateResource = templateResource;
|
|
16043
|
+
};
|
|
16044
|
+
_proto._createCloneEntity = function _createCloneEntity(srcEntity) {
|
|
16045
|
+
var cloneEntity = new Entity(srcEntity._engine, srcEntity.name);
|
|
16046
|
+
var templateResource = this._templateResource;
|
|
16047
|
+
if (templateResource) {
|
|
16048
|
+
cloneEntity._templateResource = templateResource;
|
|
16049
|
+
templateResource._addReferCount(1);
|
|
16050
|
+
}
|
|
16051
|
+
cloneEntity.layer = srcEntity.layer;
|
|
16052
|
+
cloneEntity._isActive = srcEntity._isActive;
|
|
16053
|
+
var cloneTransform = cloneEntity.transform;
|
|
16054
|
+
var srcTransform = srcEntity.transform;
|
|
16055
|
+
cloneTransform.position = srcTransform.position;
|
|
16056
|
+
cloneTransform.rotation = srcTransform.rotation;
|
|
16057
|
+
cloneTransform.scale = srcTransform.scale;
|
|
16058
|
+
var children = srcEntity._children;
|
|
16059
|
+
for(var i = 0, n = srcEntity._children.length; i < n; i++){
|
|
16060
|
+
cloneEntity.addChild(this._createCloneEntity(children[i]));
|
|
15943
16061
|
}
|
|
16062
|
+
return cloneEntity;
|
|
15944
16063
|
};
|
|
15945
|
-
_proto.
|
|
15946
|
-
var
|
|
15947
|
-
var
|
|
15948
|
-
var
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
15958
|
-
}
|
|
15959
|
-
}
|
|
15960
|
-
this._blendShapeWeights = newBlendShapeWeights;
|
|
16064
|
+
_proto._parseCloneEntity = function _parseCloneEntity(src, target, srcRoot, targetRoot, deepInstanceMap) {
|
|
16065
|
+
var srcChildren = src._children;
|
|
16066
|
+
var targetChildren = target._children;
|
|
16067
|
+
for(var i = 0, n = srcChildren.length; i < n; i++){
|
|
16068
|
+
this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot, deepInstanceMap);
|
|
16069
|
+
}
|
|
16070
|
+
var components = src._components;
|
|
16071
|
+
for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
|
|
16072
|
+
var sourceComp = components[i1];
|
|
16073
|
+
if (!_instanceof1$2(sourceComp, Transform)) {
|
|
16074
|
+
var targetComp = target.addComponent(sourceComp.constructor);
|
|
16075
|
+
ComponentCloner.cloneComponent(sourceComp, targetComp, srcRoot, targetRoot, deepInstanceMap);
|
|
15961
16076
|
}
|
|
16077
|
+
}
|
|
16078
|
+
};
|
|
16079
|
+
/**
|
|
16080
|
+
* Destroy self.
|
|
16081
|
+
*/ _proto.destroy = function destroy() {
|
|
16082
|
+
if (this._destroyed) {
|
|
16083
|
+
return;
|
|
16084
|
+
}
|
|
16085
|
+
EngineObject1.prototype.destroy.call(this);
|
|
16086
|
+
if (this._templateResource) {
|
|
16087
|
+
this._isTemplate || this._templateResource._addReferCount(-1);
|
|
16088
|
+
this._templateResource = null;
|
|
16089
|
+
}
|
|
16090
|
+
var components = this._components;
|
|
16091
|
+
for(var i = components.length - 1; i >= 0; i--){
|
|
16092
|
+
components[i].destroy();
|
|
16093
|
+
}
|
|
16094
|
+
this._components.length = 0;
|
|
16095
|
+
var children = this._children;
|
|
16096
|
+
while(children.length > 0){
|
|
16097
|
+
children[0].destroy();
|
|
16098
|
+
}
|
|
16099
|
+
if (this._isRoot) {
|
|
16100
|
+
this._scene.removeRootEntity(this);
|
|
15962
16101
|
} else {
|
|
15963
|
-
this.
|
|
16102
|
+
this._setParent(null);
|
|
15964
16103
|
}
|
|
16104
|
+
this.isActive = false;
|
|
15965
16105
|
};
|
|
15966
|
-
|
|
15967
|
-
|
|
16106
|
+
/**
|
|
16107
|
+
* @internal
|
|
16108
|
+
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
16109
|
+
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
16110
|
+
var components = this._components;
|
|
16111
|
+
components.splice(components.indexOf(component), 1);
|
|
15968
16112
|
};
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
16113
|
+
/**
|
|
16114
|
+
* @internal
|
|
16115
|
+
*/ _proto._addScript = function _addScript(script) {
|
|
16116
|
+
script._entityScriptsIndex = this._scripts.length;
|
|
16117
|
+
this._scripts.add(script);
|
|
16118
|
+
};
|
|
16119
|
+
/**
|
|
16120
|
+
* @internal
|
|
16121
|
+
*/ _proto._removeScript = function _removeScript(script) {
|
|
16122
|
+
var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
|
|
16123
|
+
replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
|
|
16124
|
+
script._entityScriptsIndex = -1;
|
|
16125
|
+
};
|
|
16126
|
+
/**
|
|
16127
|
+
* @internal
|
|
16128
|
+
*/ _proto._removeFromParent = function _removeFromParent() {
|
|
16129
|
+
var oldParent = this._parent;
|
|
16130
|
+
if (oldParent != null) {
|
|
16131
|
+
var oldSibling = oldParent._children;
|
|
16132
|
+
var index = this._siblingIndex;
|
|
16133
|
+
oldSibling.splice(index, 1);
|
|
16134
|
+
for(var n = oldSibling.length; index < n; index++){
|
|
16135
|
+
oldSibling[index]._siblingIndex--;
|
|
15975
16136
|
}
|
|
15976
|
-
|
|
15977
|
-
|
|
16137
|
+
this._parent = null;
|
|
16138
|
+
this._siblingIndex = -1;
|
|
15978
16139
|
}
|
|
15979
|
-
return true;
|
|
15980
16140
|
};
|
|
15981
16141
|
/**
|
|
15982
16142
|
* @internal
|
|
15983
|
-
*/ _proto.
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
entity = entity.children[inversePath[i]];
|
|
16143
|
+
*/ _proto._processActive = function _processActive(activeChangeFlag) {
|
|
16144
|
+
if (this._activeChangedComponents) {
|
|
16145
|
+
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.";
|
|
15987
16146
|
}
|
|
15988
|
-
|
|
16147
|
+
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
16148
|
+
this._setActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
16149
|
+
this._setActiveComponents(true, activeChangeFlag);
|
|
15989
16150
|
};
|
|
15990
|
-
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
|
|
15999
|
-
|
|
16000
|
-
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16004
|
-
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
}
|
|
16010
|
-
}
|
|
16011
|
-
},
|
|
16012
|
-
{
|
|
16013
|
-
key: "localBounds",
|
|
16014
|
-
get: /**
|
|
16015
|
-
* Local bounds.
|
|
16016
|
-
*/ function get() {
|
|
16017
|
-
return this._localBounds;
|
|
16018
|
-
},
|
|
16019
|
-
set: function set(value) {
|
|
16020
|
-
if (this._localBounds !== value) {
|
|
16021
|
-
this._localBounds.copyFrom(value);
|
|
16022
|
-
}
|
|
16151
|
+
/**
|
|
16152
|
+
* @internal
|
|
16153
|
+
*/ _proto._processInActive = function _processInActive(activeChangeFlag) {
|
|
16154
|
+
if (this._activeChangedComponents) {
|
|
16155
|
+
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.";
|
|
16156
|
+
}
|
|
16157
|
+
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
16158
|
+
this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
16159
|
+
this._setActiveComponents(false, activeChangeFlag);
|
|
16160
|
+
};
|
|
16161
|
+
_proto._addToChildrenList = function _addToChildrenList(index, child) {
|
|
16162
|
+
var children = this._children;
|
|
16163
|
+
var childCount = children.length;
|
|
16164
|
+
if (index === undefined) {
|
|
16165
|
+
child._siblingIndex = childCount;
|
|
16166
|
+
children.push(child);
|
|
16167
|
+
} else {
|
|
16168
|
+
if (index < 0 || index > childCount) {
|
|
16169
|
+
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
16023
16170
|
}
|
|
16024
|
-
|
|
16025
|
-
|
|
16171
|
+
child._siblingIndex = index;
|
|
16172
|
+
children.splice(index, 0, child);
|
|
16173
|
+
for(var i = index + 1, n = childCount + 1; i < n; i++){
|
|
16174
|
+
children[i]._siblingIndex++;
|
|
16175
|
+
}
|
|
16176
|
+
}
|
|
16177
|
+
};
|
|
16178
|
+
_proto._setParent = function _setParent(parent, siblingIndex) {
|
|
16179
|
+
var oldParent = this._parent;
|
|
16180
|
+
if (parent !== oldParent) {
|
|
16181
|
+
this._removeFromParent();
|
|
16182
|
+
this._parent = parent;
|
|
16183
|
+
if (parent) {
|
|
16184
|
+
parent._addToChildrenList(siblingIndex, this);
|
|
16185
|
+
var oldScene = this._scene;
|
|
16186
|
+
var parentScene = parent._scene;
|
|
16187
|
+
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
16188
|
+
if (!parent._isActiveInHierarchy) {
|
|
16189
|
+
this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
16190
|
+
}
|
|
16191
|
+
if (parent._isActiveInScene) {
|
|
16192
|
+
// cross scene should inActive first and then active
|
|
16193
|
+
this._isActiveInScene && oldScene !== parentScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
16194
|
+
} else {
|
|
16195
|
+
this._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
16196
|
+
}
|
|
16197
|
+
inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
|
|
16198
|
+
if (oldScene !== parentScene) {
|
|
16199
|
+
Entity._traverseSetOwnerScene(this, parentScene);
|
|
16200
|
+
}
|
|
16201
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
16202
|
+
if (this._isActive) {
|
|
16203
|
+
if (parent._isActiveInHierarchy) {
|
|
16204
|
+
!this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
16205
|
+
}
|
|
16206
|
+
if (parent._isActiveInScene) {
|
|
16207
|
+
(!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
16208
|
+
}
|
|
16209
|
+
}
|
|
16210
|
+
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
16211
|
+
} else {
|
|
16212
|
+
var inActiveChangeFlag1 = ActiveChangeFlag.None;
|
|
16213
|
+
this._isActiveInHierarchy && (inActiveChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
16214
|
+
this._isActiveInScene && (inActiveChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
16215
|
+
inActiveChangeFlag1 && this._processInActive(inActiveChangeFlag1);
|
|
16216
|
+
if (oldParent) {
|
|
16217
|
+
Entity._traverseSetOwnerScene(this, null);
|
|
16218
|
+
}
|
|
16219
|
+
}
|
|
16220
|
+
this._setTransformDirty();
|
|
16221
|
+
}
|
|
16222
|
+
};
|
|
16223
|
+
_proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
|
|
16224
|
+
for(var i = this._components.length - 1; i >= 0; i--){
|
|
16225
|
+
var component = this._components[i];
|
|
16226
|
+
if (_instanceof1$2(component, type)) {
|
|
16227
|
+
results.push(component);
|
|
16228
|
+
}
|
|
16229
|
+
}
|
|
16230
|
+
for(var i1 = this._children.length - 1; i1 >= 0; i1--){
|
|
16231
|
+
this._children[i1]._getComponentsInChildren(type, results);
|
|
16232
|
+
}
|
|
16233
|
+
};
|
|
16234
|
+
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
16235
|
+
var activeChangedComponents = this._activeChangedComponents;
|
|
16236
|
+
for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
|
|
16237
|
+
activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
|
|
16238
|
+
}
|
|
16239
|
+
this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
|
|
16240
|
+
this._activeChangedComponents = null;
|
|
16241
|
+
};
|
|
16242
|
+
_proto._setActiveInHierarchy = function _setActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
16243
|
+
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = true);
|
|
16244
|
+
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = true);
|
|
16245
|
+
var components = this._components;
|
|
16246
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
16247
|
+
var component = components[i];
|
|
16248
|
+
(component.enabled || !component._awoken) && activeChangedComponents.push(component);
|
|
16249
|
+
}
|
|
16250
|
+
var children = this._children;
|
|
16251
|
+
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
16252
|
+
var child = children[i1];
|
|
16253
|
+
child.isActive && child._setActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
16254
|
+
}
|
|
16255
|
+
};
|
|
16256
|
+
_proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
16257
|
+
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
|
|
16258
|
+
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
|
|
16259
|
+
var components = this._components;
|
|
16260
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
16261
|
+
var component = components[i];
|
|
16262
|
+
component.enabled && activeChangedComponents.push(component);
|
|
16263
|
+
}
|
|
16264
|
+
var children = this._children;
|
|
16265
|
+
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
16266
|
+
var child = children[i1];
|
|
16267
|
+
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
16268
|
+
}
|
|
16269
|
+
};
|
|
16270
|
+
_proto._setTransformDirty = function _setTransformDirty() {
|
|
16271
|
+
if (this.transform) {
|
|
16272
|
+
this.transform._parentChange();
|
|
16273
|
+
} else {
|
|
16274
|
+
for(var i = 0, len = this._children.length; i < len; i++){
|
|
16275
|
+
this._children[i]._setTransformDirty();
|
|
16276
|
+
}
|
|
16277
|
+
}
|
|
16278
|
+
};
|
|
16279
|
+
_proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
|
|
16280
|
+
target = Math.min(target, sibling.length - 1);
|
|
16281
|
+
if (target < 0) {
|
|
16282
|
+
throw "Sibling index " + target + " should large than 0";
|
|
16283
|
+
}
|
|
16284
|
+
if (this._siblingIndex !== target) {
|
|
16285
|
+
var oldIndex = this._siblingIndex;
|
|
16286
|
+
if (target < oldIndex) {
|
|
16287
|
+
for(var i = oldIndex; i >= target; i--){
|
|
16288
|
+
var child = i == target ? this : sibling[i - 1];
|
|
16289
|
+
sibling[i] = child;
|
|
16290
|
+
child._siblingIndex = i;
|
|
16291
|
+
}
|
|
16292
|
+
} else {
|
|
16293
|
+
for(var i1 = oldIndex; i1 <= target; i1++){
|
|
16294
|
+
var child1 = i1 == target ? this : sibling[i1 + 1];
|
|
16295
|
+
sibling[i1] = child1;
|
|
16296
|
+
child1._siblingIndex = i1;
|
|
16297
|
+
}
|
|
16298
|
+
}
|
|
16299
|
+
}
|
|
16300
|
+
};
|
|
16301
|
+
/**
|
|
16302
|
+
* @deprecated
|
|
16303
|
+
*/ _proto.getInvModelMatrix = function getInvModelMatrix() {
|
|
16304
|
+
if (this._inverseWorldMatFlag.flag) {
|
|
16305
|
+
Matrix.invert(this.transform.worldMatrix, this._invModelMatrix);
|
|
16306
|
+
this._inverseWorldMatFlag.flag = false;
|
|
16307
|
+
}
|
|
16308
|
+
return this._invModelMatrix;
|
|
16309
|
+
};
|
|
16310
|
+
/**
|
|
16311
|
+
* @internal
|
|
16312
|
+
*/ Entity._findChildByName = function _findChildByName(root, name1) {
|
|
16313
|
+
var children = root._children;
|
|
16314
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
16315
|
+
var child = children[i];
|
|
16316
|
+
if (child.name === name1) {
|
|
16317
|
+
return child;
|
|
16318
|
+
}
|
|
16319
|
+
}
|
|
16320
|
+
return null;
|
|
16321
|
+
};
|
|
16322
|
+
/**
|
|
16323
|
+
* @internal
|
|
16324
|
+
*/ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
|
|
16325
|
+
entity._scene = scene;
|
|
16326
|
+
var children = entity._children;
|
|
16327
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
16328
|
+
this._traverseSetOwnerScene(children[i], scene);
|
|
16329
|
+
}
|
|
16330
|
+
};
|
|
16331
|
+
/**
|
|
16332
|
+
* @internal
|
|
16333
|
+
*/ Entity._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
|
|
16334
|
+
inversePath.length = 0;
|
|
16335
|
+
while(searchEntity !== rootEntity){
|
|
16336
|
+
var parent = searchEntity.parent;
|
|
16337
|
+
if (!parent) {
|
|
16338
|
+
return false;
|
|
16339
|
+
}
|
|
16340
|
+
inversePath.push(searchEntity.siblingIndex);
|
|
16341
|
+
searchEntity = parent;
|
|
16342
|
+
}
|
|
16343
|
+
return true;
|
|
16344
|
+
};
|
|
16345
|
+
/**
|
|
16346
|
+
* @internal
|
|
16347
|
+
*/ Entity._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
|
|
16348
|
+
var entity = rootEntity;
|
|
16349
|
+
for(var i = inversePath.length - 1; i >= 0; i--){
|
|
16350
|
+
entity = entity.children[inversePath[i]];
|
|
16351
|
+
}
|
|
16352
|
+
return entity;
|
|
16353
|
+
};
|
|
16354
|
+
_create_class$2(Entity, [
|
|
16355
|
+
{
|
|
16356
|
+
key: "isActive",
|
|
16357
|
+
get: /**
|
|
16358
|
+
* Whether to activate locally.
|
|
16359
|
+
*/ function get() {
|
|
16360
|
+
return this._isActive;
|
|
16361
|
+
},
|
|
16362
|
+
set: function set(value) {
|
|
16363
|
+
if (value !== this._isActive) {
|
|
16364
|
+
this._isActive = value;
|
|
16365
|
+
if (value) {
|
|
16366
|
+
var parent = this._parent;
|
|
16367
|
+
var activeChangeFlag = ActiveChangeFlag.None;
|
|
16368
|
+
if (this._isRoot && this._scene._isActiveInEngine) {
|
|
16369
|
+
activeChangeFlag |= ActiveChangeFlag.All;
|
|
16370
|
+
} else {
|
|
16371
|
+
var _parent, _parent1;
|
|
16372
|
+
((_parent = parent) == null ? void 0 : _parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
16373
|
+
((_parent1 = parent) == null ? void 0 : _parent1._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
16374
|
+
}
|
|
16375
|
+
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
16376
|
+
} else {
|
|
16377
|
+
var activeChangeFlag1 = ActiveChangeFlag.None;
|
|
16378
|
+
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
16379
|
+
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
16380
|
+
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
16381
|
+
}
|
|
16382
|
+
}
|
|
16383
|
+
}
|
|
16384
|
+
},
|
|
16385
|
+
{
|
|
16386
|
+
key: "isActiveInHierarchy",
|
|
16387
|
+
get: /**
|
|
16388
|
+
* Whether it is active in the hierarchy.
|
|
16389
|
+
*/ function get() {
|
|
16390
|
+
return this._isActiveInHierarchy;
|
|
16391
|
+
}
|
|
16392
|
+
},
|
|
16393
|
+
{
|
|
16394
|
+
key: "parent",
|
|
16395
|
+
get: /**
|
|
16396
|
+
* The parent entity.
|
|
16397
|
+
*/ function get() {
|
|
16398
|
+
return this._parent;
|
|
16399
|
+
},
|
|
16400
|
+
set: function set(value) {
|
|
16401
|
+
this._setParent(value);
|
|
16402
|
+
}
|
|
16403
|
+
},
|
|
16404
|
+
{
|
|
16405
|
+
key: "children",
|
|
16406
|
+
get: /**
|
|
16407
|
+
* The children entities
|
|
16408
|
+
*/ function get() {
|
|
16409
|
+
return this._children;
|
|
16410
|
+
}
|
|
16411
|
+
},
|
|
16412
|
+
{
|
|
16413
|
+
key: "childCount",
|
|
16414
|
+
get: /**
|
|
16415
|
+
* @deprecated Please use `children.length` property instead.
|
|
16416
|
+
* Number of the children entities
|
|
16417
|
+
*/ function get() {
|
|
16418
|
+
return this._children.length;
|
|
16419
|
+
}
|
|
16420
|
+
},
|
|
16421
|
+
{
|
|
16422
|
+
key: "scene",
|
|
16423
|
+
get: /**
|
|
16424
|
+
* The scene the entity belongs to.
|
|
16425
|
+
*/ function get() {
|
|
16426
|
+
return this._scene;
|
|
16427
|
+
}
|
|
16428
|
+
},
|
|
16429
|
+
{
|
|
16430
|
+
key: "siblingIndex",
|
|
16431
|
+
get: /**
|
|
16432
|
+
* The sibling index.
|
|
16433
|
+
*/ function get() {
|
|
16434
|
+
return this._siblingIndex;
|
|
16435
|
+
},
|
|
16436
|
+
set: function set(value) {
|
|
16437
|
+
if (this._siblingIndex === -1) {
|
|
16438
|
+
throw "The entity " + this.name + " is not in the hierarchy";
|
|
16439
|
+
}
|
|
16440
|
+
this._setSiblingIndex(this._isRoot ? this._scene._rootEntities : this._parent._children, value);
|
|
16441
|
+
}
|
|
16442
|
+
}
|
|
16443
|
+
]);
|
|
16444
|
+
return Entity;
|
|
16445
|
+
}(EngineObject);
|
|
16446
|
+
/**
|
|
16447
|
+
* Skin used for skinned mesh renderer.
|
|
16448
|
+
*/ var Skin = /*#__PURE__*/ function(EngineObject1) {
|
|
16449
|
+
var Skin = function Skin(name1) {
|
|
16450
|
+
var _this;
|
|
16451
|
+
_this = EngineObject1.call(this, null) || this;
|
|
16452
|
+
_this.name = name1;
|
|
16453
|
+
_this.inverseBindMatrices = new Array();
|
|
16454
|
+
_this._updatedManager = new UpdateFlagManager();
|
|
16455
|
+
_this._bones = new Array();
|
|
16456
|
+
_this._updateMark = -1;
|
|
16457
|
+
_this.joints = [];
|
|
16458
|
+
return _this;
|
|
16459
|
+
};
|
|
16460
|
+
_inherits$2(Skin, EngineObject1);
|
|
16461
|
+
var _proto = Skin.prototype;
|
|
16462
|
+
/**
|
|
16463
|
+
* @internal
|
|
16464
|
+
*/ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
|
|
16465
|
+
if (this._updateMark === renderer.engine.time.frameCount) {
|
|
16466
|
+
return;
|
|
16467
|
+
}
|
|
16468
|
+
var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
|
|
16469
|
+
var _this_rootBone;
|
|
16470
|
+
var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
|
|
16471
|
+
for(var i = bones.length - 1; i >= 0; i--){
|
|
16472
|
+
var bone = bones[i];
|
|
16473
|
+
var offset = i * 16;
|
|
16474
|
+
if (bone) {
|
|
16475
|
+
Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
|
|
16476
|
+
} else {
|
|
16477
|
+
skinMatrices.set(bindMatrices[i].elements, offset);
|
|
16478
|
+
}
|
|
16479
|
+
Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
|
|
16480
|
+
}
|
|
16481
|
+
this._updateMark = renderer.engine.time.frameCount;
|
|
16482
|
+
};
|
|
16483
|
+
/**
|
|
16484
|
+
* @internal
|
|
16485
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
16486
|
+
var paths = new Array();
|
|
16487
|
+
// Clone rootBone
|
|
16488
|
+
var rootBone = this.rootBone;
|
|
16489
|
+
if (rootBone) {
|
|
16490
|
+
var success = Entity._getEntityHierarchyPath(srcRoot, rootBone, paths);
|
|
16491
|
+
target.rootBone = success ? Entity._getEntityByHierarchyPath(targetRoot, paths) : rootBone;
|
|
16492
|
+
}
|
|
16493
|
+
// Clone bones
|
|
16494
|
+
var bones = this.bones;
|
|
16495
|
+
if (bones.length > 0) {
|
|
16496
|
+
var boneCount = bones.length;
|
|
16497
|
+
var destBones = new Array(boneCount);
|
|
16498
|
+
for(var i = 0; i < boneCount; i++){
|
|
16499
|
+
var bone = bones[i];
|
|
16500
|
+
var success1 = Entity._getEntityHierarchyPath(srcRoot, bone, paths);
|
|
16501
|
+
destBones[i] = success1 ? Entity._getEntityByHierarchyPath(targetRoot, paths) : bone;
|
|
16502
|
+
}
|
|
16503
|
+
target.bones = destBones;
|
|
16504
|
+
}
|
|
16505
|
+
};
|
|
16506
|
+
_create_class$2(Skin, [
|
|
16507
|
+
{
|
|
16026
16508
|
key: "rootBone",
|
|
16027
16509
|
get: /**
|
|
16028
16510
|
* Root bone.
|
|
@@ -16031,198 +16513,463 @@
|
|
|
16031
16513
|
},
|
|
16032
16514
|
set: function set(value) {
|
|
16033
16515
|
if (this._rootBone !== value) {
|
|
16034
|
-
this.
|
|
16516
|
+
this._updatedManager.dispatch(1, value);
|
|
16035
16517
|
this._rootBone = value;
|
|
16036
|
-
this._registerEntityTransformListener();
|
|
16037
|
-
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
16038
16518
|
}
|
|
16039
16519
|
}
|
|
16040
16520
|
},
|
|
16041
16521
|
{
|
|
16042
16522
|
key: "bones",
|
|
16043
16523
|
get: /**
|
|
16044
|
-
* Bones of the
|
|
16524
|
+
* Bones of the skin.
|
|
16045
16525
|
*/ function get() {
|
|
16046
16526
|
return this._bones;
|
|
16047
16527
|
},
|
|
16048
16528
|
set: function set(value) {
|
|
16049
|
-
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
|
|
16058
|
-
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
-
} else {
|
|
16062
|
-
this._jointMatrices = null;
|
|
16063
|
-
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
16064
|
-
}
|
|
16065
|
-
}
|
|
16066
|
-
this._bones = value;
|
|
16529
|
+
var _value;
|
|
16530
|
+
var bones = this._bones;
|
|
16531
|
+
var _value_length;
|
|
16532
|
+
var boneCount = (_value_length = (_value = value) == null ? void 0 : _value.length) != null ? _value_length : 0;
|
|
16533
|
+
var lastBoneCount = bones.length;
|
|
16534
|
+
bones.length = boneCount;
|
|
16535
|
+
for(var i = 0; i < boneCount; i++){
|
|
16536
|
+
bones[i] = value[i];
|
|
16537
|
+
}
|
|
16538
|
+
if (lastBoneCount !== boneCount) {
|
|
16539
|
+
this._skinMatrices = new Float32Array(boneCount * 16);
|
|
16540
|
+
this._updatedManager.dispatch(0, boneCount);
|
|
16067
16541
|
}
|
|
16068
16542
|
}
|
|
16069
16543
|
},
|
|
16070
16544
|
{
|
|
16071
|
-
key: "
|
|
16072
|
-
get: /**
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
*
|
|
16076
|
-
* If you want get `skeleton`, use {@link SkinnedMeshRenderer.rootBone} instead.
|
|
16077
|
-
* If you want get `bones`, use {@link SkinnedMeshRenderer.bones} instead.
|
|
16078
|
-
* `inverseBindMatrices` will migrate to mesh in the future.
|
|
16079
|
-
*
|
|
16080
|
-
* @remarks `rootBone` and `bones` will not update when `skin` changed.
|
|
16081
|
-
*/ function get() {
|
|
16082
|
-
return this._skin;
|
|
16545
|
+
key: "skeleton",
|
|
16546
|
+
get: /** @deprecated Please use `rootBone` instead. */ function get() {
|
|
16547
|
+
var _this_rootBone;
|
|
16548
|
+
return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
|
|
16083
16549
|
},
|
|
16084
16550
|
set: function set(value) {
|
|
16085
|
-
|
|
16551
|
+
var rootBone = this._rootBone;
|
|
16552
|
+
if (rootBone) {
|
|
16553
|
+
rootBone.name = value;
|
|
16554
|
+
}
|
|
16086
16555
|
}
|
|
16087
16556
|
}
|
|
16088
16557
|
]);
|
|
16089
|
-
return
|
|
16090
|
-
}(
|
|
16091
|
-
(function() {
|
|
16092
|
-
SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
|
|
16093
|
-
})();
|
|
16094
|
-
(function() {
|
|
16095
|
-
SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
|
|
16096
|
-
})();
|
|
16097
|
-
(function() {
|
|
16098
|
-
SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
|
|
16099
|
-
})();
|
|
16558
|
+
return Skin;
|
|
16559
|
+
}(EngineObject);
|
|
16100
16560
|
__decorate$1([
|
|
16101
16561
|
deepClone
|
|
16102
|
-
],
|
|
16103
|
-
__decorate$1([
|
|
16104
|
-
ignoreClone
|
|
16105
|
-
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
16562
|
+
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
16106
16563
|
__decorate$1([
|
|
16107
16564
|
ignoreClone
|
|
16108
|
-
],
|
|
16109
|
-
__decorate$1([
|
|
16110
|
-
ignoreClone
|
|
16111
|
-
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
16112
|
-
__decorate$1([
|
|
16113
|
-
ignoreClone
|
|
16114
|
-
], SkinnedMeshRenderer.prototype, "_rootBone", void 0);
|
|
16115
|
-
__decorate$1([
|
|
16116
|
-
ignoreClone
|
|
16117
|
-
], SkinnedMeshRenderer.prototype, "_jointMatrices", void 0);
|
|
16565
|
+
], Skin.prototype, "_skinMatrices", void 0);
|
|
16118
16566
|
__decorate$1([
|
|
16119
16567
|
ignoreClone
|
|
16120
|
-
],
|
|
16568
|
+
], Skin.prototype, "_updatedManager", void 0);
|
|
16121
16569
|
__decorate$1([
|
|
16122
16570
|
ignoreClone
|
|
16123
|
-
],
|
|
16571
|
+
], Skin.prototype, "_rootBone", void 0);
|
|
16124
16572
|
__decorate$1([
|
|
16125
16573
|
ignoreClone
|
|
16126
|
-
],
|
|
16574
|
+
], Skin.prototype, "_bones", void 0);
|
|
16127
16575
|
__decorate$1([
|
|
16128
16576
|
ignoreClone
|
|
16129
|
-
],
|
|
16577
|
+
], Skin.prototype, "_updateMark", void 0);
|
|
16578
|
+
var SkinUpdateFlag;
|
|
16579
|
+
(function(SkinUpdateFlag) {
|
|
16580
|
+
SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
|
|
16581
|
+
SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
|
|
16582
|
+
})(SkinUpdateFlag || (SkinUpdateFlag = {}));
|
|
16130
16583
|
/**
|
|
16131
|
-
*
|
|
16132
|
-
*/ var
|
|
16133
|
-
var
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16584
|
+
* SkinnedMeshRenderer.
|
|
16585
|
+
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer1) {
|
|
16586
|
+
var SkinnedMeshRenderer = function SkinnedMeshRenderer(entity) {
|
|
16587
|
+
var _this;
|
|
16588
|
+
_this = MeshRenderer1.call(this, entity) || this;
|
|
16589
|
+
_this._localBounds = new BoundingBox();
|
|
16590
|
+
_this._jointDataCreateCache = new Vector2(-1, -1);
|
|
16591
|
+
_this._skin = null;
|
|
16592
|
+
var rhi = _this.entity.engine._hardwareRenderer;
|
|
16593
|
+
var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
|
|
16594
|
+
// Limit size to 256 to avoid some problem:
|
|
16595
|
+
// 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!
|
|
16596
|
+
// 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.
|
|
16597
|
+
maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
|
|
16598
|
+
_this._maxVertexUniformVectors = maxVertexUniformVectors;
|
|
16599
|
+
_this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_assert_this_initialized(_this));
|
|
16600
|
+
_this._onSkinUpdated = _this._onSkinUpdated.bind(_assert_this_initialized(_this));
|
|
16601
|
+
var localBounds = _this._localBounds;
|
|
16602
|
+
// @ts-ignore
|
|
16603
|
+
localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
|
|
16604
|
+
// @ts-ignore
|
|
16605
|
+
localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
|
|
16606
|
+
return _this;
|
|
16137
16607
|
};
|
|
16138
|
-
|
|
16608
|
+
_inherits$2(SkinnedMeshRenderer, MeshRenderer1);
|
|
16609
|
+
var _proto = SkinnedMeshRenderer.prototype;
|
|
16139
16610
|
/**
|
|
16140
|
-
*
|
|
16141
|
-
*/ _proto.
|
|
16142
|
-
var
|
|
16143
|
-
this.
|
|
16144
|
-
if (
|
|
16145
|
-
|
|
16146
|
-
pool.push(element);
|
|
16147
|
-
return element;
|
|
16148
|
-
} else {
|
|
16149
|
-
return pool[index];
|
|
16611
|
+
* @internal
|
|
16612
|
+
*/ _proto.update = function update() {
|
|
16613
|
+
var _skin;
|
|
16614
|
+
var skin = this._skin;
|
|
16615
|
+
if (((_skin = skin) == null ? void 0 : _skin.bones.length) > 0) {
|
|
16616
|
+
skin._updateSkinMatrices(this);
|
|
16150
16617
|
}
|
|
16151
16618
|
};
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
pool[i].dispose && pool[i].dispose();
|
|
16619
|
+
_proto._updateShaderData = function _updateShaderData(context, onlyMVP) {
|
|
16620
|
+
var _skin, _skin1;
|
|
16621
|
+
var _this = this, entity = _this.entity, skin = _this.skin;
|
|
16622
|
+
var _skin_rootBone;
|
|
16623
|
+
var worldMatrix = ((_skin_rootBone = (_skin = skin) == null ? void 0 : _skin.rootBone) != null ? _skin_rootBone : entity).transform.worldMatrix;
|
|
16624
|
+
if (onlyMVP) {
|
|
16625
|
+
this._updateMVPShaderData(context, worldMatrix);
|
|
16626
|
+
return;
|
|
16161
16627
|
}
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16628
|
+
this._updateTransformShaderData(context, worldMatrix);
|
|
16629
|
+
var shaderData = this.shaderData;
|
|
16630
|
+
var mesh = this.mesh;
|
|
16631
|
+
var blendShapeManager = mesh._blendShapeManager;
|
|
16632
|
+
blendShapeManager._updateShaderData(shaderData, this);
|
|
16633
|
+
var bones = (_skin1 = skin) == null ? void 0 : _skin1.bones;
|
|
16634
|
+
if (bones) {
|
|
16635
|
+
var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
|
|
16636
|
+
var boneCount = bones.length;
|
|
16637
|
+
var boneDataCreateCache = this._jointDataCreateCache;
|
|
16638
|
+
var boneCountChange = boneCount !== boneDataCreateCache.x;
|
|
16639
|
+
if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
|
|
16640
|
+
// directly use max joint count to avoid shader recompile
|
|
16641
|
+
// @TODO: different shader type should use different count, not always 44
|
|
16642
|
+
var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (44 + bsUniformOccupiesCount)) / 4);
|
|
16643
|
+
if (boneCount > remainUniformJointCount) {
|
|
16644
|
+
var engine = this.engine;
|
|
16645
|
+
if (engine._hardwareRenderer.canIUseMoreJoints) {
|
|
16646
|
+
if (boneCountChange) {
|
|
16647
|
+
var _this__jointTexture;
|
|
16648
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
16649
|
+
this._jointTexture = new Texture2D(engine, 4, boneCount, exports.TextureFormat.R32G32B32A32, false);
|
|
16650
|
+
this._jointTexture.filterMode = exports.TextureFilterMode.Point;
|
|
16651
|
+
this._jointTexture.isGCIgnored = true;
|
|
16652
|
+
}
|
|
16653
|
+
shaderData.disableMacro("RENDERER_JOINTS_NUM");
|
|
16654
|
+
shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
16655
|
+
shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
|
|
16656
|
+
} else {
|
|
16657
|
+
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);
|
|
16658
|
+
}
|
|
16659
|
+
} else {
|
|
16660
|
+
var _this__jointTexture1;
|
|
16661
|
+
(_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
|
|
16662
|
+
shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
|
|
16663
|
+
shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
|
|
16664
|
+
shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
|
|
16665
|
+
}
|
|
16666
|
+
boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
|
|
16667
|
+
}
|
|
16668
|
+
if (this._jointTexture) {
|
|
16669
|
+
this._jointTexture.setPixelBuffer(skin._skinMatrices);
|
|
16189
16670
|
}
|
|
16190
|
-
} else {
|
|
16191
|
-
this._drawSubElement(element, camera);
|
|
16192
16671
|
}
|
|
16672
|
+
var layer = entity.layer;
|
|
16673
|
+
this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
|
|
16193
16674
|
};
|
|
16194
16675
|
/**
|
|
16195
16676
|
* @internal
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
this.
|
|
16200
|
-
this.
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16677
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
16678
|
+
var _this__jointTexture;
|
|
16679
|
+
MeshRenderer1.prototype._onDestroy.call(this);
|
|
16680
|
+
this._jointDataCreateCache = null;
|
|
16681
|
+
this._skin = null;
|
|
16682
|
+
this._blendShapeWeights = null;
|
|
16683
|
+
this._localBounds = null;
|
|
16684
|
+
(_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
|
|
16685
|
+
this._jointTexture = null;
|
|
16205
16686
|
};
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
this.drawBatches(camera);
|
|
16213
|
-
if (!Basic2DBatcher._canUploadSameBuffer) {
|
|
16214
|
-
this._flushId++;
|
|
16687
|
+
/**
|
|
16688
|
+
* @internal
|
|
16689
|
+
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
16690
|
+
MeshRenderer1.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
|
|
16691
|
+
if (this.skin) {
|
|
16692
|
+
target._applySkin(null, target.skin);
|
|
16215
16693
|
}
|
|
16216
|
-
|
|
16217
|
-
this._subMeshPool.resetPool();
|
|
16218
|
-
this._vertexCount = 0;
|
|
16219
|
-
this._elementCount = 0;
|
|
16694
|
+
this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
|
|
16220
16695
|
};
|
|
16221
|
-
|
|
16222
|
-
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
this.
|
|
16696
|
+
/**
|
|
16697
|
+
* @internal
|
|
16698
|
+
*/ _proto._updateBounds = function _updateBounds(worldBounds) {
|
|
16699
|
+
var _this_skin;
|
|
16700
|
+
var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
|
|
16701
|
+
if (rootBone) {
|
|
16702
|
+
BoundingBox.transform(this._localBounds, rootBone.transform.worldMatrix, worldBounds);
|
|
16703
|
+
} else {
|
|
16704
|
+
MeshRenderer1.prototype._updateBounds.call(this, worldBounds);
|
|
16705
|
+
}
|
|
16706
|
+
};
|
|
16707
|
+
_proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
|
|
16708
|
+
var mesh = this._mesh;
|
|
16709
|
+
var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
|
|
16710
|
+
var lastBlendShapeWeights = this._blendShapeWeights;
|
|
16711
|
+
if (lastBlendShapeWeights) {
|
|
16712
|
+
var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
|
|
16713
|
+
if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
|
|
16714
|
+
var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
16715
|
+
if (newBlendShapeCount > lastBlendShapeWeightsCount) {
|
|
16716
|
+
newBlendShapeWeights.set(lastBlendShapeWeights);
|
|
16717
|
+
} else {
|
|
16718
|
+
for(var i = 0; i < newBlendShapeCount; i++){
|
|
16719
|
+
newBlendShapeWeights[i] = lastBlendShapeWeights[i];
|
|
16720
|
+
}
|
|
16721
|
+
}
|
|
16722
|
+
this._blendShapeWeights = newBlendShapeWeights;
|
|
16723
|
+
}
|
|
16724
|
+
} else {
|
|
16725
|
+
this._blendShapeWeights = new Float32Array(newBlendShapeCount);
|
|
16726
|
+
}
|
|
16727
|
+
};
|
|
16728
|
+
_proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
|
|
16729
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
16730
|
+
};
|
|
16731
|
+
_proto._onSkinUpdated = function _onSkinUpdated(type, value) {
|
|
16732
|
+
switch(type){
|
|
16733
|
+
case SkinUpdateFlag.BoneCountChanged:
|
|
16734
|
+
var shaderData = this.shaderData;
|
|
16735
|
+
if (value > 0) {
|
|
16736
|
+
shaderData.enableMacro("RENDERER_HAS_SKIN");
|
|
16737
|
+
shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
|
|
16738
|
+
} else {
|
|
16739
|
+
shaderData.disableMacro("RENDERER_HAS_SKIN");
|
|
16740
|
+
}
|
|
16741
|
+
break;
|
|
16742
|
+
case SkinUpdateFlag.RootBoneChanged:
|
|
16743
|
+
this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
|
|
16744
|
+
break;
|
|
16745
|
+
}
|
|
16746
|
+
};
|
|
16747
|
+
_proto._applySkin = function _applySkin(lastSkin, value) {
|
|
16748
|
+
var _lastSkin_bones, _lastSkin, _lastSkin1, _lastSkin2, _value_bones, _value, _value1, _value2;
|
|
16749
|
+
var _lastSkin_bones_length;
|
|
16750
|
+
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;
|
|
16751
|
+
var _lastSkin_rootBone;
|
|
16752
|
+
var lastRootBone = (_lastSkin_rootBone = (_lastSkin1 = lastSkin) == null ? void 0 : _lastSkin1.rootBone) != null ? _lastSkin_rootBone : this.entity;
|
|
16753
|
+
(_lastSkin2 = lastSkin) == null ? void 0 : _lastSkin2._updatedManager.removeListener(this._onSkinUpdated);
|
|
16754
|
+
var _value_bones_length;
|
|
16755
|
+
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;
|
|
16756
|
+
var _value_rootBone;
|
|
16757
|
+
var rootBone = (_value_rootBone = (_value1 = value) == null ? void 0 : _value1.rootBone) != null ? _value_rootBone : this.entity;
|
|
16758
|
+
(_value2 = value) == null ? void 0 : _value2._updatedManager.addListener(this._onSkinUpdated);
|
|
16759
|
+
if (lastSkinBoneCount !== skinBoneCount) {
|
|
16760
|
+
this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
|
|
16761
|
+
}
|
|
16762
|
+
if (lastRootBone !== rootBone) {
|
|
16763
|
+
this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
|
|
16764
|
+
}
|
|
16765
|
+
};
|
|
16766
|
+
_create_class$2(SkinnedMeshRenderer, [
|
|
16767
|
+
{
|
|
16768
|
+
key: "skin",
|
|
16769
|
+
get: /**
|
|
16770
|
+
* Skin of the SkinnedMeshRenderer.
|
|
16771
|
+
*/ function get() {
|
|
16772
|
+
return this._skin;
|
|
16773
|
+
},
|
|
16774
|
+
set: function set(value) {
|
|
16775
|
+
var lastSkin = this._skin;
|
|
16776
|
+
if (lastSkin !== value) {
|
|
16777
|
+
this._applySkin(lastSkin, value);
|
|
16778
|
+
this._skin = value;
|
|
16779
|
+
}
|
|
16780
|
+
}
|
|
16781
|
+
},
|
|
16782
|
+
{
|
|
16783
|
+
key: "blendShapeWeights",
|
|
16784
|
+
get: /**
|
|
16785
|
+
* The weights of the BlendShapes.
|
|
16786
|
+
* @remarks Array index is BlendShape index.
|
|
16787
|
+
*/ function get() {
|
|
16788
|
+
this._checkBlendShapeWeightLength();
|
|
16789
|
+
return this._blendShapeWeights;
|
|
16790
|
+
},
|
|
16791
|
+
set: function set(value) {
|
|
16792
|
+
this._checkBlendShapeWeightLength();
|
|
16793
|
+
var blendShapeWeights = this._blendShapeWeights;
|
|
16794
|
+
if (value.length <= blendShapeWeights.length) {
|
|
16795
|
+
blendShapeWeights.set(value);
|
|
16796
|
+
} else {
|
|
16797
|
+
for(var i = 0, n = blendShapeWeights.length; i < n; i++){
|
|
16798
|
+
blendShapeWeights[i] = value[i];
|
|
16799
|
+
}
|
|
16800
|
+
}
|
|
16801
|
+
}
|
|
16802
|
+
},
|
|
16803
|
+
{
|
|
16804
|
+
key: "localBounds",
|
|
16805
|
+
get: /**
|
|
16806
|
+
* Local bounds.
|
|
16807
|
+
*/ function get() {
|
|
16808
|
+
return this._localBounds;
|
|
16809
|
+
},
|
|
16810
|
+
set: function set(value) {
|
|
16811
|
+
if (this._localBounds !== value) {
|
|
16812
|
+
this._localBounds.copyFrom(value);
|
|
16813
|
+
}
|
|
16814
|
+
}
|
|
16815
|
+
},
|
|
16816
|
+
{
|
|
16817
|
+
key: "rootBone",
|
|
16818
|
+
get: /**
|
|
16819
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.rootBone} instead.
|
|
16820
|
+
*/ function get() {
|
|
16821
|
+
return this.skin.rootBone;
|
|
16822
|
+
},
|
|
16823
|
+
set: function set(value) {
|
|
16824
|
+
this.skin.rootBone = value;
|
|
16825
|
+
}
|
|
16826
|
+
},
|
|
16827
|
+
{
|
|
16828
|
+
key: "bones",
|
|
16829
|
+
get: /**
|
|
16830
|
+
* @deprecated use {@link SkinnedMeshRenderer.skin.bones} instead.
|
|
16831
|
+
*/ function get() {
|
|
16832
|
+
return this.skin.bones;
|
|
16833
|
+
},
|
|
16834
|
+
set: function set(value) {
|
|
16835
|
+
this.skin.bones = value;
|
|
16836
|
+
}
|
|
16837
|
+
}
|
|
16838
|
+
]);
|
|
16839
|
+
return SkinnedMeshRenderer;
|
|
16840
|
+
}(MeshRenderer);
|
|
16841
|
+
(function() {
|
|
16842
|
+
SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
|
|
16843
|
+
})();
|
|
16844
|
+
(function() {
|
|
16845
|
+
SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
|
|
16846
|
+
})();
|
|
16847
|
+
(function() {
|
|
16848
|
+
SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
|
|
16849
|
+
})();
|
|
16850
|
+
__decorate$1([
|
|
16851
|
+
ignoreClone
|
|
16852
|
+
], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
|
|
16853
|
+
__decorate$1([
|
|
16854
|
+
deepClone
|
|
16855
|
+
], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
|
|
16856
|
+
__decorate$1([
|
|
16857
|
+
ignoreClone
|
|
16858
|
+
], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
|
|
16859
|
+
__decorate$1([
|
|
16860
|
+
ignoreClone
|
|
16861
|
+
], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
|
|
16862
|
+
__decorate$1([
|
|
16863
|
+
ignoreClone
|
|
16864
|
+
], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
|
|
16865
|
+
__decorate$1([
|
|
16866
|
+
ignoreClone
|
|
16867
|
+
], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
|
|
16868
|
+
__decorate$1([
|
|
16869
|
+
deepClone
|
|
16870
|
+
], SkinnedMeshRenderer.prototype, "_skin", void 0);
|
|
16871
|
+
__decorate$1([
|
|
16872
|
+
ignoreClone
|
|
16873
|
+
], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
|
|
16874
|
+
__decorate$1([
|
|
16875
|
+
ignoreClone
|
|
16876
|
+
], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
|
|
16877
|
+
/**
|
|
16878
|
+
* Class pool utils.
|
|
16879
|
+
*/ var ClassPool = /*#__PURE__*/ function() {
|
|
16880
|
+
var ClassPool = function ClassPool(type) {
|
|
16881
|
+
this._elementPoolIndex = 0;
|
|
16882
|
+
this._elementPool = [];
|
|
16883
|
+
this._type = type;
|
|
16884
|
+
};
|
|
16885
|
+
var _proto = ClassPool.prototype;
|
|
16886
|
+
/**
|
|
16887
|
+
* Get element from pool.
|
|
16888
|
+
*/ _proto.getFromPool = function getFromPool() {
|
|
16889
|
+
var _this = this, index = _this._elementPoolIndex, pool = _this._elementPool;
|
|
16890
|
+
this._elementPoolIndex++;
|
|
16891
|
+
if (pool.length === index) {
|
|
16892
|
+
var element = new this._type();
|
|
16893
|
+
pool.push(element);
|
|
16894
|
+
return element;
|
|
16895
|
+
} else {
|
|
16896
|
+
return pool[index];
|
|
16897
|
+
}
|
|
16898
|
+
};
|
|
16899
|
+
/**
|
|
16900
|
+
* Reset pool.
|
|
16901
|
+
*/ _proto.resetPool = function resetPool() {
|
|
16902
|
+
this._elementPoolIndex = 0;
|
|
16903
|
+
};
|
|
16904
|
+
_proto.garbageCollection = function garbageCollection() {
|
|
16905
|
+
var _this = this, pool = _this._elementPool;
|
|
16906
|
+
for(var i = pool.length - 1; i >= 0; i--){
|
|
16907
|
+
pool[i].dispose && pool[i].dispose();
|
|
16908
|
+
}
|
|
16909
|
+
};
|
|
16910
|
+
return ClassPool;
|
|
16911
|
+
}();
|
|
16912
|
+
var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
16913
|
+
var Basic2DBatcher = function Basic2DBatcher(engine) {
|
|
16914
|
+
/** @internal */ this._subMeshPool = new ClassPool(SubMesh);
|
|
16915
|
+
/** @internal */ this._batchedQueue = [];
|
|
16916
|
+
/** @internal */ this._meshes = [];
|
|
16917
|
+
/** @internal */ this._meshCount = 1;
|
|
16918
|
+
/** @internal */ this._vertexBuffers = [];
|
|
16919
|
+
/** @internal */ this._indiceBuffers = [];
|
|
16920
|
+
/** @internal */ this._flushId = 0;
|
|
16921
|
+
/** @internal */ this._vertexCount = 0;
|
|
16922
|
+
/** @internal */ this._elementCount = 0;
|
|
16923
|
+
this._engine = engine;
|
|
16924
|
+
this._initMeshes(engine);
|
|
16925
|
+
};
|
|
16926
|
+
var _proto = Basic2DBatcher.prototype;
|
|
16927
|
+
_proto.drawElement = function drawElement(element, camera) {
|
|
16928
|
+
var data = element.data;
|
|
16929
|
+
if (data.multiRenderData) {
|
|
16930
|
+
var charsData = data.charsData;
|
|
16931
|
+
var pool = camera.engine._renderElementPool;
|
|
16932
|
+
for(var i = 0, n = charsData.length; i < n; ++i){
|
|
16933
|
+
var charRenderElement = pool.getFromPool();
|
|
16934
|
+
charRenderElement.set(charsData[i], element.shaderPasses);
|
|
16935
|
+
this._drawSubElement(charRenderElement, camera);
|
|
16936
|
+
}
|
|
16937
|
+
} else {
|
|
16938
|
+
this._drawSubElement(element, camera);
|
|
16939
|
+
}
|
|
16940
|
+
};
|
|
16941
|
+
/**
|
|
16942
|
+
* @internal
|
|
16943
|
+
* Standalone for canvas 2d renderer plugin.
|
|
16944
|
+
*/ _proto._initMeshes = function _initMeshes(engine) {
|
|
16945
|
+
var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
|
|
16946
|
+
this._vertices = new Float32Array(MAX_VERTEX_COUNT * 9);
|
|
16947
|
+
this._indices = new Uint16Array(MAX_VERTEX_COUNT * 3);
|
|
16948
|
+
var _this = this, _meshes = _this._meshes, _meshCount = _this._meshCount;
|
|
16949
|
+
for(var i = 0; i < _meshCount; i++){
|
|
16950
|
+
_meshes[i] = this._createMesh(engine, i);
|
|
16951
|
+
}
|
|
16952
|
+
};
|
|
16953
|
+
_proto.flush = function flush(camera) {
|
|
16954
|
+
var batchedQueue = this._batchedQueue;
|
|
16955
|
+
if (batchedQueue.length === 0) {
|
|
16956
|
+
return;
|
|
16957
|
+
}
|
|
16958
|
+
this._updateData(this._engine);
|
|
16959
|
+
this.drawBatches(camera);
|
|
16960
|
+
if (!Basic2DBatcher._canUploadSameBuffer) {
|
|
16961
|
+
this._flushId++;
|
|
16962
|
+
}
|
|
16963
|
+
batchedQueue.length = 0;
|
|
16964
|
+
this._subMeshPool.resetPool();
|
|
16965
|
+
this._vertexCount = 0;
|
|
16966
|
+
this._elementCount = 0;
|
|
16967
|
+
};
|
|
16968
|
+
_proto.clear = function clear() {
|
|
16969
|
+
this._flushId = 0;
|
|
16970
|
+
this._vertexCount = 0;
|
|
16971
|
+
this._elementCount = 0;
|
|
16972
|
+
this._batchedQueue.length = 0;
|
|
16226
16973
|
};
|
|
16227
16974
|
_proto.destroy = function destroy() {
|
|
16228
16975
|
this._batchedQueue = null;
|
|
@@ -18755,7 +19502,7 @@
|
|
|
18755
19502
|
*/ _proto.cloneTo = function cloneTo(target) {
|
|
18756
19503
|
target.shader = this.shader;
|
|
18757
19504
|
this.shaderData.cloneTo(target.shaderData);
|
|
18758
|
-
CloneManager.deepCloneObject(this.renderStates, target.renderStates);
|
|
19505
|
+
CloneManager.deepCloneObject(this.renderStates, target.renderStates, new Map());
|
|
18759
19506
|
};
|
|
18760
19507
|
_proto._addReferCount = function _addReferCount(value) {
|
|
18761
19508
|
if (this._destroyed) return;
|
|
@@ -19488,1067 +20235,421 @@
|
|
|
19488
20235
|
},
|
|
19489
20236
|
set: function set(value) {
|
|
19490
20237
|
this.shaderData.setTexture(PBRBaseMaterial._clearCoatRoughnessTextureProp, value);
|
|
19491
|
-
if (value) {
|
|
19492
|
-
this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE");
|
|
19493
|
-
} else {
|
|
19494
|
-
this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE");
|
|
19495
|
-
}
|
|
19496
|
-
}
|
|
19497
|
-
},
|
|
19498
|
-
{
|
|
19499
|
-
key: "clearCoatNormalTexture",
|
|
19500
|
-
get: /**
|
|
19501
|
-
* The clearCoat normal map texture.
|
|
19502
|
-
*/ function get() {
|
|
19503
|
-
return this.shaderData.getTexture(PBRBaseMaterial._clearCoatNormalTextureProp);
|
|
19504
|
-
},
|
|
19505
|
-
set: function set(value) {
|
|
19506
|
-
this.shaderData.setTexture(PBRBaseMaterial._clearCoatNormalTextureProp, value);
|
|
19507
|
-
if (value) {
|
|
19508
|
-
this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE");
|
|
19509
|
-
} else {
|
|
19510
|
-
this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE");
|
|
19511
|
-
}
|
|
19512
|
-
}
|
|
19513
|
-
}
|
|
19514
|
-
]);
|
|
19515
|
-
return PBRBaseMaterial;
|
|
19516
|
-
}(BaseMaterial);
|
|
19517
|
-
(function() {
|
|
19518
|
-
PBRBaseMaterial._occlusionTextureIntensityProp = ShaderProperty.getByName("material_OcclusionIntensity");
|
|
19519
|
-
})();
|
|
19520
|
-
(function() {
|
|
19521
|
-
PBRBaseMaterial._occlusionTextureCoordProp = ShaderProperty.getByName("material_OcclusionTextureCoord");
|
|
19522
|
-
})();
|
|
19523
|
-
(function() {
|
|
19524
|
-
PBRBaseMaterial._occlusionTextureProp = ShaderProperty.getByName("material_OcclusionTexture");
|
|
19525
|
-
})();
|
|
19526
|
-
(function() {
|
|
19527
|
-
PBRBaseMaterial._clearCoatProp = ShaderProperty.getByName("material_ClearCoat");
|
|
19528
|
-
})();
|
|
19529
|
-
(function() {
|
|
19530
|
-
PBRBaseMaterial._clearCoatTextureProp = ShaderProperty.getByName("material_ClearCoatTexture");
|
|
19531
|
-
})();
|
|
19532
|
-
(function() {
|
|
19533
|
-
PBRBaseMaterial._clearCoatRoughnessProp = ShaderProperty.getByName("material_ClearCoatRoughness");
|
|
19534
|
-
})();
|
|
19535
|
-
(function() {
|
|
19536
|
-
PBRBaseMaterial._clearCoatRoughnessTextureProp = ShaderProperty.getByName("material_ClearCoatRoughnessTexture");
|
|
19537
|
-
})();
|
|
19538
|
-
(function() {
|
|
19539
|
-
PBRBaseMaterial._clearCoatNormalTextureProp = ShaderProperty.getByName("material_ClearCoatNormalTexture");
|
|
19540
|
-
})();
|
|
19541
|
-
/**
|
|
19542
|
-
* PBR (Metallic-Roughness Workflow) Material.
|
|
19543
|
-
*/ var PBRMaterial = /*#__PURE__*/ function(PBRBaseMaterial1) {
|
|
19544
|
-
_inherits$2(PBRMaterial, PBRBaseMaterial1);
|
|
19545
|
-
function PBRMaterial(engine) {
|
|
19546
|
-
var _this;
|
|
19547
|
-
_this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr")) || this;
|
|
19548
|
-
_this._anisotropyRotation = 0;
|
|
19549
|
-
var shaderData = _this.shaderData;
|
|
19550
|
-
shaderData.setFloat(PBRMaterial._metallicProp, 1);
|
|
19551
|
-
shaderData.setFloat(PBRMaterial._roughnessProp, 1);
|
|
19552
|
-
shaderData.setFloat(PBRMaterial._iorProp, 1.5);
|
|
19553
|
-
shaderData.setVector3(PBRMaterial._anisotropyInfoProp, new Vector3(1, 0, 0));
|
|
19554
|
-
return _this;
|
|
19555
|
-
}
|
|
19556
|
-
var _proto = PBRMaterial.prototype;
|
|
19557
|
-
/**
|
|
19558
|
-
* @inheritdoc
|
|
19559
|
-
*/ _proto.clone = function clone() {
|
|
19560
|
-
var dest = new PBRMaterial(this._engine);
|
|
19561
|
-
this.cloneTo(dest);
|
|
19562
|
-
return dest;
|
|
19563
|
-
};
|
|
19564
|
-
_create_class$2(PBRMaterial, [
|
|
19565
|
-
{
|
|
19566
|
-
key: "ior",
|
|
19567
|
-
get: /**
|
|
19568
|
-
* Index Of Refraction.
|
|
19569
|
-
* @defaultValue `1.5`
|
|
19570
|
-
*/ function get() {
|
|
19571
|
-
return this.shaderData.getFloat(PBRMaterial._iorProp);
|
|
19572
|
-
},
|
|
19573
|
-
set: function set(v) {
|
|
19574
|
-
this.shaderData.setFloat(PBRMaterial._iorProp, Math.max(v, 0));
|
|
19575
|
-
}
|
|
19576
|
-
},
|
|
19577
|
-
{
|
|
19578
|
-
key: "metallic",
|
|
19579
|
-
get: /**
|
|
19580
|
-
* Metallic.
|
|
19581
|
-
* @defaultValue `1.0`
|
|
19582
|
-
*/ function get() {
|
|
19583
|
-
return this.shaderData.getFloat(PBRMaterial._metallicProp);
|
|
19584
|
-
},
|
|
19585
|
-
set: function set(value) {
|
|
19586
|
-
this.shaderData.setFloat(PBRMaterial._metallicProp, value);
|
|
19587
|
-
}
|
|
19588
|
-
},
|
|
19589
|
-
{
|
|
19590
|
-
key: "roughness",
|
|
19591
|
-
get: /**
|
|
19592
|
-
* Roughness. default 1.0.
|
|
19593
|
-
* @defaultValue `1.0`
|
|
19594
|
-
*/ function get() {
|
|
19595
|
-
return this.shaderData.getFloat(PBRMaterial._roughnessProp);
|
|
19596
|
-
},
|
|
19597
|
-
set: function set(value) {
|
|
19598
|
-
this.shaderData.setFloat(PBRMaterial._roughnessProp, value);
|
|
19599
|
-
}
|
|
19600
|
-
},
|
|
19601
|
-
{
|
|
19602
|
-
key: "roughnessMetallicTexture",
|
|
19603
|
-
get: /**
|
|
19604
|
-
* Roughness metallic texture.
|
|
19605
|
-
* @remarks G channel is roughness, B channel is metallic
|
|
19606
|
-
*/ function get() {
|
|
19607
|
-
return this.shaderData.getTexture(PBRMaterial._roughnessMetallicTextureProp);
|
|
19608
|
-
},
|
|
19609
|
-
set: function set(value) {
|
|
19610
|
-
this.shaderData.setTexture(PBRMaterial._roughnessMetallicTextureProp, value);
|
|
19611
|
-
if (value) {
|
|
19612
|
-
this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE");
|
|
19613
|
-
} else {
|
|
19614
|
-
this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE");
|
|
19615
|
-
}
|
|
19616
|
-
}
|
|
19617
|
-
},
|
|
19618
|
-
{
|
|
19619
|
-
key: "anisotropy",
|
|
19620
|
-
get: /**
|
|
19621
|
-
* The strength of anisotropy, when anisotropyTexture is present, this value is multiplied by the blue channel.
|
|
19622
|
-
* @defaultValue `0`
|
|
19623
|
-
*/ function get() {
|
|
19624
|
-
return this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp).z;
|
|
19625
|
-
},
|
|
19626
|
-
set: function set(value) {
|
|
19627
|
-
var anisotropyInfo = this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp);
|
|
19628
|
-
if (!!anisotropyInfo.z !== !!value) {
|
|
19629
|
-
if (value === 0) {
|
|
19630
|
-
this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY");
|
|
19631
|
-
} else {
|
|
19632
|
-
this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY");
|
|
19633
|
-
}
|
|
19634
|
-
}
|
|
19635
|
-
anisotropyInfo.z = value;
|
|
19636
|
-
}
|
|
19637
|
-
},
|
|
19638
|
-
{
|
|
19639
|
-
key: "anisotropyRotation",
|
|
19640
|
-
get: /**
|
|
19641
|
-
* The rotation of the anisotropy in tangent, bitangent space, value in degrees.
|
|
19642
|
-
* @defaultValue `0`
|
|
19643
|
-
*/ function get() {
|
|
19644
|
-
return this._anisotropyRotation;
|
|
19645
|
-
},
|
|
19646
|
-
set: function set(value) {
|
|
19647
|
-
if (this._anisotropyRotation !== value) {
|
|
19648
|
-
this._anisotropyRotation = value;
|
|
19649
|
-
var anisotropyInfo = this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp);
|
|
19650
|
-
var rad = MathUtil.degreeToRadFactor * value;
|
|
19651
|
-
anisotropyInfo.x = Math.cos(rad);
|
|
19652
|
-
anisotropyInfo.y = Math.sin(rad);
|
|
19653
|
-
}
|
|
19654
|
-
}
|
|
19655
|
-
},
|
|
19656
|
-
{
|
|
19657
|
-
key: "anisotropyTexture",
|
|
19658
|
-
get: /**
|
|
19659
|
-
* The anisotropy texture.
|
|
19660
|
-
* @remarks
|
|
19661
|
-
* Red and green channels represent the anisotropy direction in [-1, 1] tangent, bitangent space, to be rotated by anisotropyRotation.
|
|
19662
|
-
* The blue channel contains strength as [0, 1] to be multiplied by anisotropy.
|
|
19663
|
-
*/ function get() {
|
|
19664
|
-
return this.shaderData.getTexture(PBRMaterial._anisotropyTextureProp);
|
|
19665
|
-
},
|
|
19666
|
-
set: function set(value) {
|
|
19667
|
-
this.shaderData.setTexture(PBRMaterial._anisotropyTextureProp, value);
|
|
19668
|
-
if (value) {
|
|
19669
|
-
this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
19670
|
-
} else {
|
|
19671
|
-
this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
19672
|
-
}
|
|
19673
|
-
}
|
|
19674
|
-
}
|
|
19675
|
-
]);
|
|
19676
|
-
return PBRMaterial;
|
|
19677
|
-
}(PBRBaseMaterial);
|
|
19678
|
-
(function() {
|
|
19679
|
-
PBRMaterial._metallicProp = ShaderProperty.getByName("material_Metal");
|
|
19680
|
-
})();
|
|
19681
|
-
(function() {
|
|
19682
|
-
PBRMaterial._roughnessProp = ShaderProperty.getByName("material_Roughness");
|
|
19683
|
-
})();
|
|
19684
|
-
(function() {
|
|
19685
|
-
PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
|
|
19686
|
-
})();
|
|
19687
|
-
(function() {
|
|
19688
|
-
PBRMaterial._iorProp = ShaderProperty.getByName("material_IOR");
|
|
19689
|
-
})();
|
|
19690
|
-
(function() {
|
|
19691
|
-
PBRMaterial._anisotropyInfoProp = ShaderProperty.getByName("material_AnisotropyInfo");
|
|
19692
|
-
})();
|
|
19693
|
-
(function() {
|
|
19694
|
-
PBRMaterial._anisotropyTextureProp = ShaderProperty.getByName("material_AnisotropyTexture");
|
|
19695
|
-
})();
|
|
19696
|
-
/**
|
|
19697
|
-
* PBR (Specular-Glossiness Workflow) Material.
|
|
19698
|
-
*/ var PBRSpecularMaterial = /*#__PURE__*/ function(PBRBaseMaterial1) {
|
|
19699
|
-
_inherits$2(PBRSpecularMaterial, PBRBaseMaterial1);
|
|
19700
|
-
function PBRSpecularMaterial(engine) {
|
|
19701
|
-
var _this;
|
|
19702
|
-
_this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr-specular")) || this;
|
|
19703
|
-
_this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new Color(1, 1, 1, 1));
|
|
19704
|
-
_this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, 1.0);
|
|
19705
|
-
return _this;
|
|
19706
|
-
}
|
|
19707
|
-
var _proto = PBRSpecularMaterial.prototype;
|
|
19708
|
-
/**
|
|
19709
|
-
* @inheritdoc
|
|
19710
|
-
*/ _proto.clone = function clone() {
|
|
19711
|
-
var dest = new PBRSpecularMaterial(this._engine);
|
|
19712
|
-
this.cloneTo(dest);
|
|
19713
|
-
return dest;
|
|
19714
|
-
};
|
|
19715
|
-
_create_class$2(PBRSpecularMaterial, [
|
|
19716
|
-
{
|
|
19717
|
-
key: "specularColor",
|
|
19718
|
-
get: /**
|
|
19719
|
-
* Specular color.
|
|
19720
|
-
*/ function get() {
|
|
19721
|
-
return this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
19722
|
-
},
|
|
19723
|
-
set: function set(value) {
|
|
19724
|
-
var specularColor = this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
19725
|
-
if (value !== specularColor) {
|
|
19726
|
-
specularColor.copyFrom(value);
|
|
19727
|
-
}
|
|
19728
|
-
}
|
|
19729
|
-
},
|
|
19730
|
-
{
|
|
19731
|
-
key: "glossiness",
|
|
19732
|
-
get: /**
|
|
19733
|
-
* Glossiness.
|
|
19734
|
-
*/ function get() {
|
|
19735
|
-
return this.shaderData.getFloat(PBRSpecularMaterial._glossinessProp);
|
|
19736
|
-
},
|
|
19737
|
-
set: function set(value) {
|
|
19738
|
-
this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, value);
|
|
19739
|
-
}
|
|
19740
|
-
},
|
|
19741
|
-
{
|
|
19742
|
-
key: "specularGlossinessTexture",
|
|
19743
|
-
get: /**
|
|
19744
|
-
* Specular glossiness texture.
|
|
19745
|
-
* @remarks RGB is specular, A is glossiness
|
|
19746
|
-
*/ function get() {
|
|
19747
|
-
return this.shaderData.getTexture(PBRSpecularMaterial._specularGlossinessTextureProp);
|
|
19748
|
-
},
|
|
19749
|
-
set: function set(value) {
|
|
19750
|
-
this.shaderData.setTexture(PBRSpecularMaterial._specularGlossinessTextureProp, value);
|
|
19751
|
-
if (value) {
|
|
19752
|
-
this.shaderData.enableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
19753
|
-
} else {
|
|
19754
|
-
this.shaderData.disableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
19755
|
-
}
|
|
19756
|
-
}
|
|
19757
|
-
}
|
|
19758
|
-
]);
|
|
19759
|
-
return PBRSpecularMaterial;
|
|
19760
|
-
}(PBRBaseMaterial);
|
|
19761
|
-
(function() {
|
|
19762
|
-
PBRSpecularMaterial._specularColorProp = ShaderProperty.getByName("material_PBRSpecularColor");
|
|
19763
|
-
})();
|
|
19764
|
-
(function() {
|
|
19765
|
-
PBRSpecularMaterial._glossinessProp = ShaderProperty.getByName("material_Glossiness");
|
|
19766
|
-
})();
|
|
19767
|
-
(function() {
|
|
19768
|
-
PBRSpecularMaterial._specularGlossinessTextureProp = ShaderProperty.getByName("material_SpecularGlossinessTexture");
|
|
19769
|
-
})();
|
|
19770
|
-
(function() {
|
|
19771
|
-
PBRSpecularMaterial._specularGlossinessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");
|
|
19772
|
-
})();
|
|
19773
|
-
/**
|
|
19774
|
-
* Unlit Material.
|
|
19775
|
-
*/ var UnlitMaterial = /*#__PURE__*/ function(BaseMaterial1) {
|
|
19776
|
-
_inherits$2(UnlitMaterial, BaseMaterial1);
|
|
19777
|
-
function UnlitMaterial(engine) {
|
|
19778
|
-
var _this;
|
|
19779
|
-
_this = BaseMaterial1.call(this, engine, Shader.find("unlit")) || this;
|
|
19780
|
-
var shaderData = _this.shaderData;
|
|
19781
|
-
shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
|
|
19782
|
-
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
19783
|
-
shaderData.setColor(UnlitMaterial._baseColorProp, new Color(1, 1, 1, 1));
|
|
19784
|
-
shaderData.setVector4(UnlitMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
|
|
19785
|
-
return _this;
|
|
19786
|
-
}
|
|
19787
|
-
var _proto = UnlitMaterial.prototype;
|
|
19788
|
-
/**
|
|
19789
|
-
* @inheritdoc
|
|
19790
|
-
*/ _proto.clone = function clone() {
|
|
19791
|
-
var dest = new UnlitMaterial(this._engine);
|
|
19792
|
-
this.cloneTo(dest);
|
|
19793
|
-
return dest;
|
|
19794
|
-
};
|
|
19795
|
-
_create_class$2(UnlitMaterial, [
|
|
19796
|
-
{
|
|
19797
|
-
key: "baseColor",
|
|
19798
|
-
get: /**
|
|
19799
|
-
* Base color.
|
|
19800
|
-
*/ function get() {
|
|
19801
|
-
return this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
19802
|
-
},
|
|
19803
|
-
set: function set(value) {
|
|
19804
|
-
var baseColor = this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
19805
|
-
if (value !== baseColor) {
|
|
19806
|
-
baseColor.copyFrom(value);
|
|
19807
|
-
}
|
|
19808
|
-
}
|
|
19809
|
-
},
|
|
19810
|
-
{
|
|
19811
|
-
key: "baseTexture",
|
|
19812
|
-
get: /**
|
|
19813
|
-
* Base texture.
|
|
19814
|
-
*/ function get() {
|
|
19815
|
-
return this.shaderData.getTexture(UnlitMaterial._baseTextureProp);
|
|
19816
|
-
},
|
|
19817
|
-
set: function set(value) {
|
|
19818
|
-
this.shaderData.setTexture(UnlitMaterial._baseTextureProp, value);
|
|
19819
|
-
if (value) {
|
|
19820
|
-
this.shaderData.enableMacro(UnlitMaterial._baseTextureMacro);
|
|
19821
|
-
} else {
|
|
19822
|
-
this.shaderData.disableMacro(UnlitMaterial._baseTextureMacro);
|
|
19823
|
-
}
|
|
19824
|
-
}
|
|
19825
|
-
},
|
|
19826
|
-
{
|
|
19827
|
-
key: "tilingOffset",
|
|
19828
|
-
get: /**
|
|
19829
|
-
* Tiling and offset of main textures.
|
|
19830
|
-
*/ function get() {
|
|
19831
|
-
return this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
19832
|
-
},
|
|
19833
|
-
set: function set(value) {
|
|
19834
|
-
var tilingOffset = this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
19835
|
-
if (value !== tilingOffset) {
|
|
19836
|
-
tilingOffset.copyFrom(value);
|
|
19837
|
-
}
|
|
19838
|
-
}
|
|
19839
|
-
}
|
|
19840
|
-
]);
|
|
19841
|
-
return UnlitMaterial;
|
|
19842
|
-
}(BaseMaterial);
|
|
19843
|
-
/**
|
|
19844
|
-
* @internal
|
|
19845
|
-
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
19846
|
-
var BasicResources = function BasicResources(engine) {
|
|
19847
|
-
// prettier-ignore
|
|
19848
|
-
var vertices = new Float32Array([
|
|
19849
|
-
-1,
|
|
19850
|
-
-1,
|
|
19851
|
-
0,
|
|
19852
|
-
1,
|
|
19853
|
-
1,
|
|
19854
|
-
-1,
|
|
19855
|
-
1,
|
|
19856
|
-
1,
|
|
19857
|
-
-1,
|
|
19858
|
-
1,
|
|
19859
|
-
0,
|
|
19860
|
-
0,
|
|
19861
|
-
1,
|
|
19862
|
-
1,
|
|
19863
|
-
1,
|
|
19864
|
-
0
|
|
19865
|
-
]); // right-top
|
|
19866
|
-
// prettier-ignore
|
|
19867
|
-
var flipYVertices = new Float32Array([
|
|
19868
|
-
1,
|
|
19869
|
-
-1,
|
|
19870
|
-
1,
|
|
19871
|
-
0,
|
|
19872
|
-
-1,
|
|
19873
|
-
-1,
|
|
19874
|
-
0,
|
|
19875
|
-
0,
|
|
19876
|
-
1,
|
|
19877
|
-
1,
|
|
19878
|
-
1,
|
|
19879
|
-
1,
|
|
19880
|
-
-1,
|
|
19881
|
-
1,
|
|
19882
|
-
0,
|
|
19883
|
-
1
|
|
19884
|
-
]); // left-top
|
|
19885
|
-
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
19886
|
-
blitMaterial._addReferCount(1);
|
|
19887
|
-
blitMaterial.renderState.depthState.enabled = false;
|
|
19888
|
-
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
19889
|
-
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
19890
|
-
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
19891
|
-
this.blitMaterial = blitMaterial;
|
|
19892
|
-
};
|
|
19893
|
-
var _proto = BasicResources.prototype;
|
|
19894
|
-
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
19895
|
-
var mesh = new ModelMesh(engine);
|
|
19896
|
-
mesh._addReferCount(1);
|
|
19897
|
-
mesh.setVertexElements([
|
|
19898
|
-
new VertexElement("POSITION_UV", 0, exports.VertexElementFormat.Vector4, 0)
|
|
19899
|
-
]);
|
|
19900
|
-
mesh.setVertexBufferBinding(new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static), 16);
|
|
19901
|
-
mesh.addSubMesh(0, 4, exports.MeshTopology.TriangleStrip);
|
|
19902
|
-
return mesh;
|
|
19903
|
-
};
|
|
19904
|
-
return BasicResources;
|
|
19905
|
-
}();
|
|
19906
|
-
/**
|
|
19907
|
-
* Layer, used for bit operations.
|
|
19908
|
-
*/ exports.Layer = void 0;
|
|
19909
|
-
(function(Layer) {
|
|
19910
|
-
Layer[Layer[/** Layer 0. */ "Layer0"] = 0x1] = "Layer0";
|
|
19911
|
-
Layer[Layer[/** Layer 1. */ "Layer1"] = 0x2] = "Layer1";
|
|
19912
|
-
Layer[Layer[/** Layer 2. */ "Layer2"] = 0x4] = "Layer2";
|
|
19913
|
-
Layer[Layer[/** Layer 3. */ "Layer3"] = 0x8] = "Layer3";
|
|
19914
|
-
Layer[Layer[/** Layer 4. */ "Layer4"] = 0x10] = "Layer4";
|
|
19915
|
-
Layer[Layer[/** Layer 5. */ "Layer5"] = 0x20] = "Layer5";
|
|
19916
|
-
Layer[Layer[/** Layer 6. */ "Layer6"] = 0x40] = "Layer6";
|
|
19917
|
-
Layer[Layer[/** Layer 7. */ "Layer7"] = 0x80] = "Layer7";
|
|
19918
|
-
Layer[Layer[/** Layer 8. */ "Layer8"] = 0x100] = "Layer8";
|
|
19919
|
-
Layer[Layer[/** Layer 9. */ "Layer9"] = 0x200] = "Layer9";
|
|
19920
|
-
Layer[Layer[/** Layer 10. */ "Layer10"] = 0x400] = "Layer10";
|
|
19921
|
-
Layer[Layer[/** Layer 11. */ "Layer11"] = 0x800] = "Layer11";
|
|
19922
|
-
Layer[Layer[/** Layer 12. */ "Layer12"] = 0x1000] = "Layer12";
|
|
19923
|
-
Layer[Layer[/** Layer 13. */ "Layer13"] = 0x2000] = "Layer13";
|
|
19924
|
-
Layer[Layer[/** Layer 14. */ "Layer14"] = 0x4000] = "Layer14";
|
|
19925
|
-
Layer[Layer[/** Layer 15. */ "Layer15"] = 0x8000] = "Layer15";
|
|
19926
|
-
Layer[Layer[/** Layer 16. */ "Layer16"] = 0x10000] = "Layer16";
|
|
19927
|
-
Layer[Layer[/** Layer 17. */ "Layer17"] = 0x20000] = "Layer17";
|
|
19928
|
-
Layer[Layer[/** Layer 18. */ "Layer18"] = 0x40000] = "Layer18";
|
|
19929
|
-
Layer[Layer[/** Layer 19. */ "Layer19"] = 0x80000] = "Layer19";
|
|
19930
|
-
Layer[Layer[/** Layer 20. */ "Layer20"] = 0x100000] = "Layer20";
|
|
19931
|
-
Layer[Layer[/** Layer 21. */ "Layer21"] = 0x200000] = "Layer21";
|
|
19932
|
-
Layer[Layer[/** Layer 22. */ "Layer22"] = 0x400000] = "Layer22";
|
|
19933
|
-
Layer[Layer[/** Layer 23. */ "Layer23"] = 0x800000] = "Layer23";
|
|
19934
|
-
Layer[Layer[/** Layer 24. */ "Layer24"] = 0x1000000] = "Layer24";
|
|
19935
|
-
Layer[Layer[/** Layer 25. */ "Layer25"] = 0x2000000] = "Layer25";
|
|
19936
|
-
Layer[Layer[/** Layer 26. */ "Layer26"] = 0x4000000] = "Layer26";
|
|
19937
|
-
Layer[Layer[/** Layer 27. */ "Layer27"] = 0x8000000] = "Layer27";
|
|
19938
|
-
Layer[Layer[/** Layer 28. */ "Layer28"] = 0x10000000] = "Layer28";
|
|
19939
|
-
Layer[Layer[/** Layer 29. */ "Layer29"] = 0x20000000] = "Layer29";
|
|
19940
|
-
Layer[Layer[/** Layer 30. */ "Layer30"] = 0x40000000] = "Layer30";
|
|
19941
|
-
Layer[Layer[/** Layer 31. */ "Layer31"] = 0x80000000] = "Layer31";
|
|
19942
|
-
Layer[Layer[/** All layers. */ "Everything"] = 0xffffffff] = "Everything";
|
|
19943
|
-
Layer[Layer[/** None layer. */ "Nothing"] = 0x0] = "Nothing";
|
|
19944
|
-
})(exports.Layer || (exports.Layer = {}));
|
|
19945
|
-
var ComponentCloner = /*#__PURE__*/ function() {
|
|
19946
|
-
var ComponentCloner = function ComponentCloner() {};
|
|
19947
|
-
/**
|
|
19948
|
-
* Clone component.
|
|
19949
|
-
* @param source - Clone source
|
|
19950
|
-
* @param target - Clone target
|
|
19951
|
-
*/ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot) {
|
|
19952
|
-
var cloneModes = CloneManager.getCloneMode(source.constructor);
|
|
19953
|
-
for(var k in source){
|
|
19954
|
-
CloneManager.cloneProperty(source, target, k, cloneModes[k]);
|
|
19955
|
-
}
|
|
19956
|
-
if (source._cloneTo) {
|
|
19957
|
-
source._cloneTo(target, srcRoot, targetRoot);
|
|
19958
|
-
}
|
|
19959
|
-
};
|
|
19960
|
-
return ComponentCloner;
|
|
19961
|
-
}();
|
|
19962
|
-
/**
|
|
19963
|
-
* Entity, be used as components container.
|
|
19964
|
-
*/ var Entity = /*#__PURE__*/ function(EngineObject1) {
|
|
19965
|
-
var Entity = function Entity(engine, name1) {
|
|
19966
|
-
var _this;
|
|
19967
|
-
_this = EngineObject1.call(this, engine) || this;
|
|
19968
|
-
/** The layer the entity belongs to. */ _this.layer = exports.Layer.Layer0;
|
|
19969
|
-
/** @internal */ _this._isActiveInHierarchy = false;
|
|
19970
|
-
/** @internal */ _this._isActiveInScene = false;
|
|
19971
|
-
/** @internal */ _this._components = [];
|
|
19972
|
-
/** @internal */ _this._scripts = new DisorderedArray();
|
|
19973
|
-
/** @internal */ _this._children = [];
|
|
19974
|
-
/** @internal */ _this._isRoot = false;
|
|
19975
|
-
/** @internal */ _this._isActive = true;
|
|
19976
|
-
/** @internal */ _this._siblingIndex = -1;
|
|
19977
|
-
/** @internal */ _this._isTemplate = false;
|
|
19978
|
-
_this._parent = null;
|
|
19979
|
-
//--------------------------------------------------------------deprecated----------------------------------------------------------------
|
|
19980
|
-
_this._invModelMatrix = new Matrix();
|
|
19981
|
-
_this.name = name1;
|
|
19982
|
-
_this.transform = _this.addComponent(Transform);
|
|
19983
|
-
_this._inverseWorldMatFlag = _this.transform.registerWorldChangeFlag();
|
|
19984
|
-
return _this;
|
|
19985
|
-
};
|
|
19986
|
-
_inherits$2(Entity, EngineObject1);
|
|
19987
|
-
var _proto = Entity.prototype;
|
|
19988
|
-
/**
|
|
19989
|
-
* Add component based on the component type.
|
|
19990
|
-
* @param type - The type of the component
|
|
19991
|
-
* @returns The component which has been added
|
|
19992
|
-
*/ _proto.addComponent = function addComponent(type) {
|
|
19993
|
-
ComponentsDependencies._addCheck(this, type);
|
|
19994
|
-
var component = new type(this);
|
|
19995
|
-
this._components.push(component);
|
|
19996
|
-
component._setActive(true, ActiveChangeFlag.All);
|
|
19997
|
-
return component;
|
|
19998
|
-
};
|
|
19999
|
-
/**
|
|
20000
|
-
* Get component which match the type.
|
|
20001
|
-
* @param type - The type of the component
|
|
20002
|
-
* @returns The first component which match type
|
|
20003
|
-
*/ _proto.getComponent = function getComponent(type) {
|
|
20004
|
-
var components = this._components;
|
|
20005
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
20006
|
-
var component = components[i];
|
|
20007
|
-
if (_instanceof1$2(component, type)) {
|
|
20008
|
-
return component;
|
|
20009
|
-
}
|
|
20010
|
-
}
|
|
20011
|
-
return null;
|
|
20012
|
-
};
|
|
20013
|
-
/**
|
|
20014
|
-
* Get components which match the type.
|
|
20015
|
-
* @param type - The type of the component
|
|
20016
|
-
* @param results - The components which match type
|
|
20017
|
-
* @returns The components which match type
|
|
20018
|
-
*/ _proto.getComponents = function getComponents(type, results) {
|
|
20019
|
-
results.length = 0;
|
|
20020
|
-
var components = this._components;
|
|
20021
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
20022
|
-
var component = components[i];
|
|
20023
|
-
if (_instanceof1$2(component, type)) {
|
|
20024
|
-
results.push(component);
|
|
20025
|
-
}
|
|
20026
|
-
}
|
|
20027
|
-
return results;
|
|
20028
|
-
};
|
|
20029
|
-
/**
|
|
20030
|
-
* Get the components which match the type of the entity and it's children.
|
|
20031
|
-
* @param type - The component type
|
|
20032
|
-
* @param results - The components collection
|
|
20033
|
-
* @returns The components collection which match the type
|
|
20034
|
-
*/ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
|
|
20035
|
-
results.length = 0;
|
|
20036
|
-
this._getComponentsInChildren(type, results);
|
|
20037
|
-
return results;
|
|
20038
|
-
};
|
|
20039
|
-
_proto.addChild = function addChild(indexOrChild, child) {
|
|
20040
|
-
var index;
|
|
20041
|
-
if (typeof indexOrChild === "number") {
|
|
20042
|
-
index = indexOrChild;
|
|
20043
|
-
} else {
|
|
20044
|
-
index = undefined;
|
|
20045
|
-
child = indexOrChild;
|
|
20046
|
-
}
|
|
20047
|
-
if (child._isRoot) {
|
|
20048
|
-
child._scene._removeFromEntityList(child);
|
|
20049
|
-
child._isRoot = false;
|
|
20050
|
-
this._addToChildrenList(index, child);
|
|
20051
|
-
child._parent = this;
|
|
20052
|
-
var oldScene = child._scene;
|
|
20053
|
-
var newScene = this._scene;
|
|
20054
|
-
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
20055
|
-
if (!this._isActiveInHierarchy) {
|
|
20056
|
-
child._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
20057
|
-
}
|
|
20058
|
-
if (child._isActiveInScene) {
|
|
20059
|
-
if (this._isActiveInScene) {
|
|
20060
|
-
// Cross scene should inActive first and then active
|
|
20061
|
-
oldScene !== newScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
20062
|
-
} else {
|
|
20063
|
-
inActiveChangeFlag |= ActiveChangeFlag.Scene;
|
|
20064
|
-
}
|
|
20065
|
-
}
|
|
20066
|
-
inActiveChangeFlag && child._processInActive(inActiveChangeFlag);
|
|
20067
|
-
if (child._scene !== newScene) {
|
|
20068
|
-
Entity._traverseSetOwnerScene(child, newScene);
|
|
20069
|
-
}
|
|
20070
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
20071
|
-
if (child._isActive) {
|
|
20072
|
-
if (this._isActiveInHierarchy) {
|
|
20073
|
-
!child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
20074
|
-
}
|
|
20075
|
-
if (this._isActiveInScene) {
|
|
20076
|
-
(!child._isActiveInScene || oldScene !== newScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
20077
|
-
}
|
|
20078
|
-
}
|
|
20079
|
-
activeChangeFlag && child._processActive(activeChangeFlag);
|
|
20080
|
-
child._setTransformDirty();
|
|
20081
|
-
} else {
|
|
20082
|
-
child._setParent(this, index);
|
|
20083
|
-
}
|
|
20084
|
-
};
|
|
20085
|
-
/**
|
|
20086
|
-
* Remove child entity.
|
|
20087
|
-
* @param child - The child entity which want to be removed
|
|
20088
|
-
*/ _proto.removeChild = function removeChild(child) {
|
|
20089
|
-
child._setParent(null);
|
|
20090
|
-
};
|
|
20091
|
-
/**
|
|
20092
|
-
* @deprecated Please use `children` property instead.
|
|
20093
|
-
* Find child entity by index.
|
|
20094
|
-
* @param index - The index of the child entity
|
|
20095
|
-
* @returns The component which be found
|
|
20096
|
-
*/ _proto.getChild = function getChild(index) {
|
|
20097
|
-
return this._children[index];
|
|
20098
|
-
};
|
|
20099
|
-
/**
|
|
20100
|
-
* Find entity by name.
|
|
20101
|
-
* @param name - The name of the entity which want to be found
|
|
20102
|
-
* @returns The component which be found
|
|
20103
|
-
*/ _proto.findByName = function findByName(name1) {
|
|
20104
|
-
if (name1 === this.name) {
|
|
20105
|
-
return this;
|
|
20106
|
-
}
|
|
20107
|
-
var children = this._children;
|
|
20108
|
-
for(var i = 0, n = children.length; i < n; i++){
|
|
20109
|
-
var target = children[i].findByName(name1);
|
|
20110
|
-
if (target) {
|
|
20111
|
-
return target;
|
|
20112
|
-
}
|
|
20113
|
-
}
|
|
20114
|
-
return null;
|
|
20115
|
-
};
|
|
20116
|
-
/**
|
|
20117
|
-
* Find the entity by path.
|
|
20118
|
-
* @param path - The path fo the entity eg: /entity
|
|
20119
|
-
* @returns The component which be found
|
|
20120
|
-
*/ _proto.findByPath = function findByPath(path) {
|
|
20121
|
-
var splits = path.split("/");
|
|
20122
|
-
var entity = this;
|
|
20123
|
-
for(var i = 0, length = splits.length; i < length; ++i){
|
|
20124
|
-
var split = splits[i];
|
|
20125
|
-
if (split) {
|
|
20126
|
-
entity = Entity._findChildByName(entity, split);
|
|
20127
|
-
if (!entity) {
|
|
20128
|
-
return null;
|
|
20129
|
-
}
|
|
20130
|
-
}
|
|
20131
|
-
}
|
|
20132
|
-
return entity;
|
|
20133
|
-
};
|
|
20134
|
-
/**
|
|
20135
|
-
* Create child entity.
|
|
20136
|
-
* @param name - The child entity's name
|
|
20137
|
-
* @returns The child entity
|
|
20138
|
-
*/ _proto.createChild = function createChild(name1) {
|
|
20139
|
-
var child = new Entity(this.engine, name1);
|
|
20140
|
-
child.layer = this.layer;
|
|
20141
|
-
child.parent = this;
|
|
20142
|
-
return child;
|
|
20143
|
-
};
|
|
20144
|
-
/**
|
|
20145
|
-
* Clear children entities.
|
|
20146
|
-
*/ _proto.clearChildren = function clearChildren() {
|
|
20147
|
-
var children = this._children;
|
|
20148
|
-
for(var i = children.length - 1; i >= 0; i--){
|
|
20149
|
-
var child = children[i];
|
|
20150
|
-
child._parent = null;
|
|
20151
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
20152
|
-
child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
20153
|
-
child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
20154
|
-
activeChangeFlag && child._processInActive(activeChangeFlag);
|
|
20155
|
-
Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
|
|
20156
|
-
}
|
|
20157
|
-
children.length = 0;
|
|
20158
|
-
};
|
|
20159
|
-
/**
|
|
20160
|
-
* Clone.
|
|
20161
|
-
* @returns Cloned entity
|
|
20162
|
-
*/ _proto.clone = function clone() {
|
|
20163
|
-
var cloneEntity = this._createCloneEntity(this);
|
|
20164
|
-
this._parseCloneEntity(this, cloneEntity, this, cloneEntity);
|
|
20165
|
-
return cloneEntity;
|
|
20166
|
-
};
|
|
20167
|
-
/**
|
|
20168
|
-
* @internal
|
|
20169
|
-
*/ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
|
|
20170
|
-
this._isTemplate = true;
|
|
20171
|
-
this._templateResource = templateResource;
|
|
20172
|
-
};
|
|
20173
|
-
_proto._createCloneEntity = function _createCloneEntity(srcEntity) {
|
|
20174
|
-
var cloneEntity = new Entity(srcEntity._engine, srcEntity.name);
|
|
20175
|
-
var templateResource = this._templateResource;
|
|
20176
|
-
if (templateResource) {
|
|
20177
|
-
cloneEntity._templateResource = templateResource;
|
|
20178
|
-
templateResource._addReferCount(1);
|
|
20179
|
-
}
|
|
20180
|
-
cloneEntity.layer = srcEntity.layer;
|
|
20181
|
-
cloneEntity._isActive = srcEntity._isActive;
|
|
20182
|
-
var cloneTransform = cloneEntity.transform;
|
|
20183
|
-
var srcTransform = srcEntity.transform;
|
|
20184
|
-
cloneTransform.position = srcTransform.position;
|
|
20185
|
-
cloneTransform.rotation = srcTransform.rotation;
|
|
20186
|
-
cloneTransform.scale = srcTransform.scale;
|
|
20187
|
-
var children = srcEntity._children;
|
|
20188
|
-
for(var i = 0, n = srcEntity._children.length; i < n; i++){
|
|
20189
|
-
cloneEntity.addChild(this._createCloneEntity(children[i]));
|
|
20190
|
-
}
|
|
20191
|
-
return cloneEntity;
|
|
20192
|
-
};
|
|
20193
|
-
_proto._parseCloneEntity = function _parseCloneEntity(srcEntity, targetEntity, srcRoot, targetRoot) {
|
|
20194
|
-
var srcChildren = srcEntity._children;
|
|
20195
|
-
var targetChildren = targetEntity._children;
|
|
20196
|
-
for(var i = 0, n = srcChildren.length; i < n; i++){
|
|
20197
|
-
this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot);
|
|
20198
|
-
}
|
|
20199
|
-
var components = srcEntity._components;
|
|
20200
|
-
for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
|
|
20201
|
-
var sourceComp = components[i1];
|
|
20202
|
-
if (!_instanceof1$2(sourceComp, Transform)) {
|
|
20203
|
-
var targetComp = targetEntity.addComponent(sourceComp.constructor);
|
|
20204
|
-
ComponentCloner.cloneComponent(sourceComp, targetComp, srcRoot, targetRoot);
|
|
20205
|
-
}
|
|
20206
|
-
}
|
|
20207
|
-
};
|
|
20208
|
-
/**
|
|
20209
|
-
* Destroy self.
|
|
20210
|
-
*/ _proto.destroy = function destroy() {
|
|
20211
|
-
if (this._destroyed) {
|
|
20212
|
-
return;
|
|
20213
|
-
}
|
|
20214
|
-
EngineObject1.prototype.destroy.call(this);
|
|
20215
|
-
if (this._templateResource) {
|
|
20216
|
-
this._isTemplate || this._templateResource._addReferCount(-1);
|
|
20217
|
-
this._templateResource = null;
|
|
20218
|
-
}
|
|
20219
|
-
var components = this._components;
|
|
20220
|
-
for(var i = components.length - 1; i >= 0; i--){
|
|
20221
|
-
components[i].destroy();
|
|
20222
|
-
}
|
|
20223
|
-
this._components.length = 0;
|
|
20224
|
-
var children = this._children;
|
|
20225
|
-
while(children.length > 0){
|
|
20226
|
-
children[0].destroy();
|
|
20227
|
-
}
|
|
20228
|
-
if (this._isRoot) {
|
|
20229
|
-
this._scene.removeRootEntity(this);
|
|
20230
|
-
} else {
|
|
20231
|
-
this._setParent(null);
|
|
20232
|
-
}
|
|
20233
|
-
this.isActive = false;
|
|
20234
|
-
};
|
|
20235
|
-
/**
|
|
20236
|
-
* @internal
|
|
20237
|
-
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
20238
|
-
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
20239
|
-
var components = this._components;
|
|
20240
|
-
components.splice(components.indexOf(component), 1);
|
|
20241
|
-
};
|
|
20242
|
-
/**
|
|
20243
|
-
* @internal
|
|
20244
|
-
*/ _proto._addScript = function _addScript(script) {
|
|
20245
|
-
script._entityScriptsIndex = this._scripts.length;
|
|
20246
|
-
this._scripts.add(script);
|
|
20247
|
-
};
|
|
20248
|
-
/**
|
|
20249
|
-
* @internal
|
|
20250
|
-
*/ _proto._removeScript = function _removeScript(script) {
|
|
20251
|
-
var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
|
|
20252
|
-
replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
|
|
20253
|
-
script._entityScriptsIndex = -1;
|
|
20254
|
-
};
|
|
20255
|
-
/**
|
|
20256
|
-
* @internal
|
|
20257
|
-
*/ _proto._removeFromParent = function _removeFromParent() {
|
|
20258
|
-
var oldParent = this._parent;
|
|
20259
|
-
if (oldParent != null) {
|
|
20260
|
-
var oldSibling = oldParent._children;
|
|
20261
|
-
var index = this._siblingIndex;
|
|
20262
|
-
oldSibling.splice(index, 1);
|
|
20263
|
-
for(var n = oldSibling.length; index < n; index++){
|
|
20264
|
-
oldSibling[index]._siblingIndex--;
|
|
20265
|
-
}
|
|
20266
|
-
this._parent = null;
|
|
20267
|
-
this._siblingIndex = -1;
|
|
20268
|
-
}
|
|
20269
|
-
};
|
|
20270
|
-
/**
|
|
20271
|
-
* @internal
|
|
20272
|
-
*/ _proto._processActive = function _processActive(activeChangeFlag) {
|
|
20273
|
-
if (this._activeChangedComponents) {
|
|
20274
|
-
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.";
|
|
20275
|
-
}
|
|
20276
|
-
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
20277
|
-
this._setActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
20278
|
-
this._setActiveComponents(true, activeChangeFlag);
|
|
20279
|
-
};
|
|
20280
|
-
/**
|
|
20281
|
-
* @internal
|
|
20282
|
-
*/ _proto._processInActive = function _processInActive(activeChangeFlag) {
|
|
20283
|
-
if (this._activeChangedComponents) {
|
|
20284
|
-
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.";
|
|
20285
|
-
}
|
|
20286
|
-
this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
|
|
20287
|
-
this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
|
|
20288
|
-
this._setActiveComponents(false, activeChangeFlag);
|
|
20289
|
-
};
|
|
20290
|
-
_proto._addToChildrenList = function _addToChildrenList(index, child) {
|
|
20291
|
-
var children = this._children;
|
|
20292
|
-
var childCount = children.length;
|
|
20293
|
-
if (index === undefined) {
|
|
20294
|
-
child._siblingIndex = childCount;
|
|
20295
|
-
children.push(child);
|
|
20296
|
-
} else {
|
|
20297
|
-
if (index < 0 || index > childCount) {
|
|
20298
|
-
throw "The index " + index + " is out of child list bounds " + childCount;
|
|
20299
|
-
}
|
|
20300
|
-
child._siblingIndex = index;
|
|
20301
|
-
children.splice(index, 0, child);
|
|
20302
|
-
for(var i = index + 1, n = childCount + 1; i < n; i++){
|
|
20303
|
-
children[i]._siblingIndex++;
|
|
20304
|
-
}
|
|
20305
|
-
}
|
|
20306
|
-
};
|
|
20307
|
-
_proto._setParent = function _setParent(parent, siblingIndex) {
|
|
20308
|
-
var oldParent = this._parent;
|
|
20309
|
-
if (parent !== oldParent) {
|
|
20310
|
-
this._removeFromParent();
|
|
20311
|
-
this._parent = parent;
|
|
20312
|
-
if (parent) {
|
|
20313
|
-
parent._addToChildrenList(siblingIndex, this);
|
|
20314
|
-
var oldScene = this._scene;
|
|
20315
|
-
var parentScene = parent._scene;
|
|
20316
|
-
var inActiveChangeFlag = ActiveChangeFlag.None;
|
|
20317
|
-
if (!parent._isActiveInHierarchy) {
|
|
20318
|
-
this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
20319
|
-
}
|
|
20320
|
-
if (parent._isActiveInScene) {
|
|
20321
|
-
// cross scene should inActive first and then active
|
|
20322
|
-
this._isActiveInScene && oldScene !== parentScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
20323
|
-
} else {
|
|
20324
|
-
this._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
|
|
20325
|
-
}
|
|
20326
|
-
inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
|
|
20327
|
-
if (oldScene !== parentScene) {
|
|
20328
|
-
Entity._traverseSetOwnerScene(this, parentScene);
|
|
20329
|
-
}
|
|
20330
|
-
var activeChangeFlag = ActiveChangeFlag.None;
|
|
20331
|
-
if (this._isActive) {
|
|
20332
|
-
if (parent._isActiveInHierarchy) {
|
|
20333
|
-
!this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
|
|
20334
|
-
}
|
|
20335
|
-
if (parent._isActiveInScene) {
|
|
20336
|
-
(!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
|
|
20337
|
-
}
|
|
20338
|
-
}
|
|
20339
|
-
activeChangeFlag && this._processActive(activeChangeFlag);
|
|
20340
|
-
} else {
|
|
20341
|
-
var inActiveChangeFlag1 = ActiveChangeFlag.None;
|
|
20342
|
-
this._isActiveInHierarchy && (inActiveChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
20343
|
-
this._isActiveInScene && (inActiveChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
20344
|
-
inActiveChangeFlag1 && this._processInActive(inActiveChangeFlag1);
|
|
20345
|
-
if (oldParent) {
|
|
20346
|
-
Entity._traverseSetOwnerScene(this, null);
|
|
20347
|
-
}
|
|
20348
|
-
}
|
|
20349
|
-
this._setTransformDirty();
|
|
20350
|
-
}
|
|
20351
|
-
};
|
|
20352
|
-
_proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
|
|
20353
|
-
for(var i = this._components.length - 1; i >= 0; i--){
|
|
20354
|
-
var component = this._components[i];
|
|
20355
|
-
if (_instanceof1$2(component, type)) {
|
|
20356
|
-
results.push(component);
|
|
20357
|
-
}
|
|
20358
|
-
}
|
|
20359
|
-
for(var i1 = this._children.length - 1; i1 >= 0; i1--){
|
|
20360
|
-
this._children[i1]._getComponentsInChildren(type, results);
|
|
20361
|
-
}
|
|
20362
|
-
};
|
|
20363
|
-
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
20364
|
-
var activeChangedComponents = this._activeChangedComponents;
|
|
20365
|
-
for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
|
|
20366
|
-
activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
|
|
20367
|
-
}
|
|
20368
|
-
this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
|
|
20369
|
-
this._activeChangedComponents = null;
|
|
20370
|
-
};
|
|
20371
|
-
_proto._setActiveInHierarchy = function _setActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
20372
|
-
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = true);
|
|
20373
|
-
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = true);
|
|
20374
|
-
var components = this._components;
|
|
20375
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
20376
|
-
var component = components[i];
|
|
20377
|
-
(component.enabled || !component._awoken) && activeChangedComponents.push(component);
|
|
20378
|
-
}
|
|
20379
|
-
var children = this._children;
|
|
20380
|
-
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
20381
|
-
var child = children[i1];
|
|
20382
|
-
child.isActive && child._setActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
20383
|
-
}
|
|
20384
|
-
};
|
|
20385
|
-
_proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
20386
|
-
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
|
|
20387
|
-
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
|
|
20388
|
-
var components = this._components;
|
|
20389
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
20390
|
-
var component = components[i];
|
|
20391
|
-
component.enabled && activeChangedComponents.push(component);
|
|
20392
|
-
}
|
|
20393
|
-
var children = this._children;
|
|
20394
|
-
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
20395
|
-
var child = children[i1];
|
|
20396
|
-
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
20397
|
-
}
|
|
20398
|
-
};
|
|
20399
|
-
_proto._setTransformDirty = function _setTransformDirty() {
|
|
20400
|
-
if (this.transform) {
|
|
20401
|
-
this.transform._parentChange();
|
|
20402
|
-
} else {
|
|
20403
|
-
for(var i = 0, len = this._children.length; i < len; i++){
|
|
20404
|
-
this._children[i]._setTransformDirty();
|
|
20405
|
-
}
|
|
20406
|
-
}
|
|
20407
|
-
};
|
|
20408
|
-
_proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
|
|
20409
|
-
target = Math.min(target, sibling.length - 1);
|
|
20410
|
-
if (target < 0) {
|
|
20411
|
-
throw "Sibling index " + target + " should large than 0";
|
|
20412
|
-
}
|
|
20413
|
-
if (this._siblingIndex !== target) {
|
|
20414
|
-
var oldIndex = this._siblingIndex;
|
|
20415
|
-
if (target < oldIndex) {
|
|
20416
|
-
for(var i = oldIndex; i >= target; i--){
|
|
20417
|
-
var child = i == target ? this : sibling[i - 1];
|
|
20418
|
-
sibling[i] = child;
|
|
20419
|
-
child._siblingIndex = i;
|
|
20238
|
+
if (value) {
|
|
20239
|
+
this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE");
|
|
20240
|
+
} else {
|
|
20241
|
+
this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE");
|
|
20420
20242
|
}
|
|
20421
|
-
}
|
|
20422
|
-
|
|
20423
|
-
|
|
20424
|
-
|
|
20425
|
-
|
|
20243
|
+
}
|
|
20244
|
+
},
|
|
20245
|
+
{
|
|
20246
|
+
key: "clearCoatNormalTexture",
|
|
20247
|
+
get: /**
|
|
20248
|
+
* The clearCoat normal map texture.
|
|
20249
|
+
*/ function get() {
|
|
20250
|
+
return this.shaderData.getTexture(PBRBaseMaterial._clearCoatNormalTextureProp);
|
|
20251
|
+
},
|
|
20252
|
+
set: function set(value) {
|
|
20253
|
+
this.shaderData.setTexture(PBRBaseMaterial._clearCoatNormalTextureProp, value);
|
|
20254
|
+
if (value) {
|
|
20255
|
+
this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE");
|
|
20256
|
+
} else {
|
|
20257
|
+
this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE");
|
|
20426
20258
|
}
|
|
20427
20259
|
}
|
|
20428
20260
|
}
|
|
20429
|
-
|
|
20261
|
+
]);
|
|
20262
|
+
return PBRBaseMaterial;
|
|
20263
|
+
}(BaseMaterial);
|
|
20264
|
+
(function() {
|
|
20265
|
+
PBRBaseMaterial._occlusionTextureIntensityProp = ShaderProperty.getByName("material_OcclusionIntensity");
|
|
20266
|
+
})();
|
|
20267
|
+
(function() {
|
|
20268
|
+
PBRBaseMaterial._occlusionTextureCoordProp = ShaderProperty.getByName("material_OcclusionTextureCoord");
|
|
20269
|
+
})();
|
|
20270
|
+
(function() {
|
|
20271
|
+
PBRBaseMaterial._occlusionTextureProp = ShaderProperty.getByName("material_OcclusionTexture");
|
|
20272
|
+
})();
|
|
20273
|
+
(function() {
|
|
20274
|
+
PBRBaseMaterial._clearCoatProp = ShaderProperty.getByName("material_ClearCoat");
|
|
20275
|
+
})();
|
|
20276
|
+
(function() {
|
|
20277
|
+
PBRBaseMaterial._clearCoatTextureProp = ShaderProperty.getByName("material_ClearCoatTexture");
|
|
20278
|
+
})();
|
|
20279
|
+
(function() {
|
|
20280
|
+
PBRBaseMaterial._clearCoatRoughnessProp = ShaderProperty.getByName("material_ClearCoatRoughness");
|
|
20281
|
+
})();
|
|
20282
|
+
(function() {
|
|
20283
|
+
PBRBaseMaterial._clearCoatRoughnessTextureProp = ShaderProperty.getByName("material_ClearCoatRoughnessTexture");
|
|
20284
|
+
})();
|
|
20285
|
+
(function() {
|
|
20286
|
+
PBRBaseMaterial._clearCoatNormalTextureProp = ShaderProperty.getByName("material_ClearCoatNormalTexture");
|
|
20287
|
+
})();
|
|
20288
|
+
/**
|
|
20289
|
+
* PBR (Metallic-Roughness Workflow) Material.
|
|
20290
|
+
*/ var PBRMaterial = /*#__PURE__*/ function(PBRBaseMaterial1) {
|
|
20291
|
+
_inherits$2(PBRMaterial, PBRBaseMaterial1);
|
|
20292
|
+
function PBRMaterial(engine) {
|
|
20293
|
+
var _this;
|
|
20294
|
+
_this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr")) || this;
|
|
20295
|
+
_this._anisotropyRotation = 0;
|
|
20296
|
+
var shaderData = _this.shaderData;
|
|
20297
|
+
shaderData.setFloat(PBRMaterial._metallicProp, 1);
|
|
20298
|
+
shaderData.setFloat(PBRMaterial._roughnessProp, 1);
|
|
20299
|
+
shaderData.setFloat(PBRMaterial._iorProp, 1.5);
|
|
20300
|
+
shaderData.setVector3(PBRMaterial._anisotropyInfoProp, new Vector3(1, 0, 0));
|
|
20301
|
+
return _this;
|
|
20302
|
+
}
|
|
20303
|
+
var _proto = PBRMaterial.prototype;
|
|
20430
20304
|
/**
|
|
20431
|
-
* @
|
|
20432
|
-
*/ _proto.
|
|
20433
|
-
|
|
20434
|
-
|
|
20435
|
-
|
|
20436
|
-
}
|
|
20437
|
-
return this._invModelMatrix;
|
|
20305
|
+
* @inheritdoc
|
|
20306
|
+
*/ _proto.clone = function clone() {
|
|
20307
|
+
var dest = new PBRMaterial(this._engine);
|
|
20308
|
+
this.cloneTo(dest);
|
|
20309
|
+
return dest;
|
|
20438
20310
|
};
|
|
20439
|
-
|
|
20440
|
-
|
|
20441
|
-
|
|
20442
|
-
|
|
20443
|
-
|
|
20444
|
-
|
|
20445
|
-
|
|
20446
|
-
return
|
|
20311
|
+
_create_class$2(PBRMaterial, [
|
|
20312
|
+
{
|
|
20313
|
+
key: "ior",
|
|
20314
|
+
get: /**
|
|
20315
|
+
* Index Of Refraction.
|
|
20316
|
+
* @defaultValue `1.5`
|
|
20317
|
+
*/ function get() {
|
|
20318
|
+
return this.shaderData.getFloat(PBRMaterial._iorProp);
|
|
20319
|
+
},
|
|
20320
|
+
set: function set(v) {
|
|
20321
|
+
this.shaderData.setFloat(PBRMaterial._iorProp, Math.max(v, 0));
|
|
20447
20322
|
}
|
|
20448
|
-
}
|
|
20449
|
-
return null;
|
|
20450
|
-
};
|
|
20451
|
-
/**
|
|
20452
|
-
* @internal
|
|
20453
|
-
*/ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
|
|
20454
|
-
entity._scene = scene;
|
|
20455
|
-
var children = entity._children;
|
|
20456
|
-
for(var i = children.length - 1; i >= 0; i--){
|
|
20457
|
-
this._traverseSetOwnerScene(children[i], scene);
|
|
20458
|
-
}
|
|
20459
|
-
};
|
|
20460
|
-
_create_class$2(Entity, [
|
|
20323
|
+
},
|
|
20461
20324
|
{
|
|
20462
|
-
key: "
|
|
20325
|
+
key: "metallic",
|
|
20463
20326
|
get: /**
|
|
20464
|
-
*
|
|
20327
|
+
* Metallic.
|
|
20328
|
+
* @defaultValue `1.0`
|
|
20465
20329
|
*/ function get() {
|
|
20466
|
-
return this.
|
|
20330
|
+
return this.shaderData.getFloat(PBRMaterial._metallicProp);
|
|
20467
20331
|
},
|
|
20468
20332
|
set: function set(value) {
|
|
20469
|
-
|
|
20470
|
-
|
|
20471
|
-
|
|
20472
|
-
|
|
20473
|
-
|
|
20474
|
-
|
|
20475
|
-
|
|
20476
|
-
|
|
20477
|
-
|
|
20478
|
-
|
|
20479
|
-
|
|
20480
|
-
|
|
20481
|
-
|
|
20333
|
+
this.shaderData.setFloat(PBRMaterial._metallicProp, value);
|
|
20334
|
+
}
|
|
20335
|
+
},
|
|
20336
|
+
{
|
|
20337
|
+
key: "roughness",
|
|
20338
|
+
get: /**
|
|
20339
|
+
* Roughness. default 1.0.
|
|
20340
|
+
* @defaultValue `1.0`
|
|
20341
|
+
*/ function get() {
|
|
20342
|
+
return this.shaderData.getFloat(PBRMaterial._roughnessProp);
|
|
20343
|
+
},
|
|
20344
|
+
set: function set(value) {
|
|
20345
|
+
this.shaderData.setFloat(PBRMaterial._roughnessProp, value);
|
|
20346
|
+
}
|
|
20347
|
+
},
|
|
20348
|
+
{
|
|
20349
|
+
key: "roughnessMetallicTexture",
|
|
20350
|
+
get: /**
|
|
20351
|
+
* Roughness metallic texture.
|
|
20352
|
+
* @remarks G channel is roughness, B channel is metallic
|
|
20353
|
+
*/ function get() {
|
|
20354
|
+
return this.shaderData.getTexture(PBRMaterial._roughnessMetallicTextureProp);
|
|
20355
|
+
},
|
|
20356
|
+
set: function set(value) {
|
|
20357
|
+
this.shaderData.setTexture(PBRMaterial._roughnessMetallicTextureProp, value);
|
|
20358
|
+
if (value) {
|
|
20359
|
+
this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE");
|
|
20360
|
+
} else {
|
|
20361
|
+
this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE");
|
|
20362
|
+
}
|
|
20363
|
+
}
|
|
20364
|
+
},
|
|
20365
|
+
{
|
|
20366
|
+
key: "anisotropy",
|
|
20367
|
+
get: /**
|
|
20368
|
+
* The strength of anisotropy, when anisotropyTexture is present, this value is multiplied by the blue channel.
|
|
20369
|
+
* @defaultValue `0`
|
|
20370
|
+
*/ function get() {
|
|
20371
|
+
return this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp).z;
|
|
20372
|
+
},
|
|
20373
|
+
set: function set(value) {
|
|
20374
|
+
var anisotropyInfo = this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp);
|
|
20375
|
+
if (!!anisotropyInfo.z !== !!value) {
|
|
20376
|
+
if (value === 0) {
|
|
20377
|
+
this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY");
|
|
20482
20378
|
} else {
|
|
20483
|
-
|
|
20484
|
-
this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
|
|
20485
|
-
this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
|
|
20486
|
-
activeChangeFlag1 && this._processInActive(activeChangeFlag1);
|
|
20379
|
+
this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY");
|
|
20487
20380
|
}
|
|
20488
20381
|
}
|
|
20382
|
+
anisotropyInfo.z = value;
|
|
20489
20383
|
}
|
|
20490
20384
|
},
|
|
20491
20385
|
{
|
|
20492
|
-
key: "
|
|
20386
|
+
key: "anisotropyRotation",
|
|
20493
20387
|
get: /**
|
|
20494
|
-
*
|
|
20388
|
+
* The rotation of the anisotropy in tangent, bitangent space, value in degrees.
|
|
20389
|
+
* @defaultValue `0`
|
|
20495
20390
|
*/ function get() {
|
|
20496
|
-
return this.
|
|
20391
|
+
return this._anisotropyRotation;
|
|
20392
|
+
},
|
|
20393
|
+
set: function set(value) {
|
|
20394
|
+
if (this._anisotropyRotation !== value) {
|
|
20395
|
+
this._anisotropyRotation = value;
|
|
20396
|
+
var anisotropyInfo = this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp);
|
|
20397
|
+
var rad = MathUtil.degreeToRadFactor * value;
|
|
20398
|
+
anisotropyInfo.x = Math.cos(rad);
|
|
20399
|
+
anisotropyInfo.y = Math.sin(rad);
|
|
20400
|
+
}
|
|
20497
20401
|
}
|
|
20498
20402
|
},
|
|
20499
20403
|
{
|
|
20500
|
-
key: "
|
|
20404
|
+
key: "anisotropyTexture",
|
|
20501
20405
|
get: /**
|
|
20502
|
-
* The
|
|
20406
|
+
* The anisotropy texture.
|
|
20407
|
+
* @remarks
|
|
20408
|
+
* Red and green channels represent the anisotropy direction in [-1, 1] tangent, bitangent space, to be rotated by anisotropyRotation.
|
|
20409
|
+
* The blue channel contains strength as [0, 1] to be multiplied by anisotropy.
|
|
20503
20410
|
*/ function get() {
|
|
20504
|
-
return this.
|
|
20411
|
+
return this.shaderData.getTexture(PBRMaterial._anisotropyTextureProp);
|
|
20505
20412
|
},
|
|
20506
20413
|
set: function set(value) {
|
|
20507
|
-
this.
|
|
20414
|
+
this.shaderData.setTexture(PBRMaterial._anisotropyTextureProp, value);
|
|
20415
|
+
if (value) {
|
|
20416
|
+
this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
20417
|
+
} else {
|
|
20418
|
+
this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE");
|
|
20419
|
+
}
|
|
20420
|
+
}
|
|
20421
|
+
}
|
|
20422
|
+
]);
|
|
20423
|
+
return PBRMaterial;
|
|
20424
|
+
}(PBRBaseMaterial);
|
|
20425
|
+
(function() {
|
|
20426
|
+
PBRMaterial._metallicProp = ShaderProperty.getByName("material_Metal");
|
|
20427
|
+
})();
|
|
20428
|
+
(function() {
|
|
20429
|
+
PBRMaterial._roughnessProp = ShaderProperty.getByName("material_Roughness");
|
|
20430
|
+
})();
|
|
20431
|
+
(function() {
|
|
20432
|
+
PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
|
|
20433
|
+
})();
|
|
20434
|
+
(function() {
|
|
20435
|
+
PBRMaterial._iorProp = ShaderProperty.getByName("material_IOR");
|
|
20436
|
+
})();
|
|
20437
|
+
(function() {
|
|
20438
|
+
PBRMaterial._anisotropyInfoProp = ShaderProperty.getByName("material_AnisotropyInfo");
|
|
20439
|
+
})();
|
|
20440
|
+
(function() {
|
|
20441
|
+
PBRMaterial._anisotropyTextureProp = ShaderProperty.getByName("material_AnisotropyTexture");
|
|
20442
|
+
})();
|
|
20443
|
+
/**
|
|
20444
|
+
* PBR (Specular-Glossiness Workflow) Material.
|
|
20445
|
+
*/ var PBRSpecularMaterial = /*#__PURE__*/ function(PBRBaseMaterial1) {
|
|
20446
|
+
_inherits$2(PBRSpecularMaterial, PBRBaseMaterial1);
|
|
20447
|
+
function PBRSpecularMaterial(engine) {
|
|
20448
|
+
var _this;
|
|
20449
|
+
_this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr-specular")) || this;
|
|
20450
|
+
_this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new Color(1, 1, 1, 1));
|
|
20451
|
+
_this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, 1.0);
|
|
20452
|
+
return _this;
|
|
20453
|
+
}
|
|
20454
|
+
var _proto = PBRSpecularMaterial.prototype;
|
|
20455
|
+
/**
|
|
20456
|
+
* @inheritdoc
|
|
20457
|
+
*/ _proto.clone = function clone() {
|
|
20458
|
+
var dest = new PBRSpecularMaterial(this._engine);
|
|
20459
|
+
this.cloneTo(dest);
|
|
20460
|
+
return dest;
|
|
20461
|
+
};
|
|
20462
|
+
_create_class$2(PBRSpecularMaterial, [
|
|
20463
|
+
{
|
|
20464
|
+
key: "specularColor",
|
|
20465
|
+
get: /**
|
|
20466
|
+
* Specular color.
|
|
20467
|
+
*/ function get() {
|
|
20468
|
+
return this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
20469
|
+
},
|
|
20470
|
+
set: function set(value) {
|
|
20471
|
+
var specularColor = this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
|
|
20472
|
+
if (value !== specularColor) {
|
|
20473
|
+
specularColor.copyFrom(value);
|
|
20474
|
+
}
|
|
20508
20475
|
}
|
|
20509
20476
|
},
|
|
20510
20477
|
{
|
|
20511
|
-
key: "
|
|
20478
|
+
key: "glossiness",
|
|
20512
20479
|
get: /**
|
|
20513
|
-
*
|
|
20480
|
+
* Glossiness.
|
|
20514
20481
|
*/ function get() {
|
|
20515
|
-
return this.
|
|
20482
|
+
return this.shaderData.getFloat(PBRSpecularMaterial._glossinessProp);
|
|
20483
|
+
},
|
|
20484
|
+
set: function set(value) {
|
|
20485
|
+
this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, value);
|
|
20516
20486
|
}
|
|
20517
20487
|
},
|
|
20518
20488
|
{
|
|
20519
|
-
key: "
|
|
20489
|
+
key: "specularGlossinessTexture",
|
|
20520
20490
|
get: /**
|
|
20521
|
-
*
|
|
20522
|
-
*
|
|
20491
|
+
* Specular glossiness texture.
|
|
20492
|
+
* @remarks RGB is specular, A is glossiness
|
|
20523
20493
|
*/ function get() {
|
|
20524
|
-
return this.
|
|
20494
|
+
return this.shaderData.getTexture(PBRSpecularMaterial._specularGlossinessTextureProp);
|
|
20495
|
+
},
|
|
20496
|
+
set: function set(value) {
|
|
20497
|
+
this.shaderData.setTexture(PBRSpecularMaterial._specularGlossinessTextureProp, value);
|
|
20498
|
+
if (value) {
|
|
20499
|
+
this.shaderData.enableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
20500
|
+
} else {
|
|
20501
|
+
this.shaderData.disableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
|
|
20502
|
+
}
|
|
20503
|
+
}
|
|
20504
|
+
}
|
|
20505
|
+
]);
|
|
20506
|
+
return PBRSpecularMaterial;
|
|
20507
|
+
}(PBRBaseMaterial);
|
|
20508
|
+
(function() {
|
|
20509
|
+
PBRSpecularMaterial._specularColorProp = ShaderProperty.getByName("material_PBRSpecularColor");
|
|
20510
|
+
})();
|
|
20511
|
+
(function() {
|
|
20512
|
+
PBRSpecularMaterial._glossinessProp = ShaderProperty.getByName("material_Glossiness");
|
|
20513
|
+
})();
|
|
20514
|
+
(function() {
|
|
20515
|
+
PBRSpecularMaterial._specularGlossinessTextureProp = ShaderProperty.getByName("material_SpecularGlossinessTexture");
|
|
20516
|
+
})();
|
|
20517
|
+
(function() {
|
|
20518
|
+
PBRSpecularMaterial._specularGlossinessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");
|
|
20519
|
+
})();
|
|
20520
|
+
/**
|
|
20521
|
+
* Unlit Material.
|
|
20522
|
+
*/ var UnlitMaterial = /*#__PURE__*/ function(BaseMaterial1) {
|
|
20523
|
+
_inherits$2(UnlitMaterial, BaseMaterial1);
|
|
20524
|
+
function UnlitMaterial(engine) {
|
|
20525
|
+
var _this;
|
|
20526
|
+
_this = BaseMaterial1.call(this, engine, Shader.find("unlit")) || this;
|
|
20527
|
+
var shaderData = _this.shaderData;
|
|
20528
|
+
shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
|
|
20529
|
+
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
20530
|
+
shaderData.setColor(UnlitMaterial._baseColorProp, new Color(1, 1, 1, 1));
|
|
20531
|
+
shaderData.setVector4(UnlitMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
|
|
20532
|
+
return _this;
|
|
20533
|
+
}
|
|
20534
|
+
var _proto = UnlitMaterial.prototype;
|
|
20535
|
+
/**
|
|
20536
|
+
* @inheritdoc
|
|
20537
|
+
*/ _proto.clone = function clone() {
|
|
20538
|
+
var dest = new UnlitMaterial(this._engine);
|
|
20539
|
+
this.cloneTo(dest);
|
|
20540
|
+
return dest;
|
|
20541
|
+
};
|
|
20542
|
+
_create_class$2(UnlitMaterial, [
|
|
20543
|
+
{
|
|
20544
|
+
key: "baseColor",
|
|
20545
|
+
get: /**
|
|
20546
|
+
* Base color.
|
|
20547
|
+
*/ function get() {
|
|
20548
|
+
return this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
20549
|
+
},
|
|
20550
|
+
set: function set(value) {
|
|
20551
|
+
var baseColor = this.shaderData.getColor(UnlitMaterial._baseColorProp);
|
|
20552
|
+
if (value !== baseColor) {
|
|
20553
|
+
baseColor.copyFrom(value);
|
|
20554
|
+
}
|
|
20525
20555
|
}
|
|
20526
20556
|
},
|
|
20527
20557
|
{
|
|
20528
|
-
key: "
|
|
20558
|
+
key: "baseTexture",
|
|
20529
20559
|
get: /**
|
|
20530
|
-
*
|
|
20560
|
+
* Base texture.
|
|
20531
20561
|
*/ function get() {
|
|
20532
|
-
return this.
|
|
20562
|
+
return this.shaderData.getTexture(UnlitMaterial._baseTextureProp);
|
|
20563
|
+
},
|
|
20564
|
+
set: function set(value) {
|
|
20565
|
+
this.shaderData.setTexture(UnlitMaterial._baseTextureProp, value);
|
|
20566
|
+
if (value) {
|
|
20567
|
+
this.shaderData.enableMacro(UnlitMaterial._baseTextureMacro);
|
|
20568
|
+
} else {
|
|
20569
|
+
this.shaderData.disableMacro(UnlitMaterial._baseTextureMacro);
|
|
20570
|
+
}
|
|
20533
20571
|
}
|
|
20534
20572
|
},
|
|
20535
20573
|
{
|
|
20536
|
-
key: "
|
|
20574
|
+
key: "tilingOffset",
|
|
20537
20575
|
get: /**
|
|
20538
|
-
*
|
|
20576
|
+
* Tiling and offset of main textures.
|
|
20539
20577
|
*/ function get() {
|
|
20540
|
-
return this.
|
|
20578
|
+
return this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
20541
20579
|
},
|
|
20542
20580
|
set: function set(value) {
|
|
20543
|
-
|
|
20544
|
-
|
|
20581
|
+
var tilingOffset = this.shaderData.getVector4(UnlitMaterial._tilingOffsetProp);
|
|
20582
|
+
if (value !== tilingOffset) {
|
|
20583
|
+
tilingOffset.copyFrom(value);
|
|
20545
20584
|
}
|
|
20546
|
-
this._setSiblingIndex(this._isRoot ? this._scene._rootEntities : this._parent._children, value);
|
|
20547
20585
|
}
|
|
20548
20586
|
}
|
|
20549
20587
|
]);
|
|
20550
|
-
return
|
|
20551
|
-
}(
|
|
20588
|
+
return UnlitMaterial;
|
|
20589
|
+
}(BaseMaterial);
|
|
20590
|
+
/**
|
|
20591
|
+
* @internal
|
|
20592
|
+
*/ var BasicResources = /*#__PURE__*/ function() {
|
|
20593
|
+
var BasicResources = function BasicResources(engine) {
|
|
20594
|
+
// prettier-ignore
|
|
20595
|
+
var vertices = new Float32Array([
|
|
20596
|
+
-1,
|
|
20597
|
+
-1,
|
|
20598
|
+
0,
|
|
20599
|
+
1,
|
|
20600
|
+
1,
|
|
20601
|
+
-1,
|
|
20602
|
+
1,
|
|
20603
|
+
1,
|
|
20604
|
+
-1,
|
|
20605
|
+
1,
|
|
20606
|
+
0,
|
|
20607
|
+
0,
|
|
20608
|
+
1,
|
|
20609
|
+
1,
|
|
20610
|
+
1,
|
|
20611
|
+
0
|
|
20612
|
+
]); // right-top
|
|
20613
|
+
// prettier-ignore
|
|
20614
|
+
var flipYVertices = new Float32Array([
|
|
20615
|
+
1,
|
|
20616
|
+
-1,
|
|
20617
|
+
1,
|
|
20618
|
+
0,
|
|
20619
|
+
-1,
|
|
20620
|
+
-1,
|
|
20621
|
+
0,
|
|
20622
|
+
0,
|
|
20623
|
+
1,
|
|
20624
|
+
1,
|
|
20625
|
+
1,
|
|
20626
|
+
1,
|
|
20627
|
+
-1,
|
|
20628
|
+
1,
|
|
20629
|
+
0,
|
|
20630
|
+
1
|
|
20631
|
+
]); // left-top
|
|
20632
|
+
var blitMaterial = new Material(engine, Shader.find("blit"));
|
|
20633
|
+
blitMaterial._addReferCount(1);
|
|
20634
|
+
blitMaterial.renderState.depthState.enabled = false;
|
|
20635
|
+
blitMaterial.renderState.depthState.writeEnabled = false;
|
|
20636
|
+
this.blitMesh = this._createBlitMesh(engine, vertices);
|
|
20637
|
+
this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
|
|
20638
|
+
this.blitMaterial = blitMaterial;
|
|
20639
|
+
};
|
|
20640
|
+
var _proto = BasicResources.prototype;
|
|
20641
|
+
_proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
|
|
20642
|
+
var mesh = new ModelMesh(engine);
|
|
20643
|
+
mesh._addReferCount(1);
|
|
20644
|
+
mesh.setVertexElements([
|
|
20645
|
+
new VertexElement("POSITION_UV", 0, exports.VertexElementFormat.Vector4, 0)
|
|
20646
|
+
]);
|
|
20647
|
+
mesh.setVertexBufferBinding(new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static), 16);
|
|
20648
|
+
mesh.addSubMesh(0, 4, exports.MeshTopology.TriangleStrip);
|
|
20649
|
+
return mesh;
|
|
20650
|
+
};
|
|
20651
|
+
return BasicResources;
|
|
20652
|
+
}();
|
|
20552
20653
|
/**
|
|
20553
20654
|
* @internal
|
|
20554
20655
|
* Rendering context.
|
|
@@ -26802,9 +26903,10 @@
|
|
|
26802
26903
|
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
26803
26904
|
var _this = this, spotLight = _this._spotLights, pointLight = _this._pointLights, directLight = _this._directLights;
|
|
26804
26905
|
var _this1 = this, spotData = _this1._spotData, pointData = _this1._pointData, directData = _this1._directData;
|
|
26805
|
-
var
|
|
26806
|
-
var
|
|
26807
|
-
var
|
|
26906
|
+
var maxLight = LightManager._maxLight;
|
|
26907
|
+
var spotLightCount = Math.min(spotLight.length, maxLight);
|
|
26908
|
+
var pointLightCount = Math.min(pointLight.length, maxLight);
|
|
26909
|
+
var directLightCount = Math.min(directLight.length, maxLight);
|
|
26808
26910
|
for(var i = 0; i < spotLightCount; i++){
|
|
26809
26911
|
spotLight.get(i)._appendData(i, spotData);
|
|
26810
26912
|
}
|
|
@@ -31852,20 +31954,19 @@
|
|
|
31852
31954
|
var relativePath = curve.relativePath;
|
|
31853
31955
|
var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
|
|
31854
31956
|
if (targetEntity) {
|
|
31855
|
-
var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners,
|
|
31856
|
-
var propertyPath = "" + curve.typeIndex + "." + curve.property;
|
|
31957
|
+
var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
|
|
31857
31958
|
var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, AnimationCurveOwner._components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
|
|
31858
31959
|
if (!component) {
|
|
31859
31960
|
continue;
|
|
31860
31961
|
}
|
|
31861
31962
|
var property = curve.property;
|
|
31862
|
-
var instanceId =
|
|
31963
|
+
var instanceId = component.instanceId;
|
|
31863
31964
|
// Get owner
|
|
31864
31965
|
var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
|
|
31865
31966
|
var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity, component));
|
|
31866
31967
|
// Get layer owner
|
|
31867
31968
|
var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
|
|
31868
|
-
var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[
|
|
31969
|
+
var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
|
|
31869
31970
|
if (mask && mask.pathMasks.length) {
|
|
31870
31971
|
var _mask_getPathMask;
|
|
31871
31972
|
var _mask_getPathMask_active;
|
|
@@ -40212,6 +40313,7 @@
|
|
|
40212
40313
|
this.resourceManager = resourceManager;
|
|
40213
40314
|
this.params = params;
|
|
40214
40315
|
this.accessorBufferCache = {};
|
|
40316
|
+
this.needAnimatorController = false;
|
|
40215
40317
|
this._resourceCache = new Map();
|
|
40216
40318
|
this._progress = {
|
|
40217
40319
|
taskDetail: {},
|
|
@@ -40239,16 +40341,15 @@
|
|
|
40239
40341
|
return Promise.resolve(null);
|
|
40240
40342
|
}
|
|
40241
40343
|
var cache = this._resourceCache;
|
|
40242
|
-
var
|
|
40243
|
-
var cacheKey = isOnlyOne || index === undefined ? "" + type : type + ":" + index;
|
|
40344
|
+
var cacheKey = index === undefined ? "" + type : type + ":" + index;
|
|
40244
40345
|
var resource = cache.get(cacheKey);
|
|
40245
40346
|
if (resource) {
|
|
40246
40347
|
return resource;
|
|
40247
40348
|
}
|
|
40248
|
-
|
|
40249
|
-
|
|
40250
|
-
|
|
40251
|
-
var glTFItems = this.glTF[
|
|
40349
|
+
var glTFSchemaKey = glTFSchemaMap[type];
|
|
40350
|
+
var isSubAsset = !!glTFResourceMap[type];
|
|
40351
|
+
if (glTFSchemaKey) {
|
|
40352
|
+
var glTFItems = this.glTF[glTFSchemaKey];
|
|
40252
40353
|
if (glTFItems && (index === undefined || glTFItems[index])) {
|
|
40253
40354
|
if (index === undefined) {
|
|
40254
40355
|
resource = type === 8 ? glTFItems.map(function(_, index) {
|
|
@@ -40258,11 +40359,14 @@
|
|
|
40258
40359
|
}));
|
|
40259
40360
|
} else {
|
|
40260
40361
|
resource = parser.parse(this, index);
|
|
40261
|
-
this._handleSubAsset(resource, type, index);
|
|
40362
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
40262
40363
|
}
|
|
40263
40364
|
} else {
|
|
40264
40365
|
resource = Promise.resolve(null);
|
|
40265
40366
|
}
|
|
40367
|
+
} else {
|
|
40368
|
+
resource = parser.parse(this, index);
|
|
40369
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
40266
40370
|
}
|
|
40267
40371
|
cache.set(cacheKey, resource);
|
|
40268
40372
|
return resource;
|
|
@@ -40271,6 +40375,7 @@
|
|
|
40271
40375
|
var _this = this;
|
|
40272
40376
|
var promise = this.get(0).then(function(json) {
|
|
40273
40377
|
_this.glTF = json;
|
|
40378
|
+
_this.needAnimatorController = !!(json.skins || json.animations);
|
|
40274
40379
|
return Promise.all([
|
|
40275
40380
|
_this.get(1),
|
|
40276
40381
|
_this.get(5),
|
|
@@ -40278,11 +40383,14 @@
|
|
|
40278
40383
|
_this.get(7),
|
|
40279
40384
|
_this.get(9),
|
|
40280
40385
|
_this.get(10),
|
|
40386
|
+
_this.get(11),
|
|
40281
40387
|
_this.get(2)
|
|
40282
40388
|
]).then(function() {
|
|
40283
40389
|
var glTFResource = _this.glTFResource;
|
|
40284
|
-
|
|
40285
|
-
|
|
40390
|
+
var animatorController = glTFResource.animatorController;
|
|
40391
|
+
if (animatorController) {
|
|
40392
|
+
var animator = glTFResource._defaultSceneRoot.addComponent(Animator);
|
|
40393
|
+
animator.animatorController = animatorController;
|
|
40286
40394
|
}
|
|
40287
40395
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
40288
40396
|
return glTFResource;
|
|
@@ -40301,40 +40409,21 @@
|
|
|
40301
40409
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
40302
40410
|
});
|
|
40303
40411
|
};
|
|
40304
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
40305
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
40306
|
-
var animator = defaultSceneRoot.addComponent(Animator);
|
|
40307
|
-
var animatorController = new AnimatorController();
|
|
40308
|
-
var layer = new AnimatorControllerLayer("layer");
|
|
40309
|
-
var animatorStateMachine = new AnimatorStateMachine();
|
|
40310
|
-
animatorController.addLayer(layer);
|
|
40311
|
-
animator.animatorController = animatorController;
|
|
40312
|
-
layer.stateMachine = animatorStateMachine;
|
|
40313
|
-
if (animations) {
|
|
40314
|
-
for(var i = 0; i < animations.length; i++){
|
|
40315
|
-
var animationClip = animations[i];
|
|
40316
|
-
var name = animationClip.name;
|
|
40317
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
40318
|
-
if (uniqueName !== name) {
|
|
40319
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
40320
|
-
}
|
|
40321
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
40322
|
-
animatorState.clip = animationClip;
|
|
40323
|
-
}
|
|
40324
|
-
}
|
|
40325
|
-
};
|
|
40326
40412
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
40327
40413
|
var _this = this;
|
|
40328
40414
|
var glTFResourceKey = glTFResourceMap[type];
|
|
40329
|
-
if (!glTFResourceKey) return;
|
|
40330
40415
|
if (type === 8) {
|
|
40331
40416
|
var _this_glTFResource, _glTFResourceKey;
|
|
40332
40417
|
((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
|
|
40333
40418
|
} else {
|
|
40334
40419
|
var url = this.glTFResource.url;
|
|
40335
40420
|
resource.then(function(item) {
|
|
40336
|
-
|
|
40337
|
-
|
|
40421
|
+
if (index == undefined) {
|
|
40422
|
+
_this.glTFResource[glTFResourceKey] = item;
|
|
40423
|
+
} else {
|
|
40424
|
+
var _this_glTFResource, _glTFResourceKey;
|
|
40425
|
+
((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
|
|
40426
|
+
}
|
|
40338
40427
|
if (type === 7) {
|
|
40339
40428
|
for(var i = 0, length = item.length; i < length; i++){
|
|
40340
40429
|
var mesh = item[i];
|
|
@@ -40382,11 +40471,12 @@
|
|
|
40382
40471
|
GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
|
|
40383
40472
|
GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
|
|
40384
40473
|
GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
|
|
40474
|
+
GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
|
|
40385
40475
|
})(exports.GLTFParserType || (exports.GLTFParserType = {}));
|
|
40386
40476
|
var _obj;
|
|
40387
40477
|
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[5] = "textures", _obj[6] = "materials", _obj[7] = "meshes", _obj[8] = "nodes", _obj[9] = "skins", _obj[10] = "animations", _obj[4] = "bufferViews", _obj);
|
|
40388
40478
|
var _obj1;
|
|
40389
|
-
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1);
|
|
40479
|
+
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1[11] = "animatorController", _obj1);
|
|
40390
40480
|
function registerGLTFParser(pipeline) {
|
|
40391
40481
|
return function(Parser) {
|
|
40392
40482
|
var parser = new Parser();
|
|
@@ -42849,25 +42939,31 @@
|
|
|
42849
42939
|
camera.enabled = false;
|
|
42850
42940
|
};
|
|
42851
42941
|
_proto._createRenderer = function _createRenderer(context, entityInfo, entity) {
|
|
42852
|
-
var
|
|
42853
|
-
|
|
42854
|
-
|
|
42855
|
-
|
|
42856
|
-
|
|
42857
|
-
|
|
42858
|
-
|
|
42859
|
-
|
|
42860
|
-
|
|
42942
|
+
var _this = this;
|
|
42943
|
+
var meshID = entityInfo.mesh, skinID = entityInfo.skin;
|
|
42944
|
+
var glTFMesh = context.glTF.meshes[meshID];
|
|
42945
|
+
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
42946
|
+
var rendererCount = glTFMeshPrimitives.length;
|
|
42947
|
+
var blendShapeWeights = entityInfo.weights || glTFMesh.weights;
|
|
42948
|
+
var materialPromises = new Array(rendererCount);
|
|
42949
|
+
for(var i = 0; i < rendererCount; i++){
|
|
42950
|
+
materialPromises[i] = context.get(exports.GLTFParserType.Material, glTFMeshPrimitives[i].material);
|
|
42951
|
+
}
|
|
42952
|
+
return Promise.all([
|
|
42953
|
+
context.get(exports.GLTFParserType.Mesh, meshID),
|
|
42954
|
+
skinID !== undefined && context.get(exports.GLTFParserType.Skin, skinID),
|
|
42955
|
+
Promise.all(materialPromises)
|
|
42956
|
+
]).then(function(param) {
|
|
42957
|
+
var _loop = function _loop(i) {
|
|
42958
|
+
var material = materials[i] || exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine);
|
|
42959
|
+
var glTFPrimitive = glTFMeshPrimitives[i];
|
|
42861
42960
|
var mesh = meshes[i];
|
|
42862
|
-
var renderer;
|
|
42863
|
-
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine));
|
|
42961
|
+
var renderer = void 0;
|
|
42864
42962
|
if (skin || blendShapeWeights) {
|
|
42865
42963
|
var skinRenderer = entity.addComponent(SkinnedMeshRenderer);
|
|
42866
42964
|
skinRenderer.mesh = mesh;
|
|
42867
42965
|
if (skin) {
|
|
42868
|
-
skinRenderer.rootBone
|
|
42869
|
-
skinRenderer.bones = skin._bones;
|
|
42870
|
-
_this._computeLocalBounds(skinRenderer, mesh, skin._bones, skin._rootBone, skin.inverseBindMatrices);
|
|
42966
|
+
_this._computeLocalBounds(skinRenderer, mesh, skin.bones, skin.rootBone, skin.inverseBindMatrices);
|
|
42871
42967
|
skinRenderer.skin = skin;
|
|
42872
42968
|
}
|
|
42873
42969
|
if (blendShapeWeights) {
|
|
@@ -42886,17 +42982,10 @@
|
|
|
42886
42982
|
}
|
|
42887
42983
|
});
|
|
42888
42984
|
GLTFParser.executeExtensionsAdditiveAndParse(glTFPrimitive.extensions, context, renderer, glTFPrimitive);
|
|
42889
|
-
}
|
|
42890
|
-
|
|
42891
|
-
|
|
42892
|
-
|
|
42893
|
-
var meshID = entityInfo.mesh, skinID = entityInfo.skin;
|
|
42894
|
-
var glTFMesh = glTFMeshes[meshID];
|
|
42895
|
-
var glTFMeshPrimitives = glTFMesh.primitives;
|
|
42896
|
-
var blendShapeWeights = entityInfo.weights || glTFMesh.weights;
|
|
42897
|
-
var promises = new Array();
|
|
42898
|
-
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
42899
|
-
return Promise.all(promises);
|
|
42985
|
+
};
|
|
42986
|
+
var meshes = param[0], skin = param[1], materials = param[2];
|
|
42987
|
+
for(var i = 0; i < rendererCount; i++)_loop(i);
|
|
42988
|
+
});
|
|
42900
42989
|
};
|
|
42901
42990
|
_proto._computeLocalBounds = function _computeLocalBounds(skinnedMeshRenderer, mesh, bones, rootBone, inverseBindMatrices) {
|
|
42902
42991
|
var rootBoneIndex = bones.indexOf(rootBone);
|
|
@@ -42949,7 +43038,7 @@
|
|
|
42949
43038
|
var jointCount = joints.length;
|
|
42950
43039
|
var skin = new Skin(name);
|
|
42951
43040
|
skin.inverseBindMatrices.length = jointCount;
|
|
42952
|
-
|
|
43041
|
+
var bones = new Array(jointCount);
|
|
42953
43042
|
// parse IBM
|
|
42954
43043
|
var accessor = glTF.accessors[inverseBindMatrices];
|
|
42955
43044
|
var skinPromise = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
|
|
@@ -42961,21 +43050,20 @@
|
|
|
42961
43050
|
skin.inverseBindMatrices[i] = inverseBindMatrix;
|
|
42962
43051
|
// Get bones
|
|
42963
43052
|
var bone = entities[joints[i]];
|
|
42964
|
-
|
|
43053
|
+
bones[i] = bone;
|
|
42965
43054
|
skin.joints[i] = bone.name;
|
|
42966
|
-
|
|
42967
|
-
|
|
42968
|
-
|
|
42969
|
-
|
|
42970
|
-
|
|
43055
|
+
}
|
|
43056
|
+
skin.bones = bones;
|
|
43057
|
+
// Get skeleton
|
|
43058
|
+
if (skeleton !== undefined) {
|
|
43059
|
+
var rootBone = entities[skeleton];
|
|
43060
|
+
skin.rootBone = rootBone;
|
|
43061
|
+
} else {
|
|
43062
|
+
var rootBone1 = _this._findSkeletonRootBone(joints, entities);
|
|
43063
|
+
if (rootBone1) {
|
|
43064
|
+
skin.rootBone = rootBone1;
|
|
42971
43065
|
} else {
|
|
42972
|
-
|
|
42973
|
-
if (rootBone1) {
|
|
42974
|
-
skin._rootBone = rootBone1;
|
|
42975
|
-
skin.skeleton = rootBone1.name;
|
|
42976
|
-
} else {
|
|
42977
|
-
throw "Failed to find skeleton root bone.";
|
|
42978
|
-
}
|
|
43066
|
+
throw "Failed to find skeleton root bone.";
|
|
42979
43067
|
}
|
|
42980
43068
|
}
|
|
42981
43069
|
return skin;
|
|
@@ -43139,6 +43227,47 @@
|
|
|
43139
43227
|
exports.GLTFBufferViewParser = __decorate([
|
|
43140
43228
|
registerGLTFParser(exports.GLTFParserType.BufferView)
|
|
43141
43229
|
], exports.GLTFBufferViewParser);
|
|
43230
|
+
exports.GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
43231
|
+
var GLTFAnimatorControllerParser = function GLTFAnimatorControllerParser() {
|
|
43232
|
+
return GLTFParser1.apply(this, arguments);
|
|
43233
|
+
};
|
|
43234
|
+
_inherits(GLTFAnimatorControllerParser, GLTFParser1);
|
|
43235
|
+
var _proto = GLTFAnimatorControllerParser.prototype;
|
|
43236
|
+
_proto.parse = function parse(context) {
|
|
43237
|
+
var _this = this;
|
|
43238
|
+
if (!context.needAnimatorController) {
|
|
43239
|
+
return Promise.resolve(null);
|
|
43240
|
+
}
|
|
43241
|
+
return context.get(exports.GLTFParserType.Animation).then(function(animations) {
|
|
43242
|
+
var animatorController = _this._createAnimatorController(animations);
|
|
43243
|
+
return Promise.resolve(animatorController);
|
|
43244
|
+
});
|
|
43245
|
+
};
|
|
43246
|
+
_proto._createAnimatorController = function _createAnimatorController(animations) {
|
|
43247
|
+
var animatorController = new AnimatorController();
|
|
43248
|
+
var layer = new AnimatorControllerLayer("layer");
|
|
43249
|
+
var animatorStateMachine = new AnimatorStateMachine();
|
|
43250
|
+
animatorController.addLayer(layer);
|
|
43251
|
+
layer.stateMachine = animatorStateMachine;
|
|
43252
|
+
if (animations) {
|
|
43253
|
+
for(var i = 0; i < animations.length; i++){
|
|
43254
|
+
var animationClip = animations[i];
|
|
43255
|
+
var name = animationClip.name;
|
|
43256
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
43257
|
+
if (uniqueName !== name) {
|
|
43258
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
43259
|
+
}
|
|
43260
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
43261
|
+
animatorState.clip = animationClip;
|
|
43262
|
+
}
|
|
43263
|
+
}
|
|
43264
|
+
return animatorController;
|
|
43265
|
+
};
|
|
43266
|
+
return GLTFAnimatorControllerParser;
|
|
43267
|
+
}(GLTFParser);
|
|
43268
|
+
exports.GLTFAnimatorControllerParser = __decorate([
|
|
43269
|
+
registerGLTFParser(exports.GLTFParserType.AnimatorController)
|
|
43270
|
+
], exports.GLTFAnimatorControllerParser);
|
|
43142
43271
|
// Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
|
|
43143
43272
|
var MeshoptDecoder = function() {
|
|
43144
43273
|
var unpack = function unpack(data) {
|
|
@@ -43544,15 +43673,20 @@
|
|
|
43544
43673
|
var dataRGBA = new Uint8Array(4 * width * height);
|
|
43545
43674
|
var offset = 0, pos = 0;
|
|
43546
43675
|
var ptrEnd = 4 * scanLineWidth;
|
|
43547
|
-
var rgbeStart = new Uint8Array(4);
|
|
43548
43676
|
var scanLineBuffer = new Uint8Array(ptrEnd);
|
|
43549
43677
|
var numScanLines = height; // read in each successive scanLine
|
|
43550
43678
|
while(numScanLines > 0 && pos < byteLength){
|
|
43551
|
-
|
|
43552
|
-
|
|
43553
|
-
|
|
43554
|
-
|
|
43555
|
-
if (
|
|
43679
|
+
var a = buffer[pos++];
|
|
43680
|
+
var b = buffer[pos++];
|
|
43681
|
+
var c = buffer[pos++];
|
|
43682
|
+
var d = buffer[pos++];
|
|
43683
|
+
if (a != 2 || b != 2 || c & 0x80 || width < 8 || width > 32767) {
|
|
43684
|
+
// this file is not run length encoded
|
|
43685
|
+
// read values sequentially
|
|
43686
|
+
return buffer;
|
|
43687
|
+
}
|
|
43688
|
+
if ((c << 8 | d) != scanLineWidth) {
|
|
43689
|
+
// eslint-disable-next-line no-throw-literal
|
|
43556
43690
|
throw "HDR Bad header format, wrong scan line width";
|
|
43557
43691
|
}
|
|
43558
43692
|
// read each of the four channels for the scanline into the buffer
|
|
@@ -44958,7 +45092,7 @@
|
|
|
44958
45092
|
], KHR_materials_anisotropy);
|
|
44959
45093
|
|
|
44960
45094
|
//@ts-ignore
|
|
44961
|
-
var version = "1.2.0-beta.
|
|
45095
|
+
var version = "1.2.0-beta.5";
|
|
44962
45096
|
console.log("Galacean engine version: " + version);
|
|
44963
45097
|
for(var key in CoreObjects){
|
|
44964
45098
|
Loader.registerClass(key, CoreObjects[key]);
|