一款基于Cesium的三维角色控制器插件

admin一款基于Cesium的三维角色控制器插件已关闭评论条评论 1,299 次浏览

一款基于Cesium的三维角色控制器插件现在开源拉~欢迎使用star欢迎pr
https://github.com/ShareQiu1994/CesiumRoleController 
https://www.npmjs.com/package/cesium-role-controller
开源需要大家一起共同参与,让”前人栽树后人乘凉”的精神在中国开发者传承下去

快速上手

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运动速度number1
pitch相机看向模型的俯仰角度number0~-90-25
lockViewLevel相机看向模型的限制级别,等级由低到高,1为自由视角,3为全限制number1~33
range相机看向模型的视角范围number0~999994

method

名称说明参数参数类型返回值使用方法
init初始化optionsobjectvoidcontroller.init({…})
destory销毁voidcontroller.destory()

注意事项

  1. 本插件基于Cesium 104+以上版本进行开发,如需兼容早期版本,可自行修改源码
  2. 通过键盘W/S/A/D控制人物移动和鼠标控制相机视角
  3. 当在启用地形的地图下时 可以把speed和range设置大一些 如speed:10 range:1000

版权说明

  1. cesium-role-controller 插件由liubf自主研发,拥有所有权利。
  2. 任何个人或组织可以在遵守相关要求下可以免费无限制使用。



分类目录