跳转至

10. 动画编辑

动画

一、动画

属性列表

属性 属性名 类型 默认值/可选值 说明
启用 enabled boolean true、false 是否开启动画组件
自动播放 playAutomatically boolean true、false 是否自动播放动画
播放模式 wrapMode number 1、2、4 三种播放模式选择。1=Once,2=Loop,4=PingPong
默认动画 defaultclipName string 选择默认播放动画

二、中心点

属性列表

属性 属性名 类型 默认值/可选值 说明
编辑Pivot editPivot boolean true、false
冻结位移 lockPostion boolean true、false
冻结旋转 lockRotation Vector3 { x: 1, y: 1, z: 0 }
位移 localPosition Vector3 { x: 1, y: 1, z: 0 }
旋转 localEulerAngles Vector3 { x: 1, y: 1, z: 0 }
相对位移 actorRelativePosition Vector3 { x: 1, y: 1, z: 0 }
相对旋转 actorRelativeEulerAngles Vector3 { x: 1, y: 1, z: 0 }

三、顶点动画

属性列表

属性 属性名 类型 默认值/可选值 说明
启用 enabled boolean true、false
偏移 offset Vector3 { x: 0, y: 0, z: 0 }
大小 size Vector3 { x: 0, y: 0, z: 0 }
速度 speed Vector3 { x: 0, y: 0, z: 0 }
状态 state Vector3 { x: 0, y: 0, z: 0 }

示例代码

        // 是否启用|enabled
        animation.enabled = true;
        // 是否自动播放|playAutomatically
        animation.playAutomatically = true;
        // 选择播放模式|wrapMode 
        animation.wrapMode = 4;
        // 选择默认动画|defaultclipName
        animation.defaultclipName = "Take";

示例案例

    // 1-动画
    animation_Demo() {
        // 获取name为Box的三维物体
        let animation_Actor = gVrpManager.Scene().FindActor("Box");
        // 需要先为Box创建一个动画事件
        // 获取动画组件
        let animation = animation_Actor.GetComponent("Animation");
        // 是否启用|enabled
        animation.enabled = true;
        // 是否自动播放|playAutomatically
        animation.playAutomatically = true;
        // 选择播放模式|wrapMode 
        animation.wrapMode = 4;
        // 选择默认动画|defaultclipName
        animation.defaultclipName = "Take";
    }

    // 2-中心点
    pivot_Demo() {
        // 获取name为Box的三维物体
        let pivot_Actor = gVrpManager.Scene().FindActor("Box");
        // 获取中心点动画组件
        let pivot = pivot_Actor.GetComponent("Pivot");
        // 是否编辑Pivot|editPivot
        pivot.editPivot = true;
        // 是否冻结位移|lockPostion
        pivot.lockPostion = { x: 1, y: 1, z: 0 };
        // 是否冻结旋转|lockRotation
        pivot.lockRotation = { x: 1, y: 1, z: 0 };
        // 修改位移|localPosition
        pivot.localPosition = { x: 0, y: 0, z: 0 };
        // 修改旋转|localEulerAngles
        pivot.localEulerAngles = { x: -0, y: 0, z: 0 };
        // 修改相对位移|actorRelativePosition
        pivot.actorRelativePosition = { x: 0, y: 0, z: 0 };
        // 修改相对旋转|actorRelativeEulerAngles
        pivot.actorRelativeEulerAngles = { x: 0, y: 0, z: 0 };
    }

    // 3-顶点动画
    textureAnimation_Demo() {
        // 获取name为Box的三维物体
        let textureAnimation_Actor = gVrpManager.Scene().FindActor("Box");
        // 获取顶点动画组件
        let textureAnimation = textureAnimation_Actor.GetComponent("TextureAnimation");
        // 是否启用|enabled
        textureAnimation.enabled = true;
        // 修改偏移|offset
        textureAnimation.offset = { x: 0, y: 0, z: 0 };
        // 修改大小|size
        textureAnimation.size = { x: 0, y: 0, z: 0 };
        // 修改速度|speed
        textureAnimation.speed = { x: 0, y: 0, z: 0 };
        // 修改状态|state
        textureAnimation.state = { x: 0, y: 0, z: 0 };
    }