Skip to content

plugin-camera-follower

beta

相机跟随。

样例

安装

bash
npm install @soonspacejs/plugin-camera-follower -S
# or
yarn add @soonspacejs/plugin-camera-follower -S

使用方法

js
import SoonSpace from 'soonspacejs';
import CameraFollowerPlugin from '@soonspacejs/plugin-camera-follower';

const ssp = new SoonSpace({
  el: '#view',
  options: {},
  events: {},
});

const cameraFollowerPlugin = ssp.registerPlugin(
  CameraFollowerPlugin,
  'cameraFollowerPlugin'
);
consolo.log(cameraFollowerPlugin);

方法

start

开启相机跟随

定义

ts
interface StartOptions {
  position?: Position;
  rotation?: Rotation;
}

function start(object: Object3D, options?: StartOptions): void;

用法

js
cameraFollowerPlugin.start(model, {
  position: {
    x: 1500,
    y: 300,
    z: 0,
  },
  rotation: {
    x: 0,
    y: Math.PI / 2,
    z: 0,
  },
});

参数:

object
  • 描述: 模型对象
  • 类型: BaseObject3D
  • 必填:
options
  • 描述: 配置选项
  • 类型: StartOptions
  • 必填:
StartOptions
属性描述类型必填默认值
position相机位置(相对于模型)Position{x: 0,y: 0,z: 0}
rotation相机弧度(相对于模型)Rotation{x: 0,y: 0,z: 0}

stop

结束相机跟随

定义

ts
function stop(): void;

用法

js
cameraFollowerPlugin.stop();

浙ICP备16043491号