mirror of
https://github.com/jiawanlong/Cesium-Examples.git
synced 2025-07-04 15:17:36 +00:00
91 lines
2.9 KiB
HTML
91 lines
2.9 KiB
HTML
<!--********************************************************************
|
|
* by jiawanlong
|
|
*********************************************************************-->
|
|
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<link rel="stylesheet" href="./../../libs/cesium/Cesium1.98/Widgets/widgets.css" />
|
|
<script type="text/javascript" src="./../../libs/cesium/Cesium1.98/Cesium.js"></script>
|
|
<script src="./../libs/dat-gui/0.7.6/dat.gui.min.js"></script>
|
|
<script src="./latlng.js"></script>
|
|
</head>
|
|
|
|
<body style="
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background: #fff;
|
|
width: 100%;
|
|
height: 100%;
|
|
position: absolute;
|
|
top: 0;
|
|
">
|
|
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
|
|
|
|
<script type="text/javascript">
|
|
Cesium.Ion.defaultAccessToken =
|
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyNDMxOTA2NS1lY2Q3LTQ0YmUtOTE1Mi1iNWE2OGYwZjc0MjkiLCJpZCI6MjM1NjMwLCJpYXQiOjE3MzA3MjQzMTJ9.Xhu-9FyVEyqBKWEr0V9Sybt-elTCWHt9peL9-mNh-4E";
|
|
const viewer = new Cesium.Viewer("map", {});
|
|
viewer.scene.debugShowFramesPerSecond = true;
|
|
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
|
|
// http://cesium.xin/cesium/cn/Documentation1.95/CylinderGraphics.html#.ConstructorOptions
|
|
|
|
const obj = {
|
|
x: 120,
|
|
y: 30,
|
|
z: 1000,
|
|
heading: 0,
|
|
pitch: 0,
|
|
roll: 0,
|
|
};
|
|
|
|
|
|
addEntity();
|
|
|
|
function addEntity() {
|
|
|
|
var position = Cesium.Cartesian3.fromDegrees(obj.x, obj.y, obj.z);
|
|
var heading = Cesium.Math.toRadians(obj.heading);
|
|
var pitch = Cesium.Math.toRadians(obj.pitch);
|
|
var roll = Cesium.Math.toRadians(obj.roll);
|
|
|
|
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
|
|
var orientation = Cesium.Transforms.headingPitchRollQuaternion(
|
|
position,
|
|
hpr
|
|
);
|
|
cylinderEntity = new Cesium.Entity({
|
|
position: position,
|
|
orientation: orientation,
|
|
model: {
|
|
// uri: 'http://localhost/Cesium-Examples/examples/threeEx/zhanji.glb',、
|
|
uri: './zhanji.glb',
|
|
scale: 5,
|
|
|
|
}
|
|
})
|
|
viewer.entities.add(cylinderEntity);
|
|
|
|
viewer.flyTo(viewer.entities)
|
|
}
|
|
|
|
|
|
|
|
|
|
let handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
handler.setInputAction(function (click) {
|
|
let pickedObject = viewer.scene.pick(click.position);
|
|
alert('点击了' + pickedObject.detail.node._name)
|
|
console.log(pickedObject.detail.node)
|
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
|
|
|
|
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html> |