Appearance
plugin-follow-mouse
空间中摆放模型时,模型跟随鼠标。
交互提示
鼠标左键单击摆放模型
鼠标左键双击摆放模型并结束摆放
回车键结束摆放
鼠标右键单击或 delete
删除上一次摆放 esc
清空并取消摆放
样例
安装
bash
npm install @soonspacejs/plugin-follow-mouse -S
# or
yarn add @soonspacejs/plugin-follow-mouse -S
使用方法
js
import SoonSpace from 'soonspacejs';
import FollowMousePlugin from '@soonspacejs/plugin-follow-mouse';
const ssp = new SoonSpace({
el: '#view',
options: {},
events: {},
});
const followMousePlugin = ssp.registerPlugin(
FollowMousePlugin,
'followMousePlugin'
);
consolo.log(followMousePlugin);
方法
start
开始让模型跟随鼠标。
定义
ts
interface StartOptions {
openHelper?: boolean
helperColor?: IColor
offset?: Position
onPlace?: <ObjectType = Object3D>(object: ObjectType) => void
onDone?: <ObjectType = Object3D>(objects: ObjectType[]) => void
onBack?: <ObjectType = Object3D>(object: ObjectType) => void
onCancel?: () => void
}
function start(model: Sbm | Model, options: StartOptions = {}) => void
用法
js
followMousePlugin.start(
// model
sbmObject,
// options
{
openHelper: true,
helperColor: 0xffff00,
offsetY: {
x: 2,
y: 2,
z: 2
},
onPlace(model) {
console.log('onPlace', model);
},
onBack(model) {
console.log('onBack', model);
},
onDone(modelList) {
console.log('onDone', modelList);
},
onCancel() {
console.log('onCancel');
},
}
);
参数
model
- 描述: 跟随鼠标的模型对象
- 必填:
- 类型:
Sbm | Model
options
- 描述: 可配置项
- 必填:
- 类型:
StartOptions