cesium-role-controller
v1.0.4
Published
基于Cesium的三维角色控制器插件
Downloads
13
Maintainers
Readme
演示地址
http://devmodels.oss-cn-shenzhen.aliyuncs.com/devtest/liubofang/CesiumRoleController/index.html
快速上手
import CesiumRoleController from 'cesium-role-controller'
/*
import * as Cesium from 'cesium'
let viewer = Cesium.viewer({...})
*/
let controller = new CesiumRoleController(Cesium, viewer)
controller.init({
position: [106.306177, 36.030691],
url: 'http://devmodels.oss-cn-shenzhen.aliyuncs.com/devtest/liubofang/glb/foreigner_cesium.glb',
animation: 'run',
})
API 文档
options
| 名称 | 说明 | 类型 | 可选值 | 默认值 | 是否必选 | | ------------- | -------------------------------------------------------------- | ------ | ------- | ------ | -------- | | url | 模型地址 | string | - | - | 是 | | position | 初始经纬度坐标 | array | - | - | 是 | | animation | 模型动画名称 | string | - | - | 否 | | speed | 运动速度 | number | - | 1 | 否 | | pitch | 相机看向模型的俯仰角度 | number | 0~-90 | -25 | 否 | | lockViewLevel | 相机看向模型的限制级别,等级由低到高,1 为自由视角,3 为全限制 | number | 1~3 | 3 | 否 | | range | 相机看向模型的视角范围 | number | 0~99999 | 4 | 否 |
method
| 名称 | 说明 | 参数 | 参数类型 | 返回值 | 使用方法 | | ------- | ------ | ------- | -------- | ------ | ---------------------- | | init | 初始化 | options | object | void | controller.init({...}) | | destroy | 销毁 | - | - | void | controller.destory() |
注意事项
- 本插件基于 Cesium 104+以上版本进行开发,如需兼容早期版本,可自行修改源码
- 通过键盘 W/S/A/D 控制人物移动和鼠标控制相机视角
- 当在启用地形的地图下时 可以把 speed 和 range 设置大一些 如 speed:10 range:1000
版权说明
- cesium-role-controller 插件由liubf自主研发,拥有所有权利。
- 任何个人或组织可以在遵守相关要求下可以免费无限制使用。
版本日志
1.0.0 2023/06/07
- 添加初始化配置参数
- 添加初始化方法
1.0.1 2023/06/08
- 修复配置文件参数拼写错误 参数 lookViewLevel 修改为 lockViewLevel
1.0.2 2023/06/08
- 修复自由视角下相机飘的问题
1.0.3 2023/06/08
- 修复自由视角下多个按键按下相机飘的问题
1.0.4 2023/06/09
- 优化一些局部问题