[LayaAirIDE3]时间轴动画调了材质引用类型的属性,调用play()接口切状态的时候调用_revertDefaultKeyframeNodes报材质属性空
修改代码如下能请帮忙确认一下吗
private _addKeyframeNodeOwner(clipOwners: KeyframeNodeOwner[], node: KeyframeNode, propertyOwner: any): void {
var nodeIndex = node._indexInList;
var fullPath = node.fullPath;
var keyframeNodeOwner = this._keyframeNodeOwnerMap[fullPath];
let mat = false;
if (keyframeNodeOwner) {
keyframeNodeOwner.referenceCount++;
clipOwners[nodeIndex] = keyframeNodeOwner;
} else {
var property = propertyOwner;
for (var i = 0, n = node.propertyCount; i < n; i++) {
//-------------------------------begin------------------------------
if (property instanceof Material) {
switch (node.type) {
case KeyFrameValueType.Float:
property = property.getFloat(node.getPropertyByIndex(i));
break;
case KeyFrameValueType.Vector2:
property = property.getVector2(node.getPropertyByIndex(i)).clone();
break;
case KeyFrameValueType.Vector3:
property = property.getVector3(node.getPropertyByIndex(i)).clone();
break;
case KeyFrameValueType.Vector4:
property = property.getVector4(node.getPropertyByIndex(i)).clone();
break;
case KeyFrameValueType.Color:
const color = property.getColor(node.getPropertyByIndex(i));
property = new Vector4(color.r, color.g, color.b, color.a);
break;
}
}
//-------------------------------end------------------------------
property = property[node.getPropertyByIndex(i)];
if (property instanceof Material) {
mat = true
}
if (!property)
break;
}
keyframeNodeOwner = this._keyframeNodeOwnerMap[fullPath] = new KeyframeNodeOwner();
keyframeNodeOwner.isMaterial = mat;
keyframeNodeOwner.fullPath = fullPath;
keyframeNodeOwner.indexInList = this._keyframeNodeOwners.length;
keyframeNodeOwner.referenceCount = 1;
keyframeNodeOwner.propertyOwner = propertyOwner;
keyframeNodeOwner.nodePath = node.nodePath;
keyframeNodeOwner.callbackFunData = node.callbackFunData;
keyframeNodeOwner.callParams = node.callParams;
keyframeNodeOwner.getCallbackNode();
var propertyCount = node.propertyCount;
var propertys: string[] = [];
for (i = 0; i < propertyCount; i++)
propertys[i] = node.getPropertyByIndex(i);
keyframeNodeOwner.property = propertys;
keyframeNodeOwner.type = node.type;
if (property) {//查询成功后赋默认值
if (node.type === 0) {
keyframeNodeOwner.defaultValue = property;
} else {
var defaultValue = new property.constructor();
property.cloneTo(defaultValue);
keyframeNodeOwner.defaultValue = defaultValue;
keyframeNodeOwner.value = new property.constructor();
keyframeNodeOwner.crossFixedValue = new property.constructor();
}
}
this._keyframeNodeOwners.push(keyframeNodeOwner);
clipOwners[nodeIndex] = keyframeNodeOwner;
}
}
private _addKeyframeNodeOwner(clipOwners: KeyframeNodeOwner[], node: KeyframeNode, propertyOwner: any): void {
var nodeIndex = node._indexInList;
var fullPath = node.fullPath;
var keyframeNodeOwner = this._keyframeNodeOwnerMap[fullPath];
let mat = false;
if (keyframeNodeOwner) {
keyframeNodeOwner.referenceCount++;
clipOwners[nodeIndex] = keyframeNodeOwner;
} else {
var property = propertyOwner;
for (var i = 0, n = node.propertyCount; i < n; i++) {
//-------------------------------begin------------------------------
if (property instanceof Material) {
switch (node.type) {
case KeyFrameValueType.Float:
property = property.getFloat(node.getPropertyByIndex(i));
break;
case KeyFrameValueType.Vector2:
property = property.getVector2(node.getPropertyByIndex(i)).clone();
break;
case KeyFrameValueType.Vector3:
property = property.getVector3(node.getPropertyByIndex(i)).clone();
break;
case KeyFrameValueType.Vector4:
property = property.getVector4(node.getPropertyByIndex(i)).clone();
break;
case KeyFrameValueType.Color:
const color = property.getColor(node.getPropertyByIndex(i));
property = new Vector4(color.r, color.g, color.b, color.a);
break;
}
}
//-------------------------------end------------------------------
property = property[node.getPropertyByIndex(i)];
if (property instanceof Material) {
mat = true
}
if (!property)
break;
}
keyframeNodeOwner = this._keyframeNodeOwnerMap[fullPath] = new KeyframeNodeOwner();
keyframeNodeOwner.isMaterial = mat;
keyframeNodeOwner.fullPath = fullPath;
keyframeNodeOwner.indexInList = this._keyframeNodeOwners.length;
keyframeNodeOwner.referenceCount = 1;
keyframeNodeOwner.propertyOwner = propertyOwner;
keyframeNodeOwner.nodePath = node.nodePath;
keyframeNodeOwner.callbackFunData = node.callbackFunData;
keyframeNodeOwner.callParams = node.callParams;
keyframeNodeOwner.getCallbackNode();
var propertyCount = node.propertyCount;
var propertys: string[] = [];
for (i = 0; i < propertyCount; i++)
propertys[i] = node.getPropertyByIndex(i);
keyframeNodeOwner.property = propertys;
keyframeNodeOwner.type = node.type;
if (property) {//查询成功后赋默认值
if (node.type === 0) {
keyframeNodeOwner.defaultValue = property;
} else {
var defaultValue = new property.constructor();
property.cloneTo(defaultValue);
keyframeNodeOwner.defaultValue = defaultValue;
keyframeNodeOwner.value = new property.constructor();
keyframeNodeOwner.crossFixedValue = new property.constructor();
}
}
this._keyframeNodeOwners.push(keyframeNodeOwner);
clipOwners[nodeIndex] = keyframeNodeOwner;
}
}
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
1715665753用户
赞同来自: