基本构造方法base
Parameters:
Name | Type | Description |
---|---|---|
params |
object
|
|
viewer |
object
|
cesium 实例 |
cesiumGlobal |
object
|
cesium 全局对象 |
defaultStatic |
Array
|
静态资源 |
Methods
# bindHandelEvent(options)
鼠标事件注册
Parameters:
Name | Type | Description |
---|---|---|
options |
object
|
|
leftClick |
string
|
左键点击 |
mouseMove |
object
|
移动 |
dubleClick |
object
|
双击 |
leftDown |
object
|
左键按下 |
mouseWheel |
object
|
鼠标滚动 |
leftUp |
object
|
左键弹起 |
Example
import { Base } from 'cesium_dev_kit'
const {base} = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
base.bindHandelEvent({
leftClick: function click(event, _handlers) {
todo something...
},
mouseMove: function move(event) {
todo something...
},
});
# createGraphics() → {Entity}
创建一个Graphics实体
Entity
Entity
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
const entity = baseObj.base.createGraphics()
# flyTo(options)
相机飞行
Parameters:
Name | Type | Description |
---|---|---|
options |
object
|
|
position |
Cartesian3
|
目标位置数组 |
distance |
number
|
距离 |
duration |
number
|
过度时长(秒为单位) |
orientation |
object
|
方位,包含[朝向|倾斜角|翻滚角] |
easingFunction |
object
|
飞行中在duration时间内插值方式 |
callback |
function
|
操作完成后的回调 |
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.flyTo({
position: { x: -1337132.0092982147, y: 5330611.474631115, z: 3228680.029449292 },
orientation: {
heading: Cesium.Math.toRadians(1.0114629015290062),
pitch: Cesium.Math.toRadians(-23.53661660731824),
roll: Cesium.Math.toRadians(0.00324596311071617)
},,
distance:300,
duration:3
})
# getCameraPosition() → {cameraPosType}
获取相机位置
相机位置信息
Example
import { Base } from 'cesium_dev_kit'
const {base} = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
base.bindHandelEvent({
leftClick: function click (event, _handlers) {
const pos = base.getCameraPosition();
console.log(pos);
}
})
# getCatesian3FromPX(px) → {boolean|Cartesian3}
拾取位置点
Parameters:
Name | Type | Description |
---|---|---|
px |
Cartesian2
|
屏幕二维坐标 |
boolean
|
Cartesian3
Example
import { Base } from 'cesium_dev_kit'
const {viewer,base} = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
const _handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
_handler.setInputAction(function (movement) {
var cartesian = base.getCatesian3FromPX(movement.endPosition);
console.log(cartesian)
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
# getHandelPosition(callback)
获取鼠标信息
Parameters:
Name | Type | Description |
---|---|---|
callback |
function
|
Example
import { Base } from 'cesium_dev_kit'
const {base} = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
base.getHandelPosition(res=>{console.log(res)})
# getHandlerClickPosition(e) → {clickPositionType}
获取鼠标点击后的位置信息
Parameters:
Name | Type | Description |
---|---|---|
e |
Cesium.Event
|
监听的事件对象 |
Example
import { Base } from 'cesium_dev_kit'
const {base} = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
base.bindHandelEvent({
leftClick: function click (event, _handlers) {
const { wgs84Coor, graphicCoor } = base.getHandlerClickPosition(event);
console.log(wgs84Coor, graphicCoor);
}
})
# lnglatArrayToCartesians(lnglats) → {Array.<Cartesian3>}
经纬度坐标数组转笛卡尔积世界坐标数组
Parameters:
Name | Type | Description |
---|---|---|
lnglats |
Array.<Array>
|
经纬度坐标数组 |
cartesians - 笛卡尔积世界坐标数组
Array.<Cartesian3>
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.lnglatArrayToCartesians([[117,40],[118.41]])
# removeHandlerByName(eventNameArr)
移除绑定的handler事件
Parameters:
Name | Type | Description |
---|---|---|
eventNameArr |
Array
|
handler名称数组,如['LEFT_CLICK','MOUSE_MOVE'] |
# saveSceneImages()
保存当前场景png
Example
import { Base } from 'cesium_dev_kit'
const {base} = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
base.saveSceneImages()
# setBloomLightScene()
场景泛光
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setBloomLightScene()
# setBlurBloom(options) → {postProcessStages}
场景蓝光
Parameters:
Name | Type | Description |
---|---|---|
options |
object
|
|
width |
number
|
曝光区域宽度 |
height |
number
|
曝光区域高度 |
postProcessStages 实例
postProcessStages
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setBlurBloom({width:80,height:97})
# setCameraEotateHeading(options)
相机绕点旋转
Parameters:
Name | Type | Description |
---|---|---|
options |
object
|
|
lng |
number
|
经度 |
lat |
number
|
纬度 |
height |
number
|
z轴高度 |
Example
import { Base } from 'cesium_dev_kit'
const BaseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
BaseObj.base.setCameraEotateHeading({
lng: 117.1423291616,
lat: 39.0645831633,
height: 15.8
})
# setDarkEffect(options) → {postProcessStages}
黑夜特效
Parameters:
Name | Type | Description |
---|---|---|
options |
object
|
|
offset |
Cartesian3
|
偏移 |
postProcessStages 实例
postProcessStages
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setDarkEffect({offset:new Cesium.Cartesian3(0.1, 0.2, 0.3)})
# setDefSceneConfig()
默认场景配置
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setDefSceneConfig()
# setFogEffect() → {postProcessStages}
雾天
postProcessStages 实例
postProcessStages
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setFogEffect()
# setOneGroundSkyBox() → {GroundSkyBox}
近景天空盒
- See:
-
SkyBoxOnGround
SkyBox
GroundSkyBox
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setOneGroundSkyBox()
# setOneSkyBox() → {SkyBox}
天空盒
SkyBox
SkyBox
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setOneSkyBox()
# setRainEffect() → {postProcessStages}
雨天特效
postProcessStages 实例
postProcessStages
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setRainEffect()
# setSnowEffect() → {postProcessStages}
雪天特效
postProcessStages 实例
postProcessStages
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setSnowEffect()
# setThreeGroundSkyBox() → {GroundSkyBox}
近景天空盒3
- See:
-
SkyBoxOnGround
SkyBox
GroundSkyBox
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setThreeGroundSkyBox()
# setThreeSkyBox() → {SkyBox}
天空盒3
SkyBox
SkyBox
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setThreeSkyBox()
# setTwoGroundSkyBox() → {GroundSkyBox}
近景天空盒2
- See:
-
SkyBoxOnGround
SkyBox
GroundSkyBox
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setTwoGroundSkyBox()
# setTwoSkyBox() → {SkyBox}
天空盒2
SkyBox
SkyBox
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setTwoSkyBox()
# setView(options)
相机定位
Parameters:
Name | Type | Description |
---|---|---|
options |
object
|
|
position |
Cartesian3
|
目标位置数组 |
distance |
number
|
距离 |
orientation |
object
|
方位,包含[朝向|倾斜角|翻滚角] |
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.setView({
position: new Cesium.Cartesian3(-1337035.7496454942, 5285202.940044943, 3305373.990594733),
orientation: {
heading: 6.108097731064569,
pitch: -0.15254104473396812,
roll: 6.283157460498558,
},
});
# transformCartesianArrayToWGS84Array(cartesianArr) → {Array.<WGS84Type>}
笛卡尔积坐标数组转换 84地理坐标
Parameters:
Name | Type | Description |
---|---|---|
cartesianArr |
Array.<Cartesian3>
|
转换后的笛卡尔积数组
Array.<WGS84Type>
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.transformCartesianArrayToWGS84Array(Cesium.Cartesian3.fromDegreesArray( 110.16018735617934, 31.036076859828338, 110.17845812703679,31.033686527335444))
# transformCartesianToWGS84(cartesian) → {WGS84Type}
笛卡尔转坐标WGS84
Parameters:
Name | Type | Description |
---|---|---|
cartesian |
Cartesian3
|
笛卡尔积坐标数组 |
转换后wgs84坐标对象
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.transformCartesianToWGS84(Cesium.Cartesian3.fromDegrees(110.16018735617934, 31.036076859828338))
# transformWGS84ArrayToCartesianArray(WSG84Arr, alt) → {Array.<Cartesian3>}
坐标数组转换 笛卡尔转84
Parameters:
Name | Type | Description |
---|---|---|
WSG84Arr |
Array.<WGS84Type>
|
WSG84Arr坐标数组 |
alt |
number
|
z轴高层 |
转换后的笛卡尔积数组
Array.<Cartesian3>
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.transformWGS84ArrayToCartesianArray([{lng:110.16018735617934, lat:31.036076859828338, alt:0 }])
# transformWGS84ToCartesian(position, alt) → {Cartesian3}
坐标转换 84转笛卡尔
Parameters:
Name | Type | Description |
---|---|---|
position |
WGS84Type
|
坐标数组 |
lng |
number
|
经度 |
lon |
number
|
纬度 |
lat |
number
|
z轴 |
alt |
number
|
高层 |
转换后的笛卡尔积数组
Cartesian3
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
baseObj.base.transformWGS84ToCartesian({lng:110.16018735617934, lat:31.036076859828338, alt:0 },30)
# transformWGS84ToCartographic(position) → {CartographicType}
wgs84坐标转地图坐标
Parameters:
Name | Type | Description |
---|---|---|
position |
object.<WGS84Type>
|
|
lng |
number
|
经度 |
lon |
number
|
经度 |
lat |
number
|
纬度 |
alt |
number
|
z轴 |
地理坐标
Example
import { Base } from 'cesium_dev_kit'
const baseObj = new Base({
cesiumGlobal: Cesium,
containerId: 'cesiumContainer'
})
const wgs84 = baseObj.base.transformCartesianToWGS84(Cesium.Cartesian3.fromDegrees(110.16018735617934, 31.036076859828338));
const cartographic = baseObj.base.transformWGS84ToCartographic(wgs84)
// or
const cartographic2 = baseObj.base.transformWGS84ToCartographic({lng:110.16018735617934, lat:31.036076859828338, alt:0 });