diff --git a/bin/sample-resource b/bin/sample-resource index a61b0c0dd8..8e103d1f16 160000 --- a/bin/sample-resource +++ b/bin/sample-resource @@ -1 +1 @@ -Subproject commit a61b0c0dd87c6f438c44d798e8530a70f9c5ddf2 +Subproject commit 8e103d1f16f66295be66818d7071a90baae3613f diff --git a/src/layaAir/laya/ModuleDef.ts b/src/layaAir/laya/ModuleDef.ts index d23e36c4a7..109f12a451 100644 --- a/src/layaAir/laya/ModuleDef.ts +++ b/src/layaAir/laya/ModuleDef.ts @@ -65,7 +65,8 @@ import { PolygonPoint2D } from "./display/Scene2DSpecial/Light2D/PolygonPoint2D" import { Gradient } from "./maths/Gradient"; import { FloatKeyframe } from "./maths/FloatKeyframe"; import { Line2DRender } from "./display/Scene2DSpecial/Line2D/Line2DRender"; -import { Area2D } from "./display/Area2D"; +import { Trail2DRender } from "./display/Scene2DSpecial/Trail2D/Trail2DRender"; +import { BooleanKeyframe } from "./maths/BooleanKeyframe"; let c = ClassUtils.regClass; c("Record", Object); @@ -119,6 +120,7 @@ c("BaseRenderNode2D", BaseRenderNode2D); c("Mesh2D", Mesh2D); c("Gradient", Gradient); c("FloatKeyframe", FloatKeyframe); +c("BooleanKeyframe", BooleanKeyframe); c("BaseLight2D", BaseLight2D); c("DirectionLight2D", DirectionLight2D); diff --git a/src/layaAir/laya/d3/animation/AnimationClip.ts b/src/layaAir/laya/d3/animation/AnimationClip.ts index 13a89def5e..e7566a88ab 100644 --- a/src/layaAir/laya/d3/animation/AnimationClip.ts +++ b/src/layaAir/laya/d3/animation/AnimationClip.ts @@ -20,6 +20,7 @@ import { QuaternionKeyframe } from "../../maths/QuaternionKeyframe"; import { Vector2Keyframe } from "../../maths/Vector2Keyframe"; import { Vector3Keyframe } from "../../maths/Vector3Keyframe"; import { Vector4Keyframe } from "../../maths/Vector4Keyframe"; +import { BooleanKeyframe } from "../../maths/BooleanKeyframe"; /** * @en The AnimationClip class is used for animation clip resources. @@ -430,7 +431,7 @@ export class AnimationClip extends Resource { * @param frontPlay 是否是前向播放。 * @param outDatas 计算好的动画数据。 */ - _evaluateClipDatasRealTime(nodes: KeyframeNodeList, playCurTime: number, realTimeCurrentFrameIndexes: Int16Array, addtive: boolean, frontPlay: boolean, outDatas: Array, avatarMask: AvatarMask): void { + _evaluateClipDatasRealTime(nodes: KeyframeNodeList, playCurTime: number, realTimeCurrentFrameIndexes: Int16Array, addtive: boolean, frontPlay: boolean, outDatas: Array, avatarMask: AvatarMask): void { for (var i = 0, n = nodes.count; i < n; i++) { var node = nodes.getNodeByIndex(i); var type = node.type; @@ -474,6 +475,13 @@ export class AnimationClip extends Resource { var isEnd = nextFrameIndex === keyFramesCount; switch (type) { + case KeyFrameValueType.Boolean: + if (frameIndex !== -1) { + outDatas[i] = (keyFrames[frameIndex]).value; + } else { + outDatas[i] = (keyFrames[0]).value; + } + break; case KeyFrameValueType.Float: if (frameIndex !== -1) { var frame = (keyFrames[frameIndex]); diff --git a/src/layaAir/laya/d3/animation/AnimationClipParser04.ts b/src/layaAir/laya/d3/animation/AnimationClipParser04.ts index 1b779c32b8..20555401ae 100644 --- a/src/layaAir/laya/d3/animation/AnimationClipParser04.ts +++ b/src/layaAir/laya/d3/animation/AnimationClipParser04.ts @@ -15,6 +15,7 @@ import { QuaternionKeyframe } from "../../maths/QuaternionKeyframe"; import { Vector2Keyframe } from "../../maths/Vector2Keyframe"; import { Vector3Keyframe } from "../../maths/Vector3Keyframe"; import { Vector4Keyframe } from "../../maths/Vector4Keyframe"; +import { BooleanKeyframe } from "../../maths/BooleanKeyframe"; /** * @internal @@ -260,6 +261,12 @@ export class AnimationClipParser04 { for (j = 0; j < keyframeCount; j++) { let isWeight = 1; switch (type) { + case KeyFrameValueType.Boolean: + let booleanKeyframe = new BooleanKeyframe(); + node._setKeyframeByIndex(j, booleanKeyframe); + booleanKeyframe.time = startTimeTypes[reader.getUint16()]; + booleanKeyframe.value = reader.getByte() == 1; + break; case KeyFrameValueType.Float: var floatKeyframe: FloatKeyframe = new FloatKeyframe(); node._setKeyframeByIndex(j, floatKeyframe); diff --git a/src/layaAir/laya/d3/component/Animator/Animator.ts b/src/layaAir/laya/d3/component/Animator/Animator.ts index 6cd1ccef57..d45e93cc28 100644 --- a/src/layaAir/laya/d3/component/Animator/Animator.ts +++ b/src/layaAir/laya/d3/component/Animator/Animator.ts @@ -228,7 +228,7 @@ export class Animator extends Component { keyframeNodeOwner.type = node.type; if (property) {//查询成功后赋默认值 - if (node.type === 0) { + if (node.type === KeyFrameValueType.Float || node.type === KeyFrameValueType.Boolean) { keyframeNodeOwner.defaultValue = property; } else { var defaultValue = new property.constructor(); @@ -740,6 +740,9 @@ export class Animator extends Component { let lastpro; if (pro) { switch (nodeOwner.type) { + case KeyFrameValueType.Boolean: + console.log("Animator:Boolean not support3"); + break; case KeyFrameValueType.Float: //Float var proPat: string[] = nodeOwner.property!; var m: number = proPat.length - 1; @@ -915,6 +918,19 @@ export class Animator extends Component { let value: string; if (pro) { switch (nodeOwner.type) { + case KeyFrameValueType.Boolean: + var proPat: string[] = nodeOwner.property!; + var m: number = proPat.length - 1; + for (var j: number = 0; j < m; j++) { + pro = pro[proPat[j]]; + if (!pro)//属性可能或被置空 + break; + } + let lastBoolPro = proPat[m]; + if (!nodeOwner.isMaterial) { + pro && (pro[lastBoolPro] = realtimeDatas[i]) + } + break; case KeyFrameValueType.Float: //Float var proPat: string[] = nodeOwner.property!; var m: number = proPat.length - 1; @@ -1110,6 +1126,9 @@ export class Animator extends Component { let value: string; if (pro) { switch (nodeOwner.type) { + case KeyFrameValueType.Boolean: + console.log("Animator:Boolean not support2"); + break; case KeyFrameValueType.Float: var proPat: string[] = nodeOwner.property!; var m: number = proPat.length - 1; diff --git a/src/layaAir/laya/d3/component/Animator/AnimatorState.ts b/src/layaAir/laya/d3/component/Animator/AnimatorState.ts index 7a2f89f4a2..e8416bd337 100644 --- a/src/layaAir/laya/d3/component/Animator/AnimatorState.ts +++ b/src/layaAir/laya/d3/component/Animator/AnimatorState.ts @@ -140,6 +140,7 @@ export class AnimatorState extends EventDispatcher implements IClone { this._realtimeDatas.length = count; for (var i: number = 0; i < count; i++) { switch (clipNodes.getNodeByIndex(i).type) { + case KeyFrameValueType.Boolean: case KeyFrameValueType.Float: break; case KeyFrameValueType.Position: diff --git a/src/layaAir/laya/d3/component/Animator/KeyframeNodeOwner.ts b/src/layaAir/laya/d3/component/Animator/KeyframeNodeOwner.ts index 1978dd3b76..529539c4fa 100644 --- a/src/layaAir/laya/d3/component/Animator/KeyframeNodeOwner.ts +++ b/src/layaAir/laya/d3/component/Animator/KeyframeNodeOwner.ts @@ -11,7 +11,8 @@ export enum KeyFrameValueType { Vector2 = 5, Vector3 = 6, Vector4 = 7, - Color = 8 + Color = 8, + Boolean = 9, } /** * @internal diff --git a/src/layaAir/laya/maths/BooleanKeyframe.ts b/src/layaAir/laya/maths/BooleanKeyframe.ts new file mode 100644 index 0000000000..af5257f8cf --- /dev/null +++ b/src/layaAir/laya/maths/BooleanKeyframe.ts @@ -0,0 +1,31 @@ +import { Keyframe } from "./Keyframe"; +export class BooleanKeyframe extends Keyframe { + /** + * @en The value of the keyframe. + * @zh 关键帧的值。 + */ + value: boolean; + + /** + * @inheritDoc + * @override + * @en Clones the data to another object. + * @param destObject The target object to clone to. + * @zh 克隆数据到目标对象。 + * @param destObject 拷贝数据结构 + */ + cloneTo(destObject: BooleanKeyframe): void { + super.cloneTo(destObject);; + destObject.value = this.value; + } + + /** + * @en Clones. + * @zh 克隆 + */ + clone(): BooleanKeyframe { + let f = new BooleanKeyframe(); + this.cloneTo(f); + return f; + } +} \ No newline at end of file