Skip to content

Camera 摄像机模块 客户端

适用于摄像机运镜业务开发

python
from QuModLibs.Modules.Camera.Client import LensPlayer, LensAnim, ...

LensPlayer 播放器管理器

LensPlayer对象用于管理动画的时间轴计算以便绘制出线性的动画效果

python
from QuModLibs.Modules.Camera.Client import LensPlayer

# 镜头播放器参数
# @lensAnimType 镜头动画类型 默认为线性 具有过渡处理
# @lockOperation 是否锁定玩家的操作 默认为True 启用后在镜头动画期间锁定玩家
# 通常情况下使用默认的参数即可
lensPlayer = LensPlayer()

LensAnim 镜头动画

LensAnim描绘了镜头的运动轨迹

python
from QuModLibs.Modules.Camera.Client import LensAnim

# 基于变换参数列表构造播放动画
anim = LensAnim({
    "0.0": [0, 0, 2, 0, 0],
    "2.0": [0, 0, 2, 0, 360],
    "3.0": [0, 0, 2, 0, 720],
    "4.0": [0, 0, 2, 0, 720+360],
}).setLoop(True)    # 默认不循环


# 变换参数表说明: [x, y, z, rotX, rotY]

演示代码

python
# -*- coding: utf-8 -*-
from QuModLibs.Client import *
from QuModLibs.Modules.Camera.Client import (
    LensPlayer,
    LensAnim,
    LensAnimPositionProcessType,
    LensAnimType
)

# 创建一个全局播放器 在v1.3版本之前需手动调用释放(动态使用时)
lensPlayer = LensPlayer(
    lensAnimType = LensAnimType.LINEAR,         # 线性混合模式
    lockOperation = True                        # 播放期间锁定玩家
)

# 基于变换参数列表构造播放动画
anim = LensAnim({
    "0.0": [0, 0, 2, 0, 0],
    "2.0": [0, 0, 2, 0, 360],
    "3.0": [0, 0, 2, 0, 720],
    "4.0": [0, 0, 2, 0, 720+360],
}).setLoop(True)

# 基于blockbench动画制作 设计摄像机运镜
# anim2 = LensAnim.loadBEJSONAnim({
#     "rotation": {
#         "0.0": [192.5, 180, -180],
#         "0.2917": [199.50716, 180, -181.73655],
#         "0.4583": [191.72554, 180, -182.72887],
#         "0.6667": [156.72554, 180, -182.72887],
#         "0.8333": [156.73, 180, -182.73],
#         "1.3333": [156.73, 180, -182.73],
#         "1.8": [192.5, 180, -180],
#     },
#     "position": {
#         "0.0": [6, 39, -32],
#         "0.6667": [6, 39, -32],
#         "0.8333": [6, 39, -32],
#         "1.3333": [6, 31, -44],
#         "1.8": [6, 39, -32],
#     }
# }).setLoop(True)

@Listen(Events.ClientItemTryUseEvent)
def ClientItemTryUseEvent(args={}):
    # 调用播放器并以一定speed速度乘子播放特定动画
    lensPlayer.play(anim, speed=0.5)

Released under the BSD3 License