|
@@ -0,0 +1,116 @@
|
|
|
+
|
|
|
+export let projectionImage, handler, centerPoint
|
|
|
+export function proInit(pdistance = 300) {
|
|
|
+ viewer.resolutionScale = window.devicePixelRatio;
|
|
|
+ let scene = viewer.scene
|
|
|
+ // viewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({
|
|
|
+ // url: 'https://dev.virtualearth.net',
|
|
|
+ // mapStyle: Cesium.BingMapsStyle.AERIAL,
|
|
|
+ // key: URL_CONFIG.BING_MAP_KEY
|
|
|
+ // }));
|
|
|
+
|
|
|
+ // var scene = viewer.scene;
|
|
|
+ // scene.shadowMap.darkness = 1.275; //设置第二重烘焙纹理的效果(明暗程度)
|
|
|
+ // scene.debugShowFramesPerSecond = false;
|
|
|
+ // scene.hdrEnabled = false;
|
|
|
+ // scene.sun.show = true;
|
|
|
+
|
|
|
+ if (!scene.pickPositionSupported) {
|
|
|
+ alert('不支持深度纹理,视频投放功能无法使用!');
|
|
|
+ }
|
|
|
+ //图层加载完成,设置相机位置
|
|
|
+ scene.camera.setView({
|
|
|
+ destination: Cesium.Cartesian3.fromDegrees(109.5151, 18.3185, 100),
|
|
|
+ orientation: {
|
|
|
+ heading: 3.179304500963121,
|
|
|
+ pitch: -0.46239072362282485,
|
|
|
+ roll: 6.283185307179583
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ projectionImage = new Cesium.ProjectionImage(scene);
|
|
|
+ centerPoint = viewer.entities.add({
|
|
|
+ id: 'cameraCenter',
|
|
|
+ position: Cesium.Cartesian3.ZERO, // 初始位置设为当前视角中心,稍后更新
|
|
|
+ point: {
|
|
|
+ pixelSize: 10,
|
|
|
+ color: Cesium.Color.YELLOW,
|
|
|
+ outlineColor: Cesium.Color.BLACK,
|
|
|
+ outlineWidth: 2
|
|
|
+ }
|
|
|
+ });
|
|
|
+ handler = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point);
|
|
|
+
|
|
|
+ handler.movingEvt.addEventListener(function (windowPosition) {
|
|
|
+ // viewer.scene.pickPositionAsync(windowPosition).then((last) => {
|
|
|
+ // let geom = `POINT (${item.lzb_x} ${item.bzb_y}${gcHight ? ' ' + gcHight : ''})`
|
|
|
+ // loadGeoJSON(geom, "#facd91", { isfly: false, point: 'landslide' }, (data) => {
|
|
|
+ // geoSources[item.bsm] = data;
|
|
|
+ // data.name = "dzzh";
|
|
|
+ // });
|
|
|
+ let last = scene.pickPosition(windowPosition);
|
|
|
+
|
|
|
+ //计算该点与视口位置点坐标的距离
|
|
|
+ var distance = Cesium.Cartesian3.distance(scene.camera.position, last);
|
|
|
+ if (distance > 0) {
|
|
|
+ //将鼠标当前点坐标转化成经纬度
|
|
|
+ var cartographic = Cesium.Cartographic.fromCartesian(last);
|
|
|
+ var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
|
|
+ var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
|
|
+ var height = cartographic.height;
|
|
|
+ //通过该点设置视频投放对象的距离及方向
|
|
|
+ projectionImage.setDistDirByPoint([longitude, latitude, height]);
|
|
|
+ projectionImage.distance = pdistance;
|
|
|
+ centerPoint.position = Cesium.Cartesian3.fromDegrees(longitude, latitude, 0)
|
|
|
+
|
|
|
+ }
|
|
|
+ // })
|
|
|
+ });
|
|
|
+}
|
|
|
+export function clearAndActive(videoElement, horizontal = 20, verticalFov = 10,) {
|
|
|
+ // videoElement = videoElement// document.getElementById('trailer');
|
|
|
+ projectionImage.distance = 0.1;
|
|
|
+ var wgsPosition = viewer.scene.camera.positionCartographic;
|
|
|
+ var longitude = Cesium.Math.toDegrees(wgsPosition.longitude);
|
|
|
+ var latitude = Cesium.Math.toDegrees(wgsPosition.latitude);
|
|
|
+ var height = wgsPosition.height;
|
|
|
+ projectionImage.viewPosition = [longitude, latitude, height];
|
|
|
+ projectionImage.horizontalFov = horizontal;
|
|
|
+ projectionImage.verticalFov = verticalFov;
|
|
|
+ projectionImage.setImage({
|
|
|
+ video: videoElement
|
|
|
+ });
|
|
|
+ videoElement.play();
|
|
|
+ projectionImage.removeAllClipRegion();
|
|
|
+ projectionImage.build();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+export function chageHor(value) {
|
|
|
+ if (projectionImage) projectionImage.horizontalFov = value;
|
|
|
+}
|
|
|
+export function chageVert(value) {
|
|
|
+ if (projectionImage) projectionImage.verticalFov = value;
|
|
|
+}
|
|
|
+export function chageDist(value) {
|
|
|
+ if (projectionImage) projectionImage.distance = value;
|
|
|
+}
|
|
|
+export function chageLineVisible(checked) {
|
|
|
+ if (projectionImage) projectionImage.hintLineVisible = checked;
|
|
|
+}
|
|
|
+export function chagecilpRegion(e) {
|
|
|
+ // handlerPolygon.deactivate();
|
|
|
+ // handlerPolygon.activate();
|
|
|
+}
|
|
|
+export function chageclipmode() {
|
|
|
+ let clipMode = $(this).val() === 'clip-inside' ? SuperMap3D.ModifyRegionMode.CLIP_INSIDE : SuperMap3D.ModifyRegionMode.CLIP_OUTSIDE;
|
|
|
+ if (projectionImage) projectionImage.setClipMode(clipMode);
|
|
|
+}
|
|
|
+
|
|
|
+// $('#loadingbar').remove();
|
|
|
+// $('#toolbar').show();
|
|
|
+// if (typeof Cesium !== 'undefined') {
|
|
|
+// window.startupCalled = true;
|
|
|
+// onload(Cesium);
|
|
|
+// }
|